ReceiptController.php 371 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class ReceiptController extends DooController {
  6. public $staff;
  7. public $verifyId;
  8. public $executeId;
  9. // public static $NEW2 = 0;
  10. public $AGENCY = "日常相关费用";
  11. public $TRAVEL = "差旅相关费用";
  12. public $TRAIN = "培训班费用";
  13. public $OTHER = "其他";
  14. private $MYREVEIPTCACHEPATH = "protected/cache/myReceipt/";
  15. private $PERSONALCOLLECTCACHEPATH = "protected/cache/personalCollect/";
  16. private $CATEGORYCOLLECTPATH = "protected/cache/categoryCollect/";
  17. private $STAFFCOLLECTPATH = "protected/cache/staffCollect/";
  18. private function showCache($path) {
  19. if (file_exists ( $path )) {
  20. echo "<!DOCTYPE html>";
  21. include $path;
  22. die ();
  23. }
  24. }
  25. private function cacheFile($path) {
  26. $content = ob_get_contents ();
  27. $fp = fopen ( $path, "w" );
  28. fwrite ( $fp, $content );
  29. fclose ( $fp );
  30. }
  31. // private function getExeCount(){
  32. // Doo::loadModel('receipt');
  33. // $receipt=new receipt();
  34. // $receiptList=$receipt->find(array('where'=>'(executeCopy like \'%["'.$this->staff[0]['sid'].'%\' and executeStaff NOT LIKE \'%'.$this->staff[0]['sid'].'%\' ) and (status=1 or status=6)','desc'=>'rid','asArray'=>true));
  35. // return count($receiptList);
  36. // }
  37. // private function getReceiptCount(){
  38. // $status=2;
  39. // $year=date('Y');
  40. // Doo::loadModel('receipt');
  41. // $receipt=new receipt();
  42. // $dateCondition=" and Year(date) =".$year;
  43. // $approvalCondition=' and (nowStaff like "%,'.$this->staff[0]['sid'].'%" or nowStaff like "%'.$this->staff[0]['sid'].',%" or nowStaff='.$this->staff[0]['sid'].' ) ';
  44. // $receiptList=$receipt->find(array('where'=>' status='.$status.$dateCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  45. // return count($receiptList);
  46. // }
  47. private function collectHtml($receiptCollectList = array(), $itemCategory = "日常相关费用", $classType = "b") {
  48. $collectHtml = "";
  49. $sumPrice = 0.00;
  50. for($i = 1; $i <= 12; $i ++) {
  51. $falg = true;
  52. foreach ( $receiptCollectList as $key => $value ) {
  53. if ($value ['itemCategory'] == $itemCategory && $value ['month'] == $i) {
  54. $sumPrice += $value ['price'];
  55. if ($classType == "b") {
  56. $collectHtml .= '<td class="colGreen taR">¥' . $value ['price'] . '</td>';
  57. $falg = false;
  58. break;
  59. } else {
  60. $collectHtml .= '<td class="taR">¥' . $value ['price'] . '</td>';
  61. $falg = false;
  62. break;
  63. }
  64. }
  65. }
  66. if ($falg)
  67. $collectHtml .= '<td class="taR">-</td>';
  68. }
  69. $collectHtml .= '<td class="taR colGreen">¥' . $sumPrice . '</td>';
  70. return $collectHtml;
  71. }
  72. function __construct() {
  73. if (isset ( $_COOKIE ["staff"] )) {
  74. if (! empty ( $_COOKIE ["staff"] )) {
  75. Doo::loadModel ( 'staff' );
  76. Doo::loadModel ( 'verify' );
  77. $verify = new verify ();
  78. $staff = new staff ();
  79. Doo::loadModel ( "execute" );
  80. $execute = new execute ();
  81. $verifyList = $verify->find ( array (
  82. 'select' => 'staff',
  83. 'asArray' => true
  84. ) );
  85. $list = array ();
  86. // 判断角色的审批权限
  87. foreach ( $verifyList as $key => $value ) {
  88. $ver = json_decode ( $value ['staff'] );
  89. foreach ( $ver as $k => $v ) {
  90. if ($v [1] == 'ROLE') {
  91. $roleList = json_decode ( $v [3] );
  92. foreach ( $roleList as $t => $g ) {
  93. $gList = explode ( "_", $g );
  94. array_push ( $list, $gList [0] );
  95. // print_r($list);
  96. }
  97. } else
  98. array_push ( $list, $v [0] );
  99. }
  100. }
  101. // 判断执行人的审批权限
  102. $executeList = $execute->find ( array (
  103. 'select' => 'staff',
  104. 'asArray' => true
  105. ) );
  106. $list2 = array ();
  107. foreach ( $executeList as $key => $value ) {
  108. $ver = json_decode ( $value ['staff'] );
  109. foreach ( $ver as $k => $v ) {
  110. array_push ( $list2, $v [0] );
  111. }
  112. }
  113. $eidList = file_get_contents ( "protected/config/execute/execute.ini" );
  114. $eidList = array_filter ( explode ( ",", $eidList ) );
  115. $this->executeId = array_merge ( $list2, $eidList );
  116. $this->verifyId = $list;
  117. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  118. return "/";
  119. }
  120. }
  121. Doo::loadCore ( 'uri/DooUriRouter' );
  122. $router = new DooUriRouter ();
  123. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  124. if ($routeRs ['1'] != "login") {
  125. header ( 'Content-Type:text/html;charset=utf-8' );
  126. @header ( "Location: /login" );
  127. }
  128. }
  129. function saeaBorad() {
  130. Doo::loadModel ( 'receipt' );
  131. Doo::loadModel ( 'verify' );
  132. $verify = new verify ();
  133. $receipt = new receipt ();
  134. Doo::loadModel ( 'L_category' );
  135. $lCategory = new L_category ();
  136. Doo::loadModel ( "role" );
  137. $role = new role ();
  138. Doo::loadModel ( "receiptLog" );
  139. $receiptLog = new receiptLog ();
  140. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  141. $receiptDetail = $receipt->find ( array (
  142. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  143. 'desc' => 'rid',
  144. 'asArray' => true
  145. ) );
  146. foreach ( $receiptDetail as $key => $value ) {
  147. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  148. $veList = $verify->getOne ( array (
  149. 'where' => 'vid=' . $value ['verify'],
  150. 'asArray' => true
  151. ) );
  152. $v = json_decode ( $veList ['staff'] );
  153. array_push ( $v [0], $veList ['description'] );
  154. foreach ( $v as $n => $m ) {
  155. if ($m ['1'] == 'ROLE') {
  156. $roleInfo = $role->getOne ( array (
  157. 'where' => 'rid=' . $m [0],
  158. 'asArray' => true
  159. ) );
  160. $v [$n] [1] = $roleInfo ['name'];
  161. }
  162. }
  163. $receiptDetail [$key] ['staff'] = $v;
  164. $category = $lCategory->getOne ( array (
  165. 'where' => 'cid=' . $value ['cid'],
  166. 'asArray' => true
  167. ) );
  168. $receiptDetail [$key] ['category'] = $category ['title'];
  169. }
  170. // print_r($receiptLogList);
  171. $data ['receiptLogList'] = $receiptLogList;
  172. $data ['receiptDetail'] = $receiptDetail;
  173. $data ['memu'] = "receipt";
  174. $data ['staff'] = $this->staff;
  175. $data ['receiptMemu'] = 'saeaBorad';
  176. $data ['verifyId'] = $this->verifyId;
  177. $data ['executeId'] = $this->executeId;
  178. $this->render ( "/admin/saeaBorad", $data );
  179. }
  180. function remitAdd() {
  181. Doo::loadModel ( 'accountItem' );
  182. Doo::loadModel ( 'verify' );
  183. Doo::loadModel ( 'receipt' );
  184. Doo::loadModel ( 'L_category' );
  185. $lCategory = new L_category ();
  186. $receipt = new receipt ();
  187. $verify = new verify ();
  188. $accountItem = new accountItem ();
  189. Doo::loadModel ( "role" );
  190. $role = new role ();
  191. $acItem = $accountItem->find ( array (
  192. 'asArray' => true
  193. ) );
  194. $veList = $verify->find ( array (
  195. 'asArray' => true
  196. ) );
  197. foreach ( $veList as $key => $value ) {
  198. $v = json_decode ( $value ['staff'] );
  199. $list = array ();
  200. foreach ( $v as $n => $m ) {
  201. if ($m ['1'] == 'ROLE') {
  202. $roleInfo = $role->getOne ( array (
  203. 'where' => 'rid=' . $m [0],
  204. 'asArray' => true
  205. ) );
  206. $v [$n] [1] = $roleInfo ['name'];
  207. array_push ( $list, $roleInfo ['name'] );
  208. } else {
  209. array_push ( $list, $v [$n] [1] );
  210. }
  211. }
  212. $veList [$key] ['staff'] = implode ( '>', $list );
  213. }
  214. $data ['category'] = $lCategory->find ( array (
  215. 'asArray' => true
  216. ) );
  217. $data ['veList'] = $veList;
  218. $data ['acItem'] = $acItem;
  219. $data ['memu'] = "receipt";
  220. $data ['staff'] = $this->staff;
  221. $data ['receiptMemu'] = 'saeaBorad';
  222. $data ['verifyId'] = $this->verifyId;
  223. $data ['executeId'] = $this->executeId;
  224. $this->render ( "/admin/remitAdd", $data );
  225. }
  226. function remitAddDo() {
  227. $agency = $this->get_args ( 'agency' );
  228. $travel = $this->get_args ( 'travel' );
  229. $train = $this->get_args ( 'train' );
  230. $other = $this->get_args ( 'other' );
  231. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  232. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  233. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  234. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  235. // print_r($agency);die;
  236. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  237. Doo::loadModel ( 'receipt' );
  238. Doo::loadModel ( 'receiptDetail' );
  239. Doo::loadModel ( 'accountItem' );
  240. $accountItem = new accountItem ();
  241. $receipt = new receipt ();
  242. Doo::loadModel ( 'enclosur' );
  243. Doo::loadModel ( 'execute' );
  244. $execute = new execute ();
  245. $executeDetail = $execute->getOne ( array (
  246. 'where' => 'mold="对公汇款执行人"',
  247. 'asArray' => true
  248. ) );
  249. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  250. $aItem = $accountItem->find ( array (
  251. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  252. 'asArray' => true
  253. ) );
  254. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  255. $ag = $tr = $ta = $ot = 0;
  256. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  257. foreach ( $aItem as $key => $value ) {
  258. if ($value ['category'] == $this->AGENCY) {
  259. if (isset ( $agency [$ag] )) {
  260. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  261. array_push ( $accountJson [$this->AGENCY], array (
  262. 'aid' => $value ['aid'],
  263. 'name' => $value ['name'],
  264. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  265. ) );
  266. $sum += $agency [$ag];
  267. $agencySum += $agency [$ag];
  268. }
  269. }
  270. $ag ++;
  271. }
  272. }
  273. $accountJson ['cSum'] = array (
  274. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  275. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  276. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  277. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  278. );
  279. // 报销单
  280. $receipt->accountItem = json_encode ( $accountJson );
  281. $receipt->staff = $this->staff [0] ['sid'];
  282. $receipt->sum = number_format ( $sum, 2, '.', '' );
  283. $receipt->date = date ( "Y-m-d" );
  284. $receipt->cid = $cid;
  285. $receipt->status = 5;
  286. $receipt->Rtype = 2;
  287. // 修改审批流程加入角色
  288. $receipt->verify = $verify;
  289. $receipt->executeCopy = $executeDetail ['staff'];
  290. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  291. $receipt->explanation = $explanation;
  292. $rid = $receipt->insert ();
  293. // 附件
  294. if (! empty ( $enclosurName )) {
  295. $enclosurArray = explode ( '-', $enclosurName );
  296. foreach ( $enclosurArray as $value ) {
  297. $enclosur = new enclosur ();
  298. $enclosur->name = $value;
  299. $enclosur->rid = $rid;
  300. $enclosur->insert ();
  301. }
  302. // print_r($enclosurArray);die;
  303. }
  304. // 报销详情
  305. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  306. $receiptDetail = new receiptDetail ();
  307. $receiptDetail->staff = $this->staff [0] ['sid'];
  308. $receiptDetail->item = $value ['name'];
  309. $receiptDetail->itemCategory = $this->AGENCY;
  310. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  311. $receiptDetail->date = date ( "Y-m-d" );
  312. $receiptDetail->cid = $cid;
  313. $receiptDetail->rid = $rid;
  314. $receiptDetail->status = 4;
  315. $receiptDetail->insert ();
  316. }
  317. }
  318. return "/saeaBorad";
  319. }
  320. function remitEdit() {
  321. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  322. // echo $rid;
  323. Doo::loadModel ( 'accountItem' );
  324. Doo::loadModel ( 'verify' );
  325. Doo::loadModel ( 'receipt' );
  326. $receipt = new receipt ();
  327. $verify = new verify ();
  328. $accountItem = new accountItem ();
  329. Doo::loadModel ( 'L_category' );
  330. $lCategory = new L_category ();
  331. Doo::loadModel ( "role" );
  332. $role = new role ();
  333. $receiptDetail = $receipt->getOne ( array (
  334. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  335. 'asArray' => true
  336. ) );
  337. if (empty ( $receiptDetail ))
  338. return "/saeaCreate";
  339. $acItem = $accountItem->find ( array (
  340. 'asArray' => true
  341. ) );
  342. $veList = $verify->find ( array (
  343. 'asArray' => true
  344. ) );
  345. foreach ( $veList as $key => $value ) {
  346. $v = json_decode ( $value ['staff'] );
  347. $list = array ();
  348. foreach ( $v as $n => $m ) {
  349. if ($m ['1'] == 'ROLE') {
  350. $roleInfo = $role->getOne ( array (
  351. 'where' => 'rid=' . $m [0],
  352. 'asArray' => true
  353. ) );
  354. $v [$n] [1] = $roleInfo ['name'];
  355. array_push ( $list, $roleInfo ['name'] );
  356. } else {
  357. array_push ( $list, $v [$n] [1] );
  358. }
  359. }
  360. $veList [$key] ['staff'] = implode ( '>', $list );
  361. }
  362. // 配置编辑信息
  363. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  364. foreach ( $acItem as $key => $value ) {
  365. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  366. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  367. $acItem [$key] ['price'] = $v ['price'];
  368. }
  369. }
  370. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  371. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  372. $acItem [$key] ['price'] = $v ['price'];
  373. }
  374. }
  375. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  376. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  377. $acItem [$key] ['price'] = $v ['price'];
  378. }
  379. }
  380. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  381. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  382. $acItem [$key] ['price'] = $v ['price'];
  383. }
  384. }
  385. }
  386. $data ['category'] = $lCategory->find ( array (
  387. 'asArray' => true
  388. ) );
  389. $data ['cSum'] = $accountItemList ['cSum'];
  390. $data ['sum'] = $receiptDetail ['sum'];
  391. $data ['receiptDetail'] = $receiptDetail;
  392. $data ['veList'] = $veList;
  393. $data ['acItem'] = $acItem;
  394. $data ['memu'] = "receipt";
  395. $data ['staff'] = $this->staff;
  396. $data ['receiptMemu'] = 'saeaBorad';
  397. $data ['verify'] = $receiptDetail ['verify'];
  398. $data ['verifyId'] = $this->verifyId;
  399. $data ['executeId'] = $this->executeId;
  400. $data ['rid'] = $rid;
  401. $this->render ( "/admin/remitEdit", $data );
  402. }
  403. function remitEdiDo() {
  404. $agency = $this->get_args ( 'agency' );
  405. $travel = $this->get_args ( 'travel' );
  406. $train = $this->get_args ( 'train' );
  407. $other = $this->get_args ( 'other' );
  408. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  409. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  410. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  411. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  412. if (! empty ( $explanation )) {
  413. Doo::loadModel ( 'receipt' );
  414. Doo::loadModel ( 'receiptDetail' );
  415. Doo::loadModel ( 'accountItem' );
  416. $accountItem = new accountItem ();
  417. $receipt = new receipt ();
  418. Doo::loadModel ( 'execute' );
  419. $execute = new execute ();
  420. $executeDetail = $execute->getOne ( array (
  421. 'where' => 'mold="对公汇款执行人"',
  422. 'asArray' => true
  423. ) );
  424. $receiptDetail = $receipt->getOne ( array (
  425. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  426. 'asArray' => true
  427. ) );
  428. if (empty ( $receiptDetail ))
  429. return "/saeaBorad";
  430. $aItem = $accountItem->find ( array (
  431. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  432. 'asArray' => true
  433. ) );
  434. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  435. $ag = $tr = $ta = $ot = 0;
  436. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  437. foreach ( $aItem as $key => $value ) {
  438. if ($value ['category'] == $this->AGENCY) {
  439. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  440. array_push ( $accountJson [$this->AGENCY], array (
  441. 'aid' => $value ['aid'],
  442. 'name' => $value ['name'],
  443. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  444. ) );
  445. $sum += $agency [$ag];
  446. $agencySum += $agency [$ag];
  447. }
  448. $ag ++;
  449. }
  450. }
  451. $accountJson ['cSum'] = array (
  452. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  453. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  454. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  455. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  456. );
  457. // 报销单
  458. $rid = $receipt->rid = $receiptDetail ['rid'];
  459. $receipt->accountItem = json_encode ( $accountJson );
  460. $receipt->staff = $this->staff [0] ['sid'];
  461. $receipt->sum = number_format ( $sum, 2, '.', '' );
  462. $receipt->date = date ( "Y-m-d" );
  463. $receipt->cid = $cid;
  464. if ($receiptDetail ['Rtype'] == 1)
  465. $receipt->status = 7;
  466. else
  467. $receipt->status = 5;
  468. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  469. $receipt->verify = $verify;
  470. $receipt->executeCopy = $executeDetail ['staff'];
  471. $receipt->explanation = $explanation;
  472. $receipt->update ();
  473. $receiptDetail = new receiptDetail ();
  474. $receiptDetail->delete ( array (
  475. 'where' => 'rid=' . $rid
  476. ) );
  477. // 报销详情
  478. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  479. $receiptDetail = new receiptDetail ();
  480. $receiptDetail->staff = $this->staff [0] ['sid'];
  481. $receiptDetail->item = $value ['name'];
  482. $receiptDetail->itemCategory = $this->AGENCY;
  483. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  484. $receiptDetail->date = date ( "Y-m-d" );
  485. $receiptDetail->cid = $cid;
  486. $receiptDetail->rid = $rid;
  487. $receiptDetail->status = 4;
  488. $receiptDetail->insert ();
  489. }
  490. // return "/referReceipt/".$rid;
  491. }
  492. return "/saeaBorad";
  493. }
  494. function remitApproval() {
  495. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  496. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  497. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  498. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  499. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  500. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  501. if (empty ( $status ))
  502. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  503. $vidList = array ();
  504. $button = 0;
  505. Doo::loadModel ( 'verify' );
  506. Doo::loadModel ( 'receipt' );
  507. Doo::loadModel ( 'staff' );
  508. $staff = new staff ();
  509. $receipt = new receipt ();
  510. $verify = new verify ();
  511. Doo::loadModel ( 'L_category' );
  512. $Lcategory = new L_category ();
  513. Doo::loadModel ( 'enclosur' );
  514. $enclosur = new enclosur ();
  515. // user verify ID
  516. $verifyDetail = $verify->find ( array (
  517. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  518. 'asArray' => true
  519. ) );
  520. foreach ( $verifyDetail as $key => $value ) {
  521. array_push ( $vidList, $value ['vid'] );
  522. }
  523. $vid = implode ( ",", $vidList );
  524. if (empty ( $verifyDetail ))
  525. $vid = 0;
  526. $categoryList = $Lcategory->find ( array (
  527. 'asArray' => true
  528. ) );
  529. $staffList = $staff->find ( array (
  530. 'where' => 'cid=' . $cid,
  531. 'asArray' => true
  532. ) );
  533. $ap = "";
  534. if ($status == 4) {
  535. $ap = 4;
  536. $status = 2;
  537. }
  538. // get Receipt By verifyID status 2
  539. $receiptList = $receipt->find ( array (
  540. 'where' => 'rid =' . $rid,
  541. 'desc' => 'rid',
  542. 'asArray' => true
  543. ) );
  544. $Locate = 0;
  545. $roleId = 0;
  546. if ($ap == 4)
  547. $status = 4;
  548. foreach ( $receiptList as $key => $value ) {
  549. $receiptList [$key] ['Locate'] = $Locate;
  550. $Locate ++;
  551. $receiptList [$key] ['reviseDetail'] = array ();
  552. if (! empty ( $value ['reviseDetail'] ))
  553. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  554. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  555. $categoryDetil = $Lcategory->getOne ( array (
  556. 'where' => 'cid=' . $value ['cid'],
  557. 'asArray' => true
  558. ) );
  559. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  560. // 检测编辑状态
  561. $verifyList = $verify->getOne ( array (
  562. 'where' => 'vid=' . $value ['verify'],
  563. 'asArray' => true
  564. ) );
  565. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  566. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  567. Doo::loadModel ( 'role' );
  568. $role = new role ();
  569. // print_r($verifyList);
  570. $flag = true;
  571. $roleKey = 0;
  572. $endStaffArray = array ();
  573. $roleArrayCopy = array ();
  574. foreach ( $verifyList as $k => $v ) {
  575. // init verifyStaff
  576. if ($v [1] == 'ROLE') {
  577. if (! empty ( $verifyStaff )) {
  578. $endStaffArray = end ( $verifyStaff );
  579. if ($v [0] == $endStaffArray ['nextStaff']) {
  580. $roleId = $v [0];
  581. }
  582. }
  583. $roleVerify = json_decode ( $v [3], true );
  584. $roleKey = $k;
  585. $roleArray = array ();
  586. $rolename = $role->getOne ( array (
  587. 'where' => 'rid=' . $v [0],
  588. 'asArray' => true
  589. ) );
  590. foreach ( $roleVerify as $o => $p ) {
  591. $staffID = explode ( '_', $p );
  592. $staffInfo = $staff->getOne ( array (
  593. 'where' => 'sid=' . $staffID [0],
  594. 'asArray' => true
  595. ) );
  596. // print_r($staffID);
  597. $exp = array (
  598. 0 => $staffInfo ['sid'],
  599. 1 => $staffID [1],
  600. 2 => $staffInfo ['avatar'],
  601. 'date' => '',
  602. 'date' => '',
  603. 'opinion' => '',
  604. 'status' => '',
  605. 'rolename' => $rolename ['name']
  606. );
  607. array_push ( $roleArray, $exp );
  608. }
  609. $roleArrayCopy [$v [0]] = $roleArray;
  610. // $verifyList[$k]['roleArray']=$roleArray;
  611. }
  612. // print_r($roleArray);
  613. $verifyList [$k] ['date'] = "";
  614. $verifyList [$k] ['opinion'] = "";
  615. $verifyList [$k] ['status'] = "";
  616. if (empty ( $verifyStaff )) {
  617. $verifyList [$k] ['date'] = "";
  618. $verifyList [$k] ['opinion'] = "";
  619. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  620. $verifyList [$k] ['status'] = 4;
  621. $button = 4;
  622. $flag = false;
  623. }
  624. } else {
  625. foreach ( $verifyStaff as $m => $u ) {
  626. if ($v [0] == $m) {
  627. $verifyList [$k] ['date'] = $u ['date'];
  628. $verifyList [$k] ['opinion'] = $u ['opinion'];
  629. $verifyList [$k] ['status'] = $u ['status'];
  630. $flag = false;
  631. break;
  632. }
  633. }
  634. $endStaffArray = end ( $verifyStaff );
  635. if (isset ( $endStaffArray ['ROLE'] )) {
  636. } else {
  637. $endKey = key ( $verifyStaff );
  638. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  639. $button = 4;
  640. $verifyList [$k] ['status'] = 4;
  641. }
  642. }
  643. }
  644. }
  645. $rolename ['name'] = '';
  646. if (! empty ( $roleId )) {
  647. Doo::loadModel ( 'role' );
  648. $role = new role ();
  649. $rolename = $role->getOne ( array (
  650. 'where' => 'rid=' . $roleId,
  651. 'asArray' => true
  652. ) );
  653. }
  654. if (! empty ( $verifyStaff ))
  655. $endStaffArray = end ( $verifyStaff );
  656. $KOP = false;
  657. foreach ( $roleArrayCopy as $P => $A ) {
  658. foreach ( $A as $MKI => $AVL ) {
  659. if (! empty ( $verifyStaff )) {
  660. // &&$rolename['rid']==$endStaffArray['nextStaff']
  661. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  662. $button = 4;
  663. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  664. }
  665. foreach ( $verifyStaff as $m => $u ) {
  666. $AVLFK = $AVL [0] . '_R';
  667. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  668. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  669. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  670. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  671. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  672. break;
  673. }
  674. }
  675. } else {
  676. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  677. $button = 4;
  678. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  679. }
  680. }
  681. // $roleArray[$MKI]['rolename']=$rolename['name'];
  682. $KOP = true;
  683. }
  684. }
  685. foreach ( $roleArrayCopy as $k => $v ) {
  686. foreach ( $verifyList as $m => $n ) {
  687. if ($n [0] == $k) {
  688. array_splice ( $verifyList, $m, 1, $v );
  689. }
  690. }
  691. }
  692. $receiptList [$key] ['verifyList'] = $verifyList;
  693. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  694. 'where' => 'sid=' . $value ['staff'],
  695. 'asArray' => true
  696. ) );
  697. $receiptList [$key] ['button'] = $button;
  698. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  699. }
  700. $mothHtml = "";
  701. for($i = 1; $i <= 12; $i ++) {
  702. if ($month == $i)
  703. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  704. else
  705. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  706. }
  707. // 获取审批日志
  708. Doo::loadModel ( 'receiptLog' );
  709. $receiptLog = new receiptLog ();
  710. $rlList = array ();
  711. $rlInfo = $receiptLog->getOne ( array (
  712. 'where' => 'rid=' . $rid . ' and status=4',
  713. 'asArray' => true
  714. ) );
  715. $tijdate = $receiptLog->getOne ( array (
  716. 'where' => 'rid=' . $rid . ' and status=2',
  717. 'asc' => 'rlid',
  718. 'asArray' => true
  719. ) );
  720. if (! empty ( $rlInfo )) {
  721. $rlList = $receiptLog->find ( array (
  722. 'where' => 'rid=' . $rid,
  723. 'asc' => 'rlid',
  724. 'asArray' => true
  725. ) );
  726. }
  727. $receiptList [0] ['rlList'] = $rlList;
  728. $enclosurList = $enclosur->find ( array (
  729. 'where' => 'rid=' . $rid,
  730. 'asArray' => true
  731. ) );
  732. $enclosurHtml = '';
  733. foreach ( $enclosurList as $value ) {
  734. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  735. }
  736. // print_r($receiptList);
  737. $data ['enclosurHtml'] = $enclosurHtml;
  738. $data ['rolename'] = $rolename ['name'];
  739. $data ['datetij'] = $tijdate ['date'];
  740. $data ['mothHtml'] = $mothHtml;
  741. $data ['rid'] = $rid;
  742. $data ['receiptList'] = $receiptList;
  743. $data ['receiptApprovalCount'] = count ( $receiptList );
  744. $data ['status'] = $status;
  745. $data ['year'] = $year;
  746. $data ['categoryList'] = $categoryList;
  747. $data ['staffList'] = $staffList;
  748. $data ['cid'] = $cid;
  749. $data ['sid'] = $sid;
  750. $data ['ap'] = $ap;
  751. $data ['memu'] = "receipt";
  752. $data ['staff'] = $this->staff;
  753. $data ['receiptMemu'] = 'approvalExpenses';
  754. $data ['verifyId'] = $this->verifyId;
  755. $data ['executeId'] = $this->executeId;
  756. $this->render ( "/admin/remitApproval", $data );
  757. }
  758. function saeaLoanAdd() {
  759. Doo::loadModel ( 'verify' );
  760. $verify = new verify ();
  761. Doo::loadModel ( "role" );
  762. $role = new role ();
  763. Doo::loadModel ( 'L_category' );
  764. $lCategory = new L_category ();
  765. $veList = $verify->find ( array (
  766. 'asArray' => true
  767. ) );
  768. foreach ( $veList as $key => $value ) {
  769. $v = json_decode ( $value ['staff'] );
  770. $list = array ();
  771. foreach ( $v as $n => $m ) {
  772. if ($m ['1'] == 'ROLE') {
  773. $roleInfo = $role->getOne ( array (
  774. 'where' => 'rid=' . $m [0],
  775. 'asArray' => true
  776. ) );
  777. $v [$n] [1] = $roleInfo ['name'];
  778. array_push ( $list, $roleInfo ['name'] );
  779. } else {
  780. array_push ( $list, $v [$n] [1] );
  781. }
  782. }
  783. $veList [$key] ['staff'] = implode ( '>', $list );
  784. }
  785. $data ['category'] = $lCategory->find ( array (
  786. 'asArray' => true
  787. ) );
  788. $data ['veList'] = $veList;
  789. $data ['memu'] = "receipt";
  790. $data ['staff'] = $this->staff;
  791. $data ['receiptMemu'] = 'saeaBorad';
  792. $data ['verifyId'] = $this->verifyId;
  793. $data ['executeId'] = $this->executeId;
  794. $this->render ( "/admin/saeaLoanAdd", $data );
  795. }
  796. function saeaLoanAddDo() {
  797. $agency = $this->get_args ( 'agency' );
  798. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  799. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  800. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  801. // die;
  802. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  803. Doo::loadModel ( 'receipt' );
  804. Doo::loadModel ( 'receiptDetail' );
  805. Doo::loadModel ( 'accountItem' );
  806. $accountItem = new accountItem ();
  807. $receipt = new receipt ();
  808. Doo::loadModel ( 'loanReceipt' );
  809. $loanReceipt = new loanReceipt ();
  810. Doo::loadModel ( 'execute' );
  811. $execute = new execute ();
  812. Doo::loadModel ( 'enclosur' );
  813. $executeDetail = $execute->getOne ( array (
  814. 'where' => 'mold="借款执行人"',
  815. 'asArray' => true
  816. ) );
  817. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  818. // if(!empty($receiptDetail))
  819. // return "/referReceipt/".$receiptDetail['rid'];
  820. $aItem = $accountItem->find ( array (
  821. 'asArray' => true
  822. ) );
  823. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  824. $ag = $tr = $ta = $ot = 0;
  825. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  826. array_push ( $accountJson ['借款费用'], array (
  827. 'aid' => 0,
  828. 'name' => '申请金额',
  829. 'price' => number_format ( $agency, 2, '.', '' )
  830. ) );
  831. $sum += $agency;
  832. $agencySum += $agency;
  833. $accountJson ['cSum'] = array (
  834. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  835. 'agencySum' => number_format ( 0, 2, '.', '' ),
  836. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  837. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  838. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  839. );
  840. // 借款数据备份
  841. $loanReceipt->loanItem = json_encode ( $accountJson );
  842. $loanReceipt->staff = $this->staff [0] ['sid'];
  843. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  844. $loanReceipt->date = date ( "Y-m-d" );
  845. $loanReceipt->cid = $cid;
  846. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  847. $loanReceipt->status = 5;
  848. $loanReceipt->Rtype = 1;
  849. $loanReceipt->verify = $verify;
  850. $receipt->receiptOrder = $receipt->receiptOrder;
  851. $loanReceipt->explanation = $explanation;
  852. $loanRid = $loanReceipt->insert ();
  853. // 报销单
  854. $receipt->loanItem = json_encode ( $accountJson );
  855. $receipt->staff = $this->staff [0] ['sid'];
  856. $receipt->sum = number_format ( $sum, 2, '.', '' );
  857. $receipt->date = date ( "Y-m-d" );
  858. $receipt->cid = $cid;
  859. // 特殊状态
  860. $receipt->status = 5;
  861. $receipt->Rtype = 1;
  862. $receipt->loanRid = $loanRid;
  863. // 修改审批流程加入角色
  864. $receipt->verify = $verify;
  865. $receipt->executeCopy = $executeDetail ['staff'];
  866. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  867. $receipt->explanation = $explanation;
  868. $rid = $receipt->insert ();
  869. // 执行数据备份
  870. // $executeCopy->rid=$rid;
  871. // $executeCopy->staff=$executeDetail['staff'];
  872. // $executeCopy->eid=$executeDetail['eid'];
  873. // $ecid=$executeCopy->insert();
  874. }
  875. return "/saeaBorad";
  876. }
  877. function saeaLoanEdi() {
  878. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  879. Doo::loadModel ( 'verify' );
  880. $verify = new verify ();
  881. Doo::loadModel ( "role" );
  882. $role = new role ();
  883. Doo::loadModel ( 'L_category' );
  884. $lCategory = new L_category ();
  885. Doo::loadModel ( 'receipt' );
  886. $receipt = new receipt ();
  887. $receiptInfo = $receipt->getOne ( array (
  888. 'where' => 'rid=' . $rid,
  889. 'asArray' => true
  890. ) );
  891. $veList = $verify->find ( array (
  892. 'asArray' => true
  893. ) );
  894. foreach ( $veList as $key => $value ) {
  895. $v = json_decode ( $value ['staff'] );
  896. $list = array ();
  897. foreach ( $v as $n => $m ) {
  898. if ($m ['1'] == 'ROLE') {
  899. $roleInfo = $role->getOne ( array (
  900. 'where' => 'rid=' . $m [0],
  901. 'asArray' => true
  902. ) );
  903. $v [$n] [1] = $roleInfo ['name'];
  904. array_push ( $list, $roleInfo ['name'] );
  905. } else {
  906. array_push ( $list, $v [$n] [1] );
  907. }
  908. }
  909. $veList [$key] ['staff'] = implode ( '>', $list );
  910. }
  911. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  912. $data ['receiptInfo'] = $receiptInfo;
  913. $data ['category'] = $lCategory->find ( array (
  914. 'asArray' => true
  915. ) );
  916. $data ['veList'] = $veList;
  917. $data ['memu'] = "receipt";
  918. $data ['staff'] = $this->staff;
  919. $data ['receiptMemu'] = 'saeaBorad';
  920. $data ['verifyId'] = $this->verifyId;
  921. $data ['executeId'] = $this->executeId;
  922. $this->render ( "/admin/saeaLoanEdi", $data );
  923. }
  924. function saeaLoanEdiDo() {
  925. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  926. $agency = $this->get_args ( 'agency' );
  927. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  928. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  929. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  930. // die;
  931. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )) {
  932. Doo::loadModel ( 'receipt' );
  933. Doo::loadModel ( 'receiptDetail' );
  934. Doo::loadModel ( 'accountItem' );
  935. $accountItem = new accountItem ();
  936. $receipt = new receipt ();
  937. Doo::loadModel ( 'loanReceipt' );
  938. $loanReceipt = new loanReceipt ();
  939. Doo::loadModel ( 'enclosur' );
  940. Doo::loadModel ( 'execute' );
  941. $execute = new execute ();
  942. $executeDetail = $execute->getOne ( array (
  943. 'where' => 'mold="借款执行人"',
  944. 'asArray' => true
  945. ) );
  946. $receiptDetail = $receipt->getOne ( array (
  947. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  948. 'asArray' => true
  949. ) );
  950. if (empty ( $receiptDetail ))
  951. die ( '参数错误' );
  952. $aItem = $accountItem->find ( array (
  953. 'asArray' => true
  954. ) );
  955. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  956. $ag = $tr = $ta = $ot = 0;
  957. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  958. array_push ( $accountJson ['借款费用'], array (
  959. 'aid' => 0,
  960. 'name' => '申请金额',
  961. 'price' => number_format ( $agency, 2, '.', '' )
  962. ) );
  963. $sum += $agency;
  964. $agencySum += $agency;
  965. $accountJson ['cSum'] = array (
  966. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  967. 'agencySum' => number_format ( 0, 2, '.', '' ),
  968. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  969. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  970. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  971. );
  972. // 报销单
  973. $receipt->loanItem = json_encode ( $accountJson );
  974. $receipt->sum = number_format ( $sum, 2, '.', '' );
  975. $receipt->cid = $cid;
  976. // 特殊状态
  977. // 修改审批流程加入角色
  978. if ($receiptDetail ['status'] != 4)
  979. $receipt->verify = $verify;
  980. $receipt->explanation = $explanation;
  981. $receipt->update ( array (
  982. 'where' => 'rid=' . $rid
  983. ) );
  984. // 借款数据更新
  985. $loanReceipt->loanItem = json_encode ( $accountJson );
  986. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  987. $loanReceipt->cid = $cid;
  988. if ($receiptDetail ['status'] != 4)
  989. $loanReceipt->verify = $verify;
  990. $loanReceipt->explanation = $explanation;
  991. $receipt->executeCopy = $executeDetail ['staff'];
  992. $loanReceipt->update ( array (
  993. 'where' => 'rid=' . $receiptDetail ['loanRid']
  994. ) );
  995. }
  996. return "/saeaBorad";
  997. }
  998. function saeaLoanReceiptAdd() {
  999. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1000. Doo::loadModel ( 'receipt' );
  1001. $receipt = new receipt ();
  1002. Doo::loadModel ( 'loanReceipt' );
  1003. $loanReceipt = new loanReceipt ();
  1004. Doo::loadModel ( 'L_category' );
  1005. $Lcategory = new L_category ();
  1006. Doo::loadModel ( 'verify' );
  1007. Doo::loadModel ( 'statistics' );
  1008. $statistics = new statistics ();
  1009. $verify = new verify ();
  1010. Doo::loadModel ( 'staff' );
  1011. $staff = new staff ();
  1012. $receiptDe = $receipt->getOne ( array (
  1013. 'where' => 'rid=' . $rid,
  1014. 'desc' => 'rid',
  1015. 'asArray' => true
  1016. ) );
  1017. $receiptList = $loanReceipt->find ( array (
  1018. 'where' => 'rid=' . $receiptDe ['loanRid'],
  1019. 'desc' => 'rid',
  1020. 'asArray' => true
  1021. ) );
  1022. $Locate = 0;
  1023. $roleId = 0;
  1024. $button = 0;
  1025. foreach ( $receiptList as $key => $value ) {
  1026. $receiptList [$key] ['Locate'] = $Locate;
  1027. $Locate ++;
  1028. $receiptList [$key] ['reviseDetail'] = array ();
  1029. if (! empty ( $value ['reviseDetail'] ))
  1030. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1031. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1032. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1033. $categoryDetil = $Lcategory->getOne ( array (
  1034. 'where' => 'cid=' . $value ['cid'],
  1035. 'asArray' => true
  1036. ) );
  1037. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1038. // 检测编辑状态
  1039. $verifyList = $verify->getOne ( array (
  1040. 'where' => 'vid=' . $value ['verify'],
  1041. 'asArray' => true
  1042. ) );
  1043. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1044. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1045. Doo::loadModel ( 'role' );
  1046. $role = new role ();
  1047. $flag = true;
  1048. $roleKey = 0;
  1049. $endStaffArray = array ();
  1050. $roleArrayCopy = array ();
  1051. foreach ( $verifyList as $k => $v ) {
  1052. // init verifyStaff
  1053. if ($v [1] == 'ROLE') {
  1054. if (! empty ( $verifyStaff )) {
  1055. $endStaffArray = end ( $verifyStaff );
  1056. // if ($v[0]==$endStaffArray['nextStaff']){
  1057. // $roleId=$v[0];
  1058. // }
  1059. }
  1060. $roleVerify = json_decode ( $v [3], true );
  1061. $roleKey = $k;
  1062. $roleArray = array ();
  1063. $rolename = $role->getOne ( array (
  1064. 'where' => 'rid=' . $v [0],
  1065. 'asArray' => true
  1066. ) );
  1067. foreach ( $roleVerify as $o => $p ) {
  1068. $staffID = explode ( '_', $p );
  1069. $staffInfo = $staff->getOne ( array (
  1070. 'where' => 'sid=' . $staffID [0],
  1071. 'asArray' => true
  1072. ) );
  1073. // print_r($staffID);
  1074. $exp = array (
  1075. 0 => $staffInfo ['sid'],
  1076. 1 => $staffID [1],
  1077. 2 => $staffInfo ['avatar'],
  1078. 'date' => '',
  1079. 'date' => '',
  1080. 'opinion' => '',
  1081. 'status' => '',
  1082. 'rolename' => $rolename ['name']
  1083. );
  1084. array_push ( $roleArray, $exp );
  1085. }
  1086. $roleArrayCopy [$v [0]] = $roleArray;
  1087. // $verifyList[$k]['roleArray']=$roleArray;
  1088. }
  1089. $verifyList [$k] ['date'] = "";
  1090. $verifyList [$k] ['opinion'] = "";
  1091. $verifyList [$k] ['status'] = "";
  1092. if (empty ( $verifyStaff )) {
  1093. $verifyList [$k] ['date'] = "";
  1094. $verifyList [$k] ['opinion'] = "";
  1095. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1096. $verifyList [$k] ['status'] = 4;
  1097. $flag = false;
  1098. }
  1099. } else {
  1100. foreach ( $verifyStaff as $m => $u ) {
  1101. if ($v [0] == $m) {
  1102. $verifyList [$k] ['date'] = $u ['date'];
  1103. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1104. $verifyList [$k] ['status'] = $u ['status'];
  1105. $flag = false;
  1106. break;
  1107. }
  1108. }
  1109. $endStaffArray = end ( $verifyStaff );
  1110. if (isset ( $endStaffArray ['ROLE'] )) {
  1111. } else {
  1112. // $endKey=key($verifyStaff);
  1113. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1114. // $button=4;
  1115. // $verifyList[$k]['status']=4;
  1116. // }
  1117. }
  1118. }
  1119. }
  1120. $rolename ['name'] = '';
  1121. if (! empty ( $roleId )) {
  1122. Doo::loadModel ( 'role' );
  1123. $role = new role ();
  1124. $rolename = $role->getOne ( array (
  1125. 'where' => 'rid=' . $roleId,
  1126. 'asArray' => true
  1127. ) );
  1128. }
  1129. if (! empty ( $verifyStaff ))
  1130. $endStaffArray = end ( $verifyStaff );
  1131. $KOP = false;
  1132. foreach ( $roleArrayCopy as $P => $A ) {
  1133. foreach ( $A as $MKI => $AVL ) {
  1134. if (! empty ( $verifyStaff )) {
  1135. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1136. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1137. $button = 4;
  1138. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1139. }
  1140. foreach ( $verifyStaff as $m => $u ) {
  1141. $AVLFK = $AVL [0] . '_R';
  1142. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1143. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1144. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1145. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1146. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1147. break;
  1148. }
  1149. }
  1150. } else {
  1151. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1152. $button = 4;
  1153. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1154. }
  1155. }
  1156. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1157. $KOP = true;
  1158. }
  1159. }
  1160. foreach ( $roleArrayCopy as $k => $v ) {
  1161. foreach ( $verifyList as $m => $n ) {
  1162. if ($n [0] == $k) {
  1163. array_splice ( $verifyList, $m, 1, $v );
  1164. }
  1165. }
  1166. }
  1167. $receiptList [$key] ['verifyList'] = $verifyList;
  1168. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1169. 'where' => 'sid=' . $value ['staff'],
  1170. 'asArray' => true
  1171. ) );
  1172. $receiptList [$key] ['button'] = $button;
  1173. //
  1174. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1175. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1176. }
  1177. $data ['receiptList'] = $receiptList;
  1178. Doo::loadModel ( 'L_category' );
  1179. $lCategory = new L_category ();
  1180. Doo::loadModel ( 'accountItem' );
  1181. $accountItem = new accountItem ();
  1182. $acItem = $accountItem->find ( array (
  1183. 'asArray' => true
  1184. ) );
  1185. $veList = $verify->find ( array (
  1186. 'asArray' => true
  1187. ) );
  1188. foreach ( $veList as $key => $value ) {
  1189. $v = json_decode ( $value ['staff'] );
  1190. $list = array ();
  1191. foreach ( $v as $n => $m ) {
  1192. if ($m ['1'] == 'ROLE') {
  1193. $roleInfo = $role->getOne ( array (
  1194. 'where' => 'rid=' . $m [0],
  1195. 'asArray' => true
  1196. ) );
  1197. $v [$n] [1] = $roleInfo ['name'];
  1198. array_push ( $list, $roleInfo ['name'] );
  1199. } else {
  1200. array_push ( $list, $v [$n] [1] );
  1201. }
  1202. }
  1203. $veList [$key] ['staff'] = implode ( '>', $list );
  1204. }
  1205. $data ['rid'] = $rid;
  1206. $data ['category'] = $lCategory->find ( array (
  1207. 'asArray' => true
  1208. ) );
  1209. $data ['veList'] = $veList;
  1210. $data ['acItem'] = $acItem;
  1211. $data ['memu'] = "receipt";
  1212. $data ['staff'] = $this->staff;
  1213. $data ['receiptMemu'] = 'saeaBorad';
  1214. $data ['verifyId'] = $this->verifyId;
  1215. $data ['executeId'] = $this->executeId;
  1216. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1217. }
  1218. function saeaLoanReceiptAddDo() {
  1219. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1220. $agency = $this->get_args ( 'agency' );
  1221. $travel = $this->get_args ( 'travel' );
  1222. $train = $this->get_args ( 'train' );
  1223. $other = $this->get_args ( 'other' );
  1224. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1225. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1226. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1227. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1228. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )) {
  1229. Doo::loadModel ( 'receipt' );
  1230. Doo::loadModel ( 'receiptDetail' );
  1231. Doo::loadModel ( 'accountItem' );
  1232. $accountItem = new accountItem ();
  1233. $receipt = new receipt ();
  1234. Doo::loadModel ( 'enclosur' );
  1235. Doo::loadModel ( 'execute' );
  1236. $execute = new execute ();
  1237. $executeDetail = $execute->getOne ( array (
  1238. 'where' => 'mold="借款费用执行人"',
  1239. 'asArray' => true
  1240. ) );
  1241. $receiptDet = $receipt->getOne ( array (
  1242. 'where' => 'rid=' . $rid,
  1243. 'asArray' => true
  1244. ) );
  1245. // if(!empty($receiptDetail))
  1246. // return "/referReceipt/".$receiptDetail['rid'];
  1247. $aItem = $accountItem->find ( array (
  1248. 'asArray' => true
  1249. ) );
  1250. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1251. $ag = $tr = $ta = $ot = 0;
  1252. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1253. foreach ( $aItem as $key => $value ) {
  1254. if ($value ['category'] == $this->AGENCY) {
  1255. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1256. array_push ( $accountJson [$this->AGENCY], array (
  1257. 'aid' => $value ['aid'],
  1258. 'name' => $value ['name'],
  1259. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1260. ) );
  1261. $sum += $agency [$ag];
  1262. $agencySum += $agency [$ag];
  1263. }
  1264. $ag ++;
  1265. }
  1266. if ($value ['category'] == $this->TRAVEL) {
  1267. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1268. array_push ( $accountJson [$this->TRAVEL], array (
  1269. 'aid' => $value ['aid'],
  1270. 'name' => $value ['name'],
  1271. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1272. ) );
  1273. $sum += $travel [$tr];
  1274. $travelSum += $travel [$tr];
  1275. }
  1276. $tr ++;
  1277. }
  1278. if ($value ['category'] == $this->TRAIN) {
  1279. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1280. array_push ( $accountJson [$this->TRAIN], array (
  1281. 'aid' => $value ['aid'],
  1282. 'name' => $value ['name'],
  1283. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1284. ) );
  1285. $sum += $train [$ta];
  1286. $trainSum += $train [$ta];
  1287. }
  1288. $ta ++;
  1289. }
  1290. if ($value ['category'] == $this->OTHER) {
  1291. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1292. array_push ( $accountJson [$this->OTHER], array (
  1293. 'aid' => $value ['aid'],
  1294. 'name' => $value ['name'],
  1295. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1296. ) );
  1297. $sum += $other [$ot];
  1298. $otherSum += $other [$ot];
  1299. }
  1300. $ot ++;
  1301. }
  1302. }
  1303. $accountJson ['cSum'] = array (
  1304. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1305. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1306. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1307. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1308. );
  1309. // 报销单
  1310. $receipt->accountItem = json_encode ( $accountJson );
  1311. $receipt->staff = $this->staff [0] ['sid'];
  1312. $receipt->loanSum = $receiptDet ['sum'];
  1313. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1314. $receipt->date = date ( "Y-m-d" );
  1315. $receipt->pastDate = '';
  1316. $receipt->cid = $cid;
  1317. $receipt->status = 7;
  1318. // 修改审批流程加入角色
  1319. $receipt->verify = $verify;
  1320. $receipt->verifyStaff = '';
  1321. $receipt->executeStaff = '';
  1322. $receipt->executeCopy = $executeDetail ['staff'];
  1323. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  1324. $receipt->explanation = $explanation;
  1325. $receipt->update ( array (
  1326. 'where' => 'rid=' . $rid
  1327. ) );
  1328. // 附件
  1329. if (! empty ( $enclosurName )) {
  1330. $enclosurArray = explode ( '-', $enclosurName );
  1331. foreach ( $enclosurArray as $value ) {
  1332. $enclosur = new enclosur ();
  1333. $enclosur->name = $value;
  1334. $enclosur->rid = $rid;
  1335. $enclosur->insert ();
  1336. }
  1337. // print_r($enclosurArray);die;
  1338. }
  1339. // 报销详情
  1340. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1341. $receiptDetail = new receiptDetail ();
  1342. $receiptDetail->staff = $this->staff [0] ['sid'];
  1343. $receiptDetail->item = $value ['name'];
  1344. $receiptDetail->itemCategory = $this->AGENCY;
  1345. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1346. $receiptDetail->date = date ( "Y-m-d" );
  1347. $receiptDetail->cid = $cid;
  1348. $receiptDetail->rid = $rid;
  1349. $receiptDetail->status = 4;
  1350. $receiptDetail->insert ();
  1351. }
  1352. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1353. $receiptDetail = new receiptDetail ();
  1354. $receiptDetail->staff = $this->staff [0] ['sid'];
  1355. $receiptDetail->item = $value ['name'];
  1356. $receiptDetail->itemCategory = $this->TRAVEL;
  1357. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1358. $receiptDetail->date = date ( "Y-m-d" );
  1359. $receiptDetail->cid = $cid;
  1360. $receiptDetail->rid = $rid;
  1361. $receiptDetail->status = 4;
  1362. $receiptDetail->insert ();
  1363. }
  1364. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1365. $receiptDetail = new receiptDetail ();
  1366. $receiptDetail->staff = $this->staff [0] ['sid'];
  1367. $receiptDetail->item = $value ['name'];
  1368. $receiptDetail->itemCategory = $this->TRAIN;
  1369. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1370. $receiptDetail->date = date ( "Y-m-d" );
  1371. $receiptDetail->cid = $cid;
  1372. $receiptDetail->rid = $rid;
  1373. $receiptDetail->status = 4;
  1374. $receiptDetail->insert ();
  1375. }
  1376. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1377. $receiptDetail = new receiptDetail ();
  1378. $receiptDetail->staff = $this->staff [0] ['sid'];
  1379. $receiptDetail->item = $value ['name'];
  1380. $receiptDetail->itemCategory = $this->OTHER;
  1381. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1382. $receiptDetail->date = date ( "Y-m-d" );
  1383. $receiptDetail->cid = $cid;
  1384. $receiptDetail->rid = $rid;
  1385. $receiptDetail->status = 4;
  1386. $receiptDetail->insert ();
  1387. }
  1388. return "/saeaBorad";
  1389. }
  1390. return "/saeaLoanReceiptAdd/" . $rid;
  1391. }
  1392. function saeaLoanReceiptEdi() {
  1393. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1394. // echo $rid;
  1395. Doo::loadModel ( 'accountItem' );
  1396. Doo::loadModel ( 'verify' );
  1397. Doo::loadModel ( 'receipt' );
  1398. $receipt = new receipt ();
  1399. $verify = new verify ();
  1400. $accountItem = new accountItem ();
  1401. Doo::loadModel ( 'L_category' );
  1402. $Lcategory = new L_category ();
  1403. Doo::loadModel ( "role" );
  1404. $role = new role ();
  1405. Doo::loadModel ( 'loanReceipt' );
  1406. $loanReceipt = new loanReceipt ();
  1407. Doo::loadModel ( 'staff' );
  1408. $staff = new staff ();
  1409. $receiptDetail = $receipt->getOne ( array (
  1410. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  1411. 'asArray' => true
  1412. ) );
  1413. if (empty ( $receiptDetail ))
  1414. return "/saeaBorad";
  1415. $receiptList = $loanReceipt->find ( array (
  1416. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1417. 'desc' => 'rid',
  1418. 'asArray' => true
  1419. ) );
  1420. $Locate = 0;
  1421. $roleId = 0;
  1422. $button = 0;
  1423. foreach ( $receiptList as $key => $value ) {
  1424. $receiptList [$key] ['Locate'] = $Locate;
  1425. $Locate ++;
  1426. $receiptList [$key] ['reviseDetail'] = array ();
  1427. if (! empty ( $value ['reviseDetail'] ))
  1428. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1429. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1430. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1431. $categoryDetil = $Lcategory->getOne ( array (
  1432. 'where' => 'cid=' . $value ['cid'],
  1433. 'asArray' => true
  1434. ) );
  1435. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1436. // 检测编辑状态
  1437. $verifyList = $verify->getOne ( array (
  1438. 'where' => 'vid=' . $value ['verify'],
  1439. 'asArray' => true
  1440. ) );
  1441. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1442. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1443. Doo::loadModel ( 'role' );
  1444. $role = new role ();
  1445. $flag = true;
  1446. $roleKey = 0;
  1447. $endStaffArray = array ();
  1448. $roleArrayCopy = array ();
  1449. foreach ( $verifyList as $k => $v ) {
  1450. // init verifyStaff
  1451. if ($v [1] == 'ROLE') {
  1452. if (! empty ( $verifyStaff )) {
  1453. $endStaffArray = end ( $verifyStaff );
  1454. // if ($v[0]==$endStaffArray['nextStaff']){
  1455. // $roleId=$v[0];
  1456. // }
  1457. }
  1458. $roleVerify = json_decode ( $v [3], true );
  1459. $roleKey = $k;
  1460. $roleArray = array ();
  1461. $rolename = $role->getOne ( array (
  1462. 'where' => 'rid=' . $v [0],
  1463. 'asArray' => true
  1464. ) );
  1465. foreach ( $roleVerify as $o => $p ) {
  1466. $staffID = explode ( '_', $p );
  1467. $staffInfo = $staff->getOne ( array (
  1468. 'where' => 'sid=' . $staffID [0],
  1469. 'asArray' => true
  1470. ) );
  1471. // print_r($staffID);
  1472. $exp = array (
  1473. 0 => $staffInfo ['sid'],
  1474. 1 => $staffID [1],
  1475. 2 => $staffInfo ['avatar'],
  1476. 'date' => '',
  1477. 'date' => '',
  1478. 'opinion' => '',
  1479. 'status' => '',
  1480. 'rolename' => $rolename ['name']
  1481. );
  1482. array_push ( $roleArray, $exp );
  1483. }
  1484. $roleArrayCopy [$v [0]] = $roleArray;
  1485. // $verifyList[$k]['roleArray']=$roleArray;
  1486. }
  1487. $verifyList [$k] ['date'] = "";
  1488. $verifyList [$k] ['opinion'] = "";
  1489. $verifyList [$k] ['status'] = "";
  1490. if (empty ( $verifyStaff )) {
  1491. $verifyList [$k] ['date'] = "";
  1492. $verifyList [$k] ['opinion'] = "";
  1493. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1494. $verifyList [$k] ['status'] = 4;
  1495. $flag = false;
  1496. }
  1497. } else {
  1498. foreach ( $verifyStaff as $m => $u ) {
  1499. if ($v [0] == $m) {
  1500. $verifyList [$k] ['date'] = $u ['date'];
  1501. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1502. $verifyList [$k] ['status'] = $u ['status'];
  1503. $flag = false;
  1504. break;
  1505. }
  1506. }
  1507. $endStaffArray = end ( $verifyStaff );
  1508. if (isset ( $endStaffArray ['ROLE'] )) {
  1509. } else {
  1510. // $endKey=key($verifyStaff);
  1511. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1512. // $button=4;
  1513. // $verifyList[$k]['status']=4;
  1514. // }
  1515. }
  1516. }
  1517. }
  1518. $rolename ['name'] = '';
  1519. if (! empty ( $roleId )) {
  1520. Doo::loadModel ( 'role' );
  1521. $role = new role ();
  1522. $rolename = $role->getOne ( array (
  1523. 'where' => 'rid=' . $roleId,
  1524. 'asArray' => true
  1525. ) );
  1526. }
  1527. if (! empty ( $verifyStaff ))
  1528. $endStaffArray = end ( $verifyStaff );
  1529. $KOP = false;
  1530. foreach ( $roleArrayCopy as $P => $A ) {
  1531. foreach ( $A as $MKI => $AVL ) {
  1532. if (! empty ( $verifyStaff )) {
  1533. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1534. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1535. $button = 4;
  1536. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1537. }
  1538. foreach ( $verifyStaff as $m => $u ) {
  1539. $AVLFK = $AVL [0] . '_R';
  1540. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1541. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1542. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1543. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1544. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1545. break;
  1546. }
  1547. }
  1548. } else {
  1549. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1550. $button = 4;
  1551. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1552. }
  1553. }
  1554. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1555. $KOP = true;
  1556. }
  1557. }
  1558. foreach ( $roleArrayCopy as $k => $v ) {
  1559. foreach ( $verifyList as $m => $n ) {
  1560. if ($n [0] == $k) {
  1561. array_splice ( $verifyList, $m, 1, $v );
  1562. }
  1563. }
  1564. }
  1565. $receiptList [$key] ['verifyList'] = $verifyList;
  1566. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1567. 'where' => 'sid=' . $value ['staff'],
  1568. 'asArray' => true
  1569. ) );
  1570. $receiptList [$key] ['button'] = $button;
  1571. //
  1572. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1573. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1574. }
  1575. $data ['receiptList'] = $receiptList;
  1576. $acItem = $accountItem->find ( array (
  1577. 'asArray' => true
  1578. ) );
  1579. $veList = $verify->find ( array (
  1580. 'asArray' => true
  1581. ) );
  1582. foreach ( $veList as $key => $value ) {
  1583. $v = json_decode ( $value ['staff'] );
  1584. $list = array ();
  1585. foreach ( $v as $n => $m ) {
  1586. if ($m ['1'] == 'ROLE') {
  1587. $roleInfo = $role->getOne ( array (
  1588. 'where' => 'rid=' . $m [0],
  1589. 'asArray' => true
  1590. ) );
  1591. $v [$n] [1] = $roleInfo ['name'];
  1592. array_push ( $list, $roleInfo ['name'] );
  1593. } else {
  1594. array_push ( $list, $v [$n] [1] );
  1595. }
  1596. }
  1597. $veList [$key] ['staff'] = implode ( '>', $list );
  1598. }
  1599. // 配置编辑信息
  1600. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1601. foreach ( $acItem as $key => $value ) {
  1602. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1603. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1604. $acItem [$key] ['price'] = $v ['price'];
  1605. }
  1606. }
  1607. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1608. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1609. $acItem [$key] ['price'] = $v ['price'];
  1610. }
  1611. }
  1612. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1613. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1614. $acItem [$key] ['price'] = $v ['price'];
  1615. }
  1616. }
  1617. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1618. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1619. $acItem [$key] ['price'] = $v ['price'];
  1620. }
  1621. }
  1622. }
  1623. $data ['category'] = $Lcategory->find ( array (
  1624. 'asArray' => true
  1625. ) );
  1626. $data ['cSum'] = $accountItemList ['cSum'];
  1627. $data ['sum'] = $receiptDetail ['sum'];
  1628. $data ['receiptDetail'] = $receiptDetail;
  1629. $data ['veList'] = $veList;
  1630. $data ['acItem'] = $acItem;
  1631. $data ['memu'] = "receipt";
  1632. $data ['staff'] = $this->staff;
  1633. $data ['receiptMemu'] = 'saeaBorad';
  1634. $data ['verify'] = $receiptDetail ['verify'];
  1635. $data ['verifyId'] = $this->verifyId;
  1636. $data ['executeId'] = $this->executeId;
  1637. $data ['rid'] = $rid;
  1638. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  1639. }
  1640. function confirmation() {
  1641. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1642. Doo::loadModel ( 'receipt' );
  1643. Doo::loadModel ( 'receiptDetail' );
  1644. $receipt = new receipt ();
  1645. $receiptDetail = new receiptDetail ();
  1646. Doo::loadModel ( 'statistics' );
  1647. Doo::loadModel ( 'itemStatistics' );
  1648. $statistics = new statistics ();
  1649. $itemStatistics = new itemStatistics ();
  1650. Doo::loadModel ( "verify" );
  1651. $verify = new verify ();
  1652. $receiptDetailList = $receipt->getOne ( array (
  1653. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  1654. 'asArray' => true
  1655. ) );
  1656. if (empty ( $receiptDetailList ))
  1657. return "/saeaBorad";
  1658. $verifyDetail = $verify->getOne ( array (
  1659. 'where' => ' vid =' . $receiptDetailList ['verify'],
  1660. 'asArray' => true
  1661. ) );
  1662. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  1663. if (empty ( $receiptDetailList ['nowStaff'] )) {
  1664. $nowStaff = "";
  1665. $nowStaffList = array ();
  1666. if ($verifyDetail [0] [1] == 'ROLE') {
  1667. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  1668. foreach ( $vStaffString as $key => $value ) {
  1669. $staffK = explode ( "_", $value );
  1670. array_push ( $nowStaffList, $staffK [0] );
  1671. }
  1672. $nowStaff = implode ( ',', $nowStaffList );
  1673. } else {
  1674. $nowStaff = $verifyDetail [0] [0];
  1675. }
  1676. $receipt->nowStaff = $nowStaff;
  1677. }
  1678. // echo $nowStaff;
  1679. // print_r($verifyDetail);die;
  1680. $receipt->rid = $receiptDetailList ['rid'];
  1681. $receipt->status = 2;
  1682. $receipt->update ();
  1683. // 操作日志
  1684. Doo::loadModel ( "receiptLog" );
  1685. $receiptLog = new receiptLog ();
  1686. $verify = new verify ();
  1687. $receiptInfo = $receipt->getOne ( array (
  1688. 'where' => 'rid=' . $rid,
  1689. 'asArray' => true
  1690. ) );
  1691. $vr = $verify->getOne ( array (
  1692. 'where' => 'vid=' . $receiptInfo ['verify'],
  1693. 'asArray' => true
  1694. ) );
  1695. $jd = json_decode ( $vr ['staff'] );
  1696. $roleId = 0;
  1697. foreach ( $jd as $key => $value ) {
  1698. if ($value [1] == 'ROLE') {
  1699. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  1700. if ($pos !== false) {
  1701. $roleId = $value [0];
  1702. }
  1703. }
  1704. }
  1705. // 审批日志
  1706. // echo $roleId;die;
  1707. if (! empty ( $roleId )) {
  1708. Doo::loadModel ( "role" );
  1709. $role = new role ();
  1710. $roleInfo = $role->getOne ( array (
  1711. 'where' => 'rid=' . $roleId,
  1712. 'asArray' => true
  1713. ) );
  1714. $receiptLog->rolename = $roleInfo ['name'];
  1715. }
  1716. $receiptLog->username = $this->staff [0] ['username'];
  1717. $receiptLog->uid = $this->staff [0] ['sid'];
  1718. $receiptLog->date = date ( "Y-m-d" );
  1719. $receiptLog->opinion = '提交审批';
  1720. $receiptLog->img = $this->staff [0] ['avatar'];
  1721. $receiptLog->status = 2;
  1722. $receiptLog->rid = $rid;
  1723. $receiptLog->insert ();
  1724. return "/expenses";
  1725. }
  1726. function expenses() {
  1727. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  1728. if (empty ( $item ))
  1729. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  1730. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1731. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  1732. Doo::loadModel ( 'receipt' );
  1733. $receipt = new receipt ();
  1734. Doo::loadModel ( 'L_category' );
  1735. $Lcategory = new L_category ();
  1736. Doo::loadModel ( 'verify' );
  1737. Doo::loadModel ( 'statistics' );
  1738. $statistics = new statistics ();
  1739. $verify = new verify ();
  1740. Doo::loadModel ( 'staff' );
  1741. $staff = new staff ();
  1742. $condition = "";
  1743. if ($item == "expenses")
  1744. $condition = " and Rtype=1 ";
  1745. elseif ($item == "receipts")
  1746. $condition = " and Rtype=0 ";
  1747. elseif ($item == "remits")
  1748. $condition = " and Rtype=2 ";
  1749. $dateCondition = " and Year(date) =" . $year;
  1750. if (! empty ( $moth )) {
  1751. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  1752. $stList = $statistics->getOne ( array (
  1753. 'select' => 'rePrice ,agPrice',
  1754. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  1755. 'asArray' => true
  1756. ) );
  1757. } else
  1758. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  1759. if (empty ( $stList ))
  1760. $stList = array (
  1761. 'rePrice' => 0,
  1762. 'agPrice' => 0
  1763. );
  1764. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  1765. if (! isset ( $noPassSum ['sum'] ))
  1766. $noPassSum ['sum'] = 0;
  1767. $data ['stList'] = array (
  1768. 'rePrice' => $stList ['rePrice'],
  1769. 'agPrice' => $stList ['agPrice'],
  1770. 'skPrice' => ($noPassSum ['sum'])
  1771. );
  1772. $receiptList = $receipt->find ( array (
  1773. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  1774. 'desc' => 'rid',
  1775. 'asArray' => true
  1776. ) );
  1777. $Locate = 0;
  1778. $roleId = 0;
  1779. $button = 0;
  1780. foreach ( $receiptList as $key => $value ) {
  1781. $receiptList [$key] ['Locate'] = $Locate;
  1782. $Locate ++;
  1783. $receiptList [$key] ['reviseDetail'] = array ();
  1784. if (! empty ( $value ['reviseDetail'] ))
  1785. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1786. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1787. $categoryDetil = $Lcategory->getOne ( array (
  1788. 'where' => 'cid=' . $value ['cid'],
  1789. 'asArray' => true
  1790. ) );
  1791. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1792. // 检测编辑状态
  1793. $verifyList = $verify->getOne ( array (
  1794. 'where' => 'vid=' . $value ['verify'],
  1795. 'asArray' => true
  1796. ) );
  1797. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1798. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1799. Doo::loadModel ( 'role' );
  1800. $role = new role ();
  1801. $flag = true;
  1802. $roleKey = 0;
  1803. $endStaffArray = array ();
  1804. $roleArrayCopy = array ();
  1805. foreach ( $verifyList as $k => $v ) {
  1806. // init verifyStaff
  1807. if ($v [1] == 'ROLE') {
  1808. if (! empty ( $verifyStaff )) {
  1809. $endStaffArray = end ( $verifyStaff );
  1810. // if ($v[0]==$endStaffArray['nextStaff']){
  1811. // $roleId=$v[0];
  1812. // }
  1813. }
  1814. $roleVerify = json_decode ( $v [3], true );
  1815. $roleKey = $k;
  1816. $roleArray = array ();
  1817. $rolename = $role->getOne ( array (
  1818. 'where' => 'rid=' . $v [0],
  1819. 'asArray' => true
  1820. ) );
  1821. foreach ( $roleVerify as $o => $p ) {
  1822. $staffID = explode ( '_', $p );
  1823. $staffInfo = $staff->getOne ( array (
  1824. 'where' => 'sid=' . $staffID [0],
  1825. 'asArray' => true
  1826. ) );
  1827. // print_r($staffID);
  1828. $exp = array (
  1829. 0 => $staffInfo ['sid'],
  1830. 1 => $staffID [1],
  1831. 2 => $staffInfo ['avatar'],
  1832. 'date' => '',
  1833. 'date' => '',
  1834. 'opinion' => '',
  1835. 'status' => '',
  1836. 'rolename' => $rolename ['name']
  1837. );
  1838. array_push ( $roleArray, $exp );
  1839. }
  1840. $roleArrayCopy [$v [0]] = $roleArray;
  1841. // $verifyList[$k]['roleArray']=$roleArray;
  1842. }
  1843. $verifyList [$k] ['date'] = "";
  1844. $verifyList [$k] ['opinion'] = "";
  1845. $verifyList [$k] ['status'] = "";
  1846. if (empty ( $verifyStaff )) {
  1847. $verifyList [$k] ['date'] = "";
  1848. $verifyList [$k] ['opinion'] = "";
  1849. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1850. $verifyList [$k] ['status'] = 4;
  1851. $flag = false;
  1852. }
  1853. } else {
  1854. foreach ( $verifyStaff as $m => $u ) {
  1855. if ($v [0] == $m) {
  1856. $verifyList [$k] ['date'] = $u ['date'];
  1857. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1858. $verifyList [$k] ['status'] = $u ['status'];
  1859. $flag = false;
  1860. break;
  1861. }
  1862. }
  1863. $endStaffArray = end ( $verifyStaff );
  1864. if (isset ( $endStaffArray ['ROLE'] )) {
  1865. } else {
  1866. // $endKey=key($verifyStaff);
  1867. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1868. // $button=4;
  1869. // $verifyList[$k]['status']=4;
  1870. // }
  1871. }
  1872. }
  1873. }
  1874. $rolename ['name'] = '';
  1875. if (! empty ( $roleId )) {
  1876. Doo::loadModel ( 'role' );
  1877. $role = new role ();
  1878. $rolename = $role->getOne ( array (
  1879. 'where' => 'rid=' . $roleId,
  1880. 'asArray' => true
  1881. ) );
  1882. }
  1883. if (! empty ( $verifyStaff ))
  1884. $endStaffArray = end ( $verifyStaff );
  1885. $KOP = false;
  1886. foreach ( $roleArrayCopy as $P => $A ) {
  1887. foreach ( $A as $MKI => $AVL ) {
  1888. if (! empty ( $verifyStaff )) {
  1889. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1890. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1891. $button = 4;
  1892. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1893. }
  1894. foreach ( $verifyStaff as $m => $u ) {
  1895. $AVLFK = $AVL [0] . '_R';
  1896. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1897. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1898. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1899. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1900. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1901. break;
  1902. }
  1903. }
  1904. } else {
  1905. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1906. $button = 4;
  1907. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1908. }
  1909. }
  1910. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1911. $KOP = true;
  1912. }
  1913. }
  1914. foreach ( $roleArrayCopy as $k => $v ) {
  1915. foreach ( $verifyList as $m => $n ) {
  1916. if ($n [0] == $k) {
  1917. array_splice ( $verifyList, $m, 1, $v );
  1918. }
  1919. }
  1920. }
  1921. $receiptList [$key] ['verifyList'] = $verifyList;
  1922. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1923. 'where' => 'sid=' . $value ['staff'],
  1924. 'asArray' => true
  1925. ) );
  1926. $receiptList [$key] ['button'] = $button;
  1927. }
  1928. // print_r($receiptList);die;
  1929. $mothHtml = "";
  1930. for($i = 1; $i <= 12; $i ++) {
  1931. if ($moth == $i)
  1932. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  1933. else
  1934. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  1935. }
  1936. $data ['mothHtml'] = $mothHtml;
  1937. $data ['receiptList'] = $receiptList;
  1938. $data ['memu'] = "receipt";
  1939. $data ['staff'] = $this->staff;
  1940. $data ['receiptMemu'] = 'expenses';
  1941. $data ['verifyId'] = $this->verifyId;
  1942. $data ['executeId'] = $this->executeId;
  1943. $data ['item'] = $item;
  1944. $data ['year'] = $year;
  1945. $this->render ( "/admin/expenses", $data );
  1946. }
  1947. function expensesCollect() {
  1948. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1949. Doo::loadModel ( 'receipt' );
  1950. $receipt = new receipt ();
  1951. Doo::loadModel ( 'L_category' );
  1952. $Lcategory = new L_category ();
  1953. Doo::loadModel ( 'verify' );
  1954. Doo::loadModel ( 'statistics' );
  1955. $statistics = new statistics ();
  1956. $verify = new verify ();
  1957. Doo::loadModel ( 'staff' );
  1958. $staff = new staff ();
  1959. Doo::loadModel ( 'loanReceipt' );
  1960. $loanReceipt = new loanReceipt ();
  1961. $receiptList = $receipt->find ( array (
  1962. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  1963. 'desc' => 'rid',
  1964. 'asArray' => true
  1965. ) );
  1966. $loanList = $loanReceipt->find ( array (
  1967. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  1968. 'desc' => 'rid',
  1969. 'asArray' => true
  1970. ) );
  1971. /*
  1972. * $Locate=0;$roleId=0;$button=0; foreach ($loanList as $key=>$value){ $loanList[$key]['Locate']=$Locate;$Locate++; $loanList[$key]['reviseDetail']=array(); if (!empty($value['reviseDetail'])) $loanList[$key]['reviseDetail']=json_decode($value['reviseDetail'],true); $loanList[$key]['accountItem']=json_decode($value['accountItem'],true); $loanList[$key]['loanItem']=json_decode($value['loanItem'],true); $categoryDetil=$Lcategory->getOne(array('where'=>'cid='.$value['cid'],'asArray'=>true)); $loanList[$key]['category']=$categoryDetil['title']; //检测编辑状态 if ($value['status']==3||$value['status']==1||$value['status']==8||$value['status']==9) $verifyList['staff']=$value['verifyBreakup']; else $verifyList=$verify->getOne(array('where'=>'vid='.$value['verify'],'asArray'=>true)); $verifyList=json_decode($verifyList['staff'],true);//status opinion $verifyStaff=json_decode($value['verifyStaff'],true); Doo::loadModel('role'); $role=new role(); $flag=true;$roleKey=0;$endStaffArray=array();$roleArrayCopy=array(); foreach ($verifyList as $k=>$v){ //init verifyStaff if ($v[1]=='ROLE'){ if (!empty($verifyStaff)){ $endStaffArray=end($verifyStaff); // if ($v[0]==$endStaffArray['nextStaff']){ // $roleId=$v[0]; // } } $roleVerify=json_decode($v[3],true); $roleKey=$k;$roleArray=array(); $rolename=$role->getOne(array('where'=>'rid='.$v[0],'asArray'=>true)); foreach ($roleVerify as $o=>$p){ $staffID=explode ('_',$p); $staffInfo=$staff->getOne(array('where'=>'sid='.$staffID[0],'asArray'=>true)); //print_r($staffID); $exp=array(0=>$staffInfo['sid'],1=>$staffID[1],2=>$staffInfo['avatar'],'date'=>'','date'=>'','opinion'=>'','status'=>'','rolename'=>$rolename['name']); array_push($roleArray, $exp); } $roleArrayCopy[$v[0]]=$roleArray; //$verifyList[$k]['roleArray']=$roleArray; } $verifyList[$k]['date']=""; $verifyList[$k]['opinion']=""; $verifyList[$k]['status']=""; if (empty($verifyStaff)){ $verifyList[$k]['date']=""; $verifyList[$k]['opinion']=""; if (($verifyList[0][0]==$this->staff[0]['sid'])&&$flag){ $verifyList[$k]['status']=4; $flag=false; } }else{ foreach ($verifyStaff as $m=>$u){ if ($v[0]==$m){ $verifyList[$k]['date']=$u['date']; $verifyList[$k]['opinion']=$u['opinion']; $verifyList[$k]['status']=$u['status']; $flag=false; break; } } $endStaffArray=end($verifyStaff); if (isset($endStaffArray['ROLE'])){ }else{ // $endKey=key($verifyStaff); // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){ // $button=4; // $verifyList[$k]['status']=4; // } } } } $rolename['name']=''; if (!empty($roleId)){ Doo::loadModel('role'); $role=new role(); $rolename=$role->getOne(array('where'=>'rid='.$roleId,'asArray'=>true)); } if (!empty($verifyStaff)) $endStaffArray=end($verifyStaff); $KOP=false; foreach ($roleArrayCopy as $P=>$A){ foreach ( $A as $MKI=>$AVL){ if (!empty($verifyStaff)){ //&&$rolename['rid']==$endStaffArray['nextStaff'] if ($this->staff[0]['sid']==$AVL[0]&&isset($endStaffArray['ROLE'])&&$rolename['rid']==$endStaffArray['nextStaff']){ $button=4; $roleArrayCopy[$P][$MKI]['status']=4; } foreach ($verifyStaff as $m=>$u){ $AVLFK=$AVL[0].'_R'; //echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>'; if (strcmp($AVLFK,$m)==0){//&&isset($u['ROLE'])&&$u['ROLE']==1 $roleArrayCopy[$P][$MKI]['date']=$u['date']; $roleArrayCopy[$P][$MKI]['opinion']=$u['opinion']; $roleArrayCopy[$P][$MKI]['status']=$u['status']; break; } } }else{ if ($this->staff[0]['sid']==$AVL[0]&&$verifyList[0][1]=='ROLE'){ $button=4; $roleArrayCopy[$P][$MKI]['status']=4; } } //$roleArray[$MKI]['rolename']=$rolename['name']; $KOP=true; } } foreach ($roleArrayCopy as $k=>$v){ foreach ($verifyList as $m=>$n){ if ($n[0]==$k){ array_splice($verifyList,$m,1,$v); } } } $loanList[$key]['verifyList']=$verifyList; $loanList[$key]['staffDetail']=$staff->getOne(array('where'=>'sid='.$value['staff'],'asArray'=>true)); $loanList[$key]['button']=$button; //$loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']); } $data['loanList']=$loanList;
  1973. */
  1974. $Locate = 0;
  1975. $roleId = 0;
  1976. $button = 0;
  1977. foreach ( $receiptList as $key => $value ) {
  1978. $receiptList [$key] ['Locate'] = $Locate;
  1979. $Locate ++;
  1980. $receiptList [$key] ['reviseDetail'] = array ();
  1981. if (! empty ( $value ['reviseDetail'] ))
  1982. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1983. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1984. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1985. $categoryDetil = $Lcategory->getOne ( array (
  1986. 'where' => 'cid=' . $value ['cid'],
  1987. 'asArray' => true
  1988. ) );
  1989. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1990. // 检测编辑状态
  1991. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  1992. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  1993. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  1994. else
  1995. $verifyList ['staff'] = $value ['verifyBreakup'];
  1996. } else
  1997. $verifyList = $verify->getOne ( array (
  1998. 'where' => 'vid=' . $value ['verify'],
  1999. 'asArray' => true
  2000. ) );
  2001. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2002. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2003. Doo::loadModel ( 'role' );
  2004. $role = new role ();
  2005. $flag = true;
  2006. $roleKey = 0;
  2007. $endStaffArray = array ();
  2008. $roleArrayCopy = array ();
  2009. foreach ( $verifyList as $k => $v ) {
  2010. // init verifyStaff
  2011. if ($v [1] == 'ROLE') {
  2012. if (! empty ( $verifyStaff )) {
  2013. $endStaffArray = end ( $verifyStaff );
  2014. // if ($v[0]==$endStaffArray['nextStaff']){
  2015. // $roleId=$v[0];
  2016. // }
  2017. }
  2018. $roleVerify = json_decode ( $v [3], true );
  2019. $roleKey = $k;
  2020. $roleArray = array ();
  2021. $rolename = $role->getOne ( array (
  2022. 'where' => 'rid=' . $v [0],
  2023. 'asArray' => true
  2024. ) );
  2025. foreach ( $roleVerify as $o => $p ) {
  2026. $staffID = explode ( '_', $p );
  2027. $staffInfo = $staff->getOne ( array (
  2028. 'where' => 'sid=' . $staffID [0],
  2029. 'asArray' => true
  2030. ) );
  2031. // print_r($staffID);
  2032. $exp = array (
  2033. 0 => $staffInfo ['sid'],
  2034. 1 => $staffID [1],
  2035. 2 => $staffInfo ['avatar'],
  2036. 'date' => '',
  2037. 'date' => '',
  2038. 'opinion' => '',
  2039. 'status' => '',
  2040. 'rolename' => $rolename ['name']
  2041. );
  2042. array_push ( $roleArray, $exp );
  2043. }
  2044. $roleArrayCopy [$v [0]] = $roleArray;
  2045. // $verifyList[$k]['roleArray']=$roleArray;
  2046. }
  2047. $verifyList [$k] ['date'] = "";
  2048. $verifyList [$k] ['opinion'] = "";
  2049. $verifyList [$k] ['status'] = "";
  2050. if (empty ( $verifyStaff )) {
  2051. $verifyList [$k] ['date'] = "";
  2052. $verifyList [$k] ['opinion'] = "";
  2053. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2054. $verifyList [$k] ['status'] = 4;
  2055. $flag = false;
  2056. }
  2057. } else {
  2058. foreach ( $verifyStaff as $m => $u ) {
  2059. if ($v [0] == $m) {
  2060. $verifyList [$k] ['date'] = $u ['date'];
  2061. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2062. $verifyList [$k] ['status'] = $u ['status'];
  2063. $flag = false;
  2064. break;
  2065. }
  2066. }
  2067. $endStaffArray = end ( $verifyStaff );
  2068. if (isset ( $endStaffArray ['ROLE'] )) {
  2069. } else {
  2070. // $endKey=key($verifyStaff);
  2071. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2072. // $button=4;
  2073. // $verifyList[$k]['status']=4;
  2074. // }
  2075. }
  2076. }
  2077. }
  2078. $rolename ['name'] = '';
  2079. if (! empty ( $roleId )) {
  2080. Doo::loadModel ( 'role' );
  2081. $role = new role ();
  2082. $rolename = $role->getOne ( array (
  2083. 'where' => 'rid=' . $roleId,
  2084. 'asArray' => true
  2085. ) );
  2086. }
  2087. if (! empty ( $verifyStaff ))
  2088. $endStaffArray = end ( $verifyStaff );
  2089. $KOP = false;
  2090. foreach ( $roleArrayCopy as $P => $A ) {
  2091. foreach ( $A as $MKI => $AVL ) {
  2092. if (! empty ( $verifyStaff )) {
  2093. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2094. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2095. $button = 4;
  2096. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2097. }
  2098. foreach ( $verifyStaff as $m => $u ) {
  2099. $AVLFK = $AVL [0] . '_R';
  2100. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2101. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2102. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2103. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2104. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2105. break;
  2106. }
  2107. }
  2108. } else {
  2109. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2110. $button = 4;
  2111. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2112. }
  2113. }
  2114. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2115. $KOP = true;
  2116. }
  2117. }
  2118. foreach ( $roleArrayCopy as $k => $v ) {
  2119. foreach ( $verifyList as $m => $n ) {
  2120. if ($n [0] == $k) {
  2121. array_splice ( $verifyList, $m, 1, $v );
  2122. }
  2123. }
  2124. }
  2125. // 费用执行人相关数据
  2126. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2127. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2128. foreach ( $executeCopy as $k => $v ) {
  2129. $executeCopy [$k] ['date'] = '';
  2130. $executeCopy [$k] ['opinion'] = '';
  2131. $executeCopy [$k] ['status'] = '';
  2132. if (! empty ( $executeStaff ))
  2133. foreach ( $executeStaff as $m => $u ) {
  2134. if ($v [0] == $m) {
  2135. $executeCopy [$k] ['date'] = $u ['date'];
  2136. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2137. $executeCopy [$k] ['status'] = $u ['status'];
  2138. break;
  2139. }
  2140. }
  2141. }
  2142. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2143. $receiptList [$key] ['verifyList'] = $verifyList;
  2144. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2145. 'where' => 'sid=' . $value ['staff'],
  2146. 'asArray' => true
  2147. ) );
  2148. $receiptList [$key] ['button'] = $button;
  2149. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2150. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2151. $relust = $value ['sum'] - $value ['loanSum'];
  2152. $receiptList [$key] ['relust'] = $relust;
  2153. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2154. }
  2155. Doo::loadModel ( 'enclosur' );
  2156. $enclosur = new enclosur ();
  2157. $enclosurList = $enclosur->find ( array (
  2158. 'where' => 'rid=' . $rid,
  2159. 'asArray' => true
  2160. ) );
  2161. $enclosurHtml = '';
  2162. foreach ( $enclosurList as $value ) {
  2163. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2164. }
  2165. $data ['enclosurHtml'] = $enclosurHtml;
  2166. // print_r($receiptList);
  2167. $data ['receiptList'] = $receiptList;
  2168. $data ['memu'] = "receipt";
  2169. $data ['staff'] = $this->staff;
  2170. $data ['receiptMemu'] = 'expenses';
  2171. $data ['verifyId'] = $this->verifyId;
  2172. $data ['executeId'] = $this->executeId;
  2173. $this->render ( "/admin/expensesCollect", $data );
  2174. }
  2175. function approvalExpenses() {
  2176. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  2177. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2178. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2179. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2180. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2181. if (empty ( $status ))
  2182. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  2183. $page_size = 12;
  2184. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2185. $vidList = array ();
  2186. $button = 0;
  2187. Doo::loadModel ( 'verify' );
  2188. $verify = new verify ();
  2189. Doo::loadModel ( 'receipt' );
  2190. $receipt = new receipt ();
  2191. Doo::loadModel ( 'staff' );
  2192. $staff = new staff ();
  2193. Doo::loadModel ( 'L_category' );
  2194. $Lcategory = new L_category ();
  2195. // user verify ID
  2196. $verifyDetail = $verify->find ( array (
  2197. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  2198. 'asArray' => true
  2199. ) );
  2200. foreach ( $verifyDetail as $key => $value ) {
  2201. array_push ( $vidList, $value ['vid'] );
  2202. }
  2203. $vid = implode ( ",", $vidList );
  2204. if (empty ( $verifyDetail ))
  2205. $vid = 0;
  2206. // if ($status==0)
  2207. // $dateCondition="";
  2208. // else
  2209. $dateCondition = " and Year(date) =" . $year;
  2210. if (! empty ( $month ))
  2211. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  2212. if($status == 'done'){
  2213. $dateCondition = " and Year(pastDate) =" . $year;
  2214. if (! empty ( $month ))
  2215. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  2216. }
  2217. $categoryList = $Lcategory->find ( array (
  2218. 'asArray' => true
  2219. ) );
  2220. $staffList = $staff->find ( array (
  2221. 'where' => 'cid=' . $cid,
  2222. 'asArray' => true
  2223. ) );
  2224. $cateCondition = "";
  2225. $staffCondition = "";
  2226. $approvalCondition = "";
  2227. if (! empty ( $cid )){
  2228. $cateCondition = ' and cid=' . $cid;
  2229. }
  2230. if (! empty ( $sid )) {
  2231. $staffCondition = ' and cid=' . $cid.' and staff=' . $sid;
  2232. $cateCondition = "";
  2233. }
  2234. $get="?year=".$year."&month=".$month."&cid=".$cid."&sid=".$sid;
  2235. if ($status == 'pendApproval') {
  2236. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  2237. }
  2238. if ($status == 'ongoing') {
  2239. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  2240. }
  2241. if ($status == 'done') {
  2242. $approvalCondition = ' and (status=8 or status=9 ) ';
  2243. }
  2244. if ($status == 'termination') {
  2245. $approvalCondition = " and status=3";
  2246. }
  2247. // $approvalCondition = " and status=" . $status;
  2248. // if ($status == 2) {
  2249. // // 查找角色审批人
  2250. // }
  2251. // if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  2252. // $approvalCondition = ' and status=2 ';
  2253. // }
  2254. // if ($status == 1) {
  2255. // $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  2256. // }
  2257. // if ($status == 8) {
  2258. // $approvalCondition = ' and (status=' . $status . ' or status=9 ) ';
  2259. // }
  2260. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  2261. $pageinfo ['page'] = array (
  2262. 'previous' => ''
  2263. );
  2264. // if ($status == 0) {
  2265. // $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  2266. // $receiptList = $receipt->find ( array (
  2267. // 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ')',
  2268. // 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2269. // 'desc' => 'rid',
  2270. // 'asArray' => true
  2271. // ) );
  2272. // //echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2273. // } else
  2274. if ($status == 'done' || $status == 'termination') {
  2275. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/".$status, $get, "" );
  2276. $receiptList = $receipt->find ( array (
  2277. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
  2278. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2279. 'desc' => 'rid',
  2280. 'asArray' => true
  2281. ) );
  2282. } else
  2283. $receiptList = $receipt->find ( array (
  2284. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
  2285. 'desc' => 'rid',
  2286. 'asArray' => true
  2287. ) );
  2288. $rLRes = $receipt->find ( array (
  2289. '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,
  2290. 'desc' => 'rid',
  2291. 'asArray' => true
  2292. ) );
  2293. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2294. // print_r($pageinfo);
  2295. $Locate = 0;
  2296. foreach ( $receiptList as $key => $value ) {
  2297. $receiptList [$key] ['Locate'] = $Locate;
  2298. $Locate ++;
  2299. $receiptList [$key] ['reviseDetail'] = array ();
  2300. if (! empty ( $value ['reviseDetail'] ))
  2301. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2302. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2303. $categoryDetil = $Lcategory->getOne ( array (
  2304. 'where' => 'cid=' . $value ['cid'],
  2305. 'asArray' => true
  2306. ) );
  2307. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2308. $verifyList = $verify->getOne ( array (
  2309. 'where' => 'vid=' . $value ['verify'],
  2310. 'asArray' => true
  2311. ) );
  2312. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2313. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2314. foreach ( $verifyList as $k => $v ) {
  2315. // init verifyStaff
  2316. $verifyList [$k] ['date'] = "";
  2317. $verifyList [$k] ['opinion'] = "";
  2318. $verifyList [$k] ['status'] = "";
  2319. if (empty ( $verifyStaff )) {
  2320. $verifyList [$k] ['date'] = "";
  2321. $verifyList [$k] ['opinion'] = "";
  2322. if ($v [0] == $this->staff [0] ['sid']) {
  2323. $verifyList [$k] ['status'] = 4;
  2324. $button = 4;
  2325. }
  2326. } else {
  2327. $flag = true;
  2328. foreach ( $verifyStaff as $m => $u ) {
  2329. if ($v [0] == $m) {
  2330. $verifyList [$k] ['date'] = $u ['date'];
  2331. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2332. $verifyList [$k] ['status'] = $u ['status'];
  2333. $flag = false;
  2334. break;
  2335. }
  2336. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  2337. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  2338. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  2339. }
  2340. if ($flag) { // 检测可编辑
  2341. if ($v [0] == $this->staff [0] ['sid']) {
  2342. $verifyList [$k] ['status'] = 4;
  2343. $button = 4;
  2344. }
  2345. }
  2346. }
  2347. }
  2348. $receiptList [$key] ['verifyList'] = $verifyList;
  2349. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2350. 'where' => 'sid=' . $value ['staff'],
  2351. 'asArray' => true
  2352. ) );
  2353. $receiptList [$key] ['button'] = $button;
  2354. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  2355. }
  2356. // print_r($receiptList);die;
  2357. // $data['verifyDetail']=$verifyDetail;
  2358. $mothHtml = "";
  2359. for($i = 1; $i <= 12; $i ++) {
  2360. if ($month == $i)
  2361. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2362. else
  2363. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2364. }
  2365. $data ['mothHtml'] = $mothHtml;
  2366. $data ['page'] = $pageinfo;
  2367. $data ['receiptList'] = $receiptList;
  2368. $data ['receiptApprovalCount'] = count ( $rLRes );
  2369. $data ['status'] = $status;
  2370. $data ['year'] = $year;
  2371. $data ['categoryList'] = $categoryList;
  2372. $data ['staffList'] = $staffList;
  2373. $data ['cid'] = $cid;
  2374. $data ['sid'] = $sid;
  2375. // print_r($receiptList);
  2376. $data ['memu'] = "receipt";
  2377. $data ['staff'] = $this->staff;
  2378. $data ['receiptMemu'] = 'approvalExpenses';
  2379. $data ['verifyId'] = $this->verifyId;
  2380. $data ['executeId'] = $this->executeId;
  2381. $this->render ( "/admin/approvalExpenses", $data );
  2382. }
  2383. function expensesDoc() {
  2384. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2385. Doo::loadModel ( 'receipt' );
  2386. $receipt = new receipt ();
  2387. Doo::loadModel ( 'L_category' );
  2388. $Lcategory = new L_category ();
  2389. Doo::loadModel ( 'verify' );
  2390. Doo::loadModel ( 'statistics' );
  2391. $statistics = new statistics ();
  2392. $verify = new verify ();
  2393. Doo::loadModel ( 'staff' );
  2394. $staff = new staff ();
  2395. Doo::loadModel ( 'loanReceipt' );
  2396. $loanReceipt = new loanReceipt ();
  2397. $receiptList = $receipt->find ( array (
  2398. 'where' => ' rid=' . $rid,
  2399. 'desc' => 'rid',
  2400. 'asArray' => true
  2401. ) );
  2402. $loanList = array ();
  2403. if (! empty ( $receiptList ))
  2404. $loanList = $loanReceipt->find ( array (
  2405. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2406. 'desc' => 'rid',
  2407. 'asArray' => true
  2408. ) );
  2409. $Locate = 0;
  2410. $roleId = 0;
  2411. $button = 0;
  2412. foreach ( $loanList as $key => $value ) {
  2413. $loanList [$key] ['Locate'] = $Locate;
  2414. $Locate ++;
  2415. $loanList [$key] ['reviseDetail'] = array ();
  2416. if (! empty ( $value ['reviseDetail'] ))
  2417. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2418. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2419. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2420. $categoryDetil = $Lcategory->getOne ( array (
  2421. 'where' => 'cid=' . $value ['cid'],
  2422. 'asArray' => true
  2423. ) );
  2424. $loanList [$key] ['category'] = $categoryDetil ['title'];
  2425. // 检测编辑状态
  2426. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  2427. $verifyList ['staff'] = $value ['verifyBreakup'];
  2428. else
  2429. $verifyList = $verify->getOne ( array (
  2430. 'where' => 'vid=' . $value ['verify'],
  2431. 'asArray' => true
  2432. ) );
  2433. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2434. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2435. Doo::loadModel ( 'role' );
  2436. $role = new role ();
  2437. $flag = true;
  2438. $roleKey = 0;
  2439. $endStaffArray = array ();
  2440. $roleArrayCopy = array ();
  2441. foreach ( $verifyList as $k => $v ) {
  2442. // init verifyStaff
  2443. if ($v [1] == 'ROLE') {
  2444. if (! empty ( $verifyStaff )) {
  2445. $endStaffArray = end ( $verifyStaff );
  2446. // if ($v[0]==$endStaffArray['nextStaff']){
  2447. // $roleId=$v[0];
  2448. // }
  2449. }
  2450. $roleVerify = json_decode ( $v [3], true );
  2451. $roleKey = $k;
  2452. $roleArray = array ();
  2453. $rolename = $role->getOne ( array (
  2454. 'where' => 'rid=' . $v [0],
  2455. 'asArray' => true
  2456. ) );
  2457. foreach ( $roleVerify as $o => $p ) {
  2458. $staffID = explode ( '_', $p );
  2459. $staffInfo = $staff->getOne ( array (
  2460. 'where' => 'sid=' . $staffID [0],
  2461. 'asArray' => true
  2462. ) );
  2463. // print_r($staffID);
  2464. $exp = array (
  2465. 0 => $staffInfo ['sid'],
  2466. 1 => $staffID [1],
  2467. 2 => $staffInfo ['avatar'],
  2468. 'date' => '',
  2469. 'date' => '',
  2470. 'opinion' => '',
  2471. 'status' => '',
  2472. 'rolename' => $rolename ['name']
  2473. );
  2474. array_push ( $roleArray, $exp );
  2475. }
  2476. $roleArrayCopy [$v [0]] = $roleArray;
  2477. // $verifyList[$k]['roleArray']=$roleArray;
  2478. }
  2479. $verifyList [$k] ['date'] = "";
  2480. $verifyList [$k] ['opinion'] = "";
  2481. $verifyList [$k] ['status'] = "";
  2482. if (empty ( $verifyStaff )) {
  2483. $verifyList [$k] ['date'] = "";
  2484. $verifyList [$k] ['opinion'] = "";
  2485. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2486. $verifyList [$k] ['status'] = 4;
  2487. $flag = false;
  2488. }
  2489. } else {
  2490. foreach ( $verifyStaff as $m => $u ) {
  2491. if ($v [0] == $m) {
  2492. $verifyList [$k] ['date'] = $u ['date'];
  2493. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2494. $verifyList [$k] ['status'] = $u ['status'];
  2495. $flag = false;
  2496. break;
  2497. }
  2498. }
  2499. $endStaffArray = end ( $verifyStaff );
  2500. if (isset ( $endStaffArray ['ROLE'] )) {
  2501. } else {
  2502. // $endKey=key($verifyStaff);
  2503. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2504. // $button=4;
  2505. // $verifyList[$k]['status']=4;
  2506. // }
  2507. }
  2508. }
  2509. }
  2510. $rolename ['name'] = '';
  2511. if (! empty ( $roleId )) {
  2512. Doo::loadModel ( 'role' );
  2513. $role = new role ();
  2514. $rolename = $role->getOne ( array (
  2515. 'where' => 'rid=' . $roleId,
  2516. 'asArray' => true
  2517. ) );
  2518. }
  2519. if (! empty ( $verifyStaff ))
  2520. $endStaffArray = end ( $verifyStaff );
  2521. $KOP = false;
  2522. foreach ( $roleArrayCopy as $P => $A ) {
  2523. foreach ( $A as $MKI => $AVL ) {
  2524. if (! empty ( $verifyStaff )) {
  2525. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2526. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2527. $button = 4;
  2528. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2529. }
  2530. foreach ( $verifyStaff as $m => $u ) {
  2531. $AVLFK = $AVL [0] . '_R';
  2532. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2533. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2534. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2535. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2536. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2537. break;
  2538. }
  2539. }
  2540. } else {
  2541. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2542. $button = 4;
  2543. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2544. }
  2545. }
  2546. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2547. $KOP = true;
  2548. }
  2549. }
  2550. foreach ( $roleArrayCopy as $k => $v ) {
  2551. foreach ( $verifyList as $m => $n ) {
  2552. if ($n [0] == $k) {
  2553. array_splice ( $verifyList, $m, 1, $v );
  2554. }
  2555. }
  2556. }
  2557. $loanList [$key] ['verifyList'] = $verifyList;
  2558. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  2559. 'where' => 'sid=' . $value ['staff'],
  2560. 'asArray' => true
  2561. ) );
  2562. $loanList [$key] ['button'] = $button;
  2563. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  2564. }
  2565. $data ['loanList'] = $loanList;
  2566. // print_r($loanList);
  2567. $Locate = 0;
  2568. $roleId = 0;
  2569. $button = 0;
  2570. foreach ( $receiptList as $key => $value ) {
  2571. $receiptList [$key] ['Locate'] = $Locate;
  2572. $Locate ++;
  2573. $receiptList [$key] ['reviseDetail'] = array ();
  2574. if (! empty ( $value ['reviseDetail'] ))
  2575. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2576. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2577. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2578. $categoryDetil = $Lcategory->getOne ( array (
  2579. 'where' => 'cid=' . $value ['cid'],
  2580. 'asArray' => true
  2581. ) );
  2582. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2583. // 检测编辑状态
  2584. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  2585. $verifyList ['staff'] = $value ['verifyBreakup'];
  2586. } else
  2587. $verifyList = $verify->getOne ( array (
  2588. 'where' => 'vid=' . $value ['verify'],
  2589. 'asArray' => true
  2590. ) );
  2591. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2592. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2593. Doo::loadModel ( 'role' );
  2594. $role = new role ();
  2595. if ($verifyList == NULL)
  2596. $verifyList = array ();
  2597. $flag = true;
  2598. $roleKey = 0;
  2599. $endStaffArray = array ();
  2600. $roleArrayCopy = array ();
  2601. foreach ( $verifyList as $k => $v ) {
  2602. // init verifyStaff
  2603. if ($v [1] == 'ROLE') {
  2604. if (! empty ( $verifyStaff )) {
  2605. $endStaffArray = end ( $verifyStaff );
  2606. // if ($v[0]==$endStaffArray['nextStaff']){
  2607. // $roleId=$v[0];
  2608. // }
  2609. }
  2610. $roleVerify = json_decode ( $v [3], true );
  2611. $roleKey = $k;
  2612. $roleArray = array ();
  2613. $rolename = $role->getOne ( array (
  2614. 'where' => 'rid=' . $v [0],
  2615. 'asArray' => true
  2616. ) );
  2617. foreach ( $roleVerify as $o => $p ) {
  2618. $staffID = explode ( '_', $p );
  2619. $staffInfo = $staff->getOne ( array (
  2620. 'where' => 'sid=' . $staffID [0],
  2621. 'asArray' => true
  2622. ) );
  2623. // print_r($staffID);
  2624. $exp = array (
  2625. 0 => $staffInfo ['sid'],
  2626. 1 => $staffID [1],
  2627. 2 => $staffInfo ['avatar'],
  2628. 'date' => '',
  2629. 'date' => '',
  2630. 'opinion' => '',
  2631. 'status' => '',
  2632. 'rolename' => $rolename ['name']
  2633. );
  2634. array_push ( $roleArray, $exp );
  2635. }
  2636. $roleArrayCopy [$v [0]] = $roleArray;
  2637. // $verifyList[$k]['roleArray']=$roleArray;
  2638. }
  2639. $verifyList [$k] ['date'] = "";
  2640. $verifyList [$k] ['opinion'] = "";
  2641. $verifyList [$k] ['status'] = "";
  2642. if (empty ( $verifyStaff )) {
  2643. $verifyList [$k] ['date'] = "";
  2644. $verifyList [$k] ['opinion'] = "";
  2645. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2646. $verifyList [$k] ['status'] = 4;
  2647. $flag = false;
  2648. }
  2649. } else {
  2650. foreach ( $verifyStaff as $m => $u ) {
  2651. if ($v [0] == $m) {
  2652. $verifyList [$k] ['date'] = $u ['date'];
  2653. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2654. $verifyList [$k] ['status'] = $u ['status'];
  2655. $flag = false;
  2656. break;
  2657. }
  2658. }
  2659. $endStaffArray = end ( $verifyStaff );
  2660. if (isset ( $endStaffArray ['ROLE'] )) {
  2661. } else {
  2662. // $endKey=key($verifyStaff);
  2663. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2664. // $button=4;
  2665. // $verifyList[$k]['status']=4;
  2666. // }
  2667. }
  2668. }
  2669. }
  2670. $rolename ['name'] = '';
  2671. if (! empty ( $roleId )) {
  2672. Doo::loadModel ( 'role' );
  2673. $role = new role ();
  2674. $rolename = $role->getOne ( array (
  2675. 'where' => 'rid=' . $roleId,
  2676. 'asArray' => true
  2677. ) );
  2678. }
  2679. if (! empty ( $verifyStaff ))
  2680. $endStaffArray = end ( $verifyStaff );
  2681. $KOP = false;
  2682. foreach ( $roleArrayCopy as $P => $A ) {
  2683. foreach ( $A as $MKI => $AVL ) {
  2684. if (! empty ( $verifyStaff )) {
  2685. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2686. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2687. $button = 4;
  2688. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2689. }
  2690. foreach ( $verifyStaff as $m => $u ) {
  2691. $AVLFK = $AVL [0] . '_R';
  2692. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2693. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2694. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2695. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2696. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2697. break;
  2698. }
  2699. }
  2700. } else {
  2701. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2702. $button = 4;
  2703. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2704. }
  2705. }
  2706. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2707. $KOP = true;
  2708. }
  2709. }
  2710. foreach ( $roleArrayCopy as $k => $v ) {
  2711. foreach ( $verifyList as $m => $n ) {
  2712. if ($n [0] == $k) {
  2713. array_splice ( $verifyList, $m, 1, $v );
  2714. }
  2715. }
  2716. }
  2717. // 费用执行人相关数据
  2718. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2719. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2720. foreach ( $executeCopy as $k => $v ) {
  2721. $executeCopy [$k] ['date'] = '';
  2722. $executeCopy [$k] ['opinion'] = '';
  2723. $executeCopy [$k] ['status'] = '';
  2724. if (! empty ( $executeStaff ))
  2725. foreach ( $executeStaff as $m => $u ) {
  2726. if ($v [0] == $m) {
  2727. $executeCopy [$k] ['date'] = $u ['date'];
  2728. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2729. $executeCopy [$k] ['status'] = $u ['status'];
  2730. break;
  2731. }
  2732. }
  2733. }
  2734. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2735. $receiptList [$key] ['verifyList'] = $verifyList;
  2736. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2737. 'where' => 'sid=' . $value ['staff'],
  2738. 'asArray' => true
  2739. ) );
  2740. $receiptList [$key] ['button'] = $button;
  2741. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2742. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2743. $relust = $value ['sum'] - $value ['loanSum'];
  2744. $receiptList [$key] ['relust'] = $relust;
  2745. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2746. }
  2747. // print_r($receiptList);
  2748. // 获取审批日志
  2749. Doo::loadModel ( 'receiptLog' );
  2750. $receiptLog = new receiptLog ();
  2751. $rlList = array ();
  2752. $rlInfo = $receiptLog->getOne ( array (
  2753. 'where' => 'rid=' . $rid . ' and status=4',
  2754. 'asArray' => true
  2755. ) );
  2756. $tijdate = $receiptLog->getOne ( array (
  2757. 'where' => 'rid=' . $rid . ' and status=2',
  2758. 'asc' => 'rlid',
  2759. 'asArray' => true
  2760. ) );
  2761. if (! empty ( $rlInfo )) {
  2762. $rlList = $receiptLog->find ( array (
  2763. 'where' => 'rid=' . $rid,
  2764. 'asc' => 'rlid',
  2765. 'asArray' => true
  2766. ) );
  2767. }
  2768. Doo::loadModel ( 'enclosur' );
  2769. $enclosur = new enclosur ();
  2770. $enclosurList = $enclosur->find ( array (
  2771. 'where' => 'rid=' . $rid,
  2772. 'asArray' => true
  2773. ) );
  2774. $enclosurHtml = '';
  2775. foreach ( $enclosurList as $value ) {
  2776. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2777. }
  2778. $data ['enclosurHtml'] = $enclosurHtml;
  2779. $receiptList [0] ['rlList'] = $rlList;
  2780. $data ['receiptList'] = $receiptList;
  2781. $data ['memu'] = "receipt";
  2782. $data ['staff'] = $this->staff;
  2783. $data ['receiptMemu'] = 'approvalExpenses';
  2784. $data ['verifyId'] = $this->verifyId;
  2785. $data ['executeId'] = $this->executeId;
  2786. $this->render ( "/admin/expensesDoc", $data );
  2787. }
  2788. function expensesEdi() {
  2789. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2790. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  2791. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2792. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2793. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2794. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2795. if (empty ( $status ))
  2796. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  2797. $vidList = array ();
  2798. $button = 0;
  2799. Doo::loadModel ( 'verify' );
  2800. Doo::loadModel ( 'receipt' );
  2801. Doo::loadModel ( 'staff' );
  2802. $staff = new staff ();
  2803. $receipt = new receipt ();
  2804. $verify = new verify ();
  2805. Doo::loadModel ( 'L_category' );
  2806. $Lcategory = new L_category ();
  2807. Doo::loadModel ( 'enclosur' );
  2808. $enclosur = new enclosur ();
  2809. // user verify ID
  2810. $verifyDetail = $verify->find ( array (
  2811. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  2812. 'asArray' => true
  2813. ) );
  2814. foreach ( $verifyDetail as $key => $value ) {
  2815. array_push ( $vidList, $value ['vid'] );
  2816. }
  2817. $vid = implode ( ",", $vidList );
  2818. if (empty ( $verifyDetail ))
  2819. $vid = 0;
  2820. $categoryList = $Lcategory->find ( array (
  2821. 'asArray' => true
  2822. ) );
  2823. $staffList = $staff->find ( array (
  2824. 'where' => 'cid=' . $cid,
  2825. 'asArray' => true
  2826. ) );
  2827. $ap = "";
  2828. if ($status == 4) {
  2829. $ap = 4;
  2830. $status = 2;
  2831. }
  2832. // get Receipt By verifyID status 2
  2833. $receiptList = $receipt->find ( array (
  2834. 'where' => 'rid =' . $rid,
  2835. 'desc' => 'rid',
  2836. 'asArray' => true
  2837. ) );
  2838. $Locate = 0;
  2839. $roleId = 0;
  2840. if ($ap == 4)
  2841. $status = 4;
  2842. foreach ( $receiptList as $key => $value ) {
  2843. $receiptList [$key] ['Locate'] = $Locate;
  2844. $Locate ++;
  2845. $receiptList [$key] ['reviseDetail'] = array ();
  2846. if (! empty ( $value ['reviseDetail'] ))
  2847. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2848. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2849. $categoryDetil = $Lcategory->getOne ( array (
  2850. 'where' => 'cid=' . $value ['cid'],
  2851. 'asArray' => true
  2852. ) );
  2853. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2854. // 检测编辑状态
  2855. $verifyList = $verify->getOne ( array (
  2856. 'where' => 'vid=' . $value ['verify'],
  2857. 'asArray' => true
  2858. ) );
  2859. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2860. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2861. Doo::loadModel ( 'role' );
  2862. $role = new role ();
  2863. // print_r($verifyList);
  2864. $flag = true;
  2865. $roleKey = 0;
  2866. $endStaffArray = array ();
  2867. $roleArrayCopy = array ();
  2868. foreach ( $verifyList as $k => $v ) {
  2869. // init verifyStaff
  2870. if ($v [1] == 'ROLE') {
  2871. if (! empty ( $verifyStaff )) {
  2872. $endStaffArray = end ( $verifyStaff );
  2873. if ($v [0] == $endStaffArray ['nextStaff']) {
  2874. $roleId = $v [0];
  2875. }
  2876. }
  2877. $roleVerify = json_decode ( $v [3], true );
  2878. $roleKey = $k;
  2879. $roleArray = array ();
  2880. $rolename = $role->getOne ( array (
  2881. 'where' => 'rid=' . $v [0],
  2882. 'asArray' => true
  2883. ) );
  2884. foreach ( $roleVerify as $o => $p ) {
  2885. $staffID = explode ( '_', $p );
  2886. $staffInfo = $staff->getOne ( array (
  2887. 'where' => 'sid=' . $staffID [0],
  2888. 'asArray' => true
  2889. ) );
  2890. // print_r($staffID);
  2891. $exp = array (
  2892. 0 => $staffInfo ['sid'],
  2893. 1 => $staffID [1],
  2894. 2 => $staffInfo ['avatar'],
  2895. 'date' => '',
  2896. 'date' => '',
  2897. 'opinion' => '',
  2898. 'status' => '',
  2899. 'rolename' => $rolename ['name']
  2900. );
  2901. array_push ( $roleArray, $exp );
  2902. }
  2903. $roleArrayCopy [$v [0]] = $roleArray;
  2904. // $verifyList[$k]['roleArray']=$roleArray;
  2905. }
  2906. // print_r($roleArray);
  2907. $verifyList [$k] ['date'] = "";
  2908. $verifyList [$k] ['opinion'] = "";
  2909. $verifyList [$k] ['status'] = "";
  2910. if (empty ( $verifyStaff )) {
  2911. $verifyList [$k] ['date'] = "";
  2912. $verifyList [$k] ['opinion'] = "";
  2913. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2914. $verifyList [$k] ['status'] = 4;
  2915. $button = 4;
  2916. $flag = false;
  2917. }
  2918. } else {
  2919. foreach ( $verifyStaff as $m => $u ) {
  2920. if ($v [0] == $m) {
  2921. $verifyList [$k] ['date'] = $u ['date'];
  2922. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2923. $verifyList [$k] ['status'] = $u ['status'];
  2924. $flag = false;
  2925. break;
  2926. }
  2927. }
  2928. $endStaffArray = end ( $verifyStaff );
  2929. if (isset ( $endStaffArray ['ROLE'] )) {
  2930. } else {
  2931. $endKey = key ( $verifyStaff );
  2932. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  2933. $button = 4;
  2934. $verifyList [$k] ['status'] = 4;
  2935. }
  2936. }
  2937. }
  2938. }
  2939. $rolename ['name'] = '';
  2940. if (! empty ( $roleId )) {
  2941. Doo::loadModel ( 'role' );
  2942. $role = new role ();
  2943. $rolename = $role->getOne ( array (
  2944. 'where' => 'rid=' . $roleId,
  2945. 'asArray' => true
  2946. ) );
  2947. }
  2948. if (! empty ( $verifyStaff ))
  2949. $endStaffArray = end ( $verifyStaff );
  2950. $KOP = false;
  2951. foreach ( $roleArrayCopy as $P => $A ) {
  2952. foreach ( $A as $MKI => $AVL ) {
  2953. if (! empty ( $verifyStaff )) {
  2954. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2955. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2956. $button = 4;
  2957. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2958. }
  2959. foreach ( $verifyStaff as $m => $u ) {
  2960. $AVLFK = $AVL [0] . '_R';
  2961. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2962. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2963. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2964. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2965. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2966. break;
  2967. }
  2968. }
  2969. } else {
  2970. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2971. $button = 4;
  2972. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2973. }
  2974. }
  2975. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2976. $KOP = true;
  2977. }
  2978. }
  2979. // print_r($roleArrayCopy);
  2980. // echo $roleKey;
  2981. foreach ( $roleArrayCopy as $k => $v ) {
  2982. foreach ( $verifyList as $m => $n ) {
  2983. if ($n [0] == $k) {
  2984. array_splice ( $verifyList, $m, 1, $v );
  2985. }
  2986. }
  2987. }
  2988. $receiptList [$key] ['verifyList'] = $verifyList;
  2989. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2990. 'where' => 'sid=' . $value ['staff'],
  2991. 'asArray' => true
  2992. ) );
  2993. $receiptList [$key] ['button'] = $button;
  2994. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  2995. }
  2996. // $data['verifyDetail']=$verifyDetail;
  2997. $mothHtml = "";
  2998. for($i = 1; $i <= 12; $i ++) {
  2999. if ($month == $i)
  3000. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3001. else
  3002. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3003. }
  3004. // 获取审批日志
  3005. Doo::loadModel ( 'receiptLog' );
  3006. $receiptLog = new receiptLog ();
  3007. $rlList = array ();
  3008. $rlInfo = $receiptLog->getOne ( array (
  3009. 'where' => 'rid=' . $rid . ' and status=4',
  3010. 'asArray' => true
  3011. ) );
  3012. $tijdate = $receiptLog->getOne ( array (
  3013. 'where' => 'rid=' . $rid . ' and status=2',
  3014. 'asc' => 'rlid',
  3015. 'asArray' => true
  3016. ) );
  3017. if (! empty ( $rlInfo )) {
  3018. $rlList = $receiptLog->find ( array (
  3019. 'where' => 'rid=' . $rid,
  3020. 'asc' => 'rlid',
  3021. 'asArray' => true
  3022. ) );
  3023. }
  3024. $receiptList [0] ['rlList'] = $rlList;
  3025. $enclosurList = $enclosur->find ( array (
  3026. 'where' => 'rid=' . $rid,
  3027. 'asArray' => true
  3028. ) );
  3029. $enclosurHtml = '';
  3030. foreach ( $enclosurList as $value ) {
  3031. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3032. }
  3033. // print_r($receiptList);
  3034. $data ['rid'] = $rid;
  3035. $data ['enclosurHtml'] = $enclosurHtml;
  3036. $data ['rolename'] = $rolename ['name'];
  3037. $data ['datetij'] = $tijdate ['date'];
  3038. $data ['mothHtml'] = $mothHtml;
  3039. $data ['receiptList'] = $receiptList;
  3040. $data ['receiptApprovalCount'] = count ( $receiptList );
  3041. $data ['status'] = $status;
  3042. $data ['year'] = $year;
  3043. $data ['categoryList'] = $categoryList;
  3044. $data ['staffList'] = $staffList;
  3045. $data ['cid'] = $cid;
  3046. $data ['sid'] = $sid;
  3047. $data ['ap'] = $ap;
  3048. $data ['memu'] = "receipt";
  3049. $data ['staff'] = $this->staff;
  3050. $data ['receiptMemu'] = 'approvalExpenses';
  3051. $data ['verifyId'] = $this->verifyId;
  3052. $data ['executeId'] = $this->executeId;
  3053. $this->render ( "/admin/expensesEdi", $data );
  3054. }
  3055. function expensesDefray() {
  3056. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3057. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3058. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3059. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  3060. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  3061. if (! empty ( $rid )) {
  3062. Doo::loadModel ( "verify" );
  3063. $verify = new verify ();
  3064. Doo::loadModel ( "receiptDetail" );
  3065. $receiptDetailObj = new receiptDetail ();
  3066. Doo::loadModel ( "itemStatistics" );
  3067. Doo::loadModel ( "statistics" );
  3068. $statistics = new statistics ();
  3069. $itemStatistics = new itemStatistics ();
  3070. Doo::loadModel ( "receipt" );
  3071. $receipt = new receipt ();
  3072. Doo::loadModel ( "loanReceipt" );
  3073. $loanReceipt = new loanReceipt ();
  3074. $receiptDetail = $receipt->getOne ( array (
  3075. 'where' => 'rid=' . $rid . ' and status=2 ',
  3076. 'asArray' => true
  3077. ) );
  3078. if (empty ( $receiptDetail ))
  3079. return "/approval";
  3080. $verifyDetail = $verify->getOne ( array (
  3081. 'where' => ' vid =' . $receiptDetail ['verify'],
  3082. 'asArray' => true
  3083. ) );
  3084. $verifyString = $verifyDetail ['staff'];
  3085. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3086. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  3087. if (empty ( $opinion )) {
  3088. if ($status == 3)
  3089. $opinion = "终止";
  3090. else
  3091. $opinion = "同意支付";
  3092. }
  3093. $nowStaff = 0;
  3094. $nowStaffList = array ();
  3095. if (empty ( $verifyStaff )) {
  3096. // 还需加入是否已经进入角色审批
  3097. if ($verifyDetail [0] [1] == 'ROLE') {
  3098. // print_r($verifyDetail);echo "ddd";
  3099. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3100. foreach ( $vStaffString as $key => $value ) {
  3101. $staffK = explode ( "_", $value );
  3102. if ($staffK [0] != $this->staff [0] ['sid'])
  3103. array_push ( $nowStaffList, $staffK [0] );
  3104. }
  3105. // print_r($verifyDetail);
  3106. // die;
  3107. if (! empty ( $nowStaffList )) {
  3108. $nowStaff = implode ( ',', $nowStaffList );
  3109. $verifyStaff = array (
  3110. $this->staff [0] ['sid'] . "_R" => array (
  3111. 'date' => date ( 'Y-m-d' ),
  3112. 'opinion' => $opinion,
  3113. 'status' => $status,
  3114. 'nextStaff' => $verifyDetail [0] [0],
  3115. 'ROLE' => 1
  3116. )
  3117. );
  3118. } else {
  3119. $nowStaff = $verifyDetail [1] [0];
  3120. $verifyStaff = array (
  3121. $this->staff [0] ['sid'] . "_R" => array (
  3122. 'date' => date ( 'Y-m-d' ),
  3123. 'opinion' => $opinion,
  3124. 'status' => $status,
  3125. 'nextStaff' => $verifyDetail [1] [0]
  3126. )
  3127. );
  3128. }
  3129. } else {
  3130. if ($verifyDetail [1] [1] == 'ROLE') {
  3131. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  3132. // echo "dd";
  3133. foreach ( $vStaffString as $key => $value ) {
  3134. $staffK = explode ( "_", $value );
  3135. array_push ( $nowStaffList, $staffK [0] );
  3136. }
  3137. $nowStaff = implode ( ',', $nowStaffList );
  3138. $verifyStaff = array (
  3139. $this->staff [0] ['sid'] => array (
  3140. 'date' => date ( 'Y-m-d' ),
  3141. 'opinion' => $opinion,
  3142. 'status' => $status,
  3143. 'nextStaff' => $verifyDetail [1] [0],
  3144. 'ROLE' => 1
  3145. )
  3146. );
  3147. } else {
  3148. $nowStaff = $verifyDetail [1] [0];
  3149. $verifyStaff = array (
  3150. $this->staff [0] ['sid'] => array (
  3151. 'date' => date ( 'Y-m-d' ),
  3152. 'opinion' => $opinion,
  3153. 'status' => $status,
  3154. 'nextStaff' => $verifyDetail [1] [0]
  3155. )
  3156. );
  3157. }
  3158. }
  3159. if ($status == 3)
  3160. $verifyStaff = array (
  3161. 'final' => $status,
  3162. $this->staff [0] ['sid'] => array (
  3163. 'date' => date ( 'Y-m-d' ),
  3164. 'opinion' => $opinion,
  3165. 'status' => $status
  3166. )
  3167. );
  3168. $vStaffString = json_encode ( $verifyStaff );
  3169. $receipt->nowStaff = $nowStaff;
  3170. $receipt->verifyStaff = $vStaffString;
  3171. $loanReceipt->nowStaff = $nowStaff;
  3172. $loanReceipt->verifyStaff = $vStaffString;
  3173. } else {
  3174. $VS = end ( $verifyStaff );
  3175. // 非角色审批
  3176. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  3177. $nextStaff = 0;
  3178. $roleSTF = false;
  3179. foreach ( $verifyDetail as $key => $value ) {
  3180. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  3181. if (isset ( $verifyDetail [$key + 1] )) {
  3182. $nextStaff = $verifyDetail [$key + 1] [0];
  3183. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  3184. $roleSTF = true;
  3185. }
  3186. break;
  3187. }
  3188. }
  3189. if (! $roleSTF) {
  3190. $nowStaff = $nextStaff;
  3191. $verifyStaff [$this->staff [0] ['sid']] = array (
  3192. 'date' => date ( 'Y-m-d' ),
  3193. 'opinion' => $opinion,
  3194. 'status' => $status,
  3195. 'nextStaff' => $nextStaff
  3196. );
  3197. } else {
  3198. // 获取角色下的所有用户ID
  3199. $nowStaffList = array ();
  3200. foreach ( $verifyDetail as $vfk ) {
  3201. if ($vfk [1] == 'ROLE') {
  3202. $vStaffString = json_decode ( $vfk [3] );
  3203. foreach ( $vStaffString as $key => $value ) {
  3204. $staffK = explode ( "_", $value );
  3205. array_push ( $nowStaffList, $staffK [0] );
  3206. }
  3207. }
  3208. }
  3209. $nowStaff = implode ( ',', $nowStaffList );
  3210. $verifyStaff [$this->staff [0] ['sid']] = array (
  3211. 'date' => date ( 'Y-m-d' ),
  3212. 'opinion' => $opinion,
  3213. 'status' => $status,
  3214. 'nextStaff' => $nextStaff,
  3215. 'ROLE' => 0
  3216. );
  3217. }
  3218. if ($status == 3) {
  3219. $verifyStaff ['final'] = $status;
  3220. $verifyStaff [$this->staff [0] ['sid']] = array (
  3221. 'date' => date ( 'Y-m-d' ),
  3222. 'opinion' => $opinion,
  3223. 'status' => $status
  3224. );
  3225. }
  3226. $vStaffString = json_encode ( $verifyStaff );
  3227. $receipt->nowStaff = $nowStaff;
  3228. $receipt->verifyStaff = $vStaffString;
  3229. $loanReceipt->nowStaff = $nowStaff;
  3230. $loanReceipt->verifyStaff = $vStaffString;
  3231. }
  3232. // 角色审批
  3233. if (isset ( $VS ['ROLE'] )) {
  3234. // 找出角色人 当前审批角色组
  3235. $verifyJSStaff = array ();
  3236. $nowStaffList2 = array ();
  3237. foreach ( $verifyDetail as $key => $value ) {
  3238. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  3239. $verifyJSStaff = json_decode ( $value [3] );
  3240. foreach ( $verifyJSStaff as $m ) {
  3241. $staffK = explode ( "_", $m );
  3242. array_push ( $nowStaffList2, $staffK [0] );
  3243. }
  3244. // print_r($nowStaffList2);
  3245. }
  3246. }
  3247. $RoleVerifyStaff = array ();
  3248. foreach ( $verifyStaff as $key => $value ) {
  3249. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  3250. foreach ( $nowStaffList2 as $m ) {
  3251. if ($key == $m . "_R")
  3252. $RoleVerifyStaff [$key] = $value;
  3253. }
  3254. }
  3255. }
  3256. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  3257. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  3258. // 下一个审批人ID
  3259. $nextStaff = 0;
  3260. $falg = false;
  3261. foreach ( $verifyDetail as $key => $value ) {
  3262. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  3263. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  3264. $falg = true;
  3265. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  3266. $nowStaffList = array ();
  3267. foreach ( $vStaffString as $v ) {
  3268. $staffK = explode ( "_", $v );
  3269. array_push ( $nowStaffList, $staffK [0] );
  3270. }
  3271. $nowStaff = implode ( ',', $nowStaffList );
  3272. $nextStaff = $verifyDetail [$key + 1] [0];
  3273. } elseif (isset ( $verifyDetail [$key + 1] )) {
  3274. $nextStaff = $verifyDetail [$key + 1] [0];
  3275. $nowStaff = $nextStaff;
  3276. } else
  3277. $nowStaff = '';
  3278. break;
  3279. }
  3280. }
  3281. if ($falg)
  3282. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3283. 'date' => date ( 'Y-m-d' ),
  3284. 'opinion' => $opinion,
  3285. 'status' => $status,
  3286. 'nextStaff' => $nextStaff,
  3287. 'ROLE' => 1
  3288. );
  3289. else
  3290. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3291. 'date' => date ( 'Y-m-d' ),
  3292. 'opinion' => $opinion,
  3293. 'status' => $status,
  3294. 'nextStaff' => $nextStaff
  3295. );
  3296. // print_r($verifyStaff);
  3297. // echo $nowStaff;die;
  3298. } else { // 进入下一个角色或者审批人
  3299. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  3300. //
  3301. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  3302. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3303. 'date' => date ( 'Y-m-d' ),
  3304. 'opinion' => $opinion,
  3305. 'status' => $status,
  3306. 'nextStaff' => $VS ['nextStaff'],
  3307. 'ROLE' => 1
  3308. );
  3309. // print_r($verifyStaff);
  3310. // die;
  3311. }
  3312. if ($status == 3) {
  3313. $verifyStaff ['final'] = $status;
  3314. $verifyStaff [$this->staff [0] ['sid']] = array (
  3315. 'date' => date ( 'Y-m-d' ),
  3316. 'opinion' => $opinion,
  3317. 'status' => $status
  3318. );
  3319. }
  3320. $vStaffString = json_encode ( $verifyStaff );
  3321. $receipt->verifyStaff = $vStaffString;
  3322. $receipt->nowStaff = $nowStaff;
  3323. $loanReceipt->nowStaff = $nowStaff;
  3324. $loanReceipt->verifyStaff = $vStaffString;
  3325. // die;
  3326. // }
  3327. // print_r($verifyStaff);
  3328. // die;
  3329. }
  3330. // print_r($verifyStaff);die;
  3331. }
  3332. // print_r($verifyDetail);
  3333. $roleKey = 0;
  3334. $roleId = 0;
  3335. $verifyDetailCopy = array ();
  3336. foreach ( $verifyDetail as $k => $v ) {
  3337. if ($v [1] == 'ROLE') {
  3338. $roleId = $v [0];
  3339. $roleVerify = json_decode ( $v [3], true );
  3340. $roleKey = $k;
  3341. $roleArray = array ();
  3342. foreach ( $roleVerify as $o => $p ) {
  3343. $staffID = explode ( '_', $p );
  3344. $exp = array (
  3345. 0 => $staffID [0],
  3346. 1 => $staffID [1]
  3347. );
  3348. array_push ( $roleArray, $exp );
  3349. }
  3350. $verifyDetailCopy [$v [0]] = $roleArray;
  3351. }
  3352. }
  3353. // print_r($verifyDetail);
  3354. foreach ( $verifyDetailCopy as $k => $v ) {
  3355. foreach ( $verifyDetail as $m => $n ) {
  3356. if ($n [0] == $k) {
  3357. array_splice ( $verifyDetail, $m, 1, $v );
  3358. }
  3359. }
  3360. }
  3361. // 审批日志
  3362. if (! isset ( $verifyStaff ['final'] )) {
  3363. Doo::loadModel ( "receiptLog" );
  3364. $receiptLog = new receiptLog ();
  3365. if (! empty ( $roleId )) {
  3366. Doo::loadModel ( "role" );
  3367. $role = new role ();
  3368. $roleInfo = $role->getOne ( array (
  3369. 'where' => 'rid=' . $roleId,
  3370. 'asArray' => true
  3371. ) );
  3372. $receiptLog->rolename = $roleInfo ['name'];
  3373. }
  3374. $receiptLog->username = $this->staff [0] ['username'];
  3375. $receiptLog->uid = $this->staff [0] ['sid'];
  3376. $receiptLog->date = date ( "Y-m-d" );
  3377. $receiptLog->opinion = $opinion;
  3378. $receiptLog->img = $this->staff [0] ['avatar'];
  3379. $receiptLog->status = 1;
  3380. $receiptLog->rid = $rid;
  3381. $receiptLog->insert ();
  3382. }
  3383. if (isset ( $verifyStaff ['final'] )) { // rDetail
  3384. $receipt->status = 3;
  3385. $receipt->verifyBreakup = $verifyString;
  3386. $receiptDetailObj->status = 3;
  3387. $receiptDetailObj->update ( array (
  3388. 'where' => 'rid=' . $rid
  3389. ) );
  3390. // 微信企业号通知
  3391. $this->setWXMsg ( $rid, 3 );
  3392. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  3393. $receipt->status = 6;
  3394. $receipt->pastDate = date ( "Y-m-d" );
  3395. $receipt->isBK = 1;
  3396. $loanReceipt->verifyBreakup = $verifyString;
  3397. $loanReceipt->status = 1;
  3398. $loanReceipt->pastDate = date ( "Y-m-d" );
  3399. $loanReceipt->update ( array (
  3400. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  3401. ) );
  3402. // 微信企业号通知
  3403. $this->setWXMsg ( $rid, 1 );
  3404. }
  3405. $receipt->amount = $amount;
  3406. $receipt->update ( array (
  3407. 'where' => ' rid = ' . $rid
  3408. ) );
  3409. return "/approvalExpenses/pendApproval";
  3410. }
  3411. }
  3412. function ajaxExamineExe() {
  3413. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3414. Doo::loadModel ( 'receipt' );
  3415. $receipt = new receipt ();
  3416. Doo::loadClass ( 'XDeode' );
  3417. $XDeode = new XDeode ( 5 );
  3418. if (! empty ( $rid )) {
  3419. $rLRes = $receipt->find ( array (
  3420. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  3421. 'asArray' => true
  3422. ) );
  3423. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  3424. echo json_encode ( array (
  3425. 'status' => 1,
  3426. 'receipt' => $rLRes [0]
  3427. ) );
  3428. die ();
  3429. }
  3430. echo json_encode ( array (
  3431. 'status' => 0,
  3432. 'receipt' => array ()
  3433. ) );
  3434. die ();
  3435. }
  3436. function implement() {
  3437. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3438. Doo::loadClass ( 'XDeode' );
  3439. $XDeode = new XDeode ( 5 );
  3440. Doo::loadModel ( 'receipt' );
  3441. $receipt = new receipt ();
  3442. Doo::loadModel ( 'L_category' );
  3443. $Lcategory = new L_category ();
  3444. Doo::loadModel ( 'verify' );
  3445. $verify = new verify ();
  3446. Doo::loadModel ( 'staff' );
  3447. $staff = new staff ();
  3448. Doo::loadModel ( "execute" );
  3449. $execute = new execute ();
  3450. $rid = $XDeode->decode ( $rid );
  3451. $receiptList = $receipt->find ( array (
  3452. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  3453. 'desc' => 'rid',
  3454. 'asArray' => true
  3455. ) );
  3456. Doo::loadModel ( 'loanReceipt' );
  3457. $loanReceipt = new loanReceipt ();
  3458. // print_r($receiptList);
  3459. $loanList = array ();
  3460. if (! isset ( $receiptList ))
  3461. $loanList = $loanReceipt->find ( array (
  3462. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3463. 'desc' => 'rid',
  3464. 'asArray' => true
  3465. ) );
  3466. $Locate = 0;
  3467. $roleId = 0;
  3468. $button = 0;
  3469. foreach ( $loanList as $key => $value ) {
  3470. $loanList [$key] ['Locate'] = $Locate;
  3471. $Locate ++;
  3472. $loanList [$key] ['reviseDetail'] = array ();
  3473. if (! empty ( $value ['reviseDetail'] ))
  3474. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3475. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3476. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3477. $categoryDetil = $Lcategory->getOne ( array (
  3478. 'where' => 'cid=' . $value ['cid'],
  3479. 'asArray' => true
  3480. ) );
  3481. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3482. // 检测编辑状态
  3483. $verifyList = $verify->getOne ( array (
  3484. 'where' => 'vid=' . $value ['verify'],
  3485. 'asArray' => true
  3486. ) );
  3487. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3488. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3489. Doo::loadModel ( 'role' );
  3490. $role = new role ();
  3491. $flag = true;
  3492. $roleKey = 0;
  3493. $endStaffArray = array ();
  3494. $roleArrayCopy = array ();
  3495. foreach ( $verifyList as $k => $v ) {
  3496. // init verifyStaff
  3497. if ($v [1] == 'ROLE') {
  3498. if (! empty ( $verifyStaff )) {
  3499. $endStaffArray = end ( $verifyStaff );
  3500. // if ($v[0]==$endStaffArray['nextStaff']){
  3501. // $roleId=$v[0];
  3502. // }
  3503. }
  3504. $roleVerify = json_decode ( $v [3], true );
  3505. $roleKey = $k;
  3506. $roleArray = array ();
  3507. $rolename = $role->getOne ( array (
  3508. 'where' => 'rid=' . $v [0],
  3509. 'asArray' => true
  3510. ) );
  3511. foreach ( $roleVerify as $o => $p ) {
  3512. $staffID = explode ( '_', $p );
  3513. $staffInfo = $staff->getOne ( array (
  3514. 'where' => 'sid=' . $staffID [0],
  3515. 'asArray' => true
  3516. ) );
  3517. // print_r($staffID);
  3518. $exp = array (
  3519. 0 => $staffInfo ['sid'],
  3520. 1 => $staffID [1],
  3521. 2 => $staffInfo ['avatar'],
  3522. 'date' => '',
  3523. 'date' => '',
  3524. 'opinion' => '',
  3525. 'status' => '',
  3526. 'rolename' => $rolename ['name']
  3527. );
  3528. array_push ( $roleArray, $exp );
  3529. }
  3530. $roleArrayCopy [$v [0]] = $roleArray;
  3531. // $verifyList[$k]['roleArray']=$roleArray;
  3532. }
  3533. $verifyList [$k] ['date'] = "";
  3534. $verifyList [$k] ['opinion'] = "";
  3535. $verifyList [$k] ['status'] = "";
  3536. if (empty ( $verifyStaff )) {
  3537. $verifyList [$k] ['date'] = "";
  3538. $verifyList [$k] ['opinion'] = "";
  3539. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3540. $verifyList [$k] ['status'] = 4;
  3541. $flag = false;
  3542. }
  3543. } else {
  3544. foreach ( $verifyStaff as $m => $u ) {
  3545. if ($v [0] == $m) {
  3546. $verifyList [$k] ['date'] = $u ['date'];
  3547. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3548. $verifyList [$k] ['status'] = $u ['status'];
  3549. $flag = false;
  3550. break;
  3551. }
  3552. }
  3553. $endStaffArray = end ( $verifyStaff );
  3554. if (isset ( $endStaffArray ['ROLE'] )) {
  3555. } else {
  3556. // $endKey=key($verifyStaff);
  3557. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3558. // $button=4;
  3559. // $verifyList[$k]['status']=4;
  3560. // }
  3561. }
  3562. }
  3563. }
  3564. $rolename ['name'] = '';
  3565. if (! empty ( $roleId )) {
  3566. Doo::loadModel ( 'role' );
  3567. $role = new role ();
  3568. $rolename = $role->getOne ( array (
  3569. 'where' => 'rid=' . $roleId,
  3570. 'asArray' => true
  3571. ) );
  3572. }
  3573. if (! empty ( $verifyStaff ))
  3574. $endStaffArray = end ( $verifyStaff );
  3575. $KOP = false;
  3576. foreach ( $roleArrayCopy as $P => $A ) {
  3577. foreach ( $A as $MKI => $AVL ) {
  3578. if (! empty ( $verifyStaff )) {
  3579. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3580. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3581. $button = 4;
  3582. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3583. }
  3584. foreach ( $verifyStaff as $m => $u ) {
  3585. $AVLFK = $AVL [0] . '_R';
  3586. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3587. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3588. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3589. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3590. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3591. break;
  3592. }
  3593. }
  3594. } else {
  3595. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3596. $button = 4;
  3597. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3598. }
  3599. }
  3600. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3601. $KOP = true;
  3602. }
  3603. }
  3604. foreach ( $roleArrayCopy as $k => $v ) {
  3605. foreach ( $verifyList as $m => $n ) {
  3606. if ($n [0] == $k) {
  3607. array_splice ( $verifyList, $m, 1, $v );
  3608. }
  3609. }
  3610. }
  3611. $loanList [$key] ['verifyList'] = $verifyList;
  3612. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3613. 'where' => 'sid=' . $value ['staff'],
  3614. 'asArray' => true
  3615. ) );
  3616. }
  3617. $data ['loanList'] = $loanList;
  3618. $Locate = 0;
  3619. $roleId = 0;
  3620. $button = 0;
  3621. foreach ( $receiptList as $key => $value ) {
  3622. $button2 = 0;
  3623. $receiptList [$key] ['Locate'] = $Locate;
  3624. $Locate ++;
  3625. $receiptList [$key] ['reviseDetail'] = array ();
  3626. if (! empty ( $value ['reviseDetail'] ))
  3627. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3628. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3629. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3630. $categoryDetil = $Lcategory->getOne ( array (
  3631. 'where' => 'cid=' . $value ['cid'],
  3632. 'asArray' => true
  3633. ) );
  3634. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3635. $executeList = json_decode ( $value ['executeCopy'], true );
  3636. $executeStaff = array ();
  3637. if (! empty ( $value ['executeStaff'] ))
  3638. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3639. if (isset ( $executeList )) {
  3640. foreach ( $executeList as $op => $lo ) {
  3641. $executeList [$op] ['date'] = "";
  3642. $executeList [$op] ['opinion'] = "";
  3643. $executeList [$op] ['status'] = "";
  3644. foreach ( $executeStaff as $m => $u ) {
  3645. if ($lo [0] == $m) {
  3646. $executeList [$op] ['date'] = $u ['date'];
  3647. $executeList [$op] ['opinion'] = $u ['opinion'];
  3648. $executeList [$op] ['status'] = $u ['status'];
  3649. break;
  3650. }
  3651. }
  3652. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  3653. $button2 = 1;
  3654. $executeList [$op] ['status'] = 4;
  3655. }
  3656. }
  3657. }
  3658. // 检测编辑状态
  3659. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3660. $verifyList ['staff'] = $value ['verifyBreakup'];
  3661. } else
  3662. $verifyList = $verify->getOne ( array (
  3663. 'where' => 'vid=' . $value ['verify'],
  3664. 'asArray' => true
  3665. ) );
  3666. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3667. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3668. Doo::loadModel ( 'role' );
  3669. $role = new role ();
  3670. if ($verifyList == NULL)
  3671. $verifyList = array ();
  3672. $flag = true;
  3673. $roleKey = 0;
  3674. $endStaffArray = array ();
  3675. $roleArrayCopy = array ();
  3676. foreach ( $verifyList as $k => $v ) {
  3677. // init verifyStaff
  3678. if ($v [1] == 'ROLE') {
  3679. if (! empty ( $verifyStaff )) {
  3680. $endStaffArray = end ( $verifyStaff );
  3681. // if ($v[0]==$endStaffArray['nextStaff']){
  3682. // $roleId=$v[0];
  3683. // }
  3684. }
  3685. $roleVerify = json_decode ( $v [3], true );
  3686. $roleKey = $k;
  3687. $roleArray = array ();
  3688. $rolename = $role->getOne ( array (
  3689. 'where' => 'rid=' . $v [0],
  3690. 'asArray' => true
  3691. ) );
  3692. foreach ( $roleVerify as $o => $p ) {
  3693. $staffID = explode ( '_', $p );
  3694. $staffInfo = $staff->getOne ( array (
  3695. 'where' => 'sid=' . $staffID [0],
  3696. 'asArray' => true
  3697. ) );
  3698. // print_r($staffID);
  3699. $exp = array (
  3700. 0 => $staffInfo ['sid'],
  3701. 1 => $staffID [1],
  3702. 2 => $staffInfo ['avatar'],
  3703. 'date' => '',
  3704. 'date' => '',
  3705. 'opinion' => '',
  3706. 'status' => '',
  3707. 'rolename' => $rolename ['name']
  3708. );
  3709. array_push ( $roleArray, $exp );
  3710. }
  3711. $roleArrayCopy [$v [0]] = $roleArray;
  3712. // $verifyList[$k]['roleArray']=$roleArray;
  3713. }
  3714. $verifyList [$k] ['date'] = "";
  3715. $verifyList [$k] ['opinion'] = "";
  3716. $verifyList [$k] ['status'] = "";
  3717. if (empty ( $verifyStaff )) {
  3718. $verifyList [$k] ['date'] = "";
  3719. $verifyList [$k] ['opinion'] = "";
  3720. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3721. $verifyList [$k] ['status'] = 4;
  3722. $flag = false;
  3723. }
  3724. } else {
  3725. foreach ( $verifyStaff as $m => $u ) {
  3726. if ($v [0] == $m) {
  3727. $verifyList [$k] ['date'] = $u ['date'];
  3728. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3729. $verifyList [$k] ['status'] = $u ['status'];
  3730. $flag = false;
  3731. break;
  3732. }
  3733. }
  3734. $endStaffArray = end ( $verifyStaff );
  3735. if (isset ( $endStaffArray ['ROLE'] )) {
  3736. } else {
  3737. // $endKey=key($verifyStaff);
  3738. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3739. // $button=4;
  3740. // $verifyList[$k]['status']=4;
  3741. // }
  3742. }
  3743. }
  3744. }
  3745. $rolename ['name'] = '';
  3746. if (! empty ( $roleId )) {
  3747. Doo::loadModel ( 'role' );
  3748. $role = new role ();
  3749. $rolename = $role->getOne ( array (
  3750. 'where' => 'rid=' . $roleId,
  3751. 'asArray' => true
  3752. ) );
  3753. }
  3754. if (! empty ( $verifyStaff ))
  3755. $endStaffArray = end ( $verifyStaff );
  3756. $KOP = false;
  3757. foreach ( $roleArrayCopy as $P => $A ) {
  3758. foreach ( $A as $MKI => $AVL ) {
  3759. if (! empty ( $verifyStaff )) {
  3760. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3761. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3762. $button = 4;
  3763. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3764. }
  3765. foreach ( $verifyStaff as $m => $u ) {
  3766. $AVLFK = $AVL [0] . '_R';
  3767. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3768. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3769. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3770. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3771. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3772. break;
  3773. }
  3774. }
  3775. } else {
  3776. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3777. $button = 4;
  3778. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3779. }
  3780. }
  3781. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3782. $KOP = true;
  3783. }
  3784. }
  3785. foreach ( $roleArrayCopy as $k => $v ) {
  3786. foreach ( $verifyList as $m => $n ) {
  3787. if ($n [0] == $k) {
  3788. array_splice ( $verifyList, $m, 1, $v );
  3789. }
  3790. }
  3791. }
  3792. $receiptList [$key] ['verifyList'] = $verifyList;
  3793. $receiptList [$key] ['executeList'] = $executeList;
  3794. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3795. 'where' => 'sid=' . $value ['staff'],
  3796. 'asArray' => true
  3797. ) );
  3798. $receiptList [$key] ['button2'] = $button2;
  3799. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3800. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3801. $relust = $value ['sum'] - $value ['loanSum'];
  3802. $receiptList [$key] ['relust'] = $relust;
  3803. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  3804. }
  3805. // print_r($receiptList[$key]['executeList']);
  3806. $data ['receiptList'] = $receiptList;
  3807. $data ['memu'] = "receipt";
  3808. $data ['staff'] = $this->staff;
  3809. $data ['receiptMemu'] = 'implement';
  3810. $data ['verifyId'] = $this->verifyId;
  3811. $data ['executeId'] = $this->executeId;
  3812. $this->render ( "/admin/implement", $data );
  3813. }
  3814. function implementDo() {
  3815. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3816. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3817. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  3818. if (! empty ( $rid ) && $amount != '') {
  3819. Doo::loadModel ( 'receipt' );
  3820. $receipt = new receipt ();
  3821. Doo::loadClass ( 'XDeode' );
  3822. $XDeode = new XDeode ( 5 );
  3823. $rinfo = $receipt->getOne ( array (
  3824. 'where' => 'rid=' . $rid,
  3825. 'asArray' => true
  3826. ) );
  3827. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  3828. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  3829. if (empty ( $executeStaff )) {
  3830. $executeStaff = array (
  3831. $this->staff [0] ['sid'] => array (
  3832. 'date' => date ( 'Y-m-d' ),
  3833. 'opinion' => $implementOpinions,
  3834. 'status' => 1
  3835. )
  3836. );
  3837. } else {
  3838. $executeStaff [$this->staff [0] ['sid']] = array (
  3839. 'date' => date ( 'Y-m-d' ),
  3840. 'opinion' => $implementOpinions,
  3841. 'status' => 1
  3842. );
  3843. }
  3844. if (count ( $executeStaff ) == count ( $executeCopy )) {
  3845. $receipt->executeStaff = json_encode ( $executeStaff );
  3846. $receipt->status = 8;
  3847. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  3848. $receipt->status = 9;
  3849. if($rinfo ['status']==6){
  3850. $receipt->loanDate=date ( "Y-m-d" );
  3851. }
  3852. $receipt->executeDate = date ( "Y-m-d" );
  3853. } else {
  3854. $receipt->executeStaff = json_encode ( $executeStaff );
  3855. }
  3856. $receipt->amount = $amount;
  3857. $receipt->update ( array (
  3858. 'where' => 'rid=' . $rid
  3859. ) );
  3860. }
  3861. $ridKey = $XDeode->encode ( $rid );
  3862. return "/implement/" . $ridKey . ".html";
  3863. }
  3864. function receiptburEdi() {
  3865. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3866. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  3867. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  3868. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  3869. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3870. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  3871. if (empty ( $status ))
  3872. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  3873. $vidList = array ();
  3874. $button = 0;
  3875. Doo::loadModel ( 'verify' );
  3876. Doo::loadModel ( 'receipt' );
  3877. Doo::loadModel ( 'staff' );
  3878. $staff = new staff ();
  3879. $receipt = new receipt ();
  3880. $verify = new verify ();
  3881. Doo::loadModel ( 'L_category' );
  3882. $Lcategory = new L_category ();
  3883. Doo::loadModel ( 'enclosur' );
  3884. $enclosur = new enclosur ();
  3885. Doo::loadModel ( 'loanReceipt' );
  3886. $loanReceipt = new loanReceipt ();
  3887. // user verify ID
  3888. $verifyDetail = $verify->find ( array (
  3889. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  3890. 'asArray' => true
  3891. ) );
  3892. foreach ( $verifyDetail as $key => $value ) {
  3893. array_push ( $vidList, $value ['vid'] );
  3894. }
  3895. $vid = implode ( ",", $vidList );
  3896. if (empty ( $verifyDetail ))
  3897. $vid = 0;
  3898. $categoryList = $Lcategory->find ( array (
  3899. 'asArray' => true
  3900. ) );
  3901. $staffList = $staff->find ( array (
  3902. 'where' => 'cid=' . $cid,
  3903. 'asArray' => true
  3904. ) );
  3905. $ap = "";
  3906. if ($status == 4) {
  3907. $ap = 4;
  3908. $status = 2;
  3909. }
  3910. // get Receipt By verifyID status 2
  3911. $receiptList = $receipt->find ( array (
  3912. 'where' => 'rid =' . $rid,
  3913. 'desc' => 'rid',
  3914. 'asArray' => true
  3915. ) );
  3916. $loanList = $loanReceipt->find ( array (
  3917. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3918. 'desc' => 'rid',
  3919. 'asArray' => true
  3920. ) );
  3921. $Locate = 0;
  3922. $roleId = 0;
  3923. $button = 0;
  3924. foreach ( $loanList as $key => $value ) {
  3925. $loanList [$key] ['Locate'] = $Locate;
  3926. $Locate ++;
  3927. $loanList [$key] ['reviseDetail'] = array ();
  3928. if (! empty ( $value ['reviseDetail'] ))
  3929. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3930. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3931. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3932. $categoryDetil = $Lcategory->getOne ( array (
  3933. 'where' => 'cid=' . $value ['cid'],
  3934. 'asArray' => true
  3935. ) );
  3936. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3937. // 检测编辑状态
  3938. $verifyList = $verify->getOne ( array (
  3939. 'where' => 'vid=' . $value ['verify'],
  3940. 'asArray' => true
  3941. ) );
  3942. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3943. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3944. Doo::loadModel ( 'role' );
  3945. $role = new role ();
  3946. $flag = true;
  3947. $roleKey = 0;
  3948. $endStaffArray = array ();
  3949. $roleArrayCopy = array ();
  3950. foreach ( $verifyList as $k => $v ) {
  3951. // init verifyStaff
  3952. if ($v [1] == 'ROLE') {
  3953. if (! empty ( $verifyStaff )) {
  3954. $endStaffArray = end ( $verifyStaff );
  3955. }
  3956. $roleVerify = json_decode ( $v [3], true );
  3957. $roleKey = $k;
  3958. $roleArray = array ();
  3959. $rolename = $role->getOne ( array (
  3960. 'where' => 'rid=' . $v [0],
  3961. 'asArray' => true
  3962. ) );
  3963. foreach ( $roleVerify as $o => $p ) {
  3964. $staffID = explode ( '_', $p );
  3965. $staffInfo = $staff->getOne ( array (
  3966. 'where' => 'sid=' . $staffID [0],
  3967. 'asArray' => true
  3968. ) );
  3969. // print_r($staffID);
  3970. $exp = array (
  3971. 0 => $staffInfo ['sid'],
  3972. 1 => $staffID [1],
  3973. 2 => $staffInfo ['avatar'],
  3974. 'date' => '',
  3975. 'date' => '',
  3976. 'opinion' => '',
  3977. 'status' => '',
  3978. 'rolename' => $rolename ['name']
  3979. );
  3980. array_push ( $roleArray, $exp );
  3981. }
  3982. $roleArrayCopy [$v [0]] = $roleArray;
  3983. // $verifyList[$k]['roleArray']=$roleArray;
  3984. }
  3985. $verifyList [$k] ['date'] = "";
  3986. $verifyList [$k] ['opinion'] = "";
  3987. $verifyList [$k] ['status'] = "";
  3988. if (empty ( $verifyStaff )) {
  3989. $verifyList [$k] ['date'] = "";
  3990. $verifyList [$k] ['opinion'] = "";
  3991. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3992. $verifyList [$k] ['status'] = 4;
  3993. $flag = false;
  3994. }
  3995. } else {
  3996. foreach ( $verifyStaff as $m => $u ) {
  3997. if ($v [0] == $m) {
  3998. $verifyList [$k] ['date'] = $u ['date'];
  3999. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4000. $verifyList [$k] ['status'] = $u ['status'];
  4001. $flag = false;
  4002. break;
  4003. }
  4004. }
  4005. $endStaffArray = end ( $verifyStaff );
  4006. if (isset ( $endStaffArray ['ROLE'] )) {
  4007. } else {
  4008. }
  4009. }
  4010. }
  4011. $rolename ['name'] = '';
  4012. if (! empty ( $roleId )) {
  4013. Doo::loadModel ( 'role' );
  4014. $role = new role ();
  4015. $rolename = $role->getOne ( array (
  4016. 'where' => 'rid=' . $roleId,
  4017. 'asArray' => true
  4018. ) );
  4019. }
  4020. if (! empty ( $verifyStaff ))
  4021. $endStaffArray = end ( $verifyStaff );
  4022. $KOP = false;
  4023. foreach ( $roleArrayCopy as $P => $A ) {
  4024. foreach ( $A as $MKI => $AVL ) {
  4025. if (! empty ( $verifyStaff )) {
  4026. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4027. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4028. $button = 4;
  4029. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4030. }
  4031. foreach ( $verifyStaff as $m => $u ) {
  4032. $AVLFK = $AVL [0] . '_R';
  4033. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4034. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4035. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4036. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4037. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4038. break;
  4039. }
  4040. }
  4041. } else {
  4042. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4043. $button = 4;
  4044. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4045. }
  4046. }
  4047. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4048. $KOP = true;
  4049. }
  4050. }
  4051. foreach ( $roleArrayCopy as $k => $v ) {
  4052. foreach ( $verifyList as $m => $n ) {
  4053. if ($n [0] == $k) {
  4054. array_splice ( $verifyList, $m, 1, $v );
  4055. }
  4056. }
  4057. }
  4058. $loanList [$key] ['verifyList'] = $verifyList;
  4059. }
  4060. $htmlLoan = '';
  4061. if (isset ( $loanList [0] )) {
  4062. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  4063. if ($value ['status'] == 1)
  4064. $htmlLoan .= '<li class="done" >';
  4065. elseif ($value ['status'] == 3)
  4066. $htmlLoan .= '<li class="undone" >';
  4067. $htmlLoan .= '<div class="avtra"><img src="' . $value [2] . '_2.jpg"></div>';
  4068. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  4069. if (isset ( $value ['rolename'] ))
  4070. $htmlLoan .= $value ['rolename'];
  4071. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  4072. }
  4073. $data ['loanDate'] = $loanList [0] ['date'];
  4074. }
  4075. $data ['htmlLoan'] = $htmlLoan;
  4076. // print_r($loanList);
  4077. $Locate = 0;
  4078. $roleId = 0;
  4079. $button = 0;
  4080. if ($ap == 4)
  4081. $status = 4;
  4082. foreach ( $receiptList as $key => $value ) {
  4083. $receiptList [$key] ['Locate'] = $Locate;
  4084. $Locate ++;
  4085. $receiptList [$key] ['reviseDetail'] = array ();
  4086. if (! empty ( $value ['reviseDetail'] ))
  4087. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4088. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4089. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4090. $categoryDetil = $Lcategory->getOne ( array (
  4091. 'where' => 'cid=' . $value ['cid'],
  4092. 'asArray' => true
  4093. ) );
  4094. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4095. // 检测编辑状态
  4096. $verifyList = $verify->getOne ( array (
  4097. 'where' => 'vid=' . $value ['verify'],
  4098. 'asArray' => true
  4099. ) );
  4100. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4101. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4102. Doo::loadModel ( 'role' );
  4103. $role = new role ();
  4104. // print_r($verifyList);
  4105. $flag = true;
  4106. $roleKey = 0;
  4107. $endStaffArray = array ();
  4108. $roleArrayCopy = array ();
  4109. foreach ( $verifyList as $k => $v ) {
  4110. // init verifyStaff
  4111. if ($v [1] == 'ROLE') {
  4112. if (! empty ( $verifyStaff )) {
  4113. $endStaffArray = end ( $verifyStaff );
  4114. if ($v [0] == $endStaffArray ['nextStaff']) {
  4115. $roleId = $v [0];
  4116. }
  4117. }
  4118. $roleVerify = json_decode ( $v [3], true );
  4119. $roleKey = $k;
  4120. $roleArray = array ();
  4121. $rolename = $role->getOne ( array (
  4122. 'where' => 'rid=' . $v [0],
  4123. 'asArray' => true
  4124. ) );
  4125. foreach ( $roleVerify as $o => $p ) {
  4126. $staffID = explode ( '_', $p );
  4127. $staffInfo = $staff->getOne ( array (
  4128. 'where' => 'sid=' . $staffID [0],
  4129. 'asArray' => true
  4130. ) );
  4131. // print_r($staffID);
  4132. $exp = array (
  4133. 0 => $staffInfo ['sid'],
  4134. 1 => $staffID [1],
  4135. 2 => $staffInfo ['avatar'],
  4136. 'date' => '',
  4137. 'date' => '',
  4138. 'opinion' => '',
  4139. 'status' => '',
  4140. 'rolename' => $rolename ['name']
  4141. );
  4142. array_push ( $roleArray, $exp );
  4143. }
  4144. $roleArrayCopy [$v [0]] = $roleArray;
  4145. // $verifyList[$k]['roleArray']=$roleArray;
  4146. }
  4147. // print_r($roleArray);
  4148. $verifyList [$k] ['date'] = "";
  4149. $verifyList [$k] ['opinion'] = "";
  4150. $verifyList [$k] ['status'] = "";
  4151. if (empty ( $verifyStaff )) {
  4152. $verifyList [$k] ['date'] = "";
  4153. $verifyList [$k] ['opinion'] = "";
  4154. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4155. $verifyList [$k] ['status'] = 4;
  4156. $button = 4;
  4157. $flag = false;
  4158. }
  4159. } else {
  4160. foreach ( $verifyStaff as $m => $u ) {
  4161. if ($v [0] == $m) {
  4162. $verifyList [$k] ['date'] = $u ['date'];
  4163. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4164. $verifyList [$k] ['status'] = $u ['status'];
  4165. $flag = false;
  4166. break;
  4167. }
  4168. }
  4169. $endStaffArray = end ( $verifyStaff );
  4170. if (isset ( $endStaffArray ['ROLE'] )) {
  4171. } else {
  4172. $endKey = key ( $verifyStaff );
  4173. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4174. $button = 4;
  4175. $verifyList [$k] ['status'] = 4;
  4176. }
  4177. }
  4178. }
  4179. }
  4180. $rolename ['name'] = '';
  4181. if (! empty ( $roleId )) {
  4182. Doo::loadModel ( 'role' );
  4183. $role = new role ();
  4184. $rolename = $role->getOne ( array (
  4185. 'where' => 'rid=' . $roleId,
  4186. 'asArray' => true
  4187. ) );
  4188. }
  4189. if (! empty ( $verifyStaff ))
  4190. $endStaffArray = end ( $verifyStaff );
  4191. $KOP = false;
  4192. foreach ( $roleArrayCopy as $P => $A ) {
  4193. foreach ( $A as $MKI => $AVL ) {
  4194. if (! empty ( $verifyStaff )) {
  4195. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4196. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4197. $button = 4;
  4198. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4199. }
  4200. foreach ( $verifyStaff as $m => $u ) {
  4201. $AVLFK = $AVL [0] . '_R';
  4202. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4203. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4204. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4205. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4206. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4207. break;
  4208. }
  4209. }
  4210. } else {
  4211. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4212. $button = 4;
  4213. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4214. }
  4215. }
  4216. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4217. $KOP = true;
  4218. }
  4219. }
  4220. foreach ( $roleArrayCopy as $k => $v ) {
  4221. foreach ( $verifyList as $m => $n ) {
  4222. if ($n [0] == $k) {
  4223. array_splice ( $verifyList, $m, 1, $v );
  4224. }
  4225. }
  4226. }
  4227. // print_r($verifyList);
  4228. $receiptList [$key] ['verifyList'] = $verifyList;
  4229. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4230. 'where' => 'sid=' . $value ['staff'],
  4231. 'asArray' => true
  4232. ) );
  4233. $receiptList [$key] ['button'] = $button;
  4234. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4235. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4236. $relust = $value ['sum'] - $value ['loanSum'];
  4237. $receiptList [$key] ['relust'] = $relust;
  4238. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4239. }
  4240. // print_r($receiptList);die;
  4241. // $data['verifyDetail']=$verifyDetail;
  4242. $mothHtml = "";
  4243. for($i = 1; $i <= 12; $i ++) {
  4244. if ($month == $i)
  4245. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4246. else
  4247. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4248. }
  4249. // 获取审批日志
  4250. Doo::loadModel ( 'receiptLog' );
  4251. $receiptLog = new receiptLog ();
  4252. $rlList = array ();
  4253. $rlInfo = $receiptLog->getOne ( array (
  4254. 'where' => 'rid=' . $rid . ' and status=4',
  4255. 'asArray' => true
  4256. ) );
  4257. $tijdate = $receiptLog->getOne ( array (
  4258. 'where' => 'rid=' . $rid . ' and status=2',
  4259. 'asc' => 'rlid',
  4260. 'asArray' => true
  4261. ) );
  4262. if (! empty ( $rlInfo )) {
  4263. $rlList = $receiptLog->find ( array (
  4264. 'where' => 'rid=' . $rid,
  4265. 'asc' => 'rlid',
  4266. 'asArray' => true
  4267. ) );
  4268. }
  4269. // echo $rid;
  4270. // print_r($receiptList);
  4271. $receiptList [0] ['rlList'] = $rlList;
  4272. // print_r($receiptList);
  4273. $enclosurList = $enclosur->find ( array (
  4274. 'where' => 'rid=' . $rid,
  4275. 'asArray' => true
  4276. ) );
  4277. $enclosurHtml = '';
  4278. foreach ( $enclosurList as $value ) {
  4279. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4280. }
  4281. $data ['enclosurHtml'] = $enclosurHtml;
  4282. $data ['rolename'] = $rolename ['name'];
  4283. // $data['datetij']=$tijdate['date'];
  4284. $data ['mothHtml'] = $mothHtml;
  4285. // print_r($receiptList);
  4286. $data ['rid'] = $rid;
  4287. $data ['tijdate'] = $tijdate ['date'];
  4288. $data ['receiptList'] = $receiptList;
  4289. $data ['receiptApprovalCount'] = count ( $receiptList );
  4290. $data ['status'] = $status;
  4291. $data ['year'] = $year;
  4292. $data ['categoryList'] = $categoryList;
  4293. $data ['staffList'] = $staffList;
  4294. $data ['cid'] = $cid;
  4295. $data ['sid'] = $sid;
  4296. $data ['ap'] = $ap;
  4297. $data ['memu'] = "receipt";
  4298. $data ['staff'] = $this->staff;
  4299. $data ['receiptMemu'] = 'approvalExpenses';
  4300. $data ['verifyId'] = $this->verifyId;
  4301. $data ['executeId'] = $this->executeId;
  4302. $this->render ( "/admin/receiptburEdi", $data );
  4303. }
  4304. function hisImplement() {
  4305. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4306. if (empty ( $item ))
  4307. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4308. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4309. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  4310. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  4311. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  4312. Doo::loadModel ( 'receipt' );
  4313. $receipt = new receipt ();
  4314. Doo::loadModel ( 'L_category' );
  4315. $Lcategory = new L_category ();
  4316. Doo::loadModel ( 'verify' );
  4317. Doo::loadModel ( 'statistics' );
  4318. $statistics = new statistics ();
  4319. $verify = new verify ();
  4320. Doo::loadModel ( 'staff' );
  4321. $staff = new staff ();
  4322. Doo::loadClass ( 'XDeode' );
  4323. $XDeode = new XDeode ( 5 );
  4324. $condition = "";
  4325. if ($item == "expenses")
  4326. $condition = " and Rtype=1 ";
  4327. elseif ($item == "receipts")
  4328. $condition = " and Rtype=0 ";
  4329. elseif ($item == "remits")
  4330. $condition = " and Rtype=2 ";
  4331. $sopString = "";
  4332. $dateCondition = " and Year(date) =" . $year;
  4333. if ($sop != 'SOP')
  4334. $sopString = " and staff=" . $sop;
  4335. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  4336. if ($item == 'teipts') {
  4337. $statusCon = '(status=1 or status=6 )';
  4338. $dateCondition = " and Year(pastDate) =" . $year;
  4339. if ($moth != 'MONTH')
  4340. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth;
  4341. if ($day != 'DAY')
  4342. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth . " and day(pastDate)=" . $day;
  4343. } elseif ($item == 'alerpts') {
  4344. $statusCon = '(status=8 or status=9 )';
  4345. $dateCondition = " and Year(executeDate) =" . $year;
  4346. if ($moth != 'MONTH')
  4347. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  4348. if ($day != 'DAY')
  4349. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  4350. }
  4351. // $noPassSum=$receipt->receiptByYear($year,$this->staff[0]['sid']); and (status=1 or status=6)
  4352. $receiptList = $receipt->find ( array (
  4353. 'where' => $statusCon . $condition . $dateCondition . $sopString,
  4354. 'desc' => 'rid',
  4355. 'asArray' => true
  4356. ) );
  4357. // 员工筛选
  4358. $receiptList2 = $receipt->find ( array (
  4359. 'where' => $statusCon . $condition . $dateCondition,
  4360. 'desc' => 'rid',
  4361. 'asArray' => true
  4362. ) );
  4363. $sopStaff = array ();
  4364. foreach ( $receiptList2 as $key => $value ) {
  4365. $staffDetail = $staff->getOne ( array (
  4366. 'where' => 'sid=' . $value ['staff'],
  4367. 'asArray' => true
  4368. ) );
  4369. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  4370. }
  4371. $Locate = 0;
  4372. $roleId = 0;
  4373. $button = 0;
  4374. foreach ( $receiptList as $key => $value ) {
  4375. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4376. $receiptList [$key] ['Texe'] = 'false';
  4377. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  4378. $receiptList [$key] ['Texe'] = 'true';
  4379. }
  4380. $receiptList [$key] ['TRexe'] = 'true';
  4381. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  4382. $receiptList [$key] ['TRexe'] = 'false';
  4383. }
  4384. $receiptList [$key] ['Locate'] = $Locate;
  4385. $Locate ++;
  4386. $receiptList [$key] ['reviseDetail'] = array ();
  4387. if (! empty ( $value ['reviseDetail'] ))
  4388. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4389. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4390. $categoryDetil = $Lcategory->getOne ( array (
  4391. 'where' => 'cid=' . $value ['cid'],
  4392. 'asArray' => true
  4393. ) );
  4394. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4395. // 检测编辑状态
  4396. $verifyList = $verify->getOne ( array (
  4397. 'where' => 'vid=' . $value ['verify'],
  4398. 'asArray' => true
  4399. ) );
  4400. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4401. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4402. Doo::loadModel ( 'role' );
  4403. $role = new role ();
  4404. $flag = true;
  4405. $roleKey = 0;
  4406. $endStaffArray = array ();
  4407. $roleArrayCopy = array ();
  4408. foreach ( $verifyList as $k => $v ) {
  4409. // init verifyStaff
  4410. if ($v [1] == 'ROLE') {
  4411. if (! empty ( $verifyStaff )) {
  4412. $endStaffArray = end ( $verifyStaff );
  4413. }
  4414. $roleVerify = json_decode ( $v [3], true );
  4415. $roleKey = $k;
  4416. $roleArray = array ();
  4417. $rolename = $role->getOne ( array (
  4418. 'where' => 'rid=' . $v [0],
  4419. 'asArray' => true
  4420. ) );
  4421. foreach ( $roleVerify as $o => $p ) {
  4422. $staffID = explode ( '_', $p );
  4423. $staffInfo = $staff->getOne ( array (
  4424. 'where' => 'sid=' . $staffID [0],
  4425. 'asArray' => true
  4426. ) );
  4427. $exp = array (
  4428. 0 => $staffInfo ['sid'],
  4429. 1 => $staffID [1],
  4430. 2 => $staffInfo ['avatar'],
  4431. 'date' => '',
  4432. 'date' => '',
  4433. 'opinion' => '',
  4434. 'status' => '',
  4435. 'rolename' => $rolename ['name']
  4436. );
  4437. array_push ( $roleArray, $exp );
  4438. }
  4439. $roleArrayCopy [$v [0]] = $roleArray;
  4440. }
  4441. $verifyList [$k] ['date'] = "";
  4442. $verifyList [$k] ['opinion'] = "";
  4443. $verifyList [$k] ['status'] = "";
  4444. if (empty ( $verifyStaff )) {
  4445. $verifyList [$k] ['date'] = "";
  4446. $verifyList [$k] ['opinion'] = "";
  4447. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4448. $verifyList [$k] ['status'] = 4;
  4449. $flag = false;
  4450. }
  4451. } else {
  4452. foreach ( $verifyStaff as $m => $u ) {
  4453. if ($v [0] == $m) {
  4454. $verifyList [$k] ['date'] = $u ['date'];
  4455. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4456. $verifyList [$k] ['status'] = $u ['status'];
  4457. $flag = false;
  4458. break;
  4459. }
  4460. }
  4461. $endStaffArray = end ( $verifyStaff );
  4462. }
  4463. }
  4464. $rolename ['name'] = '';
  4465. if (! empty ( $roleId )) {
  4466. Doo::loadModel ( 'role' );
  4467. $role = new role ();
  4468. $rolename = $role->getOne ( array (
  4469. 'where' => 'rid=' . $roleId,
  4470. 'asArray' => true
  4471. ) );
  4472. }
  4473. if (! empty ( $verifyStaff ))
  4474. $endStaffArray = end ( $verifyStaff );
  4475. $KOP = false;
  4476. foreach ( $roleArrayCopy as $P => $A ) {
  4477. foreach ( $A as $MKI => $AVL ) {
  4478. if (! empty ( $verifyStaff )) {
  4479. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4480. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4481. $button = 4;
  4482. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4483. }
  4484. foreach ( $verifyStaff as $m => $u ) {
  4485. $AVLFK = $AVL [0] . '_R';
  4486. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4487. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4488. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4489. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4490. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4491. break;
  4492. }
  4493. }
  4494. } else {
  4495. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4496. $button = 4;
  4497. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4498. }
  4499. }
  4500. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4501. $KOP = true;
  4502. }
  4503. }
  4504. foreach ( $roleArrayCopy as $k => $v ) {
  4505. foreach ( $verifyList as $m => $n ) {
  4506. if ($n [0] == $k) {
  4507. array_splice ( $verifyList, $m, 1, $v );
  4508. }
  4509. }
  4510. }
  4511. $receiptList [$key] ['verifyList'] = $verifyList;
  4512. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4513. 'where' => 'sid=' . $value ['staff'],
  4514. 'asArray' => true
  4515. ) );
  4516. $receiptList [$key] ['button'] = $button;
  4517. }
  4518. // print_r($receiptList);
  4519. $mothHtml = "";
  4520. for($i = 1; $i <= 12; $i ++) {
  4521. if ($moth == $i)
  4522. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4523. else
  4524. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4525. }
  4526. $dayHtml = "";
  4527. if ($day != "DAY" || $moth != "MONTH") {
  4528. for($i = 1; $i <= 31; $i ++) {
  4529. if ($day == $i)
  4530. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  4531. else
  4532. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  4533. }
  4534. }
  4535. $sopHtml = "";
  4536. foreach ( $sopStaff as $key => $value ) {
  4537. if ($sop == $key)
  4538. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4539. else
  4540. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4541. }
  4542. $data ['sopHtml'] = $sopHtml;
  4543. $data ['dayHtml'] = $dayHtml;
  4544. $data ['mothHtml'] = $mothHtml;
  4545. $data ['receiptList'] = $receiptList;
  4546. $data ['memu'] = "receipt";
  4547. $data ['staff'] = $this->staff;
  4548. $data ['receiptMemu'] = 'implement';
  4549. $data ['verifyId'] = $this->verifyId;
  4550. $data ['executeId'] = $this->executeId;
  4551. $data ['item'] = $item;
  4552. $data ['year'] = $year;
  4553. $data ['moth'] = $moth;
  4554. $data ['day'] = $day;
  4555. $data ['sop'] = $sop;
  4556. $this->render ( "/admin/hisImplement", $data );
  4557. }
  4558. function ajaxExamine() {
  4559. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4560. Doo::loadModel ( 'receipt' );
  4561. $receipt = new receipt ();
  4562. if (! empty ( $rid )) {
  4563. $rLRes = $receipt->find ( array (
  4564. '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,
  4565. 'asArray' => true
  4566. ) );
  4567. echo json_encode ( array (
  4568. 'status' => 1,
  4569. 'receipt' => $rLRes [0]
  4570. ) );
  4571. die ();
  4572. }
  4573. echo json_encode ( array (
  4574. 'status' => 0,
  4575. 'receipt' => array ()
  4576. ) );
  4577. die ();
  4578. }
  4579. /*
  4580. * 废弃
  4581. */
  4582. function myReceipt() {
  4583. // all approval past withdraw
  4584. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4585. if (empty ( $item ))
  4586. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4587. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4588. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  4589. Doo::loadModel ( 'receipt' );
  4590. $receipt = new receipt ();
  4591. // pre-loaded
  4592. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4593. // have cache
  4594. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  4595. if (! empty ( $moth )) // yearPage
  4596. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  4597. $this->showCache ( $path );
  4598. }
  4599. Doo::loadModel ( 'L_category' );
  4600. $Lcategory = new L_category ();
  4601. Doo::loadModel ( 'verify' );
  4602. Doo::loadModel ( 'statistics' );
  4603. $statistics = new statistics ();
  4604. $verify = new verify ();
  4605. Doo::loadModel ( 'staff' );
  4606. $staff = new staff ();
  4607. $condition = " and status!=0 ";
  4608. if ($item == "approval")
  4609. $condition = " and status=2 ";
  4610. elseif ($item == "withdraw")
  4611. $condition = " and status=3 ";
  4612. elseif ($item == "past")
  4613. $condition = " and status=1 ";
  4614. elseif ($item == "whdw")
  4615. $condition = " and status=4 ";
  4616. $dateCondition = " and Year(date) =" . $year;
  4617. if (! empty ( $moth )) {
  4618. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  4619. $stList = $statistics->getOne ( array (
  4620. 'select' => 'rePrice ,agPrice',
  4621. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  4622. 'asArray' => true
  4623. ) );
  4624. } else
  4625. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  4626. if (empty ( $stList ))
  4627. $stList = array (
  4628. 'rePrice' => 0,
  4629. 'agPrice' => 0
  4630. );
  4631. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  4632. $data ['stList'] = array (
  4633. 'rePrice' => $stList ['rePrice'],
  4634. 'agPrice' => $stList ['agPrice'],
  4635. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  4636. );
  4637. $receiptList = $receipt->find ( array (
  4638. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  4639. 'desc' => 'rid',
  4640. 'asArray' => true
  4641. ) );
  4642. $Locate = 0;
  4643. $roleId = 0;
  4644. $button = 0;
  4645. foreach ( $receiptList as $key => $value ) {
  4646. $receiptList [$key] ['Locate'] = $Locate;
  4647. $Locate ++;
  4648. $receiptList [$key] ['reviseDetail'] = array ();
  4649. if (! empty ( $value ['reviseDetail'] ))
  4650. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4651. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4652. $categoryDetil = $Lcategory->getOne ( array (
  4653. 'where' => 'cid=' . $value ['cid'],
  4654. 'asArray' => true
  4655. ) );
  4656. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4657. // 检测编辑状态
  4658. $verifyList = $verify->getOne ( array (
  4659. 'where' => 'vid=' . $value ['verify'],
  4660. 'asArray' => true
  4661. ) );
  4662. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4663. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4664. Doo::loadModel ( 'role' );
  4665. $role = new role ();
  4666. $flag = true;
  4667. $roleKey = 0;
  4668. $endStaffArray = array ();
  4669. $roleArrayCopy = array ();
  4670. foreach ( $verifyList as $k => $v ) {
  4671. // init verifyStaff
  4672. if ($v [1] == 'ROLE') {
  4673. if (! empty ( $verifyStaff )) {
  4674. $endStaffArray = end ( $verifyStaff );
  4675. // if ($v[0]==$endStaffArray['nextStaff']){
  4676. // $roleId=$v[0];
  4677. // }
  4678. }
  4679. $roleVerify = json_decode ( $v [3], true );
  4680. $roleKey = $k;
  4681. $roleArray = array ();
  4682. $rolename = $role->getOne ( array (
  4683. 'where' => 'rid=' . $v [0],
  4684. 'asArray' => true
  4685. ) );
  4686. foreach ( $roleVerify as $o => $p ) {
  4687. $staffID = explode ( '_', $p );
  4688. $staffInfo = $staff->getOne ( array (
  4689. 'where' => 'sid=' . $staffID [0],
  4690. 'asArray' => true
  4691. ) );
  4692. // print_r($staffID);
  4693. $exp = array (
  4694. 0 => $staffInfo ['sid'],
  4695. 1 => $staffID [1],
  4696. 2 => $staffInfo ['avatar'],
  4697. 'date' => '',
  4698. 'date' => '',
  4699. 'opinion' => '',
  4700. 'status' => '',
  4701. 'rolename' => $rolename ['name']
  4702. );
  4703. array_push ( $roleArray, $exp );
  4704. }
  4705. $roleArrayCopy [$v [0]] = $roleArray;
  4706. // $verifyList[$k]['roleArray']=$roleArray;
  4707. }
  4708. $verifyList [$k] ['date'] = "";
  4709. $verifyList [$k] ['opinion'] = "";
  4710. $verifyList [$k] ['status'] = "";
  4711. if (empty ( $verifyStaff )) {
  4712. $verifyList [$k] ['date'] = "";
  4713. $verifyList [$k] ['opinion'] = "";
  4714. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4715. $verifyList [$k] ['status'] = 4;
  4716. $flag = false;
  4717. }
  4718. } else {
  4719. foreach ( $verifyStaff as $m => $u ) {
  4720. if ($v [0] == $m) {
  4721. $verifyList [$k] ['date'] = $u ['date'];
  4722. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4723. $verifyList [$k] ['status'] = $u ['status'];
  4724. $flag = false;
  4725. break;
  4726. }
  4727. }
  4728. $endStaffArray = end ( $verifyStaff );
  4729. if (isset ( $endStaffArray ['ROLE'] )) {
  4730. } else {
  4731. // $endKey=key($verifyStaff);
  4732. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4733. // $button=4;
  4734. // $verifyList[$k]['status']=4;
  4735. // }
  4736. }
  4737. }
  4738. }
  4739. $rolename ['name'] = '';
  4740. if (! empty ( $roleId )) {
  4741. Doo::loadModel ( 'role' );
  4742. $role = new role ();
  4743. $rolename = $role->getOne ( array (
  4744. 'where' => 'rid=' . $roleId,
  4745. 'asArray' => true
  4746. ) );
  4747. }
  4748. if (! empty ( $verifyStaff ))
  4749. $endStaffArray = end ( $verifyStaff );
  4750. $KOP = false;
  4751. foreach ( $roleArrayCopy as $P => $A ) {
  4752. foreach ( $A as $MKI => $AVL ) {
  4753. if (! empty ( $verifyStaff )) {
  4754. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4755. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4756. $button = 4;
  4757. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4758. }
  4759. foreach ( $verifyStaff as $m => $u ) {
  4760. $AVLFK = $AVL [0] . '_R';
  4761. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4762. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4763. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4764. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4765. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4766. break;
  4767. }
  4768. }
  4769. } else {
  4770. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4771. $button = 4;
  4772. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4773. }
  4774. }
  4775. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4776. $KOP = true;
  4777. }
  4778. }
  4779. foreach ( $roleArrayCopy as $k => $v ) {
  4780. foreach ( $verifyList as $m => $n ) {
  4781. if ($n [0] == $k) {
  4782. array_splice ( $verifyList, $m, 1, $v );
  4783. }
  4784. }
  4785. }
  4786. $receiptList [$key] ['verifyList'] = $verifyList;
  4787. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4788. 'where' => 'sid=' . $value ['staff'],
  4789. 'asArray' => true
  4790. ) );
  4791. $receiptList [$key] ['button'] = $button;
  4792. }
  4793. // print_r($receiptList);die;
  4794. $mothHtml = "";
  4795. for($i = 1; $i <= 12; $i ++) {
  4796. if ($moth == $i)
  4797. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4798. else
  4799. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4800. }
  4801. $data ['mothHtml'] = $mothHtml;
  4802. $data ['receiptList'] = $receiptList;
  4803. $data ['memu'] = "receipt";
  4804. $data ['staff'] = $this->staff;
  4805. $data ['receiptMemu'] = 'receipt';
  4806. $data ['verifyId'] = $this->verifyId;
  4807. $data ['executeId'] = $this->executeId;
  4808. $data ['item'] = $item;
  4809. $data ['year'] = $year;
  4810. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4811. // sufficient condition to generate cache
  4812. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  4813. $receiptList = $receipt->find ( array (
  4814. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  4815. 'asArray' => true
  4816. ) );
  4817. if (empty ( $receiptList )) { // generated files
  4818. ob_start ();
  4819. $this->render ( "/admin/saea_myList", $data );
  4820. $this->cacheFile ( $path );
  4821. die ();
  4822. // $content = ob_get_contents();
  4823. // $fp = fopen($path, "w");
  4824. // fwrite($fp, $content);
  4825. // fclose($fp);
  4826. }
  4827. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  4828. $receiptList = $receipt->find ( array (
  4829. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  4830. 'asArray' => true
  4831. ) );
  4832. if (empty ( $receiptList )) { // generated files
  4833. ob_start ();
  4834. $this->render ( "/admin/saea_myList", $data );
  4835. $this->cacheFile ( $path );
  4836. die ();
  4837. }
  4838. }
  4839. }
  4840. $this->render ( "/admin/saea_myList", $data );
  4841. }
  4842. function saeaCreate() {
  4843. Doo::loadModel ( 'accountItem' );
  4844. Doo::loadModel ( 'verify' );
  4845. Doo::loadModel ( 'receipt' );
  4846. Doo::loadModel ( 'L_category' );
  4847. $lCategory = new L_category ();
  4848. $receipt = new receipt ();
  4849. $verify = new verify ();
  4850. $accountItem = new accountItem ();
  4851. Doo::loadModel ( "role" );
  4852. $role = new role ();
  4853. $acItem = $accountItem->find ( array (
  4854. 'asArray' => true
  4855. ) );
  4856. $veList = $verify->find ( array (
  4857. 'asArray' => true
  4858. ) );
  4859. foreach ( $veList as $key => $value ) {
  4860. $v = json_decode ( $value ['staff'] );
  4861. $list = array ();
  4862. foreach ( $v as $n => $m ) {
  4863. if ($m ['1'] == 'ROLE') {
  4864. $roleInfo = $role->getOne ( array (
  4865. 'where' => 'rid=' . $m [0],
  4866. 'asArray' => true
  4867. ) );
  4868. $v [$n] [1] = $roleInfo ['name'];
  4869. array_push ( $list, $roleInfo ['name'] );
  4870. } else {
  4871. array_push ( $list, $v [$n] [1] );
  4872. }
  4873. }
  4874. $veList [$key] ['staff'] = implode ( '>', $list );
  4875. }
  4876. $data ['category'] = $lCategory->find ( array (
  4877. 'asArray' => true
  4878. ) );
  4879. $data ['veList'] = $veList;
  4880. $data ['acItem'] = $acItem;
  4881. $data ['memu'] = "receipt";
  4882. $data ['staff'] = $this->staff;
  4883. $data ['receiptMemu'] = 'saeaBorad';
  4884. $data ['verifyId'] = $this->verifyId;
  4885. $data ['executeId'] = $this->executeId;
  4886. $this->render ( "/admin/saea_create", $data );
  4887. }
  4888. function addReceipt() {
  4889. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  4890. $agency = $this->get_args ( 'agency' );
  4891. $travel = $this->get_args ( 'travel' );
  4892. $train = $this->get_args ( 'train' );
  4893. $other = $this->get_args ( 'other' );
  4894. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  4895. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  4896. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  4897. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  4898. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  4899. Doo::loadModel ( 'receipt' );
  4900. Doo::loadModel ( 'receiptDetail' );
  4901. Doo::loadModel ( 'accountItem' );
  4902. $accountItem = new accountItem ();
  4903. $receipt = new receipt ();
  4904. Doo::loadModel ( 'enclosur' );
  4905. Doo::loadModel ( 'execute' );
  4906. $execute = new execute ();
  4907. $executeDetail = $execute->getOne ( array (
  4908. 'where' => 'mold="报销单执行人"',
  4909. 'asArray' => true
  4910. ) );
  4911. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  4912. // if(!empty($receiptDetail))
  4913. // return "/referReceipt/".$receiptDetail['rid'];
  4914. $aItem = $accountItem->find ( array (
  4915. 'asArray' => true
  4916. ) );
  4917. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  4918. $ag = $tr = $ta = $ot = 0;
  4919. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  4920. foreach ( $aItem as $key => $value ) {
  4921. if ($value ['category'] == $this->AGENCY) {
  4922. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  4923. array_push ( $accountJson [$this->AGENCY], array (
  4924. 'aid' => $value ['aid'],
  4925. 'name' => $value ['name'],
  4926. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  4927. ) );
  4928. $sum += $agency [$ag];
  4929. $agencySum += $agency [$ag];
  4930. }
  4931. $ag ++;
  4932. }
  4933. if ($value ['category'] == $this->TRAVEL) {
  4934. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  4935. array_push ( $accountJson [$this->TRAVEL], array (
  4936. 'aid' => $value ['aid'],
  4937. 'name' => $value ['name'],
  4938. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  4939. ) );
  4940. $sum += $travel [$tr];
  4941. $travelSum += $travel [$tr];
  4942. }
  4943. $tr ++;
  4944. }
  4945. if ($value ['category'] == $this->TRAIN) {
  4946. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  4947. array_push ( $accountJson [$this->TRAIN], array (
  4948. 'aid' => $value ['aid'],
  4949. 'name' => $value ['name'],
  4950. 'price' => number_format ( $train [$ta], 2, '.', '' )
  4951. ) );
  4952. $sum += $train [$ta];
  4953. $trainSum += $train [$ta];
  4954. }
  4955. $ta ++;
  4956. }
  4957. if ($value ['category'] == $this->OTHER) {
  4958. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  4959. array_push ( $accountJson [$this->OTHER], array (
  4960. 'aid' => $value ['aid'],
  4961. 'name' => $value ['name'],
  4962. 'price' => number_format ( $other [$ot], 2, '.', '' )
  4963. ) );
  4964. $sum += $other [$ot];
  4965. $otherSum += $other [$ot];
  4966. }
  4967. $ot ++;
  4968. }
  4969. }
  4970. $accountJson ['cSum'] = array (
  4971. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  4972. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  4973. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  4974. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  4975. );
  4976. // 报销单
  4977. $receipt->accountItem = json_encode ( $accountJson );
  4978. $receipt->staff = $this->staff [0] ['sid'];
  4979. $receipt->sum = number_format ( $sum, 2, '.', '' );
  4980. $receipt->date = date ( "Y-m-d" );
  4981. $receipt->cid = $cid;
  4982. $receipt->status = 5;
  4983. // 修改审批流程加入角色
  4984. $receipt->verify = $verify;
  4985. $receipt->executeCopy = $executeDetail ['staff'];
  4986. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  4987. $receipt->explanation = $explanation;
  4988. $rid = $receipt->insert ();
  4989. // 附件
  4990. if (! empty ( $enclosurName )) {
  4991. $enclosurArray = explode ( '-', $enclosurName );
  4992. foreach ( $enclosurArray as $value ) {
  4993. $enclosur = new enclosur ();
  4994. $enclosur->name = $value;
  4995. $enclosur->rid = $rid;
  4996. $enclosur->insert ();
  4997. }
  4998. // print_r($enclosurArray);die;
  4999. }
  5000. // 报销详情
  5001. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5002. $receiptDetail = new receiptDetail ();
  5003. $receiptDetail->staff = $this->staff [0] ['sid'];
  5004. $receiptDetail->item = $value ['name'];
  5005. $receiptDetail->itemCategory = $this->AGENCY;
  5006. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5007. $receiptDetail->date = date ( "Y-m-d" );
  5008. $receiptDetail->cid = $cid;
  5009. $receiptDetail->rid = $rid;
  5010. $receiptDetail->status = 4;
  5011. $receiptDetail->insert ();
  5012. }
  5013. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5014. $receiptDetail = new receiptDetail ();
  5015. $receiptDetail->staff = $this->staff [0] ['sid'];
  5016. $receiptDetail->item = $value ['name'];
  5017. $receiptDetail->itemCategory = $this->TRAVEL;
  5018. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5019. $receiptDetail->date = date ( "Y-m-d" );
  5020. $receiptDetail->cid = $cid;
  5021. $receiptDetail->rid = $rid;
  5022. $receiptDetail->status = 4;
  5023. $receiptDetail->insert ();
  5024. }
  5025. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5026. $receiptDetail = new receiptDetail ();
  5027. $receiptDetail->staff = $this->staff [0] ['sid'];
  5028. $receiptDetail->item = $value ['name'];
  5029. $receiptDetail->itemCategory = $this->TRAIN;
  5030. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5031. $receiptDetail->date = date ( "Y-m-d" );
  5032. $receiptDetail->cid = $cid;
  5033. $receiptDetail->rid = $rid;
  5034. $receiptDetail->status = 4;
  5035. $receiptDetail->insert ();
  5036. }
  5037. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5038. $receiptDetail = new receiptDetail ();
  5039. $receiptDetail->staff = $this->staff [0] ['sid'];
  5040. $receiptDetail->item = $value ['name'];
  5041. $receiptDetail->itemCategory = $this->OTHER;
  5042. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5043. $receiptDetail->date = date ( "Y-m-d" );
  5044. $receiptDetail->cid = $cid;
  5045. $receiptDetail->rid = $rid;
  5046. $receiptDetail->status = 4;
  5047. $receiptDetail->insert ();
  5048. }
  5049. // return "/referReceipt/".$rid;
  5050. }
  5051. return "/saeaBorad";
  5052. }
  5053. function referReceipt() {
  5054. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  5055. Doo::loadModel ( 'receipt' );
  5056. Doo::loadModel ( 'verify' );
  5057. $verify = new verify ();
  5058. $receipt = new receipt ();
  5059. Doo::loadModel ( 'L_category' );
  5060. $lCategory = new L_category ();
  5061. Doo::loadModel ( "role" );
  5062. $role = new role ();
  5063. $receiptDetail = $receipt->find ( array (
  5064. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  5065. 'asArray' => true
  5066. ) );
  5067. if (empty ( $receiptDetail ))
  5068. return "/addReceipt";
  5069. foreach ( $receiptDetail as $key => $value ) {
  5070. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5071. $veList = $verify->getOne ( array (
  5072. 'where' => 'vid=' . $value ['verify'],
  5073. 'asArray' => true
  5074. ) );
  5075. $v = json_decode ( $veList ['staff'] );
  5076. array_push ( $v [0], $veList ['description'] );
  5077. foreach ( $v as $n => $m ) {
  5078. if ($m ['1'] == 'ROLE') {
  5079. $roleInfo = $role->getOne ( array (
  5080. 'where' => 'rid=' . $m [0],
  5081. 'asArray' => true
  5082. ) );
  5083. $v [$n] [1] = $roleInfo ['name'];
  5084. }
  5085. }
  5086. $receiptDetail [$key] ['staff'] = $v;
  5087. $category = $lCategory->getOne ( array (
  5088. 'where' => 'cid=' . $value ['cid'],
  5089. 'asArray' => true
  5090. ) );
  5091. $receiptDetail [$key] ['category'] = $category ['title'];
  5092. }
  5093. // print_r($receiptDetail);
  5094. $data ['receiptDetail'] = $receiptDetail;
  5095. $data ['memu'] = "receipt";
  5096. $data ['staff'] = $this->staff;
  5097. $data ['receiptMemu'] = 'saeaCreate';
  5098. $data ['verifyId'] = $this->verifyId;
  5099. $data ['executeId'] = $this->executeId;
  5100. $this->render ( "/admin/saea_confirm", $data );
  5101. }
  5102. function editReceipt() {
  5103. // edit status 4
  5104. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5105. // echo $rid;
  5106. Doo::loadModel ( 'accountItem' );
  5107. Doo::loadModel ( 'verify' );
  5108. Doo::loadModel ( 'receipt' );
  5109. $receipt = new receipt ();
  5110. $verify = new verify ();
  5111. $accountItem = new accountItem ();
  5112. Doo::loadModel ( 'L_category' );
  5113. $lCategory = new L_category ();
  5114. Doo::loadModel ( "role" );
  5115. $role = new role ();
  5116. $receiptDetail = $receipt->getOne ( array (
  5117. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  5118. 'asArray' => true
  5119. ) );
  5120. if (empty ( $receiptDetail ))
  5121. return "/saeaCreate";
  5122. $acItem = $accountItem->find ( array (
  5123. 'asArray' => true
  5124. ) );
  5125. $veList = $verify->find ( array (
  5126. 'asArray' => true
  5127. ) );
  5128. foreach ( $veList as $key => $value ) {
  5129. $v = json_decode ( $value ['staff'] );
  5130. $list = array ();
  5131. foreach ( $v as $n => $m ) {
  5132. if ($m ['1'] == 'ROLE') {
  5133. $roleInfo = $role->getOne ( array (
  5134. 'where' => 'rid=' . $m [0],
  5135. 'asArray' => true
  5136. ) );
  5137. $v [$n] [1] = $roleInfo ['name'];
  5138. array_push ( $list, $roleInfo ['name'] );
  5139. } else {
  5140. array_push ( $list, $v [$n] [1] );
  5141. }
  5142. }
  5143. $veList [$key] ['staff'] = implode ( '>', $list );
  5144. }
  5145. // 配置编辑信息
  5146. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  5147. foreach ( $acItem as $key => $value ) {
  5148. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  5149. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  5150. $acItem [$key] ['price'] = $v ['price'];
  5151. }
  5152. }
  5153. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  5154. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  5155. $acItem [$key] ['price'] = $v ['price'];
  5156. }
  5157. }
  5158. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  5159. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  5160. $acItem [$key] ['price'] = $v ['price'];
  5161. }
  5162. }
  5163. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  5164. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  5165. $acItem [$key] ['price'] = $v ['price'];
  5166. }
  5167. }
  5168. }
  5169. $data ['category'] = $lCategory->find ( array (
  5170. 'asArray' => true
  5171. ) );
  5172. $data ['cSum'] = $accountItemList ['cSum'];
  5173. $data ['sum'] = $receiptDetail ['sum'];
  5174. $data ['receiptDetail'] = $receiptDetail;
  5175. $data ['veList'] = $veList;
  5176. $data ['acItem'] = $acItem;
  5177. $data ['memu'] = "receipt";
  5178. $data ['staff'] = $this->staff;
  5179. $data ['receiptMemu'] = 'saeaBorad';
  5180. $data ['verify'] = $receiptDetail ['verify'];
  5181. $data ['verifyId'] = $this->verifyId;
  5182. $data ['executeId'] = $this->executeId;
  5183. $data ['rid'] = $rid;
  5184. $this->render ( "/admin/saea_edit", $data );
  5185. }
  5186. function updateReceipt() {
  5187. $agency = $this->get_args ( 'agency' );
  5188. $travel = $this->get_args ( 'travel' );
  5189. $train = $this->get_args ( 'train' );
  5190. $other = $this->get_args ( 'other' );
  5191. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5192. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5193. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5194. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5195. if (! empty ( $explanation )) {
  5196. Doo::loadModel ( 'receipt' );
  5197. Doo::loadModel ( 'receiptDetail' );
  5198. Doo::loadModel ( 'accountItem' );
  5199. $accountItem = new accountItem ();
  5200. $receipt = new receipt ();
  5201. Doo::loadModel ( 'execute' );
  5202. $execute = new execute ();
  5203. $receiptDetail = $receipt->getOne ( array (
  5204. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  5205. 'asArray' => true
  5206. ) );
  5207. if (empty ( $receiptDetail ))
  5208. return "/saeaBorad";
  5209. if ($receiptDetail ['Rtype'] == 1)
  5210. $executeDetail = $execute->getOne ( array (
  5211. 'where' => 'mold="借款费用执行人"',
  5212. 'asArray' => true
  5213. ) );
  5214. else
  5215. $executeDetail = $execute->getOne ( array (
  5216. 'where' => 'mold="报销单执行人"',
  5217. 'asArray' => true
  5218. ) );
  5219. $aItem = $accountItem->find ( array (
  5220. 'asArray' => true
  5221. ) );
  5222. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5223. $ag = $tr = $ta = $ot = 0;
  5224. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5225. foreach ( $aItem as $key => $value ) {
  5226. if ($value ['category'] == $this->AGENCY) {
  5227. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5228. array_push ( $accountJson [$this->AGENCY], array (
  5229. 'aid' => $value ['aid'],
  5230. 'name' => $value ['name'],
  5231. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5232. ) );
  5233. $sum += $agency [$ag];
  5234. $agencySum += $agency [$ag];
  5235. }
  5236. $ag ++;
  5237. }
  5238. if ($value ['category'] == $this->TRAVEL) {
  5239. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5240. array_push ( $accountJson [$this->TRAVEL], array (
  5241. 'aid' => $value ['aid'],
  5242. 'name' => $value ['name'],
  5243. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5244. ) );
  5245. $sum += $travel [$tr];
  5246. $travelSum += $travel [$tr];
  5247. }
  5248. $tr ++;
  5249. }
  5250. if ($value ['category'] == $this->TRAIN) {
  5251. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5252. array_push ( $accountJson [$this->TRAIN], array (
  5253. 'aid' => $value ['aid'],
  5254. 'name' => $value ['name'],
  5255. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5256. ) );
  5257. $sum += $train [$ta];
  5258. $trainSum += $train [$ta];
  5259. }
  5260. $ta ++;
  5261. }
  5262. if ($value ['category'] == $this->OTHER) {
  5263. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5264. array_push ( $accountJson [$this->OTHER], array (
  5265. 'aid' => $value ['aid'],
  5266. 'name' => $value ['name'],
  5267. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5268. ) );
  5269. $sum += $other [$ot];
  5270. $otherSum += $other [$ot];
  5271. }
  5272. $ot ++;
  5273. }
  5274. }
  5275. $accountJson ['cSum'] = array (
  5276. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5277. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5278. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5279. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5280. );
  5281. // 报销单
  5282. $rid = $receipt->rid = $receiptDetail ['rid'];
  5283. $receipt->accountItem = json_encode ( $accountJson );
  5284. $receipt->staff = $this->staff [0] ['sid'];
  5285. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5286. $receipt->date = date ( "Y-m-d" );
  5287. $receipt->cid = $cid;
  5288. if (($receiptDetail ['status'] != 4)) {
  5289. if ($receiptDetail ['Rtype'] == 1)
  5290. $receipt->status = 7;
  5291. else
  5292. $receipt->status = 5;
  5293. }
  5294. if ($receiptDetail != 4 && ! empty ( $verify ))
  5295. $receipt->verify = $verify;
  5296. $receipt->executeCopy = $executeDetail ['staff'];
  5297. $receipt->explanation = $explanation;
  5298. $receipt->update ();
  5299. $receiptDetail = new receiptDetail ();
  5300. $receiptDetail->delete ( array (
  5301. 'where' => 'rid=' . $rid
  5302. ) );
  5303. // 报销详情
  5304. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5305. $receiptDetail = new receiptDetail ();
  5306. $receiptDetail->staff = $this->staff [0] ['sid'];
  5307. $receiptDetail->item = $value ['name'];
  5308. $receiptDetail->itemCategory = $this->AGENCY;
  5309. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5310. $receiptDetail->date = date ( "Y-m-d" );
  5311. $receiptDetail->cid = $cid;
  5312. $receiptDetail->rid = $rid;
  5313. $receiptDetail->status = 4;
  5314. $receiptDetail->insert ();
  5315. }
  5316. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5317. $receiptDetail = new receiptDetail ();
  5318. $receiptDetail->staff = $this->staff [0] ['sid'];
  5319. $receiptDetail->item = $value ['name'];
  5320. $receiptDetail->itemCategory = $this->TRAVEL;
  5321. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5322. $receiptDetail->date = date ( "Y-m-d" );
  5323. $receiptDetail->cid = $cid;
  5324. $receiptDetail->rid = $rid;
  5325. $receiptDetail->status = 4;
  5326. $receiptDetail->insert ();
  5327. }
  5328. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5329. $receiptDetail = new receiptDetail ();
  5330. $receiptDetail->staff = $this->staff [0] ['sid'];
  5331. $receiptDetail->item = $value ['name'];
  5332. $receiptDetail->itemCategory = $this->TRAIN;
  5333. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5334. $receiptDetail->date = date ( "Y-m-d" );
  5335. $receiptDetail->cid = $cid;
  5336. $receiptDetail->rid = $rid;
  5337. $receiptDetail->status = 4;
  5338. $receiptDetail->insert ();
  5339. }
  5340. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5341. $receiptDetail = new receiptDetail ();
  5342. $receiptDetail->staff = $this->staff [0] ['sid'];
  5343. $receiptDetail->item = $value ['name'];
  5344. $receiptDetail->itemCategory = $this->OTHER;
  5345. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5346. $receiptDetail->date = date ( "Y-m-d" );
  5347. $receiptDetail->cid = $cid;
  5348. $receiptDetail->rid = $rid;
  5349. $receiptDetail->status = 4;
  5350. $receiptDetail->insert ();
  5351. }
  5352. // return "/referReceipt/".$rid;
  5353. }
  5354. return "/saeaBorad";
  5355. }
  5356. function approvedReceipt() {
  5357. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5358. Doo::loadModel ( 'receipt' );
  5359. Doo::loadModel ( 'receiptDetail' );
  5360. $receipt = new receipt ();
  5361. $receiptDetail = new receiptDetail ();
  5362. Doo::loadModel ( 'statistics' );
  5363. Doo::loadModel ( 'itemStatistics' );
  5364. $statistics = new statistics ();
  5365. $itemStatistics = new itemStatistics ();
  5366. Doo::loadModel ( "verify" );
  5367. $verify = new verify ();
  5368. // 审批状态的判定
  5369. $receiptDetailList = $receipt->getOne ( array (
  5370. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  5371. 'asArray' => true
  5372. ) );
  5373. if (empty ( $receiptDetailList ))
  5374. return "/saeaBorad";
  5375. $verifyDetail = $verify->getOne ( array (
  5376. 'where' => ' vid =' . $receiptDetailList ['verify'],
  5377. 'asArray' => true
  5378. ) );
  5379. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5380. if (empty ( $receiptDetailList ['nowStaff'] )) {
  5381. $nowStaff = "";
  5382. $nowStaffList = array ();
  5383. if ($verifyDetail [0] [1] == 'ROLE') {
  5384. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5385. foreach ( $vStaffString as $key => $value ) {
  5386. $staffK = explode ( "_", $value );
  5387. array_push ( $nowStaffList, $staffK [0] );
  5388. }
  5389. $nowStaff = implode ( ',', $nowStaffList );
  5390. } else {
  5391. $nowStaff = $verifyDetail [0] [0];
  5392. }
  5393. $receipt->nowStaff = $nowStaff;
  5394. }
  5395. // echo $nowStaff;
  5396. // print_r($verifyDetail);die;
  5397. $receipt->rid = $receiptDetailList ['rid'];
  5398. $receipt->date = date ( "Y-m-d" );
  5399. $receipt->status = 2;
  5400. $receipt->update ();
  5401. $receiptDetail->status = 2;
  5402. $receiptDetail->update ( array (
  5403. 'where' => 'rid=' . $receiptDetailList ['rid']
  5404. ) );
  5405. Doo::loadModel ( "receiptLog" );
  5406. $receiptLog = new receiptLog ();
  5407. Doo::loadModel ( "verify" );
  5408. $verify = new verify ();
  5409. $receiptInfo = $receipt->getOne ( array (
  5410. 'where' => 'rid=' . $rid,
  5411. 'asArray' => true
  5412. ) );
  5413. $vr = $verify->getOne ( array (
  5414. 'where' => 'vid=' . $receiptInfo ['verify'],
  5415. 'asArray' => true
  5416. ) );
  5417. $jd = json_decode ( $vr ['staff'] );
  5418. $roleId = 0;
  5419. foreach ( $jd as $key => $value ) {
  5420. if ($value [1] == 'ROLE') {
  5421. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  5422. if ($pos !== false) {
  5423. $roleId = $value [0];
  5424. }
  5425. }
  5426. }
  5427. // 审批日志
  5428. // echo $roleId;die;
  5429. if (! empty ( $roleId )) {
  5430. Doo::loadModel ( "role" );
  5431. $role = new role ();
  5432. $roleInfo = $role->getOne ( array (
  5433. 'where' => 'rid=' . $roleId,
  5434. 'asArray' => true
  5435. ) );
  5436. $receiptLog->rolename = $roleInfo ['name'];
  5437. }
  5438. $receiptLog->username = $this->staff [0] ['username'];
  5439. $receiptLog->uid = $this->staff [0] ['sid'];
  5440. $receiptLog->date = date ( "Y-m-d" );
  5441. $receiptLog->opinion = '提交审批';
  5442. $receiptLog->img = $this->staff [0] ['avatar'];
  5443. $receiptLog->status = 2;
  5444. $receiptLog->rid = $rid;
  5445. $receiptLog->insert ();
  5446. // statistics item
  5447. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  5448. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  5449. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  5450. // print_r($accountItem['cSum']['agencySum']);die;
  5451. // foreach ($accountItem['cSum'] as $key=>$value){
  5452. // if($key=="agencySum"){
  5453. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->AGENCY.'"'.$dateCondition,'asArray'=>true));
  5454. // if(empty($iStatistics)){
  5455. // $itemStatistics->cid=$this->staff[0]['cid'];
  5456. // $itemStatistics->staff=$this->staff[0]['sid'];
  5457. // $itemStatistics->price=$value;
  5458. // $itemStatistics->itemCategory=$this->AGENCY;
  5459. // $itemStatistics->date=date("Y-m-d");
  5460. // $itemStatistics->insert();
  5461. // }else{
  5462. // if (!empty($value)){
  5463. // $itemStatistics->price=$value+$iStatistics['price'];
  5464. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5465. // }
  5466. // }
  5467. // }elseif($key=="travelSum"){
  5468. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->TRAVEL.'"'.$dateCondition,'asArray'=>true));
  5469. // if(empty($iStatistics)){
  5470. // $itemStatistics->cid=$this->staff[0]['cid'];
  5471. // $itemStatistics->staff=$this->staff[0]['sid'];
  5472. // $itemStatistics->price=$value;
  5473. // $itemStatistics->itemCategory=$this->TRAVEL;
  5474. // $itemStatistics->date=date("Y-m-d");
  5475. // $itemStatistics->insert();
  5476. // }else{
  5477. // if (!empty($value)){
  5478. // $itemStatistics->price=$value+$iStatistics['price'];
  5479. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5480. // }
  5481. // }
  5482. // }elseif($key=="trainSum"){
  5483. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->TRAIN.'"'.$dateCondition,'asArray'=>true));
  5484. // if(empty($iStatistics)){
  5485. // $itemStatistics->cid=$this->staff[0]['cid'];
  5486. // $itemStatistics->staff=$this->staff[0]['sid'];
  5487. // $itemStatistics->price=$value;
  5488. // $itemStatistics->itemCategory=$this->TRAIN;
  5489. // $itemStatistics->date=date("Y-m-d");
  5490. // $itemStatistics->insert();
  5491. // }else{
  5492. // if (!empty($value)){
  5493. // $itemStatistics->price=$value+$iStatistics['price'];
  5494. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5495. // }
  5496. // }
  5497. // }elseif($key=="otherSum"){
  5498. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->OTHER.'"'.$dateCondition,'asArray'=>true));
  5499. // if(empty($iStatistics)){
  5500. // $itemStatistics->cid=$this->staff[0]['cid'];
  5501. // $itemStatistics->staff=$this->staff[0]['sid'];
  5502. // $itemStatistics->price=$value;
  5503. // $itemStatistics->itemCategory=$this->OTHER;
  5504. // $itemStatistics->date=date("Y-m-d");
  5505. // $itemStatistics->insert();
  5506. // }else{
  5507. // if (!empty($value)){
  5508. // $itemStatistics->price=$value+$iStatistics['price'];
  5509. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5510. // }
  5511. // }
  5512. // }
  5513. // }
  5514. $stat = $statistics->getOne ( array (
  5515. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5516. 'asArray' => true
  5517. ) );
  5518. if (empty ( $stat )) {
  5519. $statistics->date = date ( "Y-m-d" );
  5520. $statistics->cid = $this->staff [0] ['cid'];
  5521. $statistics->staff = $this->staff [0] ['sid'];
  5522. $statistics->agPrice = 0;
  5523. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5524. $statistics->insert ();
  5525. } else {
  5526. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5527. $statistics->update ( array (
  5528. 'where' => 'sid=' . $stat ['sid']
  5529. ) );
  5530. }
  5531. return "/expenses";
  5532. }
  5533. function approval() {
  5534. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5535. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5536. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5537. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5538. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5539. if (empty ( $status ))
  5540. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5541. $vidList = array ();
  5542. $button = 0;
  5543. Doo::loadModel ( 'verify' );
  5544. $verify = new verify ();
  5545. Doo::loadModel ( 'receipt' );
  5546. $receipt = new receipt ();
  5547. Doo::loadModel ( 'staff' );
  5548. $staff = new staff ();
  5549. Doo::loadModel ( 'L_category' );
  5550. $Lcategory = new L_category ();
  5551. // user verify ID
  5552. $verifyDetail = $verify->find ( array (
  5553. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5554. 'asArray' => true
  5555. ) );
  5556. foreach ( $verifyDetail as $key => $value ) {
  5557. array_push ( $vidList, $value ['vid'] );
  5558. }
  5559. $vid = implode ( ",", $vidList );
  5560. if (empty ( $verifyDetail ))
  5561. $vid = 0;
  5562. /*
  5563. */
  5564. $dateCondition = " and Year(date) =" . $year;
  5565. if (! empty ( $month ))
  5566. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  5567. $categoryList = $Lcategory->find ( array (
  5568. 'asArray' => true
  5569. ) );
  5570. $staffList = $staff->find ( array (
  5571. 'where' => 'cid=' . $cid,
  5572. 'asArray' => true
  5573. ) );
  5574. $cateCondition = "";
  5575. $staffCondition = "";
  5576. $approvalCondition = "";
  5577. if (! empty ( $cid ))
  5578. $cateCondition = ' and cid=' . $cid;
  5579. if (! empty ( $sid )) {
  5580. $staffCondition = ' and staff=' . $sid;
  5581. $cateCondition = "";
  5582. }
  5583. // elseif($status==1){
  5584. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  5585. // }
  5586. if ($status == 2) {
  5587. // 查找角色审批人
  5588. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  5589. }
  5590. $ap = "";
  5591. if ($status == 4) {
  5592. $ap = 4;
  5593. $status = 2;
  5594. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  5595. }
  5596. if ($status == 5) {
  5597. $status = 4;
  5598. $ap = 5;
  5599. }
  5600. // echo $vid;
  5601. // get Receipt By verifyID status 2 .$approvalCondition
  5602. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  5603. $receiptList = $receipt->find ( array (
  5604. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  5605. 'desc' => 'rid',
  5606. 'asArray' => true
  5607. ) );
  5608. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  5609. $Locate = 0;
  5610. if ($ap == 4)
  5611. $status = 4;
  5612. elseif ($ap == 5)
  5613. $status = 5;
  5614. foreach ( $receiptList as $key => $value ) {
  5615. $receiptList [$key] ['Locate'] = $Locate;
  5616. $Locate ++;
  5617. $receiptList [$key] ['reviseDetail'] = array ();
  5618. if (! empty ( $value ['reviseDetail'] ))
  5619. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5620. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5621. $categoryDetil = $Lcategory->getOne ( array (
  5622. 'where' => 'cid=' . $value ['cid'],
  5623. 'asArray' => true
  5624. ) );
  5625. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5626. $verifyList = $verify->getOne ( array (
  5627. 'where' => 'vid=' . $value ['verify'],
  5628. 'asArray' => true
  5629. ) );
  5630. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5631. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5632. foreach ( $verifyList as $k => $v ) {
  5633. // init verifyStaff
  5634. $verifyList [$k] ['date'] = "";
  5635. $verifyList [$k] ['opinion'] = "";
  5636. $verifyList [$k] ['status'] = "";
  5637. if (empty ( $verifyStaff )) {
  5638. $verifyList [$k] ['date'] = "";
  5639. $verifyList [$k] ['opinion'] = "";
  5640. if ($v [0] == $this->staff [0] ['sid']) {
  5641. $verifyList [$k] ['status'] = 4;
  5642. $button = 4;
  5643. }
  5644. } else {
  5645. $flag = true;
  5646. foreach ( $verifyStaff as $m => $u ) {
  5647. if ($v [0] == $m) {
  5648. $verifyList [$k] ['date'] = $u ['date'];
  5649. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5650. $verifyList [$k] ['status'] = $u ['status'];
  5651. $flag = false;
  5652. break;
  5653. }
  5654. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  5655. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  5656. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  5657. }
  5658. if ($flag) { // 检测可编辑
  5659. if ($v [0] == $this->staff [0] ['sid']) {
  5660. $verifyList [$k] ['status'] = 4;
  5661. $button = 4;
  5662. }
  5663. }
  5664. }
  5665. }
  5666. $receiptList [$key] ['verifyList'] = $verifyList;
  5667. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5668. 'where' => 'sid=' . $value ['staff'],
  5669. 'asArray' => true
  5670. ) );
  5671. $receiptList [$key] ['button'] = $button;
  5672. }
  5673. // print_r($receiptList);die;
  5674. // $data['verifyDetail']=$verifyDetail;
  5675. $mothHtml = "";
  5676. for($i = 1; $i <= 12; $i ++) {
  5677. if ($month == $i)
  5678. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5679. else
  5680. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5681. }
  5682. $data ['mothHtml'] = $mothHtml;
  5683. $data ['receiptList'] = $receiptList;
  5684. $data ['receiptApprovalCount'] = count ( $receiptList );
  5685. $data ['status'] = $status;
  5686. $data ['year'] = $year;
  5687. $data ['categoryList'] = $categoryList;
  5688. $data ['staffList'] = $staffList;
  5689. $data ['cid'] = $cid;
  5690. $data ['sid'] = $sid;
  5691. $data ['ap'] = $ap;
  5692. $data ['memu'] = "receipt";
  5693. $data ['staff'] = $this->staff;
  5694. $data ['receiptMemu'] = 'approval';
  5695. $data ['verifyId'] = $this->verifyId;
  5696. $data ['executeId'] = $this->executeId;
  5697. $this->render ( "/admin/saea_reportList", $data );
  5698. }
  5699. function approvalDetails() {
  5700. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5701. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5702. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5703. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5704. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5705. Doo::loadModel ( 'verify' );
  5706. $verify = new verify ();
  5707. Doo::loadModel ( 'receipt' );
  5708. $receipt = new receipt ();
  5709. Doo::loadModel ( 'staff' );
  5710. $staff = new staff ();
  5711. Doo::loadModel ( 'L_category' );
  5712. $Lcategory = new L_category ();
  5713. Doo::loadModel ( 'enclosur' );
  5714. $enclosur = new enclosur ();
  5715. $vidList = array ();
  5716. $verifyDetail = $verify->find ( array (
  5717. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5718. 'asArray' => true
  5719. ) );
  5720. foreach ( $verifyDetail as $key => $value ) {
  5721. array_push ( $vidList, $value ['vid'] );
  5722. }
  5723. $vid = implode ( ",", $vidList );
  5724. if (empty ( $verifyDetail ))
  5725. $vid = 0;
  5726. $categoryList = $Lcategory->find ( array (
  5727. 'asArray' => true
  5728. ) );
  5729. $staffList = $staff->find ( array (
  5730. 'where' => 'cid=' . $cid,
  5731. 'asArray' => true
  5732. ) );
  5733. $ap = 0;
  5734. $receiptList = $receipt->find ( array (
  5735. 'where' => 'rid =' . $rid,
  5736. 'desc' => 'rid',
  5737. 'asArray' => true
  5738. ) );
  5739. $Locate = 0;
  5740. $roleId = 0;
  5741. $button = 0;
  5742. foreach ( $receiptList as $key => $value ) {
  5743. $receiptList [$key] ['Locate'] = $Locate;
  5744. $Locate ++;
  5745. $receiptList [$key] ['reviseDetail'] = array ();
  5746. if (! empty ( $value ['reviseDetail'] ))
  5747. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5748. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5749. $categoryDetil = $Lcategory->getOne ( array (
  5750. 'where' => 'cid=' . $value ['cid'],
  5751. 'asArray' => true
  5752. ) );
  5753. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5754. // 检测编辑状态
  5755. $verifyList = $verify->getOne ( array (
  5756. 'where' => 'vid=' . $value ['verify'],
  5757. 'asArray' => true
  5758. ) );
  5759. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5760. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5761. Doo::loadModel ( 'role' );
  5762. $role = new role ();
  5763. // print_r($verifyList);
  5764. $flag = true;
  5765. $roleKey = 0;
  5766. $endStaffArray = array ();
  5767. $roleArrayCopy = array ();
  5768. foreach ( $verifyList as $k => $v ) {
  5769. // init verifyStaff
  5770. if ($v [1] == 'ROLE') {
  5771. if (! empty ( $verifyStaff )) {
  5772. $endStaffArray = end ( $verifyStaff );
  5773. if ($v [0] == $endStaffArray ['nextStaff']) {
  5774. $roleId = $v [0];
  5775. }
  5776. }
  5777. $roleVerify = json_decode ( $v [3], true );
  5778. $roleKey = $k;
  5779. $roleArray = array ();
  5780. $rolename = $role->getOne ( array (
  5781. 'where' => 'rid=' . $v [0],
  5782. 'asArray' => true
  5783. ) );
  5784. foreach ( $roleVerify as $o => $p ) {
  5785. $staffID = explode ( '_', $p );
  5786. $staffInfo = $staff->getOne ( array (
  5787. 'where' => 'sid=' . $staffID [0],
  5788. 'asArray' => true
  5789. ) );
  5790. // print_r($staffID);
  5791. $exp = array (
  5792. 0 => $staffInfo ['sid'],
  5793. 1 => $staffID [1],
  5794. 2 => $staffInfo ['avatar'],
  5795. 'date' => '',
  5796. 'date' => '',
  5797. 'opinion' => '',
  5798. 'status' => '',
  5799. 'rolename' => $rolename ['name']
  5800. );
  5801. array_push ( $roleArray, $exp );
  5802. }
  5803. $roleArrayCopy [$v [0]] = $roleArray;
  5804. // $verifyList[$k]['roleArray']=$roleArray;
  5805. }
  5806. // print_r($roleArray);
  5807. $verifyList [$k] ['date'] = "";
  5808. $verifyList [$k] ['opinion'] = "";
  5809. $verifyList [$k] ['status'] = "";
  5810. if (empty ( $verifyStaff )) {
  5811. $verifyList [$k] ['date'] = "";
  5812. $verifyList [$k] ['opinion'] = "";
  5813. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5814. $verifyList [$k] ['status'] = 4;
  5815. $button = 4;
  5816. $flag = false;
  5817. }
  5818. } else {
  5819. foreach ( $verifyStaff as $m => $u ) {
  5820. if ($v [0] == $m) {
  5821. $verifyList [$k] ['date'] = $u ['date'];
  5822. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5823. $verifyList [$k] ['status'] = $u ['status'];
  5824. $flag = false;
  5825. break;
  5826. }
  5827. }
  5828. $endStaffArray = end ( $verifyStaff );
  5829. if (isset ( $endStaffArray ['ROLE'] )) {
  5830. } else {
  5831. $endKey = key ( $verifyStaff );
  5832. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5833. $button = 4;
  5834. $verifyList [$k] ['status'] = 4;
  5835. }
  5836. }
  5837. }
  5838. }
  5839. $rolename ['name'] = '';
  5840. if (! empty ( $roleId )) {
  5841. Doo::loadModel ( 'role' );
  5842. $role = new role ();
  5843. $rolename = $role->getOne ( array (
  5844. 'where' => 'rid=' . $roleId,
  5845. 'asArray' => true
  5846. ) );
  5847. }
  5848. if (! empty ( $verifyStaff ))
  5849. $endStaffArray = end ( $verifyStaff );
  5850. $KOP = false;
  5851. foreach ( $roleArrayCopy as $P => $A ) {
  5852. foreach ( $A as $MKI => $AVL ) {
  5853. if (! empty ( $verifyStaff )) {
  5854. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5855. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5856. $button = 4;
  5857. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5858. }
  5859. foreach ( $verifyStaff as $m => $u ) {
  5860. $AVLFK = $AVL [0] . '_R';
  5861. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5862. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5863. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5864. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5865. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5866. break;
  5867. }
  5868. }
  5869. } else {
  5870. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5871. $button = 4;
  5872. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5873. }
  5874. }
  5875. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5876. $KOP = true;
  5877. }
  5878. }
  5879. foreach ( $roleArrayCopy as $k => $v ) {
  5880. foreach ( $verifyList as $m => $n ) {
  5881. if ($n [0] == $k) {
  5882. array_splice ( $verifyList, $m, 1, $v );
  5883. }
  5884. }
  5885. }
  5886. $receiptList [$key] ['verifyList'] = $verifyList;
  5887. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5888. 'where' => 'sid=' . $value ['staff'],
  5889. 'asArray' => true
  5890. ) );
  5891. $receiptList [$key] ['button'] = $button;
  5892. }
  5893. $mothHtml = "";
  5894. for($i = 1; $i <= 12; $i ++) {
  5895. if ($month == $i)
  5896. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5897. else
  5898. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5899. }
  5900. // 获取审批日志
  5901. Doo::loadModel ( 'receiptLog' );
  5902. $receiptLog = new receiptLog ();
  5903. $rlList = array ();
  5904. $rlInfo = $receiptLog->getOne ( array (
  5905. 'where' => 'rid=' . $rid . ' and status=4',
  5906. 'asArray' => true
  5907. ) );
  5908. $tijdate = $receiptLog->getOne ( array (
  5909. 'where' => 'rid=' . $rid . ' and status=2',
  5910. 'asc' => 'rlid',
  5911. 'asArray' => true
  5912. ) );
  5913. if (! empty ( $rlInfo )) {
  5914. $rlList = $receiptLog->find ( array (
  5915. 'where' => 'rid=' . $rid,
  5916. 'asc' => 'rlid',
  5917. 'asArray' => true
  5918. ) );
  5919. }
  5920. $receiptList [0] ['rlList'] = $rlList;
  5921. $enclosurList = $enclosur->find ( array (
  5922. 'where' => 'rid=' . $rid,
  5923. 'asArray' => true
  5924. ) );
  5925. $enclosurHtml = '';
  5926. foreach ( $enclosurList as $value ) {
  5927. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5928. }
  5929. $data ['enclosurHtml'] = $enclosurHtml;
  5930. $data ['rolename'] = $rolename ['name'];
  5931. $data ['datetij'] = $tijdate ['date'];
  5932. $data ['mothHtml'] = $mothHtml;
  5933. $data ['receiptList'] = $receiptList;
  5934. $data ['receiptApprovalCount'] = count ( $receiptList );
  5935. $data ['year'] = $year;
  5936. $data ['categoryList'] = $categoryList;
  5937. $data ['staffList'] = $staffList;
  5938. $data ['cid'] = $cid;
  5939. $data ['sid'] = $sid;
  5940. $data ['status'] = 0;
  5941. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  5942. $ap = 4;
  5943. } else
  5944. $data ['status'] = $receiptList [0] ['status'];
  5945. if ($receiptList [0] ['status'] == 4) {
  5946. $data ['status'] = 5;
  5947. $ap = 0;
  5948. }
  5949. $data ['ap'] = $ap;
  5950. $data ['memu'] = "receipt";
  5951. $data ['staff'] = $this->staff;
  5952. $data ['receiptMemu'] = 'approval';
  5953. $data ['verifyId'] = $this->verifyId;
  5954. $data ['executeId'] = $this->executeId;
  5955. $this->render ( "/admin/saeaReportListReport", $data );
  5956. }
  5957. function approvalEdi() {
  5958. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5959. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5960. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5961. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5962. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5963. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5964. if (empty ( $status ))
  5965. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5966. $vidList = array ();
  5967. $button = 0;
  5968. Doo::loadModel ( 'verify' );
  5969. Doo::loadModel ( 'receipt' );
  5970. Doo::loadModel ( 'staff' );
  5971. $staff = new staff ();
  5972. $receipt = new receipt ();
  5973. $verify = new verify ();
  5974. Doo::loadModel ( 'L_category' );
  5975. $Lcategory = new L_category ();
  5976. Doo::loadModel ( 'enclosur' );
  5977. $enclosur = new enclosur ();
  5978. // user verify ID
  5979. $verifyDetail = $verify->find ( array (
  5980. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5981. 'asArray' => true
  5982. ) );
  5983. foreach ( $verifyDetail as $key => $value ) {
  5984. array_push ( $vidList, $value ['vid'] );
  5985. }
  5986. $vid = implode ( ",", $vidList );
  5987. if (empty ( $verifyDetail ))
  5988. $vid = 0;
  5989. $categoryList = $Lcategory->find ( array (
  5990. 'asArray' => true
  5991. ) );
  5992. $staffList = $staff->find ( array (
  5993. 'where' => 'cid=' . $cid,
  5994. 'asArray' => true
  5995. ) );
  5996. $ap = "";
  5997. if ($status == 4) {
  5998. $ap = 4;
  5999. $status = 2;
  6000. }
  6001. // get Receipt By verifyID status 2
  6002. $receiptList = $receipt->find ( array (
  6003. 'where' => 'rid =' . $rid,
  6004. 'desc' => 'rid',
  6005. 'asArray' => true
  6006. ) );
  6007. $Locate = 0;
  6008. $roleId = 0;
  6009. if ($ap == 4)
  6010. $status = 4;
  6011. foreach ( $receiptList as $key => $value ) {
  6012. $receiptList [$key] ['Locate'] = $Locate;
  6013. $Locate ++;
  6014. $receiptList [$key] ['reviseDetail'] = array ();
  6015. if (! empty ( $value ['reviseDetail'] ))
  6016. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6017. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6018. $categoryDetil = $Lcategory->getOne ( array (
  6019. 'where' => 'cid=' . $value ['cid'],
  6020. 'asArray' => true
  6021. ) );
  6022. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6023. // 检测编辑状态
  6024. $verifyList = $verify->getOne ( array (
  6025. 'where' => 'vid=' . $value ['verify'],
  6026. 'asArray' => true
  6027. ) );
  6028. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6029. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6030. // print_r($verifyList);
  6031. //
  6032. // if (empty($verifyStaff)){
  6033. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6034. // $verifyList[0]['status']=4;$button=4;
  6035. // }
  6036. //
  6037. // }else{
  6038. //
  6039. // }
  6040. // die;
  6041. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  6042. // echo array_search("green",$a);
  6043. //
  6044. Doo::loadModel ( 'role' );
  6045. $role = new role ();
  6046. // print_r($verifyList);
  6047. $flag = true;
  6048. $roleKey = 0;
  6049. $endStaffArray = array ();
  6050. $roleArrayCopy = array ();
  6051. foreach ( $verifyList as $k => $v ) {
  6052. // init verifyStaff
  6053. if ($v [1] == 'ROLE') {
  6054. if (! empty ( $verifyStaff )) {
  6055. $endStaffArray = end ( $verifyStaff );
  6056. if ($v [0] == $endStaffArray ['nextStaff']) {
  6057. $roleId = $v [0];
  6058. }
  6059. }
  6060. $roleVerify = json_decode ( $v [3], true );
  6061. $roleKey = $k;
  6062. $roleArray = array ();
  6063. $rolename = $role->getOne ( array (
  6064. 'where' => 'rid=' . $v [0],
  6065. 'asArray' => true
  6066. ) );
  6067. foreach ( $roleVerify as $o => $p ) {
  6068. $staffID = explode ( '_', $p );
  6069. $staffInfo = $staff->getOne ( array (
  6070. 'where' => 'sid=' . $staffID [0],
  6071. 'asArray' => true
  6072. ) );
  6073. // print_r($staffID);
  6074. $exp = array (
  6075. 0 => $staffInfo ['sid'],
  6076. 1 => $staffID [1],
  6077. 2 => $staffInfo ['avatar'],
  6078. 'date' => '',
  6079. 'date' => '',
  6080. 'opinion' => '',
  6081. 'status' => '',
  6082. 'rolename' => $rolename ['name']
  6083. );
  6084. array_push ( $roleArray, $exp );
  6085. }
  6086. $roleArrayCopy [$v [0]] = $roleArray;
  6087. // $verifyList[$k]['roleArray']=$roleArray;
  6088. }
  6089. // print_r($roleArray);
  6090. $verifyList [$k] ['date'] = "";
  6091. $verifyList [$k] ['opinion'] = "";
  6092. $verifyList [$k] ['status'] = "";
  6093. if (empty ( $verifyStaff )) {
  6094. $verifyList [$k] ['date'] = "";
  6095. $verifyList [$k] ['opinion'] = "";
  6096. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6097. $verifyList [$k] ['status'] = 4;
  6098. $button = 4;
  6099. $flag = false;
  6100. }
  6101. } else {
  6102. foreach ( $verifyStaff as $m => $u ) {
  6103. if ($v [0] == $m) {
  6104. $verifyList [$k] ['date'] = $u ['date'];
  6105. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6106. $verifyList [$k] ['status'] = $u ['status'];
  6107. $flag = false;
  6108. break;
  6109. }
  6110. }
  6111. $endStaffArray = end ( $verifyStaff );
  6112. if (isset ( $endStaffArray ['ROLE'] )) {
  6113. } else {
  6114. $endKey = key ( $verifyStaff );
  6115. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6116. $button = 4;
  6117. $verifyList [$k] ['status'] = 4;
  6118. }
  6119. }
  6120. // print_r($endStaffArray);die;
  6121. // if (empty($verifyStaff)){
  6122. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6123. // $verifyList[$k]['status']=4;$button=4;
  6124. // }
  6125. //
  6126. // }else{
  6127. //
  6128. // }
  6129. // if($flag){//检测可编辑
  6130. // if($v[0]==$this->staff[0]['sid']){
  6131. // $verifyList[$k]['status']=4;$button=4;
  6132. // }
  6133. // }
  6134. }
  6135. }
  6136. $rolename ['name'] = '';
  6137. if (! empty ( $roleId )) {
  6138. Doo::loadModel ( 'role' );
  6139. $role = new role ();
  6140. $rolename = $role->getOne ( array (
  6141. 'where' => 'rid=' . $roleId,
  6142. 'asArray' => true
  6143. ) );
  6144. }
  6145. if (! empty ( $verifyStaff ))
  6146. $endStaffArray = end ( $verifyStaff );
  6147. $KOP = false;
  6148. foreach ( $roleArrayCopy as $P => $A ) {
  6149. foreach ( $A as $MKI => $AVL ) {
  6150. if (! empty ( $verifyStaff )) {
  6151. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6152. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6153. $button = 4;
  6154. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6155. }
  6156. foreach ( $verifyStaff as $m => $u ) {
  6157. $AVLFK = $AVL [0] . '_R';
  6158. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6159. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6160. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6161. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6162. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6163. break;
  6164. }
  6165. }
  6166. } else {
  6167. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6168. $button = 4;
  6169. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6170. }
  6171. }
  6172. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6173. $KOP = true;
  6174. }
  6175. }
  6176. // print_r($roleArrayCopy);
  6177. // echo $roleKey;
  6178. foreach ( $roleArrayCopy as $k => $v ) {
  6179. foreach ( $verifyList as $m => $n ) {
  6180. if ($n [0] == $k) {
  6181. array_splice ( $verifyList, $m, 1, $v );
  6182. }
  6183. }
  6184. }
  6185. // if ($KOP)
  6186. // array_splice($verifyList,$roleKey,1,$roleArray);
  6187. // print_r($verifyList);
  6188. $receiptList [$key] ['verifyList'] = $verifyList;
  6189. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6190. 'where' => 'sid=' . $value ['staff'],
  6191. 'asArray' => true
  6192. ) );
  6193. $receiptList [$key] ['button'] = $button;
  6194. }
  6195. // $data['verifyDetail']=$verifyDetail;
  6196. $mothHtml = "";
  6197. for($i = 1; $i <= 12; $i ++) {
  6198. if ($month == $i)
  6199. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6200. else
  6201. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6202. }
  6203. // 获取审批日志
  6204. Doo::loadModel ( 'receiptLog' );
  6205. $receiptLog = new receiptLog ();
  6206. $rlList = array ();
  6207. $rlInfo = $receiptLog->getOne ( array (
  6208. 'where' => 'rid=' . $rid . ' and status=4',
  6209. 'asArray' => true
  6210. ) );
  6211. $tijdate = $receiptLog->getOne ( array (
  6212. 'where' => 'rid=' . $rid . ' and status=2',
  6213. 'asc' => 'rlid',
  6214. 'asArray' => true
  6215. ) );
  6216. if (! empty ( $rlInfo )) {
  6217. $rlList = $receiptLog->find ( array (
  6218. 'where' => 'rid=' . $rid,
  6219. 'asc' => 'rlid',
  6220. 'asArray' => true
  6221. ) );
  6222. }
  6223. $receiptList [0] ['rlList'] = $rlList;
  6224. $enclosurList = $enclosur->find ( array (
  6225. 'where' => 'rid=' . $rid,
  6226. 'asArray' => true
  6227. ) );
  6228. $enclosurHtml = '';
  6229. foreach ( $enclosurList as $value ) {
  6230. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6231. }
  6232. $data ['enclosurHtml'] = $enclosurHtml;
  6233. $data ['rolename'] = $rolename ['name'];
  6234. $data ['datetij'] = $tijdate ['date'];
  6235. $data ['mothHtml'] = $mothHtml;
  6236. $data ['receiptList'] = $receiptList;
  6237. $data ['receiptApprovalCount'] = count ( $receiptList );
  6238. $data ['status'] = $status;
  6239. $data ['year'] = $year;
  6240. $data ['categoryList'] = $categoryList;
  6241. $data ['staffList'] = $staffList;
  6242. $data ['cid'] = $cid;
  6243. $data ['sid'] = $sid;
  6244. $data ['ap'] = $ap;
  6245. $data ['memu'] = "receipt";
  6246. $data ['staff'] = $this->staff;
  6247. $data ['receiptMemu'] = 'approval';
  6248. $data ['verifyId'] = $this->verifyId;
  6249. $data ['executeId'] = $this->executeId;
  6250. $this->render ( "/admin/saeaReportListReport", $data );
  6251. }
  6252. function remittanceHky() {
  6253. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6254. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  6255. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6256. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  6257. $page_size = 15;
  6258. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  6259. Doo::loadModel ( 'receipt' );
  6260. $receipt = new receipt ();
  6261. Doo::loadModel ( 'staff' );
  6262. $staff = new staff ();
  6263. $dateCondition = " and Year(executeDate) =" . $year;
  6264. if ($moth != 'MONTH')
  6265. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  6266. if ($day != 'DAY' && $moth != 'MONTH')
  6267. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  6268. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  6269. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  6270. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  6271. $limit = $pageinfo ['lower'] . ',' . $page_size;
  6272. $dayList = $receipt->find ( array (
  6273. 'select' => 'executeDate,sum(amount) as amount',
  6274. 'where' => $sql,
  6275. 'desc' => 'executeDate',
  6276. 'groupby' => 'executeDate',
  6277. 'limit' => $limit,
  6278. 'asArray' => true
  6279. ) );
  6280. // print_r($dayList);
  6281. foreach ( $dayList as $key => $value ) {
  6282. $remitString = "";
  6283. $receiptList = $receipt->find ( array (
  6284. 'select' => 'rid,executeDate,amount,staff,cid',
  6285. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  6286. 'desc' => 'executeDate',
  6287. 'asArray' => true
  6288. ) );
  6289. foreach ( $receiptList as $k => $v ) {
  6290. $sinfo = $staff->getOne ( array (
  6291. 'select' => 'username,category',
  6292. 'where' => ' sid=' . $v ['staff'],
  6293. 'asArray' => true
  6294. ) );
  6295. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  6296. }
  6297. $dayList [$key] ['staff'] = $remitString;
  6298. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  6299. }
  6300. // print_r($dayList);
  6301. $mothHtml = "";
  6302. for($i = 1; $i <= 12; $i ++) {
  6303. if ($moth == $i)
  6304. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6305. else
  6306. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6307. }
  6308. $dayHtml = "";
  6309. if ($day != "DAY" || $moth != "MONTH") {
  6310. for($i = 1; $i <= 31; $i ++) {
  6311. if ($day == $i)
  6312. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6313. else
  6314. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6315. }
  6316. }
  6317. $data ['page'] = $pageinfo;
  6318. $data ['year'] = $year;
  6319. $data ['moth'] = $moth;
  6320. $data ['day'] = $day;
  6321. $data ['get'] = $get;
  6322. $data ['dayHtml'] = $dayHtml;
  6323. $data ['mothHtml'] = $mothHtml;
  6324. $data ['receiptList'] = $dayList;
  6325. $data ['memu'] = "receipt";
  6326. $data ['staff'] = $this->staff;
  6327. $data ['receiptMemu'] = 'remittanceHky';
  6328. $data ['verifyId'] = $this->verifyId;
  6329. $data ['executeId'] = $this->executeId;
  6330. $this->render ( "/admin/remittanceHky", $data );
  6331. }
  6332. function remittancep() {
  6333. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  6334. Doo::loadModel ( 'receipt' );
  6335. $receipt = new receipt ();
  6336. Doo::loadModel ( 'staff' );
  6337. $staff = new staff ();
  6338. Doo::loadClass ( 'XDeode' );
  6339. $XDeode = new XDeode ( 5 );
  6340. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  6341. $rplist = $receipt->find ( array (
  6342. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6343. 'asArray' => true
  6344. ) );
  6345. $dayList = $receipt->find ( array (
  6346. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6347. 'desc' => 'executeDate',
  6348. 'groupby' => 'staff',
  6349. 'asArray' => true
  6350. ) );
  6351. $html = '';
  6352. foreach ( $dayList as $key => $value ) {
  6353. $sinfo = $staff->getOne ( array (
  6354. 'select' => 'username,category',
  6355. 'where' => ' sid=' . $value ['staff'],
  6356. 'asArray' => true
  6357. ) );
  6358. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  6359. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  6360. $au = 0;
  6361. foreach ( $rplist as $k => $v ) {
  6362. if ($value ['staff'] == $v ['staff']) {
  6363. $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>';
  6364. $au += $v ['amount'];
  6365. }
  6366. }
  6367. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  6368. }
  6369. $data ['html'] = $html;
  6370. $data ['memu'] = "receipt";
  6371. $data ['staff'] = $this->staff;
  6372. $data ['receiptMemu'] = 'remittanceHky';
  6373. $data ['verifyId'] = $this->verifyId;
  6374. $data ['executeId'] = $this->executeId;
  6375. $this->render ( "/admin/remittancep", $data );
  6376. }
  6377. function ajaxGetReceiptDetails() {
  6378. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  6379. Doo::loadClass ( 'XDeode' );
  6380. $XDeode = new XDeode ( 5 );
  6381. $rid = $XDeode->decode ( $rid );
  6382. if (empty ( $rid )) {
  6383. echo json_encode ( array (
  6384. 'status' => 2,
  6385. 'msg' => 'illegal request'
  6386. ) );
  6387. die ();
  6388. }
  6389. Doo::loadModel ( 'receipt' );
  6390. $receipt = new receipt ();
  6391. Doo::loadModel ( 'staff' );
  6392. $staff = new staff ();
  6393. $rinfo = $receipt->getOne ( array (
  6394. 'where' => 'rid= ' . $rid,
  6395. 'asArray' => true
  6396. ) );
  6397. $sinfo = $staff->getOne ( array (
  6398. 'select' => 'username,category',
  6399. 'where' => ' sid=' . $rinfo ['staff'],
  6400. 'asArray' => true
  6401. ) );
  6402. $rinfo ['reviseDetail'] = array ();
  6403. if (! empty ( $rinfo ['reviseDetail'] ))
  6404. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  6405. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  6406. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  6407. $rinfo ['category'] = $sinfo ['category'];
  6408. $verifyStaff = array ();
  6409. if (! empty ( $rinfo ['verifyStaff'] ))
  6410. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  6411. $relust = $rinfo ['sum'] - $rinfo ['loanSum'];
  6412. $rinfo ['relust'] = $relust;
  6413. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  6414. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  6415. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  6416. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  6417. // 费用执行人相关数据
  6418. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6419. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6420. foreach ( $executeCopy as $k => $v ) {
  6421. $executeCopy [$k] ['date'] = '';
  6422. $executeCopy [$k] ['opinion'] = '';
  6423. $executeCopy [$k] ['status'] = '';
  6424. if (! empty ( $executeStaff ))
  6425. foreach ( $executeStaff as $m => $u ) {
  6426. if ($v [0] == $m) {
  6427. $executeCopy [$k] ['date'] = $u ['date'];
  6428. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  6429. $executeCopy [$k] ['status'] = $u ['status'];
  6430. break;
  6431. }
  6432. }
  6433. }
  6434. $rinfo ['executeCopy'] = $executeCopy;
  6435. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  6436. if ($rinfo ['Rtype'] == 1) { // 借款费用
  6437. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6438. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  6439. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  6440. $html .= '<tr><th>' . $value ['name'] . '</th>
  6441. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6442. }
  6443. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6444. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6445. <tr><th class="taC" colspan="2">费用说明</th>
  6446. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6447. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6448. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  6449. </tbody></table>';
  6450. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  6451. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6452. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6453. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6454. $html .= '<tr><th>' . $value ['name'] . '</th>
  6455. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6456. }
  6457. $html .= '<tr><th class="taR">合计</th>
  6458. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6459. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6460. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6461. $html .= '<tr><th>' . $value ['name'] . '</th>
  6462. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6463. }
  6464. $html .= '<tr><th class="taR">合计</th>
  6465. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  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'] ['trainSum'] . '</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'] ['otherSum'] . '</td></tr>';
  6480. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6481. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6482. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6483. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6484. }
  6485. $html .= '<tr><th class="taR">合计</th>
  6486. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6487. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6488. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6489. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6490. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6491. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6492. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6493. <tr';
  6494. if ($rinfo ['relust'] >= 0) {
  6495. $html .= 'class="success"';
  6496. } else {
  6497. $html .= 'class="error"';
  6498. }
  6499. $html .= '><td class="taR"><b>借款结余</b></td>
  6500. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  6501. </tbody></table>
  6502. ';
  6503. }
  6504. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  6505. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6506. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  6507. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6508. $html .= '<tr><th>' . $value ['name'] . '</th>
  6509. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6510. }
  6511. $html .= '<tr><th class="taR">合计</th>
  6512. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6513. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6514. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6515. <tr><th class="taC" colspan="2">费用说明</th>
  6516. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6517. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6518. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6519. </tbody></table>';
  6520. } else {
  6521. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6522. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6523. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6524. $html .= '<tr><th>' . $value ['name'] . '</th>
  6525. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6526. }
  6527. $html .= '<tr><th class="taR">合计</th>
  6528. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6529. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6530. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6531. $html .= '<tr><th>' . $value ['name'] . '</th>
  6532. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6533. }
  6534. $html .= '<tr><th class="taR">合计</th>
  6535. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6536. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6537. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6538. $html .= '<tr><th>' . $value ['name'] . '</th>
  6539. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6540. }
  6541. $html .= '<tr><th class="taR">合计</th>
  6542. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6543. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6544. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6545. $html .= '<tr><th>' . $value ['name'] . '</th>
  6546. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6547. }
  6548. $html .= '<tr><th class="taR">合计</th>
  6549. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6550. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6551. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6552. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6553. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6554. }
  6555. $html .= '<tr><th class="taR">合计</th>
  6556. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6557. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6558. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6559. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6560. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6561. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6562. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  6563. $html .= '</tbody></table>';
  6564. /*
  6565. * <table class="table table-bordered table-condensed table-hover"> <tbody> <tr><th colspan="2" class="taC">日常相关费用</th></tr> <!-- loop receiptList' value.accountItem.日常相关费用 --> <tr><th>{{receiptList' value' value.name}}</th><td width="140" class="taR">¥{{receiptList' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptList' value.accountItem.cSum.agencySum}}</td></tr>
  6566. * <tr><th colspan="2" class="taC">差旅相关费用</th></tr> <!-- loop receiptDetail' value.accountItem.差旅相关费用 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.travelSum}}</td></tr>
  6567. * <tr><th colspan="2" class="taC">培训班费用</th></tr> <!-- loop receiptDetail' value.accountItem.培训班费用 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.trainSum}}</td></tr>
  6568. * <tr><th colspan="2" class="taC">其他</th></tr> <!-- loop receiptDetail' value.accountItem.其他 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.otherSum}}</td></tr>
  6569. * <tr><th colspan="2" class="taC">报销金额调整</th></tr> <!-- loop receiptList' value.reviseDetail --> <tr><th><span class="interval">|</span>{{receiptList' value' value.name}}:{{receiptList' value' value.description}}</th><td class="taR">¥{{receiptList' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colOrange taR">¥{{receiptList' value.revisePrice}}</td></tr>
  6570. * <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr> <tr><th style="text-align:center" colspan="2">{{receiptDetail' value.category}}</th></tr> <tr><th class="taC" colspan="2">报销说明</th></tr> <tr><td colspan="2">{{receiptDetail' value.explanation}}</td></tr> <tr class="warning"><td class="taR"><b>({{receiptDetail' value.receiptOrder}})本次报销费用合计</b></td> <td class="colGreed taR"><b style="font-size:24px">¥{{receiptDetail' value.sum}}</b><br>{{receiptDetail' value.sumCN}}</td></tr>
  6571. * </tbody> </table>
  6572. */
  6573. }
  6574. // print_r($verifyStaff);die;
  6575. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  6576. foreach ( $verifyStaff as $key => $value ) {
  6577. $key = trim ( strtr ( $key, '_R', ' ' ) );
  6578. $sinfo = $staff->getOne ( array (
  6579. 'select' => 'username',
  6580. 'where' => ' sid=' . $key,
  6581. 'asArray' => true
  6582. ) );
  6583. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6584. }
  6585. $html .= '</tbody></table>';
  6586. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  6587. foreach ( $rinfo ['executeCopy'] as $value ) {
  6588. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6589. }
  6590. $html .= '</tbody></table>';
  6591. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  6592. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  6593. </tr></table>';
  6594. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  6595. echo json_encode ( array (
  6596. 'status' => 1,
  6597. 'html' => $html
  6598. ) );
  6599. die ();
  6600. }
  6601. function remittance() {
  6602. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6603. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6604. Doo::loadModel ( 'receipt' );
  6605. $receipt = new receipt ();
  6606. Doo::loadModel ( 'staff' );
  6607. $staff = new staff ();
  6608. $dateCondition = " and Year(pastDate) =" . $year;
  6609. if (! empty ( $month ))
  6610. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  6611. // get Receipt By verifyID status 1
  6612. $receiptList = $receipt->find ( array (
  6613. 'select' => 'sum(sum) as sum,staff,pastDate',
  6614. 'where' => ' status=1' . $dateCondition,
  6615. 'desc' => 'pastDate',
  6616. 'groupby' => 'staff,pastDate',
  6617. 'asArray' => true
  6618. ) );
  6619. $dateList = $receipt->find ( array (
  6620. 'select' => 'pastDate,verifyStaff',
  6621. 'where' => ' status=1' . $dateCondition,
  6622. 'desc' => 'pastDate',
  6623. 'groupby' => 'pastDate',
  6624. 'asArray' => true
  6625. ) );
  6626. $dataList = array ();
  6627. foreach ( $dateList as $d => $a ) {
  6628. $dataList [$a ['pastDate']] = array ();
  6629. $daySum = 0;
  6630. foreach ( $receiptList as $key => $value ) {
  6631. if ($a ['pastDate'] == $value ['pastDate']) {
  6632. $oderList = $receipt->find ( array (
  6633. 'select' => 'receiptOrder',
  6634. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  6635. 'asArray' => true
  6636. ) );
  6637. $list = array ();
  6638. $html = "";
  6639. foreach ( $oderList as $v ) {
  6640. array_push ( $list, $v ['receiptOrder'] );
  6641. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  6642. }
  6643. $receiptList [$key] ['receiptOrder'] = $html;
  6644. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  6645. $sinfo = $staff->getOne ( array (
  6646. 'select' => 'username ',
  6647. 'where' => ' sid=' . $value ['staff'],
  6648. 'asArray' => true
  6649. ) );
  6650. $receiptList [$key] ['username'] = $sinfo ['username'];
  6651. $daySum += $value ['sum'];
  6652. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  6653. }
  6654. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  6655. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  6656. }
  6657. }
  6658. // print_r($dataList);
  6659. $data ['dataList'] = $dataList;
  6660. $mothHtml = "";
  6661. for($i = 1; $i <= 12; $i ++) {
  6662. if ($month == $i)
  6663. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6664. else
  6665. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6666. }
  6667. $data ['year'] = $year;
  6668. $data ['mothHtml'] = $mothHtml;
  6669. $data ['memu'] = "receipt";
  6670. $data ['staff'] = $this->staff;
  6671. $data ['receiptMemu'] = 'approval';
  6672. $data ['verifyId'] = $this->verifyId;
  6673. $data ['executeId'] = $this->executeId;
  6674. $this->render ( "/admin/saeaReportListPay", $data );
  6675. }
  6676. function revocationAdjustment() {
  6677. $sid = isset ( $this->params ['sid'] ) && is_numeric ( $this->params ['sid'] ) ? $this->params ['sid'] : 0;
  6678. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  6679. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6680. // echo $price;die;
  6681. if ((! empty ( $sid )) && ($price != - 99999) && (! empty ( $rid ))) {
  6682. Doo::loadModel ( 'receipt' );
  6683. $receipt = new receipt ();
  6684. $receiptDetail = $receipt->getOne ( array (
  6685. 'where' => 'rid=' . $rid,
  6686. 'asArray' => true
  6687. ) );
  6688. if (empty ( $receiptDetail ['reviseDetail'] ))
  6689. return "/approval";
  6690. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  6691. $RD = array ();
  6692. foreach ( $reviseDetail as $key => $value ) {
  6693. if ($value ['price'] == $price && $value ['sid'] == $sid)
  6694. continue;
  6695. array_push ( $RD, $value );
  6696. }
  6697. $reviseDetailString = json_encode ( $RD );
  6698. $receipt->reviseDetail = $reviseDetailString;
  6699. $receipt->sum = $receiptDetail ['sum'] - $price;
  6700. $receipt->revisePrice = $receiptDetail ['revisePrice'] - $price;
  6701. $receipt->update ( array (
  6702. 'where' => 'rid=' . $rid
  6703. ) );
  6704. }
  6705. // approvalEdi/37
  6706. return "/approvalEdi/" . $rid;
  6707. }
  6708. function updateApprovalReceipt() {
  6709. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6710. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  6711. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6712. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  6713. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  6714. if (! empty ( $rid )) {
  6715. Doo::loadModel ( "verify" );
  6716. $verify = new verify ();
  6717. Doo::loadModel ( "receiptDetail" );
  6718. $receiptDetailObj = new receiptDetail ();
  6719. Doo::loadModel ( "itemStatistics" );
  6720. Doo::loadModel ( "statistics" );
  6721. $statistics = new statistics ();
  6722. $itemStatistics = new itemStatistics ();
  6723. Doo::loadModel ( "receipt" );
  6724. $receipt = new receipt ();
  6725. $receiptDetail = $receipt->getOne ( array (
  6726. 'where' => 'rid=' . $rid . ' and status=2 ',
  6727. 'asArray' => true
  6728. ) );
  6729. if (empty ( $receiptDetail ))
  6730. return "/approval";
  6731. $verifyDetail = $verify->getOne ( array (
  6732. 'where' => ' vid =' . $receiptDetail ['verify'],
  6733. 'asArray' => true
  6734. ) );
  6735. $verifyString = $verifyDetail ['staff'];
  6736. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  6737. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  6738. if (empty ( $opinion )) {
  6739. if ($status == 3)
  6740. $opinion = "终止";
  6741. else
  6742. $opinion = "同意支付";
  6743. }
  6744. $nowStaff = 0;
  6745. $nowStaffList = array ();
  6746. if (empty ( $verifyStaff )) {
  6747. // 还需加入是否已经进入角色审批
  6748. if ($verifyDetail [0] [1] == 'ROLE') {
  6749. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  6750. foreach ( $vStaffString as $key => $value ) {
  6751. $staffK = explode ( "_", $value );
  6752. if ($staffK [0] != $this->staff [0] ['sid'])
  6753. array_push ( $nowStaffList, $staffK [0] );
  6754. }
  6755. // print_r($verifyDetail);
  6756. // die;
  6757. if (! empty ( $nowStaffList )) {
  6758. $nowStaff = implode ( ',', $nowStaffList );
  6759. $verifyStaff = array (
  6760. $this->staff [0] ['sid'] . "_R" => array (
  6761. 'date' => date ( 'Y-m-d' ),
  6762. 'opinion' => $opinion,
  6763. 'status' => $status,
  6764. 'nextStaff' => $verifyDetail [0] [0],
  6765. 'ROLE' => 1
  6766. )
  6767. );
  6768. } else {
  6769. $nowStaff = $verifyDetail [1] [0];
  6770. $verifyStaff = array (
  6771. $this->staff [0] ['sid'] . "_R" => array (
  6772. 'date' => date ( 'Y-m-d' ),
  6773. 'opinion' => $opinion,
  6774. 'status' => $status,
  6775. 'nextStaff' => $verifyDetail [1] [0]
  6776. )
  6777. );
  6778. }
  6779. } else {
  6780. if ($verifyDetail [1] [1] == 'ROLE') {
  6781. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  6782. // echo "dd";
  6783. foreach ( $vStaffString as $key => $value ) {
  6784. $staffK = explode ( "_", $value );
  6785. array_push ( $nowStaffList, $staffK [0] );
  6786. }
  6787. $nowStaff = implode ( ',', $nowStaffList );
  6788. $verifyStaff = array (
  6789. $this->staff [0] ['sid'] => array (
  6790. 'date' => date ( 'Y-m-d' ),
  6791. 'opinion' => $opinion,
  6792. 'status' => $status,
  6793. 'nextStaff' => $verifyDetail [1] [0],
  6794. 'ROLE' => 1
  6795. )
  6796. );
  6797. } else {
  6798. $nowStaff = $verifyDetail [1] [0];
  6799. $verifyStaff = array (
  6800. $this->staff [0] ['sid'] => array (
  6801. 'date' => date ( 'Y-m-d' ),
  6802. 'opinion' => $opinion,
  6803. 'status' => $status,
  6804. 'nextStaff' => $verifyDetail [1] [0]
  6805. )
  6806. );
  6807. }
  6808. }
  6809. if ($status == 3)
  6810. $verifyStaff = array (
  6811. 'final' => $status,
  6812. $this->staff [0] ['sid'] => array (
  6813. 'date' => date ( 'Y-m-d' ),
  6814. 'opinion' => $opinion,
  6815. 'status' => $status
  6816. )
  6817. );
  6818. $vStaffString = json_encode ( $verifyStaff );
  6819. $receipt->nowStaff = $nowStaff;
  6820. $receipt->verifyStaff = $vStaffString;
  6821. } else {
  6822. $VS = end ( $verifyStaff );
  6823. // 非角色审批
  6824. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  6825. $nextStaff = 0;
  6826. $roleSTF = false;
  6827. foreach ( $verifyDetail as $key => $value ) {
  6828. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  6829. if (isset ( $verifyDetail [$key + 1] )) {
  6830. $nextStaff = $verifyDetail [$key + 1] [0];
  6831. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  6832. $roleSTF = true;
  6833. }
  6834. break;
  6835. }
  6836. }
  6837. if (! $roleSTF) {
  6838. $nowStaff = $nextStaff;
  6839. $verifyStaff [$this->staff [0] ['sid']] = array (
  6840. 'date' => date ( 'Y-m-d' ),
  6841. 'opinion' => $opinion,
  6842. 'status' => $status,
  6843. 'nextStaff' => $nextStaff
  6844. );
  6845. } else {
  6846. // 获取角色下的所有用户ID
  6847. $nowStaffList = array ();
  6848. foreach ( $verifyDetail as $vfk ) {
  6849. if ($vfk [1] == 'ROLE') {
  6850. $vStaffString = json_decode ( $vfk [3] );
  6851. foreach ( $vStaffString as $key => $value ) {
  6852. $staffK = explode ( "_", $value );
  6853. array_push ( $nowStaffList, $staffK [0] );
  6854. }
  6855. }
  6856. }
  6857. $nowStaff = implode ( ',', $nowStaffList );
  6858. $verifyStaff [$this->staff [0] ['sid']] = array (
  6859. 'date' => date ( 'Y-m-d' ),
  6860. 'opinion' => $opinion,
  6861. 'status' => $status,
  6862. 'nextStaff' => $nextStaff,
  6863. 'ROLE' => 0
  6864. );
  6865. }
  6866. if ($status == 3) {
  6867. $verifyStaff ['final'] = $status;
  6868. $verifyStaff [$this->staff [0] ['sid']] = array (
  6869. 'date' => date ( 'Y-m-d' ),
  6870. 'opinion' => $opinion,
  6871. 'status' => $status
  6872. );
  6873. }
  6874. $vStaffString = json_encode ( $verifyStaff );
  6875. $receipt->nowStaff = $nowStaff;
  6876. $receipt->verifyStaff = $vStaffString;
  6877. }
  6878. // 角色审批
  6879. if (isset ( $VS ['ROLE'] )) {
  6880. // 找出角色人 当前审批角色组
  6881. $verifyJSStaff = array ();
  6882. $nowStaffList2 = array ();
  6883. foreach ( $verifyDetail as $key => $value ) {
  6884. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  6885. $verifyJSStaff = json_decode ( $value [3] );
  6886. foreach ( $verifyJSStaff as $m ) {
  6887. $staffK = explode ( "_", $m );
  6888. array_push ( $nowStaffList2, $staffK [0] );
  6889. }
  6890. // print_r($nowStaffList2);
  6891. }
  6892. }
  6893. $RoleVerifyStaff = array ();
  6894. foreach ( $verifyStaff as $key => $value ) {
  6895. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  6896. foreach ( $nowStaffList2 as $m ) {
  6897. if ($key == $m . "_R")
  6898. $RoleVerifyStaff [$key] = $value;
  6899. }
  6900. }
  6901. }
  6902. // print_r($verifyStaff);
  6903. // print_r($nowStaffList2);
  6904. // print_r($RoleVerifyStaff);
  6905. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  6906. // print_r($verifyJSStaff);
  6907. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  6908. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  6909. // 下一个审批人ID
  6910. $nextStaff = 0;
  6911. $falg = false;
  6912. foreach ( $verifyDetail as $key => $value ) {
  6913. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  6914. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  6915. $falg = true;
  6916. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  6917. $nowStaffList = array ();
  6918. foreach ( $vStaffString as $v ) {
  6919. $staffK = explode ( "_", $v );
  6920. array_push ( $nowStaffList, $staffK [0] );
  6921. }
  6922. $nowStaff = implode ( ',', $nowStaffList );
  6923. $nextStaff = $verifyDetail [$key + 1] [0];
  6924. } elseif (isset ( $verifyDetail [$key + 1] )) {
  6925. $nextStaff = $verifyDetail [$key + 1] [0];
  6926. $nowStaff = $nextStaff;
  6927. } else
  6928. $nowStaff = '';
  6929. break;
  6930. }
  6931. }
  6932. if ($falg)
  6933. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6934. 'date' => date ( 'Y-m-d' ),
  6935. 'opinion' => $opinion,
  6936. 'status' => $status,
  6937. 'nextStaff' => $nextStaff,
  6938. 'ROLE' => 1
  6939. );
  6940. else
  6941. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6942. 'date' => date ( 'Y-m-d' ),
  6943. 'opinion' => $opinion,
  6944. 'status' => $status,
  6945. 'nextStaff' => $nextStaff
  6946. );
  6947. // print_r($verifyStaff);
  6948. // echo $nowStaff;die;
  6949. } else { // 进入下一个角色或者审批人
  6950. /*
  6951. *
  6952. */
  6953. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  6954. //
  6955. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  6956. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6957. 'date' => date ( 'Y-m-d' ),
  6958. 'opinion' => $opinion,
  6959. 'status' => $status,
  6960. 'nextStaff' => $VS ['nextStaff'],
  6961. 'ROLE' => 1
  6962. );
  6963. // print_r($verifyStaff);
  6964. // die;
  6965. }
  6966. if ($status == 3) {
  6967. $verifyStaff ['final'] = $status;
  6968. $verifyStaff [$this->staff [0] ['sid']] = array (
  6969. 'date' => date ( 'Y-m-d' ),
  6970. 'opinion' => $opinion,
  6971. 'status' => $status
  6972. );
  6973. }
  6974. $vStaffString = json_encode ( $verifyStaff );
  6975. $receipt->verifyStaff = $vStaffString;
  6976. $receipt->nowStaff = $nowStaff;
  6977. // die;
  6978. // }
  6979. // print_r($verifyStaff);
  6980. // die;
  6981. }
  6982. // print_r($verifyStaff);die;
  6983. }
  6984. // print_r($verifyDetail);
  6985. $roleKey = 0;
  6986. $roleId = 0;
  6987. $verifyDetailCopy = array ();
  6988. foreach ( $verifyDetail as $k => $v ) {
  6989. if ($v [1] == 'ROLE') {
  6990. $roleId = $v [0];
  6991. $roleVerify = json_decode ( $v [3], true );
  6992. $roleKey = $k;
  6993. $roleArray = array ();
  6994. foreach ( $roleVerify as $o => $p ) {
  6995. $staffID = explode ( '_', $p );
  6996. $exp = array (
  6997. 0 => $staffID [0],
  6998. 1 => $staffID [1]
  6999. );
  7000. array_push ( $roleArray, $exp );
  7001. }
  7002. $verifyDetailCopy [$v [0]] = $roleArray;
  7003. }
  7004. }
  7005. // print_r($verifyDetail);
  7006. foreach ( $verifyDetailCopy as $k => $v ) {
  7007. foreach ( $verifyDetail as $m => $n ) {
  7008. if ($n [0] == $k) {
  7009. array_splice ( $verifyDetail, $m, 1, $v );
  7010. }
  7011. }
  7012. }
  7013. // die;
  7014. // if (!empty($roleArray))
  7015. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  7016. // echo $roleId;
  7017. // print_r($verifyStaff);
  7018. // print_r($verifyDetail);
  7019. // die;
  7020. Doo::loadModel ( "receiptLog" );
  7021. $receiptLog = new receiptLog ();
  7022. // 审批日志
  7023. if (! isset ( $verifyStaff ['final'] )) {
  7024. if (! empty ( $roleId )) {
  7025. Doo::loadModel ( "role" );
  7026. $role = new role ();
  7027. $roleInfo = $role->getOne ( array (
  7028. 'where' => 'rid=' . $roleId,
  7029. 'asArray' => true
  7030. ) );
  7031. $receiptLog->rolename = $roleInfo ['name'];
  7032. }
  7033. $receiptLog->username = $this->staff [0] ['username'];
  7034. $receiptLog->uid = $this->staff [0] ['sid'];
  7035. $receiptLog->date = date ( "Y-m-d" );
  7036. $receiptLog->opinion = $opinion;
  7037. $receiptLog->img = $this->staff [0] ['avatar'];
  7038. $receiptLog->status = 1;
  7039. $receiptLog->rid = $rid;
  7040. $receiptLog->insert ();
  7041. }
  7042. if (isset ( $verifyStaff ['final'] )) { // rDetail
  7043. $receipt->verifyBreakup = $verifyString;
  7044. $receipt->status = 3;
  7045. $receiptDetailObj->status = 3;
  7046. $receiptDetailObj->update ( array (
  7047. 'where' => 'rid=' . $rid
  7048. ) );
  7049. if (! empty ( $roleId )) {
  7050. Doo::loadModel ( "role" );
  7051. $role = new role ();
  7052. $roleInfo = $role->getOne ( array (
  7053. 'where' => 'rid=' . $roleId,
  7054. 'asArray' => true
  7055. ) );
  7056. $receiptLog->rolename = $roleInfo ['name'];
  7057. }
  7058. $receiptLog->username = $this->staff [0] ['username'];
  7059. $receiptLog->uid = $this->staff [0] ['sid'];
  7060. $receiptLog->date = date ( "Y-m-d" );
  7061. $receiptLog->opinion = $opinion;
  7062. $receiptLog->img = $this->staff [0] ['avatar'];
  7063. $receiptLog->status = 3;
  7064. $receiptLog->rid = $rid;
  7065. $receiptLog->insert ();
  7066. // 微信企业号通知
  7067. $this->setWXMsg ( $rid, 3 );
  7068. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  7069. $receipt->status = 1;
  7070. $reviseSum = 0;
  7071. $receipt->verifyBreakup = $verifyString;
  7072. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  7073. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7074. foreach ( $reviseDetail as $key => $value ) {
  7075. $receiptDetailObj = new receiptDetail ();
  7076. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7077. $receiptDetailObj->item = $value ['description'];
  7078. $receiptDetailObj->itemCategory = "报销金额调整";
  7079. $receiptDetailObj->price = $value ['price'];
  7080. $receiptDetailObj->date = $receiptDetail ['date'];
  7081. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  7082. $receiptDetailObj->rid = $rid;
  7083. $receiptDetailObj->status = 1;
  7084. $receiptDetailObj->insert ();
  7085. $reviseSum += $value ['price'];
  7086. }
  7087. $itemStatistics = new itemStatistics ();
  7088. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7089. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7090. $itemStatistics->price = $reviseSum;
  7091. $itemStatistics->itemCategory = "报销金额调整";
  7092. $itemStatistics->date = $receiptDetail ['date'];
  7093. $itemStatistics->insert ();
  7094. }
  7095. $receiptDetailObj = new receiptDetail ();
  7096. $receiptDetailObj->status = 1;
  7097. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  7098. $receiptDetailObj->update ( array (
  7099. 'where' => 'rid=' . $rid
  7100. ) );
  7101. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7102. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7103. $stat = $statistics->getOne ( array (
  7104. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  7105. 'asArray' => true
  7106. ) );
  7107. if (empty ( $stat )) {
  7108. $statistics->date = $receiptDetail ['date'];
  7109. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7110. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7111. $statistics->agPrice = $receiptDetail ['sum'];
  7112. $statistics->rePrice = $reviseSum;
  7113. $statistics->insert ();
  7114. } else {
  7115. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  7116. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  7117. $statistics->update ( array (
  7118. 'where' => 'sid=' . $stat ['sid']
  7119. ) );
  7120. }
  7121. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7122. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7123. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  7124. foreach ( $accountItem ['cSum'] as $key => $value ) {
  7125. if ($key == "agencySum") {
  7126. $iStatistics = $itemStatistics->getOne ( array (
  7127. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  7128. 'asArray' => true
  7129. ) );
  7130. if (empty ( $iStatistics )) {
  7131. $itemStatistics->cid = $receiptDetail ['cid'];
  7132. ;
  7133. $itemStatistics->staff = $receiptDetail ['staff'];
  7134. $itemStatistics->price = $value;
  7135. $itemStatistics->itemCategory = $this->AGENCY;
  7136. $itemStatistics->date = $receiptDetail ['date'];
  7137. $itemStatistics->insert ();
  7138. } else {
  7139. if (! empty ( $value )) {
  7140. $itemStatistics->price = $value + $iStatistics ['price'];
  7141. $itemStatistics->update ( array (
  7142. 'where' => 'sid=' . $iStatistics ['sid']
  7143. ) );
  7144. }
  7145. }
  7146. } elseif ($key == "travelSum") {
  7147. $iStatistics = $itemStatistics->getOne ( array (
  7148. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  7149. 'asArray' => true
  7150. ) );
  7151. if (empty ( $iStatistics )) {
  7152. $itemStatistics->cid = $receiptDetail ['cid'];
  7153. $itemStatistics->staff = $receiptDetail ['staff'];
  7154. $itemStatistics->price = $value;
  7155. $itemStatistics->itemCategory = $this->TRAVEL;
  7156. $itemStatistics->date = $receiptDetail ['date'];
  7157. $itemStatistics->insert ();
  7158. } else {
  7159. if (! empty ( $value )) {
  7160. $itemStatistics->price = $value + $iStatistics ['price'];
  7161. $itemStatistics->update ( array (
  7162. 'where' => 'sid=' . $iStatistics ['sid']
  7163. ) );
  7164. }
  7165. }
  7166. } elseif ($key == "trainSum") {
  7167. $iStatistics = $itemStatistics->getOne ( array (
  7168. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  7169. 'asArray' => true
  7170. ) );
  7171. if (empty ( $iStatistics )) {
  7172. $itemStatistics->cid = $receiptDetail ['cid'];
  7173. $itemStatistics->staff = $receiptDetail ['staff'];
  7174. $itemStatistics->price = $value;
  7175. $itemStatistics->itemCategory = $this->TRAIN;
  7176. $itemStatistics->date = $receiptDetail ['date'];
  7177. $itemStatistics->insert ();
  7178. } else {
  7179. if (! empty ( $value )) {
  7180. $itemStatistics->price = $value + $iStatistics ['price'];
  7181. $itemStatistics->update ( array (
  7182. 'where' => 'sid=' . $iStatistics ['sid']
  7183. ) );
  7184. }
  7185. }
  7186. } elseif ($key == "otherSum") {
  7187. $iStatistics = $itemStatistics->getOne ( array (
  7188. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  7189. 'asArray' => true
  7190. ) );
  7191. if (empty ( $iStatistics )) {
  7192. $itemStatistics->cid = $receiptDetail ['cid'];
  7193. $itemStatistics->staff = $receiptDetail ['staff'];
  7194. $itemStatistics->price = $value;
  7195. $itemStatistics->itemCategory = $this->OTHER;
  7196. $itemStatistics->date = $receiptDetail ['date'];
  7197. $itemStatistics->insert ();
  7198. } else {
  7199. if (! empty ( $value )) {
  7200. $itemStatistics->price = $value + $iStatistics ['price'];
  7201. $itemStatistics->update ( array (
  7202. 'where' => 'sid=' . $iStatistics ['sid']
  7203. ) );
  7204. }
  7205. }
  7206. }
  7207. }
  7208. $receipt->pastDate = date ( "Y-m-d" );
  7209. // 微信企业号通知
  7210. $this->setWXMsg ( $rid, 1 );
  7211. }
  7212. $receipt->amount = $amount;
  7213. $receipt->update ( array (
  7214. 'where' => ' rid = ' . $rid
  7215. ) );
  7216. return "/approvalExpenses/pendApproval";
  7217. }
  7218. }
  7219. function expensesRetreats() {
  7220. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7221. if (! empty ( $rid )) {
  7222. // 操作记录
  7223. Doo::loadModel ( "receipt" );
  7224. $receipt = new receipt ();
  7225. Doo::loadModel ( "receiptLog" );
  7226. $receiptLog = new receiptLog ();
  7227. Doo::loadModel ( "verify" );
  7228. $verify = new verify ();
  7229. $receiptInfo = $receipt->getOne ( array (
  7230. 'where' => 'rid=' . $rid,
  7231. 'asArray' => true
  7232. ) );
  7233. $vr = $verify->getOne ( array (
  7234. 'where' => 'vid=' . $receiptInfo ['verify'],
  7235. 'asArray' => true
  7236. ) );
  7237. $jd = json_decode ( $vr ['staff'] );
  7238. $roleId = 0;
  7239. foreach ( $jd as $key => $value ) {
  7240. if ($value [1] == 'ROLE') {
  7241. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7242. if ($pos !== false) {
  7243. $roleId = $value [0];
  7244. }
  7245. }
  7246. }
  7247. // 审批日志
  7248. // echo $roleId;die;
  7249. if (! empty ( $roleId )) {
  7250. Doo::loadModel ( "role" );
  7251. $role = new role ();
  7252. $roleInfo = $role->getOne ( array (
  7253. 'where' => 'rid=' . $roleId,
  7254. 'asArray' => true
  7255. ) );
  7256. $receiptLog->rolename = $roleInfo ['name'];
  7257. }
  7258. $receiptLog->username = $this->staff [0] ['username'];
  7259. $receiptLog->uid = $this->staff [0] ['sid'];
  7260. $receiptLog->date = date ( "Y-m-d" );
  7261. $receiptLog->opinion = '撤回';
  7262. $receiptLog->img = $this->staff [0] ['avatar'];
  7263. $receiptLog->status = 4;
  7264. $receiptLog->rid = $rid;
  7265. $receiptLog->insert ();
  7266. $receipt->status = 4;
  7267. $receipt->update ( array (
  7268. 'where' => 'rid=' . $rid
  7269. ) );
  7270. // 微信企业号通知
  7271. $this->setWXMsg ( $rid, 2 );
  7272. }
  7273. // echo "ddd";
  7274. return '/approvalExpenses/pendApproval';
  7275. }
  7276. function updateCheReceipt() {
  7277. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7278. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7279. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  7280. if (! empty ( $rid )) {
  7281. // 操作记录
  7282. Doo::loadModel ( "receipt" );
  7283. $receipt = new receipt ();
  7284. Doo::loadModel ( "receiptLog" );
  7285. $receiptLog = new receiptLog ();
  7286. Doo::loadModel ( "verify" );
  7287. $verify = new verify ();
  7288. $receiptInfo = $receipt->getOne ( array (
  7289. 'where' => 'rid=' . $rid,
  7290. 'asArray' => true
  7291. ) );
  7292. $vr = $verify->getOne ( array (
  7293. 'where' => 'vid=' . $receiptInfo ['verify'],
  7294. 'asArray' => true
  7295. ) );
  7296. $jd = json_decode ( $vr ['staff'] );
  7297. $roleId = 0;
  7298. foreach ( $jd as $key => $value ) {
  7299. if ($value [1] == 'ROLE') {
  7300. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7301. if ($pos !== false) {
  7302. $roleId = $value [0];
  7303. }
  7304. }
  7305. }
  7306. // 审批日志
  7307. // echo $roleId;die;
  7308. if (! empty ( $roleId )) {
  7309. Doo::loadModel ( "role" );
  7310. $role = new role ();
  7311. $roleInfo = $role->getOne ( array (
  7312. 'where' => 'rid=' . $roleId,
  7313. 'asArray' => true
  7314. ) );
  7315. $receiptLog->rolename = $roleInfo ['name'];
  7316. }
  7317. $receiptLog->username = $this->staff [0] ['username'];
  7318. $receiptLog->uid = $this->staff [0] ['sid'];
  7319. $receiptLog->date = date ( "Y-m-d" );
  7320. $receiptLog->opinion = $opinion;
  7321. $receiptLog->img = $this->staff [0] ['avatar'];
  7322. $receiptLog->status = 4;
  7323. $receiptLog->rid = $rid;
  7324. $receiptLog->insert ();
  7325. $receipt->status = 4;
  7326. $receipt->update ( array (
  7327. 'where' => 'rid=' . $rid
  7328. ) );
  7329. // 微信企业号通知
  7330. $this->setWXMsg ( $rid, 2 );
  7331. echo json_encode ( array (
  7332. 'status' => 1
  7333. ) );
  7334. die ();
  7335. }
  7336. echo json_encode ( array (
  7337. 'status' => 2
  7338. ) );
  7339. die ();
  7340. // echo "ddd";
  7341. // return '/saeaBorad';
  7342. }
  7343. function revisePrice() {
  7344. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  7345. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  7346. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7347. // echo $price;die;
  7348. if (! empty ( $rid )) {
  7349. Doo::loadModel ( "receipt" );
  7350. $receipt = new receipt ();
  7351. $receiptDetail = $receipt->getOne ( array (
  7352. 'where' => 'rid=' . $rid . ' and status=2 ',
  7353. 'asArray' => true
  7354. ) );
  7355. if (empty ( $receiptDetail ))
  7356. return "/approval";
  7357. $reviseDetail = array ();
  7358. if (empty ( $receiptDetail ['reviseDetail'] )) {
  7359. array_push ( $reviseDetail, array (
  7360. 'sid' => $this->staff [0] ['sid'],
  7361. 'name' => $this->staff [0] ['username'],
  7362. 'description' => $description,
  7363. 'price' => $price
  7364. ) );
  7365. $reviseDetailString = json_encode ( $reviseDetail );
  7366. $receipt->reviseDetail = $reviseDetailString;
  7367. $receipt->revisePrice = $price;
  7368. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7369. } else {
  7370. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7371. array_push ( $reviseDetail, array (
  7372. 'sid' => $this->staff [0] ['sid'],
  7373. 'name' => $this->staff [0] ['username'],
  7374. 'description' => $description,
  7375. 'price' => $price
  7376. ) );
  7377. $reviseDetailString = json_encode ( $reviseDetail );
  7378. $receipt->reviseDetail = $reviseDetailString;
  7379. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  7380. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7381. }
  7382. $receipt->update ( array (
  7383. 'where' => 'rid=' . $rid
  7384. ) );
  7385. }
  7386. return '/approvalEdi/' . $rid;
  7387. }
  7388. function personalCollect() {
  7389. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7390. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  7391. $this->showCache ( $path );
  7392. Doo::loadModel ( "receiptDetail" );
  7393. Doo::loadModel ( "itemStatistics" );
  7394. Doo::loadModel ( 'statistics' );
  7395. $statistics = new statistics ();
  7396. $itemStatistics = new itemStatistics ();
  7397. $receiptDetail = new receiptDetail ();
  7398. $receiptCollectList = $receiptDetail->find ( array (
  7399. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7400. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7401. 'groupby' => 'itemCategory,Month(date)',
  7402. 'asArray' => true
  7403. ) );
  7404. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  7405. 'where' => 'staff=' . $this->staff [0] ['sid'],
  7406. 'asArray' => true
  7407. ) );
  7408. // create collect html
  7409. $collectArray = array (
  7410. '日常相关费用' => array (),
  7411. '差旅相关费用' => array (),
  7412. '培训班费用' => array (),
  7413. '其他' => array ()
  7414. );
  7415. $adjustment = array ();
  7416. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  7417. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7418. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  7419. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7420. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  7421. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7422. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  7423. array_push ( $collectArray ['其他'], $collectHtml );
  7424. $data ['collectArray'] = $collectArray;
  7425. // statistics html
  7426. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7427. if (empty ( $stList ))
  7428. $stList = array (
  7429. 'rePrice' => 0,
  7430. 'agPrice' => 0
  7431. );
  7432. $data ['stList'] = array (
  7433. 'rePrice' => $stList ['rePrice'],
  7434. 'agPrice' => $stList ['agPrice'],
  7435. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7436. );
  7437. // Adjustment price html
  7438. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7439. array_push ( $adjustment, $collectHtml );
  7440. $data ['adjustment'] = $adjustment;
  7441. // total price html
  7442. $collectHtml = "";
  7443. $total = 0;
  7444. for($i = 1; $i <= 12; $i ++) {
  7445. $sumPrice = 0;
  7446. foreach ( $receiptCollectList as $key => $value ) {
  7447. if ($value ['month'] == $i) {
  7448. $sumPrice += $value ['price'];
  7449. }
  7450. }
  7451. if ($sumPrice == 0)
  7452. $collectHtml .= '<td class="taR">-</td>';
  7453. else
  7454. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7455. $total += $sumPrice;
  7456. }
  7457. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7458. $data ['totalPrice'] = $collectHtml;
  7459. $data ['year'] = $year;
  7460. $data ['totalYear'] = $total;
  7461. $data ['memu'] = "receipt";
  7462. $data ['staff'] = $this->staff;
  7463. $data ['receiptMemu'] = 'personalCollect';
  7464. $data ['verifyId'] = $this->verifyId;
  7465. $data ['executeId'] = $this->executeId;
  7466. // year staff status 2,4
  7467. if ($year < date ( "Y" )) {
  7468. Doo::loadModel ( 'receipt' );
  7469. $receipt = new receipt ();
  7470. $receiptList = $receipt->find ( array (
  7471. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7472. 'asArray' => true
  7473. ) );
  7474. if (empty ( $receiptList )) {
  7475. ob_start ();
  7476. $this->render ( "/admin/saea_slist_collect", $data );
  7477. $this->cacheFile ( $path );
  7478. die ();
  7479. }
  7480. }
  7481. $this->render ( "/admin/saea_slist_collect", $data );
  7482. }
  7483. function personalCollectDetail() {
  7484. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7485. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  7486. $this->showCache ( $path );
  7487. Doo::loadModel ( "receiptDetail" );
  7488. Doo::loadModel ( "itemStatistics" );
  7489. Doo::loadModel ( 'statistics' );
  7490. Doo::loadModel ( 'accountItem' );
  7491. $accountItem = new accountItem ();
  7492. $statistics = new statistics ();
  7493. $itemStatistics = new itemStatistics ();
  7494. $receiptDetail = new receiptDetail ();
  7495. $receiptCollectList = $receiptDetail->find ( array (
  7496. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  7497. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7498. 'groupby' => 'item,Month(date)',
  7499. 'asArray' => true
  7500. ) );
  7501. $accountList = $accountItem->find ( array (
  7502. 'asArray' => true
  7503. ) );
  7504. // create CollectDetail HTML
  7505. $collectHtml = array ();
  7506. foreach ( $accountList as $key => $value ) {
  7507. $html = "";
  7508. $asum = 0;
  7509. for($i = 1; $i <= 12; $i ++) {
  7510. $falg = true;
  7511. foreach ( $receiptCollectList as $v ) {
  7512. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7513. $asum += $v ['price'];
  7514. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7515. $falg = false;
  7516. break;
  7517. }
  7518. }
  7519. if ($falg)
  7520. $html .= '<td class="taR">-</td>';
  7521. }
  7522. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7523. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7524. }
  7525. $data ['collectHtml'] = $collectHtml;
  7526. // create Adjustment price html
  7527. $receiptCollectList = $receiptDetail->find ( array (
  7528. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7529. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7530. 'groupby' => 'itemCategory,Month(date)',
  7531. 'asArray' => true
  7532. ) );
  7533. $adjustment = array ();
  7534. $collectArray = array (
  7535. '日常相关费用' => array (),
  7536. '差旅相关费用' => array (),
  7537. '培训班费用' => array (),
  7538. '其他' => array ()
  7539. );
  7540. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7541. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7542. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7543. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7544. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7545. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7546. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7547. array_push ( $collectArray ['其他'], $collectHtml );
  7548. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7549. array_push ( $adjustment, $collectHtml );
  7550. // total price html
  7551. $collectHtml = "";
  7552. $total = 0;
  7553. for($i = 1; $i <= 12; $i ++) {
  7554. $sumPrice = 0;
  7555. foreach ( $receiptCollectList as $key => $value ) {
  7556. if ($value ['month'] == $i) {
  7557. $sumPrice += $value ['price'];
  7558. }
  7559. }
  7560. if ($sumPrice == 0)
  7561. $collectHtml .= '<td class="taR">-</td>';
  7562. else
  7563. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7564. $total += $sumPrice;
  7565. }
  7566. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7567. // statistics html
  7568. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7569. if (empty ( $stList ))
  7570. $stList = array (
  7571. 'rePrice' => 0,
  7572. 'agPrice' => 0
  7573. );
  7574. $data ['stList'] = array (
  7575. 'rePrice' => $stList ['rePrice'],
  7576. 'agPrice' => $stList ['agPrice'],
  7577. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7578. );
  7579. $data ['collectArray'] = $collectArray;
  7580. $data ['adjustment'] = $adjustment;
  7581. $data ['totalPrice'] = $collectHtml;
  7582. $data ['totalYear'] = $total;
  7583. $data ['year'] = $year;
  7584. $data ['memu'] = "receipt";
  7585. $data ['staff'] = $this->staff;
  7586. $data ['receiptMemu'] = 'personalCollect';
  7587. $data ['verifyId'] = $this->verifyId;
  7588. $data ['executeId'] = $this->executeId;
  7589. // year staff status 2,4
  7590. if ($year < date ( "Y" )) {
  7591. Doo::loadModel ( 'receipt' );
  7592. $receipt = new receipt ();
  7593. $receiptList = $receipt->find ( array (
  7594. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7595. 'asArray' => true
  7596. ) );
  7597. if (empty ( $receiptList )) {
  7598. ob_start ();
  7599. $this->render ( "/admin/saeaCollectArticles", $data );
  7600. $this->cacheFile ( $path );
  7601. die ();
  7602. }
  7603. }
  7604. $this->render ( "/admin/saeaCollectArticles", $data );
  7605. }
  7606. function companyCategoryCollect() {
  7607. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7608. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  7609. $this->showCache ( $path );
  7610. Doo::loadModel ( 'L_category' );
  7611. Doo::loadModel ( 'itemStatistics' );
  7612. Doo::loadModel ( 'statistics' );
  7613. $statistics = new statistics ();
  7614. $Lcategory = new L_category ();
  7615. $itemStatistics = new itemStatistics ();
  7616. $LcategoryList = $Lcategory->find ( array (
  7617. 'asArray' => true
  7618. ) ); // 'staff='.$this->staff[0]['sid']." and
  7619. $itemStatisticsList = $itemStatistics->find ( array (
  7620. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7621. 'where' => " Year(date)=" . $year,
  7622. 'groupby' => 'cid,Month(date)',
  7623. 'asArray' => true
  7624. ) );
  7625. // ceatre companyCollectHtml
  7626. foreach ( $LcategoryList as $value ) {
  7627. $html = "";
  7628. $asum = 0;
  7629. for($i = 1; $i <= 12; $i ++) {
  7630. $falg = true;
  7631. foreach ( $itemStatisticsList as $v ) {
  7632. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  7633. $asum += $v ['price'];
  7634. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7635. $falg = false;
  7636. break;
  7637. }
  7638. }
  7639. if ($falg)
  7640. $html .= '<td class="taR">-</td>';
  7641. }
  7642. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7643. $collectHtml [$value ['title']] = array (
  7644. 'html' => $html,
  7645. 'cid' => $value ['cid']
  7646. );
  7647. }
  7648. $data ['companyHtml'] = $collectHtml;
  7649. // total price html
  7650. $collectHtml = "";
  7651. $total = 0;
  7652. for($i = 1; $i <= 12; $i ++) {
  7653. $sumPrice = 0;
  7654. foreach ( $itemStatisticsList as $key => $value ) {
  7655. if ($value ['month'] == $i) {
  7656. $sumPrice += $value ['price'];
  7657. }
  7658. }
  7659. if ($sumPrice == 0)
  7660. $collectHtml .= '<td class="taR">-</td>';
  7661. else
  7662. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7663. $total += $sumPrice;
  7664. }
  7665. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7666. $data ['companyTotalHtml'] = $collectHtml;
  7667. $data ['total'] = $total;
  7668. // statistics html
  7669. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7670. if (empty ( $stList ))
  7671. $stList = array (
  7672. 'rePrice' => 0,
  7673. 'agPrice' => 0
  7674. );
  7675. $data ['stList'] = array (
  7676. 'rePrice' => $stList ['rePrice'],
  7677. 'agPrice' => $stList ['agPrice'],
  7678. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7679. );
  7680. $data ['year'] = $year;
  7681. $data ['memu'] = "receipt";
  7682. $data ['staff'] = $this->staff;
  7683. $data ['receiptMemu'] = 'companyCategoryCollect';
  7684. $data ['verifyId'] = $this->verifyId;
  7685. $data ['executeId'] = $this->executeId;
  7686. // year staff status 2,4
  7687. if ($year < date ( "Y" )) {
  7688. Doo::loadModel ( 'receipt' );
  7689. $receipt = new receipt ();
  7690. $receiptList = $receipt->find ( array (
  7691. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  7692. 'asArray' => true
  7693. ) );
  7694. if (empty ( $receiptList )) {
  7695. ob_start ();
  7696. $this->render ( "/admin/saeaCompanyCollect", $data );
  7697. $this->cacheFile ( $path );
  7698. die ();
  7699. }
  7700. }
  7701. $this->render ( "/admin/saeaCompanyCollect", $data );
  7702. }
  7703. function categoryCollectDetail() {
  7704. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7705. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  7706. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  7707. $this->showCache ( $path );
  7708. Doo::loadModel ( 'statistics' );
  7709. $statistics = new statistics ();
  7710. Doo::loadModel ( "receiptDetail" );
  7711. $receiptDetail = new receiptDetail ();
  7712. Doo::loadModel ( 'L_category' );
  7713. $Lcategory = new L_category ();
  7714. Doo::loadModel ( 'accountItem' );
  7715. $accountItem = new accountItem ();
  7716. $LcategoryList = $Lcategory->find ( array (
  7717. 'asArray' => true
  7718. ) );
  7719. if ($cid == 0) {
  7720. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7721. if ($cid == 0)
  7722. $cid = $LcategoryList [0] ['cid'];
  7723. }
  7724. $data ['LcategoryList'] = $LcategoryList;
  7725. $receiptCollectList = $receiptDetail->find ( array (
  7726. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  7727. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7728. 'groupby' => 'item,Month(pastDate)',
  7729. 'asArray' => true
  7730. ) );
  7731. $accountList = $accountItem->find ( array (
  7732. 'asArray' => true
  7733. ) );
  7734. // create CollectDetail HTML
  7735. $collectHtml = array ();
  7736. foreach ( $accountList as $key => $value ) {
  7737. $html = "";
  7738. $asum = 0;
  7739. for($i = 1; $i <= 12; $i ++) {
  7740. $falg = true;
  7741. foreach ( $receiptCollectList as $v ) {
  7742. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7743. $asum += $v ['price'];
  7744. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7745. $falg = false;
  7746. break;
  7747. }
  7748. }
  7749. if ($falg)
  7750. $html .= '<td class="taR">-</td>';
  7751. }
  7752. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7753. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7754. }
  7755. $data ['collectHtml'] = $collectHtml;
  7756. // create Adjustment price html
  7757. $receiptCollectList = $receiptDetail->find ( array (
  7758. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  7759. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7760. 'groupby' => 'itemCategory,Month(pastDate)',
  7761. 'asArray' => true
  7762. ) );
  7763. $adjustment = array ();
  7764. $collectArray = array (
  7765. '日常相关费用' => array (),
  7766. '差旅相关费用' => array (),
  7767. '培训班费用' => array (),
  7768. '其他' => array ()
  7769. );
  7770. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7771. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7772. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7773. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7774. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7775. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7776. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7777. array_push ( $collectArray ['其他'], $collectHtml );
  7778. $data ['collectArray'] = $collectArray;
  7779. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7780. array_push ( $adjustment, $collectHtml );
  7781. $data ['adjustment'] = $adjustment;
  7782. // total price html
  7783. $collectHtml = "";
  7784. $total = 0;
  7785. for($i = 1; $i <= 12; $i ++) {
  7786. $sumPrice = 0;
  7787. foreach ( $receiptCollectList as $key => $value ) {
  7788. if ($value ['month'] == $i) {
  7789. $sumPrice += $value ['price'];
  7790. }
  7791. }
  7792. if ($sumPrice == 0)
  7793. $collectHtml .= '<td class="taR">-</td>';
  7794. else
  7795. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7796. $total += $sumPrice;
  7797. }
  7798. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7799. // statistics html
  7800. $stList = $statistics->statisticsByCid ( $year, $cid );
  7801. if (empty ( $stList ))
  7802. $stList = array (
  7803. 'rePrice' => 0,
  7804. 'agPrice' => 0
  7805. );
  7806. $data ['stList'] = array (
  7807. 'rePrice' => $stList ['rePrice'],
  7808. 'agPrice' => $stList ['agPrice'],
  7809. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7810. );
  7811. $data ['totalYear'] = $total;
  7812. $data ['year'] = $year;
  7813. $data ['cid'] = $cid;
  7814. $data ['memu'] = "receipt";
  7815. $data ['staff'] = $this->staff;
  7816. $data ['receiptMemu'] = 'companyCategoryCollect';
  7817. $data ['verifyId'] = $this->verifyId;
  7818. $data ['executeId'] = $this->executeId;
  7819. // year staff status 2,4
  7820. if ($year < date ( "Y" )) {
  7821. Doo::loadModel ( 'receipt' );
  7822. $receipt = new receipt ();
  7823. $receiptList = $receipt->find ( array (
  7824. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  7825. 'asArray' => true
  7826. ) );
  7827. if (empty ( $receiptList )) {
  7828. ob_start ();
  7829. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7830. $this->cacheFile ( $path );
  7831. die ();
  7832. }
  7833. }
  7834. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7835. }
  7836. function staffCollect() {
  7837. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7838. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  7839. // $this->showCache($path);
  7840. Doo::loadModel ( 'statistics' );
  7841. $statistics = new statistics ();
  7842. Doo::loadModel ( "receiptDetail" );
  7843. $receiptDetail = new receiptDetail ();
  7844. Doo::loadModel ( 'L_category' );
  7845. $Lcategory = new L_category ();
  7846. Doo::loadModel ( 'accountItem' );
  7847. $accountItem = new accountItem ();
  7848. Doo::loadModel ( 'staff' );
  7849. $staff = new staff ();
  7850. Doo::loadModel ( 'itemStatistics' );
  7851. $itemStatistics = new itemStatistics ();
  7852. /*
  7853. * $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']));
  7854. */
  7855. // statistics html
  7856. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7857. if (empty ( $stList ))
  7858. $stList = array (
  7859. 'rePrice' => 0,
  7860. 'agPrice' => 0
  7861. );
  7862. $data ['stList'] = array (
  7863. 'rePrice' => $stList ['rePrice'],
  7864. 'agPrice' => $stList ['agPrice'],
  7865. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7866. );
  7867. // ---
  7868. $staffList = $staff->find ( array (
  7869. 'where' => 'username !="admin"',
  7870. 'asArray' => true
  7871. ) );
  7872. $LcategoryList = $Lcategory->find ( array (
  7873. 'asArray' => true
  7874. ) ); // 'staff='.$this->staff[0]['sid']." and
  7875. $itemStatisticsList = $itemStatistics->find ( array (
  7876. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7877. 'where' => " Year(date)=" . $year,
  7878. 'groupby' => 'staff,Month(date)',
  7879. 'asArray' => true
  7880. ) );
  7881. $categoryList = $staff->find ( array (
  7882. 'select' => 'COUNT(*) as count,cid,category',
  7883. 'where' => 'username !="admin"',
  7884. 'groupby' => 'cid',
  7885. 'asArray' => true
  7886. ) );
  7887. // print_r($itemStatisticsList);die;
  7888. // ceatre companyCollectHtml
  7889. foreach ( $categoryList as $vlu ) {
  7890. $count = $vlu ['count'] + 1;
  7891. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  7892. $m1 = 0;
  7893. $m2 = 0;
  7894. $m3 = 0;
  7895. $m4 = 0;
  7896. $m5 = 0;
  7897. $m6 = 0;
  7898. $m7 = 0;
  7899. $m8 = 0;
  7900. $m9 = 0;
  7901. $m10 = 0;
  7902. $m11 = 0;
  7903. $m12 = 0;
  7904. $m13 = 0;
  7905. foreach ( $staffList as $value ) {
  7906. if ($vlu ['cid'] == $value ['cid']) {
  7907. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  7908. $asum = 0;
  7909. for($i = 1; $i <= 12; $i ++) {
  7910. $falg = true;
  7911. foreach ( $itemStatisticsList as $v ) {
  7912. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  7913. if ($v ['month'] == 1)
  7914. $m1 += $v ['price'];
  7915. if ($v ['month'] == 2)
  7916. $m2 += $v ['price'];
  7917. if ($v ['month'] == 3)
  7918. $m3 += $v ['price'];
  7919. if ($v ['month'] == 4)
  7920. $m4 += $v ['price'];
  7921. if ($v ['month'] == 5)
  7922. $m5 += $v ['price'];
  7923. if ($v ['month'] == 6)
  7924. $m6 += $v ['price'];
  7925. if ($v ['month'] == 7)
  7926. $m7 += $v ['price'];
  7927. if ($v ['month'] == 8)
  7928. $m8 += $v ['price'];
  7929. if ($v ['month'] == 9)
  7930. $m9 += $v ['price'];
  7931. if ($v ['month'] == 10)
  7932. $m10 += $v ['price'];
  7933. if ($v ['month'] == 11)
  7934. $m11 += $v ['price'];
  7935. if ($v ['month'] == 12)
  7936. $m12 += $v ['price'];
  7937. $asum += $v ['price'];
  7938. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7939. $falg = false;
  7940. break;
  7941. }
  7942. }
  7943. if ($falg)
  7944. $html .= '<td class="taR">-</td>';
  7945. }
  7946. $m13 += $asum;
  7947. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7948. $collectHtml [$value ['username']] = array (
  7949. 'html' => $html,
  7950. 'sid' => $value ['sid']
  7951. );
  7952. $html = "";
  7953. }
  7954. }
  7955. $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>
  7956. <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>
  7957. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  7958. $collectHtml [$vlu ['cid']] = array (
  7959. 'html' => $hl,
  7960. 'sid' => ''
  7961. );
  7962. }
  7963. $data ['companyHtml'] = $collectHtml;
  7964. // total price html
  7965. $collectHtml = "";
  7966. $total = 0;
  7967. for($i = 1; $i <= 12; $i ++) {
  7968. $sumPrice = 0;
  7969. foreach ( $itemStatisticsList as $key => $value ) {
  7970. if ($value ['month'] == $i) {
  7971. $sumPrice += $value ['price'];
  7972. }
  7973. }
  7974. if ($sumPrice == 0)
  7975. $collectHtml .= '<td class="taR">-</td>';
  7976. else
  7977. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7978. $total += $sumPrice;
  7979. }
  7980. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7981. $data ['companyTotalHtml'] = $collectHtml;
  7982. $data ['total'] = $total;
  7983. $data ['year'] = $year;
  7984. $data ['memu'] = "receipt";
  7985. $data ['staff'] = $this->staff;
  7986. $data ['receiptMemu'] = 'companyCategoryCollect';
  7987. $data ['verifyId'] = $this->verifyId;
  7988. $data ['executeId'] = $this->executeId;
  7989. if ($year <= date ( "Y" )) {
  7990. Doo::loadModel ( 'receipt' );
  7991. $receipt = new receipt ();
  7992. $receiptList = $receipt->find ( array (
  7993. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  7994. 'asArray' => true
  7995. ) );
  7996. if (empty ( $receiptList )) { // generated files
  7997. ob_start ();
  7998. $this->render ( "/admin/saeaStaffCollectB", $data );
  7999. $this->cacheFile ( $path );
  8000. die ();
  8001. }
  8002. }
  8003. $this->render ( "/admin/saeaStaffCollectB", $data );
  8004. }
  8005. function staffCollectBak() {
  8006. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8007. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  8008. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  8009. $this->showCache ( $path );
  8010. Doo::loadModel ( 'statistics' );
  8011. $statistics = new statistics ();
  8012. Doo::loadModel ( "receiptDetail" );
  8013. $receiptDetail = new receiptDetail ();
  8014. Doo::loadModel ( 'L_category' );
  8015. $Lcategory = new L_category ();
  8016. Doo::loadModel ( 'accountItem' );
  8017. $accountItem = new accountItem ();
  8018. Doo::loadModel ( 'staff' );
  8019. $staff = new staff ();
  8020. Doo::loadModel ( 'itemStatistics' );
  8021. $itemStatistics = new itemStatistics ();
  8022. $itemStatisticsList = $itemStatistics->find ( array (
  8023. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8024. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8025. 'groupby' => 'staff,itemCategory,Month(date)',
  8026. 'asArray' => true
  8027. ) );
  8028. $itemCategoryList = $itemStatistics->find ( array (
  8029. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8030. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8031. 'groupby' => 'cid,itemCategory,Month(date)',
  8032. 'asArray' => true
  8033. ) );
  8034. $LcategoryList = $Lcategory->find ( array (
  8035. 'asArray' => true
  8036. ) );
  8037. $staffList = $staff->find ( array (
  8038. 'asArray' => true
  8039. ) );
  8040. $htmlArray = array ();
  8041. foreach ( $LcategoryList as $value ) {
  8042. $htmlArray [$value ['title']] = array ();
  8043. foreach ( $staffList as $v ) {
  8044. if ($value ['cid'] == $v ['cid']) {
  8045. $html = "";
  8046. $falg = true;
  8047. $staffSumPrice = 0;
  8048. foreach ( $itemStatisticsList as $a ) {
  8049. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  8050. if (empty ( $a ['price'] )) {
  8051. $html .= '<td class="taR">-</td>';
  8052. $falg = false;
  8053. break;
  8054. } else {
  8055. $staffSumPrice += $a ['price'];
  8056. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8057. $falg = false;
  8058. break;
  8059. }
  8060. }
  8061. }
  8062. if ($falg) {
  8063. $html .= '<td class="taR">-</td>';
  8064. $falg = true;
  8065. }
  8066. $falg = true;
  8067. foreach ( $itemStatisticsList as $a ) {
  8068. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  8069. if (empty ( $a ['price'] )) {
  8070. $html .= '<td class="taR">-</td>';
  8071. $falg = false;
  8072. break;
  8073. } else {
  8074. $staffSumPrice += $a ['price'];
  8075. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8076. $falg = false;
  8077. break;
  8078. }
  8079. }
  8080. }
  8081. if ($falg) {
  8082. $html .= '<td class="taR">-</td>';
  8083. $falg = true;
  8084. }
  8085. $falg = true;
  8086. foreach ( $itemStatisticsList as $a ) {
  8087. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  8088. if (empty ( $a ['price'] )) {
  8089. $html .= '<td class="taR">-</td>';
  8090. $falg = false;
  8091. break;
  8092. } else {
  8093. $staffSumPrice += $a ['price'];
  8094. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8095. $falg = false;
  8096. break;
  8097. }
  8098. }
  8099. }
  8100. if ($falg) {
  8101. $html .= '<td class="taR">-</td>';
  8102. $falg = true;
  8103. }
  8104. $falg = true;
  8105. foreach ( $itemStatisticsList as $a ) {
  8106. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  8107. if (! empty ( $a ['price'] )) {
  8108. $staffSumPrice += $a ['price'];
  8109. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8110. $falg = false;
  8111. break;
  8112. } else {
  8113. $html .= '<td class="taR">-</td>';
  8114. $falg = false;
  8115. break;
  8116. }
  8117. }
  8118. }
  8119. if ($falg) {
  8120. $html .= '<td class="taR">-</td>';
  8121. $falg = true;
  8122. }
  8123. $falg = true;
  8124. foreach ( $itemStatisticsList as $a ) {
  8125. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  8126. if (! empty ( $a ['price'] )) {
  8127. $staffSumPrice += $a ['price'];
  8128. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8129. $falg = false;
  8130. break;
  8131. } else {
  8132. $html .= '<td class="taR">-</td>';
  8133. $falg = false;
  8134. break;
  8135. }
  8136. }
  8137. }
  8138. if ($falg) {
  8139. $html .= '<td class="taR">-</td>';
  8140. $falg = true;
  8141. }
  8142. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  8143. $htmlArray [$value ['title']] [$v ['username']] = $html;
  8144. }
  8145. }
  8146. /* -- --- */
  8147. // 合计费用
  8148. $cateHtml = "";
  8149. $catePrice = 0;
  8150. $cateFalg = true;
  8151. foreach ( $itemCategoryList as $l ) {
  8152. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  8153. if (empty ( $l ['price'] )) {
  8154. $cateHtml .= '<td class="colGreen taR">-</td>';
  8155. $cateFalg = false;
  8156. break;
  8157. } else {
  8158. $catePrice += $l ['price'];
  8159. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8160. $cateFalg = false;
  8161. break;
  8162. }
  8163. }
  8164. }
  8165. if ($cateFalg) {
  8166. $cateHtml .= '<td class="colGreen taR">-</td>';
  8167. $cateFalg = true;
  8168. }
  8169. $cateFalg = true;
  8170. foreach ( $itemCategoryList as $l ) {
  8171. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  8172. if (empty ( $l ['price'] )) {
  8173. $cateHtml .= '<td class="colGreen taR">-</td>';
  8174. $cateFalg = false;
  8175. break;
  8176. } else {
  8177. $catePrice += $l ['price'];
  8178. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8179. $cateFalg = false;
  8180. break;
  8181. }
  8182. }
  8183. }
  8184. if ($cateFalg) {
  8185. $cateHtml .= '<td class="colGreen taR">-</td>';
  8186. $cateFalg = true;
  8187. }
  8188. $cateFalg = true;
  8189. foreach ( $itemCategoryList as $l ) {
  8190. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  8191. if (empty ( $l ['price'] )) {
  8192. $cateHtml .= '<td class="colGreen taR">-</td>';
  8193. $cateFalg = false;
  8194. break;
  8195. } else {
  8196. $catePrice += $l ['price'];
  8197. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8198. $cateFalg = false;
  8199. break;
  8200. }
  8201. }
  8202. }
  8203. if ($cateFalg) {
  8204. $cateHtml .= '<td class="colGreen taR">-</td>';
  8205. $cateFalg = true;
  8206. }
  8207. $cateFalg = true;
  8208. foreach ( $itemCategoryList as $l ) {
  8209. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  8210. if (empty ( $l ['price'] )) {
  8211. $cateHtml .= '<td class="colGreen taR">-</td>';
  8212. $cateFalg = false;
  8213. break;
  8214. } else {
  8215. $catePrice += $l ['price'];
  8216. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8217. $cateFalg = false;
  8218. break;
  8219. }
  8220. }
  8221. }
  8222. if ($cateFalg) {
  8223. $cateHtml .= '<td class="colGreen taR">-</td>';
  8224. $cateFalg = true;
  8225. }
  8226. $cateFalg = true;
  8227. foreach ( $itemCategoryList as $l ) {
  8228. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  8229. if (empty ( $l ['price'] )) {
  8230. $cateHtml .= '<td class="colGreen taR">-</td>';
  8231. $cateFalg = false;
  8232. break;
  8233. } else {
  8234. $catePrice += $l ['price'];
  8235. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8236. $cateFalg = false;
  8237. break;
  8238. }
  8239. }
  8240. }
  8241. if ($cateFalg) {
  8242. $cateHtml .= '<td class="colGreen taR">-</td>';
  8243. $cateFalg = true;
  8244. }
  8245. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  8246. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  8247. /* -- --- */
  8248. }
  8249. // print_r($htmlArray);die;
  8250. $data ['htmlArray'] = $htmlArray;
  8251. // statistics html
  8252. $stList = $statistics->getOne ( array (
  8253. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8254. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8255. 'groupby' => 'Month(date)',
  8256. 'asArray' => true
  8257. ) );
  8258. if (empty ( $stList ))
  8259. $stList = array (
  8260. 'rePrice' => 0,
  8261. 'agPrice' => 0
  8262. );
  8263. $data ['stList'] = array (
  8264. 'rePrice' => $stList ['rePrice'],
  8265. 'agPrice' => $stList ['agPrice'],
  8266. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8267. );
  8268. $monthHtml = "";
  8269. for($i = 1; $i <= 12; $i ++) {
  8270. if ($i == $month)
  8271. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8272. else
  8273. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8274. }
  8275. $data ['monthHtml'] = $monthHtml;
  8276. $data ['year'] = $year;
  8277. $data ['month'] = $month;
  8278. $data ['memu'] = "receipt";
  8279. $data ['staff'] = $this->staff;
  8280. $data ['receiptMemu'] = 'companyCategoryCollect';
  8281. $data ['verifyId'] = $this->verifyId;
  8282. $data ['executeId'] = $this->executeId;
  8283. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  8284. Doo::loadModel ( 'receipt' );
  8285. $receipt = new receipt ();
  8286. $receiptList = $receipt->find ( array (
  8287. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  8288. 'asArray' => true
  8289. ) );
  8290. if (empty ( $receiptList )) { // generated files
  8291. ob_start ();
  8292. $this->render ( "/admin/saeaStaffCollect", $data );
  8293. $this->cacheFile ( $path );
  8294. die ();
  8295. }
  8296. }
  8297. $this->render ( "/admin/saeaStaffCollect", $data );
  8298. }
  8299. function lyt() {
  8300. Doo::loadModel ( "receiptDetail" );
  8301. $receiptDetail = new receiptDetail ();
  8302. $receiptCollectList = $receiptDetail->find ( array (
  8303. 'where' => 'status=1 ',
  8304. 'asArray' => true
  8305. ) );
  8306. foreach ( $receiptCollectList as $key => $value ) {
  8307. $receiptDetail = new receiptDetail ();
  8308. $receiptDetail->pastDate = $value ['date'];
  8309. $receiptDetail->update ( array (
  8310. 'where' => "rdid= '" . $value ['rdid'] . "'"
  8311. ) );
  8312. }
  8313. }
  8314. function staffCollectMonthDetail() {
  8315. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8316. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8317. if (! $year)
  8318. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8319. if (! $month)
  8320. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8321. Doo::loadModel ( 'staff' );
  8322. $staff = new staff ();
  8323. Doo::loadModel ( "receiptDetail" );
  8324. $receiptDetail = new receiptDetail ();
  8325. Doo::loadModel ( 'accountItem' );
  8326. $accountItem = new accountItem ();
  8327. Doo::loadModel ( 'statistics' );
  8328. $statistics = new statistics ();
  8329. Doo::loadModel ( 'L_category' );
  8330. $lCategory = new L_category ();
  8331. $staffList = $staff->find ( array (
  8332. 'where' => 'username!="admin"',
  8333. 'asArray' => true
  8334. ) );
  8335. $categoryList = $staff->find ( array (
  8336. 'select' => 'COUNT(*) as count,cid,category',
  8337. 'where' => 'username !="admin"',
  8338. 'groupby' => 'cid',
  8339. 'asArray' => true
  8340. ) );
  8341. $list = array ();
  8342. foreach ( $categoryList as $vlu ) {
  8343. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8344. $r1 = 0;
  8345. $r2 = 0;
  8346. $r3 = 0;
  8347. $r4 = 0;
  8348. $r5 = 0;
  8349. $r6 = 0;
  8350. $r7 = 0;
  8351. $r8 = 0;
  8352. $r9 = 0;
  8353. $r10 = 0;
  8354. $r11 = 0;
  8355. $r12 = 0;
  8356. $r13 = 0;
  8357. $r14 = 0;
  8358. $r15 = 0;
  8359. $c1 = 0;
  8360. $c2 = 0;
  8361. $c3 = 0;
  8362. $c4 = 0;
  8363. $c5 = 0;
  8364. $c6 = 0;
  8365. $p1 = 0;
  8366. $p2 = 0;
  8367. $p3 = 0;
  8368. $p4 = 0;
  8369. $p5 = 0;
  8370. $p6 = 0;
  8371. $p7 = 0;
  8372. $p8 = 0;
  8373. $p9 = 0;
  8374. $t1 = 0;
  8375. $t2 = 0;
  8376. $t3 = 0;
  8377. $t4 = 0;
  8378. $t5 = 0;
  8379. $s1 = 0;
  8380. $m1 = 0;
  8381. foreach ( $staffList as $value ) {
  8382. if ($vlu ['cid'] == $value ['cid']) {
  8383. // pastDate
  8384. $receiptCollectList = $receiptDetail->find ( array (
  8385. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8386. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8387. 'groupby' => 'item,Month(pastDate),itemCategory',
  8388. 'asArray' => true
  8389. ) );
  8390. // if ($value['sid']==42){
  8391. // print_r($receiptCollectList);die;
  8392. // }
  8393. if (! empty ( $receiptCollectList )) {
  8394. $receiptL = array (
  8395. '日常相关费用' => array (),
  8396. '差旅相关费用' => array (),
  8397. '培训班费用' => array (),
  8398. '其他' => array ()
  8399. );
  8400. $html = "";
  8401. $psum = 0;
  8402. $item = array (
  8403. '市内交通费',
  8404. '市内出租费',
  8405. '办事处房租',
  8406. '电话费',
  8407. '水费',
  8408. '电费',
  8409. '办公费用',
  8410. '邮寄费',
  8411. '其他费用',
  8412. '车辆费用',
  8413. '广告费',
  8414. '团队建设费',
  8415. '物业管理费',
  8416. '宽带费'
  8417. );
  8418. foreach ( $item as $va ) {
  8419. $falg = true;
  8420. foreach ( $receiptCollectList as $v ) {
  8421. if ($v ['itemCategory'] == '日常相关费用') {
  8422. if ($v ['item'] == $va) {
  8423. if ($va == '市内交通费')
  8424. $r1 += $v ['price'];
  8425. if ($va == '市内出租费')
  8426. $r2 += $v ['price'];
  8427. if ($va == '办事处房租')
  8428. $r3 += $v ['price'];
  8429. if ($va == '电话费')
  8430. $r4 += $v ['price'];
  8431. if ($va == '水费')
  8432. $r5 += $v ['price'];
  8433. if ($va == '电费')
  8434. $r6 += $v ['price'];
  8435. if ($va == '办公费用')
  8436. $r7 += $v ['price'];
  8437. if ($va == '邮寄费')
  8438. $r8 += $v ['price'];
  8439. if ($va == '其他费用')
  8440. $r9 += $v ['price'];
  8441. if ($va == '车辆费用')
  8442. $r10 += $v ['price'];
  8443. if ($va == '广告费')
  8444. $r11 += $v ['price'];
  8445. if ($va == '团队建设费')
  8446. $r13 += $v ['price'];
  8447. if ($va == '物业管理费')
  8448. $r14 += $v ['price'];
  8449. if ($va == '宽带费')
  8450. $r15 += $v ['price'];
  8451. $psum += $v ['price'];
  8452. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8453. $falg = false;
  8454. break;
  8455. }
  8456. }
  8457. }
  8458. if ($falg)
  8459. $html .= '<td class="taR">-</td>';
  8460. }
  8461. $r12 += $psum;
  8462. if (! empty ( $psum ))
  8463. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8464. else
  8465. $psum = '<td class="colGreen taR">-</td>';
  8466. $receiptL ['日常相关费用'] = $psum . $html;
  8467. /* ----------------------------------- */
  8468. $html = "";
  8469. $psum = 0;
  8470. $item = array (
  8471. '往来交通费',
  8472. '市内交通费',
  8473. '出差住宿费',
  8474. '出差补助',
  8475. '其他费用'
  8476. );
  8477. foreach ( $item as $va ) {
  8478. $falg = true;
  8479. foreach ( $receiptCollectList as $v ) {
  8480. if ($v ['itemCategory'] == '差旅相关费用') {
  8481. if ($v ['item'] == $va) {
  8482. if ($va == '往来交通费')
  8483. $c1 += $v ['price'];
  8484. if ($va == '市内交通费')
  8485. $c2 += $v ['price'];
  8486. if ($va == '出差住宿费')
  8487. $c3 += $v ['price'];
  8488. if ($va == '出差补助')
  8489. $c4 += $v ['price'];
  8490. if ($va == '其他费用')
  8491. $c5 += $v ['price'];
  8492. $psum += $v ['price'];
  8493. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8494. $falg = false;
  8495. break;
  8496. }
  8497. }
  8498. }
  8499. if ($falg)
  8500. $html .= '<td class="taR">-</td>';
  8501. }
  8502. $c6 += $psum;
  8503. if (! empty ( $psum ))
  8504. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8505. else
  8506. $psum = '<td class="colGreen taR">-</td>';
  8507. $receiptL ['差旅相关费用'] = $psum . $html;
  8508. /* ------------------------------------- */
  8509. $html = "";
  8510. $psum = 0;
  8511. $item = array (
  8512. '场租费',
  8513. '薪酬',
  8514. '住宿费',
  8515. '交通费',
  8516. '餐饮费',
  8517. '办公费',
  8518. '公关费',
  8519. '其他'
  8520. );
  8521. foreach ( $item as $va ) {
  8522. $falg = true;
  8523. foreach ( $receiptCollectList as $v ) {
  8524. if ($v ['itemCategory'] == '培训班费用') {
  8525. if ($v ['item'] == $va) {
  8526. if ($va == '场租费')
  8527. $p1 += $v ['price'];
  8528. if ($va == '薪酬')
  8529. $p2 += $v ['price'];
  8530. if ($va == '住宿费')
  8531. $p3 += $v ['price'];
  8532. if ($va == '交通费')
  8533. $p4 += $v ['price'];
  8534. if ($va == '餐饮费')
  8535. $p5 += $v ['price'];
  8536. if ($va == '办公费')
  8537. $p6 += $v ['price'];
  8538. if ($va == '公关费')
  8539. $p7 += $v ['price'];
  8540. if ($va == '其他')
  8541. $p8 += $v ['price'];
  8542. $psum += $v ['price'];
  8543. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8544. $falg = false;
  8545. break;
  8546. }
  8547. }
  8548. }
  8549. if ($falg)
  8550. $html .= '<td class="taR">-</td>';
  8551. }
  8552. $p9 += $psum;
  8553. if (! empty ( $psum ))
  8554. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8555. else
  8556. $psum = '<td class="colGreen taR">-</td>';
  8557. $receiptL ['培训班费用'] = $psum . $html;
  8558. /* ------------------------------------- */
  8559. $html = "";
  8560. $psum = 0;
  8561. $item = array (
  8562. '公关费',
  8563. '广告费',
  8564. '借款',
  8565. '可自加费用'
  8566. );
  8567. foreach ( $item as $va ) {
  8568. $falg = true;
  8569. foreach ( $receiptCollectList as $v ) {
  8570. if ($v ['itemCategory'] == '其他') {
  8571. // if ($value['sid']==42){
  8572. //
  8573. // echo var_dump($v['item']);
  8574. // echo var_dump($va);
  8575. // echo var_dump($v['item']==" ".$va);
  8576. // echo $v['item']."==".$va."/<br/>";
  8577. // //print_r( $receiptCollectList);//echo $va;
  8578. // }
  8579. if (trim ( $v ['item'] ) == $va) {
  8580. if ($va == '公关费')
  8581. $t1 += $v ['price'];
  8582. if ($va == '广告费') {
  8583. $t2 += $v ['price'];
  8584. }
  8585. if ($va == '借款')
  8586. $t3 += $v ['price'];
  8587. if ($va == '可自加费用')
  8588. $t4 += $v ['price'];
  8589. $psum += $v ['price'];
  8590. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8591. $falg = false;
  8592. break;
  8593. }
  8594. }
  8595. }
  8596. if ($falg)
  8597. $html .= '<td class="taR">-</td>';
  8598. }
  8599. $t5 += $psum;
  8600. if (! empty ( $psum ))
  8601. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8602. else
  8603. $psum = '<td class="colGreen taR">-</td>';
  8604. $receiptL ['其他'] = $psum . $html;
  8605. /* ------------------------------------- */
  8606. $html = "";
  8607. $psum = 0;
  8608. foreach ( $receiptCollectList as $v ) {
  8609. if ($v ['itemCategory'] == '报销金额调整') {
  8610. if (! empty ( $v ['price'] )) {
  8611. $psum += $v ['price'];
  8612. }
  8613. }
  8614. }
  8615. $s1 += $psum;
  8616. if (! empty ( $psum ))
  8617. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8618. else
  8619. $psum = '<td class="taR colOrange">-</td>';
  8620. $receiptL ['报销金额调整'] = $psum . $html;
  8621. } else {
  8622. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8623. <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>
  8624. <td class="taR">-</td><td class="taR">-</td>';
  8625. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  8626. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8627. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8628. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8629. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8630. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  8631. }
  8632. $monthStaffPrice = $receiptDetail->find ( array (
  8633. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8634. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8635. 'groupby' => 'Month(pastDate)',
  8636. 'asArray' => true
  8637. ) );
  8638. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  8639. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  8640. $m1 += $monthStaffPrice [0] ['price'];
  8641. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  8642. } else
  8643. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  8644. $list [$value ['username']] = $receiptL;
  8645. }
  8646. }
  8647. $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>
  8648. <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>
  8649. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  8650. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  8651. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  8652. $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>
  8653. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  8654. $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>';
  8655. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  8656. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  8657. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  8658. }
  8659. $data ['list'] = $list;
  8660. $receiptCollectList = $receiptDetail->find ( array (
  8661. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8662. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8663. 'groupby' => 'item,Month(pastDate),itemCategory',
  8664. 'asArray' => true
  8665. ) );
  8666. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  8667. // statistics html
  8668. $stList = $statistics->getOne ( array (
  8669. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8670. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8671. 'groupby' => 'Month(date)',
  8672. 'asArray' => true
  8673. ) );
  8674. if (empty ( $stList ))
  8675. $stList = array (
  8676. 'rePrice' => 0,
  8677. 'agPrice' => 0
  8678. );
  8679. $data ['stList'] = array (
  8680. 'rePrice' => $stList ['rePrice'],
  8681. 'agPrice' => $stList ['agPrice'],
  8682. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8683. );
  8684. $monthHtml = "";
  8685. for($i = 1; $i <= 12; $i ++) {
  8686. if ($i == $month)
  8687. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8688. else
  8689. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8690. }
  8691. $data ['monthHtml'] = $monthHtml;
  8692. $data ['year'] = $year;
  8693. $data ['month'] = $month;
  8694. $data ['memu'] = "receipt";
  8695. $data ['staff'] = $this->staff;
  8696. $data ['receiptMemu'] = 'companyCategoryCollect';
  8697. $data ['verifyId'] = $this->verifyId;
  8698. $data ['executeId'] = $this->executeId;
  8699. $this->render ( "/admin/staffCollectMonthDetail", $data );
  8700. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  8701. }
  8702. function staffCollectMonthDetail2() {
  8703. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8704. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8705. if (! $year)
  8706. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8707. if (! $month)
  8708. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8709. Doo::loadModel ( 'staff' );
  8710. $staff = new staff ();
  8711. Doo::loadModel ( "receiptDetail" );
  8712. $receiptDetail = new receiptDetail ();
  8713. Doo::loadModel ( 'accountItem' );
  8714. $accountItem = new accountItem ();
  8715. Doo::loadModel ( 'statistics' );
  8716. $statistics = new statistics ();
  8717. Doo::loadModel ( 'L_category' );
  8718. $lCategory = new L_category ();
  8719. $staffList = $staff->find ( array (
  8720. 'where' => 'username!="admin"',
  8721. 'asArray' => true
  8722. ) );
  8723. $categoryList = $staff->find ( array (
  8724. 'select' => 'COUNT(*) as count,cid,category',
  8725. 'where' => 'username !="admin"',
  8726. 'groupby' => 'cid',
  8727. 'asArray' => true
  8728. ) );
  8729. $list = array ();
  8730. foreach ( $categoryList as $vlu ) {
  8731. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8732. $r1 = 0;
  8733. $r2 = 0;
  8734. $r3 = 0;
  8735. $r4 = 0;
  8736. $r5 = 0;
  8737. $r6 = 0;
  8738. $r7 = 0;
  8739. $r8 = 0;
  8740. $r9 = 0;
  8741. $r10 = 0;
  8742. $r11 = 0;
  8743. $r12 = 0;
  8744. $r13 = 0;
  8745. $r14 = 0;
  8746. $r15 = 0;
  8747. $c1 = 0;
  8748. $c2 = 0;
  8749. $c3 = 0;
  8750. $c4 = 0;
  8751. $c5 = 0;
  8752. $c6 = 0;
  8753. $p1 = 0;
  8754. $p2 = 0;
  8755. $p3 = 0;
  8756. $p4 = 0;
  8757. $p5 = 0;
  8758. $p6 = 0;
  8759. $p7 = 0;
  8760. $p8 = 0;
  8761. $p9 = 0;
  8762. $t1 = 0;
  8763. $t2 = 0;
  8764. $t3 = 0;
  8765. $t4 = 0;
  8766. $t5 = 0;
  8767. $s1 = 0;
  8768. $m1 = 0;
  8769. foreach ( $staffList as $value ) {
  8770. if ($vlu ['cid'] == $value ['cid']) {
  8771. $receiptCollectList = $receiptDetail->find ( array (
  8772. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  8773. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  8774. 'groupby' => 'item,Month(date),itemCategory',
  8775. 'asArray' => true
  8776. ) );
  8777. if (! empty ( $receiptCollectList )) {
  8778. $receiptL = array (
  8779. '日常相关费用' => array (),
  8780. '差旅相关费用' => array (),
  8781. '培训班费用' => array (),
  8782. '其他' => array ()
  8783. );
  8784. $html = "";
  8785. $psum = 0;
  8786. $item = array (
  8787. '市内交通费',
  8788. '市内出租费',
  8789. '办事处房租',
  8790. '电话费',
  8791. '水费',
  8792. '电费',
  8793. '办公费用',
  8794. '邮寄费',
  8795. '其他费用',
  8796. '车辆费用',
  8797. '广告费',
  8798. '团队建设费',
  8799. '物业管理费',
  8800. '宽带费'
  8801. );
  8802. foreach ( $item as $va ) {
  8803. $falg = true;
  8804. foreach ( $receiptCollectList as $v ) {
  8805. if ($v ['itemCategory'] == '日常相关费用') {
  8806. if ($v ['item'] == $va) {
  8807. if ($va == '市内交通费')
  8808. $r1 += $v ['price'];
  8809. if ($va == '市内出租费')
  8810. $r2 += $v ['price'];
  8811. if ($va == '办事处房租')
  8812. $r3 += $v ['price'];
  8813. if ($va == '电话费')
  8814. $r4 += $v ['price'];
  8815. if ($va == '水费')
  8816. $r5 += $v ['price'];
  8817. if ($va == '电费')
  8818. $r6 += $v ['price'];
  8819. if ($va == '办公费用')
  8820. $r7 += $v ['price'];
  8821. if ($va == '邮寄费')
  8822. $r8 += $v ['price'];
  8823. if ($va == '其他费用')
  8824. $r9 += $v ['price'];
  8825. if ($va == '车辆费用')
  8826. $r10 += $v ['price'];
  8827. if ($va == '广告费')
  8828. $r11 += $v ['price'];
  8829. if ($va == '团队建设费')
  8830. $r13 += $v ['price'];
  8831. if ($va == '物业管理费')
  8832. $r14 += $v ['price'];
  8833. if ($va == '宽带费')
  8834. $r15 += $v ['price'];
  8835. $psum += $v ['price'];
  8836. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8837. $falg = false;
  8838. break;
  8839. }
  8840. }
  8841. }
  8842. if ($falg)
  8843. $html .= '<td class="taR">-</td>';
  8844. }
  8845. $r12 += $psum;
  8846. if (! empty ( $psum ))
  8847. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8848. else
  8849. $psum = '<td class="colGreen taR">-</td>';
  8850. $receiptL ['日常相关费用'] = $psum . $html;
  8851. /* ----------------------------------- */
  8852. $html = "";
  8853. $psum = 0;
  8854. $item = array (
  8855. '往来交通费',
  8856. '市内交通费',
  8857. '出差住宿费',
  8858. '出差补助',
  8859. '其他费用'
  8860. );
  8861. foreach ( $item as $va ) {
  8862. $falg = true;
  8863. foreach ( $receiptCollectList as $v ) {
  8864. if ($v ['itemCategory'] == '差旅相关费用') {
  8865. if ($v ['item'] == $va) {
  8866. if ($va == '往来交通费')
  8867. $c1 += $v ['price'];
  8868. if ($va == '市内交通费')
  8869. $c2 += $v ['price'];
  8870. if ($va == '出差住宿费')
  8871. $c3 += $v ['price'];
  8872. if ($va == '出差补助')
  8873. $c4 += $v ['price'];
  8874. if ($va == '其他费用')
  8875. $c5 += $v ['price'];
  8876. $psum += $v ['price'];
  8877. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8878. $falg = false;
  8879. break;
  8880. }
  8881. }
  8882. }
  8883. if ($falg)
  8884. $html .= '<td class="taR">-</td>';
  8885. }
  8886. $c6 += $psum;
  8887. if (! empty ( $psum ))
  8888. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8889. else
  8890. $psum = '<td class="colGreen taR">-</td>';
  8891. $receiptL ['差旅相关费用'] = $psum . $html;
  8892. /* ------------------------------------- */
  8893. $html = "";
  8894. $psum = 0;
  8895. $item = array (
  8896. '场租费',
  8897. '薪酬',
  8898. '住宿费',
  8899. '交通费',
  8900. '餐饮费',
  8901. '办公费',
  8902. '公关费',
  8903. '其他'
  8904. );
  8905. foreach ( $item as $va ) {
  8906. $falg = true;
  8907. foreach ( $receiptCollectList as $v ) {
  8908. if ($v ['itemCategory'] == '培训班费用') {
  8909. if ($v ['item'] == $va) {
  8910. if ($va == '场租费')
  8911. $p1 += $v ['price'];
  8912. if ($va == '薪酬')
  8913. $p2 += $v ['price'];
  8914. if ($va == '住宿费')
  8915. $p3 += $v ['price'];
  8916. if ($va == '交通费')
  8917. $p4 += $v ['price'];
  8918. if ($va == '餐饮费')
  8919. $p5 += $v ['price'];
  8920. if ($va == '办公费')
  8921. $p6 += $v ['price'];
  8922. if ($va == '公关费')
  8923. $p7 += $v ['price'];
  8924. if ($va == '其他')
  8925. $p8 += $v ['price'];
  8926. $psum += $v ['price'];
  8927. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8928. $falg = false;
  8929. break;
  8930. }
  8931. }
  8932. }
  8933. if ($falg)
  8934. $html .= '<td class="taR">-</td>';
  8935. }
  8936. $p9 += $psum;
  8937. if (! empty ( $psum ))
  8938. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8939. else
  8940. $psum = '<td class="colGreen taR">-</td>';
  8941. $receiptL ['培训班费用'] = $psum . $html;
  8942. /* ------------------------------------- */
  8943. $html = "";
  8944. $psum = 0;
  8945. $item = array (
  8946. '公关费',
  8947. '广告费',
  8948. '借款',
  8949. '可自加费用'
  8950. );
  8951. foreach ( $item as $va ) {
  8952. $falg = true;
  8953. foreach ( $receiptCollectList as $v ) {
  8954. if ($v ['itemCategory'] == '其他') {
  8955. if ($v ['item'] == $va) {
  8956. if ($va == '公关费')
  8957. $t1 += $v ['price'];
  8958. if ($va == '广告费')
  8959. $t2 += $v ['price'];
  8960. if ($va == '借款')
  8961. $t3 += $v ['price'];
  8962. if ($va == '可自加费用')
  8963. $t4 += $v ['price'];
  8964. $psum += $v ['price'];
  8965. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8966. $falg = false;
  8967. break;
  8968. }
  8969. }
  8970. }
  8971. if ($falg)
  8972. $html .= '<td class="taR">-</td>';
  8973. }
  8974. $t5 += $psum;
  8975. if (! empty ( $psum ))
  8976. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8977. else
  8978. $psum = '<td class="colGreen taR">-</td>';
  8979. $receiptL ['其他'] = $psum . $html;
  8980. /* ------------------------------------- */
  8981. $html = "";
  8982. $psum = 0;
  8983. foreach ( $receiptCollectList as $v ) {
  8984. if ($v ['itemCategory'] == '报销金额调整') {
  8985. if (! empty ( $v ['price'] )) {
  8986. $psum += $v ['price'];
  8987. }
  8988. }
  8989. }
  8990. $s1 += $psum;
  8991. if (! empty ( $psum ))
  8992. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8993. else
  8994. $psum = '<td class="taR colOrange">-</td>';
  8995. $receiptL ['报销金额调整'] = $psum . $html;
  8996. } else {
  8997. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8998. <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>';
  8999. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9000. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9001. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9002. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9003. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9004. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9005. }
  9006. $monthStaffPrice = $receiptDetail->find ( array (
  9007. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9008. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9009. 'asArray' => true
  9010. ) );
  9011. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  9012. $m1 += $monthStaffPrice [0] ['price'];
  9013. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9014. } else
  9015. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9016. $list [$value ['username']] = $receiptL;
  9017. }
  9018. }
  9019. $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>
  9020. <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>
  9021. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  9022. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  9023. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  9024. $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>
  9025. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  9026. $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>';
  9027. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  9028. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  9029. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  9030. }
  9031. $data ['list'] = $list;
  9032. $receiptCollectList = $receiptDetail->find ( array (
  9033. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9034. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9035. 'groupby' => 'item,Month(date),itemCategory',
  9036. 'asArray' => true
  9037. ) );
  9038. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9039. // statistics html
  9040. $stList = $statistics->getOne ( array (
  9041. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9042. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9043. 'groupby' => 'Month(date)',
  9044. 'asArray' => true
  9045. ) );
  9046. if (empty ( $stList ))
  9047. $stList = array (
  9048. 'rePrice' => 0,
  9049. 'agPrice' => 0
  9050. );
  9051. $data ['stList'] = array (
  9052. 'rePrice' => $stList ['rePrice'],
  9053. 'agPrice' => $stList ['agPrice'],
  9054. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9055. );
  9056. $monthHtml = "";
  9057. for($i = 1; $i <= 12; $i ++) {
  9058. if ($i == $month)
  9059. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9060. else
  9061. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9062. }
  9063. $data ['monthHtml'] = $monthHtml;
  9064. $data ['year'] = $year;
  9065. $data ['month'] = $month;
  9066. $data ['memu'] = "receipt";
  9067. $data ['staff'] = $this->staff;
  9068. $data ['receiptMemu'] = 'companyCategoryCollect';
  9069. $data ['verifyId'] = $this->verifyId;
  9070. $data ['executeId'] = $this->executeId;
  9071. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  9072. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9073. }
  9074. function companyMonthCollectDetail() {
  9075. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9076. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9077. if (! $year)
  9078. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9079. if (! $month)
  9080. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9081. Doo::loadModel ( 'staff' );
  9082. $staff = new staff ();
  9083. Doo::loadModel ( "receiptDetail" );
  9084. $receiptDetail = new receiptDetail ();
  9085. Doo::loadModel ( 'accountItem' );
  9086. $accountItem = new accountItem ();
  9087. Doo::loadModel ( 'statistics' );
  9088. $statistics = new statistics ();
  9089. Doo::loadModel ( 'L_category' );
  9090. $lCategory = new L_category ();
  9091. $staffList = $staff->find ( array (
  9092. 'where' => 'username!="admin"',
  9093. 'asArray' => true
  9094. ) );
  9095. $categoryList = $lCategory->find ( array (
  9096. 'asArray' => true
  9097. ) );
  9098. $list = array ();
  9099. foreach ( $categoryList as $value ) {
  9100. $receiptCollectList = $receiptDetail->find ( array (
  9101. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9102. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9103. 'groupby' => 'item,Month(pastDate),itemCategory',
  9104. 'asArray' => true
  9105. ) );
  9106. if (! empty ( $receiptCollectList )) {
  9107. $receiptL = array (
  9108. '日常相关费用' => array (),
  9109. '差旅相关费用' => array (),
  9110. '培训班费用' => array (),
  9111. '其他' => array ()
  9112. );
  9113. $html = "";
  9114. $psum = 0;
  9115. $item = array (
  9116. '市内交通费',
  9117. '市内出租费',
  9118. '办事处房租',
  9119. '电话费',
  9120. '水费',
  9121. '电费',
  9122. '办公费用',
  9123. '邮寄费',
  9124. '其他费用',
  9125. '车辆费用',
  9126. '广告费',
  9127. '团队建设费'
  9128. );
  9129. foreach ( $item as $va ) {
  9130. $falg = true;
  9131. foreach ( $receiptCollectList as $v ) {
  9132. if ($v ['itemCategory'] == '日常相关费用') {
  9133. if ($v ['item'] == $va) {
  9134. $psum += $v ['price'];
  9135. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9136. $falg = false;
  9137. break;
  9138. }
  9139. }
  9140. }
  9141. if ($falg)
  9142. $html .= '<td class="taR">-</td>';
  9143. }
  9144. if (! empty ( $psum ))
  9145. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9146. else
  9147. $psum = '<td class="colGreen taR">-</td>';
  9148. $receiptL ['日常相关费用'] = $psum . $html;
  9149. /* ----------------------------------- */
  9150. $html = "";
  9151. $psum = 0;
  9152. $item = array (
  9153. '往来交通费',
  9154. '市内交通费',
  9155. '出差住宿费',
  9156. '出差补助',
  9157. '其他费用'
  9158. );
  9159. foreach ( $item as $va ) {
  9160. $falg = true;
  9161. foreach ( $receiptCollectList as $v ) {
  9162. if ($v ['itemCategory'] == '差旅相关费用') {
  9163. if ($v ['item'] == $va) {
  9164. $psum += $v ['price'];
  9165. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9166. $falg = false;
  9167. break;
  9168. }
  9169. }
  9170. }
  9171. if ($falg)
  9172. $html .= '<td class="taR">-</td>';
  9173. }
  9174. if (! empty ( $psum ))
  9175. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9176. else
  9177. $psum = '<td class="colGreen taR">-</td>';
  9178. $receiptL ['差旅相关费用'] = $psum . $html;
  9179. /* ------------------------------------- */
  9180. $html = "";
  9181. $psum = 0;
  9182. $item = array (
  9183. '场租费',
  9184. '薪酬',
  9185. '住宿费',
  9186. '交通费',
  9187. '餐饮费',
  9188. '办公费',
  9189. '公关费',
  9190. '其他'
  9191. );
  9192. foreach ( $item as $va ) {
  9193. $falg = true;
  9194. foreach ( $receiptCollectList as $v ) {
  9195. if ($v ['itemCategory'] == '培训班费用') {
  9196. if ($v ['item'] == $va) {
  9197. $psum += $v ['price'];
  9198. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9199. $falg = false;
  9200. break;
  9201. }
  9202. }
  9203. }
  9204. if ($falg)
  9205. $html .= '<td class="taR">-</td>';
  9206. }
  9207. if (! empty ( $psum ))
  9208. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9209. else
  9210. $psum = '<td class="colGreen taR">-</td>';
  9211. $receiptL ['培训班费用'] = $psum . $html;
  9212. /* ------------------------------------- */
  9213. $html = "";
  9214. $psum = 0;
  9215. $item = array (
  9216. '公关费',
  9217. '广告费',
  9218. '借款',
  9219. '可自加费用'
  9220. );
  9221. foreach ( $item as $va ) {
  9222. $falg = true;
  9223. foreach ( $receiptCollectList as $v ) {
  9224. if ($v ['itemCategory'] == '其他') {
  9225. if ($v ['item'] == $va) {
  9226. $psum += $v ['price'];
  9227. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9228. $falg = false;
  9229. break;
  9230. }
  9231. }
  9232. }
  9233. if ($falg)
  9234. $html .= '<td class="taR">-</td>';
  9235. }
  9236. if (! empty ( $psum ))
  9237. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9238. else
  9239. $psum = '<td class="colGreen taR">-</td>';
  9240. $receiptL ['其他'] = $psum . $html;
  9241. /* ------------------------------------- */
  9242. $html = "";
  9243. $psum = 0;
  9244. foreach ( $receiptCollectList as $v ) {
  9245. if ($v ['itemCategory'] == '报销金额调整') {
  9246. if (! empty ( $v ['price'] ))
  9247. $psum += $v ['price'];
  9248. }
  9249. }
  9250. if (! empty ( $psum ))
  9251. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9252. else
  9253. $psum = '<td class="taR colOrange">-</td>';
  9254. $receiptL ['报销金额调整'] = $psum . $html;
  9255. } else {
  9256. $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>
  9257. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9258. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9259. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9260. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9261. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9262. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9263. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9264. }
  9265. $monthStaffPrice = $receiptDetail->find ( array (
  9266. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9267. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9268. 'asArray' => true
  9269. ) );
  9270. if (! empty ( $monthStaffPrice [0] ['price'] ))
  9271. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9272. else
  9273. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9274. $list [$value ['title']] = $receiptL;
  9275. }
  9276. $data ['list'] = $list;
  9277. $receiptCollectList = $receiptDetail->find ( array (
  9278. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9279. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9280. 'groupby' => 'item,Month(pastDate),itemCategory',
  9281. 'asArray' => true
  9282. ) );
  9283. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9284. // print_r($data['monthPriceHtml']);
  9285. // foreach ($data['monthPriceHtml'] as $value){
  9286. // echo $value;
  9287. // }
  9288. // die;
  9289. // statistics html
  9290. $stList = $statistics->getOne ( array (
  9291. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9292. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9293. 'groupby' => 'Month(date)',
  9294. 'asArray' => true
  9295. ) );
  9296. if (empty ( $stList ))
  9297. $stList = array (
  9298. 'rePrice' => 0,
  9299. 'agPrice' => 0
  9300. );
  9301. $data ['stList'] = array (
  9302. 'rePrice' => $stList ['rePrice'],
  9303. 'agPrice' => $stList ['agPrice'],
  9304. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9305. );
  9306. $monthHtml = "";
  9307. for($i = 1; $i <= 12; $i ++) {
  9308. if ($i == $month)
  9309. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9310. else
  9311. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9312. }
  9313. $data ['monthHtml'] = $monthHtml;
  9314. $data ['year'] = $year;
  9315. $data ['month'] = $month;
  9316. $data ['memu'] = "receipt";
  9317. $data ['staff'] = $this->staff;
  9318. $data ['receiptMemu'] = 'companyCategoryCollect';
  9319. $data ['verifyId'] = $this->verifyId;
  9320. $data ['executeId'] = $this->executeId;
  9321. $this->render ( "/admin/companyMonthCollectDetail", $data );
  9322. }
  9323. function staffCollectDetail() {
  9324. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9325. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  9326. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  9327. if (! $staffname) {
  9328. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  9329. $staffname = urldecode ( $staffname );
  9330. }
  9331. Doo::loadModel ( 'staff' );
  9332. $staff = new staff ();
  9333. Doo::loadModel ( "receiptDetail" );
  9334. $receiptDetail = new receiptDetail ();
  9335. Doo::loadModel ( 'accountItem' );
  9336. $accountItem = new accountItem ();
  9337. Doo::loadModel ( 'statistics' );
  9338. $statistics = new statistics ();
  9339. Doo::loadModel ( 'L_category' );
  9340. $lCategory = new L_category ();
  9341. $staffList = $staff->find ( array (
  9342. 'asArray' => true
  9343. ) );
  9344. $stHtml = '';
  9345. $stTitle = "";
  9346. $staffId = 0;
  9347. $cid = 0;
  9348. $ocid = 0;
  9349. foreach ( $staffList as $value ) {
  9350. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  9351. $stTitle = $value ['category'] . '-' . $value ['username'];
  9352. $staffId = $value ['sid'];
  9353. $cid = $value ['cid'];
  9354. $ocid = $value ['cid'];
  9355. if (! empty ( $value ['othercid'] ))
  9356. $cid = $value ['cid'] . ',' . $value ['othercid'];
  9357. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9358. } elseif ($value ['username'] != 'admin')
  9359. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9360. }
  9361. $data ['lCategoryHtml'] = $lCategory->find ( array (
  9362. 'where' => 'cid in(' . $cid . ')',
  9363. 'asArray' => true
  9364. ) );
  9365. if (empty ( $pcid ))
  9366. $pcid = $ocid;
  9367. $data ['ocid'] = $pcid;
  9368. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  9369. $this->showCache ( $path );
  9370. //
  9371. $receiptCollectList = $receiptDetail->find ( array (
  9372. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9373. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9374. 'groupby' => 'item,Month(pastDate),itemCategory',
  9375. 'asArray' => true
  9376. ) );
  9377. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  9378. // print_r($receiptCollectList);
  9379. $accountList = $accountItem->find ( array (
  9380. 'asArray' => true
  9381. ) );
  9382. // create CollectDetail HTML
  9383. $collectHtml = array ();
  9384. foreach ( $accountList as $key => $value ) {
  9385. $html = "";
  9386. $asum = 0;
  9387. for($i = 1; $i <= 12; $i ++) {
  9388. $falg = true;
  9389. foreach ( $receiptCollectList as $v ) {
  9390. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9391. if ($v ['item'] == '可自加费用') {
  9392. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  9393. }
  9394. $asum += $v ['price'];
  9395. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9396. $falg = false;
  9397. break;
  9398. }
  9399. }
  9400. if ($falg)
  9401. $html .= '<td class="taR">-</td>';
  9402. }
  9403. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9404. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9405. }
  9406. $data ['collectHtml'] = $collectHtml;
  9407. // print_r($collectHtml);
  9408. // create Adjustment price html
  9409. $receiptCollectList = $receiptDetail->find ( array (
  9410. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9411. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9412. 'groupby' => 'itemCategory,Month(pastDate)',
  9413. 'asArray' => true
  9414. ) );
  9415. $adjustment = array ();
  9416. $collectArray = array (
  9417. '日常相关费用' => array (),
  9418. '差旅相关费用' => array (),
  9419. '培训班费用' => array (),
  9420. '其他' => array ()
  9421. );
  9422. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9423. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9424. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9425. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9426. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9427. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9428. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9429. array_push ( $collectArray ['其他'], $collectHtml );
  9430. $data ['collectArray'] = $collectArray;
  9431. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9432. array_push ( $adjustment, $collectHtml );
  9433. $data ['adjustment'] = $adjustment;
  9434. // total price html
  9435. $collectHtml = "";
  9436. $total = 0;
  9437. for($i = 1; $i <= 12; $i ++) {
  9438. $sumPrice = 0;
  9439. foreach ( $receiptCollectList as $key => $value ) {
  9440. if ($value ['month'] == $i) {
  9441. $sumPrice += $value ['price'];
  9442. }
  9443. }
  9444. if ($sumPrice == 0)
  9445. $collectHtml .= '<td class="taR">-</td>';
  9446. else
  9447. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9448. $total += $sumPrice;
  9449. }
  9450. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9451. // statistics html
  9452. $stList = $statistics->statisticsByYear ( $year, $staffId );
  9453. if (empty ( $stList ))
  9454. $stList = array (
  9455. 'rePrice' => 0,
  9456. 'agPrice' => 0
  9457. );
  9458. $data ['stList'] = array (
  9459. 'rePrice' => $stList ['rePrice'],
  9460. 'agPrice' => $stList ['agPrice'],
  9461. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9462. );
  9463. $data ['totalPrice'] = $collectHtml;
  9464. $data ['totalYear'] = $total;
  9465. $data ['stHtml'] = $stHtml;
  9466. $data ['year'] = $year;
  9467. $data ['stTitle'] = $stTitle;
  9468. $data ['memu'] = "receipt";
  9469. $data ['staff'] = $this->staff;
  9470. $data ['receiptMemu'] = 'companyCategoryCollect';
  9471. $data ['verifyId'] = $this->verifyId;
  9472. $data ['executeId'] = $this->executeId;
  9473. if ($year < date ( "Y" )) {
  9474. Doo::loadModel ( 'receipt' );
  9475. $receipt = new receipt ();
  9476. $receiptList = $receipt->find ( array (
  9477. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  9478. 'asArray' => true
  9479. ) );
  9480. if (empty ( $receiptList )) { // generated files
  9481. ob_start ();
  9482. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9483. $this->cacheFile ( $path );
  9484. die ();
  9485. }
  9486. }
  9487. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9488. }
  9489. function BUGFLAG() {
  9490. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  9491. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  9492. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9493. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9494. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  9495. if (empty ( $status ))
  9496. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  9497. $page_size = 12;
  9498. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  9499. $vidList = array ();
  9500. $button = 0;
  9501. Doo::loadModel ( 'verify' );
  9502. $verify = new verify ();
  9503. Doo::loadModel ( 'receipt' );
  9504. $receipt = new receipt ();
  9505. Doo::loadModel ( 'staff' );
  9506. $staff = new staff ();
  9507. Doo::loadModel ( 'L_category' );
  9508. $Lcategory = new L_category ();
  9509. $dateCondition = " and Year(date) =" . $year;
  9510. if (! empty ( $month ))
  9511. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  9512. $categoryList = $Lcategory->find ( array (
  9513. 'asArray' => true
  9514. ) );
  9515. $staffList = $staff->find ( array (
  9516. 'where' => 'cid=' . $cid,
  9517. 'asArray' => true
  9518. ) );
  9519. $cateCondition = "";
  9520. $staffCondition = "";
  9521. $approvalCondition = "";
  9522. if (! empty ( $cid ))
  9523. $cateCondition = ' and cid=' . $cid;
  9524. if (! empty ( $sid )) {
  9525. $staffCondition = ' and staff=' . $sid;
  9526. $cateCondition = "";
  9527. }
  9528. $approvalCondition = " and status=" . $status;
  9529. if ($status == 2) {
  9530. // 查找角色审批人
  9531. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9532. }
  9533. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  9534. $approvalCondition = ' and status=2 ';
  9535. }
  9536. if ($status == 1) {
  9537. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  9538. }
  9539. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  9540. $pageinfo ['page'] = array (
  9541. 'previous' => ''
  9542. );
  9543. if ($status == 0) {
  9544. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  9545. $receiptList = $receipt->find ( array (
  9546. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  9547. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  9548. 'desc' => 'rid',
  9549. 'asArray' => true
  9550. ) );
  9551. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9552. } else
  9553. $receiptList = $receipt->find ( array (
  9554. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  9555. 'desc' => 'rid',
  9556. 'asArray' => true
  9557. ) );
  9558. $rLRes = $receipt->find ( array (
  9559. '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,
  9560. 'desc' => 'rid',
  9561. 'asArray' => true
  9562. ) );
  9563. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9564. // print_r($pageinfo);
  9565. $Locate = 0;
  9566. foreach ( $receiptList as $key => $value ) {
  9567. $receiptList [$key] ['Locate'] = $Locate;
  9568. $Locate ++;
  9569. $receiptList [$key] ['reviseDetail'] = array ();
  9570. if (! empty ( $value ['reviseDetail'] ))
  9571. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  9572. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  9573. $categoryDetil = $Lcategory->getOne ( array (
  9574. 'where' => 'cid=' . $value ['cid'],
  9575. 'asArray' => true
  9576. ) );
  9577. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  9578. $verifyList = $verify->getOne ( array (
  9579. 'where' => 'vid=' . $value ['verify'],
  9580. 'asArray' => true
  9581. ) );
  9582. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  9583. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  9584. foreach ( $verifyList as $k => $v ) {
  9585. // init verifyStaff
  9586. $verifyList [$k] ['date'] = "";
  9587. $verifyList [$k] ['opinion'] = "";
  9588. $verifyList [$k] ['status'] = "";
  9589. if (empty ( $verifyStaff )) {
  9590. $verifyList [$k] ['date'] = "";
  9591. $verifyList [$k] ['opinion'] = "";
  9592. if ($v [0] == $this->staff [0] ['sid']) {
  9593. $verifyList [$k] ['status'] = 4;
  9594. $button = 4;
  9595. }
  9596. } else {
  9597. $flag = true;
  9598. foreach ( $verifyStaff as $m => $u ) {
  9599. if ($v [0] == $m) {
  9600. $verifyList [$k] ['date'] = $u ['date'];
  9601. $verifyList [$k] ['opinion'] = $u ['opinion'];
  9602. $verifyList [$k] ['status'] = $u ['status'];
  9603. $flag = false;
  9604. break;
  9605. }
  9606. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  9607. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  9608. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  9609. }
  9610. if ($flag) { // 检测可编辑
  9611. if ($v [0] == $this->staff [0] ['sid']) {
  9612. $verifyList [$k] ['status'] = 4;
  9613. $button = 4;
  9614. }
  9615. }
  9616. }
  9617. }
  9618. $receiptList [$key] ['verifyList'] = $verifyList;
  9619. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  9620. 'where' => 'sid=' . $value ['staff'],
  9621. 'asArray' => true
  9622. ) );
  9623. $receiptList [$key] ['button'] = $button;
  9624. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  9625. }
  9626. // print_r($receiptList);die;
  9627. // $data['verifyDetail']=$verifyDetail;
  9628. $mothHtml = "";
  9629. for($i = 1; $i <= 12; $i ++) {
  9630. if ($month == $i)
  9631. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  9632. else
  9633. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  9634. }
  9635. $data ['mothHtml'] = $mothHtml;
  9636. $data ['page'] = $pageinfo;
  9637. $data ['receiptList'] = $receiptList;
  9638. $data ['receiptApprovalCount'] = count ( $rLRes );
  9639. $data ['status'] = $status;
  9640. $data ['year'] = $year;
  9641. $data ['categoryList'] = $categoryList;
  9642. $data ['staffList'] = $staffList;
  9643. $data ['cid'] = $cid;
  9644. $data ['sid'] = $sid;
  9645. // print_r($receiptList);
  9646. $data ['memu'] = "receipt";
  9647. $data ['staff'] = $this->staff;
  9648. $data ['receiptMemu'] = 'approvalExpenses';
  9649. $data ['verifyId'] = $this->verifyId;
  9650. $data ['executeId'] = $this->executeId;
  9651. $this->render ( "/admin/FALG", $data );
  9652. }
  9653. function ajaxGetReceiptOrder() {
  9654. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  9655. if (! empty ( $receiptOrder )) {
  9656. Doo::loadModel ( 'receipt' );
  9657. $receipt = new receipt ();
  9658. Doo::loadModel ( 'staff' );
  9659. $staff = new staff ();
  9660. $receiptInfo = $receipt->getOne ( array (
  9661. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  9662. 'asArray' => true
  9663. ) );
  9664. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  9665. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  9666. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  9667. </tbody></table><table class="table table table-bordered"><tbody>';
  9668. foreach ( $verifyStaff as $key => $value ) {
  9669. $staffInfo = $staff->getOne ( array (
  9670. 'select' => 'username',
  9671. 'where' => ' sid="' . $key . '"',
  9672. 'asArray' => true
  9673. ) );
  9674. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  9675. }
  9676. $html .= '</tbody></table></div></div>';
  9677. echo json_encode ( array (
  9678. 'status' => 1,
  9679. 'receiptHtml' => $html
  9680. ) );
  9681. die ();
  9682. }
  9683. echo json_encode ( array (
  9684. 'status' => 2,
  9685. 'receiptHtml' => ''
  9686. ) );
  9687. die ();
  9688. }
  9689. function _getMonthCollectDetail($receiptCollectList) {
  9690. if (! empty ( $receiptCollectList )) {
  9691. $receiptL = array (
  9692. '日常相关费用' => array (),
  9693. '差旅相关费用' => array (),
  9694. '培训班费用' => array (),
  9695. '其他' => array ()
  9696. );
  9697. $html = "";
  9698. $psum = 0;
  9699. $item = array (
  9700. '市内交通费',
  9701. '市内出租费',
  9702. '办事处房租',
  9703. '电话费',
  9704. '水费',
  9705. '电费',
  9706. '办公费用',
  9707. '邮寄费',
  9708. '其他费用',
  9709. '车辆费用',
  9710. '广告费',
  9711. '团队建设费',
  9712. '物业管理费',
  9713. '宽带费'
  9714. );
  9715. foreach ( $item as $value ) {
  9716. $falg = true;
  9717. foreach ( $receiptCollectList as $v ) {
  9718. if ($v ['itemCategory'] == '日常相关费用') {
  9719. if ($v ['item'] == $value) {
  9720. $psum += $v ['price'];
  9721. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9722. $falg = false;
  9723. break;
  9724. }
  9725. }
  9726. }
  9727. if ($falg)
  9728. $html .= '<td class="taR">-</td>';
  9729. }
  9730. if (! empty ( $psum ))
  9731. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9732. else
  9733. $psum = '<td class="colGreen taR">-</td>';
  9734. $receiptL ['日常相关费用'] = $psum . $html;
  9735. /* ----------------------------------- */
  9736. $html = "";
  9737. $psum = 0;
  9738. $item = array (
  9739. '往来交通费',
  9740. '市内交通费',
  9741. '出差住宿费',
  9742. '出差补助',
  9743. '其他费用'
  9744. );
  9745. foreach ( $item as $value ) {
  9746. $falg = true;
  9747. foreach ( $receiptCollectList as $v ) {
  9748. if ($v ['itemCategory'] == '差旅相关费用') {
  9749. if ($v ['item'] == $value) {
  9750. $psum += $v ['price'];
  9751. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9752. $falg = false;
  9753. break;
  9754. }
  9755. }
  9756. }
  9757. if ($falg)
  9758. $html .= '<td class="taR">-</td>';
  9759. }
  9760. if (! empty ( $psum ))
  9761. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9762. else
  9763. $psum = '<td class="colGreen taR">-</td>';
  9764. $receiptL ['差旅相关费用'] = $psum . $html;
  9765. /* ------------------------------------- */
  9766. $html = "";
  9767. $psum = 0;
  9768. $item = array (
  9769. '场租费',
  9770. '薪酬',
  9771. '住宿费',
  9772. '交通费',
  9773. '餐饮费',
  9774. '办公费',
  9775. '公关费',
  9776. '其他'
  9777. );
  9778. foreach ( $item as $value ) {
  9779. $falg = true;
  9780. foreach ( $receiptCollectList as $v ) {
  9781. if ($v ['itemCategory'] == '培训班费用') {
  9782. if ($v ['item'] == $value) {
  9783. $psum += $v ['price'];
  9784. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9785. $falg = false;
  9786. break;
  9787. }
  9788. }
  9789. }
  9790. if ($falg)
  9791. $html .= '<td class="taR">-</td>';
  9792. }
  9793. if (! empty ( $psum ))
  9794. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9795. else
  9796. $psum = '<td class="colGreen taR">-</td>';
  9797. $receiptL ['培训班费用'] = $psum . $html;
  9798. /* ------------------------------------- */
  9799. $html = "";
  9800. $psum = 0;
  9801. $item = array (
  9802. '公关费',
  9803. '广告费',
  9804. '借款',
  9805. '可自加费用'
  9806. );
  9807. foreach ( $item as $value ) {
  9808. $falg = true;
  9809. foreach ( $receiptCollectList as $v ) {
  9810. if ($v ['itemCategory'] == '其他') {
  9811. if ($v ['item'] == $value) {
  9812. $psum += $v ['price'];
  9813. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9814. $falg = false;
  9815. break;
  9816. }
  9817. }
  9818. }
  9819. if ($falg)
  9820. $html .= '<td class="taR">-</td>';
  9821. }
  9822. if (! empty ( $psum ))
  9823. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9824. else
  9825. $psum = '<td class="colGreen taR">-</td>';
  9826. $receiptL ['其他'] = $psum . $html;
  9827. /* ------------------------------------- */
  9828. $html = "";
  9829. $psum = 0;
  9830. foreach ( $receiptCollectList as $v ) {
  9831. if ($v ['itemCategory'] == '报销金额调整') {
  9832. if (! empty ( $v ['price'] ))
  9833. $psum += $v ['price'];
  9834. }
  9835. }
  9836. if (! empty ( $psum ))
  9837. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9838. else
  9839. $psum = '<td class="taR colOrange">-</td>';
  9840. $receiptL ['报销金额调整'] = $psum . $html;
  9841. } else {
  9842. $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>
  9843. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9844. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9845. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9846. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9847. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9848. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9849. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9850. }
  9851. return $receiptL;
  9852. }
  9853. function eMail() {
  9854. Doo::loadModel ( 'staff' );
  9855. $staff = new staff ();
  9856. Doo::loadModel ( 'receipt' );
  9857. $receipt = new receipt ();
  9858. Doo::loadModel ( 'L_category' );
  9859. $Lcategory = new L_category ();
  9860. Doo::loadModel ( "verify" );
  9861. $verify = new verify ();
  9862. $staffList = $staff->find ( array (
  9863. 'asArray' => true
  9864. ) );
  9865. foreach ( $staffList as $key => $value ) {
  9866. if ($value ['username'] != 'admin') {
  9867. // 提交人
  9868. $receiptList = $receipt->find ( array (
  9869. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  9870. 'asArray' => true
  9871. ) );
  9872. if (! empty ( $receiptList )) {
  9873. $html = '<br><div><style></style>
  9874. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  9875. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  9876. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9877. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  9878. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9879. <tbody><tr>
  9880. <td style="padding: 0 40px;" align="left">
  9881. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9882. </td></tr><tr>
  9883. <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>
  9884. </tr>
  9885. </tbody> </table></td> </tr> <tr><td>
  9886. <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">
  9887. <tbody> <tr><td>
  9888. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  9889. 以下报销单完成了审批,等着收款吧:</p>
  9890. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  9891. foreach ( $receiptList as $k => $v ) {
  9892. $category = $Lcategory->getOne ( array (
  9893. 'where' => 'cid=' . $v ['cid'],
  9894. 'asArray' => true
  9895. ) );
  9896. $html .= '
  9897. <tr>
  9898. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  9899. <td align="left">
  9900. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  9901. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  9902. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  9903. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  9904. </tr>';
  9905. }
  9906. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  9907. <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>
  9908. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  9909. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  9910. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  9911. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9912. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9913. $receipt = new receipt ();
  9914. $receipt->notice = 1;
  9915. $receipt->update ( array (
  9916. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  9917. ) );
  9918. }
  9919. }
  9920. // 审批人
  9921. $verifyList = $verify->find ( array (
  9922. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  9923. 'asArray' => true
  9924. ) );
  9925. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  9926. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  9927. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9928. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  9929. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9930. <tbody><tr><td style="padding: 0 40px;" align="left">
  9931. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9932. </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>
  9933. </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">
  9934. <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>
  9935. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  9936. foreach ( $verifyList as $k => $v ) {
  9937. $receiptList = $receipt->find ( array (
  9938. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  9939. 'asArray' => true
  9940. ) );
  9941. foreach ( $receiptList as $r => $l ) {
  9942. $category = $Lcategory->getOne ( array (
  9943. 'where' => 'cid=' . $l ['cid'],
  9944. 'asArray' => true
  9945. ) );
  9946. $staffDetile = $staff->getOne ( array (
  9947. 'where' => 'sid=' . $l ['staff'],
  9948. 'asArray' => true
  9949. ) );
  9950. $html .= '
  9951. <tr>
  9952. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  9953. <td align="left">
  9954. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  9955. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  9956. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  9957. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  9958. </tr>';
  9959. }
  9960. }
  9961. $html .= '
  9962. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  9963. <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>
  9964. </tr></tbody></table></td></tr></tbody></table></div><br>';
  9965. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  9966. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  9967. // $receipt=new receipt();
  9968. // $receipt->notice=1;
  9969. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  9970. }
  9971. }
  9972. }
  9973. }
  9974. function setWXMsg($rid, $type) {
  9975. Doo::loadModel ( "receipt" );
  9976. $receipt = new receipt ();
  9977. $receiptDetail = $receipt->getOne ( array (
  9978. 'where' => 'rid=' . $rid,
  9979. 'asArray' => true
  9980. ) );
  9981. if (! empty ( $receiptDetail )) {
  9982. Doo::loadModel ( 'staff' );
  9983. $staff = new staff ();
  9984. $staffmsg = $staff->getOne ( array (
  9985. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  9986. 'asArray' => TRUE
  9987. ) );
  9988. if (! empty ( $staffmsg ['wxid'] )) {
  9989. require_once (SITE_PATH . '/protected/class/client.php');
  9990. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  9991. $user = $staffmsg ['wxid'];
  9992. $receiptName = '';
  9993. $msg = '';
  9994. switch ($receiptDetail ['Rtype']) {
  9995. case 0 :
  9996. $receiptName = '报销';
  9997. break;
  9998. case 1 :
  9999. $receiptName = '借款';
  10000. break;
  10001. case 2 :
  10002. $receiptName = '对公汇款';
  10003. break;
  10004. }
  10005. switch ($type) {
  10006. case 1 :
  10007. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  10008. break;
  10009. case 2 :
  10010. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  10011. break;
  10012. case 3 :
  10013. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  10014. break;
  10015. }
  10016. $result = $client->SendMsg ( $user, $msg, 'text' );
  10017. }
  10018. }
  10019. }
  10020. // Email发送函数
  10021. function SMail($toemail, $subject, $contents) {
  10022. Doo::loadClass ( 'class.phpmailer' );
  10023. $mail = new PHPMailer ();
  10024. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  10025. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  10026. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  10027. $mail->Password = "cDO1GjtY1seH"; // 密码
  10028. $mail->CharSet = "UTF8";
  10029. $mail->SMTPAuth = true;
  10030. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  10031. $mail->Mailer = "smtp";
  10032. $mail->Port = 25;
  10033. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  10034. $mail->MsgHTML ( $contents );
  10035. $mail->AddAddress ( $toemail );
  10036. $mail->CharSet = "UTF-8";
  10037. return $mail->Send ();
  10038. }
  10039. function swfupload() {
  10040. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  10041. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  10042. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  10043. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  10044. header ( "HTTP/1.1 500 Internal Server Error" );
  10045. echo "POST exceeded maximum allowed size.";
  10046. exit ( 0 );
  10047. }
  10048. // Settings
  10049. $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)
  10050. $upload_name = "Filedata";
  10051. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  10052. $extension_whitelist = array (
  10053. "doc",
  10054. "txt",
  10055. "jpg",
  10056. "gif",
  10057. "png"
  10058. ); // Allowed file extensions
  10059. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  10060. // Other variables
  10061. $MAX_FILENAME_LENGTH = 260;
  10062. $file_name = "";
  10063. $file_extension = "";
  10064. $uploadErrors = array (
  10065. 0 => "文件上传成功",
  10066. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  10067. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  10068. 3 => "上传的文件仅为部分文件",
  10069. 4 => "没有文件上传",
  10070. 6 => "缺少临时文件夹"
  10071. );
  10072. $nk = time ();
  10073. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  10074. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  10075. echo "文件无法保存.";
  10076. exit ( 0 );
  10077. }
  10078. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  10079. echo json_encode ( array (
  10080. 'filename' => $file_name,
  10081. 'id' => $nk
  10082. ) );
  10083. exit ( 0 );
  10084. }
  10085. function _GetFileEXT($filename) {
  10086. $pics = explode ( '.', $filename );
  10087. $num = count ( $pics );
  10088. return $pics [$num - 1];
  10089. }
  10090. /**
  10091. * 获取get或者POST值
  10092. * @param string $name 属性名称
  10093. * @return fixed 值
  10094. */
  10095. function get_args($name) {
  10096. if (isset ( $_GET [$name] )) {
  10097. if (is_array ( $_GET [$name] ))
  10098. return $_GET [$name];
  10099. else
  10100. return addslashes ( $_GET [$name] );
  10101. } elseif (isset ( $_POST [$name] )) {
  10102. if (is_array ( $_POST [$name] ))
  10103. return $_POST [$name];
  10104. else
  10105. return addslashes ( $_POST [$name] );
  10106. } else
  10107. return false;
  10108. }
  10109. function num_to_rmb($num) {
  10110. $c1 = "零壹贰叁肆伍陆柒捌玖";
  10111. $c2 = "分角元拾佰仟万拾佰仟亿";
  10112. // 精确到分后面就不要了,所以只留两个小数位
  10113. $num = round ( $num, 2 );
  10114. // 将数字转化为整数
  10115. $num = $num * 100;
  10116. if (strlen ( $num ) > 10) {
  10117. return "金额太大,请检查";
  10118. }
  10119. $i = 0;
  10120. $c = "";
  10121. while ( 1 ) {
  10122. if ($i == 0) {
  10123. // 获取最后一位数字
  10124. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  10125. } else {
  10126. $n = $num % 10;
  10127. }
  10128. // 每次将最后一位数字转化为中文
  10129. $p1 = substr ( $c1, 3 * $n, 3 );
  10130. $p2 = substr ( $c2, 3 * $i, 3 );
  10131. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  10132. $c = $p1 . $p2 . $c;
  10133. } else {
  10134. $c = $p1 . $c;
  10135. }
  10136. $i = $i + 1;
  10137. // 去掉数字最后一位了
  10138. $num = $num / 10;
  10139. $num = ( int ) $num;
  10140. // 结束循环
  10141. if ($num == 0) {
  10142. break;
  10143. }
  10144. }
  10145. $j = 0;
  10146. $slen = strlen ( $c );
  10147. while ( $j < $slen ) {
  10148. // utf8一个汉字相当3个字符
  10149. $m = substr ( $c, $j, 6 );
  10150. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  10151. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  10152. $left = substr ( $c, 0, $j );
  10153. $right = substr ( $c, $j + 3 );
  10154. $c = $left . $right;
  10155. $j = $j - 3;
  10156. $slen = $slen - 3;
  10157. }
  10158. $j = $j + 3;
  10159. }
  10160. // 这个是为了去掉类似23.0中最后一个“零”字
  10161. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  10162. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  10163. }
  10164. // 将处理的汉字加上“整”
  10165. if (empty ( $c )) {
  10166. return "零元整";
  10167. } else {
  10168. return $c . "整";
  10169. }
  10170. }
  10171. /**
  10172. * 获得分页数据
  10173. * @param unknown_type $table
  10174. * @param unknown_type $condition
  10175. * @param unknown_type $on_page
  10176. * @param unknown_type $page_size
  10177. */
  10178. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  10179. $page_c = "";
  10180. $page ['previous'] = $this->get_previous ( $on_page );
  10181. $page ['on_page'] = $on_page;
  10182. $total_count = $this->get_table_count ( $table, $condition );
  10183. $total = intval ( $total_count / $page_size );
  10184. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  10185. $page ['total_data'] = $total_count;
  10186. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  10187. $i = 1;
  10188. $page_max = 1;
  10189. $page_width = 3;
  10190. if ($on_page >= $page_width) {
  10191. $page_max = intval ( $on_page / $page_width ) + 1;
  10192. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  10193. }
  10194. for(; $i <= $page ['total_page']; $i ++) {
  10195. if ($i == $on_page)
  10196. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  10197. else
  10198. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  10199. if ($i == ($page_width * $page_max))
  10200. break;
  10201. }
  10202. $page ['page'] = $page_c;
  10203. $page ['lower'] = (-- $on_page) * $page_size;
  10204. return $page;
  10205. }
  10206. /**
  10207. * 获取总页数
  10208. * @param unknown_type $table
  10209. * @param unknown_type $condition
  10210. */
  10211. public function get_table_count($table = "", $condition = "") {
  10212. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10213. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10214. // echo $sql;die;
  10215. $query = Doo::db ()->query ( $sql );
  10216. $result = $query->fetch ();
  10217. return $result ['count'];
  10218. }
  10219. /**
  10220. * 获取上一页
  10221. * @param unknown_type $on_page
  10222. */
  10223. function get_previous($on_page = 1) {
  10224. return $on_page != 0 ? $on_page - 1 : $on_page;
  10225. }
  10226. }
  10227. ?>