ReceiptController.php 371 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class ReceiptController extends DooController {
  6. public $staff;
  7. public $verifyId;
  8. public $executeId;
  9. // public static $NEW2 = 0;
  10. public $AGENCY = "日常相关费用";
  11. public $TRAVEL = "差旅相关费用";
  12. public $TRAIN = "培训班费用";
  13. public $OTHER = "其他";
  14. private $MYREVEIPTCACHEPATH = "protected/cache/myReceipt/";
  15. private $PERSONALCOLLECTCACHEPATH = "protected/cache/personalCollect/";
  16. private $CATEGORYCOLLECTPATH = "protected/cache/categoryCollect/";
  17. private $STAFFCOLLECTPATH = "protected/cache/staffCollect/";
  18. private function showCache($path) {
  19. if (file_exists ( $path )) {
  20. echo "<!DOCTYPE html>";
  21. include $path;
  22. die ();
  23. }
  24. }
  25. private function cacheFile($path) {
  26. $content = ob_get_contents ();
  27. $fp = fopen ( $path, "w" );
  28. fwrite ( $fp, $content );
  29. fclose ( $fp );
  30. }
  31. // private function getExeCount(){
  32. // Doo::loadModel('receipt');
  33. // $receipt=new receipt();
  34. // $receiptList=$receipt->find(array('where'=>'(executeCopy like \'%["'.$this->staff[0]['sid'].'%\' and executeStaff NOT LIKE \'%'.$this->staff[0]['sid'].'%\' ) and (status=1 or status=6)','desc'=>'rid','asArray'=>true));
  35. // return count($receiptList);
  36. // }
  37. // private function getReceiptCount(){
  38. // $status=2;
  39. // $year=date('Y');
  40. // Doo::loadModel('receipt');
  41. // $receipt=new receipt();
  42. // $dateCondition=" and Year(date) =".$year;
  43. // $approvalCondition=' and (nowStaff like "%,'.$this->staff[0]['sid'].'%" or nowStaff like "%'.$this->staff[0]['sid'].',%" or nowStaff='.$this->staff[0]['sid'].' ) ';
  44. // $receiptList=$receipt->find(array('where'=>' status='.$status.$dateCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  45. // return count($receiptList);
  46. // }
  47. private function collectHtml($receiptCollectList = array(), $itemCategory = "日常相关费用", $classType = "b") {
  48. $collectHtml = "";
  49. $sumPrice = 0.00;
  50. for($i = 1; $i <= 12; $i ++) {
  51. $falg = true;
  52. foreach ( $receiptCollectList as $key => $value ) {
  53. if ($value ['itemCategory'] == $itemCategory && $value ['month'] == $i) {
  54. $sumPrice += $value ['price'];
  55. if ($classType == "b") {
  56. $collectHtml .= '<td class="colGreen taR">¥' . $value ['price'] . '</td>';
  57. $falg = false;
  58. break;
  59. } else {
  60. $collectHtml .= '<td class="taR">¥' . $value ['price'] . '</td>';
  61. $falg = false;
  62. break;
  63. }
  64. }
  65. }
  66. if ($falg)
  67. $collectHtml .= '<td class="taR">-</td>';
  68. }
  69. $collectHtml .= '<td class="taR colGreen">¥' . $sumPrice . '</td>';
  70. return $collectHtml;
  71. }
  72. function __construct() {
  73. if (isset ( $_COOKIE ["staff"] )) {
  74. if (! empty ( $_COOKIE ["staff"] )) {
  75. Doo::loadModel ( 'staff' );
  76. Doo::loadModel ( 'verify' );
  77. $verify = new verify ();
  78. $staff = new staff ();
  79. Doo::loadModel ( "execute" );
  80. $execute = new execute ();
  81. $verifyList = $verify->find ( array (
  82. 'select' => 'staff',
  83. 'asArray' => true
  84. ) );
  85. $list = array ();
  86. // 判断角色的审批权限
  87. foreach ( $verifyList as $key => $value ) {
  88. $ver = json_decode ( $value ['staff'] );
  89. foreach ( $ver as $k => $v ) {
  90. if ($v [1] == 'ROLE') {
  91. $roleList = json_decode ( $v [3] );
  92. foreach ( $roleList as $t => $g ) {
  93. $gList = explode ( "_", $g );
  94. array_push ( $list, $gList [0] );
  95. // print_r($list);
  96. }
  97. } else
  98. array_push ( $list, $v [0] );
  99. }
  100. }
  101. // 判断执行人的审批权限
  102. $executeList = $execute->find ( array (
  103. 'select' => 'staff',
  104. 'asArray' => true
  105. ) );
  106. $list2 = array ();
  107. foreach ( $executeList as $key => $value ) {
  108. $ver = json_decode ( $value ['staff'] );
  109. foreach ( $ver as $k => $v ) {
  110. array_push ( $list2, $v [0] );
  111. }
  112. }
  113. $eidList = file_get_contents ( "protected/config/execute/execute.ini" );
  114. $eidList = array_filter ( explode ( ",", $eidList ) );
  115. $this->executeId = array_merge ( $list2, $eidList );
  116. $this->verifyId = $list;
  117. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  118. return "/";
  119. }
  120. }
  121. Doo::loadCore ( 'uri/DooUriRouter' );
  122. $router = new DooUriRouter ();
  123. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  124. if ($routeRs ['1'] != "login") {
  125. header ( 'Content-Type:text/html;charset=utf-8' );
  126. @header ( "Location: /login" );
  127. }
  128. }
  129. function saeaBorad() {
  130. Doo::loadModel ( 'receipt' );
  131. Doo::loadModel ( 'verify' );
  132. $verify = new verify ();
  133. $receipt = new receipt ();
  134. Doo::loadModel ( 'L_category' );
  135. $lCategory = new L_category ();
  136. Doo::loadModel ( "role" );
  137. $role = new role ();
  138. Doo::loadModel ( "receiptLog" );
  139. $receiptLog = new receiptLog ();
  140. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  141. $receiptDetail = $receipt->find ( array (
  142. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  143. 'desc' => 'rid',
  144. 'asArray' => true
  145. ) );
  146. foreach ( $receiptDetail as $key => $value ) {
  147. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  148. $veList = $verify->getOne ( array (
  149. 'where' => 'vid=' . $value ['verify'],
  150. 'asArray' => true
  151. ) );
  152. $v = json_decode ( $veList ['staff'] );
  153. array_push ( $v [0], $veList ['description'] );
  154. foreach ( $v as $n => $m ) {
  155. if ($m ['1'] == 'ROLE') {
  156. $roleInfo = $role->getOne ( array (
  157. 'where' => 'rid=' . $m [0],
  158. 'asArray' => true
  159. ) );
  160. $v [$n] [1] = $roleInfo ['name'];
  161. }
  162. }
  163. $receiptDetail [$key] ['staff'] = $v;
  164. $category = $lCategory->getOne ( array (
  165. 'where' => 'cid=' . $value ['cid'],
  166. 'asArray' => true
  167. ) );
  168. $receiptDetail [$key] ['category'] = $category ['title'];
  169. }
  170. // print_r($receiptLogList);
  171. $data ['receiptLogList'] = $receiptLogList;
  172. $data ['receiptDetail'] = $receiptDetail;
  173. $data ['memu'] = "receipt";
  174. $data ['staff'] = $this->staff;
  175. $data ['receiptMemu'] = 'saeaBorad';
  176. $data ['verifyId'] = $this->verifyId;
  177. $data ['executeId'] = $this->executeId;
  178. $this->render ( "/admin/saeaBorad", $data );
  179. }
  180. function remitAdd() {
  181. Doo::loadModel ( 'accountItem' );
  182. Doo::loadModel ( 'verify' );
  183. Doo::loadModel ( 'receipt' );
  184. Doo::loadModel ( 'L_category' );
  185. $lCategory = new L_category ();
  186. $receipt = new receipt ();
  187. $verify = new verify ();
  188. $accountItem = new accountItem ();
  189. Doo::loadModel ( "role" );
  190. $role = new role ();
  191. $acItem = $accountItem->find ( array (
  192. 'asArray' => true
  193. ) );
  194. $veList = $verify->find ( array (
  195. 'asArray' => true
  196. ) );
  197. foreach ( $veList as $key => $value ) {
  198. $v = json_decode ( $value ['staff'] );
  199. $list = array ();
  200. foreach ( $v as $n => $m ) {
  201. if ($m ['1'] == 'ROLE') {
  202. $roleInfo = $role->getOne ( array (
  203. 'where' => 'rid=' . $m [0],
  204. 'asArray' => true
  205. ) );
  206. $v [$n] [1] = $roleInfo ['name'];
  207. array_push ( $list, $roleInfo ['name'] );
  208. } else {
  209. array_push ( $list, $v [$n] [1] );
  210. }
  211. }
  212. $veList [$key] ['staff'] = implode ( '>', $list );
  213. }
  214. $data ['category'] = $lCategory->find ( array (
  215. 'asArray' => true
  216. ) );
  217. $data ['veList'] = $veList;
  218. $data ['acItem'] = $acItem;
  219. $data ['memu'] = "receipt";
  220. $data ['staff'] = $this->staff;
  221. $data ['receiptMemu'] = 'saeaBorad';
  222. $data ['verifyId'] = $this->verifyId;
  223. $data ['executeId'] = $this->executeId;
  224. $this->render ( "/admin/remitAdd", $data );
  225. }
  226. function remitAddDo() {
  227. $agency = $this->get_args ( 'agency' );
  228. $travel = $this->get_args ( 'travel' );
  229. $train = $this->get_args ( 'train' );
  230. $other = $this->get_args ( 'other' );
  231. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  232. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  233. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  234. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  235. // print_r($agency);die;
  236. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  237. Doo::loadModel ( 'receipt' );
  238. Doo::loadModel ( 'receiptDetail' );
  239. Doo::loadModel ( 'accountItem' );
  240. $accountItem = new accountItem ();
  241. $receipt = new receipt ();
  242. Doo::loadModel ( 'enclosur' );
  243. Doo::loadModel ( 'execute' );
  244. $execute = new execute ();
  245. $executeDetail = $execute->getOne ( array (
  246. 'where' => 'mold="对公汇款执行人"',
  247. 'asArray' => true
  248. ) );
  249. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  250. $aItem = $accountItem->find ( array (
  251. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  252. 'asArray' => true
  253. ) );
  254. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  255. $ag = $tr = $ta = $ot = 0;
  256. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  257. foreach ( $aItem as $key => $value ) {
  258. if ($value ['category'] == $this->AGENCY) {
  259. if (isset ( $agency [$ag] )) {
  260. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  261. array_push ( $accountJson [$this->AGENCY], array (
  262. 'aid' => $value ['aid'],
  263. 'name' => $value ['name'],
  264. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  265. ) );
  266. $sum += $agency [$ag];
  267. $agencySum += $agency [$ag];
  268. }
  269. }
  270. $ag ++;
  271. }
  272. }
  273. $accountJson ['cSum'] = array (
  274. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  275. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  276. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  277. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  278. );
  279. // 报销单
  280. $receipt->accountItem = json_encode ( $accountJson );
  281. $receipt->staff = $this->staff [0] ['sid'];
  282. $receipt->sum = number_format ( $sum, 2, '.', '' );
  283. $receipt->date = date ( "Y-m-d" );
  284. $receipt->cid = $cid;
  285. $receipt->status = 5;
  286. $receipt->Rtype = 2;
  287. // 修改审批流程加入角色
  288. $receipt->verify = $verify;
  289. $receipt->executeCopy = $executeDetail ['staff'];
  290. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  291. $receipt->explanation = $explanation;
  292. $rid = $receipt->insert ();
  293. // 附件
  294. if (! empty ( $enclosurName )) {
  295. $enclosurArray = explode ( '-', $enclosurName );
  296. foreach ( $enclosurArray as $value ) {
  297. $enclosur = new enclosur ();
  298. $enclosur->name = $value;
  299. $enclosur->rid = $rid;
  300. $enclosur->insert ();
  301. }
  302. // print_r($enclosurArray);die;
  303. }
  304. // 报销详情
  305. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  306. $receiptDetail = new receiptDetail ();
  307. $receiptDetail->staff = $this->staff [0] ['sid'];
  308. $receiptDetail->item = $value ['name'];
  309. $receiptDetail->itemCategory = $this->AGENCY;
  310. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  311. $receiptDetail->date = date ( "Y-m-d" );
  312. $receiptDetail->cid = $cid;
  313. $receiptDetail->rid = $rid;
  314. $receiptDetail->status = 4;
  315. $receiptDetail->insert ();
  316. }
  317. }
  318. return "/saeaBorad";
  319. }
  320. function remitEdit() {
  321. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  322. // echo $rid;
  323. Doo::loadModel ( 'accountItem' );
  324. Doo::loadModel ( 'verify' );
  325. Doo::loadModel ( 'receipt' );
  326. $receipt = new receipt ();
  327. $verify = new verify ();
  328. $accountItem = new accountItem ();
  329. Doo::loadModel ( 'L_category' );
  330. $lCategory = new L_category ();
  331. Doo::loadModel ( "role" );
  332. $role = new role ();
  333. $receiptDetail = $receipt->getOne ( array (
  334. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  335. 'asArray' => true
  336. ) );
  337. if (empty ( $receiptDetail ))
  338. return "/saeaCreate";
  339. $acItem = $accountItem->find ( array (
  340. 'asArray' => true
  341. ) );
  342. $veList = $verify->find ( array (
  343. 'asArray' => true
  344. ) );
  345. foreach ( $veList as $key => $value ) {
  346. $v = json_decode ( $value ['staff'] );
  347. $list = array ();
  348. foreach ( $v as $n => $m ) {
  349. if ($m ['1'] == 'ROLE') {
  350. $roleInfo = $role->getOne ( array (
  351. 'where' => 'rid=' . $m [0],
  352. 'asArray' => true
  353. ) );
  354. $v [$n] [1] = $roleInfo ['name'];
  355. array_push ( $list, $roleInfo ['name'] );
  356. } else {
  357. array_push ( $list, $v [$n] [1] );
  358. }
  359. }
  360. $veList [$key] ['staff'] = implode ( '>', $list );
  361. }
  362. // 配置编辑信息
  363. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  364. foreach ( $acItem as $key => $value ) {
  365. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  366. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  367. $acItem [$key] ['price'] = $v ['price'];
  368. }
  369. }
  370. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  371. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  372. $acItem [$key] ['price'] = $v ['price'];
  373. }
  374. }
  375. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  376. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  377. $acItem [$key] ['price'] = $v ['price'];
  378. }
  379. }
  380. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  381. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  382. $acItem [$key] ['price'] = $v ['price'];
  383. }
  384. }
  385. }
  386. $data ['category'] = $lCategory->find ( array (
  387. 'asArray' => true
  388. ) );
  389. $data ['cSum'] = $accountItemList ['cSum'];
  390. $data ['sum'] = $receiptDetail ['sum'];
  391. $data ['receiptDetail'] = $receiptDetail;
  392. $data ['veList'] = $veList;
  393. $data ['acItem'] = $acItem;
  394. $data ['memu'] = "receipt";
  395. $data ['staff'] = $this->staff;
  396. $data ['receiptMemu'] = 'saeaBorad';
  397. $data ['verify'] = $receiptDetail ['verify'];
  398. $data ['verifyId'] = $this->verifyId;
  399. $data ['executeId'] = $this->executeId;
  400. $data ['rid'] = $rid;
  401. $this->render ( "/admin/remitEdit", $data );
  402. }
  403. function remitEdiDo() {
  404. $agency = $this->get_args ( 'agency' );
  405. $travel = $this->get_args ( 'travel' );
  406. $train = $this->get_args ( 'train' );
  407. $other = $this->get_args ( 'other' );
  408. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  409. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  410. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  411. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  412. if (! empty ( $explanation )) {
  413. Doo::loadModel ( 'receipt' );
  414. Doo::loadModel ( 'receiptDetail' );
  415. Doo::loadModel ( 'accountItem' );
  416. $accountItem = new accountItem ();
  417. $receipt = new receipt ();
  418. Doo::loadModel ( 'execute' );
  419. $execute = new execute ();
  420. $executeDetail = $execute->getOne ( array (
  421. 'where' => 'mold="对公汇款执行人"',
  422. 'asArray' => true
  423. ) );
  424. $receiptDetail = $receipt->getOne ( array (
  425. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  426. 'asArray' => true
  427. ) );
  428. if (empty ( $receiptDetail ))
  429. return "/saeaBorad";
  430. $aItem = $accountItem->find ( array (
  431. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  432. 'asArray' => true
  433. ) );
  434. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  435. $ag = $tr = $ta = $ot = 0;
  436. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  437. foreach ( $aItem as $key => $value ) {
  438. if ($value ['category'] == $this->AGENCY) {
  439. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  440. array_push ( $accountJson [$this->AGENCY], array (
  441. 'aid' => $value ['aid'],
  442. 'name' => $value ['name'],
  443. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  444. ) );
  445. $sum += $agency [$ag];
  446. $agencySum += $agency [$ag];
  447. }
  448. $ag ++;
  449. }
  450. }
  451. $accountJson ['cSum'] = array (
  452. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  453. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  454. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  455. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  456. );
  457. // 报销单
  458. $rid = $receipt->rid = $receiptDetail ['rid'];
  459. $receipt->accountItem = json_encode ( $accountJson );
  460. $receipt->staff = $this->staff [0] ['sid'];
  461. $receipt->sum = number_format ( $sum, 2, '.', '' );
  462. $receipt->date = date ( "Y-m-d" );
  463. $receipt->cid = $cid;
  464. if ($receiptDetail ['Rtype'] == 1)
  465. $receipt->status = 7;
  466. else
  467. $receipt->status = 5;
  468. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  469. $receipt->verify = $verify;
  470. $receipt->executeCopy = $executeDetail ['staff'];
  471. $receipt->explanation = $explanation;
  472. $receipt->update ();
  473. $receiptDetail = new receiptDetail ();
  474. $receiptDetail->delete ( array (
  475. 'where' => 'rid=' . $rid
  476. ) );
  477. // 报销详情
  478. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  479. $receiptDetail = new receiptDetail ();
  480. $receiptDetail->staff = $this->staff [0] ['sid'];
  481. $receiptDetail->item = $value ['name'];
  482. $receiptDetail->itemCategory = $this->AGENCY;
  483. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  484. $receiptDetail->date = date ( "Y-m-d" );
  485. $receiptDetail->cid = $cid;
  486. $receiptDetail->rid = $rid;
  487. $receiptDetail->status = 4;
  488. $receiptDetail->insert ();
  489. }
  490. // return "/referReceipt/".$rid;
  491. }
  492. return "/saeaBorad";
  493. }
  494. function remitApproval() {
  495. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  496. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  497. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  498. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  499. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  500. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  501. if (empty ( $status ))
  502. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  503. $vidList = array ();
  504. $button = 0;
  505. Doo::loadModel ( 'verify' );
  506. Doo::loadModel ( 'receipt' );
  507. Doo::loadModel ( 'staff' );
  508. $staff = new staff ();
  509. $receipt = new receipt ();
  510. $verify = new verify ();
  511. Doo::loadModel ( 'L_category' );
  512. $Lcategory = new L_category ();
  513. Doo::loadModel ( 'enclosur' );
  514. $enclosur = new enclosur ();
  515. // user verify ID
  516. $verifyDetail = $verify->find ( array (
  517. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  518. 'asArray' => true
  519. ) );
  520. foreach ( $verifyDetail as $key => $value ) {
  521. array_push ( $vidList, $value ['vid'] );
  522. }
  523. $vid = implode ( ",", $vidList );
  524. if (empty ( $verifyDetail ))
  525. $vid = 0;
  526. $categoryList = $Lcategory->find ( array (
  527. 'asArray' => true
  528. ) );
  529. $staffList = $staff->find ( array (
  530. 'where' => 'cid=' . $cid,
  531. 'asArray' => true
  532. ) );
  533. $ap = "";
  534. if ($status == 4) {
  535. $ap = 4;
  536. $status = 2;
  537. }
  538. // get Receipt By verifyID status 2
  539. $receiptList = $receipt->find ( array (
  540. 'where' => 'rid =' . $rid,
  541. 'desc' => 'rid',
  542. 'asArray' => true
  543. ) );
  544. $Locate = 0;
  545. $roleId = 0;
  546. if ($ap == 4)
  547. $status = 4;
  548. foreach ( $receiptList as $key => $value ) {
  549. $receiptList [$key] ['Locate'] = $Locate;
  550. $Locate ++;
  551. $receiptList [$key] ['reviseDetail'] = array ();
  552. if (! empty ( $value ['reviseDetail'] ))
  553. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  554. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  555. $categoryDetil = $Lcategory->getOne ( array (
  556. 'where' => 'cid=' . $value ['cid'],
  557. 'asArray' => true
  558. ) );
  559. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  560. // 检测编辑状态
  561. $verifyList = $verify->getOne ( array (
  562. 'where' => 'vid=' . $value ['verify'],
  563. 'asArray' => true
  564. ) );
  565. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  566. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  567. Doo::loadModel ( 'role' );
  568. $role = new role ();
  569. // print_r($verifyList);
  570. $flag = true;
  571. $roleKey = 0;
  572. $endStaffArray = array ();
  573. $roleArrayCopy = array ();
  574. foreach ( $verifyList as $k => $v ) {
  575. // init verifyStaff
  576. if ($v [1] == 'ROLE') {
  577. if (! empty ( $verifyStaff )) {
  578. $endStaffArray = end ( $verifyStaff );
  579. if ($v [0] == $endStaffArray ['nextStaff']) {
  580. $roleId = $v [0];
  581. }
  582. }
  583. $roleVerify = json_decode ( $v [3], true );
  584. $roleKey = $k;
  585. $roleArray = array ();
  586. $rolename = $role->getOne ( array (
  587. 'where' => 'rid=' . $v [0],
  588. 'asArray' => true
  589. ) );
  590. foreach ( $roleVerify as $o => $p ) {
  591. $staffID = explode ( '_', $p );
  592. $staffInfo = $staff->getOne ( array (
  593. 'where' => 'sid=' . $staffID [0],
  594. 'asArray' => true
  595. ) );
  596. // print_r($staffID);
  597. $exp = array (
  598. 0 => $staffInfo ['sid'],
  599. 1 => $staffID [1],
  600. 2 => $staffInfo ['avatar'],
  601. 'date' => '',
  602. 'date' => '',
  603. 'opinion' => '',
  604. 'status' => '',
  605. 'rolename' => $rolename ['name']
  606. );
  607. array_push ( $roleArray, $exp );
  608. }
  609. $roleArrayCopy [$v [0]] = $roleArray;
  610. // $verifyList[$k]['roleArray']=$roleArray;
  611. }
  612. // print_r($roleArray);
  613. $verifyList [$k] ['date'] = "";
  614. $verifyList [$k] ['opinion'] = "";
  615. $verifyList [$k] ['status'] = "";
  616. if (empty ( $verifyStaff )) {
  617. $verifyList [$k] ['date'] = "";
  618. $verifyList [$k] ['opinion'] = "";
  619. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  620. $verifyList [$k] ['status'] = 4;
  621. $button = 4;
  622. $flag = false;
  623. }
  624. } else {
  625. foreach ( $verifyStaff as $m => $u ) {
  626. if ($v [0] == $m) {
  627. $verifyList [$k] ['date'] = $u ['date'];
  628. $verifyList [$k] ['opinion'] = $u ['opinion'];
  629. $verifyList [$k] ['status'] = $u ['status'];
  630. $flag = false;
  631. break;
  632. }
  633. }
  634. $endStaffArray = end ( $verifyStaff );
  635. if (isset ( $endStaffArray ['ROLE'] )) {
  636. } else {
  637. $endKey = key ( $verifyStaff );
  638. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  639. $button = 4;
  640. $verifyList [$k] ['status'] = 4;
  641. }
  642. }
  643. }
  644. }
  645. $rolename ['name'] = '';
  646. if (! empty ( $roleId )) {
  647. Doo::loadModel ( 'role' );
  648. $role = new role ();
  649. $rolename = $role->getOne ( array (
  650. 'where' => 'rid=' . $roleId,
  651. 'asArray' => true
  652. ) );
  653. }
  654. if (! empty ( $verifyStaff ))
  655. $endStaffArray = end ( $verifyStaff );
  656. $KOP = false;
  657. foreach ( $roleArrayCopy as $P => $A ) {
  658. foreach ( $A as $MKI => $AVL ) {
  659. if (! empty ( $verifyStaff )) {
  660. // &&$rolename['rid']==$endStaffArray['nextStaff']
  661. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  662. $button = 4;
  663. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  664. }
  665. foreach ( $verifyStaff as $m => $u ) {
  666. $AVLFK = $AVL [0] . '_R';
  667. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  668. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  669. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  670. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  671. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  672. break;
  673. }
  674. }
  675. } else {
  676. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  677. $button = 4;
  678. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  679. }
  680. }
  681. // $roleArray[$MKI]['rolename']=$rolename['name'];
  682. $KOP = true;
  683. }
  684. }
  685. foreach ( $roleArrayCopy as $k => $v ) {
  686. foreach ( $verifyList as $m => $n ) {
  687. if ($n [0] == $k) {
  688. array_splice ( $verifyList, $m, 1, $v );
  689. }
  690. }
  691. }
  692. $receiptList [$key] ['verifyList'] = $verifyList;
  693. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  694. 'where' => 'sid=' . $value ['staff'],
  695. 'asArray' => true
  696. ) );
  697. $receiptList [$key] ['button'] = $button;
  698. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  699. }
  700. $mothHtml = "";
  701. for($i = 1; $i <= 12; $i ++) {
  702. if ($month == $i)
  703. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  704. else
  705. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  706. }
  707. // 获取审批日志
  708. Doo::loadModel ( 'receiptLog' );
  709. $receiptLog = new receiptLog ();
  710. $rlList = array ();
  711. $rlInfo = $receiptLog->getOne ( array (
  712. 'where' => 'rid=' . $rid . ' and status=4',
  713. 'asArray' => true
  714. ) );
  715. $tijdate = $receiptLog->getOne ( array (
  716. 'where' => 'rid=' . $rid . ' and status=2',
  717. 'asc' => 'rlid',
  718. 'asArray' => true
  719. ) );
  720. if (! empty ( $rlInfo )) {
  721. $rlList = $receiptLog->find ( array (
  722. 'where' => 'rid=' . $rid,
  723. 'asc' => 'rlid',
  724. 'asArray' => true
  725. ) );
  726. }
  727. $receiptList [0] ['rlList'] = $rlList;
  728. $enclosurList = $enclosur->find ( array (
  729. 'where' => 'rid=' . $rid,
  730. 'asArray' => true
  731. ) );
  732. $enclosurHtml = '';
  733. foreach ( $enclosurList as $value ) {
  734. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  735. }
  736. // print_r($receiptList);
  737. $data ['enclosurHtml'] = $enclosurHtml;
  738. $data ['rolename'] = $rolename ['name'];
  739. $data ['datetij'] = $tijdate ['date'];
  740. $data ['mothHtml'] = $mothHtml;
  741. $data ['rid'] = $rid;
  742. $data ['receiptList'] = $receiptList;
  743. $data ['receiptApprovalCount'] = count ( $receiptList );
  744. $data ['status'] = $status;
  745. $data ['year'] = $year;
  746. $data ['categoryList'] = $categoryList;
  747. $data ['staffList'] = $staffList;
  748. $data ['cid'] = $cid;
  749. $data ['sid'] = $sid;
  750. $data ['ap'] = $ap;
  751. $data ['memu'] = "receipt";
  752. $data ['staff'] = $this->staff;
  753. $data ['receiptMemu'] = 'approvalExpenses';
  754. $data ['verifyId'] = $this->verifyId;
  755. $data ['executeId'] = $this->executeId;
  756. $this->render ( "/admin/remitApproval", $data );
  757. }
  758. function saeaLoanAdd() {
  759. Doo::loadModel ( 'verify' );
  760. $verify = new verify ();
  761. Doo::loadModel ( "role" );
  762. $role = new role ();
  763. Doo::loadModel ( 'L_category' );
  764. $lCategory = new L_category ();
  765. $veList = $verify->find ( array (
  766. 'asArray' => true
  767. ) );
  768. foreach ( $veList as $key => $value ) {
  769. $v = json_decode ( $value ['staff'] );
  770. $list = array ();
  771. foreach ( $v as $n => $m ) {
  772. if ($m ['1'] == 'ROLE') {
  773. $roleInfo = $role->getOne ( array (
  774. 'where' => 'rid=' . $m [0],
  775. 'asArray' => true
  776. ) );
  777. $v [$n] [1] = $roleInfo ['name'];
  778. array_push ( $list, $roleInfo ['name'] );
  779. } else {
  780. array_push ( $list, $v [$n] [1] );
  781. }
  782. }
  783. $veList [$key] ['staff'] = implode ( '>', $list );
  784. }
  785. $data ['category'] = $lCategory->find ( array (
  786. 'asArray' => true
  787. ) );
  788. $data ['veList'] = $veList;
  789. $data ['memu'] = "receipt";
  790. $data ['staff'] = $this->staff;
  791. $data ['receiptMemu'] = 'saeaBorad';
  792. $data ['verifyId'] = $this->verifyId;
  793. $data ['executeId'] = $this->executeId;
  794. $this->render ( "/admin/saeaLoanAdd", $data );
  795. }
  796. function saeaLoanAddDo() {
  797. $agency = $this->get_args ( 'agency' );
  798. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  799. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  800. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  801. // die;
  802. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  803. Doo::loadModel ( 'receipt' );
  804. Doo::loadModel ( 'receiptDetail' );
  805. Doo::loadModel ( 'accountItem' );
  806. $accountItem = new accountItem ();
  807. $receipt = new receipt ();
  808. Doo::loadModel ( 'loanReceipt' );
  809. $loanReceipt = new loanReceipt ();
  810. Doo::loadModel ( 'execute' );
  811. $execute = new execute ();
  812. Doo::loadModel ( 'enclosur' );
  813. $executeDetail = $execute->getOne ( array (
  814. 'where' => 'mold="借款执行人"',
  815. 'asArray' => true
  816. ) );
  817. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  818. // if(!empty($receiptDetail))
  819. // return "/referReceipt/".$receiptDetail['rid'];
  820. $aItem = $accountItem->find ( array (
  821. 'asArray' => true
  822. ) );
  823. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  824. $ag = $tr = $ta = $ot = 0;
  825. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  826. array_push ( $accountJson ['借款费用'], array (
  827. 'aid' => 0,
  828. 'name' => '申请金额',
  829. 'price' => number_format ( $agency, 2, '.', '' )
  830. ) );
  831. $sum += $agency;
  832. $agencySum += $agency;
  833. $accountJson ['cSum'] = array (
  834. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  835. 'agencySum' => number_format ( 0, 2, '.', '' ),
  836. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  837. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  838. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  839. );
  840. // 借款数据备份
  841. $loanReceipt->loanItem = json_encode ( $accountJson );
  842. $loanReceipt->staff = $this->staff [0] ['sid'];
  843. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  844. $loanReceipt->date = date ( "Y-m-d" );
  845. $loanReceipt->cid = $cid;
  846. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  847. $loanReceipt->status = 5;
  848. $loanReceipt->Rtype = 1;
  849. $loanReceipt->verify = $verify;
  850. $receipt->receiptOrder = $receipt->receiptOrder;
  851. $loanReceipt->explanation = $explanation;
  852. $loanRid = $loanReceipt->insert ();
  853. // 报销单
  854. $receipt->loanItem = json_encode ( $accountJson );
  855. $receipt->staff = $this->staff [0] ['sid'];
  856. $receipt->sum = number_format ( $sum, 2, '.', '' );
  857. $receipt->date = date ( "Y-m-d" );
  858. $receipt->cid = $cid;
  859. // 特殊状态
  860. $receipt->status = 5;
  861. $receipt->Rtype = 1;
  862. $receipt->loanRid = $loanRid;
  863. // 修改审批流程加入角色
  864. $receipt->verify = $verify;
  865. $receipt->executeCopy = $executeDetail ['staff'];
  866. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  867. $receipt->explanation = $explanation;
  868. $rid = $receipt->insert ();
  869. // 执行数据备份
  870. // $executeCopy->rid=$rid;
  871. // $executeCopy->staff=$executeDetail['staff'];
  872. // $executeCopy->eid=$executeDetail['eid'];
  873. // $ecid=$executeCopy->insert();
  874. }
  875. return "/saeaBorad";
  876. }
  877. function saeaLoanEdi() {
  878. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  879. Doo::loadModel ( 'verify' );
  880. $verify = new verify ();
  881. Doo::loadModel ( "role" );
  882. $role = new role ();
  883. Doo::loadModel ( 'L_category' );
  884. $lCategory = new L_category ();
  885. Doo::loadModel ( 'receipt' );
  886. $receipt = new receipt ();
  887. $receiptInfo = $receipt->getOne ( array (
  888. 'where' => 'rid=' . $rid,
  889. 'asArray' => true
  890. ) );
  891. $veList = $verify->find ( array (
  892. 'asArray' => true
  893. ) );
  894. foreach ( $veList as $key => $value ) {
  895. $v = json_decode ( $value ['staff'] );
  896. $list = array ();
  897. foreach ( $v as $n => $m ) {
  898. if ($m ['1'] == 'ROLE') {
  899. $roleInfo = $role->getOne ( array (
  900. 'where' => 'rid=' . $m [0],
  901. 'asArray' => true
  902. ) );
  903. $v [$n] [1] = $roleInfo ['name'];
  904. array_push ( $list, $roleInfo ['name'] );
  905. } else {
  906. array_push ( $list, $v [$n] [1] );
  907. }
  908. }
  909. $veList [$key] ['staff'] = implode ( '>', $list );
  910. }
  911. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  912. $data ['receiptInfo'] = $receiptInfo;
  913. $data ['category'] = $lCategory->find ( array (
  914. 'asArray' => true
  915. ) );
  916. $data ['veList'] = $veList;
  917. $data ['memu'] = "receipt";
  918. $data ['staff'] = $this->staff;
  919. $data ['receiptMemu'] = 'saeaBorad';
  920. $data ['verifyId'] = $this->verifyId;
  921. $data ['executeId'] = $this->executeId;
  922. $this->render ( "/admin/saeaLoanEdi", $data );
  923. }
  924. function saeaLoanEdiDo() {
  925. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  926. $agency = $this->get_args ( 'agency' );
  927. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  928. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  929. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  930. // die;
  931. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )) {
  932. Doo::loadModel ( 'receipt' );
  933. Doo::loadModel ( 'receiptDetail' );
  934. Doo::loadModel ( 'accountItem' );
  935. $accountItem = new accountItem ();
  936. $receipt = new receipt ();
  937. Doo::loadModel ( 'loanReceipt' );
  938. $loanReceipt = new loanReceipt ();
  939. Doo::loadModel ( 'enclosur' );
  940. Doo::loadModel ( 'execute' );
  941. $execute = new execute ();
  942. $executeDetail = $execute->getOne ( array (
  943. 'where' => 'mold="借款执行人"',
  944. 'asArray' => true
  945. ) );
  946. $receiptDetail = $receipt->getOne ( array (
  947. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  948. 'asArray' => true
  949. ) );
  950. if (empty ( $receiptDetail ))
  951. die ( '参数错误' );
  952. $aItem = $accountItem->find ( array (
  953. 'asArray' => true
  954. ) );
  955. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  956. $ag = $tr = $ta = $ot = 0;
  957. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  958. array_push ( $accountJson ['借款费用'], array (
  959. 'aid' => 0,
  960. 'name' => '申请金额',
  961. 'price' => number_format ( $agency, 2, '.', '' )
  962. ) );
  963. $sum += $agency;
  964. $agencySum += $agency;
  965. $accountJson ['cSum'] = array (
  966. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  967. 'agencySum' => number_format ( 0, 2, '.', '' ),
  968. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  969. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  970. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  971. );
  972. // 报销单
  973. $receipt->loanItem = json_encode ( $accountJson );
  974. $receipt->sum = number_format ( $sum, 2, '.', '' );
  975. $receipt->cid = $cid;
  976. // 特殊状态
  977. // 修改审批流程加入角色
  978. if ($receiptDetail ['status'] != 4)
  979. $receipt->verify = $verify;
  980. $receipt->explanation = $explanation;
  981. $receipt->update ( array (
  982. 'where' => 'rid=' . $rid
  983. ) );
  984. // 借款数据更新
  985. $loanReceipt->loanItem = json_encode ( $accountJson );
  986. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  987. $loanReceipt->cid = $cid;
  988. if ($receiptDetail ['status'] != 4)
  989. $loanReceipt->verify = $verify;
  990. $loanReceipt->explanation = $explanation;
  991. $receipt->executeCopy = $executeDetail ['staff'];
  992. $loanReceipt->update ( array (
  993. 'where' => 'rid=' . $receiptDetail ['loanRid']
  994. ) );
  995. }
  996. return "/saeaBorad";
  997. }
  998. function saeaLoanReceiptAdd() {
  999. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1000. Doo::loadModel ( 'receipt' );
  1001. $receipt = new receipt ();
  1002. Doo::loadModel ( 'loanReceipt' );
  1003. $loanReceipt = new loanReceipt ();
  1004. Doo::loadModel ( 'L_category' );
  1005. $Lcategory = new L_category ();
  1006. Doo::loadModel ( 'verify' );
  1007. Doo::loadModel ( 'statistics' );
  1008. $statistics = new statistics ();
  1009. $verify = new verify ();
  1010. Doo::loadModel ( 'staff' );
  1011. $staff = new staff ();
  1012. $receiptDe = $receipt->getOne ( array (
  1013. 'where' => 'rid=' . $rid,
  1014. 'desc' => 'rid',
  1015. 'asArray' => true
  1016. ) );
  1017. $receiptList = $loanReceipt->find ( array (
  1018. 'where' => 'rid=' . $receiptDe ['loanRid'],
  1019. 'desc' => 'rid',
  1020. 'asArray' => true
  1021. ) );
  1022. $Locate = 0;
  1023. $roleId = 0;
  1024. $button = 0;
  1025. foreach ( $receiptList as $key => $value ) {
  1026. $receiptList [$key] ['Locate'] = $Locate;
  1027. $Locate ++;
  1028. $receiptList [$key] ['reviseDetail'] = array ();
  1029. if (! empty ( $value ['reviseDetail'] ))
  1030. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1031. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1032. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1033. $categoryDetil = $Lcategory->getOne ( array (
  1034. 'where' => 'cid=' . $value ['cid'],
  1035. 'asArray' => true
  1036. ) );
  1037. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1038. // 检测编辑状态
  1039. $verifyList = $verify->getOne ( array (
  1040. 'where' => 'vid=' . $value ['verify'],
  1041. 'asArray' => true
  1042. ) );
  1043. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1044. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1045. Doo::loadModel ( 'role' );
  1046. $role = new role ();
  1047. $flag = true;
  1048. $roleKey = 0;
  1049. $endStaffArray = array ();
  1050. $roleArrayCopy = array ();
  1051. foreach ( $verifyList as $k => $v ) {
  1052. // init verifyStaff
  1053. if ($v [1] == 'ROLE') {
  1054. if (! empty ( $verifyStaff )) {
  1055. $endStaffArray = end ( $verifyStaff );
  1056. // if ($v[0]==$endStaffArray['nextStaff']){
  1057. // $roleId=$v[0];
  1058. // }
  1059. }
  1060. $roleVerify = json_decode ( $v [3], true );
  1061. $roleKey = $k;
  1062. $roleArray = array ();
  1063. $rolename = $role->getOne ( array (
  1064. 'where' => 'rid=' . $v [0],
  1065. 'asArray' => true
  1066. ) );
  1067. foreach ( $roleVerify as $o => $p ) {
  1068. $staffID = explode ( '_', $p );
  1069. $staffInfo = $staff->getOne ( array (
  1070. 'where' => 'sid=' . $staffID [0],
  1071. 'asArray' => true
  1072. ) );
  1073. // print_r($staffID);
  1074. $exp = array (
  1075. 0 => $staffInfo ['sid'],
  1076. 1 => $staffID [1],
  1077. 2 => $staffInfo ['avatar'],
  1078. 'date' => '',
  1079. 'date' => '',
  1080. 'opinion' => '',
  1081. 'status' => '',
  1082. 'rolename' => $rolename ['name']
  1083. );
  1084. array_push ( $roleArray, $exp );
  1085. }
  1086. $roleArrayCopy [$v [0]] = $roleArray;
  1087. // $verifyList[$k]['roleArray']=$roleArray;
  1088. }
  1089. $verifyList [$k] ['date'] = "";
  1090. $verifyList [$k] ['opinion'] = "";
  1091. $verifyList [$k] ['status'] = "";
  1092. if (empty ( $verifyStaff )) {
  1093. $verifyList [$k] ['date'] = "";
  1094. $verifyList [$k] ['opinion'] = "";
  1095. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1096. $verifyList [$k] ['status'] = 4;
  1097. $flag = false;
  1098. }
  1099. } else {
  1100. foreach ( $verifyStaff as $m => $u ) {
  1101. if ($v [0] == $m) {
  1102. $verifyList [$k] ['date'] = $u ['date'];
  1103. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1104. $verifyList [$k] ['status'] = $u ['status'];
  1105. $flag = false;
  1106. break;
  1107. }
  1108. }
  1109. $endStaffArray = end ( $verifyStaff );
  1110. if (isset ( $endStaffArray ['ROLE'] )) {
  1111. } else {
  1112. // $endKey=key($verifyStaff);
  1113. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1114. // $button=4;
  1115. // $verifyList[$k]['status']=4;
  1116. // }
  1117. }
  1118. }
  1119. }
  1120. $rolename ['name'] = '';
  1121. if (! empty ( $roleId )) {
  1122. Doo::loadModel ( 'role' );
  1123. $role = new role ();
  1124. $rolename = $role->getOne ( array (
  1125. 'where' => 'rid=' . $roleId,
  1126. 'asArray' => true
  1127. ) );
  1128. }
  1129. if (! empty ( $verifyStaff ))
  1130. $endStaffArray = end ( $verifyStaff );
  1131. $KOP = false;
  1132. foreach ( $roleArrayCopy as $P => $A ) {
  1133. foreach ( $A as $MKI => $AVL ) {
  1134. if (! empty ( $verifyStaff )) {
  1135. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1136. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1137. $button = 4;
  1138. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1139. }
  1140. foreach ( $verifyStaff as $m => $u ) {
  1141. $AVLFK = $AVL [0] . '_R';
  1142. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1143. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1144. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1145. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1146. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1147. break;
  1148. }
  1149. }
  1150. } else {
  1151. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1152. $button = 4;
  1153. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1154. }
  1155. }
  1156. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1157. $KOP = true;
  1158. }
  1159. }
  1160. foreach ( $roleArrayCopy as $k => $v ) {
  1161. foreach ( $verifyList as $m => $n ) {
  1162. if ($n [0] == $k) {
  1163. array_splice ( $verifyList, $m, 1, $v );
  1164. }
  1165. }
  1166. }
  1167. $receiptList [$key] ['verifyList'] = $verifyList;
  1168. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1169. 'where' => 'sid=' . $value ['staff'],
  1170. 'asArray' => true
  1171. ) );
  1172. $receiptList [$key] ['button'] = $button;
  1173. //
  1174. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1175. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1176. }
  1177. $data ['receiptList'] = $receiptList;
  1178. Doo::loadModel ( 'L_category' );
  1179. $lCategory = new L_category ();
  1180. Doo::loadModel ( 'accountItem' );
  1181. $accountItem = new accountItem ();
  1182. $acItem = $accountItem->find ( array (
  1183. 'asArray' => true
  1184. ) );
  1185. $veList = $verify->find ( array (
  1186. 'asArray' => true
  1187. ) );
  1188. foreach ( $veList as $key => $value ) {
  1189. $v = json_decode ( $value ['staff'] );
  1190. $list = array ();
  1191. foreach ( $v as $n => $m ) {
  1192. if ($m ['1'] == 'ROLE') {
  1193. $roleInfo = $role->getOne ( array (
  1194. 'where' => 'rid=' . $m [0],
  1195. 'asArray' => true
  1196. ) );
  1197. $v [$n] [1] = $roleInfo ['name'];
  1198. array_push ( $list, $roleInfo ['name'] );
  1199. } else {
  1200. array_push ( $list, $v [$n] [1] );
  1201. }
  1202. }
  1203. $veList [$key] ['staff'] = implode ( '>', $list );
  1204. }
  1205. $data ['rid'] = $rid;
  1206. $data ['category'] = $lCategory->find ( array (
  1207. 'asArray' => true
  1208. ) );
  1209. $data ['veList'] = $veList;
  1210. $data ['acItem'] = $acItem;
  1211. $data ['memu'] = "receipt";
  1212. $data ['staff'] = $this->staff;
  1213. $data ['receiptMemu'] = 'saeaBorad';
  1214. $data ['verifyId'] = $this->verifyId;
  1215. $data ['executeId'] = $this->executeId;
  1216. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1217. }
  1218. function saeaLoanReceiptAddDo() {
  1219. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1220. $agency = $this->get_args ( 'agency' );
  1221. $travel = $this->get_args ( 'travel' );
  1222. $train = $this->get_args ( 'train' );
  1223. $other = $this->get_args ( 'other' );
  1224. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1225. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1226. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1227. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1228. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )) {
  1229. Doo::loadModel ( 'receipt' );
  1230. Doo::loadModel ( 'receiptDetail' );
  1231. Doo::loadModel ( 'accountItem' );
  1232. $accountItem = new accountItem ();
  1233. $receipt = new receipt ();
  1234. Doo::loadModel ( 'enclosur' );
  1235. Doo::loadModel ( 'execute' );
  1236. $execute = new execute ();
  1237. $executeDetail = $execute->getOne ( array (
  1238. 'where' => 'mold="借款费用执行人"',
  1239. 'asArray' => true
  1240. ) );
  1241. $receiptDet = $receipt->getOne ( array (
  1242. 'where' => 'rid=' . $rid,
  1243. 'asArray' => true
  1244. ) );
  1245. // if(!empty($receiptDetail))
  1246. // return "/referReceipt/".$receiptDetail['rid'];
  1247. $aItem = $accountItem->find ( array (
  1248. 'asArray' => true
  1249. ) );
  1250. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1251. $ag = $tr = $ta = $ot = 0;
  1252. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1253. foreach ( $aItem as $key => $value ) {
  1254. if ($value ['category'] == $this->AGENCY) {
  1255. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1256. array_push ( $accountJson [$this->AGENCY], array (
  1257. 'aid' => $value ['aid'],
  1258. 'name' => $value ['name'],
  1259. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1260. ) );
  1261. $sum += $agency [$ag];
  1262. $agencySum += $agency [$ag];
  1263. }
  1264. $ag ++;
  1265. }
  1266. if ($value ['category'] == $this->TRAVEL) {
  1267. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1268. array_push ( $accountJson [$this->TRAVEL], array (
  1269. 'aid' => $value ['aid'],
  1270. 'name' => $value ['name'],
  1271. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1272. ) );
  1273. $sum += $travel [$tr];
  1274. $travelSum += $travel [$tr];
  1275. }
  1276. $tr ++;
  1277. }
  1278. if ($value ['category'] == $this->TRAIN) {
  1279. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1280. array_push ( $accountJson [$this->TRAIN], array (
  1281. 'aid' => $value ['aid'],
  1282. 'name' => $value ['name'],
  1283. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1284. ) );
  1285. $sum += $train [$ta];
  1286. $trainSum += $train [$ta];
  1287. }
  1288. $ta ++;
  1289. }
  1290. if ($value ['category'] == $this->OTHER) {
  1291. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1292. array_push ( $accountJson [$this->OTHER], array (
  1293. 'aid' => $value ['aid'],
  1294. 'name' => $value ['name'],
  1295. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1296. ) );
  1297. $sum += $other [$ot];
  1298. $otherSum += $other [$ot];
  1299. }
  1300. $ot ++;
  1301. }
  1302. }
  1303. $accountJson ['cSum'] = array (
  1304. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1305. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1306. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1307. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1308. );
  1309. // 报销单
  1310. $receipt->accountItem = json_encode ( $accountJson );
  1311. $receipt->staff = $this->staff [0] ['sid'];
  1312. $receipt->loanSum = $receiptDet ['sum'];
  1313. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1314. $receipt->date = date ( "Y-m-d" );
  1315. $receipt->pastDate = '';
  1316. $receipt->cid = $cid;
  1317. $receipt->status = 7;
  1318. // 修改审批流程加入角色
  1319. $receipt->verify = $verify;
  1320. $receipt->verifyStaff = '';
  1321. $receipt->executeStaff = '';
  1322. $receipt->executeCopy = $executeDetail ['staff'];
  1323. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  1324. $receipt->explanation = $explanation;
  1325. $receipt->update ( array (
  1326. 'where' => 'rid=' . $rid
  1327. ) );
  1328. // 附件
  1329. if (! empty ( $enclosurName )) {
  1330. $enclosurArray = explode ( '-', $enclosurName );
  1331. foreach ( $enclosurArray as $value ) {
  1332. $enclosur = new enclosur ();
  1333. $enclosur->name = $value;
  1334. $enclosur->rid = $rid;
  1335. $enclosur->insert ();
  1336. }
  1337. // print_r($enclosurArray);die;
  1338. }
  1339. // 报销详情
  1340. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1341. $receiptDetail = new receiptDetail ();
  1342. $receiptDetail->staff = $this->staff [0] ['sid'];
  1343. $receiptDetail->item = $value ['name'];
  1344. $receiptDetail->itemCategory = $this->AGENCY;
  1345. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1346. $receiptDetail->date = date ( "Y-m-d" );
  1347. $receiptDetail->cid = $cid;
  1348. $receiptDetail->rid = $rid;
  1349. $receiptDetail->status = 4;
  1350. $receiptDetail->insert ();
  1351. }
  1352. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1353. $receiptDetail = new receiptDetail ();
  1354. $receiptDetail->staff = $this->staff [0] ['sid'];
  1355. $receiptDetail->item = $value ['name'];
  1356. $receiptDetail->itemCategory = $this->TRAVEL;
  1357. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1358. $receiptDetail->date = date ( "Y-m-d" );
  1359. $receiptDetail->cid = $cid;
  1360. $receiptDetail->rid = $rid;
  1361. $receiptDetail->status = 4;
  1362. $receiptDetail->insert ();
  1363. }
  1364. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1365. $receiptDetail = new receiptDetail ();
  1366. $receiptDetail->staff = $this->staff [0] ['sid'];
  1367. $receiptDetail->item = $value ['name'];
  1368. $receiptDetail->itemCategory = $this->TRAIN;
  1369. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1370. $receiptDetail->date = date ( "Y-m-d" );
  1371. $receiptDetail->cid = $cid;
  1372. $receiptDetail->rid = $rid;
  1373. $receiptDetail->status = 4;
  1374. $receiptDetail->insert ();
  1375. }
  1376. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1377. $receiptDetail = new receiptDetail ();
  1378. $receiptDetail->staff = $this->staff [0] ['sid'];
  1379. $receiptDetail->item = $value ['name'];
  1380. $receiptDetail->itemCategory = $this->OTHER;
  1381. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1382. $receiptDetail->date = date ( "Y-m-d" );
  1383. $receiptDetail->cid = $cid;
  1384. $receiptDetail->rid = $rid;
  1385. $receiptDetail->status = 4;
  1386. $receiptDetail->insert ();
  1387. }
  1388. return "/saeaBorad";
  1389. }
  1390. return "/saeaLoanReceiptAdd/" . $rid;
  1391. }
  1392. function saeaLoanReceiptEdi() {
  1393. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1394. // echo $rid;
  1395. Doo::loadModel ( 'accountItem' );
  1396. Doo::loadModel ( 'verify' );
  1397. Doo::loadModel ( 'receipt' );
  1398. $receipt = new receipt ();
  1399. $verify = new verify ();
  1400. $accountItem = new accountItem ();
  1401. Doo::loadModel ( 'L_category' );
  1402. $Lcategory = new L_category ();
  1403. Doo::loadModel ( "role" );
  1404. $role = new role ();
  1405. Doo::loadModel ( 'loanReceipt' );
  1406. $loanReceipt = new loanReceipt ();
  1407. Doo::loadModel ( 'staff' );
  1408. $staff = new staff ();
  1409. $receiptDetail = $receipt->getOne ( array (
  1410. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  1411. 'asArray' => true
  1412. ) );
  1413. if (empty ( $receiptDetail ))
  1414. return "/saeaBorad";
  1415. $receiptList = $loanReceipt->find ( array (
  1416. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1417. 'desc' => 'rid',
  1418. 'asArray' => true
  1419. ) );
  1420. $Locate = 0;
  1421. $roleId = 0;
  1422. $button = 0;
  1423. foreach ( $receiptList as $key => $value ) {
  1424. $receiptList [$key] ['Locate'] = $Locate;
  1425. $Locate ++;
  1426. $receiptList [$key] ['reviseDetail'] = array ();
  1427. if (! empty ( $value ['reviseDetail'] ))
  1428. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1429. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1430. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1431. $categoryDetil = $Lcategory->getOne ( array (
  1432. 'where' => 'cid=' . $value ['cid'],
  1433. 'asArray' => true
  1434. ) );
  1435. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1436. // 检测编辑状态
  1437. $verifyList = $verify->getOne ( array (
  1438. 'where' => 'vid=' . $value ['verify'],
  1439. 'asArray' => true
  1440. ) );
  1441. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1442. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1443. Doo::loadModel ( 'role' );
  1444. $role = new role ();
  1445. $flag = true;
  1446. $roleKey = 0;
  1447. $endStaffArray = array ();
  1448. $roleArrayCopy = array ();
  1449. foreach ( $verifyList as $k => $v ) {
  1450. // init verifyStaff
  1451. if ($v [1] == 'ROLE') {
  1452. if (! empty ( $verifyStaff )) {
  1453. $endStaffArray = end ( $verifyStaff );
  1454. // if ($v[0]==$endStaffArray['nextStaff']){
  1455. // $roleId=$v[0];
  1456. // }
  1457. }
  1458. $roleVerify = json_decode ( $v [3], true );
  1459. $roleKey = $k;
  1460. $roleArray = array ();
  1461. $rolename = $role->getOne ( array (
  1462. 'where' => 'rid=' . $v [0],
  1463. 'asArray' => true
  1464. ) );
  1465. foreach ( $roleVerify as $o => $p ) {
  1466. $staffID = explode ( '_', $p );
  1467. $staffInfo = $staff->getOne ( array (
  1468. 'where' => 'sid=' . $staffID [0],
  1469. 'asArray' => true
  1470. ) );
  1471. // print_r($staffID);
  1472. $exp = array (
  1473. 0 => $staffInfo ['sid'],
  1474. 1 => $staffID [1],
  1475. 2 => $staffInfo ['avatar'],
  1476. 'date' => '',
  1477. 'date' => '',
  1478. 'opinion' => '',
  1479. 'status' => '',
  1480. 'rolename' => $rolename ['name']
  1481. );
  1482. array_push ( $roleArray, $exp );
  1483. }
  1484. $roleArrayCopy [$v [0]] = $roleArray;
  1485. // $verifyList[$k]['roleArray']=$roleArray;
  1486. }
  1487. $verifyList [$k] ['date'] = "";
  1488. $verifyList [$k] ['opinion'] = "";
  1489. $verifyList [$k] ['status'] = "";
  1490. if (empty ( $verifyStaff )) {
  1491. $verifyList [$k] ['date'] = "";
  1492. $verifyList [$k] ['opinion'] = "";
  1493. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1494. $verifyList [$k] ['status'] = 4;
  1495. $flag = false;
  1496. }
  1497. } else {
  1498. foreach ( $verifyStaff as $m => $u ) {
  1499. if ($v [0] == $m) {
  1500. $verifyList [$k] ['date'] = $u ['date'];
  1501. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1502. $verifyList [$k] ['status'] = $u ['status'];
  1503. $flag = false;
  1504. break;
  1505. }
  1506. }
  1507. $endStaffArray = end ( $verifyStaff );
  1508. if (isset ( $endStaffArray ['ROLE'] )) {
  1509. } else {
  1510. // $endKey=key($verifyStaff);
  1511. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1512. // $button=4;
  1513. // $verifyList[$k]['status']=4;
  1514. // }
  1515. }
  1516. }
  1517. }
  1518. $rolename ['name'] = '';
  1519. if (! empty ( $roleId )) {
  1520. Doo::loadModel ( 'role' );
  1521. $role = new role ();
  1522. $rolename = $role->getOne ( array (
  1523. 'where' => 'rid=' . $roleId,
  1524. 'asArray' => true
  1525. ) );
  1526. }
  1527. if (! empty ( $verifyStaff ))
  1528. $endStaffArray = end ( $verifyStaff );
  1529. $KOP = false;
  1530. foreach ( $roleArrayCopy as $P => $A ) {
  1531. foreach ( $A as $MKI => $AVL ) {
  1532. if (! empty ( $verifyStaff )) {
  1533. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1534. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1535. $button = 4;
  1536. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1537. }
  1538. foreach ( $verifyStaff as $m => $u ) {
  1539. $AVLFK = $AVL [0] . '_R';
  1540. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1541. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1542. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1543. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1544. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1545. break;
  1546. }
  1547. }
  1548. } else {
  1549. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1550. $button = 4;
  1551. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1552. }
  1553. }
  1554. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1555. $KOP = true;
  1556. }
  1557. }
  1558. foreach ( $roleArrayCopy as $k => $v ) {
  1559. foreach ( $verifyList as $m => $n ) {
  1560. if ($n [0] == $k) {
  1561. array_splice ( $verifyList, $m, 1, $v );
  1562. }
  1563. }
  1564. }
  1565. $receiptList [$key] ['verifyList'] = $verifyList;
  1566. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1567. 'where' => 'sid=' . $value ['staff'],
  1568. 'asArray' => true
  1569. ) );
  1570. $receiptList [$key] ['button'] = $button;
  1571. //
  1572. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1573. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1574. }
  1575. $data ['receiptList'] = $receiptList;
  1576. $acItem = $accountItem->find ( array (
  1577. 'asArray' => true
  1578. ) );
  1579. $veList = $verify->find ( array (
  1580. 'asArray' => true
  1581. ) );
  1582. foreach ( $veList as $key => $value ) {
  1583. $v = json_decode ( $value ['staff'] );
  1584. $list = array ();
  1585. foreach ( $v as $n => $m ) {
  1586. if ($m ['1'] == 'ROLE') {
  1587. $roleInfo = $role->getOne ( array (
  1588. 'where' => 'rid=' . $m [0],
  1589. 'asArray' => true
  1590. ) );
  1591. $v [$n] [1] = $roleInfo ['name'];
  1592. array_push ( $list, $roleInfo ['name'] );
  1593. } else {
  1594. array_push ( $list, $v [$n] [1] );
  1595. }
  1596. }
  1597. $veList [$key] ['staff'] = implode ( '>', $list );
  1598. }
  1599. // 配置编辑信息
  1600. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1601. foreach ( $acItem as $key => $value ) {
  1602. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1603. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1604. $acItem [$key] ['price'] = $v ['price'];
  1605. }
  1606. }
  1607. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1608. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1609. $acItem [$key] ['price'] = $v ['price'];
  1610. }
  1611. }
  1612. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1613. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1614. $acItem [$key] ['price'] = $v ['price'];
  1615. }
  1616. }
  1617. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1618. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1619. $acItem [$key] ['price'] = $v ['price'];
  1620. }
  1621. }
  1622. }
  1623. $data ['category'] = $Lcategory->find ( array (
  1624. 'asArray' => true
  1625. ) );
  1626. $data ['cSum'] = $accountItemList ['cSum'];
  1627. $data ['sum'] = $receiptDetail ['sum'];
  1628. $data ['receiptDetail'] = $receiptDetail;
  1629. $data ['veList'] = $veList;
  1630. $data ['acItem'] = $acItem;
  1631. $data ['memu'] = "receipt";
  1632. $data ['staff'] = $this->staff;
  1633. $data ['receiptMemu'] = 'saeaBorad';
  1634. $data ['verify'] = $receiptDetail ['verify'];
  1635. $data ['verifyId'] = $this->verifyId;
  1636. $data ['executeId'] = $this->executeId;
  1637. $data ['rid'] = $rid;
  1638. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  1639. }
  1640. function confirmation() {
  1641. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1642. Doo::loadModel ( 'receipt' );
  1643. Doo::loadModel ( 'receiptDetail' );
  1644. $receipt = new receipt ();
  1645. $receiptDetail = new receiptDetail ();
  1646. Doo::loadModel ( 'statistics' );
  1647. Doo::loadModel ( 'itemStatistics' );
  1648. $statistics = new statistics ();
  1649. $itemStatistics = new itemStatistics ();
  1650. Doo::loadModel ( "verify" );
  1651. $verify = new verify ();
  1652. $receiptDetailList = $receipt->getOne ( array (
  1653. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  1654. 'asArray' => true
  1655. ) );
  1656. if (empty ( $receiptDetailList ))
  1657. return "/saeaBorad";
  1658. $verifyDetail = $verify->getOne ( array (
  1659. 'where' => ' vid =' . $receiptDetailList ['verify'],
  1660. 'asArray' => true
  1661. ) );
  1662. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  1663. if (empty ( $receiptDetailList ['nowStaff'] )) {
  1664. $nowStaff = "";
  1665. $nowStaffList = array ();
  1666. if ($verifyDetail [0] [1] == 'ROLE') {
  1667. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  1668. foreach ( $vStaffString as $key => $value ) {
  1669. $staffK = explode ( "_", $value );
  1670. array_push ( $nowStaffList, $staffK [0] );
  1671. }
  1672. $nowStaff = implode ( ',', $nowStaffList );
  1673. } else {
  1674. $nowStaff = $verifyDetail [0] [0];
  1675. }
  1676. $receipt->nowStaff = $nowStaff;
  1677. }
  1678. // echo $nowStaff;
  1679. // print_r($verifyDetail);die;
  1680. $receipt->rid = $receiptDetailList ['rid'];
  1681. $receipt->status = 2;
  1682. $receipt->update ();
  1683. // 操作日志
  1684. Doo::loadModel ( "receiptLog" );
  1685. $receiptLog = new receiptLog ();
  1686. $verify = new verify ();
  1687. $receiptInfo = $receipt->getOne ( array (
  1688. 'where' => 'rid=' . $rid,
  1689. 'asArray' => true
  1690. ) );
  1691. $vr = $verify->getOne ( array (
  1692. 'where' => 'vid=' . $receiptInfo ['verify'],
  1693. 'asArray' => true
  1694. ) );
  1695. $jd = json_decode ( $vr ['staff'] );
  1696. $roleId = 0;
  1697. foreach ( $jd as $key => $value ) {
  1698. if ($value [1] == 'ROLE') {
  1699. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  1700. if ($pos !== false) {
  1701. $roleId = $value [0];
  1702. }
  1703. }
  1704. }
  1705. // 审批日志
  1706. // echo $roleId;die;
  1707. if (! empty ( $roleId )) {
  1708. Doo::loadModel ( "role" );
  1709. $role = new role ();
  1710. $roleInfo = $role->getOne ( array (
  1711. 'where' => 'rid=' . $roleId,
  1712. 'asArray' => true
  1713. ) );
  1714. $receiptLog->rolename = $roleInfo ['name'];
  1715. }
  1716. $receiptLog->username = $this->staff [0] ['username'];
  1717. $receiptLog->uid = $this->staff [0] ['sid'];
  1718. $receiptLog->date = date ( "Y-m-d" );
  1719. $receiptLog->opinion = '提交审批';
  1720. $receiptLog->img = $this->staff [0] ['avatar'];
  1721. $receiptLog->status = 2;
  1722. $receiptLog->rid = $rid;
  1723. $receiptLog->insert ();
  1724. return "/expenses";
  1725. }
  1726. function expenses() {
  1727. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  1728. if (empty ( $item ))
  1729. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  1730. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1731. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  1732. Doo::loadModel ( 'receipt' );
  1733. $receipt = new receipt ();
  1734. Doo::loadModel ( 'L_category' );
  1735. $Lcategory = new L_category ();
  1736. Doo::loadModel ( 'verify' );
  1737. Doo::loadModel ( 'statistics' );
  1738. $statistics = new statistics ();
  1739. $verify = new verify ();
  1740. Doo::loadModel ( 'staff' );
  1741. $staff = new staff ();
  1742. $condition = "";
  1743. if ($item == "expenses")
  1744. $condition = " and Rtype=1 ";
  1745. elseif ($item == "receipts")
  1746. $condition = " and Rtype=0 ";
  1747. elseif ($item == "remits")
  1748. $condition = " and Rtype=2 ";
  1749. $dateCondition = " and Year(date) =" . $year;
  1750. if (! empty ( $moth )) {
  1751. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  1752. $stList = $statistics->getOne ( array (
  1753. 'select' => 'rePrice ,agPrice',
  1754. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  1755. 'asArray' => true
  1756. ) );
  1757. } else
  1758. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  1759. if (empty ( $stList ))
  1760. $stList = array (
  1761. 'rePrice' => 0,
  1762. 'agPrice' => 0
  1763. );
  1764. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  1765. if (! isset ( $noPassSum ['sum'] ))
  1766. $noPassSum ['sum'] = 0;
  1767. $data ['stList'] = array (
  1768. 'rePrice' => $stList ['rePrice'],
  1769. 'agPrice' => $stList ['agPrice'],
  1770. 'skPrice' => ($noPassSum ['sum'])
  1771. );
  1772. $receiptList = $receipt->find ( array (
  1773. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  1774. 'desc' => 'rid',
  1775. 'asArray' => true
  1776. ) );
  1777. $Locate = 0;
  1778. $roleId = 0;
  1779. $button = 0;
  1780. foreach ( $receiptList as $key => $value ) {
  1781. $receiptList [$key] ['Locate'] = $Locate;
  1782. $Locate ++;
  1783. $receiptList [$key] ['reviseDetail'] = array ();
  1784. if (! empty ( $value ['reviseDetail'] ))
  1785. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1786. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1787. $categoryDetil = $Lcategory->getOne ( array (
  1788. 'where' => 'cid=' . $value ['cid'],
  1789. 'asArray' => true
  1790. ) );
  1791. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1792. // 检测编辑状态
  1793. $verifyList = $verify->getOne ( array (
  1794. 'where' => 'vid=' . $value ['verify'],
  1795. 'asArray' => true
  1796. ) );
  1797. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1798. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1799. Doo::loadModel ( 'role' );
  1800. $role = new role ();
  1801. $flag = true;
  1802. $roleKey = 0;
  1803. $endStaffArray = array ();
  1804. $roleArrayCopy = array ();
  1805. foreach ( $verifyList as $k => $v ) {
  1806. // init verifyStaff
  1807. if ($v [1] == 'ROLE') {
  1808. if (! empty ( $verifyStaff )) {
  1809. $endStaffArray = end ( $verifyStaff );
  1810. // if ($v[0]==$endStaffArray['nextStaff']){
  1811. // $roleId=$v[0];
  1812. // }
  1813. }
  1814. $roleVerify = json_decode ( $v [3], true );
  1815. $roleKey = $k;
  1816. $roleArray = array ();
  1817. $rolename = $role->getOne ( array (
  1818. 'where' => 'rid=' . $v [0],
  1819. 'asArray' => true
  1820. ) );
  1821. foreach ( $roleVerify as $o => $p ) {
  1822. $staffID = explode ( '_', $p );
  1823. $staffInfo = $staff->getOne ( array (
  1824. 'where' => 'sid=' . $staffID [0],
  1825. 'asArray' => true
  1826. ) );
  1827. // print_r($staffID);
  1828. $exp = array (
  1829. 0 => $staffInfo ['sid'],
  1830. 1 => $staffID [1],
  1831. 2 => $staffInfo ['avatar'],
  1832. 'date' => '',
  1833. 'date' => '',
  1834. 'opinion' => '',
  1835. 'status' => '',
  1836. 'rolename' => $rolename ['name']
  1837. );
  1838. array_push ( $roleArray, $exp );
  1839. }
  1840. $roleArrayCopy [$v [0]] = $roleArray;
  1841. // $verifyList[$k]['roleArray']=$roleArray;
  1842. }
  1843. $verifyList [$k] ['date'] = "";
  1844. $verifyList [$k] ['opinion'] = "";
  1845. $verifyList [$k] ['status'] = "";
  1846. if (empty ( $verifyStaff )) {
  1847. $verifyList [$k] ['date'] = "";
  1848. $verifyList [$k] ['opinion'] = "";
  1849. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1850. $verifyList [$k] ['status'] = 4;
  1851. $flag = false;
  1852. }
  1853. } else {
  1854. foreach ( $verifyStaff as $m => $u ) {
  1855. if ($v [0] == $m) {
  1856. $verifyList [$k] ['date'] = $u ['date'];
  1857. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1858. $verifyList [$k] ['status'] = $u ['status'];
  1859. $flag = false;
  1860. break;
  1861. }
  1862. }
  1863. $endStaffArray = end ( $verifyStaff );
  1864. if (isset ( $endStaffArray ['ROLE'] )) {
  1865. } else {
  1866. // $endKey=key($verifyStaff);
  1867. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1868. // $button=4;
  1869. // $verifyList[$k]['status']=4;
  1870. // }
  1871. }
  1872. }
  1873. }
  1874. $rolename ['name'] = '';
  1875. if (! empty ( $roleId )) {
  1876. Doo::loadModel ( 'role' );
  1877. $role = new role ();
  1878. $rolename = $role->getOne ( array (
  1879. 'where' => 'rid=' . $roleId,
  1880. 'asArray' => true
  1881. ) );
  1882. }
  1883. if (! empty ( $verifyStaff ))
  1884. $endStaffArray = end ( $verifyStaff );
  1885. $KOP = false;
  1886. foreach ( $roleArrayCopy as $P => $A ) {
  1887. foreach ( $A as $MKI => $AVL ) {
  1888. if (! empty ( $verifyStaff )) {
  1889. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1890. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1891. $button = 4;
  1892. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1893. }
  1894. foreach ( $verifyStaff as $m => $u ) {
  1895. $AVLFK = $AVL [0] . '_R';
  1896. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1897. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1898. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1899. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1900. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1901. break;
  1902. }
  1903. }
  1904. } else {
  1905. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1906. $button = 4;
  1907. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1908. }
  1909. }
  1910. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1911. $KOP = true;
  1912. }
  1913. }
  1914. foreach ( $roleArrayCopy as $k => $v ) {
  1915. foreach ( $verifyList as $m => $n ) {
  1916. if ($n [0] == $k) {
  1917. array_splice ( $verifyList, $m, 1, $v );
  1918. }
  1919. }
  1920. }
  1921. $receiptList [$key] ['verifyList'] = $verifyList;
  1922. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1923. 'where' => 'sid=' . $value ['staff'],
  1924. 'asArray' => true
  1925. ) );
  1926. $receiptList [$key] ['button'] = $button;
  1927. }
  1928. // print_r($receiptList);die;
  1929. $mothHtml = "";
  1930. for($i = 1; $i <= 12; $i ++) {
  1931. if ($moth == $i)
  1932. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  1933. else
  1934. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  1935. }
  1936. $data ['mothHtml'] = $mothHtml;
  1937. $data ['receiptList'] = $receiptList;
  1938. $data ['memu'] = "receipt";
  1939. $data ['staff'] = $this->staff;
  1940. $data ['receiptMemu'] = 'expenses';
  1941. $data ['verifyId'] = $this->verifyId;
  1942. $data ['executeId'] = $this->executeId;
  1943. $data ['item'] = $item;
  1944. $data ['year'] = $year;
  1945. $this->render ( "/admin/expenses", $data );
  1946. }
  1947. function expensesCollect() {
  1948. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1949. Doo::loadModel ( 'receipt' );
  1950. $receipt = new receipt ();
  1951. Doo::loadModel ( 'L_category' );
  1952. $Lcategory = new L_category ();
  1953. Doo::loadModel ( 'verify' );
  1954. Doo::loadModel ( 'statistics' );
  1955. $statistics = new statistics ();
  1956. $verify = new verify ();
  1957. Doo::loadModel ( 'staff' );
  1958. $staff = new staff ();
  1959. Doo::loadModel ( 'loanReceipt' );
  1960. $loanReceipt = new loanReceipt ();
  1961. $receiptList = $receipt->find ( array (
  1962. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  1963. 'desc' => 'rid',
  1964. 'asArray' => true
  1965. ) );
  1966. $loanList = $loanReceipt->find ( array (
  1967. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  1968. 'desc' => 'rid',
  1969. 'asArray' => true
  1970. ) );
  1971. /*
  1972. * $Locate=0;$roleId=0;$button=0; foreach ($loanList as $key=>$value){ $loanList[$key]['Locate']=$Locate;$Locate++; $loanList[$key]['reviseDetail']=array(); if (!empty($value['reviseDetail'])) $loanList[$key]['reviseDetail']=json_decode($value['reviseDetail'],true); $loanList[$key]['accountItem']=json_decode($value['accountItem'],true); $loanList[$key]['loanItem']=json_decode($value['loanItem'],true); $categoryDetil=$Lcategory->getOne(array('where'=>'cid='.$value['cid'],'asArray'=>true)); $loanList[$key]['category']=$categoryDetil['title']; //检测编辑状态 if ($value['status']==3||$value['status']==1||$value['status']==8||$value['status']==9) $verifyList['staff']=$value['verifyBreakup']; else $verifyList=$verify->getOne(array('where'=>'vid='.$value['verify'],'asArray'=>true)); $verifyList=json_decode($verifyList['staff'],true);//status opinion $verifyStaff=json_decode($value['verifyStaff'],true); Doo::loadModel('role'); $role=new role(); $flag=true;$roleKey=0;$endStaffArray=array();$roleArrayCopy=array(); foreach ($verifyList as $k=>$v){ //init verifyStaff if ($v[1]=='ROLE'){ if (!empty($verifyStaff)){ $endStaffArray=end($verifyStaff); // if ($v[0]==$endStaffArray['nextStaff']){ // $roleId=$v[0]; // } } $roleVerify=json_decode($v[3],true); $roleKey=$k;$roleArray=array(); $rolename=$role->getOne(array('where'=>'rid='.$v[0],'asArray'=>true)); foreach ($roleVerify as $o=>$p){ $staffID=explode ('_',$p); $staffInfo=$staff->getOne(array('where'=>'sid='.$staffID[0],'asArray'=>true)); //print_r($staffID); $exp=array(0=>$staffInfo['sid'],1=>$staffID[1],2=>$staffInfo['avatar'],'date'=>'','date'=>'','opinion'=>'','status'=>'','rolename'=>$rolename['name']); array_push($roleArray, $exp); } $roleArrayCopy[$v[0]]=$roleArray; //$verifyList[$k]['roleArray']=$roleArray; } $verifyList[$k]['date']=""; $verifyList[$k]['opinion']=""; $verifyList[$k]['status']=""; if (empty($verifyStaff)){ $verifyList[$k]['date']=""; $verifyList[$k]['opinion']=""; if (($verifyList[0][0]==$this->staff[0]['sid'])&&$flag){ $verifyList[$k]['status']=4; $flag=false; } }else{ foreach ($verifyStaff as $m=>$u){ if ($v[0]==$m){ $verifyList[$k]['date']=$u['date']; $verifyList[$k]['opinion']=$u['opinion']; $verifyList[$k]['status']=$u['status']; $flag=false; break; } } $endStaffArray=end($verifyStaff); if (isset($endStaffArray['ROLE'])){ }else{ // $endKey=key($verifyStaff); // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){ // $button=4; // $verifyList[$k]['status']=4; // } } } } $rolename['name']=''; if (!empty($roleId)){ Doo::loadModel('role'); $role=new role(); $rolename=$role->getOne(array('where'=>'rid='.$roleId,'asArray'=>true)); } if (!empty($verifyStaff)) $endStaffArray=end($verifyStaff); $KOP=false; foreach ($roleArrayCopy as $P=>$A){ foreach ( $A as $MKI=>$AVL){ if (!empty($verifyStaff)){ //&&$rolename['rid']==$endStaffArray['nextStaff'] if ($this->staff[0]['sid']==$AVL[0]&&isset($endStaffArray['ROLE'])&&$rolename['rid']==$endStaffArray['nextStaff']){ $button=4; $roleArrayCopy[$P][$MKI]['status']=4; } foreach ($verifyStaff as $m=>$u){ $AVLFK=$AVL[0].'_R'; //echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>'; if (strcmp($AVLFK,$m)==0){//&&isset($u['ROLE'])&&$u['ROLE']==1 $roleArrayCopy[$P][$MKI]['date']=$u['date']; $roleArrayCopy[$P][$MKI]['opinion']=$u['opinion']; $roleArrayCopy[$P][$MKI]['status']=$u['status']; break; } } }else{ if ($this->staff[0]['sid']==$AVL[0]&&$verifyList[0][1]=='ROLE'){ $button=4; $roleArrayCopy[$P][$MKI]['status']=4; } } //$roleArray[$MKI]['rolename']=$rolename['name']; $KOP=true; } } foreach ($roleArrayCopy as $k=>$v){ foreach ($verifyList as $m=>$n){ if ($n[0]==$k){ array_splice($verifyList,$m,1,$v); } } } $loanList[$key]['verifyList']=$verifyList; $loanList[$key]['staffDetail']=$staff->getOne(array('where'=>'sid='.$value['staff'],'asArray'=>true)); $loanList[$key]['button']=$button; //$loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']); } $data['loanList']=$loanList;
  1973. */
  1974. $Locate = 0;
  1975. $roleId = 0;
  1976. $button = 0;
  1977. foreach ( $receiptList as $key => $value ) {
  1978. $receiptList [$key] ['Locate'] = $Locate;
  1979. $Locate ++;
  1980. $receiptList [$key] ['reviseDetail'] = array ();
  1981. if (! empty ( $value ['reviseDetail'] ))
  1982. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1983. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1984. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1985. $categoryDetil = $Lcategory->getOne ( array (
  1986. 'where' => 'cid=' . $value ['cid'],
  1987. 'asArray' => true
  1988. ) );
  1989. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1990. // 检测编辑状态
  1991. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  1992. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  1993. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  1994. else
  1995. $verifyList ['staff'] = $value ['verifyBreakup'];
  1996. } else
  1997. $verifyList = $verify->getOne ( array (
  1998. 'where' => 'vid=' . $value ['verify'],
  1999. 'asArray' => true
  2000. ) );
  2001. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2002. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2003. Doo::loadModel ( 'role' );
  2004. $role = new role ();
  2005. $flag = true;
  2006. $roleKey = 0;
  2007. $endStaffArray = array ();
  2008. $roleArrayCopy = array ();
  2009. foreach ( $verifyList as $k => $v ) {
  2010. // init verifyStaff
  2011. if ($v [1] == 'ROLE') {
  2012. if (! empty ( $verifyStaff )) {
  2013. $endStaffArray = end ( $verifyStaff );
  2014. // if ($v[0]==$endStaffArray['nextStaff']){
  2015. // $roleId=$v[0];
  2016. // }
  2017. }
  2018. $roleVerify = json_decode ( $v [3], true );
  2019. $roleKey = $k;
  2020. $roleArray = array ();
  2021. $rolename = $role->getOne ( array (
  2022. 'where' => 'rid=' . $v [0],
  2023. 'asArray' => true
  2024. ) );
  2025. foreach ( $roleVerify as $o => $p ) {
  2026. $staffID = explode ( '_', $p );
  2027. $staffInfo = $staff->getOne ( array (
  2028. 'where' => 'sid=' . $staffID [0],
  2029. 'asArray' => true
  2030. ) );
  2031. // print_r($staffID);
  2032. $exp = array (
  2033. 0 => $staffInfo ['sid'],
  2034. 1 => $staffID [1],
  2035. 2 => $staffInfo ['avatar'],
  2036. 'date' => '',
  2037. 'date' => '',
  2038. 'opinion' => '',
  2039. 'status' => '',
  2040. 'rolename' => $rolename ['name']
  2041. );
  2042. array_push ( $roleArray, $exp );
  2043. }
  2044. $roleArrayCopy [$v [0]] = $roleArray;
  2045. // $verifyList[$k]['roleArray']=$roleArray;
  2046. }
  2047. $verifyList [$k] ['date'] = "";
  2048. $verifyList [$k] ['opinion'] = "";
  2049. $verifyList [$k] ['status'] = "";
  2050. if (empty ( $verifyStaff )) {
  2051. $verifyList [$k] ['date'] = "";
  2052. $verifyList [$k] ['opinion'] = "";
  2053. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2054. $verifyList [$k] ['status'] = 4;
  2055. $flag = false;
  2056. }
  2057. } else {
  2058. foreach ( $verifyStaff as $m => $u ) {
  2059. if ($v [0] == $m) {
  2060. $verifyList [$k] ['date'] = $u ['date'];
  2061. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2062. $verifyList [$k] ['status'] = $u ['status'];
  2063. $flag = false;
  2064. break;
  2065. }
  2066. }
  2067. $endStaffArray = end ( $verifyStaff );
  2068. if (isset ( $endStaffArray ['ROLE'] )) {
  2069. } else {
  2070. // $endKey=key($verifyStaff);
  2071. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2072. // $button=4;
  2073. // $verifyList[$k]['status']=4;
  2074. // }
  2075. }
  2076. }
  2077. }
  2078. $rolename ['name'] = '';
  2079. if (! empty ( $roleId )) {
  2080. Doo::loadModel ( 'role' );
  2081. $role = new role ();
  2082. $rolename = $role->getOne ( array (
  2083. 'where' => 'rid=' . $roleId,
  2084. 'asArray' => true
  2085. ) );
  2086. }
  2087. if (! empty ( $verifyStaff ))
  2088. $endStaffArray = end ( $verifyStaff );
  2089. $KOP = false;
  2090. foreach ( $roleArrayCopy as $P => $A ) {
  2091. foreach ( $A as $MKI => $AVL ) {
  2092. if (! empty ( $verifyStaff )) {
  2093. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2094. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2095. $button = 4;
  2096. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2097. }
  2098. foreach ( $verifyStaff as $m => $u ) {
  2099. $AVLFK = $AVL [0] . '_R';
  2100. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2101. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2102. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2103. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2104. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2105. break;
  2106. }
  2107. }
  2108. } else {
  2109. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2110. $button = 4;
  2111. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2112. }
  2113. }
  2114. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2115. $KOP = true;
  2116. }
  2117. }
  2118. foreach ( $roleArrayCopy as $k => $v ) {
  2119. foreach ( $verifyList as $m => $n ) {
  2120. if ($n [0] == $k) {
  2121. array_splice ( $verifyList, $m, 1, $v );
  2122. }
  2123. }
  2124. }
  2125. // 费用执行人相关数据
  2126. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2127. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2128. foreach ( $executeCopy as $k => $v ) {
  2129. $executeCopy [$k] ['date'] = '';
  2130. $executeCopy [$k] ['opinion'] = '';
  2131. $executeCopy [$k] ['status'] = '';
  2132. if (! empty ( $executeStaff ))
  2133. foreach ( $executeStaff as $m => $u ) {
  2134. if ($v [0] == $m) {
  2135. $executeCopy [$k] ['date'] = $u ['date'];
  2136. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2137. $executeCopy [$k] ['status'] = $u ['status'];
  2138. break;
  2139. }
  2140. }
  2141. }
  2142. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2143. $receiptList [$key] ['verifyList'] = $verifyList;
  2144. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2145. 'where' => 'sid=' . $value ['staff'],
  2146. 'asArray' => true
  2147. ) );
  2148. $receiptList [$key] ['button'] = $button;
  2149. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2150. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2151. $relust = $value ['sum'] - $value ['loanSum'];
  2152. $receiptList [$key] ['relust'] = $relust;
  2153. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2154. }
  2155. Doo::loadModel ( 'enclosur' );
  2156. $enclosur = new enclosur ();
  2157. $enclosurList = $enclosur->find ( array (
  2158. 'where' => 'rid=' . $rid,
  2159. 'asArray' => true
  2160. ) );
  2161. $enclosurHtml = '';
  2162. foreach ( $enclosurList as $value ) {
  2163. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2164. }
  2165. $data ['enclosurHtml'] = $enclosurHtml;
  2166. // print_r($receiptList);
  2167. $data ['receiptList'] = $receiptList;
  2168. $data ['memu'] = "receipt";
  2169. $data ['staff'] = $this->staff;
  2170. $data ['receiptMemu'] = 'expenses';
  2171. $data ['verifyId'] = $this->verifyId;
  2172. $data ['executeId'] = $this->executeId;
  2173. $this->render ( "/admin/expensesCollect", $data );
  2174. }
  2175. function approvalExpenses() {
  2176. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  2177. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2178. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2179. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2180. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2181. if (empty ( $status ))
  2182. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  2183. $page_size = 12;
  2184. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2185. $vidList = array ();
  2186. $button = 0;
  2187. Doo::loadModel ( 'verify' );
  2188. $verify = new verify ();
  2189. Doo::loadModel ( 'receipt' );
  2190. $receipt = new receipt ();
  2191. Doo::loadModel ( 'staff' );
  2192. $staff = new staff ();
  2193. Doo::loadModel ( 'L_category' );
  2194. $Lcategory = new L_category ();
  2195. // user verify ID
  2196. $verifyDetail = $verify->find ( array (
  2197. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  2198. 'asArray' => true
  2199. ) );
  2200. foreach ( $verifyDetail as $key => $value ) {
  2201. array_push ( $vidList, $value ['vid'] );
  2202. }
  2203. $vid = implode ( ",", $vidList );
  2204. if (empty ( $verifyDetail ))
  2205. $vid = 0;
  2206. // if ($status==0)
  2207. // $dateCondition="";
  2208. // else
  2209. $dateCondition = " and Year(date) =" . $year;
  2210. if (! empty ( $month ))
  2211. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  2212. if($status == 'done'){
  2213. $dateCondition = " and Year(pastDate) =" . $year;
  2214. if (! empty ( $month ))
  2215. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  2216. }
  2217. $categoryList = $Lcategory->find ( array (
  2218. 'asArray' => true
  2219. ) );
  2220. $staffList = $staff->find ( array (
  2221. 'where' => 'cid=' . $cid,
  2222. 'asArray' => true
  2223. ) );
  2224. $cateCondition = "";
  2225. $staffCondition = "";
  2226. $approvalCondition = "";
  2227. if (! empty ( $cid )){
  2228. $cateCondition = ' and cid=' . $cid;
  2229. }
  2230. if (! empty ( $sid )) {
  2231. $staffCondition = ' and cid=' . $cid.' and staff=' . $sid;
  2232. $cateCondition = "";
  2233. }
  2234. $get="?year=".$year."&month=".$month."&cid=".$cid."&sid=".$sid;
  2235. if ($status == 'pendApproval') {
  2236. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  2237. }
  2238. if ($status == 'ongoing') {
  2239. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  2240. }
  2241. if ($status == 'done') {
  2242. $approvalCondition = ' and (status=8 or status=9 ) ';
  2243. }
  2244. if ($status == 'termination') {
  2245. $approvalCondition = " and status=3";
  2246. }
  2247. // $approvalCondition = " and status=" . $status;
  2248. // if ($status == 2) {
  2249. // // 查找角色审批人
  2250. // }
  2251. // if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  2252. // $approvalCondition = ' and status=2 ';
  2253. // }
  2254. // if ($status == 1) {
  2255. // $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  2256. // }
  2257. // if ($status == 8) {
  2258. // $approvalCondition = ' and (status=' . $status . ' or status=9 ) ';
  2259. // }
  2260. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  2261. $pageinfo ['page'] = array (
  2262. 'previous' => ''
  2263. );
  2264. // if ($status == 0) {
  2265. // $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  2266. // $receiptList = $receipt->find ( array (
  2267. // 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ')',
  2268. // 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2269. // 'desc' => 'rid',
  2270. // 'asArray' => true
  2271. // ) );
  2272. // //echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2273. // } else
  2274. if ($status == 'done' || $status == 'termination') {
  2275. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/".$status, $get, "" );
  2276. $receiptList = $receipt->find ( array (
  2277. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
  2278. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2279. 'desc' => 'rid',
  2280. 'asArray' => true
  2281. ) );
  2282. } else
  2283. $receiptList = $receipt->find ( array (
  2284. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
  2285. 'desc' => 'rid',
  2286. 'asArray' => true
  2287. ) );
  2288. $rLRes = $receipt->find ( array (
  2289. 'where' => 'status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )' . $cateCondition . $staffCondition,
  2290. 'desc' => 'rid',
  2291. 'asArray' => true
  2292. ) );
  2293. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2294. // print_r($pageinfo);
  2295. $Locate = 0;
  2296. foreach ( $receiptList as $key => $value ) {
  2297. $receiptList [$key] ['Locate'] = $Locate;
  2298. $Locate ++;
  2299. $receiptList [$key] ['reviseDetail'] = array ();
  2300. if (! empty ( $value ['reviseDetail'] ))
  2301. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2302. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2303. $categoryDetil = $Lcategory->getOne ( array (
  2304. 'where' => 'cid=' . $value ['cid'],
  2305. 'asArray' => true
  2306. ) );
  2307. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2308. $verifyList = $verify->getOne ( array (
  2309. 'where' => 'vid=' . $value ['verify'],
  2310. 'asArray' => true
  2311. ) );
  2312. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2313. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2314. foreach ( $verifyList as $k => $v ) {
  2315. // init verifyStaff
  2316. $verifyList [$k] ['date'] = "";
  2317. $verifyList [$k] ['opinion'] = "";
  2318. $verifyList [$k] ['status'] = "";
  2319. if (empty ( $verifyStaff )) {
  2320. $verifyList [$k] ['date'] = "";
  2321. $verifyList [$k] ['opinion'] = "";
  2322. if ($v [0] == $this->staff [0] ['sid']) {
  2323. $verifyList [$k] ['status'] = 4;
  2324. $button = 4;
  2325. }
  2326. } else {
  2327. $flag = true;
  2328. foreach ( $verifyStaff as $m => $u ) {
  2329. if ($v [0] == $m) {
  2330. $verifyList [$k] ['date'] = $u ['date'];
  2331. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2332. $verifyList [$k] ['status'] = $u ['status'];
  2333. $flag = false;
  2334. break;
  2335. }
  2336. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  2337. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  2338. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  2339. }
  2340. if ($flag) { // 检测可编辑
  2341. if ($v [0] == $this->staff [0] ['sid']) {
  2342. $verifyList [$k] ['status'] = 4;
  2343. $button = 4;
  2344. }
  2345. }
  2346. }
  2347. }
  2348. $receiptList [$key] ['verifyList'] = $verifyList;
  2349. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2350. 'where' => 'sid=' . $value ['staff'],
  2351. 'asArray' => true
  2352. ) );
  2353. $receiptList [$key] ['button'] = $button;
  2354. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  2355. }
  2356. // print_r($receiptList);die;
  2357. // $data['verifyDetail']=$verifyDetail;
  2358. $mothHtml = "";
  2359. for($i = 1; $i <= 12; $i ++) {
  2360. if ($month == $i)
  2361. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2362. else
  2363. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2364. }
  2365. $data ['mothHtml'] = $mothHtml;
  2366. $data ['page'] = $pageinfo;
  2367. $data ['receiptList'] = $receiptList;
  2368. $data ['receiptApprovalCount'] = count ( $rLRes );
  2369. $data ['status'] = $status;
  2370. $data ['year'] = $year;
  2371. $data ['categoryList'] = $categoryList;
  2372. $data ['staffList'] = $staffList;
  2373. $data ['cid'] = $cid;
  2374. $data ['sid'] = $sid;
  2375. // print_r($receiptList);
  2376. $data ['memu'] = "receipt";
  2377. $data ['staff'] = $this->staff;
  2378. $data ['receiptMemu'] = 'approvalExpenses';
  2379. $data ['verifyId'] = $this->verifyId;
  2380. $data ['executeId'] = $this->executeId;
  2381. $this->render ( "/admin/approvalExpenses", $data );
  2382. }
  2383. function expensesDoc() {
  2384. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2385. Doo::loadModel ( 'receipt' );
  2386. $receipt = new receipt ();
  2387. Doo::loadModel ( 'L_category' );
  2388. $Lcategory = new L_category ();
  2389. Doo::loadModel ( 'verify' );
  2390. Doo::loadModel ( 'statistics' );
  2391. $statistics = new statistics ();
  2392. $verify = new verify ();
  2393. Doo::loadModel ( 'staff' );
  2394. $staff = new staff ();
  2395. Doo::loadModel ( 'loanReceipt' );
  2396. $loanReceipt = new loanReceipt ();
  2397. $receiptList = $receipt->find ( array (
  2398. 'where' => ' rid=' . $rid,
  2399. 'desc' => 'rid',
  2400. 'asArray' => true
  2401. ) );
  2402. $loanList = array ();
  2403. if (! empty ( $receiptList ))
  2404. $loanList = $loanReceipt->find ( array (
  2405. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2406. 'desc' => 'rid',
  2407. 'asArray' => true
  2408. ) );
  2409. $Locate = 0;
  2410. $roleId = 0;
  2411. $button = 0;
  2412. foreach ( $loanList as $key => $value ) {
  2413. $loanList [$key] ['Locate'] = $Locate;
  2414. $Locate ++;
  2415. $loanList [$key] ['reviseDetail'] = array ();
  2416. if (! empty ( $value ['reviseDetail'] ))
  2417. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2418. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2419. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2420. $categoryDetil = $Lcategory->getOne ( array (
  2421. 'where' => 'cid=' . $value ['cid'],
  2422. 'asArray' => true
  2423. ) );
  2424. $loanList [$key] ['category'] = $categoryDetil ['title'];
  2425. // 检测编辑状态
  2426. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  2427. $verifyList ['staff'] = $value ['verifyBreakup'];
  2428. else
  2429. $verifyList = $verify->getOne ( array (
  2430. 'where' => 'vid=' . $value ['verify'],
  2431. 'asArray' => true
  2432. ) );
  2433. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2434. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2435. Doo::loadModel ( 'role' );
  2436. $role = new role ();
  2437. $flag = true;
  2438. $roleKey = 0;
  2439. $endStaffArray = array ();
  2440. $roleArrayCopy = array ();
  2441. foreach ( $verifyList as $k => $v ) {
  2442. // init verifyStaff
  2443. if ($v [1] == 'ROLE') {
  2444. if (! empty ( $verifyStaff )) {
  2445. $endStaffArray = end ( $verifyStaff );
  2446. // if ($v[0]==$endStaffArray['nextStaff']){
  2447. // $roleId=$v[0];
  2448. // }
  2449. }
  2450. $roleVerify = json_decode ( $v [3], true );
  2451. $roleKey = $k;
  2452. $roleArray = array ();
  2453. $rolename = $role->getOne ( array (
  2454. 'where' => 'rid=' . $v [0],
  2455. 'asArray' => true
  2456. ) );
  2457. foreach ( $roleVerify as $o => $p ) {
  2458. $staffID = explode ( '_', $p );
  2459. $staffInfo = $staff->getOne ( array (
  2460. 'where' => 'sid=' . $staffID [0],
  2461. 'asArray' => true
  2462. ) );
  2463. // print_r($staffID);
  2464. $exp = array (
  2465. 0 => $staffInfo ['sid'],
  2466. 1 => $staffID [1],
  2467. 2 => $staffInfo ['avatar'],
  2468. 'date' => '',
  2469. 'date' => '',
  2470. 'opinion' => '',
  2471. 'status' => '',
  2472. 'rolename' => $rolename ['name']
  2473. );
  2474. array_push ( $roleArray, $exp );
  2475. }
  2476. $roleArrayCopy [$v [0]] = $roleArray;
  2477. // $verifyList[$k]['roleArray']=$roleArray;
  2478. }
  2479. $verifyList [$k] ['date'] = "";
  2480. $verifyList [$k] ['opinion'] = "";
  2481. $verifyList [$k] ['status'] = "";
  2482. if (empty ( $verifyStaff )) {
  2483. $verifyList [$k] ['date'] = "";
  2484. $verifyList [$k] ['opinion'] = "";
  2485. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2486. $verifyList [$k] ['status'] = 4;
  2487. $flag = false;
  2488. }
  2489. } else {
  2490. foreach ( $verifyStaff as $m => $u ) {
  2491. if ($v [0] == $m) {
  2492. $verifyList [$k] ['date'] = $u ['date'];
  2493. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2494. $verifyList [$k] ['status'] = $u ['status'];
  2495. $flag = false;
  2496. break;
  2497. }
  2498. }
  2499. $endStaffArray = end ( $verifyStaff );
  2500. if (isset ( $endStaffArray ['ROLE'] )) {
  2501. } else {
  2502. // $endKey=key($verifyStaff);
  2503. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2504. // $button=4;
  2505. // $verifyList[$k]['status']=4;
  2506. // }
  2507. }
  2508. }
  2509. }
  2510. $rolename ['name'] = '';
  2511. if (! empty ( $roleId )) {
  2512. Doo::loadModel ( 'role' );
  2513. $role = new role ();
  2514. $rolename = $role->getOne ( array (
  2515. 'where' => 'rid=' . $roleId,
  2516. 'asArray' => true
  2517. ) );
  2518. }
  2519. if (! empty ( $verifyStaff ))
  2520. $endStaffArray = end ( $verifyStaff );
  2521. $KOP = false;
  2522. foreach ( $roleArrayCopy as $P => $A ) {
  2523. foreach ( $A as $MKI => $AVL ) {
  2524. if (! empty ( $verifyStaff )) {
  2525. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2526. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2527. $button = 4;
  2528. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2529. }
  2530. foreach ( $verifyStaff as $m => $u ) {
  2531. $AVLFK = $AVL [0] . '_R';
  2532. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2533. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2534. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2535. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2536. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2537. break;
  2538. }
  2539. }
  2540. } else {
  2541. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2542. $button = 4;
  2543. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2544. }
  2545. }
  2546. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2547. $KOP = true;
  2548. }
  2549. }
  2550. foreach ( $roleArrayCopy as $k => $v ) {
  2551. foreach ( $verifyList as $m => $n ) {
  2552. if ($n [0] == $k) {
  2553. array_splice ( $verifyList, $m, 1, $v );
  2554. }
  2555. }
  2556. }
  2557. $loanList [$key] ['verifyList'] = $verifyList;
  2558. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  2559. 'where' => 'sid=' . $value ['staff'],
  2560. 'asArray' => true
  2561. ) );
  2562. $loanList [$key] ['button'] = $button;
  2563. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  2564. }
  2565. $data ['loanList'] = $loanList;
  2566. // print_r($loanList);
  2567. $Locate = 0;
  2568. $roleId = 0;
  2569. $button = 0;
  2570. foreach ( $receiptList as $key => $value ) {
  2571. $receiptList [$key] ['Locate'] = $Locate;
  2572. $Locate ++;
  2573. $receiptList [$key] ['reviseDetail'] = array ();
  2574. if (! empty ( $value ['reviseDetail'] ))
  2575. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2576. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2577. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2578. $categoryDetil = $Lcategory->getOne ( array (
  2579. 'where' => 'cid=' . $value ['cid'],
  2580. 'asArray' => true
  2581. ) );
  2582. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2583. // 检测编辑状态
  2584. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  2585. $verifyList ['staff'] = $value ['verifyBreakup'];
  2586. } else
  2587. $verifyList = $verify->getOne ( array (
  2588. 'where' => 'vid=' . $value ['verify'],
  2589. 'asArray' => true
  2590. ) );
  2591. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2592. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2593. Doo::loadModel ( 'role' );
  2594. $role = new role ();
  2595. if ($verifyList == NULL)
  2596. $verifyList = array ();
  2597. $flag = true;
  2598. $roleKey = 0;
  2599. $endStaffArray = array ();
  2600. $roleArrayCopy = array ();
  2601. foreach ( $verifyList as $k => $v ) {
  2602. // init verifyStaff
  2603. if ($v [1] == 'ROLE') {
  2604. if (! empty ( $verifyStaff )) {
  2605. $endStaffArray = end ( $verifyStaff );
  2606. // if ($v[0]==$endStaffArray['nextStaff']){
  2607. // $roleId=$v[0];
  2608. // }
  2609. }
  2610. $roleVerify = json_decode ( $v [3], true );
  2611. $roleKey = $k;
  2612. $roleArray = array ();
  2613. $rolename = $role->getOne ( array (
  2614. 'where' => 'rid=' . $v [0],
  2615. 'asArray' => true
  2616. ) );
  2617. foreach ( $roleVerify as $o => $p ) {
  2618. $staffID = explode ( '_', $p );
  2619. $staffInfo = $staff->getOne ( array (
  2620. 'where' => 'sid=' . $staffID [0],
  2621. 'asArray' => true
  2622. ) );
  2623. // print_r($staffID);
  2624. $exp = array (
  2625. 0 => $staffInfo ['sid'],
  2626. 1 => $staffID [1],
  2627. 2 => $staffInfo ['avatar'],
  2628. 'date' => '',
  2629. 'date' => '',
  2630. 'opinion' => '',
  2631. 'status' => '',
  2632. 'rolename' => $rolename ['name']
  2633. );
  2634. array_push ( $roleArray, $exp );
  2635. }
  2636. $roleArrayCopy [$v [0]] = $roleArray;
  2637. // $verifyList[$k]['roleArray']=$roleArray;
  2638. }
  2639. $verifyList [$k] ['date'] = "";
  2640. $verifyList [$k] ['opinion'] = "";
  2641. $verifyList [$k] ['status'] = "";
  2642. if (empty ( $verifyStaff )) {
  2643. $verifyList [$k] ['date'] = "";
  2644. $verifyList [$k] ['opinion'] = "";
  2645. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2646. $verifyList [$k] ['status'] = 4;
  2647. $flag = false;
  2648. }
  2649. } else {
  2650. foreach ( $verifyStaff as $m => $u ) {
  2651. if ($v [0] == $m) {
  2652. $verifyList [$k] ['date'] = $u ['date'];
  2653. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2654. $verifyList [$k] ['status'] = $u ['status'];
  2655. $flag = false;
  2656. break;
  2657. }
  2658. }
  2659. $endStaffArray = end ( $verifyStaff );
  2660. if (isset ( $endStaffArray ['ROLE'] )) {
  2661. } else {
  2662. // $endKey=key($verifyStaff);
  2663. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2664. // $button=4;
  2665. // $verifyList[$k]['status']=4;
  2666. // }
  2667. }
  2668. }
  2669. }
  2670. $rolename ['name'] = '';
  2671. if (! empty ( $roleId )) {
  2672. Doo::loadModel ( 'role' );
  2673. $role = new role ();
  2674. $rolename = $role->getOne ( array (
  2675. 'where' => 'rid=' . $roleId,
  2676. 'asArray' => true
  2677. ) );
  2678. }
  2679. if (! empty ( $verifyStaff ))
  2680. $endStaffArray = end ( $verifyStaff );
  2681. $KOP = false;
  2682. foreach ( $roleArrayCopy as $P => $A ) {
  2683. foreach ( $A as $MKI => $AVL ) {
  2684. if (! empty ( $verifyStaff )) {
  2685. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2686. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2687. $button = 4;
  2688. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2689. }
  2690. foreach ( $verifyStaff as $m => $u ) {
  2691. $AVLFK = $AVL [0] . '_R';
  2692. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2693. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2694. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2695. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2696. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2697. break;
  2698. }
  2699. }
  2700. } else {
  2701. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2702. $button = 4;
  2703. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2704. }
  2705. }
  2706. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2707. $KOP = true;
  2708. }
  2709. }
  2710. foreach ( $roleArrayCopy as $k => $v ) {
  2711. foreach ( $verifyList as $m => $n ) {
  2712. if ($n [0] == $k) {
  2713. array_splice ( $verifyList, $m, 1, $v );
  2714. }
  2715. }
  2716. }
  2717. // 费用执行人相关数据
  2718. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2719. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2720. foreach ( $executeCopy as $k => $v ) {
  2721. $executeCopy [$k] ['date'] = '';
  2722. $executeCopy [$k] ['opinion'] = '';
  2723. $executeCopy [$k] ['status'] = '';
  2724. if (! empty ( $executeStaff ))
  2725. foreach ( $executeStaff as $m => $u ) {
  2726. if ($v [0] == $m) {
  2727. $executeCopy [$k] ['date'] = $u ['date'];
  2728. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2729. $executeCopy [$k] ['status'] = $u ['status'];
  2730. break;
  2731. }
  2732. }
  2733. }
  2734. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2735. $receiptList [$key] ['verifyList'] = $verifyList;
  2736. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2737. 'where' => 'sid=' . $value ['staff'],
  2738. 'asArray' => true
  2739. ) );
  2740. $receiptList [$key] ['button'] = $button;
  2741. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2742. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2743. $relust = $value ['sum'] - $value ['loanSum'];
  2744. $receiptList [$key] ['relust'] = $relust;
  2745. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2746. }
  2747. // print_r($receiptList);
  2748. // 获取审批日志
  2749. Doo::loadModel ( 'receiptLog' );
  2750. $receiptLog = new receiptLog ();
  2751. $rlList = array ();
  2752. $rlInfo = $receiptLog->getOne ( array (
  2753. 'where' => 'rid=' . $rid . ' and status=4',
  2754. 'asArray' => true
  2755. ) );
  2756. $tijdate = $receiptLog->getOne ( array (
  2757. 'where' => 'rid=' . $rid . ' and status=2',
  2758. 'asc' => 'rlid',
  2759. 'asArray' => true
  2760. ) );
  2761. if (! empty ( $rlInfo )) {
  2762. $rlList = $receiptLog->find ( array (
  2763. 'where' => 'rid=' . $rid,
  2764. 'asc' => 'rlid',
  2765. 'asArray' => true
  2766. ) );
  2767. }
  2768. Doo::loadModel ( 'enclosur' );
  2769. $enclosur = new enclosur ();
  2770. $enclosurList = $enclosur->find ( array (
  2771. 'where' => 'rid=' . $rid,
  2772. 'asArray' => true
  2773. ) );
  2774. $enclosurHtml = '';
  2775. foreach ( $enclosurList as $value ) {
  2776. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2777. }
  2778. $data ['enclosurHtml'] = $enclosurHtml;
  2779. $receiptList [0] ['rlList'] = $rlList;
  2780. $data ['receiptList'] = $receiptList;
  2781. $data ['memu'] = "receipt";
  2782. $data ['staff'] = $this->staff;
  2783. $data ['receiptMemu'] = 'approvalExpenses';
  2784. $data ['verifyId'] = $this->verifyId;
  2785. $data ['executeId'] = $this->executeId;
  2786. $this->render ( "/admin/expensesDoc", $data );
  2787. }
  2788. function expensesEdi() {
  2789. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2790. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  2791. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2792. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2793. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2794. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2795. if (empty ( $status ))
  2796. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  2797. $vidList = array ();
  2798. $button = 0;
  2799. Doo::loadModel ( 'verify' );
  2800. Doo::loadModel ( 'receipt' );
  2801. Doo::loadModel ( 'staff' );
  2802. $staff = new staff ();
  2803. $receipt = new receipt ();
  2804. $verify = new verify ();
  2805. Doo::loadModel ( 'L_category' );
  2806. $Lcategory = new L_category ();
  2807. Doo::loadModel ( 'enclosur' );
  2808. $enclosur = new enclosur ();
  2809. // user verify ID
  2810. $verifyDetail = $verify->find ( array (
  2811. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  2812. 'asArray' => true
  2813. ) );
  2814. foreach ( $verifyDetail as $key => $value ) {
  2815. array_push ( $vidList, $value ['vid'] );
  2816. }
  2817. $vid = implode ( ",", $vidList );
  2818. if (empty ( $verifyDetail ))
  2819. $vid = 0;
  2820. $categoryList = $Lcategory->find ( array (
  2821. 'asArray' => true
  2822. ) );
  2823. $staffList = $staff->find ( array (
  2824. 'where' => 'cid=' . $cid,
  2825. 'asArray' => true
  2826. ) );
  2827. $ap = "";
  2828. if ($status == 4) {
  2829. $ap = 4;
  2830. $status = 2;
  2831. }
  2832. // get Receipt By verifyID status 2
  2833. $receiptList = $receipt->find ( array (
  2834. 'where' => 'rid =' . $rid,
  2835. 'desc' => 'rid',
  2836. 'asArray' => true
  2837. ) );
  2838. $Locate = 0;
  2839. $roleId = 0;
  2840. if ($ap == 4)
  2841. $status = 4;
  2842. foreach ( $receiptList as $key => $value ) {
  2843. $receiptList [$key] ['Locate'] = $Locate;
  2844. $Locate ++;
  2845. $receiptList [$key] ['reviseDetail'] = array ();
  2846. if (! empty ( $value ['reviseDetail'] ))
  2847. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2848. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2849. $categoryDetil = $Lcategory->getOne ( array (
  2850. 'where' => 'cid=' . $value ['cid'],
  2851. 'asArray' => true
  2852. ) );
  2853. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2854. // 检测编辑状态
  2855. $verifyList = $verify->getOne ( array (
  2856. 'where' => 'vid=' . $value ['verify'],
  2857. 'asArray' => true
  2858. ) );
  2859. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2860. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2861. Doo::loadModel ( 'role' );
  2862. $role = new role ();
  2863. // print_r($verifyList);
  2864. $flag = true;
  2865. $roleKey = 0;
  2866. $endStaffArray = array ();
  2867. $roleArrayCopy = array ();
  2868. foreach ( $verifyList as $k => $v ) {
  2869. // init verifyStaff
  2870. if ($v [1] == 'ROLE') {
  2871. if (! empty ( $verifyStaff )) {
  2872. $endStaffArray = end ( $verifyStaff );
  2873. if ($v [0] == $endStaffArray ['nextStaff']) {
  2874. $roleId = $v [0];
  2875. }
  2876. }
  2877. $roleVerify = json_decode ( $v [3], true );
  2878. $roleKey = $k;
  2879. $roleArray = array ();
  2880. $rolename = $role->getOne ( array (
  2881. 'where' => 'rid=' . $v [0],
  2882. 'asArray' => true
  2883. ) );
  2884. foreach ( $roleVerify as $o => $p ) {
  2885. $staffID = explode ( '_', $p );
  2886. $staffInfo = $staff->getOne ( array (
  2887. 'where' => 'sid=' . $staffID [0],
  2888. 'asArray' => true
  2889. ) );
  2890. // print_r($staffID);
  2891. $exp = array (
  2892. 0 => $staffInfo ['sid'],
  2893. 1 => $staffID [1],
  2894. 2 => $staffInfo ['avatar'],
  2895. 'date' => '',
  2896. 'date' => '',
  2897. 'opinion' => '',
  2898. 'status' => '',
  2899. 'rolename' => $rolename ['name']
  2900. );
  2901. array_push ( $roleArray, $exp );
  2902. }
  2903. $roleArrayCopy [$v [0]] = $roleArray;
  2904. // $verifyList[$k]['roleArray']=$roleArray;
  2905. }
  2906. // print_r($roleArray);
  2907. $verifyList [$k] ['date'] = "";
  2908. $verifyList [$k] ['opinion'] = "";
  2909. $verifyList [$k] ['status'] = "";
  2910. if (empty ( $verifyStaff )) {
  2911. $verifyList [$k] ['date'] = "";
  2912. $verifyList [$k] ['opinion'] = "";
  2913. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2914. $verifyList [$k] ['status'] = 4;
  2915. $button = 4;
  2916. $flag = false;
  2917. }
  2918. } else {
  2919. foreach ( $verifyStaff as $m => $u ) {
  2920. if ($v [0] == $m) {
  2921. $verifyList [$k] ['date'] = $u ['date'];
  2922. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2923. $verifyList [$k] ['status'] = $u ['status'];
  2924. $flag = false;
  2925. break;
  2926. }
  2927. }
  2928. $endStaffArray = end ( $verifyStaff );
  2929. if (isset ( $endStaffArray ['ROLE'] )) {
  2930. } else {
  2931. $endKey = key ( $verifyStaff );
  2932. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  2933. $button = 4;
  2934. $verifyList [$k] ['status'] = 4;
  2935. }
  2936. }
  2937. }
  2938. }
  2939. $rolename ['name'] = '';
  2940. if (! empty ( $roleId )) {
  2941. Doo::loadModel ( 'role' );
  2942. $role = new role ();
  2943. $rolename = $role->getOne ( array (
  2944. 'where' => 'rid=' . $roleId,
  2945. 'asArray' => true
  2946. ) );
  2947. }
  2948. if (! empty ( $verifyStaff ))
  2949. $endStaffArray = end ( $verifyStaff );
  2950. $KOP = false;
  2951. foreach ( $roleArrayCopy as $P => $A ) {
  2952. foreach ( $A as $MKI => $AVL ) {
  2953. if (! empty ( $verifyStaff )) {
  2954. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2955. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2956. $button = 4;
  2957. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2958. }
  2959. foreach ( $verifyStaff as $m => $u ) {
  2960. $AVLFK = $AVL [0] . '_R';
  2961. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2962. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2963. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2964. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2965. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2966. break;
  2967. }
  2968. }
  2969. } else {
  2970. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2971. $button = 4;
  2972. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2973. }
  2974. }
  2975. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2976. $KOP = true;
  2977. }
  2978. }
  2979. // print_r($roleArrayCopy);
  2980. // echo $roleKey;
  2981. foreach ( $roleArrayCopy as $k => $v ) {
  2982. foreach ( $verifyList as $m => $n ) {
  2983. if ($n [0] == $k) {
  2984. array_splice ( $verifyList, $m, 1, $v );
  2985. }
  2986. }
  2987. }
  2988. $receiptList [$key] ['verifyList'] = $verifyList;
  2989. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2990. 'where' => 'sid=' . $value ['staff'],
  2991. 'asArray' => true
  2992. ) );
  2993. $receiptList [$key] ['button'] = $button;
  2994. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  2995. }
  2996. // $data['verifyDetail']=$verifyDetail;
  2997. $mothHtml = "";
  2998. for($i = 1; $i <= 12; $i ++) {
  2999. if ($month == $i)
  3000. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3001. else
  3002. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3003. }
  3004. // 获取审批日志
  3005. Doo::loadModel ( 'receiptLog' );
  3006. $receiptLog = new receiptLog ();
  3007. $rlList = array ();
  3008. $rlInfo = $receiptLog->getOne ( array (
  3009. 'where' => 'rid=' . $rid . ' and status=4',
  3010. 'asArray' => true
  3011. ) );
  3012. $tijdate = $receiptLog->getOne ( array (
  3013. 'where' => 'rid=' . $rid . ' and status=2',
  3014. 'asc' => 'rlid',
  3015. 'asArray' => true
  3016. ) );
  3017. if (! empty ( $rlInfo )) {
  3018. $rlList = $receiptLog->find ( array (
  3019. 'where' => 'rid=' . $rid,
  3020. 'asc' => 'rlid',
  3021. 'asArray' => true
  3022. ) );
  3023. }
  3024. $receiptList [0] ['rlList'] = $rlList;
  3025. $enclosurList = $enclosur->find ( array (
  3026. 'where' => 'rid=' . $rid,
  3027. 'asArray' => true
  3028. ) );
  3029. $enclosurHtml = '';
  3030. foreach ( $enclosurList as $value ) {
  3031. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3032. }
  3033. // print_r($receiptList);
  3034. $data ['rid'] = $rid;
  3035. $data ['enclosurHtml'] = $enclosurHtml;
  3036. $data ['rolename'] = $rolename ['name'];
  3037. $data ['datetij'] = $tijdate ['date'];
  3038. $data ['mothHtml'] = $mothHtml;
  3039. $data ['receiptList'] = $receiptList;
  3040. $data ['receiptApprovalCount'] = count ( $receiptList );
  3041. $data ['status'] = $status;
  3042. $data ['year'] = $year;
  3043. $data ['categoryList'] = $categoryList;
  3044. $data ['staffList'] = $staffList;
  3045. $data ['cid'] = $cid;
  3046. $data ['sid'] = $sid;
  3047. $data ['ap'] = $ap;
  3048. $data ['memu'] = "receipt";
  3049. $data ['staff'] = $this->staff;
  3050. $data ['receiptMemu'] = 'approvalExpenses';
  3051. $data ['verifyId'] = $this->verifyId;
  3052. $data ['executeId'] = $this->executeId;
  3053. $this->render ( "/admin/expensesEdi", $data );
  3054. }
  3055. function expensesDefray() {
  3056. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3057. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3058. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3059. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  3060. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  3061. if (! empty ( $rid )) {
  3062. Doo::loadModel ( "verify" );
  3063. $verify = new verify ();
  3064. Doo::loadModel ( "receiptDetail" );
  3065. $receiptDetailObj = new receiptDetail ();
  3066. Doo::loadModel ( "itemStatistics" );
  3067. Doo::loadModel ( "statistics" );
  3068. $statistics = new statistics ();
  3069. $itemStatistics = new itemStatistics ();
  3070. Doo::loadModel ( "receipt" );
  3071. $receipt = new receipt ();
  3072. Doo::loadModel ( "loanReceipt" );
  3073. $loanReceipt = new loanReceipt ();
  3074. $receiptDetail = $receipt->getOne ( array (
  3075. 'where' => 'rid=' . $rid . ' and status=2 ',
  3076. 'asArray' => true
  3077. ) );
  3078. if (empty ( $receiptDetail ))
  3079. return "/approval";
  3080. $verifyDetail = $verify->getOne ( array (
  3081. 'where' => ' vid =' . $receiptDetail ['verify'],
  3082. 'asArray' => true
  3083. ) );
  3084. $verifyString = $verifyDetail ['staff'];
  3085. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3086. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  3087. if (empty ( $opinion )) {
  3088. if ($status == 3)
  3089. $opinion = "终止";
  3090. else
  3091. $opinion = "同意支付";
  3092. }
  3093. $nowStaff = 0;
  3094. $nowStaffList = array ();
  3095. if (empty ( $verifyStaff )) {
  3096. // 还需加入是否已经进入角色审批
  3097. if ($verifyDetail [0] [1] == 'ROLE') {
  3098. // print_r($verifyDetail);echo "ddd";
  3099. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3100. foreach ( $vStaffString as $key => $value ) {
  3101. $staffK = explode ( "_", $value );
  3102. if ($staffK [0] != $this->staff [0] ['sid'])
  3103. array_push ( $nowStaffList, $staffK [0] );
  3104. }
  3105. // print_r($verifyDetail);
  3106. // die;
  3107. if (! empty ( $nowStaffList )) {
  3108. $nowStaff = implode ( ',', $nowStaffList );
  3109. $verifyStaff = array (
  3110. $this->staff [0] ['sid'] . "_R" => array (
  3111. 'date' => date ( 'Y-m-d' ),
  3112. 'opinion' => $opinion,
  3113. 'status' => $status,
  3114. 'nextStaff' => $verifyDetail [0] [0],
  3115. 'ROLE' => 1
  3116. )
  3117. );
  3118. } else {
  3119. $nowStaff = $verifyDetail [1] [0];
  3120. $verifyStaff = array (
  3121. $this->staff [0] ['sid'] . "_R" => array (
  3122. 'date' => date ( 'Y-m-d' ),
  3123. 'opinion' => $opinion,
  3124. 'status' => $status,
  3125. 'nextStaff' => $verifyDetail [1] [0]
  3126. )
  3127. );
  3128. }
  3129. } else {
  3130. if ($verifyDetail [1] [1] == 'ROLE') {
  3131. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  3132. // echo "dd";
  3133. foreach ( $vStaffString as $key => $value ) {
  3134. $staffK = explode ( "_", $value );
  3135. array_push ( $nowStaffList, $staffK [0] );
  3136. }
  3137. $nowStaff = implode ( ',', $nowStaffList );
  3138. $verifyStaff = array (
  3139. $this->staff [0] ['sid'] => array (
  3140. 'date' => date ( 'Y-m-d' ),
  3141. 'opinion' => $opinion,
  3142. 'status' => $status,
  3143. 'nextStaff' => $verifyDetail [1] [0],
  3144. 'ROLE' => 1
  3145. )
  3146. );
  3147. } else {
  3148. $nowStaff = $verifyDetail [1] [0];
  3149. $verifyStaff = array (
  3150. $this->staff [0] ['sid'] => array (
  3151. 'date' => date ( 'Y-m-d' ),
  3152. 'opinion' => $opinion,
  3153. 'status' => $status,
  3154. 'nextStaff' => $verifyDetail [1] [0]
  3155. )
  3156. );
  3157. }
  3158. }
  3159. if ($status == 3)
  3160. $verifyStaff = array (
  3161. 'final' => $status,
  3162. $this->staff [0] ['sid'] => array (
  3163. 'date' => date ( 'Y-m-d' ),
  3164. 'opinion' => $opinion,
  3165. 'status' => $status
  3166. )
  3167. );
  3168. $vStaffString = json_encode ( $verifyStaff );
  3169. $receipt->nowStaff = $nowStaff;
  3170. $receipt->verifyStaff = $vStaffString;
  3171. $loanReceipt->nowStaff = $nowStaff;
  3172. $loanReceipt->verifyStaff = $vStaffString;
  3173. } else {
  3174. $VS = end ( $verifyStaff );
  3175. // 非角色审批
  3176. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  3177. $nextStaff = 0;
  3178. $roleSTF = false;
  3179. foreach ( $verifyDetail as $key => $value ) {
  3180. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  3181. if (isset ( $verifyDetail [$key + 1] )) {
  3182. $nextStaff = $verifyDetail [$key + 1] [0];
  3183. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  3184. $roleSTF = true;
  3185. }
  3186. break;
  3187. }
  3188. }
  3189. if (! $roleSTF) {
  3190. $nowStaff = $nextStaff;
  3191. $verifyStaff [$this->staff [0] ['sid']] = array (
  3192. 'date' => date ( 'Y-m-d' ),
  3193. 'opinion' => $opinion,
  3194. 'status' => $status,
  3195. 'nextStaff' => $nextStaff
  3196. );
  3197. } else {
  3198. // 获取角色下的所有用户ID
  3199. $nowStaffList = array ();
  3200. foreach ( $verifyDetail as $vfk ) {
  3201. if ($vfk [1] == 'ROLE') {
  3202. $vStaffString = json_decode ( $vfk [3] );
  3203. foreach ( $vStaffString as $key => $value ) {
  3204. $staffK = explode ( "_", $value );
  3205. array_push ( $nowStaffList, $staffK [0] );
  3206. }
  3207. }
  3208. }
  3209. $nowStaff = implode ( ',', $nowStaffList );
  3210. $verifyStaff [$this->staff [0] ['sid']] = array (
  3211. 'date' => date ( 'Y-m-d' ),
  3212. 'opinion' => $opinion,
  3213. 'status' => $status,
  3214. 'nextStaff' => $nextStaff,
  3215. 'ROLE' => 0
  3216. );
  3217. }
  3218. if ($status == 3) {
  3219. $verifyStaff ['final'] = $status;
  3220. $verifyStaff [$this->staff [0] ['sid']] = array (
  3221. 'date' => date ( 'Y-m-d' ),
  3222. 'opinion' => $opinion,
  3223. 'status' => $status
  3224. );
  3225. }
  3226. $vStaffString = json_encode ( $verifyStaff );
  3227. $receipt->nowStaff = $nowStaff;
  3228. $receipt->verifyStaff = $vStaffString;
  3229. $loanReceipt->nowStaff = $nowStaff;
  3230. $loanReceipt->verifyStaff = $vStaffString;
  3231. }
  3232. // 角色审批
  3233. if (isset ( $VS ['ROLE'] )) {
  3234. // 找出角色人 当前审批角色组
  3235. $verifyJSStaff = array ();
  3236. $nowStaffList2 = array ();
  3237. foreach ( $verifyDetail as $key => $value ) {
  3238. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  3239. $verifyJSStaff = json_decode ( $value [3] );
  3240. foreach ( $verifyJSStaff as $m ) {
  3241. $staffK = explode ( "_", $m );
  3242. array_push ( $nowStaffList2, $staffK [0] );
  3243. }
  3244. // print_r($nowStaffList2);
  3245. }
  3246. }
  3247. $RoleVerifyStaff = array ();
  3248. foreach ( $verifyStaff as $key => $value ) {
  3249. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  3250. foreach ( $nowStaffList2 as $m ) {
  3251. if ($key == $m . "_R")
  3252. $RoleVerifyStaff [$key] = $value;
  3253. }
  3254. }
  3255. }
  3256. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  3257. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  3258. // 下一个审批人ID
  3259. $nextStaff = 0;
  3260. $falg = false;
  3261. foreach ( $verifyDetail as $key => $value ) {
  3262. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  3263. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  3264. $falg = true;
  3265. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  3266. $nowStaffList = array ();
  3267. foreach ( $vStaffString as $v ) {
  3268. $staffK = explode ( "_", $v );
  3269. array_push ( $nowStaffList, $staffK [0] );
  3270. }
  3271. $nowStaff = implode ( ',', $nowStaffList );
  3272. $nextStaff = $verifyDetail [$key + 1] [0];
  3273. } elseif (isset ( $verifyDetail [$key + 1] )) {
  3274. $nextStaff = $verifyDetail [$key + 1] [0];
  3275. $nowStaff = $nextStaff;
  3276. } else
  3277. $nowStaff = '';
  3278. break;
  3279. }
  3280. }
  3281. if ($falg)
  3282. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3283. 'date' => date ( 'Y-m-d' ),
  3284. 'opinion' => $opinion,
  3285. 'status' => $status,
  3286. 'nextStaff' => $nextStaff,
  3287. 'ROLE' => 1
  3288. );
  3289. else
  3290. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3291. 'date' => date ( 'Y-m-d' ),
  3292. 'opinion' => $opinion,
  3293. 'status' => $status,
  3294. 'nextStaff' => $nextStaff
  3295. );
  3296. // print_r($verifyStaff);
  3297. // echo $nowStaff;die;
  3298. } else { // 进入下一个角色或者审批人
  3299. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  3300. //
  3301. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  3302. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3303. 'date' => date ( 'Y-m-d' ),
  3304. 'opinion' => $opinion,
  3305. 'status' => $status,
  3306. 'nextStaff' => $VS ['nextStaff'],
  3307. 'ROLE' => 1
  3308. );
  3309. // print_r($verifyStaff);
  3310. // die;
  3311. }
  3312. if ($status == 3) {
  3313. $verifyStaff ['final'] = $status;
  3314. $verifyStaff [$this->staff [0] ['sid']] = array (
  3315. 'date' => date ( 'Y-m-d' ),
  3316. 'opinion' => $opinion,
  3317. 'status' => $status
  3318. );
  3319. }
  3320. $vStaffString = json_encode ( $verifyStaff );
  3321. $receipt->verifyStaff = $vStaffString;
  3322. $receipt->nowStaff = $nowStaff;
  3323. $loanReceipt->nowStaff = $nowStaff;
  3324. $loanReceipt->verifyStaff = $vStaffString;
  3325. // die;
  3326. // }
  3327. // print_r($verifyStaff);
  3328. // die;
  3329. }
  3330. // print_r($verifyStaff);die;
  3331. }
  3332. // print_r($verifyDetail);
  3333. $roleKey = 0;
  3334. $roleId = 0;
  3335. $verifyDetailCopy = array ();
  3336. foreach ( $verifyDetail as $k => $v ) {
  3337. if ($v [1] == 'ROLE') {
  3338. $roleId = $v [0];
  3339. $roleVerify = json_decode ( $v [3], true );
  3340. $roleKey = $k;
  3341. $roleArray = array ();
  3342. foreach ( $roleVerify as $o => $p ) {
  3343. $staffID = explode ( '_', $p );
  3344. $exp = array (
  3345. 0 => $staffID [0],
  3346. 1 => $staffID [1]
  3347. );
  3348. array_push ( $roleArray, $exp );
  3349. }
  3350. $verifyDetailCopy [$v [0]] = $roleArray;
  3351. }
  3352. }
  3353. // print_r($verifyDetail);
  3354. foreach ( $verifyDetailCopy as $k => $v ) {
  3355. foreach ( $verifyDetail as $m => $n ) {
  3356. if ($n [0] == $k) {
  3357. array_splice ( $verifyDetail, $m, 1, $v );
  3358. }
  3359. }
  3360. }
  3361. // 审批日志
  3362. if (! isset ( $verifyStaff ['final'] )) {
  3363. Doo::loadModel ( "receiptLog" );
  3364. $receiptLog = new receiptLog ();
  3365. if (! empty ( $roleId )) {
  3366. Doo::loadModel ( "role" );
  3367. $role = new role ();
  3368. $roleInfo = $role->getOne ( array (
  3369. 'where' => 'rid=' . $roleId,
  3370. 'asArray' => true
  3371. ) );
  3372. $receiptLog->rolename = $roleInfo ['name'];
  3373. }
  3374. $receiptLog->username = $this->staff [0] ['username'];
  3375. $receiptLog->uid = $this->staff [0] ['sid'];
  3376. $receiptLog->date = date ( "Y-m-d" );
  3377. $receiptLog->opinion = $opinion;
  3378. $receiptLog->img = $this->staff [0] ['avatar'];
  3379. $receiptLog->status = 1;
  3380. $receiptLog->rid = $rid;
  3381. $receiptLog->insert ();
  3382. }
  3383. if (isset ( $verifyStaff ['final'] )) { // rDetail
  3384. $receipt->status = 3;
  3385. $receipt->verifyBreakup = $verifyString;
  3386. $receiptDetailObj->status = 3;
  3387. $receiptDetailObj->update ( array (
  3388. 'where' => 'rid=' . $rid
  3389. ) );
  3390. // 微信企业号通知
  3391. $this->setWXMsg ( $rid, 3 );
  3392. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  3393. $receipt->status = 6;
  3394. $receipt->pastDate = date ( "Y-m-d" );
  3395. $receipt->isBK = 1;
  3396. $loanReceipt->verifyBreakup = $verifyString;
  3397. $loanReceipt->status = 1;
  3398. $loanReceipt->pastDate = date ( "Y-m-d" );
  3399. $loanReceipt->update ( array (
  3400. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  3401. ) );
  3402. // 微信企业号通知
  3403. $this->setWXMsg ( $rid, 1 );
  3404. }
  3405. $receipt->amount = $amount;
  3406. $receipt->update ( array (
  3407. 'where' => ' rid = ' . $rid
  3408. ) );
  3409. return "/approvalExpenses/pendApproval";
  3410. }
  3411. }
  3412. function ajaxExamineExe() {
  3413. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3414. Doo::loadModel ( 'receipt' );
  3415. $receipt = new receipt ();
  3416. Doo::loadClass ( 'XDeode' );
  3417. $XDeode = new XDeode ( 5 );
  3418. if (! empty ( $rid )) {
  3419. $rLRes = $receipt->find ( array (
  3420. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  3421. 'asArray' => true
  3422. ) );
  3423. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  3424. echo json_encode ( array (
  3425. 'status' => 1,
  3426. 'receipt' => $rLRes [0]
  3427. ) );
  3428. die ();
  3429. }
  3430. echo json_encode ( array (
  3431. 'status' => 0,
  3432. 'receipt' => array ()
  3433. ) );
  3434. die ();
  3435. }
  3436. function implement() {
  3437. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3438. Doo::loadClass ( 'XDeode' );
  3439. $XDeode = new XDeode ( 5 );
  3440. Doo::loadModel ( 'receipt' );
  3441. $receipt = new receipt ();
  3442. Doo::loadModel ( 'L_category' );
  3443. $Lcategory = new L_category ();
  3444. Doo::loadModel ( 'verify' );
  3445. $verify = new verify ();
  3446. Doo::loadModel ( 'staff' );
  3447. $staff = new staff ();
  3448. Doo::loadModel ( "execute" );
  3449. $execute = new execute ();
  3450. $rid = $XDeode->decode ( $rid );
  3451. $receiptList = $receipt->find ( array (
  3452. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  3453. 'desc' => 'rid',
  3454. 'asArray' => true
  3455. ) );
  3456. Doo::loadModel ( 'loanReceipt' );
  3457. $loanReceipt = new loanReceipt ();
  3458. // print_r($receiptList);
  3459. $loanList = array ();
  3460. if (! isset ( $receiptList ))
  3461. $loanList = $loanReceipt->find ( array (
  3462. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3463. 'desc' => 'rid',
  3464. 'asArray' => true
  3465. ) );
  3466. $Locate = 0;
  3467. $roleId = 0;
  3468. $button = 0;
  3469. foreach ( $loanList as $key => $value ) {
  3470. $loanList [$key] ['Locate'] = $Locate;
  3471. $Locate ++;
  3472. $loanList [$key] ['reviseDetail'] = array ();
  3473. if (! empty ( $value ['reviseDetail'] ))
  3474. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3475. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3476. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3477. $categoryDetil = $Lcategory->getOne ( array (
  3478. 'where' => 'cid=' . $value ['cid'],
  3479. 'asArray' => true
  3480. ) );
  3481. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3482. // 检测编辑状态
  3483. $verifyList = $verify->getOne ( array (
  3484. 'where' => 'vid=' . $value ['verify'],
  3485. 'asArray' => true
  3486. ) );
  3487. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3488. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3489. Doo::loadModel ( 'role' );
  3490. $role = new role ();
  3491. $flag = true;
  3492. $roleKey = 0;
  3493. $endStaffArray = array ();
  3494. $roleArrayCopy = array ();
  3495. foreach ( $verifyList as $k => $v ) {
  3496. // init verifyStaff
  3497. if ($v [1] == 'ROLE') {
  3498. if (! empty ( $verifyStaff )) {
  3499. $endStaffArray = end ( $verifyStaff );
  3500. // if ($v[0]==$endStaffArray['nextStaff']){
  3501. // $roleId=$v[0];
  3502. // }
  3503. }
  3504. $roleVerify = json_decode ( $v [3], true );
  3505. $roleKey = $k;
  3506. $roleArray = array ();
  3507. $rolename = $role->getOne ( array (
  3508. 'where' => 'rid=' . $v [0],
  3509. 'asArray' => true
  3510. ) );
  3511. foreach ( $roleVerify as $o => $p ) {
  3512. $staffID = explode ( '_', $p );
  3513. $staffInfo = $staff->getOne ( array (
  3514. 'where' => 'sid=' . $staffID [0],
  3515. 'asArray' => true
  3516. ) );
  3517. // print_r($staffID);
  3518. $exp = array (
  3519. 0 => $staffInfo ['sid'],
  3520. 1 => $staffID [1],
  3521. 2 => $staffInfo ['avatar'],
  3522. 'date' => '',
  3523. 'date' => '',
  3524. 'opinion' => '',
  3525. 'status' => '',
  3526. 'rolename' => $rolename ['name']
  3527. );
  3528. array_push ( $roleArray, $exp );
  3529. }
  3530. $roleArrayCopy [$v [0]] = $roleArray;
  3531. // $verifyList[$k]['roleArray']=$roleArray;
  3532. }
  3533. $verifyList [$k] ['date'] = "";
  3534. $verifyList [$k] ['opinion'] = "";
  3535. $verifyList [$k] ['status'] = "";
  3536. if (empty ( $verifyStaff )) {
  3537. $verifyList [$k] ['date'] = "";
  3538. $verifyList [$k] ['opinion'] = "";
  3539. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3540. $verifyList [$k] ['status'] = 4;
  3541. $flag = false;
  3542. }
  3543. } else {
  3544. foreach ( $verifyStaff as $m => $u ) {
  3545. if ($v [0] == $m) {
  3546. $verifyList [$k] ['date'] = $u ['date'];
  3547. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3548. $verifyList [$k] ['status'] = $u ['status'];
  3549. $flag = false;
  3550. break;
  3551. }
  3552. }
  3553. $endStaffArray = end ( $verifyStaff );
  3554. if (isset ( $endStaffArray ['ROLE'] )) {
  3555. } else {
  3556. // $endKey=key($verifyStaff);
  3557. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3558. // $button=4;
  3559. // $verifyList[$k]['status']=4;
  3560. // }
  3561. }
  3562. }
  3563. }
  3564. $rolename ['name'] = '';
  3565. if (! empty ( $roleId )) {
  3566. Doo::loadModel ( 'role' );
  3567. $role = new role ();
  3568. $rolename = $role->getOne ( array (
  3569. 'where' => 'rid=' . $roleId,
  3570. 'asArray' => true
  3571. ) );
  3572. }
  3573. if (! empty ( $verifyStaff ))
  3574. $endStaffArray = end ( $verifyStaff );
  3575. $KOP = false;
  3576. foreach ( $roleArrayCopy as $P => $A ) {
  3577. foreach ( $A as $MKI => $AVL ) {
  3578. if (! empty ( $verifyStaff )) {
  3579. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3580. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3581. $button = 4;
  3582. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3583. }
  3584. foreach ( $verifyStaff as $m => $u ) {
  3585. $AVLFK = $AVL [0] . '_R';
  3586. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3587. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3588. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3589. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3590. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3591. break;
  3592. }
  3593. }
  3594. } else {
  3595. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3596. $button = 4;
  3597. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3598. }
  3599. }
  3600. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3601. $KOP = true;
  3602. }
  3603. }
  3604. foreach ( $roleArrayCopy as $k => $v ) {
  3605. foreach ( $verifyList as $m => $n ) {
  3606. if ($n [0] == $k) {
  3607. array_splice ( $verifyList, $m, 1, $v );
  3608. }
  3609. }
  3610. }
  3611. $loanList [$key] ['verifyList'] = $verifyList;
  3612. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3613. 'where' => 'sid=' . $value ['staff'],
  3614. 'asArray' => true
  3615. ) );
  3616. }
  3617. $data ['loanList'] = $loanList;
  3618. $Locate = 0;
  3619. $roleId = 0;
  3620. $button = 0;
  3621. foreach ( $receiptList as $key => $value ) {
  3622. $button2 = 0;
  3623. $receiptList [$key] ['Locate'] = $Locate;
  3624. $Locate ++;
  3625. $receiptList [$key] ['reviseDetail'] = array ();
  3626. if (! empty ( $value ['reviseDetail'] ))
  3627. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3628. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3629. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3630. $categoryDetil = $Lcategory->getOne ( array (
  3631. 'where' => 'cid=' . $value ['cid'],
  3632. 'asArray' => true
  3633. ) );
  3634. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3635. $executeList = json_decode ( $value ['executeCopy'], true );
  3636. $executeStaff = array ();
  3637. if (! empty ( $value ['executeStaff'] ))
  3638. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3639. if (isset ( $executeList )) {
  3640. foreach ( $executeList as $op => $lo ) {
  3641. $executeList [$op] ['date'] = "";
  3642. $executeList [$op] ['opinion'] = "";
  3643. $executeList [$op] ['status'] = "";
  3644. foreach ( $executeStaff as $m => $u ) {
  3645. if ($lo [0] == $m) {
  3646. $executeList [$op] ['date'] = $u ['date'];
  3647. $executeList [$op] ['opinion'] = $u ['opinion'];
  3648. $executeList [$op] ['status'] = $u ['status'];
  3649. break;
  3650. }
  3651. }
  3652. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  3653. $button2 = 1;
  3654. $executeList [$op] ['status'] = 4;
  3655. }
  3656. }
  3657. }
  3658. // 检测编辑状态
  3659. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3660. $verifyList ['staff'] = $value ['verifyBreakup'];
  3661. } else
  3662. $verifyList = $verify->getOne ( array (
  3663. 'where' => 'vid=' . $value ['verify'],
  3664. 'asArray' => true
  3665. ) );
  3666. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3667. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3668. Doo::loadModel ( 'role' );
  3669. $role = new role ();
  3670. if ($verifyList == NULL)
  3671. $verifyList = array ();
  3672. $flag = true;
  3673. $roleKey = 0;
  3674. $endStaffArray = array ();
  3675. $roleArrayCopy = array ();
  3676. foreach ( $verifyList as $k => $v ) {
  3677. // init verifyStaff
  3678. if ($v [1] == 'ROLE') {
  3679. if (! empty ( $verifyStaff )) {
  3680. $endStaffArray = end ( $verifyStaff );
  3681. // if ($v[0]==$endStaffArray['nextStaff']){
  3682. // $roleId=$v[0];
  3683. // }
  3684. }
  3685. $roleVerify = json_decode ( $v [3], true );
  3686. $roleKey = $k;
  3687. $roleArray = array ();
  3688. $rolename = $role->getOne ( array (
  3689. 'where' => 'rid=' . $v [0],
  3690. 'asArray' => true
  3691. ) );
  3692. foreach ( $roleVerify as $o => $p ) {
  3693. $staffID = explode ( '_', $p );
  3694. $staffInfo = $staff->getOne ( array (
  3695. 'where' => 'sid=' . $staffID [0],
  3696. 'asArray' => true
  3697. ) );
  3698. // print_r($staffID);
  3699. $exp = array (
  3700. 0 => $staffInfo ['sid'],
  3701. 1 => $staffID [1],
  3702. 2 => $staffInfo ['avatar'],
  3703. 'date' => '',
  3704. 'date' => '',
  3705. 'opinion' => '',
  3706. 'status' => '',
  3707. 'rolename' => $rolename ['name']
  3708. );
  3709. array_push ( $roleArray, $exp );
  3710. }
  3711. $roleArrayCopy [$v [0]] = $roleArray;
  3712. // $verifyList[$k]['roleArray']=$roleArray;
  3713. }
  3714. $verifyList [$k] ['date'] = "";
  3715. $verifyList [$k] ['opinion'] = "";
  3716. $verifyList [$k] ['status'] = "";
  3717. if (empty ( $verifyStaff )) {
  3718. $verifyList [$k] ['date'] = "";
  3719. $verifyList [$k] ['opinion'] = "";
  3720. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3721. $verifyList [$k] ['status'] = 4;
  3722. $flag = false;
  3723. }
  3724. } else {
  3725. foreach ( $verifyStaff as $m => $u ) {
  3726. if ($v [0] == $m) {
  3727. $verifyList [$k] ['date'] = $u ['date'];
  3728. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3729. $verifyList [$k] ['status'] = $u ['status'];
  3730. $flag = false;
  3731. break;
  3732. }
  3733. }
  3734. $endStaffArray = end ( $verifyStaff );
  3735. if (isset ( $endStaffArray ['ROLE'] )) {
  3736. } else {
  3737. // $endKey=key($verifyStaff);
  3738. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3739. // $button=4;
  3740. // $verifyList[$k]['status']=4;
  3741. // }
  3742. }
  3743. }
  3744. }
  3745. $rolename ['name'] = '';
  3746. if (! empty ( $roleId )) {
  3747. Doo::loadModel ( 'role' );
  3748. $role = new role ();
  3749. $rolename = $role->getOne ( array (
  3750. 'where' => 'rid=' . $roleId,
  3751. 'asArray' => true
  3752. ) );
  3753. }
  3754. if (! empty ( $verifyStaff ))
  3755. $endStaffArray = end ( $verifyStaff );
  3756. $KOP = false;
  3757. foreach ( $roleArrayCopy as $P => $A ) {
  3758. foreach ( $A as $MKI => $AVL ) {
  3759. if (! empty ( $verifyStaff )) {
  3760. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3761. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3762. $button = 4;
  3763. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3764. }
  3765. foreach ( $verifyStaff as $m => $u ) {
  3766. $AVLFK = $AVL [0] . '_R';
  3767. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3768. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3769. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3770. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3771. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3772. break;
  3773. }
  3774. }
  3775. } else {
  3776. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3777. $button = 4;
  3778. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3779. }
  3780. }
  3781. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3782. $KOP = true;
  3783. }
  3784. }
  3785. foreach ( $roleArrayCopy as $k => $v ) {
  3786. foreach ( $verifyList as $m => $n ) {
  3787. if ($n [0] == $k) {
  3788. array_splice ( $verifyList, $m, 1, $v );
  3789. }
  3790. }
  3791. }
  3792. $receiptList [$key] ['verifyList'] = $verifyList;
  3793. $receiptList [$key] ['executeList'] = $executeList;
  3794. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3795. 'where' => 'sid=' . $value ['staff'],
  3796. 'asArray' => true
  3797. ) );
  3798. $receiptList [$key] ['button2'] = $button2;
  3799. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3800. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3801. $relust = $value ['sum'] - $value ['loanSum'];
  3802. $receiptList [$key] ['relust'] = $relust;
  3803. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  3804. }
  3805. // print_r($receiptList[$key]['executeList']);
  3806. $data ['receiptList'] = $receiptList;
  3807. $data ['memu'] = "receipt";
  3808. $data ['staff'] = $this->staff;
  3809. $data ['receiptMemu'] = 'implement';
  3810. $data ['verifyId'] = $this->verifyId;
  3811. $data ['executeId'] = $this->executeId;
  3812. $this->render ( "/admin/implement", $data );
  3813. }
  3814. function implementDo() {
  3815. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3816. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3817. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  3818. if (! empty ( $rid ) && $amount != '') {
  3819. Doo::loadModel ( 'receipt' );
  3820. $receipt = new receipt ();
  3821. Doo::loadClass ( 'XDeode' );
  3822. $XDeode = new XDeode ( 5 );
  3823. $rinfo = $receipt->getOne ( array (
  3824. 'where' => 'rid=' . $rid,
  3825. 'asArray' => true
  3826. ) );
  3827. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  3828. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  3829. if (empty ( $executeStaff )) {
  3830. $executeStaff = array (
  3831. $this->staff [0] ['sid'] => array (
  3832. 'date' => date ( 'Y-m-d' ),
  3833. 'opinion' => $implementOpinions,
  3834. 'status' => 1
  3835. )
  3836. );
  3837. } else {
  3838. $executeStaff [$this->staff [0] ['sid']] = array (
  3839. 'date' => date ( 'Y-m-d' ),
  3840. 'opinion' => $implementOpinions,
  3841. 'status' => 1
  3842. );
  3843. }
  3844. if (count ( $executeStaff ) == count ( $executeCopy )) {
  3845. $receipt->executeStaff = json_encode ( $executeStaff );
  3846. $receipt->status = 8;
  3847. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  3848. $receipt->status = 9;
  3849. if($rinfo ['status']==6){
  3850. $receipt->loanDate=date ( "Y-m-d" );
  3851. }
  3852. $receipt->executeDate = date ( "Y-m-d" );
  3853. } else {
  3854. $receipt->executeStaff = json_encode ( $executeStaff );
  3855. }
  3856. $receipt->amount = $amount;
  3857. $receipt->update ( array (
  3858. 'where' => 'rid=' . $rid
  3859. ) );
  3860. }
  3861. $ridKey = $XDeode->encode ( $rid );
  3862. return "/hisImplement";
  3863. //return "/implement/" . $ridKey . ".html";
  3864. }
  3865. function receiptburEdi() {
  3866. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3867. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  3868. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  3869. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  3870. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3871. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  3872. if (empty ( $status ))
  3873. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  3874. $vidList = array ();
  3875. $button = 0;
  3876. Doo::loadModel ( 'verify' );
  3877. Doo::loadModel ( 'receipt' );
  3878. Doo::loadModel ( 'staff' );
  3879. $staff = new staff ();
  3880. $receipt = new receipt ();
  3881. $verify = new verify ();
  3882. Doo::loadModel ( 'L_category' );
  3883. $Lcategory = new L_category ();
  3884. Doo::loadModel ( 'enclosur' );
  3885. $enclosur = new enclosur ();
  3886. Doo::loadModel ( 'loanReceipt' );
  3887. $loanReceipt = new loanReceipt ();
  3888. // user verify ID
  3889. $verifyDetail = $verify->find ( array (
  3890. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  3891. 'asArray' => true
  3892. ) );
  3893. foreach ( $verifyDetail as $key => $value ) {
  3894. array_push ( $vidList, $value ['vid'] );
  3895. }
  3896. $vid = implode ( ",", $vidList );
  3897. if (empty ( $verifyDetail ))
  3898. $vid = 0;
  3899. $categoryList = $Lcategory->find ( array (
  3900. 'asArray' => true
  3901. ) );
  3902. $staffList = $staff->find ( array (
  3903. 'where' => 'cid=' . $cid,
  3904. 'asArray' => true
  3905. ) );
  3906. $ap = "";
  3907. if ($status == 4) {
  3908. $ap = 4;
  3909. $status = 2;
  3910. }
  3911. // get Receipt By verifyID status 2
  3912. $receiptList = $receipt->find ( array (
  3913. 'where' => 'rid =' . $rid,
  3914. 'desc' => 'rid',
  3915. 'asArray' => true
  3916. ) );
  3917. $loanList = $loanReceipt->find ( array (
  3918. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3919. 'desc' => 'rid',
  3920. 'asArray' => true
  3921. ) );
  3922. $Locate = 0;
  3923. $roleId = 0;
  3924. $button = 0;
  3925. foreach ( $loanList as $key => $value ) {
  3926. $loanList [$key] ['Locate'] = $Locate;
  3927. $Locate ++;
  3928. $loanList [$key] ['reviseDetail'] = array ();
  3929. if (! empty ( $value ['reviseDetail'] ))
  3930. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3931. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3932. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3933. $categoryDetil = $Lcategory->getOne ( array (
  3934. 'where' => 'cid=' . $value ['cid'],
  3935. 'asArray' => true
  3936. ) );
  3937. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3938. // 检测编辑状态
  3939. $verifyList = $verify->getOne ( array (
  3940. 'where' => 'vid=' . $value ['verify'],
  3941. 'asArray' => true
  3942. ) );
  3943. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3944. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3945. Doo::loadModel ( 'role' );
  3946. $role = new role ();
  3947. $flag = true;
  3948. $roleKey = 0;
  3949. $endStaffArray = array ();
  3950. $roleArrayCopy = array ();
  3951. foreach ( $verifyList as $k => $v ) {
  3952. // init verifyStaff
  3953. if ($v [1] == 'ROLE') {
  3954. if (! empty ( $verifyStaff )) {
  3955. $endStaffArray = end ( $verifyStaff );
  3956. }
  3957. $roleVerify = json_decode ( $v [3], true );
  3958. $roleKey = $k;
  3959. $roleArray = array ();
  3960. $rolename = $role->getOne ( array (
  3961. 'where' => 'rid=' . $v [0],
  3962. 'asArray' => true
  3963. ) );
  3964. foreach ( $roleVerify as $o => $p ) {
  3965. $staffID = explode ( '_', $p );
  3966. $staffInfo = $staff->getOne ( array (
  3967. 'where' => 'sid=' . $staffID [0],
  3968. 'asArray' => true
  3969. ) );
  3970. // print_r($staffID);
  3971. $exp = array (
  3972. 0 => $staffInfo ['sid'],
  3973. 1 => $staffID [1],
  3974. 2 => $staffInfo ['avatar'],
  3975. 'date' => '',
  3976. 'date' => '',
  3977. 'opinion' => '',
  3978. 'status' => '',
  3979. 'rolename' => $rolename ['name']
  3980. );
  3981. array_push ( $roleArray, $exp );
  3982. }
  3983. $roleArrayCopy [$v [0]] = $roleArray;
  3984. // $verifyList[$k]['roleArray']=$roleArray;
  3985. }
  3986. $verifyList [$k] ['date'] = "";
  3987. $verifyList [$k] ['opinion'] = "";
  3988. $verifyList [$k] ['status'] = "";
  3989. if (empty ( $verifyStaff )) {
  3990. $verifyList [$k] ['date'] = "";
  3991. $verifyList [$k] ['opinion'] = "";
  3992. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3993. $verifyList [$k] ['status'] = 4;
  3994. $flag = false;
  3995. }
  3996. } else {
  3997. foreach ( $verifyStaff as $m => $u ) {
  3998. if ($v [0] == $m) {
  3999. $verifyList [$k] ['date'] = $u ['date'];
  4000. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4001. $verifyList [$k] ['status'] = $u ['status'];
  4002. $flag = false;
  4003. break;
  4004. }
  4005. }
  4006. $endStaffArray = end ( $verifyStaff );
  4007. if (isset ( $endStaffArray ['ROLE'] )) {
  4008. } else {
  4009. }
  4010. }
  4011. }
  4012. $rolename ['name'] = '';
  4013. if (! empty ( $roleId )) {
  4014. Doo::loadModel ( 'role' );
  4015. $role = new role ();
  4016. $rolename = $role->getOne ( array (
  4017. 'where' => 'rid=' . $roleId,
  4018. 'asArray' => true
  4019. ) );
  4020. }
  4021. if (! empty ( $verifyStaff ))
  4022. $endStaffArray = end ( $verifyStaff );
  4023. $KOP = false;
  4024. foreach ( $roleArrayCopy as $P => $A ) {
  4025. foreach ( $A as $MKI => $AVL ) {
  4026. if (! empty ( $verifyStaff )) {
  4027. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4028. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4029. $button = 4;
  4030. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4031. }
  4032. foreach ( $verifyStaff as $m => $u ) {
  4033. $AVLFK = $AVL [0] . '_R';
  4034. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4035. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4036. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4037. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4038. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4039. break;
  4040. }
  4041. }
  4042. } else {
  4043. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4044. $button = 4;
  4045. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4046. }
  4047. }
  4048. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4049. $KOP = true;
  4050. }
  4051. }
  4052. foreach ( $roleArrayCopy as $k => $v ) {
  4053. foreach ( $verifyList as $m => $n ) {
  4054. if ($n [0] == $k) {
  4055. array_splice ( $verifyList, $m, 1, $v );
  4056. }
  4057. }
  4058. }
  4059. $loanList [$key] ['verifyList'] = $verifyList;
  4060. }
  4061. $htmlLoan = '';
  4062. if (isset ( $loanList [0] )) {
  4063. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  4064. if ($value ['status'] == 1)
  4065. $htmlLoan .= '<li class="done" >';
  4066. elseif ($value ['status'] == 3)
  4067. $htmlLoan .= '<li class="undone" >';
  4068. $htmlLoan .= '<div class="avtra"><img src="' . $value [2] . '_2.jpg"></div>';
  4069. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  4070. if (isset ( $value ['rolename'] ))
  4071. $htmlLoan .= $value ['rolename'];
  4072. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  4073. }
  4074. $data ['loanDate'] = $loanList [0] ['date'];
  4075. }
  4076. $data ['htmlLoan'] = $htmlLoan;
  4077. // print_r($loanList);
  4078. $Locate = 0;
  4079. $roleId = 0;
  4080. $button = 0;
  4081. if ($ap == 4)
  4082. $status = 4;
  4083. foreach ( $receiptList as $key => $value ) {
  4084. $receiptList [$key] ['Locate'] = $Locate;
  4085. $Locate ++;
  4086. $receiptList [$key] ['reviseDetail'] = array ();
  4087. if (! empty ( $value ['reviseDetail'] ))
  4088. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4089. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4090. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4091. $categoryDetil = $Lcategory->getOne ( array (
  4092. 'where' => 'cid=' . $value ['cid'],
  4093. 'asArray' => true
  4094. ) );
  4095. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4096. // 检测编辑状态
  4097. $verifyList = $verify->getOne ( array (
  4098. 'where' => 'vid=' . $value ['verify'],
  4099. 'asArray' => true
  4100. ) );
  4101. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4102. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4103. Doo::loadModel ( 'role' );
  4104. $role = new role ();
  4105. // print_r($verifyList);
  4106. $flag = true;
  4107. $roleKey = 0;
  4108. $endStaffArray = array ();
  4109. $roleArrayCopy = array ();
  4110. foreach ( $verifyList as $k => $v ) {
  4111. // init verifyStaff
  4112. if ($v [1] == 'ROLE') {
  4113. if (! empty ( $verifyStaff )) {
  4114. $endStaffArray = end ( $verifyStaff );
  4115. if ($v [0] == $endStaffArray ['nextStaff']) {
  4116. $roleId = $v [0];
  4117. }
  4118. }
  4119. $roleVerify = json_decode ( $v [3], true );
  4120. $roleKey = $k;
  4121. $roleArray = array ();
  4122. $rolename = $role->getOne ( array (
  4123. 'where' => 'rid=' . $v [0],
  4124. 'asArray' => true
  4125. ) );
  4126. foreach ( $roleVerify as $o => $p ) {
  4127. $staffID = explode ( '_', $p );
  4128. $staffInfo = $staff->getOne ( array (
  4129. 'where' => 'sid=' . $staffID [0],
  4130. 'asArray' => true
  4131. ) );
  4132. // print_r($staffID);
  4133. $exp = array (
  4134. 0 => $staffInfo ['sid'],
  4135. 1 => $staffID [1],
  4136. 2 => $staffInfo ['avatar'],
  4137. 'date' => '',
  4138. 'date' => '',
  4139. 'opinion' => '',
  4140. 'status' => '',
  4141. 'rolename' => $rolename ['name']
  4142. );
  4143. array_push ( $roleArray, $exp );
  4144. }
  4145. $roleArrayCopy [$v [0]] = $roleArray;
  4146. // $verifyList[$k]['roleArray']=$roleArray;
  4147. }
  4148. // print_r($roleArray);
  4149. $verifyList [$k] ['date'] = "";
  4150. $verifyList [$k] ['opinion'] = "";
  4151. $verifyList [$k] ['status'] = "";
  4152. if (empty ( $verifyStaff )) {
  4153. $verifyList [$k] ['date'] = "";
  4154. $verifyList [$k] ['opinion'] = "";
  4155. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4156. $verifyList [$k] ['status'] = 4;
  4157. $button = 4;
  4158. $flag = false;
  4159. }
  4160. } else {
  4161. foreach ( $verifyStaff as $m => $u ) {
  4162. if ($v [0] == $m) {
  4163. $verifyList [$k] ['date'] = $u ['date'];
  4164. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4165. $verifyList [$k] ['status'] = $u ['status'];
  4166. $flag = false;
  4167. break;
  4168. }
  4169. }
  4170. $endStaffArray = end ( $verifyStaff );
  4171. if (isset ( $endStaffArray ['ROLE'] )) {
  4172. } else {
  4173. $endKey = key ( $verifyStaff );
  4174. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4175. $button = 4;
  4176. $verifyList [$k] ['status'] = 4;
  4177. }
  4178. }
  4179. }
  4180. }
  4181. $rolename ['name'] = '';
  4182. if (! empty ( $roleId )) {
  4183. Doo::loadModel ( 'role' );
  4184. $role = new role ();
  4185. $rolename = $role->getOne ( array (
  4186. 'where' => 'rid=' . $roleId,
  4187. 'asArray' => true
  4188. ) );
  4189. }
  4190. if (! empty ( $verifyStaff ))
  4191. $endStaffArray = end ( $verifyStaff );
  4192. $KOP = false;
  4193. foreach ( $roleArrayCopy as $P => $A ) {
  4194. foreach ( $A as $MKI => $AVL ) {
  4195. if (! empty ( $verifyStaff )) {
  4196. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4197. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4198. $button = 4;
  4199. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4200. }
  4201. foreach ( $verifyStaff as $m => $u ) {
  4202. $AVLFK = $AVL [0] . '_R';
  4203. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4204. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4205. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4206. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4207. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4208. break;
  4209. }
  4210. }
  4211. } else {
  4212. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4213. $button = 4;
  4214. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4215. }
  4216. }
  4217. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4218. $KOP = true;
  4219. }
  4220. }
  4221. foreach ( $roleArrayCopy as $k => $v ) {
  4222. foreach ( $verifyList as $m => $n ) {
  4223. if ($n [0] == $k) {
  4224. array_splice ( $verifyList, $m, 1, $v );
  4225. }
  4226. }
  4227. }
  4228. // print_r($verifyList);
  4229. $receiptList [$key] ['verifyList'] = $verifyList;
  4230. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4231. 'where' => 'sid=' . $value ['staff'],
  4232. 'asArray' => true
  4233. ) );
  4234. $receiptList [$key] ['button'] = $button;
  4235. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4236. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4237. $relust = $value ['sum'] - $value ['loanSum'];
  4238. $receiptList [$key] ['relust'] = $relust;
  4239. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4240. }
  4241. // print_r($receiptList);die;
  4242. // $data['verifyDetail']=$verifyDetail;
  4243. $mothHtml = "";
  4244. for($i = 1; $i <= 12; $i ++) {
  4245. if ($month == $i)
  4246. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4247. else
  4248. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4249. }
  4250. // 获取审批日志
  4251. Doo::loadModel ( 'receiptLog' );
  4252. $receiptLog = new receiptLog ();
  4253. $rlList = array ();
  4254. $rlInfo = $receiptLog->getOne ( array (
  4255. 'where' => 'rid=' . $rid . ' and status=4',
  4256. 'asArray' => true
  4257. ) );
  4258. $tijdate = $receiptLog->getOne ( array (
  4259. 'where' => 'rid=' . $rid . ' and status=2',
  4260. 'asc' => 'rlid',
  4261. 'asArray' => true
  4262. ) );
  4263. if (! empty ( $rlInfo )) {
  4264. $rlList = $receiptLog->find ( array (
  4265. 'where' => 'rid=' . $rid,
  4266. 'asc' => 'rlid',
  4267. 'asArray' => true
  4268. ) );
  4269. }
  4270. // echo $rid;
  4271. // print_r($receiptList);
  4272. $receiptList [0] ['rlList'] = $rlList;
  4273. // print_r($receiptList);
  4274. $enclosurList = $enclosur->find ( array (
  4275. 'where' => 'rid=' . $rid,
  4276. 'asArray' => true
  4277. ) );
  4278. $enclosurHtml = '';
  4279. foreach ( $enclosurList as $value ) {
  4280. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4281. }
  4282. $data ['enclosurHtml'] = $enclosurHtml;
  4283. $data ['rolename'] = $rolename ['name'];
  4284. // $data['datetij']=$tijdate['date'];
  4285. $data ['mothHtml'] = $mothHtml;
  4286. // print_r($receiptList);
  4287. $data ['rid'] = $rid;
  4288. $data ['tijdate'] = $tijdate ['date'];
  4289. $data ['receiptList'] = $receiptList;
  4290. $data ['receiptApprovalCount'] = count ( $receiptList );
  4291. $data ['status'] = $status;
  4292. $data ['year'] = $year;
  4293. $data ['categoryList'] = $categoryList;
  4294. $data ['staffList'] = $staffList;
  4295. $data ['cid'] = $cid;
  4296. $data ['sid'] = $sid;
  4297. $data ['ap'] = $ap;
  4298. $data ['memu'] = "receipt";
  4299. $data ['staff'] = $this->staff;
  4300. $data ['receiptMemu'] = 'approvalExpenses';
  4301. $data ['verifyId'] = $this->verifyId;
  4302. $data ['executeId'] = $this->executeId;
  4303. $this->render ( "/admin/receiptburEdi", $data );
  4304. }
  4305. function hisImplement() {
  4306. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4307. if (empty ( $item ))
  4308. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4309. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4310. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  4311. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  4312. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  4313. Doo::loadModel ( 'receipt' );
  4314. $receipt = new receipt ();
  4315. Doo::loadModel ( 'L_category' );
  4316. $Lcategory = new L_category ();
  4317. Doo::loadModel ( 'verify' );
  4318. Doo::loadModel ( 'statistics' );
  4319. $statistics = new statistics ();
  4320. $verify = new verify ();
  4321. Doo::loadModel ( 'staff' );
  4322. $staff = new staff ();
  4323. Doo::loadClass ( 'XDeode' );
  4324. $XDeode = new XDeode ( 5 );
  4325. $condition = "";
  4326. if ($item == "expenses")
  4327. $condition = " and Rtype=1 ";
  4328. elseif ($item == "receipts")
  4329. $condition = " and Rtype=0 ";
  4330. elseif ($item == "remits")
  4331. $condition = " and Rtype=2 ";
  4332. $sopString = "";
  4333. $dateCondition = " and Year(date) =" . $year;
  4334. if ($sop != 'SOP')
  4335. $sopString = " and staff=" . $sop;
  4336. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  4337. if ($item == 'teipts') {
  4338. $statusCon = '(status=1 or status=6 )';
  4339. $dateCondition = " and Year(pastDate) =" . $year;
  4340. if ($moth != 'MONTH')
  4341. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth;
  4342. if ($day != 'DAY')
  4343. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth . " and day(pastDate)=" . $day;
  4344. } elseif ($item == 'alerpts') {
  4345. $statusCon = '(status=8 or status=9 )';
  4346. $dateCondition = " and Year(executeDate) =" . $year;
  4347. if ($moth != 'MONTH')
  4348. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  4349. if ($day != 'DAY')
  4350. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  4351. }
  4352. // $noPassSum=$receipt->receiptByYear($year,$this->staff[0]['sid']); and (status=1 or status=6)
  4353. $receiptList = $receipt->find ( array (
  4354. 'where' => $statusCon . $condition . $dateCondition . $sopString,
  4355. 'desc' => 'rid',
  4356. 'asArray' => true
  4357. ) );
  4358. // 员工筛选
  4359. $receiptList2 = $receipt->find ( array (
  4360. 'where' => $statusCon . $condition . $dateCondition,
  4361. 'desc' => 'rid',
  4362. 'asArray' => true
  4363. ) );
  4364. $sopStaff = array ();
  4365. foreach ( $receiptList2 as $key => $value ) {
  4366. $staffDetail = $staff->getOne ( array (
  4367. 'where' => 'sid=' . $value ['staff'],
  4368. 'asArray' => true
  4369. ) );
  4370. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  4371. }
  4372. $Locate = 0;
  4373. $roleId = 0;
  4374. $button = 0;
  4375. foreach ( $receiptList as $key => $value ) {
  4376. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4377. $receiptList [$key] ['Texe'] = 'false';
  4378. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  4379. $receiptList [$key] ['Texe'] = 'true';
  4380. }
  4381. $receiptList [$key] ['TRexe'] = 'true';
  4382. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  4383. $receiptList [$key] ['TRexe'] = 'false';
  4384. }
  4385. $receiptList [$key] ['Locate'] = $Locate;
  4386. $Locate ++;
  4387. $receiptList [$key] ['reviseDetail'] = array ();
  4388. if (! empty ( $value ['reviseDetail'] ))
  4389. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4390. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4391. $categoryDetil = $Lcategory->getOne ( array (
  4392. 'where' => 'cid=' . $value ['cid'],
  4393. 'asArray' => true
  4394. ) );
  4395. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4396. // 检测编辑状态
  4397. $verifyList = $verify->getOne ( array (
  4398. 'where' => 'vid=' . $value ['verify'],
  4399. 'asArray' => true
  4400. ) );
  4401. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4402. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4403. Doo::loadModel ( 'role' );
  4404. $role = new role ();
  4405. $flag = true;
  4406. $roleKey = 0;
  4407. $endStaffArray = array ();
  4408. $roleArrayCopy = array ();
  4409. foreach ( $verifyList as $k => $v ) {
  4410. // init verifyStaff
  4411. if ($v [1] == 'ROLE') {
  4412. if (! empty ( $verifyStaff )) {
  4413. $endStaffArray = end ( $verifyStaff );
  4414. }
  4415. $roleVerify = json_decode ( $v [3], true );
  4416. $roleKey = $k;
  4417. $roleArray = array ();
  4418. $rolename = $role->getOne ( array (
  4419. 'where' => 'rid=' . $v [0],
  4420. 'asArray' => true
  4421. ) );
  4422. foreach ( $roleVerify as $o => $p ) {
  4423. $staffID = explode ( '_', $p );
  4424. $staffInfo = $staff->getOne ( array (
  4425. 'where' => 'sid=' . $staffID [0],
  4426. 'asArray' => true
  4427. ) );
  4428. $exp = array (
  4429. 0 => $staffInfo ['sid'],
  4430. 1 => $staffID [1],
  4431. 2 => $staffInfo ['avatar'],
  4432. 'date' => '',
  4433. 'date' => '',
  4434. 'opinion' => '',
  4435. 'status' => '',
  4436. 'rolename' => $rolename ['name']
  4437. );
  4438. array_push ( $roleArray, $exp );
  4439. }
  4440. $roleArrayCopy [$v [0]] = $roleArray;
  4441. }
  4442. $verifyList [$k] ['date'] = "";
  4443. $verifyList [$k] ['opinion'] = "";
  4444. $verifyList [$k] ['status'] = "";
  4445. if (empty ( $verifyStaff )) {
  4446. $verifyList [$k] ['date'] = "";
  4447. $verifyList [$k] ['opinion'] = "";
  4448. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4449. $verifyList [$k] ['status'] = 4;
  4450. $flag = false;
  4451. }
  4452. } else {
  4453. foreach ( $verifyStaff as $m => $u ) {
  4454. if ($v [0] == $m) {
  4455. $verifyList [$k] ['date'] = $u ['date'];
  4456. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4457. $verifyList [$k] ['status'] = $u ['status'];
  4458. $flag = false;
  4459. break;
  4460. }
  4461. }
  4462. $endStaffArray = end ( $verifyStaff );
  4463. }
  4464. }
  4465. $rolename ['name'] = '';
  4466. if (! empty ( $roleId )) {
  4467. Doo::loadModel ( 'role' );
  4468. $role = new role ();
  4469. $rolename = $role->getOne ( array (
  4470. 'where' => 'rid=' . $roleId,
  4471. 'asArray' => true
  4472. ) );
  4473. }
  4474. if (! empty ( $verifyStaff ))
  4475. $endStaffArray = end ( $verifyStaff );
  4476. $KOP = false;
  4477. foreach ( $roleArrayCopy as $P => $A ) {
  4478. foreach ( $A as $MKI => $AVL ) {
  4479. if (! empty ( $verifyStaff )) {
  4480. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4481. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4482. $button = 4;
  4483. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4484. }
  4485. foreach ( $verifyStaff as $m => $u ) {
  4486. $AVLFK = $AVL [0] . '_R';
  4487. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4488. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4489. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4490. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4491. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4492. break;
  4493. }
  4494. }
  4495. } else {
  4496. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4497. $button = 4;
  4498. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4499. }
  4500. }
  4501. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4502. $KOP = true;
  4503. }
  4504. }
  4505. foreach ( $roleArrayCopy as $k => $v ) {
  4506. foreach ( $verifyList as $m => $n ) {
  4507. if ($n [0] == $k) {
  4508. array_splice ( $verifyList, $m, 1, $v );
  4509. }
  4510. }
  4511. }
  4512. $receiptList [$key] ['verifyList'] = $verifyList;
  4513. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4514. 'where' => 'sid=' . $value ['staff'],
  4515. 'asArray' => true
  4516. ) );
  4517. $receiptList [$key] ['button'] = $button;
  4518. }
  4519. // print_r($receiptList);
  4520. $mothHtml = "";
  4521. for($i = 1; $i <= 12; $i ++) {
  4522. if ($moth == $i)
  4523. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4524. else
  4525. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4526. }
  4527. $dayHtml = "";
  4528. if ($day != "DAY" || $moth != "MONTH") {
  4529. for($i = 1; $i <= 31; $i ++) {
  4530. if ($day == $i)
  4531. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  4532. else
  4533. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  4534. }
  4535. }
  4536. $sopHtml = "";
  4537. foreach ( $sopStaff as $key => $value ) {
  4538. if ($sop == $key)
  4539. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4540. else
  4541. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4542. }
  4543. $data ['sopHtml'] = $sopHtml;
  4544. $data ['dayHtml'] = $dayHtml;
  4545. $data ['mothHtml'] = $mothHtml;
  4546. $data ['receiptList'] = $receiptList;
  4547. $data ['memu'] = "receipt";
  4548. $data ['staff'] = $this->staff;
  4549. $data ['receiptMemu'] = 'implement';
  4550. $data ['verifyId'] = $this->verifyId;
  4551. $data ['executeId'] = $this->executeId;
  4552. $data ['item'] = $item;
  4553. $data ['year'] = $year;
  4554. $data ['moth'] = $moth;
  4555. $data ['day'] = $day;
  4556. $data ['sop'] = $sop;
  4557. $this->render ( "/admin/hisImplement", $data );
  4558. }
  4559. function ajaxExamine() {
  4560. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4561. Doo::loadModel ( 'receipt' );
  4562. $receipt = new receipt ();
  4563. if (! empty ( $rid )) {
  4564. $rLRes = $receipt->find ( array (
  4565. '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,
  4566. 'asArray' => true
  4567. ) );
  4568. echo json_encode ( array (
  4569. 'status' => 1,
  4570. 'receipt' => $rLRes [0]
  4571. ) );
  4572. die ();
  4573. }
  4574. echo json_encode ( array (
  4575. 'status' => 0,
  4576. 'receipt' => array ()
  4577. ) );
  4578. die ();
  4579. }
  4580. /*
  4581. * 废弃
  4582. */
  4583. function myReceipt() {
  4584. // all approval past withdraw
  4585. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4586. if (empty ( $item ))
  4587. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4588. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4589. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  4590. Doo::loadModel ( 'receipt' );
  4591. $receipt = new receipt ();
  4592. // pre-loaded
  4593. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4594. // have cache
  4595. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  4596. if (! empty ( $moth )) // yearPage
  4597. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  4598. $this->showCache ( $path );
  4599. }
  4600. Doo::loadModel ( 'L_category' );
  4601. $Lcategory = new L_category ();
  4602. Doo::loadModel ( 'verify' );
  4603. Doo::loadModel ( 'statistics' );
  4604. $statistics = new statistics ();
  4605. $verify = new verify ();
  4606. Doo::loadModel ( 'staff' );
  4607. $staff = new staff ();
  4608. $condition = " and status!=0 ";
  4609. if ($item == "approval")
  4610. $condition = " and status=2 ";
  4611. elseif ($item == "withdraw")
  4612. $condition = " and status=3 ";
  4613. elseif ($item == "past")
  4614. $condition = " and status=1 ";
  4615. elseif ($item == "whdw")
  4616. $condition = " and status=4 ";
  4617. $dateCondition = " and Year(date) =" . $year;
  4618. if (! empty ( $moth )) {
  4619. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  4620. $stList = $statistics->getOne ( array (
  4621. 'select' => 'rePrice ,agPrice',
  4622. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  4623. 'asArray' => true
  4624. ) );
  4625. } else
  4626. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  4627. if (empty ( $stList ))
  4628. $stList = array (
  4629. 'rePrice' => 0,
  4630. 'agPrice' => 0
  4631. );
  4632. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  4633. $data ['stList'] = array (
  4634. 'rePrice' => $stList ['rePrice'],
  4635. 'agPrice' => $stList ['agPrice'],
  4636. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  4637. );
  4638. $receiptList = $receipt->find ( array (
  4639. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  4640. 'desc' => 'rid',
  4641. 'asArray' => true
  4642. ) );
  4643. $Locate = 0;
  4644. $roleId = 0;
  4645. $button = 0;
  4646. foreach ( $receiptList as $key => $value ) {
  4647. $receiptList [$key] ['Locate'] = $Locate;
  4648. $Locate ++;
  4649. $receiptList [$key] ['reviseDetail'] = array ();
  4650. if (! empty ( $value ['reviseDetail'] ))
  4651. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4652. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4653. $categoryDetil = $Lcategory->getOne ( array (
  4654. 'where' => 'cid=' . $value ['cid'],
  4655. 'asArray' => true
  4656. ) );
  4657. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4658. // 检测编辑状态
  4659. $verifyList = $verify->getOne ( array (
  4660. 'where' => 'vid=' . $value ['verify'],
  4661. 'asArray' => true
  4662. ) );
  4663. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4664. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4665. Doo::loadModel ( 'role' );
  4666. $role = new role ();
  4667. $flag = true;
  4668. $roleKey = 0;
  4669. $endStaffArray = array ();
  4670. $roleArrayCopy = array ();
  4671. foreach ( $verifyList as $k => $v ) {
  4672. // init verifyStaff
  4673. if ($v [1] == 'ROLE') {
  4674. if (! empty ( $verifyStaff )) {
  4675. $endStaffArray = end ( $verifyStaff );
  4676. // if ($v[0]==$endStaffArray['nextStaff']){
  4677. // $roleId=$v[0];
  4678. // }
  4679. }
  4680. $roleVerify = json_decode ( $v [3], true );
  4681. $roleKey = $k;
  4682. $roleArray = array ();
  4683. $rolename = $role->getOne ( array (
  4684. 'where' => 'rid=' . $v [0],
  4685. 'asArray' => true
  4686. ) );
  4687. foreach ( $roleVerify as $o => $p ) {
  4688. $staffID = explode ( '_', $p );
  4689. $staffInfo = $staff->getOne ( array (
  4690. 'where' => 'sid=' . $staffID [0],
  4691. 'asArray' => true
  4692. ) );
  4693. // print_r($staffID);
  4694. $exp = array (
  4695. 0 => $staffInfo ['sid'],
  4696. 1 => $staffID [1],
  4697. 2 => $staffInfo ['avatar'],
  4698. 'date' => '',
  4699. 'date' => '',
  4700. 'opinion' => '',
  4701. 'status' => '',
  4702. 'rolename' => $rolename ['name']
  4703. );
  4704. array_push ( $roleArray, $exp );
  4705. }
  4706. $roleArrayCopy [$v [0]] = $roleArray;
  4707. // $verifyList[$k]['roleArray']=$roleArray;
  4708. }
  4709. $verifyList [$k] ['date'] = "";
  4710. $verifyList [$k] ['opinion'] = "";
  4711. $verifyList [$k] ['status'] = "";
  4712. if (empty ( $verifyStaff )) {
  4713. $verifyList [$k] ['date'] = "";
  4714. $verifyList [$k] ['opinion'] = "";
  4715. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4716. $verifyList [$k] ['status'] = 4;
  4717. $flag = false;
  4718. }
  4719. } else {
  4720. foreach ( $verifyStaff as $m => $u ) {
  4721. if ($v [0] == $m) {
  4722. $verifyList [$k] ['date'] = $u ['date'];
  4723. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4724. $verifyList [$k] ['status'] = $u ['status'];
  4725. $flag = false;
  4726. break;
  4727. }
  4728. }
  4729. $endStaffArray = end ( $verifyStaff );
  4730. if (isset ( $endStaffArray ['ROLE'] )) {
  4731. } else {
  4732. // $endKey=key($verifyStaff);
  4733. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4734. // $button=4;
  4735. // $verifyList[$k]['status']=4;
  4736. // }
  4737. }
  4738. }
  4739. }
  4740. $rolename ['name'] = '';
  4741. if (! empty ( $roleId )) {
  4742. Doo::loadModel ( 'role' );
  4743. $role = new role ();
  4744. $rolename = $role->getOne ( array (
  4745. 'where' => 'rid=' . $roleId,
  4746. 'asArray' => true
  4747. ) );
  4748. }
  4749. if (! empty ( $verifyStaff ))
  4750. $endStaffArray = end ( $verifyStaff );
  4751. $KOP = false;
  4752. foreach ( $roleArrayCopy as $P => $A ) {
  4753. foreach ( $A as $MKI => $AVL ) {
  4754. if (! empty ( $verifyStaff )) {
  4755. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4756. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4757. $button = 4;
  4758. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4759. }
  4760. foreach ( $verifyStaff as $m => $u ) {
  4761. $AVLFK = $AVL [0] . '_R';
  4762. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4763. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4764. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4765. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4766. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4767. break;
  4768. }
  4769. }
  4770. } else {
  4771. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4772. $button = 4;
  4773. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4774. }
  4775. }
  4776. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4777. $KOP = true;
  4778. }
  4779. }
  4780. foreach ( $roleArrayCopy as $k => $v ) {
  4781. foreach ( $verifyList as $m => $n ) {
  4782. if ($n [0] == $k) {
  4783. array_splice ( $verifyList, $m, 1, $v );
  4784. }
  4785. }
  4786. }
  4787. $receiptList [$key] ['verifyList'] = $verifyList;
  4788. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4789. 'where' => 'sid=' . $value ['staff'],
  4790. 'asArray' => true
  4791. ) );
  4792. $receiptList [$key] ['button'] = $button;
  4793. }
  4794. // print_r($receiptList);die;
  4795. $mothHtml = "";
  4796. for($i = 1; $i <= 12; $i ++) {
  4797. if ($moth == $i)
  4798. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4799. else
  4800. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4801. }
  4802. $data ['mothHtml'] = $mothHtml;
  4803. $data ['receiptList'] = $receiptList;
  4804. $data ['memu'] = "receipt";
  4805. $data ['staff'] = $this->staff;
  4806. $data ['receiptMemu'] = 'receipt';
  4807. $data ['verifyId'] = $this->verifyId;
  4808. $data ['executeId'] = $this->executeId;
  4809. $data ['item'] = $item;
  4810. $data ['year'] = $year;
  4811. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4812. // sufficient condition to generate cache
  4813. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  4814. $receiptList = $receipt->find ( array (
  4815. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  4816. 'asArray' => true
  4817. ) );
  4818. if (empty ( $receiptList )) { // generated files
  4819. ob_start ();
  4820. $this->render ( "/admin/saea_myList", $data );
  4821. $this->cacheFile ( $path );
  4822. die ();
  4823. // $content = ob_get_contents();
  4824. // $fp = fopen($path, "w");
  4825. // fwrite($fp, $content);
  4826. // fclose($fp);
  4827. }
  4828. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  4829. $receiptList = $receipt->find ( array (
  4830. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  4831. 'asArray' => true
  4832. ) );
  4833. if (empty ( $receiptList )) { // generated files
  4834. ob_start ();
  4835. $this->render ( "/admin/saea_myList", $data );
  4836. $this->cacheFile ( $path );
  4837. die ();
  4838. }
  4839. }
  4840. }
  4841. $this->render ( "/admin/saea_myList", $data );
  4842. }
  4843. function saeaCreate() {
  4844. Doo::loadModel ( 'accountItem' );
  4845. Doo::loadModel ( 'verify' );
  4846. Doo::loadModel ( 'receipt' );
  4847. Doo::loadModel ( 'L_category' );
  4848. $lCategory = new L_category ();
  4849. $receipt = new receipt ();
  4850. $verify = new verify ();
  4851. $accountItem = new accountItem ();
  4852. Doo::loadModel ( "role" );
  4853. $role = new role ();
  4854. $acItem = $accountItem->find ( array (
  4855. 'asArray' => true
  4856. ) );
  4857. $veList = $verify->find ( array (
  4858. 'asArray' => true
  4859. ) );
  4860. foreach ( $veList as $key => $value ) {
  4861. $v = json_decode ( $value ['staff'] );
  4862. $list = array ();
  4863. foreach ( $v as $n => $m ) {
  4864. if ($m ['1'] == 'ROLE') {
  4865. $roleInfo = $role->getOne ( array (
  4866. 'where' => 'rid=' . $m [0],
  4867. 'asArray' => true
  4868. ) );
  4869. $v [$n] [1] = $roleInfo ['name'];
  4870. array_push ( $list, $roleInfo ['name'] );
  4871. } else {
  4872. array_push ( $list, $v [$n] [1] );
  4873. }
  4874. }
  4875. $veList [$key] ['staff'] = implode ( '>', $list );
  4876. }
  4877. $data ['category'] = $lCategory->find ( array (
  4878. 'asArray' => true
  4879. ) );
  4880. $data ['veList'] = $veList;
  4881. $data ['acItem'] = $acItem;
  4882. $data ['memu'] = "receipt";
  4883. $data ['staff'] = $this->staff;
  4884. $data ['receiptMemu'] = 'saeaBorad';
  4885. $data ['verifyId'] = $this->verifyId;
  4886. $data ['executeId'] = $this->executeId;
  4887. $this->render ( "/admin/saea_create", $data );
  4888. }
  4889. function addReceipt() {
  4890. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  4891. $agency = $this->get_args ( 'agency' );
  4892. $travel = $this->get_args ( 'travel' );
  4893. $train = $this->get_args ( 'train' );
  4894. $other = $this->get_args ( 'other' );
  4895. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  4896. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  4897. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  4898. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  4899. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  4900. Doo::loadModel ( 'receipt' );
  4901. Doo::loadModel ( 'receiptDetail' );
  4902. Doo::loadModel ( 'accountItem' );
  4903. $accountItem = new accountItem ();
  4904. $receipt = new receipt ();
  4905. Doo::loadModel ( 'enclosur' );
  4906. Doo::loadModel ( 'execute' );
  4907. $execute = new execute ();
  4908. $executeDetail = $execute->getOne ( array (
  4909. 'where' => 'mold="报销单执行人"',
  4910. 'asArray' => true
  4911. ) );
  4912. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  4913. // if(!empty($receiptDetail))
  4914. // return "/referReceipt/".$receiptDetail['rid'];
  4915. $aItem = $accountItem->find ( array (
  4916. 'asArray' => true
  4917. ) );
  4918. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  4919. $ag = $tr = $ta = $ot = 0;
  4920. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  4921. foreach ( $aItem as $key => $value ) {
  4922. if ($value ['category'] == $this->AGENCY) {
  4923. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  4924. array_push ( $accountJson [$this->AGENCY], array (
  4925. 'aid' => $value ['aid'],
  4926. 'name' => $value ['name'],
  4927. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  4928. ) );
  4929. $sum += $agency [$ag];
  4930. $agencySum += $agency [$ag];
  4931. }
  4932. $ag ++;
  4933. }
  4934. if ($value ['category'] == $this->TRAVEL) {
  4935. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  4936. array_push ( $accountJson [$this->TRAVEL], array (
  4937. 'aid' => $value ['aid'],
  4938. 'name' => $value ['name'],
  4939. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  4940. ) );
  4941. $sum += $travel [$tr];
  4942. $travelSum += $travel [$tr];
  4943. }
  4944. $tr ++;
  4945. }
  4946. if ($value ['category'] == $this->TRAIN) {
  4947. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  4948. array_push ( $accountJson [$this->TRAIN], array (
  4949. 'aid' => $value ['aid'],
  4950. 'name' => $value ['name'],
  4951. 'price' => number_format ( $train [$ta], 2, '.', '' )
  4952. ) );
  4953. $sum += $train [$ta];
  4954. $trainSum += $train [$ta];
  4955. }
  4956. $ta ++;
  4957. }
  4958. if ($value ['category'] == $this->OTHER) {
  4959. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  4960. array_push ( $accountJson [$this->OTHER], array (
  4961. 'aid' => $value ['aid'],
  4962. 'name' => $value ['name'],
  4963. 'price' => number_format ( $other [$ot], 2, '.', '' )
  4964. ) );
  4965. $sum += $other [$ot];
  4966. $otherSum += $other [$ot];
  4967. }
  4968. $ot ++;
  4969. }
  4970. }
  4971. $accountJson ['cSum'] = array (
  4972. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  4973. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  4974. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  4975. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  4976. );
  4977. // 报销单
  4978. $receipt->accountItem = json_encode ( $accountJson );
  4979. $receipt->staff = $this->staff [0] ['sid'];
  4980. $receipt->sum = number_format ( $sum, 2, '.', '' );
  4981. $receipt->date = date ( "Y-m-d" );
  4982. $receipt->cid = $cid;
  4983. $receipt->status = 5;
  4984. // 修改审批流程加入角色
  4985. $receipt->verify = $verify;
  4986. $receipt->executeCopy = $executeDetail ['staff'];
  4987. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  4988. $receipt->explanation = $explanation;
  4989. $rid = $receipt->insert ();
  4990. // 附件
  4991. if (! empty ( $enclosurName )) {
  4992. $enclosurArray = explode ( '-', $enclosurName );
  4993. foreach ( $enclosurArray as $value ) {
  4994. $enclosur = new enclosur ();
  4995. $enclosur->name = $value;
  4996. $enclosur->rid = $rid;
  4997. $enclosur->insert ();
  4998. }
  4999. // print_r($enclosurArray);die;
  5000. }
  5001. // 报销详情
  5002. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5003. $receiptDetail = new receiptDetail ();
  5004. $receiptDetail->staff = $this->staff [0] ['sid'];
  5005. $receiptDetail->item = $value ['name'];
  5006. $receiptDetail->itemCategory = $this->AGENCY;
  5007. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5008. $receiptDetail->date = date ( "Y-m-d" );
  5009. $receiptDetail->cid = $cid;
  5010. $receiptDetail->rid = $rid;
  5011. $receiptDetail->status = 4;
  5012. $receiptDetail->insert ();
  5013. }
  5014. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5015. $receiptDetail = new receiptDetail ();
  5016. $receiptDetail->staff = $this->staff [0] ['sid'];
  5017. $receiptDetail->item = $value ['name'];
  5018. $receiptDetail->itemCategory = $this->TRAVEL;
  5019. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5020. $receiptDetail->date = date ( "Y-m-d" );
  5021. $receiptDetail->cid = $cid;
  5022. $receiptDetail->rid = $rid;
  5023. $receiptDetail->status = 4;
  5024. $receiptDetail->insert ();
  5025. }
  5026. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5027. $receiptDetail = new receiptDetail ();
  5028. $receiptDetail->staff = $this->staff [0] ['sid'];
  5029. $receiptDetail->item = $value ['name'];
  5030. $receiptDetail->itemCategory = $this->TRAIN;
  5031. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5032. $receiptDetail->date = date ( "Y-m-d" );
  5033. $receiptDetail->cid = $cid;
  5034. $receiptDetail->rid = $rid;
  5035. $receiptDetail->status = 4;
  5036. $receiptDetail->insert ();
  5037. }
  5038. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5039. $receiptDetail = new receiptDetail ();
  5040. $receiptDetail->staff = $this->staff [0] ['sid'];
  5041. $receiptDetail->item = $value ['name'];
  5042. $receiptDetail->itemCategory = $this->OTHER;
  5043. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5044. $receiptDetail->date = date ( "Y-m-d" );
  5045. $receiptDetail->cid = $cid;
  5046. $receiptDetail->rid = $rid;
  5047. $receiptDetail->status = 4;
  5048. $receiptDetail->insert ();
  5049. }
  5050. // return "/referReceipt/".$rid;
  5051. }
  5052. return "/saeaBorad";
  5053. }
  5054. function referReceipt() {
  5055. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  5056. Doo::loadModel ( 'receipt' );
  5057. Doo::loadModel ( 'verify' );
  5058. $verify = new verify ();
  5059. $receipt = new receipt ();
  5060. Doo::loadModel ( 'L_category' );
  5061. $lCategory = new L_category ();
  5062. Doo::loadModel ( "role" );
  5063. $role = new role ();
  5064. $receiptDetail = $receipt->find ( array (
  5065. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  5066. 'asArray' => true
  5067. ) );
  5068. if (empty ( $receiptDetail ))
  5069. return "/addReceipt";
  5070. foreach ( $receiptDetail as $key => $value ) {
  5071. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5072. $veList = $verify->getOne ( array (
  5073. 'where' => 'vid=' . $value ['verify'],
  5074. 'asArray' => true
  5075. ) );
  5076. $v = json_decode ( $veList ['staff'] );
  5077. array_push ( $v [0], $veList ['description'] );
  5078. foreach ( $v as $n => $m ) {
  5079. if ($m ['1'] == 'ROLE') {
  5080. $roleInfo = $role->getOne ( array (
  5081. 'where' => 'rid=' . $m [0],
  5082. 'asArray' => true
  5083. ) );
  5084. $v [$n] [1] = $roleInfo ['name'];
  5085. }
  5086. }
  5087. $receiptDetail [$key] ['staff'] = $v;
  5088. $category = $lCategory->getOne ( array (
  5089. 'where' => 'cid=' . $value ['cid'],
  5090. 'asArray' => true
  5091. ) );
  5092. $receiptDetail [$key] ['category'] = $category ['title'];
  5093. }
  5094. // print_r($receiptDetail);
  5095. $data ['receiptDetail'] = $receiptDetail;
  5096. $data ['memu'] = "receipt";
  5097. $data ['staff'] = $this->staff;
  5098. $data ['receiptMemu'] = 'saeaCreate';
  5099. $data ['verifyId'] = $this->verifyId;
  5100. $data ['executeId'] = $this->executeId;
  5101. $this->render ( "/admin/saea_confirm", $data );
  5102. }
  5103. function editReceipt() {
  5104. // edit status 4
  5105. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5106. // echo $rid;
  5107. Doo::loadModel ( 'accountItem' );
  5108. Doo::loadModel ( 'verify' );
  5109. Doo::loadModel ( 'receipt' );
  5110. $receipt = new receipt ();
  5111. $verify = new verify ();
  5112. $accountItem = new accountItem ();
  5113. Doo::loadModel ( 'L_category' );
  5114. $lCategory = new L_category ();
  5115. Doo::loadModel ( "role" );
  5116. $role = new role ();
  5117. $receiptDetail = $receipt->getOne ( array (
  5118. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  5119. 'asArray' => true
  5120. ) );
  5121. if (empty ( $receiptDetail ))
  5122. return "/saeaCreate";
  5123. $acItem = $accountItem->find ( array (
  5124. 'asArray' => true
  5125. ) );
  5126. $veList = $verify->find ( array (
  5127. 'asArray' => true
  5128. ) );
  5129. foreach ( $veList as $key => $value ) {
  5130. $v = json_decode ( $value ['staff'] );
  5131. $list = array ();
  5132. foreach ( $v as $n => $m ) {
  5133. if ($m ['1'] == 'ROLE') {
  5134. $roleInfo = $role->getOne ( array (
  5135. 'where' => 'rid=' . $m [0],
  5136. 'asArray' => true
  5137. ) );
  5138. $v [$n] [1] = $roleInfo ['name'];
  5139. array_push ( $list, $roleInfo ['name'] );
  5140. } else {
  5141. array_push ( $list, $v [$n] [1] );
  5142. }
  5143. }
  5144. $veList [$key] ['staff'] = implode ( '>', $list );
  5145. }
  5146. // 配置编辑信息
  5147. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  5148. foreach ( $acItem as $key => $value ) {
  5149. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  5150. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  5151. $acItem [$key] ['price'] = $v ['price'];
  5152. }
  5153. }
  5154. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  5155. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  5156. $acItem [$key] ['price'] = $v ['price'];
  5157. }
  5158. }
  5159. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  5160. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  5161. $acItem [$key] ['price'] = $v ['price'];
  5162. }
  5163. }
  5164. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  5165. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  5166. $acItem [$key] ['price'] = $v ['price'];
  5167. }
  5168. }
  5169. }
  5170. $data ['category'] = $lCategory->find ( array (
  5171. 'asArray' => true
  5172. ) );
  5173. $data ['cSum'] = $accountItemList ['cSum'];
  5174. $data ['sum'] = $receiptDetail ['sum'];
  5175. $data ['receiptDetail'] = $receiptDetail;
  5176. $data ['veList'] = $veList;
  5177. $data ['acItem'] = $acItem;
  5178. $data ['memu'] = "receipt";
  5179. $data ['staff'] = $this->staff;
  5180. $data ['receiptMemu'] = 'saeaBorad';
  5181. $data ['verify'] = $receiptDetail ['verify'];
  5182. $data ['verifyId'] = $this->verifyId;
  5183. $data ['executeId'] = $this->executeId;
  5184. $data ['rid'] = $rid;
  5185. $this->render ( "/admin/saea_edit", $data );
  5186. }
  5187. function updateReceipt() {
  5188. $agency = $this->get_args ( 'agency' );
  5189. $travel = $this->get_args ( 'travel' );
  5190. $train = $this->get_args ( 'train' );
  5191. $other = $this->get_args ( 'other' );
  5192. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5193. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5194. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5195. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5196. if (! empty ( $explanation )) {
  5197. Doo::loadModel ( 'receipt' );
  5198. Doo::loadModel ( 'receiptDetail' );
  5199. Doo::loadModel ( 'accountItem' );
  5200. $accountItem = new accountItem ();
  5201. $receipt = new receipt ();
  5202. Doo::loadModel ( 'execute' );
  5203. $execute = new execute ();
  5204. $receiptDetail = $receipt->getOne ( array (
  5205. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  5206. 'asArray' => true
  5207. ) );
  5208. if (empty ( $receiptDetail ))
  5209. return "/saeaBorad";
  5210. if ($receiptDetail ['Rtype'] == 1)
  5211. $executeDetail = $execute->getOne ( array (
  5212. 'where' => 'mold="借款费用执行人"',
  5213. 'asArray' => true
  5214. ) );
  5215. else
  5216. $executeDetail = $execute->getOne ( array (
  5217. 'where' => 'mold="报销单执行人"',
  5218. 'asArray' => true
  5219. ) );
  5220. $aItem = $accountItem->find ( array (
  5221. 'asArray' => true
  5222. ) );
  5223. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5224. $ag = $tr = $ta = $ot = 0;
  5225. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5226. foreach ( $aItem as $key => $value ) {
  5227. if ($value ['category'] == $this->AGENCY) {
  5228. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5229. array_push ( $accountJson [$this->AGENCY], array (
  5230. 'aid' => $value ['aid'],
  5231. 'name' => $value ['name'],
  5232. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5233. ) );
  5234. $sum += $agency [$ag];
  5235. $agencySum += $agency [$ag];
  5236. }
  5237. $ag ++;
  5238. }
  5239. if ($value ['category'] == $this->TRAVEL) {
  5240. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5241. array_push ( $accountJson [$this->TRAVEL], array (
  5242. 'aid' => $value ['aid'],
  5243. 'name' => $value ['name'],
  5244. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5245. ) );
  5246. $sum += $travel [$tr];
  5247. $travelSum += $travel [$tr];
  5248. }
  5249. $tr ++;
  5250. }
  5251. if ($value ['category'] == $this->TRAIN) {
  5252. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5253. array_push ( $accountJson [$this->TRAIN], array (
  5254. 'aid' => $value ['aid'],
  5255. 'name' => $value ['name'],
  5256. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5257. ) );
  5258. $sum += $train [$ta];
  5259. $trainSum += $train [$ta];
  5260. }
  5261. $ta ++;
  5262. }
  5263. if ($value ['category'] == $this->OTHER) {
  5264. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5265. array_push ( $accountJson [$this->OTHER], array (
  5266. 'aid' => $value ['aid'],
  5267. 'name' => $value ['name'],
  5268. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5269. ) );
  5270. $sum += $other [$ot];
  5271. $otherSum += $other [$ot];
  5272. }
  5273. $ot ++;
  5274. }
  5275. }
  5276. $accountJson ['cSum'] = array (
  5277. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5278. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5279. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5280. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5281. );
  5282. // 报销单
  5283. $rid = $receipt->rid = $receiptDetail ['rid'];
  5284. $receipt->accountItem = json_encode ( $accountJson );
  5285. $receipt->staff = $this->staff [0] ['sid'];
  5286. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5287. $receipt->date = date ( "Y-m-d" );
  5288. $receipt->cid = $cid;
  5289. if (($receiptDetail ['status'] != 4)) {
  5290. if ($receiptDetail ['Rtype'] == 1)
  5291. $receipt->status = 7;
  5292. else
  5293. $receipt->status = 5;
  5294. }
  5295. if ($receiptDetail != 4 && ! empty ( $verify ))
  5296. $receipt->verify = $verify;
  5297. $receipt->executeCopy = $executeDetail ['staff'];
  5298. $receipt->explanation = $explanation;
  5299. $receipt->update ();
  5300. $receiptDetail = new receiptDetail ();
  5301. $receiptDetail->delete ( array (
  5302. 'where' => 'rid=' . $rid
  5303. ) );
  5304. // 报销详情
  5305. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5306. $receiptDetail = new receiptDetail ();
  5307. $receiptDetail->staff = $this->staff [0] ['sid'];
  5308. $receiptDetail->item = $value ['name'];
  5309. $receiptDetail->itemCategory = $this->AGENCY;
  5310. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5311. $receiptDetail->date = date ( "Y-m-d" );
  5312. $receiptDetail->cid = $cid;
  5313. $receiptDetail->rid = $rid;
  5314. $receiptDetail->status = 4;
  5315. $receiptDetail->insert ();
  5316. }
  5317. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5318. $receiptDetail = new receiptDetail ();
  5319. $receiptDetail->staff = $this->staff [0] ['sid'];
  5320. $receiptDetail->item = $value ['name'];
  5321. $receiptDetail->itemCategory = $this->TRAVEL;
  5322. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5323. $receiptDetail->date = date ( "Y-m-d" );
  5324. $receiptDetail->cid = $cid;
  5325. $receiptDetail->rid = $rid;
  5326. $receiptDetail->status = 4;
  5327. $receiptDetail->insert ();
  5328. }
  5329. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5330. $receiptDetail = new receiptDetail ();
  5331. $receiptDetail->staff = $this->staff [0] ['sid'];
  5332. $receiptDetail->item = $value ['name'];
  5333. $receiptDetail->itemCategory = $this->TRAIN;
  5334. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5335. $receiptDetail->date = date ( "Y-m-d" );
  5336. $receiptDetail->cid = $cid;
  5337. $receiptDetail->rid = $rid;
  5338. $receiptDetail->status = 4;
  5339. $receiptDetail->insert ();
  5340. }
  5341. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5342. $receiptDetail = new receiptDetail ();
  5343. $receiptDetail->staff = $this->staff [0] ['sid'];
  5344. $receiptDetail->item = $value ['name'];
  5345. $receiptDetail->itemCategory = $this->OTHER;
  5346. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5347. $receiptDetail->date = date ( "Y-m-d" );
  5348. $receiptDetail->cid = $cid;
  5349. $receiptDetail->rid = $rid;
  5350. $receiptDetail->status = 4;
  5351. $receiptDetail->insert ();
  5352. }
  5353. // return "/referReceipt/".$rid;
  5354. }
  5355. return "/saeaBorad";
  5356. }
  5357. function approvedReceipt() {
  5358. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5359. Doo::loadModel ( 'receipt' );
  5360. Doo::loadModel ( 'receiptDetail' );
  5361. $receipt = new receipt ();
  5362. $receiptDetail = new receiptDetail ();
  5363. Doo::loadModel ( 'statistics' );
  5364. Doo::loadModel ( 'itemStatistics' );
  5365. $statistics = new statistics ();
  5366. $itemStatistics = new itemStatistics ();
  5367. Doo::loadModel ( "verify" );
  5368. $verify = new verify ();
  5369. // 审批状态的判定
  5370. $receiptDetailList = $receipt->getOne ( array (
  5371. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  5372. 'asArray' => true
  5373. ) );
  5374. if (empty ( $receiptDetailList ))
  5375. return "/saeaBorad";
  5376. $verifyDetail = $verify->getOne ( array (
  5377. 'where' => ' vid =' . $receiptDetailList ['verify'],
  5378. 'asArray' => true
  5379. ) );
  5380. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5381. if (empty ( $receiptDetailList ['nowStaff'] )) {
  5382. $nowStaff = "";
  5383. $nowStaffList = array ();
  5384. if ($verifyDetail [0] [1] == 'ROLE') {
  5385. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5386. foreach ( $vStaffString as $key => $value ) {
  5387. $staffK = explode ( "_", $value );
  5388. array_push ( $nowStaffList, $staffK [0] );
  5389. }
  5390. $nowStaff = implode ( ',', $nowStaffList );
  5391. } else {
  5392. $nowStaff = $verifyDetail [0] [0];
  5393. }
  5394. $receipt->nowStaff = $nowStaff;
  5395. }
  5396. // echo $nowStaff;
  5397. // print_r($verifyDetail);die;
  5398. $receipt->rid = $receiptDetailList ['rid'];
  5399. $receipt->date = date ( "Y-m-d" );
  5400. $receipt->status = 2;
  5401. $receipt->update ();
  5402. $receiptDetail->status = 2;
  5403. $receiptDetail->update ( array (
  5404. 'where' => 'rid=' . $receiptDetailList ['rid']
  5405. ) );
  5406. Doo::loadModel ( "receiptLog" );
  5407. $receiptLog = new receiptLog ();
  5408. Doo::loadModel ( "verify" );
  5409. $verify = new verify ();
  5410. $receiptInfo = $receipt->getOne ( array (
  5411. 'where' => 'rid=' . $rid,
  5412. 'asArray' => true
  5413. ) );
  5414. $vr = $verify->getOne ( array (
  5415. 'where' => 'vid=' . $receiptInfo ['verify'],
  5416. 'asArray' => true
  5417. ) );
  5418. $jd = json_decode ( $vr ['staff'] );
  5419. $roleId = 0;
  5420. foreach ( $jd as $key => $value ) {
  5421. if ($value [1] == 'ROLE') {
  5422. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  5423. if ($pos !== false) {
  5424. $roleId = $value [0];
  5425. }
  5426. }
  5427. }
  5428. // 审批日志
  5429. // echo $roleId;die;
  5430. if (! empty ( $roleId )) {
  5431. Doo::loadModel ( "role" );
  5432. $role = new role ();
  5433. $roleInfo = $role->getOne ( array (
  5434. 'where' => 'rid=' . $roleId,
  5435. 'asArray' => true
  5436. ) );
  5437. $receiptLog->rolename = $roleInfo ['name'];
  5438. }
  5439. $receiptLog->username = $this->staff [0] ['username'];
  5440. $receiptLog->uid = $this->staff [0] ['sid'];
  5441. $receiptLog->date = date ( "Y-m-d" );
  5442. $receiptLog->opinion = '提交审批';
  5443. $receiptLog->img = $this->staff [0] ['avatar'];
  5444. $receiptLog->status = 2;
  5445. $receiptLog->rid = $rid;
  5446. $receiptLog->insert ();
  5447. // statistics item
  5448. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  5449. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  5450. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  5451. // print_r($accountItem['cSum']['agencySum']);die;
  5452. // foreach ($accountItem['cSum'] as $key=>$value){
  5453. // if($key=="agencySum"){
  5454. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->AGENCY.'"'.$dateCondition,'asArray'=>true));
  5455. // if(empty($iStatistics)){
  5456. // $itemStatistics->cid=$this->staff[0]['cid'];
  5457. // $itemStatistics->staff=$this->staff[0]['sid'];
  5458. // $itemStatistics->price=$value;
  5459. // $itemStatistics->itemCategory=$this->AGENCY;
  5460. // $itemStatistics->date=date("Y-m-d");
  5461. // $itemStatistics->insert();
  5462. // }else{
  5463. // if (!empty($value)){
  5464. // $itemStatistics->price=$value+$iStatistics['price'];
  5465. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5466. // }
  5467. // }
  5468. // }elseif($key=="travelSum"){
  5469. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->TRAVEL.'"'.$dateCondition,'asArray'=>true));
  5470. // if(empty($iStatistics)){
  5471. // $itemStatistics->cid=$this->staff[0]['cid'];
  5472. // $itemStatistics->staff=$this->staff[0]['sid'];
  5473. // $itemStatistics->price=$value;
  5474. // $itemStatistics->itemCategory=$this->TRAVEL;
  5475. // $itemStatistics->date=date("Y-m-d");
  5476. // $itemStatistics->insert();
  5477. // }else{
  5478. // if (!empty($value)){
  5479. // $itemStatistics->price=$value+$iStatistics['price'];
  5480. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5481. // }
  5482. // }
  5483. // }elseif($key=="trainSum"){
  5484. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->TRAIN.'"'.$dateCondition,'asArray'=>true));
  5485. // if(empty($iStatistics)){
  5486. // $itemStatistics->cid=$this->staff[0]['cid'];
  5487. // $itemStatistics->staff=$this->staff[0]['sid'];
  5488. // $itemStatistics->price=$value;
  5489. // $itemStatistics->itemCategory=$this->TRAIN;
  5490. // $itemStatistics->date=date("Y-m-d");
  5491. // $itemStatistics->insert();
  5492. // }else{
  5493. // if (!empty($value)){
  5494. // $itemStatistics->price=$value+$iStatistics['price'];
  5495. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5496. // }
  5497. // }
  5498. // }elseif($key=="otherSum"){
  5499. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->OTHER.'"'.$dateCondition,'asArray'=>true));
  5500. // if(empty($iStatistics)){
  5501. // $itemStatistics->cid=$this->staff[0]['cid'];
  5502. // $itemStatistics->staff=$this->staff[0]['sid'];
  5503. // $itemStatistics->price=$value;
  5504. // $itemStatistics->itemCategory=$this->OTHER;
  5505. // $itemStatistics->date=date("Y-m-d");
  5506. // $itemStatistics->insert();
  5507. // }else{
  5508. // if (!empty($value)){
  5509. // $itemStatistics->price=$value+$iStatistics['price'];
  5510. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5511. // }
  5512. // }
  5513. // }
  5514. // }
  5515. $stat = $statistics->getOne ( array (
  5516. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5517. 'asArray' => true
  5518. ) );
  5519. if (empty ( $stat )) {
  5520. $statistics->date = date ( "Y-m-d" );
  5521. $statistics->cid = $this->staff [0] ['cid'];
  5522. $statistics->staff = $this->staff [0] ['sid'];
  5523. $statistics->agPrice = 0;
  5524. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5525. $statistics->insert ();
  5526. } else {
  5527. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5528. $statistics->update ( array (
  5529. 'where' => 'sid=' . $stat ['sid']
  5530. ) );
  5531. }
  5532. return "/expenses";
  5533. }
  5534. function approval() {
  5535. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5536. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5537. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5538. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5539. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5540. if (empty ( $status ))
  5541. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5542. $vidList = array ();
  5543. $button = 0;
  5544. Doo::loadModel ( 'verify' );
  5545. $verify = new verify ();
  5546. Doo::loadModel ( 'receipt' );
  5547. $receipt = new receipt ();
  5548. Doo::loadModel ( 'staff' );
  5549. $staff = new staff ();
  5550. Doo::loadModel ( 'L_category' );
  5551. $Lcategory = new L_category ();
  5552. // user verify ID
  5553. $verifyDetail = $verify->find ( array (
  5554. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5555. 'asArray' => true
  5556. ) );
  5557. foreach ( $verifyDetail as $key => $value ) {
  5558. array_push ( $vidList, $value ['vid'] );
  5559. }
  5560. $vid = implode ( ",", $vidList );
  5561. if (empty ( $verifyDetail ))
  5562. $vid = 0;
  5563. /*
  5564. */
  5565. $dateCondition = " and Year(date) =" . $year;
  5566. if (! empty ( $month ))
  5567. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  5568. $categoryList = $Lcategory->find ( array (
  5569. 'asArray' => true
  5570. ) );
  5571. $staffList = $staff->find ( array (
  5572. 'where' => 'cid=' . $cid,
  5573. 'asArray' => true
  5574. ) );
  5575. $cateCondition = "";
  5576. $staffCondition = "";
  5577. $approvalCondition = "";
  5578. if (! empty ( $cid ))
  5579. $cateCondition = ' and cid=' . $cid;
  5580. if (! empty ( $sid )) {
  5581. $staffCondition = ' and staff=' . $sid;
  5582. $cateCondition = "";
  5583. }
  5584. // elseif($status==1){
  5585. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  5586. // }
  5587. if ($status == 2) {
  5588. // 查找角色审批人
  5589. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  5590. }
  5591. $ap = "";
  5592. if ($status == 4) {
  5593. $ap = 4;
  5594. $status = 2;
  5595. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  5596. }
  5597. if ($status == 5) {
  5598. $status = 4;
  5599. $ap = 5;
  5600. }
  5601. // echo $vid;
  5602. // get Receipt By verifyID status 2 .$approvalCondition
  5603. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  5604. $receiptList = $receipt->find ( array (
  5605. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  5606. 'desc' => 'rid',
  5607. 'asArray' => true
  5608. ) );
  5609. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  5610. $Locate = 0;
  5611. if ($ap == 4)
  5612. $status = 4;
  5613. elseif ($ap == 5)
  5614. $status = 5;
  5615. foreach ( $receiptList as $key => $value ) {
  5616. $receiptList [$key] ['Locate'] = $Locate;
  5617. $Locate ++;
  5618. $receiptList [$key] ['reviseDetail'] = array ();
  5619. if (! empty ( $value ['reviseDetail'] ))
  5620. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5621. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5622. $categoryDetil = $Lcategory->getOne ( array (
  5623. 'where' => 'cid=' . $value ['cid'],
  5624. 'asArray' => true
  5625. ) );
  5626. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5627. $verifyList = $verify->getOne ( array (
  5628. 'where' => 'vid=' . $value ['verify'],
  5629. 'asArray' => true
  5630. ) );
  5631. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5632. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5633. foreach ( $verifyList as $k => $v ) {
  5634. // init verifyStaff
  5635. $verifyList [$k] ['date'] = "";
  5636. $verifyList [$k] ['opinion'] = "";
  5637. $verifyList [$k] ['status'] = "";
  5638. if (empty ( $verifyStaff )) {
  5639. $verifyList [$k] ['date'] = "";
  5640. $verifyList [$k] ['opinion'] = "";
  5641. if ($v [0] == $this->staff [0] ['sid']) {
  5642. $verifyList [$k] ['status'] = 4;
  5643. $button = 4;
  5644. }
  5645. } else {
  5646. $flag = true;
  5647. foreach ( $verifyStaff as $m => $u ) {
  5648. if ($v [0] == $m) {
  5649. $verifyList [$k] ['date'] = $u ['date'];
  5650. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5651. $verifyList [$k] ['status'] = $u ['status'];
  5652. $flag = false;
  5653. break;
  5654. }
  5655. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  5656. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  5657. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  5658. }
  5659. if ($flag) { // 检测可编辑
  5660. if ($v [0] == $this->staff [0] ['sid']) {
  5661. $verifyList [$k] ['status'] = 4;
  5662. $button = 4;
  5663. }
  5664. }
  5665. }
  5666. }
  5667. $receiptList [$key] ['verifyList'] = $verifyList;
  5668. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5669. 'where' => 'sid=' . $value ['staff'],
  5670. 'asArray' => true
  5671. ) );
  5672. $receiptList [$key] ['button'] = $button;
  5673. }
  5674. // print_r($receiptList);die;
  5675. // $data['verifyDetail']=$verifyDetail;
  5676. $mothHtml = "";
  5677. for($i = 1; $i <= 12; $i ++) {
  5678. if ($month == $i)
  5679. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5680. else
  5681. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5682. }
  5683. $data ['mothHtml'] = $mothHtml;
  5684. $data ['receiptList'] = $receiptList;
  5685. $data ['receiptApprovalCount'] = count ( $receiptList );
  5686. $data ['status'] = $status;
  5687. $data ['year'] = $year;
  5688. $data ['categoryList'] = $categoryList;
  5689. $data ['staffList'] = $staffList;
  5690. $data ['cid'] = $cid;
  5691. $data ['sid'] = $sid;
  5692. $data ['ap'] = $ap;
  5693. $data ['memu'] = "receipt";
  5694. $data ['staff'] = $this->staff;
  5695. $data ['receiptMemu'] = 'approval';
  5696. $data ['verifyId'] = $this->verifyId;
  5697. $data ['executeId'] = $this->executeId;
  5698. $this->render ( "/admin/saea_reportList", $data );
  5699. }
  5700. function approvalDetails() {
  5701. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5702. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5703. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5704. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5705. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5706. Doo::loadModel ( 'verify' );
  5707. $verify = new verify ();
  5708. Doo::loadModel ( 'receipt' );
  5709. $receipt = new receipt ();
  5710. Doo::loadModel ( 'staff' );
  5711. $staff = new staff ();
  5712. Doo::loadModel ( 'L_category' );
  5713. $Lcategory = new L_category ();
  5714. Doo::loadModel ( 'enclosur' );
  5715. $enclosur = new enclosur ();
  5716. $vidList = array ();
  5717. $verifyDetail = $verify->find ( array (
  5718. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5719. 'asArray' => true
  5720. ) );
  5721. foreach ( $verifyDetail as $key => $value ) {
  5722. array_push ( $vidList, $value ['vid'] );
  5723. }
  5724. $vid = implode ( ",", $vidList );
  5725. if (empty ( $verifyDetail ))
  5726. $vid = 0;
  5727. $categoryList = $Lcategory->find ( array (
  5728. 'asArray' => true
  5729. ) );
  5730. $staffList = $staff->find ( array (
  5731. 'where' => 'cid=' . $cid,
  5732. 'asArray' => true
  5733. ) );
  5734. $ap = 0;
  5735. $receiptList = $receipt->find ( array (
  5736. 'where' => 'rid =' . $rid,
  5737. 'desc' => 'rid',
  5738. 'asArray' => true
  5739. ) );
  5740. $Locate = 0;
  5741. $roleId = 0;
  5742. $button = 0;
  5743. foreach ( $receiptList as $key => $value ) {
  5744. $receiptList [$key] ['Locate'] = $Locate;
  5745. $Locate ++;
  5746. $receiptList [$key] ['reviseDetail'] = array ();
  5747. if (! empty ( $value ['reviseDetail'] ))
  5748. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5749. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5750. $categoryDetil = $Lcategory->getOne ( array (
  5751. 'where' => 'cid=' . $value ['cid'],
  5752. 'asArray' => true
  5753. ) );
  5754. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5755. // 检测编辑状态
  5756. $verifyList = $verify->getOne ( array (
  5757. 'where' => 'vid=' . $value ['verify'],
  5758. 'asArray' => true
  5759. ) );
  5760. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5761. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5762. Doo::loadModel ( 'role' );
  5763. $role = new role ();
  5764. // print_r($verifyList);
  5765. $flag = true;
  5766. $roleKey = 0;
  5767. $endStaffArray = array ();
  5768. $roleArrayCopy = array ();
  5769. foreach ( $verifyList as $k => $v ) {
  5770. // init verifyStaff
  5771. if ($v [1] == 'ROLE') {
  5772. if (! empty ( $verifyStaff )) {
  5773. $endStaffArray = end ( $verifyStaff );
  5774. if ($v [0] == $endStaffArray ['nextStaff']) {
  5775. $roleId = $v [0];
  5776. }
  5777. }
  5778. $roleVerify = json_decode ( $v [3], true );
  5779. $roleKey = $k;
  5780. $roleArray = array ();
  5781. $rolename = $role->getOne ( array (
  5782. 'where' => 'rid=' . $v [0],
  5783. 'asArray' => true
  5784. ) );
  5785. foreach ( $roleVerify as $o => $p ) {
  5786. $staffID = explode ( '_', $p );
  5787. $staffInfo = $staff->getOne ( array (
  5788. 'where' => 'sid=' . $staffID [0],
  5789. 'asArray' => true
  5790. ) );
  5791. // print_r($staffID);
  5792. $exp = array (
  5793. 0 => $staffInfo ['sid'],
  5794. 1 => $staffID [1],
  5795. 2 => $staffInfo ['avatar'],
  5796. 'date' => '',
  5797. 'date' => '',
  5798. 'opinion' => '',
  5799. 'status' => '',
  5800. 'rolename' => $rolename ['name']
  5801. );
  5802. array_push ( $roleArray, $exp );
  5803. }
  5804. $roleArrayCopy [$v [0]] = $roleArray;
  5805. // $verifyList[$k]['roleArray']=$roleArray;
  5806. }
  5807. // print_r($roleArray);
  5808. $verifyList [$k] ['date'] = "";
  5809. $verifyList [$k] ['opinion'] = "";
  5810. $verifyList [$k] ['status'] = "";
  5811. if (empty ( $verifyStaff )) {
  5812. $verifyList [$k] ['date'] = "";
  5813. $verifyList [$k] ['opinion'] = "";
  5814. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5815. $verifyList [$k] ['status'] = 4;
  5816. $button = 4;
  5817. $flag = false;
  5818. }
  5819. } else {
  5820. foreach ( $verifyStaff as $m => $u ) {
  5821. if ($v [0] == $m) {
  5822. $verifyList [$k] ['date'] = $u ['date'];
  5823. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5824. $verifyList [$k] ['status'] = $u ['status'];
  5825. $flag = false;
  5826. break;
  5827. }
  5828. }
  5829. $endStaffArray = end ( $verifyStaff );
  5830. if (isset ( $endStaffArray ['ROLE'] )) {
  5831. } else {
  5832. $endKey = key ( $verifyStaff );
  5833. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5834. $button = 4;
  5835. $verifyList [$k] ['status'] = 4;
  5836. }
  5837. }
  5838. }
  5839. }
  5840. $rolename ['name'] = '';
  5841. if (! empty ( $roleId )) {
  5842. Doo::loadModel ( 'role' );
  5843. $role = new role ();
  5844. $rolename = $role->getOne ( array (
  5845. 'where' => 'rid=' . $roleId,
  5846. 'asArray' => true
  5847. ) );
  5848. }
  5849. if (! empty ( $verifyStaff ))
  5850. $endStaffArray = end ( $verifyStaff );
  5851. $KOP = false;
  5852. foreach ( $roleArrayCopy as $P => $A ) {
  5853. foreach ( $A as $MKI => $AVL ) {
  5854. if (! empty ( $verifyStaff )) {
  5855. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5856. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5857. $button = 4;
  5858. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5859. }
  5860. foreach ( $verifyStaff as $m => $u ) {
  5861. $AVLFK = $AVL [0] . '_R';
  5862. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5863. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5864. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5865. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5866. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5867. break;
  5868. }
  5869. }
  5870. } else {
  5871. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5872. $button = 4;
  5873. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5874. }
  5875. }
  5876. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5877. $KOP = true;
  5878. }
  5879. }
  5880. foreach ( $roleArrayCopy as $k => $v ) {
  5881. foreach ( $verifyList as $m => $n ) {
  5882. if ($n [0] == $k) {
  5883. array_splice ( $verifyList, $m, 1, $v );
  5884. }
  5885. }
  5886. }
  5887. $receiptList [$key] ['verifyList'] = $verifyList;
  5888. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5889. 'where' => 'sid=' . $value ['staff'],
  5890. 'asArray' => true
  5891. ) );
  5892. $receiptList [$key] ['button'] = $button;
  5893. }
  5894. $mothHtml = "";
  5895. for($i = 1; $i <= 12; $i ++) {
  5896. if ($month == $i)
  5897. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5898. else
  5899. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5900. }
  5901. // 获取审批日志
  5902. Doo::loadModel ( 'receiptLog' );
  5903. $receiptLog = new receiptLog ();
  5904. $rlList = array ();
  5905. $rlInfo = $receiptLog->getOne ( array (
  5906. 'where' => 'rid=' . $rid . ' and status=4',
  5907. 'asArray' => true
  5908. ) );
  5909. $tijdate = $receiptLog->getOne ( array (
  5910. 'where' => 'rid=' . $rid . ' and status=2',
  5911. 'asc' => 'rlid',
  5912. 'asArray' => true
  5913. ) );
  5914. if (! empty ( $rlInfo )) {
  5915. $rlList = $receiptLog->find ( array (
  5916. 'where' => 'rid=' . $rid,
  5917. 'asc' => 'rlid',
  5918. 'asArray' => true
  5919. ) );
  5920. }
  5921. $receiptList [0] ['rlList'] = $rlList;
  5922. $enclosurList = $enclosur->find ( array (
  5923. 'where' => 'rid=' . $rid,
  5924. 'asArray' => true
  5925. ) );
  5926. $enclosurHtml = '';
  5927. foreach ( $enclosurList as $value ) {
  5928. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5929. }
  5930. $data ['enclosurHtml'] = $enclosurHtml;
  5931. $data ['rolename'] = $rolename ['name'];
  5932. $data ['datetij'] = $tijdate ['date'];
  5933. $data ['mothHtml'] = $mothHtml;
  5934. $data ['receiptList'] = $receiptList;
  5935. $data ['receiptApprovalCount'] = count ( $receiptList );
  5936. $data ['year'] = $year;
  5937. $data ['categoryList'] = $categoryList;
  5938. $data ['staffList'] = $staffList;
  5939. $data ['cid'] = $cid;
  5940. $data ['sid'] = $sid;
  5941. $data ['status'] = 0;
  5942. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  5943. $ap = 4;
  5944. } else
  5945. $data ['status'] = $receiptList [0] ['status'];
  5946. if ($receiptList [0] ['status'] == 4) {
  5947. $data ['status'] = 5;
  5948. $ap = 0;
  5949. }
  5950. $data ['ap'] = $ap;
  5951. $data ['memu'] = "receipt";
  5952. $data ['staff'] = $this->staff;
  5953. $data ['receiptMemu'] = 'approval';
  5954. $data ['verifyId'] = $this->verifyId;
  5955. $data ['executeId'] = $this->executeId;
  5956. $this->render ( "/admin/saeaReportListReport", $data );
  5957. }
  5958. function approvalEdi() {
  5959. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5960. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5961. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5962. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5963. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5964. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5965. if (empty ( $status ))
  5966. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5967. $vidList = array ();
  5968. $button = 0;
  5969. Doo::loadModel ( 'verify' );
  5970. Doo::loadModel ( 'receipt' );
  5971. Doo::loadModel ( 'staff' );
  5972. $staff = new staff ();
  5973. $receipt = new receipt ();
  5974. $verify = new verify ();
  5975. Doo::loadModel ( 'L_category' );
  5976. $Lcategory = new L_category ();
  5977. Doo::loadModel ( 'enclosur' );
  5978. $enclosur = new enclosur ();
  5979. // user verify ID
  5980. $verifyDetail = $verify->find ( array (
  5981. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5982. 'asArray' => true
  5983. ) );
  5984. foreach ( $verifyDetail as $key => $value ) {
  5985. array_push ( $vidList, $value ['vid'] );
  5986. }
  5987. $vid = implode ( ",", $vidList );
  5988. if (empty ( $verifyDetail ))
  5989. $vid = 0;
  5990. $categoryList = $Lcategory->find ( array (
  5991. 'asArray' => true
  5992. ) );
  5993. $staffList = $staff->find ( array (
  5994. 'where' => 'cid=' . $cid,
  5995. 'asArray' => true
  5996. ) );
  5997. $ap = "";
  5998. if ($status == 4) {
  5999. $ap = 4;
  6000. $status = 2;
  6001. }
  6002. // get Receipt By verifyID status 2
  6003. $receiptList = $receipt->find ( array (
  6004. 'where' => 'rid =' . $rid,
  6005. 'desc' => 'rid',
  6006. 'asArray' => true
  6007. ) );
  6008. $Locate = 0;
  6009. $roleId = 0;
  6010. if ($ap == 4)
  6011. $status = 4;
  6012. foreach ( $receiptList as $key => $value ) {
  6013. $receiptList [$key] ['Locate'] = $Locate;
  6014. $Locate ++;
  6015. $receiptList [$key] ['reviseDetail'] = array ();
  6016. if (! empty ( $value ['reviseDetail'] ))
  6017. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6018. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6019. $categoryDetil = $Lcategory->getOne ( array (
  6020. 'where' => 'cid=' . $value ['cid'],
  6021. 'asArray' => true
  6022. ) );
  6023. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6024. // 检测编辑状态
  6025. $verifyList = $verify->getOne ( array (
  6026. 'where' => 'vid=' . $value ['verify'],
  6027. 'asArray' => true
  6028. ) );
  6029. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6030. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6031. // print_r($verifyList);
  6032. //
  6033. // if (empty($verifyStaff)){
  6034. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6035. // $verifyList[0]['status']=4;$button=4;
  6036. // }
  6037. //
  6038. // }else{
  6039. //
  6040. // }
  6041. // die;
  6042. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  6043. // echo array_search("green",$a);
  6044. //
  6045. Doo::loadModel ( 'role' );
  6046. $role = new role ();
  6047. // print_r($verifyList);
  6048. $flag = true;
  6049. $roleKey = 0;
  6050. $endStaffArray = array ();
  6051. $roleArrayCopy = array ();
  6052. foreach ( $verifyList as $k => $v ) {
  6053. // init verifyStaff
  6054. if ($v [1] == 'ROLE') {
  6055. if (! empty ( $verifyStaff )) {
  6056. $endStaffArray = end ( $verifyStaff );
  6057. if ($v [0] == $endStaffArray ['nextStaff']) {
  6058. $roleId = $v [0];
  6059. }
  6060. }
  6061. $roleVerify = json_decode ( $v [3], true );
  6062. $roleKey = $k;
  6063. $roleArray = array ();
  6064. $rolename = $role->getOne ( array (
  6065. 'where' => 'rid=' . $v [0],
  6066. 'asArray' => true
  6067. ) );
  6068. foreach ( $roleVerify as $o => $p ) {
  6069. $staffID = explode ( '_', $p );
  6070. $staffInfo = $staff->getOne ( array (
  6071. 'where' => 'sid=' . $staffID [0],
  6072. 'asArray' => true
  6073. ) );
  6074. // print_r($staffID);
  6075. $exp = array (
  6076. 0 => $staffInfo ['sid'],
  6077. 1 => $staffID [1],
  6078. 2 => $staffInfo ['avatar'],
  6079. 'date' => '',
  6080. 'date' => '',
  6081. 'opinion' => '',
  6082. 'status' => '',
  6083. 'rolename' => $rolename ['name']
  6084. );
  6085. array_push ( $roleArray, $exp );
  6086. }
  6087. $roleArrayCopy [$v [0]] = $roleArray;
  6088. // $verifyList[$k]['roleArray']=$roleArray;
  6089. }
  6090. // print_r($roleArray);
  6091. $verifyList [$k] ['date'] = "";
  6092. $verifyList [$k] ['opinion'] = "";
  6093. $verifyList [$k] ['status'] = "";
  6094. if (empty ( $verifyStaff )) {
  6095. $verifyList [$k] ['date'] = "";
  6096. $verifyList [$k] ['opinion'] = "";
  6097. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6098. $verifyList [$k] ['status'] = 4;
  6099. $button = 4;
  6100. $flag = false;
  6101. }
  6102. } else {
  6103. foreach ( $verifyStaff as $m => $u ) {
  6104. if ($v [0] == $m) {
  6105. $verifyList [$k] ['date'] = $u ['date'];
  6106. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6107. $verifyList [$k] ['status'] = $u ['status'];
  6108. $flag = false;
  6109. break;
  6110. }
  6111. }
  6112. $endStaffArray = end ( $verifyStaff );
  6113. if (isset ( $endStaffArray ['ROLE'] )) {
  6114. } else {
  6115. $endKey = key ( $verifyStaff );
  6116. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6117. $button = 4;
  6118. $verifyList [$k] ['status'] = 4;
  6119. }
  6120. }
  6121. // print_r($endStaffArray);die;
  6122. // if (empty($verifyStaff)){
  6123. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6124. // $verifyList[$k]['status']=4;$button=4;
  6125. // }
  6126. //
  6127. // }else{
  6128. //
  6129. // }
  6130. // if($flag){//检测可编辑
  6131. // if($v[0]==$this->staff[0]['sid']){
  6132. // $verifyList[$k]['status']=4;$button=4;
  6133. // }
  6134. // }
  6135. }
  6136. }
  6137. $rolename ['name'] = '';
  6138. if (! empty ( $roleId )) {
  6139. Doo::loadModel ( 'role' );
  6140. $role = new role ();
  6141. $rolename = $role->getOne ( array (
  6142. 'where' => 'rid=' . $roleId,
  6143. 'asArray' => true
  6144. ) );
  6145. }
  6146. if (! empty ( $verifyStaff ))
  6147. $endStaffArray = end ( $verifyStaff );
  6148. $KOP = false;
  6149. foreach ( $roleArrayCopy as $P => $A ) {
  6150. foreach ( $A as $MKI => $AVL ) {
  6151. if (! empty ( $verifyStaff )) {
  6152. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6153. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6154. $button = 4;
  6155. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6156. }
  6157. foreach ( $verifyStaff as $m => $u ) {
  6158. $AVLFK = $AVL [0] . '_R';
  6159. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6160. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6161. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6162. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6163. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6164. break;
  6165. }
  6166. }
  6167. } else {
  6168. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6169. $button = 4;
  6170. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6171. }
  6172. }
  6173. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6174. $KOP = true;
  6175. }
  6176. }
  6177. // print_r($roleArrayCopy);
  6178. // echo $roleKey;
  6179. foreach ( $roleArrayCopy as $k => $v ) {
  6180. foreach ( $verifyList as $m => $n ) {
  6181. if ($n [0] == $k) {
  6182. array_splice ( $verifyList, $m, 1, $v );
  6183. }
  6184. }
  6185. }
  6186. // if ($KOP)
  6187. // array_splice($verifyList,$roleKey,1,$roleArray);
  6188. // print_r($verifyList);
  6189. $receiptList [$key] ['verifyList'] = $verifyList;
  6190. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6191. 'where' => 'sid=' . $value ['staff'],
  6192. 'asArray' => true
  6193. ) );
  6194. $receiptList [$key] ['button'] = $button;
  6195. }
  6196. // $data['verifyDetail']=$verifyDetail;
  6197. $mothHtml = "";
  6198. for($i = 1; $i <= 12; $i ++) {
  6199. if ($month == $i)
  6200. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6201. else
  6202. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6203. }
  6204. // 获取审批日志
  6205. Doo::loadModel ( 'receiptLog' );
  6206. $receiptLog = new receiptLog ();
  6207. $rlList = array ();
  6208. $rlInfo = $receiptLog->getOne ( array (
  6209. 'where' => 'rid=' . $rid . ' and status=4',
  6210. 'asArray' => true
  6211. ) );
  6212. $tijdate = $receiptLog->getOne ( array (
  6213. 'where' => 'rid=' . $rid . ' and status=2',
  6214. 'asc' => 'rlid',
  6215. 'asArray' => true
  6216. ) );
  6217. if (! empty ( $rlInfo )) {
  6218. $rlList = $receiptLog->find ( array (
  6219. 'where' => 'rid=' . $rid,
  6220. 'asc' => 'rlid',
  6221. 'asArray' => true
  6222. ) );
  6223. }
  6224. $receiptList [0] ['rlList'] = $rlList;
  6225. $enclosurList = $enclosur->find ( array (
  6226. 'where' => 'rid=' . $rid,
  6227. 'asArray' => true
  6228. ) );
  6229. $enclosurHtml = '';
  6230. foreach ( $enclosurList as $value ) {
  6231. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6232. }
  6233. $data ['enclosurHtml'] = $enclosurHtml;
  6234. $data ['rolename'] = $rolename ['name'];
  6235. $data ['datetij'] = $tijdate ['date'];
  6236. $data ['mothHtml'] = $mothHtml;
  6237. $data ['receiptList'] = $receiptList;
  6238. $data ['receiptApprovalCount'] = count ( $receiptList );
  6239. $data ['status'] = $status;
  6240. $data ['year'] = $year;
  6241. $data ['categoryList'] = $categoryList;
  6242. $data ['staffList'] = $staffList;
  6243. $data ['cid'] = $cid;
  6244. $data ['sid'] = $sid;
  6245. $data ['ap'] = $ap;
  6246. $data ['memu'] = "receipt";
  6247. $data ['staff'] = $this->staff;
  6248. $data ['receiptMemu'] = 'approval';
  6249. $data ['verifyId'] = $this->verifyId;
  6250. $data ['executeId'] = $this->executeId;
  6251. $this->render ( "/admin/saeaReportListReport", $data );
  6252. }
  6253. function remittanceHky() {
  6254. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6255. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  6256. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6257. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  6258. $page_size = 15;
  6259. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  6260. Doo::loadModel ( 'receipt' );
  6261. $receipt = new receipt ();
  6262. Doo::loadModel ( 'staff' );
  6263. $staff = new staff ();
  6264. $dateCondition = " and Year(executeDate) =" . $year;
  6265. if ($moth != 'MONTH')
  6266. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  6267. if ($day != 'DAY' && $moth != 'MONTH')
  6268. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  6269. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  6270. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  6271. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  6272. $limit = $pageinfo ['lower'] . ',' . $page_size;
  6273. $dayList = $receipt->find ( array (
  6274. 'select' => 'executeDate,sum(amount) as amount',
  6275. 'where' => $sql,
  6276. 'desc' => 'executeDate',
  6277. 'groupby' => 'executeDate',
  6278. 'limit' => $limit,
  6279. 'asArray' => true
  6280. ) );
  6281. // print_r($dayList);
  6282. foreach ( $dayList as $key => $value ) {
  6283. $remitString = "";
  6284. $receiptList = $receipt->find ( array (
  6285. 'select' => 'rid,executeDate,amount,staff,cid',
  6286. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  6287. 'desc' => 'executeDate',
  6288. 'asArray' => true
  6289. ) );
  6290. foreach ( $receiptList as $k => $v ) {
  6291. $sinfo = $staff->getOne ( array (
  6292. 'select' => 'username,category',
  6293. 'where' => ' sid=' . $v ['staff'],
  6294. 'asArray' => true
  6295. ) );
  6296. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  6297. }
  6298. $dayList [$key] ['staff'] = $remitString;
  6299. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  6300. }
  6301. // print_r($dayList);
  6302. $mothHtml = "";
  6303. for($i = 1; $i <= 12; $i ++) {
  6304. if ($moth == $i)
  6305. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6306. else
  6307. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6308. }
  6309. $dayHtml = "";
  6310. if ($day != "DAY" || $moth != "MONTH") {
  6311. for($i = 1; $i <= 31; $i ++) {
  6312. if ($day == $i)
  6313. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6314. else
  6315. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6316. }
  6317. }
  6318. $data ['page'] = $pageinfo;
  6319. $data ['year'] = $year;
  6320. $data ['moth'] = $moth;
  6321. $data ['day'] = $day;
  6322. $data ['get'] = $get;
  6323. $data ['dayHtml'] = $dayHtml;
  6324. $data ['mothHtml'] = $mothHtml;
  6325. $data ['receiptList'] = $dayList;
  6326. $data ['memu'] = "receipt";
  6327. $data ['staff'] = $this->staff;
  6328. $data ['receiptMemu'] = 'remittanceHky';
  6329. $data ['verifyId'] = $this->verifyId;
  6330. $data ['executeId'] = $this->executeId;
  6331. $this->render ( "/admin/remittanceHky", $data );
  6332. }
  6333. function remittancep() {
  6334. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  6335. Doo::loadModel ( 'receipt' );
  6336. $receipt = new receipt ();
  6337. Doo::loadModel ( 'staff' );
  6338. $staff = new staff ();
  6339. Doo::loadClass ( 'XDeode' );
  6340. $XDeode = new XDeode ( 5 );
  6341. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  6342. $rplist = $receipt->find ( array (
  6343. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6344. 'asArray' => true
  6345. ) );
  6346. $dayList = $receipt->find ( array (
  6347. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6348. 'desc' => 'executeDate',
  6349. 'groupby' => 'staff',
  6350. 'asArray' => true
  6351. ) );
  6352. $html = '';
  6353. foreach ( $dayList as $key => $value ) {
  6354. $sinfo = $staff->getOne ( array (
  6355. 'select' => 'username,category',
  6356. 'where' => ' sid=' . $value ['staff'],
  6357. 'asArray' => true
  6358. ) );
  6359. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  6360. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  6361. $au = 0;
  6362. foreach ( $rplist as $k => $v ) {
  6363. if ($value ['staff'] == $v ['staff']) {
  6364. $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>';
  6365. $au += $v ['amount'];
  6366. }
  6367. }
  6368. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  6369. }
  6370. $data ['html'] = $html;
  6371. $data ['memu'] = "receipt";
  6372. $data ['staff'] = $this->staff;
  6373. $data ['receiptMemu'] = 'remittanceHky';
  6374. $data ['verifyId'] = $this->verifyId;
  6375. $data ['executeId'] = $this->executeId;
  6376. $this->render ( "/admin/remittancep", $data );
  6377. }
  6378. function ajaxGetReceiptDetails() {
  6379. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  6380. Doo::loadClass ( 'XDeode' );
  6381. $XDeode = new XDeode ( 5 );
  6382. $rid = $XDeode->decode ( $rid );
  6383. if (empty ( $rid )) {
  6384. echo json_encode ( array (
  6385. 'status' => 2,
  6386. 'msg' => 'illegal request'
  6387. ) );
  6388. die ();
  6389. }
  6390. Doo::loadModel ( 'receipt' );
  6391. $receipt = new receipt ();
  6392. Doo::loadModel ( 'staff' );
  6393. $staff = new staff ();
  6394. $rinfo = $receipt->getOne ( array (
  6395. 'where' => 'rid= ' . $rid,
  6396. 'asArray' => true
  6397. ) );
  6398. $sinfo = $staff->getOne ( array (
  6399. 'select' => 'username,category',
  6400. 'where' => ' sid=' . $rinfo ['staff'],
  6401. 'asArray' => true
  6402. ) );
  6403. $rinfo ['reviseDetail'] = array ();
  6404. if (! empty ( $rinfo ['reviseDetail'] ))
  6405. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  6406. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  6407. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  6408. $rinfo ['category'] = $sinfo ['category'];
  6409. $verifyStaff = array ();
  6410. if (! empty ( $rinfo ['verifyStaff'] ))
  6411. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  6412. $relust = $rinfo ['sum'] - $rinfo ['loanSum'];
  6413. $rinfo ['relust'] = $relust;
  6414. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  6415. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  6416. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  6417. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  6418. // 费用执行人相关数据
  6419. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6420. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6421. foreach ( $executeCopy as $k => $v ) {
  6422. $executeCopy [$k] ['date'] = '';
  6423. $executeCopy [$k] ['opinion'] = '';
  6424. $executeCopy [$k] ['status'] = '';
  6425. if (! empty ( $executeStaff ))
  6426. foreach ( $executeStaff as $m => $u ) {
  6427. if ($v [0] == $m) {
  6428. $executeCopy [$k] ['date'] = $u ['date'];
  6429. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  6430. $executeCopy [$k] ['status'] = $u ['status'];
  6431. break;
  6432. }
  6433. }
  6434. }
  6435. $rinfo ['executeCopy'] = $executeCopy;
  6436. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  6437. if ($rinfo ['Rtype'] == 1) { // 借款费用
  6438. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6439. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  6440. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  6441. $html .= '<tr><th>' . $value ['name'] . '</th>
  6442. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6443. }
  6444. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6445. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6446. <tr><th class="taC" colspan="2">费用说明</th>
  6447. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6448. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6449. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  6450. </tbody></table>';
  6451. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  6452. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6453. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6454. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6455. $html .= '<tr><th>' . $value ['name'] . '</th>
  6456. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6457. }
  6458. $html .= '<tr><th class="taR">合计</th>
  6459. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6460. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6461. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6462. $html .= '<tr><th>' . $value ['name'] . '</th>
  6463. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6464. }
  6465. $html .= '<tr><th class="taR">合计</th>
  6466. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6467. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6468. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6469. $html .= '<tr><th>' . $value ['name'] . '</th>
  6470. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6471. }
  6472. $html .= '<tr><th class="taR">合计</th>
  6473. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6474. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6475. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6476. $html .= '<tr><th>' . $value ['name'] . '</th>
  6477. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6478. }
  6479. $html .= '<tr><th class="taR">合计</th>
  6480. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6481. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6482. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6483. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6484. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6485. }
  6486. $html .= '<tr><th class="taR">合计</th>
  6487. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6488. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6489. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6490. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6491. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6492. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6493. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6494. <tr';
  6495. if ($rinfo ['relust'] >= 0) {
  6496. $html .= 'class="success"';
  6497. } else {
  6498. $html .= 'class="error"';
  6499. }
  6500. $html .= '><td class="taR"><b>借款结余</b></td>
  6501. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  6502. </tbody></table>
  6503. ';
  6504. }
  6505. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  6506. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6507. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  6508. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6509. $html .= '<tr><th>' . $value ['name'] . '</th>
  6510. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6511. }
  6512. $html .= '<tr><th class="taR">合计</th>
  6513. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6514. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6515. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6516. <tr><th class="taC" colspan="2">费用说明</th>
  6517. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6518. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6519. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6520. </tbody></table>';
  6521. } else {
  6522. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6523. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6524. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6525. $html .= '<tr><th>' . $value ['name'] . '</th>
  6526. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6527. }
  6528. $html .= '<tr><th class="taR">合计</th>
  6529. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6530. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6531. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6532. $html .= '<tr><th>' . $value ['name'] . '</th>
  6533. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6534. }
  6535. $html .= '<tr><th class="taR">合计</th>
  6536. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6537. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6538. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6539. $html .= '<tr><th>' . $value ['name'] . '</th>
  6540. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6541. }
  6542. $html .= '<tr><th class="taR">合计</th>
  6543. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6544. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6545. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6546. $html .= '<tr><th>' . $value ['name'] . '</th>
  6547. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6548. }
  6549. $html .= '<tr><th class="taR">合计</th>
  6550. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6551. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6552. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6553. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6554. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6555. }
  6556. $html .= '<tr><th class="taR">合计</th>
  6557. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6558. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6559. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6560. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6561. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6562. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6563. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  6564. $html .= '</tbody></table>';
  6565. /*
  6566. * <table class="table table-bordered table-condensed table-hover"> <tbody> <tr><th colspan="2" class="taC">日常相关费用</th></tr> <!-- loop receiptList' value.accountItem.日常相关费用 --> <tr><th>{{receiptList' value' value.name}}</th><td width="140" class="taR">¥{{receiptList' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptList' value.accountItem.cSum.agencySum}}</td></tr>
  6567. * <tr><th colspan="2" class="taC">差旅相关费用</th></tr> <!-- loop receiptDetail' value.accountItem.差旅相关费用 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.travelSum}}</td></tr>
  6568. * <tr><th colspan="2" class="taC">培训班费用</th></tr> <!-- loop receiptDetail' value.accountItem.培训班费用 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.trainSum}}</td></tr>
  6569. * <tr><th colspan="2" class="taC">其他</th></tr> <!-- loop receiptDetail' value.accountItem.其他 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.otherSum}}</td></tr>
  6570. * <tr><th colspan="2" class="taC">报销金额调整</th></tr> <!-- loop receiptList' value.reviseDetail --> <tr><th><span class="interval">|</span>{{receiptList' value' value.name}}:{{receiptList' value' value.description}}</th><td class="taR">¥{{receiptList' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colOrange taR">¥{{receiptList' value.revisePrice}}</td></tr>
  6571. * <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr> <tr><th style="text-align:center" colspan="2">{{receiptDetail' value.category}}</th></tr> <tr><th class="taC" colspan="2">报销说明</th></tr> <tr><td colspan="2">{{receiptDetail' value.explanation}}</td></tr> <tr class="warning"><td class="taR"><b>({{receiptDetail' value.receiptOrder}})本次报销费用合计</b></td> <td class="colGreed taR"><b style="font-size:24px">¥{{receiptDetail' value.sum}}</b><br>{{receiptDetail' value.sumCN}}</td></tr>
  6572. * </tbody> </table>
  6573. */
  6574. }
  6575. // print_r($verifyStaff);die;
  6576. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  6577. foreach ( $verifyStaff as $key => $value ) {
  6578. $key = trim ( strtr ( $key, '_R', ' ' ) );
  6579. $sinfo = $staff->getOne ( array (
  6580. 'select' => 'username',
  6581. 'where' => ' sid=' . $key,
  6582. 'asArray' => true
  6583. ) );
  6584. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6585. }
  6586. $html .= '</tbody></table>';
  6587. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  6588. foreach ( $rinfo ['executeCopy'] as $value ) {
  6589. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6590. }
  6591. $html .= '</tbody></table>';
  6592. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  6593. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  6594. </tr></table>';
  6595. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  6596. echo json_encode ( array (
  6597. 'status' => 1,
  6598. 'html' => $html
  6599. ) );
  6600. die ();
  6601. }
  6602. function remittance() {
  6603. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6604. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6605. Doo::loadModel ( 'receipt' );
  6606. $receipt = new receipt ();
  6607. Doo::loadModel ( 'staff' );
  6608. $staff = new staff ();
  6609. $dateCondition = " and Year(pastDate) =" . $year;
  6610. if (! empty ( $month ))
  6611. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  6612. // get Receipt By verifyID status 1
  6613. $receiptList = $receipt->find ( array (
  6614. 'select' => 'sum(sum) as sum,staff,pastDate',
  6615. 'where' => ' status=1' . $dateCondition,
  6616. 'desc' => 'pastDate',
  6617. 'groupby' => 'staff,pastDate',
  6618. 'asArray' => true
  6619. ) );
  6620. $dateList = $receipt->find ( array (
  6621. 'select' => 'pastDate,verifyStaff',
  6622. 'where' => ' status=1' . $dateCondition,
  6623. 'desc' => 'pastDate',
  6624. 'groupby' => 'pastDate',
  6625. 'asArray' => true
  6626. ) );
  6627. $dataList = array ();
  6628. foreach ( $dateList as $d => $a ) {
  6629. $dataList [$a ['pastDate']] = array ();
  6630. $daySum = 0;
  6631. foreach ( $receiptList as $key => $value ) {
  6632. if ($a ['pastDate'] == $value ['pastDate']) {
  6633. $oderList = $receipt->find ( array (
  6634. 'select' => 'receiptOrder',
  6635. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  6636. 'asArray' => true
  6637. ) );
  6638. $list = array ();
  6639. $html = "";
  6640. foreach ( $oderList as $v ) {
  6641. array_push ( $list, $v ['receiptOrder'] );
  6642. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  6643. }
  6644. $receiptList [$key] ['receiptOrder'] = $html;
  6645. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  6646. $sinfo = $staff->getOne ( array (
  6647. 'select' => 'username ',
  6648. 'where' => ' sid=' . $value ['staff'],
  6649. 'asArray' => true
  6650. ) );
  6651. $receiptList [$key] ['username'] = $sinfo ['username'];
  6652. $daySum += $value ['sum'];
  6653. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  6654. }
  6655. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  6656. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  6657. }
  6658. }
  6659. // print_r($dataList);
  6660. $data ['dataList'] = $dataList;
  6661. $mothHtml = "";
  6662. for($i = 1; $i <= 12; $i ++) {
  6663. if ($month == $i)
  6664. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6665. else
  6666. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6667. }
  6668. $data ['year'] = $year;
  6669. $data ['mothHtml'] = $mothHtml;
  6670. $data ['memu'] = "receipt";
  6671. $data ['staff'] = $this->staff;
  6672. $data ['receiptMemu'] = 'approval';
  6673. $data ['verifyId'] = $this->verifyId;
  6674. $data ['executeId'] = $this->executeId;
  6675. $this->render ( "/admin/saeaReportListPay", $data );
  6676. }
  6677. function revocationAdjustment() {
  6678. $sid = isset ( $this->params ['sid'] ) && is_numeric ( $this->params ['sid'] ) ? $this->params ['sid'] : 0;
  6679. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  6680. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6681. // echo $price;die;
  6682. if ((! empty ( $sid )) && ($price != - 99999) && (! empty ( $rid ))) {
  6683. Doo::loadModel ( 'receipt' );
  6684. $receipt = new receipt ();
  6685. $receiptDetail = $receipt->getOne ( array (
  6686. 'where' => 'rid=' . $rid,
  6687. 'asArray' => true
  6688. ) );
  6689. if (empty ( $receiptDetail ['reviseDetail'] ))
  6690. return "/approval";
  6691. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  6692. $RD = array ();
  6693. foreach ( $reviseDetail as $key => $value ) {
  6694. if ($value ['price'] == $price && $value ['sid'] == $sid)
  6695. continue;
  6696. array_push ( $RD, $value );
  6697. }
  6698. $reviseDetailString = json_encode ( $RD );
  6699. $receipt->reviseDetail = $reviseDetailString;
  6700. $receipt->sum = $receiptDetail ['sum'] - $price;
  6701. $receipt->revisePrice = $receiptDetail ['revisePrice'] - $price;
  6702. $receipt->update ( array (
  6703. 'where' => 'rid=' . $rid
  6704. ) );
  6705. }
  6706. // approvalEdi/37
  6707. return "/approvalEdi/" . $rid;
  6708. }
  6709. function updateApprovalReceipt() {
  6710. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6711. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  6712. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6713. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  6714. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  6715. if (! empty ( $rid )) {
  6716. Doo::loadModel ( "verify" );
  6717. $verify = new verify ();
  6718. Doo::loadModel ( "receiptDetail" );
  6719. $receiptDetailObj = new receiptDetail ();
  6720. Doo::loadModel ( "itemStatistics" );
  6721. Doo::loadModel ( "statistics" );
  6722. $statistics = new statistics ();
  6723. $itemStatistics = new itemStatistics ();
  6724. Doo::loadModel ( "receipt" );
  6725. $receipt = new receipt ();
  6726. $receiptDetail = $receipt->getOne ( array (
  6727. 'where' => 'rid=' . $rid . ' and status=2 ',
  6728. 'asArray' => true
  6729. ) );
  6730. if (empty ( $receiptDetail ))
  6731. return "/approval";
  6732. $verifyDetail = $verify->getOne ( array (
  6733. 'where' => ' vid =' . $receiptDetail ['verify'],
  6734. 'asArray' => true
  6735. ) );
  6736. $verifyString = $verifyDetail ['staff'];
  6737. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  6738. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  6739. if (empty ( $opinion )) {
  6740. if ($status == 3)
  6741. $opinion = "终止";
  6742. else
  6743. $opinion = "同意支付";
  6744. }
  6745. $nowStaff = 0;
  6746. $nowStaffList = array ();
  6747. if (empty ( $verifyStaff )) {
  6748. // 还需加入是否已经进入角色审批
  6749. if ($verifyDetail [0] [1] == 'ROLE') {
  6750. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  6751. foreach ( $vStaffString as $key => $value ) {
  6752. $staffK = explode ( "_", $value );
  6753. if ($staffK [0] != $this->staff [0] ['sid'])
  6754. array_push ( $nowStaffList, $staffK [0] );
  6755. }
  6756. // print_r($verifyDetail);
  6757. // die;
  6758. if (! empty ( $nowStaffList )) {
  6759. $nowStaff = implode ( ',', $nowStaffList );
  6760. $verifyStaff = array (
  6761. $this->staff [0] ['sid'] . "_R" => array (
  6762. 'date' => date ( 'Y-m-d' ),
  6763. 'opinion' => $opinion,
  6764. 'status' => $status,
  6765. 'nextStaff' => $verifyDetail [0] [0],
  6766. 'ROLE' => 1
  6767. )
  6768. );
  6769. } else {
  6770. $nowStaff = $verifyDetail [1] [0];
  6771. $verifyStaff = array (
  6772. $this->staff [0] ['sid'] . "_R" => array (
  6773. 'date' => date ( 'Y-m-d' ),
  6774. 'opinion' => $opinion,
  6775. 'status' => $status,
  6776. 'nextStaff' => $verifyDetail [1] [0]
  6777. )
  6778. );
  6779. }
  6780. } else {
  6781. if ($verifyDetail [1] [1] == 'ROLE') {
  6782. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  6783. // echo "dd";
  6784. foreach ( $vStaffString as $key => $value ) {
  6785. $staffK = explode ( "_", $value );
  6786. array_push ( $nowStaffList, $staffK [0] );
  6787. }
  6788. $nowStaff = implode ( ',', $nowStaffList );
  6789. $verifyStaff = array (
  6790. $this->staff [0] ['sid'] => array (
  6791. 'date' => date ( 'Y-m-d' ),
  6792. 'opinion' => $opinion,
  6793. 'status' => $status,
  6794. 'nextStaff' => $verifyDetail [1] [0],
  6795. 'ROLE' => 1
  6796. )
  6797. );
  6798. } else {
  6799. $nowStaff = $verifyDetail [1] [0];
  6800. $verifyStaff = array (
  6801. $this->staff [0] ['sid'] => array (
  6802. 'date' => date ( 'Y-m-d' ),
  6803. 'opinion' => $opinion,
  6804. 'status' => $status,
  6805. 'nextStaff' => $verifyDetail [1] [0]
  6806. )
  6807. );
  6808. }
  6809. }
  6810. if ($status == 3)
  6811. $verifyStaff = array (
  6812. 'final' => $status,
  6813. $this->staff [0] ['sid'] => array (
  6814. 'date' => date ( 'Y-m-d' ),
  6815. 'opinion' => $opinion,
  6816. 'status' => $status
  6817. )
  6818. );
  6819. $vStaffString = json_encode ( $verifyStaff );
  6820. $receipt->nowStaff = $nowStaff;
  6821. $receipt->verifyStaff = $vStaffString;
  6822. } else {
  6823. $VS = end ( $verifyStaff );
  6824. // 非角色审批
  6825. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  6826. $nextStaff = 0;
  6827. $roleSTF = false;
  6828. foreach ( $verifyDetail as $key => $value ) {
  6829. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  6830. if (isset ( $verifyDetail [$key + 1] )) {
  6831. $nextStaff = $verifyDetail [$key + 1] [0];
  6832. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  6833. $roleSTF = true;
  6834. }
  6835. break;
  6836. }
  6837. }
  6838. if (! $roleSTF) {
  6839. $nowStaff = $nextStaff;
  6840. $verifyStaff [$this->staff [0] ['sid']] = array (
  6841. 'date' => date ( 'Y-m-d' ),
  6842. 'opinion' => $opinion,
  6843. 'status' => $status,
  6844. 'nextStaff' => $nextStaff
  6845. );
  6846. } else {
  6847. // 获取角色下的所有用户ID
  6848. $nowStaffList = array ();
  6849. foreach ( $verifyDetail as $vfk ) {
  6850. if ($vfk [1] == 'ROLE') {
  6851. $vStaffString = json_decode ( $vfk [3] );
  6852. foreach ( $vStaffString as $key => $value ) {
  6853. $staffK = explode ( "_", $value );
  6854. array_push ( $nowStaffList, $staffK [0] );
  6855. }
  6856. }
  6857. }
  6858. $nowStaff = implode ( ',', $nowStaffList );
  6859. $verifyStaff [$this->staff [0] ['sid']] = array (
  6860. 'date' => date ( 'Y-m-d' ),
  6861. 'opinion' => $opinion,
  6862. 'status' => $status,
  6863. 'nextStaff' => $nextStaff,
  6864. 'ROLE' => 0
  6865. );
  6866. }
  6867. if ($status == 3) {
  6868. $verifyStaff ['final'] = $status;
  6869. $verifyStaff [$this->staff [0] ['sid']] = array (
  6870. 'date' => date ( 'Y-m-d' ),
  6871. 'opinion' => $opinion,
  6872. 'status' => $status
  6873. );
  6874. }
  6875. $vStaffString = json_encode ( $verifyStaff );
  6876. $receipt->nowStaff = $nowStaff;
  6877. $receipt->verifyStaff = $vStaffString;
  6878. }
  6879. // 角色审批
  6880. if (isset ( $VS ['ROLE'] )) {
  6881. // 找出角色人 当前审批角色组
  6882. $verifyJSStaff = array ();
  6883. $nowStaffList2 = array ();
  6884. foreach ( $verifyDetail as $key => $value ) {
  6885. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  6886. $verifyJSStaff = json_decode ( $value [3] );
  6887. foreach ( $verifyJSStaff as $m ) {
  6888. $staffK = explode ( "_", $m );
  6889. array_push ( $nowStaffList2, $staffK [0] );
  6890. }
  6891. // print_r($nowStaffList2);
  6892. }
  6893. }
  6894. $RoleVerifyStaff = array ();
  6895. foreach ( $verifyStaff as $key => $value ) {
  6896. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  6897. foreach ( $nowStaffList2 as $m ) {
  6898. if ($key == $m . "_R")
  6899. $RoleVerifyStaff [$key] = $value;
  6900. }
  6901. }
  6902. }
  6903. // print_r($verifyStaff);
  6904. // print_r($nowStaffList2);
  6905. // print_r($RoleVerifyStaff);
  6906. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  6907. // print_r($verifyJSStaff);
  6908. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  6909. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  6910. // 下一个审批人ID
  6911. $nextStaff = 0;
  6912. $falg = false;
  6913. foreach ( $verifyDetail as $key => $value ) {
  6914. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  6915. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  6916. $falg = true;
  6917. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  6918. $nowStaffList = array ();
  6919. foreach ( $vStaffString as $v ) {
  6920. $staffK = explode ( "_", $v );
  6921. array_push ( $nowStaffList, $staffK [0] );
  6922. }
  6923. $nowStaff = implode ( ',', $nowStaffList );
  6924. $nextStaff = $verifyDetail [$key + 1] [0];
  6925. } elseif (isset ( $verifyDetail [$key + 1] )) {
  6926. $nextStaff = $verifyDetail [$key + 1] [0];
  6927. $nowStaff = $nextStaff;
  6928. } else
  6929. $nowStaff = '';
  6930. break;
  6931. }
  6932. }
  6933. if ($falg)
  6934. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6935. 'date' => date ( 'Y-m-d' ),
  6936. 'opinion' => $opinion,
  6937. 'status' => $status,
  6938. 'nextStaff' => $nextStaff,
  6939. 'ROLE' => 1
  6940. );
  6941. else
  6942. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6943. 'date' => date ( 'Y-m-d' ),
  6944. 'opinion' => $opinion,
  6945. 'status' => $status,
  6946. 'nextStaff' => $nextStaff
  6947. );
  6948. // print_r($verifyStaff);
  6949. // echo $nowStaff;die;
  6950. } else { // 进入下一个角色或者审批人
  6951. /*
  6952. *
  6953. */
  6954. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  6955. //
  6956. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  6957. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6958. 'date' => date ( 'Y-m-d' ),
  6959. 'opinion' => $opinion,
  6960. 'status' => $status,
  6961. 'nextStaff' => $VS ['nextStaff'],
  6962. 'ROLE' => 1
  6963. );
  6964. // print_r($verifyStaff);
  6965. // die;
  6966. }
  6967. if ($status == 3) {
  6968. $verifyStaff ['final'] = $status;
  6969. $verifyStaff [$this->staff [0] ['sid']] = array (
  6970. 'date' => date ( 'Y-m-d' ),
  6971. 'opinion' => $opinion,
  6972. 'status' => $status
  6973. );
  6974. }
  6975. $vStaffString = json_encode ( $verifyStaff );
  6976. $receipt->verifyStaff = $vStaffString;
  6977. $receipt->nowStaff = $nowStaff;
  6978. // die;
  6979. // }
  6980. // print_r($verifyStaff);
  6981. // die;
  6982. }
  6983. // print_r($verifyStaff);die;
  6984. }
  6985. // print_r($verifyDetail);
  6986. $roleKey = 0;
  6987. $roleId = 0;
  6988. $verifyDetailCopy = array ();
  6989. foreach ( $verifyDetail as $k => $v ) {
  6990. if ($v [1] == 'ROLE') {
  6991. $roleId = $v [0];
  6992. $roleVerify = json_decode ( $v [3], true );
  6993. $roleKey = $k;
  6994. $roleArray = array ();
  6995. foreach ( $roleVerify as $o => $p ) {
  6996. $staffID = explode ( '_', $p );
  6997. $exp = array (
  6998. 0 => $staffID [0],
  6999. 1 => $staffID [1]
  7000. );
  7001. array_push ( $roleArray, $exp );
  7002. }
  7003. $verifyDetailCopy [$v [0]] = $roleArray;
  7004. }
  7005. }
  7006. // print_r($verifyDetail);
  7007. foreach ( $verifyDetailCopy as $k => $v ) {
  7008. foreach ( $verifyDetail as $m => $n ) {
  7009. if ($n [0] == $k) {
  7010. array_splice ( $verifyDetail, $m, 1, $v );
  7011. }
  7012. }
  7013. }
  7014. // die;
  7015. // if (!empty($roleArray))
  7016. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  7017. // echo $roleId;
  7018. // print_r($verifyStaff);
  7019. // print_r($verifyDetail);
  7020. // die;
  7021. Doo::loadModel ( "receiptLog" );
  7022. $receiptLog = new receiptLog ();
  7023. // 审批日志
  7024. if (! isset ( $verifyStaff ['final'] )) {
  7025. if (! empty ( $roleId )) {
  7026. Doo::loadModel ( "role" );
  7027. $role = new role ();
  7028. $roleInfo = $role->getOne ( array (
  7029. 'where' => 'rid=' . $roleId,
  7030. 'asArray' => true
  7031. ) );
  7032. $receiptLog->rolename = $roleInfo ['name'];
  7033. }
  7034. $receiptLog->username = $this->staff [0] ['username'];
  7035. $receiptLog->uid = $this->staff [0] ['sid'];
  7036. $receiptLog->date = date ( "Y-m-d" );
  7037. $receiptLog->opinion = $opinion;
  7038. $receiptLog->img = $this->staff [0] ['avatar'];
  7039. $receiptLog->status = 1;
  7040. $receiptLog->rid = $rid;
  7041. $receiptLog->insert ();
  7042. }
  7043. if (isset ( $verifyStaff ['final'] )) { // rDetail
  7044. $receipt->verifyBreakup = $verifyString;
  7045. $receipt->status = 3;
  7046. $receiptDetailObj->status = 3;
  7047. $receiptDetailObj->update ( array (
  7048. 'where' => 'rid=' . $rid
  7049. ) );
  7050. if (! empty ( $roleId )) {
  7051. Doo::loadModel ( "role" );
  7052. $role = new role ();
  7053. $roleInfo = $role->getOne ( array (
  7054. 'where' => 'rid=' . $roleId,
  7055. 'asArray' => true
  7056. ) );
  7057. $receiptLog->rolename = $roleInfo ['name'];
  7058. }
  7059. $receiptLog->username = $this->staff [0] ['username'];
  7060. $receiptLog->uid = $this->staff [0] ['sid'];
  7061. $receiptLog->date = date ( "Y-m-d" );
  7062. $receiptLog->opinion = $opinion;
  7063. $receiptLog->img = $this->staff [0] ['avatar'];
  7064. $receiptLog->status = 3;
  7065. $receiptLog->rid = $rid;
  7066. $receiptLog->insert ();
  7067. // 微信企业号通知
  7068. $this->setWXMsg ( $rid, 3 );
  7069. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  7070. $receipt->status = 1;
  7071. $reviseSum = 0;
  7072. $receipt->verifyBreakup = $verifyString;
  7073. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  7074. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7075. foreach ( $reviseDetail as $key => $value ) {
  7076. $receiptDetailObj = new receiptDetail ();
  7077. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7078. $receiptDetailObj->item = $value ['description'];
  7079. $receiptDetailObj->itemCategory = "报销金额调整";
  7080. $receiptDetailObj->price = $value ['price'];
  7081. $receiptDetailObj->date = $receiptDetail ['date'];
  7082. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  7083. $receiptDetailObj->rid = $rid;
  7084. $receiptDetailObj->status = 1;
  7085. $receiptDetailObj->insert ();
  7086. $reviseSum += $value ['price'];
  7087. }
  7088. $itemStatistics = new itemStatistics ();
  7089. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7090. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7091. $itemStatistics->price = $reviseSum;
  7092. $itemStatistics->itemCategory = "报销金额调整";
  7093. $itemStatistics->date = $receiptDetail ['date'];
  7094. $itemStatistics->insert ();
  7095. }
  7096. $receiptDetailObj = new receiptDetail ();
  7097. $receiptDetailObj->status = 1;
  7098. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  7099. $receiptDetailObj->update ( array (
  7100. 'where' => 'rid=' . $rid
  7101. ) );
  7102. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7103. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7104. $stat = $statistics->getOne ( array (
  7105. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  7106. 'asArray' => true
  7107. ) );
  7108. if (empty ( $stat )) {
  7109. $statistics->date = $receiptDetail ['date'];
  7110. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7111. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7112. $statistics->agPrice = $receiptDetail ['sum'];
  7113. $statistics->rePrice = $reviseSum;
  7114. $statistics->insert ();
  7115. } else {
  7116. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  7117. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  7118. $statistics->update ( array (
  7119. 'where' => 'sid=' . $stat ['sid']
  7120. ) );
  7121. }
  7122. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7123. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7124. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  7125. foreach ( $accountItem ['cSum'] as $key => $value ) {
  7126. if ($key == "agencySum") {
  7127. $iStatistics = $itemStatistics->getOne ( array (
  7128. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  7129. 'asArray' => true
  7130. ) );
  7131. if (empty ( $iStatistics )) {
  7132. $itemStatistics->cid = $receiptDetail ['cid'];
  7133. ;
  7134. $itemStatistics->staff = $receiptDetail ['staff'];
  7135. $itemStatistics->price = $value;
  7136. $itemStatistics->itemCategory = $this->AGENCY;
  7137. $itemStatistics->date = $receiptDetail ['date'];
  7138. $itemStatistics->insert ();
  7139. } else {
  7140. if (! empty ( $value )) {
  7141. $itemStatistics->price = $value + $iStatistics ['price'];
  7142. $itemStatistics->update ( array (
  7143. 'where' => 'sid=' . $iStatistics ['sid']
  7144. ) );
  7145. }
  7146. }
  7147. } elseif ($key == "travelSum") {
  7148. $iStatistics = $itemStatistics->getOne ( array (
  7149. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  7150. 'asArray' => true
  7151. ) );
  7152. if (empty ( $iStatistics )) {
  7153. $itemStatistics->cid = $receiptDetail ['cid'];
  7154. $itemStatistics->staff = $receiptDetail ['staff'];
  7155. $itemStatistics->price = $value;
  7156. $itemStatistics->itemCategory = $this->TRAVEL;
  7157. $itemStatistics->date = $receiptDetail ['date'];
  7158. $itemStatistics->insert ();
  7159. } else {
  7160. if (! empty ( $value )) {
  7161. $itemStatistics->price = $value + $iStatistics ['price'];
  7162. $itemStatistics->update ( array (
  7163. 'where' => 'sid=' . $iStatistics ['sid']
  7164. ) );
  7165. }
  7166. }
  7167. } elseif ($key == "trainSum") {
  7168. $iStatistics = $itemStatistics->getOne ( array (
  7169. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  7170. 'asArray' => true
  7171. ) );
  7172. if (empty ( $iStatistics )) {
  7173. $itemStatistics->cid = $receiptDetail ['cid'];
  7174. $itemStatistics->staff = $receiptDetail ['staff'];
  7175. $itemStatistics->price = $value;
  7176. $itemStatistics->itemCategory = $this->TRAIN;
  7177. $itemStatistics->date = $receiptDetail ['date'];
  7178. $itemStatistics->insert ();
  7179. } else {
  7180. if (! empty ( $value )) {
  7181. $itemStatistics->price = $value + $iStatistics ['price'];
  7182. $itemStatistics->update ( array (
  7183. 'where' => 'sid=' . $iStatistics ['sid']
  7184. ) );
  7185. }
  7186. }
  7187. } elseif ($key == "otherSum") {
  7188. $iStatistics = $itemStatistics->getOne ( array (
  7189. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  7190. 'asArray' => true
  7191. ) );
  7192. if (empty ( $iStatistics )) {
  7193. $itemStatistics->cid = $receiptDetail ['cid'];
  7194. $itemStatistics->staff = $receiptDetail ['staff'];
  7195. $itemStatistics->price = $value;
  7196. $itemStatistics->itemCategory = $this->OTHER;
  7197. $itemStatistics->date = $receiptDetail ['date'];
  7198. $itemStatistics->insert ();
  7199. } else {
  7200. if (! empty ( $value )) {
  7201. $itemStatistics->price = $value + $iStatistics ['price'];
  7202. $itemStatistics->update ( array (
  7203. 'where' => 'sid=' . $iStatistics ['sid']
  7204. ) );
  7205. }
  7206. }
  7207. }
  7208. }
  7209. $receipt->pastDate = date ( "Y-m-d" );
  7210. // 微信企业号通知
  7211. $this->setWXMsg ( $rid, 1 );
  7212. }
  7213. $receipt->amount = $amount;
  7214. $receipt->update ( array (
  7215. 'where' => ' rid = ' . $rid
  7216. ) );
  7217. return "/approvalExpenses/pendApproval";
  7218. }
  7219. }
  7220. function expensesRetreats() {
  7221. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7222. if (! empty ( $rid )) {
  7223. // 操作记录
  7224. Doo::loadModel ( "receipt" );
  7225. $receipt = new receipt ();
  7226. Doo::loadModel ( "receiptLog" );
  7227. $receiptLog = new receiptLog ();
  7228. Doo::loadModel ( "verify" );
  7229. $verify = new verify ();
  7230. $receiptInfo = $receipt->getOne ( array (
  7231. 'where' => 'rid=' . $rid,
  7232. 'asArray' => true
  7233. ) );
  7234. $vr = $verify->getOne ( array (
  7235. 'where' => 'vid=' . $receiptInfo ['verify'],
  7236. 'asArray' => true
  7237. ) );
  7238. $jd = json_decode ( $vr ['staff'] );
  7239. $roleId = 0;
  7240. foreach ( $jd as $key => $value ) {
  7241. if ($value [1] == 'ROLE') {
  7242. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7243. if ($pos !== false) {
  7244. $roleId = $value [0];
  7245. }
  7246. }
  7247. }
  7248. // 审批日志
  7249. // echo $roleId;die;
  7250. if (! empty ( $roleId )) {
  7251. Doo::loadModel ( "role" );
  7252. $role = new role ();
  7253. $roleInfo = $role->getOne ( array (
  7254. 'where' => 'rid=' . $roleId,
  7255. 'asArray' => true
  7256. ) );
  7257. $receiptLog->rolename = $roleInfo ['name'];
  7258. }
  7259. $receiptLog->username = $this->staff [0] ['username'];
  7260. $receiptLog->uid = $this->staff [0] ['sid'];
  7261. $receiptLog->date = date ( "Y-m-d" );
  7262. $receiptLog->opinion = '撤回';
  7263. $receiptLog->img = $this->staff [0] ['avatar'];
  7264. $receiptLog->status = 4;
  7265. $receiptLog->rid = $rid;
  7266. $receiptLog->insert ();
  7267. $receipt->status = 4;
  7268. $receipt->update ( array (
  7269. 'where' => 'rid=' . $rid
  7270. ) );
  7271. // 微信企业号通知
  7272. $this->setWXMsg ( $rid, 2 );
  7273. }
  7274. // echo "ddd";
  7275. return '/approvalExpenses/pendApproval';
  7276. }
  7277. function updateCheReceipt() {
  7278. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7279. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7280. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  7281. if (! empty ( $rid )) {
  7282. // 操作记录
  7283. Doo::loadModel ( "receipt" );
  7284. $receipt = new receipt ();
  7285. Doo::loadModel ( "receiptLog" );
  7286. $receiptLog = new receiptLog ();
  7287. Doo::loadModel ( "verify" );
  7288. $verify = new verify ();
  7289. $receiptInfo = $receipt->getOne ( array (
  7290. 'where' => 'rid=' . $rid,
  7291. 'asArray' => true
  7292. ) );
  7293. $vr = $verify->getOne ( array (
  7294. 'where' => 'vid=' . $receiptInfo ['verify'],
  7295. 'asArray' => true
  7296. ) );
  7297. $jd = json_decode ( $vr ['staff'] );
  7298. $roleId = 0;
  7299. foreach ( $jd as $key => $value ) {
  7300. if ($value [1] == 'ROLE') {
  7301. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7302. if ($pos !== false) {
  7303. $roleId = $value [0];
  7304. }
  7305. }
  7306. }
  7307. // 审批日志
  7308. // echo $roleId;die;
  7309. if (! empty ( $roleId )) {
  7310. Doo::loadModel ( "role" );
  7311. $role = new role ();
  7312. $roleInfo = $role->getOne ( array (
  7313. 'where' => 'rid=' . $roleId,
  7314. 'asArray' => true
  7315. ) );
  7316. $receiptLog->rolename = $roleInfo ['name'];
  7317. }
  7318. $receiptLog->username = $this->staff [0] ['username'];
  7319. $receiptLog->uid = $this->staff [0] ['sid'];
  7320. $receiptLog->date = date ( "Y-m-d" );
  7321. $receiptLog->opinion = $opinion;
  7322. $receiptLog->img = $this->staff [0] ['avatar'];
  7323. $receiptLog->status = 4;
  7324. $receiptLog->rid = $rid;
  7325. $receiptLog->insert ();
  7326. $receipt->status = 4;
  7327. $receipt->update ( array (
  7328. 'where' => 'rid=' . $rid
  7329. ) );
  7330. // 微信企业号通知
  7331. $this->setWXMsg ( $rid, 2 );
  7332. echo json_encode ( array (
  7333. 'status' => 1
  7334. ) );
  7335. die ();
  7336. }
  7337. echo json_encode ( array (
  7338. 'status' => 2
  7339. ) );
  7340. die ();
  7341. // echo "ddd";
  7342. // return '/saeaBorad';
  7343. }
  7344. function revisePrice() {
  7345. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  7346. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  7347. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7348. // echo $price;die;
  7349. if (! empty ( $rid )) {
  7350. Doo::loadModel ( "receipt" );
  7351. $receipt = new receipt ();
  7352. $receiptDetail = $receipt->getOne ( array (
  7353. 'where' => 'rid=' . $rid . ' and status=2 ',
  7354. 'asArray' => true
  7355. ) );
  7356. if (empty ( $receiptDetail ))
  7357. return "/approval";
  7358. $reviseDetail = array ();
  7359. if (empty ( $receiptDetail ['reviseDetail'] )) {
  7360. array_push ( $reviseDetail, array (
  7361. 'sid' => $this->staff [0] ['sid'],
  7362. 'name' => $this->staff [0] ['username'],
  7363. 'description' => $description,
  7364. 'price' => $price
  7365. ) );
  7366. $reviseDetailString = json_encode ( $reviseDetail );
  7367. $receipt->reviseDetail = $reviseDetailString;
  7368. $receipt->revisePrice = $price;
  7369. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7370. } else {
  7371. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7372. array_push ( $reviseDetail, array (
  7373. 'sid' => $this->staff [0] ['sid'],
  7374. 'name' => $this->staff [0] ['username'],
  7375. 'description' => $description,
  7376. 'price' => $price
  7377. ) );
  7378. $reviseDetailString = json_encode ( $reviseDetail );
  7379. $receipt->reviseDetail = $reviseDetailString;
  7380. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  7381. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7382. }
  7383. $receipt->update ( array (
  7384. 'where' => 'rid=' . $rid
  7385. ) );
  7386. }
  7387. return '/approvalEdi/' . $rid;
  7388. }
  7389. function personalCollect() {
  7390. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7391. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  7392. $this->showCache ( $path );
  7393. Doo::loadModel ( "receiptDetail" );
  7394. Doo::loadModel ( "itemStatistics" );
  7395. Doo::loadModel ( 'statistics' );
  7396. $statistics = new statistics ();
  7397. $itemStatistics = new itemStatistics ();
  7398. $receiptDetail = new receiptDetail ();
  7399. $receiptCollectList = $receiptDetail->find ( array (
  7400. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7401. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7402. 'groupby' => 'itemCategory,Month(date)',
  7403. 'asArray' => true
  7404. ) );
  7405. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  7406. 'where' => 'staff=' . $this->staff [0] ['sid'],
  7407. 'asArray' => true
  7408. ) );
  7409. // create collect html
  7410. $collectArray = array (
  7411. '日常相关费用' => array (),
  7412. '差旅相关费用' => array (),
  7413. '培训班费用' => array (),
  7414. '其他' => array ()
  7415. );
  7416. $adjustment = array ();
  7417. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  7418. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7419. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  7420. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7421. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  7422. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7423. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  7424. array_push ( $collectArray ['其他'], $collectHtml );
  7425. $data ['collectArray'] = $collectArray;
  7426. // statistics html
  7427. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7428. if (empty ( $stList ))
  7429. $stList = array (
  7430. 'rePrice' => 0,
  7431. 'agPrice' => 0
  7432. );
  7433. $data ['stList'] = array (
  7434. 'rePrice' => $stList ['rePrice'],
  7435. 'agPrice' => $stList ['agPrice'],
  7436. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7437. );
  7438. // Adjustment price html
  7439. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7440. array_push ( $adjustment, $collectHtml );
  7441. $data ['adjustment'] = $adjustment;
  7442. // total price html
  7443. $collectHtml = "";
  7444. $total = 0;
  7445. for($i = 1; $i <= 12; $i ++) {
  7446. $sumPrice = 0;
  7447. foreach ( $receiptCollectList as $key => $value ) {
  7448. if ($value ['month'] == $i) {
  7449. $sumPrice += $value ['price'];
  7450. }
  7451. }
  7452. if ($sumPrice == 0)
  7453. $collectHtml .= '<td class="taR">-</td>';
  7454. else
  7455. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7456. $total += $sumPrice;
  7457. }
  7458. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7459. $data ['totalPrice'] = $collectHtml;
  7460. $data ['year'] = $year;
  7461. $data ['totalYear'] = $total;
  7462. $data ['memu'] = "receipt";
  7463. $data ['staff'] = $this->staff;
  7464. $data ['receiptMemu'] = 'personalCollect';
  7465. $data ['verifyId'] = $this->verifyId;
  7466. $data ['executeId'] = $this->executeId;
  7467. // year staff status 2,4
  7468. if ($year < date ( "Y" )) {
  7469. Doo::loadModel ( 'receipt' );
  7470. $receipt = new receipt ();
  7471. $receiptList = $receipt->find ( array (
  7472. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7473. 'asArray' => true
  7474. ) );
  7475. if (empty ( $receiptList )) {
  7476. ob_start ();
  7477. $this->render ( "/admin/saea_slist_collect", $data );
  7478. $this->cacheFile ( $path );
  7479. die ();
  7480. }
  7481. }
  7482. $this->render ( "/admin/saea_slist_collect", $data );
  7483. }
  7484. function personalCollectDetail() {
  7485. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7486. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  7487. $this->showCache ( $path );
  7488. Doo::loadModel ( "receiptDetail" );
  7489. Doo::loadModel ( "itemStatistics" );
  7490. Doo::loadModel ( 'statistics' );
  7491. Doo::loadModel ( 'accountItem' );
  7492. $accountItem = new accountItem ();
  7493. $statistics = new statistics ();
  7494. $itemStatistics = new itemStatistics ();
  7495. $receiptDetail = new receiptDetail ();
  7496. $receiptCollectList = $receiptDetail->find ( array (
  7497. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  7498. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7499. 'groupby' => 'item,Month(date)',
  7500. 'asArray' => true
  7501. ) );
  7502. $accountList = $accountItem->find ( array (
  7503. 'asArray' => true
  7504. ) );
  7505. // create CollectDetail HTML
  7506. $collectHtml = array ();
  7507. foreach ( $accountList as $key => $value ) {
  7508. $html = "";
  7509. $asum = 0;
  7510. for($i = 1; $i <= 12; $i ++) {
  7511. $falg = true;
  7512. foreach ( $receiptCollectList as $v ) {
  7513. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7514. $asum += $v ['price'];
  7515. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7516. $falg = false;
  7517. break;
  7518. }
  7519. }
  7520. if ($falg)
  7521. $html .= '<td class="taR">-</td>';
  7522. }
  7523. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7524. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7525. }
  7526. $data ['collectHtml'] = $collectHtml;
  7527. // create Adjustment price html
  7528. $receiptCollectList = $receiptDetail->find ( array (
  7529. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7530. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7531. 'groupby' => 'itemCategory,Month(date)',
  7532. 'asArray' => true
  7533. ) );
  7534. $adjustment = array ();
  7535. $collectArray = array (
  7536. '日常相关费用' => array (),
  7537. '差旅相关费用' => array (),
  7538. '培训班费用' => array (),
  7539. '其他' => array ()
  7540. );
  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, '培训班费用', 'b' );
  7546. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7547. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7548. array_push ( $collectArray ['其他'], $collectHtml );
  7549. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7550. array_push ( $adjustment, $collectHtml );
  7551. // total price html
  7552. $collectHtml = "";
  7553. $total = 0;
  7554. for($i = 1; $i <= 12; $i ++) {
  7555. $sumPrice = 0;
  7556. foreach ( $receiptCollectList as $key => $value ) {
  7557. if ($value ['month'] == $i) {
  7558. $sumPrice += $value ['price'];
  7559. }
  7560. }
  7561. if ($sumPrice == 0)
  7562. $collectHtml .= '<td class="taR">-</td>';
  7563. else
  7564. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7565. $total += $sumPrice;
  7566. }
  7567. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7568. // statistics html
  7569. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7570. if (empty ( $stList ))
  7571. $stList = array (
  7572. 'rePrice' => 0,
  7573. 'agPrice' => 0
  7574. );
  7575. $data ['stList'] = array (
  7576. 'rePrice' => $stList ['rePrice'],
  7577. 'agPrice' => $stList ['agPrice'],
  7578. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7579. );
  7580. $data ['collectArray'] = $collectArray;
  7581. $data ['adjustment'] = $adjustment;
  7582. $data ['totalPrice'] = $collectHtml;
  7583. $data ['totalYear'] = $total;
  7584. $data ['year'] = $year;
  7585. $data ['memu'] = "receipt";
  7586. $data ['staff'] = $this->staff;
  7587. $data ['receiptMemu'] = 'personalCollect';
  7588. $data ['verifyId'] = $this->verifyId;
  7589. $data ['executeId'] = $this->executeId;
  7590. // year staff status 2,4
  7591. if ($year < date ( "Y" )) {
  7592. Doo::loadModel ( 'receipt' );
  7593. $receipt = new receipt ();
  7594. $receiptList = $receipt->find ( array (
  7595. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7596. 'asArray' => true
  7597. ) );
  7598. if (empty ( $receiptList )) {
  7599. ob_start ();
  7600. $this->render ( "/admin/saeaCollectArticles", $data );
  7601. $this->cacheFile ( $path );
  7602. die ();
  7603. }
  7604. }
  7605. $this->render ( "/admin/saeaCollectArticles", $data );
  7606. }
  7607. function companyCategoryCollect() {
  7608. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7609. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  7610. $this->showCache ( $path );
  7611. Doo::loadModel ( 'L_category' );
  7612. Doo::loadModel ( 'itemStatistics' );
  7613. Doo::loadModel ( 'statistics' );
  7614. $statistics = new statistics ();
  7615. $Lcategory = new L_category ();
  7616. $itemStatistics = new itemStatistics ();
  7617. $LcategoryList = $Lcategory->find ( array (
  7618. 'asArray' => true
  7619. ) ); // 'staff='.$this->staff[0]['sid']." and
  7620. $itemStatisticsList = $itemStatistics->find ( array (
  7621. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7622. 'where' => " Year(date)=" . $year,
  7623. 'groupby' => 'cid,Month(date)',
  7624. 'asArray' => true
  7625. ) );
  7626. // ceatre companyCollectHtml
  7627. foreach ( $LcategoryList as $value ) {
  7628. $html = "";
  7629. $asum = 0;
  7630. for($i = 1; $i <= 12; $i ++) {
  7631. $falg = true;
  7632. foreach ( $itemStatisticsList as $v ) {
  7633. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  7634. $asum += $v ['price'];
  7635. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7636. $falg = false;
  7637. break;
  7638. }
  7639. }
  7640. if ($falg)
  7641. $html .= '<td class="taR">-</td>';
  7642. }
  7643. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7644. $collectHtml [$value ['title']] = array (
  7645. 'html' => $html,
  7646. 'cid' => $value ['cid']
  7647. );
  7648. }
  7649. $data ['companyHtml'] = $collectHtml;
  7650. // total price html
  7651. $collectHtml = "";
  7652. $total = 0;
  7653. for($i = 1; $i <= 12; $i ++) {
  7654. $sumPrice = 0;
  7655. foreach ( $itemStatisticsList as $key => $value ) {
  7656. if ($value ['month'] == $i) {
  7657. $sumPrice += $value ['price'];
  7658. }
  7659. }
  7660. if ($sumPrice == 0)
  7661. $collectHtml .= '<td class="taR">-</td>';
  7662. else
  7663. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7664. $total += $sumPrice;
  7665. }
  7666. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7667. $data ['companyTotalHtml'] = $collectHtml;
  7668. $data ['total'] = $total;
  7669. // statistics html
  7670. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7671. if (empty ( $stList ))
  7672. $stList = array (
  7673. 'rePrice' => 0,
  7674. 'agPrice' => 0
  7675. );
  7676. $data ['stList'] = array (
  7677. 'rePrice' => $stList ['rePrice'],
  7678. 'agPrice' => $stList ['agPrice'],
  7679. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7680. );
  7681. $data ['year'] = $year;
  7682. $data ['memu'] = "receipt";
  7683. $data ['staff'] = $this->staff;
  7684. $data ['receiptMemu'] = 'companyCategoryCollect';
  7685. $data ['verifyId'] = $this->verifyId;
  7686. $data ['executeId'] = $this->executeId;
  7687. // year staff status 2,4
  7688. if ($year < date ( "Y" )) {
  7689. Doo::loadModel ( 'receipt' );
  7690. $receipt = new receipt ();
  7691. $receiptList = $receipt->find ( array (
  7692. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  7693. 'asArray' => true
  7694. ) );
  7695. if (empty ( $receiptList )) {
  7696. ob_start ();
  7697. $this->render ( "/admin/saeaCompanyCollect", $data );
  7698. $this->cacheFile ( $path );
  7699. die ();
  7700. }
  7701. }
  7702. $this->render ( "/admin/saeaCompanyCollect", $data );
  7703. }
  7704. function categoryCollectDetail() {
  7705. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7706. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  7707. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  7708. $this->showCache ( $path );
  7709. Doo::loadModel ( 'statistics' );
  7710. $statistics = new statistics ();
  7711. Doo::loadModel ( "receiptDetail" );
  7712. $receiptDetail = new receiptDetail ();
  7713. Doo::loadModel ( 'L_category' );
  7714. $Lcategory = new L_category ();
  7715. Doo::loadModel ( 'accountItem' );
  7716. $accountItem = new accountItem ();
  7717. $LcategoryList = $Lcategory->find ( array (
  7718. 'asArray' => true
  7719. ) );
  7720. if ($cid == 0) {
  7721. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7722. if ($cid == 0)
  7723. $cid = $LcategoryList [0] ['cid'];
  7724. }
  7725. $data ['LcategoryList'] = $LcategoryList;
  7726. $receiptCollectList = $receiptDetail->find ( array (
  7727. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  7728. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7729. 'groupby' => 'item,Month(pastDate)',
  7730. 'asArray' => true
  7731. ) );
  7732. $accountList = $accountItem->find ( array (
  7733. 'asArray' => true
  7734. ) );
  7735. // create CollectDetail HTML
  7736. $collectHtml = array ();
  7737. foreach ( $accountList as $key => $value ) {
  7738. $html = "";
  7739. $asum = 0;
  7740. for($i = 1; $i <= 12; $i ++) {
  7741. $falg = true;
  7742. foreach ( $receiptCollectList as $v ) {
  7743. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7744. $asum += $v ['price'];
  7745. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7746. $falg = false;
  7747. break;
  7748. }
  7749. }
  7750. if ($falg)
  7751. $html .= '<td class="taR">-</td>';
  7752. }
  7753. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7754. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7755. }
  7756. $data ['collectHtml'] = $collectHtml;
  7757. // create Adjustment price html
  7758. $receiptCollectList = $receiptDetail->find ( array (
  7759. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  7760. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7761. 'groupby' => 'itemCategory,Month(pastDate)',
  7762. 'asArray' => true
  7763. ) );
  7764. $adjustment = array ();
  7765. $collectArray = array (
  7766. '日常相关费用' => array (),
  7767. '差旅相关费用' => array (),
  7768. '培训班费用' => array (),
  7769. '其他' => array ()
  7770. );
  7771. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7772. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7773. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7774. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7775. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7776. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7777. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7778. array_push ( $collectArray ['其他'], $collectHtml );
  7779. $data ['collectArray'] = $collectArray;
  7780. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7781. array_push ( $adjustment, $collectHtml );
  7782. $data ['adjustment'] = $adjustment;
  7783. // total price html
  7784. $collectHtml = "";
  7785. $total = 0;
  7786. for($i = 1; $i <= 12; $i ++) {
  7787. $sumPrice = 0;
  7788. foreach ( $receiptCollectList as $key => $value ) {
  7789. if ($value ['month'] == $i) {
  7790. $sumPrice += $value ['price'];
  7791. }
  7792. }
  7793. if ($sumPrice == 0)
  7794. $collectHtml .= '<td class="taR">-</td>';
  7795. else
  7796. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7797. $total += $sumPrice;
  7798. }
  7799. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7800. // statistics html
  7801. $stList = $statistics->statisticsByCid ( $year, $cid );
  7802. if (empty ( $stList ))
  7803. $stList = array (
  7804. 'rePrice' => 0,
  7805. 'agPrice' => 0
  7806. );
  7807. $data ['stList'] = array (
  7808. 'rePrice' => $stList ['rePrice'],
  7809. 'agPrice' => $stList ['agPrice'],
  7810. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7811. );
  7812. $data ['totalYear'] = $total;
  7813. $data ['year'] = $year;
  7814. $data ['cid'] = $cid;
  7815. $data ['memu'] = "receipt";
  7816. $data ['staff'] = $this->staff;
  7817. $data ['receiptMemu'] = 'companyCategoryCollect';
  7818. $data ['verifyId'] = $this->verifyId;
  7819. $data ['executeId'] = $this->executeId;
  7820. // year staff status 2,4
  7821. if ($year < date ( "Y" )) {
  7822. Doo::loadModel ( 'receipt' );
  7823. $receipt = new receipt ();
  7824. $receiptList = $receipt->find ( array (
  7825. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  7826. 'asArray' => true
  7827. ) );
  7828. if (empty ( $receiptList )) {
  7829. ob_start ();
  7830. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7831. $this->cacheFile ( $path );
  7832. die ();
  7833. }
  7834. }
  7835. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7836. }
  7837. function staffCollect() {
  7838. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7839. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  7840. // $this->showCache($path);
  7841. Doo::loadModel ( 'statistics' );
  7842. $statistics = new statistics ();
  7843. Doo::loadModel ( "receiptDetail" );
  7844. $receiptDetail = new receiptDetail ();
  7845. Doo::loadModel ( 'L_category' );
  7846. $Lcategory = new L_category ();
  7847. Doo::loadModel ( 'accountItem' );
  7848. $accountItem = new accountItem ();
  7849. Doo::loadModel ( 'staff' );
  7850. $staff = new staff ();
  7851. Doo::loadModel ( 'itemStatistics' );
  7852. $itemStatistics = new itemStatistics ();
  7853. /*
  7854. * $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']));
  7855. */
  7856. // statistics html
  7857. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7858. if (empty ( $stList ))
  7859. $stList = array (
  7860. 'rePrice' => 0,
  7861. 'agPrice' => 0
  7862. );
  7863. $data ['stList'] = array (
  7864. 'rePrice' => $stList ['rePrice'],
  7865. 'agPrice' => $stList ['agPrice'],
  7866. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7867. );
  7868. // ---
  7869. $staffList = $staff->find ( array (
  7870. 'where' => 'username !="admin"',
  7871. 'asArray' => true
  7872. ) );
  7873. $LcategoryList = $Lcategory->find ( array (
  7874. 'asArray' => true
  7875. ) ); // 'staff='.$this->staff[0]['sid']." and
  7876. $itemStatisticsList = $itemStatistics->find ( array (
  7877. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7878. 'where' => " Year(date)=" . $year,
  7879. 'groupby' => 'staff,Month(date)',
  7880. 'asArray' => true
  7881. ) );
  7882. $categoryList = $staff->find ( array (
  7883. 'select' => 'COUNT(*) as count,cid,category',
  7884. 'where' => 'username !="admin"',
  7885. 'groupby' => 'cid',
  7886. 'asArray' => true
  7887. ) );
  7888. // print_r($itemStatisticsList);die;
  7889. // ceatre companyCollectHtml
  7890. foreach ( $categoryList as $vlu ) {
  7891. $count = $vlu ['count'] + 1;
  7892. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  7893. $m1 = 0;
  7894. $m2 = 0;
  7895. $m3 = 0;
  7896. $m4 = 0;
  7897. $m5 = 0;
  7898. $m6 = 0;
  7899. $m7 = 0;
  7900. $m8 = 0;
  7901. $m9 = 0;
  7902. $m10 = 0;
  7903. $m11 = 0;
  7904. $m12 = 0;
  7905. $m13 = 0;
  7906. foreach ( $staffList as $value ) {
  7907. if ($vlu ['cid'] == $value ['cid']) {
  7908. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  7909. $asum = 0;
  7910. for($i = 1; $i <= 12; $i ++) {
  7911. $falg = true;
  7912. foreach ( $itemStatisticsList as $v ) {
  7913. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  7914. if ($v ['month'] == 1)
  7915. $m1 += $v ['price'];
  7916. if ($v ['month'] == 2)
  7917. $m2 += $v ['price'];
  7918. if ($v ['month'] == 3)
  7919. $m3 += $v ['price'];
  7920. if ($v ['month'] == 4)
  7921. $m4 += $v ['price'];
  7922. if ($v ['month'] == 5)
  7923. $m5 += $v ['price'];
  7924. if ($v ['month'] == 6)
  7925. $m6 += $v ['price'];
  7926. if ($v ['month'] == 7)
  7927. $m7 += $v ['price'];
  7928. if ($v ['month'] == 8)
  7929. $m8 += $v ['price'];
  7930. if ($v ['month'] == 9)
  7931. $m9 += $v ['price'];
  7932. if ($v ['month'] == 10)
  7933. $m10 += $v ['price'];
  7934. if ($v ['month'] == 11)
  7935. $m11 += $v ['price'];
  7936. if ($v ['month'] == 12)
  7937. $m12 += $v ['price'];
  7938. $asum += $v ['price'];
  7939. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7940. $falg = false;
  7941. break;
  7942. }
  7943. }
  7944. if ($falg)
  7945. $html .= '<td class="taR">-</td>';
  7946. }
  7947. $m13 += $asum;
  7948. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7949. $collectHtml [$value ['username']] = array (
  7950. 'html' => $html,
  7951. 'sid' => $value ['sid']
  7952. );
  7953. $html = "";
  7954. }
  7955. }
  7956. $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>
  7957. <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>
  7958. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  7959. $collectHtml [$vlu ['cid']] = array (
  7960. 'html' => $hl,
  7961. 'sid' => ''
  7962. );
  7963. }
  7964. $data ['companyHtml'] = $collectHtml;
  7965. // total price html
  7966. $collectHtml = "";
  7967. $total = 0;
  7968. for($i = 1; $i <= 12; $i ++) {
  7969. $sumPrice = 0;
  7970. foreach ( $itemStatisticsList as $key => $value ) {
  7971. if ($value ['month'] == $i) {
  7972. $sumPrice += $value ['price'];
  7973. }
  7974. }
  7975. if ($sumPrice == 0)
  7976. $collectHtml .= '<td class="taR">-</td>';
  7977. else
  7978. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7979. $total += $sumPrice;
  7980. }
  7981. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7982. $data ['companyTotalHtml'] = $collectHtml;
  7983. $data ['total'] = $total;
  7984. $data ['year'] = $year;
  7985. $data ['memu'] = "receipt";
  7986. $data ['staff'] = $this->staff;
  7987. $data ['receiptMemu'] = 'companyCategoryCollect';
  7988. $data ['verifyId'] = $this->verifyId;
  7989. $data ['executeId'] = $this->executeId;
  7990. if ($year <= date ( "Y" )) {
  7991. Doo::loadModel ( 'receipt' );
  7992. $receipt = new receipt ();
  7993. $receiptList = $receipt->find ( array (
  7994. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  7995. 'asArray' => true
  7996. ) );
  7997. if (empty ( $receiptList )) { // generated files
  7998. ob_start ();
  7999. $this->render ( "/admin/saeaStaffCollectB", $data );
  8000. $this->cacheFile ( $path );
  8001. die ();
  8002. }
  8003. }
  8004. $this->render ( "/admin/saeaStaffCollectB", $data );
  8005. }
  8006. function staffCollectBak() {
  8007. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8008. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  8009. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  8010. $this->showCache ( $path );
  8011. Doo::loadModel ( 'statistics' );
  8012. $statistics = new statistics ();
  8013. Doo::loadModel ( "receiptDetail" );
  8014. $receiptDetail = new receiptDetail ();
  8015. Doo::loadModel ( 'L_category' );
  8016. $Lcategory = new L_category ();
  8017. Doo::loadModel ( 'accountItem' );
  8018. $accountItem = new accountItem ();
  8019. Doo::loadModel ( 'staff' );
  8020. $staff = new staff ();
  8021. Doo::loadModel ( 'itemStatistics' );
  8022. $itemStatistics = new itemStatistics ();
  8023. $itemStatisticsList = $itemStatistics->find ( array (
  8024. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8025. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8026. 'groupby' => 'staff,itemCategory,Month(date)',
  8027. 'asArray' => true
  8028. ) );
  8029. $itemCategoryList = $itemStatistics->find ( array (
  8030. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8031. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8032. 'groupby' => 'cid,itemCategory,Month(date)',
  8033. 'asArray' => true
  8034. ) );
  8035. $LcategoryList = $Lcategory->find ( array (
  8036. 'asArray' => true
  8037. ) );
  8038. $staffList = $staff->find ( array (
  8039. 'asArray' => true
  8040. ) );
  8041. $htmlArray = array ();
  8042. foreach ( $LcategoryList as $value ) {
  8043. $htmlArray [$value ['title']] = array ();
  8044. foreach ( $staffList as $v ) {
  8045. if ($value ['cid'] == $v ['cid']) {
  8046. $html = "";
  8047. $falg = true;
  8048. $staffSumPrice = 0;
  8049. foreach ( $itemStatisticsList as $a ) {
  8050. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  8051. if (empty ( $a ['price'] )) {
  8052. $html .= '<td class="taR">-</td>';
  8053. $falg = false;
  8054. break;
  8055. } else {
  8056. $staffSumPrice += $a ['price'];
  8057. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8058. $falg = false;
  8059. break;
  8060. }
  8061. }
  8062. }
  8063. if ($falg) {
  8064. $html .= '<td class="taR">-</td>';
  8065. $falg = true;
  8066. }
  8067. $falg = true;
  8068. foreach ( $itemStatisticsList as $a ) {
  8069. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  8070. if (empty ( $a ['price'] )) {
  8071. $html .= '<td class="taR">-</td>';
  8072. $falg = false;
  8073. break;
  8074. } else {
  8075. $staffSumPrice += $a ['price'];
  8076. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8077. $falg = false;
  8078. break;
  8079. }
  8080. }
  8081. }
  8082. if ($falg) {
  8083. $html .= '<td class="taR">-</td>';
  8084. $falg = true;
  8085. }
  8086. $falg = true;
  8087. foreach ( $itemStatisticsList as $a ) {
  8088. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  8089. if (empty ( $a ['price'] )) {
  8090. $html .= '<td class="taR">-</td>';
  8091. $falg = false;
  8092. break;
  8093. } else {
  8094. $staffSumPrice += $a ['price'];
  8095. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8096. $falg = false;
  8097. break;
  8098. }
  8099. }
  8100. }
  8101. if ($falg) {
  8102. $html .= '<td class="taR">-</td>';
  8103. $falg = true;
  8104. }
  8105. $falg = true;
  8106. foreach ( $itemStatisticsList as $a ) {
  8107. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  8108. if (! empty ( $a ['price'] )) {
  8109. $staffSumPrice += $a ['price'];
  8110. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8111. $falg = false;
  8112. break;
  8113. } else {
  8114. $html .= '<td class="taR">-</td>';
  8115. $falg = false;
  8116. break;
  8117. }
  8118. }
  8119. }
  8120. if ($falg) {
  8121. $html .= '<td class="taR">-</td>';
  8122. $falg = true;
  8123. }
  8124. $falg = true;
  8125. foreach ( $itemStatisticsList as $a ) {
  8126. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  8127. if (! empty ( $a ['price'] )) {
  8128. $staffSumPrice += $a ['price'];
  8129. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8130. $falg = false;
  8131. break;
  8132. } else {
  8133. $html .= '<td class="taR">-</td>';
  8134. $falg = false;
  8135. break;
  8136. }
  8137. }
  8138. }
  8139. if ($falg) {
  8140. $html .= '<td class="taR">-</td>';
  8141. $falg = true;
  8142. }
  8143. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  8144. $htmlArray [$value ['title']] [$v ['username']] = $html;
  8145. }
  8146. }
  8147. /* -- --- */
  8148. // 合计费用
  8149. $cateHtml = "";
  8150. $catePrice = 0;
  8151. $cateFalg = true;
  8152. foreach ( $itemCategoryList as $l ) {
  8153. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  8154. if (empty ( $l ['price'] )) {
  8155. $cateHtml .= '<td class="colGreen taR">-</td>';
  8156. $cateFalg = false;
  8157. break;
  8158. } else {
  8159. $catePrice += $l ['price'];
  8160. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8161. $cateFalg = false;
  8162. break;
  8163. }
  8164. }
  8165. }
  8166. if ($cateFalg) {
  8167. $cateHtml .= '<td class="colGreen taR">-</td>';
  8168. $cateFalg = true;
  8169. }
  8170. $cateFalg = true;
  8171. foreach ( $itemCategoryList as $l ) {
  8172. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  8173. if (empty ( $l ['price'] )) {
  8174. $cateHtml .= '<td class="colGreen taR">-</td>';
  8175. $cateFalg = false;
  8176. break;
  8177. } else {
  8178. $catePrice += $l ['price'];
  8179. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8180. $cateFalg = false;
  8181. break;
  8182. }
  8183. }
  8184. }
  8185. if ($cateFalg) {
  8186. $cateHtml .= '<td class="colGreen taR">-</td>';
  8187. $cateFalg = true;
  8188. }
  8189. $cateFalg = true;
  8190. foreach ( $itemCategoryList as $l ) {
  8191. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  8192. if (empty ( $l ['price'] )) {
  8193. $cateHtml .= '<td class="colGreen taR">-</td>';
  8194. $cateFalg = false;
  8195. break;
  8196. } else {
  8197. $catePrice += $l ['price'];
  8198. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8199. $cateFalg = false;
  8200. break;
  8201. }
  8202. }
  8203. }
  8204. if ($cateFalg) {
  8205. $cateHtml .= '<td class="colGreen taR">-</td>';
  8206. $cateFalg = true;
  8207. }
  8208. $cateFalg = true;
  8209. foreach ( $itemCategoryList as $l ) {
  8210. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  8211. if (empty ( $l ['price'] )) {
  8212. $cateHtml .= '<td class="colGreen taR">-</td>';
  8213. $cateFalg = false;
  8214. break;
  8215. } else {
  8216. $catePrice += $l ['price'];
  8217. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8218. $cateFalg = false;
  8219. break;
  8220. }
  8221. }
  8222. }
  8223. if ($cateFalg) {
  8224. $cateHtml .= '<td class="colGreen taR">-</td>';
  8225. $cateFalg = true;
  8226. }
  8227. $cateFalg = true;
  8228. foreach ( $itemCategoryList as $l ) {
  8229. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  8230. if (empty ( $l ['price'] )) {
  8231. $cateHtml .= '<td class="colGreen taR">-</td>';
  8232. $cateFalg = false;
  8233. break;
  8234. } else {
  8235. $catePrice += $l ['price'];
  8236. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8237. $cateFalg = false;
  8238. break;
  8239. }
  8240. }
  8241. }
  8242. if ($cateFalg) {
  8243. $cateHtml .= '<td class="colGreen taR">-</td>';
  8244. $cateFalg = true;
  8245. }
  8246. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  8247. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  8248. /* -- --- */
  8249. }
  8250. // print_r($htmlArray);die;
  8251. $data ['htmlArray'] = $htmlArray;
  8252. // statistics html
  8253. $stList = $statistics->getOne ( array (
  8254. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8255. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8256. 'groupby' => 'Month(date)',
  8257. 'asArray' => true
  8258. ) );
  8259. if (empty ( $stList ))
  8260. $stList = array (
  8261. 'rePrice' => 0,
  8262. 'agPrice' => 0
  8263. );
  8264. $data ['stList'] = array (
  8265. 'rePrice' => $stList ['rePrice'],
  8266. 'agPrice' => $stList ['agPrice'],
  8267. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8268. );
  8269. $monthHtml = "";
  8270. for($i = 1; $i <= 12; $i ++) {
  8271. if ($i == $month)
  8272. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8273. else
  8274. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8275. }
  8276. $data ['monthHtml'] = $monthHtml;
  8277. $data ['year'] = $year;
  8278. $data ['month'] = $month;
  8279. $data ['memu'] = "receipt";
  8280. $data ['staff'] = $this->staff;
  8281. $data ['receiptMemu'] = 'companyCategoryCollect';
  8282. $data ['verifyId'] = $this->verifyId;
  8283. $data ['executeId'] = $this->executeId;
  8284. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  8285. Doo::loadModel ( 'receipt' );
  8286. $receipt = new receipt ();
  8287. $receiptList = $receipt->find ( array (
  8288. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  8289. 'asArray' => true
  8290. ) );
  8291. if (empty ( $receiptList )) { // generated files
  8292. ob_start ();
  8293. $this->render ( "/admin/saeaStaffCollect", $data );
  8294. $this->cacheFile ( $path );
  8295. die ();
  8296. }
  8297. }
  8298. $this->render ( "/admin/saeaStaffCollect", $data );
  8299. }
  8300. function lyt() {
  8301. Doo::loadModel ( "receiptDetail" );
  8302. $receiptDetail = new receiptDetail ();
  8303. $receiptCollectList = $receiptDetail->find ( array (
  8304. 'where' => 'status=1 ',
  8305. 'asArray' => true
  8306. ) );
  8307. foreach ( $receiptCollectList as $key => $value ) {
  8308. $receiptDetail = new receiptDetail ();
  8309. $receiptDetail->pastDate = $value ['date'];
  8310. $receiptDetail->update ( array (
  8311. 'where' => "rdid= '" . $value ['rdid'] . "'"
  8312. ) );
  8313. }
  8314. }
  8315. function staffCollectMonthDetail() {
  8316. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8317. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8318. if (! $year)
  8319. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8320. if (! $month)
  8321. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8322. Doo::loadModel ( 'staff' );
  8323. $staff = new staff ();
  8324. Doo::loadModel ( "receiptDetail" );
  8325. $receiptDetail = new receiptDetail ();
  8326. Doo::loadModel ( 'accountItem' );
  8327. $accountItem = new accountItem ();
  8328. Doo::loadModel ( 'statistics' );
  8329. $statistics = new statistics ();
  8330. Doo::loadModel ( 'L_category' );
  8331. $lCategory = new L_category ();
  8332. $staffList = $staff->find ( array (
  8333. 'where' => 'username!="admin"',
  8334. 'asArray' => true
  8335. ) );
  8336. $categoryList = $staff->find ( array (
  8337. 'select' => 'COUNT(*) as count,cid,category',
  8338. 'where' => 'username !="admin"',
  8339. 'groupby' => 'cid',
  8340. 'asArray' => true
  8341. ) );
  8342. $list = array ();
  8343. foreach ( $categoryList as $vlu ) {
  8344. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8345. $r1 = 0;
  8346. $r2 = 0;
  8347. $r3 = 0;
  8348. $r4 = 0;
  8349. $r5 = 0;
  8350. $r6 = 0;
  8351. $r7 = 0;
  8352. $r8 = 0;
  8353. $r9 = 0;
  8354. $r10 = 0;
  8355. $r11 = 0;
  8356. $r12 = 0;
  8357. $r13 = 0;
  8358. $r14 = 0;
  8359. $r15 = 0;
  8360. $c1 = 0;
  8361. $c2 = 0;
  8362. $c3 = 0;
  8363. $c4 = 0;
  8364. $c5 = 0;
  8365. $c6 = 0;
  8366. $p1 = 0;
  8367. $p2 = 0;
  8368. $p3 = 0;
  8369. $p4 = 0;
  8370. $p5 = 0;
  8371. $p6 = 0;
  8372. $p7 = 0;
  8373. $p8 = 0;
  8374. $p9 = 0;
  8375. $t1 = 0;
  8376. $t2 = 0;
  8377. $t3 = 0;
  8378. $t4 = 0;
  8379. $t5 = 0;
  8380. $s1 = 0;
  8381. $m1 = 0;
  8382. foreach ( $staffList as $value ) {
  8383. if ($vlu ['cid'] == $value ['cid']) {
  8384. // pastDate
  8385. $receiptCollectList = $receiptDetail->find ( array (
  8386. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8387. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8388. 'groupby' => 'item,Month(pastDate),itemCategory',
  8389. 'asArray' => true
  8390. ) );
  8391. // if ($value['sid']==42){
  8392. // print_r($receiptCollectList);die;
  8393. // }
  8394. if (! empty ( $receiptCollectList )) {
  8395. $receiptL = array (
  8396. '日常相关费用' => array (),
  8397. '差旅相关费用' => array (),
  8398. '培训班费用' => array (),
  8399. '其他' => array ()
  8400. );
  8401. $html = "";
  8402. $psum = 0;
  8403. $item = array (
  8404. '市内交通费',
  8405. '市内出租费',
  8406. '办事处房租',
  8407. '电话费',
  8408. '水费',
  8409. '电费',
  8410. '办公费用',
  8411. '邮寄费',
  8412. '其他费用',
  8413. '车辆费用',
  8414. '广告费',
  8415. '团队建设费',
  8416. '物业管理费',
  8417. '宽带费'
  8418. );
  8419. foreach ( $item as $va ) {
  8420. $falg = true;
  8421. foreach ( $receiptCollectList as $v ) {
  8422. if ($v ['itemCategory'] == '日常相关费用') {
  8423. if ($v ['item'] == $va) {
  8424. if ($va == '市内交通费')
  8425. $r1 += $v ['price'];
  8426. if ($va == '市内出租费')
  8427. $r2 += $v ['price'];
  8428. if ($va == '办事处房租')
  8429. $r3 += $v ['price'];
  8430. if ($va == '电话费')
  8431. $r4 += $v ['price'];
  8432. if ($va == '水费')
  8433. $r5 += $v ['price'];
  8434. if ($va == '电费')
  8435. $r6 += $v ['price'];
  8436. if ($va == '办公费用')
  8437. $r7 += $v ['price'];
  8438. if ($va == '邮寄费')
  8439. $r8 += $v ['price'];
  8440. if ($va == '其他费用')
  8441. $r9 += $v ['price'];
  8442. if ($va == '车辆费用')
  8443. $r10 += $v ['price'];
  8444. if ($va == '广告费')
  8445. $r11 += $v ['price'];
  8446. if ($va == '团队建设费')
  8447. $r13 += $v ['price'];
  8448. if ($va == '物业管理费')
  8449. $r14 += $v ['price'];
  8450. if ($va == '宽带费')
  8451. $r15 += $v ['price'];
  8452. $psum += $v ['price'];
  8453. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8454. $falg = false;
  8455. break;
  8456. }
  8457. }
  8458. }
  8459. if ($falg)
  8460. $html .= '<td class="taR">-</td>';
  8461. }
  8462. $r12 += $psum;
  8463. if (! empty ( $psum ))
  8464. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8465. else
  8466. $psum = '<td class="colGreen taR">-</td>';
  8467. $receiptL ['日常相关费用'] = $psum . $html;
  8468. /* ----------------------------------- */
  8469. $html = "";
  8470. $psum = 0;
  8471. $item = array (
  8472. '往来交通费',
  8473. '市内交通费',
  8474. '出差住宿费',
  8475. '出差补助',
  8476. '其他费用'
  8477. );
  8478. foreach ( $item as $va ) {
  8479. $falg = true;
  8480. foreach ( $receiptCollectList as $v ) {
  8481. if ($v ['itemCategory'] == '差旅相关费用') {
  8482. if ($v ['item'] == $va) {
  8483. if ($va == '往来交通费')
  8484. $c1 += $v ['price'];
  8485. if ($va == '市内交通费')
  8486. $c2 += $v ['price'];
  8487. if ($va == '出差住宿费')
  8488. $c3 += $v ['price'];
  8489. if ($va == '出差补助')
  8490. $c4 += $v ['price'];
  8491. if ($va == '其他费用')
  8492. $c5 += $v ['price'];
  8493. $psum += $v ['price'];
  8494. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8495. $falg = false;
  8496. break;
  8497. }
  8498. }
  8499. }
  8500. if ($falg)
  8501. $html .= '<td class="taR">-</td>';
  8502. }
  8503. $c6 += $psum;
  8504. if (! empty ( $psum ))
  8505. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8506. else
  8507. $psum = '<td class="colGreen taR">-</td>';
  8508. $receiptL ['差旅相关费用'] = $psum . $html;
  8509. /* ------------------------------------- */
  8510. $html = "";
  8511. $psum = 0;
  8512. $item = array (
  8513. '场租费',
  8514. '薪酬',
  8515. '住宿费',
  8516. '交通费',
  8517. '餐饮费',
  8518. '办公费',
  8519. '公关费',
  8520. '其他'
  8521. );
  8522. foreach ( $item as $va ) {
  8523. $falg = true;
  8524. foreach ( $receiptCollectList as $v ) {
  8525. if ($v ['itemCategory'] == '培训班费用') {
  8526. if ($v ['item'] == $va) {
  8527. if ($va == '场租费')
  8528. $p1 += $v ['price'];
  8529. if ($va == '薪酬')
  8530. $p2 += $v ['price'];
  8531. if ($va == '住宿费')
  8532. $p3 += $v ['price'];
  8533. if ($va == '交通费')
  8534. $p4 += $v ['price'];
  8535. if ($va == '餐饮费')
  8536. $p5 += $v ['price'];
  8537. if ($va == '办公费')
  8538. $p6 += $v ['price'];
  8539. if ($va == '公关费')
  8540. $p7 += $v ['price'];
  8541. if ($va == '其他')
  8542. $p8 += $v ['price'];
  8543. $psum += $v ['price'];
  8544. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8545. $falg = false;
  8546. break;
  8547. }
  8548. }
  8549. }
  8550. if ($falg)
  8551. $html .= '<td class="taR">-</td>';
  8552. }
  8553. $p9 += $psum;
  8554. if (! empty ( $psum ))
  8555. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8556. else
  8557. $psum = '<td class="colGreen taR">-</td>';
  8558. $receiptL ['培训班费用'] = $psum . $html;
  8559. /* ------------------------------------- */
  8560. $html = "";
  8561. $psum = 0;
  8562. $item = array (
  8563. '公关费',
  8564. '广告费',
  8565. '借款',
  8566. '可自加费用'
  8567. );
  8568. foreach ( $item as $va ) {
  8569. $falg = true;
  8570. foreach ( $receiptCollectList as $v ) {
  8571. if ($v ['itemCategory'] == '其他') {
  8572. // if ($value['sid']==42){
  8573. //
  8574. // echo var_dump($v['item']);
  8575. // echo var_dump($va);
  8576. // echo var_dump($v['item']==" ".$va);
  8577. // echo $v['item']."==".$va."/<br/>";
  8578. // //print_r( $receiptCollectList);//echo $va;
  8579. // }
  8580. if (trim ( $v ['item'] ) == $va) {
  8581. if ($va == '公关费')
  8582. $t1 += $v ['price'];
  8583. if ($va == '广告费') {
  8584. $t2 += $v ['price'];
  8585. }
  8586. if ($va == '借款')
  8587. $t3 += $v ['price'];
  8588. if ($va == '可自加费用')
  8589. $t4 += $v ['price'];
  8590. $psum += $v ['price'];
  8591. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8592. $falg = false;
  8593. break;
  8594. }
  8595. }
  8596. }
  8597. if ($falg)
  8598. $html .= '<td class="taR">-</td>';
  8599. }
  8600. $t5 += $psum;
  8601. if (! empty ( $psum ))
  8602. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8603. else
  8604. $psum = '<td class="colGreen taR">-</td>';
  8605. $receiptL ['其他'] = $psum . $html;
  8606. /* ------------------------------------- */
  8607. $html = "";
  8608. $psum = 0;
  8609. foreach ( $receiptCollectList as $v ) {
  8610. if ($v ['itemCategory'] == '报销金额调整') {
  8611. if (! empty ( $v ['price'] )) {
  8612. $psum += $v ['price'];
  8613. }
  8614. }
  8615. }
  8616. $s1 += $psum;
  8617. if (! empty ( $psum ))
  8618. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8619. else
  8620. $psum = '<td class="taR colOrange">-</td>';
  8621. $receiptL ['报销金额调整'] = $psum . $html;
  8622. } else {
  8623. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8624. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="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>';
  8626. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  8627. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8628. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8629. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8630. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8631. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  8632. }
  8633. $monthStaffPrice = $receiptDetail->find ( array (
  8634. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8635. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8636. 'groupby' => 'Month(pastDate)',
  8637. 'asArray' => true
  8638. ) );
  8639. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  8640. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  8641. $m1 += $monthStaffPrice [0] ['price'];
  8642. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  8643. } else
  8644. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  8645. $list [$value ['username']] = $receiptL;
  8646. }
  8647. }
  8648. $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>
  8649. <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>
  8650. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  8651. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  8652. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  8653. $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>
  8654. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  8655. $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>';
  8656. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  8657. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  8658. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  8659. }
  8660. $data ['list'] = $list;
  8661. $receiptCollectList = $receiptDetail->find ( array (
  8662. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8663. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8664. 'groupby' => 'item,Month(pastDate),itemCategory',
  8665. 'asArray' => true
  8666. ) );
  8667. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  8668. // statistics html
  8669. $stList = $statistics->getOne ( array (
  8670. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8671. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8672. 'groupby' => 'Month(date)',
  8673. 'asArray' => true
  8674. ) );
  8675. if (empty ( $stList ))
  8676. $stList = array (
  8677. 'rePrice' => 0,
  8678. 'agPrice' => 0
  8679. );
  8680. $data ['stList'] = array (
  8681. 'rePrice' => $stList ['rePrice'],
  8682. 'agPrice' => $stList ['agPrice'],
  8683. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8684. );
  8685. $monthHtml = "";
  8686. for($i = 1; $i <= 12; $i ++) {
  8687. if ($i == $month)
  8688. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8689. else
  8690. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8691. }
  8692. $data ['monthHtml'] = $monthHtml;
  8693. $data ['year'] = $year;
  8694. $data ['month'] = $month;
  8695. $data ['memu'] = "receipt";
  8696. $data ['staff'] = $this->staff;
  8697. $data ['receiptMemu'] = 'companyCategoryCollect';
  8698. $data ['verifyId'] = $this->verifyId;
  8699. $data ['executeId'] = $this->executeId;
  8700. $this->render ( "/admin/staffCollectMonthDetail", $data );
  8701. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  8702. }
  8703. function staffCollectMonthDetail2() {
  8704. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8705. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8706. if (! $year)
  8707. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8708. if (! $month)
  8709. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8710. Doo::loadModel ( 'staff' );
  8711. $staff = new staff ();
  8712. Doo::loadModel ( "receiptDetail" );
  8713. $receiptDetail = new receiptDetail ();
  8714. Doo::loadModel ( 'accountItem' );
  8715. $accountItem = new accountItem ();
  8716. Doo::loadModel ( 'statistics' );
  8717. $statistics = new statistics ();
  8718. Doo::loadModel ( 'L_category' );
  8719. $lCategory = new L_category ();
  8720. $staffList = $staff->find ( array (
  8721. 'where' => 'username!="admin"',
  8722. 'asArray' => true
  8723. ) );
  8724. $categoryList = $staff->find ( array (
  8725. 'select' => 'COUNT(*) as count,cid,category',
  8726. 'where' => 'username !="admin"',
  8727. 'groupby' => 'cid',
  8728. 'asArray' => true
  8729. ) );
  8730. $list = array ();
  8731. foreach ( $categoryList as $vlu ) {
  8732. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8733. $r1 = 0;
  8734. $r2 = 0;
  8735. $r3 = 0;
  8736. $r4 = 0;
  8737. $r5 = 0;
  8738. $r6 = 0;
  8739. $r7 = 0;
  8740. $r8 = 0;
  8741. $r9 = 0;
  8742. $r10 = 0;
  8743. $r11 = 0;
  8744. $r12 = 0;
  8745. $r13 = 0;
  8746. $r14 = 0;
  8747. $r15 = 0;
  8748. $c1 = 0;
  8749. $c2 = 0;
  8750. $c3 = 0;
  8751. $c4 = 0;
  8752. $c5 = 0;
  8753. $c6 = 0;
  8754. $p1 = 0;
  8755. $p2 = 0;
  8756. $p3 = 0;
  8757. $p4 = 0;
  8758. $p5 = 0;
  8759. $p6 = 0;
  8760. $p7 = 0;
  8761. $p8 = 0;
  8762. $p9 = 0;
  8763. $t1 = 0;
  8764. $t2 = 0;
  8765. $t3 = 0;
  8766. $t4 = 0;
  8767. $t5 = 0;
  8768. $s1 = 0;
  8769. $m1 = 0;
  8770. foreach ( $staffList as $value ) {
  8771. if ($vlu ['cid'] == $value ['cid']) {
  8772. $receiptCollectList = $receiptDetail->find ( array (
  8773. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  8774. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  8775. 'groupby' => 'item,Month(date),itemCategory',
  8776. 'asArray' => true
  8777. ) );
  8778. if (! empty ( $receiptCollectList )) {
  8779. $receiptL = array (
  8780. '日常相关费用' => array (),
  8781. '差旅相关费用' => array (),
  8782. '培训班费用' => array (),
  8783. '其他' => array ()
  8784. );
  8785. $html = "";
  8786. $psum = 0;
  8787. $item = array (
  8788. '市内交通费',
  8789. '市内出租费',
  8790. '办事处房租',
  8791. '电话费',
  8792. '水费',
  8793. '电费',
  8794. '办公费用',
  8795. '邮寄费',
  8796. '其他费用',
  8797. '车辆费用',
  8798. '广告费',
  8799. '团队建设费',
  8800. '物业管理费',
  8801. '宽带费'
  8802. );
  8803. foreach ( $item as $va ) {
  8804. $falg = true;
  8805. foreach ( $receiptCollectList as $v ) {
  8806. if ($v ['itemCategory'] == '日常相关费用') {
  8807. if ($v ['item'] == $va) {
  8808. if ($va == '市内交通费')
  8809. $r1 += $v ['price'];
  8810. if ($va == '市内出租费')
  8811. $r2 += $v ['price'];
  8812. if ($va == '办事处房租')
  8813. $r3 += $v ['price'];
  8814. if ($va == '电话费')
  8815. $r4 += $v ['price'];
  8816. if ($va == '水费')
  8817. $r5 += $v ['price'];
  8818. if ($va == '电费')
  8819. $r6 += $v ['price'];
  8820. if ($va == '办公费用')
  8821. $r7 += $v ['price'];
  8822. if ($va == '邮寄费')
  8823. $r8 += $v ['price'];
  8824. if ($va == '其他费用')
  8825. $r9 += $v ['price'];
  8826. if ($va == '车辆费用')
  8827. $r10 += $v ['price'];
  8828. if ($va == '广告费')
  8829. $r11 += $v ['price'];
  8830. if ($va == '团队建设费')
  8831. $r13 += $v ['price'];
  8832. if ($va == '物业管理费')
  8833. $r14 += $v ['price'];
  8834. if ($va == '宽带费')
  8835. $r15 += $v ['price'];
  8836. $psum += $v ['price'];
  8837. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8838. $falg = false;
  8839. break;
  8840. }
  8841. }
  8842. }
  8843. if ($falg)
  8844. $html .= '<td class="taR">-</td>';
  8845. }
  8846. $r12 += $psum;
  8847. if (! empty ( $psum ))
  8848. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8849. else
  8850. $psum = '<td class="colGreen taR">-</td>';
  8851. $receiptL ['日常相关费用'] = $psum . $html;
  8852. /* ----------------------------------- */
  8853. $html = "";
  8854. $psum = 0;
  8855. $item = array (
  8856. '往来交通费',
  8857. '市内交通费',
  8858. '出差住宿费',
  8859. '出差补助',
  8860. '其他费用'
  8861. );
  8862. foreach ( $item as $va ) {
  8863. $falg = true;
  8864. foreach ( $receiptCollectList as $v ) {
  8865. if ($v ['itemCategory'] == '差旅相关费用') {
  8866. if ($v ['item'] == $va) {
  8867. if ($va == '往来交通费')
  8868. $c1 += $v ['price'];
  8869. if ($va == '市内交通费')
  8870. $c2 += $v ['price'];
  8871. if ($va == '出差住宿费')
  8872. $c3 += $v ['price'];
  8873. if ($va == '出差补助')
  8874. $c4 += $v ['price'];
  8875. if ($va == '其他费用')
  8876. $c5 += $v ['price'];
  8877. $psum += $v ['price'];
  8878. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8879. $falg = false;
  8880. break;
  8881. }
  8882. }
  8883. }
  8884. if ($falg)
  8885. $html .= '<td class="taR">-</td>';
  8886. }
  8887. $c6 += $psum;
  8888. if (! empty ( $psum ))
  8889. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8890. else
  8891. $psum = '<td class="colGreen taR">-</td>';
  8892. $receiptL ['差旅相关费用'] = $psum . $html;
  8893. /* ------------------------------------- */
  8894. $html = "";
  8895. $psum = 0;
  8896. $item = array (
  8897. '场租费',
  8898. '薪酬',
  8899. '住宿费',
  8900. '交通费',
  8901. '餐饮费',
  8902. '办公费',
  8903. '公关费',
  8904. '其他'
  8905. );
  8906. foreach ( $item as $va ) {
  8907. $falg = true;
  8908. foreach ( $receiptCollectList as $v ) {
  8909. if ($v ['itemCategory'] == '培训班费用') {
  8910. if ($v ['item'] == $va) {
  8911. if ($va == '场租费')
  8912. $p1 += $v ['price'];
  8913. if ($va == '薪酬')
  8914. $p2 += $v ['price'];
  8915. if ($va == '住宿费')
  8916. $p3 += $v ['price'];
  8917. if ($va == '交通费')
  8918. $p4 += $v ['price'];
  8919. if ($va == '餐饮费')
  8920. $p5 += $v ['price'];
  8921. if ($va == '办公费')
  8922. $p6 += $v ['price'];
  8923. if ($va == '公关费')
  8924. $p7 += $v ['price'];
  8925. if ($va == '其他')
  8926. $p8 += $v ['price'];
  8927. $psum += $v ['price'];
  8928. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8929. $falg = false;
  8930. break;
  8931. }
  8932. }
  8933. }
  8934. if ($falg)
  8935. $html .= '<td class="taR">-</td>';
  8936. }
  8937. $p9 += $psum;
  8938. if (! empty ( $psum ))
  8939. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8940. else
  8941. $psum = '<td class="colGreen taR">-</td>';
  8942. $receiptL ['培训班费用'] = $psum . $html;
  8943. /* ------------------------------------- */
  8944. $html = "";
  8945. $psum = 0;
  8946. $item = array (
  8947. '公关费',
  8948. '广告费',
  8949. '借款',
  8950. '可自加费用'
  8951. );
  8952. foreach ( $item as $va ) {
  8953. $falg = true;
  8954. foreach ( $receiptCollectList as $v ) {
  8955. if ($v ['itemCategory'] == '其他') {
  8956. if ($v ['item'] == $va) {
  8957. if ($va == '公关费')
  8958. $t1 += $v ['price'];
  8959. if ($va == '广告费')
  8960. $t2 += $v ['price'];
  8961. if ($va == '借款')
  8962. $t3 += $v ['price'];
  8963. if ($va == '可自加费用')
  8964. $t4 += $v ['price'];
  8965. $psum += $v ['price'];
  8966. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8967. $falg = false;
  8968. break;
  8969. }
  8970. }
  8971. }
  8972. if ($falg)
  8973. $html .= '<td class="taR">-</td>';
  8974. }
  8975. $t5 += $psum;
  8976. if (! empty ( $psum ))
  8977. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8978. else
  8979. $psum = '<td class="colGreen taR">-</td>';
  8980. $receiptL ['其他'] = $psum . $html;
  8981. /* ------------------------------------- */
  8982. $html = "";
  8983. $psum = 0;
  8984. foreach ( $receiptCollectList as $v ) {
  8985. if ($v ['itemCategory'] == '报销金额调整') {
  8986. if (! empty ( $v ['price'] )) {
  8987. $psum += $v ['price'];
  8988. }
  8989. }
  8990. }
  8991. $s1 += $psum;
  8992. if (! empty ( $psum ))
  8993. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8994. else
  8995. $psum = '<td class="taR colOrange">-</td>';
  8996. $receiptL ['报销金额调整'] = $psum . $html;
  8997. } else {
  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><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>
  9001. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9002. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9003. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9004. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9005. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9006. }
  9007. $monthStaffPrice = $receiptDetail->find ( array (
  9008. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9009. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9010. 'asArray' => true
  9011. ) );
  9012. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  9013. $m1 += $monthStaffPrice [0] ['price'];
  9014. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9015. } else
  9016. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9017. $list [$value ['username']] = $receiptL;
  9018. }
  9019. }
  9020. $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>
  9021. <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>
  9022. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  9023. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  9024. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  9025. $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>
  9026. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  9027. $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>';
  9028. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  9029. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  9030. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  9031. }
  9032. $data ['list'] = $list;
  9033. $receiptCollectList = $receiptDetail->find ( array (
  9034. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9035. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9036. 'groupby' => 'item,Month(date),itemCategory',
  9037. 'asArray' => true
  9038. ) );
  9039. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9040. // statistics html
  9041. $stList = $statistics->getOne ( array (
  9042. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9043. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9044. 'groupby' => 'Month(date)',
  9045. 'asArray' => true
  9046. ) );
  9047. if (empty ( $stList ))
  9048. $stList = array (
  9049. 'rePrice' => 0,
  9050. 'agPrice' => 0
  9051. );
  9052. $data ['stList'] = array (
  9053. 'rePrice' => $stList ['rePrice'],
  9054. 'agPrice' => $stList ['agPrice'],
  9055. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9056. );
  9057. $monthHtml = "";
  9058. for($i = 1; $i <= 12; $i ++) {
  9059. if ($i == $month)
  9060. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9061. else
  9062. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9063. }
  9064. $data ['monthHtml'] = $monthHtml;
  9065. $data ['year'] = $year;
  9066. $data ['month'] = $month;
  9067. $data ['memu'] = "receipt";
  9068. $data ['staff'] = $this->staff;
  9069. $data ['receiptMemu'] = 'companyCategoryCollect';
  9070. $data ['verifyId'] = $this->verifyId;
  9071. $data ['executeId'] = $this->executeId;
  9072. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  9073. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9074. }
  9075. function companyMonthCollectDetail() {
  9076. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9077. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9078. if (! $year)
  9079. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9080. if (! $month)
  9081. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9082. Doo::loadModel ( 'staff' );
  9083. $staff = new staff ();
  9084. Doo::loadModel ( "receiptDetail" );
  9085. $receiptDetail = new receiptDetail ();
  9086. Doo::loadModel ( 'accountItem' );
  9087. $accountItem = new accountItem ();
  9088. Doo::loadModel ( 'statistics' );
  9089. $statistics = new statistics ();
  9090. Doo::loadModel ( 'L_category' );
  9091. $lCategory = new L_category ();
  9092. $staffList = $staff->find ( array (
  9093. 'where' => 'username!="admin"',
  9094. 'asArray' => true
  9095. ) );
  9096. $categoryList = $lCategory->find ( array (
  9097. 'asArray' => true
  9098. ) );
  9099. $list = array ();
  9100. foreach ( $categoryList as $value ) {
  9101. $receiptCollectList = $receiptDetail->find ( array (
  9102. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9103. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9104. 'groupby' => 'item,Month(pastDate),itemCategory',
  9105. 'asArray' => true
  9106. ) );
  9107. if (! empty ( $receiptCollectList )) {
  9108. $receiptL = array (
  9109. '日常相关费用' => array (),
  9110. '差旅相关费用' => array (),
  9111. '培训班费用' => array (),
  9112. '其他' => array ()
  9113. );
  9114. $html = "";
  9115. $psum = 0;
  9116. $item = array (
  9117. '市内交通费',
  9118. '市内出租费',
  9119. '办事处房租',
  9120. '电话费',
  9121. '水费',
  9122. '电费',
  9123. '办公费用',
  9124. '邮寄费',
  9125. '其他费用',
  9126. '车辆费用',
  9127. '广告费',
  9128. '团队建设费'
  9129. );
  9130. foreach ( $item as $va ) {
  9131. $falg = true;
  9132. foreach ( $receiptCollectList as $v ) {
  9133. if ($v ['itemCategory'] == '日常相关费用') {
  9134. if ($v ['item'] == $va) {
  9135. $psum += $v ['price'];
  9136. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9137. $falg = false;
  9138. break;
  9139. }
  9140. }
  9141. }
  9142. if ($falg)
  9143. $html .= '<td class="taR">-</td>';
  9144. }
  9145. if (! empty ( $psum ))
  9146. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9147. else
  9148. $psum = '<td class="colGreen taR">-</td>';
  9149. $receiptL ['日常相关费用'] = $psum . $html;
  9150. /* ----------------------------------- */
  9151. $html = "";
  9152. $psum = 0;
  9153. $item = array (
  9154. '往来交通费',
  9155. '市内交通费',
  9156. '出差住宿费',
  9157. '出差补助',
  9158. '其他费用'
  9159. );
  9160. foreach ( $item as $va ) {
  9161. $falg = true;
  9162. foreach ( $receiptCollectList as $v ) {
  9163. if ($v ['itemCategory'] == '差旅相关费用') {
  9164. if ($v ['item'] == $va) {
  9165. $psum += $v ['price'];
  9166. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9167. $falg = false;
  9168. break;
  9169. }
  9170. }
  9171. }
  9172. if ($falg)
  9173. $html .= '<td class="taR">-</td>';
  9174. }
  9175. if (! empty ( $psum ))
  9176. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9177. else
  9178. $psum = '<td class="colGreen taR">-</td>';
  9179. $receiptL ['差旅相关费用'] = $psum . $html;
  9180. /* ------------------------------------- */
  9181. $html = "";
  9182. $psum = 0;
  9183. $item = array (
  9184. '场租费',
  9185. '薪酬',
  9186. '住宿费',
  9187. '交通费',
  9188. '餐饮费',
  9189. '办公费',
  9190. '公关费',
  9191. '其他'
  9192. );
  9193. foreach ( $item as $va ) {
  9194. $falg = true;
  9195. foreach ( $receiptCollectList as $v ) {
  9196. if ($v ['itemCategory'] == '培训班费用') {
  9197. if ($v ['item'] == $va) {
  9198. $psum += $v ['price'];
  9199. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9200. $falg = false;
  9201. break;
  9202. }
  9203. }
  9204. }
  9205. if ($falg)
  9206. $html .= '<td class="taR">-</td>';
  9207. }
  9208. if (! empty ( $psum ))
  9209. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9210. else
  9211. $psum = '<td class="colGreen taR">-</td>';
  9212. $receiptL ['培训班费用'] = $psum . $html;
  9213. /* ------------------------------------- */
  9214. $html = "";
  9215. $psum = 0;
  9216. $item = array (
  9217. '公关费',
  9218. '广告费',
  9219. '借款',
  9220. '可自加费用'
  9221. );
  9222. foreach ( $item as $va ) {
  9223. $falg = true;
  9224. foreach ( $receiptCollectList as $v ) {
  9225. if ($v ['itemCategory'] == '其他') {
  9226. if ($v ['item'] == $va) {
  9227. $psum += $v ['price'];
  9228. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9229. $falg = false;
  9230. break;
  9231. }
  9232. }
  9233. }
  9234. if ($falg)
  9235. $html .= '<td class="taR">-</td>';
  9236. }
  9237. if (! empty ( $psum ))
  9238. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9239. else
  9240. $psum = '<td class="colGreen taR">-</td>';
  9241. $receiptL ['其他'] = $psum . $html;
  9242. /* ------------------------------------- */
  9243. $html = "";
  9244. $psum = 0;
  9245. foreach ( $receiptCollectList as $v ) {
  9246. if ($v ['itemCategory'] == '报销金额调整') {
  9247. if (! empty ( $v ['price'] ))
  9248. $psum += $v ['price'];
  9249. }
  9250. }
  9251. if (! empty ( $psum ))
  9252. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9253. else
  9254. $psum = '<td class="taR colOrange">-</td>';
  9255. $receiptL ['报销金额调整'] = $psum . $html;
  9256. } else {
  9257. $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>
  9258. <td class="taR">-</td><td class="taR">-</td><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>
  9260. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9261. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9262. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9263. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9264. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9265. }
  9266. $monthStaffPrice = $receiptDetail->find ( array (
  9267. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9268. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9269. 'asArray' => true
  9270. ) );
  9271. if (! empty ( $monthStaffPrice [0] ['price'] ))
  9272. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9273. else
  9274. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9275. $list [$value ['title']] = $receiptL;
  9276. }
  9277. $data ['list'] = $list;
  9278. $receiptCollectList = $receiptDetail->find ( array (
  9279. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9280. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9281. 'groupby' => 'item,Month(pastDate),itemCategory',
  9282. 'asArray' => true
  9283. ) );
  9284. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9285. // print_r($data['monthPriceHtml']);
  9286. // foreach ($data['monthPriceHtml'] as $value){
  9287. // echo $value;
  9288. // }
  9289. // die;
  9290. // statistics html
  9291. $stList = $statistics->getOne ( array (
  9292. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9293. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9294. 'groupby' => 'Month(date)',
  9295. 'asArray' => true
  9296. ) );
  9297. if (empty ( $stList ))
  9298. $stList = array (
  9299. 'rePrice' => 0,
  9300. 'agPrice' => 0
  9301. );
  9302. $data ['stList'] = array (
  9303. 'rePrice' => $stList ['rePrice'],
  9304. 'agPrice' => $stList ['agPrice'],
  9305. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9306. );
  9307. $monthHtml = "";
  9308. for($i = 1; $i <= 12; $i ++) {
  9309. if ($i == $month)
  9310. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9311. else
  9312. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9313. }
  9314. $data ['monthHtml'] = $monthHtml;
  9315. $data ['year'] = $year;
  9316. $data ['month'] = $month;
  9317. $data ['memu'] = "receipt";
  9318. $data ['staff'] = $this->staff;
  9319. $data ['receiptMemu'] = 'companyCategoryCollect';
  9320. $data ['verifyId'] = $this->verifyId;
  9321. $data ['executeId'] = $this->executeId;
  9322. $this->render ( "/admin/companyMonthCollectDetail", $data );
  9323. }
  9324. function staffCollectDetail() {
  9325. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9326. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  9327. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  9328. if (! $staffname) {
  9329. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  9330. $staffname = urldecode ( $staffname );
  9331. }
  9332. Doo::loadModel ( 'staff' );
  9333. $staff = new staff ();
  9334. Doo::loadModel ( "receiptDetail" );
  9335. $receiptDetail = new receiptDetail ();
  9336. Doo::loadModel ( 'accountItem' );
  9337. $accountItem = new accountItem ();
  9338. Doo::loadModel ( 'statistics' );
  9339. $statistics = new statistics ();
  9340. Doo::loadModel ( 'L_category' );
  9341. $lCategory = new L_category ();
  9342. $staffList = $staff->find ( array (
  9343. 'asArray' => true
  9344. ) );
  9345. $stHtml = '';
  9346. $stTitle = "";
  9347. $staffId = 0;
  9348. $cid = 0;
  9349. $ocid = 0;
  9350. foreach ( $staffList as $value ) {
  9351. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  9352. $stTitle = $value ['category'] . '-' . $value ['username'];
  9353. $staffId = $value ['sid'];
  9354. $cid = $value ['cid'];
  9355. $ocid = $value ['cid'];
  9356. if (! empty ( $value ['othercid'] ))
  9357. $cid = $value ['cid'] . ',' . $value ['othercid'];
  9358. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9359. } elseif ($value ['username'] != 'admin')
  9360. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9361. }
  9362. $data ['lCategoryHtml'] = $lCategory->find ( array (
  9363. 'where' => 'cid in(' . $cid . ')',
  9364. 'asArray' => true
  9365. ) );
  9366. if (empty ( $pcid ))
  9367. $pcid = $ocid;
  9368. $data ['ocid'] = $pcid;
  9369. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  9370. $this->showCache ( $path );
  9371. //
  9372. $receiptCollectList = $receiptDetail->find ( array (
  9373. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9374. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9375. 'groupby' => 'item,Month(pastDate),itemCategory',
  9376. 'asArray' => true
  9377. ) );
  9378. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  9379. // print_r($receiptCollectList);
  9380. $accountList = $accountItem->find ( array (
  9381. 'asArray' => true
  9382. ) );
  9383. // create CollectDetail HTML
  9384. $collectHtml = array ();
  9385. foreach ( $accountList as $key => $value ) {
  9386. $html = "";
  9387. $asum = 0;
  9388. for($i = 1; $i <= 12; $i ++) {
  9389. $falg = true;
  9390. foreach ( $receiptCollectList as $v ) {
  9391. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9392. if ($v ['item'] == '可自加费用') {
  9393. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  9394. }
  9395. $asum += $v ['price'];
  9396. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9397. $falg = false;
  9398. break;
  9399. }
  9400. }
  9401. if ($falg)
  9402. $html .= '<td class="taR">-</td>';
  9403. }
  9404. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9405. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9406. }
  9407. $data ['collectHtml'] = $collectHtml;
  9408. // print_r($collectHtml);
  9409. // create Adjustment price html
  9410. $receiptCollectList = $receiptDetail->find ( array (
  9411. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9412. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9413. 'groupby' => 'itemCategory,Month(pastDate)',
  9414. 'asArray' => true
  9415. ) );
  9416. $adjustment = array ();
  9417. $collectArray = array (
  9418. '日常相关费用' => array (),
  9419. '差旅相关费用' => array (),
  9420. '培训班费用' => array (),
  9421. '其他' => array ()
  9422. );
  9423. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9424. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9425. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9426. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9427. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9428. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9429. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9430. array_push ( $collectArray ['其他'], $collectHtml );
  9431. $data ['collectArray'] = $collectArray;
  9432. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9433. array_push ( $adjustment, $collectHtml );
  9434. $data ['adjustment'] = $adjustment;
  9435. // total price html
  9436. $collectHtml = "";
  9437. $total = 0;
  9438. for($i = 1; $i <= 12; $i ++) {
  9439. $sumPrice = 0;
  9440. foreach ( $receiptCollectList as $key => $value ) {
  9441. if ($value ['month'] == $i) {
  9442. $sumPrice += $value ['price'];
  9443. }
  9444. }
  9445. if ($sumPrice == 0)
  9446. $collectHtml .= '<td class="taR">-</td>';
  9447. else
  9448. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9449. $total += $sumPrice;
  9450. }
  9451. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9452. // statistics html
  9453. $stList = $statistics->statisticsByYear ( $year, $staffId );
  9454. if (empty ( $stList ))
  9455. $stList = array (
  9456. 'rePrice' => 0,
  9457. 'agPrice' => 0
  9458. );
  9459. $data ['stList'] = array (
  9460. 'rePrice' => $stList ['rePrice'],
  9461. 'agPrice' => $stList ['agPrice'],
  9462. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9463. );
  9464. $data ['totalPrice'] = $collectHtml;
  9465. $data ['totalYear'] = $total;
  9466. $data ['stHtml'] = $stHtml;
  9467. $data ['year'] = $year;
  9468. $data ['stTitle'] = $stTitle;
  9469. $data ['memu'] = "receipt";
  9470. $data ['staff'] = $this->staff;
  9471. $data ['receiptMemu'] = 'companyCategoryCollect';
  9472. $data ['verifyId'] = $this->verifyId;
  9473. $data ['executeId'] = $this->executeId;
  9474. if ($year < date ( "Y" )) {
  9475. Doo::loadModel ( 'receipt' );
  9476. $receipt = new receipt ();
  9477. $receiptList = $receipt->find ( array (
  9478. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  9479. 'asArray' => true
  9480. ) );
  9481. if (empty ( $receiptList )) { // generated files
  9482. ob_start ();
  9483. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9484. $this->cacheFile ( $path );
  9485. die ();
  9486. }
  9487. }
  9488. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9489. }
  9490. function BUGFLAG() {
  9491. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  9492. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  9493. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9494. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9495. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  9496. if (empty ( $status ))
  9497. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  9498. $page_size = 12;
  9499. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  9500. $vidList = array ();
  9501. $button = 0;
  9502. Doo::loadModel ( 'verify' );
  9503. $verify = new verify ();
  9504. Doo::loadModel ( 'receipt' );
  9505. $receipt = new receipt ();
  9506. Doo::loadModel ( 'staff' );
  9507. $staff = new staff ();
  9508. Doo::loadModel ( 'L_category' );
  9509. $Lcategory = new L_category ();
  9510. $dateCondition = " and Year(date) =" . $year;
  9511. if (! empty ( $month ))
  9512. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  9513. $categoryList = $Lcategory->find ( array (
  9514. 'asArray' => true
  9515. ) );
  9516. $staffList = $staff->find ( array (
  9517. 'where' => 'cid=' . $cid,
  9518. 'asArray' => true
  9519. ) );
  9520. $cateCondition = "";
  9521. $staffCondition = "";
  9522. $approvalCondition = "";
  9523. if (! empty ( $cid ))
  9524. $cateCondition = ' and cid=' . $cid;
  9525. if (! empty ( $sid )) {
  9526. $staffCondition = ' and staff=' . $sid;
  9527. $cateCondition = "";
  9528. }
  9529. $approvalCondition = " and status=" . $status;
  9530. if ($status == 2) {
  9531. // 查找角色审批人
  9532. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9533. }
  9534. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  9535. $approvalCondition = ' and status=2 ';
  9536. }
  9537. if ($status == 1) {
  9538. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  9539. }
  9540. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  9541. $pageinfo ['page'] = array (
  9542. 'previous' => ''
  9543. );
  9544. if ($status == 0) {
  9545. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  9546. $receiptList = $receipt->find ( array (
  9547. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  9548. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  9549. 'desc' => 'rid',
  9550. 'asArray' => true
  9551. ) );
  9552. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9553. } else
  9554. $receiptList = $receipt->find ( array (
  9555. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  9556. 'desc' => 'rid',
  9557. 'asArray' => true
  9558. ) );
  9559. $rLRes = $receipt->find ( array (
  9560. '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,
  9561. 'desc' => 'rid',
  9562. 'asArray' => true
  9563. ) );
  9564. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9565. // print_r($pageinfo);
  9566. $Locate = 0;
  9567. foreach ( $receiptList as $key => $value ) {
  9568. $receiptList [$key] ['Locate'] = $Locate;
  9569. $Locate ++;
  9570. $receiptList [$key] ['reviseDetail'] = array ();
  9571. if (! empty ( $value ['reviseDetail'] ))
  9572. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  9573. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  9574. $categoryDetil = $Lcategory->getOne ( array (
  9575. 'where' => 'cid=' . $value ['cid'],
  9576. 'asArray' => true
  9577. ) );
  9578. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  9579. $verifyList = $verify->getOne ( array (
  9580. 'where' => 'vid=' . $value ['verify'],
  9581. 'asArray' => true
  9582. ) );
  9583. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  9584. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  9585. foreach ( $verifyList as $k => $v ) {
  9586. // init verifyStaff
  9587. $verifyList [$k] ['date'] = "";
  9588. $verifyList [$k] ['opinion'] = "";
  9589. $verifyList [$k] ['status'] = "";
  9590. if (empty ( $verifyStaff )) {
  9591. $verifyList [$k] ['date'] = "";
  9592. $verifyList [$k] ['opinion'] = "";
  9593. if ($v [0] == $this->staff [0] ['sid']) {
  9594. $verifyList [$k] ['status'] = 4;
  9595. $button = 4;
  9596. }
  9597. } else {
  9598. $flag = true;
  9599. foreach ( $verifyStaff as $m => $u ) {
  9600. if ($v [0] == $m) {
  9601. $verifyList [$k] ['date'] = $u ['date'];
  9602. $verifyList [$k] ['opinion'] = $u ['opinion'];
  9603. $verifyList [$k] ['status'] = $u ['status'];
  9604. $flag = false;
  9605. break;
  9606. }
  9607. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  9608. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  9609. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  9610. }
  9611. if ($flag) { // 检测可编辑
  9612. if ($v [0] == $this->staff [0] ['sid']) {
  9613. $verifyList [$k] ['status'] = 4;
  9614. $button = 4;
  9615. }
  9616. }
  9617. }
  9618. }
  9619. $receiptList [$key] ['verifyList'] = $verifyList;
  9620. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  9621. 'where' => 'sid=' . $value ['staff'],
  9622. 'asArray' => true
  9623. ) );
  9624. $receiptList [$key] ['button'] = $button;
  9625. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  9626. }
  9627. // print_r($receiptList);die;
  9628. // $data['verifyDetail']=$verifyDetail;
  9629. $mothHtml = "";
  9630. for($i = 1; $i <= 12; $i ++) {
  9631. if ($month == $i)
  9632. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  9633. else
  9634. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  9635. }
  9636. $data ['mothHtml'] = $mothHtml;
  9637. $data ['page'] = $pageinfo;
  9638. $data ['receiptList'] = $receiptList;
  9639. $data ['receiptApprovalCount'] = count ( $rLRes );
  9640. $data ['status'] = $status;
  9641. $data ['year'] = $year;
  9642. $data ['categoryList'] = $categoryList;
  9643. $data ['staffList'] = $staffList;
  9644. $data ['cid'] = $cid;
  9645. $data ['sid'] = $sid;
  9646. // print_r($receiptList);
  9647. $data ['memu'] = "receipt";
  9648. $data ['staff'] = $this->staff;
  9649. $data ['receiptMemu'] = 'approvalExpenses';
  9650. $data ['verifyId'] = $this->verifyId;
  9651. $data ['executeId'] = $this->executeId;
  9652. $this->render ( "/admin/FALG", $data );
  9653. }
  9654. function ajaxGetReceiptOrder() {
  9655. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  9656. if (! empty ( $receiptOrder )) {
  9657. Doo::loadModel ( 'receipt' );
  9658. $receipt = new receipt ();
  9659. Doo::loadModel ( 'staff' );
  9660. $staff = new staff ();
  9661. $receiptInfo = $receipt->getOne ( array (
  9662. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  9663. 'asArray' => true
  9664. ) );
  9665. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  9666. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  9667. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  9668. </tbody></table><table class="table table table-bordered"><tbody>';
  9669. foreach ( $verifyStaff as $key => $value ) {
  9670. $staffInfo = $staff->getOne ( array (
  9671. 'select' => 'username',
  9672. 'where' => ' sid="' . $key . '"',
  9673. 'asArray' => true
  9674. ) );
  9675. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  9676. }
  9677. $html .= '</tbody></table></div></div>';
  9678. echo json_encode ( array (
  9679. 'status' => 1,
  9680. 'receiptHtml' => $html
  9681. ) );
  9682. die ();
  9683. }
  9684. echo json_encode ( array (
  9685. 'status' => 2,
  9686. 'receiptHtml' => ''
  9687. ) );
  9688. die ();
  9689. }
  9690. function _getMonthCollectDetail($receiptCollectList) {
  9691. if (! empty ( $receiptCollectList )) {
  9692. $receiptL = array (
  9693. '日常相关费用' => array (),
  9694. '差旅相关费用' => array (),
  9695. '培训班费用' => array (),
  9696. '其他' => array ()
  9697. );
  9698. $html = "";
  9699. $psum = 0;
  9700. $item = array (
  9701. '市内交通费',
  9702. '市内出租费',
  9703. '办事处房租',
  9704. '电话费',
  9705. '水费',
  9706. '电费',
  9707. '办公费用',
  9708. '邮寄费',
  9709. '其他费用',
  9710. '车辆费用',
  9711. '广告费',
  9712. '团队建设费',
  9713. '物业管理费',
  9714. '宽带费'
  9715. );
  9716. foreach ( $item as $value ) {
  9717. $falg = true;
  9718. foreach ( $receiptCollectList as $v ) {
  9719. if ($v ['itemCategory'] == '日常相关费用') {
  9720. if ($v ['item'] == $value) {
  9721. $psum += $v ['price'];
  9722. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9723. $falg = false;
  9724. break;
  9725. }
  9726. }
  9727. }
  9728. if ($falg)
  9729. $html .= '<td class="taR">-</td>';
  9730. }
  9731. if (! empty ( $psum ))
  9732. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9733. else
  9734. $psum = '<td class="colGreen taR">-</td>';
  9735. $receiptL ['日常相关费用'] = $psum . $html;
  9736. /* ----------------------------------- */
  9737. $html = "";
  9738. $psum = 0;
  9739. $item = array (
  9740. '往来交通费',
  9741. '市内交通费',
  9742. '出差住宿费',
  9743. '出差补助',
  9744. '其他费用'
  9745. );
  9746. foreach ( $item as $value ) {
  9747. $falg = true;
  9748. foreach ( $receiptCollectList as $v ) {
  9749. if ($v ['itemCategory'] == '差旅相关费用') {
  9750. if ($v ['item'] == $value) {
  9751. $psum += $v ['price'];
  9752. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9753. $falg = false;
  9754. break;
  9755. }
  9756. }
  9757. }
  9758. if ($falg)
  9759. $html .= '<td class="taR">-</td>';
  9760. }
  9761. if (! empty ( $psum ))
  9762. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9763. else
  9764. $psum = '<td class="colGreen taR">-</td>';
  9765. $receiptL ['差旅相关费用'] = $psum . $html;
  9766. /* ------------------------------------- */
  9767. $html = "";
  9768. $psum = 0;
  9769. $item = array (
  9770. '场租费',
  9771. '薪酬',
  9772. '住宿费',
  9773. '交通费',
  9774. '餐饮费',
  9775. '办公费',
  9776. '公关费',
  9777. '其他'
  9778. );
  9779. foreach ( $item as $value ) {
  9780. $falg = true;
  9781. foreach ( $receiptCollectList as $v ) {
  9782. if ($v ['itemCategory'] == '培训班费用') {
  9783. if ($v ['item'] == $value) {
  9784. $psum += $v ['price'];
  9785. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9786. $falg = false;
  9787. break;
  9788. }
  9789. }
  9790. }
  9791. if ($falg)
  9792. $html .= '<td class="taR">-</td>';
  9793. }
  9794. if (! empty ( $psum ))
  9795. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9796. else
  9797. $psum = '<td class="colGreen taR">-</td>';
  9798. $receiptL ['培训班费用'] = $psum . $html;
  9799. /* ------------------------------------- */
  9800. $html = "";
  9801. $psum = 0;
  9802. $item = array (
  9803. '公关费',
  9804. '广告费',
  9805. '借款',
  9806. '可自加费用'
  9807. );
  9808. foreach ( $item as $value ) {
  9809. $falg = true;
  9810. foreach ( $receiptCollectList as $v ) {
  9811. if ($v ['itemCategory'] == '其他') {
  9812. if ($v ['item'] == $value) {
  9813. $psum += $v ['price'];
  9814. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9815. $falg = false;
  9816. break;
  9817. }
  9818. }
  9819. }
  9820. if ($falg)
  9821. $html .= '<td class="taR">-</td>';
  9822. }
  9823. if (! empty ( $psum ))
  9824. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9825. else
  9826. $psum = '<td class="colGreen taR">-</td>';
  9827. $receiptL ['其他'] = $psum . $html;
  9828. /* ------------------------------------- */
  9829. $html = "";
  9830. $psum = 0;
  9831. foreach ( $receiptCollectList as $v ) {
  9832. if ($v ['itemCategory'] == '报销金额调整') {
  9833. if (! empty ( $v ['price'] ))
  9834. $psum += $v ['price'];
  9835. }
  9836. }
  9837. if (! empty ( $psum ))
  9838. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9839. else
  9840. $psum = '<td class="taR colOrange">-</td>';
  9841. $receiptL ['报销金额调整'] = $psum . $html;
  9842. } else {
  9843. $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>
  9844. <td class="taR">-</td><td class="taR">-</td><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>
  9846. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9847. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9848. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9849. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9850. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9851. }
  9852. return $receiptL;
  9853. }
  9854. function eMail() {
  9855. Doo::loadModel ( 'staff' );
  9856. $staff = new staff ();
  9857. Doo::loadModel ( 'receipt' );
  9858. $receipt = new receipt ();
  9859. Doo::loadModel ( 'L_category' );
  9860. $Lcategory = new L_category ();
  9861. Doo::loadModel ( "verify" );
  9862. $verify = new verify ();
  9863. $staffList = $staff->find ( array (
  9864. 'asArray' => true
  9865. ) );
  9866. foreach ( $staffList as $key => $value ) {
  9867. if ($value ['username'] != 'admin') {
  9868. // 提交人
  9869. $receiptList = $receipt->find ( array (
  9870. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  9871. 'asArray' => true
  9872. ) );
  9873. if (! empty ( $receiptList )) {
  9874. $html = '<br><div><style></style>
  9875. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  9876. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  9877. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9878. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  9879. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9880. <tbody><tr>
  9881. <td style="padding: 0 40px;" align="left">
  9882. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9883. </td></tr><tr>
  9884. <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>
  9885. </tr>
  9886. </tbody> </table></td> </tr> <tr><td>
  9887. <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">
  9888. <tbody> <tr><td>
  9889. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  9890. 以下报销单完成了审批,等着收款吧:</p>
  9891. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  9892. foreach ( $receiptList as $k => $v ) {
  9893. $category = $Lcategory->getOne ( array (
  9894. 'where' => 'cid=' . $v ['cid'],
  9895. 'asArray' => true
  9896. ) );
  9897. $html .= '
  9898. <tr>
  9899. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  9900. <td align="left">
  9901. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  9902. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  9903. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  9904. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  9905. </tr>';
  9906. }
  9907. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  9908. <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>
  9909. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  9910. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  9911. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  9912. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9913. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9914. $receipt = new receipt ();
  9915. $receipt->notice = 1;
  9916. $receipt->update ( array (
  9917. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  9918. ) );
  9919. }
  9920. }
  9921. // 审批人
  9922. $verifyList = $verify->find ( array (
  9923. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  9924. 'asArray' => true
  9925. ) );
  9926. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  9927. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  9928. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9929. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  9930. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9931. <tbody><tr><td style="padding: 0 40px;" align="left">
  9932. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9933. </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>
  9934. </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">
  9935. <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>
  9936. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  9937. foreach ( $verifyList as $k => $v ) {
  9938. $receiptList = $receipt->find ( array (
  9939. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  9940. 'asArray' => true
  9941. ) );
  9942. foreach ( $receiptList as $r => $l ) {
  9943. $category = $Lcategory->getOne ( array (
  9944. 'where' => 'cid=' . $l ['cid'],
  9945. 'asArray' => true
  9946. ) );
  9947. $staffDetile = $staff->getOne ( array (
  9948. 'where' => 'sid=' . $l ['staff'],
  9949. 'asArray' => true
  9950. ) );
  9951. $html .= '
  9952. <tr>
  9953. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  9954. <td align="left">
  9955. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  9956. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  9957. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  9958. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  9959. </tr>';
  9960. }
  9961. }
  9962. $html .= '
  9963. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  9964. <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>
  9965. </tr></tbody></table></td></tr></tbody></table></div><br>';
  9966. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  9967. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  9968. // $receipt=new receipt();
  9969. // $receipt->notice=1;
  9970. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  9971. }
  9972. }
  9973. }
  9974. }
  9975. function setWXMsg($rid, $type) {
  9976. Doo::loadModel ( "receipt" );
  9977. $receipt = new receipt ();
  9978. $receiptDetail = $receipt->getOne ( array (
  9979. 'where' => 'rid=' . $rid,
  9980. 'asArray' => true
  9981. ) );
  9982. if (! empty ( $receiptDetail )) {
  9983. Doo::loadModel ( 'staff' );
  9984. $staff = new staff ();
  9985. $staffmsg = $staff->getOne ( array (
  9986. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  9987. 'asArray' => TRUE
  9988. ) );
  9989. if (! empty ( $staffmsg ['wxid'] )) {
  9990. require_once (SITE_PATH . '/protected/class/client.php');
  9991. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  9992. $user = $staffmsg ['wxid'];
  9993. $receiptName = '';
  9994. $msg = '';
  9995. switch ($receiptDetail ['Rtype']) {
  9996. case 0 :
  9997. $receiptName = '报销';
  9998. break;
  9999. case 1 :
  10000. $receiptName = '借款';
  10001. break;
  10002. case 2 :
  10003. $receiptName = '对公汇款';
  10004. break;
  10005. }
  10006. switch ($type) {
  10007. case 1 :
  10008. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  10009. break;
  10010. case 2 :
  10011. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  10012. break;
  10013. case 3 :
  10014. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  10015. break;
  10016. }
  10017. $result = $client->SendMsg ( $user, $msg, 'text' );
  10018. }
  10019. }
  10020. }
  10021. // Email发送函数
  10022. function SMail($toemail, $subject, $contents) {
  10023. Doo::loadClass ( 'class.phpmailer' );
  10024. $mail = new PHPMailer ();
  10025. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  10026. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  10027. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  10028. $mail->Password = "cDO1GjtY1seH"; // 密码
  10029. $mail->CharSet = "UTF8";
  10030. $mail->SMTPAuth = true;
  10031. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  10032. $mail->Mailer = "smtp";
  10033. $mail->Port = 25;
  10034. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  10035. $mail->MsgHTML ( $contents );
  10036. $mail->AddAddress ( $toemail );
  10037. $mail->CharSet = "UTF-8";
  10038. return $mail->Send ();
  10039. }
  10040. function swfupload() {
  10041. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  10042. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  10043. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  10044. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  10045. header ( "HTTP/1.1 500 Internal Server Error" );
  10046. echo "POST exceeded maximum allowed size.";
  10047. exit ( 0 );
  10048. }
  10049. // Settings
  10050. $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)
  10051. $upload_name = "Filedata";
  10052. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  10053. $extension_whitelist = array (
  10054. "doc",
  10055. "txt",
  10056. "jpg",
  10057. "gif",
  10058. "png"
  10059. ); // Allowed file extensions
  10060. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  10061. // Other variables
  10062. $MAX_FILENAME_LENGTH = 260;
  10063. $file_name = "";
  10064. $file_extension = "";
  10065. $uploadErrors = array (
  10066. 0 => "文件上传成功",
  10067. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  10068. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  10069. 3 => "上传的文件仅为部分文件",
  10070. 4 => "没有文件上传",
  10071. 6 => "缺少临时文件夹"
  10072. );
  10073. $nk = time ();
  10074. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  10075. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  10076. echo "文件无法保存.";
  10077. exit ( 0 );
  10078. }
  10079. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  10080. echo json_encode ( array (
  10081. 'filename' => $file_name,
  10082. 'id' => $nk
  10083. ) );
  10084. exit ( 0 );
  10085. }
  10086. function _GetFileEXT($filename) {
  10087. $pics = explode ( '.', $filename );
  10088. $num = count ( $pics );
  10089. return $pics [$num - 1];
  10090. }
  10091. /**
  10092. * 获取get或者POST值
  10093. * @param string $name 属性名称
  10094. * @return fixed 值
  10095. */
  10096. function get_args($name) {
  10097. if (isset ( $_GET [$name] )) {
  10098. if (is_array ( $_GET [$name] ))
  10099. return $_GET [$name];
  10100. else
  10101. return addslashes ( $_GET [$name] );
  10102. } elseif (isset ( $_POST [$name] )) {
  10103. if (is_array ( $_POST [$name] ))
  10104. return $_POST [$name];
  10105. else
  10106. return addslashes ( $_POST [$name] );
  10107. } else
  10108. return false;
  10109. }
  10110. function num_to_rmb($num) {
  10111. $c1 = "零壹贰叁肆伍陆柒捌玖";
  10112. $c2 = "分角元拾佰仟万拾佰仟亿";
  10113. // 精确到分后面就不要了,所以只留两个小数位
  10114. $num = round ( $num, 2 );
  10115. // 将数字转化为整数
  10116. $num = $num * 100;
  10117. if (strlen ( $num ) > 10) {
  10118. return "金额太大,请检查";
  10119. }
  10120. $i = 0;
  10121. $c = "";
  10122. while ( 1 ) {
  10123. if ($i == 0) {
  10124. // 获取最后一位数字
  10125. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  10126. } else {
  10127. $n = $num % 10;
  10128. }
  10129. // 每次将最后一位数字转化为中文
  10130. $p1 = substr ( $c1, 3 * $n, 3 );
  10131. $p2 = substr ( $c2, 3 * $i, 3 );
  10132. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  10133. $c = $p1 . $p2 . $c;
  10134. } else {
  10135. $c = $p1 . $c;
  10136. }
  10137. $i = $i + 1;
  10138. // 去掉数字最后一位了
  10139. $num = $num / 10;
  10140. $num = ( int ) $num;
  10141. // 结束循环
  10142. if ($num == 0) {
  10143. break;
  10144. }
  10145. }
  10146. $j = 0;
  10147. $slen = strlen ( $c );
  10148. while ( $j < $slen ) {
  10149. // utf8一个汉字相当3个字符
  10150. $m = substr ( $c, $j, 6 );
  10151. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  10152. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  10153. $left = substr ( $c, 0, $j );
  10154. $right = substr ( $c, $j + 3 );
  10155. $c = $left . $right;
  10156. $j = $j - 3;
  10157. $slen = $slen - 3;
  10158. }
  10159. $j = $j + 3;
  10160. }
  10161. // 这个是为了去掉类似23.0中最后一个“零”字
  10162. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  10163. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  10164. }
  10165. // 将处理的汉字加上“整”
  10166. if (empty ( $c )) {
  10167. return "零元整";
  10168. } else {
  10169. return $c . "整";
  10170. }
  10171. }
  10172. /**
  10173. * 获得分页数据
  10174. * @param unknown_type $table
  10175. * @param unknown_type $condition
  10176. * @param unknown_type $on_page
  10177. * @param unknown_type $page_size
  10178. */
  10179. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  10180. $page_c = "";
  10181. $page ['previous'] = $this->get_previous ( $on_page );
  10182. $page ['on_page'] = $on_page;
  10183. $total_count = $this->get_table_count ( $table, $condition );
  10184. $total = intval ( $total_count / $page_size );
  10185. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  10186. $page ['total_data'] = $total_count;
  10187. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  10188. $i = 1;
  10189. $page_max = 1;
  10190. $page_width = 3;
  10191. if ($on_page >= $page_width) {
  10192. $page_max = intval ( $on_page / $page_width ) + 1;
  10193. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  10194. }
  10195. for(; $i <= $page ['total_page']; $i ++) {
  10196. if ($i == $on_page)
  10197. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  10198. else
  10199. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  10200. if ($i == ($page_width * $page_max))
  10201. break;
  10202. }
  10203. $page ['page'] = $page_c;
  10204. $page ['lower'] = (-- $on_page) * $page_size;
  10205. return $page;
  10206. }
  10207. /**
  10208. * 获取总页数
  10209. * @param unknown_type $table
  10210. * @param unknown_type $condition
  10211. */
  10212. public function get_table_count($table = "", $condition = "") {
  10213. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10214. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10215. // echo $sql;die;
  10216. $query = Doo::db ()->query ( $sql );
  10217. $result = $query->fetch ();
  10218. return $result ['count'];
  10219. }
  10220. /**
  10221. * 获取上一页
  10222. * @param unknown_type $on_page
  10223. */
  10224. function get_previous($on_page = 1) {
  10225. return $on_page != 0 ? $on_page - 1 : $on_page;
  10226. }
  10227. }
  10228. ?>