ReceiptController.php 369 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557
  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'] ) && is_numeric ( $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. $categoryList = $Lcategory->find ( array (
  2213. 'asArray' => true
  2214. ) );
  2215. $staffList = $staff->find ( array (
  2216. 'where' => 'cid=' . $cid,
  2217. 'asArray' => true
  2218. ) );
  2219. $cateCondition = "";
  2220. $staffCondition = "";
  2221. $approvalCondition = "";
  2222. if (! empty ( $cid ))
  2223. $cateCondition = ' and cid=' . $cid;
  2224. if (! empty ( $sid )) {
  2225. $staffCondition = ' and staff=' . $sid;
  2226. $cateCondition = "";
  2227. }
  2228. $approvalCondition = " and status=" . $status;
  2229. if ($status == 2) {
  2230. // 查找角色审批人
  2231. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  2232. }
  2233. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  2234. $approvalCondition = ' and status=2 ';
  2235. }
  2236. if ($status == 1) {
  2237. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  2238. }
  2239. if ($status == 8) {
  2240. $approvalCondition = ' and (status=' . $status . ' or status=9) ';
  2241. }
  2242. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  2243. $pageinfo ['page'] = array (
  2244. 'previous' => ''
  2245. );
  2246. if ($status == 0) {
  2247. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  2248. $receiptList = $receipt->find ( array (
  2249. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ')',
  2250. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2251. 'desc' => 'rid',
  2252. 'asArray' => true
  2253. ) );
  2254. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2255. } else
  2256. $receiptList = $receipt->find ( array (
  2257. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
  2258. 'desc' => 'rid',
  2259. 'asArray' => true
  2260. ) );
  2261. $rLRes = $receipt->find ( array (
  2262. '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,
  2263. 'desc' => 'rid',
  2264. 'asArray' => true
  2265. ) );
  2266. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2267. // print_r($pageinfo);
  2268. $Locate = 0;
  2269. foreach ( $receiptList as $key => $value ) {
  2270. $receiptList [$key] ['Locate'] = $Locate;
  2271. $Locate ++;
  2272. $receiptList [$key] ['reviseDetail'] = array ();
  2273. if (! empty ( $value ['reviseDetail'] ))
  2274. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2275. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2276. $categoryDetil = $Lcategory->getOne ( array (
  2277. 'where' => 'cid=' . $value ['cid'],
  2278. 'asArray' => true
  2279. ) );
  2280. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2281. $verifyList = $verify->getOne ( array (
  2282. 'where' => 'vid=' . $value ['verify'],
  2283. 'asArray' => true
  2284. ) );
  2285. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2286. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2287. foreach ( $verifyList as $k => $v ) {
  2288. // init verifyStaff
  2289. $verifyList [$k] ['date'] = "";
  2290. $verifyList [$k] ['opinion'] = "";
  2291. $verifyList [$k] ['status'] = "";
  2292. if (empty ( $verifyStaff )) {
  2293. $verifyList [$k] ['date'] = "";
  2294. $verifyList [$k] ['opinion'] = "";
  2295. if ($v [0] == $this->staff [0] ['sid']) {
  2296. $verifyList [$k] ['status'] = 4;
  2297. $button = 4;
  2298. }
  2299. } else {
  2300. $flag = true;
  2301. foreach ( $verifyStaff as $m => $u ) {
  2302. if ($v [0] == $m) {
  2303. $verifyList [$k] ['date'] = $u ['date'];
  2304. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2305. $verifyList [$k] ['status'] = $u ['status'];
  2306. $flag = false;
  2307. break;
  2308. }
  2309. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  2310. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  2311. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  2312. }
  2313. if ($flag) { // 检测可编辑
  2314. if ($v [0] == $this->staff [0] ['sid']) {
  2315. $verifyList [$k] ['status'] = 4;
  2316. $button = 4;
  2317. }
  2318. }
  2319. }
  2320. }
  2321. $receiptList [$key] ['verifyList'] = $verifyList;
  2322. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2323. 'where' => 'sid=' . $value ['staff'],
  2324. 'asArray' => true
  2325. ) );
  2326. $receiptList [$key] ['button'] = $button;
  2327. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  2328. }
  2329. // print_r($receiptList);die;
  2330. // $data['verifyDetail']=$verifyDetail;
  2331. $mothHtml = "";
  2332. for($i = 1; $i <= 12; $i ++) {
  2333. if ($month == $i)
  2334. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2335. else
  2336. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2337. }
  2338. $data ['mothHtml'] = $mothHtml;
  2339. $data ['page'] = $pageinfo;
  2340. $data ['receiptList'] = $receiptList;
  2341. $data ['receiptApprovalCount'] = count ( $rLRes );
  2342. $data ['status'] = $status;
  2343. $data ['year'] = $year;
  2344. $data ['categoryList'] = $categoryList;
  2345. $data ['staffList'] = $staffList;
  2346. $data ['cid'] = $cid;
  2347. $data ['sid'] = $sid;
  2348. // print_r($receiptList);
  2349. $data ['memu'] = "receipt";
  2350. $data ['staff'] = $this->staff;
  2351. $data ['receiptMemu'] = 'approvalExpenses';
  2352. $data ['verifyId'] = $this->verifyId;
  2353. $data ['executeId'] = $this->executeId;
  2354. $this->render ( "/admin/approvalExpenses", $data );
  2355. }
  2356. function expensesDoc() {
  2357. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2358. Doo::loadModel ( 'receipt' );
  2359. $receipt = new receipt ();
  2360. Doo::loadModel ( 'L_category' );
  2361. $Lcategory = new L_category ();
  2362. Doo::loadModel ( 'verify' );
  2363. Doo::loadModel ( 'statistics' );
  2364. $statistics = new statistics ();
  2365. $verify = new verify ();
  2366. Doo::loadModel ( 'staff' );
  2367. $staff = new staff ();
  2368. Doo::loadModel ( 'loanReceipt' );
  2369. $loanReceipt = new loanReceipt ();
  2370. $receiptList = $receipt->find ( array (
  2371. 'where' => ' rid=' . $rid,
  2372. 'desc' => 'rid',
  2373. 'asArray' => true
  2374. ) );
  2375. $loanList = array ();
  2376. if (! empty ( $receiptList ))
  2377. $loanList = $loanReceipt->find ( array (
  2378. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2379. 'desc' => 'rid',
  2380. 'asArray' => true
  2381. ) );
  2382. $Locate = 0;
  2383. $roleId = 0;
  2384. $button = 0;
  2385. foreach ( $loanList as $key => $value ) {
  2386. $loanList [$key] ['Locate'] = $Locate;
  2387. $Locate ++;
  2388. $loanList [$key] ['reviseDetail'] = array ();
  2389. if (! empty ( $value ['reviseDetail'] ))
  2390. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2391. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2392. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2393. $categoryDetil = $Lcategory->getOne ( array (
  2394. 'where' => 'cid=' . $value ['cid'],
  2395. 'asArray' => true
  2396. ) );
  2397. $loanList [$key] ['category'] = $categoryDetil ['title'];
  2398. // 检测编辑状态
  2399. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  2400. $verifyList ['staff'] = $value ['verifyBreakup'];
  2401. else
  2402. $verifyList = $verify->getOne ( array (
  2403. 'where' => 'vid=' . $value ['verify'],
  2404. 'asArray' => true
  2405. ) );
  2406. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2407. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2408. Doo::loadModel ( 'role' );
  2409. $role = new role ();
  2410. $flag = true;
  2411. $roleKey = 0;
  2412. $endStaffArray = array ();
  2413. $roleArrayCopy = array ();
  2414. foreach ( $verifyList as $k => $v ) {
  2415. // init verifyStaff
  2416. if ($v [1] == 'ROLE') {
  2417. if (! empty ( $verifyStaff )) {
  2418. $endStaffArray = end ( $verifyStaff );
  2419. // if ($v[0]==$endStaffArray['nextStaff']){
  2420. // $roleId=$v[0];
  2421. // }
  2422. }
  2423. $roleVerify = json_decode ( $v [3], true );
  2424. $roleKey = $k;
  2425. $roleArray = array ();
  2426. $rolename = $role->getOne ( array (
  2427. 'where' => 'rid=' . $v [0],
  2428. 'asArray' => true
  2429. ) );
  2430. foreach ( $roleVerify as $o => $p ) {
  2431. $staffID = explode ( '_', $p );
  2432. $staffInfo = $staff->getOne ( array (
  2433. 'where' => 'sid=' . $staffID [0],
  2434. 'asArray' => true
  2435. ) );
  2436. // print_r($staffID);
  2437. $exp = array (
  2438. 0 => $staffInfo ['sid'],
  2439. 1 => $staffID [1],
  2440. 2 => $staffInfo ['avatar'],
  2441. 'date' => '',
  2442. 'date' => '',
  2443. 'opinion' => '',
  2444. 'status' => '',
  2445. 'rolename' => $rolename ['name']
  2446. );
  2447. array_push ( $roleArray, $exp );
  2448. }
  2449. $roleArrayCopy [$v [0]] = $roleArray;
  2450. // $verifyList[$k]['roleArray']=$roleArray;
  2451. }
  2452. $verifyList [$k] ['date'] = "";
  2453. $verifyList [$k] ['opinion'] = "";
  2454. $verifyList [$k] ['status'] = "";
  2455. if (empty ( $verifyStaff )) {
  2456. $verifyList [$k] ['date'] = "";
  2457. $verifyList [$k] ['opinion'] = "";
  2458. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2459. $verifyList [$k] ['status'] = 4;
  2460. $flag = false;
  2461. }
  2462. } else {
  2463. foreach ( $verifyStaff as $m => $u ) {
  2464. if ($v [0] == $m) {
  2465. $verifyList [$k] ['date'] = $u ['date'];
  2466. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2467. $verifyList [$k] ['status'] = $u ['status'];
  2468. $flag = false;
  2469. break;
  2470. }
  2471. }
  2472. $endStaffArray = end ( $verifyStaff );
  2473. if (isset ( $endStaffArray ['ROLE'] )) {
  2474. } else {
  2475. // $endKey=key($verifyStaff);
  2476. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2477. // $button=4;
  2478. // $verifyList[$k]['status']=4;
  2479. // }
  2480. }
  2481. }
  2482. }
  2483. $rolename ['name'] = '';
  2484. if (! empty ( $roleId )) {
  2485. Doo::loadModel ( 'role' );
  2486. $role = new role ();
  2487. $rolename = $role->getOne ( array (
  2488. 'where' => 'rid=' . $roleId,
  2489. 'asArray' => true
  2490. ) );
  2491. }
  2492. if (! empty ( $verifyStaff ))
  2493. $endStaffArray = end ( $verifyStaff );
  2494. $KOP = false;
  2495. foreach ( $roleArrayCopy as $P => $A ) {
  2496. foreach ( $A as $MKI => $AVL ) {
  2497. if (! empty ( $verifyStaff )) {
  2498. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2499. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2500. $button = 4;
  2501. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2502. }
  2503. foreach ( $verifyStaff as $m => $u ) {
  2504. $AVLFK = $AVL [0] . '_R';
  2505. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2506. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2507. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2508. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2509. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2510. break;
  2511. }
  2512. }
  2513. } else {
  2514. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2515. $button = 4;
  2516. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2517. }
  2518. }
  2519. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2520. $KOP = true;
  2521. }
  2522. }
  2523. foreach ( $roleArrayCopy as $k => $v ) {
  2524. foreach ( $verifyList as $m => $n ) {
  2525. if ($n [0] == $k) {
  2526. array_splice ( $verifyList, $m, 1, $v );
  2527. }
  2528. }
  2529. }
  2530. $loanList [$key] ['verifyList'] = $verifyList;
  2531. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  2532. 'where' => 'sid=' . $value ['staff'],
  2533. 'asArray' => true
  2534. ) );
  2535. $loanList [$key] ['button'] = $button;
  2536. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  2537. }
  2538. $data ['loanList'] = $loanList;
  2539. // print_r($loanList);
  2540. $Locate = 0;
  2541. $roleId = 0;
  2542. $button = 0;
  2543. foreach ( $receiptList as $key => $value ) {
  2544. $receiptList [$key] ['Locate'] = $Locate;
  2545. $Locate ++;
  2546. $receiptList [$key] ['reviseDetail'] = array ();
  2547. if (! empty ( $value ['reviseDetail'] ))
  2548. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2549. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2550. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2551. $categoryDetil = $Lcategory->getOne ( array (
  2552. 'where' => 'cid=' . $value ['cid'],
  2553. 'asArray' => true
  2554. ) );
  2555. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2556. // 检测编辑状态
  2557. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  2558. $verifyList ['staff'] = $value ['verifyBreakup'];
  2559. } else
  2560. $verifyList = $verify->getOne ( array (
  2561. 'where' => 'vid=' . $value ['verify'],
  2562. 'asArray' => true
  2563. ) );
  2564. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2565. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2566. Doo::loadModel ( 'role' );
  2567. $role = new role ();
  2568. if ($verifyList == NULL)
  2569. $verifyList = array ();
  2570. $flag = true;
  2571. $roleKey = 0;
  2572. $endStaffArray = array ();
  2573. $roleArrayCopy = array ();
  2574. foreach ( $verifyList as $k => $v ) {
  2575. // init verifyStaff
  2576. if ($v [1] == 'ROLE') {
  2577. if (! empty ( $verifyStaff )) {
  2578. $endStaffArray = end ( $verifyStaff );
  2579. // if ($v[0]==$endStaffArray['nextStaff']){
  2580. // $roleId=$v[0];
  2581. // }
  2582. }
  2583. $roleVerify = json_decode ( $v [3], true );
  2584. $roleKey = $k;
  2585. $roleArray = array ();
  2586. $rolename = $role->getOne ( array (
  2587. 'where' => 'rid=' . $v [0],
  2588. 'asArray' => true
  2589. ) );
  2590. foreach ( $roleVerify as $o => $p ) {
  2591. $staffID = explode ( '_', $p );
  2592. $staffInfo = $staff->getOne ( array (
  2593. 'where' => 'sid=' . $staffID [0],
  2594. 'asArray' => true
  2595. ) );
  2596. // print_r($staffID);
  2597. $exp = array (
  2598. 0 => $staffInfo ['sid'],
  2599. 1 => $staffID [1],
  2600. 2 => $staffInfo ['avatar'],
  2601. 'date' => '',
  2602. 'date' => '',
  2603. 'opinion' => '',
  2604. 'status' => '',
  2605. 'rolename' => $rolename ['name']
  2606. );
  2607. array_push ( $roleArray, $exp );
  2608. }
  2609. $roleArrayCopy [$v [0]] = $roleArray;
  2610. // $verifyList[$k]['roleArray']=$roleArray;
  2611. }
  2612. $verifyList [$k] ['date'] = "";
  2613. $verifyList [$k] ['opinion'] = "";
  2614. $verifyList [$k] ['status'] = "";
  2615. if (empty ( $verifyStaff )) {
  2616. $verifyList [$k] ['date'] = "";
  2617. $verifyList [$k] ['opinion'] = "";
  2618. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2619. $verifyList [$k] ['status'] = 4;
  2620. $flag = false;
  2621. }
  2622. } else {
  2623. foreach ( $verifyStaff as $m => $u ) {
  2624. if ($v [0] == $m) {
  2625. $verifyList [$k] ['date'] = $u ['date'];
  2626. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2627. $verifyList [$k] ['status'] = $u ['status'];
  2628. $flag = false;
  2629. break;
  2630. }
  2631. }
  2632. $endStaffArray = end ( $verifyStaff );
  2633. if (isset ( $endStaffArray ['ROLE'] )) {
  2634. } else {
  2635. // $endKey=key($verifyStaff);
  2636. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2637. // $button=4;
  2638. // $verifyList[$k]['status']=4;
  2639. // }
  2640. }
  2641. }
  2642. }
  2643. $rolename ['name'] = '';
  2644. if (! empty ( $roleId )) {
  2645. Doo::loadModel ( 'role' );
  2646. $role = new role ();
  2647. $rolename = $role->getOne ( array (
  2648. 'where' => 'rid=' . $roleId,
  2649. 'asArray' => true
  2650. ) );
  2651. }
  2652. if (! empty ( $verifyStaff ))
  2653. $endStaffArray = end ( $verifyStaff );
  2654. $KOP = false;
  2655. foreach ( $roleArrayCopy as $P => $A ) {
  2656. foreach ( $A as $MKI => $AVL ) {
  2657. if (! empty ( $verifyStaff )) {
  2658. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2659. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2660. $button = 4;
  2661. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2662. }
  2663. foreach ( $verifyStaff as $m => $u ) {
  2664. $AVLFK = $AVL [0] . '_R';
  2665. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2666. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2667. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2668. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2669. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2670. break;
  2671. }
  2672. }
  2673. } else {
  2674. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2675. $button = 4;
  2676. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2677. }
  2678. }
  2679. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2680. $KOP = true;
  2681. }
  2682. }
  2683. foreach ( $roleArrayCopy as $k => $v ) {
  2684. foreach ( $verifyList as $m => $n ) {
  2685. if ($n [0] == $k) {
  2686. array_splice ( $verifyList, $m, 1, $v );
  2687. }
  2688. }
  2689. }
  2690. // 费用执行人相关数据
  2691. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2692. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2693. foreach ( $executeCopy as $k => $v ) {
  2694. $executeCopy [$k] ['date'] = '';
  2695. $executeCopy [$k] ['opinion'] = '';
  2696. $executeCopy [$k] ['status'] = '';
  2697. if (! empty ( $executeStaff ))
  2698. foreach ( $executeStaff as $m => $u ) {
  2699. if ($v [0] == $m) {
  2700. $executeCopy [$k] ['date'] = $u ['date'];
  2701. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2702. $executeCopy [$k] ['status'] = $u ['status'];
  2703. break;
  2704. }
  2705. }
  2706. }
  2707. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2708. $receiptList [$key] ['verifyList'] = $verifyList;
  2709. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2710. 'where' => 'sid=' . $value ['staff'],
  2711. 'asArray' => true
  2712. ) );
  2713. $receiptList [$key] ['button'] = $button;
  2714. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2715. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2716. $relust = $value ['sum'] - $value ['loanSum'];
  2717. $receiptList [$key] ['relust'] = $relust;
  2718. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs($relust) );
  2719. }
  2720. // print_r($receiptList);
  2721. // 获取审批日志
  2722. Doo::loadModel ( 'receiptLog' );
  2723. $receiptLog = new receiptLog ();
  2724. $rlList = array ();
  2725. $rlInfo = $receiptLog->getOne ( array (
  2726. 'where' => 'rid=' . $rid . ' and status=4',
  2727. 'asArray' => true
  2728. ) );
  2729. $tijdate = $receiptLog->getOne ( array (
  2730. 'where' => 'rid=' . $rid . ' and status=2',
  2731. 'asc' => 'rlid',
  2732. 'asArray' => true
  2733. ) );
  2734. if (! empty ( $rlInfo )) {
  2735. $rlList = $receiptLog->find ( array (
  2736. 'where' => 'rid=' . $rid,
  2737. 'asc' => 'rlid',
  2738. 'asArray' => true
  2739. ) );
  2740. }
  2741. Doo::loadModel ( 'enclosur' );
  2742. $enclosur = new enclosur ();
  2743. $enclosurList = $enclosur->find ( array (
  2744. 'where' => 'rid=' . $rid,
  2745. 'asArray' => true
  2746. ) );
  2747. $enclosurHtml = '';
  2748. foreach ( $enclosurList as $value ) {
  2749. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2750. }
  2751. $data ['enclosurHtml'] = $enclosurHtml;
  2752. $receiptList [0] ['rlList'] = $rlList;
  2753. $data ['receiptList'] = $receiptList;
  2754. $data ['memu'] = "receipt";
  2755. $data ['staff'] = $this->staff;
  2756. $data ['receiptMemu'] = 'approvalExpenses';
  2757. $data ['verifyId'] = $this->verifyId;
  2758. $data ['executeId'] = $this->executeId;
  2759. $this->render ( "/admin/expensesDoc", $data );
  2760. }
  2761. function expensesEdi() {
  2762. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2763. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  2764. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2765. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2766. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2767. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2768. if (empty ( $status ))
  2769. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  2770. $vidList = array ();
  2771. $button = 0;
  2772. Doo::loadModel ( 'verify' );
  2773. Doo::loadModel ( 'receipt' );
  2774. Doo::loadModel ( 'staff' );
  2775. $staff = new staff ();
  2776. $receipt = new receipt ();
  2777. $verify = new verify ();
  2778. Doo::loadModel ( 'L_category' );
  2779. $Lcategory = new L_category ();
  2780. Doo::loadModel ( 'enclosur' );
  2781. $enclosur = new enclosur ();
  2782. // user verify ID
  2783. $verifyDetail = $verify->find ( array (
  2784. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  2785. 'asArray' => true
  2786. ) );
  2787. foreach ( $verifyDetail as $key => $value ) {
  2788. array_push ( $vidList, $value ['vid'] );
  2789. }
  2790. $vid = implode ( ",", $vidList );
  2791. if (empty ( $verifyDetail ))
  2792. $vid = 0;
  2793. $categoryList = $Lcategory->find ( array (
  2794. 'asArray' => true
  2795. ) );
  2796. $staffList = $staff->find ( array (
  2797. 'where' => 'cid=' . $cid,
  2798. 'asArray' => true
  2799. ) );
  2800. $ap = "";
  2801. if ($status == 4) {
  2802. $ap = 4;
  2803. $status = 2;
  2804. }
  2805. // get Receipt By verifyID status 2
  2806. $receiptList = $receipt->find ( array (
  2807. 'where' => 'rid =' . $rid,
  2808. 'desc' => 'rid',
  2809. 'asArray' => true
  2810. ) );
  2811. $Locate = 0;
  2812. $roleId = 0;
  2813. if ($ap == 4)
  2814. $status = 4;
  2815. foreach ( $receiptList as $key => $value ) {
  2816. $receiptList [$key] ['Locate'] = $Locate;
  2817. $Locate ++;
  2818. $receiptList [$key] ['reviseDetail'] = array ();
  2819. if (! empty ( $value ['reviseDetail'] ))
  2820. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2821. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2822. $categoryDetil = $Lcategory->getOne ( array (
  2823. 'where' => 'cid=' . $value ['cid'],
  2824. 'asArray' => true
  2825. ) );
  2826. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2827. // 检测编辑状态
  2828. $verifyList = $verify->getOne ( array (
  2829. 'where' => 'vid=' . $value ['verify'],
  2830. 'asArray' => true
  2831. ) );
  2832. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2833. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2834. Doo::loadModel ( 'role' );
  2835. $role = new role ();
  2836. // print_r($verifyList);
  2837. $flag = true;
  2838. $roleKey = 0;
  2839. $endStaffArray = array ();
  2840. $roleArrayCopy = array ();
  2841. foreach ( $verifyList as $k => $v ) {
  2842. // init verifyStaff
  2843. if ($v [1] == 'ROLE') {
  2844. if (! empty ( $verifyStaff )) {
  2845. $endStaffArray = end ( $verifyStaff );
  2846. if ($v [0] == $endStaffArray ['nextStaff']) {
  2847. $roleId = $v [0];
  2848. }
  2849. }
  2850. $roleVerify = json_decode ( $v [3], true );
  2851. $roleKey = $k;
  2852. $roleArray = array ();
  2853. $rolename = $role->getOne ( array (
  2854. 'where' => 'rid=' . $v [0],
  2855. 'asArray' => true
  2856. ) );
  2857. foreach ( $roleVerify as $o => $p ) {
  2858. $staffID = explode ( '_', $p );
  2859. $staffInfo = $staff->getOne ( array (
  2860. 'where' => 'sid=' . $staffID [0],
  2861. 'asArray' => true
  2862. ) );
  2863. // print_r($staffID);
  2864. $exp = array (
  2865. 0 => $staffInfo ['sid'],
  2866. 1 => $staffID [1],
  2867. 2 => $staffInfo ['avatar'],
  2868. 'date' => '',
  2869. 'date' => '',
  2870. 'opinion' => '',
  2871. 'status' => '',
  2872. 'rolename' => $rolename ['name']
  2873. );
  2874. array_push ( $roleArray, $exp );
  2875. }
  2876. $roleArrayCopy [$v [0]] = $roleArray;
  2877. // $verifyList[$k]['roleArray']=$roleArray;
  2878. }
  2879. // print_r($roleArray);
  2880. $verifyList [$k] ['date'] = "";
  2881. $verifyList [$k] ['opinion'] = "";
  2882. $verifyList [$k] ['status'] = "";
  2883. if (empty ( $verifyStaff )) {
  2884. $verifyList [$k] ['date'] = "";
  2885. $verifyList [$k] ['opinion'] = "";
  2886. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2887. $verifyList [$k] ['status'] = 4;
  2888. $button = 4;
  2889. $flag = false;
  2890. }
  2891. } else {
  2892. foreach ( $verifyStaff as $m => $u ) {
  2893. if ($v [0] == $m) {
  2894. $verifyList [$k] ['date'] = $u ['date'];
  2895. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2896. $verifyList [$k] ['status'] = $u ['status'];
  2897. $flag = false;
  2898. break;
  2899. }
  2900. }
  2901. $endStaffArray = end ( $verifyStaff );
  2902. if (isset ( $endStaffArray ['ROLE'] )) {
  2903. } else {
  2904. $endKey = key ( $verifyStaff );
  2905. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  2906. $button = 4;
  2907. $verifyList [$k] ['status'] = 4;
  2908. }
  2909. }
  2910. }
  2911. }
  2912. $rolename ['name'] = '';
  2913. if (! empty ( $roleId )) {
  2914. Doo::loadModel ( 'role' );
  2915. $role = new role ();
  2916. $rolename = $role->getOne ( array (
  2917. 'where' => 'rid=' . $roleId,
  2918. 'asArray' => true
  2919. ) );
  2920. }
  2921. if (! empty ( $verifyStaff ))
  2922. $endStaffArray = end ( $verifyStaff );
  2923. $KOP = false;
  2924. foreach ( $roleArrayCopy as $P => $A ) {
  2925. foreach ( $A as $MKI => $AVL ) {
  2926. if (! empty ( $verifyStaff )) {
  2927. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2928. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2929. $button = 4;
  2930. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2931. }
  2932. foreach ( $verifyStaff as $m => $u ) {
  2933. $AVLFK = $AVL [0] . '_R';
  2934. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2935. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2936. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2937. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2938. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2939. break;
  2940. }
  2941. }
  2942. } else {
  2943. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2944. $button = 4;
  2945. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2946. }
  2947. }
  2948. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2949. $KOP = true;
  2950. }
  2951. }
  2952. // print_r($roleArrayCopy);
  2953. // echo $roleKey;
  2954. foreach ( $roleArrayCopy as $k => $v ) {
  2955. foreach ( $verifyList as $m => $n ) {
  2956. if ($n [0] == $k) {
  2957. array_splice ( $verifyList, $m, 1, $v );
  2958. }
  2959. }
  2960. }
  2961. $receiptList [$key] ['verifyList'] = $verifyList;
  2962. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2963. 'where' => 'sid=' . $value ['staff'],
  2964. 'asArray' => true
  2965. ) );
  2966. $receiptList [$key] ['button'] = $button;
  2967. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  2968. }
  2969. // $data['verifyDetail']=$verifyDetail;
  2970. $mothHtml = "";
  2971. for($i = 1; $i <= 12; $i ++) {
  2972. if ($month == $i)
  2973. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2974. else
  2975. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2976. }
  2977. // 获取审批日志
  2978. Doo::loadModel ( 'receiptLog' );
  2979. $receiptLog = new receiptLog ();
  2980. $rlList = array ();
  2981. $rlInfo = $receiptLog->getOne ( array (
  2982. 'where' => 'rid=' . $rid . ' and status=4',
  2983. 'asArray' => true
  2984. ) );
  2985. $tijdate = $receiptLog->getOne ( array (
  2986. 'where' => 'rid=' . $rid . ' and status=2',
  2987. 'asc' => 'rlid',
  2988. 'asArray' => true
  2989. ) );
  2990. if (! empty ( $rlInfo )) {
  2991. $rlList = $receiptLog->find ( array (
  2992. 'where' => 'rid=' . $rid,
  2993. 'asc' => 'rlid',
  2994. 'asArray' => true
  2995. ) );
  2996. }
  2997. $receiptList [0] ['rlList'] = $rlList;
  2998. $enclosurList = $enclosur->find ( array (
  2999. 'where' => 'rid=' . $rid,
  3000. 'asArray' => true
  3001. ) );
  3002. $enclosurHtml = '';
  3003. foreach ( $enclosurList as $value ) {
  3004. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3005. }
  3006. // print_r($receiptList);
  3007. $data ['rid'] = $rid;
  3008. $data ['enclosurHtml'] = $enclosurHtml;
  3009. $data ['rolename'] = $rolename ['name'];
  3010. $data ['datetij'] = $tijdate ['date'];
  3011. $data ['mothHtml'] = $mothHtml;
  3012. $data ['receiptList'] = $receiptList;
  3013. $data ['receiptApprovalCount'] = count ( $receiptList );
  3014. $data ['status'] = $status;
  3015. $data ['year'] = $year;
  3016. $data ['categoryList'] = $categoryList;
  3017. $data ['staffList'] = $staffList;
  3018. $data ['cid'] = $cid;
  3019. $data ['sid'] = $sid;
  3020. $data ['ap'] = $ap;
  3021. $data ['memu'] = "receipt";
  3022. $data ['staff'] = $this->staff;
  3023. $data ['receiptMemu'] = 'approvalExpenses';
  3024. $data ['verifyId'] = $this->verifyId;
  3025. $data ['executeId'] = $this->executeId;
  3026. $this->render ( "/admin/expensesEdi", $data );
  3027. }
  3028. function expensesDefray() {
  3029. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3030. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3031. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3032. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  3033. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  3034. if (! empty ( $rid )) {
  3035. Doo::loadModel ( "verify" );
  3036. $verify = new verify ();
  3037. Doo::loadModel ( "receiptDetail" );
  3038. $receiptDetailObj = new receiptDetail ();
  3039. Doo::loadModel ( "itemStatistics" );
  3040. Doo::loadModel ( "statistics" );
  3041. $statistics = new statistics ();
  3042. $itemStatistics = new itemStatistics ();
  3043. Doo::loadModel ( "receipt" );
  3044. $receipt = new receipt ();
  3045. Doo::loadModel ( "loanReceipt" );
  3046. $loanReceipt = new loanReceipt ();
  3047. $receiptDetail = $receipt->getOne ( array (
  3048. 'where' => 'rid=' . $rid . ' and status=2 ',
  3049. 'asArray' => true
  3050. ) );
  3051. if (empty ( $receiptDetail ))
  3052. return "/approval";
  3053. $verifyDetail = $verify->getOne ( array (
  3054. 'where' => ' vid =' . $receiptDetail ['verify'],
  3055. 'asArray' => true
  3056. ) );
  3057. $verifyString = $verifyDetail ['staff'];
  3058. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3059. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  3060. if (empty ( $opinion )) {
  3061. if ($status == 3)
  3062. $opinion = "终止";
  3063. else
  3064. $opinion = "同意支付";
  3065. }
  3066. $nowStaff = 0;
  3067. $nowStaffList = array ();
  3068. if (empty ( $verifyStaff )) {
  3069. // 还需加入是否已经进入角色审批
  3070. if ($verifyDetail [0] [1] == 'ROLE') {
  3071. // print_r($verifyDetail);echo "ddd";
  3072. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3073. foreach ( $vStaffString as $key => $value ) {
  3074. $staffK = explode ( "_", $value );
  3075. if ($staffK [0] != $this->staff [0] ['sid'])
  3076. array_push ( $nowStaffList, $staffK [0] );
  3077. }
  3078. // print_r($verifyDetail);
  3079. // die;
  3080. if (! empty ( $nowStaffList )) {
  3081. $nowStaff = implode ( ',', $nowStaffList );
  3082. $verifyStaff = array (
  3083. $this->staff [0] ['sid'] . "_R" => array (
  3084. 'date' => date ( 'Y-m-d' ),
  3085. 'opinion' => $opinion,
  3086. 'status' => $status,
  3087. 'nextStaff' => $verifyDetail [0] [0],
  3088. 'ROLE' => 1
  3089. )
  3090. );
  3091. } else {
  3092. $nowStaff = $verifyDetail [1] [0];
  3093. $verifyStaff = array (
  3094. $this->staff [0] ['sid'] . "_R" => array (
  3095. 'date' => date ( 'Y-m-d' ),
  3096. 'opinion' => $opinion,
  3097. 'status' => $status,
  3098. 'nextStaff' => $verifyDetail [1] [0]
  3099. )
  3100. );
  3101. }
  3102. } else {
  3103. if ($verifyDetail [1] [1] == 'ROLE') {
  3104. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  3105. // echo "dd";
  3106. foreach ( $vStaffString as $key => $value ) {
  3107. $staffK = explode ( "_", $value );
  3108. array_push ( $nowStaffList, $staffK [0] );
  3109. }
  3110. $nowStaff = implode ( ',', $nowStaffList );
  3111. $verifyStaff = array (
  3112. $this->staff [0] ['sid'] => array (
  3113. 'date' => date ( 'Y-m-d' ),
  3114. 'opinion' => $opinion,
  3115. 'status' => $status,
  3116. 'nextStaff' => $verifyDetail [1] [0],
  3117. 'ROLE' => 1
  3118. )
  3119. );
  3120. } else {
  3121. $nowStaff = $verifyDetail [1] [0];
  3122. $verifyStaff = array (
  3123. $this->staff [0] ['sid'] => array (
  3124. 'date' => date ( 'Y-m-d' ),
  3125. 'opinion' => $opinion,
  3126. 'status' => $status,
  3127. 'nextStaff' => $verifyDetail [1] [0]
  3128. )
  3129. );
  3130. }
  3131. }
  3132. if ($status == 3)
  3133. $verifyStaff = array (
  3134. 'final' => $status,
  3135. $this->staff [0] ['sid'] => array (
  3136. 'date' => date ( 'Y-m-d' ),
  3137. 'opinion' => $opinion,
  3138. 'status' => $status
  3139. )
  3140. );
  3141. $vStaffString = json_encode ( $verifyStaff );
  3142. $receipt->nowStaff = $nowStaff;
  3143. $receipt->verifyStaff = $vStaffString;
  3144. $loanReceipt->nowStaff = $nowStaff;
  3145. $loanReceipt->verifyStaff = $vStaffString;
  3146. } else {
  3147. $VS = end ( $verifyStaff );
  3148. // 非角色审批
  3149. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  3150. $nextStaff = 0;
  3151. $roleSTF = false;
  3152. foreach ( $verifyDetail as $key => $value ) {
  3153. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  3154. if (isset ( $verifyDetail [$key + 1] )) {
  3155. $nextStaff = $verifyDetail [$key + 1] [0];
  3156. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  3157. $roleSTF = true;
  3158. }
  3159. break;
  3160. }
  3161. }
  3162. if (! $roleSTF) {
  3163. $nowStaff = $nextStaff;
  3164. $verifyStaff [$this->staff [0] ['sid']] = array (
  3165. 'date' => date ( 'Y-m-d' ),
  3166. 'opinion' => $opinion,
  3167. 'status' => $status,
  3168. 'nextStaff' => $nextStaff
  3169. );
  3170. } else {
  3171. // 获取角色下的所有用户ID
  3172. $nowStaffList = array ();
  3173. foreach ( $verifyDetail as $vfk ) {
  3174. if ($vfk [1] == 'ROLE') {
  3175. $vStaffString = json_decode ( $vfk [3] );
  3176. foreach ( $vStaffString as $key => $value ) {
  3177. $staffK = explode ( "_", $value );
  3178. array_push ( $nowStaffList, $staffK [0] );
  3179. }
  3180. }
  3181. }
  3182. $nowStaff = implode ( ',', $nowStaffList );
  3183. $verifyStaff [$this->staff [0] ['sid']] = array (
  3184. 'date' => date ( 'Y-m-d' ),
  3185. 'opinion' => $opinion,
  3186. 'status' => $status,
  3187. 'nextStaff' => $nextStaff,
  3188. 'ROLE' => 0
  3189. );
  3190. }
  3191. if ($status == 3) {
  3192. $verifyStaff ['final'] = $status;
  3193. $verifyStaff [$this->staff [0] ['sid']] = array (
  3194. 'date' => date ( 'Y-m-d' ),
  3195. 'opinion' => $opinion,
  3196. 'status' => $status
  3197. );
  3198. }
  3199. $vStaffString = json_encode ( $verifyStaff );
  3200. $receipt->nowStaff = $nowStaff;
  3201. $receipt->verifyStaff = $vStaffString;
  3202. $loanReceipt->nowStaff = $nowStaff;
  3203. $loanReceipt->verifyStaff = $vStaffString;
  3204. }
  3205. // 角色审批
  3206. if (isset ( $VS ['ROLE'] )) {
  3207. // 找出角色人 当前审批角色组
  3208. $verifyJSStaff = array ();
  3209. $nowStaffList2 = array ();
  3210. foreach ( $verifyDetail as $key => $value ) {
  3211. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  3212. $verifyJSStaff = json_decode ( $value [3] );
  3213. foreach ( $verifyJSStaff as $m ) {
  3214. $staffK = explode ( "_", $m );
  3215. array_push ( $nowStaffList2, $staffK [0] );
  3216. }
  3217. // print_r($nowStaffList2);
  3218. }
  3219. }
  3220. $RoleVerifyStaff = array ();
  3221. foreach ( $verifyStaff as $key => $value ) {
  3222. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  3223. foreach ( $nowStaffList2 as $m ) {
  3224. if ($key == $m . "_R")
  3225. $RoleVerifyStaff [$key] = $value;
  3226. }
  3227. }
  3228. }
  3229. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  3230. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  3231. // 下一个审批人ID
  3232. $nextStaff = 0;
  3233. $falg = false;
  3234. foreach ( $verifyDetail as $key => $value ) {
  3235. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  3236. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  3237. $falg = true;
  3238. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  3239. $nowStaffList = array ();
  3240. foreach ( $vStaffString as $v ) {
  3241. $staffK = explode ( "_", $v );
  3242. array_push ( $nowStaffList, $staffK [0] );
  3243. }
  3244. $nowStaff = implode ( ',', $nowStaffList );
  3245. $nextStaff = $verifyDetail [$key + 1] [0];
  3246. } elseif (isset ( $verifyDetail [$key + 1] )) {
  3247. $nextStaff = $verifyDetail [$key + 1] [0];
  3248. $nowStaff = $nextStaff;
  3249. } else
  3250. $nowStaff = '';
  3251. break;
  3252. }
  3253. }
  3254. if ($falg)
  3255. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3256. 'date' => date ( 'Y-m-d' ),
  3257. 'opinion' => $opinion,
  3258. 'status' => $status,
  3259. 'nextStaff' => $nextStaff,
  3260. 'ROLE' => 1
  3261. );
  3262. else
  3263. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3264. 'date' => date ( 'Y-m-d' ),
  3265. 'opinion' => $opinion,
  3266. 'status' => $status,
  3267. 'nextStaff' => $nextStaff
  3268. );
  3269. // print_r($verifyStaff);
  3270. // echo $nowStaff;die;
  3271. } else { // 进入下一个角色或者审批人
  3272. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  3273. //
  3274. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  3275. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3276. 'date' => date ( 'Y-m-d' ),
  3277. 'opinion' => $opinion,
  3278. 'status' => $status,
  3279. 'nextStaff' => $VS ['nextStaff'],
  3280. 'ROLE' => 1
  3281. );
  3282. // print_r($verifyStaff);
  3283. // die;
  3284. }
  3285. if ($status == 3) {
  3286. $verifyStaff ['final'] = $status;
  3287. $verifyStaff [$this->staff [0] ['sid']] = array (
  3288. 'date' => date ( 'Y-m-d' ),
  3289. 'opinion' => $opinion,
  3290. 'status' => $status
  3291. );
  3292. }
  3293. $vStaffString = json_encode ( $verifyStaff );
  3294. $receipt->verifyStaff = $vStaffString;
  3295. $receipt->nowStaff = $nowStaff;
  3296. $loanReceipt->nowStaff = $nowStaff;
  3297. $loanReceipt->verifyStaff = $vStaffString;
  3298. // die;
  3299. // }
  3300. // print_r($verifyStaff);
  3301. // die;
  3302. }
  3303. // print_r($verifyStaff);die;
  3304. }
  3305. // print_r($verifyDetail);
  3306. $roleKey = 0;
  3307. $roleId = 0;
  3308. $verifyDetailCopy = array ();
  3309. foreach ( $verifyDetail as $k => $v ) {
  3310. if ($v [1] == 'ROLE') {
  3311. $roleId = $v [0];
  3312. $roleVerify = json_decode ( $v [3], true );
  3313. $roleKey = $k;
  3314. $roleArray = array ();
  3315. foreach ( $roleVerify as $o => $p ) {
  3316. $staffID = explode ( '_', $p );
  3317. $exp = array (
  3318. 0 => $staffID [0],
  3319. 1 => $staffID [1]
  3320. );
  3321. array_push ( $roleArray, $exp );
  3322. }
  3323. $verifyDetailCopy [$v [0]] = $roleArray;
  3324. }
  3325. }
  3326. // print_r($verifyDetail);
  3327. foreach ( $verifyDetailCopy as $k => $v ) {
  3328. foreach ( $verifyDetail as $m => $n ) {
  3329. if ($n [0] == $k) {
  3330. array_splice ( $verifyDetail, $m, 1, $v );
  3331. }
  3332. }
  3333. }
  3334. // 审批日志
  3335. if (! isset ( $verifyStaff ['final'] )) {
  3336. Doo::loadModel ( "receiptLog" );
  3337. $receiptLog = new receiptLog ();
  3338. if (! empty ( $roleId )) {
  3339. Doo::loadModel ( "role" );
  3340. $role = new role ();
  3341. $roleInfo = $role->getOne ( array (
  3342. 'where' => 'rid=' . $roleId,
  3343. 'asArray' => true
  3344. ) );
  3345. $receiptLog->rolename = $roleInfo ['name'];
  3346. }
  3347. $receiptLog->username = $this->staff [0] ['username'];
  3348. $receiptLog->uid = $this->staff [0] ['sid'];
  3349. $receiptLog->date = date ( "Y-m-d" );
  3350. $receiptLog->opinion = $opinion;
  3351. $receiptLog->img = $this->staff [0] ['avatar'];
  3352. $receiptLog->status = 1;
  3353. $receiptLog->rid = $rid;
  3354. $receiptLog->insert ();
  3355. }
  3356. if (isset ( $verifyStaff ['final'] )) { // rDetail
  3357. $receipt->status = 3;
  3358. $receipt->verifyBreakup = $verifyString;
  3359. $receiptDetailObj->status = 3;
  3360. $receiptDetailObj->update ( array (
  3361. 'where' => 'rid=' . $rid
  3362. ) );
  3363. // 微信企业号通知
  3364. $this->setWXMsg ( $rid, 3 );
  3365. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  3366. $receipt->status = 6;
  3367. $receipt->pastDate = date ( "Y-m-d" );
  3368. $receipt->isBK = 1;
  3369. $loanReceipt->verifyBreakup = $verifyString;
  3370. $loanReceipt->status = 1;
  3371. $loanReceipt->pastDate = date ( "Y-m-d" );
  3372. $loanReceipt->update ( array (
  3373. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  3374. ) );
  3375. // 微信企业号通知
  3376. $this->setWXMsg ( $rid, 1 );
  3377. }
  3378. $receipt->amount = $amount;
  3379. $receipt->update ( array (
  3380. 'where' => ' rid = ' . $rid
  3381. ) );
  3382. return "/approvalExpenses/2";
  3383. }
  3384. }
  3385. function ajaxExamineExe() {
  3386. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3387. Doo::loadModel ( 'receipt' );
  3388. $receipt = new receipt ();
  3389. Doo::loadClass ( 'XDeode' );
  3390. $XDeode = new XDeode ( 5 );
  3391. if (! empty ( $rid )) {
  3392. $rLRes = $receipt->find ( array (
  3393. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  3394. 'asArray' => true
  3395. ) );
  3396. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  3397. echo json_encode ( array (
  3398. 'status' => 1,
  3399. 'receipt' => $rLRes [0]
  3400. ) );
  3401. die ();
  3402. }
  3403. echo json_encode ( array (
  3404. 'status' => 0,
  3405. 'receipt' => array ()
  3406. ) );
  3407. die ();
  3408. }
  3409. function implement() {
  3410. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3411. Doo::loadClass ( 'XDeode' );
  3412. $XDeode = new XDeode ( 5 );
  3413. Doo::loadModel ( 'receipt' );
  3414. $receipt = new receipt ();
  3415. Doo::loadModel ( 'L_category' );
  3416. $Lcategory = new L_category ();
  3417. Doo::loadModel ( 'verify' );
  3418. $verify = new verify ();
  3419. Doo::loadModel ( 'staff' );
  3420. $staff = new staff ();
  3421. Doo::loadModel ( "execute" );
  3422. $execute = new execute ();
  3423. $rid = $XDeode->decode ( $rid );
  3424. $receiptList = $receipt->find ( array (
  3425. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  3426. 'desc' => 'rid',
  3427. 'asArray' => true
  3428. ) );
  3429. Doo::loadModel ( 'loanReceipt' );
  3430. $loanReceipt = new loanReceipt ();
  3431. // print_r($receiptList);
  3432. $loanList = array ();
  3433. if (! isset ( $receiptList ))
  3434. $loanList = $loanReceipt->find ( array (
  3435. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3436. 'desc' => 'rid',
  3437. 'asArray' => true
  3438. ) );
  3439. $Locate = 0;
  3440. $roleId = 0;
  3441. $button = 0;
  3442. foreach ( $loanList as $key => $value ) {
  3443. $loanList [$key] ['Locate'] = $Locate;
  3444. $Locate ++;
  3445. $loanList [$key] ['reviseDetail'] = array ();
  3446. if (! empty ( $value ['reviseDetail'] ))
  3447. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3448. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3449. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3450. $categoryDetil = $Lcategory->getOne ( array (
  3451. 'where' => 'cid=' . $value ['cid'],
  3452. 'asArray' => true
  3453. ) );
  3454. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3455. // 检测编辑状态
  3456. $verifyList = $verify->getOne ( array (
  3457. 'where' => 'vid=' . $value ['verify'],
  3458. 'asArray' => true
  3459. ) );
  3460. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3461. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3462. Doo::loadModel ( 'role' );
  3463. $role = new role ();
  3464. $flag = true;
  3465. $roleKey = 0;
  3466. $endStaffArray = array ();
  3467. $roleArrayCopy = array ();
  3468. foreach ( $verifyList as $k => $v ) {
  3469. // init verifyStaff
  3470. if ($v [1] == 'ROLE') {
  3471. if (! empty ( $verifyStaff )) {
  3472. $endStaffArray = end ( $verifyStaff );
  3473. // if ($v[0]==$endStaffArray['nextStaff']){
  3474. // $roleId=$v[0];
  3475. // }
  3476. }
  3477. $roleVerify = json_decode ( $v [3], true );
  3478. $roleKey = $k;
  3479. $roleArray = array ();
  3480. $rolename = $role->getOne ( array (
  3481. 'where' => 'rid=' . $v [0],
  3482. 'asArray' => true
  3483. ) );
  3484. foreach ( $roleVerify as $o => $p ) {
  3485. $staffID = explode ( '_', $p );
  3486. $staffInfo = $staff->getOne ( array (
  3487. 'where' => 'sid=' . $staffID [0],
  3488. 'asArray' => true
  3489. ) );
  3490. // print_r($staffID);
  3491. $exp = array (
  3492. 0 => $staffInfo ['sid'],
  3493. 1 => $staffID [1],
  3494. 2 => $staffInfo ['avatar'],
  3495. 'date' => '',
  3496. 'date' => '',
  3497. 'opinion' => '',
  3498. 'status' => '',
  3499. 'rolename' => $rolename ['name']
  3500. );
  3501. array_push ( $roleArray, $exp );
  3502. }
  3503. $roleArrayCopy [$v [0]] = $roleArray;
  3504. // $verifyList[$k]['roleArray']=$roleArray;
  3505. }
  3506. $verifyList [$k] ['date'] = "";
  3507. $verifyList [$k] ['opinion'] = "";
  3508. $verifyList [$k] ['status'] = "";
  3509. if (empty ( $verifyStaff )) {
  3510. $verifyList [$k] ['date'] = "";
  3511. $verifyList [$k] ['opinion'] = "";
  3512. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3513. $verifyList [$k] ['status'] = 4;
  3514. $flag = false;
  3515. }
  3516. } else {
  3517. foreach ( $verifyStaff as $m => $u ) {
  3518. if ($v [0] == $m) {
  3519. $verifyList [$k] ['date'] = $u ['date'];
  3520. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3521. $verifyList [$k] ['status'] = $u ['status'];
  3522. $flag = false;
  3523. break;
  3524. }
  3525. }
  3526. $endStaffArray = end ( $verifyStaff );
  3527. if (isset ( $endStaffArray ['ROLE'] )) {
  3528. } else {
  3529. // $endKey=key($verifyStaff);
  3530. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3531. // $button=4;
  3532. // $verifyList[$k]['status']=4;
  3533. // }
  3534. }
  3535. }
  3536. }
  3537. $rolename ['name'] = '';
  3538. if (! empty ( $roleId )) {
  3539. Doo::loadModel ( 'role' );
  3540. $role = new role ();
  3541. $rolename = $role->getOne ( array (
  3542. 'where' => 'rid=' . $roleId,
  3543. 'asArray' => true
  3544. ) );
  3545. }
  3546. if (! empty ( $verifyStaff ))
  3547. $endStaffArray = end ( $verifyStaff );
  3548. $KOP = false;
  3549. foreach ( $roleArrayCopy as $P => $A ) {
  3550. foreach ( $A as $MKI => $AVL ) {
  3551. if (! empty ( $verifyStaff )) {
  3552. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3553. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3554. $button = 4;
  3555. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3556. }
  3557. foreach ( $verifyStaff as $m => $u ) {
  3558. $AVLFK = $AVL [0] . '_R';
  3559. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3560. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3561. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3562. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3563. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3564. break;
  3565. }
  3566. }
  3567. } else {
  3568. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3569. $button = 4;
  3570. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3571. }
  3572. }
  3573. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3574. $KOP = true;
  3575. }
  3576. }
  3577. foreach ( $roleArrayCopy as $k => $v ) {
  3578. foreach ( $verifyList as $m => $n ) {
  3579. if ($n [0] == $k) {
  3580. array_splice ( $verifyList, $m, 1, $v );
  3581. }
  3582. }
  3583. }
  3584. $loanList [$key] ['verifyList'] = $verifyList;
  3585. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3586. 'where' => 'sid=' . $value ['staff'],
  3587. 'asArray' => true
  3588. ) );
  3589. }
  3590. $data ['loanList'] = $loanList;
  3591. $Locate = 0;
  3592. $roleId = 0;
  3593. $button = 0;
  3594. foreach ( $receiptList as $key => $value ) {
  3595. $button2 = 0;
  3596. $receiptList [$key] ['Locate'] = $Locate;
  3597. $Locate ++;
  3598. $receiptList [$key] ['reviseDetail'] = array ();
  3599. if (! empty ( $value ['reviseDetail'] ))
  3600. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3601. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3602. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3603. $categoryDetil = $Lcategory->getOne ( array (
  3604. 'where' => 'cid=' . $value ['cid'],
  3605. 'asArray' => true
  3606. ) );
  3607. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3608. $executeList = json_decode ( $value ['executeCopy'], true );
  3609. $executeStaff = array ();
  3610. if (! empty ( $value ['executeStaff'] ))
  3611. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3612. if (isset ( $executeList )) {
  3613. foreach ( $executeList as $op => $lo ) {
  3614. $executeList [$op] ['date'] = "";
  3615. $executeList [$op] ['opinion'] = "";
  3616. $executeList [$op] ['status'] = "";
  3617. foreach ( $executeStaff as $m => $u ) {
  3618. if ($lo [0] == $m) {
  3619. $executeList [$op] ['date'] = $u ['date'];
  3620. $executeList [$op] ['opinion'] = $u ['opinion'];
  3621. $executeList [$op] ['status'] = $u ['status'];
  3622. break;
  3623. }
  3624. }
  3625. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  3626. $button2 = 1;
  3627. $executeList [$op] ['status'] = 4;
  3628. }
  3629. }
  3630. }
  3631. // 检测编辑状态
  3632. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3633. $verifyList ['staff'] = $value ['verifyBreakup'];
  3634. } else
  3635. $verifyList = $verify->getOne ( array (
  3636. 'where' => 'vid=' . $value ['verify'],
  3637. 'asArray' => true
  3638. ) );
  3639. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3640. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3641. Doo::loadModel ( 'role' );
  3642. $role = new role ();
  3643. if ($verifyList == NULL)
  3644. $verifyList = array ();
  3645. $flag = true;
  3646. $roleKey = 0;
  3647. $endStaffArray = array ();
  3648. $roleArrayCopy = array ();
  3649. foreach ( $verifyList as $k => $v ) {
  3650. // init verifyStaff
  3651. if ($v [1] == 'ROLE') {
  3652. if (! empty ( $verifyStaff )) {
  3653. $endStaffArray = end ( $verifyStaff );
  3654. // if ($v[0]==$endStaffArray['nextStaff']){
  3655. // $roleId=$v[0];
  3656. // }
  3657. }
  3658. $roleVerify = json_decode ( $v [3], true );
  3659. $roleKey = $k;
  3660. $roleArray = array ();
  3661. $rolename = $role->getOne ( array (
  3662. 'where' => 'rid=' . $v [0],
  3663. 'asArray' => true
  3664. ) );
  3665. foreach ( $roleVerify as $o => $p ) {
  3666. $staffID = explode ( '_', $p );
  3667. $staffInfo = $staff->getOne ( array (
  3668. 'where' => 'sid=' . $staffID [0],
  3669. 'asArray' => true
  3670. ) );
  3671. // print_r($staffID);
  3672. $exp = array (
  3673. 0 => $staffInfo ['sid'],
  3674. 1 => $staffID [1],
  3675. 2 => $staffInfo ['avatar'],
  3676. 'date' => '',
  3677. 'date' => '',
  3678. 'opinion' => '',
  3679. 'status' => '',
  3680. 'rolename' => $rolename ['name']
  3681. );
  3682. array_push ( $roleArray, $exp );
  3683. }
  3684. $roleArrayCopy [$v [0]] = $roleArray;
  3685. // $verifyList[$k]['roleArray']=$roleArray;
  3686. }
  3687. $verifyList [$k] ['date'] = "";
  3688. $verifyList [$k] ['opinion'] = "";
  3689. $verifyList [$k] ['status'] = "";
  3690. if (empty ( $verifyStaff )) {
  3691. $verifyList [$k] ['date'] = "";
  3692. $verifyList [$k] ['opinion'] = "";
  3693. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3694. $verifyList [$k] ['status'] = 4;
  3695. $flag = false;
  3696. }
  3697. } else {
  3698. foreach ( $verifyStaff as $m => $u ) {
  3699. if ($v [0] == $m) {
  3700. $verifyList [$k] ['date'] = $u ['date'];
  3701. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3702. $verifyList [$k] ['status'] = $u ['status'];
  3703. $flag = false;
  3704. break;
  3705. }
  3706. }
  3707. $endStaffArray = end ( $verifyStaff );
  3708. if (isset ( $endStaffArray ['ROLE'] )) {
  3709. } else {
  3710. // $endKey=key($verifyStaff);
  3711. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3712. // $button=4;
  3713. // $verifyList[$k]['status']=4;
  3714. // }
  3715. }
  3716. }
  3717. }
  3718. $rolename ['name'] = '';
  3719. if (! empty ( $roleId )) {
  3720. Doo::loadModel ( 'role' );
  3721. $role = new role ();
  3722. $rolename = $role->getOne ( array (
  3723. 'where' => 'rid=' . $roleId,
  3724. 'asArray' => true
  3725. ) );
  3726. }
  3727. if (! empty ( $verifyStaff ))
  3728. $endStaffArray = end ( $verifyStaff );
  3729. $KOP = false;
  3730. foreach ( $roleArrayCopy as $P => $A ) {
  3731. foreach ( $A as $MKI => $AVL ) {
  3732. if (! empty ( $verifyStaff )) {
  3733. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3734. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3735. $button = 4;
  3736. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3737. }
  3738. foreach ( $verifyStaff as $m => $u ) {
  3739. $AVLFK = $AVL [0] . '_R';
  3740. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3741. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3742. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3743. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3744. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3745. break;
  3746. }
  3747. }
  3748. } else {
  3749. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3750. $button = 4;
  3751. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3752. }
  3753. }
  3754. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3755. $KOP = true;
  3756. }
  3757. }
  3758. foreach ( $roleArrayCopy as $k => $v ) {
  3759. foreach ( $verifyList as $m => $n ) {
  3760. if ($n [0] == $k) {
  3761. array_splice ( $verifyList, $m, 1, $v );
  3762. }
  3763. }
  3764. }
  3765. $receiptList [$key] ['verifyList'] = $verifyList;
  3766. $receiptList [$key] ['executeList'] = $executeList;
  3767. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3768. 'where' => 'sid=' . $value ['staff'],
  3769. 'asArray' => true
  3770. ) );
  3771. $receiptList [$key] ['button2'] = $button2;
  3772. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3773. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3774. $relust = $value ['sum'] - $value ['loanSum'];
  3775. $receiptList [$key] ['relust'] = $relust;
  3776. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  3777. }
  3778. // print_r($receiptList[$key]['executeList']);
  3779. $data ['receiptList'] = $receiptList;
  3780. $data ['memu'] = "receipt";
  3781. $data ['staff'] = $this->staff;
  3782. $data ['receiptMemu'] = 'implement';
  3783. $data ['verifyId'] = $this->verifyId;
  3784. $data ['executeId'] = $this->executeId;
  3785. $this->render ( "/admin/implement", $data );
  3786. }
  3787. function implementDo() {
  3788. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3789. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3790. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  3791. if (! empty ( $rid ) && $amount!='') {
  3792. Doo::loadModel ( 'receipt' );
  3793. $receipt = new receipt ();
  3794. Doo::loadClass ( 'XDeode' );
  3795. $XDeode = new XDeode ( 5 );
  3796. $rinfo = $receipt->getOne ( array (
  3797. 'where' => 'rid=' . $rid,
  3798. 'asArray' => true
  3799. ) );
  3800. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  3801. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  3802. if (empty ( $executeStaff )) {
  3803. $executeStaff = array (
  3804. $this->staff [0] ['sid'] => array (
  3805. 'date' => date ( 'Y-m-d' ),
  3806. 'opinion' => $implementOpinions,
  3807. 'status' => 1
  3808. )
  3809. );
  3810. } else {
  3811. $executeStaff [$this->staff [0] ['sid']] = array (
  3812. 'date' => date ( 'Y-m-d' ),
  3813. 'opinion' => $implementOpinions,
  3814. 'status' => 1
  3815. );
  3816. }
  3817. if (count ( $executeStaff ) == count ( $executeCopy )) {
  3818. $receipt->executeStaff = json_encode ( $executeStaff );
  3819. $receipt->status = 8;
  3820. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  3821. $receipt->status = 9;
  3822. $receipt->executeDate = date ( "Y-m-d" );
  3823. } else {
  3824. $receipt->executeStaff = json_encode ( $executeStaff );
  3825. }
  3826. $receipt->amount = $amount;
  3827. $receipt->update ( array (
  3828. 'where' => 'rid=' . $rid
  3829. ) );
  3830. }
  3831. $ridKey = $XDeode->encode ( $rid );
  3832. return "/implement/" . $ridKey . ".html";
  3833. }
  3834. function receiptburEdi() {
  3835. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3836. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  3837. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  3838. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  3839. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3840. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  3841. if (empty ( $status ))
  3842. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  3843. $vidList = array ();
  3844. $button = 0;
  3845. Doo::loadModel ( 'verify' );
  3846. Doo::loadModel ( 'receipt' );
  3847. Doo::loadModel ( 'staff' );
  3848. $staff = new staff ();
  3849. $receipt = new receipt ();
  3850. $verify = new verify ();
  3851. Doo::loadModel ( 'L_category' );
  3852. $Lcategory = new L_category ();
  3853. Doo::loadModel ( 'enclosur' );
  3854. $enclosur = new enclosur ();
  3855. Doo::loadModel ( 'loanReceipt' );
  3856. $loanReceipt = new loanReceipt ();
  3857. // user verify ID
  3858. $verifyDetail = $verify->find ( array (
  3859. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  3860. 'asArray' => true
  3861. ) );
  3862. foreach ( $verifyDetail as $key => $value ) {
  3863. array_push ( $vidList, $value ['vid'] );
  3864. }
  3865. $vid = implode ( ",", $vidList );
  3866. if (empty ( $verifyDetail ))
  3867. $vid = 0;
  3868. $categoryList = $Lcategory->find ( array (
  3869. 'asArray' => true
  3870. ) );
  3871. $staffList = $staff->find ( array (
  3872. 'where' => 'cid=' . $cid,
  3873. 'asArray' => true
  3874. ) );
  3875. $ap = "";
  3876. if ($status == 4) {
  3877. $ap = 4;
  3878. $status = 2;
  3879. }
  3880. // get Receipt By verifyID status 2
  3881. $receiptList = $receipt->find ( array (
  3882. 'where' => 'rid =' . $rid,
  3883. 'desc' => 'rid',
  3884. 'asArray' => true
  3885. ) );
  3886. $loanList = $loanReceipt->find ( array (
  3887. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3888. 'desc' => 'rid',
  3889. 'asArray' => true
  3890. ) );
  3891. $Locate = 0;
  3892. $roleId = 0;
  3893. $button = 0;
  3894. foreach ( $loanList as $key => $value ) {
  3895. $loanList [$key] ['Locate'] = $Locate;
  3896. $Locate ++;
  3897. $loanList [$key] ['reviseDetail'] = array ();
  3898. if (! empty ( $value ['reviseDetail'] ))
  3899. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3900. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3901. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3902. $categoryDetil = $Lcategory->getOne ( array (
  3903. 'where' => 'cid=' . $value ['cid'],
  3904. 'asArray' => true
  3905. ) );
  3906. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3907. // 检测编辑状态
  3908. $verifyList = $verify->getOne ( array (
  3909. 'where' => 'vid=' . $value ['verify'],
  3910. 'asArray' => true
  3911. ) );
  3912. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3913. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3914. Doo::loadModel ( 'role' );
  3915. $role = new role ();
  3916. $flag = true;
  3917. $roleKey = 0;
  3918. $endStaffArray = array ();
  3919. $roleArrayCopy = array ();
  3920. foreach ( $verifyList as $k => $v ) {
  3921. // init verifyStaff
  3922. if ($v [1] == 'ROLE') {
  3923. if (! empty ( $verifyStaff )) {
  3924. $endStaffArray = end ( $verifyStaff );
  3925. }
  3926. $roleVerify = json_decode ( $v [3], true );
  3927. $roleKey = $k;
  3928. $roleArray = array ();
  3929. $rolename = $role->getOne ( array (
  3930. 'where' => 'rid=' . $v [0],
  3931. 'asArray' => true
  3932. ) );
  3933. foreach ( $roleVerify as $o => $p ) {
  3934. $staffID = explode ( '_', $p );
  3935. $staffInfo = $staff->getOne ( array (
  3936. 'where' => 'sid=' . $staffID [0],
  3937. 'asArray' => true
  3938. ) );
  3939. // print_r($staffID);
  3940. $exp = array (
  3941. 0 => $staffInfo ['sid'],
  3942. 1 => $staffID [1],
  3943. 2 => $staffInfo ['avatar'],
  3944. 'date' => '',
  3945. 'date' => '',
  3946. 'opinion' => '',
  3947. 'status' => '',
  3948. 'rolename' => $rolename ['name']
  3949. );
  3950. array_push ( $roleArray, $exp );
  3951. }
  3952. $roleArrayCopy [$v [0]] = $roleArray;
  3953. // $verifyList[$k]['roleArray']=$roleArray;
  3954. }
  3955. $verifyList [$k] ['date'] = "";
  3956. $verifyList [$k] ['opinion'] = "";
  3957. $verifyList [$k] ['status'] = "";
  3958. if (empty ( $verifyStaff )) {
  3959. $verifyList [$k] ['date'] = "";
  3960. $verifyList [$k] ['opinion'] = "";
  3961. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3962. $verifyList [$k] ['status'] = 4;
  3963. $flag = false;
  3964. }
  3965. } else {
  3966. foreach ( $verifyStaff as $m => $u ) {
  3967. if ($v [0] == $m) {
  3968. $verifyList [$k] ['date'] = $u ['date'];
  3969. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3970. $verifyList [$k] ['status'] = $u ['status'];
  3971. $flag = false;
  3972. break;
  3973. }
  3974. }
  3975. $endStaffArray = end ( $verifyStaff );
  3976. if (isset ( $endStaffArray ['ROLE'] )) {
  3977. } else {
  3978. }
  3979. }
  3980. }
  3981. $rolename ['name'] = '';
  3982. if (! empty ( $roleId )) {
  3983. Doo::loadModel ( 'role' );
  3984. $role = new role ();
  3985. $rolename = $role->getOne ( array (
  3986. 'where' => 'rid=' . $roleId,
  3987. 'asArray' => true
  3988. ) );
  3989. }
  3990. if (! empty ( $verifyStaff ))
  3991. $endStaffArray = end ( $verifyStaff );
  3992. $KOP = false;
  3993. foreach ( $roleArrayCopy as $P => $A ) {
  3994. foreach ( $A as $MKI => $AVL ) {
  3995. if (! empty ( $verifyStaff )) {
  3996. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3997. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3998. $button = 4;
  3999. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4000. }
  4001. foreach ( $verifyStaff as $m => $u ) {
  4002. $AVLFK = $AVL [0] . '_R';
  4003. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4004. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4005. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4006. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4007. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4008. break;
  4009. }
  4010. }
  4011. } else {
  4012. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4013. $button = 4;
  4014. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4015. }
  4016. }
  4017. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4018. $KOP = true;
  4019. }
  4020. }
  4021. foreach ( $roleArrayCopy as $k => $v ) {
  4022. foreach ( $verifyList as $m => $n ) {
  4023. if ($n [0] == $k) {
  4024. array_splice ( $verifyList, $m, 1, $v );
  4025. }
  4026. }
  4027. }
  4028. $loanList [$key] ['verifyList'] = $verifyList;
  4029. }
  4030. $htmlLoan = '';
  4031. if (isset ( $loanList [0] )) {
  4032. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  4033. if ($value ['status'] == 1)
  4034. $htmlLoan .= '<li class="done" >';
  4035. elseif ($value ['status'] == 3)
  4036. $htmlLoan .= '<li class="undone" >';
  4037. $htmlLoan .= '<div class="avtra"><img src="' . $value [2] . '_2.jpg"></div>';
  4038. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  4039. if (isset ( $value ['rolename'] ))
  4040. $htmlLoan .= $value ['rolename'];
  4041. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  4042. }
  4043. $data ['loanDate'] = $loanList [0] ['date'];
  4044. }
  4045. $data ['htmlLoan'] = $htmlLoan;
  4046. // print_r($loanList);
  4047. $Locate = 0;
  4048. $roleId = 0;
  4049. $button = 0;
  4050. if ($ap == 4)
  4051. $status = 4;
  4052. foreach ( $receiptList as $key => $value ) {
  4053. $receiptList [$key] ['Locate'] = $Locate;
  4054. $Locate ++;
  4055. $receiptList [$key] ['reviseDetail'] = array ();
  4056. if (! empty ( $value ['reviseDetail'] ))
  4057. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4058. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4059. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4060. $categoryDetil = $Lcategory->getOne ( array (
  4061. 'where' => 'cid=' . $value ['cid'],
  4062. 'asArray' => true
  4063. ) );
  4064. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4065. // 检测编辑状态
  4066. $verifyList = $verify->getOne ( array (
  4067. 'where' => 'vid=' . $value ['verify'],
  4068. 'asArray' => true
  4069. ) );
  4070. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4071. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4072. Doo::loadModel ( 'role' );
  4073. $role = new role ();
  4074. // print_r($verifyList);
  4075. $flag = true;
  4076. $roleKey = 0;
  4077. $endStaffArray = array ();
  4078. $roleArrayCopy = array ();
  4079. foreach ( $verifyList as $k => $v ) {
  4080. // init verifyStaff
  4081. if ($v [1] == 'ROLE') {
  4082. if (! empty ( $verifyStaff )) {
  4083. $endStaffArray = end ( $verifyStaff );
  4084. if ($v [0] == $endStaffArray ['nextStaff']) {
  4085. $roleId = $v [0];
  4086. }
  4087. }
  4088. $roleVerify = json_decode ( $v [3], true );
  4089. $roleKey = $k;
  4090. $roleArray = array ();
  4091. $rolename = $role->getOne ( array (
  4092. 'where' => 'rid=' . $v [0],
  4093. 'asArray' => true
  4094. ) );
  4095. foreach ( $roleVerify as $o => $p ) {
  4096. $staffID = explode ( '_', $p );
  4097. $staffInfo = $staff->getOne ( array (
  4098. 'where' => 'sid=' . $staffID [0],
  4099. 'asArray' => true
  4100. ) );
  4101. // print_r($staffID);
  4102. $exp = array (
  4103. 0 => $staffInfo ['sid'],
  4104. 1 => $staffID [1],
  4105. 2 => $staffInfo ['avatar'],
  4106. 'date' => '',
  4107. 'date' => '',
  4108. 'opinion' => '',
  4109. 'status' => '',
  4110. 'rolename' => $rolename ['name']
  4111. );
  4112. array_push ( $roleArray, $exp );
  4113. }
  4114. $roleArrayCopy [$v [0]] = $roleArray;
  4115. // $verifyList[$k]['roleArray']=$roleArray;
  4116. }
  4117. // print_r($roleArray);
  4118. $verifyList [$k] ['date'] = "";
  4119. $verifyList [$k] ['opinion'] = "";
  4120. $verifyList [$k] ['status'] = "";
  4121. if (empty ( $verifyStaff )) {
  4122. $verifyList [$k] ['date'] = "";
  4123. $verifyList [$k] ['opinion'] = "";
  4124. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4125. $verifyList [$k] ['status'] = 4;
  4126. $button = 4;
  4127. $flag = false;
  4128. }
  4129. } else {
  4130. foreach ( $verifyStaff as $m => $u ) {
  4131. if ($v [0] == $m) {
  4132. $verifyList [$k] ['date'] = $u ['date'];
  4133. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4134. $verifyList [$k] ['status'] = $u ['status'];
  4135. $flag = false;
  4136. break;
  4137. }
  4138. }
  4139. $endStaffArray = end ( $verifyStaff );
  4140. if (isset ( $endStaffArray ['ROLE'] )) {
  4141. } else {
  4142. $endKey = key ( $verifyStaff );
  4143. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4144. $button = 4;
  4145. $verifyList [$k] ['status'] = 4;
  4146. }
  4147. }
  4148. }
  4149. }
  4150. $rolename ['name'] = '';
  4151. if (! empty ( $roleId )) {
  4152. Doo::loadModel ( 'role' );
  4153. $role = new role ();
  4154. $rolename = $role->getOne ( array (
  4155. 'where' => 'rid=' . $roleId,
  4156. 'asArray' => true
  4157. ) );
  4158. }
  4159. if (! empty ( $verifyStaff ))
  4160. $endStaffArray = end ( $verifyStaff );
  4161. $KOP = false;
  4162. foreach ( $roleArrayCopy as $P => $A ) {
  4163. foreach ( $A as $MKI => $AVL ) {
  4164. if (! empty ( $verifyStaff )) {
  4165. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4166. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4167. $button = 4;
  4168. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4169. }
  4170. foreach ( $verifyStaff as $m => $u ) {
  4171. $AVLFK = $AVL [0] . '_R';
  4172. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4173. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4174. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4175. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4176. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4177. break;
  4178. }
  4179. }
  4180. } else {
  4181. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4182. $button = 4;
  4183. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4184. }
  4185. }
  4186. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4187. $KOP = true;
  4188. }
  4189. }
  4190. foreach ( $roleArrayCopy as $k => $v ) {
  4191. foreach ( $verifyList as $m => $n ) {
  4192. if ($n [0] == $k) {
  4193. array_splice ( $verifyList, $m, 1, $v );
  4194. }
  4195. }
  4196. }
  4197. // print_r($verifyList);
  4198. $receiptList [$key] ['verifyList'] = $verifyList;
  4199. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4200. 'where' => 'sid=' . $value ['staff'],
  4201. 'asArray' => true
  4202. ) );
  4203. $receiptList [$key] ['button'] = $button;
  4204. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4205. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4206. $relust = $value ['sum'] - $value ['loanSum'];
  4207. $receiptList [$key] ['relust'] = $relust;
  4208. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs($relust) );
  4209. }
  4210. // print_r($receiptList);die;
  4211. // $data['verifyDetail']=$verifyDetail;
  4212. $mothHtml = "";
  4213. for($i = 1; $i <= 12; $i ++) {
  4214. if ($month == $i)
  4215. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4216. else
  4217. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4218. }
  4219. // 获取审批日志
  4220. Doo::loadModel ( 'receiptLog' );
  4221. $receiptLog = new receiptLog ();
  4222. $rlList = array ();
  4223. $rlInfo = $receiptLog->getOne ( array (
  4224. 'where' => 'rid=' . $rid . ' and status=4',
  4225. 'asArray' => true
  4226. ) );
  4227. $tijdate = $receiptLog->getOne ( array (
  4228. 'where' => 'rid=' . $rid . ' and status=2',
  4229. 'asc' => 'rlid',
  4230. 'asArray' => true
  4231. ) );
  4232. if (! empty ( $rlInfo )) {
  4233. $rlList = $receiptLog->find ( array (
  4234. 'where' => 'rid=' . $rid,
  4235. 'asc' => 'rlid',
  4236. 'asArray' => true
  4237. ) );
  4238. }
  4239. // echo $rid;
  4240. // print_r($receiptList);
  4241. $receiptList [0] ['rlList'] = $rlList;
  4242. $enclosurList = $enclosur->find ( array (
  4243. 'where' => 'rid=' . $rid,
  4244. 'asArray' => true
  4245. ) );
  4246. $enclosurHtml = '';
  4247. foreach ( $enclosurList as $value ) {
  4248. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4249. }
  4250. $data ['enclosurHtml'] = $enclosurHtml;
  4251. $data ['rolename'] = $rolename ['name'];
  4252. // $data['datetij']=$tijdate['date'];
  4253. $data ['mothHtml'] = $mothHtml;
  4254. // print_r($receiptList);
  4255. $data ['rid'] = $rid;
  4256. $data ['tijdate'] = $tijdate ['date'];
  4257. $data ['receiptList'] = $receiptList;
  4258. $data ['receiptApprovalCount'] = count ( $receiptList );
  4259. $data ['status'] = $status;
  4260. $data ['year'] = $year;
  4261. $data ['categoryList'] = $categoryList;
  4262. $data ['staffList'] = $staffList;
  4263. $data ['cid'] = $cid;
  4264. $data ['sid'] = $sid;
  4265. $data ['ap'] = $ap;
  4266. $data ['memu'] = "receipt";
  4267. $data ['staff'] = $this->staff;
  4268. $data ['receiptMemu'] = 'approvalExpenses';
  4269. $data ['verifyId'] = $this->verifyId;
  4270. $data ['executeId'] = $this->executeId;
  4271. $this->render ( "/admin/receiptburEdi", $data );
  4272. }
  4273. function hisImplement() {
  4274. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4275. if (empty ( $item ))
  4276. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4277. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4278. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  4279. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  4280. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  4281. Doo::loadModel ( 'receipt' );
  4282. $receipt = new receipt ();
  4283. Doo::loadModel ( 'L_category' );
  4284. $Lcategory = new L_category ();
  4285. Doo::loadModel ( 'verify' );
  4286. Doo::loadModel ( 'statistics' );
  4287. $statistics = new statistics ();
  4288. $verify = new verify ();
  4289. Doo::loadModel ( 'staff' );
  4290. $staff = new staff ();
  4291. Doo::loadClass ( 'XDeode' );
  4292. $XDeode = new XDeode ( 5 );
  4293. $condition = "";
  4294. if ($item == "expenses")
  4295. $condition = " and Rtype=1 ";
  4296. elseif ($item == "receipts")
  4297. $condition = " and Rtype=0 ";
  4298. elseif ($item == "remits")
  4299. $condition = " and Rtype=2 ";
  4300. $sopString = "";
  4301. $dateCondition = " and Year(date) =" . $year;
  4302. if ($sop != 'SOP')
  4303. $sopString = " and staff=" . $sop;
  4304. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  4305. if ($item == 'teipts') {
  4306. $statusCon = '(status=1 or status=6 )';
  4307. $dateCondition = " and Year(pastDate) =" . $year;
  4308. if ($moth != 'MONTH')
  4309. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth;
  4310. if ($day != 'DAY')
  4311. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth . " and day(pastDate)=" . $day;
  4312. } elseif ($item == 'alerpts') {
  4313. $statusCon = '(status=8 or status=9 )';
  4314. $dateCondition = " and Year(executeDate) =" . $year;
  4315. if ($moth != 'MONTH')
  4316. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  4317. if ($day != 'DAY')
  4318. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  4319. }
  4320. // $noPassSum=$receipt->receiptByYear($year,$this->staff[0]['sid']); and (status=1 or status=6)
  4321. $receiptList = $receipt->find ( array (
  4322. 'where' => $statusCon . $condition . $dateCondition . $sopString,
  4323. 'desc' => 'rid',
  4324. 'asArray' => true
  4325. ) );
  4326. // 员工筛选
  4327. $receiptList2 = $receipt->find ( array (
  4328. 'where' => $statusCon . $condition . $dateCondition,
  4329. 'desc' => 'rid',
  4330. 'asArray' => true
  4331. ) );
  4332. $sopStaff = array ();
  4333. foreach ( $receiptList2 as $key => $value ) {
  4334. $staffDetail = $staff->getOne ( array (
  4335. 'where' => 'sid=' . $value ['staff'],
  4336. 'asArray' => true
  4337. ) );
  4338. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  4339. }
  4340. $Locate = 0;
  4341. $roleId = 0;
  4342. $button = 0;
  4343. foreach ( $receiptList as $key => $value ) {
  4344. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4345. $receiptList [$key] ['Texe'] = 'false';
  4346. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  4347. $receiptList [$key] ['Texe'] = 'true';
  4348. }
  4349. $receiptList [$key] ['TRexe'] = 'true';
  4350. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  4351. $receiptList [$key] ['TRexe'] = 'false';
  4352. }
  4353. $receiptList [$key] ['Locate'] = $Locate;
  4354. $Locate ++;
  4355. $receiptList [$key] ['reviseDetail'] = array ();
  4356. if (! empty ( $value ['reviseDetail'] ))
  4357. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4358. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4359. $categoryDetil = $Lcategory->getOne ( array (
  4360. 'where' => 'cid=' . $value ['cid'],
  4361. 'asArray' => true
  4362. ) );
  4363. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4364. // 检测编辑状态
  4365. $verifyList = $verify->getOne ( array (
  4366. 'where' => 'vid=' . $value ['verify'],
  4367. 'asArray' => true
  4368. ) );
  4369. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4370. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4371. Doo::loadModel ( 'role' );
  4372. $role = new role ();
  4373. $flag = true;
  4374. $roleKey = 0;
  4375. $endStaffArray = array ();
  4376. $roleArrayCopy = array ();
  4377. foreach ( $verifyList as $k => $v ) {
  4378. // init verifyStaff
  4379. if ($v [1] == 'ROLE') {
  4380. if (! empty ( $verifyStaff )) {
  4381. $endStaffArray = end ( $verifyStaff );
  4382. }
  4383. $roleVerify = json_decode ( $v [3], true );
  4384. $roleKey = $k;
  4385. $roleArray = array ();
  4386. $rolename = $role->getOne ( array (
  4387. 'where' => 'rid=' . $v [0],
  4388. 'asArray' => true
  4389. ) );
  4390. foreach ( $roleVerify as $o => $p ) {
  4391. $staffID = explode ( '_', $p );
  4392. $staffInfo = $staff->getOne ( array (
  4393. 'where' => 'sid=' . $staffID [0],
  4394. 'asArray' => true
  4395. ) );
  4396. $exp = array (
  4397. 0 => $staffInfo ['sid'],
  4398. 1 => $staffID [1],
  4399. 2 => $staffInfo ['avatar'],
  4400. 'date' => '',
  4401. 'date' => '',
  4402. 'opinion' => '',
  4403. 'status' => '',
  4404. 'rolename' => $rolename ['name']
  4405. );
  4406. array_push ( $roleArray, $exp );
  4407. }
  4408. $roleArrayCopy [$v [0]] = $roleArray;
  4409. }
  4410. $verifyList [$k] ['date'] = "";
  4411. $verifyList [$k] ['opinion'] = "";
  4412. $verifyList [$k] ['status'] = "";
  4413. if (empty ( $verifyStaff )) {
  4414. $verifyList [$k] ['date'] = "";
  4415. $verifyList [$k] ['opinion'] = "";
  4416. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4417. $verifyList [$k] ['status'] = 4;
  4418. $flag = false;
  4419. }
  4420. } else {
  4421. foreach ( $verifyStaff as $m => $u ) {
  4422. if ($v [0] == $m) {
  4423. $verifyList [$k] ['date'] = $u ['date'];
  4424. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4425. $verifyList [$k] ['status'] = $u ['status'];
  4426. $flag = false;
  4427. break;
  4428. }
  4429. }
  4430. $endStaffArray = end ( $verifyStaff );
  4431. }
  4432. }
  4433. $rolename ['name'] = '';
  4434. if (! empty ( $roleId )) {
  4435. Doo::loadModel ( 'role' );
  4436. $role = new role ();
  4437. $rolename = $role->getOne ( array (
  4438. 'where' => 'rid=' . $roleId,
  4439. 'asArray' => true
  4440. ) );
  4441. }
  4442. if (! empty ( $verifyStaff ))
  4443. $endStaffArray = end ( $verifyStaff );
  4444. $KOP = false;
  4445. foreach ( $roleArrayCopy as $P => $A ) {
  4446. foreach ( $A as $MKI => $AVL ) {
  4447. if (! empty ( $verifyStaff )) {
  4448. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4449. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4450. $button = 4;
  4451. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4452. }
  4453. foreach ( $verifyStaff as $m => $u ) {
  4454. $AVLFK = $AVL [0] . '_R';
  4455. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4456. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4457. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4458. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4459. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4460. break;
  4461. }
  4462. }
  4463. } else {
  4464. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4465. $button = 4;
  4466. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4467. }
  4468. }
  4469. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4470. $KOP = true;
  4471. }
  4472. }
  4473. foreach ( $roleArrayCopy as $k => $v ) {
  4474. foreach ( $verifyList as $m => $n ) {
  4475. if ($n [0] == $k) {
  4476. array_splice ( $verifyList, $m, 1, $v );
  4477. }
  4478. }
  4479. }
  4480. $receiptList [$key] ['verifyList'] = $verifyList;
  4481. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4482. 'where' => 'sid=' . $value ['staff'],
  4483. 'asArray' => true
  4484. ) );
  4485. $receiptList [$key] ['button'] = $button;
  4486. }
  4487. // print_r($receiptList);
  4488. $mothHtml = "";
  4489. for($i = 1; $i <= 12; $i ++) {
  4490. if ($moth == $i)
  4491. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4492. else
  4493. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4494. }
  4495. $dayHtml = "";
  4496. if ($day != "DAY" || $moth != "MONTH") {
  4497. for($i = 1; $i <= 31; $i ++) {
  4498. if ($day == $i)
  4499. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  4500. else
  4501. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  4502. }
  4503. }
  4504. $sopHtml = "";
  4505. foreach ( $sopStaff as $key => $value ) {
  4506. if ($sop == $key)
  4507. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4508. else
  4509. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4510. }
  4511. $data ['sopHtml'] = $sopHtml;
  4512. $data ['dayHtml'] = $dayHtml;
  4513. $data ['mothHtml'] = $mothHtml;
  4514. $data ['receiptList'] = $receiptList;
  4515. $data ['memu'] = "receipt";
  4516. $data ['staff'] = $this->staff;
  4517. $data ['receiptMemu'] = 'implement';
  4518. $data ['verifyId'] = $this->verifyId;
  4519. $data ['executeId'] = $this->executeId;
  4520. $data ['item'] = $item;
  4521. $data ['year'] = $year;
  4522. $data ['moth'] = $moth;
  4523. $data ['day'] = $day;
  4524. $data ['sop'] = $sop;
  4525. $this->render ( "/admin/hisImplement", $data );
  4526. }
  4527. function ajaxExamine() {
  4528. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4529. Doo::loadModel ( 'receipt' );
  4530. $receipt = new receipt ();
  4531. if (! empty ( $rid )) {
  4532. $rLRes = $receipt->find ( array (
  4533. '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,
  4534. 'asArray' => true
  4535. ) );
  4536. echo json_encode ( array (
  4537. 'status' => 1,
  4538. 'receipt' => $rLRes [0]
  4539. ) );
  4540. die ();
  4541. }
  4542. echo json_encode ( array (
  4543. 'status' => 0,
  4544. 'receipt' => array ()
  4545. ) );
  4546. die ();
  4547. }
  4548. /*
  4549. * 废弃
  4550. */
  4551. function myReceipt() {
  4552. // all approval past withdraw
  4553. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4554. if (empty ( $item ))
  4555. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4556. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4557. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  4558. Doo::loadModel ( 'receipt' );
  4559. $receipt = new receipt ();
  4560. // pre-loaded
  4561. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4562. // have cache
  4563. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  4564. if (! empty ( $moth )) // yearPage
  4565. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  4566. $this->showCache ( $path );
  4567. }
  4568. Doo::loadModel ( 'L_category' );
  4569. $Lcategory = new L_category ();
  4570. Doo::loadModel ( 'verify' );
  4571. Doo::loadModel ( 'statistics' );
  4572. $statistics = new statistics ();
  4573. $verify = new verify ();
  4574. Doo::loadModel ( 'staff' );
  4575. $staff = new staff ();
  4576. $condition = " and status!=0 ";
  4577. if ($item == "approval")
  4578. $condition = " and status=2 ";
  4579. elseif ($item == "withdraw")
  4580. $condition = " and status=3 ";
  4581. elseif ($item == "past")
  4582. $condition = " and status=1 ";
  4583. elseif ($item == "whdw")
  4584. $condition = " and status=4 ";
  4585. $dateCondition = " and Year(date) =" . $year;
  4586. if (! empty ( $moth )) {
  4587. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  4588. $stList = $statistics->getOne ( array (
  4589. 'select' => 'rePrice ,agPrice',
  4590. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  4591. 'asArray' => true
  4592. ) );
  4593. } else
  4594. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  4595. if (empty ( $stList ))
  4596. $stList = array (
  4597. 'rePrice' => 0,
  4598. 'agPrice' => 0
  4599. );
  4600. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  4601. $data ['stList'] = array (
  4602. 'rePrice' => $stList ['rePrice'],
  4603. 'agPrice' => $stList ['agPrice'],
  4604. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  4605. );
  4606. $receiptList = $receipt->find ( array (
  4607. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  4608. 'desc' => 'rid',
  4609. 'asArray' => true
  4610. ) );
  4611. $Locate = 0;
  4612. $roleId = 0;
  4613. $button = 0;
  4614. foreach ( $receiptList as $key => $value ) {
  4615. $receiptList [$key] ['Locate'] = $Locate;
  4616. $Locate ++;
  4617. $receiptList [$key] ['reviseDetail'] = array ();
  4618. if (! empty ( $value ['reviseDetail'] ))
  4619. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4620. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4621. $categoryDetil = $Lcategory->getOne ( array (
  4622. 'where' => 'cid=' . $value ['cid'],
  4623. 'asArray' => true
  4624. ) );
  4625. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4626. // 检测编辑状态
  4627. $verifyList = $verify->getOne ( array (
  4628. 'where' => 'vid=' . $value ['verify'],
  4629. 'asArray' => true
  4630. ) );
  4631. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4632. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4633. Doo::loadModel ( 'role' );
  4634. $role = new role ();
  4635. $flag = true;
  4636. $roleKey = 0;
  4637. $endStaffArray = array ();
  4638. $roleArrayCopy = array ();
  4639. foreach ( $verifyList as $k => $v ) {
  4640. // init verifyStaff
  4641. if ($v [1] == 'ROLE') {
  4642. if (! empty ( $verifyStaff )) {
  4643. $endStaffArray = end ( $verifyStaff );
  4644. // if ($v[0]==$endStaffArray['nextStaff']){
  4645. // $roleId=$v[0];
  4646. // }
  4647. }
  4648. $roleVerify = json_decode ( $v [3], true );
  4649. $roleKey = $k;
  4650. $roleArray = array ();
  4651. $rolename = $role->getOne ( array (
  4652. 'where' => 'rid=' . $v [0],
  4653. 'asArray' => true
  4654. ) );
  4655. foreach ( $roleVerify as $o => $p ) {
  4656. $staffID = explode ( '_', $p );
  4657. $staffInfo = $staff->getOne ( array (
  4658. 'where' => 'sid=' . $staffID [0],
  4659. 'asArray' => true
  4660. ) );
  4661. // print_r($staffID);
  4662. $exp = array (
  4663. 0 => $staffInfo ['sid'],
  4664. 1 => $staffID [1],
  4665. 2 => $staffInfo ['avatar'],
  4666. 'date' => '',
  4667. 'date' => '',
  4668. 'opinion' => '',
  4669. 'status' => '',
  4670. 'rolename' => $rolename ['name']
  4671. );
  4672. array_push ( $roleArray, $exp );
  4673. }
  4674. $roleArrayCopy [$v [0]] = $roleArray;
  4675. // $verifyList[$k]['roleArray']=$roleArray;
  4676. }
  4677. $verifyList [$k] ['date'] = "";
  4678. $verifyList [$k] ['opinion'] = "";
  4679. $verifyList [$k] ['status'] = "";
  4680. if (empty ( $verifyStaff )) {
  4681. $verifyList [$k] ['date'] = "";
  4682. $verifyList [$k] ['opinion'] = "";
  4683. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4684. $verifyList [$k] ['status'] = 4;
  4685. $flag = false;
  4686. }
  4687. } else {
  4688. foreach ( $verifyStaff as $m => $u ) {
  4689. if ($v [0] == $m) {
  4690. $verifyList [$k] ['date'] = $u ['date'];
  4691. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4692. $verifyList [$k] ['status'] = $u ['status'];
  4693. $flag = false;
  4694. break;
  4695. }
  4696. }
  4697. $endStaffArray = end ( $verifyStaff );
  4698. if (isset ( $endStaffArray ['ROLE'] )) {
  4699. } else {
  4700. // $endKey=key($verifyStaff);
  4701. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4702. // $button=4;
  4703. // $verifyList[$k]['status']=4;
  4704. // }
  4705. }
  4706. }
  4707. }
  4708. $rolename ['name'] = '';
  4709. if (! empty ( $roleId )) {
  4710. Doo::loadModel ( 'role' );
  4711. $role = new role ();
  4712. $rolename = $role->getOne ( array (
  4713. 'where' => 'rid=' . $roleId,
  4714. 'asArray' => true
  4715. ) );
  4716. }
  4717. if (! empty ( $verifyStaff ))
  4718. $endStaffArray = end ( $verifyStaff );
  4719. $KOP = false;
  4720. foreach ( $roleArrayCopy as $P => $A ) {
  4721. foreach ( $A as $MKI => $AVL ) {
  4722. if (! empty ( $verifyStaff )) {
  4723. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4724. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4725. $button = 4;
  4726. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4727. }
  4728. foreach ( $verifyStaff as $m => $u ) {
  4729. $AVLFK = $AVL [0] . '_R';
  4730. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4731. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4732. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4733. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4734. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4735. break;
  4736. }
  4737. }
  4738. } else {
  4739. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4740. $button = 4;
  4741. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4742. }
  4743. }
  4744. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4745. $KOP = true;
  4746. }
  4747. }
  4748. foreach ( $roleArrayCopy as $k => $v ) {
  4749. foreach ( $verifyList as $m => $n ) {
  4750. if ($n [0] == $k) {
  4751. array_splice ( $verifyList, $m, 1, $v );
  4752. }
  4753. }
  4754. }
  4755. $receiptList [$key] ['verifyList'] = $verifyList;
  4756. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4757. 'where' => 'sid=' . $value ['staff'],
  4758. 'asArray' => true
  4759. ) );
  4760. $receiptList [$key] ['button'] = $button;
  4761. }
  4762. // print_r($receiptList);die;
  4763. $mothHtml = "";
  4764. for($i = 1; $i <= 12; $i ++) {
  4765. if ($moth == $i)
  4766. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4767. else
  4768. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4769. }
  4770. $data ['mothHtml'] = $mothHtml;
  4771. $data ['receiptList'] = $receiptList;
  4772. $data ['memu'] = "receipt";
  4773. $data ['staff'] = $this->staff;
  4774. $data ['receiptMemu'] = 'receipt';
  4775. $data ['verifyId'] = $this->verifyId;
  4776. $data ['executeId'] = $this->executeId;
  4777. $data ['item'] = $item;
  4778. $data ['year'] = $year;
  4779. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4780. // sufficient condition to generate cache
  4781. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  4782. $receiptList = $receipt->find ( array (
  4783. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  4784. 'asArray' => true
  4785. ) );
  4786. if (empty ( $receiptList )) { // generated files
  4787. ob_start ();
  4788. $this->render ( "/admin/saea_myList", $data );
  4789. $this->cacheFile ( $path );
  4790. die ();
  4791. // $content = ob_get_contents();
  4792. // $fp = fopen($path, "w");
  4793. // fwrite($fp, $content);
  4794. // fclose($fp);
  4795. }
  4796. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  4797. $receiptList = $receipt->find ( array (
  4798. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  4799. 'asArray' => true
  4800. ) );
  4801. if (empty ( $receiptList )) { // generated files
  4802. ob_start ();
  4803. $this->render ( "/admin/saea_myList", $data );
  4804. $this->cacheFile ( $path );
  4805. die ();
  4806. }
  4807. }
  4808. }
  4809. $this->render ( "/admin/saea_myList", $data );
  4810. }
  4811. function saeaCreate() {
  4812. Doo::loadModel ( 'accountItem' );
  4813. Doo::loadModel ( 'verify' );
  4814. Doo::loadModel ( 'receipt' );
  4815. Doo::loadModel ( 'L_category' );
  4816. $lCategory = new L_category ();
  4817. $receipt = new receipt ();
  4818. $verify = new verify ();
  4819. $accountItem = new accountItem ();
  4820. Doo::loadModel ( "role" );
  4821. $role = new role ();
  4822. $acItem = $accountItem->find ( array (
  4823. 'asArray' => true
  4824. ) );
  4825. $veList = $verify->find ( array (
  4826. 'asArray' => true
  4827. ) );
  4828. foreach ( $veList as $key => $value ) {
  4829. $v = json_decode ( $value ['staff'] );
  4830. $list = array ();
  4831. foreach ( $v as $n => $m ) {
  4832. if ($m ['1'] == 'ROLE') {
  4833. $roleInfo = $role->getOne ( array (
  4834. 'where' => 'rid=' . $m [0],
  4835. 'asArray' => true
  4836. ) );
  4837. $v [$n] [1] = $roleInfo ['name'];
  4838. array_push ( $list, $roleInfo ['name'] );
  4839. } else {
  4840. array_push ( $list, $v [$n] [1] );
  4841. }
  4842. }
  4843. $veList [$key] ['staff'] = implode ( '>', $list );
  4844. }
  4845. $data ['category'] = $lCategory->find ( array (
  4846. 'asArray' => true
  4847. ) );
  4848. $data ['veList'] = $veList;
  4849. $data ['acItem'] = $acItem;
  4850. $data ['memu'] = "receipt";
  4851. $data ['staff'] = $this->staff;
  4852. $data ['receiptMemu'] = 'saeaBorad';
  4853. $data ['verifyId'] = $this->verifyId;
  4854. $data ['executeId'] = $this->executeId;
  4855. $this->render ( "/admin/saea_create", $data );
  4856. }
  4857. function addReceipt() {
  4858. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  4859. $agency = $this->get_args ( 'agency' );
  4860. $travel = $this->get_args ( 'travel' );
  4861. $train = $this->get_args ( 'train' );
  4862. $other = $this->get_args ( 'other' );
  4863. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  4864. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  4865. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  4866. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  4867. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  4868. Doo::loadModel ( 'receipt' );
  4869. Doo::loadModel ( 'receiptDetail' );
  4870. Doo::loadModel ( 'accountItem' );
  4871. $accountItem = new accountItem ();
  4872. $receipt = new receipt ();
  4873. Doo::loadModel ( 'enclosur' );
  4874. Doo::loadModel ( 'execute' );
  4875. $execute = new execute ();
  4876. $executeDetail = $execute->getOne ( array (
  4877. 'where' => 'mold="报销单执行人"',
  4878. 'asArray' => true
  4879. ) );
  4880. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  4881. // if(!empty($receiptDetail))
  4882. // return "/referReceipt/".$receiptDetail['rid'];
  4883. $aItem = $accountItem->find ( array (
  4884. 'asArray' => true
  4885. ) );
  4886. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  4887. $ag = $tr = $ta = $ot = 0;
  4888. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  4889. foreach ( $aItem as $key => $value ) {
  4890. if ($value ['category'] == $this->AGENCY) {
  4891. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  4892. array_push ( $accountJson [$this->AGENCY], array (
  4893. 'aid' => $value ['aid'],
  4894. 'name' => $value ['name'],
  4895. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  4896. ) );
  4897. $sum += $agency [$ag];
  4898. $agencySum += $agency [$ag];
  4899. }
  4900. $ag ++;
  4901. }
  4902. if ($value ['category'] == $this->TRAVEL) {
  4903. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  4904. array_push ( $accountJson [$this->TRAVEL], array (
  4905. 'aid' => $value ['aid'],
  4906. 'name' => $value ['name'],
  4907. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  4908. ) );
  4909. $sum += $travel [$tr];
  4910. $travelSum += $travel [$tr];
  4911. }
  4912. $tr ++;
  4913. }
  4914. if ($value ['category'] == $this->TRAIN) {
  4915. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  4916. array_push ( $accountJson [$this->TRAIN], array (
  4917. 'aid' => $value ['aid'],
  4918. 'name' => $value ['name'],
  4919. 'price' => number_format ( $train [$ta], 2, '.', '' )
  4920. ) );
  4921. $sum += $train [$ta];
  4922. $trainSum += $train [$ta];
  4923. }
  4924. $ta ++;
  4925. }
  4926. if ($value ['category'] == $this->OTHER) {
  4927. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  4928. array_push ( $accountJson [$this->OTHER], array (
  4929. 'aid' => $value ['aid'],
  4930. 'name' => $value ['name'],
  4931. 'price' => number_format ( $other [$ot], 2, '.', '' )
  4932. ) );
  4933. $sum += $other [$ot];
  4934. $otherSum += $other [$ot];
  4935. }
  4936. $ot ++;
  4937. }
  4938. }
  4939. $accountJson ['cSum'] = array (
  4940. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  4941. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  4942. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  4943. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  4944. );
  4945. // 报销单
  4946. $receipt->accountItem = json_encode ( $accountJson );
  4947. $receipt->staff = $this->staff [0] ['sid'];
  4948. $receipt->sum = number_format ( $sum, 2, '.', '' );
  4949. $receipt->date = date ( "Y-m-d" );
  4950. $receipt->cid = $cid;
  4951. $receipt->status = 5;
  4952. // 修改审批流程加入角色
  4953. $receipt->verify = $verify;
  4954. $receipt->executeCopy = $executeDetail ['staff'];
  4955. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  4956. $receipt->explanation = $explanation;
  4957. $rid = $receipt->insert ();
  4958. // 附件
  4959. if (! empty ( $enclosurName )) {
  4960. $enclosurArray = explode ( '-', $enclosurName );
  4961. foreach ( $enclosurArray as $value ) {
  4962. $enclosur = new enclosur ();
  4963. $enclosur->name = $value;
  4964. $enclosur->rid = $rid;
  4965. $enclosur->insert ();
  4966. }
  4967. // print_r($enclosurArray);die;
  4968. }
  4969. // 报销详情
  4970. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  4971. $receiptDetail = new receiptDetail ();
  4972. $receiptDetail->staff = $this->staff [0] ['sid'];
  4973. $receiptDetail->item = $value ['name'];
  4974. $receiptDetail->itemCategory = $this->AGENCY;
  4975. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  4976. $receiptDetail->date = date ( "Y-m-d" );
  4977. $receiptDetail->cid = $cid;
  4978. $receiptDetail->rid = $rid;
  4979. $receiptDetail->status = 4;
  4980. $receiptDetail->insert ();
  4981. }
  4982. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  4983. $receiptDetail = new receiptDetail ();
  4984. $receiptDetail->staff = $this->staff [0] ['sid'];
  4985. $receiptDetail->item = $value ['name'];
  4986. $receiptDetail->itemCategory = $this->TRAVEL;
  4987. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  4988. $receiptDetail->date = date ( "Y-m-d" );
  4989. $receiptDetail->cid = $cid;
  4990. $receiptDetail->rid = $rid;
  4991. $receiptDetail->status = 4;
  4992. $receiptDetail->insert ();
  4993. }
  4994. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  4995. $receiptDetail = new receiptDetail ();
  4996. $receiptDetail->staff = $this->staff [0] ['sid'];
  4997. $receiptDetail->item = $value ['name'];
  4998. $receiptDetail->itemCategory = $this->TRAIN;
  4999. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5000. $receiptDetail->date = date ( "Y-m-d" );
  5001. $receiptDetail->cid = $cid;
  5002. $receiptDetail->rid = $rid;
  5003. $receiptDetail->status = 4;
  5004. $receiptDetail->insert ();
  5005. }
  5006. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5007. $receiptDetail = new receiptDetail ();
  5008. $receiptDetail->staff = $this->staff [0] ['sid'];
  5009. $receiptDetail->item = $value ['name'];
  5010. $receiptDetail->itemCategory = $this->OTHER;
  5011. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5012. $receiptDetail->date = date ( "Y-m-d" );
  5013. $receiptDetail->cid = $cid;
  5014. $receiptDetail->rid = $rid;
  5015. $receiptDetail->status = 4;
  5016. $receiptDetail->insert ();
  5017. }
  5018. // return "/referReceipt/".$rid;
  5019. }
  5020. return "/saeaBorad";
  5021. }
  5022. function referReceipt() {
  5023. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  5024. Doo::loadModel ( 'receipt' );
  5025. Doo::loadModel ( 'verify' );
  5026. $verify = new verify ();
  5027. $receipt = new receipt ();
  5028. Doo::loadModel ( 'L_category' );
  5029. $lCategory = new L_category ();
  5030. Doo::loadModel ( "role" );
  5031. $role = new role ();
  5032. $receiptDetail = $receipt->find ( array (
  5033. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  5034. 'asArray' => true
  5035. ) );
  5036. if (empty ( $receiptDetail ))
  5037. return "/addReceipt";
  5038. foreach ( $receiptDetail as $key => $value ) {
  5039. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5040. $veList = $verify->getOne ( array (
  5041. 'where' => 'vid=' . $value ['verify'],
  5042. 'asArray' => true
  5043. ) );
  5044. $v = json_decode ( $veList ['staff'] );
  5045. array_push ( $v [0], $veList ['description'] );
  5046. foreach ( $v as $n => $m ) {
  5047. if ($m ['1'] == 'ROLE') {
  5048. $roleInfo = $role->getOne ( array (
  5049. 'where' => 'rid=' . $m [0],
  5050. 'asArray' => true
  5051. ) );
  5052. $v [$n] [1] = $roleInfo ['name'];
  5053. }
  5054. }
  5055. $receiptDetail [$key] ['staff'] = $v;
  5056. $category = $lCategory->getOne ( array (
  5057. 'where' => 'cid=' . $value ['cid'],
  5058. 'asArray' => true
  5059. ) );
  5060. $receiptDetail [$key] ['category'] = $category ['title'];
  5061. }
  5062. // print_r($receiptDetail);
  5063. $data ['receiptDetail'] = $receiptDetail;
  5064. $data ['memu'] = "receipt";
  5065. $data ['staff'] = $this->staff;
  5066. $data ['receiptMemu'] = 'saeaCreate';
  5067. $data ['verifyId'] = $this->verifyId;
  5068. $data ['executeId'] = $this->executeId;
  5069. $this->render ( "/admin/saea_confirm", $data );
  5070. }
  5071. function editReceipt() {
  5072. // edit status 4
  5073. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5074. // echo $rid;
  5075. Doo::loadModel ( 'accountItem' );
  5076. Doo::loadModel ( 'verify' );
  5077. Doo::loadModel ( 'receipt' );
  5078. $receipt = new receipt ();
  5079. $verify = new verify ();
  5080. $accountItem = new accountItem ();
  5081. Doo::loadModel ( 'L_category' );
  5082. $lCategory = new L_category ();
  5083. Doo::loadModel ( "role" );
  5084. $role = new role ();
  5085. $receiptDetail = $receipt->getOne ( array (
  5086. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  5087. 'asArray' => true
  5088. ) );
  5089. if (empty ( $receiptDetail ))
  5090. return "/saeaCreate";
  5091. $acItem = $accountItem->find ( array (
  5092. 'asArray' => true
  5093. ) );
  5094. $veList = $verify->find ( array (
  5095. 'asArray' => true
  5096. ) );
  5097. foreach ( $veList as $key => $value ) {
  5098. $v = json_decode ( $value ['staff'] );
  5099. $list = array ();
  5100. foreach ( $v as $n => $m ) {
  5101. if ($m ['1'] == 'ROLE') {
  5102. $roleInfo = $role->getOne ( array (
  5103. 'where' => 'rid=' . $m [0],
  5104. 'asArray' => true
  5105. ) );
  5106. $v [$n] [1] = $roleInfo ['name'];
  5107. array_push ( $list, $roleInfo ['name'] );
  5108. } else {
  5109. array_push ( $list, $v [$n] [1] );
  5110. }
  5111. }
  5112. $veList [$key] ['staff'] = implode ( '>', $list );
  5113. }
  5114. // 配置编辑信息
  5115. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  5116. foreach ( $acItem as $key => $value ) {
  5117. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  5118. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  5119. $acItem [$key] ['price'] = $v ['price'];
  5120. }
  5121. }
  5122. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  5123. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  5124. $acItem [$key] ['price'] = $v ['price'];
  5125. }
  5126. }
  5127. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  5128. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  5129. $acItem [$key] ['price'] = $v ['price'];
  5130. }
  5131. }
  5132. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  5133. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  5134. $acItem [$key] ['price'] = $v ['price'];
  5135. }
  5136. }
  5137. }
  5138. $data ['category'] = $lCategory->find ( array (
  5139. 'asArray' => true
  5140. ) );
  5141. $data ['cSum'] = $accountItemList ['cSum'];
  5142. $data ['sum'] = $receiptDetail ['sum'];
  5143. $data ['receiptDetail'] = $receiptDetail;
  5144. $data ['veList'] = $veList;
  5145. $data ['acItem'] = $acItem;
  5146. $data ['memu'] = "receipt";
  5147. $data ['staff'] = $this->staff;
  5148. $data ['receiptMemu'] = 'saeaBorad';
  5149. $data ['verify'] = $receiptDetail ['verify'];
  5150. $data ['verifyId'] = $this->verifyId;
  5151. $data ['executeId'] = $this->executeId;
  5152. $data ['rid'] = $rid;
  5153. $this->render ( "/admin/saea_edit", $data );
  5154. }
  5155. function updateReceipt() {
  5156. $agency = $this->get_args ( 'agency' );
  5157. $travel = $this->get_args ( 'travel' );
  5158. $train = $this->get_args ( 'train' );
  5159. $other = $this->get_args ( 'other' );
  5160. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5161. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5162. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5163. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5164. if (! empty ( $explanation )) {
  5165. Doo::loadModel ( 'receipt' );
  5166. Doo::loadModel ( 'receiptDetail' );
  5167. Doo::loadModel ( 'accountItem' );
  5168. $accountItem = new accountItem ();
  5169. $receipt = new receipt ();
  5170. Doo::loadModel ( 'execute' );
  5171. $execute = new execute ();
  5172. $receiptDetail = $receipt->getOne ( array (
  5173. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  5174. 'asArray' => true
  5175. ) );
  5176. if (empty ( $receiptDetail ))
  5177. return "/saeaBorad";
  5178. if ($receiptDetail ['Rtype'] == 1)
  5179. $executeDetail = $execute->getOne ( array (
  5180. 'where' => 'mold="借款费用执行人"',
  5181. 'asArray' => true
  5182. ) );
  5183. else
  5184. $executeDetail = $execute->getOne ( array (
  5185. 'where' => 'mold="报销单执行人"',
  5186. 'asArray' => true
  5187. ) );
  5188. $aItem = $accountItem->find ( array (
  5189. 'asArray' => true
  5190. ) );
  5191. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5192. $ag = $tr = $ta = $ot = 0;
  5193. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5194. foreach ( $aItem as $key => $value ) {
  5195. if ($value ['category'] == $this->AGENCY) {
  5196. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5197. array_push ( $accountJson [$this->AGENCY], array (
  5198. 'aid' => $value ['aid'],
  5199. 'name' => $value ['name'],
  5200. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5201. ) );
  5202. $sum += $agency [$ag];
  5203. $agencySum += $agency [$ag];
  5204. }
  5205. $ag ++;
  5206. }
  5207. if ($value ['category'] == $this->TRAVEL) {
  5208. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5209. array_push ( $accountJson [$this->TRAVEL], array (
  5210. 'aid' => $value ['aid'],
  5211. 'name' => $value ['name'],
  5212. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5213. ) );
  5214. $sum += $travel [$tr];
  5215. $travelSum += $travel [$tr];
  5216. }
  5217. $tr ++;
  5218. }
  5219. if ($value ['category'] == $this->TRAIN) {
  5220. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5221. array_push ( $accountJson [$this->TRAIN], array (
  5222. 'aid' => $value ['aid'],
  5223. 'name' => $value ['name'],
  5224. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5225. ) );
  5226. $sum += $train [$ta];
  5227. $trainSum += $train [$ta];
  5228. }
  5229. $ta ++;
  5230. }
  5231. if ($value ['category'] == $this->OTHER) {
  5232. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5233. array_push ( $accountJson [$this->OTHER], array (
  5234. 'aid' => $value ['aid'],
  5235. 'name' => $value ['name'],
  5236. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5237. ) );
  5238. $sum += $other [$ot];
  5239. $otherSum += $other [$ot];
  5240. }
  5241. $ot ++;
  5242. }
  5243. }
  5244. $accountJson ['cSum'] = array (
  5245. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5246. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5247. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5248. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5249. );
  5250. // 报销单
  5251. $rid = $receipt->rid = $receiptDetail ['rid'];
  5252. $receipt->accountItem = json_encode ( $accountJson );
  5253. $receipt->staff = $this->staff [0] ['sid'];
  5254. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5255. $receipt->date = date ( "Y-m-d" );
  5256. $receipt->cid = $cid;
  5257. if (($receiptDetail ['status'] != 4)) {
  5258. if ($receiptDetail ['Rtype'] == 1)
  5259. $receipt->status = 7;
  5260. else
  5261. $receipt->status = 5;
  5262. }
  5263. if ($receiptDetail != 4 && ! empty ( $verify ))
  5264. $receipt->verify = $verify;
  5265. $receipt->executeCopy = $executeDetail ['staff'];
  5266. $receipt->explanation = $explanation;
  5267. $receipt->update ();
  5268. $receiptDetail = new receiptDetail ();
  5269. $receiptDetail->delete ( array (
  5270. 'where' => 'rid=' . $rid
  5271. ) );
  5272. // 报销详情
  5273. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5274. $receiptDetail = new receiptDetail ();
  5275. $receiptDetail->staff = $this->staff [0] ['sid'];
  5276. $receiptDetail->item = $value ['name'];
  5277. $receiptDetail->itemCategory = $this->AGENCY;
  5278. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5279. $receiptDetail->date = date ( "Y-m-d" );
  5280. $receiptDetail->cid = $cid;
  5281. $receiptDetail->rid = $rid;
  5282. $receiptDetail->status = 4;
  5283. $receiptDetail->insert ();
  5284. }
  5285. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5286. $receiptDetail = new receiptDetail ();
  5287. $receiptDetail->staff = $this->staff [0] ['sid'];
  5288. $receiptDetail->item = $value ['name'];
  5289. $receiptDetail->itemCategory = $this->TRAVEL;
  5290. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5291. $receiptDetail->date = date ( "Y-m-d" );
  5292. $receiptDetail->cid = $cid;
  5293. $receiptDetail->rid = $rid;
  5294. $receiptDetail->status = 4;
  5295. $receiptDetail->insert ();
  5296. }
  5297. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5298. $receiptDetail = new receiptDetail ();
  5299. $receiptDetail->staff = $this->staff [0] ['sid'];
  5300. $receiptDetail->item = $value ['name'];
  5301. $receiptDetail->itemCategory = $this->TRAIN;
  5302. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5303. $receiptDetail->date = date ( "Y-m-d" );
  5304. $receiptDetail->cid = $cid;
  5305. $receiptDetail->rid = $rid;
  5306. $receiptDetail->status = 4;
  5307. $receiptDetail->insert ();
  5308. }
  5309. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5310. $receiptDetail = new receiptDetail ();
  5311. $receiptDetail->staff = $this->staff [0] ['sid'];
  5312. $receiptDetail->item = $value ['name'];
  5313. $receiptDetail->itemCategory = $this->OTHER;
  5314. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5315. $receiptDetail->date = date ( "Y-m-d" );
  5316. $receiptDetail->cid = $cid;
  5317. $receiptDetail->rid = $rid;
  5318. $receiptDetail->status = 4;
  5319. $receiptDetail->insert ();
  5320. }
  5321. // return "/referReceipt/".$rid;
  5322. }
  5323. return "/saeaBorad";
  5324. }
  5325. function approvedReceipt() {
  5326. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5327. Doo::loadModel ( 'receipt' );
  5328. Doo::loadModel ( 'receiptDetail' );
  5329. $receipt = new receipt ();
  5330. $receiptDetail = new receiptDetail ();
  5331. Doo::loadModel ( 'statistics' );
  5332. Doo::loadModel ( 'itemStatistics' );
  5333. $statistics = new statistics ();
  5334. $itemStatistics = new itemStatistics ();
  5335. Doo::loadModel ( "verify" );
  5336. $verify = new verify ();
  5337. // 审批状态的判定
  5338. $receiptDetailList = $receipt->getOne ( array (
  5339. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  5340. 'asArray' => true
  5341. ) );
  5342. if (empty ( $receiptDetailList ))
  5343. return "/saeaBorad";
  5344. $verifyDetail = $verify->getOne ( array (
  5345. 'where' => ' vid =' . $receiptDetailList ['verify'],
  5346. 'asArray' => true
  5347. ) );
  5348. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5349. if (empty ( $receiptDetailList ['nowStaff'] )) {
  5350. $nowStaff = "";
  5351. $nowStaffList = array ();
  5352. if ($verifyDetail [0] [1] == 'ROLE') {
  5353. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5354. foreach ( $vStaffString as $key => $value ) {
  5355. $staffK = explode ( "_", $value );
  5356. array_push ( $nowStaffList, $staffK [0] );
  5357. }
  5358. $nowStaff = implode ( ',', $nowStaffList );
  5359. } else {
  5360. $nowStaff = $verifyDetail [0] [0];
  5361. }
  5362. $receipt->nowStaff = $nowStaff;
  5363. }
  5364. // echo $nowStaff;
  5365. // print_r($verifyDetail);die;
  5366. $receipt->rid = $receiptDetailList ['rid'];
  5367. $receipt->date = date ( "Y-m-d" );
  5368. $receipt->status = 2;
  5369. $receipt->update ();
  5370. $receiptDetail->status = 2;
  5371. $receiptDetail->update ( array (
  5372. 'where' => 'rid=' . $receiptDetailList ['rid']
  5373. ) );
  5374. Doo::loadModel ( "receiptLog" );
  5375. $receiptLog = new receiptLog ();
  5376. Doo::loadModel ( "verify" );
  5377. $verify = new verify ();
  5378. $receiptInfo = $receipt->getOne ( array (
  5379. 'where' => 'rid=' . $rid,
  5380. 'asArray' => true
  5381. ) );
  5382. $vr = $verify->getOne ( array (
  5383. 'where' => 'vid=' . $receiptInfo ['verify'],
  5384. 'asArray' => true
  5385. ) );
  5386. $jd = json_decode ( $vr ['staff'] );
  5387. $roleId = 0;
  5388. foreach ( $jd as $key => $value ) {
  5389. if ($value [1] == 'ROLE') {
  5390. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  5391. if ($pos !== false) {
  5392. $roleId = $value [0];
  5393. }
  5394. }
  5395. }
  5396. // 审批日志
  5397. // echo $roleId;die;
  5398. if (! empty ( $roleId )) {
  5399. Doo::loadModel ( "role" );
  5400. $role = new role ();
  5401. $roleInfo = $role->getOne ( array (
  5402. 'where' => 'rid=' . $roleId,
  5403. 'asArray' => true
  5404. ) );
  5405. $receiptLog->rolename = $roleInfo ['name'];
  5406. }
  5407. $receiptLog->username = $this->staff [0] ['username'];
  5408. $receiptLog->uid = $this->staff [0] ['sid'];
  5409. $receiptLog->date = date ( "Y-m-d" );
  5410. $receiptLog->opinion = '提交审批';
  5411. $receiptLog->img = $this->staff [0] ['avatar'];
  5412. $receiptLog->status = 2;
  5413. $receiptLog->rid = $rid;
  5414. $receiptLog->insert ();
  5415. // statistics item
  5416. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  5417. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  5418. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  5419. // print_r($accountItem['cSum']['agencySum']);die;
  5420. // foreach ($accountItem['cSum'] as $key=>$value){
  5421. // if($key=="agencySum"){
  5422. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->AGENCY.'"'.$dateCondition,'asArray'=>true));
  5423. // if(empty($iStatistics)){
  5424. // $itemStatistics->cid=$this->staff[0]['cid'];
  5425. // $itemStatistics->staff=$this->staff[0]['sid'];
  5426. // $itemStatistics->price=$value;
  5427. // $itemStatistics->itemCategory=$this->AGENCY;
  5428. // $itemStatistics->date=date("Y-m-d");
  5429. // $itemStatistics->insert();
  5430. // }else{
  5431. // if (!empty($value)){
  5432. // $itemStatistics->price=$value+$iStatistics['price'];
  5433. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5434. // }
  5435. // }
  5436. // }elseif($key=="travelSum"){
  5437. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->TRAVEL.'"'.$dateCondition,'asArray'=>true));
  5438. // if(empty($iStatistics)){
  5439. // $itemStatistics->cid=$this->staff[0]['cid'];
  5440. // $itemStatistics->staff=$this->staff[0]['sid'];
  5441. // $itemStatistics->price=$value;
  5442. // $itemStatistics->itemCategory=$this->TRAVEL;
  5443. // $itemStatistics->date=date("Y-m-d");
  5444. // $itemStatistics->insert();
  5445. // }else{
  5446. // if (!empty($value)){
  5447. // $itemStatistics->price=$value+$iStatistics['price'];
  5448. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5449. // }
  5450. // }
  5451. // }elseif($key=="trainSum"){
  5452. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->TRAIN.'"'.$dateCondition,'asArray'=>true));
  5453. // if(empty($iStatistics)){
  5454. // $itemStatistics->cid=$this->staff[0]['cid'];
  5455. // $itemStatistics->staff=$this->staff[0]['sid'];
  5456. // $itemStatistics->price=$value;
  5457. // $itemStatistics->itemCategory=$this->TRAIN;
  5458. // $itemStatistics->date=date("Y-m-d");
  5459. // $itemStatistics->insert();
  5460. // }else{
  5461. // if (!empty($value)){
  5462. // $itemStatistics->price=$value+$iStatistics['price'];
  5463. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5464. // }
  5465. // }
  5466. // }elseif($key=="otherSum"){
  5467. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->OTHER.'"'.$dateCondition,'asArray'=>true));
  5468. // if(empty($iStatistics)){
  5469. // $itemStatistics->cid=$this->staff[0]['cid'];
  5470. // $itemStatistics->staff=$this->staff[0]['sid'];
  5471. // $itemStatistics->price=$value;
  5472. // $itemStatistics->itemCategory=$this->OTHER;
  5473. // $itemStatistics->date=date("Y-m-d");
  5474. // $itemStatistics->insert();
  5475. // }else{
  5476. // if (!empty($value)){
  5477. // $itemStatistics->price=$value+$iStatistics['price'];
  5478. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5479. // }
  5480. // }
  5481. // }
  5482. // }
  5483. $stat = $statistics->getOne ( array (
  5484. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5485. 'asArray' => true
  5486. ) );
  5487. if (empty ( $stat )) {
  5488. $statistics->date = date ( "Y-m-d" );
  5489. $statistics->cid = $this->staff [0] ['cid'];
  5490. $statistics->staff = $this->staff [0] ['sid'];
  5491. $statistics->agPrice = 0;
  5492. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5493. $statistics->insert ();
  5494. } else {
  5495. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5496. $statistics->update ( array (
  5497. 'where' => 'sid=' . $stat ['sid']
  5498. ) );
  5499. }
  5500. return "/expenses";
  5501. }
  5502. function approval() {
  5503. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5504. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5505. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5506. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5507. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5508. if (empty ( $status ))
  5509. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5510. $vidList = array ();
  5511. $button = 0;
  5512. Doo::loadModel ( 'verify' );
  5513. $verify = new verify ();
  5514. Doo::loadModel ( 'receipt' );
  5515. $receipt = new receipt ();
  5516. Doo::loadModel ( 'staff' );
  5517. $staff = new staff ();
  5518. Doo::loadModel ( 'L_category' );
  5519. $Lcategory = new L_category ();
  5520. // user verify ID
  5521. $verifyDetail = $verify->find ( array (
  5522. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5523. 'asArray' => true
  5524. ) );
  5525. foreach ( $verifyDetail as $key => $value ) {
  5526. array_push ( $vidList, $value ['vid'] );
  5527. }
  5528. $vid = implode ( ",", $vidList );
  5529. if (empty ( $verifyDetail ))
  5530. $vid = 0;
  5531. /*
  5532. */
  5533. $dateCondition = " and Year(date) =" . $year;
  5534. if (! empty ( $month ))
  5535. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  5536. $categoryList = $Lcategory->find ( array (
  5537. 'asArray' => true
  5538. ) );
  5539. $staffList = $staff->find ( array (
  5540. 'where' => 'cid=' . $cid,
  5541. 'asArray' => true
  5542. ) );
  5543. $cateCondition = "";
  5544. $staffCondition = "";
  5545. $approvalCondition = "";
  5546. if (! empty ( $cid ))
  5547. $cateCondition = ' and cid=' . $cid;
  5548. if (! empty ( $sid )) {
  5549. $staffCondition = ' and staff=' . $sid;
  5550. $cateCondition = "";
  5551. }
  5552. // elseif($status==1){
  5553. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  5554. // }
  5555. if ($status == 2) {
  5556. // 查找角色审批人
  5557. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  5558. }
  5559. $ap = "";
  5560. if ($status == 4) {
  5561. $ap = 4;
  5562. $status = 2;
  5563. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  5564. }
  5565. if ($status == 5) {
  5566. $status = 4;
  5567. $ap = 5;
  5568. }
  5569. // echo $vid;
  5570. // get Receipt By verifyID status 2 .$approvalCondition
  5571. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  5572. $receiptList = $receipt->find ( array (
  5573. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  5574. 'desc' => 'rid',
  5575. 'asArray' => true
  5576. ) );
  5577. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  5578. $Locate = 0;
  5579. if ($ap == 4)
  5580. $status = 4;
  5581. elseif ($ap == 5)
  5582. $status = 5;
  5583. foreach ( $receiptList as $key => $value ) {
  5584. $receiptList [$key] ['Locate'] = $Locate;
  5585. $Locate ++;
  5586. $receiptList [$key] ['reviseDetail'] = array ();
  5587. if (! empty ( $value ['reviseDetail'] ))
  5588. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5589. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5590. $categoryDetil = $Lcategory->getOne ( array (
  5591. 'where' => 'cid=' . $value ['cid'],
  5592. 'asArray' => true
  5593. ) );
  5594. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5595. $verifyList = $verify->getOne ( array (
  5596. 'where' => 'vid=' . $value ['verify'],
  5597. 'asArray' => true
  5598. ) );
  5599. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5600. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5601. foreach ( $verifyList as $k => $v ) {
  5602. // init verifyStaff
  5603. $verifyList [$k] ['date'] = "";
  5604. $verifyList [$k] ['opinion'] = "";
  5605. $verifyList [$k] ['status'] = "";
  5606. if (empty ( $verifyStaff )) {
  5607. $verifyList [$k] ['date'] = "";
  5608. $verifyList [$k] ['opinion'] = "";
  5609. if ($v [0] == $this->staff [0] ['sid']) {
  5610. $verifyList [$k] ['status'] = 4;
  5611. $button = 4;
  5612. }
  5613. } else {
  5614. $flag = true;
  5615. foreach ( $verifyStaff as $m => $u ) {
  5616. if ($v [0] == $m) {
  5617. $verifyList [$k] ['date'] = $u ['date'];
  5618. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5619. $verifyList [$k] ['status'] = $u ['status'];
  5620. $flag = false;
  5621. break;
  5622. }
  5623. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  5624. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  5625. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  5626. }
  5627. if ($flag) { // 检测可编辑
  5628. if ($v [0] == $this->staff [0] ['sid']) {
  5629. $verifyList [$k] ['status'] = 4;
  5630. $button = 4;
  5631. }
  5632. }
  5633. }
  5634. }
  5635. $receiptList [$key] ['verifyList'] = $verifyList;
  5636. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5637. 'where' => 'sid=' . $value ['staff'],
  5638. 'asArray' => true
  5639. ) );
  5640. $receiptList [$key] ['button'] = $button;
  5641. }
  5642. // print_r($receiptList);die;
  5643. // $data['verifyDetail']=$verifyDetail;
  5644. $mothHtml = "";
  5645. for($i = 1; $i <= 12; $i ++) {
  5646. if ($month == $i)
  5647. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5648. else
  5649. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5650. }
  5651. $data ['mothHtml'] = $mothHtml;
  5652. $data ['receiptList'] = $receiptList;
  5653. $data ['receiptApprovalCount'] = count ( $receiptList );
  5654. $data ['status'] = $status;
  5655. $data ['year'] = $year;
  5656. $data ['categoryList'] = $categoryList;
  5657. $data ['staffList'] = $staffList;
  5658. $data ['cid'] = $cid;
  5659. $data ['sid'] = $sid;
  5660. $data ['ap'] = $ap;
  5661. $data ['memu'] = "receipt";
  5662. $data ['staff'] = $this->staff;
  5663. $data ['receiptMemu'] = 'approval';
  5664. $data ['verifyId'] = $this->verifyId;
  5665. $data ['executeId'] = $this->executeId;
  5666. $this->render ( "/admin/saea_reportList", $data );
  5667. }
  5668. function approvalDetails() {
  5669. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5670. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5671. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5672. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5673. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5674. Doo::loadModel ( 'verify' );
  5675. $verify = new verify ();
  5676. Doo::loadModel ( 'receipt' );
  5677. $receipt = new receipt ();
  5678. Doo::loadModel ( 'staff' );
  5679. $staff = new staff ();
  5680. Doo::loadModel ( 'L_category' );
  5681. $Lcategory = new L_category ();
  5682. Doo::loadModel ( 'enclosur' );
  5683. $enclosur = new enclosur ();
  5684. $vidList = array ();
  5685. $verifyDetail = $verify->find ( array (
  5686. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5687. 'asArray' => true
  5688. ) );
  5689. foreach ( $verifyDetail as $key => $value ) {
  5690. array_push ( $vidList, $value ['vid'] );
  5691. }
  5692. $vid = implode ( ",", $vidList );
  5693. if (empty ( $verifyDetail ))
  5694. $vid = 0;
  5695. $categoryList = $Lcategory->find ( array (
  5696. 'asArray' => true
  5697. ) );
  5698. $staffList = $staff->find ( array (
  5699. 'where' => 'cid=' . $cid,
  5700. 'asArray' => true
  5701. ) );
  5702. $ap = 0;
  5703. $receiptList = $receipt->find ( array (
  5704. 'where' => 'rid =' . $rid,
  5705. 'desc' => 'rid',
  5706. 'asArray' => true
  5707. ) );
  5708. $Locate = 0;
  5709. $roleId = 0;
  5710. $button = 0;
  5711. foreach ( $receiptList as $key => $value ) {
  5712. $receiptList [$key] ['Locate'] = $Locate;
  5713. $Locate ++;
  5714. $receiptList [$key] ['reviseDetail'] = array ();
  5715. if (! empty ( $value ['reviseDetail'] ))
  5716. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5717. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5718. $categoryDetil = $Lcategory->getOne ( array (
  5719. 'where' => 'cid=' . $value ['cid'],
  5720. 'asArray' => true
  5721. ) );
  5722. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5723. // 检测编辑状态
  5724. $verifyList = $verify->getOne ( array (
  5725. 'where' => 'vid=' . $value ['verify'],
  5726. 'asArray' => true
  5727. ) );
  5728. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5729. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5730. Doo::loadModel ( 'role' );
  5731. $role = new role ();
  5732. // print_r($verifyList);
  5733. $flag = true;
  5734. $roleKey = 0;
  5735. $endStaffArray = array ();
  5736. $roleArrayCopy = array ();
  5737. foreach ( $verifyList as $k => $v ) {
  5738. // init verifyStaff
  5739. if ($v [1] == 'ROLE') {
  5740. if (! empty ( $verifyStaff )) {
  5741. $endStaffArray = end ( $verifyStaff );
  5742. if ($v [0] == $endStaffArray ['nextStaff']) {
  5743. $roleId = $v [0];
  5744. }
  5745. }
  5746. $roleVerify = json_decode ( $v [3], true );
  5747. $roleKey = $k;
  5748. $roleArray = array ();
  5749. $rolename = $role->getOne ( array (
  5750. 'where' => 'rid=' . $v [0],
  5751. 'asArray' => true
  5752. ) );
  5753. foreach ( $roleVerify as $o => $p ) {
  5754. $staffID = explode ( '_', $p );
  5755. $staffInfo = $staff->getOne ( array (
  5756. 'where' => 'sid=' . $staffID [0],
  5757. 'asArray' => true
  5758. ) );
  5759. // print_r($staffID);
  5760. $exp = array (
  5761. 0 => $staffInfo ['sid'],
  5762. 1 => $staffID [1],
  5763. 2 => $staffInfo ['avatar'],
  5764. 'date' => '',
  5765. 'date' => '',
  5766. 'opinion' => '',
  5767. 'status' => '',
  5768. 'rolename' => $rolename ['name']
  5769. );
  5770. array_push ( $roleArray, $exp );
  5771. }
  5772. $roleArrayCopy [$v [0]] = $roleArray;
  5773. // $verifyList[$k]['roleArray']=$roleArray;
  5774. }
  5775. // print_r($roleArray);
  5776. $verifyList [$k] ['date'] = "";
  5777. $verifyList [$k] ['opinion'] = "";
  5778. $verifyList [$k] ['status'] = "";
  5779. if (empty ( $verifyStaff )) {
  5780. $verifyList [$k] ['date'] = "";
  5781. $verifyList [$k] ['opinion'] = "";
  5782. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5783. $verifyList [$k] ['status'] = 4;
  5784. $button = 4;
  5785. $flag = false;
  5786. }
  5787. } else {
  5788. foreach ( $verifyStaff as $m => $u ) {
  5789. if ($v [0] == $m) {
  5790. $verifyList [$k] ['date'] = $u ['date'];
  5791. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5792. $verifyList [$k] ['status'] = $u ['status'];
  5793. $flag = false;
  5794. break;
  5795. }
  5796. }
  5797. $endStaffArray = end ( $verifyStaff );
  5798. if (isset ( $endStaffArray ['ROLE'] )) {
  5799. } else {
  5800. $endKey = key ( $verifyStaff );
  5801. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5802. $button = 4;
  5803. $verifyList [$k] ['status'] = 4;
  5804. }
  5805. }
  5806. }
  5807. }
  5808. $rolename ['name'] = '';
  5809. if (! empty ( $roleId )) {
  5810. Doo::loadModel ( 'role' );
  5811. $role = new role ();
  5812. $rolename = $role->getOne ( array (
  5813. 'where' => 'rid=' . $roleId,
  5814. 'asArray' => true
  5815. ) );
  5816. }
  5817. if (! empty ( $verifyStaff ))
  5818. $endStaffArray = end ( $verifyStaff );
  5819. $KOP = false;
  5820. foreach ( $roleArrayCopy as $P => $A ) {
  5821. foreach ( $A as $MKI => $AVL ) {
  5822. if (! empty ( $verifyStaff )) {
  5823. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5824. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5825. $button = 4;
  5826. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5827. }
  5828. foreach ( $verifyStaff as $m => $u ) {
  5829. $AVLFK = $AVL [0] . '_R';
  5830. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5831. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5832. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5833. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5834. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5835. break;
  5836. }
  5837. }
  5838. } else {
  5839. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5840. $button = 4;
  5841. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5842. }
  5843. }
  5844. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5845. $KOP = true;
  5846. }
  5847. }
  5848. foreach ( $roleArrayCopy as $k => $v ) {
  5849. foreach ( $verifyList as $m => $n ) {
  5850. if ($n [0] == $k) {
  5851. array_splice ( $verifyList, $m, 1, $v );
  5852. }
  5853. }
  5854. }
  5855. $receiptList [$key] ['verifyList'] = $verifyList;
  5856. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5857. 'where' => 'sid=' . $value ['staff'],
  5858. 'asArray' => true
  5859. ) );
  5860. $receiptList [$key] ['button'] = $button;
  5861. }
  5862. $mothHtml = "";
  5863. for($i = 1; $i <= 12; $i ++) {
  5864. if ($month == $i)
  5865. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5866. else
  5867. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5868. }
  5869. // 获取审批日志
  5870. Doo::loadModel ( 'receiptLog' );
  5871. $receiptLog = new receiptLog ();
  5872. $rlList = array ();
  5873. $rlInfo = $receiptLog->getOne ( array (
  5874. 'where' => 'rid=' . $rid . ' and status=4',
  5875. 'asArray' => true
  5876. ) );
  5877. $tijdate = $receiptLog->getOne ( array (
  5878. 'where' => 'rid=' . $rid . ' and status=2',
  5879. 'asc' => 'rlid',
  5880. 'asArray' => true
  5881. ) );
  5882. if (! empty ( $rlInfo )) {
  5883. $rlList = $receiptLog->find ( array (
  5884. 'where' => 'rid=' . $rid,
  5885. 'asc' => 'rlid',
  5886. 'asArray' => true
  5887. ) );
  5888. }
  5889. $receiptList [0] ['rlList'] = $rlList;
  5890. $enclosurList = $enclosur->find ( array (
  5891. 'where' => 'rid=' . $rid,
  5892. 'asArray' => true
  5893. ) );
  5894. $enclosurHtml = '';
  5895. foreach ( $enclosurList as $value ) {
  5896. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5897. }
  5898. $data ['enclosurHtml'] = $enclosurHtml;
  5899. $data ['rolename'] = $rolename ['name'];
  5900. $data ['datetij'] = $tijdate ['date'];
  5901. $data ['mothHtml'] = $mothHtml;
  5902. $data ['receiptList'] = $receiptList;
  5903. $data ['receiptApprovalCount'] = count ( $receiptList );
  5904. $data ['year'] = $year;
  5905. $data ['categoryList'] = $categoryList;
  5906. $data ['staffList'] = $staffList;
  5907. $data ['cid'] = $cid;
  5908. $data ['sid'] = $sid;
  5909. $data ['status'] = 0;
  5910. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  5911. $ap = 4;
  5912. } else
  5913. $data ['status'] = $receiptList [0] ['status'];
  5914. if ($receiptList [0] ['status'] == 4) {
  5915. $data ['status'] = 5;
  5916. $ap = 0;
  5917. }
  5918. $data ['ap'] = $ap;
  5919. $data ['memu'] = "receipt";
  5920. $data ['staff'] = $this->staff;
  5921. $data ['receiptMemu'] = 'approval';
  5922. $data ['verifyId'] = $this->verifyId;
  5923. $data ['executeId'] = $this->executeId;
  5924. $this->render ( "/admin/saeaReportListReport", $data );
  5925. }
  5926. function approvalEdi() {
  5927. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5928. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5929. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5930. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5931. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5932. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5933. if (empty ( $status ))
  5934. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5935. $vidList = array ();
  5936. $button = 0;
  5937. Doo::loadModel ( 'verify' );
  5938. Doo::loadModel ( 'receipt' );
  5939. Doo::loadModel ( 'staff' );
  5940. $staff = new staff ();
  5941. $receipt = new receipt ();
  5942. $verify = new verify ();
  5943. Doo::loadModel ( 'L_category' );
  5944. $Lcategory = new L_category ();
  5945. Doo::loadModel ( 'enclosur' );
  5946. $enclosur = new enclosur ();
  5947. // user verify ID
  5948. $verifyDetail = $verify->find ( array (
  5949. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5950. 'asArray' => true
  5951. ) );
  5952. foreach ( $verifyDetail as $key => $value ) {
  5953. array_push ( $vidList, $value ['vid'] );
  5954. }
  5955. $vid = implode ( ",", $vidList );
  5956. if (empty ( $verifyDetail ))
  5957. $vid = 0;
  5958. $categoryList = $Lcategory->find ( array (
  5959. 'asArray' => true
  5960. ) );
  5961. $staffList = $staff->find ( array (
  5962. 'where' => 'cid=' . $cid,
  5963. 'asArray' => true
  5964. ) );
  5965. $ap = "";
  5966. if ($status == 4) {
  5967. $ap = 4;
  5968. $status = 2;
  5969. }
  5970. // get Receipt By verifyID status 2
  5971. $receiptList = $receipt->find ( array (
  5972. 'where' => 'rid =' . $rid,
  5973. 'desc' => 'rid',
  5974. 'asArray' => true
  5975. ) );
  5976. $Locate = 0;
  5977. $roleId = 0;
  5978. if ($ap == 4)
  5979. $status = 4;
  5980. foreach ( $receiptList as $key => $value ) {
  5981. $receiptList [$key] ['Locate'] = $Locate;
  5982. $Locate ++;
  5983. $receiptList [$key] ['reviseDetail'] = array ();
  5984. if (! empty ( $value ['reviseDetail'] ))
  5985. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5986. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5987. $categoryDetil = $Lcategory->getOne ( array (
  5988. 'where' => 'cid=' . $value ['cid'],
  5989. 'asArray' => true
  5990. ) );
  5991. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5992. // 检测编辑状态
  5993. $verifyList = $verify->getOne ( array (
  5994. 'where' => 'vid=' . $value ['verify'],
  5995. 'asArray' => true
  5996. ) );
  5997. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5998. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5999. // print_r($verifyList);
  6000. //
  6001. // if (empty($verifyStaff)){
  6002. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6003. // $verifyList[0]['status']=4;$button=4;
  6004. // }
  6005. //
  6006. // }else{
  6007. //
  6008. // }
  6009. // die;
  6010. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  6011. // echo array_search("green",$a);
  6012. //
  6013. Doo::loadModel ( 'role' );
  6014. $role = new role ();
  6015. // print_r($verifyList);
  6016. $flag = true;
  6017. $roleKey = 0;
  6018. $endStaffArray = array ();
  6019. $roleArrayCopy = array ();
  6020. foreach ( $verifyList as $k => $v ) {
  6021. // init verifyStaff
  6022. if ($v [1] == 'ROLE') {
  6023. if (! empty ( $verifyStaff )) {
  6024. $endStaffArray = end ( $verifyStaff );
  6025. if ($v [0] == $endStaffArray ['nextStaff']) {
  6026. $roleId = $v [0];
  6027. }
  6028. }
  6029. $roleVerify = json_decode ( $v [3], true );
  6030. $roleKey = $k;
  6031. $roleArray = array ();
  6032. $rolename = $role->getOne ( array (
  6033. 'where' => 'rid=' . $v [0],
  6034. 'asArray' => true
  6035. ) );
  6036. foreach ( $roleVerify as $o => $p ) {
  6037. $staffID = explode ( '_', $p );
  6038. $staffInfo = $staff->getOne ( array (
  6039. 'where' => 'sid=' . $staffID [0],
  6040. 'asArray' => true
  6041. ) );
  6042. // print_r($staffID);
  6043. $exp = array (
  6044. 0 => $staffInfo ['sid'],
  6045. 1 => $staffID [1],
  6046. 2 => $staffInfo ['avatar'],
  6047. 'date' => '',
  6048. 'date' => '',
  6049. 'opinion' => '',
  6050. 'status' => '',
  6051. 'rolename' => $rolename ['name']
  6052. );
  6053. array_push ( $roleArray, $exp );
  6054. }
  6055. $roleArrayCopy [$v [0]] = $roleArray;
  6056. // $verifyList[$k]['roleArray']=$roleArray;
  6057. }
  6058. // print_r($roleArray);
  6059. $verifyList [$k] ['date'] = "";
  6060. $verifyList [$k] ['opinion'] = "";
  6061. $verifyList [$k] ['status'] = "";
  6062. if (empty ( $verifyStaff )) {
  6063. $verifyList [$k] ['date'] = "";
  6064. $verifyList [$k] ['opinion'] = "";
  6065. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6066. $verifyList [$k] ['status'] = 4;
  6067. $button = 4;
  6068. $flag = false;
  6069. }
  6070. } else {
  6071. foreach ( $verifyStaff as $m => $u ) {
  6072. if ($v [0] == $m) {
  6073. $verifyList [$k] ['date'] = $u ['date'];
  6074. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6075. $verifyList [$k] ['status'] = $u ['status'];
  6076. $flag = false;
  6077. break;
  6078. }
  6079. }
  6080. $endStaffArray = end ( $verifyStaff );
  6081. if (isset ( $endStaffArray ['ROLE'] )) {
  6082. } else {
  6083. $endKey = key ( $verifyStaff );
  6084. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6085. $button = 4;
  6086. $verifyList [$k] ['status'] = 4;
  6087. }
  6088. }
  6089. // print_r($endStaffArray);die;
  6090. // if (empty($verifyStaff)){
  6091. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6092. // $verifyList[$k]['status']=4;$button=4;
  6093. // }
  6094. //
  6095. // }else{
  6096. //
  6097. // }
  6098. // if($flag){//检测可编辑
  6099. // if($v[0]==$this->staff[0]['sid']){
  6100. // $verifyList[$k]['status']=4;$button=4;
  6101. // }
  6102. // }
  6103. }
  6104. }
  6105. $rolename ['name'] = '';
  6106. if (! empty ( $roleId )) {
  6107. Doo::loadModel ( 'role' );
  6108. $role = new role ();
  6109. $rolename = $role->getOne ( array (
  6110. 'where' => 'rid=' . $roleId,
  6111. 'asArray' => true
  6112. ) );
  6113. }
  6114. if (! empty ( $verifyStaff ))
  6115. $endStaffArray = end ( $verifyStaff );
  6116. $KOP = false;
  6117. foreach ( $roleArrayCopy as $P => $A ) {
  6118. foreach ( $A as $MKI => $AVL ) {
  6119. if (! empty ( $verifyStaff )) {
  6120. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6121. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6122. $button = 4;
  6123. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6124. }
  6125. foreach ( $verifyStaff as $m => $u ) {
  6126. $AVLFK = $AVL [0] . '_R';
  6127. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6128. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6129. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6130. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6131. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6132. break;
  6133. }
  6134. }
  6135. } else {
  6136. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6137. $button = 4;
  6138. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6139. }
  6140. }
  6141. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6142. $KOP = true;
  6143. }
  6144. }
  6145. // print_r($roleArrayCopy);
  6146. // echo $roleKey;
  6147. foreach ( $roleArrayCopy as $k => $v ) {
  6148. foreach ( $verifyList as $m => $n ) {
  6149. if ($n [0] == $k) {
  6150. array_splice ( $verifyList, $m, 1, $v );
  6151. }
  6152. }
  6153. }
  6154. // if ($KOP)
  6155. // array_splice($verifyList,$roleKey,1,$roleArray);
  6156. // print_r($verifyList);
  6157. $receiptList [$key] ['verifyList'] = $verifyList;
  6158. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6159. 'where' => 'sid=' . $value ['staff'],
  6160. 'asArray' => true
  6161. ) );
  6162. $receiptList [$key] ['button'] = $button;
  6163. }
  6164. // $data['verifyDetail']=$verifyDetail;
  6165. $mothHtml = "";
  6166. for($i = 1; $i <= 12; $i ++) {
  6167. if ($month == $i)
  6168. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6169. else
  6170. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6171. }
  6172. // 获取审批日志
  6173. Doo::loadModel ( 'receiptLog' );
  6174. $receiptLog = new receiptLog ();
  6175. $rlList = array ();
  6176. $rlInfo = $receiptLog->getOne ( array (
  6177. 'where' => 'rid=' . $rid . ' and status=4',
  6178. 'asArray' => true
  6179. ) );
  6180. $tijdate = $receiptLog->getOne ( array (
  6181. 'where' => 'rid=' . $rid . ' and status=2',
  6182. 'asc' => 'rlid',
  6183. 'asArray' => true
  6184. ) );
  6185. if (! empty ( $rlInfo )) {
  6186. $rlList = $receiptLog->find ( array (
  6187. 'where' => 'rid=' . $rid,
  6188. 'asc' => 'rlid',
  6189. 'asArray' => true
  6190. ) );
  6191. }
  6192. $receiptList [0] ['rlList'] = $rlList;
  6193. $enclosurList = $enclosur->find ( array (
  6194. 'where' => 'rid=' . $rid,
  6195. 'asArray' => true
  6196. ) );
  6197. $enclosurHtml = '';
  6198. foreach ( $enclosurList as $value ) {
  6199. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6200. }
  6201. $data ['enclosurHtml'] = $enclosurHtml;
  6202. $data ['rolename'] = $rolename ['name'];
  6203. $data ['datetij'] = $tijdate ['date'];
  6204. $data ['mothHtml'] = $mothHtml;
  6205. $data ['receiptList'] = $receiptList;
  6206. $data ['receiptApprovalCount'] = count ( $receiptList );
  6207. $data ['status'] = $status;
  6208. $data ['year'] = $year;
  6209. $data ['categoryList'] = $categoryList;
  6210. $data ['staffList'] = $staffList;
  6211. $data ['cid'] = $cid;
  6212. $data ['sid'] = $sid;
  6213. $data ['ap'] = $ap;
  6214. $data ['memu'] = "receipt";
  6215. $data ['staff'] = $this->staff;
  6216. $data ['receiptMemu'] = 'approval';
  6217. $data ['verifyId'] = $this->verifyId;
  6218. $data ['executeId'] = $this->executeId;
  6219. $this->render ( "/admin/saeaReportListReport", $data );
  6220. }
  6221. function remittanceHky() {
  6222. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6223. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  6224. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6225. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  6226. $page_size = 15;
  6227. $get = "?year=".$year."&moth=".$moth."&day=".$day;
  6228. Doo::loadModel ( 'receipt' );
  6229. $receipt = new receipt ();
  6230. Doo::loadModel ( 'staff' );
  6231. $staff = new staff ();
  6232. $dateCondition = " and Year(executeDate) =" . $year;
  6233. if ($moth != 'MONTH')
  6234. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  6235. if ($day != 'DAY'&&$moth != 'MONTH')
  6236. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  6237. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  6238. $table='(SELECT count(*) FROM CLD_receipt WHERE '.$sql.' group by executeDate ) a ';
  6239. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  6240. $limit = $pageinfo ['lower'] . ',' . $page_size;
  6241. $dayList = $receipt->find ( array (
  6242. 'select' => 'executeDate,sum(amount) as amount',
  6243. 'where' => $sql,
  6244. 'desc' => 'executeDate',
  6245. 'groupby' => 'executeDate',
  6246. 'limit' => $limit,
  6247. 'asArray' => true
  6248. ) );
  6249. //print_r($dayList);
  6250. foreach ( $dayList as $key => $value ) {
  6251. $remitString = "";
  6252. $receiptList = $receipt->find ( array (
  6253. 'select' => 'rid,executeDate,amount,staff,cid',
  6254. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'].'"',
  6255. 'desc' => 'executeDate',
  6256. 'asArray' => true
  6257. ) );
  6258. foreach ( $receiptList as $k => $v ) {
  6259. $sinfo = $staff->getOne ( array (
  6260. 'select' => 'username,category',
  6261. 'where' => ' sid=' . $v ['staff'],
  6262. 'asArray' => true
  6263. ) );
  6264. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  6265. }
  6266. $dayList [$key] ['staff'] = $remitString;
  6267. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  6268. }
  6269. //print_r($dayList);
  6270. $mothHtml = "";
  6271. for($i = 1; $i <= 12; $i ++) {
  6272. if ($moth == $i)
  6273. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6274. else
  6275. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6276. }
  6277. $dayHtml = "";
  6278. if ($day != "DAY" || $moth != "MONTH") {
  6279. for($i = 1; $i <= 31; $i ++) {
  6280. if ($day == $i)
  6281. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6282. else
  6283. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6284. }
  6285. }
  6286. $data ['page'] = $pageinfo;
  6287. $data ['year'] = $year;
  6288. $data ['moth'] = $moth;
  6289. $data ['day'] = $day;
  6290. $data ['get'] = $get;
  6291. $data ['dayHtml'] = $dayHtml;
  6292. $data ['mothHtml'] = $mothHtml;
  6293. $data ['receiptList'] = $dayList;
  6294. $data ['memu'] = "receipt";
  6295. $data ['staff'] = $this->staff;
  6296. $data ['receiptMemu'] = 'remittanceHky';
  6297. $data ['verifyId'] = $this->verifyId;
  6298. $data ['executeId'] = $this->executeId;
  6299. $this->render ( "/admin/remittanceHky", $data );
  6300. }
  6301. function remittancep(){
  6302. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  6303. Doo::loadModel ( 'receipt' );
  6304. $receipt = new receipt ();
  6305. Doo::loadModel ( 'staff' );
  6306. $staff = new staff ();
  6307. Doo::loadClass ( 'XDeode' );
  6308. $XDeode = new XDeode ( 5 );
  6309. $dateCondition=' and executeDate="'.date('Y-m-d', $timeStamp).'"';
  6310. $rplist = $receipt->find ( array (
  6311. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6312. 'asArray' => true
  6313. ) );
  6314. $dayList = $receipt->find ( array (
  6315. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6316. 'desc' => 'executeDate',
  6317. 'groupby' => 'staff',
  6318. 'asArray' => true
  6319. ) );
  6320. $html='';
  6321. foreach ( $dayList as $key => $value ) {
  6322. $sinfo = $staff->getOne ( array (
  6323. 'select' => 'username,category',
  6324. 'where' => ' sid=' . $value ['staff'],
  6325. 'asArray' => true
  6326. ) );
  6327. $html.='<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">'.$sinfo['category'].'-'.$sinfo['username'].'</th></tr></thead><tbody>
  6328. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  6329. $au=0;
  6330. foreach ($rplist as $k=>$v){
  6331. if ($value ['staff']==$v['staff']){
  6332. $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>';
  6333. $au+=$v['amount'];
  6334. }
  6335. }
  6336. $html.='<tr><td>合计</td><td class="taR"><b>¥'.$au.'</b></td></tr></tbody></table>';
  6337. }
  6338. $data ['html'] =$html;
  6339. $data ['memu'] = "receipt";
  6340. $data ['staff'] = $this->staff;
  6341. $data ['receiptMemu'] = 'remittanceHky';
  6342. $data ['verifyId'] = $this->verifyId;
  6343. $data ['executeId'] = $this->executeId;
  6344. $this->render ( "/admin/remittancep", $data );
  6345. }
  6346. function ajaxGetReceiptDetails(){
  6347. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  6348. Doo::loadClass ( 'XDeode' );
  6349. $XDeode = new XDeode ( 5 );
  6350. $rid=$XDeode->decode($rid);
  6351. if (empty ( $rid )) {
  6352. echo json_encode ( array (
  6353. 'status' => 2,
  6354. 'msg' => 'illegal request'
  6355. ) );
  6356. die ();
  6357. }
  6358. Doo::loadModel ( 'receipt' );
  6359. $receipt = new receipt ();
  6360. Doo::loadModel ( 'staff' );
  6361. $staff = new staff ();
  6362. $rinfo = $receipt->getOne ( array (
  6363. 'where' => 'rid= ' . $rid,
  6364. 'asArray' => true
  6365. ) );
  6366. $sinfo = $staff->getOne ( array (
  6367. 'select' => 'username,category',
  6368. 'where' => ' sid=' . $rinfo ['staff'],
  6369. 'asArray' => true
  6370. ) );
  6371. $rinfo['reviseDetail'] = array ();
  6372. if (! empty ( $rinfo ['reviseDetail'] ))
  6373. $rinfo['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  6374. $rinfo['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  6375. $rinfo['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  6376. $rinfo['category'] = $sinfo ['category'];
  6377. $verifyStaff=array();
  6378. if (!empty($rinfo ['verifyStaff']))
  6379. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  6380. $relust = $rinfo ['sum'] - $rinfo ['loanSum'];
  6381. $rinfo ['relust'] = $relust;
  6382. $rinfo['relustCN'] = $this->num_to_rmb ( $relust );
  6383. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  6384. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  6385. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  6386. // 费用执行人相关数据
  6387. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6388. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6389. foreach ( $executeCopy as $k => $v ) {
  6390. $executeCopy [$k] ['date'] = '';
  6391. $executeCopy [$k] ['opinion'] = '';
  6392. $executeCopy [$k] ['status'] = '';
  6393. if (! empty ( $executeStaff ))
  6394. foreach ( $executeStaff as $m => $u ) {
  6395. if ($v [0] == $m) {
  6396. $executeCopy [$k] ['date'] = $u ['date'];
  6397. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  6398. $executeCopy [$k] ['status'] = $u ['status'];
  6399. break;
  6400. }
  6401. }
  6402. }
  6403. $rinfo ['executeCopy'] = $executeCopy;
  6404. $html='<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  6405. if ($rinfo['Rtype']==1){//借款费用
  6406. $html.='<table class="table table-bordered table-condensed table-hover"><tbody>
  6407. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  6408. foreach ($rinfo['loanItem']['借款费用'] as $value){
  6409. $html.='<tr><th>'.$value['name'].'</th>
  6410. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6411. }
  6412. $html.='<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6413. <tr><th style="text-align:center" colspan="2">'.$rinfo['category'].'</th></tr>
  6414. <tr><th class="taC" colspan="2">费用说明</th>
  6415. </tr><tr><td colspan="2">'.$rinfo['explanation'].'</td></tr>
  6416. <tr class="warning"><td class="taR"><b>('.$rinfo['receiptOrder'].')本次费用合计</b></td>
  6417. <td class="taR"><b style="font-size:24px">¥'.$rinfo['loanSum'].'</b><br>'.$rinfo['loanSumCN'].'</td></tr>
  6418. </tbody></table>';
  6419. if ($rinfo['loanRid']!=0&&!empty($rinfo['accountItem'])){
  6420. $html.='<table class="table table-bordered table-condensed table-hover"><tbody>';
  6421. $html.='<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6422. foreach ($rinfo['accountItem']['日常相关费用'] as $value){
  6423. $html.='<tr><th>'.$value['name'].'</th>
  6424. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6425. }
  6426. $html.='<tr><th class="taR">合计</th>
  6427. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['agencySum'].'</td></tr>';
  6428. $html.='<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6429. foreach ($rinfo['accountItem']['差旅相关费用'] as $value){
  6430. $html.='<tr><th>'.$value['name'].'</th>
  6431. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6432. }
  6433. $html.='<tr><th class="taR">合计</th>
  6434. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['travelSum'].'</td></tr>';
  6435. $html.='<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6436. foreach ($rinfo['accountItem']['培训班费用'] as $value){
  6437. $html.='<tr><th>'.$value['name'].'</th>
  6438. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6439. }
  6440. $html.='<tr><th class="taR">合计</th>
  6441. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['trainSum'].'</td></tr>';
  6442. $html.='<tr><th colspan="2" class="taC">其他</th></tr>';
  6443. foreach ($rinfo['accountItem']['其他'] as $value){
  6444. $html.='<tr><th>'.$value['name'].'</th>
  6445. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6446. }
  6447. $html.='<tr><th class="taR">合计</th>
  6448. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['otherSum'].'</td></tr>';
  6449. $html.='<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6450. foreach ($rinfo['reviseDetail'] as $value){
  6451. $html.='<tr><th><span class="interval">|</span>'.$value['name'].':'.$value['description'].'</th>
  6452. <td class="taR">¥'.$value['price'].'</td></tr>';
  6453. }
  6454. $html.='<tr><th class="taR">合计</th>
  6455. <td class="colGreen taR">¥'.$rinfo['revisePrice'].'</td></tr>';
  6456. $html.='<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6457. <tr><th style="text-align:center" colspan="2">'.$rinfo['category'].'</th></tr>
  6458. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6459. <tr><td colspan="2">'.$rinfo['explanation'].'</td></tr>
  6460. <tr class="warning"><td class="taR"><b>('.$rinfo['receiptOrder'].')本次报销费用合计</b></td>
  6461. <td class="colGreed taR"><b style="font-size:24px">¥'.$rinfo['sum'].'</b><br>'.$rinfo['sumCN'].'</td></tr>
  6462. <tr';
  6463. if($rinfo['relust']>=0){
  6464. $html.='class="success"';
  6465. }else{
  6466. $html.='class="error"';
  6467. }
  6468. $html.='><td class="taR"><b>借款结余</b></td>
  6469. <td class="taR"><b style="font-size:24px">¥'.$rinfo['relust'].'</b><br>'.$rinfo['relustCN'].'</td></tr>
  6470. </tbody></table>
  6471. ';
  6472. }
  6473. }elseif ($rinfo['Rtype']==2){//对公汇款
  6474. $html.='<table class="table table-bordered table-condensed table-hover"><tbody>
  6475. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  6476. foreach ($rinfo['accountItem']['日常相关费用'] as $value){
  6477. $html.='<tr><th>'.$value['name'].'</th>
  6478. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6479. }
  6480. $html.='<tr><th class="taR">合计</th>
  6481. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['agencySum'].'</td></tr>';
  6482. $html.='<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6483. <tr><th style="text-align:center" colspan="2">'.$rinfo['category'].'</th></tr>
  6484. <tr><th class="taC" colspan="2">费用说明</th>
  6485. </tr><tr><td colspan="2">'.$rinfo['explanation'].'</td></tr>
  6486. <tr class="warning"><td class="taR"><b>('.$rinfo['receiptOrder'].')本次费用合计</b></td>
  6487. <td class="taR"><b style="font-size:24px">¥'.$rinfo['sum'].'</b><br>'.$rinfo['sumCN'].'</td></tr>
  6488. </tbody></table>';
  6489. }else{
  6490. $html.='<table class="table table-bordered table-condensed table-hover"><tbody>';
  6491. $html.='<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6492. foreach ($rinfo['accountItem']['日常相关费用'] as $value){
  6493. $html.='<tr><th>'.$value['name'].'</th>
  6494. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6495. }
  6496. $html.='<tr><th class="taR">合计</th>
  6497. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['agencySum'].'</td></tr>';
  6498. $html.='<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6499. foreach ($rinfo['accountItem']['差旅相关费用'] as $value){
  6500. $html.='<tr><th>'.$value['name'].'</th>
  6501. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6502. }
  6503. $html.='<tr><th class="taR">合计</th>
  6504. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['travelSum'].'</td></tr>';
  6505. $html.='<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6506. foreach ($rinfo['accountItem']['培训班费用'] as $value){
  6507. $html.='<tr><th>'.$value['name'].'</th>
  6508. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6509. }
  6510. $html.='<tr><th class="taR">合计</th>
  6511. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['trainSum'].'</td></tr>';
  6512. $html.='<tr><th colspan="2" class="taC">其他</th></tr>';
  6513. foreach ($rinfo['accountItem']['其他'] as $value){
  6514. $html.='<tr><th>'.$value['name'].'</th>
  6515. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6516. }
  6517. $html.='<tr><th class="taR">合计</th>
  6518. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['otherSum'].'</td></tr>';
  6519. $html.='<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6520. foreach ($rinfo['reviseDetail'] as $value){
  6521. $html.='<tr><th><span class="interval">|</span>'.$value['name'].':'.$value['description'].'</th>
  6522. <td class="taR">¥'.$value['price'].'</td></tr>';
  6523. }
  6524. $html.='<tr><th class="taR">合计</th>
  6525. <td class="colGreen taR">¥'.$rinfo['revisePrice'].'</td></tr>';
  6526. $html.='<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6527. <tr><th style="text-align:center" colspan="2">'.$rinfo['category'].'</th></tr>
  6528. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6529. <tr><td colspan="2">'.$rinfo['explanation'].'</td></tr>
  6530. <tr class="warning"><td class="taR"><b>('.$rinfo['receiptOrder'].')本次报销费用合计</b></td>
  6531. <td class="colGreed taR"><b style="font-size:24px">¥'.$rinfo['sum'].'</b><br>'.$rinfo['sumCN'].'</td></tr>';
  6532. $html.='</tbody></table>';
  6533. /*
  6534. <table class="table table-bordered table-condensed table-hover">
  6535. <tbody>
  6536. <tr><th colspan="2" class="taC">日常相关费用</th></tr>
  6537. <!-- loop receiptList' value.accountItem.日常相关费用 -->
  6538. <tr><th>{{receiptList' value' value.name}}</th><td width="140" class="taR">¥{{receiptList' value' value.price}}</td></tr>
  6539. <!-- endloop -->
  6540. <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptList' value.accountItem.cSum.agencySum}}</td></tr>
  6541. <tr><th colspan="2" class="taC">差旅相关费用</th></tr>
  6542. <!-- loop receiptDetail' value.accountItem.差旅相关费用 -->
  6543. <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr>
  6544. <!-- endloop -->
  6545. <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.travelSum}}</td></tr>
  6546. <tr><th colspan="2" class="taC">培训班费用</th></tr>
  6547. <!-- loop receiptDetail' value.accountItem.培训班费用 -->
  6548. <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr>
  6549. <!-- endloop -->
  6550. <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.trainSum}}</td></tr>
  6551. <tr><th colspan="2" class="taC">其他</th></tr>
  6552. <!-- loop receiptDetail' value.accountItem.其他 -->
  6553. <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr>
  6554. <!-- endloop -->
  6555. <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.otherSum}}</td></tr>
  6556. <tr><th colspan="2" class="taC">报销金额调整</th></tr>
  6557. <!-- loop receiptList' value.reviseDetail -->
  6558. <tr><th><span class="interval">|</span>{{receiptList' value' value.name}}:{{receiptList' value' value.description}}</th><td class="taR">¥{{receiptList' value' value.price}}</td></tr>
  6559. <!-- endloop -->
  6560. <tr><th class="taR">合计</th><td class="colOrange taR">¥{{receiptList' value.revisePrice}}</td></tr>
  6561. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6562. <tr><th style="text-align:center" colspan="2">{{receiptDetail' value.category}}</th></tr>
  6563. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6564. <tr><td colspan="2">{{receiptDetail' value.explanation}}</td></tr>
  6565. <tr class="warning"><td class="taR"><b>({{receiptDetail' value.receiptOrder}})本次报销费用合计</b></td>
  6566. <td class="colGreed taR"><b style="font-size:24px">¥{{receiptDetail' value.sum}}</b><br>{{receiptDetail' value.sumCN}}</td></tr>
  6567. </tbody>
  6568. </table>
  6569. */
  6570. }
  6571. //print_r($verifyStaff);die;
  6572. $html.='<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  6573. foreach ($verifyStaff as $key=>$value){
  6574. $key=trim(strtr($key,'_R',' '));
  6575. $sinfo = $staff->getOne ( array (
  6576. 'select' => 'username',
  6577. 'where' => ' sid=' . $key,
  6578. 'asArray' => true
  6579. ) );
  6580. $html.='<tr><td>'.$sinfo['username'].'</td><td>'.$value['opinion'].'</td></tr>';
  6581. }
  6582. $html.='</tbody></table>';
  6583. $html.='<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  6584. foreach ($rinfo['executeCopy'] as $value){
  6585. $html.='<tr><td>'.$value[1].'</td><td>'.$value['opinion'].'</td></tr>';
  6586. }
  6587. $html.='</tbody></table>';
  6588. $html.='<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  6589. <td width="140" class="taR"><b style="font-size:24px">¥'.$rinfo['amount'].'</b><br>'.$rinfo['amountCN'].'</td>
  6590. </tr></table>';
  6591. $html.='</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  6592. echo json_encode ( array (
  6593. 'status' => 1,
  6594. 'html' => $html
  6595. ) );
  6596. die;
  6597. }
  6598. function remittance() {
  6599. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6600. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6601. Doo::loadModel ( 'receipt' );
  6602. $receipt = new receipt ();
  6603. Doo::loadModel ( 'staff' );
  6604. $staff = new staff ();
  6605. $dateCondition = " and Year(pastDate) =" . $year;
  6606. if (! empty ( $month ))
  6607. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  6608. // get Receipt By verifyID status 1
  6609. $receiptList = $receipt->find ( array (
  6610. 'select' => 'sum(sum) as sum,staff,pastDate',
  6611. 'where' => ' status=1' . $dateCondition,
  6612. 'desc' => 'pastDate',
  6613. 'groupby' => 'staff,pastDate',
  6614. 'asArray' => true
  6615. ) );
  6616. $dateList = $receipt->find ( array (
  6617. 'select' => 'pastDate,verifyStaff',
  6618. 'where' => ' status=1' . $dateCondition,
  6619. 'desc' => 'pastDate',
  6620. 'groupby' => 'pastDate',
  6621. 'asArray' => true
  6622. ) );
  6623. $dataList = array ();
  6624. foreach ( $dateList as $d => $a ) {
  6625. $dataList [$a ['pastDate']] = array ();
  6626. $daySum = 0;
  6627. foreach ( $receiptList as $key => $value ) {
  6628. if ($a ['pastDate'] == $value ['pastDate']) {
  6629. $oderList = $receipt->find ( array (
  6630. 'select' => 'receiptOrder',
  6631. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  6632. 'asArray' => true
  6633. ) );
  6634. $list = array ();
  6635. $html = "";
  6636. foreach ( $oderList as $v ) {
  6637. array_push ( $list, $v ['receiptOrder'] );
  6638. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  6639. }
  6640. $receiptList [$key] ['receiptOrder'] = $html;
  6641. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  6642. $sinfo = $staff->getOne ( array (
  6643. 'select' => 'username ',
  6644. 'where' => ' sid=' . $value ['staff'],
  6645. 'asArray' => true
  6646. ) );
  6647. $receiptList [$key] ['username'] = $sinfo ['username'];
  6648. $daySum += $value ['sum'];
  6649. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  6650. }
  6651. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  6652. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  6653. }
  6654. }
  6655. // print_r($dataList);
  6656. $data ['dataList'] = $dataList;
  6657. $mothHtml = "";
  6658. for($i = 1; $i <= 12; $i ++) {
  6659. if ($month == $i)
  6660. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6661. else
  6662. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6663. }
  6664. $data ['year'] = $year;
  6665. $data ['mothHtml'] = $mothHtml;
  6666. $data ['memu'] = "receipt";
  6667. $data ['staff'] = $this->staff;
  6668. $data ['receiptMemu'] = 'approval';
  6669. $data ['verifyId'] = $this->verifyId;
  6670. $data ['executeId'] = $this->executeId;
  6671. $this->render ( "/admin/saeaReportListPay", $data );
  6672. }
  6673. function revocationAdjustment() {
  6674. $sid = isset ( $this->params ['sid'] ) && is_numeric ( $this->params ['sid'] ) ? $this->params ['sid'] : 0;
  6675. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  6676. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6677. // echo $price;die;
  6678. if ((! empty ( $sid )) && ($price != - 99999) && (! empty ( $rid ))) {
  6679. Doo::loadModel ( 'receipt' );
  6680. $receipt = new receipt ();
  6681. $receiptDetail = $receipt->getOne ( array (
  6682. 'where' => 'rid=' . $rid,
  6683. 'asArray' => true
  6684. ) );
  6685. if (empty ( $receiptDetail ['reviseDetail'] ))
  6686. return "/approval";
  6687. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  6688. $RD = array ();
  6689. foreach ( $reviseDetail as $key => $value ) {
  6690. if ($value ['price'] == $price && $value ['sid'] == $sid)
  6691. continue;
  6692. array_push ( $RD, $value );
  6693. }
  6694. $reviseDetailString = json_encode ( $RD );
  6695. $receipt->reviseDetail = $reviseDetailString;
  6696. $receipt->sum = $receiptDetail ['sum'] - $price;
  6697. $receipt->revisePrice = $receiptDetail ['revisePrice'] - $price;
  6698. $receipt->update ( array (
  6699. 'where' => 'rid=' . $rid
  6700. ) );
  6701. }
  6702. // approvalEdi/37
  6703. return "/approvalEdi/" . $rid;
  6704. }
  6705. function updateApprovalReceipt() {
  6706. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6707. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  6708. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6709. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  6710. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  6711. if (! empty ( $rid )) {
  6712. Doo::loadModel ( "verify" );
  6713. $verify = new verify ();
  6714. Doo::loadModel ( "receiptDetail" );
  6715. $receiptDetailObj = new receiptDetail ();
  6716. Doo::loadModel ( "itemStatistics" );
  6717. Doo::loadModel ( "statistics" );
  6718. $statistics = new statistics ();
  6719. $itemStatistics = new itemStatistics ();
  6720. Doo::loadModel ( "receipt" );
  6721. $receipt = new receipt ();
  6722. $receiptDetail = $receipt->getOne ( array (
  6723. 'where' => 'rid=' . $rid . ' and status=2 ',
  6724. 'asArray' => true
  6725. ) );
  6726. if (empty ( $receiptDetail ))
  6727. return "/approval";
  6728. $verifyDetail = $verify->getOne ( array (
  6729. 'where' => ' vid =' . $receiptDetail ['verify'],
  6730. 'asArray' => true
  6731. ) );
  6732. $verifyString = $verifyDetail ['staff'];
  6733. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  6734. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  6735. if (empty ( $opinion )) {
  6736. if ($status == 3)
  6737. $opinion = "终止";
  6738. else
  6739. $opinion = "同意支付";
  6740. }
  6741. $nowStaff = 0;
  6742. $nowStaffList = array ();
  6743. if (empty ( $verifyStaff )) {
  6744. // 还需加入是否已经进入角色审批
  6745. if ($verifyDetail [0] [1] == 'ROLE') {
  6746. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  6747. foreach ( $vStaffString as $key => $value ) {
  6748. $staffK = explode ( "_", $value );
  6749. if ($staffK [0] != $this->staff [0] ['sid'])
  6750. array_push ( $nowStaffList, $staffK [0] );
  6751. }
  6752. // print_r($verifyDetail);
  6753. // die;
  6754. if (! empty ( $nowStaffList )) {
  6755. $nowStaff = implode ( ',', $nowStaffList );
  6756. $verifyStaff = array (
  6757. $this->staff [0] ['sid'] . "_R" => array (
  6758. 'date' => date ( 'Y-m-d' ),
  6759. 'opinion' => $opinion,
  6760. 'status' => $status,
  6761. 'nextStaff' => $verifyDetail [0] [0],
  6762. 'ROLE' => 1
  6763. )
  6764. );
  6765. } else {
  6766. $nowStaff = $verifyDetail [1] [0];
  6767. $verifyStaff = array (
  6768. $this->staff [0] ['sid'] . "_R" => array (
  6769. 'date' => date ( 'Y-m-d' ),
  6770. 'opinion' => $opinion,
  6771. 'status' => $status,
  6772. 'nextStaff' => $verifyDetail [1] [0]
  6773. )
  6774. );
  6775. }
  6776. } else {
  6777. if ($verifyDetail [1] [1] == 'ROLE') {
  6778. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  6779. // echo "dd";
  6780. foreach ( $vStaffString as $key => $value ) {
  6781. $staffK = explode ( "_", $value );
  6782. array_push ( $nowStaffList, $staffK [0] );
  6783. }
  6784. $nowStaff = implode ( ',', $nowStaffList );
  6785. $verifyStaff = array (
  6786. $this->staff [0] ['sid'] => array (
  6787. 'date' => date ( 'Y-m-d' ),
  6788. 'opinion' => $opinion,
  6789. 'status' => $status,
  6790. 'nextStaff' => $verifyDetail [1] [0],
  6791. 'ROLE' => 1
  6792. )
  6793. );
  6794. } else {
  6795. $nowStaff = $verifyDetail [1] [0];
  6796. $verifyStaff = array (
  6797. $this->staff [0] ['sid'] => array (
  6798. 'date' => date ( 'Y-m-d' ),
  6799. 'opinion' => $opinion,
  6800. 'status' => $status,
  6801. 'nextStaff' => $verifyDetail [1] [0]
  6802. )
  6803. );
  6804. }
  6805. }
  6806. if ($status == 3)
  6807. $verifyStaff = array (
  6808. 'final' => $status,
  6809. $this->staff [0] ['sid'] => array (
  6810. 'date' => date ( 'Y-m-d' ),
  6811. 'opinion' => $opinion,
  6812. 'status' => $status
  6813. )
  6814. );
  6815. $vStaffString = json_encode ( $verifyStaff );
  6816. $receipt->nowStaff = $nowStaff;
  6817. $receipt->verifyStaff = $vStaffString;
  6818. } else {
  6819. $VS = end ( $verifyStaff );
  6820. // 非角色审批
  6821. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  6822. $nextStaff = 0;
  6823. $roleSTF = false;
  6824. foreach ( $verifyDetail as $key => $value ) {
  6825. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  6826. if (isset ( $verifyDetail [$key + 1] )) {
  6827. $nextStaff = $verifyDetail [$key + 1] [0];
  6828. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  6829. $roleSTF = true;
  6830. }
  6831. break;
  6832. }
  6833. }
  6834. if (! $roleSTF) {
  6835. $nowStaff = $nextStaff;
  6836. $verifyStaff [$this->staff [0] ['sid']] = array (
  6837. 'date' => date ( 'Y-m-d' ),
  6838. 'opinion' => $opinion,
  6839. 'status' => $status,
  6840. 'nextStaff' => $nextStaff
  6841. );
  6842. } else {
  6843. // 获取角色下的所有用户ID
  6844. $nowStaffList = array ();
  6845. foreach ( $verifyDetail as $vfk ) {
  6846. if ($vfk [1] == 'ROLE') {
  6847. $vStaffString = json_decode ( $vfk [3] );
  6848. foreach ( $vStaffString as $key => $value ) {
  6849. $staffK = explode ( "_", $value );
  6850. array_push ( $nowStaffList, $staffK [0] );
  6851. }
  6852. }
  6853. }
  6854. $nowStaff = implode ( ',', $nowStaffList );
  6855. $verifyStaff [$this->staff [0] ['sid']] = array (
  6856. 'date' => date ( 'Y-m-d' ),
  6857. 'opinion' => $opinion,
  6858. 'status' => $status,
  6859. 'nextStaff' => $nextStaff,
  6860. 'ROLE' => 0
  6861. );
  6862. }
  6863. if ($status == 3) {
  6864. $verifyStaff ['final'] = $status;
  6865. $verifyStaff [$this->staff [0] ['sid']] = array (
  6866. 'date' => date ( 'Y-m-d' ),
  6867. 'opinion' => $opinion,
  6868. 'status' => $status
  6869. );
  6870. }
  6871. $vStaffString = json_encode ( $verifyStaff );
  6872. $receipt->nowStaff = $nowStaff;
  6873. $receipt->verifyStaff = $vStaffString;
  6874. }
  6875. // 角色审批
  6876. if (isset ( $VS ['ROLE'] )) {
  6877. // 找出角色人 当前审批角色组
  6878. $verifyJSStaff = array ();
  6879. $nowStaffList2 = array ();
  6880. foreach ( $verifyDetail as $key => $value ) {
  6881. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  6882. $verifyJSStaff = json_decode ( $value [3] );
  6883. foreach ( $verifyJSStaff as $m ) {
  6884. $staffK = explode ( "_", $m );
  6885. array_push ( $nowStaffList2, $staffK [0] );
  6886. }
  6887. // print_r($nowStaffList2);
  6888. }
  6889. }
  6890. $RoleVerifyStaff = array ();
  6891. foreach ( $verifyStaff as $key => $value ) {
  6892. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  6893. foreach ( $nowStaffList2 as $m ) {
  6894. if ($key == $m . "_R")
  6895. $RoleVerifyStaff [$key] = $value;
  6896. }
  6897. }
  6898. }
  6899. // print_r($verifyStaff);
  6900. // print_r($nowStaffList2);
  6901. // print_r($RoleVerifyStaff);
  6902. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  6903. // print_r($verifyJSStaff);
  6904. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  6905. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  6906. // 下一个审批人ID
  6907. $nextStaff = 0;
  6908. $falg = false;
  6909. foreach ( $verifyDetail as $key => $value ) {
  6910. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  6911. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  6912. $falg = true;
  6913. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  6914. $nowStaffList = array ();
  6915. foreach ( $vStaffString as $v ) {
  6916. $staffK = explode ( "_", $v );
  6917. array_push ( $nowStaffList, $staffK [0] );
  6918. }
  6919. $nowStaff = implode ( ',', $nowStaffList );
  6920. $nextStaff = $verifyDetail [$key + 1] [0];
  6921. } elseif (isset ( $verifyDetail [$key + 1] )) {
  6922. $nextStaff = $verifyDetail [$key + 1] [0];
  6923. $nowStaff = $nextStaff;
  6924. } else
  6925. $nowStaff = '';
  6926. break;
  6927. }
  6928. }
  6929. if ($falg)
  6930. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6931. 'date' => date ( 'Y-m-d' ),
  6932. 'opinion' => $opinion,
  6933. 'status' => $status,
  6934. 'nextStaff' => $nextStaff,
  6935. 'ROLE' => 1
  6936. );
  6937. else
  6938. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6939. 'date' => date ( 'Y-m-d' ),
  6940. 'opinion' => $opinion,
  6941. 'status' => $status,
  6942. 'nextStaff' => $nextStaff
  6943. );
  6944. // print_r($verifyStaff);
  6945. // echo $nowStaff;die;
  6946. } else { // 进入下一个角色或者审批人
  6947. /*
  6948. *
  6949. */
  6950. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  6951. //
  6952. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  6953. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6954. 'date' => date ( 'Y-m-d' ),
  6955. 'opinion' => $opinion,
  6956. 'status' => $status,
  6957. 'nextStaff' => $VS ['nextStaff'],
  6958. 'ROLE' => 1
  6959. );
  6960. // print_r($verifyStaff);
  6961. // die;
  6962. }
  6963. if ($status == 3) {
  6964. $verifyStaff ['final'] = $status;
  6965. $verifyStaff [$this->staff [0] ['sid']] = array (
  6966. 'date' => date ( 'Y-m-d' ),
  6967. 'opinion' => $opinion,
  6968. 'status' => $status
  6969. );
  6970. }
  6971. $vStaffString = json_encode ( $verifyStaff );
  6972. $receipt->verifyStaff = $vStaffString;
  6973. $receipt->nowStaff = $nowStaff;
  6974. // die;
  6975. // }
  6976. // print_r($verifyStaff);
  6977. // die;
  6978. }
  6979. // print_r($verifyStaff);die;
  6980. }
  6981. // print_r($verifyDetail);
  6982. $roleKey = 0;
  6983. $roleId = 0;
  6984. $verifyDetailCopy = array ();
  6985. foreach ( $verifyDetail as $k => $v ) {
  6986. if ($v [1] == 'ROLE') {
  6987. $roleId = $v [0];
  6988. $roleVerify = json_decode ( $v [3], true );
  6989. $roleKey = $k;
  6990. $roleArray = array ();
  6991. foreach ( $roleVerify as $o => $p ) {
  6992. $staffID = explode ( '_', $p );
  6993. $exp = array (
  6994. 0 => $staffID [0],
  6995. 1 => $staffID [1]
  6996. );
  6997. array_push ( $roleArray, $exp );
  6998. }
  6999. $verifyDetailCopy [$v [0]] = $roleArray;
  7000. }
  7001. }
  7002. // print_r($verifyDetail);
  7003. foreach ( $verifyDetailCopy as $k => $v ) {
  7004. foreach ( $verifyDetail as $m => $n ) {
  7005. if ($n [0] == $k) {
  7006. array_splice ( $verifyDetail, $m, 1, $v );
  7007. }
  7008. }
  7009. }
  7010. // die;
  7011. // if (!empty($roleArray))
  7012. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  7013. // echo $roleId;
  7014. // print_r($verifyStaff);
  7015. // print_r($verifyDetail);
  7016. // die;
  7017. Doo::loadModel ( "receiptLog" );
  7018. $receiptLog = new receiptLog ();
  7019. // 审批日志
  7020. if (! isset ( $verifyStaff ['final'] )) {
  7021. if (! empty ( $roleId )) {
  7022. Doo::loadModel ( "role" );
  7023. $role = new role ();
  7024. $roleInfo = $role->getOne ( array (
  7025. 'where' => 'rid=' . $roleId,
  7026. 'asArray' => true
  7027. ) );
  7028. $receiptLog->rolename = $roleInfo ['name'];
  7029. }
  7030. $receiptLog->username = $this->staff [0] ['username'];
  7031. $receiptLog->uid = $this->staff [0] ['sid'];
  7032. $receiptLog->date = date ( "Y-m-d" );
  7033. $receiptLog->opinion = $opinion;
  7034. $receiptLog->img = $this->staff [0] ['avatar'];
  7035. $receiptLog->status = 1;
  7036. $receiptLog->rid = $rid;
  7037. $receiptLog->insert ();
  7038. }
  7039. if (isset ( $verifyStaff ['final'] )) { // rDetail
  7040. $receipt->verifyBreakup = $verifyString;
  7041. $receipt->status = 3;
  7042. $receiptDetailObj->status = 3;
  7043. $receiptDetailObj->update ( array (
  7044. 'where' => 'rid=' . $rid
  7045. ) );
  7046. if (! empty ( $roleId )) {
  7047. Doo::loadModel ( "role" );
  7048. $role = new role ();
  7049. $roleInfo = $role->getOne ( array (
  7050. 'where' => 'rid=' . $roleId,
  7051. 'asArray' => true
  7052. ) );
  7053. $receiptLog->rolename = $roleInfo ['name'];
  7054. }
  7055. $receiptLog->username = $this->staff [0] ['username'];
  7056. $receiptLog->uid = $this->staff [0] ['sid'];
  7057. $receiptLog->date = date ( "Y-m-d" );
  7058. $receiptLog->opinion = $opinion;
  7059. $receiptLog->img = $this->staff [0] ['avatar'];
  7060. $receiptLog->status = 3;
  7061. $receiptLog->rid = $rid;
  7062. $receiptLog->insert ();
  7063. // 微信企业号通知
  7064. $this->setWXMsg ( $rid, 3 );
  7065. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  7066. $receipt->status = 1;
  7067. $reviseSum = 0;
  7068. $receipt->verifyBreakup = $verifyString;
  7069. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  7070. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7071. foreach ( $reviseDetail as $key => $value ) {
  7072. $receiptDetailObj = new receiptDetail ();
  7073. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7074. $receiptDetailObj->item = $value ['description'];
  7075. $receiptDetailObj->itemCategory = "报销金额调整";
  7076. $receiptDetailObj->price = $value ['price'];
  7077. $receiptDetailObj->date = $receiptDetail ['date'];
  7078. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  7079. $receiptDetailObj->rid = $rid;
  7080. $receiptDetailObj->status = 1;
  7081. $receiptDetailObj->insert ();
  7082. $reviseSum += $value ['price'];
  7083. }
  7084. $itemStatistics = new itemStatistics ();
  7085. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7086. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7087. $itemStatistics->price = $reviseSum;
  7088. $itemStatistics->itemCategory = "报销金额调整";
  7089. $itemStatistics->date = $receiptDetail ['date'];
  7090. $itemStatistics->insert ();
  7091. }
  7092. $receiptDetailObj = new receiptDetail ();
  7093. $receiptDetailObj->status = 1;
  7094. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  7095. $receiptDetailObj->update ( array (
  7096. 'where' => 'rid=' . $rid
  7097. ) );
  7098. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7099. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7100. $stat = $statistics->getOne ( array (
  7101. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  7102. 'asArray' => true
  7103. ) );
  7104. if (empty ( $stat )) {
  7105. $statistics->date = $receiptDetail ['date'];
  7106. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7107. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7108. $statistics->agPrice = $receiptDetail ['sum'];
  7109. $statistics->rePrice = $reviseSum;
  7110. $statistics->insert ();
  7111. } else {
  7112. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  7113. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  7114. $statistics->update ( array (
  7115. 'where' => 'sid=' . $stat ['sid']
  7116. ) );
  7117. }
  7118. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7119. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7120. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  7121. foreach ( $accountItem ['cSum'] as $key => $value ) {
  7122. if ($key == "agencySum") {
  7123. $iStatistics = $itemStatistics->getOne ( array (
  7124. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  7125. 'asArray' => true
  7126. ) );
  7127. if (empty ( $iStatistics )) {
  7128. $itemStatistics->cid = $receiptDetail ['cid'];
  7129. ;
  7130. $itemStatistics->staff = $receiptDetail ['staff'];
  7131. $itemStatistics->price = $value;
  7132. $itemStatistics->itemCategory = $this->AGENCY;
  7133. $itemStatistics->date = $receiptDetail ['date'];
  7134. $itemStatistics->insert ();
  7135. } else {
  7136. if (! empty ( $value )) {
  7137. $itemStatistics->price = $value + $iStatistics ['price'];
  7138. $itemStatistics->update ( array (
  7139. 'where' => 'sid=' . $iStatistics ['sid']
  7140. ) );
  7141. }
  7142. }
  7143. } elseif ($key == "travelSum") {
  7144. $iStatistics = $itemStatistics->getOne ( array (
  7145. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  7146. 'asArray' => true
  7147. ) );
  7148. if (empty ( $iStatistics )) {
  7149. $itemStatistics->cid = $receiptDetail ['cid'];
  7150. $itemStatistics->staff = $receiptDetail ['staff'];
  7151. $itemStatistics->price = $value;
  7152. $itemStatistics->itemCategory = $this->TRAVEL;
  7153. $itemStatistics->date = $receiptDetail ['date'];
  7154. $itemStatistics->insert ();
  7155. } else {
  7156. if (! empty ( $value )) {
  7157. $itemStatistics->price = $value + $iStatistics ['price'];
  7158. $itemStatistics->update ( array (
  7159. 'where' => 'sid=' . $iStatistics ['sid']
  7160. ) );
  7161. }
  7162. }
  7163. } elseif ($key == "trainSum") {
  7164. $iStatistics = $itemStatistics->getOne ( array (
  7165. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  7166. 'asArray' => true
  7167. ) );
  7168. if (empty ( $iStatistics )) {
  7169. $itemStatistics->cid = $receiptDetail ['cid'];
  7170. $itemStatistics->staff = $receiptDetail ['staff'];
  7171. $itemStatistics->price = $value;
  7172. $itemStatistics->itemCategory = $this->TRAIN;
  7173. $itemStatistics->date = $receiptDetail ['date'];
  7174. $itemStatistics->insert ();
  7175. } else {
  7176. if (! empty ( $value )) {
  7177. $itemStatistics->price = $value + $iStatistics ['price'];
  7178. $itemStatistics->update ( array (
  7179. 'where' => 'sid=' . $iStatistics ['sid']
  7180. ) );
  7181. }
  7182. }
  7183. } elseif ($key == "otherSum") {
  7184. $iStatistics = $itemStatistics->getOne ( array (
  7185. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  7186. 'asArray' => true
  7187. ) );
  7188. if (empty ( $iStatistics )) {
  7189. $itemStatistics->cid = $receiptDetail ['cid'];
  7190. $itemStatistics->staff = $receiptDetail ['staff'];
  7191. $itemStatistics->price = $value;
  7192. $itemStatistics->itemCategory = $this->OTHER;
  7193. $itemStatistics->date = $receiptDetail ['date'];
  7194. $itemStatistics->insert ();
  7195. } else {
  7196. if (! empty ( $value )) {
  7197. $itemStatistics->price = $value + $iStatistics ['price'];
  7198. $itemStatistics->update ( array (
  7199. 'where' => 'sid=' . $iStatistics ['sid']
  7200. ) );
  7201. }
  7202. }
  7203. }
  7204. }
  7205. $receipt->pastDate = date ( "Y-m-d" );
  7206. // 微信企业号通知
  7207. $this->setWXMsg ( $rid, 1 );
  7208. }
  7209. $receipt->amount = $amount;
  7210. $receipt->update ( array (
  7211. 'where' => ' rid = ' . $rid
  7212. ) );
  7213. return "/approvalExpenses/2";
  7214. }
  7215. }
  7216. function expensesRetreats() {
  7217. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7218. if (! empty ( $rid )) {
  7219. // 操作记录
  7220. Doo::loadModel ( "receipt" );
  7221. $receipt = new receipt ();
  7222. Doo::loadModel ( "receiptLog" );
  7223. $receiptLog = new receiptLog ();
  7224. Doo::loadModel ( "verify" );
  7225. $verify = new verify ();
  7226. $receiptInfo = $receipt->getOne ( array (
  7227. 'where' => 'rid=' . $rid,
  7228. 'asArray' => true
  7229. ) );
  7230. $vr = $verify->getOne ( array (
  7231. 'where' => 'vid=' . $receiptInfo ['verify'],
  7232. 'asArray' => true
  7233. ) );
  7234. $jd = json_decode ( $vr ['staff'] );
  7235. $roleId = 0;
  7236. foreach ( $jd as $key => $value ) {
  7237. if ($value [1] == 'ROLE') {
  7238. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7239. if ($pos !== false) {
  7240. $roleId = $value [0];
  7241. }
  7242. }
  7243. }
  7244. // 审批日志
  7245. // echo $roleId;die;
  7246. if (! empty ( $roleId )) {
  7247. Doo::loadModel ( "role" );
  7248. $role = new role ();
  7249. $roleInfo = $role->getOne ( array (
  7250. 'where' => 'rid=' . $roleId,
  7251. 'asArray' => true
  7252. ) );
  7253. $receiptLog->rolename = $roleInfo ['name'];
  7254. }
  7255. $receiptLog->username = $this->staff [0] ['username'];
  7256. $receiptLog->uid = $this->staff [0] ['sid'];
  7257. $receiptLog->date = date ( "Y-m-d" );
  7258. $receiptLog->opinion = '撤回';
  7259. $receiptLog->img = $this->staff [0] ['avatar'];
  7260. $receiptLog->status = 4;
  7261. $receiptLog->rid = $rid;
  7262. $receiptLog->insert ();
  7263. $receipt->status = 4;
  7264. $receipt->update ( array (
  7265. 'where' => 'rid=' . $rid
  7266. ) );
  7267. // 微信企业号通知
  7268. $this->setWXMsg ( $rid, 2 );
  7269. }
  7270. // echo "ddd";
  7271. return '/approvalExpenses';
  7272. }
  7273. function updateCheReceipt() {
  7274. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7275. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7276. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  7277. if (! empty ( $rid )) {
  7278. // 操作记录
  7279. Doo::loadModel ( "receipt" );
  7280. $receipt = new receipt ();
  7281. Doo::loadModel ( "receiptLog" );
  7282. $receiptLog = new receiptLog ();
  7283. Doo::loadModel ( "verify" );
  7284. $verify = new verify ();
  7285. $receiptInfo = $receipt->getOne ( array (
  7286. 'where' => 'rid=' . $rid,
  7287. 'asArray' => true
  7288. ) );
  7289. $vr = $verify->getOne ( array (
  7290. 'where' => 'vid=' . $receiptInfo ['verify'],
  7291. 'asArray' => true
  7292. ) );
  7293. $jd = json_decode ( $vr ['staff'] );
  7294. $roleId = 0;
  7295. foreach ( $jd as $key => $value ) {
  7296. if ($value [1] == 'ROLE') {
  7297. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7298. if ($pos !== false) {
  7299. $roleId = $value [0];
  7300. }
  7301. }
  7302. }
  7303. // 审批日志
  7304. // echo $roleId;die;
  7305. if (! empty ( $roleId )) {
  7306. Doo::loadModel ( "role" );
  7307. $role = new role ();
  7308. $roleInfo = $role->getOne ( array (
  7309. 'where' => 'rid=' . $roleId,
  7310. 'asArray' => true
  7311. ) );
  7312. $receiptLog->rolename = $roleInfo ['name'];
  7313. }
  7314. $receiptLog->username = $this->staff [0] ['username'];
  7315. $receiptLog->uid = $this->staff [0] ['sid'];
  7316. $receiptLog->date = date ( "Y-m-d" );
  7317. $receiptLog->opinion = $opinion;
  7318. $receiptLog->img = $this->staff [0] ['avatar'];
  7319. $receiptLog->status = 4;
  7320. $receiptLog->rid = $rid;
  7321. $receiptLog->insert ();
  7322. $receipt->status = 4;
  7323. $receipt->update ( array (
  7324. 'where' => 'rid=' . $rid
  7325. ) );
  7326. // 微信企业号通知
  7327. $this->setWXMsg ( $rid, 2 );
  7328. echo json_encode ( array (
  7329. 'status' => 1
  7330. ) );
  7331. die ();
  7332. }
  7333. echo json_encode ( array (
  7334. 'status' => 2
  7335. ) );
  7336. die ();
  7337. // echo "ddd";
  7338. // return '/saeaBorad';
  7339. }
  7340. function revisePrice() {
  7341. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  7342. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  7343. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7344. // echo $price;die;
  7345. if (! empty ( $rid )) {
  7346. Doo::loadModel ( "receipt" );
  7347. $receipt = new receipt ();
  7348. $receiptDetail = $receipt->getOne ( array (
  7349. 'where' => 'rid=' . $rid . ' and status=2 ',
  7350. 'asArray' => true
  7351. ) );
  7352. if (empty ( $receiptDetail ))
  7353. return "/approval";
  7354. $reviseDetail = array ();
  7355. if (empty ( $receiptDetail ['reviseDetail'] )) {
  7356. array_push ( $reviseDetail, array (
  7357. 'sid' => $this->staff [0] ['sid'],
  7358. 'name' => $this->staff [0] ['username'],
  7359. 'description' => $description,
  7360. 'price' => $price
  7361. ) );
  7362. $reviseDetailString = json_encode ( $reviseDetail );
  7363. $receipt->reviseDetail = $reviseDetailString;
  7364. $receipt->revisePrice = $price;
  7365. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7366. } else {
  7367. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7368. array_push ( $reviseDetail, array (
  7369. 'sid' => $this->staff [0] ['sid'],
  7370. 'name' => $this->staff [0] ['username'],
  7371. 'description' => $description,
  7372. 'price' => $price
  7373. ) );
  7374. $reviseDetailString = json_encode ( $reviseDetail );
  7375. $receipt->reviseDetail = $reviseDetailString;
  7376. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  7377. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7378. }
  7379. $receipt->update ( array (
  7380. 'where' => 'rid=' . $rid
  7381. ) );
  7382. }
  7383. return '/approvalEdi/' . $rid;
  7384. }
  7385. function personalCollect() {
  7386. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7387. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  7388. $this->showCache ( $path );
  7389. Doo::loadModel ( "receiptDetail" );
  7390. Doo::loadModel ( "itemStatistics" );
  7391. Doo::loadModel ( 'statistics' );
  7392. $statistics = new statistics ();
  7393. $itemStatistics = new itemStatistics ();
  7394. $receiptDetail = new receiptDetail ();
  7395. $receiptCollectList = $receiptDetail->find ( array (
  7396. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7397. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7398. 'groupby' => 'itemCategory,Month(date)',
  7399. 'asArray' => true
  7400. ) );
  7401. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  7402. 'where' => 'staff=' . $this->staff [0] ['sid'],
  7403. 'asArray' => true
  7404. ) );
  7405. // create collect html
  7406. $collectArray = array (
  7407. '日常相关费用' => array (),
  7408. '差旅相关费用' => array (),
  7409. '培训班费用' => array (),
  7410. '其他' => array ()
  7411. );
  7412. $adjustment = array ();
  7413. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  7414. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7415. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  7416. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7417. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  7418. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7419. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  7420. array_push ( $collectArray ['其他'], $collectHtml );
  7421. $data ['collectArray'] = $collectArray;
  7422. // statistics html
  7423. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7424. if (empty ( $stList ))
  7425. $stList = array (
  7426. 'rePrice' => 0,
  7427. 'agPrice' => 0
  7428. );
  7429. $data ['stList'] = array (
  7430. 'rePrice' => $stList ['rePrice'],
  7431. 'agPrice' => $stList ['agPrice'],
  7432. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7433. );
  7434. // Adjustment price html
  7435. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7436. array_push ( $adjustment, $collectHtml );
  7437. $data ['adjustment'] = $adjustment;
  7438. // total price html
  7439. $collectHtml = "";
  7440. $total = 0;
  7441. for($i = 1; $i <= 12; $i ++) {
  7442. $sumPrice = 0;
  7443. foreach ( $receiptCollectList as $key => $value ) {
  7444. if ($value ['month'] == $i) {
  7445. $sumPrice += $value ['price'];
  7446. }
  7447. }
  7448. if ($sumPrice == 0)
  7449. $collectHtml .= '<td class="taR">-</td>';
  7450. else
  7451. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7452. $total += $sumPrice;
  7453. }
  7454. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7455. $data ['totalPrice'] = $collectHtml;
  7456. $data ['year'] = $year;
  7457. $data ['totalYear'] = $total;
  7458. $data ['memu'] = "receipt";
  7459. $data ['staff'] = $this->staff;
  7460. $data ['receiptMemu'] = 'personalCollect';
  7461. $data ['verifyId'] = $this->verifyId;
  7462. $data ['executeId'] = $this->executeId;
  7463. // year staff status 2,4
  7464. if ($year < date ( "Y" )) {
  7465. Doo::loadModel ( 'receipt' );
  7466. $receipt = new receipt ();
  7467. $receiptList = $receipt->find ( array (
  7468. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7469. 'asArray' => true
  7470. ) );
  7471. if (empty ( $receiptList )) {
  7472. ob_start ();
  7473. $this->render ( "/admin/saea_slist_collect", $data );
  7474. $this->cacheFile ( $path );
  7475. die ();
  7476. }
  7477. }
  7478. $this->render ( "/admin/saea_slist_collect", $data );
  7479. }
  7480. function personalCollectDetail() {
  7481. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7482. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  7483. $this->showCache ( $path );
  7484. Doo::loadModel ( "receiptDetail" );
  7485. Doo::loadModel ( "itemStatistics" );
  7486. Doo::loadModel ( 'statistics' );
  7487. Doo::loadModel ( 'accountItem' );
  7488. $accountItem = new accountItem ();
  7489. $statistics = new statistics ();
  7490. $itemStatistics = new itemStatistics ();
  7491. $receiptDetail = new receiptDetail ();
  7492. $receiptCollectList = $receiptDetail->find ( array (
  7493. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  7494. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7495. 'groupby' => 'item,Month(date)',
  7496. 'asArray' => true
  7497. ) );
  7498. $accountList = $accountItem->find ( array (
  7499. 'asArray' => true
  7500. ) );
  7501. // create CollectDetail HTML
  7502. $collectHtml = array ();
  7503. foreach ( $accountList as $key => $value ) {
  7504. $html = "";
  7505. $asum = 0;
  7506. for($i = 1; $i <= 12; $i ++) {
  7507. $falg = true;
  7508. foreach ( $receiptCollectList as $v ) {
  7509. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7510. $asum += $v ['price'];
  7511. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7512. $falg = false;
  7513. break;
  7514. }
  7515. }
  7516. if ($falg)
  7517. $html .= '<td class="taR">-</td>';
  7518. }
  7519. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7520. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7521. }
  7522. $data ['collectHtml'] = $collectHtml;
  7523. // create Adjustment price html
  7524. $receiptCollectList = $receiptDetail->find ( array (
  7525. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7526. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7527. 'groupby' => 'itemCategory,Month(date)',
  7528. 'asArray' => true
  7529. ) );
  7530. $adjustment = array ();
  7531. $collectArray = array (
  7532. '日常相关费用' => array (),
  7533. '差旅相关费用' => array (),
  7534. '培训班费用' => array (),
  7535. '其他' => array ()
  7536. );
  7537. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7538. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7539. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7540. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7541. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7542. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7543. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7544. array_push ( $collectArray ['其他'], $collectHtml );
  7545. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7546. array_push ( $adjustment, $collectHtml );
  7547. // total price html
  7548. $collectHtml = "";
  7549. $total = 0;
  7550. for($i = 1; $i <= 12; $i ++) {
  7551. $sumPrice = 0;
  7552. foreach ( $receiptCollectList as $key => $value ) {
  7553. if ($value ['month'] == $i) {
  7554. $sumPrice += $value ['price'];
  7555. }
  7556. }
  7557. if ($sumPrice == 0)
  7558. $collectHtml .= '<td class="taR">-</td>';
  7559. else
  7560. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7561. $total += $sumPrice;
  7562. }
  7563. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7564. // statistics html
  7565. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7566. if (empty ( $stList ))
  7567. $stList = array (
  7568. 'rePrice' => 0,
  7569. 'agPrice' => 0
  7570. );
  7571. $data ['stList'] = array (
  7572. 'rePrice' => $stList ['rePrice'],
  7573. 'agPrice' => $stList ['agPrice'],
  7574. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7575. );
  7576. $data ['collectArray'] = $collectArray;
  7577. $data ['adjustment'] = $adjustment;
  7578. $data ['totalPrice'] = $collectHtml;
  7579. $data ['totalYear'] = $total;
  7580. $data ['year'] = $year;
  7581. $data ['memu'] = "receipt";
  7582. $data ['staff'] = $this->staff;
  7583. $data ['receiptMemu'] = 'personalCollect';
  7584. $data ['verifyId'] = $this->verifyId;
  7585. $data ['executeId'] = $this->executeId;
  7586. // year staff status 2,4
  7587. if ($year < date ( "Y" )) {
  7588. Doo::loadModel ( 'receipt' );
  7589. $receipt = new receipt ();
  7590. $receiptList = $receipt->find ( array (
  7591. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7592. 'asArray' => true
  7593. ) );
  7594. if (empty ( $receiptList )) {
  7595. ob_start ();
  7596. $this->render ( "/admin/saeaCollectArticles", $data );
  7597. $this->cacheFile ( $path );
  7598. die ();
  7599. }
  7600. }
  7601. $this->render ( "/admin/saeaCollectArticles", $data );
  7602. }
  7603. function companyCategoryCollect() {
  7604. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7605. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  7606. $this->showCache ( $path );
  7607. Doo::loadModel ( 'L_category' );
  7608. Doo::loadModel ( 'itemStatistics' );
  7609. Doo::loadModel ( 'statistics' );
  7610. $statistics = new statistics ();
  7611. $Lcategory = new L_category ();
  7612. $itemStatistics = new itemStatistics ();
  7613. $LcategoryList = $Lcategory->find ( array (
  7614. 'asArray' => true
  7615. ) ); // 'staff='.$this->staff[0]['sid']." and
  7616. $itemStatisticsList = $itemStatistics->find ( array (
  7617. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7618. 'where' => " Year(date)=" . $year,
  7619. 'groupby' => 'cid,Month(date)',
  7620. 'asArray' => true
  7621. ) );
  7622. // ceatre companyCollectHtml
  7623. foreach ( $LcategoryList as $value ) {
  7624. $html = "";
  7625. $asum = 0;
  7626. for($i = 1; $i <= 12; $i ++) {
  7627. $falg = true;
  7628. foreach ( $itemStatisticsList as $v ) {
  7629. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  7630. $asum += $v ['price'];
  7631. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7632. $falg = false;
  7633. break;
  7634. }
  7635. }
  7636. if ($falg)
  7637. $html .= '<td class="taR">-</td>';
  7638. }
  7639. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7640. $collectHtml [$value ['title']] = array (
  7641. 'html' => $html,
  7642. 'cid' => $value ['cid']
  7643. );
  7644. }
  7645. $data ['companyHtml'] = $collectHtml;
  7646. // total price html
  7647. $collectHtml = "";
  7648. $total = 0;
  7649. for($i = 1; $i <= 12; $i ++) {
  7650. $sumPrice = 0;
  7651. foreach ( $itemStatisticsList as $key => $value ) {
  7652. if ($value ['month'] == $i) {
  7653. $sumPrice += $value ['price'];
  7654. }
  7655. }
  7656. if ($sumPrice == 0)
  7657. $collectHtml .= '<td class="taR">-</td>';
  7658. else
  7659. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7660. $total += $sumPrice;
  7661. }
  7662. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7663. $data ['companyTotalHtml'] = $collectHtml;
  7664. $data ['total'] = $total;
  7665. // statistics html
  7666. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7667. if (empty ( $stList ))
  7668. $stList = array (
  7669. 'rePrice' => 0,
  7670. 'agPrice' => 0
  7671. );
  7672. $data ['stList'] = array (
  7673. 'rePrice' => $stList ['rePrice'],
  7674. 'agPrice' => $stList ['agPrice'],
  7675. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7676. );
  7677. $data ['year'] = $year;
  7678. $data ['memu'] = "receipt";
  7679. $data ['staff'] = $this->staff;
  7680. $data ['receiptMemu'] = 'companyCategoryCollect';
  7681. $data ['verifyId'] = $this->verifyId;
  7682. $data ['executeId'] = $this->executeId;
  7683. // year staff status 2,4
  7684. if ($year < date ( "Y" )) {
  7685. Doo::loadModel ( 'receipt' );
  7686. $receipt = new receipt ();
  7687. $receiptList = $receipt->find ( array (
  7688. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  7689. 'asArray' => true
  7690. ) );
  7691. if (empty ( $receiptList )) {
  7692. ob_start ();
  7693. $this->render ( "/admin/saeaCompanyCollect", $data );
  7694. $this->cacheFile ( $path );
  7695. die ();
  7696. }
  7697. }
  7698. $this->render ( "/admin/saeaCompanyCollect", $data );
  7699. }
  7700. function categoryCollectDetail() {
  7701. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7702. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  7703. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  7704. $this->showCache ( $path );
  7705. Doo::loadModel ( 'statistics' );
  7706. $statistics = new statistics ();
  7707. Doo::loadModel ( "receiptDetail" );
  7708. $receiptDetail = new receiptDetail ();
  7709. Doo::loadModel ( 'L_category' );
  7710. $Lcategory = new L_category ();
  7711. Doo::loadModel ( 'accountItem' );
  7712. $accountItem = new accountItem ();
  7713. $LcategoryList = $Lcategory->find ( array (
  7714. 'asArray' => true
  7715. ) );
  7716. if ($cid == 0) {
  7717. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7718. if ($cid == 0)
  7719. $cid = $LcategoryList [0] ['cid'];
  7720. }
  7721. $data ['LcategoryList'] = $LcategoryList;
  7722. $receiptCollectList = $receiptDetail->find ( array (
  7723. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  7724. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7725. 'groupby' => 'item,Month(pastDate)',
  7726. 'asArray' => true
  7727. ) );
  7728. $accountList = $accountItem->find ( array (
  7729. 'asArray' => true
  7730. ) );
  7731. // create CollectDetail HTML
  7732. $collectHtml = array ();
  7733. foreach ( $accountList as $key => $value ) {
  7734. $html = "";
  7735. $asum = 0;
  7736. for($i = 1; $i <= 12; $i ++) {
  7737. $falg = true;
  7738. foreach ( $receiptCollectList as $v ) {
  7739. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7740. $asum += $v ['price'];
  7741. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7742. $falg = false;
  7743. break;
  7744. }
  7745. }
  7746. if ($falg)
  7747. $html .= '<td class="taR">-</td>';
  7748. }
  7749. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7750. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7751. }
  7752. $data ['collectHtml'] = $collectHtml;
  7753. // create Adjustment price html
  7754. $receiptCollectList = $receiptDetail->find ( array (
  7755. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  7756. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7757. 'groupby' => 'itemCategory,Month(pastDate)',
  7758. 'asArray' => true
  7759. ) );
  7760. $adjustment = array ();
  7761. $collectArray = array (
  7762. '日常相关费用' => array (),
  7763. '差旅相关费用' => array (),
  7764. '培训班费用' => array (),
  7765. '其他' => array ()
  7766. );
  7767. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7768. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7769. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7770. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7771. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7772. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7773. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7774. array_push ( $collectArray ['其他'], $collectHtml );
  7775. $data ['collectArray'] = $collectArray;
  7776. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7777. array_push ( $adjustment, $collectHtml );
  7778. $data ['adjustment'] = $adjustment;
  7779. // total price html
  7780. $collectHtml = "";
  7781. $total = 0;
  7782. for($i = 1; $i <= 12; $i ++) {
  7783. $sumPrice = 0;
  7784. foreach ( $receiptCollectList as $key => $value ) {
  7785. if ($value ['month'] == $i) {
  7786. $sumPrice += $value ['price'];
  7787. }
  7788. }
  7789. if ($sumPrice == 0)
  7790. $collectHtml .= '<td class="taR">-</td>';
  7791. else
  7792. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7793. $total += $sumPrice;
  7794. }
  7795. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7796. // statistics html
  7797. $stList = $statistics->statisticsByCid ( $year, $cid );
  7798. if (empty ( $stList ))
  7799. $stList = array (
  7800. 'rePrice' => 0,
  7801. 'agPrice' => 0
  7802. );
  7803. $data ['stList'] = array (
  7804. 'rePrice' => $stList ['rePrice'],
  7805. 'agPrice' => $stList ['agPrice'],
  7806. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7807. );
  7808. $data ['totalYear'] = $total;
  7809. $data ['year'] = $year;
  7810. $data ['cid'] = $cid;
  7811. $data ['memu'] = "receipt";
  7812. $data ['staff'] = $this->staff;
  7813. $data ['receiptMemu'] = 'companyCategoryCollect';
  7814. $data ['verifyId'] = $this->verifyId;
  7815. $data ['executeId'] = $this->executeId;
  7816. // year staff status 2,4
  7817. if ($year < date ( "Y" )) {
  7818. Doo::loadModel ( 'receipt' );
  7819. $receipt = new receipt ();
  7820. $receiptList = $receipt->find ( array (
  7821. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  7822. 'asArray' => true
  7823. ) );
  7824. if (empty ( $receiptList )) {
  7825. ob_start ();
  7826. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7827. $this->cacheFile ( $path );
  7828. die ();
  7829. }
  7830. }
  7831. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7832. }
  7833. function staffCollect() {
  7834. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7835. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  7836. // $this->showCache($path);
  7837. Doo::loadModel ( 'statistics' );
  7838. $statistics = new statistics ();
  7839. Doo::loadModel ( "receiptDetail" );
  7840. $receiptDetail = new receiptDetail ();
  7841. Doo::loadModel ( 'L_category' );
  7842. $Lcategory = new L_category ();
  7843. Doo::loadModel ( 'accountItem' );
  7844. $accountItem = new accountItem ();
  7845. Doo::loadModel ( 'staff' );
  7846. $staff = new staff ();
  7847. Doo::loadModel ( 'itemStatistics' );
  7848. $itemStatistics = new itemStatistics ();
  7849. /*
  7850. * $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']));
  7851. */
  7852. // statistics html
  7853. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7854. if (empty ( $stList ))
  7855. $stList = array (
  7856. 'rePrice' => 0,
  7857. 'agPrice' => 0
  7858. );
  7859. $data ['stList'] = array (
  7860. 'rePrice' => $stList ['rePrice'],
  7861. 'agPrice' => $stList ['agPrice'],
  7862. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7863. );
  7864. // ---
  7865. $staffList = $staff->find ( array (
  7866. 'where' => 'username !="admin"',
  7867. 'asArray' => true
  7868. ) );
  7869. $LcategoryList = $Lcategory->find ( array (
  7870. 'asArray' => true
  7871. ) ); // 'staff='.$this->staff[0]['sid']." and
  7872. $itemStatisticsList = $itemStatistics->find ( array (
  7873. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7874. 'where' => " Year(date)=" . $year,
  7875. 'groupby' => 'staff,Month(date)',
  7876. 'asArray' => true
  7877. ) );
  7878. $categoryList = $staff->find ( array (
  7879. 'select' => 'COUNT(*) as count,cid,category',
  7880. 'where' => 'username !="admin"',
  7881. 'groupby' => 'cid',
  7882. 'asArray' => true
  7883. ) );
  7884. // print_r($itemStatisticsList);die;
  7885. // ceatre companyCollectHtml
  7886. foreach ( $categoryList as $vlu ) {
  7887. $count = $vlu ['count'] + 1;
  7888. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  7889. $m1 = 0;
  7890. $m2 = 0;
  7891. $m3 = 0;
  7892. $m4 = 0;
  7893. $m5 = 0;
  7894. $m6 = 0;
  7895. $m7 = 0;
  7896. $m8 = 0;
  7897. $m9 = 0;
  7898. $m10 = 0;
  7899. $m11 = 0;
  7900. $m12 = 0;
  7901. $m13 = 0;
  7902. foreach ( $staffList as $value ) {
  7903. if ($vlu ['cid'] == $value ['cid']) {
  7904. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  7905. $asum = 0;
  7906. for($i = 1; $i <= 12; $i ++) {
  7907. $falg = true;
  7908. foreach ( $itemStatisticsList as $v ) {
  7909. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  7910. if ($v ['month'] == 1)
  7911. $m1 += $v ['price'];
  7912. if ($v ['month'] == 2)
  7913. $m2 += $v ['price'];
  7914. if ($v ['month'] == 3)
  7915. $m3 += $v ['price'];
  7916. if ($v ['month'] == 4)
  7917. $m4 += $v ['price'];
  7918. if ($v ['month'] == 5)
  7919. $m5 += $v ['price'];
  7920. if ($v ['month'] == 6)
  7921. $m6 += $v ['price'];
  7922. if ($v ['month'] == 7)
  7923. $m7 += $v ['price'];
  7924. if ($v ['month'] == 8)
  7925. $m8 += $v ['price'];
  7926. if ($v ['month'] == 9)
  7927. $m9 += $v ['price'];
  7928. if ($v ['month'] == 10)
  7929. $m10 += $v ['price'];
  7930. if ($v ['month'] == 11)
  7931. $m11 += $v ['price'];
  7932. if ($v ['month'] == 12)
  7933. $m12 += $v ['price'];
  7934. $asum += $v ['price'];
  7935. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7936. $falg = false;
  7937. break;
  7938. }
  7939. }
  7940. if ($falg)
  7941. $html .= '<td class="taR">-</td>';
  7942. }
  7943. $m13 += $asum;
  7944. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7945. $collectHtml [$value ['username']] = array (
  7946. 'html' => $html,
  7947. 'sid' => $value ['sid']
  7948. );
  7949. $html = "";
  7950. }
  7951. }
  7952. $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>
  7953. <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>
  7954. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  7955. $collectHtml [$vlu ['cid']] = array (
  7956. 'html' => $hl,
  7957. 'sid' => ''
  7958. );
  7959. }
  7960. $data ['companyHtml'] = $collectHtml;
  7961. // total price html
  7962. $collectHtml = "";
  7963. $total = 0;
  7964. for($i = 1; $i <= 12; $i ++) {
  7965. $sumPrice = 0;
  7966. foreach ( $itemStatisticsList as $key => $value ) {
  7967. if ($value ['month'] == $i) {
  7968. $sumPrice += $value ['price'];
  7969. }
  7970. }
  7971. if ($sumPrice == 0)
  7972. $collectHtml .= '<td class="taR">-</td>';
  7973. else
  7974. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7975. $total += $sumPrice;
  7976. }
  7977. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7978. $data ['companyTotalHtml'] = $collectHtml;
  7979. $data ['total'] = $total;
  7980. $data ['year'] = $year;
  7981. $data ['memu'] = "receipt";
  7982. $data ['staff'] = $this->staff;
  7983. $data ['receiptMemu'] = 'companyCategoryCollect';
  7984. $data ['verifyId'] = $this->verifyId;
  7985. $data ['executeId'] = $this->executeId;
  7986. if ($year <= date ( "Y" )) {
  7987. Doo::loadModel ( 'receipt' );
  7988. $receipt = new receipt ();
  7989. $receiptList = $receipt->find ( array (
  7990. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  7991. 'asArray' => true
  7992. ) );
  7993. if (empty ( $receiptList )) { // generated files
  7994. ob_start ();
  7995. $this->render ( "/admin/saeaStaffCollectB", $data );
  7996. $this->cacheFile ( $path );
  7997. die ();
  7998. }
  7999. }
  8000. $this->render ( "/admin/saeaStaffCollectB", $data );
  8001. }
  8002. function staffCollectBak() {
  8003. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8004. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  8005. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  8006. $this->showCache ( $path );
  8007. Doo::loadModel ( 'statistics' );
  8008. $statistics = new statistics ();
  8009. Doo::loadModel ( "receiptDetail" );
  8010. $receiptDetail = new receiptDetail ();
  8011. Doo::loadModel ( 'L_category' );
  8012. $Lcategory = new L_category ();
  8013. Doo::loadModel ( 'accountItem' );
  8014. $accountItem = new accountItem ();
  8015. Doo::loadModel ( 'staff' );
  8016. $staff = new staff ();
  8017. Doo::loadModel ( 'itemStatistics' );
  8018. $itemStatistics = new itemStatistics ();
  8019. $itemStatisticsList = $itemStatistics->find ( array (
  8020. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8021. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8022. 'groupby' => 'staff,itemCategory,Month(date)',
  8023. 'asArray' => true
  8024. ) );
  8025. $itemCategoryList = $itemStatistics->find ( array (
  8026. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8027. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8028. 'groupby' => 'cid,itemCategory,Month(date)',
  8029. 'asArray' => true
  8030. ) );
  8031. $LcategoryList = $Lcategory->find ( array (
  8032. 'asArray' => true
  8033. ) );
  8034. $staffList = $staff->find ( array (
  8035. 'asArray' => true
  8036. ) );
  8037. $htmlArray = array ();
  8038. foreach ( $LcategoryList as $value ) {
  8039. $htmlArray [$value ['title']] = array ();
  8040. foreach ( $staffList as $v ) {
  8041. if ($value ['cid'] == $v ['cid']) {
  8042. $html = "";
  8043. $falg = true;
  8044. $staffSumPrice = 0;
  8045. foreach ( $itemStatisticsList as $a ) {
  8046. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  8047. if (empty ( $a ['price'] )) {
  8048. $html .= '<td class="taR">-</td>';
  8049. $falg = false;
  8050. break;
  8051. } else {
  8052. $staffSumPrice += $a ['price'];
  8053. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8054. $falg = false;
  8055. break;
  8056. }
  8057. }
  8058. }
  8059. if ($falg) {
  8060. $html .= '<td class="taR">-</td>';
  8061. $falg = true;
  8062. }
  8063. $falg = true;
  8064. foreach ( $itemStatisticsList as $a ) {
  8065. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  8066. if (empty ( $a ['price'] )) {
  8067. $html .= '<td class="taR">-</td>';
  8068. $falg = false;
  8069. break;
  8070. } else {
  8071. $staffSumPrice += $a ['price'];
  8072. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8073. $falg = false;
  8074. break;
  8075. }
  8076. }
  8077. }
  8078. if ($falg) {
  8079. $html .= '<td class="taR">-</td>';
  8080. $falg = true;
  8081. }
  8082. $falg = true;
  8083. foreach ( $itemStatisticsList as $a ) {
  8084. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  8085. if (empty ( $a ['price'] )) {
  8086. $html .= '<td class="taR">-</td>';
  8087. $falg = false;
  8088. break;
  8089. } else {
  8090. $staffSumPrice += $a ['price'];
  8091. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8092. $falg = false;
  8093. break;
  8094. }
  8095. }
  8096. }
  8097. if ($falg) {
  8098. $html .= '<td class="taR">-</td>';
  8099. $falg = true;
  8100. }
  8101. $falg = true;
  8102. foreach ( $itemStatisticsList as $a ) {
  8103. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  8104. if (! empty ( $a ['price'] )) {
  8105. $staffSumPrice += $a ['price'];
  8106. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8107. $falg = false;
  8108. break;
  8109. } else {
  8110. $html .= '<td class="taR">-</td>';
  8111. $falg = false;
  8112. break;
  8113. }
  8114. }
  8115. }
  8116. if ($falg) {
  8117. $html .= '<td class="taR">-</td>';
  8118. $falg = true;
  8119. }
  8120. $falg = true;
  8121. foreach ( $itemStatisticsList as $a ) {
  8122. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  8123. if (! empty ( $a ['price'] )) {
  8124. $staffSumPrice += $a ['price'];
  8125. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8126. $falg = false;
  8127. break;
  8128. } else {
  8129. $html .= '<td class="taR">-</td>';
  8130. $falg = false;
  8131. break;
  8132. }
  8133. }
  8134. }
  8135. if ($falg) {
  8136. $html .= '<td class="taR">-</td>';
  8137. $falg = true;
  8138. }
  8139. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  8140. $htmlArray [$value ['title']] [$v ['username']] = $html;
  8141. }
  8142. }
  8143. /* -- --- */
  8144. // 合计费用
  8145. $cateHtml = "";
  8146. $catePrice = 0;
  8147. $cateFalg = true;
  8148. foreach ( $itemCategoryList as $l ) {
  8149. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  8150. if (empty ( $l ['price'] )) {
  8151. $cateHtml .= '<td class="colGreen taR">-</td>';
  8152. $cateFalg = false;
  8153. break;
  8154. } else {
  8155. $catePrice += $l ['price'];
  8156. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8157. $cateFalg = false;
  8158. break;
  8159. }
  8160. }
  8161. }
  8162. if ($cateFalg) {
  8163. $cateHtml .= '<td class="colGreen taR">-</td>';
  8164. $cateFalg = true;
  8165. }
  8166. $cateFalg = true;
  8167. foreach ( $itemCategoryList as $l ) {
  8168. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  8169. if (empty ( $l ['price'] )) {
  8170. $cateHtml .= '<td class="colGreen taR">-</td>';
  8171. $cateFalg = false;
  8172. break;
  8173. } else {
  8174. $catePrice += $l ['price'];
  8175. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8176. $cateFalg = false;
  8177. break;
  8178. }
  8179. }
  8180. }
  8181. if ($cateFalg) {
  8182. $cateHtml .= '<td class="colGreen taR">-</td>';
  8183. $cateFalg = true;
  8184. }
  8185. $cateFalg = true;
  8186. foreach ( $itemCategoryList as $l ) {
  8187. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  8188. if (empty ( $l ['price'] )) {
  8189. $cateHtml .= '<td class="colGreen taR">-</td>';
  8190. $cateFalg = false;
  8191. break;
  8192. } else {
  8193. $catePrice += $l ['price'];
  8194. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8195. $cateFalg = false;
  8196. break;
  8197. }
  8198. }
  8199. }
  8200. if ($cateFalg) {
  8201. $cateHtml .= '<td class="colGreen taR">-</td>';
  8202. $cateFalg = true;
  8203. }
  8204. $cateFalg = true;
  8205. foreach ( $itemCategoryList as $l ) {
  8206. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  8207. if (empty ( $l ['price'] )) {
  8208. $cateHtml .= '<td class="colGreen taR">-</td>';
  8209. $cateFalg = false;
  8210. break;
  8211. } else {
  8212. $catePrice += $l ['price'];
  8213. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8214. $cateFalg = false;
  8215. break;
  8216. }
  8217. }
  8218. }
  8219. if ($cateFalg) {
  8220. $cateHtml .= '<td class="colGreen taR">-</td>';
  8221. $cateFalg = true;
  8222. }
  8223. $cateFalg = true;
  8224. foreach ( $itemCategoryList as $l ) {
  8225. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  8226. if (empty ( $l ['price'] )) {
  8227. $cateHtml .= '<td class="colGreen taR">-</td>';
  8228. $cateFalg = false;
  8229. break;
  8230. } else {
  8231. $catePrice += $l ['price'];
  8232. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8233. $cateFalg = false;
  8234. break;
  8235. }
  8236. }
  8237. }
  8238. if ($cateFalg) {
  8239. $cateHtml .= '<td class="colGreen taR">-</td>';
  8240. $cateFalg = true;
  8241. }
  8242. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  8243. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  8244. /* -- --- */
  8245. }
  8246. // print_r($htmlArray);die;
  8247. $data ['htmlArray'] = $htmlArray;
  8248. // statistics html
  8249. $stList = $statistics->getOne ( array (
  8250. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8251. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8252. 'groupby' => 'Month(date)',
  8253. 'asArray' => true
  8254. ) );
  8255. if (empty ( $stList ))
  8256. $stList = array (
  8257. 'rePrice' => 0,
  8258. 'agPrice' => 0
  8259. );
  8260. $data ['stList'] = array (
  8261. 'rePrice' => $stList ['rePrice'],
  8262. 'agPrice' => $stList ['agPrice'],
  8263. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8264. );
  8265. $monthHtml = "";
  8266. for($i = 1; $i <= 12; $i ++) {
  8267. if ($i == $month)
  8268. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8269. else
  8270. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8271. }
  8272. $data ['monthHtml'] = $monthHtml;
  8273. $data ['year'] = $year;
  8274. $data ['month'] = $month;
  8275. $data ['memu'] = "receipt";
  8276. $data ['staff'] = $this->staff;
  8277. $data ['receiptMemu'] = 'companyCategoryCollect';
  8278. $data ['verifyId'] = $this->verifyId;
  8279. $data ['executeId'] = $this->executeId;
  8280. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  8281. Doo::loadModel ( 'receipt' );
  8282. $receipt = new receipt ();
  8283. $receiptList = $receipt->find ( array (
  8284. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  8285. 'asArray' => true
  8286. ) );
  8287. if (empty ( $receiptList )) { // generated files
  8288. ob_start ();
  8289. $this->render ( "/admin/saeaStaffCollect", $data );
  8290. $this->cacheFile ( $path );
  8291. die ();
  8292. }
  8293. }
  8294. $this->render ( "/admin/saeaStaffCollect", $data );
  8295. }
  8296. function lyt() {
  8297. Doo::loadModel ( "receiptDetail" );
  8298. $receiptDetail = new receiptDetail ();
  8299. $receiptCollectList = $receiptDetail->find ( array (
  8300. 'where' => 'status=1 ',
  8301. 'asArray' => true
  8302. ) );
  8303. foreach ( $receiptCollectList as $key => $value ) {
  8304. $receiptDetail = new receiptDetail ();
  8305. $receiptDetail->pastDate = $value ['date'];
  8306. $receiptDetail->update ( array (
  8307. 'where' => "rdid= '" . $value ['rdid'] . "'"
  8308. ) );
  8309. }
  8310. }
  8311. function staffCollectMonthDetail() {
  8312. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8313. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8314. if (! $year)
  8315. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8316. if (! $month)
  8317. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8318. Doo::loadModel ( 'staff' );
  8319. $staff = new staff ();
  8320. Doo::loadModel ( "receiptDetail" );
  8321. $receiptDetail = new receiptDetail ();
  8322. Doo::loadModel ( 'accountItem' );
  8323. $accountItem = new accountItem ();
  8324. Doo::loadModel ( 'statistics' );
  8325. $statistics = new statistics ();
  8326. Doo::loadModel ( 'L_category' );
  8327. $lCategory = new L_category ();
  8328. $staffList = $staff->find ( array (
  8329. 'where' => 'username!="admin"',
  8330. 'asArray' => true
  8331. ) );
  8332. $categoryList = $staff->find ( array (
  8333. 'select' => 'COUNT(*) as count,cid,category',
  8334. 'where' => 'username !="admin"',
  8335. 'groupby' => 'cid',
  8336. 'asArray' => true
  8337. ) );
  8338. $list = array ();
  8339. foreach ( $categoryList as $vlu ) {
  8340. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8341. $r1 = 0;
  8342. $r2 = 0;
  8343. $r3 = 0;
  8344. $r4 = 0;
  8345. $r5 = 0;
  8346. $r6 = 0;
  8347. $r7 = 0;
  8348. $r8 = 0;
  8349. $r9 = 0;
  8350. $r10 = 0;
  8351. $r11 = 0;
  8352. $r12 = 0;
  8353. $r13 = 0;
  8354. $r14 = 0;
  8355. $r15 = 0;
  8356. $c1 = 0;
  8357. $c2 = 0;
  8358. $c3 = 0;
  8359. $c4 = 0;
  8360. $c5 = 0;
  8361. $c6 = 0;
  8362. $p1 = 0;
  8363. $p2 = 0;
  8364. $p3 = 0;
  8365. $p4 = 0;
  8366. $p5 = 0;
  8367. $p6 = 0;
  8368. $p7 = 0;
  8369. $p8 = 0;
  8370. $p9 = 0;
  8371. $t1 = 0;
  8372. $t2 = 0;
  8373. $t3 = 0;
  8374. $t4 = 0;
  8375. $t5 = 0;
  8376. $s1 = 0;
  8377. $m1 = 0;
  8378. foreach ( $staffList as $value ) {
  8379. if ($vlu ['cid'] == $value ['cid']) {
  8380. // pastDate
  8381. $receiptCollectList = $receiptDetail->find ( array (
  8382. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8383. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8384. 'groupby' => 'item,Month(pastDate),itemCategory',
  8385. 'asArray' => true
  8386. ) );
  8387. // if ($value['sid']==42){
  8388. // print_r($receiptCollectList);die;
  8389. // }
  8390. if (! empty ( $receiptCollectList )) {
  8391. $receiptL = array (
  8392. '日常相关费用' => array (),
  8393. '差旅相关费用' => array (),
  8394. '培训班费用' => array (),
  8395. '其他' => array ()
  8396. );
  8397. $html = "";
  8398. $psum = 0;
  8399. $item = array (
  8400. '市内交通费',
  8401. '市内出租费',
  8402. '办事处房租',
  8403. '电话费',
  8404. '水费',
  8405. '电费',
  8406. '办公费用',
  8407. '邮寄费',
  8408. '其他费用',
  8409. '车辆费用',
  8410. '广告费',
  8411. '团队建设费',
  8412. '物业管理费',
  8413. '宽带费'
  8414. );
  8415. foreach ( $item as $va ) {
  8416. $falg = true;
  8417. foreach ( $receiptCollectList as $v ) {
  8418. if ($v ['itemCategory'] == '日常相关费用') {
  8419. if ($v ['item'] == $va) {
  8420. if ($va == '市内交通费')
  8421. $r1 += $v ['price'];
  8422. if ($va == '市内出租费')
  8423. $r2 += $v ['price'];
  8424. if ($va == '办事处房租')
  8425. $r3 += $v ['price'];
  8426. if ($va == '电话费')
  8427. $r4 += $v ['price'];
  8428. if ($va == '水费')
  8429. $r5 += $v ['price'];
  8430. if ($va == '电费')
  8431. $r6 += $v ['price'];
  8432. if ($va == '办公费用')
  8433. $r7 += $v ['price'];
  8434. if ($va == '邮寄费')
  8435. $r8 += $v ['price'];
  8436. if ($va == '其他费用')
  8437. $r9 += $v ['price'];
  8438. if ($va == '车辆费用')
  8439. $r10 += $v ['price'];
  8440. if ($va == '广告费')
  8441. $r11 += $v ['price'];
  8442. if ($va == '团队建设费')
  8443. $r13 += $v ['price'];
  8444. if ($va == '物业管理费')
  8445. $r14 += $v ['price'];
  8446. if ($va == '宽带费')
  8447. $r15 += $v ['price'];
  8448. $psum += $v ['price'];
  8449. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8450. $falg = false;
  8451. break;
  8452. }
  8453. }
  8454. }
  8455. if ($falg)
  8456. $html .= '<td class="taR">-</td>';
  8457. }
  8458. $r12 += $psum;
  8459. if (! empty ( $psum ))
  8460. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8461. else
  8462. $psum = '<td class="colGreen taR">-</td>';
  8463. $receiptL ['日常相关费用'] = $psum . $html;
  8464. /* ----------------------------------- */
  8465. $html = "";
  8466. $psum = 0;
  8467. $item = array (
  8468. '往来交通费',
  8469. '市内交通费',
  8470. '出差住宿费',
  8471. '出差补助',
  8472. '其他费用'
  8473. );
  8474. foreach ( $item as $va ) {
  8475. $falg = true;
  8476. foreach ( $receiptCollectList as $v ) {
  8477. if ($v ['itemCategory'] == '差旅相关费用') {
  8478. if ($v ['item'] == $va) {
  8479. if ($va == '往来交通费')
  8480. $c1 += $v ['price'];
  8481. if ($va == '市内交通费')
  8482. $c2 += $v ['price'];
  8483. if ($va == '出差住宿费')
  8484. $c3 += $v ['price'];
  8485. if ($va == '出差补助')
  8486. $c4 += $v ['price'];
  8487. if ($va == '其他费用')
  8488. $c5 += $v ['price'];
  8489. $psum += $v ['price'];
  8490. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8491. $falg = false;
  8492. break;
  8493. }
  8494. }
  8495. }
  8496. if ($falg)
  8497. $html .= '<td class="taR">-</td>';
  8498. }
  8499. $c6 += $psum;
  8500. if (! empty ( $psum ))
  8501. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8502. else
  8503. $psum = '<td class="colGreen taR">-</td>';
  8504. $receiptL ['差旅相关费用'] = $psum . $html;
  8505. /* ------------------------------------- */
  8506. $html = "";
  8507. $psum = 0;
  8508. $item = array (
  8509. '场租费',
  8510. '薪酬',
  8511. '住宿费',
  8512. '交通费',
  8513. '餐饮费',
  8514. '办公费',
  8515. '公关费',
  8516. '其他'
  8517. );
  8518. foreach ( $item as $va ) {
  8519. $falg = true;
  8520. foreach ( $receiptCollectList as $v ) {
  8521. if ($v ['itemCategory'] == '培训班费用') {
  8522. if ($v ['item'] == $va) {
  8523. if ($va == '场租费')
  8524. $p1 += $v ['price'];
  8525. if ($va == '薪酬')
  8526. $p2 += $v ['price'];
  8527. if ($va == '住宿费')
  8528. $p3 += $v ['price'];
  8529. if ($va == '交通费')
  8530. $p4 += $v ['price'];
  8531. if ($va == '餐饮费')
  8532. $p5 += $v ['price'];
  8533. if ($va == '办公费')
  8534. $p6 += $v ['price'];
  8535. if ($va == '公关费')
  8536. $p7 += $v ['price'];
  8537. if ($va == '其他')
  8538. $p8 += $v ['price'];
  8539. $psum += $v ['price'];
  8540. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8541. $falg = false;
  8542. break;
  8543. }
  8544. }
  8545. }
  8546. if ($falg)
  8547. $html .= '<td class="taR">-</td>';
  8548. }
  8549. $p9 += $psum;
  8550. if (! empty ( $psum ))
  8551. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8552. else
  8553. $psum = '<td class="colGreen taR">-</td>';
  8554. $receiptL ['培训班费用'] = $psum . $html;
  8555. /* ------------------------------------- */
  8556. $html = "";
  8557. $psum = 0;
  8558. $item = array (
  8559. '公关费',
  8560. '广告费',
  8561. '借款',
  8562. '可自加费用'
  8563. );
  8564. foreach ( $item as $va ) {
  8565. $falg = true;
  8566. foreach ( $receiptCollectList as $v ) {
  8567. if ($v ['itemCategory'] == '其他') {
  8568. // if ($value['sid']==42){
  8569. //
  8570. // echo var_dump($v['item']);
  8571. // echo var_dump($va);
  8572. // echo var_dump($v['item']==" ".$va);
  8573. // echo $v['item']."==".$va."/<br/>";
  8574. // //print_r( $receiptCollectList);//echo $va;
  8575. // }
  8576. if (trim ( $v ['item'] ) == $va) {
  8577. if ($va == '公关费')
  8578. $t1 += $v ['price'];
  8579. if ($va == '广告费') {
  8580. $t2 += $v ['price'];
  8581. }
  8582. if ($va == '借款')
  8583. $t3 += $v ['price'];
  8584. if ($va == '可自加费用')
  8585. $t4 += $v ['price'];
  8586. $psum += $v ['price'];
  8587. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8588. $falg = false;
  8589. break;
  8590. }
  8591. }
  8592. }
  8593. if ($falg)
  8594. $html .= '<td class="taR">-</td>';
  8595. }
  8596. $t5 += $psum;
  8597. if (! empty ( $psum ))
  8598. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8599. else
  8600. $psum = '<td class="colGreen taR">-</td>';
  8601. $receiptL ['其他'] = $psum . $html;
  8602. /* ------------------------------------- */
  8603. $html = "";
  8604. $psum = 0;
  8605. foreach ( $receiptCollectList as $v ) {
  8606. if ($v ['itemCategory'] == '报销金额调整') {
  8607. if (! empty ( $v ['price'] )) {
  8608. $psum += $v ['price'];
  8609. }
  8610. }
  8611. }
  8612. $s1 += $psum;
  8613. if (! empty ( $psum ))
  8614. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8615. else
  8616. $psum = '<td class="taR colOrange">-</td>';
  8617. $receiptL ['报销金额调整'] = $psum . $html;
  8618. } else {
  8619. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8620. <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>
  8621. <td class="taR">-</td><td class="taR">-</td>';
  8622. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  8623. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8624. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8625. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8626. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8627. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  8628. }
  8629. $monthStaffPrice = $receiptDetail->find ( array (
  8630. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8631. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8632. 'groupby' => 'Month(pastDate)',
  8633. 'asArray' => true
  8634. ) );
  8635. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  8636. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  8637. $m1 += $monthStaffPrice [0] ['price'];
  8638. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  8639. } else
  8640. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  8641. $list [$value ['username']] = $receiptL;
  8642. }
  8643. }
  8644. $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>
  8645. <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>
  8646. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  8647. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  8648. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  8649. $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>
  8650. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  8651. $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>';
  8652. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  8653. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  8654. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  8655. }
  8656. $data ['list'] = $list;
  8657. $receiptCollectList = $receiptDetail->find ( array (
  8658. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8659. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8660. 'groupby' => 'item,Month(pastDate),itemCategory',
  8661. 'asArray' => true
  8662. ) );
  8663. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  8664. // statistics html
  8665. $stList = $statistics->getOne ( array (
  8666. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8667. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8668. 'groupby' => 'Month(date)',
  8669. 'asArray' => true
  8670. ) );
  8671. if (empty ( $stList ))
  8672. $stList = array (
  8673. 'rePrice' => 0,
  8674. 'agPrice' => 0
  8675. );
  8676. $data ['stList'] = array (
  8677. 'rePrice' => $stList ['rePrice'],
  8678. 'agPrice' => $stList ['agPrice'],
  8679. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8680. );
  8681. $monthHtml = "";
  8682. for($i = 1; $i <= 12; $i ++) {
  8683. if ($i == $month)
  8684. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8685. else
  8686. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8687. }
  8688. $data ['monthHtml'] = $monthHtml;
  8689. $data ['year'] = $year;
  8690. $data ['month'] = $month;
  8691. $data ['memu'] = "receipt";
  8692. $data ['staff'] = $this->staff;
  8693. $data ['receiptMemu'] = 'companyCategoryCollect';
  8694. $data ['verifyId'] = $this->verifyId;
  8695. $data ['executeId'] = $this->executeId;
  8696. $this->render ( "/admin/staffCollectMonthDetail", $data );
  8697. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  8698. }
  8699. function staffCollectMonthDetail2() {
  8700. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8701. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8702. if (! $year)
  8703. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8704. if (! $month)
  8705. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8706. Doo::loadModel ( 'staff' );
  8707. $staff = new staff ();
  8708. Doo::loadModel ( "receiptDetail" );
  8709. $receiptDetail = new receiptDetail ();
  8710. Doo::loadModel ( 'accountItem' );
  8711. $accountItem = new accountItem ();
  8712. Doo::loadModel ( 'statistics' );
  8713. $statistics = new statistics ();
  8714. Doo::loadModel ( 'L_category' );
  8715. $lCategory = new L_category ();
  8716. $staffList = $staff->find ( array (
  8717. 'where' => 'username!="admin"',
  8718. 'asArray' => true
  8719. ) );
  8720. $categoryList = $staff->find ( array (
  8721. 'select' => 'COUNT(*) as count,cid,category',
  8722. 'where' => 'username !="admin"',
  8723. 'groupby' => 'cid',
  8724. 'asArray' => true
  8725. ) );
  8726. $list = array ();
  8727. foreach ( $categoryList as $vlu ) {
  8728. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8729. $r1 = 0;
  8730. $r2 = 0;
  8731. $r3 = 0;
  8732. $r4 = 0;
  8733. $r5 = 0;
  8734. $r6 = 0;
  8735. $r7 = 0;
  8736. $r8 = 0;
  8737. $r9 = 0;
  8738. $r10 = 0;
  8739. $r11 = 0;
  8740. $r12 = 0;
  8741. $r13 = 0;
  8742. $r14 = 0;
  8743. $r15 = 0;
  8744. $c1 = 0;
  8745. $c2 = 0;
  8746. $c3 = 0;
  8747. $c4 = 0;
  8748. $c5 = 0;
  8749. $c6 = 0;
  8750. $p1 = 0;
  8751. $p2 = 0;
  8752. $p3 = 0;
  8753. $p4 = 0;
  8754. $p5 = 0;
  8755. $p6 = 0;
  8756. $p7 = 0;
  8757. $p8 = 0;
  8758. $p9 = 0;
  8759. $t1 = 0;
  8760. $t2 = 0;
  8761. $t3 = 0;
  8762. $t4 = 0;
  8763. $t5 = 0;
  8764. $s1 = 0;
  8765. $m1 = 0;
  8766. foreach ( $staffList as $value ) {
  8767. if ($vlu ['cid'] == $value ['cid']) {
  8768. $receiptCollectList = $receiptDetail->find ( array (
  8769. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  8770. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  8771. 'groupby' => 'item,Month(date),itemCategory',
  8772. 'asArray' => true
  8773. ) );
  8774. if (! empty ( $receiptCollectList )) {
  8775. $receiptL = array (
  8776. '日常相关费用' => array (),
  8777. '差旅相关费用' => array (),
  8778. '培训班费用' => array (),
  8779. '其他' => array ()
  8780. );
  8781. $html = "";
  8782. $psum = 0;
  8783. $item = array (
  8784. '市内交通费',
  8785. '市内出租费',
  8786. '办事处房租',
  8787. '电话费',
  8788. '水费',
  8789. '电费',
  8790. '办公费用',
  8791. '邮寄费',
  8792. '其他费用',
  8793. '车辆费用',
  8794. '广告费',
  8795. '团队建设费',
  8796. '物业管理费',
  8797. '宽带费'
  8798. );
  8799. foreach ( $item as $va ) {
  8800. $falg = true;
  8801. foreach ( $receiptCollectList as $v ) {
  8802. if ($v ['itemCategory'] == '日常相关费用') {
  8803. if ($v ['item'] == $va) {
  8804. if ($va == '市内交通费')
  8805. $r1 += $v ['price'];
  8806. if ($va == '市内出租费')
  8807. $r2 += $v ['price'];
  8808. if ($va == '办事处房租')
  8809. $r3 += $v ['price'];
  8810. if ($va == '电话费')
  8811. $r4 += $v ['price'];
  8812. if ($va == '水费')
  8813. $r5 += $v ['price'];
  8814. if ($va == '电费')
  8815. $r6 += $v ['price'];
  8816. if ($va == '办公费用')
  8817. $r7 += $v ['price'];
  8818. if ($va == '邮寄费')
  8819. $r8 += $v ['price'];
  8820. if ($va == '其他费用')
  8821. $r9 += $v ['price'];
  8822. if ($va == '车辆费用')
  8823. $r10 += $v ['price'];
  8824. if ($va == '广告费')
  8825. $r11 += $v ['price'];
  8826. if ($va == '团队建设费')
  8827. $r13 += $v ['price'];
  8828. if ($va == '物业管理费')
  8829. $r14 += $v ['price'];
  8830. if ($va == '宽带费')
  8831. $r15 += $v ['price'];
  8832. $psum += $v ['price'];
  8833. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8834. $falg = false;
  8835. break;
  8836. }
  8837. }
  8838. }
  8839. if ($falg)
  8840. $html .= '<td class="taR">-</td>';
  8841. }
  8842. $r12 += $psum;
  8843. if (! empty ( $psum ))
  8844. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8845. else
  8846. $psum = '<td class="colGreen taR">-</td>';
  8847. $receiptL ['日常相关费用'] = $psum . $html;
  8848. /* ----------------------------------- */
  8849. $html = "";
  8850. $psum = 0;
  8851. $item = array (
  8852. '往来交通费',
  8853. '市内交通费',
  8854. '出差住宿费',
  8855. '出差补助',
  8856. '其他费用'
  8857. );
  8858. foreach ( $item as $va ) {
  8859. $falg = true;
  8860. foreach ( $receiptCollectList as $v ) {
  8861. if ($v ['itemCategory'] == '差旅相关费用') {
  8862. if ($v ['item'] == $va) {
  8863. if ($va == '往来交通费')
  8864. $c1 += $v ['price'];
  8865. if ($va == '市内交通费')
  8866. $c2 += $v ['price'];
  8867. if ($va == '出差住宿费')
  8868. $c3 += $v ['price'];
  8869. if ($va == '出差补助')
  8870. $c4 += $v ['price'];
  8871. if ($va == '其他费用')
  8872. $c5 += $v ['price'];
  8873. $psum += $v ['price'];
  8874. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8875. $falg = false;
  8876. break;
  8877. }
  8878. }
  8879. }
  8880. if ($falg)
  8881. $html .= '<td class="taR">-</td>';
  8882. }
  8883. $c6 += $psum;
  8884. if (! empty ( $psum ))
  8885. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8886. else
  8887. $psum = '<td class="colGreen taR">-</td>';
  8888. $receiptL ['差旅相关费用'] = $psum . $html;
  8889. /* ------------------------------------- */
  8890. $html = "";
  8891. $psum = 0;
  8892. $item = array (
  8893. '场租费',
  8894. '薪酬',
  8895. '住宿费',
  8896. '交通费',
  8897. '餐饮费',
  8898. '办公费',
  8899. '公关费',
  8900. '其他'
  8901. );
  8902. foreach ( $item as $va ) {
  8903. $falg = true;
  8904. foreach ( $receiptCollectList as $v ) {
  8905. if ($v ['itemCategory'] == '培训班费用') {
  8906. if ($v ['item'] == $va) {
  8907. if ($va == '场租费')
  8908. $p1 += $v ['price'];
  8909. if ($va == '薪酬')
  8910. $p2 += $v ['price'];
  8911. if ($va == '住宿费')
  8912. $p3 += $v ['price'];
  8913. if ($va == '交通费')
  8914. $p4 += $v ['price'];
  8915. if ($va == '餐饮费')
  8916. $p5 += $v ['price'];
  8917. if ($va == '办公费')
  8918. $p6 += $v ['price'];
  8919. if ($va == '公关费')
  8920. $p7 += $v ['price'];
  8921. if ($va == '其他')
  8922. $p8 += $v ['price'];
  8923. $psum += $v ['price'];
  8924. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8925. $falg = false;
  8926. break;
  8927. }
  8928. }
  8929. }
  8930. if ($falg)
  8931. $html .= '<td class="taR">-</td>';
  8932. }
  8933. $p9 += $psum;
  8934. if (! empty ( $psum ))
  8935. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8936. else
  8937. $psum = '<td class="colGreen taR">-</td>';
  8938. $receiptL ['培训班费用'] = $psum . $html;
  8939. /* ------------------------------------- */
  8940. $html = "";
  8941. $psum = 0;
  8942. $item = array (
  8943. '公关费',
  8944. '广告费',
  8945. '借款',
  8946. '可自加费用'
  8947. );
  8948. foreach ( $item as $va ) {
  8949. $falg = true;
  8950. foreach ( $receiptCollectList as $v ) {
  8951. if ($v ['itemCategory'] == '其他') {
  8952. if ($v ['item'] == $va) {
  8953. if ($va == '公关费')
  8954. $t1 += $v ['price'];
  8955. if ($va == '广告费')
  8956. $t2 += $v ['price'];
  8957. if ($va == '借款')
  8958. $t3 += $v ['price'];
  8959. if ($va == '可自加费用')
  8960. $t4 += $v ['price'];
  8961. $psum += $v ['price'];
  8962. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8963. $falg = false;
  8964. break;
  8965. }
  8966. }
  8967. }
  8968. if ($falg)
  8969. $html .= '<td class="taR">-</td>';
  8970. }
  8971. $t5 += $psum;
  8972. if (! empty ( $psum ))
  8973. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8974. else
  8975. $psum = '<td class="colGreen taR">-</td>';
  8976. $receiptL ['其他'] = $psum . $html;
  8977. /* ------------------------------------- */
  8978. $html = "";
  8979. $psum = 0;
  8980. foreach ( $receiptCollectList as $v ) {
  8981. if ($v ['itemCategory'] == '报销金额调整') {
  8982. if (! empty ( $v ['price'] )) {
  8983. $psum += $v ['price'];
  8984. }
  8985. }
  8986. }
  8987. $s1 += $psum;
  8988. if (! empty ( $psum ))
  8989. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8990. else
  8991. $psum = '<td class="taR colOrange">-</td>';
  8992. $receiptL ['报销金额调整'] = $psum . $html;
  8993. } else {
  8994. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8995. <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>';
  8996. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  8997. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8998. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8999. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9000. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9001. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9002. }
  9003. $monthStaffPrice = $receiptDetail->find ( array (
  9004. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9005. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9006. 'asArray' => true
  9007. ) );
  9008. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  9009. $m1 += $monthStaffPrice [0] ['price'];
  9010. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9011. } else
  9012. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9013. $list [$value ['username']] = $receiptL;
  9014. }
  9015. }
  9016. $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>
  9017. <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>
  9018. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  9019. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  9020. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  9021. $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>
  9022. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  9023. $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>';
  9024. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  9025. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  9026. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  9027. }
  9028. $data ['list'] = $list;
  9029. $receiptCollectList = $receiptDetail->find ( array (
  9030. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9031. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9032. 'groupby' => 'item,Month(date),itemCategory',
  9033. 'asArray' => true
  9034. ) );
  9035. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9036. // statistics html
  9037. $stList = $statistics->getOne ( array (
  9038. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9039. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9040. 'groupby' => 'Month(date)',
  9041. 'asArray' => true
  9042. ) );
  9043. if (empty ( $stList ))
  9044. $stList = array (
  9045. 'rePrice' => 0,
  9046. 'agPrice' => 0
  9047. );
  9048. $data ['stList'] = array (
  9049. 'rePrice' => $stList ['rePrice'],
  9050. 'agPrice' => $stList ['agPrice'],
  9051. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9052. );
  9053. $monthHtml = "";
  9054. for($i = 1; $i <= 12; $i ++) {
  9055. if ($i == $month)
  9056. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9057. else
  9058. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9059. }
  9060. $data ['monthHtml'] = $monthHtml;
  9061. $data ['year'] = $year;
  9062. $data ['month'] = $month;
  9063. $data ['memu'] = "receipt";
  9064. $data ['staff'] = $this->staff;
  9065. $data ['receiptMemu'] = 'companyCategoryCollect';
  9066. $data ['verifyId'] = $this->verifyId;
  9067. $data ['executeId'] = $this->executeId;
  9068. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  9069. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9070. }
  9071. function companyMonthCollectDetail() {
  9072. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9073. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9074. if (! $year)
  9075. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9076. if (! $month)
  9077. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9078. Doo::loadModel ( 'staff' );
  9079. $staff = new staff ();
  9080. Doo::loadModel ( "receiptDetail" );
  9081. $receiptDetail = new receiptDetail ();
  9082. Doo::loadModel ( 'accountItem' );
  9083. $accountItem = new accountItem ();
  9084. Doo::loadModel ( 'statistics' );
  9085. $statistics = new statistics ();
  9086. Doo::loadModel ( 'L_category' );
  9087. $lCategory = new L_category ();
  9088. $staffList = $staff->find ( array (
  9089. 'where' => 'username!="admin"',
  9090. 'asArray' => true
  9091. ) );
  9092. $categoryList = $lCategory->find ( array (
  9093. 'asArray' => true
  9094. ) );
  9095. $list = array ();
  9096. foreach ( $categoryList as $value ) {
  9097. $receiptCollectList = $receiptDetail->find ( array (
  9098. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9099. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9100. 'groupby' => 'item,Month(pastDate),itemCategory',
  9101. 'asArray' => true
  9102. ) );
  9103. if (! empty ( $receiptCollectList )) {
  9104. $receiptL = array (
  9105. '日常相关费用' => array (),
  9106. '差旅相关费用' => array (),
  9107. '培训班费用' => array (),
  9108. '其他' => array ()
  9109. );
  9110. $html = "";
  9111. $psum = 0;
  9112. $item = array (
  9113. '市内交通费',
  9114. '市内出租费',
  9115. '办事处房租',
  9116. '电话费',
  9117. '水费',
  9118. '电费',
  9119. '办公费用',
  9120. '邮寄费',
  9121. '其他费用',
  9122. '车辆费用',
  9123. '广告费',
  9124. '团队建设费'
  9125. );
  9126. foreach ( $item as $va ) {
  9127. $falg = true;
  9128. foreach ( $receiptCollectList as $v ) {
  9129. if ($v ['itemCategory'] == '日常相关费用') {
  9130. if ($v ['item'] == $va) {
  9131. $psum += $v ['price'];
  9132. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9133. $falg = false;
  9134. break;
  9135. }
  9136. }
  9137. }
  9138. if ($falg)
  9139. $html .= '<td class="taR">-</td>';
  9140. }
  9141. if (! empty ( $psum ))
  9142. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9143. else
  9144. $psum = '<td class="colGreen taR">-</td>';
  9145. $receiptL ['日常相关费用'] = $psum . $html;
  9146. /* ----------------------------------- */
  9147. $html = "";
  9148. $psum = 0;
  9149. $item = array (
  9150. '往来交通费',
  9151. '市内交通费',
  9152. '出差住宿费',
  9153. '出差补助',
  9154. '其他费用'
  9155. );
  9156. foreach ( $item as $va ) {
  9157. $falg = true;
  9158. foreach ( $receiptCollectList as $v ) {
  9159. if ($v ['itemCategory'] == '差旅相关费用') {
  9160. if ($v ['item'] == $va) {
  9161. $psum += $v ['price'];
  9162. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9163. $falg = false;
  9164. break;
  9165. }
  9166. }
  9167. }
  9168. if ($falg)
  9169. $html .= '<td class="taR">-</td>';
  9170. }
  9171. if (! empty ( $psum ))
  9172. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9173. else
  9174. $psum = '<td class="colGreen taR">-</td>';
  9175. $receiptL ['差旅相关费用'] = $psum . $html;
  9176. /* ------------------------------------- */
  9177. $html = "";
  9178. $psum = 0;
  9179. $item = array (
  9180. '场租费',
  9181. '薪酬',
  9182. '住宿费',
  9183. '交通费',
  9184. '餐饮费',
  9185. '办公费',
  9186. '公关费',
  9187. '其他'
  9188. );
  9189. foreach ( $item as $va ) {
  9190. $falg = true;
  9191. foreach ( $receiptCollectList as $v ) {
  9192. if ($v ['itemCategory'] == '培训班费用') {
  9193. if ($v ['item'] == $va) {
  9194. $psum += $v ['price'];
  9195. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9196. $falg = false;
  9197. break;
  9198. }
  9199. }
  9200. }
  9201. if ($falg)
  9202. $html .= '<td class="taR">-</td>';
  9203. }
  9204. if (! empty ( $psum ))
  9205. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9206. else
  9207. $psum = '<td class="colGreen taR">-</td>';
  9208. $receiptL ['培训班费用'] = $psum . $html;
  9209. /* ------------------------------------- */
  9210. $html = "";
  9211. $psum = 0;
  9212. $item = array (
  9213. '公关费',
  9214. '广告费',
  9215. '借款',
  9216. '可自加费用'
  9217. );
  9218. foreach ( $item as $va ) {
  9219. $falg = true;
  9220. foreach ( $receiptCollectList as $v ) {
  9221. if ($v ['itemCategory'] == '其他') {
  9222. if ($v ['item'] == $va) {
  9223. $psum += $v ['price'];
  9224. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9225. $falg = false;
  9226. break;
  9227. }
  9228. }
  9229. }
  9230. if ($falg)
  9231. $html .= '<td class="taR">-</td>';
  9232. }
  9233. if (! empty ( $psum ))
  9234. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9235. else
  9236. $psum = '<td class="colGreen taR">-</td>';
  9237. $receiptL ['其他'] = $psum . $html;
  9238. /* ------------------------------------- */
  9239. $html = "";
  9240. $psum = 0;
  9241. foreach ( $receiptCollectList as $v ) {
  9242. if ($v ['itemCategory'] == '报销金额调整') {
  9243. if (! empty ( $v ['price'] ))
  9244. $psum += $v ['price'];
  9245. }
  9246. }
  9247. if (! empty ( $psum ))
  9248. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9249. else
  9250. $psum = '<td class="taR colOrange">-</td>';
  9251. $receiptL ['报销金额调整'] = $psum . $html;
  9252. } else {
  9253. $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>
  9254. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9255. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9256. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9257. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9258. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9259. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9260. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9261. }
  9262. $monthStaffPrice = $receiptDetail->find ( array (
  9263. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9264. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9265. 'asArray' => true
  9266. ) );
  9267. if (! empty ( $monthStaffPrice [0] ['price'] ))
  9268. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9269. else
  9270. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9271. $list [$value ['title']] = $receiptL;
  9272. }
  9273. $data ['list'] = $list;
  9274. $receiptCollectList = $receiptDetail->find ( array (
  9275. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9276. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9277. 'groupby' => 'item,Month(pastDate),itemCategory',
  9278. 'asArray' => true
  9279. ) );
  9280. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9281. // print_r($data['monthPriceHtml']);
  9282. // foreach ($data['monthPriceHtml'] as $value){
  9283. // echo $value;
  9284. // }
  9285. // die;
  9286. // statistics html
  9287. $stList = $statistics->getOne ( array (
  9288. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9289. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9290. 'groupby' => 'Month(date)',
  9291. 'asArray' => true
  9292. ) );
  9293. if (empty ( $stList ))
  9294. $stList = array (
  9295. 'rePrice' => 0,
  9296. 'agPrice' => 0
  9297. );
  9298. $data ['stList'] = array (
  9299. 'rePrice' => $stList ['rePrice'],
  9300. 'agPrice' => $stList ['agPrice'],
  9301. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9302. );
  9303. $monthHtml = "";
  9304. for($i = 1; $i <= 12; $i ++) {
  9305. if ($i == $month)
  9306. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9307. else
  9308. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9309. }
  9310. $data ['monthHtml'] = $monthHtml;
  9311. $data ['year'] = $year;
  9312. $data ['month'] = $month;
  9313. $data ['memu'] = "receipt";
  9314. $data ['staff'] = $this->staff;
  9315. $data ['receiptMemu'] = 'companyCategoryCollect';
  9316. $data ['verifyId'] = $this->verifyId;
  9317. $data ['executeId'] = $this->executeId;
  9318. $this->render ( "/admin/companyMonthCollectDetail", $data );
  9319. }
  9320. function staffCollectDetail() {
  9321. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9322. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  9323. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  9324. if (! $staffname) {
  9325. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  9326. $staffname = urldecode ( $staffname );
  9327. }
  9328. Doo::loadModel ( 'staff' );
  9329. $staff = new staff ();
  9330. Doo::loadModel ( "receiptDetail" );
  9331. $receiptDetail = new receiptDetail ();
  9332. Doo::loadModel ( 'accountItem' );
  9333. $accountItem = new accountItem ();
  9334. Doo::loadModel ( 'statistics' );
  9335. $statistics = new statistics ();
  9336. Doo::loadModel ( 'L_category' );
  9337. $lCategory = new L_category ();
  9338. $staffList = $staff->find ( array (
  9339. 'asArray' => true
  9340. ) );
  9341. $stHtml = '';
  9342. $stTitle = "";
  9343. $staffId = 0;
  9344. $cid = 0;
  9345. $ocid = 0;
  9346. foreach ( $staffList as $value ) {
  9347. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  9348. $stTitle = $value ['category'] . '-' . $value ['username'];
  9349. $staffId = $value ['sid'];
  9350. $cid = $value ['cid'];
  9351. $ocid = $value ['cid'];
  9352. if (! empty ( $value ['othercid'] ))
  9353. $cid = $value ['cid'] . ',' . $value ['othercid'];
  9354. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9355. } elseif ($value ['username'] != 'admin')
  9356. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9357. }
  9358. $data ['lCategoryHtml'] = $lCategory->find ( array (
  9359. 'where' => 'cid in(' . $cid . ')',
  9360. 'asArray' => true
  9361. ) );
  9362. if (empty ( $pcid ))
  9363. $pcid = $ocid;
  9364. $data ['ocid'] = $pcid;
  9365. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  9366. $this->showCache ( $path );
  9367. //
  9368. $receiptCollectList = $receiptDetail->find ( array (
  9369. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9370. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9371. 'groupby' => 'item,Month(pastDate),itemCategory',
  9372. 'asArray' => true
  9373. ) );
  9374. //echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  9375. //print_r($receiptCollectList);
  9376. $accountList = $accountItem->find ( array (
  9377. 'asArray' => true
  9378. ) );
  9379. // create CollectDetail HTML
  9380. $collectHtml = array ();
  9381. foreach ( $accountList as $key => $value ) {
  9382. $html = "";
  9383. $asum = 0;
  9384. for($i = 1; $i <= 12; $i ++) {
  9385. $falg = true;
  9386. foreach ( $receiptCollectList as $v ) {
  9387. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9388. if($v ['item']=='可自加费用'){
  9389. //echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  9390. }
  9391. $asum += $v ['price'];
  9392. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9393. $falg = false;
  9394. break;
  9395. }
  9396. }
  9397. if ($falg)
  9398. $html .= '<td class="taR">-</td>';
  9399. }
  9400. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9401. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9402. }
  9403. $data ['collectHtml'] = $collectHtml;
  9404. //print_r($collectHtml);
  9405. // create Adjustment price html
  9406. $receiptCollectList = $receiptDetail->find ( array (
  9407. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9408. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9409. 'groupby' => 'itemCategory,Month(pastDate)',
  9410. 'asArray' => true
  9411. ) );
  9412. $adjustment = array ();
  9413. $collectArray = array (
  9414. '日常相关费用' => array (),
  9415. '差旅相关费用' => array (),
  9416. '培训班费用' => array (),
  9417. '其他' => array ()
  9418. );
  9419. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9420. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9421. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9422. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9423. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9424. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9425. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9426. array_push ( $collectArray ['其他'], $collectHtml );
  9427. $data ['collectArray'] = $collectArray;
  9428. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9429. array_push ( $adjustment, $collectHtml );
  9430. $data ['adjustment'] = $adjustment;
  9431. // total price html
  9432. $collectHtml = "";
  9433. $total = 0;
  9434. for($i = 1; $i <= 12; $i ++) {
  9435. $sumPrice = 0;
  9436. foreach ( $receiptCollectList as $key => $value ) {
  9437. if ($value ['month'] == $i) {
  9438. $sumPrice += $value ['price'];
  9439. }
  9440. }
  9441. if ($sumPrice == 0)
  9442. $collectHtml .= '<td class="taR">-</td>';
  9443. else
  9444. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9445. $total += $sumPrice;
  9446. }
  9447. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9448. // statistics html
  9449. $stList = $statistics->statisticsByYear ( $year, $staffId );
  9450. if (empty ( $stList ))
  9451. $stList = array (
  9452. 'rePrice' => 0,
  9453. 'agPrice' => 0
  9454. );
  9455. $data ['stList'] = array (
  9456. 'rePrice' => $stList ['rePrice'],
  9457. 'agPrice' => $stList ['agPrice'],
  9458. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9459. );
  9460. $data ['totalPrice'] = $collectHtml;
  9461. $data ['totalYear'] = $total;
  9462. $data ['stHtml'] = $stHtml;
  9463. $data ['year'] = $year;
  9464. $data ['stTitle'] = $stTitle;
  9465. $data ['memu'] = "receipt";
  9466. $data ['staff'] = $this->staff;
  9467. $data ['receiptMemu'] = 'companyCategoryCollect';
  9468. $data ['verifyId'] = $this->verifyId;
  9469. $data ['executeId'] = $this->executeId;
  9470. if ($year < date ( "Y" )) {
  9471. Doo::loadModel ( 'receipt' );
  9472. $receipt = new receipt ();
  9473. $receiptList = $receipt->find ( array (
  9474. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  9475. 'asArray' => true
  9476. ) );
  9477. if (empty ( $receiptList )) { // generated files
  9478. ob_start ();
  9479. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9480. $this->cacheFile ( $path );
  9481. die ();
  9482. }
  9483. }
  9484. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9485. }
  9486. function BUGFLAG() {
  9487. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  9488. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  9489. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9490. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9491. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  9492. if (empty ( $status ))
  9493. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  9494. $page_size = 12;
  9495. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  9496. $vidList = array ();
  9497. $button = 0;
  9498. Doo::loadModel ( 'verify' );
  9499. $verify = new verify ();
  9500. Doo::loadModel ( 'receipt' );
  9501. $receipt = new receipt ();
  9502. Doo::loadModel ( 'staff' );
  9503. $staff = new staff ();
  9504. Doo::loadModel ( 'L_category' );
  9505. $Lcategory = new L_category ();
  9506. $dateCondition = " and Year(date) =" . $year;
  9507. if (! empty ( $month ))
  9508. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  9509. $categoryList = $Lcategory->find ( array (
  9510. 'asArray' => true
  9511. ) );
  9512. $staffList = $staff->find ( array (
  9513. 'where' => 'cid=' . $cid,
  9514. 'asArray' => true
  9515. ) );
  9516. $cateCondition = "";
  9517. $staffCondition = "";
  9518. $approvalCondition = "";
  9519. if (! empty ( $cid ))
  9520. $cateCondition = ' and cid=' . $cid;
  9521. if (! empty ( $sid )) {
  9522. $staffCondition = ' and staff=' . $sid;
  9523. $cateCondition = "";
  9524. }
  9525. $approvalCondition = " and status=" . $status;
  9526. if ($status == 2) {
  9527. // 查找角色审批人
  9528. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9529. }
  9530. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  9531. $approvalCondition = ' and status=2 ';
  9532. }
  9533. if ($status == 1) {
  9534. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  9535. }
  9536. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  9537. $pageinfo ['page'] = array (
  9538. 'previous' => ''
  9539. );
  9540. if ($status == 0) {
  9541. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  9542. $receiptList = $receipt->find ( array (
  9543. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  9544. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  9545. 'desc' => 'rid',
  9546. 'asArray' => true
  9547. ) );
  9548. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9549. } else
  9550. $receiptList = $receipt->find ( array (
  9551. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  9552. 'desc' => 'rid',
  9553. 'asArray' => true
  9554. ) );
  9555. $rLRes = $receipt->find ( array (
  9556. '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,
  9557. 'desc' => 'rid',
  9558. 'asArray' => true
  9559. ) );
  9560. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9561. // print_r($pageinfo);
  9562. $Locate = 0;
  9563. foreach ( $receiptList as $key => $value ) {
  9564. $receiptList [$key] ['Locate'] = $Locate;
  9565. $Locate ++;
  9566. $receiptList [$key] ['reviseDetail'] = array ();
  9567. if (! empty ( $value ['reviseDetail'] ))
  9568. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  9569. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  9570. $categoryDetil = $Lcategory->getOne ( array (
  9571. 'where' => 'cid=' . $value ['cid'],
  9572. 'asArray' => true
  9573. ) );
  9574. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  9575. $verifyList = $verify->getOne ( array (
  9576. 'where' => 'vid=' . $value ['verify'],
  9577. 'asArray' => true
  9578. ) );
  9579. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  9580. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  9581. foreach ( $verifyList as $k => $v ) {
  9582. // init verifyStaff
  9583. $verifyList [$k] ['date'] = "";
  9584. $verifyList [$k] ['opinion'] = "";
  9585. $verifyList [$k] ['status'] = "";
  9586. if (empty ( $verifyStaff )) {
  9587. $verifyList [$k] ['date'] = "";
  9588. $verifyList [$k] ['opinion'] = "";
  9589. if ($v [0] == $this->staff [0] ['sid']) {
  9590. $verifyList [$k] ['status'] = 4;
  9591. $button = 4;
  9592. }
  9593. } else {
  9594. $flag = true;
  9595. foreach ( $verifyStaff as $m => $u ) {
  9596. if ($v [0] == $m) {
  9597. $verifyList [$k] ['date'] = $u ['date'];
  9598. $verifyList [$k] ['opinion'] = $u ['opinion'];
  9599. $verifyList [$k] ['status'] = $u ['status'];
  9600. $flag = false;
  9601. break;
  9602. }
  9603. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  9604. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  9605. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  9606. }
  9607. if ($flag) { // 检测可编辑
  9608. if ($v [0] == $this->staff [0] ['sid']) {
  9609. $verifyList [$k] ['status'] = 4;
  9610. $button = 4;
  9611. }
  9612. }
  9613. }
  9614. }
  9615. $receiptList [$key] ['verifyList'] = $verifyList;
  9616. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  9617. 'where' => 'sid=' . $value ['staff'],
  9618. 'asArray' => true
  9619. ) );
  9620. $receiptList [$key] ['button'] = $button;
  9621. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  9622. }
  9623. // print_r($receiptList);die;
  9624. // $data['verifyDetail']=$verifyDetail;
  9625. $mothHtml = "";
  9626. for($i = 1; $i <= 12; $i ++) {
  9627. if ($month == $i)
  9628. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  9629. else
  9630. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  9631. }
  9632. $data ['mothHtml'] = $mothHtml;
  9633. $data ['page'] = $pageinfo;
  9634. $data ['receiptList'] = $receiptList;
  9635. $data ['receiptApprovalCount'] = count ( $rLRes );
  9636. $data ['status'] = $status;
  9637. $data ['year'] = $year;
  9638. $data ['categoryList'] = $categoryList;
  9639. $data ['staffList'] = $staffList;
  9640. $data ['cid'] = $cid;
  9641. $data ['sid'] = $sid;
  9642. // print_r($receiptList);
  9643. $data ['memu'] = "receipt";
  9644. $data ['staff'] = $this->staff;
  9645. $data ['receiptMemu'] = 'approvalExpenses';
  9646. $data ['verifyId'] = $this->verifyId;
  9647. $data ['executeId'] = $this->executeId;
  9648. $this->render ( "/admin/FALG", $data );
  9649. }
  9650. function ajaxGetReceiptOrder() {
  9651. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  9652. if (! empty ( $receiptOrder )) {
  9653. Doo::loadModel ( 'receipt' );
  9654. $receipt = new receipt ();
  9655. Doo::loadModel ( 'staff' );
  9656. $staff = new staff ();
  9657. $receiptInfo = $receipt->getOne ( array (
  9658. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  9659. 'asArray' => true
  9660. ) );
  9661. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  9662. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  9663. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  9664. </tbody></table><table class="table table table-bordered"><tbody>';
  9665. foreach ( $verifyStaff as $key => $value ) {
  9666. $staffInfo = $staff->getOne ( array (
  9667. 'select' => 'username',
  9668. 'where' => ' sid="' . $key . '"',
  9669. 'asArray' => true
  9670. ) );
  9671. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  9672. }
  9673. $html .= '</tbody></table></div></div>';
  9674. echo json_encode ( array (
  9675. 'status' => 1,
  9676. 'receiptHtml' => $html
  9677. ) );
  9678. die ();
  9679. }
  9680. echo json_encode ( array (
  9681. 'status' => 2,
  9682. 'receiptHtml' => ''
  9683. ) );
  9684. die ();
  9685. }
  9686. function _getMonthCollectDetail($receiptCollectList) {
  9687. if (! empty ( $receiptCollectList )) {
  9688. $receiptL = array (
  9689. '日常相关费用' => array (),
  9690. '差旅相关费用' => array (),
  9691. '培训班费用' => array (),
  9692. '其他' => array ()
  9693. );
  9694. $html = "";
  9695. $psum = 0;
  9696. $item = array (
  9697. '市内交通费',
  9698. '市内出租费',
  9699. '办事处房租',
  9700. '电话费',
  9701. '水费',
  9702. '电费',
  9703. '办公费用',
  9704. '邮寄费',
  9705. '其他费用',
  9706. '车辆费用',
  9707. '广告费',
  9708. '团队建设费',
  9709. '物业管理费',
  9710. '宽带费'
  9711. );
  9712. foreach ( $item as $value ) {
  9713. $falg = true;
  9714. foreach ( $receiptCollectList as $v ) {
  9715. if ($v ['itemCategory'] == '日常相关费用') {
  9716. if ($v ['item'] == $value) {
  9717. $psum += $v ['price'];
  9718. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9719. $falg = false;
  9720. break;
  9721. }
  9722. }
  9723. }
  9724. if ($falg)
  9725. $html .= '<td class="taR">-</td>';
  9726. }
  9727. if (! empty ( $psum ))
  9728. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9729. else
  9730. $psum = '<td class="colGreen taR">-</td>';
  9731. $receiptL ['日常相关费用'] = $psum . $html;
  9732. /* ----------------------------------- */
  9733. $html = "";
  9734. $psum = 0;
  9735. $item = array (
  9736. '往来交通费',
  9737. '市内交通费',
  9738. '出差住宿费',
  9739. '出差补助',
  9740. '其他费用'
  9741. );
  9742. foreach ( $item as $value ) {
  9743. $falg = true;
  9744. foreach ( $receiptCollectList as $v ) {
  9745. if ($v ['itemCategory'] == '差旅相关费用') {
  9746. if ($v ['item'] == $value) {
  9747. $psum += $v ['price'];
  9748. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9749. $falg = false;
  9750. break;
  9751. }
  9752. }
  9753. }
  9754. if ($falg)
  9755. $html .= '<td class="taR">-</td>';
  9756. }
  9757. if (! empty ( $psum ))
  9758. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9759. else
  9760. $psum = '<td class="colGreen taR">-</td>';
  9761. $receiptL ['差旅相关费用'] = $psum . $html;
  9762. /* ------------------------------------- */
  9763. $html = "";
  9764. $psum = 0;
  9765. $item = array (
  9766. '场租费',
  9767. '薪酬',
  9768. '住宿费',
  9769. '交通费',
  9770. '餐饮费',
  9771. '办公费',
  9772. '公关费',
  9773. '其他'
  9774. );
  9775. foreach ( $item as $value ) {
  9776. $falg = true;
  9777. foreach ( $receiptCollectList as $v ) {
  9778. if ($v ['itemCategory'] == '培训班费用') {
  9779. if ($v ['item'] == $value) {
  9780. $psum += $v ['price'];
  9781. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9782. $falg = false;
  9783. break;
  9784. }
  9785. }
  9786. }
  9787. if ($falg)
  9788. $html .= '<td class="taR">-</td>';
  9789. }
  9790. if (! empty ( $psum ))
  9791. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9792. else
  9793. $psum = '<td class="colGreen taR">-</td>';
  9794. $receiptL ['培训班费用'] = $psum . $html;
  9795. /* ------------------------------------- */
  9796. $html = "";
  9797. $psum = 0;
  9798. $item = array (
  9799. '公关费',
  9800. '广告费',
  9801. '借款',
  9802. '可自加费用'
  9803. );
  9804. foreach ( $item as $value ) {
  9805. $falg = true;
  9806. foreach ( $receiptCollectList as $v ) {
  9807. if ($v ['itemCategory'] == '其他') {
  9808. if ($v ['item'] == $value) {
  9809. $psum += $v ['price'];
  9810. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9811. $falg = false;
  9812. break;
  9813. }
  9814. }
  9815. }
  9816. if ($falg)
  9817. $html .= '<td class="taR">-</td>';
  9818. }
  9819. if (! empty ( $psum ))
  9820. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9821. else
  9822. $psum = '<td class="colGreen taR">-</td>';
  9823. $receiptL ['其他'] = $psum . $html;
  9824. /* ------------------------------------- */
  9825. $html = "";
  9826. $psum = 0;
  9827. foreach ( $receiptCollectList as $v ) {
  9828. if ($v ['itemCategory'] == '报销金额调整') {
  9829. if (! empty ( $v ['price'] ))
  9830. $psum += $v ['price'];
  9831. }
  9832. }
  9833. if (! empty ( $psum ))
  9834. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9835. else
  9836. $psum = '<td class="taR colOrange">-</td>';
  9837. $receiptL ['报销金额调整'] = $psum . $html;
  9838. } else {
  9839. $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>
  9840. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9841. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9842. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9843. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9844. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9845. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9846. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9847. }
  9848. return $receiptL;
  9849. }
  9850. function eMail() {
  9851. Doo::loadModel ( 'staff' );
  9852. $staff = new staff ();
  9853. Doo::loadModel ( 'receipt' );
  9854. $receipt = new receipt ();
  9855. Doo::loadModel ( 'L_category' );
  9856. $Lcategory = new L_category ();
  9857. Doo::loadModel ( "verify" );
  9858. $verify = new verify ();
  9859. $staffList = $staff->find ( array (
  9860. 'asArray' => true
  9861. ) );
  9862. foreach ( $staffList as $key => $value ) {
  9863. if ($value ['username'] != 'admin') {
  9864. // 提交人
  9865. $receiptList = $receipt->find ( array (
  9866. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  9867. 'asArray' => true
  9868. ) );
  9869. if (! empty ( $receiptList )) {
  9870. $html = '<br><div><style></style>
  9871. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  9872. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  9873. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9874. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  9875. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9876. <tbody><tr>
  9877. <td style="padding: 0 40px;" align="left">
  9878. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9879. </td></tr><tr>
  9880. <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>
  9881. </tr>
  9882. </tbody> </table></td> </tr> <tr><td>
  9883. <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">
  9884. <tbody> <tr><td>
  9885. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  9886. 以下报销单完成了审批,等着收款吧:</p>
  9887. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  9888. foreach ( $receiptList as $k => $v ) {
  9889. $category = $Lcategory->getOne ( array (
  9890. 'where' => 'cid=' . $v ['cid'],
  9891. 'asArray' => true
  9892. ) );
  9893. $html .= '
  9894. <tr>
  9895. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  9896. <td align="left">
  9897. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  9898. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  9899. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  9900. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  9901. </tr>';
  9902. }
  9903. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  9904. <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>
  9905. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  9906. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  9907. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  9908. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9909. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9910. $receipt = new receipt ();
  9911. $receipt->notice = 1;
  9912. $receipt->update ( array (
  9913. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  9914. ) );
  9915. }
  9916. }
  9917. // 审批人
  9918. $verifyList = $verify->find ( array (
  9919. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  9920. 'asArray' => true
  9921. ) );
  9922. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  9923. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  9924. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9925. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  9926. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9927. <tbody><tr><td style="padding: 0 40px;" align="left">
  9928. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9929. </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>
  9930. </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">
  9931. <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>
  9932. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  9933. foreach ( $verifyList as $k => $v ) {
  9934. $receiptList = $receipt->find ( array (
  9935. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  9936. 'asArray' => true
  9937. ) );
  9938. foreach ( $receiptList as $r => $l ) {
  9939. $category = $Lcategory->getOne ( array (
  9940. 'where' => 'cid=' . $l ['cid'],
  9941. 'asArray' => true
  9942. ) );
  9943. $staffDetile = $staff->getOne ( array (
  9944. 'where' => 'sid=' . $l ['staff'],
  9945. 'asArray' => true
  9946. ) );
  9947. $html .= '
  9948. <tr>
  9949. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  9950. <td align="left">
  9951. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  9952. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  9953. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  9954. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  9955. </tr>';
  9956. }
  9957. }
  9958. $html .= '
  9959. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  9960. <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>
  9961. </tr></tbody></table></td></tr></tbody></table></div><br>';
  9962. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  9963. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  9964. // $receipt=new receipt();
  9965. // $receipt->notice=1;
  9966. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  9967. }
  9968. }
  9969. }
  9970. }
  9971. function setWXMsg($rid, $type) {
  9972. Doo::loadModel ( "receipt" );
  9973. $receipt = new receipt ();
  9974. $receiptDetail = $receipt->getOne ( array (
  9975. 'where' => 'rid=' . $rid,
  9976. 'asArray' => true
  9977. ) );
  9978. if (! empty ( $receiptDetail )) {
  9979. Doo::loadModel ( 'staff' );
  9980. $staff = new staff ();
  9981. $staffmsg = $staff->getOne(array('where' => "sid='". $receiptDetail['staff'] ."'", 'asArray' => TRUE));
  9982. if (! empty ( $staffmsg ['wxid'] )) {
  9983. require_once (SITE_PATH . '/protected/class/client.php');
  9984. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  9985. $user = $staffmsg ['wxid'];
  9986. $receiptName = '';
  9987. $msg = '';
  9988. switch ($receiptDetail ['Rtype']) {
  9989. case 0 :
  9990. $receiptName = '报销';
  9991. break;
  9992. case 1 :
  9993. $receiptName = '借款';
  9994. break;
  9995. case 2 :
  9996. $receiptName = '对公汇款';
  9997. break;
  9998. }
  9999. switch ($type) {
  10000. case 1 :
  10001. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  10002. break;
  10003. case 2 :
  10004. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  10005. break;
  10006. case 3 :
  10007. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  10008. break;
  10009. }
  10010. $result = $client->SendMsg ( $user, $msg, 'text' );
  10011. }
  10012. }
  10013. }
  10014. // Email发送函数
  10015. function SMail($toemail, $subject, $contents) {
  10016. Doo::loadClass ( 'class.phpmailer' );
  10017. $mail = new PHPMailer ();
  10018. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  10019. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  10020. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  10021. $mail->Password = "cDO1GjtY1seH"; // 密码
  10022. $mail->CharSet = "UTF8";
  10023. $mail->SMTPAuth = true;
  10024. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  10025. $mail->Mailer = "smtp";
  10026. $mail->Port = 25;
  10027. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  10028. $mail->MsgHTML ( $contents );
  10029. $mail->AddAddress ( $toemail );
  10030. $mail->CharSet = "UTF-8";
  10031. return $mail->Send ();
  10032. }
  10033. function swfupload() {
  10034. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  10035. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  10036. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  10037. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  10038. header ( "HTTP/1.1 500 Internal Server Error" );
  10039. echo "POST exceeded maximum allowed size.";
  10040. exit ( 0 );
  10041. }
  10042. // Settings
  10043. $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)
  10044. $upload_name = "Filedata";
  10045. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  10046. $extension_whitelist = array (
  10047. "doc",
  10048. "txt",
  10049. "jpg",
  10050. "gif",
  10051. "png"
  10052. ); // Allowed file extensions
  10053. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  10054. // Other variables
  10055. $MAX_FILENAME_LENGTH = 260;
  10056. $file_name = "";
  10057. $file_extension = "";
  10058. $uploadErrors = array (
  10059. 0 => "文件上传成功",
  10060. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  10061. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  10062. 3 => "上传的文件仅为部分文件",
  10063. 4 => "没有文件上传",
  10064. 6 => "缺少临时文件夹"
  10065. );
  10066. $nk = time ();
  10067. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  10068. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  10069. echo "文件无法保存.";
  10070. exit ( 0 );
  10071. }
  10072. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  10073. echo json_encode ( array (
  10074. 'filename' => $file_name,
  10075. 'id' => $nk
  10076. ) );
  10077. exit ( 0 );
  10078. }
  10079. function _GetFileEXT($filename) {
  10080. $pics = explode ( '.', $filename );
  10081. $num = count ( $pics );
  10082. return $pics [$num - 1];
  10083. }
  10084. /**
  10085. * 获取get或者POST值
  10086. * @param string $name 属性名称
  10087. * @return fixed 值
  10088. */
  10089. function get_args($name) {
  10090. if (isset ( $_GET [$name] )) {
  10091. if (is_array ( $_GET [$name] ))
  10092. return $_GET [$name];
  10093. else
  10094. return addslashes ( $_GET [$name] );
  10095. } elseif (isset ( $_POST [$name] )) {
  10096. if (is_array ( $_POST [$name] ))
  10097. return $_POST [$name];
  10098. else
  10099. return addslashes ( $_POST [$name] );
  10100. } else
  10101. return false;
  10102. }
  10103. function num_to_rmb($num) {
  10104. $c1 = "零壹贰叁肆伍陆柒捌玖";
  10105. $c2 = "分角元拾佰仟万拾佰仟亿";
  10106. // 精确到分后面就不要了,所以只留两个小数位
  10107. $num = round ( $num, 2 );
  10108. // 将数字转化为整数
  10109. $num = $num * 100;
  10110. if (strlen ( $num ) > 10) {
  10111. return "金额太大,请检查";
  10112. }
  10113. $i = 0;
  10114. $c = "";
  10115. while ( 1 ) {
  10116. if ($i == 0) {
  10117. // 获取最后一位数字
  10118. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  10119. } else {
  10120. $n = $num % 10;
  10121. }
  10122. // 每次将最后一位数字转化为中文
  10123. $p1 = substr ( $c1, 3 * $n, 3 );
  10124. $p2 = substr ( $c2, 3 * $i, 3 );
  10125. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  10126. $c = $p1 . $p2 . $c;
  10127. } else {
  10128. $c = $p1 . $c;
  10129. }
  10130. $i = $i + 1;
  10131. // 去掉数字最后一位了
  10132. $num = $num / 10;
  10133. $num = ( int ) $num;
  10134. // 结束循环
  10135. if ($num == 0) {
  10136. break;
  10137. }
  10138. }
  10139. $j = 0;
  10140. $slen = strlen ( $c );
  10141. while ( $j < $slen ) {
  10142. // utf8一个汉字相当3个字符
  10143. $m = substr ( $c, $j, 6 );
  10144. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  10145. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  10146. $left = substr ( $c, 0, $j );
  10147. $right = substr ( $c, $j + 3 );
  10148. $c = $left . $right;
  10149. $j = $j - 3;
  10150. $slen = $slen - 3;
  10151. }
  10152. $j = $j + 3;
  10153. }
  10154. // 这个是为了去掉类似23.0中最后一个“零”字
  10155. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  10156. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  10157. }
  10158. // 将处理的汉字加上“整”
  10159. if (empty ( $c )) {
  10160. return "零元整";
  10161. } else {
  10162. return $c . "整";
  10163. }
  10164. }
  10165. /**
  10166. * 获得分页数据
  10167. * @param unknown_type $table
  10168. * @param unknown_type $condition
  10169. * @param unknown_type $on_page
  10170. * @param unknown_type $page_size
  10171. */
  10172. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  10173. $page_c = "";
  10174. $page ['previous'] = $this->get_previous ( $on_page );
  10175. $page ['on_page'] = $on_page;
  10176. $total_count = $this->get_table_count ( $table, $condition );
  10177. $total = intval ( $total_count / $page_size );
  10178. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  10179. $page ['total_data'] = $total_count;
  10180. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  10181. $i = 1;
  10182. $page_max = 1;
  10183. $page_width = 3;
  10184. if ($on_page >= $page_width) {
  10185. $page_max = intval ( $on_page / $page_width ) + 1;
  10186. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  10187. }
  10188. for(; $i <= $page ['total_page']; $i ++) {
  10189. if ($i == $on_page)
  10190. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  10191. else
  10192. $page_c .= '<li><a href="/' . $action . '/0/' . $i . $get . '">' . $i . '</a></li>';
  10193. if ($i == ($page_width * $page_max))
  10194. break;
  10195. }
  10196. $page ['page'] = $page_c;
  10197. $page ['lower'] = (-- $on_page) * $page_size;
  10198. return $page;
  10199. }
  10200. /**
  10201. * 获取总页数
  10202. * @param unknown_type $table
  10203. * @param unknown_type $condition
  10204. */
  10205. public function get_table_count($table = "", $condition = "") {
  10206. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10207. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10208. //echo $sql;die;
  10209. $query = Doo::db ()->query ( $sql );
  10210. $result = $query->fetch ();
  10211. return $result ['count'];
  10212. }
  10213. /**
  10214. * 获取上一页
  10215. * @param unknown_type $on_page
  10216. */
  10217. function get_previous($on_page = 1) {
  10218. return $on_page != 0 ? $on_page - 1 : $on_page;
  10219. }
  10220. }
  10221. ?>