ReceiptController.php 386 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class ReceiptController extends DooController {
  6. public $staff;
  7. public $verifyId;
  8. public $executeId;
  9. // public static $NEW2 = 0;
  10. public $AGENCY = "日常相关费用";
  11. public $TRAVEL = "差旅相关费用";
  12. public $TRAIN = "培训班费用";
  13. public $OTHER = "其他";
  14. private $MYREVEIPTCACHEPATH = "protected/cache/myReceipt/";
  15. private $PERSONALCOLLECTCACHEPATH = "protected/cache/personalCollect/";
  16. private $CATEGORYCOLLECTPATH = "protected/cache/categoryCollect/";
  17. private $STAFFCOLLECTPATH = "protected/cache/staffCollect/";
  18. private function showCache($path) {
  19. if (file_exists ( $path )) {
  20. echo "<!DOCTYPE html>";
  21. include $path;
  22. die ();
  23. }
  24. }
  25. private function cacheFile($path) {
  26. $content = ob_get_contents ();
  27. $fp = fopen ( $path, "w" );
  28. fwrite ( $fp, $content );
  29. fclose ( $fp );
  30. }
  31. private function collectHtml($receiptCollectList = array(), $itemCategory = "日常相关费用", $classType = "b") {
  32. $collectHtml = "";
  33. $sumPrice = 0.00;
  34. for($i = 1; $i <= 12; $i ++) {
  35. $falg = true;
  36. foreach ( $receiptCollectList as $key => $value ) {
  37. if ($value ['itemCategory'] == $itemCategory && $value ['month'] == $i) {
  38. $sumPrice += $value ['price'];
  39. if ($classType == "b") {
  40. $collectHtml .= '<td class="colGreen taR">¥' . $value ['price'] . '</td>';
  41. $falg = false;
  42. break;
  43. } else {
  44. $collectHtml .= '<td class="taR">¥' . $value ['price'] . '</td>';
  45. $falg = false;
  46. break;
  47. }
  48. }
  49. }
  50. if ($falg)
  51. $collectHtml .= '<td class="taR">-</td>';
  52. }
  53. $collectHtml .= '<td class="taR colGreen">¥' . $sumPrice . '</td>';
  54. return $collectHtml;
  55. }
  56. function __construct() {
  57. if (isset ( $_COOKIE ["staff"] )) {
  58. if (! empty ( $_COOKIE ["staff"] )) {
  59. Doo::loadModel ( 'staff' );
  60. Doo::loadModel ( 'verify' );
  61. $verify = new verify ();
  62. $staff = new staff ();
  63. Doo::loadModel ( "execute" );
  64. $execute = new execute ();
  65. $verifyList = $verify->find ( array (
  66. 'select' => 'staff',
  67. 'asArray' => true
  68. ) );
  69. $list = array ();
  70. // 判断角色的审批权限
  71. foreach ( $verifyList as $key => $value ) {
  72. $ver = json_decode ( $value ['staff'] );
  73. foreach ( $ver as $k => $v ) {
  74. if ($v [1] == 'ROLE') {
  75. $roleList = json_decode ( $v [3] );
  76. foreach ( $roleList as $t => $g ) {
  77. $gList = explode ( "_", $g );
  78. array_push ( $list, $gList [0] );
  79. // print_r($list);
  80. }
  81. } else
  82. array_push ( $list, $v [0] );
  83. }
  84. }
  85. // 判断执行人的审批权限
  86. $executeList = $execute->find ( array (
  87. 'select' => 'staff',
  88. 'asArray' => true
  89. ) );
  90. $list2 = array ();
  91. foreach ( $executeList as $key => $value ) {
  92. $ver = json_decode ( $value ['staff'] );
  93. foreach ( $ver as $k => $v ) {
  94. array_push ( $list2, $v [0] );
  95. }
  96. }
  97. $eidList = file_get_contents ( "protected/config/execute/execute.ini" );
  98. $eidList = array_filter ( explode ( ",", $eidList ) );
  99. $this->executeId = array_merge ( $list2, $eidList );
  100. $this->verifyId = $list;
  101. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  102. return "/";
  103. }
  104. }
  105. Doo::loadCore ( 'uri/DooUriRouter' );
  106. $router = new DooUriRouter ();
  107. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  108. if ($routeRs ['1'] != "login") {
  109. header ( 'Content-Type:text/html;charset=utf-8' );
  110. @header ( "Location: /login" );
  111. }
  112. }
  113. function saeaBorad() {
  114. Doo::loadModel ( 'receipt' );
  115. Doo::loadModel ( 'verify' );
  116. $verify = new verify ();
  117. $receipt = new receipt ();
  118. Doo::loadModel ( 'L_category' );
  119. $lCategory = new L_category ();
  120. Doo::loadModel ( "role" );
  121. $role = new role ();
  122. Doo::loadModel ( "receiptLog" );
  123. $receiptLog = new receiptLog ();
  124. Doo::loadClass ( 'XDeode' );
  125. $XDeode = new XDeode ( 7 );
  126. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  127. $receiptDetail = $receipt->find ( array (
  128. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  129. 'desc' => 'rid',
  130. 'asArray' => true
  131. ) );
  132. foreach ( $receiptDetail as $key => $value ) {
  133. $receiptDetail [$key]['ridKey']=$XDeode->encode ( $value['rid'] );
  134. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  135. $veList = $verify->getOne ( array (
  136. 'where' => 'vid=' . $value ['verify'],
  137. 'asArray' => true
  138. ) );
  139. $v = json_decode ( $veList ['staff'] );
  140. array_push ( $v [0], $veList ['description'] );
  141. foreach ( $v as $n => $m ) {
  142. if ($m ['1'] == 'ROLE') {
  143. $roleInfo = $role->getOne ( array (
  144. 'where' => 'rid=' . $m [0],
  145. 'asArray' => true
  146. ) );
  147. $v [$n] [1] = $roleInfo ['name'];
  148. }
  149. }
  150. $receiptDetail [$key] ['staff'] = $v;
  151. $category = $lCategory->getOne ( array (
  152. 'where' => 'cid=' . $value ['cid'],
  153. 'asArray' => true
  154. ) );
  155. $receiptDetail [$key] ['category'] = $category ['title'];
  156. }
  157. // print_r($receiptLogList);
  158. $data ['receiptLogList'] = $receiptLogList;
  159. $data ['receiptDetail'] = $receiptDetail;
  160. $data ['memu'] = "receipt";
  161. $data ['staff'] = $this->staff;
  162. $data ['receiptMemu'] = 'saeaBorad';
  163. $data ['verifyId'] = $this->verifyId;
  164. $data ['executeId'] = $this->executeId;
  165. $this->render ( "/admin/saeaBorad", $data );
  166. }
  167. function remitAdd() {
  168. Doo::loadModel ( 'accountItem' );
  169. Doo::loadModel ( 'verify' );
  170. Doo::loadModel ( 'receipt' );
  171. Doo::loadModel ( 'L_category' );
  172. $lCategory = new L_category ();
  173. $receipt = new receipt ();
  174. $verify = new verify ();
  175. $accountItem = new accountItem ();
  176. Doo::loadModel ( "role" );
  177. $role = new role ();
  178. $acItem = $accountItem->find ( array (
  179. 'asArray' => true
  180. ) );
  181. $veList = $verify->find ( array (
  182. 'asArray' => true
  183. ) );
  184. foreach ( $veList as $key => $value ) {
  185. $v = json_decode ( $value ['staff'] );
  186. $list = array ();
  187. foreach ( $v as $n => $m ) {
  188. if ($m ['1'] == 'ROLE') {
  189. $roleInfo = $role->getOne ( array (
  190. 'where' => 'rid=' . $m [0],
  191. 'asArray' => true
  192. ) );
  193. $v [$n] [1] = $roleInfo ['name'];
  194. array_push ( $list, $roleInfo ['name'] );
  195. } else {
  196. array_push ( $list, $v [$n] [1] );
  197. }
  198. }
  199. $veList [$key] ['staff'] = implode ( '>', $list );
  200. }
  201. $data ['category'] = $lCategory->find ( array (
  202. 'asArray' => true
  203. ) );
  204. $data ['veList'] = $veList;
  205. $data ['acItem'] = $acItem;
  206. $data ['memu'] = "receipt";
  207. $data ['staff'] = $this->staff;
  208. $data ['receiptMemu'] = 'saeaBorad';
  209. $data ['verifyId'] = $this->verifyId;
  210. $data ['executeId'] = $this->executeId;
  211. $this->render ( "/admin/remitAdd", $data );
  212. }
  213. function remitAddDo() {
  214. $agency = $this->get_args ( 'agency' );
  215. $travel = $this->get_args ( 'travel' );
  216. $train = $this->get_args ( 'train' );
  217. $other = $this->get_args ( 'other' );
  218. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  219. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  220. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  221. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  222. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  223. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  224. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  225. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  226. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  227. // print_r($agency);die;
  228. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  229. if ($remittanceBankType==1&&empty($coupletNumber)){
  230. header ( 'Content-Type:text/html;charset=utf-8' );
  231. die ( '请填写联行号' );
  232. }
  233. Doo::loadModel ( 'receipt' );
  234. Doo::loadModel ( 'receiptDetail' );
  235. Doo::loadModel ( 'accountItem' );
  236. $accountItem = new accountItem ();
  237. $receipt = new receipt ();
  238. Doo::loadModel ( 'enclosur' );
  239. Doo::loadModel ( 'execute' );
  240. $execute = new execute ();
  241. $executeDetail = $execute->getOne ( array (
  242. 'where' => 'mold="对公汇款执行人"',
  243. 'asArray' => true
  244. ) );
  245. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  246. $aItem = $accountItem->find ( array (
  247. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  248. 'asArray' => true
  249. ) );
  250. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  251. $ag = $tr = $ta = $ot = 0;
  252. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  253. foreach ( $aItem as $key => $value ) {
  254. if ($value ['category'] == $this->AGENCY) {
  255. if (isset ( $agency [$ag] )) {
  256. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  257. array_push ( $accountJson [$this->AGENCY], array (
  258. 'aid' => $value ['aid'],
  259. 'name' => $value ['name'],
  260. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  261. ) );
  262. $sum += $agency [$ag];
  263. $agencySum += $agency [$ag];
  264. }
  265. }
  266. $ag ++;
  267. }
  268. }
  269. $accountJson ['cSum'] = array (
  270. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  271. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  272. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  273. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  274. );
  275. // 报销单
  276. $receipt->accountItem = json_encode ( $accountJson );
  277. $receipt->staff = $this->staff [0] ['sid'];
  278. $receipt->sum = number_format ( $sum, 2, '.', '' );
  279. $receipt->date = date ( "Y-m-d" );
  280. $receipt->cid = $cid;
  281. $receipt->status = 5;
  282. $receipt->Rtype = 2;
  283. // 修改审批流程加入角色
  284. $receipt->verify = $verify;
  285. $receipt->executeCopy = $executeDetail ['staff'];
  286. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  287. $receipt->explanation = $explanation;
  288. $receipt->remittanceName = $remittanceName;
  289. $receipt->bankName = $bankName;
  290. $receipt->bankNumber = $bankNumber;
  291. $receipt->remittanceBankType = $remittanceBankType;
  292. if ($remittanceBankType==1)
  293. $receipt->coupletNumber = $coupletNumber;
  294. $rid = $receipt->insert ();
  295. // 附件
  296. if (! empty ( $enclosurName )) {
  297. $enclosurArray = explode ( '-', $enclosurName );
  298. foreach ( $enclosurArray as $value ) {
  299. $enclosur = new enclosur ();
  300. $enclosur->name = $value;
  301. $enclosur->rid = $rid;
  302. $enclosur->insert ();
  303. }
  304. // print_r($enclosurArray);die;
  305. }
  306. // 报销详情
  307. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  308. $receiptDetail = new receiptDetail ();
  309. $receiptDetail->staff = $this->staff [0] ['sid'];
  310. $receiptDetail->item = $value ['name'];
  311. $receiptDetail->itemCategory = $this->AGENCY;
  312. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  313. $receiptDetail->date = date ( "Y-m-d" );
  314. $receiptDetail->cid = $cid;
  315. $receiptDetail->rid = $rid;
  316. $receiptDetail->status = 4;
  317. $receiptDetail->insert ();
  318. }
  319. return "/saeaBorad";
  320. } else
  321. die ( 'illegal request' );
  322. }
  323. function remitEdit() {
  324. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  325. Doo::loadClass ( 'XDeode' );
  326. $XDeode = new XDeode ( 7 );
  327. $rid = $XDeode->decode ( $ridKey );
  328. if (! is_numeric ( $rid ))
  329. die ( 'illegal request' );
  330. Doo::loadModel ( 'accountItem' );
  331. Doo::loadModel ( 'verify' );
  332. Doo::loadModel ( 'receipt' );
  333. $receipt = new receipt ();
  334. $verify = new verify ();
  335. $accountItem = new accountItem ();
  336. Doo::loadModel ( 'L_category' );
  337. $lCategory = new L_category ();
  338. Doo::loadModel ( "role" );
  339. $role = new role ();
  340. Doo::loadModel ( 'enclosur' );
  341. $enclosur = new enclosur ();
  342. $receiptDetail = $receipt->getOne ( array (
  343. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  344. 'asArray' => true
  345. ) );
  346. if (empty ( $receiptDetail ))
  347. return "/saeaCreate";
  348. $enclosurList=$enclosur->getEnclosurByRid($receiptDetail['rid']);
  349. $acItem = $accountItem->find ( array (
  350. 'asArray' => true
  351. ) );
  352. $veList = $verify->find ( array (
  353. 'asArray' => true
  354. ) );
  355. foreach ( $veList as $key => $value ) {
  356. $v = json_decode ( $value ['staff'] );
  357. $list = array ();
  358. foreach ( $v as $n => $m ) {
  359. if ($m ['1'] == 'ROLE') {
  360. $roleInfo = $role->getOne ( array (
  361. 'where' => 'rid=' . $m [0],
  362. 'asArray' => true
  363. ) );
  364. $v [$n] [1] = $roleInfo ['name'];
  365. array_push ( $list, $roleInfo ['name'] );
  366. } else {
  367. array_push ( $list, $v [$n] [1] );
  368. }
  369. }
  370. $veList [$key] ['staff'] = implode ( '>', $list );
  371. }
  372. // 配置编辑信息
  373. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  374. foreach ( $acItem as $key => $value ) {
  375. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  376. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  377. $acItem [$key] ['price'] = $v ['price'];
  378. }
  379. }
  380. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  381. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  382. $acItem [$key] ['price'] = $v ['price'];
  383. }
  384. }
  385. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  386. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  387. $acItem [$key] ['price'] = $v ['price'];
  388. }
  389. }
  390. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  391. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  392. $acItem [$key] ['price'] = $v ['price'];
  393. }
  394. }
  395. }
  396. $data ['category'] = $lCategory->find ( array (
  397. 'asArray' => true
  398. ) );
  399. $data ['enclosurList'] =$enclosurList;
  400. $data ['cSum'] = $accountItemList ['cSum'];
  401. $data ['sum'] = $receiptDetail ['sum'];
  402. $data ['receiptDetail'] = $receiptDetail;
  403. $data ['veList'] = $veList;
  404. $data ['acItem'] = $acItem;
  405. $data ['memu'] = "receipt";
  406. $data ['staff'] = $this->staff;
  407. $data ['receiptMemu'] = 'saeaBorad';
  408. $data ['verify'] = $receiptDetail ['verify'];
  409. $data ['verifyId'] = $this->verifyId;
  410. $data ['executeId'] = $this->executeId;
  411. $data ['rid'] = $rid;
  412. $data ['ridKey'] =$ridKey;
  413. $this->render ( "/admin/remitEdit", $data );
  414. }
  415. function remitEdiDo() {
  416. $agency = $this->get_args ( 'agency' );
  417. $travel = $this->get_args ( 'travel' );
  418. $train = $this->get_args ( 'train' );
  419. $other = $this->get_args ( 'other' );
  420. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  421. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  422. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  423. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  424. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  425. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  426. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  427. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  428. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  429. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  430. Doo::loadClass ( 'XDeode' );
  431. $XDeode = new XDeode ( 7 );
  432. $rid = $XDeode->decode ( $ridKey );
  433. if (! empty ( $rid )&&! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  434. if ($remittanceBankType==1&&empty($coupletNumber)){
  435. header ( 'Content-Type:text/html;charset=utf-8' );
  436. die ( '请填写联行号' );
  437. }
  438. Doo::loadModel ( 'receipt' );
  439. Doo::loadModel ( 'receiptDetail' );
  440. Doo::loadModel ( 'accountItem' );
  441. $accountItem = new accountItem ();
  442. $receipt = new receipt ();
  443. Doo::loadModel ( 'enclosur' );
  444. $enclosur = new enclosur ();
  445. Doo::loadModel ( 'execute' );
  446. $execute = new execute ();
  447. $executeDetail = $execute->getOne ( array (
  448. 'where' => 'mold="对公汇款执行人"',
  449. 'asArray' => true
  450. ) );
  451. $receiptDetail = $receipt->getOne ( array (
  452. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  453. 'asArray' => true
  454. ) );
  455. if (empty ( $receiptDetail ))
  456. return "/saeaBorad";
  457. $aItem = $accountItem->find ( array (
  458. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  459. 'asArray' => true
  460. ) );
  461. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  462. $ag = $tr = $ta = $ot = 0;
  463. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  464. foreach ( $aItem as $key => $value ) {
  465. if ($value ['category'] == $this->AGENCY) {
  466. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  467. array_push ( $accountJson [$this->AGENCY], array (
  468. 'aid' => $value ['aid'],
  469. 'name' => $value ['name'],
  470. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  471. ) );
  472. $sum += $agency [$ag];
  473. $agencySum += $agency [$ag];
  474. }
  475. $ag ++;
  476. }
  477. }
  478. $accountJson ['cSum'] = array (
  479. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  480. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  481. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  482. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  483. );
  484. // 报销单
  485. $rid = $receipt->rid = $receiptDetail ['rid'];
  486. $receipt->accountItem = json_encode ( $accountJson );
  487. $receipt->staff = $this->staff [0] ['sid'];
  488. $receipt->sum = number_format ( $sum, 2, '.', '' );
  489. $receipt->date = date ( "Y-m-d" );
  490. $receipt->cid = $cid;
  491. if ($receiptDetail ['Rtype'] == 1)
  492. $receipt->status = 7;
  493. else
  494. $receipt->status = 5;
  495. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  496. $receipt->verify = $verify;
  497. $receipt->executeCopy = $executeDetail ['staff'];
  498. $receipt->explanation = $explanation;
  499. $receipt->remittanceName = $remittanceName;
  500. $receipt->bankName = $bankName;
  501. $receipt->bankNumber = $bankNumber;
  502. $receipt->remittanceBankType = $remittanceBankType;
  503. if ($remittanceBankType==1)
  504. $receipt->coupletNumber = $coupletNumber;
  505. $receipt->update ();
  506. $receiptDetail = new receiptDetail ();
  507. $receiptDetail->delete ( array (
  508. 'where' => 'rid=' . $rid
  509. ) );
  510. // 报销详情
  511. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  512. $receiptDetail = new receiptDetail ();
  513. $receiptDetail->staff = $this->staff [0] ['sid'];
  514. $receiptDetail->item = $value ['name'];
  515. $receiptDetail->itemCategory = $this->AGENCY;
  516. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  517. $receiptDetail->date = date ( "Y-m-d" );
  518. $receiptDetail->cid = $cid;
  519. $receiptDetail->rid = $rid;
  520. $receiptDetail->status = 4;
  521. $receiptDetail->insert ();
  522. }
  523. // 附件
  524. if (! empty ( $enclosurName )) {
  525. $enclosurArray = explode ( '-', $enclosurName );
  526. foreach ( $enclosurArray as $value ) {
  527. $enclosur = new enclosur ();
  528. $enclosur->name = $value;
  529. $enclosur->rid = $rid;
  530. $enclosur->insert ();
  531. }
  532. }
  533. }
  534. return "/saeaBorad";
  535. }
  536. function remitApproval() {
  537. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  538. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  539. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  540. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  541. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  542. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  543. if (empty ( $status ))
  544. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  545. $vidList = array ();
  546. $button = 0;
  547. Doo::loadModel ( 'verify' );
  548. Doo::loadModel ( 'receipt' );
  549. Doo::loadModel ( 'staff' );
  550. $staff = new staff ();
  551. $receipt = new receipt ();
  552. $verify = new verify ();
  553. Doo::loadModel ( 'L_category' );
  554. $Lcategory = new L_category ();
  555. Doo::loadModel ( 'enclosur' );
  556. $enclosur = new enclosur ();
  557. // user verify ID
  558. $verifyDetail = $verify->find ( array (
  559. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  560. 'asArray' => true
  561. ) );
  562. foreach ( $verifyDetail as $key => $value ) {
  563. array_push ( $vidList, $value ['vid'] );
  564. }
  565. $vid = implode ( ",", $vidList );
  566. if (empty ( $verifyDetail ))
  567. $vid = 0;
  568. $categoryList = $Lcategory->find ( array (
  569. 'asArray' => true
  570. ) );
  571. $staffList = $staff->find ( array (
  572. 'where' => 'cid=' . $cid,
  573. 'asArray' => true
  574. ) );
  575. $ap = "";
  576. if ($status == 4) {
  577. $ap = 4;
  578. $status = 2;
  579. }
  580. // get Receipt By verifyID status 2
  581. $receiptList = $receipt->find ( array (
  582. 'where' => 'rid =' . $rid . ' and status=2',
  583. 'desc' => 'rid',
  584. 'asArray' => true
  585. ) );
  586. if (empty ( $receiptList )) {
  587. die ( 'illegal request' );
  588. }
  589. $Locate = 0;
  590. $roleId = 0;
  591. if ($ap == 4)
  592. $status = 4;
  593. foreach ( $receiptList as $key => $value ) {
  594. $receiptList [$key] ['Locate'] = $Locate;
  595. $Locate ++;
  596. $receiptList [$key] ['reviseDetail'] = array ();
  597. if (! empty ( $value ['reviseDetail'] ))
  598. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  599. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  600. $categoryDetil = $Lcategory->getOne ( array (
  601. 'where' => 'cid=' . $value ['cid'],
  602. 'asArray' => true
  603. ) );
  604. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  605. // 检测编辑状态
  606. $verifyList = $verify->getOne ( array (
  607. 'where' => 'vid=' . $value ['verify'],
  608. 'asArray' => true
  609. ) );
  610. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  611. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  612. Doo::loadModel ( 'role' );
  613. $role = new role ();
  614. // print_r($verifyList);
  615. $flag = true;
  616. $roleKey = 0;
  617. $endStaffArray = array ();
  618. $roleArrayCopy = array ();
  619. foreach ( $verifyList as $k => $v ) {
  620. // init verifyStaff
  621. if ($v [1] == 'ROLE') {
  622. if (! empty ( $verifyStaff )) {
  623. $endStaffArray = end ( $verifyStaff );
  624. if ($v [0] == $endStaffArray ['nextStaff']) {
  625. $roleId = $v [0];
  626. }
  627. }
  628. $roleVerify = json_decode ( $v [3], true );
  629. $roleKey = $k;
  630. $roleArray = array ();
  631. $rolename = $role->getOne ( array (
  632. 'where' => 'rid=' . $v [0],
  633. 'asArray' => true
  634. ) );
  635. foreach ( $roleVerify as $o => $p ) {
  636. $staffID = explode ( '_', $p );
  637. $staffInfo = $staff->getOne ( array (
  638. 'where' => 'sid=' . $staffID [0],
  639. 'asArray' => true
  640. ) );
  641. // print_r($staffID);
  642. $exp = array (
  643. 0 => $staffInfo ['sid'],
  644. 1 => $staffID [1],
  645. 2 => $staffInfo ['avatar'],
  646. 'date' => '',
  647. 'date' => '',
  648. 'opinion' => '',
  649. 'status' => '',
  650. 'rolename' => $rolename ['name']
  651. );
  652. array_push ( $roleArray, $exp );
  653. }
  654. $roleArrayCopy [$v [0]] = $roleArray;
  655. // $verifyList[$k]['roleArray']=$roleArray;
  656. }
  657. // print_r($roleArray);
  658. $verifyList [$k] ['date'] = "";
  659. $verifyList [$k] ['opinion'] = "";
  660. $verifyList [$k] ['status'] = "";
  661. if (empty ( $verifyStaff )) {
  662. $verifyList [$k] ['date'] = "";
  663. $verifyList [$k] ['opinion'] = "";
  664. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  665. $verifyList [$k] ['status'] = 4;
  666. $button = 4;
  667. $flag = false;
  668. }
  669. } else {
  670. foreach ( $verifyStaff as $m => $u ) {
  671. if ($v [0] == $m) {
  672. $verifyList [$k] ['date'] = $u ['date'];
  673. $verifyList [$k] ['opinion'] = $u ['opinion'];
  674. $verifyList [$k] ['status'] = $u ['status'];
  675. $flag = false;
  676. break;
  677. }
  678. }
  679. $endStaffArray = end ( $verifyStaff );
  680. if (isset ( $endStaffArray ['ROLE'] )) {
  681. } else {
  682. $endKey = key ( $verifyStaff );
  683. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  684. $button = 4;
  685. $verifyList [$k] ['status'] = 4;
  686. }
  687. }
  688. }
  689. }
  690. $rolename ['name'] = '';
  691. if (! empty ( $roleId )) {
  692. Doo::loadModel ( 'role' );
  693. $role = new role ();
  694. $rolename = $role->getOne ( array (
  695. 'where' => 'rid=' . $roleId,
  696. 'asArray' => true
  697. ) );
  698. }
  699. if (! empty ( $verifyStaff ))
  700. $endStaffArray = end ( $verifyStaff );
  701. $KOP = false;
  702. foreach ( $roleArrayCopy as $P => $A ) {
  703. foreach ( $A as $MKI => $AVL ) {
  704. if (! empty ( $verifyStaff )) {
  705. // &&$rolename['rid']==$endStaffArray['nextStaff']
  706. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  707. $button = 4;
  708. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  709. }
  710. foreach ( $verifyStaff as $m => $u ) {
  711. $AVLFK = $AVL [0] . '_R';
  712. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  713. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  714. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  715. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  716. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  717. break;
  718. }
  719. }
  720. } else {
  721. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  722. $button = 4;
  723. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  724. }
  725. }
  726. // $roleArray[$MKI]['rolename']=$rolename['name'];
  727. $KOP = true;
  728. }
  729. }
  730. foreach ( $roleArrayCopy as $k => $v ) {
  731. foreach ( $verifyList as $m => $n ) {
  732. if ($n [0] == $k) {
  733. array_splice ( $verifyList, $m, 1, $v );
  734. }
  735. }
  736. }
  737. $receiptList [$key] ['verifyList'] = $verifyList;
  738. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  739. 'where' => 'sid=' . $value ['staff'],
  740. 'asArray' => true
  741. ) );
  742. $receiptList [$key] ['button'] = $button;
  743. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  744. }
  745. $mothHtml = "";
  746. for($i = 1; $i <= 12; $i ++) {
  747. if ($month == $i)
  748. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  749. else
  750. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  751. }
  752. // 获取审批日志
  753. Doo::loadModel ( 'receiptLog' );
  754. $receiptLog = new receiptLog ();
  755. $rlList = array ();
  756. $rlInfo = $receiptLog->getOne ( array (
  757. 'where' => 'rid=' . $rid . ' and status=4',
  758. 'asArray' => true
  759. ) );
  760. $tijdate = $receiptLog->getOne ( array (
  761. 'where' => 'rid=' . $rid . ' and status=2',
  762. 'asc' => 'rlid',
  763. 'asArray' => true
  764. ) );
  765. if (! empty ( $rlInfo )) {
  766. $rlList = $receiptLog->find ( array (
  767. 'where' => 'rid=' . $rid,
  768. 'asc' => 'rlid',
  769. 'asArray' => true
  770. ) );
  771. }
  772. $receiptList [0] ['rlList'] = $rlList;
  773. $enclosurList = $enclosur->find ( array (
  774. 'where' => 'rid=' . $rid,
  775. 'asArray' => true
  776. ) );
  777. $enclosurHtml = '';
  778. foreach ( $enclosurList as $value ) {
  779. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  780. }
  781. // print_r($receiptList);
  782. $data ['enclosurHtml'] = $enclosurHtml;
  783. $data ['rolename'] = $rolename ['name'];
  784. $data ['datetij'] = $tijdate ['date'];
  785. $data ['mothHtml'] = $mothHtml;
  786. $data ['rid'] = $rid;
  787. $data ['receiptList'] = $receiptList;
  788. $data ['receiptApprovalCount'] = count ( $receiptList );
  789. $data ['status'] = $status;
  790. $data ['year'] = $year;
  791. $data ['categoryList'] = $categoryList;
  792. $data ['staffList'] = $staffList;
  793. $data ['cid'] = $cid;
  794. $data ['sid'] = $sid;
  795. $data ['ap'] = $ap;
  796. $data ['memu'] = "receipt";
  797. $data ['staff'] = $this->staff;
  798. $data ['receiptMemu'] = 'approvalExpenses';
  799. $data ['verifyId'] = $this->verifyId;
  800. $data ['executeId'] = $this->executeId;
  801. $this->render ( "/admin/remitApproval", $data );
  802. }
  803. function saeaLoanAdd() {
  804. Doo::loadModel ( 'verify' );
  805. $verify = new verify ();
  806. Doo::loadModel ( "role" );
  807. $role = new role ();
  808. Doo::loadModel ( 'L_category' );
  809. $lCategory = new L_category ();
  810. $veList = $verify->find ( array (
  811. 'asArray' => true
  812. ) );
  813. foreach ( $veList as $key => $value ) {
  814. $v = json_decode ( $value ['staff'] );
  815. $list = array ();
  816. foreach ( $v as $n => $m ) {
  817. if ($m ['1'] == 'ROLE') {
  818. $roleInfo = $role->getOne ( array (
  819. 'where' => 'rid=' . $m [0],
  820. 'asArray' => true
  821. ) );
  822. $v [$n] [1] = $roleInfo ['name'];
  823. array_push ( $list, $roleInfo ['name'] );
  824. } else {
  825. array_push ( $list, $v [$n] [1] );
  826. }
  827. }
  828. $veList [$key] ['staff'] = implode ( '>', $list );
  829. }
  830. $data ['category'] = $lCategory->find ( array (
  831. 'asArray' => true
  832. ) );
  833. $data ['veList'] = $veList;
  834. $data ['memu'] = "receipt";
  835. $data ['staff'] = $this->staff;
  836. $data ['receiptMemu'] = 'saeaBorad';
  837. $data ['verifyId'] = $this->verifyId;
  838. $data ['executeId'] = $this->executeId;
  839. $this->render ( "/admin/saeaLoanAdd", $data );
  840. }
  841. function saeaLoanAddDo() {
  842. $agency = $this->get_args ( 'agency' );
  843. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  844. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  845. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  846. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  847. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  848. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  849. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  850. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  851. // die;
  852. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  853. if ($remittanceBankType==1&&empty($coupletNumber)){
  854. header ( 'Content-Type:text/html;charset=utf-8' );
  855. die ( '请填写联行号' );
  856. }
  857. Doo::loadModel ( 'receipt' );
  858. Doo::loadModel ( 'receiptDetail' );
  859. Doo::loadModel ( 'accountItem' );
  860. $accountItem = new accountItem ();
  861. $receipt = new receipt ();
  862. Doo::loadModel ( 'loanReceipt' );
  863. $loanReceipt = new loanReceipt ();
  864. Doo::loadModel ( 'execute' );
  865. $execute = new execute ();
  866. Doo::loadModel ( 'enclosur' );
  867. $executeDetail = $execute->getOne ( array (
  868. 'where' => 'mold="借款执行人"',
  869. 'asArray' => true
  870. ) );
  871. $aItem = $accountItem->find ( array (
  872. 'asArray' => true
  873. ) );
  874. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  875. $ag = $tr = $ta = $ot = 0;
  876. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  877. array_push ( $accountJson ['借款费用'], array (
  878. 'aid' => 0,
  879. 'name' => '申请金额',
  880. 'price' => number_format ( $agency, 2, '.', '' )
  881. ) );
  882. $sum += $agency;
  883. $agencySum += $agency;
  884. $accountJson ['cSum'] = array (
  885. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  886. 'agencySum' => number_format ( 0, 2, '.', '' ),
  887. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  888. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  889. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  890. );
  891. // 借款数据备份
  892. $loanReceipt->loanItem = json_encode ( $accountJson );
  893. $loanReceipt->staff = $this->staff [0] ['sid'];
  894. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  895. $loanReceipt->date = date ( "Y-m-d" );
  896. $loanReceipt->cid = $cid;
  897. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  898. $loanReceipt->status = 5;
  899. $loanReceipt->Rtype = 1;
  900. $loanReceipt->verify = $verify;
  901. $receipt->receiptOrder = $receipt->receiptOrder;
  902. $loanReceipt->explanation = $explanation;
  903. $loanRid = $loanReceipt->insert ();
  904. // 报销单
  905. $receipt->loanItem = json_encode ( $accountJson );
  906. $receipt->staff = $this->staff [0] ['sid'];
  907. $receipt->sum = number_format ( $sum, 2, '.', '' );
  908. $receipt->date = date ( "Y-m-d" );
  909. $receipt->cid = $cid;
  910. // 特殊状态
  911. $receipt->status = 5;
  912. $receipt->Rtype = 1;
  913. $receipt->loanRid = $loanRid;
  914. // 修改审批流程加入角色
  915. $receipt->verify = $verify;
  916. $receipt->executeCopy = $executeDetail ['staff'];
  917. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  918. $receipt->explanation = $explanation;
  919. $receipt->remittanceName = $remittanceName;
  920. $receipt->bankName = $bankName;
  921. $receipt->bankNumber = $bankNumber;
  922. $receipt->remittanceBankType = $remittanceBankType;
  923. if ($remittanceBankType==1)
  924. $receipt->coupletNumber = $coupletNumber;
  925. $rid = $receipt->insert ();
  926. return "/saeaBorad";
  927. } else
  928. die ( 'illegal request' );
  929. }
  930. function saeaLoanEdi() {
  931. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  932. Doo::loadClass ( 'XDeode' );
  933. $XDeode = new XDeode ( 7 );
  934. $rid = $XDeode->decode ( $ridKey );
  935. if (! is_numeric ( $rid ))
  936. die ( 'illegal request' );
  937. Doo::loadModel ( 'verify' );
  938. $verify = new verify ();
  939. Doo::loadModel ( "role" );
  940. $role = new role ();
  941. Doo::loadModel ( 'L_category' );
  942. $lCategory = new L_category ();
  943. Doo::loadModel ( 'receipt' );
  944. $receipt = new receipt ();
  945. $receiptInfo = $receipt->getOne ( array (
  946. 'where' => 'rid=' . $rid,
  947. 'asArray' => true
  948. ) );
  949. $veList = $verify->find ( array (
  950. 'asArray' => true
  951. ) );
  952. foreach ( $veList as $key => $value ) {
  953. $v = json_decode ( $value ['staff'] );
  954. $list = array ();
  955. foreach ( $v as $n => $m ) {
  956. if ($m ['1'] == 'ROLE') {
  957. $roleInfo = $role->getOne ( array (
  958. 'where' => 'rid=' . $m [0],
  959. 'asArray' => true
  960. ) );
  961. $v [$n] [1] = $roleInfo ['name'];
  962. array_push ( $list, $roleInfo ['name'] );
  963. } else {
  964. array_push ( $list, $v [$n] [1] );
  965. }
  966. }
  967. $veList [$key] ['staff'] = implode ( '>', $list );
  968. }
  969. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  970. //print_r($receiptInfo);
  971. $data ['receiptInfo'] = $receiptInfo;
  972. $data ['category'] = $lCategory->find ( array (
  973. 'asArray' => true
  974. ) );
  975. $data ['veList'] = $veList;
  976. $data['ridKey']=$ridKey;
  977. $data ['memu'] = "receipt";
  978. $data ['staff'] = $this->staff;
  979. $data ['receiptMemu'] = 'saeaBorad';
  980. $data ['verifyId'] = $this->verifyId;
  981. $data ['executeId'] = $this->executeId;
  982. $this->render ( "/admin/saeaLoanEdi", $data );
  983. }
  984. function saeaLoanEdiDo() {
  985. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  986. $agency = $this->get_args ( 'agency' );
  987. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  988. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  989. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  990. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  991. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  992. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  993. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  994. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  995. // die;
  996. Doo::loadClass ( 'XDeode' );
  997. $XDeode = new XDeode ( 7 );
  998. $rid = $XDeode->decode ( $ridKey );
  999. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )&& ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1000. if ($remittanceBankType==1&&empty($coupletNumber)){
  1001. header ( 'Content-Type:text/html;charset=utf-8' );
  1002. die ( '请填写联行号' );
  1003. }
  1004. Doo::loadModel ( 'receipt' );
  1005. Doo::loadModel ( 'receiptDetail' );
  1006. Doo::loadModel ( 'accountItem' );
  1007. $accountItem = new accountItem ();
  1008. $receipt = new receipt ();
  1009. Doo::loadModel ( 'loanReceipt' );
  1010. $loanReceipt = new loanReceipt ();
  1011. Doo::loadModel ( 'enclosur' );
  1012. Doo::loadModel ( 'execute' );
  1013. $execute = new execute ();
  1014. $executeDetail = $execute->getOne ( array (
  1015. 'where' => 'mold="借款执行人"',
  1016. 'asArray' => true
  1017. ) );
  1018. $receiptDetail = $receipt->getOne ( array (
  1019. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  1020. 'asArray' => true
  1021. ) );
  1022. if (empty ( $receiptDetail ))
  1023. die ( '参数错误' );
  1024. $aItem = $accountItem->find ( array (
  1025. 'asArray' => true
  1026. ) );
  1027. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1028. $ag = $tr = $ta = $ot = 0;
  1029. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1030. array_push ( $accountJson ['借款费用'], array (
  1031. 'aid' => 0,
  1032. 'name' => '申请金额',
  1033. 'price' => number_format ( $agency, 2, '.', '' )
  1034. ) );
  1035. $sum += $agency;
  1036. $agencySum += $agency;
  1037. $accountJson ['cSum'] = array (
  1038. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1039. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1040. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1041. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1042. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1043. );
  1044. // 报销单
  1045. $receipt->loanItem = json_encode ( $accountJson );
  1046. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1047. $receipt->cid = $cid;
  1048. // 特殊状态
  1049. // 修改审批流程加入角色
  1050. if ($receiptDetail ['status'] != 4)
  1051. $receipt->verify = $verify;
  1052. $receipt->explanation = $explanation;
  1053. $receipt->remittanceName = $remittanceName;
  1054. $receipt->bankName = $bankName;
  1055. $receipt->bankNumber = $bankNumber;
  1056. $receipt->remittanceBankType = $remittanceBankType;
  1057. if ($remittanceBankType==1)
  1058. $receipt->coupletNumber = $coupletNumber;
  1059. $receipt->update ( array (
  1060. 'where' => 'rid=' . $rid
  1061. ) );
  1062. // 借款数据更新
  1063. $loanReceipt->loanItem = json_encode ( $accountJson );
  1064. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1065. $loanReceipt->cid = $cid;
  1066. if ($receiptDetail ['status'] != 4)
  1067. $loanReceipt->verify = $verify;
  1068. $loanReceipt->explanation = $explanation;
  1069. $receipt->executeCopy = $executeDetail ['staff'];
  1070. $loanReceipt->update ( array (
  1071. 'where' => 'rid=' . $receiptDetail ['loanRid']
  1072. ) );
  1073. }
  1074. return "/saeaBorad";
  1075. }
  1076. function saeaLoanReceiptAdd() {
  1077. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1078. Doo::loadModel ( 'receipt' );
  1079. $receipt = new receipt ();
  1080. Doo::loadModel ( 'loanReceipt' );
  1081. $loanReceipt = new loanReceipt ();
  1082. Doo::loadModel ( 'L_category' );
  1083. $Lcategory = new L_category ();
  1084. Doo::loadModel ( 'verify' );
  1085. Doo::loadModel ( 'statistics' );
  1086. $statistics = new statistics ();
  1087. $verify = new verify ();
  1088. Doo::loadModel ( 'staff' );
  1089. $staff = new staff ();
  1090. $receiptDetail = $receipt->getOne ( array (
  1091. 'where' => 'rid=' . $rid,
  1092. 'desc' => 'rid',
  1093. 'asArray' => true
  1094. ) );
  1095. $receiptList = $loanReceipt->find ( array (
  1096. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1097. 'desc' => 'rid',
  1098. 'asArray' => true
  1099. ) );
  1100. $Locate = 0;
  1101. $roleId = 0;
  1102. $button = 0;
  1103. foreach ( $receiptList as $key => $value ) {
  1104. $receiptList [$key] ['Locate'] = $Locate;
  1105. $Locate ++;
  1106. $receiptList [$key] ['reviseDetail'] = array ();
  1107. if (! empty ( $value ['reviseDetail'] ))
  1108. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1109. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1110. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1111. $categoryDetil = $Lcategory->getOne ( array (
  1112. 'where' => 'cid=' . $value ['cid'],
  1113. 'asArray' => true
  1114. ) );
  1115. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1116. // 检测编辑状态
  1117. $verifyList = $verify->getOne ( array (
  1118. 'where' => 'vid=' . $value ['verify'],
  1119. 'asArray' => true
  1120. ) );
  1121. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1122. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1123. Doo::loadModel ( 'role' );
  1124. $role = new role ();
  1125. $flag = true;
  1126. $roleKey = 0;
  1127. $endStaffArray = array ();
  1128. $roleArrayCopy = array ();
  1129. foreach ( $verifyList as $k => $v ) {
  1130. // init verifyStaff
  1131. if ($v [1] == 'ROLE') {
  1132. if (! empty ( $verifyStaff )) {
  1133. $endStaffArray = end ( $verifyStaff );
  1134. // if ($v[0]==$endStaffArray['nextStaff']){
  1135. // $roleId=$v[0];
  1136. // }
  1137. }
  1138. $roleVerify = json_decode ( $v [3], true );
  1139. $roleKey = $k;
  1140. $roleArray = array ();
  1141. $rolename = $role->getOne ( array (
  1142. 'where' => 'rid=' . $v [0],
  1143. 'asArray' => true
  1144. ) );
  1145. foreach ( $roleVerify as $o => $p ) {
  1146. $staffID = explode ( '_', $p );
  1147. $staffInfo = $staff->getOne ( array (
  1148. 'where' => 'sid=' . $staffID [0],
  1149. 'asArray' => true
  1150. ) );
  1151. // print_r($staffID);
  1152. $exp = array (
  1153. 0 => $staffInfo ['sid'],
  1154. 1 => $staffID [1],
  1155. 2 => $staffInfo ['avatar'],
  1156. 'date' => '',
  1157. 'date' => '',
  1158. 'opinion' => '',
  1159. 'status' => '',
  1160. 'rolename' => $rolename ['name']
  1161. );
  1162. array_push ( $roleArray, $exp );
  1163. }
  1164. $roleArrayCopy [$v [0]] = $roleArray;
  1165. // $verifyList[$k]['roleArray']=$roleArray;
  1166. }
  1167. $verifyList [$k] ['date'] = "";
  1168. $verifyList [$k] ['opinion'] = "";
  1169. $verifyList [$k] ['status'] = "";
  1170. if (empty ( $verifyStaff )) {
  1171. $verifyList [$k] ['date'] = "";
  1172. $verifyList [$k] ['opinion'] = "";
  1173. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1174. $verifyList [$k] ['status'] = 4;
  1175. $flag = false;
  1176. }
  1177. } else {
  1178. foreach ( $verifyStaff as $m => $u ) {
  1179. if ($v [0] == $m) {
  1180. $verifyList [$k] ['date'] = $u ['date'];
  1181. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1182. $verifyList [$k] ['status'] = $u ['status'];
  1183. $flag = false;
  1184. break;
  1185. }
  1186. }
  1187. $endStaffArray = end ( $verifyStaff );
  1188. if (isset ( $endStaffArray ['ROLE'] )) {
  1189. } else {
  1190. // $endKey=key($verifyStaff);
  1191. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1192. // $button=4;
  1193. // $verifyList[$k]['status']=4;
  1194. // }
  1195. }
  1196. }
  1197. }
  1198. $rolename ['name'] = '';
  1199. if (! empty ( $roleId )) {
  1200. Doo::loadModel ( 'role' );
  1201. $role = new role ();
  1202. $rolename = $role->getOne ( array (
  1203. 'where' => 'rid=' . $roleId,
  1204. 'asArray' => true
  1205. ) );
  1206. }
  1207. if (! empty ( $verifyStaff ))
  1208. $endStaffArray = end ( $verifyStaff );
  1209. $KOP = false;
  1210. foreach ( $roleArrayCopy as $P => $A ) {
  1211. foreach ( $A as $MKI => $AVL ) {
  1212. if (! empty ( $verifyStaff )) {
  1213. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1214. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1215. $button = 4;
  1216. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1217. }
  1218. foreach ( $verifyStaff as $m => $u ) {
  1219. $AVLFK = $AVL [0] . '_R';
  1220. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1221. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1222. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1223. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1224. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1225. break;
  1226. }
  1227. }
  1228. } else {
  1229. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1230. $button = 4;
  1231. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1232. }
  1233. }
  1234. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1235. $KOP = true;
  1236. }
  1237. }
  1238. foreach ( $roleArrayCopy as $k => $v ) {
  1239. foreach ( $verifyList as $m => $n ) {
  1240. if ($n [0] == $k) {
  1241. array_splice ( $verifyList, $m, 1, $v );
  1242. }
  1243. }
  1244. }
  1245. $receiptList [$key] ['verifyList'] = $verifyList;
  1246. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1247. 'where' => 'sid=' . $value ['staff'],
  1248. 'asArray' => true
  1249. ) );
  1250. $receiptList [$key] ['button'] = $button;
  1251. //
  1252. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1253. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1254. }
  1255. $data ['receiptList'] = $receiptList;
  1256. $data['receiptDetail']=$receiptDetail;
  1257. Doo::loadModel ( 'L_category' );
  1258. $lCategory = new L_category ();
  1259. Doo::loadModel ( 'accountItem' );
  1260. $accountItem = new accountItem ();
  1261. $acItem = $accountItem->find ( array (
  1262. 'asArray' => true
  1263. ) );
  1264. $veList = $verify->find ( array (
  1265. 'asArray' => true
  1266. ) );
  1267. foreach ( $veList as $key => $value ) {
  1268. $v = json_decode ( $value ['staff'] );
  1269. $list = array ();
  1270. foreach ( $v as $n => $m ) {
  1271. if ($m ['1'] == 'ROLE') {
  1272. $roleInfo = $role->getOne ( array (
  1273. 'where' => 'rid=' . $m [0],
  1274. 'asArray' => true
  1275. ) );
  1276. $v [$n] [1] = $roleInfo ['name'];
  1277. array_push ( $list, $roleInfo ['name'] );
  1278. } else {
  1279. array_push ( $list, $v [$n] [1] );
  1280. }
  1281. }
  1282. $veList [$key] ['staff'] = implode ( '>', $list );
  1283. }
  1284. $data ['rid'] = $rid;
  1285. $data ['category'] = $lCategory->find ( array (
  1286. 'asArray' => true
  1287. ) );
  1288. $data ['veList'] = $veList;
  1289. $data ['acItem'] = $acItem;
  1290. $data ['memu'] = "receipt";
  1291. $data ['staff'] = $this->staff;
  1292. $data ['receiptMemu'] = 'saeaBorad';
  1293. $data ['verifyId'] = $this->verifyId;
  1294. $data ['executeId'] = $this->executeId;
  1295. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1296. }
  1297. function saeaLoanReceiptAddDo() {
  1298. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1299. $agency = $this->get_args ( 'agency' );
  1300. $travel = $this->get_args ( 'travel' );
  1301. $train = $this->get_args ( 'train' );
  1302. $other = $this->get_args ( 'other' );
  1303. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1304. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1305. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1306. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1307. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1308. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1309. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1310. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1311. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1312. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1313. if ($remittanceBankType==1&&empty($coupletNumber)){
  1314. header ( 'Content-Type:text/html;charset=utf-8' );
  1315. die ( '请填写联行号' );
  1316. }
  1317. Doo::loadModel ( 'receipt' );
  1318. Doo::loadModel ( 'receiptDetail' );
  1319. Doo::loadModel ( 'accountItem' );
  1320. $accountItem = new accountItem ();
  1321. $receipt = new receipt ();
  1322. Doo::loadModel ( 'enclosur' );
  1323. Doo::loadModel ( 'execute' );
  1324. $execute = new execute ();
  1325. $executeDetail = $execute->getOne ( array (
  1326. 'where' => 'mold="借款费用执行人"',
  1327. 'asArray' => true
  1328. ) );
  1329. $receiptDet = $receipt->getOne ( array (
  1330. 'where' => 'rid=' . $rid,
  1331. 'asArray' => true
  1332. ) );
  1333. // if(!empty($receiptDetail))
  1334. // return "/referReceipt/".$receiptDetail['rid'];
  1335. $aItem = $accountItem->find ( array (
  1336. 'asArray' => true
  1337. ) );
  1338. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1339. $ag = $tr = $ta = $ot = 0;
  1340. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1341. foreach ( $aItem as $key => $value ) {
  1342. if ($value ['category'] == $this->AGENCY) {
  1343. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1344. array_push ( $accountJson [$this->AGENCY], array (
  1345. 'aid' => $value ['aid'],
  1346. 'name' => $value ['name'],
  1347. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1348. ) );
  1349. $sum += $agency [$ag];
  1350. $agencySum += $agency [$ag];
  1351. }
  1352. $ag ++;
  1353. }
  1354. if ($value ['category'] == $this->TRAVEL) {
  1355. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1356. array_push ( $accountJson [$this->TRAVEL], array (
  1357. 'aid' => $value ['aid'],
  1358. 'name' => $value ['name'],
  1359. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1360. ) );
  1361. $sum += $travel [$tr];
  1362. $travelSum += $travel [$tr];
  1363. }
  1364. $tr ++;
  1365. }
  1366. if ($value ['category'] == $this->TRAIN) {
  1367. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1368. array_push ( $accountJson [$this->TRAIN], array (
  1369. 'aid' => $value ['aid'],
  1370. 'name' => $value ['name'],
  1371. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1372. ) );
  1373. $sum += $train [$ta];
  1374. $trainSum += $train [$ta];
  1375. }
  1376. $ta ++;
  1377. }
  1378. if ($value ['category'] == $this->OTHER) {
  1379. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1380. array_push ( $accountJson [$this->OTHER], array (
  1381. 'aid' => $value ['aid'],
  1382. 'name' => $value ['name'],
  1383. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1384. ) );
  1385. $sum += $other [$ot];
  1386. $otherSum += $other [$ot];
  1387. }
  1388. $ot ++;
  1389. }
  1390. }
  1391. $accountJson ['cSum'] = array (
  1392. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1393. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1394. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1395. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1396. );
  1397. // 报销单
  1398. $receipt->accountItem = json_encode ( $accountJson );
  1399. $receipt->staff = $this->staff [0] ['sid'];
  1400. $receipt->loanSum = $receiptDet ['sum'];
  1401. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1402. $receipt->date = date ( "Y-m-d" );
  1403. $receipt->pastDate = '';
  1404. $receipt->cid = $cid;
  1405. $receipt->status = 7;
  1406. // 修改审批流程加入角色
  1407. $receipt->verify = $verify;
  1408. $receipt->verifyStaff = '';
  1409. $receipt->executeStaff = '';
  1410. $receipt->executeCopy = $executeDetail ['staff'];
  1411. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  1412. $receipt->explanation = $explanation;
  1413. $receipt->remittanceName = $remittanceName;
  1414. $receipt->bankName = $bankName;
  1415. $receipt->bankNumber = $bankNumber;
  1416. $receipt->remittanceBankType = $remittanceBankType;
  1417. if ($remittanceBankType==1)
  1418. $receipt->coupletNumber = $coupletNumber;
  1419. $receipt->update ( array (
  1420. 'where' => 'rid=' . $rid
  1421. ) );
  1422. // 附件
  1423. if (! empty ( $enclosurName )) {
  1424. $enclosurArray = explode ( '-', $enclosurName );
  1425. foreach ( $enclosurArray as $value ) {
  1426. $enclosur = new enclosur ();
  1427. $enclosur->name = $value;
  1428. $enclosur->rid = $rid;
  1429. $enclosur->insert ();
  1430. }
  1431. // print_r($enclosurArray);die;
  1432. }
  1433. // 报销详情
  1434. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1435. $receiptDetail = new receiptDetail ();
  1436. $receiptDetail->staff = $this->staff [0] ['sid'];
  1437. $receiptDetail->item = $value ['name'];
  1438. $receiptDetail->itemCategory = $this->AGENCY;
  1439. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1440. $receiptDetail->date = date ( "Y-m-d" );
  1441. $receiptDetail->cid = $cid;
  1442. $receiptDetail->rid = $rid;
  1443. $receiptDetail->status = 4;
  1444. $receiptDetail->insert ();
  1445. }
  1446. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1447. $receiptDetail = new receiptDetail ();
  1448. $receiptDetail->staff = $this->staff [0] ['sid'];
  1449. $receiptDetail->item = $value ['name'];
  1450. $receiptDetail->itemCategory = $this->TRAVEL;
  1451. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1452. $receiptDetail->date = date ( "Y-m-d" );
  1453. $receiptDetail->cid = $cid;
  1454. $receiptDetail->rid = $rid;
  1455. $receiptDetail->status = 4;
  1456. $receiptDetail->insert ();
  1457. }
  1458. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1459. $receiptDetail = new receiptDetail ();
  1460. $receiptDetail->staff = $this->staff [0] ['sid'];
  1461. $receiptDetail->item = $value ['name'];
  1462. $receiptDetail->itemCategory = $this->TRAIN;
  1463. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1464. $receiptDetail->date = date ( "Y-m-d" );
  1465. $receiptDetail->cid = $cid;
  1466. $receiptDetail->rid = $rid;
  1467. $receiptDetail->status = 4;
  1468. $receiptDetail->insert ();
  1469. }
  1470. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1471. $receiptDetail = new receiptDetail ();
  1472. $receiptDetail->staff = $this->staff [0] ['sid'];
  1473. $receiptDetail->item = $value ['name'];
  1474. $receiptDetail->itemCategory = $this->OTHER;
  1475. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1476. $receiptDetail->date = date ( "Y-m-d" );
  1477. $receiptDetail->cid = $cid;
  1478. $receiptDetail->rid = $rid;
  1479. $receiptDetail->status = 4;
  1480. $receiptDetail->insert ();
  1481. }
  1482. return "/saeaBorad";
  1483. }
  1484. return "/saeaLoanReceiptAdd/" . $rid;
  1485. }
  1486. function saeaLoanReceiptEdi() {
  1487. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1488. Doo::loadClass ( 'XDeode' );
  1489. $XDeode = new XDeode ( 7 );
  1490. $rid = $XDeode->decode ( $ridKey );
  1491. if (! is_numeric ( $rid ))
  1492. die ( 'illegal request' );
  1493. Doo::loadModel ( 'accountItem' );
  1494. Doo::loadModel ( 'verify' );
  1495. Doo::loadModel ( 'receipt' );
  1496. $receipt = new receipt ();
  1497. $verify = new verify ();
  1498. $accountItem = new accountItem ();
  1499. Doo::loadModel ( 'L_category' );
  1500. $Lcategory = new L_category ();
  1501. Doo::loadModel ( "role" );
  1502. $role = new role ();
  1503. Doo::loadModel ( 'loanReceipt' );
  1504. $loanReceipt = new loanReceipt ();
  1505. Doo::loadModel ( 'staff' );
  1506. $staff = new staff ();
  1507. $receiptDetail = $receipt->getOne ( array (
  1508. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  1509. 'asArray' => true
  1510. ) );
  1511. if (empty ( $receiptDetail ))
  1512. return "/saeaBorad";
  1513. $receiptList = $loanReceipt->find ( array (
  1514. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1515. 'desc' => 'rid',
  1516. 'asArray' => true
  1517. ) );
  1518. $Locate = 0;
  1519. $roleId = 0;
  1520. $button = 0;
  1521. foreach ( $receiptList as $key => $value ) {
  1522. $receiptList [$key] ['Locate'] = $Locate;
  1523. $Locate ++;
  1524. $receiptList [$key] ['reviseDetail'] = array ();
  1525. if (! empty ( $value ['reviseDetail'] ))
  1526. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1527. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1528. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1529. $categoryDetil = $Lcategory->getOne ( array (
  1530. 'where' => 'cid=' . $value ['cid'],
  1531. 'asArray' => true
  1532. ) );
  1533. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1534. // 检测编辑状态
  1535. $verifyList = $verify->getOne ( array (
  1536. 'where' => 'vid=' . $value ['verify'],
  1537. 'asArray' => true
  1538. ) );
  1539. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1540. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1541. Doo::loadModel ( 'role' );
  1542. $role = new role ();
  1543. $flag = true;
  1544. $roleKey = 0;
  1545. $endStaffArray = array ();
  1546. $roleArrayCopy = array ();
  1547. foreach ( $verifyList as $k => $v ) {
  1548. // init verifyStaff
  1549. if ($v [1] == 'ROLE') {
  1550. if (! empty ( $verifyStaff )) {
  1551. $endStaffArray = end ( $verifyStaff );
  1552. // if ($v[0]==$endStaffArray['nextStaff']){
  1553. // $roleId=$v[0];
  1554. // }
  1555. }
  1556. $roleVerify = json_decode ( $v [3], true );
  1557. $roleKey = $k;
  1558. $roleArray = array ();
  1559. $rolename = $role->getOne ( array (
  1560. 'where' => 'rid=' . $v [0],
  1561. 'asArray' => true
  1562. ) );
  1563. foreach ( $roleVerify as $o => $p ) {
  1564. $staffID = explode ( '_', $p );
  1565. $staffInfo = $staff->getOne ( array (
  1566. 'where' => 'sid=' . $staffID [0],
  1567. 'asArray' => true
  1568. ) );
  1569. // print_r($staffID);
  1570. $exp = array (
  1571. 0 => $staffInfo ['sid'],
  1572. 1 => $staffID [1],
  1573. 2 => $staffInfo ['avatar'],
  1574. 'date' => '',
  1575. 'date' => '',
  1576. 'opinion' => '',
  1577. 'status' => '',
  1578. 'rolename' => $rolename ['name']
  1579. );
  1580. array_push ( $roleArray, $exp );
  1581. }
  1582. $roleArrayCopy [$v [0]] = $roleArray;
  1583. // $verifyList[$k]['roleArray']=$roleArray;
  1584. }
  1585. $verifyList [$k] ['date'] = "";
  1586. $verifyList [$k] ['opinion'] = "";
  1587. $verifyList [$k] ['status'] = "";
  1588. if (empty ( $verifyStaff )) {
  1589. $verifyList [$k] ['date'] = "";
  1590. $verifyList [$k] ['opinion'] = "";
  1591. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1592. $verifyList [$k] ['status'] = 4;
  1593. $flag = false;
  1594. }
  1595. } else {
  1596. foreach ( $verifyStaff as $m => $u ) {
  1597. if ($v [0] == $m) {
  1598. $verifyList [$k] ['date'] = $u ['date'];
  1599. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1600. $verifyList [$k] ['status'] = $u ['status'];
  1601. $flag = false;
  1602. break;
  1603. }
  1604. }
  1605. $endStaffArray = end ( $verifyStaff );
  1606. if (isset ( $endStaffArray ['ROLE'] )) {
  1607. } else {
  1608. // $endKey=key($verifyStaff);
  1609. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1610. // $button=4;
  1611. // $verifyList[$k]['status']=4;
  1612. // }
  1613. }
  1614. }
  1615. }
  1616. $rolename ['name'] = '';
  1617. if (! empty ( $roleId )) {
  1618. Doo::loadModel ( 'role' );
  1619. $role = new role ();
  1620. $rolename = $role->getOne ( array (
  1621. 'where' => 'rid=' . $roleId,
  1622. 'asArray' => true
  1623. ) );
  1624. }
  1625. if (! empty ( $verifyStaff ))
  1626. $endStaffArray = end ( $verifyStaff );
  1627. $KOP = false;
  1628. foreach ( $roleArrayCopy as $P => $A ) {
  1629. foreach ( $A as $MKI => $AVL ) {
  1630. if (! empty ( $verifyStaff )) {
  1631. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1632. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1633. $button = 4;
  1634. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1635. }
  1636. foreach ( $verifyStaff as $m => $u ) {
  1637. $AVLFK = $AVL [0] . '_R';
  1638. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1639. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1640. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1641. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1642. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1643. break;
  1644. }
  1645. }
  1646. } else {
  1647. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1648. $button = 4;
  1649. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1650. }
  1651. }
  1652. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1653. $KOP = true;
  1654. }
  1655. }
  1656. foreach ( $roleArrayCopy as $k => $v ) {
  1657. foreach ( $verifyList as $m => $n ) {
  1658. if ($n [0] == $k) {
  1659. array_splice ( $verifyList, $m, 1, $v );
  1660. }
  1661. }
  1662. }
  1663. $receiptList [$key] ['verifyList'] = $verifyList;
  1664. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1665. 'where' => 'sid=' . $value ['staff'],
  1666. 'asArray' => true
  1667. ) );
  1668. $receiptList [$key] ['button'] = $button;
  1669. //
  1670. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1671. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1672. }
  1673. $data ['receiptList'] = $receiptList;
  1674. $acItem = $accountItem->find ( array (
  1675. 'asArray' => true
  1676. ) );
  1677. $veList = $verify->find ( array (
  1678. 'asArray' => true
  1679. ) );
  1680. foreach ( $veList as $key => $value ) {
  1681. $v = json_decode ( $value ['staff'] );
  1682. $list = array ();
  1683. foreach ( $v as $n => $m ) {
  1684. if ($m ['1'] == 'ROLE') {
  1685. $roleInfo = $role->getOne ( array (
  1686. 'where' => 'rid=' . $m [0],
  1687. 'asArray' => true
  1688. ) );
  1689. $v [$n] [1] = $roleInfo ['name'];
  1690. array_push ( $list, $roleInfo ['name'] );
  1691. } else {
  1692. array_push ( $list, $v [$n] [1] );
  1693. }
  1694. }
  1695. $veList [$key] ['staff'] = implode ( '>', $list );
  1696. }
  1697. // 配置编辑信息
  1698. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1699. foreach ( $acItem as $key => $value ) {
  1700. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1701. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1702. $acItem [$key] ['price'] = $v ['price'];
  1703. }
  1704. }
  1705. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1706. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1707. $acItem [$key] ['price'] = $v ['price'];
  1708. }
  1709. }
  1710. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1711. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1712. $acItem [$key] ['price'] = $v ['price'];
  1713. }
  1714. }
  1715. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1716. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1717. $acItem [$key] ['price'] = $v ['price'];
  1718. }
  1719. }
  1720. }
  1721. $data ['category'] = $Lcategory->find ( array (
  1722. 'asArray' => true
  1723. ) );
  1724. $data['ridKey']=$ridKey;
  1725. $data ['cSum'] = $accountItemList ['cSum'];
  1726. $data ['sum'] = $receiptDetail ['sum'];
  1727. $data ['receiptDetail'] = $receiptDetail;
  1728. $data ['veList'] = $veList;
  1729. $data ['acItem'] = $acItem;
  1730. $data ['memu'] = "receipt";
  1731. $data ['staff'] = $this->staff;
  1732. $data ['receiptMemu'] = 'saeaBorad';
  1733. $data ['verify'] = $receiptDetail ['verify'];
  1734. $data ['verifyId'] = $this->verifyId;
  1735. $data ['executeId'] = $this->executeId;
  1736. $data ['rid'] = $rid;
  1737. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  1738. }
  1739. function confirmation() {
  1740. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1741. Doo::loadModel ( 'receipt' );
  1742. Doo::loadModel ( 'receiptDetail' );
  1743. $receipt = new receipt ();
  1744. $receiptDetail = new receiptDetail ();
  1745. Doo::loadModel ( 'statistics' );
  1746. Doo::loadModel ( 'itemStatistics' );
  1747. $statistics = new statistics ();
  1748. $itemStatistics = new itemStatistics ();
  1749. Doo::loadModel ( "verify" );
  1750. $verify = new verify ();
  1751. $receiptDetailList = $receipt->getOne ( array (
  1752. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  1753. 'asArray' => true
  1754. ) );
  1755. if (empty ( $receiptDetailList ))
  1756. return "/saeaBorad";
  1757. $verifyDetail = $verify->getOne ( array (
  1758. 'where' => ' vid =' . $receiptDetailList ['verify'],
  1759. 'asArray' => true
  1760. ) );
  1761. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  1762. if (empty ( $receiptDetailList ['nowStaff'] )) {
  1763. $nowStaff = "";
  1764. $nowStaffList = array ();
  1765. if ($verifyDetail [0] [1] == 'ROLE') {
  1766. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  1767. foreach ( $vStaffString as $key => $value ) {
  1768. $staffK = explode ( "_", $value );
  1769. array_push ( $nowStaffList, $staffK [0] );
  1770. }
  1771. $nowStaff = implode ( ',', $nowStaffList );
  1772. } else {
  1773. $nowStaff = $verifyDetail [0] [0];
  1774. }
  1775. $receipt->nowStaff = $nowStaff;
  1776. }
  1777. // echo $nowStaff;
  1778. // print_r($verifyDetail);die;
  1779. $receipt->rid = $receiptDetailList ['rid'];
  1780. $receipt->status = 2;
  1781. $receipt->update ();
  1782. // 操作日志
  1783. Doo::loadModel ( "receiptLog" );
  1784. $receiptLog = new receiptLog ();
  1785. $verify = new verify ();
  1786. $receiptInfo = $receipt->getOne ( array (
  1787. 'where' => 'rid=' . $rid,
  1788. 'asArray' => true
  1789. ) );
  1790. $vr = $verify->getOne ( array (
  1791. 'where' => 'vid=' . $receiptInfo ['verify'],
  1792. 'asArray' => true
  1793. ) );
  1794. $jd = json_decode ( $vr ['staff'] );
  1795. $roleId = 0;
  1796. foreach ( $jd as $key => $value ) {
  1797. if ($value [1] == 'ROLE') {
  1798. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  1799. if ($pos !== false) {
  1800. $roleId = $value [0];
  1801. }
  1802. }
  1803. }
  1804. // 审批日志
  1805. // echo $roleId;die;
  1806. if (! empty ( $roleId )) {
  1807. Doo::loadModel ( "role" );
  1808. $role = new role ();
  1809. $roleInfo = $role->getOne ( array (
  1810. 'where' => 'rid=' . $roleId,
  1811. 'asArray' => true
  1812. ) );
  1813. $receiptLog->rolename = $roleInfo ['name'];
  1814. }
  1815. $receiptLog->username = $this->staff [0] ['username'];
  1816. $receiptLog->uid = $this->staff [0] ['sid'];
  1817. $receiptLog->date = date ( "Y-m-d" );
  1818. $receiptLog->opinion = '提交审批';
  1819. $receiptLog->img = $this->staff [0] ['avatar'];
  1820. $receiptLog->status = 2;
  1821. $receiptLog->rid = $rid;
  1822. $receiptLog->insert ();
  1823. return "/expenses";
  1824. }
  1825. function expenses() {
  1826. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  1827. if (empty ( $item ))
  1828. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  1829. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1830. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  1831. Doo::loadModel ( 'receipt' );
  1832. $receipt = new receipt ();
  1833. Doo::loadModel ( 'L_category' );
  1834. $Lcategory = new L_category ();
  1835. Doo::loadModel ( 'verify' );
  1836. Doo::loadModel ( 'statistics' );
  1837. $statistics = new statistics ();
  1838. $verify = new verify ();
  1839. Doo::loadModel ( 'staff' );
  1840. $staff = new staff ();
  1841. $condition = "";
  1842. if ($item == "expenses")
  1843. $condition = " and Rtype=1 ";
  1844. elseif ($item == "receipts")
  1845. $condition = " and Rtype=0 ";
  1846. elseif ($item == "remits")
  1847. $condition = " and Rtype=2 ";
  1848. $dateCondition = " and Year(date) =" . $year;
  1849. if (! empty ( $moth )) {
  1850. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  1851. $stList = $statistics->getOne ( array (
  1852. 'select' => 'rePrice ,agPrice',
  1853. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  1854. 'asArray' => true
  1855. ) );
  1856. } else
  1857. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  1858. if (empty ( $stList ))
  1859. $stList = array (
  1860. 'rePrice' => 0,
  1861. 'agPrice' => 0
  1862. );
  1863. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  1864. if (! isset ( $noPassSum ['sum'] ))
  1865. $noPassSum ['sum'] = 0;
  1866. $data ['stList'] = array (
  1867. 'rePrice' => $stList ['rePrice'],
  1868. 'agPrice' => $stList ['agPrice'],
  1869. 'skPrice' => ($noPassSum ['sum'])
  1870. );
  1871. $receiptList = $receipt->find ( array (
  1872. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  1873. 'desc' => 'rid',
  1874. 'asArray' => true
  1875. ) );
  1876. $Locate = 0;
  1877. $roleId = 0;
  1878. $button = 0;
  1879. foreach ( $receiptList as $key => $value ) {
  1880. $receiptList [$key] ['Locate'] = $Locate;
  1881. $Locate ++;
  1882. $receiptList [$key] ['reviseDetail'] = array ();
  1883. if (! empty ( $value ['reviseDetail'] ))
  1884. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1885. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1886. $categoryDetil = $Lcategory->getOne ( array (
  1887. 'where' => 'cid=' . $value ['cid'],
  1888. 'asArray' => true
  1889. ) );
  1890. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1891. // 检测编辑状态
  1892. $verifyList = $verify->getOne ( array (
  1893. 'where' => 'vid=' . $value ['verify'],
  1894. 'asArray' => true
  1895. ) );
  1896. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1897. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1898. Doo::loadModel ( 'role' );
  1899. $role = new role ();
  1900. $flag = true;
  1901. $roleKey = 0;
  1902. $endStaffArray = array ();
  1903. $roleArrayCopy = array ();
  1904. foreach ( $verifyList as $k => $v ) {
  1905. // init verifyStaff
  1906. if ($v [1] == 'ROLE') {
  1907. if (! empty ( $verifyStaff )) {
  1908. $endStaffArray = end ( $verifyStaff );
  1909. // if ($v[0]==$endStaffArray['nextStaff']){
  1910. // $roleId=$v[0];
  1911. // }
  1912. }
  1913. $roleVerify = json_decode ( $v [3], true );
  1914. $roleKey = $k;
  1915. $roleArray = array ();
  1916. $rolename = $role->getOne ( array (
  1917. 'where' => 'rid=' . $v [0],
  1918. 'asArray' => true
  1919. ) );
  1920. foreach ( $roleVerify as $o => $p ) {
  1921. $staffID = explode ( '_', $p );
  1922. $staffInfo = $staff->getOne ( array (
  1923. 'where' => 'sid=' . $staffID [0],
  1924. 'asArray' => true
  1925. ) );
  1926. // print_r($staffID);
  1927. $exp = array (
  1928. 0 => $staffInfo ['sid'],
  1929. 1 => $staffID [1],
  1930. 2 => $staffInfo ['avatar'],
  1931. 'date' => '',
  1932. 'date' => '',
  1933. 'opinion' => '',
  1934. 'status' => '',
  1935. 'rolename' => $rolename ['name']
  1936. );
  1937. array_push ( $roleArray, $exp );
  1938. }
  1939. $roleArrayCopy [$v [0]] = $roleArray;
  1940. // $verifyList[$k]['roleArray']=$roleArray;
  1941. }
  1942. $verifyList [$k] ['date'] = "";
  1943. $verifyList [$k] ['opinion'] = "";
  1944. $verifyList [$k] ['status'] = "";
  1945. if (empty ( $verifyStaff )) {
  1946. $verifyList [$k] ['date'] = "";
  1947. $verifyList [$k] ['opinion'] = "";
  1948. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1949. $verifyList [$k] ['status'] = 4;
  1950. $flag = false;
  1951. }
  1952. } else {
  1953. foreach ( $verifyStaff as $m => $u ) {
  1954. if ($v [0] == $m) {
  1955. $verifyList [$k] ['date'] = $u ['date'];
  1956. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1957. $verifyList [$k] ['status'] = $u ['status'];
  1958. $flag = false;
  1959. break;
  1960. }
  1961. }
  1962. $endStaffArray = end ( $verifyStaff );
  1963. if (isset ( $endStaffArray ['ROLE'] )) {
  1964. } else {
  1965. // $endKey=key($verifyStaff);
  1966. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1967. // $button=4;
  1968. // $verifyList[$k]['status']=4;
  1969. // }
  1970. }
  1971. }
  1972. }
  1973. $rolename ['name'] = '';
  1974. if (! empty ( $roleId )) {
  1975. Doo::loadModel ( 'role' );
  1976. $role = new role ();
  1977. $rolename = $role->getOne ( array (
  1978. 'where' => 'rid=' . $roleId,
  1979. 'asArray' => true
  1980. ) );
  1981. }
  1982. if (! empty ( $verifyStaff ))
  1983. $endStaffArray = end ( $verifyStaff );
  1984. $KOP = false;
  1985. foreach ( $roleArrayCopy as $P => $A ) {
  1986. foreach ( $A as $MKI => $AVL ) {
  1987. if (! empty ( $verifyStaff )) {
  1988. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1989. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1990. $button = 4;
  1991. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1992. }
  1993. foreach ( $verifyStaff as $m => $u ) {
  1994. $AVLFK = $AVL [0] . '_R';
  1995. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1996. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1997. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1998. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1999. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2000. break;
  2001. }
  2002. }
  2003. } else {
  2004. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2005. $button = 4;
  2006. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2007. }
  2008. }
  2009. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2010. $KOP = true;
  2011. }
  2012. }
  2013. foreach ( $roleArrayCopy as $k => $v ) {
  2014. foreach ( $verifyList as $m => $n ) {
  2015. if ($n [0] == $k) {
  2016. array_splice ( $verifyList, $m, 1, $v );
  2017. }
  2018. }
  2019. }
  2020. $receiptList [$key] ['verifyList'] = $verifyList;
  2021. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2022. 'where' => 'sid=' . $value ['staff'],
  2023. 'asArray' => true
  2024. ) );
  2025. $receiptList [$key] ['button'] = $button;
  2026. }
  2027. // print_r($receiptList);die;
  2028. $mothHtml = "";
  2029. for($i = 1; $i <= 12; $i ++) {
  2030. if ($moth == $i)
  2031. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2032. else
  2033. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2034. }
  2035. $data ['mothHtml'] = $mothHtml;
  2036. $data ['receiptList'] = $receiptList;
  2037. $data ['memu'] = "receipt";
  2038. $data ['staff'] = $this->staff;
  2039. $data ['receiptMemu'] = 'expenses';
  2040. $data ['verifyId'] = $this->verifyId;
  2041. $data ['executeId'] = $this->executeId;
  2042. $data ['item'] = $item;
  2043. $data ['year'] = $year;
  2044. $this->render ( "/admin/expenses", $data );
  2045. }
  2046. function expensesCollect() {
  2047. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2048. Doo::loadModel ( 'receipt' );
  2049. $receipt = new receipt ();
  2050. Doo::loadModel ( 'L_category' );
  2051. $Lcategory = new L_category ();
  2052. Doo::loadModel ( 'verify' );
  2053. Doo::loadModel ( 'statistics' );
  2054. $statistics = new statistics ();
  2055. $verify = new verify ();
  2056. Doo::loadModel ( 'staff' );
  2057. $staff = new staff ();
  2058. Doo::loadModel ( 'loanReceipt' );
  2059. $loanReceipt = new loanReceipt ();
  2060. $receiptList = $receipt->find ( array (
  2061. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  2062. 'desc' => 'rid',
  2063. 'asArray' => true
  2064. ) );
  2065. $loanList = $loanReceipt->find ( array (
  2066. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2067. 'desc' => 'rid',
  2068. 'asArray' => true
  2069. ) );
  2070. /*
  2071. * $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;
  2072. */
  2073. $data ['explanation'] ='';
  2074. if (!empty($loanList))
  2075. $data ['explanation'] = $loanList[0]['explanation'];
  2076. $Locate = 0;
  2077. $roleId = 0;
  2078. $button = 0;
  2079. foreach ( $receiptList as $key => $value ) {
  2080. $receiptList [$key] ['Locate'] = $Locate;
  2081. $Locate ++;
  2082. $receiptList [$key] ['reviseDetail'] = array ();
  2083. if (! empty ( $value ['reviseDetail'] ))
  2084. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2085. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2086. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2087. $categoryDetil = $Lcategory->getOne ( array (
  2088. 'where' => 'cid=' . $value ['cid'],
  2089. 'asArray' => true
  2090. ) );
  2091. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2092. // 检测编辑状态
  2093. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  2094. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  2095. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  2096. else
  2097. $verifyList ['staff'] = $value ['verifyBreakup'];
  2098. } else
  2099. $verifyList = $verify->getOne ( array (
  2100. 'where' => 'vid=' . $value ['verify'],
  2101. 'asArray' => true
  2102. ) );
  2103. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2104. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2105. Doo::loadModel ( 'role' );
  2106. $role = new role ();
  2107. $flag = true;
  2108. $roleKey = 0;
  2109. $endStaffArray = array ();
  2110. $roleArrayCopy = array ();
  2111. foreach ( $verifyList as $k => $v ) {
  2112. // init verifyStaff
  2113. if ($v [1] == 'ROLE') {
  2114. if (! empty ( $verifyStaff )) {
  2115. $endStaffArray = end ( $verifyStaff );
  2116. // if ($v[0]==$endStaffArray['nextStaff']){
  2117. // $roleId=$v[0];
  2118. // }
  2119. }
  2120. $roleVerify = json_decode ( $v [3], true );
  2121. $roleKey = $k;
  2122. $roleArray = array ();
  2123. $rolename = $role->getOne ( array (
  2124. 'where' => 'rid=' . $v [0],
  2125. 'asArray' => true
  2126. ) );
  2127. foreach ( $roleVerify as $o => $p ) {
  2128. $staffID = explode ( '_', $p );
  2129. $staffInfo = $staff->getOne ( array (
  2130. 'where' => 'sid=' . $staffID [0],
  2131. 'asArray' => true
  2132. ) );
  2133. // print_r($staffID);
  2134. $exp = array (
  2135. 0 => $staffInfo ['sid'],
  2136. 1 => $staffID [1],
  2137. 2 => $staffInfo ['avatar'],
  2138. 'date' => '',
  2139. 'date' => '',
  2140. 'opinion' => '',
  2141. 'status' => '',
  2142. 'rolename' => $rolename ['name']
  2143. );
  2144. array_push ( $roleArray, $exp );
  2145. }
  2146. $roleArrayCopy [$v [0]] = $roleArray;
  2147. // $verifyList[$k]['roleArray']=$roleArray;
  2148. }
  2149. $verifyList [$k] ['date'] = "";
  2150. $verifyList [$k] ['opinion'] = "";
  2151. $verifyList [$k] ['status'] = "";
  2152. if (empty ( $verifyStaff )) {
  2153. $verifyList [$k] ['date'] = "";
  2154. $verifyList [$k] ['opinion'] = "";
  2155. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2156. $verifyList [$k] ['status'] = 4;
  2157. $flag = false;
  2158. }
  2159. } else {
  2160. foreach ( $verifyStaff as $m => $u ) {
  2161. if ($v [0] == $m) {
  2162. $verifyList [$k] ['date'] = $u ['date'];
  2163. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2164. $verifyList [$k] ['status'] = $u ['status'];
  2165. $flag = false;
  2166. break;
  2167. }
  2168. }
  2169. $endStaffArray = end ( $verifyStaff );
  2170. if (isset ( $endStaffArray ['ROLE'] )) {
  2171. } else {
  2172. // $endKey=key($verifyStaff);
  2173. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2174. // $button=4;
  2175. // $verifyList[$k]['status']=4;
  2176. // }
  2177. }
  2178. }
  2179. }
  2180. $rolename ['name'] = '';
  2181. if (! empty ( $roleId )) {
  2182. Doo::loadModel ( 'role' );
  2183. $role = new role ();
  2184. $rolename = $role->getOne ( array (
  2185. 'where' => 'rid=' . $roleId,
  2186. 'asArray' => true
  2187. ) );
  2188. }
  2189. if (! empty ( $verifyStaff ))
  2190. $endStaffArray = end ( $verifyStaff );
  2191. $KOP = false;
  2192. foreach ( $roleArrayCopy as $P => $A ) {
  2193. foreach ( $A as $MKI => $AVL ) {
  2194. if (! empty ( $verifyStaff )) {
  2195. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2196. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2197. $button = 4;
  2198. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2199. }
  2200. foreach ( $verifyStaff as $m => $u ) {
  2201. $AVLFK = $AVL [0] . '_R';
  2202. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2203. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2204. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2205. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2206. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2207. break;
  2208. }
  2209. }
  2210. } else {
  2211. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2212. $button = 4;
  2213. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2214. }
  2215. }
  2216. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2217. $KOP = true;
  2218. }
  2219. }
  2220. foreach ( $roleArrayCopy as $k => $v ) {
  2221. foreach ( $verifyList as $m => $n ) {
  2222. if ($n [0] == $k) {
  2223. array_splice ( $verifyList, $m, 1, $v );
  2224. }
  2225. }
  2226. }
  2227. // 费用执行人相关数据
  2228. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2229. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2230. foreach ( $executeCopy as $k => $v ) {
  2231. $executeCopy [$k] ['date'] = '';
  2232. $executeCopy [$k] ['opinion'] = '';
  2233. $executeCopy [$k] ['status'] = '';
  2234. if (! empty ( $executeStaff ))
  2235. foreach ( $executeStaff as $m => $u ) {
  2236. if ($v [0] == $m) {
  2237. $executeCopy [$k] ['date'] = $u ['date'];
  2238. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2239. $executeCopy [$k] ['status'] = $u ['status'];
  2240. break;
  2241. }
  2242. }
  2243. }
  2244. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2245. $receiptList [$key] ['verifyList'] = $verifyList;
  2246. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2247. 'where' => 'sid=' . $value ['staff'],
  2248. 'asArray' => true
  2249. ) );
  2250. $receiptList [$key] ['button'] = $button;
  2251. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2252. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2253. $relust = $value ['sum'] - $value ['loanSum'];
  2254. $receiptList [$key] ['relust'] = $relust;
  2255. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2256. }
  2257. Doo::loadModel ( 'enclosur' );
  2258. $enclosur = new enclosur ();
  2259. $enclosurList = $enclosur->find ( array (
  2260. 'where' => 'rid=' . $rid,
  2261. 'asArray' => true
  2262. ) );
  2263. $enclosurHtml = '';
  2264. foreach ( $enclosurList as $value ) {
  2265. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2266. }
  2267. $data ['enclosurHtml'] = $enclosurHtml;
  2268. // print_r($receiptList);
  2269. $data ['receiptList'] = $receiptList;
  2270. $data ['memu'] = "receipt";
  2271. $data ['staff'] = $this->staff;
  2272. $data ['receiptMemu'] = 'expenses';
  2273. $data ['verifyId'] = $this->verifyId;
  2274. $data ['executeId'] = $this->executeId;
  2275. $this->render ( "/admin/expensesCollect", $data );
  2276. }
  2277. function approvalExpenses() {
  2278. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  2279. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : '';
  2280. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2281. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2282. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2283. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  2284. // echo $rdate;
  2285. if (empty ( $status ))
  2286. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  2287. $page_size = 12;
  2288. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2289. $vidList = array ();
  2290. $button = 0;
  2291. Doo::loadModel ( 'verify' );
  2292. $verify = new verify ();
  2293. Doo::loadModel ( 'receipt' );
  2294. $receipt = new receipt ();
  2295. Doo::loadModel ( 'staff' );
  2296. $staff = new staff ();
  2297. Doo::loadModel ( 'L_category' );
  2298. $Lcategory = new L_category ();
  2299. // user verify ID
  2300. $verifyDetail = $verify->find ( array (
  2301. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  2302. 'asArray' => true
  2303. ) );
  2304. foreach ( $verifyDetail as $key => $value ) {
  2305. array_push ( $vidList, $value ['vid'] );
  2306. }
  2307. $vid = implode ( ",", $vidList );
  2308. if (empty ( $verifyDetail ))
  2309. $vid = 0;
  2310. // if ($status==0)
  2311. // $dateCondition="";
  2312. // else
  2313. $dateCondition = " ";
  2314. // if (! empty ( $month ))
  2315. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  2316. if ($status == 'done'|| $status == 'termination') {
  2317. if (!empty($year)){
  2318. $dateCondition = " and Year(pastDate) =" . $year;
  2319. if (! empty ( $month ))
  2320. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  2321. }
  2322. }
  2323. // date ( 'Y-m' )
  2324. if (! empty ( $rdate ) && $status == 'done')
  2325. $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  2326. elseif (! empty ( $rdate ))
  2327. $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  2328. $categoryList = $Lcategory->find ( array (
  2329. 'asArray' => true
  2330. ) );
  2331. $staffList = $staff->find ( array (
  2332. 'where' => 'cid=' . $cid,
  2333. 'asArray' => true
  2334. ) );
  2335. $cateCondition = "";
  2336. $staffCondition = "";
  2337. $approvalCondition = "";
  2338. if (! empty ( $cid )) {
  2339. $cateCondition = ' and cid=' . $cid;
  2340. }
  2341. if (! empty ( $sid )) {
  2342. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  2343. $cateCondition = "";
  2344. }
  2345. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  2346. if ($status == 'pendApproval') {
  2347. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  2348. }
  2349. if ($status == 'ongoing') {
  2350. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  2351. }
  2352. if ($status == 'done') {
  2353. $approvalCondition = ' and (status=8 or status=9 ) ';
  2354. }
  2355. if ($status == 'termination') {
  2356. $approvalCondition = " and status=3";
  2357. }
  2358. if($status == 'finish'){
  2359. $approvalCondition = " and status=1";
  2360. }
  2361. // $approvalCondition = " and status=" . $status;
  2362. // if ($status == 2) {
  2363. // // 查找角色审批人
  2364. // }
  2365. // if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  2366. // $approvalCondition = ' and status=2 ';
  2367. // }
  2368. // if ($status == 1) {
  2369. // $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  2370. // }
  2371. // if ($status == 8) {
  2372. // $approvalCondition = ' and (status=' . $status . ' or status=9 ) ';
  2373. // }
  2374. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  2375. $pageinfo ['page'] = array (
  2376. 'previous' => ''
  2377. );
  2378. // if ($status == 0) {
  2379. // $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  2380. // $receiptList = $receipt->find ( array (
  2381. // 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ')',
  2382. // 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2383. // 'desc' => 'rid',
  2384. // 'asArray' => true
  2385. // ) );
  2386. // //echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2387. // } else
  2388. if ($status == 'done' || $status == 'termination') { // $dateCondition .
  2389. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  2390. $receiptList = $receipt->find ( array ( // $dateCondition.
  2391. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  2392. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2393. 'desc' => 'rid',
  2394. 'asArray' => true
  2395. ) );
  2396. } else {
  2397. $receiptList = $receipt->find ( array ( // $dateCondition
  2398. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
  2399. 'desc' => 'rid',
  2400. 'asArray' => true
  2401. ) );
  2402. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  2403. }
  2404. $rLRes = $receipt->find ( array (
  2405. 'where' => 'status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )' . $cateCondition . $staffCondition . ' and verify in (' . $vid . ')',
  2406. 'desc' => 'rid',
  2407. 'asArray' => true
  2408. ) );
  2409. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  2410. // print_r($receiptList);
  2411. $Locate = 0;
  2412. $reportList = $reportCateList = array ();
  2413. foreach ( $receiptList as $key => $value ) {
  2414. $receiptList [$key] ['Locate'] = $Locate;
  2415. $Locate ++;
  2416. $receiptList [$key] ['reviseDetail'] = array ();
  2417. if (! empty ( $value ['reviseDetail'] ))
  2418. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2419. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2420. $categoryDetil = $Lcategory->getOne ( array (
  2421. 'where' => 'cid=' . $value ['cid'],
  2422. 'asArray' => true
  2423. ) );
  2424. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2425. $verifyList = $verify->getOne ( array (
  2426. 'where' => 'vid=' . $value ['verify'],
  2427. 'asArray' => true
  2428. ) );
  2429. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2430. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2431. foreach ( $verifyList as $k => $v ) {
  2432. // init verifyStaff
  2433. $verifyList [$k] ['date'] = "";
  2434. $verifyList [$k] ['opinion'] = "";
  2435. $verifyList [$k] ['status'] = "";
  2436. if (empty ( $verifyStaff )) {
  2437. $verifyList [$k] ['date'] = "";
  2438. $verifyList [$k] ['opinion'] = "";
  2439. if ($v [0] == $this->staff [0] ['sid']) {
  2440. $verifyList [$k] ['status'] = 4;
  2441. $button = 4;
  2442. }
  2443. } else {
  2444. $flag = true;
  2445. foreach ( $verifyStaff as $m => $u ) {
  2446. if ($v [0] == $m) {
  2447. $verifyList [$k] ['date'] = $u ['date'];
  2448. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2449. $verifyList [$k] ['status'] = $u ['status'];
  2450. $flag = false;
  2451. break;
  2452. }
  2453. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  2454. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  2455. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  2456. }
  2457. if ($flag) { // 检测可编辑
  2458. if ($v [0] == $this->staff [0] ['sid']) {
  2459. $verifyList [$k] ['status'] = 4;
  2460. $button = 4;
  2461. }
  2462. }
  2463. }
  2464. }
  2465. $receiptList [$key] ['verifyList'] = $verifyList;
  2466. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2467. 'where' => 'sid=' . $value ['staff'],
  2468. 'asArray' => true
  2469. ) );
  2470. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  2471. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  2472. $receiptList [$key] ['button'] = $button;
  2473. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  2474. }
  2475. $reportList = array_unique ( $reportList );
  2476. $reportHtml = '';
  2477. foreach ( $reportList as $key => $value ) {
  2478. $v = explode ( "-", $value );
  2479. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  2480. }
  2481. // print_r($reportList)
  2482. $data ['reportHtml'] = $reportHtml;
  2483. $reportCateList = array_unique ( $reportCateList );
  2484. $reportCateHtml = '';
  2485. foreach ( $reportCateList as $key => $value ) {
  2486. $v = explode ( "-", $value );
  2487. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  2488. }
  2489. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  2490. $data ['reportCateHtml'] = $reportCateHtml;
  2491. // print_r($receiptList);die;
  2492. // $data['verifyDetail']=$verifyDetail;
  2493. $mothHtml = "";
  2494. for($i = 1; $i <= 12; $i ++) {
  2495. if ($month == $i)
  2496. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2497. else
  2498. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2499. }
  2500. $data ['mothHtml'] = $mothHtml;
  2501. $data ['page'] = $pageinfo;
  2502. $data ['receiptList'] = $receiptList;
  2503. $data ['receiptApprovalCount'] = count ( $rLRes );
  2504. $data ['status'] = $status;
  2505. $data ['year'] = $year;
  2506. $data ['categoryList'] = $categoryList;
  2507. $data ['staffList'] = $staffList;
  2508. $data ['cid'] = $cid;
  2509. $data ['sid'] = $sid;
  2510. // print_r($receiptList);
  2511. $data ['memu'] = "receipt";
  2512. $data ['staff'] = $this->staff;
  2513. $data ['receiptMemu'] = 'approvalExpenses';
  2514. $data ['verifyId'] = $this->verifyId;
  2515. $data ['executeId'] = $this->executeId;
  2516. $this->render ( "/admin/approvalExpenses", $data );
  2517. }
  2518. function expensesDoc() {
  2519. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2520. Doo::loadModel ( 'receipt' );
  2521. $receipt = new receipt ();
  2522. Doo::loadModel ( 'L_category' );
  2523. $Lcategory = new L_category ();
  2524. Doo::loadModel ( 'verify' );
  2525. Doo::loadModel ( 'statistics' );
  2526. $statistics = new statistics ();
  2527. $verify = new verify ();
  2528. Doo::loadModel ( 'staff' );
  2529. $staff = new staff ();
  2530. Doo::loadModel ( 'loanReceipt' );
  2531. $loanReceipt = new loanReceipt ();
  2532. $receiptList = $receipt->find ( array (
  2533. 'where' => ' rid=' . $rid,
  2534. 'desc' => 'rid',
  2535. 'asArray' => true
  2536. ) );
  2537. $loanList = array ();
  2538. if (! empty ( $receiptList ))
  2539. $loanList = $loanReceipt->find ( array (
  2540. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2541. 'desc' => 'rid',
  2542. 'asArray' => true
  2543. ) );
  2544. $Locate = 0;
  2545. $roleId = 0;
  2546. $button = 0;
  2547. foreach ( $loanList as $key => $value ) {
  2548. $loanList [$key] ['Locate'] = $Locate;
  2549. $Locate ++;
  2550. $loanList [$key] ['reviseDetail'] = array ();
  2551. if (! empty ( $value ['reviseDetail'] ))
  2552. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2553. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2554. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2555. $categoryDetil = $Lcategory->getOne ( array (
  2556. 'where' => 'cid=' . $value ['cid'],
  2557. 'asArray' => true
  2558. ) );
  2559. $loanList [$key] ['category'] = $categoryDetil ['title'];
  2560. // 检测编辑状态
  2561. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  2562. $verifyList ['staff'] = $value ['verifyBreakup'];
  2563. else
  2564. $verifyList = $verify->getOne ( array (
  2565. 'where' => 'vid=' . $value ['verify'],
  2566. 'asArray' => true
  2567. ) );
  2568. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2569. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2570. Doo::loadModel ( 'role' );
  2571. $role = new role ();
  2572. $flag = true;
  2573. $roleKey = 0;
  2574. $endStaffArray = array ();
  2575. $roleArrayCopy = array ();
  2576. foreach ( $verifyList as $k => $v ) {
  2577. // init verifyStaff
  2578. if ($v [1] == 'ROLE') {
  2579. if (! empty ( $verifyStaff )) {
  2580. $endStaffArray = end ( $verifyStaff );
  2581. // if ($v[0]==$endStaffArray['nextStaff']){
  2582. // $roleId=$v[0];
  2583. // }
  2584. }
  2585. $roleVerify = json_decode ( $v [3], true );
  2586. $roleKey = $k;
  2587. $roleArray = array ();
  2588. $rolename = $role->getOne ( array (
  2589. 'where' => 'rid=' . $v [0],
  2590. 'asArray' => true
  2591. ) );
  2592. foreach ( $roleVerify as $o => $p ) {
  2593. $staffID = explode ( '_', $p );
  2594. $staffInfo = $staff->getOne ( array (
  2595. 'where' => 'sid=' . $staffID [0],
  2596. 'asArray' => true
  2597. ) );
  2598. // print_r($staffID);
  2599. $exp = array (
  2600. 0 => $staffInfo ['sid'],
  2601. 1 => $staffID [1],
  2602. 2 => $staffInfo ['avatar'],
  2603. 'date' => '',
  2604. 'date' => '',
  2605. 'opinion' => '',
  2606. 'status' => '',
  2607. 'rolename' => $rolename ['name']
  2608. );
  2609. array_push ( $roleArray, $exp );
  2610. }
  2611. $roleArrayCopy [$v [0]] = $roleArray;
  2612. // $verifyList[$k]['roleArray']=$roleArray;
  2613. }
  2614. $verifyList [$k] ['date'] = "";
  2615. $verifyList [$k] ['opinion'] = "";
  2616. $verifyList [$k] ['status'] = "";
  2617. if (empty ( $verifyStaff )) {
  2618. $verifyList [$k] ['date'] = "";
  2619. $verifyList [$k] ['opinion'] = "";
  2620. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2621. $verifyList [$k] ['status'] = 4;
  2622. $flag = false;
  2623. }
  2624. } else {
  2625. foreach ( $verifyStaff as $m => $u ) {
  2626. if ($v [0] == $m) {
  2627. $verifyList [$k] ['date'] = $u ['date'];
  2628. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2629. $verifyList [$k] ['status'] = $u ['status'];
  2630. $flag = false;
  2631. break;
  2632. }
  2633. }
  2634. $endStaffArray = end ( $verifyStaff );
  2635. if (isset ( $endStaffArray ['ROLE'] )) {
  2636. } else {
  2637. // $endKey=key($verifyStaff);
  2638. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2639. // $button=4;
  2640. // $verifyList[$k]['status']=4;
  2641. // }
  2642. }
  2643. }
  2644. }
  2645. $rolename ['name'] = '';
  2646. if (! empty ( $roleId )) {
  2647. Doo::loadModel ( 'role' );
  2648. $role = new role ();
  2649. $rolename = $role->getOne ( array (
  2650. 'where' => 'rid=' . $roleId,
  2651. 'asArray' => true
  2652. ) );
  2653. }
  2654. if (! empty ( $verifyStaff ))
  2655. $endStaffArray = end ( $verifyStaff );
  2656. $KOP = false;
  2657. foreach ( $roleArrayCopy as $P => $A ) {
  2658. foreach ( $A as $MKI => $AVL ) {
  2659. if (! empty ( $verifyStaff )) {
  2660. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2661. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2662. $button = 4;
  2663. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2664. }
  2665. foreach ( $verifyStaff as $m => $u ) {
  2666. $AVLFK = $AVL [0] . '_R';
  2667. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2668. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2669. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2670. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2671. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2672. break;
  2673. }
  2674. }
  2675. } else {
  2676. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2677. $button = 4;
  2678. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2679. }
  2680. }
  2681. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2682. $KOP = true;
  2683. }
  2684. }
  2685. foreach ( $roleArrayCopy as $k => $v ) {
  2686. foreach ( $verifyList as $m => $n ) {
  2687. if ($n [0] == $k) {
  2688. array_splice ( $verifyList, $m, 1, $v );
  2689. }
  2690. }
  2691. }
  2692. $loanList [$key] ['verifyList'] = $verifyList;
  2693. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  2694. 'where' => 'sid=' . $value ['staff'],
  2695. 'asArray' => true
  2696. ) );
  2697. $loanList [$key] ['button'] = $button;
  2698. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  2699. }
  2700. $data ['loanList'] = $loanList;
  2701. // print_r($loanList);
  2702. $Locate = 0;
  2703. $roleId = 0;
  2704. $button = 0;
  2705. foreach ( $receiptList as $key => $value ) {
  2706. $receiptList [$key] ['Locate'] = $Locate;
  2707. $Locate ++;
  2708. $receiptList [$key] ['reviseDetail'] = array ();
  2709. if (! empty ( $value ['reviseDetail'] ))
  2710. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2711. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2712. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2713. $categoryDetil = $Lcategory->getOne ( array (
  2714. 'where' => 'cid=' . $value ['cid'],
  2715. 'asArray' => true
  2716. ) );
  2717. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2718. // 检测编辑状态
  2719. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  2720. $verifyList ['staff'] = $value ['verifyBreakup'];
  2721. } else
  2722. $verifyList = $verify->getOne ( array (
  2723. 'where' => 'vid=' . $value ['verify'],
  2724. 'asArray' => true
  2725. ) );
  2726. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2727. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2728. Doo::loadModel ( 'role' );
  2729. $role = new role ();
  2730. if ($verifyList == NULL)
  2731. $verifyList = array ();
  2732. $flag = true;
  2733. $roleKey = 0;
  2734. $endStaffArray = array ();
  2735. $roleArrayCopy = array ();
  2736. foreach ( $verifyList as $k => $v ) {
  2737. // init verifyStaff
  2738. if ($v [1] == 'ROLE') {
  2739. if (! empty ( $verifyStaff )) {
  2740. $endStaffArray = end ( $verifyStaff );
  2741. // if ($v[0]==$endStaffArray['nextStaff']){
  2742. // $roleId=$v[0];
  2743. // }
  2744. }
  2745. $roleVerify = json_decode ( $v [3], true );
  2746. $roleKey = $k;
  2747. $roleArray = array ();
  2748. $rolename = $role->getOne ( array (
  2749. 'where' => 'rid=' . $v [0],
  2750. 'asArray' => true
  2751. ) );
  2752. foreach ( $roleVerify as $o => $p ) {
  2753. $staffID = explode ( '_', $p );
  2754. $staffInfo = $staff->getOne ( array (
  2755. 'where' => 'sid=' . $staffID [0],
  2756. 'asArray' => true
  2757. ) );
  2758. // print_r($staffID);
  2759. $exp = array (
  2760. 0 => $staffInfo ['sid'],
  2761. 1 => $staffID [1],
  2762. 2 => $staffInfo ['avatar'],
  2763. 'date' => '',
  2764. 'date' => '',
  2765. 'opinion' => '',
  2766. 'status' => '',
  2767. 'rolename' => $rolename ['name']
  2768. );
  2769. array_push ( $roleArray, $exp );
  2770. }
  2771. $roleArrayCopy [$v [0]] = $roleArray;
  2772. // $verifyList[$k]['roleArray']=$roleArray;
  2773. }
  2774. $verifyList [$k] ['date'] = "";
  2775. $verifyList [$k] ['opinion'] = "";
  2776. $verifyList [$k] ['status'] = "";
  2777. if (empty ( $verifyStaff )) {
  2778. $verifyList [$k] ['date'] = "";
  2779. $verifyList [$k] ['opinion'] = "";
  2780. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2781. $verifyList [$k] ['status'] = 4;
  2782. $flag = false;
  2783. }
  2784. } else {
  2785. foreach ( $verifyStaff as $m => $u ) {
  2786. if ($v [0] == $m) {
  2787. $verifyList [$k] ['date'] = $u ['date'];
  2788. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2789. $verifyList [$k] ['status'] = $u ['status'];
  2790. $flag = false;
  2791. break;
  2792. }
  2793. }
  2794. $endStaffArray = end ( $verifyStaff );
  2795. if (isset ( $endStaffArray ['ROLE'] )) {
  2796. } else {
  2797. // $endKey=key($verifyStaff);
  2798. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2799. // $button=4;
  2800. // $verifyList[$k]['status']=4;
  2801. // }
  2802. }
  2803. }
  2804. }
  2805. $rolename ['name'] = '';
  2806. if (! empty ( $roleId )) {
  2807. Doo::loadModel ( 'role' );
  2808. $role = new role ();
  2809. $rolename = $role->getOne ( array (
  2810. 'where' => 'rid=' . $roleId,
  2811. 'asArray' => true
  2812. ) );
  2813. }
  2814. if (! empty ( $verifyStaff ))
  2815. $endStaffArray = end ( $verifyStaff );
  2816. $KOP = false;
  2817. foreach ( $roleArrayCopy as $P => $A ) {
  2818. foreach ( $A as $MKI => $AVL ) {
  2819. if (! empty ( $verifyStaff )) {
  2820. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2821. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2822. $button = 4;
  2823. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2824. }
  2825. foreach ( $verifyStaff as $m => $u ) {
  2826. $AVLFK = $AVL [0] . '_R';
  2827. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2828. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2829. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2830. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2831. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2832. break;
  2833. }
  2834. }
  2835. } else {
  2836. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2837. $button = 4;
  2838. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2839. }
  2840. }
  2841. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2842. $KOP = true;
  2843. }
  2844. }
  2845. foreach ( $roleArrayCopy as $k => $v ) {
  2846. foreach ( $verifyList as $m => $n ) {
  2847. if ($n [0] == $k) {
  2848. array_splice ( $verifyList, $m, 1, $v );
  2849. }
  2850. }
  2851. }
  2852. // 费用执行人相关数据
  2853. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2854. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2855. foreach ( $executeCopy as $k => $v ) {
  2856. $executeCopy [$k] ['date'] = '';
  2857. $executeCopy [$k] ['opinion'] = '';
  2858. $executeCopy [$k] ['status'] = '';
  2859. if (! empty ( $executeStaff ))
  2860. foreach ( $executeStaff as $m => $u ) {
  2861. if ($v [0] == $m) {
  2862. $executeCopy [$k] ['date'] = $u ['date'];
  2863. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2864. $executeCopy [$k] ['status'] = $u ['status'];
  2865. break;
  2866. }
  2867. }
  2868. }
  2869. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2870. $receiptList [$key] ['verifyList'] = $verifyList;
  2871. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2872. 'where' => 'sid=' . $value ['staff'],
  2873. 'asArray' => true
  2874. ) );
  2875. $receiptList [$key] ['button'] = $button;
  2876. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2877. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2878. $relust = $value ['sum'] - $value ['loanSum'];
  2879. $receiptList [$key] ['relust'] = $relust;
  2880. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2881. }
  2882. // print_r($receiptList);
  2883. // 获取审批日志
  2884. Doo::loadModel ( 'receiptLog' );
  2885. $receiptLog = new receiptLog ();
  2886. $rlList = array ();
  2887. $rlInfo = $receiptLog->getOne ( array (
  2888. 'where' => 'rid=' . $rid . ' and status=4',
  2889. 'asArray' => true
  2890. ) );
  2891. $tijdate = $receiptLog->getOne ( array (
  2892. 'where' => 'rid=' . $rid . ' and status=2',
  2893. 'asc' => 'rlid',
  2894. 'asArray' => true
  2895. ) );
  2896. if (! empty ( $rlInfo )) {
  2897. $rlList = $receiptLog->find ( array (
  2898. 'where' => 'rid=' . $rid,
  2899. 'asc' => 'rlid',
  2900. 'asArray' => true
  2901. ) );
  2902. }
  2903. Doo::loadModel ( 'enclosur' );
  2904. $enclosur = new enclosur ();
  2905. $enclosurList = $enclosur->find ( array (
  2906. 'where' => 'rid=' . $rid,
  2907. 'asArray' => true
  2908. ) );
  2909. $enclosurHtml = '';
  2910. foreach ( $enclosurList as $value ) {
  2911. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2912. }
  2913. $data ['enclosurHtml'] = $enclosurHtml;
  2914. $receiptList [0] ['rlList'] = $rlList;
  2915. $data ['receiptList'] = $receiptList;
  2916. $data ['memu'] = "receipt";
  2917. $data ['staff'] = $this->staff;
  2918. $data ['receiptMemu'] = 'approvalExpenses';
  2919. $data ['verifyId'] = $this->verifyId;
  2920. $data ['executeId'] = $this->executeId;
  2921. $this->render ( "/admin/expensesDoc", $data );
  2922. }
  2923. function expensesEdi() {
  2924. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2925. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  2926. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2927. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2928. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2929. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2930. if (empty ( $status ))
  2931. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  2932. $vidList = array ();
  2933. $button = 0;
  2934. Doo::loadModel ( 'verify' );
  2935. Doo::loadModel ( 'receipt' );
  2936. Doo::loadModel ( 'staff' );
  2937. $staff = new staff ();
  2938. $receipt = new receipt ();
  2939. $verify = new verify ();
  2940. Doo::loadModel ( 'L_category' );
  2941. $Lcategory = new L_category ();
  2942. Doo::loadModel ( 'enclosur' );
  2943. $enclosur = new enclosur ();
  2944. // user verify ID
  2945. $verifyDetail = $verify->find ( array (
  2946. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  2947. 'asArray' => true
  2948. ) );
  2949. foreach ( $verifyDetail as $key => $value ) {
  2950. array_push ( $vidList, $value ['vid'] );
  2951. }
  2952. $vid = implode ( ",", $vidList );
  2953. if (empty ( $verifyDetail ))
  2954. $vid = 0;
  2955. $categoryList = $Lcategory->find ( array (
  2956. 'asArray' => true
  2957. ) );
  2958. $staffList = $staff->find ( array (
  2959. 'where' => 'cid=' . $cid,
  2960. 'asArray' => true
  2961. ) );
  2962. $ap = "";
  2963. if ($status == 4) {
  2964. $ap = 4;
  2965. $status = 2;
  2966. }
  2967. // get Receipt By verifyID status 2
  2968. $receiptList = $receipt->find ( array (
  2969. 'where' => 'rid =' . $rid . ' and status=2',
  2970. 'desc' => 'rid',
  2971. 'asArray' => true
  2972. ) );
  2973. if (empty ( $receiptList )) {
  2974. die ( 'illegal request' );
  2975. }
  2976. $Locate = 0;
  2977. $roleId = 0;
  2978. if ($ap == 4)
  2979. $status = 4;
  2980. foreach ( $receiptList as $key => $value ) {
  2981. $receiptList [$key] ['Locate'] = $Locate;
  2982. $Locate ++;
  2983. $receiptList [$key] ['reviseDetail'] = array ();
  2984. if (! empty ( $value ['reviseDetail'] ))
  2985. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2986. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2987. $categoryDetil = $Lcategory->getOne ( array (
  2988. 'where' => 'cid=' . $value ['cid'],
  2989. 'asArray' => true
  2990. ) );
  2991. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2992. // 检测编辑状态
  2993. $verifyList = $verify->getOne ( array (
  2994. 'where' => 'vid=' . $value ['verify'],
  2995. 'asArray' => true
  2996. ) );
  2997. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2998. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2999. Doo::loadModel ( 'role' );
  3000. $role = new role ();
  3001. // print_r($verifyList);
  3002. $flag = true;
  3003. $roleKey = 0;
  3004. $endStaffArray = array ();
  3005. $roleArrayCopy = array ();
  3006. foreach ( $verifyList as $k => $v ) {
  3007. // init verifyStaff
  3008. if ($v [1] == 'ROLE') {
  3009. if (! empty ( $verifyStaff )) {
  3010. $endStaffArray = end ( $verifyStaff );
  3011. if ($v [0] == $endStaffArray ['nextStaff']) {
  3012. $roleId = $v [0];
  3013. }
  3014. }
  3015. $roleVerify = json_decode ( $v [3], true );
  3016. $roleKey = $k;
  3017. $roleArray = array ();
  3018. $rolename = $role->getOne ( array (
  3019. 'where' => 'rid=' . $v [0],
  3020. 'asArray' => true
  3021. ) );
  3022. foreach ( $roleVerify as $o => $p ) {
  3023. $staffID = explode ( '_', $p );
  3024. $staffInfo = $staff->getOne ( array (
  3025. 'where' => 'sid=' . $staffID [0],
  3026. 'asArray' => true
  3027. ) );
  3028. // print_r($staffID);
  3029. $exp = array (
  3030. 0 => $staffInfo ['sid'],
  3031. 1 => $staffID [1],
  3032. 2 => $staffInfo ['avatar'],
  3033. 'date' => '',
  3034. 'date' => '',
  3035. 'opinion' => '',
  3036. 'status' => '',
  3037. 'rolename' => $rolename ['name']
  3038. );
  3039. array_push ( $roleArray, $exp );
  3040. }
  3041. $roleArrayCopy [$v [0]] = $roleArray;
  3042. // $verifyList[$k]['roleArray']=$roleArray;
  3043. }
  3044. // print_r($roleArray);
  3045. $verifyList [$k] ['date'] = "";
  3046. $verifyList [$k] ['opinion'] = "";
  3047. $verifyList [$k] ['status'] = "";
  3048. if (empty ( $verifyStaff )) {
  3049. $verifyList [$k] ['date'] = "";
  3050. $verifyList [$k] ['opinion'] = "";
  3051. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3052. $verifyList [$k] ['status'] = 4;
  3053. $button = 4;
  3054. $flag = false;
  3055. }
  3056. } else {
  3057. foreach ( $verifyStaff as $m => $u ) {
  3058. if ($v [0] == $m) {
  3059. $verifyList [$k] ['date'] = $u ['date'];
  3060. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3061. $verifyList [$k] ['status'] = $u ['status'];
  3062. $flag = false;
  3063. break;
  3064. }
  3065. }
  3066. $endStaffArray = end ( $verifyStaff );
  3067. if (isset ( $endStaffArray ['ROLE'] )) {
  3068. } else {
  3069. $endKey = key ( $verifyStaff );
  3070. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  3071. $button = 4;
  3072. $verifyList [$k] ['status'] = 4;
  3073. }
  3074. }
  3075. }
  3076. }
  3077. $rolename ['name'] = '';
  3078. if (! empty ( $roleId )) {
  3079. Doo::loadModel ( 'role' );
  3080. $role = new role ();
  3081. $rolename = $role->getOne ( array (
  3082. 'where' => 'rid=' . $roleId,
  3083. 'asArray' => true
  3084. ) );
  3085. }
  3086. if (! empty ( $verifyStaff ))
  3087. $endStaffArray = end ( $verifyStaff );
  3088. $KOP = false;
  3089. foreach ( $roleArrayCopy as $P => $A ) {
  3090. foreach ( $A as $MKI => $AVL ) {
  3091. if (! empty ( $verifyStaff )) {
  3092. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3093. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3094. $button = 4;
  3095. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3096. }
  3097. foreach ( $verifyStaff as $m => $u ) {
  3098. $AVLFK = $AVL [0] . '_R';
  3099. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3100. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3101. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3102. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3103. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3104. break;
  3105. }
  3106. }
  3107. } else {
  3108. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3109. $button = 4;
  3110. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3111. }
  3112. }
  3113. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3114. $KOP = true;
  3115. }
  3116. }
  3117. // print_r($roleArrayCopy);
  3118. // echo $roleKey;
  3119. foreach ( $roleArrayCopy as $k => $v ) {
  3120. foreach ( $verifyList as $m => $n ) {
  3121. if ($n [0] == $k) {
  3122. array_splice ( $verifyList, $m, 1, $v );
  3123. }
  3124. }
  3125. }
  3126. $receiptList [$key] ['verifyList'] = $verifyList;
  3127. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3128. 'where' => 'sid=' . $value ['staff'],
  3129. 'asArray' => true
  3130. ) );
  3131. $receiptList [$key] ['button'] = $button;
  3132. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  3133. }
  3134. // $data['verifyDetail']=$verifyDetail;
  3135. $mothHtml = "";
  3136. for($i = 1; $i <= 12; $i ++) {
  3137. if ($month == $i)
  3138. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3139. else
  3140. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3141. }
  3142. // 获取审批日志
  3143. Doo::loadModel ( 'receiptLog' );
  3144. $receiptLog = new receiptLog ();
  3145. $rlList = array ();
  3146. $rlInfo = $receiptLog->getOne ( array (
  3147. 'where' => 'rid=' . $rid . ' and status=4',
  3148. 'asArray' => true
  3149. ) );
  3150. $tijdate = $receiptLog->getOne ( array (
  3151. 'where' => 'rid=' . $rid . ' and status=2',
  3152. 'asc' => 'rlid',
  3153. 'asArray' => true
  3154. ) );
  3155. if (! empty ( $rlInfo )) {
  3156. $rlList = $receiptLog->find ( array (
  3157. 'where' => 'rid=' . $rid,
  3158. 'asc' => 'rlid',
  3159. 'asArray' => true
  3160. ) );
  3161. }
  3162. $receiptList [0] ['rlList'] = $rlList;
  3163. $enclosurList = $enclosur->find ( array (
  3164. 'where' => 'rid=' . $rid,
  3165. 'asArray' => true
  3166. ) );
  3167. $enclosurHtml = '';
  3168. foreach ( $enclosurList as $value ) {
  3169. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3170. }
  3171. // print_r($receiptList);
  3172. $data ['rid'] = $rid;
  3173. $data ['enclosurHtml'] = $enclosurHtml;
  3174. $data ['rolename'] = $rolename ['name'];
  3175. $data ['datetij'] = $tijdate ['date'];
  3176. $data ['mothHtml'] = $mothHtml;
  3177. $data ['receiptList'] = $receiptList;
  3178. $data ['receiptApprovalCount'] = count ( $receiptList );
  3179. $data ['status'] = $status;
  3180. $data ['year'] = $year;
  3181. $data ['categoryList'] = $categoryList;
  3182. $data ['staffList'] = $staffList;
  3183. $data ['cid'] = $cid;
  3184. $data ['sid'] = $sid;
  3185. $data ['ap'] = $ap;
  3186. $data ['memu'] = "receipt";
  3187. $data ['staff'] = $this->staff;
  3188. $data ['receiptMemu'] = 'approvalExpenses';
  3189. $data ['verifyId'] = $this->verifyId;
  3190. $data ['executeId'] = $this->executeId;
  3191. $this->render ( "/admin/expensesEdi", $data );
  3192. }
  3193. function expensesDefray() {
  3194. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3195. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3196. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3197. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  3198. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  3199. if (! empty ( $rid )) {
  3200. Doo::loadModel ( "verify" );
  3201. $verify = new verify ();
  3202. Doo::loadModel ( "receiptDetail" );
  3203. $receiptDetailObj = new receiptDetail ();
  3204. Doo::loadModel ( "itemStatistics" );
  3205. Doo::loadModel ( "statistics" );
  3206. $statistics = new statistics ();
  3207. $itemStatistics = new itemStatistics ();
  3208. Doo::loadModel ( "receipt" );
  3209. $receipt = new receipt ();
  3210. Doo::loadModel ( "loanReceipt" );
  3211. $loanReceipt = new loanReceipt ();
  3212. $receiptDetail = $receipt->getOne ( array (
  3213. 'where' => 'rid=' . $rid . ' and status=2 ',
  3214. 'asArray' => true
  3215. ) );
  3216. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  3217. $nsflag = true;
  3218. foreach ( $nslist as $value ) {
  3219. if ($value == $this->staff ['0'] ['sid']) {
  3220. $nsflag = false;
  3221. break;
  3222. }
  3223. }
  3224. // print_r($nslist);die;
  3225. if (empty ( $receiptDetail ) || $nsflag)
  3226. return "/approvalExpenses/pendApproval";
  3227. $verifyDetail = $verify->getOne ( array (
  3228. 'where' => ' vid =' . $receiptDetail ['verify'],
  3229. 'asArray' => true
  3230. ) );
  3231. $verifyString = $verifyDetail ['staff'];
  3232. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3233. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  3234. if (empty ( $opinion )) {
  3235. if ($status == 3)
  3236. $opinion = "终止";
  3237. else
  3238. $opinion = "同意支付";
  3239. }
  3240. $nowStaff = 0;
  3241. $nowStaffList = array ();
  3242. if (empty ( $verifyStaff )) {
  3243. // 还需加入是否已经进入角色审批
  3244. if ($verifyDetail [0] [1] == 'ROLE') {
  3245. // print_r($verifyDetail);echo "ddd";
  3246. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3247. foreach ( $vStaffString as $key => $value ) {
  3248. $staffK = explode ( "_", $value );
  3249. if ($staffK [0] != $this->staff [0] ['sid'])
  3250. array_push ( $nowStaffList, $staffK [0] );
  3251. }
  3252. // print_r($verifyDetail);
  3253. // die;
  3254. if (! empty ( $nowStaffList )) {
  3255. $nowStaff = implode ( ',', $nowStaffList );
  3256. $verifyStaff = array (
  3257. $this->staff [0] ['sid'] . "_R" => array (
  3258. 'date' => date ( 'Y-m-d' ),
  3259. 'opinion' => $opinion,
  3260. 'status' => $status,
  3261. 'nextStaff' => $verifyDetail [0] [0],
  3262. 'ROLE' => 1
  3263. )
  3264. );
  3265. } else {
  3266. $nowStaff = $verifyDetail [1] [0];
  3267. $verifyStaff = array (
  3268. $this->staff [0] ['sid'] . "_R" => array (
  3269. 'date' => date ( 'Y-m-d' ),
  3270. 'opinion' => $opinion,
  3271. 'status' => $status,
  3272. 'nextStaff' => $verifyDetail [1] [0]
  3273. )
  3274. );
  3275. }
  3276. } else {
  3277. if ($verifyDetail [1] [1] == 'ROLE') {
  3278. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  3279. // echo "dd";
  3280. foreach ( $vStaffString as $key => $value ) {
  3281. $staffK = explode ( "_", $value );
  3282. array_push ( $nowStaffList, $staffK [0] );
  3283. }
  3284. $nowStaff = implode ( ',', $nowStaffList );
  3285. $verifyStaff = array (
  3286. $this->staff [0] ['sid'] => array (
  3287. 'date' => date ( 'Y-m-d' ),
  3288. 'opinion' => $opinion,
  3289. 'status' => $status,
  3290. 'nextStaff' => $verifyDetail [1] [0],
  3291. 'ROLE' => 1
  3292. )
  3293. );
  3294. } else {
  3295. $nowStaff = $verifyDetail [1] [0];
  3296. $verifyStaff = array (
  3297. $this->staff [0] ['sid'] => array (
  3298. 'date' => date ( 'Y-m-d' ),
  3299. 'opinion' => $opinion,
  3300. 'status' => $status,
  3301. 'nextStaff' => $verifyDetail [1] [0]
  3302. )
  3303. );
  3304. }
  3305. }
  3306. if ($status == 3)
  3307. $verifyStaff = array (
  3308. 'final' => $status,
  3309. $this->staff [0] ['sid'] => array (
  3310. 'date' => date ( 'Y-m-d' ),
  3311. 'opinion' => $opinion,
  3312. 'status' => $status
  3313. )
  3314. );
  3315. $vStaffString = json_encode ( $verifyStaff );
  3316. $receipt->nowStaff = $nowStaff;
  3317. $receipt->verifyStaff = $vStaffString;
  3318. $loanReceipt->nowStaff = $nowStaff;
  3319. $loanReceipt->verifyStaff = $vStaffString;
  3320. } else {
  3321. $VS = end ( $verifyStaff );
  3322. // 非角色审批
  3323. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  3324. $nextStaff = 0;
  3325. $roleSTF = false;
  3326. foreach ( $verifyDetail as $key => $value ) {
  3327. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  3328. if (isset ( $verifyDetail [$key + 1] )) {
  3329. $nextStaff = $verifyDetail [$key + 1] [0];
  3330. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  3331. $roleSTF = true;
  3332. }
  3333. break;
  3334. }
  3335. }
  3336. if (! $roleSTF) {
  3337. $nowStaff = $nextStaff;
  3338. $verifyStaff [$this->staff [0] ['sid']] = array (
  3339. 'date' => date ( 'Y-m-d' ),
  3340. 'opinion' => $opinion,
  3341. 'status' => $status,
  3342. 'nextStaff' => $nextStaff
  3343. );
  3344. } else {
  3345. // 获取角色下的所有用户ID
  3346. $nowStaffList = array ();
  3347. foreach ( $verifyDetail as $vfk ) {
  3348. if ($vfk [1] == 'ROLE') {
  3349. $vStaffString = json_decode ( $vfk [3] );
  3350. foreach ( $vStaffString as $key => $value ) {
  3351. $staffK = explode ( "_", $value );
  3352. array_push ( $nowStaffList, $staffK [0] );
  3353. }
  3354. }
  3355. }
  3356. $nowStaff = implode ( ',', $nowStaffList );
  3357. $verifyStaff [$this->staff [0] ['sid']] = array (
  3358. 'date' => date ( 'Y-m-d' ),
  3359. 'opinion' => $opinion,
  3360. 'status' => $status,
  3361. 'nextStaff' => $nextStaff,
  3362. 'ROLE' => 0
  3363. );
  3364. }
  3365. if ($status == 3) {
  3366. $verifyStaff ['final'] = $status;
  3367. $verifyStaff [$this->staff [0] ['sid']] = array (
  3368. 'date' => date ( 'Y-m-d' ),
  3369. 'opinion' => $opinion,
  3370. 'status' => $status
  3371. );
  3372. }
  3373. $vStaffString = json_encode ( $verifyStaff );
  3374. $receipt->nowStaff = $nowStaff;
  3375. $receipt->verifyStaff = $vStaffString;
  3376. $loanReceipt->nowStaff = $nowStaff;
  3377. $loanReceipt->verifyStaff = $vStaffString;
  3378. }
  3379. // 角色审批
  3380. if (isset ( $VS ['ROLE'] )) {
  3381. // 找出角色人 当前审批角色组
  3382. $verifyJSStaff = array ();
  3383. $nowStaffList2 = array ();
  3384. foreach ( $verifyDetail as $key => $value ) {
  3385. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  3386. $verifyJSStaff = json_decode ( $value [3] );
  3387. foreach ( $verifyJSStaff as $m ) {
  3388. $staffK = explode ( "_", $m );
  3389. array_push ( $nowStaffList2, $staffK [0] );
  3390. }
  3391. // print_r($nowStaffList2);
  3392. }
  3393. }
  3394. $RoleVerifyStaff = array ();
  3395. foreach ( $verifyStaff as $key => $value ) {
  3396. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  3397. foreach ( $nowStaffList2 as $m ) {
  3398. if ($key == $m . "_R")
  3399. $RoleVerifyStaff [$key] = $value;
  3400. }
  3401. }
  3402. }
  3403. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  3404. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  3405. // 下一个审批人ID
  3406. $nextStaff = 0;
  3407. $falg = false;
  3408. foreach ( $verifyDetail as $key => $value ) {
  3409. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  3410. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  3411. $falg = true;
  3412. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  3413. $nowStaffList = array ();
  3414. foreach ( $vStaffString as $v ) {
  3415. $staffK = explode ( "_", $v );
  3416. array_push ( $nowStaffList, $staffK [0] );
  3417. }
  3418. $nowStaff = implode ( ',', $nowStaffList );
  3419. $nextStaff = $verifyDetail [$key + 1] [0];
  3420. } elseif (isset ( $verifyDetail [$key + 1] )) {
  3421. $nextStaff = $verifyDetail [$key + 1] [0];
  3422. $nowStaff = $nextStaff;
  3423. } else
  3424. $nowStaff = '';
  3425. break;
  3426. }
  3427. }
  3428. if ($falg)
  3429. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3430. 'date' => date ( 'Y-m-d' ),
  3431. 'opinion' => $opinion,
  3432. 'status' => $status,
  3433. 'nextStaff' => $nextStaff,
  3434. 'ROLE' => 1
  3435. );
  3436. else
  3437. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3438. 'date' => date ( 'Y-m-d' ),
  3439. 'opinion' => $opinion,
  3440. 'status' => $status,
  3441. 'nextStaff' => $nextStaff
  3442. );
  3443. // print_r($verifyStaff);
  3444. // echo $nowStaff;die;
  3445. } else { // 进入下一个角色或者审批人
  3446. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  3447. //
  3448. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  3449. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3450. 'date' => date ( 'Y-m-d' ),
  3451. 'opinion' => $opinion,
  3452. 'status' => $status,
  3453. 'nextStaff' => $VS ['nextStaff'],
  3454. 'ROLE' => 1
  3455. );
  3456. // print_r($verifyStaff);
  3457. // die;
  3458. }
  3459. if ($status == 3) {
  3460. $verifyStaff ['final'] = $status;
  3461. $verifyStaff [$this->staff [0] ['sid']] = array (
  3462. 'date' => date ( 'Y-m-d' ),
  3463. 'opinion' => $opinion,
  3464. 'status' => $status
  3465. );
  3466. }
  3467. $vStaffString = json_encode ( $verifyStaff );
  3468. $receipt->verifyStaff = $vStaffString;
  3469. $receipt->nowStaff = $nowStaff;
  3470. $loanReceipt->nowStaff = $nowStaff;
  3471. $loanReceipt->verifyStaff = $vStaffString;
  3472. // die;
  3473. // }
  3474. // print_r($verifyStaff);
  3475. // die;
  3476. }
  3477. // print_r($verifyStaff);die;
  3478. }
  3479. // print_r($verifyDetail);
  3480. $roleKey = 0;
  3481. $roleId = 0;
  3482. $verifyDetailCopy = array ();
  3483. foreach ( $verifyDetail as $k => $v ) {
  3484. if ($v [1] == 'ROLE') {
  3485. $roleId = $v [0];
  3486. $roleVerify = json_decode ( $v [3], true );
  3487. $roleKey = $k;
  3488. $roleArray = array ();
  3489. foreach ( $roleVerify as $o => $p ) {
  3490. $staffID = explode ( '_', $p );
  3491. $exp = array (
  3492. 0 => $staffID [0],
  3493. 1 => $staffID [1]
  3494. );
  3495. array_push ( $roleArray, $exp );
  3496. }
  3497. $verifyDetailCopy [$v [0]] = $roleArray;
  3498. }
  3499. }
  3500. // print_r($verifyDetail);
  3501. foreach ( $verifyDetailCopy as $k => $v ) {
  3502. foreach ( $verifyDetail as $m => $n ) {
  3503. if ($n [0] == $k) {
  3504. array_splice ( $verifyDetail, $m, 1, $v );
  3505. }
  3506. }
  3507. }
  3508. // 审批日志
  3509. if (! isset ( $verifyStaff ['final'] )) {
  3510. Doo::loadModel ( "receiptLog" );
  3511. $receiptLog = new receiptLog ();
  3512. if (! empty ( $roleId )) {
  3513. Doo::loadModel ( "role" );
  3514. $role = new role ();
  3515. $roleInfo = $role->getOne ( array (
  3516. 'where' => 'rid=' . $roleId,
  3517. 'asArray' => true
  3518. ) );
  3519. $receiptLog->rolename = $roleInfo ['name'];
  3520. }
  3521. $receiptLog->username = $this->staff [0] ['username'];
  3522. $receiptLog->uid = $this->staff [0] ['sid'];
  3523. $receiptLog->date = date ( "Y-m-d" );
  3524. $receiptLog->opinion = $opinion;
  3525. $receiptLog->img = $this->staff [0] ['avatar'];
  3526. $receiptLog->status = 1;
  3527. $receiptLog->rid = $rid;
  3528. $receiptLog->insert ();
  3529. }
  3530. if (isset ( $verifyStaff ['final'] )) { // rDetail
  3531. $receipt->status = 3;
  3532. $receipt->verifyBreakup = $verifyString;
  3533. $receiptDetailObj->status = 3;
  3534. $receiptDetailObj->update ( array (
  3535. 'where' => 'rid=' . $rid
  3536. ) );
  3537. // 微信企业号通知
  3538. $this->setWXMsg ( $rid, 3 );
  3539. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  3540. $receipt->status = 6;
  3541. $receipt->pastDate = date ( "Y-m-d" );
  3542. $receipt->isBK = 1;
  3543. $loanReceipt->verifyBreakup = $verifyString;
  3544. $loanReceipt->status = 1;
  3545. $loanReceipt->pastDate = date ( "Y-m-d" );
  3546. $loanReceipt->amount = $receiptDetail ['amount'];
  3547. $loanReceipt->update ( array (
  3548. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  3549. ) );
  3550. // 微信企业号通知
  3551. $this->setWXMsg ( $rid, 1 );
  3552. }
  3553. $receipt->amount = $amount;
  3554. $receipt->update ( array (
  3555. 'where' => ' rid = ' . $rid
  3556. ) );
  3557. // 进入下一条审批费用新加需求
  3558. $vidList = array ();
  3559. $verifyDetail = $verify->find ( array (
  3560. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  3561. 'asArray' => true
  3562. ) );
  3563. foreach ( $verifyDetail as $key => $value ) {
  3564. array_push ( $vidList, $value ['vid'] );
  3565. }
  3566. $vid = implode ( ",", $vidList );
  3567. if (empty ( $verifyDetail ))
  3568. $vid = 0;
  3569. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  3570. $receipt = new receipt ();
  3571. $rd = $receipt->getOne ( array (
  3572. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  3573. 'asc' => 'rid',
  3574. 'asArray' => true
  3575. ) );
  3576. if (empty ( $rd )) {
  3577. return '/approvalExpenses/pendApproval';
  3578. }
  3579. if ($rd ['Rtype'] == 1) {
  3580. if ($rd ['isBK'] == 1) {
  3581. return '/receiptburEdi/' . $rd ['rid'];
  3582. } else {
  3583. return '/expensesEdi/' . $rd ['rid'];
  3584. }
  3585. } elseif ($rd ['Rtype'] == 2) {
  3586. return '/remitApproval/' . $rd ['rid'];
  3587. } else {
  3588. return '/receiptburEdi/' . $rd ['rid'];
  3589. }
  3590. // return "/approvalExpenses/pendApproval";
  3591. }
  3592. }
  3593. function ajaxExamineExe() {
  3594. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3595. Doo::loadModel ( 'receipt' );
  3596. $receipt = new receipt ();
  3597. Doo::loadClass ( 'XDeode' );
  3598. $XDeode = new XDeode ( 5 );
  3599. if (! empty ( $rid )) {
  3600. $rLRes = $receipt->find ( array (
  3601. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  3602. 'asArray' => true
  3603. ) );
  3604. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  3605. echo json_encode ( array (
  3606. 'status' => 1,
  3607. 'receipt' => $rLRes [0]
  3608. ) );
  3609. die ();
  3610. }
  3611. echo json_encode ( array (
  3612. 'status' => 0,
  3613. 'receipt' => array ()
  3614. ) );
  3615. die ();
  3616. }
  3617. function implement() {
  3618. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3619. Doo::loadClass ( 'XDeode' );
  3620. $XDeode = new XDeode ( 5 );
  3621. Doo::loadModel ( 'receipt' );
  3622. $receipt = new receipt ();
  3623. Doo::loadModel ( 'L_category' );
  3624. $Lcategory = new L_category ();
  3625. Doo::loadModel ( 'verify' );
  3626. $verify = new verify ();
  3627. Doo::loadModel ( 'staff' );
  3628. $staff = new staff ();
  3629. Doo::loadModel ( "execute" );
  3630. $execute = new execute ();
  3631. $rid = $XDeode->decode ( $rid );
  3632. $receiptList = $receipt->find ( array (
  3633. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  3634. 'desc' => 'rid',
  3635. 'asArray' => true
  3636. ) );
  3637. Doo::loadModel ( 'loanReceipt' );
  3638. $loanReceipt = new loanReceipt ();
  3639. // print_r($receiptList);
  3640. $loanList = array ();
  3641. if (! isset ( $receiptList ))
  3642. $loanList = $loanReceipt->find ( array (
  3643. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3644. 'desc' => 'rid',
  3645. 'asArray' => true
  3646. ) );
  3647. $Locate = 0;
  3648. $roleId = 0;
  3649. $button = 0;
  3650. foreach ( $loanList as $key => $value ) {
  3651. $loanList [$key] ['Locate'] = $Locate;
  3652. $Locate ++;
  3653. $loanList [$key] ['reviseDetail'] = array ();
  3654. if (! empty ( $value ['reviseDetail'] ))
  3655. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3656. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3657. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3658. $categoryDetil = $Lcategory->getOne ( array (
  3659. 'where' => 'cid=' . $value ['cid'],
  3660. 'asArray' => true
  3661. ) );
  3662. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3663. // 检测编辑状态
  3664. $verifyList = $verify->getOne ( array (
  3665. 'where' => 'vid=' . $value ['verify'],
  3666. 'asArray' => true
  3667. ) );
  3668. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3669. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3670. Doo::loadModel ( 'role' );
  3671. $role = new role ();
  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. $loanList [$key] ['verifyList'] = $verifyList;
  3793. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3794. 'where' => 'sid=' . $value ['staff'],
  3795. 'asArray' => true
  3796. ) );
  3797. }
  3798. $data ['loanList'] = $loanList;
  3799. $Locate = 0;
  3800. $roleId = 0;
  3801. $button = 0;
  3802. foreach ( $receiptList as $key => $value ) {
  3803. $button2 = 0;
  3804. $receiptList [$key] ['Locate'] = $Locate;
  3805. $Locate ++;
  3806. $receiptList [$key] ['reviseDetail'] = array ();
  3807. if (! empty ( $value ['reviseDetail'] ))
  3808. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3809. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3810. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3811. $categoryDetil = $Lcategory->getOne ( array (
  3812. 'where' => 'cid=' . $value ['cid'],
  3813. 'asArray' => true
  3814. ) );
  3815. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3816. $executeList = json_decode ( $value ['executeCopy'], true );
  3817. $executeStaff = array ();
  3818. if (! empty ( $value ['executeStaff'] ))
  3819. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3820. if (isset ( $executeList )) {
  3821. foreach ( $executeList as $op => $lo ) {
  3822. $executeList [$op] ['date'] = "";
  3823. $executeList [$op] ['opinion'] = "";
  3824. $executeList [$op] ['status'] = "";
  3825. foreach ( $executeStaff as $m => $u ) {
  3826. if ($lo [0] == $m) {
  3827. $executeList [$op] ['date'] = $u ['date'];
  3828. $executeList [$op] ['opinion'] = $u ['opinion'];
  3829. $executeList [$op] ['status'] = $u ['status'];
  3830. break;
  3831. }
  3832. }
  3833. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  3834. $button2 = 1;
  3835. $executeList [$op] ['status'] = 4;
  3836. }
  3837. }
  3838. }
  3839. // 检测编辑状态
  3840. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3841. $verifyList ['staff'] = $value ['verifyBreakup'];
  3842. } else
  3843. $verifyList = $verify->getOne ( array (
  3844. 'where' => 'vid=' . $value ['verify'],
  3845. 'asArray' => true
  3846. ) );
  3847. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3848. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3849. Doo::loadModel ( 'role' );
  3850. $role = new role ();
  3851. if ($verifyList == NULL)
  3852. $verifyList = array ();
  3853. $flag = true;
  3854. $roleKey = 0;
  3855. $endStaffArray = array ();
  3856. $roleArrayCopy = array ();
  3857. foreach ( $verifyList as $k => $v ) {
  3858. // init verifyStaff
  3859. if ($v [1] == 'ROLE') {
  3860. if (! empty ( $verifyStaff )) {
  3861. $endStaffArray = end ( $verifyStaff );
  3862. // if ($v[0]==$endStaffArray['nextStaff']){
  3863. // $roleId=$v[0];
  3864. // }
  3865. }
  3866. $roleVerify = json_decode ( $v [3], true );
  3867. $roleKey = $k;
  3868. $roleArray = array ();
  3869. $rolename = $role->getOne ( array (
  3870. 'where' => 'rid=' . $v [0],
  3871. 'asArray' => true
  3872. ) );
  3873. foreach ( $roleVerify as $o => $p ) {
  3874. $staffID = explode ( '_', $p );
  3875. $staffInfo = $staff->getOne ( array (
  3876. 'where' => 'sid=' . $staffID [0],
  3877. 'asArray' => true
  3878. ) );
  3879. // print_r($staffID);
  3880. $exp = array (
  3881. 0 => $staffInfo ['sid'],
  3882. 1 => $staffID [1],
  3883. 2 => $staffInfo ['avatar'],
  3884. 'date' => '',
  3885. 'date' => '',
  3886. 'opinion' => '',
  3887. 'status' => '',
  3888. 'rolename' => $rolename ['name']
  3889. );
  3890. array_push ( $roleArray, $exp );
  3891. }
  3892. $roleArrayCopy [$v [0]] = $roleArray;
  3893. // $verifyList[$k]['roleArray']=$roleArray;
  3894. }
  3895. $verifyList [$k] ['date'] = "";
  3896. $verifyList [$k] ['opinion'] = "";
  3897. $verifyList [$k] ['status'] = "";
  3898. if (empty ( $verifyStaff )) {
  3899. $verifyList [$k] ['date'] = "";
  3900. $verifyList [$k] ['opinion'] = "";
  3901. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3902. $verifyList [$k] ['status'] = 4;
  3903. $flag = false;
  3904. }
  3905. } else {
  3906. foreach ( $verifyStaff as $m => $u ) {
  3907. if ($v [0] == $m) {
  3908. $verifyList [$k] ['date'] = $u ['date'];
  3909. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3910. $verifyList [$k] ['status'] = $u ['status'];
  3911. $flag = false;
  3912. break;
  3913. }
  3914. }
  3915. $endStaffArray = end ( $verifyStaff );
  3916. if (isset ( $endStaffArray ['ROLE'] )) {
  3917. } else {
  3918. // $endKey=key($verifyStaff);
  3919. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3920. // $button=4;
  3921. // $verifyList[$k]['status']=4;
  3922. // }
  3923. }
  3924. }
  3925. }
  3926. $rolename ['name'] = '';
  3927. if (! empty ( $roleId )) {
  3928. Doo::loadModel ( 'role' );
  3929. $role = new role ();
  3930. $rolename = $role->getOne ( array (
  3931. 'where' => 'rid=' . $roleId,
  3932. 'asArray' => true
  3933. ) );
  3934. }
  3935. if (! empty ( $verifyStaff ))
  3936. $endStaffArray = end ( $verifyStaff );
  3937. $KOP = false;
  3938. foreach ( $roleArrayCopy as $P => $A ) {
  3939. foreach ( $A as $MKI => $AVL ) {
  3940. if (! empty ( $verifyStaff )) {
  3941. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3942. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3943. $button = 4;
  3944. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3945. }
  3946. foreach ( $verifyStaff as $m => $u ) {
  3947. $AVLFK = $AVL [0] . '_R';
  3948. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3949. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3950. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3951. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3952. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3953. break;
  3954. }
  3955. }
  3956. } else {
  3957. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3958. $button = 4;
  3959. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3960. }
  3961. }
  3962. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3963. $KOP = true;
  3964. }
  3965. }
  3966. foreach ( $roleArrayCopy as $k => $v ) {
  3967. foreach ( $verifyList as $m => $n ) {
  3968. if ($n [0] == $k) {
  3969. array_splice ( $verifyList, $m, 1, $v );
  3970. }
  3971. }
  3972. }
  3973. $receiptList [$key] ['verifyList'] = $verifyList;
  3974. $receiptList [$key] ['executeList'] = $executeList;
  3975. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3976. 'where' => 'sid=' . $value ['staff'],
  3977. 'asArray' => true
  3978. ) );
  3979. $receiptList [$key] ['button2'] = $button2;
  3980. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3981. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3982. $relust = $value ['sum'] - $value ['loanSum'];
  3983. $receiptList [$key] ['relust'] = $relust;
  3984. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  3985. }
  3986. // print_r($receiptList[$key]['executeList']);
  3987. $data ['receiptList'] = $receiptList;
  3988. $data ['memu'] = "receipt";
  3989. $data ['staff'] = $this->staff;
  3990. $data ['receiptMemu'] = 'implement';
  3991. $data ['verifyId'] = $this->verifyId;
  3992. $data ['executeId'] = $this->executeId;
  3993. $this->render ( "/admin/implement", $data );
  3994. }
  3995. function implementDo() {
  3996. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3997. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3998. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  3999. if (! empty ( $rid ) && $amount != '') {
  4000. Doo::loadModel ( 'receipt' );
  4001. $receipt = new receipt ();
  4002. Doo::loadClass ( 'XDeode' );
  4003. $XDeode = new XDeode ( 5 );
  4004. $rinfo = $receipt->getOne ( array (
  4005. 'where' => 'rid=' . $rid,
  4006. 'asArray' => true
  4007. ) );
  4008. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  4009. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  4010. if (empty ( $executeStaff )) {
  4011. $executeStaff = array (
  4012. $this->staff [0] ['sid'] => array (
  4013. 'date' => date ( 'Y-m-d' ),
  4014. 'opinion' => $implementOpinions,
  4015. 'status' => 1
  4016. )
  4017. );
  4018. } else {
  4019. $executeStaff [$this->staff [0] ['sid']] = array (
  4020. 'date' => date ( 'Y-m-d' ),
  4021. 'opinion' => $implementOpinions,
  4022. 'status' => 1
  4023. );
  4024. }
  4025. if (count ( $executeStaff ) == count ( $executeCopy )) {
  4026. $receipt->executeStaff = json_encode ( $executeStaff );
  4027. $receipt->status = 8;
  4028. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  4029. $receipt->status = 9;
  4030. if ($rinfo ['status'] == 6) {
  4031. $receipt->loanDate = date ( "Y-m-d" );
  4032. }
  4033. $receipt->executeDate = date ( "Y-m-d" );
  4034. } else {
  4035. $receipt->executeStaff = json_encode ( $executeStaff );
  4036. }
  4037. $receipt->amount = $amount;
  4038. $receipt->update ( array (
  4039. 'where' => 'rid=' . $rid
  4040. ) );
  4041. }
  4042. $ridKey = $XDeode->encode ( $rid );
  4043. return "/hisImplement";
  4044. // return "/implement/" . $ridKey . ".html";
  4045. }
  4046. function receiptburEdi() {
  4047. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4048. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  4049. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4050. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4051. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4052. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4053. if (empty ( $status ))
  4054. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  4055. $vidList = array ();
  4056. $button = 0;
  4057. Doo::loadModel ( 'verify' );
  4058. Doo::loadModel ( 'receipt' );
  4059. Doo::loadModel ( 'staff' );
  4060. $staff = new staff ();
  4061. $receipt = new receipt ();
  4062. $verify = new verify ();
  4063. Doo::loadModel ( 'L_category' );
  4064. $Lcategory = new L_category ();
  4065. Doo::loadModel ( 'enclosur' );
  4066. $enclosur = new enclosur ();
  4067. Doo::loadModel ( 'loanReceipt' );
  4068. $loanReceipt = new loanReceipt ();
  4069. // user verify ID
  4070. $verifyDetail = $verify->find ( array (
  4071. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  4072. 'asArray' => true
  4073. ) );
  4074. foreach ( $verifyDetail as $key => $value ) {
  4075. array_push ( $vidList, $value ['vid'] );
  4076. }
  4077. $vid = implode ( ",", $vidList );
  4078. if (empty ( $verifyDetail ))
  4079. $vid = 0;
  4080. $categoryList = $Lcategory->find ( array (
  4081. 'asArray' => true
  4082. ) );
  4083. $staffList = $staff->find ( array (
  4084. 'where' => 'cid=' . $cid,
  4085. 'asArray' => true
  4086. ) );
  4087. $ap = "";
  4088. if ($status == 4) {
  4089. $ap = 4;
  4090. $status = 2;
  4091. }
  4092. // get Receipt By verifyID status 2
  4093. $receiptList = $receipt->find ( array (
  4094. 'where' => 'rid =' . $rid . ' and status=2',
  4095. 'desc' => 'rid',
  4096. 'asArray' => true
  4097. ) );
  4098. if (empty ( $receiptList )) {
  4099. die ( 'illegal request' );
  4100. }
  4101. $loanList = $loanReceipt->find ( array (
  4102. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4103. 'desc' => 'rid',
  4104. 'asArray' => true
  4105. ) );
  4106. $data ['explanation'] ='';
  4107. if (!empty($loanList))
  4108. $data ['explanation'] = $loanList[0]['explanation'];
  4109. $Locate = 0;
  4110. $roleId = 0;
  4111. $button = 0;
  4112. foreach ( $loanList as $key => $value ) {
  4113. $loanList [$key] ['Locate'] = $Locate;
  4114. $Locate ++;
  4115. $loanList [$key] ['reviseDetail'] = array ();
  4116. if (! empty ( $value ['reviseDetail'] ))
  4117. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4118. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4119. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4120. $categoryDetil = $Lcategory->getOne ( array (
  4121. 'where' => 'cid=' . $value ['cid'],
  4122. 'asArray' => true
  4123. ) );
  4124. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4125. // 检测编辑状态
  4126. $verifyList = $verify->getOne ( array (
  4127. 'where' => 'vid=' . $value ['verify'],
  4128. 'asArray' => true
  4129. ) );
  4130. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4131. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4132. Doo::loadModel ( 'role' );
  4133. $role = new role ();
  4134. $flag = true;
  4135. $roleKey = 0;
  4136. $endStaffArray = array ();
  4137. $roleArrayCopy = array ();
  4138. foreach ( $verifyList as $k => $v ) {
  4139. // init verifyStaff
  4140. if ($v [1] == 'ROLE') {
  4141. if (! empty ( $verifyStaff )) {
  4142. $endStaffArray = end ( $verifyStaff );
  4143. }
  4144. $roleVerify = json_decode ( $v [3], true );
  4145. $roleKey = $k;
  4146. $roleArray = array ();
  4147. $rolename = $role->getOne ( array (
  4148. 'where' => 'rid=' . $v [0],
  4149. 'asArray' => true
  4150. ) );
  4151. foreach ( $roleVerify as $o => $p ) {
  4152. $staffID = explode ( '_', $p );
  4153. $staffInfo = $staff->getOne ( array (
  4154. 'where' => 'sid=' . $staffID [0],
  4155. 'asArray' => true
  4156. ) );
  4157. // print_r($staffID);
  4158. $exp = array (
  4159. 0 => $staffInfo ['sid'],
  4160. 1 => $staffID [1],
  4161. 2 => $staffInfo ['avatar'],
  4162. 'date' => '',
  4163. 'date' => '',
  4164. 'opinion' => '',
  4165. 'status' => '',
  4166. 'rolename' => $rolename ['name']
  4167. );
  4168. array_push ( $roleArray, $exp );
  4169. }
  4170. $roleArrayCopy [$v [0]] = $roleArray;
  4171. // $verifyList[$k]['roleArray']=$roleArray;
  4172. }
  4173. $verifyList [$k] ['date'] = "";
  4174. $verifyList [$k] ['opinion'] = "";
  4175. $verifyList [$k] ['status'] = "";
  4176. if (empty ( $verifyStaff )) {
  4177. $verifyList [$k] ['date'] = "";
  4178. $verifyList [$k] ['opinion'] = "";
  4179. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4180. $verifyList [$k] ['status'] = 4;
  4181. $flag = false;
  4182. }
  4183. } else {
  4184. foreach ( $verifyStaff as $m => $u ) {
  4185. if ($v [0] == $m) {
  4186. $verifyList [$k] ['date'] = $u ['date'];
  4187. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4188. $verifyList [$k] ['status'] = $u ['status'];
  4189. $flag = false;
  4190. break;
  4191. }
  4192. }
  4193. $endStaffArray = end ( $verifyStaff );
  4194. if (isset ( $endStaffArray ['ROLE'] )) {
  4195. } else {
  4196. }
  4197. }
  4198. }
  4199. $rolename ['name'] = '';
  4200. if (! empty ( $roleId )) {
  4201. Doo::loadModel ( 'role' );
  4202. $role = new role ();
  4203. $rolename = $role->getOne ( array (
  4204. 'where' => 'rid=' . $roleId,
  4205. 'asArray' => true
  4206. ) );
  4207. }
  4208. if (! empty ( $verifyStaff ))
  4209. $endStaffArray = end ( $verifyStaff );
  4210. $KOP = false;
  4211. foreach ( $roleArrayCopy as $P => $A ) {
  4212. foreach ( $A as $MKI => $AVL ) {
  4213. if (! empty ( $verifyStaff )) {
  4214. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4215. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4216. $button = 4;
  4217. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4218. }
  4219. foreach ( $verifyStaff as $m => $u ) {
  4220. $AVLFK = $AVL [0] . '_R';
  4221. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4222. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4223. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4224. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4225. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4226. break;
  4227. }
  4228. }
  4229. } else {
  4230. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4231. $button = 4;
  4232. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4233. }
  4234. }
  4235. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4236. $KOP = true;
  4237. }
  4238. }
  4239. foreach ( $roleArrayCopy as $k => $v ) {
  4240. foreach ( $verifyList as $m => $n ) {
  4241. if ($n [0] == $k) {
  4242. array_splice ( $verifyList, $m, 1, $v );
  4243. }
  4244. }
  4245. }
  4246. $loanList [$key] ['verifyList'] = $verifyList;
  4247. }
  4248. $htmlLoan = '';
  4249. if (isset ( $loanList [0] )) {
  4250. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  4251. if ($value ['status'] == 1)
  4252. $htmlLoan .= '<li class="done" >';
  4253. elseif ($value ['status'] == 3)
  4254. $htmlLoan .= '<li class="undone" >';
  4255. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  4256. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  4257. if (isset ( $value ['rolename'] ))
  4258. $htmlLoan .= $value ['rolename'];
  4259. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  4260. }
  4261. $data ['loanDate'] = $loanList [0] ['date'];
  4262. }else{
  4263. $data ['loanReceiptDate'] =''; //$loanList [0] ['date'];
  4264. }
  4265. $data ['htmlLoan'] = $htmlLoan;
  4266. // $data ['LoanReceipt']=$loanList[0];
  4267. // print_r($loanList);
  4268. $Locate = 0;
  4269. $roleId = 0;
  4270. $button = 0;
  4271. if ($ap == 4)
  4272. $status = 4;
  4273. Doo::loadClass ( 'XDeode' );
  4274. $XDeode = new XDeode ( 5 );
  4275. foreach ( $receiptList as $key => $value ) {
  4276. $receiptList[$key]['ridKey']=$XDeode->encode ( $value ['rid'] );
  4277. $receiptList [$key] ['Locate'] = $Locate;
  4278. $Locate ++;
  4279. $receiptList [$key] ['reviseDetail'] = array ();
  4280. //调整金额 代码调整
  4281. if (! empty ( $value ['reviseDetail'] )){
  4282. $reviseDetail=json_decode ( $value ['reviseDetail'], true );
  4283. foreach ($reviseDetail as $ry=>$re){
  4284. $reviseDetail[$ry]['sidKey']=$XDeode->encode ( $re ['sid'] );
  4285. $reviseDetail[$ry]['reviseKey']=$XDeode->encode ($ry);
  4286. }
  4287. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  4288. //print_r($reviseDetail);
  4289. }
  4290. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4291. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4292. $categoryDetil = $Lcategory->getOne ( array (
  4293. 'where' => 'cid=' . $value ['cid'],
  4294. 'asArray' => true
  4295. ) );
  4296. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4297. // 检测编辑状态
  4298. $verifyList = $verify->getOne ( array (
  4299. 'where' => 'vid=' . $value ['verify'],
  4300. 'asArray' => true
  4301. ) );
  4302. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4303. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4304. Doo::loadModel ( 'role' );
  4305. $role = new role ();
  4306. // print_r($verifyList);
  4307. $flag = true;
  4308. $roleKey = 0;
  4309. $endStaffArray = array ();
  4310. $roleArrayCopy = array ();
  4311. foreach ( $verifyList as $k => $v ) {
  4312. // init verifyStaff
  4313. if ($v [1] == 'ROLE') {
  4314. if (! empty ( $verifyStaff )) {
  4315. $endStaffArray = end ( $verifyStaff );
  4316. if ($v [0] == $endStaffArray ['nextStaff']) {
  4317. $roleId = $v [0];
  4318. }
  4319. }
  4320. $roleVerify = json_decode ( $v [3], true );
  4321. $roleKey = $k;
  4322. $roleArray = array ();
  4323. $rolename = $role->getOne ( array (
  4324. 'where' => 'rid=' . $v [0],
  4325. 'asArray' => true
  4326. ) );
  4327. foreach ( $roleVerify as $o => $p ) {
  4328. $staffID = explode ( '_', $p );
  4329. $staffInfo = $staff->getOne ( array (
  4330. 'where' => 'sid=' . $staffID [0],
  4331. 'asArray' => true
  4332. ) );
  4333. // print_r($staffID);
  4334. $exp = array (
  4335. 0 => $staffInfo ['sid'],
  4336. 1 => $staffID [1],
  4337. 2 => $staffInfo ['avatar'],
  4338. 'date' => '',
  4339. 'date' => '',
  4340. 'opinion' => '',
  4341. 'status' => '',
  4342. 'rolename' => $rolename ['name']
  4343. );
  4344. array_push ( $roleArray, $exp );
  4345. }
  4346. $roleArrayCopy [$v [0]] = $roleArray;
  4347. // $verifyList[$k]['roleArray']=$roleArray;
  4348. }
  4349. // print_r($roleArray);
  4350. $verifyList [$k] ['date'] = "";
  4351. $verifyList [$k] ['opinion'] = "";
  4352. $verifyList [$k] ['status'] = "";
  4353. if (empty ( $verifyStaff )) {
  4354. $verifyList [$k] ['date'] = "";
  4355. $verifyList [$k] ['opinion'] = "";
  4356. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4357. $verifyList [$k] ['status'] = 4;
  4358. $button = 4;
  4359. $flag = false;
  4360. }
  4361. } else {
  4362. foreach ( $verifyStaff as $m => $u ) {
  4363. if ($v [0] == $m) {
  4364. $verifyList [$k] ['date'] = $u ['date'];
  4365. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4366. $verifyList [$k] ['status'] = $u ['status'];
  4367. $flag = false;
  4368. break;
  4369. }
  4370. }
  4371. $endStaffArray = end ( $verifyStaff );
  4372. if (isset ( $endStaffArray ['ROLE'] )) {
  4373. } else {
  4374. $endKey = key ( $verifyStaff );
  4375. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4376. $button = 4;
  4377. $verifyList [$k] ['status'] = 4;
  4378. }
  4379. }
  4380. }
  4381. }
  4382. $rolename ['name'] = '';
  4383. if (! empty ( $roleId )) {
  4384. Doo::loadModel ( 'role' );
  4385. $role = new role ();
  4386. $rolename = $role->getOne ( array (
  4387. 'where' => 'rid=' . $roleId,
  4388. 'asArray' => true
  4389. ) );
  4390. }
  4391. if (! empty ( $verifyStaff ))
  4392. $endStaffArray = end ( $verifyStaff );
  4393. $KOP = false;
  4394. foreach ( $roleArrayCopy as $P => $A ) {
  4395. foreach ( $A as $MKI => $AVL ) {
  4396. if (! empty ( $verifyStaff )) {
  4397. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4398. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4399. $button = 4;
  4400. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4401. }
  4402. foreach ( $verifyStaff as $m => $u ) {
  4403. $AVLFK = $AVL [0] . '_R';
  4404. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4405. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4406. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4407. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4408. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4409. break;
  4410. }
  4411. }
  4412. } else {
  4413. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4414. $button = 4;
  4415. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4416. }
  4417. }
  4418. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4419. $KOP = true;
  4420. }
  4421. }
  4422. foreach ( $roleArrayCopy as $k => $v ) {
  4423. foreach ( $verifyList as $m => $n ) {
  4424. if ($n [0] == $k) {
  4425. array_splice ( $verifyList, $m, 1, $v );
  4426. }
  4427. }
  4428. }
  4429. // print_r($verifyList);
  4430. $receiptList [$key] ['verifyList'] = $verifyList;
  4431. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4432. 'where' => 'sid=' . $value ['staff'],
  4433. 'asArray' => true
  4434. ) );
  4435. $receiptList [$key] ['button'] = $button;
  4436. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4437. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4438. $relust = $value ['sum'] - $value ['loanSum'];
  4439. $receiptList [$key] ['relust'] = $relust;
  4440. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4441. }
  4442. // print_r($receiptList);die;
  4443. // $data['verifyDetail']=$verifyDetail;
  4444. $mothHtml = "";
  4445. for($i = 1; $i <= 12; $i ++) {
  4446. if ($month == $i)
  4447. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4448. else
  4449. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4450. }
  4451. // 获取审批日志
  4452. Doo::loadModel ( 'receiptLog' );
  4453. $receiptLog = new receiptLog ();
  4454. $rlList = array ();
  4455. $rlInfo = $receiptLog->getOne ( array (
  4456. 'where' => 'rid=' . $rid . ' and status=4',
  4457. 'asArray' => true
  4458. ) );
  4459. $tijdate = $receiptLog->getOne ( array (
  4460. 'where' => 'rid=' . $rid . ' and status=2',
  4461. 'asc' => 'rlid',
  4462. 'asArray' => true
  4463. ) );
  4464. if (! empty ( $rlInfo )) {
  4465. $rlList = $receiptLog->find ( array (
  4466. 'where' => 'rid=' . $rid,
  4467. 'asc' => 'rlid',
  4468. 'asArray' => true
  4469. ) );
  4470. }
  4471. // echo $rid;
  4472. // print_r($receiptList);
  4473. $receiptList [0] ['rlList'] = $rlList;
  4474. // print_r($receiptList);
  4475. $enclosurList = $enclosur->find ( array (
  4476. 'where' => 'rid=' . $rid,
  4477. 'asArray' => true
  4478. ) );
  4479. $enclosurHtml = '';
  4480. foreach ( $enclosurList as $value ) {
  4481. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4482. }
  4483. $data ['enclosurHtml'] = $enclosurHtml;
  4484. $data ['rolename'] = $rolename ['name'];
  4485. $data ['mothHtml'] = $mothHtml;
  4486. // print_r($receiptList);
  4487. $data ['rid'] = $rid;
  4488. $data ['tijdate'] = $tijdate ['date'];
  4489. $data ['receiptList'] = $receiptList;
  4490. $data ['receiptApprovalCount'] = count ( $receiptList );
  4491. $data ['status'] = $status;
  4492. $data ['year'] = $year;
  4493. $data ['categoryList'] = $categoryList;
  4494. $data ['staffList'] = $staffList;
  4495. $data ['cid'] = $cid;
  4496. $data ['sid'] = $sid;
  4497. $data ['ap'] = $ap;
  4498. $data ['memu'] = "receipt";
  4499. $data ['staff'] = $this->staff;
  4500. $data ['receiptMemu'] = 'approvalExpenses';
  4501. $data ['verifyId'] = $this->verifyId;
  4502. $data ['executeId'] = $this->executeId;
  4503. $this->render ( "/admin/receiptburEdi", $data );
  4504. }
  4505. function hisImplement() {
  4506. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4507. if (empty ( $item ))
  4508. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "expenses";
  4509. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  4510. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4511. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  4512. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  4513. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  4514. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'pendImplement';
  4515. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  4516. Doo::loadClass ( 'XDeode' );
  4517. $XDeode = new XDeode ( 5 );
  4518. Doo::loadModel ( 'receipt' );
  4519. $receipt = new receipt ();
  4520. Doo::loadModel ( 'L_category' );
  4521. $Lcategory = new L_category ();
  4522. Doo::loadModel ( 'verify' );
  4523. Doo::loadModel ( 'statistics' );
  4524. $statistics = new statistics ();
  4525. $verify = new verify ();
  4526. Doo::loadModel ( 'staff' );
  4527. $staff = new staff ();
  4528. Doo::loadClass ( 'XDeode' );
  4529. $XDeode = new XDeode ( 5 );
  4530. $cid = $XDeode->decode ( $cidKey );
  4531. $condition = "";
  4532. if ($item == "expenses")
  4533. $condition = " and Rtype=1 ";
  4534. elseif ($item == "receipts")
  4535. $condition = " and Rtype=0 ";
  4536. elseif ($item == "remits")
  4537. $condition = " and Rtype=2 ";
  4538. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  4539. $sopString =$cidString= "";
  4540. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  4541. if (empty ( $rdate ))
  4542. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  4543. else
  4544. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  4545. if($status=='pendImplement'){
  4546. $condition .= ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  4547. }elseif($status == 'alerpts'){
  4548. $statusCon = '(status=8 or status=9 )';
  4549. if (empty ( $rdate ))
  4550. $dateCondition .= " and Year(date) =" . $year;
  4551. else
  4552. $dateCondition .= " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  4553. }
  4554. if ($sop != 'SOP')
  4555. $sopString = " and staff=" . $sop;
  4556. if ($cidKey != 'ALL')
  4557. $cidString = " and cid=" . $cid;
  4558. $receiptList = $receipt->find ( array (
  4559. 'where' => $statusCon . $condition . $dateCondition . $sopString.$cidString,
  4560. 'desc' => 'rid',
  4561. 'asArray' => true
  4562. ) );
  4563. // 员工筛选
  4564. $receiptList2 = $receipt->find ( array (
  4565. 'where' => $statusCon . $condition . $dateCondition,
  4566. 'desc' => 'rid',
  4567. 'asArray' => true
  4568. ) );
  4569. $sopStaff = array ();
  4570. foreach ( $receiptList2 as $key => $value ) {
  4571. $staffDetail = $staff->getOne ( array (
  4572. 'select'=>'username',
  4573. 'where' => 'sid=' . $value ['staff'],
  4574. 'asArray' => true
  4575. ) );
  4576. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  4577. }
  4578. //办事处筛选
  4579. $categoryScreen=array();
  4580. $categorList=$Lcategory->getCategory();
  4581. foreach ( $receiptList2 as $key => $value ) {
  4582. foreach ($categorList as $k=>$v){
  4583. if ($value['cid']==$v['cid']){
  4584. $categoryScreen[$v['cidKey']]=$v['title'];
  4585. break;
  4586. }
  4587. }
  4588. }
  4589. $categoryScreenHtml = "";
  4590. foreach ( $categoryScreen as $key => $value ) {
  4591. if ($cidKey == $key)
  4592. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4593. else
  4594. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4595. }
  4596. $data['categoryScreenHtml']=$categoryScreenHtml;
  4597. $data['cidKey']=$cidKey;
  4598. $Locate = 0;
  4599. $roleId = 0;
  4600. $button = 0;
  4601. $staffBatchNumber=100001;
  4602. $remittanceList=array();
  4603. foreach ( $receiptList as $key => $value ) {
  4604. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4605. $receiptList [$key] ['Texe'] = 'false';
  4606. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  4607. $receiptList [$key] ['Texe'] = 'true';
  4608. }
  4609. $receiptList [$key] ['TRexe'] = 'true';
  4610. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  4611. $receiptList [$key] ['TRexe'] = 'false';
  4612. }
  4613. $receiptList [$key] ['Locate'] = $Locate;
  4614. $Locate ++;
  4615. $receiptList [$key] ['reviseDetail'] = array ();
  4616. if (! empty ( $value ['reviseDetail'] ))
  4617. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4618. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4619. $categoryDetil = $Lcategory->getOne ( array (
  4620. 'where' => 'cid=' . $value ['cid'],
  4621. 'asArray' => true
  4622. ) );
  4623. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4624. // 检测编辑状态
  4625. $verifyList = $verify->getOne ( array (
  4626. 'where' => 'vid=' . $value ['verify'],
  4627. 'asArray' => true
  4628. ) );
  4629. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4630. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4631. Doo::loadModel ( 'role' );
  4632. $role = new role ();
  4633. $flag = true;
  4634. $roleKey = 0;
  4635. $endStaffArray = array ();
  4636. $roleArrayCopy = array ();
  4637. foreach ( $verifyList as $k => $v ) {
  4638. // init verifyStaff
  4639. if ($v [1] == 'ROLE') {
  4640. if (! empty ( $verifyStaff )) {
  4641. $endStaffArray = end ( $verifyStaff );
  4642. }
  4643. $roleVerify = json_decode ( $v [3], true );
  4644. $roleKey = $k;
  4645. $roleArray = array ();
  4646. $rolename = $role->getOne ( array (
  4647. 'where' => 'rid=' . $v [0],
  4648. 'asArray' => true
  4649. ) );
  4650. foreach ( $roleVerify as $o => $p ) {
  4651. $staffID = explode ( '_', $p );
  4652. $staffInfo = $staff->getOne ( array (
  4653. 'where' => 'sid=' . $staffID [0],
  4654. 'asArray' => true
  4655. ) );
  4656. $exp = array (
  4657. 0 => $staffInfo ['sid'],
  4658. 1 => $staffID [1],
  4659. 2 => $staffInfo ['avatar'],
  4660. 'date' => '',
  4661. 'date' => '',
  4662. 'opinion' => '',
  4663. 'status' => '',
  4664. 'rolename' => $rolename ['name']
  4665. );
  4666. array_push ( $roleArray, $exp );
  4667. }
  4668. $roleArrayCopy [$v [0]] = $roleArray;
  4669. }
  4670. $verifyList [$k] ['date'] = "";
  4671. $verifyList [$k] ['opinion'] = "";
  4672. $verifyList [$k] ['status'] = "";
  4673. if (empty ( $verifyStaff )) {
  4674. $verifyList [$k] ['date'] = "";
  4675. $verifyList [$k] ['opinion'] = "";
  4676. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4677. $verifyList [$k] ['status'] = 4;
  4678. $flag = false;
  4679. }
  4680. } else {
  4681. foreach ( $verifyStaff as $m => $u ) {
  4682. if ($v [0] == $m) {
  4683. $verifyList [$k] ['date'] = $u ['date'];
  4684. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4685. $verifyList [$k] ['status'] = $u ['status'];
  4686. $flag = false;
  4687. break;
  4688. }
  4689. }
  4690. $endStaffArray = end ( $verifyStaff );
  4691. }
  4692. }
  4693. $rolename ['name'] = '';
  4694. if (! empty ( $roleId )) {
  4695. Doo::loadModel ( 'role' );
  4696. $role = new role ();
  4697. $rolename = $role->getOne ( array (
  4698. 'where' => 'rid=' . $roleId,
  4699. 'asArray' => true
  4700. ) );
  4701. }
  4702. if (! empty ( $verifyStaff ))
  4703. $endStaffArray = end ( $verifyStaff );
  4704. $KOP = false;
  4705. foreach ( $roleArrayCopy as $P => $A ) {
  4706. foreach ( $A as $MKI => $AVL ) {
  4707. if (! empty ( $verifyStaff )) {
  4708. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4709. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4710. $button = 4;
  4711. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4712. }
  4713. foreach ( $verifyStaff as $m => $u ) {
  4714. $AVLFK = $AVL [0] . '_R';
  4715. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4716. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4717. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4718. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4719. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4720. break;
  4721. }
  4722. }
  4723. } else {
  4724. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4725. $button = 4;
  4726. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4727. }
  4728. }
  4729. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4730. $KOP = true;
  4731. }
  4732. }
  4733. foreach ( $roleArrayCopy as $k => $v ) {
  4734. foreach ( $verifyList as $m => $n ) {
  4735. if ($n [0] == $k) {
  4736. array_splice ( $verifyList, $m, 1, $v );
  4737. }
  4738. }
  4739. }
  4740. $receiptList [$key] ['verifyList'] = $verifyList;
  4741. $staffDetail=$staff->getOne ( array (
  4742. 'where' => 'sid=' . $value ['staff'],
  4743. 'asArray' => true
  4744. ) );
  4745. $receiptList [$key] ['staffDetail'] =$staffDetail;
  4746. $receiptList [$key] ['button'] = $button;
  4747. //设置导出汇款execl
  4748. if (!empty($value['remittanceName'])&&!empty($value['bankName'])&&!empty($value['bankNumber'])){
  4749. $remittanceDetail=array($staffBatchNumber,$value['remittanceName'],$value['bankNumber'],$value['bankName'],$value['remittanceBankType'],$value['coupletNumber'],$value['sum']);
  4750. array_push($remittanceList, $remittanceDetail);
  4751. $staffBatchNumber++;
  4752. }
  4753. }
  4754. $data['remittanceList']=json_encode($remittanceList);
  4755. // print_r($receiptList);
  4756. $mothHtml = "";
  4757. for($i = 1; $i <= 12; $i ++) {
  4758. if ($moth == $i)
  4759. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4760. else
  4761. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4762. }
  4763. $dayHtml = "";
  4764. if ($day != "DAY" || $moth != "MONTH") {
  4765. for($i = 1; $i <= 31; $i ++) {
  4766. if ($day == $i)
  4767. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  4768. else
  4769. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  4770. }
  4771. }
  4772. $sopHtml = "";
  4773. foreach ( $sopStaff as $key => $value ) {
  4774. if ($sop == $key)
  4775. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4776. else
  4777. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4778. }
  4779. $data['status']=$status;
  4780. $data ['rdate'] = $rdate;
  4781. $data ['sopHtml'] = $sopHtml;
  4782. $data ['dayHtml'] = $dayHtml;
  4783. $data ['mothHtml'] = $mothHtml;
  4784. $data ['receiptList'] = $receiptList;
  4785. $data ['memu'] = "receipt";
  4786. $data ['staff'] = $this->staff;
  4787. $data ['receiptMemu'] = 'implement';
  4788. $data ['verifyId'] = $this->verifyId;
  4789. $data ['executeId'] = $this->executeId;
  4790. $data ['item'] = $item;
  4791. $data ['year'] = $year;
  4792. $data ['moth'] = $moth;
  4793. $data ['day'] = $day;
  4794. $data ['sop'] = $sop;
  4795. $this->render ( "/admin/hisImplement", $data );
  4796. }
  4797. /**
  4798. * 导出汇款信息的exelc
  4799. */
  4800. function exportRemittance(){
  4801. $remittanceInfo = $_POST['remittanceInfo'];//$this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  4802. if (empty ( $remittanceInfo ))
  4803. die ( 'illegal request' );
  4804. $title=array('员工编号','姓名','员工账号','员工账户开户行','转账类型','联行号','金额');
  4805. $data=json_decode($remittanceInfo,true);
  4806. if (empty ( $data ))
  4807. die ( 'illegal request' );
  4808. Doo::loadClass ( 'receipt.func' );
  4809. exportExcel($title,$data,'批量日常报销-公司账号','./',true);
  4810. header ( 'Content-Type:text/html;charset=utf-8' );
  4811. die ( '导出'.count($data).'条数据,<a href="/hisImplement">返回</a>' );
  4812. }
  4813. function ajaxExamine() {
  4814. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4815. Doo::loadModel ( 'receipt' );
  4816. $receipt = new receipt ();
  4817. if (! empty ( $rid )) {
  4818. $rLRes = $receipt->find ( array (
  4819. '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,
  4820. 'asArray' => true
  4821. ) );
  4822. echo json_encode ( array (
  4823. 'status' => 1,
  4824. 'receipt' => $rLRes [0]
  4825. ) );
  4826. die ();
  4827. }
  4828. echo json_encode ( array (
  4829. 'status' => 0,
  4830. 'receipt' => array ()
  4831. ) );
  4832. die ();
  4833. }
  4834. /*
  4835. * 废弃
  4836. */
  4837. function myReceipt() {
  4838. // all approval past withdraw
  4839. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4840. if (empty ( $item ))
  4841. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4842. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4843. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  4844. Doo::loadModel ( 'receipt' );
  4845. $receipt = new receipt ();
  4846. // pre-loaded
  4847. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4848. // have cache
  4849. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  4850. if (! empty ( $moth )) // yearPage
  4851. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  4852. $this->showCache ( $path );
  4853. }
  4854. Doo::loadModel ( 'L_category' );
  4855. $Lcategory = new L_category ();
  4856. Doo::loadModel ( 'verify' );
  4857. Doo::loadModel ( 'statistics' );
  4858. $statistics = new statistics ();
  4859. $verify = new verify ();
  4860. Doo::loadModel ( 'staff' );
  4861. $staff = new staff ();
  4862. $condition = " and status!=0 ";
  4863. if ($item == "approval")
  4864. $condition = " and status=2 ";
  4865. elseif ($item == "withdraw")
  4866. $condition = " and status=3 ";
  4867. elseif ($item == "past")
  4868. $condition = " and status=1 ";
  4869. elseif ($item == "whdw")
  4870. $condition = " and status=4 ";
  4871. $dateCondition = " and Year(date) =" . $year;
  4872. if (! empty ( $moth )) {
  4873. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  4874. $stList = $statistics->getOne ( array (
  4875. 'select' => 'rePrice ,agPrice',
  4876. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  4877. 'asArray' => true
  4878. ) );
  4879. } else
  4880. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  4881. if (empty ( $stList ))
  4882. $stList = array (
  4883. 'rePrice' => 0,
  4884. 'agPrice' => 0
  4885. );
  4886. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  4887. $data ['stList'] = array (
  4888. 'rePrice' => $stList ['rePrice'],
  4889. 'agPrice' => $stList ['agPrice'],
  4890. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  4891. );
  4892. $receiptList = $receipt->find ( array (
  4893. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  4894. 'desc' => 'rid',
  4895. 'asArray' => true
  4896. ) );
  4897. $Locate = 0;
  4898. $roleId = 0;
  4899. $button = 0;
  4900. foreach ( $receiptList as $key => $value ) {
  4901. $receiptList [$key] ['Locate'] = $Locate;
  4902. $Locate ++;
  4903. $receiptList [$key] ['reviseDetail'] = array ();
  4904. if (! empty ( $value ['reviseDetail'] ))
  4905. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4906. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4907. $categoryDetil = $Lcategory->getOne ( array (
  4908. 'where' => 'cid=' . $value ['cid'],
  4909. 'asArray' => true
  4910. ) );
  4911. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4912. // 检测编辑状态
  4913. $verifyList = $verify->getOne ( array (
  4914. 'where' => 'vid=' . $value ['verify'],
  4915. 'asArray' => true
  4916. ) );
  4917. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4918. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4919. Doo::loadModel ( 'role' );
  4920. $role = new role ();
  4921. $flag = true;
  4922. $roleKey = 0;
  4923. $endStaffArray = array ();
  4924. $roleArrayCopy = array ();
  4925. foreach ( $verifyList as $k => $v ) {
  4926. // init verifyStaff
  4927. if ($v [1] == 'ROLE') {
  4928. if (! empty ( $verifyStaff )) {
  4929. $endStaffArray = end ( $verifyStaff );
  4930. // if ($v[0]==$endStaffArray['nextStaff']){
  4931. // $roleId=$v[0];
  4932. // }
  4933. }
  4934. $roleVerify = json_decode ( $v [3], true );
  4935. $roleKey = $k;
  4936. $roleArray = array ();
  4937. $rolename = $role->getOne ( array (
  4938. 'where' => 'rid=' . $v [0],
  4939. 'asArray' => true
  4940. ) );
  4941. foreach ( $roleVerify as $o => $p ) {
  4942. $staffID = explode ( '_', $p );
  4943. $staffInfo = $staff->getOne ( array (
  4944. 'where' => 'sid=' . $staffID [0],
  4945. 'asArray' => true
  4946. ) );
  4947. // print_r($staffID);
  4948. $exp = array (
  4949. 0 => $staffInfo ['sid'],
  4950. 1 => $staffID [1],
  4951. 2 => $staffInfo ['avatar'],
  4952. 'date' => '',
  4953. 'date' => '',
  4954. 'opinion' => '',
  4955. 'status' => '',
  4956. 'rolename' => $rolename ['name']
  4957. );
  4958. array_push ( $roleArray, $exp );
  4959. }
  4960. $roleArrayCopy [$v [0]] = $roleArray;
  4961. // $verifyList[$k]['roleArray']=$roleArray;
  4962. }
  4963. $verifyList [$k] ['date'] = "";
  4964. $verifyList [$k] ['opinion'] = "";
  4965. $verifyList [$k] ['status'] = "";
  4966. if (empty ( $verifyStaff )) {
  4967. $verifyList [$k] ['date'] = "";
  4968. $verifyList [$k] ['opinion'] = "";
  4969. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4970. $verifyList [$k] ['status'] = 4;
  4971. $flag = false;
  4972. }
  4973. } else {
  4974. foreach ( $verifyStaff as $m => $u ) {
  4975. if ($v [0] == $m) {
  4976. $verifyList [$k] ['date'] = $u ['date'];
  4977. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4978. $verifyList [$k] ['status'] = $u ['status'];
  4979. $flag = false;
  4980. break;
  4981. }
  4982. }
  4983. $endStaffArray = end ( $verifyStaff );
  4984. if (isset ( $endStaffArray ['ROLE'] )) {
  4985. } else {
  4986. // $endKey=key($verifyStaff);
  4987. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4988. // $button=4;
  4989. // $verifyList[$k]['status']=4;
  4990. // }
  4991. }
  4992. }
  4993. }
  4994. $rolename ['name'] = '';
  4995. if (! empty ( $roleId )) {
  4996. Doo::loadModel ( 'role' );
  4997. $role = new role ();
  4998. $rolename = $role->getOne ( array (
  4999. 'where' => 'rid=' . $roleId,
  5000. 'asArray' => true
  5001. ) );
  5002. }
  5003. if (! empty ( $verifyStaff ))
  5004. $endStaffArray = end ( $verifyStaff );
  5005. $KOP = false;
  5006. foreach ( $roleArrayCopy as $P => $A ) {
  5007. foreach ( $A as $MKI => $AVL ) {
  5008. if (! empty ( $verifyStaff )) {
  5009. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5010. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5011. $button = 4;
  5012. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5013. }
  5014. foreach ( $verifyStaff as $m => $u ) {
  5015. $AVLFK = $AVL [0] . '_R';
  5016. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5017. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5018. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5019. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5020. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5021. break;
  5022. }
  5023. }
  5024. } else {
  5025. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5026. $button = 4;
  5027. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5028. }
  5029. }
  5030. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5031. $KOP = true;
  5032. }
  5033. }
  5034. foreach ( $roleArrayCopy as $k => $v ) {
  5035. foreach ( $verifyList as $m => $n ) {
  5036. if ($n [0] == $k) {
  5037. array_splice ( $verifyList, $m, 1, $v );
  5038. }
  5039. }
  5040. }
  5041. $receiptList [$key] ['verifyList'] = $verifyList;
  5042. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5043. 'where' => 'sid=' . $value ['staff'],
  5044. 'asArray' => true
  5045. ) );
  5046. $receiptList [$key] ['button'] = $button;
  5047. }
  5048. // print_r($receiptList);die;
  5049. $mothHtml = "";
  5050. for($i = 1; $i <= 12; $i ++) {
  5051. if ($moth == $i)
  5052. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5053. else
  5054. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5055. }
  5056. $data ['mothHtml'] = $mothHtml;
  5057. $data ['receiptList'] = $receiptList;
  5058. $data ['memu'] = "receipt";
  5059. $data ['staff'] = $this->staff;
  5060. $data ['receiptMemu'] = 'receipt';
  5061. $data ['verifyId'] = $this->verifyId;
  5062. $data ['executeId'] = $this->executeId;
  5063. $data ['item'] = $item;
  5064. $data ['year'] = $year;
  5065. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  5066. // sufficient condition to generate cache
  5067. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  5068. $receiptList = $receipt->find ( array (
  5069. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  5070. 'asArray' => true
  5071. ) );
  5072. if (empty ( $receiptList )) { // generated files
  5073. ob_start ();
  5074. $this->render ( "/admin/saea_myList", $data );
  5075. $this->cacheFile ( $path );
  5076. die ();
  5077. // $content = ob_get_contents();
  5078. // $fp = fopen($path, "w");
  5079. // fwrite($fp, $content);
  5080. // fclose($fp);
  5081. }
  5082. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  5083. $receiptList = $receipt->find ( array (
  5084. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  5085. 'asArray' => true
  5086. ) );
  5087. if (empty ( $receiptList )) { // generated files
  5088. ob_start ();
  5089. $this->render ( "/admin/saea_myList", $data );
  5090. $this->cacheFile ( $path );
  5091. die ();
  5092. }
  5093. }
  5094. }
  5095. $this->render ( "/admin/saea_myList", $data );
  5096. }
  5097. function saeaCreate() {
  5098. Doo::loadModel ( 'accountItem' );
  5099. Doo::loadModel ( 'verify' );
  5100. Doo::loadModel ( 'receipt' );
  5101. Doo::loadModel ( 'L_category' );
  5102. $lCategory = new L_category ();
  5103. $receipt = new receipt ();
  5104. $verify = new verify ();
  5105. $accountItem = new accountItem ();
  5106. Doo::loadModel ( "role" );
  5107. $role = new role ();
  5108. $acItem = $accountItem->find ( array (
  5109. 'asArray' => true
  5110. ) );
  5111. $veList = $verify->find ( array (
  5112. 'asArray' => true
  5113. ) );
  5114. foreach ( $veList as $key => $value ) {
  5115. $v = json_decode ( $value ['staff'] );
  5116. $list = array ();
  5117. foreach ( $v as $n => $m ) {
  5118. if ($m ['1'] == 'ROLE') {
  5119. $roleInfo = $role->getOne ( array (
  5120. 'where' => 'rid=' . $m [0],
  5121. 'asArray' => true
  5122. ) );
  5123. $v [$n] [1] = $roleInfo ['name'];
  5124. array_push ( $list, $roleInfo ['name'] );
  5125. } else {
  5126. array_push ( $list, $v [$n] [1] );
  5127. }
  5128. }
  5129. $veList [$key] ['staff'] = implode ( '>', $list );
  5130. }
  5131. $data ['category'] = $lCategory->find ( array (
  5132. 'asArray' => true
  5133. ) );
  5134. $data ['veList'] = $veList;
  5135. $data ['acItem'] = $acItem;
  5136. $data ['memu'] = "receipt";
  5137. $data ['staff'] = $this->staff;
  5138. $data ['receiptMemu'] = 'saeaBorad';
  5139. $data ['verifyId'] = $this->verifyId;
  5140. $data ['executeId'] = $this->executeId;
  5141. $this->render ( "/admin/saea_create", $data );
  5142. }
  5143. function addReceipt() {
  5144. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  5145. $agency = $this->get_args ( 'agency' );
  5146. $travel = $this->get_args ( 'travel' );
  5147. $train = $this->get_args ( 'train' );
  5148. $other = $this->get_args ( 'other' );
  5149. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5150. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5151. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5152. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  5153. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  5154. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  5155. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  5156. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  5157. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  5158. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  5159. if ($remittanceBankType==1&&empty($coupletNumber)){
  5160. header ( 'Content-Type:text/html;charset=utf-8' );
  5161. die ( '请填写联行号' );
  5162. }
  5163. Doo::loadModel ( 'receipt' );
  5164. Doo::loadModel ( 'receiptDetail' );
  5165. Doo::loadModel ( 'accountItem' );
  5166. $accountItem = new accountItem ();
  5167. $receipt = new receipt ();
  5168. Doo::loadModel ( 'enclosur' );
  5169. Doo::loadModel ( 'execute' );
  5170. $execute = new execute ();
  5171. $executeDetail = $execute->getOne ( array (
  5172. 'where' => 'mold="报销单执行人"',
  5173. 'asArray' => true
  5174. ) );
  5175. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  5176. // if(!empty($receiptDetail))
  5177. // return "/referReceipt/".$receiptDetail['rid'];
  5178. $aItem = $accountItem->find ( array (
  5179. 'asArray' => true
  5180. ) );
  5181. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5182. $ag = $tr = $ta = $ot = 0;
  5183. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5184. foreach ( $aItem as $key => $value ) {
  5185. if ($value ['category'] == $this->AGENCY) {
  5186. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5187. array_push ( $accountJson [$this->AGENCY], array (
  5188. 'aid' => $value ['aid'],
  5189. 'name' => $value ['name'],
  5190. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5191. ) );
  5192. $sum += $agency [$ag];
  5193. $agencySum += $agency [$ag];
  5194. }
  5195. $ag ++;
  5196. }
  5197. if ($value ['category'] == $this->TRAVEL) {
  5198. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5199. array_push ( $accountJson [$this->TRAVEL], array (
  5200. 'aid' => $value ['aid'],
  5201. 'name' => $value ['name'],
  5202. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5203. ) );
  5204. $sum += $travel [$tr];
  5205. $travelSum += $travel [$tr];
  5206. }
  5207. $tr ++;
  5208. }
  5209. if ($value ['category'] == $this->TRAIN) {
  5210. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5211. array_push ( $accountJson [$this->TRAIN], array (
  5212. 'aid' => $value ['aid'],
  5213. 'name' => $value ['name'],
  5214. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5215. ) );
  5216. $sum += $train [$ta];
  5217. $trainSum += $train [$ta];
  5218. }
  5219. $ta ++;
  5220. }
  5221. if ($value ['category'] == $this->OTHER) {
  5222. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5223. array_push ( $accountJson [$this->OTHER], array (
  5224. 'aid' => $value ['aid'],
  5225. 'name' => $value ['name'],
  5226. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5227. ) );
  5228. $sum += $other [$ot];
  5229. $otherSum += $other [$ot];
  5230. }
  5231. $ot ++;
  5232. }
  5233. }
  5234. $accountJson ['cSum'] = array (
  5235. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5236. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5237. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5238. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5239. );
  5240. // 报销单
  5241. $receipt->accountItem = json_encode ( $accountJson );
  5242. $receipt->staff = $this->staff [0] ['sid'];
  5243. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5244. $receipt->date = date ( "Y-m-d" );
  5245. $receipt->cid = $cid;
  5246. $receipt->status = 5;
  5247. // 修改审批流程加入角色
  5248. $receipt->verify = $verify;
  5249. $receipt->executeCopy = $executeDetail ['staff'];
  5250. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  5251. $receipt->explanation = $explanation;
  5252. $receipt->remittanceName = $remittanceName;
  5253. $receipt->bankName = $bankName;
  5254. $receipt->bankNumber = $bankNumber;
  5255. $receipt->remittanceBankType = $remittanceBankType;
  5256. if ($remittanceBankType==1)
  5257. $receipt->coupletNumber = $coupletNumber;
  5258. $rid = $receipt->insert ();
  5259. // 附件
  5260. if (! empty ( $enclosurName )) {
  5261. $enclosurArray = explode ( '-', $enclosurName );
  5262. foreach ( $enclosurArray as $value ) {
  5263. $enclosur = new enclosur ();
  5264. $enclosur->name = $value;
  5265. $enclosur->rid = $rid;
  5266. $enclosur->insert ();
  5267. }
  5268. // print_r($enclosurArray);die;
  5269. }
  5270. // 报销详情
  5271. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5272. $receiptDetail = new receiptDetail ();
  5273. $receiptDetail->staff = $this->staff [0] ['sid'];
  5274. $receiptDetail->item = $value ['name'];
  5275. $receiptDetail->itemCategory = $this->AGENCY;
  5276. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5277. $receiptDetail->date = date ( "Y-m-d" );
  5278. $receiptDetail->cid = $cid;
  5279. $receiptDetail->rid = $rid;
  5280. $receiptDetail->status = 4;
  5281. $receiptDetail->insert ();
  5282. }
  5283. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5284. $receiptDetail = new receiptDetail ();
  5285. $receiptDetail->staff = $this->staff [0] ['sid'];
  5286. $receiptDetail->item = $value ['name'];
  5287. $receiptDetail->itemCategory = $this->TRAVEL;
  5288. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5289. $receiptDetail->date = date ( "Y-m-d" );
  5290. $receiptDetail->cid = $cid;
  5291. $receiptDetail->rid = $rid;
  5292. $receiptDetail->status = 4;
  5293. $receiptDetail->insert ();
  5294. }
  5295. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5296. $receiptDetail = new receiptDetail ();
  5297. $receiptDetail->staff = $this->staff [0] ['sid'];
  5298. $receiptDetail->item = $value ['name'];
  5299. $receiptDetail->itemCategory = $this->TRAIN;
  5300. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5301. $receiptDetail->date = date ( "Y-m-d" );
  5302. $receiptDetail->cid = $cid;
  5303. $receiptDetail->rid = $rid;
  5304. $receiptDetail->status = 4;
  5305. $receiptDetail->insert ();
  5306. }
  5307. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5308. $receiptDetail = new receiptDetail ();
  5309. $receiptDetail->staff = $this->staff [0] ['sid'];
  5310. $receiptDetail->item = $value ['name'];
  5311. $receiptDetail->itemCategory = $this->OTHER;
  5312. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5313. $receiptDetail->date = date ( "Y-m-d" );
  5314. $receiptDetail->cid = $cid;
  5315. $receiptDetail->rid = $rid;
  5316. $receiptDetail->status = 4;
  5317. $receiptDetail->insert ();
  5318. }
  5319. return "/saeaBorad";
  5320. } else
  5321. die ( 'illegal request' );
  5322. }
  5323. function referReceipt() {
  5324. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  5325. Doo::loadModel ( 'receipt' );
  5326. Doo::loadModel ( 'verify' );
  5327. $verify = new verify ();
  5328. $receipt = new receipt ();
  5329. Doo::loadModel ( 'L_category' );
  5330. $lCategory = new L_category ();
  5331. Doo::loadModel ( "role" );
  5332. $role = new role ();
  5333. $receiptDetail = $receipt->find ( array (
  5334. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  5335. 'asArray' => true
  5336. ) );
  5337. if (empty ( $receiptDetail ))
  5338. return "/addReceipt";
  5339. foreach ( $receiptDetail as $key => $value ) {
  5340. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5341. $veList = $verify->getOne ( array (
  5342. 'where' => 'vid=' . $value ['verify'],
  5343. 'asArray' => true
  5344. ) );
  5345. $v = json_decode ( $veList ['staff'] );
  5346. array_push ( $v [0], $veList ['description'] );
  5347. foreach ( $v as $n => $m ) {
  5348. if ($m ['1'] == 'ROLE') {
  5349. $roleInfo = $role->getOne ( array (
  5350. 'where' => 'rid=' . $m [0],
  5351. 'asArray' => true
  5352. ) );
  5353. $v [$n] [1] = $roleInfo ['name'];
  5354. }
  5355. }
  5356. $receiptDetail [$key] ['staff'] = $v;
  5357. $category = $lCategory->getOne ( array (
  5358. 'where' => 'cid=' . $value ['cid'],
  5359. 'asArray' => true
  5360. ) );
  5361. $receiptDetail [$key] ['category'] = $category ['title'];
  5362. }
  5363. // print_r($receiptDetail);
  5364. $data ['receiptDetail'] = $receiptDetail;
  5365. $data ['memu'] = "receipt";
  5366. $data ['staff'] = $this->staff;
  5367. $data ['receiptMemu'] = 'saeaCreate';
  5368. $data ['verifyId'] = $this->verifyId;
  5369. $data ['executeId'] = $this->executeId;
  5370. $this->render ( "/admin/saea_confirm", $data );
  5371. }
  5372. function editReceipt() {
  5373. // edit status 4
  5374. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  5375. Doo::loadClass ( 'XDeode' );
  5376. $XDeode = new XDeode ( 7 );
  5377. $rid = $XDeode->decode ( $ridKey );
  5378. if (empty ( $rid ))
  5379. die ( 'illegal request' );
  5380. // echo $rid.'sd';
  5381. Doo::loadModel ( 'accountItem' );
  5382. Doo::loadModel ( 'verify' );
  5383. Doo::loadModel ( 'receipt' );
  5384. $receipt = new receipt ();
  5385. $verify = new verify ();
  5386. $accountItem = new accountItem ();
  5387. Doo::loadModel ( 'L_category' );
  5388. $lCategory = new L_category ();
  5389. Doo::loadModel ( "role" );
  5390. $role = new role ();
  5391. Doo::loadModel ( 'enclosur' );
  5392. $enclosur = new enclosur ();
  5393. $receiptDetail = $receipt->getOne ( array (
  5394. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  5395. 'asArray' => true
  5396. ) );
  5397. if (empty ( $receiptDetail ))
  5398. die ( 'illegal request' );
  5399. $enclosurList=$enclosur->getEnclosurByRid($receiptDetail['rid']);
  5400. $acItem = $accountItem->find ( array (
  5401. 'asArray' => true
  5402. ) );
  5403. $veList = $verify->find ( array (
  5404. 'asArray' => true
  5405. ) );
  5406. foreach ( $veList as $key => $value ) {
  5407. $v = json_decode ( $value ['staff'] );
  5408. $list = array ();
  5409. foreach ( $v as $n => $m ) {
  5410. if ($m ['1'] == 'ROLE') {
  5411. $roleInfo = $role->getOne ( array (
  5412. 'where' => 'rid=' . $m [0],
  5413. 'asArray' => true
  5414. ) );
  5415. $v [$n] [1] = $roleInfo ['name'];
  5416. array_push ( $list, $roleInfo ['name'] );
  5417. } else {
  5418. array_push ( $list, $v [$n] [1] );
  5419. }
  5420. }
  5421. $veList [$key] ['staff'] = implode ( '>', $list );
  5422. }
  5423. // 配置编辑信息
  5424. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  5425. foreach ( $acItem as $key => $value ) {
  5426. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  5427. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  5428. $acItem [$key] ['price'] = $v ['price'];
  5429. }
  5430. }
  5431. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  5432. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  5433. $acItem [$key] ['price'] = $v ['price'];
  5434. }
  5435. }
  5436. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  5437. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  5438. $acItem [$key] ['price'] = $v ['price'];
  5439. }
  5440. }
  5441. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  5442. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  5443. $acItem [$key] ['price'] = $v ['price'];
  5444. }
  5445. }
  5446. }
  5447. $data ['category'] = $lCategory->find ( array (
  5448. 'asArray' => true
  5449. ) );
  5450. $data ['cSum'] = $accountItemList ['cSum'];
  5451. $data ['sum'] = $receiptDetail ['sum'];
  5452. $data ['enclosurList'] =$enclosurList;
  5453. $data ['receiptDetail'] = $receiptDetail;
  5454. $data ['veList'] = $veList;
  5455. $data ['acItem'] = $acItem;
  5456. $data ['memu'] = "receipt";
  5457. $data ['staff'] = $this->staff;
  5458. $data ['receiptMemu'] = 'saeaBorad';
  5459. $data ['verify'] = $receiptDetail ['verify'];
  5460. $data ['verifyId'] = $this->verifyId;
  5461. $data ['executeId'] = $this->executeId;
  5462. $data ['rid'] = $ridKey;
  5463. $this->render ( "/admin/saea_edit", $data );
  5464. }
  5465. function updateReceipt() {
  5466. $agency = $this->get_args ( 'agency' );
  5467. $travel = $this->get_args ( 'travel' );
  5468. $train = $this->get_args ( 'train' );
  5469. $other = $this->get_args ( 'other' );
  5470. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5471. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5472. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5473. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  5474. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  5475. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  5476. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  5477. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  5478. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  5479. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  5480. Doo::loadClass ( 'XDeode' );
  5481. $XDeode = new XDeode ( 7 );
  5482. $rid = $XDeode->decode ( $ridKey );
  5483. if (! empty ( $rid )&&! empty ( $explanation )&& ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  5484. if ($remittanceBankType==1&&empty($coupletNumber)){
  5485. header ( 'Content-Type:text/html;charset=utf-8' );
  5486. die ( '请填写联行号' );
  5487. }
  5488. Doo::loadModel ( 'receipt' );
  5489. Doo::loadModel ( 'receiptDetail' );
  5490. Doo::loadModel ( 'accountItem' );
  5491. $accountItem = new accountItem ();
  5492. $receipt = new receipt ();
  5493. Doo::loadModel ( 'enclosur' );
  5494. Doo::loadModel ( 'execute' );
  5495. $execute = new execute ();
  5496. $receiptDetail = $receipt->getOne ( array (
  5497. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  5498. 'asArray' => true
  5499. ) );
  5500. if (empty ( $receiptDetail ))
  5501. return "/saeaBorad";
  5502. if ($receiptDetail ['Rtype'] == 1)
  5503. $executeDetail = $execute->getOne ( array (
  5504. 'where' => 'mold="借款费用执行人"',
  5505. 'asArray' => true
  5506. ) );
  5507. else
  5508. $executeDetail = $execute->getOne ( array (
  5509. 'where' => 'mold="报销单执行人"',
  5510. 'asArray' => true
  5511. ) );
  5512. $aItem = $accountItem->find ( array (
  5513. 'asArray' => true
  5514. ) );
  5515. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5516. $ag = $tr = $ta = $ot = 0;
  5517. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5518. foreach ( $aItem as $key => $value ) {
  5519. if ($value ['category'] == $this->AGENCY) {
  5520. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5521. array_push ( $accountJson [$this->AGENCY], array (
  5522. 'aid' => $value ['aid'],
  5523. 'name' => $value ['name'],
  5524. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5525. ) );
  5526. $sum += $agency [$ag];
  5527. $agencySum += $agency [$ag];
  5528. }
  5529. $ag ++;
  5530. }
  5531. if ($value ['category'] == $this->TRAVEL) {
  5532. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5533. array_push ( $accountJson [$this->TRAVEL], array (
  5534. 'aid' => $value ['aid'],
  5535. 'name' => $value ['name'],
  5536. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5537. ) );
  5538. $sum += $travel [$tr];
  5539. $travelSum += $travel [$tr];
  5540. }
  5541. $tr ++;
  5542. }
  5543. if ($value ['category'] == $this->TRAIN) {
  5544. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5545. array_push ( $accountJson [$this->TRAIN], array (
  5546. 'aid' => $value ['aid'],
  5547. 'name' => $value ['name'],
  5548. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5549. ) );
  5550. $sum += $train [$ta];
  5551. $trainSum += $train [$ta];
  5552. }
  5553. $ta ++;
  5554. }
  5555. if ($value ['category'] == $this->OTHER) {
  5556. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5557. array_push ( $accountJson [$this->OTHER], array (
  5558. 'aid' => $value ['aid'],
  5559. 'name' => $value ['name'],
  5560. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5561. ) );
  5562. $sum += $other [$ot];
  5563. $otherSum += $other [$ot];
  5564. }
  5565. $ot ++;
  5566. }
  5567. }
  5568. $accountJson ['cSum'] = array (
  5569. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5570. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5571. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5572. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5573. );
  5574. // 报销单
  5575. $rid = $receipt->rid = $receiptDetail ['rid'];
  5576. $receipt->accountItem = json_encode ( $accountJson );
  5577. $receipt->staff = $this->staff [0] ['sid'];
  5578. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5579. $receipt->date = date ( "Y-m-d" );
  5580. $receipt->cid = $cid;
  5581. if (($receiptDetail ['status'] != 4)) {
  5582. if ($receiptDetail ['Rtype'] == 1)
  5583. $receipt->status = 7;
  5584. else
  5585. $receipt->status = 5;
  5586. }
  5587. if ($receiptDetail != 4 && ! empty ( $verify ))
  5588. $receipt->verify = $verify;
  5589. $receipt->executeCopy = $executeDetail ['staff'];
  5590. $receipt->explanation = $explanation;
  5591. $receipt->remittanceName = $remittanceName;
  5592. $receipt->bankName = $bankName;
  5593. $receipt->bankNumber = $bankNumber;
  5594. $receipt->remittanceBankType = $remittanceBankType;
  5595. if ($remittanceBankType==1)
  5596. $receipt->coupletNumber = $coupletNumber;
  5597. $receipt->update ();
  5598. $receiptDetail = new receiptDetail ();
  5599. $receiptDetail->delete ( array (
  5600. 'where' => 'rid=' . $rid
  5601. ) );
  5602. // 报销详情
  5603. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5604. $receiptDetail = new receiptDetail ();
  5605. $receiptDetail->staff = $this->staff [0] ['sid'];
  5606. $receiptDetail->item = $value ['name'];
  5607. $receiptDetail->itemCategory = $this->AGENCY;
  5608. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5609. $receiptDetail->date = date ( "Y-m-d" );
  5610. $receiptDetail->cid = $cid;
  5611. $receiptDetail->rid = $rid;
  5612. $receiptDetail->status = 4;
  5613. $receiptDetail->insert ();
  5614. }
  5615. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5616. $receiptDetail = new receiptDetail ();
  5617. $receiptDetail->staff = $this->staff [0] ['sid'];
  5618. $receiptDetail->item = $value ['name'];
  5619. $receiptDetail->itemCategory = $this->TRAVEL;
  5620. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5621. $receiptDetail->date = date ( "Y-m-d" );
  5622. $receiptDetail->cid = $cid;
  5623. $receiptDetail->rid = $rid;
  5624. $receiptDetail->status = 4;
  5625. $receiptDetail->insert ();
  5626. }
  5627. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5628. $receiptDetail = new receiptDetail ();
  5629. $receiptDetail->staff = $this->staff [0] ['sid'];
  5630. $receiptDetail->item = $value ['name'];
  5631. $receiptDetail->itemCategory = $this->TRAIN;
  5632. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5633. $receiptDetail->date = date ( "Y-m-d" );
  5634. $receiptDetail->cid = $cid;
  5635. $receiptDetail->rid = $rid;
  5636. $receiptDetail->status = 4;
  5637. $receiptDetail->insert ();
  5638. }
  5639. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5640. $receiptDetail = new receiptDetail ();
  5641. $receiptDetail->staff = $this->staff [0] ['sid'];
  5642. $receiptDetail->item = $value ['name'];
  5643. $receiptDetail->itemCategory = $this->OTHER;
  5644. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5645. $receiptDetail->date = date ( "Y-m-d" );
  5646. $receiptDetail->cid = $cid;
  5647. $receiptDetail->rid = $rid;
  5648. $receiptDetail->status = 4;
  5649. $receiptDetail->insert ();
  5650. }
  5651. // 附件
  5652. if (! empty ( $enclosurName )) {
  5653. $enclosurArray = explode ( '-', $enclosurName );
  5654. foreach ( $enclosurArray as $value ) {
  5655. $enclosur = new enclosur ();
  5656. $enclosur->name = $value;
  5657. $enclosur->rid = $rid;
  5658. $enclosur->insert ();
  5659. }
  5660. }
  5661. // return "/referReceipt/".$rid;
  5662. }
  5663. return "/saeaBorad";
  5664. }
  5665. function approvedReceipt() {
  5666. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5667. Doo::loadModel ( 'receipt' );
  5668. Doo::loadModel ( 'receiptDetail' );
  5669. $receipt = new receipt ();
  5670. $receiptDetail = new receiptDetail ();
  5671. Doo::loadModel ( 'statistics' );
  5672. Doo::loadModel ( 'itemStatistics' );
  5673. $statistics = new statistics ();
  5674. $itemStatistics = new itemStatistics ();
  5675. Doo::loadModel ( "verify" );
  5676. $verify = new verify ();
  5677. // 审批状态的判定
  5678. $receiptDetailList = $receipt->getOne ( array (
  5679. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  5680. 'asArray' => true
  5681. ) );
  5682. if (empty ( $receiptDetailList ))
  5683. return "/saeaBorad";
  5684. $verifyDetail = $verify->getOne ( array (
  5685. 'where' => ' vid =' . $receiptDetailList ['verify'],
  5686. 'asArray' => true
  5687. ) );
  5688. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5689. if (empty ( $receiptDetailList ['nowStaff'] )) {
  5690. $nowStaff = "";
  5691. $nowStaffList = array ();
  5692. if ($verifyDetail [0] [1] == 'ROLE') {
  5693. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5694. foreach ( $vStaffString as $key => $value ) {
  5695. $staffK = explode ( "_", $value );
  5696. array_push ( $nowStaffList, $staffK [0] );
  5697. }
  5698. $nowStaff = implode ( ',', $nowStaffList );
  5699. } else {
  5700. $nowStaff = $verifyDetail [0] [0];
  5701. }
  5702. $receipt->nowStaff = $nowStaff;
  5703. }
  5704. // echo $nowStaff;
  5705. // print_r($verifyDetail);die;
  5706. $receipt->rid = $receiptDetailList ['rid'];
  5707. $receipt->date = date ( "Y-m-d" );
  5708. $receipt->status = 2;
  5709. $receipt->update ();
  5710. $receiptDetail->status = 2;
  5711. $receiptDetail->update ( array (
  5712. 'where' => 'rid=' . $receiptDetailList ['rid']
  5713. ) );
  5714. Doo::loadModel ( "receiptLog" );
  5715. $receiptLog = new receiptLog ();
  5716. Doo::loadModel ( "verify" );
  5717. $verify = new verify ();
  5718. $receiptInfo = $receipt->getOne ( array (
  5719. 'where' => 'rid=' . $rid,
  5720. 'asArray' => true
  5721. ) );
  5722. $vr = $verify->getOne ( array (
  5723. 'where' => 'vid=' . $receiptInfo ['verify'],
  5724. 'asArray' => true
  5725. ) );
  5726. $jd = json_decode ( $vr ['staff'] );
  5727. $roleId = 0;
  5728. foreach ( $jd as $key => $value ) {
  5729. if ($value [1] == 'ROLE') {
  5730. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  5731. if ($pos !== false) {
  5732. $roleId = $value [0];
  5733. }
  5734. }
  5735. }
  5736. // 审批日志
  5737. // echo $roleId;die;
  5738. if (! empty ( $roleId )) {
  5739. Doo::loadModel ( "role" );
  5740. $role = new role ();
  5741. $roleInfo = $role->getOne ( array (
  5742. 'where' => 'rid=' . $roleId,
  5743. 'asArray' => true
  5744. ) );
  5745. $receiptLog->rolename = $roleInfo ['name'];
  5746. }
  5747. $receiptLog->username = $this->staff [0] ['username'];
  5748. $receiptLog->uid = $this->staff [0] ['sid'];
  5749. $receiptLog->date = date ( "Y-m-d" );
  5750. $receiptLog->opinion = '提交审批';
  5751. $receiptLog->img = $this->staff [0] ['avatar'];
  5752. $receiptLog->status = 2;
  5753. $receiptLog->rid = $rid;
  5754. $receiptLog->insert ();
  5755. // statistics item
  5756. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  5757. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  5758. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  5759. $stat = $statistics->getOne ( array (
  5760. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5761. 'asArray' => true
  5762. ) );
  5763. if (empty ( $stat )) {
  5764. $statistics->date = date ( "Y-m-d" );
  5765. $statistics->cid = $this->staff [0] ['cid'];
  5766. $statistics->staff = $this->staff [0] ['sid'];
  5767. $statistics->agPrice = 0;
  5768. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5769. $statistics->insert ();
  5770. } else {
  5771. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5772. $statistics->update ( array (
  5773. 'where' => 'sid=' . $stat ['sid']
  5774. ) );
  5775. }
  5776. return "/expenses";
  5777. }
  5778. function approval() {
  5779. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5780. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5781. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5782. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5783. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5784. if (empty ( $status ))
  5785. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5786. $vidList = array ();
  5787. $button = 0;
  5788. Doo::loadModel ( 'verify' );
  5789. $verify = new verify ();
  5790. Doo::loadModel ( 'receipt' );
  5791. $receipt = new receipt ();
  5792. Doo::loadModel ( 'staff' );
  5793. $staff = new staff ();
  5794. Doo::loadModel ( 'L_category' );
  5795. $Lcategory = new L_category ();
  5796. // user verify ID
  5797. $verifyDetail = $verify->find ( array (
  5798. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5799. 'asArray' => true
  5800. ) );
  5801. foreach ( $verifyDetail as $key => $value ) {
  5802. array_push ( $vidList, $value ['vid'] );
  5803. }
  5804. $vid = implode ( ",", $vidList );
  5805. if (empty ( $verifyDetail ))
  5806. $vid = 0;
  5807. /*
  5808. */
  5809. $dateCondition = " and Year(date) =" . $year;
  5810. if (! empty ( $month ))
  5811. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  5812. $categoryList = $Lcategory->find ( array (
  5813. 'asArray' => true
  5814. ) );
  5815. $staffList = $staff->find ( array (
  5816. 'where' => 'cid=' . $cid,
  5817. 'asArray' => true
  5818. ) );
  5819. $cateCondition = "";
  5820. $staffCondition = "";
  5821. $approvalCondition = "";
  5822. if (! empty ( $cid ))
  5823. $cateCondition = ' and cid=' . $cid;
  5824. if (! empty ( $sid )) {
  5825. $staffCondition = ' and staff=' . $sid;
  5826. $cateCondition = "";
  5827. }
  5828. // elseif($status==1){
  5829. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  5830. // }
  5831. if ($status == 2) {
  5832. // 查找角色审批人
  5833. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  5834. }
  5835. $ap = "";
  5836. if ($status == 4) {
  5837. $ap = 4;
  5838. $status = 2;
  5839. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  5840. }
  5841. if ($status == 5) {
  5842. $status = 4;
  5843. $ap = 5;
  5844. }
  5845. // echo $vid;
  5846. // get Receipt By verifyID status 2 .$approvalCondition
  5847. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  5848. $receiptList = $receipt->find ( array (
  5849. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  5850. 'desc' => 'rid',
  5851. 'asArray' => true
  5852. ) );
  5853. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  5854. $Locate = 0;
  5855. if ($ap == 4)
  5856. $status = 4;
  5857. elseif ($ap == 5)
  5858. $status = 5;
  5859. foreach ( $receiptList as $key => $value ) {
  5860. $receiptList [$key] ['Locate'] = $Locate;
  5861. $Locate ++;
  5862. $receiptList [$key] ['reviseDetail'] = array ();
  5863. if (! empty ( $value ['reviseDetail'] ))
  5864. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5865. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5866. $categoryDetil = $Lcategory->getOne ( array (
  5867. 'where' => 'cid=' . $value ['cid'],
  5868. 'asArray' => true
  5869. ) );
  5870. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5871. $verifyList = $verify->getOne ( array (
  5872. 'where' => 'vid=' . $value ['verify'],
  5873. 'asArray' => true
  5874. ) );
  5875. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5876. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5877. foreach ( $verifyList as $k => $v ) {
  5878. // init verifyStaff
  5879. $verifyList [$k] ['date'] = "";
  5880. $verifyList [$k] ['opinion'] = "";
  5881. $verifyList [$k] ['status'] = "";
  5882. if (empty ( $verifyStaff )) {
  5883. $verifyList [$k] ['date'] = "";
  5884. $verifyList [$k] ['opinion'] = "";
  5885. if ($v [0] == $this->staff [0] ['sid']) {
  5886. $verifyList [$k] ['status'] = 4;
  5887. $button = 4;
  5888. }
  5889. } else {
  5890. $flag = true;
  5891. foreach ( $verifyStaff as $m => $u ) {
  5892. if ($v [0] == $m) {
  5893. $verifyList [$k] ['date'] = $u ['date'];
  5894. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5895. $verifyList [$k] ['status'] = $u ['status'];
  5896. $flag = false;
  5897. break;
  5898. }
  5899. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  5900. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  5901. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  5902. }
  5903. if ($flag) { // 检测可编辑
  5904. if ($v [0] == $this->staff [0] ['sid']) {
  5905. $verifyList [$k] ['status'] = 4;
  5906. $button = 4;
  5907. }
  5908. }
  5909. }
  5910. }
  5911. $receiptList [$key] ['verifyList'] = $verifyList;
  5912. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5913. 'where' => 'sid=' . $value ['staff'],
  5914. 'asArray' => true
  5915. ) );
  5916. $receiptList [$key] ['button'] = $button;
  5917. }
  5918. // print_r($receiptList);die;
  5919. // $data['verifyDetail']=$verifyDetail;
  5920. $mothHtml = "";
  5921. for($i = 1; $i <= 12; $i ++) {
  5922. if ($month == $i)
  5923. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5924. else
  5925. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5926. }
  5927. $data ['mothHtml'] = $mothHtml;
  5928. $data ['receiptList'] = $receiptList;
  5929. $data ['receiptApprovalCount'] = count ( $receiptList );
  5930. $data ['status'] = $status;
  5931. $data ['year'] = $year;
  5932. $data ['categoryList'] = $categoryList;
  5933. $data ['staffList'] = $staffList;
  5934. $data ['cid'] = $cid;
  5935. $data ['sid'] = $sid;
  5936. $data ['ap'] = $ap;
  5937. $data ['memu'] = "receipt";
  5938. $data ['staff'] = $this->staff;
  5939. $data ['receiptMemu'] = 'approval';
  5940. $data ['verifyId'] = $this->verifyId;
  5941. $data ['executeId'] = $this->executeId;
  5942. $this->render ( "/admin/saea_reportList", $data );
  5943. }
  5944. function approvalDetails() {
  5945. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5946. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5947. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5948. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5949. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5950. Doo::loadModel ( 'verify' );
  5951. $verify = new verify ();
  5952. Doo::loadModel ( 'receipt' );
  5953. $receipt = new receipt ();
  5954. Doo::loadModel ( 'staff' );
  5955. $staff = new staff ();
  5956. Doo::loadModel ( 'L_category' );
  5957. $Lcategory = new L_category ();
  5958. Doo::loadModel ( 'enclosur' );
  5959. $enclosur = new enclosur ();
  5960. $vidList = array ();
  5961. $verifyDetail = $verify->find ( array (
  5962. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5963. 'asArray' => true
  5964. ) );
  5965. foreach ( $verifyDetail as $key => $value ) {
  5966. array_push ( $vidList, $value ['vid'] );
  5967. }
  5968. $vid = implode ( ",", $vidList );
  5969. if (empty ( $verifyDetail ))
  5970. $vid = 0;
  5971. $categoryList = $Lcategory->find ( array (
  5972. 'asArray' => true
  5973. ) );
  5974. $staffList = $staff->find ( array (
  5975. 'where' => 'cid=' . $cid,
  5976. 'asArray' => true
  5977. ) );
  5978. $ap = 0;
  5979. $receiptList = $receipt->find ( array (
  5980. 'where' => 'rid =' . $rid,
  5981. 'desc' => 'rid',
  5982. 'asArray' => true
  5983. ) );
  5984. $Locate = 0;
  5985. $roleId = 0;
  5986. $button = 0;
  5987. foreach ( $receiptList as $key => $value ) {
  5988. $receiptList [$key] ['Locate'] = $Locate;
  5989. $Locate ++;
  5990. $receiptList [$key] ['reviseDetail'] = array ();
  5991. if (! empty ( $value ['reviseDetail'] ))
  5992. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5993. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5994. $categoryDetil = $Lcategory->getOne ( array (
  5995. 'where' => 'cid=' . $value ['cid'],
  5996. 'asArray' => true
  5997. ) );
  5998. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5999. // 检测编辑状态
  6000. $verifyList = $verify->getOne ( array (
  6001. 'where' => 'vid=' . $value ['verify'],
  6002. 'asArray' => true
  6003. ) );
  6004. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6005. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6006. Doo::loadModel ( 'role' );
  6007. $role = new role ();
  6008. // print_r($verifyList);
  6009. $flag = true;
  6010. $roleKey = 0;
  6011. $endStaffArray = array ();
  6012. $roleArrayCopy = array ();
  6013. foreach ( $verifyList as $k => $v ) {
  6014. // init verifyStaff
  6015. if ($v [1] == 'ROLE') {
  6016. if (! empty ( $verifyStaff )) {
  6017. $endStaffArray = end ( $verifyStaff );
  6018. if ($v [0] == $endStaffArray ['nextStaff']) {
  6019. $roleId = $v [0];
  6020. }
  6021. }
  6022. $roleVerify = json_decode ( $v [3], true );
  6023. $roleKey = $k;
  6024. $roleArray = array ();
  6025. $rolename = $role->getOne ( array (
  6026. 'where' => 'rid=' . $v [0],
  6027. 'asArray' => true
  6028. ) );
  6029. foreach ( $roleVerify as $o => $p ) {
  6030. $staffID = explode ( '_', $p );
  6031. $staffInfo = $staff->getOne ( array (
  6032. 'where' => 'sid=' . $staffID [0],
  6033. 'asArray' => true
  6034. ) );
  6035. // print_r($staffID);
  6036. $exp = array (
  6037. 0 => $staffInfo ['sid'],
  6038. 1 => $staffID [1],
  6039. 2 => $staffInfo ['avatar'],
  6040. 'date' => '',
  6041. 'date' => '',
  6042. 'opinion' => '',
  6043. 'status' => '',
  6044. 'rolename' => $rolename ['name']
  6045. );
  6046. array_push ( $roleArray, $exp );
  6047. }
  6048. $roleArrayCopy [$v [0]] = $roleArray;
  6049. // $verifyList[$k]['roleArray']=$roleArray;
  6050. }
  6051. // print_r($roleArray);
  6052. $verifyList [$k] ['date'] = "";
  6053. $verifyList [$k] ['opinion'] = "";
  6054. $verifyList [$k] ['status'] = "";
  6055. if (empty ( $verifyStaff )) {
  6056. $verifyList [$k] ['date'] = "";
  6057. $verifyList [$k] ['opinion'] = "";
  6058. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6059. $verifyList [$k] ['status'] = 4;
  6060. $button = 4;
  6061. $flag = false;
  6062. }
  6063. } else {
  6064. foreach ( $verifyStaff as $m => $u ) {
  6065. if ($v [0] == $m) {
  6066. $verifyList [$k] ['date'] = $u ['date'];
  6067. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6068. $verifyList [$k] ['status'] = $u ['status'];
  6069. $flag = false;
  6070. break;
  6071. }
  6072. }
  6073. $endStaffArray = end ( $verifyStaff );
  6074. if (isset ( $endStaffArray ['ROLE'] )) {
  6075. } else {
  6076. $endKey = key ( $verifyStaff );
  6077. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6078. $button = 4;
  6079. $verifyList [$k] ['status'] = 4;
  6080. }
  6081. }
  6082. }
  6083. }
  6084. $rolename ['name'] = '';
  6085. if (! empty ( $roleId )) {
  6086. Doo::loadModel ( 'role' );
  6087. $role = new role ();
  6088. $rolename = $role->getOne ( array (
  6089. 'where' => 'rid=' . $roleId,
  6090. 'asArray' => true
  6091. ) );
  6092. }
  6093. if (! empty ( $verifyStaff ))
  6094. $endStaffArray = end ( $verifyStaff );
  6095. $KOP = false;
  6096. foreach ( $roleArrayCopy as $P => $A ) {
  6097. foreach ( $A as $MKI => $AVL ) {
  6098. if (! empty ( $verifyStaff )) {
  6099. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6100. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6101. $button = 4;
  6102. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6103. }
  6104. foreach ( $verifyStaff as $m => $u ) {
  6105. $AVLFK = $AVL [0] . '_R';
  6106. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6107. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6108. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6109. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6110. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6111. break;
  6112. }
  6113. }
  6114. } else {
  6115. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6116. $button = 4;
  6117. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6118. }
  6119. }
  6120. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6121. $KOP = true;
  6122. }
  6123. }
  6124. foreach ( $roleArrayCopy as $k => $v ) {
  6125. foreach ( $verifyList as $m => $n ) {
  6126. if ($n [0] == $k) {
  6127. array_splice ( $verifyList, $m, 1, $v );
  6128. }
  6129. }
  6130. }
  6131. $receiptList [$key] ['verifyList'] = $verifyList;
  6132. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6133. 'where' => 'sid=' . $value ['staff'],
  6134. 'asArray' => true
  6135. ) );
  6136. $receiptList [$key] ['button'] = $button;
  6137. }
  6138. $mothHtml = "";
  6139. for($i = 1; $i <= 12; $i ++) {
  6140. if ($month == $i)
  6141. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6142. else
  6143. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6144. }
  6145. // 获取审批日志
  6146. Doo::loadModel ( 'receiptLog' );
  6147. $receiptLog = new receiptLog ();
  6148. $rlList = array ();
  6149. $rlInfo = $receiptLog->getOne ( array (
  6150. 'where' => 'rid=' . $rid . ' and status=4',
  6151. 'asArray' => true
  6152. ) );
  6153. $tijdate = $receiptLog->getOne ( array (
  6154. 'where' => 'rid=' . $rid . ' and status=2',
  6155. 'asc' => 'rlid',
  6156. 'asArray' => true
  6157. ) );
  6158. if (! empty ( $rlInfo )) {
  6159. $rlList = $receiptLog->find ( array (
  6160. 'where' => 'rid=' . $rid,
  6161. 'asc' => 'rlid',
  6162. 'asArray' => true
  6163. ) );
  6164. }
  6165. $receiptList [0] ['rlList'] = $rlList;
  6166. $enclosurList = $enclosur->find ( array (
  6167. 'where' => 'rid=' . $rid,
  6168. 'asArray' => true
  6169. ) );
  6170. $enclosurHtml = '';
  6171. foreach ( $enclosurList as $value ) {
  6172. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6173. }
  6174. $data ['enclosurHtml'] = $enclosurHtml;
  6175. $data ['rolename'] = $rolename ['name'];
  6176. $data ['datetij'] = $tijdate ['date'];
  6177. $data ['mothHtml'] = $mothHtml;
  6178. $data ['receiptList'] = $receiptList;
  6179. $data ['receiptApprovalCount'] = count ( $receiptList );
  6180. $data ['year'] = $year;
  6181. $data ['categoryList'] = $categoryList;
  6182. $data ['staffList'] = $staffList;
  6183. $data ['cid'] = $cid;
  6184. $data ['sid'] = $sid;
  6185. $data ['status'] = 0;
  6186. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  6187. $ap = 4;
  6188. } else
  6189. $data ['status'] = $receiptList [0] ['status'];
  6190. if ($receiptList [0] ['status'] == 4) {
  6191. $data ['status'] = 5;
  6192. $ap = 0;
  6193. }
  6194. $data ['ap'] = $ap;
  6195. $data ['memu'] = "receipt";
  6196. $data ['staff'] = $this->staff;
  6197. $data ['receiptMemu'] = 'approval';
  6198. $data ['verifyId'] = $this->verifyId;
  6199. $data ['executeId'] = $this->executeId;
  6200. $this->render ( "/admin/saeaReportListReport", $data );
  6201. }
  6202. function approvalEdi() {
  6203. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6204. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  6205. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6206. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6207. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6208. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6209. if (empty ( $status ))
  6210. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  6211. $vidList = array ();
  6212. $button = 0;
  6213. Doo::loadModel ( 'verify' );
  6214. Doo::loadModel ( 'receipt' );
  6215. Doo::loadModel ( 'staff' );
  6216. $staff = new staff ();
  6217. $receipt = new receipt ();
  6218. $verify = new verify ();
  6219. Doo::loadModel ( 'L_category' );
  6220. $Lcategory = new L_category ();
  6221. Doo::loadModel ( 'enclosur' );
  6222. $enclosur = new enclosur ();
  6223. // user verify ID
  6224. $verifyDetail = $verify->find ( array (
  6225. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6226. 'asArray' => true
  6227. ) );
  6228. foreach ( $verifyDetail as $key => $value ) {
  6229. array_push ( $vidList, $value ['vid'] );
  6230. }
  6231. $vid = implode ( ",", $vidList );
  6232. if (empty ( $verifyDetail ))
  6233. $vid = 0;
  6234. $categoryList = $Lcategory->find ( array (
  6235. 'asArray' => true
  6236. ) );
  6237. $staffList = $staff->find ( array (
  6238. 'where' => 'cid=' . $cid,
  6239. 'asArray' => true
  6240. ) );
  6241. $ap = "";
  6242. if ($status == 4) {
  6243. $ap = 4;
  6244. $status = 2;
  6245. }
  6246. // get Receipt By verifyID status 2
  6247. $receiptList = $receipt->find ( array (
  6248. 'where' => 'rid =' . $rid,
  6249. 'desc' => 'rid',
  6250. 'asArray' => true
  6251. ) );
  6252. $Locate = 0;
  6253. $roleId = 0;
  6254. if ($ap == 4)
  6255. $status = 4;
  6256. foreach ( $receiptList as $key => $value ) {
  6257. $receiptList [$key] ['Locate'] = $Locate;
  6258. $Locate ++;
  6259. $receiptList [$key] ['reviseDetail'] = array ();
  6260. if (! empty ( $value ['reviseDetail'] ))
  6261. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6262. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6263. $categoryDetil = $Lcategory->getOne ( array (
  6264. 'where' => 'cid=' . $value ['cid'],
  6265. 'asArray' => true
  6266. ) );
  6267. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6268. // 检测编辑状态
  6269. $verifyList = $verify->getOne ( array (
  6270. 'where' => 'vid=' . $value ['verify'],
  6271. 'asArray' => true
  6272. ) );
  6273. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6274. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6275. // print_r($verifyList);
  6276. //
  6277. // if (empty($verifyStaff)){
  6278. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6279. // $verifyList[0]['status']=4;$button=4;
  6280. // }
  6281. //
  6282. // }else{
  6283. //
  6284. // }
  6285. // die;
  6286. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  6287. // echo array_search("green",$a);
  6288. //
  6289. Doo::loadModel ( 'role' );
  6290. $role = new role ();
  6291. // print_r($verifyList);
  6292. $flag = true;
  6293. $roleKey = 0;
  6294. $endStaffArray = array ();
  6295. $roleArrayCopy = array ();
  6296. foreach ( $verifyList as $k => $v ) {
  6297. // init verifyStaff
  6298. if ($v [1] == 'ROLE') {
  6299. if (! empty ( $verifyStaff )) {
  6300. $endStaffArray = end ( $verifyStaff );
  6301. if ($v [0] == $endStaffArray ['nextStaff']) {
  6302. $roleId = $v [0];
  6303. }
  6304. }
  6305. $roleVerify = json_decode ( $v [3], true );
  6306. $roleKey = $k;
  6307. $roleArray = array ();
  6308. $rolename = $role->getOne ( array (
  6309. 'where' => 'rid=' . $v [0],
  6310. 'asArray' => true
  6311. ) );
  6312. foreach ( $roleVerify as $o => $p ) {
  6313. $staffID = explode ( '_', $p );
  6314. $staffInfo = $staff->getOne ( array (
  6315. 'where' => 'sid=' . $staffID [0],
  6316. 'asArray' => true
  6317. ) );
  6318. // print_r($staffID);
  6319. $exp = array (
  6320. 0 => $staffInfo ['sid'],
  6321. 1 => $staffID [1],
  6322. 2 => $staffInfo ['avatar'],
  6323. 'date' => '',
  6324. 'date' => '',
  6325. 'opinion' => '',
  6326. 'status' => '',
  6327. 'rolename' => $rolename ['name']
  6328. );
  6329. array_push ( $roleArray, $exp );
  6330. }
  6331. $roleArrayCopy [$v [0]] = $roleArray;
  6332. // $verifyList[$k]['roleArray']=$roleArray;
  6333. }
  6334. // print_r($roleArray);
  6335. $verifyList [$k] ['date'] = "";
  6336. $verifyList [$k] ['opinion'] = "";
  6337. $verifyList [$k] ['status'] = "";
  6338. if (empty ( $verifyStaff )) {
  6339. $verifyList [$k] ['date'] = "";
  6340. $verifyList [$k] ['opinion'] = "";
  6341. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6342. $verifyList [$k] ['status'] = 4;
  6343. $button = 4;
  6344. $flag = false;
  6345. }
  6346. } else {
  6347. foreach ( $verifyStaff as $m => $u ) {
  6348. if ($v [0] == $m) {
  6349. $verifyList [$k] ['date'] = $u ['date'];
  6350. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6351. $verifyList [$k] ['status'] = $u ['status'];
  6352. $flag = false;
  6353. break;
  6354. }
  6355. }
  6356. $endStaffArray = end ( $verifyStaff );
  6357. if (isset ( $endStaffArray ['ROLE'] )) {
  6358. } else {
  6359. $endKey = key ( $verifyStaff );
  6360. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6361. $button = 4;
  6362. $verifyList [$k] ['status'] = 4;
  6363. }
  6364. }
  6365. // print_r($endStaffArray);die;
  6366. // if (empty($verifyStaff)){
  6367. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6368. // $verifyList[$k]['status']=4;$button=4;
  6369. // }
  6370. //
  6371. // }else{
  6372. //
  6373. // }
  6374. // if($flag){//检测可编辑
  6375. // if($v[0]==$this->staff[0]['sid']){
  6376. // $verifyList[$k]['status']=4;$button=4;
  6377. // }
  6378. // }
  6379. }
  6380. }
  6381. $rolename ['name'] = '';
  6382. if (! empty ( $roleId )) {
  6383. Doo::loadModel ( 'role' );
  6384. $role = new role ();
  6385. $rolename = $role->getOne ( array (
  6386. 'where' => 'rid=' . $roleId,
  6387. 'asArray' => true
  6388. ) );
  6389. }
  6390. if (! empty ( $verifyStaff ))
  6391. $endStaffArray = end ( $verifyStaff );
  6392. $KOP = false;
  6393. foreach ( $roleArrayCopy as $P => $A ) {
  6394. foreach ( $A as $MKI => $AVL ) {
  6395. if (! empty ( $verifyStaff )) {
  6396. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6397. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6398. $button = 4;
  6399. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6400. }
  6401. foreach ( $verifyStaff as $m => $u ) {
  6402. $AVLFK = $AVL [0] . '_R';
  6403. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6404. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6405. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6406. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6407. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6408. break;
  6409. }
  6410. }
  6411. } else {
  6412. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6413. $button = 4;
  6414. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6415. }
  6416. }
  6417. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6418. $KOP = true;
  6419. }
  6420. }
  6421. // print_r($roleArrayCopy);
  6422. // echo $roleKey;
  6423. foreach ( $roleArrayCopy as $k => $v ) {
  6424. foreach ( $verifyList as $m => $n ) {
  6425. if ($n [0] == $k) {
  6426. array_splice ( $verifyList, $m, 1, $v );
  6427. }
  6428. }
  6429. }
  6430. // if ($KOP)
  6431. // array_splice($verifyList,$roleKey,1,$roleArray);
  6432. // print_r($verifyList);
  6433. $receiptList [$key] ['verifyList'] = $verifyList;
  6434. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6435. 'where' => 'sid=' . $value ['staff'],
  6436. 'asArray' => true
  6437. ) );
  6438. $receiptList [$key] ['button'] = $button;
  6439. }
  6440. // $data['verifyDetail']=$verifyDetail;
  6441. $mothHtml = "";
  6442. for($i = 1; $i <= 12; $i ++) {
  6443. if ($month == $i)
  6444. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6445. else
  6446. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6447. }
  6448. // 获取审批日志
  6449. Doo::loadModel ( 'receiptLog' );
  6450. $receiptLog = new receiptLog ();
  6451. $rlList = array ();
  6452. $rlInfo = $receiptLog->getOne ( array (
  6453. 'where' => 'rid=' . $rid . ' and status=4',
  6454. 'asArray' => true
  6455. ) );
  6456. $tijdate = $receiptLog->getOne ( array (
  6457. 'where' => 'rid=' . $rid . ' and status=2',
  6458. 'asc' => 'rlid',
  6459. 'asArray' => true
  6460. ) );
  6461. if (! empty ( $rlInfo )) {
  6462. $rlList = $receiptLog->find ( array (
  6463. 'where' => 'rid=' . $rid,
  6464. 'asc' => 'rlid',
  6465. 'asArray' => true
  6466. ) );
  6467. }
  6468. $receiptList [0] ['rlList'] = $rlList;
  6469. $enclosurList = $enclosur->find ( array (
  6470. 'where' => 'rid=' . $rid,
  6471. 'asArray' => true
  6472. ) );
  6473. $enclosurHtml = '';
  6474. foreach ( $enclosurList as $value ) {
  6475. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6476. }
  6477. $data ['enclosurHtml'] = $enclosurHtml;
  6478. $data ['rolename'] = $rolename ['name'];
  6479. $data ['datetij'] = $tijdate ['date'];
  6480. $data ['mothHtml'] = $mothHtml;
  6481. $data ['receiptList'] = $receiptList;
  6482. $data ['receiptApprovalCount'] = count ( $receiptList );
  6483. $data ['status'] = $status;
  6484. $data ['year'] = $year;
  6485. $data ['categoryList'] = $categoryList;
  6486. $data ['staffList'] = $staffList;
  6487. $data ['cid'] = $cid;
  6488. $data ['sid'] = $sid;
  6489. $data ['ap'] = $ap;
  6490. $data ['memu'] = "receipt";
  6491. $data ['staff'] = $this->staff;
  6492. $data ['receiptMemu'] = 'approval';
  6493. $data ['verifyId'] = $this->verifyId;
  6494. $data ['executeId'] = $this->executeId;
  6495. $this->render ( "/admin/saeaReportListReport", $data );
  6496. }
  6497. function remittanceHky() {
  6498. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6499. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  6500. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6501. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  6502. $page_size = 15;
  6503. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  6504. Doo::loadModel ( 'receipt' );
  6505. $receipt = new receipt ();
  6506. Doo::loadModel ( 'staff' );
  6507. $staff = new staff ();
  6508. $dateCondition = " and Year(executeDate) =" . $year;
  6509. if ($moth != 'MONTH')
  6510. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  6511. if ($day != 'DAY' && $moth != 'MONTH')
  6512. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  6513. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  6514. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  6515. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  6516. $limit = $pageinfo ['lower'] . ',' . $page_size;
  6517. $dayList = $receipt->find ( array (
  6518. 'select' => 'executeDate,sum(amount) as amount',
  6519. 'where' => $sql,
  6520. 'desc' => 'executeDate',
  6521. 'groupby' => 'executeDate',
  6522. 'limit' => $limit,
  6523. 'asArray' => true
  6524. ) );
  6525. // print_r($dayList);
  6526. foreach ( $dayList as $key => $value ) {
  6527. $remitString = "";
  6528. $receiptList = $receipt->find ( array (
  6529. 'select' => 'rid,executeDate,amount,staff,cid',
  6530. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  6531. 'desc' => 'executeDate',
  6532. 'asArray' => true
  6533. ) );
  6534. foreach ( $receiptList as $k => $v ) {
  6535. $sinfo = $staff->getOne ( array (
  6536. 'select' => 'username,category',
  6537. 'where' => ' sid=' . $v ['staff'],
  6538. 'asArray' => true
  6539. ) );
  6540. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  6541. }
  6542. $dayList [$key] ['staff'] = $remitString;
  6543. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  6544. }
  6545. // print_r($dayList);
  6546. $mothHtml = "";
  6547. for($i = 1; $i <= 12; $i ++) {
  6548. if ($moth == $i)
  6549. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6550. else
  6551. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6552. }
  6553. $dayHtml = "";
  6554. if ($day != "DAY" || $moth != "MONTH") {
  6555. for($i = 1; $i <= 31; $i ++) {
  6556. if ($day == $i)
  6557. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6558. else
  6559. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6560. }
  6561. }
  6562. $data ['page'] = $pageinfo;
  6563. $data ['year'] = $year;
  6564. $data ['moth'] = $moth;
  6565. $data ['day'] = $day;
  6566. $data ['get'] = $get;
  6567. $data ['dayHtml'] = $dayHtml;
  6568. $data ['mothHtml'] = $mothHtml;
  6569. $data ['receiptList'] = $dayList;
  6570. $data ['memu'] = "receipt";
  6571. $data ['staff'] = $this->staff;
  6572. $data ['receiptMemu'] = 'remittanceHky';
  6573. $data ['verifyId'] = $this->verifyId;
  6574. $data ['executeId'] = $this->executeId;
  6575. $this->render ( "/admin/remittanceHky", $data );
  6576. }
  6577. function remittancep() {
  6578. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  6579. Doo::loadModel ( 'receipt' );
  6580. $receipt = new receipt ();
  6581. Doo::loadModel ( 'staff' );
  6582. $staff = new staff ();
  6583. Doo::loadClass ( 'XDeode' );
  6584. $XDeode = new XDeode ( 5 );
  6585. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  6586. $rplist = $receipt->find ( array (
  6587. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6588. 'asArray' => true
  6589. ) );
  6590. $dayList = $receipt->find ( array (
  6591. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6592. 'desc' => 'executeDate',
  6593. 'groupby' => 'staff',
  6594. 'asArray' => true
  6595. ) );
  6596. $html = '';
  6597. foreach ( $dayList as $key => $value ) {
  6598. $sinfo = $staff->getOne ( array (
  6599. 'select' => 'username,category',
  6600. 'where' => ' sid=' . $value ['staff'],
  6601. 'asArray' => true
  6602. ) );
  6603. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  6604. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  6605. $au = 0;
  6606. foreach ( $rplist as $k => $v ) {
  6607. if ($value ['staff'] == $v ['staff']) {
  6608. $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>';
  6609. $au += $v ['amount'];
  6610. }
  6611. }
  6612. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  6613. }
  6614. $data ['html'] = $html;
  6615. $data ['memu'] = "receipt";
  6616. $data ['staff'] = $this->staff;
  6617. $data ['receiptMemu'] = 'remittanceHky';
  6618. $data ['verifyId'] = $this->verifyId;
  6619. $data ['executeId'] = $this->executeId;
  6620. $this->render ( "/admin/remittancep", $data );
  6621. }
  6622. function ajaxGetReceiptDetails() {
  6623. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  6624. Doo::loadClass ( 'XDeode' );
  6625. $XDeode = new XDeode ( 5 );
  6626. $rid = $XDeode->decode ( $rid );
  6627. if (empty ( $rid )) {
  6628. echo json_encode ( array (
  6629. 'status' => 2,
  6630. 'msg' => 'illegal request'
  6631. ) );
  6632. die ();
  6633. }
  6634. Doo::loadModel ( 'receipt' );
  6635. $receipt = new receipt ();
  6636. Doo::loadModel ( 'staff' );
  6637. $staff = new staff ();
  6638. $rinfo = $receipt->getOne ( array (
  6639. 'where' => 'rid= ' . $rid,
  6640. 'asArray' => true
  6641. ) );
  6642. $sinfo = $staff->getOne ( array (
  6643. 'select' => 'username,category',
  6644. 'where' => ' sid=' . $rinfo ['staff'],
  6645. 'asArray' => true
  6646. ) );
  6647. $rinfo ['reviseDetail'] = array ();
  6648. if (! empty ( $rinfo ['reviseDetail'] ))
  6649. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  6650. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  6651. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  6652. $rinfo ['category'] = $sinfo ['category'];
  6653. $verifyStaff = array ();
  6654. if (! empty ( $rinfo ['verifyStaff'] ))
  6655. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  6656. $relust = $rinfo ['sum'] - $rinfo ['loanSum'];
  6657. $rinfo ['relust'] = $relust;
  6658. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  6659. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  6660. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  6661. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  6662. // 费用执行人相关数据
  6663. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6664. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6665. foreach ( $executeCopy as $k => $v ) {
  6666. $executeCopy [$k] ['date'] = '';
  6667. $executeCopy [$k] ['opinion'] = '';
  6668. $executeCopy [$k] ['status'] = '';
  6669. if (! empty ( $executeStaff ))
  6670. foreach ( $executeStaff as $m => $u ) {
  6671. if ($v [0] == $m) {
  6672. $executeCopy [$k] ['date'] = $u ['date'];
  6673. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  6674. $executeCopy [$k] ['status'] = $u ['status'];
  6675. break;
  6676. }
  6677. }
  6678. }
  6679. $rinfo ['executeCopy'] = $executeCopy;
  6680. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  6681. if ($rinfo ['Rtype'] == 1) { // 借款费用
  6682. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6683. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  6684. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  6685. $html .= '<tr><th>' . $value ['name'] . '</th>
  6686. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6687. }
  6688. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6689. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6690. <tr><th class="taC" colspan="2">费用说明</th>
  6691. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6692. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6693. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  6694. </tbody></table>';
  6695. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  6696. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6697. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6698. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6699. $html .= '<tr><th>' . $value ['name'] . '</th>
  6700. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6701. }
  6702. $html .= '<tr><th class="taR">合计</th>
  6703. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6704. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6705. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6706. $html .= '<tr><th>' . $value ['name'] . '</th>
  6707. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6708. }
  6709. $html .= '<tr><th class="taR">合计</th>
  6710. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6711. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6712. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6713. $html .= '<tr><th>' . $value ['name'] . '</th>
  6714. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6715. }
  6716. $html .= '<tr><th class="taR">合计</th>
  6717. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6718. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6719. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6720. $html .= '<tr><th>' . $value ['name'] . '</th>
  6721. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6722. }
  6723. $html .= '<tr><th class="taR">合计</th>
  6724. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6725. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6726. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6727. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6728. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6729. }
  6730. $html .= '<tr><th class="taR">合计</th>
  6731. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6732. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6733. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6734. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6735. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6736. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6737. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6738. <tr';
  6739. if ($rinfo ['relust'] >= 0) {
  6740. $html .= 'class="success"';
  6741. } else {
  6742. $html .= 'class="error"';
  6743. }
  6744. $html .= '><td class="taR"><b>借款结余</b></td>
  6745. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  6746. </tbody></table>
  6747. ';
  6748. }
  6749. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  6750. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6751. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  6752. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6753. $html .= '<tr><th>' . $value ['name'] . '</th>
  6754. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6755. }
  6756. $html .= '<tr><th class="taR">合计</th>
  6757. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6758. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6759. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6760. <tr><th class="taC" colspan="2">费用说明</th>
  6761. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6762. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6763. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6764. </tbody></table>';
  6765. } else {
  6766. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6767. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6768. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6769. $html .= '<tr><th>' . $value ['name'] . '</th>
  6770. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6771. }
  6772. $html .= '<tr><th class="taR">合计</th>
  6773. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6774. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6775. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6776. $html .= '<tr><th>' . $value ['name'] . '</th>
  6777. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6778. }
  6779. $html .= '<tr><th class="taR">合计</th>
  6780. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6781. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6782. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6783. $html .= '<tr><th>' . $value ['name'] . '</th>
  6784. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6785. }
  6786. $html .= '<tr><th class="taR">合计</th>
  6787. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6788. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6789. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6790. $html .= '<tr><th>' . $value ['name'] . '</th>
  6791. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6792. }
  6793. $html .= '<tr><th class="taR">合计</th>
  6794. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6795. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6796. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6797. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6798. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6799. }
  6800. $html .= '<tr><th class="taR">合计</th>
  6801. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6802. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6803. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6804. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6805. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6806. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6807. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  6808. $html .= '</tbody></table>';
  6809. /*
  6810. * <table class="table table-bordered table-condensed table-hover"> <tbody> <tr><th colspan="2" class="taC">日常相关费用</th></tr> <!-- loop receiptList' value.accountItem.日常相关费用 --> <tr><th>{{receiptList' value' value.name}}</th><td width="140" class="taR">¥{{receiptList' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptList' value.accountItem.cSum.agencySum}}</td></tr> <tr><th colspan="2" class="taC">差旅相关费用</th></tr> <!-- loop receiptDetail' value.accountItem.差旅相关费用 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.travelSum}}</td></tr> <tr><th colspan="2" class="taC">培训班费用</th></tr> <!-- loop receiptDetail' value.accountItem.培训班费用 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.trainSum}}</td></tr> <tr><th colspan="2" class="taC">其他</th></tr> <!-- loop receiptDetail' value.accountItem.其他 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.otherSum}}</td></tr> <tr><th colspan="2" class="taC">报销金额调整</th></tr> <!-- loop receiptList' value.reviseDetail --> <tr><th><span class="interval">|</span>{{receiptList' value' value.name}}:{{receiptList' value' value.description}}</th><td class="taR">¥{{receiptList' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colOrange taR">¥{{receiptList' value.revisePrice}}</td></tr> <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr> <tr><th style="text-align:center" colspan="2">{{receiptDetail' value.category}}</th></tr> <tr><th class="taC" colspan="2">报销说明</th></tr> <tr><td colspan="2">{{receiptDetail' value.explanation}}</td></tr> <tr class="warning"><td class="taR"><b>({{receiptDetail' value.receiptOrder}})本次报销费用合计</b></td> <td class="colGreed taR"><b style="font-size:24px">¥{{receiptDetail' value.sum}}</b><br>{{receiptDetail' value.sumCN}}</td></tr> </tbody> </table>
  6811. */
  6812. }
  6813. // print_r($verifyStaff);die;
  6814. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  6815. foreach ( $verifyStaff as $key => $value ) {
  6816. $key = trim ( strtr ( $key, '_R', ' ' ) );
  6817. $sinfo = $staff->getOne ( array (
  6818. 'select' => 'username',
  6819. 'where' => ' sid=' . $key,
  6820. 'asArray' => true
  6821. ) );
  6822. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6823. }
  6824. $html .= '</tbody></table>';
  6825. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  6826. foreach ( $rinfo ['executeCopy'] as $value ) {
  6827. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6828. }
  6829. $html .= '</tbody></table>';
  6830. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  6831. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  6832. </tr></table>';
  6833. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  6834. echo json_encode ( array (
  6835. 'status' => 1,
  6836. 'html' => $html
  6837. ) );
  6838. die ();
  6839. }
  6840. /**
  6841. * 删除附件
  6842. */
  6843. function ajaxRemEnclousur(){
  6844. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  6845. if (empty($key))
  6846. echo json_encode ( array (
  6847. 'status' => 2
  6848. ) );
  6849. Doo::loadModel ( 'enclosur' );
  6850. $enclosur = new enclosur ();
  6851. $enclosur->delEnclosurByEid($key);
  6852. echo json_encode ( array (
  6853. 'status' => 1
  6854. ) );
  6855. }
  6856. function remittance() {
  6857. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6858. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6859. Doo::loadModel ( 'receipt' );
  6860. $receipt = new receipt ();
  6861. Doo::loadModel ( 'staff' );
  6862. $staff = new staff ();
  6863. $dateCondition = " and Year(pastDate) =" . $year;
  6864. if (! empty ( $month ))
  6865. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  6866. // get Receipt By verifyID status 1
  6867. $receiptList = $receipt->find ( array (
  6868. 'select' => 'sum(sum) as sum,staff,pastDate',
  6869. 'where' => ' status=1' . $dateCondition,
  6870. 'desc' => 'pastDate',
  6871. 'groupby' => 'staff,pastDate',
  6872. 'asArray' => true
  6873. ) );
  6874. $dateList = $receipt->find ( array (
  6875. 'select' => 'pastDate,verifyStaff',
  6876. 'where' => ' status=1' . $dateCondition,
  6877. 'desc' => 'pastDate',
  6878. 'groupby' => 'pastDate',
  6879. 'asArray' => true
  6880. ) );
  6881. $dataList = array ();
  6882. foreach ( $dateList as $d => $a ) {
  6883. $dataList [$a ['pastDate']] = array ();
  6884. $daySum = 0;
  6885. foreach ( $receiptList as $key => $value ) {
  6886. if ($a ['pastDate'] == $value ['pastDate']) {
  6887. $oderList = $receipt->find ( array (
  6888. 'select' => 'receiptOrder',
  6889. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  6890. 'asArray' => true
  6891. ) );
  6892. $list = array ();
  6893. $html = "";
  6894. foreach ( $oderList as $v ) {
  6895. array_push ( $list, $v ['receiptOrder'] );
  6896. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  6897. }
  6898. $receiptList [$key] ['receiptOrder'] = $html;
  6899. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  6900. $sinfo = $staff->getOne ( array (
  6901. 'select' => 'username ',
  6902. 'where' => ' sid=' . $value ['staff'],
  6903. 'asArray' => true
  6904. ) );
  6905. $receiptList [$key] ['username'] = $sinfo ['username'];
  6906. $daySum += $value ['sum'];
  6907. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  6908. }
  6909. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  6910. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  6911. }
  6912. }
  6913. // print_r($dataList);
  6914. $data ['dataList'] = $dataList;
  6915. $mothHtml = "";
  6916. for($i = 1; $i <= 12; $i ++) {
  6917. if ($month == $i)
  6918. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6919. else
  6920. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6921. }
  6922. $data ['year'] = $year;
  6923. $data ['mothHtml'] = $mothHtml;
  6924. $data ['memu'] = "receipt";
  6925. $data ['staff'] = $this->staff;
  6926. $data ['receiptMemu'] = 'approval';
  6927. $data ['verifyId'] = $this->verifyId;
  6928. $data ['executeId'] = $this->executeId;
  6929. $this->render ( "/admin/saeaReportListPay", $data );
  6930. }
  6931. /**
  6932. * 金额调整,提高稳定性
  6933. * @return string
  6934. */
  6935. function revocationAdjustment() {
  6936. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  6937. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  6938. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  6939. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  6940. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey )&&(!empty($reviseKey)))) {
  6941. Doo::loadClass ( 'XDeode' );
  6942. $XDeode = new XDeode ( 5 );
  6943. Doo::loadModel ( 'receipt' );
  6944. $receipt = new receipt ();
  6945. $sid = $XDeode->decode ( $sidKey );
  6946. $rid = $XDeode->decode ( $ridKey );
  6947. $reviseKey = $XDeode->decode ( $reviseKey );
  6948. if(!is_numeric($sid)&&!is_numeric($rid)&&!is_numeric($reviseKey))
  6949. die ( 'illegal request' );
  6950. $receiptDetail = $receipt->getOne ( array (
  6951. 'where' => 'rid=' . $rid,
  6952. 'asArray' => true
  6953. ) );
  6954. if (empty($receiptDetail)||empty ( $receiptDetail ['reviseDetail'] ))
  6955. die ( 'illegal request' );
  6956. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  6957. if (!isset($reviseDetail[$reviseKey]))
  6958. die ( 'illegal request' );
  6959. if($reviseDetail[$reviseKey]['sid']==$sid&&$reviseDetail[$reviseKey]['price']==$price)
  6960. unset($reviseDetail[$reviseKey]);
  6961. $revisePrice=0;
  6962. foreach ( $reviseDetail as $key => $value ) {
  6963. $revisePrice+=$value['price'];
  6964. }
  6965. $reviseDetailString = json_encode ( $reviseDetail );
  6966. $receipt->reviseDetail = $reviseDetailString;
  6967. $receipt->sum = $receiptDetail ['sum'] - $price;
  6968. $receipt->revisePrice = $revisePrice;
  6969. $receipt->update ( array (
  6970. 'where' => 'rid=' . $rid
  6971. ) );
  6972. return '/receiptburEdi/' . $rid;
  6973. }else
  6974. die ( 'illegal request2' );
  6975. }
  6976. function updateApprovalReceipt() {
  6977. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6978. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  6979. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6980. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  6981. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  6982. if (! empty ( $rid )) {
  6983. Doo::loadModel ( "verify" );
  6984. $verify = new verify ();
  6985. Doo::loadModel ( "receiptDetail" );
  6986. $receiptDetailObj = new receiptDetail ();
  6987. Doo::loadModel ( "itemStatistics" );
  6988. Doo::loadModel ( "statistics" );
  6989. $statistics = new statistics ();
  6990. $itemStatistics = new itemStatistics ();
  6991. Doo::loadModel ( "receipt" );
  6992. $receipt = new receipt ();
  6993. $receiptDetail = $receipt->getOne ( array (
  6994. 'where' => 'rid=' . $rid . ' and status=2 ',
  6995. 'asArray' => true
  6996. ) );
  6997. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  6998. $nsflag = true;
  6999. foreach ( $nslist as $value ) {
  7000. if ($value == $this->staff ['0'] ['sid']) {
  7001. $nsflag = false;
  7002. break;
  7003. }
  7004. }
  7005. if (empty ( $receiptDetail ) || $nsflag)
  7006. return "/approval";
  7007. $verifyDetail = $verify->getOne ( array (
  7008. 'where' => ' vid =' . $receiptDetail ['verify'],
  7009. 'asArray' => true
  7010. ) );
  7011. $verifyString = $verifyDetail ['staff'];
  7012. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  7013. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  7014. if (empty ( $opinion )) {
  7015. if ($status == 3)
  7016. $opinion = "终止";
  7017. else
  7018. $opinion = "同意支付";
  7019. }
  7020. $nowStaff = 0;
  7021. $nowStaffList = array ();
  7022. if (empty ( $verifyStaff )) {
  7023. // 还需加入是否已经进入角色审批
  7024. if ($verifyDetail [0] [1] == 'ROLE') {
  7025. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  7026. foreach ( $vStaffString as $key => $value ) {
  7027. $staffK = explode ( "_", $value );
  7028. if ($staffK [0] != $this->staff [0] ['sid'])
  7029. array_push ( $nowStaffList, $staffK [0] );
  7030. }
  7031. // print_r($verifyDetail);
  7032. // die;
  7033. if (! empty ( $nowStaffList )) {
  7034. $nowStaff = implode ( ',', $nowStaffList );
  7035. $verifyStaff = array (
  7036. $this->staff [0] ['sid'] . "_R" => array (
  7037. 'date' => date ( 'Y-m-d' ),
  7038. 'opinion' => $opinion,
  7039. 'status' => $status,
  7040. 'nextStaff' => $verifyDetail [0] [0],
  7041. 'ROLE' => 1
  7042. )
  7043. );
  7044. } else {
  7045. $nowStaff = $verifyDetail [1] [0];
  7046. $verifyStaff = array (
  7047. $this->staff [0] ['sid'] . "_R" => array (
  7048. 'date' => date ( 'Y-m-d' ),
  7049. 'opinion' => $opinion,
  7050. 'status' => $status,
  7051. 'nextStaff' => $verifyDetail [1] [0]
  7052. )
  7053. );
  7054. }
  7055. } else {
  7056. if ($verifyDetail [1] [1] == 'ROLE') {
  7057. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  7058. // echo "dd";
  7059. foreach ( $vStaffString as $key => $value ) {
  7060. $staffK = explode ( "_", $value );
  7061. array_push ( $nowStaffList, $staffK [0] );
  7062. }
  7063. $nowStaff = implode ( ',', $nowStaffList );
  7064. $verifyStaff = array (
  7065. $this->staff [0] ['sid'] => array (
  7066. 'date' => date ( 'Y-m-d' ),
  7067. 'opinion' => $opinion,
  7068. 'status' => $status,
  7069. 'nextStaff' => $verifyDetail [1] [0],
  7070. 'ROLE' => 1
  7071. )
  7072. );
  7073. } else {
  7074. $nowStaff = $verifyDetail [1] [0];
  7075. $verifyStaff = array (
  7076. $this->staff [0] ['sid'] => array (
  7077. 'date' => date ( 'Y-m-d' ),
  7078. 'opinion' => $opinion,
  7079. 'status' => $status,
  7080. 'nextStaff' => $verifyDetail [1] [0]
  7081. )
  7082. );
  7083. }
  7084. }
  7085. if ($status == 3)
  7086. $verifyStaff = array (
  7087. 'final' => $status,
  7088. $this->staff [0] ['sid'] => array (
  7089. 'date' => date ( 'Y-m-d' ),
  7090. 'opinion' => $opinion,
  7091. 'status' => $status
  7092. )
  7093. );
  7094. $vStaffString = json_encode ( $verifyStaff );
  7095. $receipt->nowStaff = $nowStaff;
  7096. $receipt->verifyStaff = $vStaffString;
  7097. } else {
  7098. $VS = end ( $verifyStaff );
  7099. // 非角色审批
  7100. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  7101. $nextStaff = 0;
  7102. $roleSTF = false;
  7103. foreach ( $verifyDetail as $key => $value ) {
  7104. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  7105. if (isset ( $verifyDetail [$key + 1] )) {
  7106. $nextStaff = $verifyDetail [$key + 1] [0];
  7107. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  7108. $roleSTF = true;
  7109. }
  7110. break;
  7111. }
  7112. }
  7113. if (! $roleSTF) {
  7114. $nowStaff = $nextStaff;
  7115. $verifyStaff [$this->staff [0] ['sid']] = array (
  7116. 'date' => date ( 'Y-m-d' ),
  7117. 'opinion' => $opinion,
  7118. 'status' => $status,
  7119. 'nextStaff' => $nextStaff
  7120. );
  7121. } else {
  7122. // 获取角色下的所有用户ID
  7123. $nowStaffList = array ();
  7124. foreach ( $verifyDetail as $vfk ) {
  7125. if ($vfk [1] == 'ROLE') {
  7126. $vStaffString = json_decode ( $vfk [3] );
  7127. foreach ( $vStaffString as $key => $value ) {
  7128. $staffK = explode ( "_", $value );
  7129. array_push ( $nowStaffList, $staffK [0] );
  7130. }
  7131. }
  7132. }
  7133. $nowStaff = implode ( ',', $nowStaffList );
  7134. $verifyStaff [$this->staff [0] ['sid']] = array (
  7135. 'date' => date ( 'Y-m-d' ),
  7136. 'opinion' => $opinion,
  7137. 'status' => $status,
  7138. 'nextStaff' => $nextStaff,
  7139. 'ROLE' => 0
  7140. );
  7141. }
  7142. if ($status == 3) {
  7143. $verifyStaff ['final'] = $status;
  7144. $verifyStaff [$this->staff [0] ['sid']] = array (
  7145. 'date' => date ( 'Y-m-d' ),
  7146. 'opinion' => $opinion,
  7147. 'status' => $status
  7148. );
  7149. }
  7150. $vStaffString = json_encode ( $verifyStaff );
  7151. $receipt->nowStaff = $nowStaff;
  7152. $receipt->verifyStaff = $vStaffString;
  7153. }
  7154. // 角色审批
  7155. if (isset ( $VS ['ROLE'] )) {
  7156. // 找出角色人 当前审批角色组
  7157. $verifyJSStaff = array ();
  7158. $nowStaffList2 = array ();
  7159. foreach ( $verifyDetail as $key => $value ) {
  7160. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  7161. $verifyJSStaff = json_decode ( $value [3] );
  7162. foreach ( $verifyJSStaff as $m ) {
  7163. $staffK = explode ( "_", $m );
  7164. array_push ( $nowStaffList2, $staffK [0] );
  7165. }
  7166. // print_r($nowStaffList2);
  7167. }
  7168. }
  7169. $RoleVerifyStaff = array ();
  7170. foreach ( $verifyStaff as $key => $value ) {
  7171. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  7172. foreach ( $nowStaffList2 as $m ) {
  7173. if ($key == $m . "_R")
  7174. $RoleVerifyStaff [$key] = $value;
  7175. }
  7176. }
  7177. }
  7178. // print_r($verifyStaff);
  7179. // print_r($nowStaffList2);
  7180. // print_r($RoleVerifyStaff);
  7181. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  7182. // print_r($verifyJSStaff);
  7183. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  7184. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  7185. // 下一个审批人ID
  7186. $nextStaff = 0;
  7187. $falg = false;
  7188. foreach ( $verifyDetail as $key => $value ) {
  7189. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  7190. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  7191. $falg = true;
  7192. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  7193. $nowStaffList = array ();
  7194. foreach ( $vStaffString as $v ) {
  7195. $staffK = explode ( "_", $v );
  7196. array_push ( $nowStaffList, $staffK [0] );
  7197. }
  7198. $nowStaff = implode ( ',', $nowStaffList );
  7199. $nextStaff = $verifyDetail [$key + 1] [0];
  7200. } elseif (isset ( $verifyDetail [$key + 1] )) {
  7201. $nextStaff = $verifyDetail [$key + 1] [0];
  7202. $nowStaff = $nextStaff;
  7203. } else
  7204. $nowStaff = '';
  7205. break;
  7206. }
  7207. }
  7208. if ($falg)
  7209. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7210. 'date' => date ( 'Y-m-d' ),
  7211. 'opinion' => $opinion,
  7212. 'status' => $status,
  7213. 'nextStaff' => $nextStaff,
  7214. 'ROLE' => 1
  7215. );
  7216. else
  7217. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7218. 'date' => date ( 'Y-m-d' ),
  7219. 'opinion' => $opinion,
  7220. 'status' => $status,
  7221. 'nextStaff' => $nextStaff
  7222. );
  7223. // print_r($verifyStaff);
  7224. // echo $nowStaff;die;
  7225. } else { // 进入下一个角色或者审批人
  7226. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  7227. //
  7228. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  7229. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7230. 'date' => date ( 'Y-m-d' ),
  7231. 'opinion' => $opinion,
  7232. 'status' => $status,
  7233. 'nextStaff' => $VS ['nextStaff'],
  7234. 'ROLE' => 1
  7235. );
  7236. // print_r($verifyStaff);
  7237. // die;
  7238. }
  7239. if ($status == 3) {
  7240. $verifyStaff ['final'] = $status;
  7241. $verifyStaff [$this->staff [0] ['sid']] = array (
  7242. 'date' => date ( 'Y-m-d' ),
  7243. 'opinion' => $opinion,
  7244. 'status' => $status
  7245. );
  7246. }
  7247. $vStaffString = json_encode ( $verifyStaff );
  7248. $receipt->verifyStaff = $vStaffString;
  7249. $receipt->nowStaff = $nowStaff;
  7250. // die;
  7251. // }
  7252. // print_r($verifyStaff);
  7253. // die;
  7254. }
  7255. // print_r($verifyStaff);die;
  7256. }
  7257. // print_r($verifyDetail);
  7258. $roleKey = 0;
  7259. $roleId = 0;
  7260. $verifyDetailCopy = array ();
  7261. foreach ( $verifyDetail as $k => $v ) {
  7262. if ($v [1] == 'ROLE') {
  7263. $roleId = $v [0];
  7264. $roleVerify = json_decode ( $v [3], true );
  7265. $roleKey = $k;
  7266. $roleArray = array ();
  7267. foreach ( $roleVerify as $o => $p ) {
  7268. $staffID = explode ( '_', $p );
  7269. $exp = array (
  7270. 0 => $staffID [0],
  7271. 1 => $staffID [1]
  7272. );
  7273. array_push ( $roleArray, $exp );
  7274. }
  7275. $verifyDetailCopy [$v [0]] = $roleArray;
  7276. }
  7277. }
  7278. // print_r($verifyDetail);
  7279. foreach ( $verifyDetailCopy as $k => $v ) {
  7280. foreach ( $verifyDetail as $m => $n ) {
  7281. if ($n [0] == $k) {
  7282. array_splice ( $verifyDetail, $m, 1, $v );
  7283. }
  7284. }
  7285. }
  7286. // die;
  7287. // if (!empty($roleArray))
  7288. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  7289. // echo $roleId;
  7290. // print_r($verifyStaff);
  7291. // print_r($verifyDetail);
  7292. // die;
  7293. Doo::loadModel ( "receiptLog" );
  7294. $receiptLog = new receiptLog ();
  7295. // 审批日志
  7296. if (! isset ( $verifyStaff ['final'] )) {
  7297. if (! empty ( $roleId )) {
  7298. Doo::loadModel ( "role" );
  7299. $role = new role ();
  7300. $roleInfo = $role->getOne ( array (
  7301. 'where' => 'rid=' . $roleId,
  7302. 'asArray' => true
  7303. ) );
  7304. $receiptLog->rolename = $roleInfo ['name'];
  7305. }
  7306. $receiptLog->username = $this->staff [0] ['username'];
  7307. $receiptLog->uid = $this->staff [0] ['sid'];
  7308. $receiptLog->date = date ( "Y-m-d" );
  7309. $receiptLog->opinion = $opinion;
  7310. $receiptLog->img = $this->staff [0] ['avatar'];
  7311. $receiptLog->status = 1;
  7312. $receiptLog->rid = $rid;
  7313. $receiptLog->insert ();
  7314. }
  7315. if (isset ( $verifyStaff ['final'] )) { // rDetail
  7316. $receipt->verifyBreakup = $verifyString;
  7317. $receipt->status = 3;
  7318. $receiptDetailObj->status = 3;
  7319. $receiptDetailObj->update ( array (
  7320. 'where' => 'rid=' . $rid
  7321. ) );
  7322. if (! empty ( $roleId )) {
  7323. Doo::loadModel ( "role" );
  7324. $role = new role ();
  7325. $roleInfo = $role->getOne ( array (
  7326. 'where' => 'rid=' . $roleId,
  7327. 'asArray' => true
  7328. ) );
  7329. $receiptLog->rolename = $roleInfo ['name'];
  7330. }
  7331. $receiptLog->username = $this->staff [0] ['username'];
  7332. $receiptLog->uid = $this->staff [0] ['sid'];
  7333. $receiptLog->date = date ( "Y-m-d" );
  7334. $receiptLog->opinion = $opinion;
  7335. $receiptLog->img = $this->staff [0] ['avatar'];
  7336. $receiptLog->status = 3;
  7337. $receiptLog->rid = $rid;
  7338. $receiptLog->insert ();
  7339. // 微信企业号通知
  7340. $this->setWXMsg ( $rid, 3 );
  7341. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  7342. $receipt->status = 1;
  7343. $reviseSum = 0;
  7344. $receipt->verifyBreakup = $verifyString;
  7345. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  7346. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7347. foreach ( $reviseDetail as $key => $value ) {
  7348. $receiptDetailObj = new receiptDetail ();
  7349. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7350. $receiptDetailObj->item = $value ['description'];
  7351. $receiptDetailObj->itemCategory = "报销金额调整";
  7352. $receiptDetailObj->price = $value ['price'];
  7353. $receiptDetailObj->date = $receiptDetail ['date'];
  7354. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  7355. $receiptDetailObj->rid = $rid;
  7356. $receiptDetailObj->status = 1;
  7357. $receiptDetailObj->insert ();
  7358. $reviseSum += $value ['price'];
  7359. }
  7360. $itemStatistics = new itemStatistics ();
  7361. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7362. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7363. $itemStatistics->price = $reviseSum;
  7364. $itemStatistics->itemCategory = "报销金额调整";
  7365. $itemStatistics->date = $receiptDetail ['date'];
  7366. $itemStatistics->insert ();
  7367. }
  7368. $receiptDetailObj = new receiptDetail ();
  7369. $receiptDetailObj->status = 1;
  7370. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  7371. $receiptDetailObj->update ( array (
  7372. 'where' => 'rid=' . $rid
  7373. ) );
  7374. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7375. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7376. $stat = $statistics->getOne ( array (
  7377. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  7378. 'asArray' => true
  7379. ) );
  7380. if (empty ( $stat )) {
  7381. $statistics->date = $receiptDetail ['date'];
  7382. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7383. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7384. $statistics->agPrice = $receiptDetail ['sum'];
  7385. $statistics->rePrice = $reviseSum;
  7386. $statistics->insert ();
  7387. } else {
  7388. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  7389. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  7390. $statistics->update ( array (
  7391. 'where' => 'sid=' . $stat ['sid']
  7392. ) );
  7393. }
  7394. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7395. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7396. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  7397. foreach ( $accountItem ['cSum'] as $key => $value ) {
  7398. if ($key == "agencySum") {
  7399. $iStatistics = $itemStatistics->getOne ( array (
  7400. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  7401. 'asArray' => true
  7402. ) );
  7403. if (empty ( $iStatistics )) {
  7404. $itemStatistics->cid = $receiptDetail ['cid'];
  7405. ;
  7406. $itemStatistics->staff = $receiptDetail ['staff'];
  7407. $itemStatistics->price = $value;
  7408. $itemStatistics->itemCategory = $this->AGENCY;
  7409. $itemStatistics->date = $receiptDetail ['date'];
  7410. $itemStatistics->insert ();
  7411. } else {
  7412. if (! empty ( $value )) {
  7413. $itemStatistics->price = $value + $iStatistics ['price'];
  7414. $itemStatistics->update ( array (
  7415. 'where' => 'sid=' . $iStatistics ['sid']
  7416. ) );
  7417. }
  7418. }
  7419. } elseif ($key == "travelSum") {
  7420. $iStatistics = $itemStatistics->getOne ( array (
  7421. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  7422. 'asArray' => true
  7423. ) );
  7424. if (empty ( $iStatistics )) {
  7425. $itemStatistics->cid = $receiptDetail ['cid'];
  7426. $itemStatistics->staff = $receiptDetail ['staff'];
  7427. $itemStatistics->price = $value;
  7428. $itemStatistics->itemCategory = $this->TRAVEL;
  7429. $itemStatistics->date = $receiptDetail ['date'];
  7430. $itemStatistics->insert ();
  7431. } else {
  7432. if (! empty ( $value )) {
  7433. $itemStatistics->price = $value + $iStatistics ['price'];
  7434. $itemStatistics->update ( array (
  7435. 'where' => 'sid=' . $iStatistics ['sid']
  7436. ) );
  7437. }
  7438. }
  7439. } elseif ($key == "trainSum") {
  7440. $iStatistics = $itemStatistics->getOne ( array (
  7441. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  7442. 'asArray' => true
  7443. ) );
  7444. if (empty ( $iStatistics )) {
  7445. $itemStatistics->cid = $receiptDetail ['cid'];
  7446. $itemStatistics->staff = $receiptDetail ['staff'];
  7447. $itemStatistics->price = $value;
  7448. $itemStatistics->itemCategory = $this->TRAIN;
  7449. $itemStatistics->date = $receiptDetail ['date'];
  7450. $itemStatistics->insert ();
  7451. } else {
  7452. if (! empty ( $value )) {
  7453. $itemStatistics->price = $value + $iStatistics ['price'];
  7454. $itemStatistics->update ( array (
  7455. 'where' => 'sid=' . $iStatistics ['sid']
  7456. ) );
  7457. }
  7458. }
  7459. } elseif ($key == "otherSum") {
  7460. $iStatistics = $itemStatistics->getOne ( array (
  7461. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  7462. 'asArray' => true
  7463. ) );
  7464. if (empty ( $iStatistics )) {
  7465. $itemStatistics->cid = $receiptDetail ['cid'];
  7466. $itemStatistics->staff = $receiptDetail ['staff'];
  7467. $itemStatistics->price = $value;
  7468. $itemStatistics->itemCategory = $this->OTHER;
  7469. $itemStatistics->date = $receiptDetail ['date'];
  7470. $itemStatistics->insert ();
  7471. } else {
  7472. if (! empty ( $value )) {
  7473. $itemStatistics->price = $value + $iStatistics ['price'];
  7474. $itemStatistics->update ( array (
  7475. 'where' => 'sid=' . $iStatistics ['sid']
  7476. ) );
  7477. }
  7478. }
  7479. }
  7480. }
  7481. $receipt->pastDate = date ( "Y-m-d" );
  7482. // 微信企业号通知
  7483. $this->setWXMsg ( $rid, 1 );
  7484. }
  7485. $receipt->amount = $amount;
  7486. $receipt->update ( array (
  7487. 'where' => ' rid = ' . $rid
  7488. ) );
  7489. // 进入下一条审批费用新加需求
  7490. $vidList = array ();
  7491. $verifyDetail = $verify->find ( array (
  7492. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  7493. 'asArray' => true
  7494. ) );
  7495. foreach ( $verifyDetail as $key => $value ) {
  7496. array_push ( $vidList, $value ['vid'] );
  7497. }
  7498. $vid = implode ( ",", $vidList );
  7499. if (empty ( $verifyDetail ))
  7500. $vid = 0;
  7501. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  7502. $receipt = new receipt ();
  7503. $rd = $receipt->getOne ( array (
  7504. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  7505. 'asc' => 'rid',
  7506. 'asArray' => true
  7507. ) );
  7508. if (empty ( $rd )) {
  7509. return '/approvalExpenses/pendApproval';
  7510. }
  7511. if ($rd ['Rtype'] == 1) {
  7512. if ($rd ['isBK'] == 1) {
  7513. return '/receiptburEdi/' . $rd ['rid'];
  7514. } else {
  7515. return '/expensesEdi/' . $rd ['rid'];
  7516. }
  7517. } elseif ($rd ['Rtype'] == 2) {
  7518. return '/remitApproval/' . $rd ['rid'];
  7519. } else {
  7520. return '/receiptburEdi/' . $rd ['rid'];
  7521. }
  7522. // return "/approvalExpenses/pendApproval";
  7523. }
  7524. }
  7525. function expensesRetreats() {
  7526. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7527. if (! empty ( $rid )) {
  7528. // 操作记录
  7529. Doo::loadModel ( "receipt" );
  7530. $receipt = new receipt ();
  7531. Doo::loadModel ( "receiptLog" );
  7532. $receiptLog = new receiptLog ();
  7533. Doo::loadModel ( "verify" );
  7534. $verify = new verify ();
  7535. $receiptInfo = $receipt->getOne ( array (
  7536. 'where' => 'rid=' . $rid,
  7537. 'asArray' => true
  7538. ) );
  7539. $vr = $verify->getOne ( array (
  7540. 'where' => 'vid=' . $receiptInfo ['verify'],
  7541. 'asArray' => true
  7542. ) );
  7543. $jd = json_decode ( $vr ['staff'] );
  7544. $roleId = 0;
  7545. foreach ( $jd as $key => $value ) {
  7546. if ($value [1] == 'ROLE') {
  7547. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7548. if ($pos !== false) {
  7549. $roleId = $value [0];
  7550. }
  7551. }
  7552. }
  7553. // 审批日志
  7554. // echo $roleId;die;
  7555. if (! empty ( $roleId )) {
  7556. Doo::loadModel ( "role" );
  7557. $role = new role ();
  7558. $roleInfo = $role->getOne ( array (
  7559. 'where' => 'rid=' . $roleId,
  7560. 'asArray' => true
  7561. ) );
  7562. $receiptLog->rolename = $roleInfo ['name'];
  7563. }
  7564. $receiptLog->username = $this->staff [0] ['username'];
  7565. $receiptLog->uid = $this->staff [0] ['sid'];
  7566. $receiptLog->date = date ( "Y-m-d" );
  7567. $receiptLog->opinion = '撤回';
  7568. $receiptLog->img = $this->staff [0] ['avatar'];
  7569. $receiptLog->status = 4;
  7570. $receiptLog->rid = $rid;
  7571. $receiptLog->insert ();
  7572. $receipt->status = 4;
  7573. $receipt->update ( array (
  7574. 'where' => 'rid=' . $rid
  7575. ) );
  7576. // 微信企业号通知
  7577. $this->setWXMsg ( $rid, 2 );
  7578. }
  7579. // echo "ddd";
  7580. return '/approvalExpenses/pendApproval';
  7581. }
  7582. function updateCheReceipt() {
  7583. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7584. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7585. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  7586. if (! empty ( $rid )) {
  7587. // 操作记录
  7588. Doo::loadModel ( "receipt" );
  7589. $receipt = new receipt ();
  7590. Doo::loadModel ( "receiptLog" );
  7591. $receiptLog = new receiptLog ();
  7592. Doo::loadModel ( "verify" );
  7593. $verify = new verify ();
  7594. $receiptInfo = $receipt->getOne ( array (
  7595. 'where' => 'rid=' . $rid . ' and status=2',
  7596. 'asArray' => true
  7597. ) );
  7598. if (empty ( $receiptInfo )) {
  7599. echo json_encode ( array (
  7600. 'status' => 2
  7601. ) );
  7602. die ();
  7603. }
  7604. $vr = $verify->getOne ( array (
  7605. 'where' => 'vid=' . $receiptInfo ['verify'],
  7606. 'asArray' => true
  7607. ) );
  7608. $jd = json_decode ( $vr ['staff'] );
  7609. $roleId = 0;
  7610. foreach ( $jd as $key => $value ) {
  7611. if ($value [1] == 'ROLE') {
  7612. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7613. if ($pos !== false) {
  7614. $roleId = $value [0];
  7615. }
  7616. }
  7617. }
  7618. // 审批日志
  7619. // echo $roleId;die;
  7620. if (! empty ( $roleId )) {
  7621. Doo::loadModel ( "role" );
  7622. $role = new role ();
  7623. $roleInfo = $role->getOne ( array (
  7624. 'where' => 'rid=' . $roleId,
  7625. 'asArray' => true
  7626. ) );
  7627. $receiptLog->rolename = $roleInfo ['name'];
  7628. }
  7629. $receiptLog->username = $this->staff [0] ['username'];
  7630. $receiptLog->uid = $this->staff [0] ['sid'];
  7631. $receiptLog->date = date ( "Y-m-d" );
  7632. $receiptLog->opinion = $opinion;
  7633. $receiptLog->img = $this->staff [0] ['avatar'];
  7634. $receiptLog->status = 4;
  7635. $receiptLog->rid = $rid;
  7636. $receiptLog->insert ();
  7637. $receipt->status = 4;
  7638. $receipt->update ( array (
  7639. 'where' => 'rid=' . $rid
  7640. ) );
  7641. // 微信企业号通知
  7642. $this->setWXMsg ( $rid, 2 );
  7643. echo json_encode ( array (
  7644. 'status' => 1
  7645. ) );
  7646. // Header("HTTP/1.1 303 See Other");
  7647. // Header("Location: /approvalExpenses/pendApproval");
  7648. die ();
  7649. }
  7650. echo json_encode ( array (
  7651. 'status' => 2
  7652. ) );
  7653. die ();
  7654. // echo "ddd";
  7655. // return '/saeaBorad';
  7656. }
  7657. function revisePrice() {
  7658. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  7659. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  7660. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7661. // echo $price;die;
  7662. if (! empty ( $rid )) {
  7663. Doo::loadModel ( "receipt" );
  7664. $receipt = new receipt ();
  7665. $receiptDetail = $receipt->getOne ( array (
  7666. 'where' => 'rid=' . $rid . ' and status=2 ',
  7667. 'asArray' => true
  7668. ) );
  7669. if (empty ( $receiptDetail ))
  7670. die ( 'illegal request' );
  7671. $reviseDetail = array ();
  7672. if (empty ( $receiptDetail ['reviseDetail'] )) {
  7673. array_push ( $reviseDetail, array (
  7674. 'sid' => $this->staff [0] ['sid'],
  7675. 'name' => $this->staff [0] ['username'],
  7676. 'description' => $description,
  7677. 'price' => $price
  7678. ) );
  7679. $reviseDetailString = json_encode ( $reviseDetail );
  7680. $receipt->reviseDetail = $reviseDetailString;
  7681. $receipt->revisePrice = $price;
  7682. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7683. } else {
  7684. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7685. array_push ( $reviseDetail, array (
  7686. 'sid' => $this->staff [0] ['sid'],
  7687. 'name' => $this->staff [0] ['username'],
  7688. 'description' => $description,
  7689. 'price' => $price
  7690. ) );
  7691. $reviseDetailString = json_encode ( $reviseDetail );
  7692. $receipt->reviseDetail = $reviseDetailString;
  7693. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  7694. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7695. }
  7696. $receipt->update ( array (
  7697. 'where' => 'rid=' . $rid
  7698. ) );
  7699. if ($receiptDetail ['Rtype'] == 1) {
  7700. if ($receiptDetail ['isBK'] == 1) {
  7701. return '/receiptburEdi/'.$receiptDetail['rid'];
  7702. }
  7703. } elseif ($receiptDetail ['Rtype'] == 2) {
  7704. } else {
  7705. return '/receiptburEdi/'.$receiptDetail['rid'];
  7706. }
  7707. }
  7708. die ( 'illegal request' );
  7709. }
  7710. function personalCollect() {
  7711. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7712. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  7713. $this->showCache ( $path );
  7714. Doo::loadModel ( "receiptDetail" );
  7715. Doo::loadModel ( "itemStatistics" );
  7716. Doo::loadModel ( 'statistics' );
  7717. $statistics = new statistics ();
  7718. $itemStatistics = new itemStatistics ();
  7719. $receiptDetail = new receiptDetail ();
  7720. $receiptCollectList = $receiptDetail->find ( array (
  7721. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7722. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7723. 'groupby' => 'itemCategory,Month(date)',
  7724. 'asArray' => true
  7725. ) );
  7726. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  7727. 'where' => 'staff=' . $this->staff [0] ['sid'],
  7728. 'asArray' => true
  7729. ) );
  7730. // create collect html
  7731. $collectArray = array (
  7732. '日常相关费用' => array (),
  7733. '差旅相关费用' => array (),
  7734. '培训班费用' => array (),
  7735. '其他' => array ()
  7736. );
  7737. $adjustment = array ();
  7738. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  7739. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7740. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  7741. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7742. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  7743. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7744. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  7745. array_push ( $collectArray ['其他'], $collectHtml );
  7746. $data ['collectArray'] = $collectArray;
  7747. // statistics html
  7748. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7749. if (empty ( $stList ))
  7750. $stList = array (
  7751. 'rePrice' => 0,
  7752. 'agPrice' => 0
  7753. );
  7754. $data ['stList'] = array (
  7755. 'rePrice' => $stList ['rePrice'],
  7756. 'agPrice' => $stList ['agPrice'],
  7757. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7758. );
  7759. // Adjustment price html
  7760. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7761. array_push ( $adjustment, $collectHtml );
  7762. $data ['adjustment'] = $adjustment;
  7763. // total price html
  7764. $collectHtml = "";
  7765. $total = 0;
  7766. for($i = 1; $i <= 12; $i ++) {
  7767. $sumPrice = 0;
  7768. foreach ( $receiptCollectList as $key => $value ) {
  7769. if ($value ['month'] == $i) {
  7770. $sumPrice += $value ['price'];
  7771. }
  7772. }
  7773. if ($sumPrice == 0)
  7774. $collectHtml .= '<td class="taR">-</td>';
  7775. else
  7776. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7777. $total += $sumPrice;
  7778. }
  7779. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7780. $data ['totalPrice'] = $collectHtml;
  7781. $data ['year'] = $year;
  7782. $data ['totalYear'] = $total;
  7783. $data ['memu'] = "receipt";
  7784. $data ['staff'] = $this->staff;
  7785. $data ['receiptMemu'] = 'personalCollect';
  7786. $data ['verifyId'] = $this->verifyId;
  7787. $data ['executeId'] = $this->executeId;
  7788. // year staff status 2,4
  7789. if ($year < date ( "Y" )) {
  7790. Doo::loadModel ( 'receipt' );
  7791. $receipt = new receipt ();
  7792. $receiptList = $receipt->find ( array (
  7793. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7794. 'asArray' => true
  7795. ) );
  7796. if (empty ( $receiptList )) {
  7797. ob_start ();
  7798. $this->render ( "/admin/saea_slist_collect", $data );
  7799. $this->cacheFile ( $path );
  7800. die ();
  7801. }
  7802. }
  7803. $this->render ( "/admin/saea_slist_collect", $data );
  7804. }
  7805. function personalCollectDetail() {
  7806. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7807. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  7808. $this->showCache ( $path );
  7809. Doo::loadModel ( "receiptDetail" );
  7810. Doo::loadModel ( "itemStatistics" );
  7811. Doo::loadModel ( 'statistics' );
  7812. Doo::loadModel ( 'accountItem' );
  7813. $accountItem = new accountItem ();
  7814. $statistics = new statistics ();
  7815. $itemStatistics = new itemStatistics ();
  7816. $receiptDetail = new receiptDetail ();
  7817. $receiptCollectList = $receiptDetail->find ( array (
  7818. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  7819. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7820. 'groupby' => 'item,Month(date)',
  7821. 'asArray' => true
  7822. ) );
  7823. $accountList = $accountItem->find ( array (
  7824. 'asArray' => true
  7825. ) );
  7826. // create CollectDetail HTML
  7827. $collectHtml = array ();
  7828. foreach ( $accountList as $key => $value ) {
  7829. $html = "";
  7830. $asum = 0;
  7831. for($i = 1; $i <= 12; $i ++) {
  7832. $falg = true;
  7833. foreach ( $receiptCollectList as $v ) {
  7834. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7835. $asum += $v ['price'];
  7836. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7837. $falg = false;
  7838. break;
  7839. }
  7840. }
  7841. if ($falg)
  7842. $html .= '<td class="taR">-</td>';
  7843. }
  7844. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7845. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7846. }
  7847. $data ['collectHtml'] = $collectHtml;
  7848. // create Adjustment price html
  7849. $receiptCollectList = $receiptDetail->find ( array (
  7850. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7851. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7852. 'groupby' => 'itemCategory,Month(date)',
  7853. 'asArray' => true
  7854. ) );
  7855. $adjustment = array ();
  7856. $collectArray = array (
  7857. '日常相关费用' => array (),
  7858. '差旅相关费用' => array (),
  7859. '培训班费用' => array (),
  7860. '其他' => array ()
  7861. );
  7862. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7863. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7864. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7865. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7866. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7867. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7868. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7869. array_push ( $collectArray ['其他'], $collectHtml );
  7870. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7871. array_push ( $adjustment, $collectHtml );
  7872. // total price html
  7873. $collectHtml = "";
  7874. $total = 0;
  7875. for($i = 1; $i <= 12; $i ++) {
  7876. $sumPrice = 0;
  7877. foreach ( $receiptCollectList as $key => $value ) {
  7878. if ($value ['month'] == $i) {
  7879. $sumPrice += $value ['price'];
  7880. }
  7881. }
  7882. if ($sumPrice == 0)
  7883. $collectHtml .= '<td class="taR">-</td>';
  7884. else
  7885. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7886. $total += $sumPrice;
  7887. }
  7888. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7889. // statistics html
  7890. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7891. if (empty ( $stList ))
  7892. $stList = array (
  7893. 'rePrice' => 0,
  7894. 'agPrice' => 0
  7895. );
  7896. $data ['stList'] = array (
  7897. 'rePrice' => $stList ['rePrice'],
  7898. 'agPrice' => $stList ['agPrice'],
  7899. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7900. );
  7901. $data ['collectArray'] = $collectArray;
  7902. $data ['adjustment'] = $adjustment;
  7903. $data ['totalPrice'] = $collectHtml;
  7904. $data ['totalYear'] = $total;
  7905. $data ['year'] = $year;
  7906. $data ['memu'] = "receipt";
  7907. $data ['staff'] = $this->staff;
  7908. $data ['receiptMemu'] = 'personalCollect';
  7909. $data ['verifyId'] = $this->verifyId;
  7910. $data ['executeId'] = $this->executeId;
  7911. // year staff status 2,4
  7912. if ($year < date ( "Y" )) {
  7913. Doo::loadModel ( 'receipt' );
  7914. $receipt = new receipt ();
  7915. $receiptList = $receipt->find ( array (
  7916. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7917. 'asArray' => true
  7918. ) );
  7919. if (empty ( $receiptList )) {
  7920. ob_start ();
  7921. $this->render ( "/admin/saeaCollectArticles", $data );
  7922. $this->cacheFile ( $path );
  7923. die ();
  7924. }
  7925. }
  7926. $this->render ( "/admin/saeaCollectArticles", $data );
  7927. }
  7928. function companyCategoryCollect() {
  7929. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7930. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  7931. $this->showCache ( $path );
  7932. Doo::loadModel ( 'L_category' );
  7933. Doo::loadModel ( 'itemStatistics' );
  7934. Doo::loadModel ( 'statistics' );
  7935. $statistics = new statistics ();
  7936. $Lcategory = new L_category ();
  7937. $itemStatistics = new itemStatistics ();
  7938. $LcategoryList = $Lcategory->find ( array (
  7939. 'asArray' => true
  7940. ) ); // 'staff='.$this->staff[0]['sid']." and
  7941. $itemStatisticsList = $itemStatistics->find ( array (
  7942. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7943. 'where' => " Year(date)=" . $year,
  7944. 'groupby' => 'cid,Month(date)',
  7945. 'asArray' => true
  7946. ) );
  7947. // ceatre companyCollectHtml
  7948. foreach ( $LcategoryList as $value ) {
  7949. $html = "";
  7950. $asum = 0;
  7951. for($i = 1; $i <= 12; $i ++) {
  7952. $falg = true;
  7953. foreach ( $itemStatisticsList as $v ) {
  7954. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  7955. $asum += $v ['price'];
  7956. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7957. $falg = false;
  7958. break;
  7959. }
  7960. }
  7961. if ($falg)
  7962. $html .= '<td class="taR">-</td>';
  7963. }
  7964. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7965. $collectHtml [$value ['title']] = array (
  7966. 'html' => $html,
  7967. 'cid' => $value ['cid']
  7968. );
  7969. }
  7970. $data ['companyHtml'] = $collectHtml;
  7971. // total price html
  7972. $collectHtml = "";
  7973. $total = 0;
  7974. for($i = 1; $i <= 12; $i ++) {
  7975. $sumPrice = 0;
  7976. foreach ( $itemStatisticsList as $key => $value ) {
  7977. if ($value ['month'] == $i) {
  7978. $sumPrice += $value ['price'];
  7979. }
  7980. }
  7981. if ($sumPrice == 0)
  7982. $collectHtml .= '<td class="taR">-</td>';
  7983. else
  7984. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7985. $total += $sumPrice;
  7986. }
  7987. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7988. $data ['companyTotalHtml'] = $collectHtml;
  7989. $data ['total'] = $total;
  7990. // statistics html
  7991. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7992. if (empty ( $stList ))
  7993. $stList = array (
  7994. 'rePrice' => 0,
  7995. 'agPrice' => 0
  7996. );
  7997. $data ['stList'] = array (
  7998. 'rePrice' => $stList ['rePrice'],
  7999. 'agPrice' => $stList ['agPrice'],
  8000. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8001. );
  8002. $data ['year'] = $year;
  8003. $data ['memu'] = "receipt";
  8004. $data ['staff'] = $this->staff;
  8005. $data ['receiptMemu'] = 'companyCategoryCollect';
  8006. $data ['verifyId'] = $this->verifyId;
  8007. $data ['executeId'] = $this->executeId;
  8008. // year staff status 2,4
  8009. if ($year < date ( "Y" )) {
  8010. Doo::loadModel ( 'receipt' );
  8011. $receipt = new receipt ();
  8012. $receiptList = $receipt->find ( array (
  8013. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  8014. 'asArray' => true
  8015. ) );
  8016. if (empty ( $receiptList )) {
  8017. ob_start ();
  8018. $this->render ( "/admin/saeaCompanyCollect", $data );
  8019. $this->cacheFile ( $path );
  8020. die ();
  8021. }
  8022. }
  8023. $this->render ( "/admin/saeaCompanyCollect", $data );
  8024. }
  8025. function categoryCollectDetail() {
  8026. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8027. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  8028. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  8029. $this->showCache ( $path );
  8030. Doo::loadModel ( 'statistics' );
  8031. $statistics = new statistics ();
  8032. Doo::loadModel ( "receiptDetail" );
  8033. $receiptDetail = new receiptDetail ();
  8034. Doo::loadModel ( 'L_category' );
  8035. $Lcategory = new L_category ();
  8036. Doo::loadModel ( 'accountItem' );
  8037. $accountItem = new accountItem ();
  8038. $LcategoryList = $Lcategory->find ( array (
  8039. 'asArray' => true
  8040. ) );
  8041. if ($cid == 0) {
  8042. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  8043. if ($cid == 0)
  8044. $cid = $LcategoryList [0] ['cid'];
  8045. }
  8046. $data ['LcategoryList'] = $LcategoryList;
  8047. $receiptCollectList = $receiptDetail->find ( array (
  8048. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8049. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  8050. 'groupby' => 'item,Month(pastDate)',
  8051. 'asArray' => true
  8052. ) );
  8053. $accountList = $accountItem->find ( array (
  8054. 'asArray' => true
  8055. ) );
  8056. // create CollectDetail HTML
  8057. $collectHtml = array ();
  8058. foreach ( $accountList as $key => $value ) {
  8059. $html = "";
  8060. $asum = 0;
  8061. for($i = 1; $i <= 12; $i ++) {
  8062. $falg = true;
  8063. foreach ( $receiptCollectList as $v ) {
  8064. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  8065. $asum += $v ['price'];
  8066. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8067. $falg = false;
  8068. break;
  8069. }
  8070. }
  8071. if ($falg)
  8072. $html .= '<td class="taR">-</td>';
  8073. }
  8074. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8075. $collectHtml [$value ['category']] [$value ['name']] = $html;
  8076. }
  8077. $data ['collectHtml'] = $collectHtml;
  8078. // create Adjustment price html
  8079. $receiptCollectList = $receiptDetail->find ( array (
  8080. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  8081. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  8082. 'groupby' => 'itemCategory,Month(pastDate)',
  8083. 'asArray' => true
  8084. ) );
  8085. $adjustment = array ();
  8086. $collectArray = array (
  8087. '日常相关费用' => array (),
  8088. '差旅相关费用' => array (),
  8089. '培训班费用' => array (),
  8090. '其他' => array ()
  8091. );
  8092. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  8093. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  8094. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  8095. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  8096. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  8097. array_push ( $collectArray ['培训班费用'], $collectHtml );
  8098. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  8099. array_push ( $collectArray ['其他'], $collectHtml );
  8100. $data ['collectArray'] = $collectArray;
  8101. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  8102. array_push ( $adjustment, $collectHtml );
  8103. $data ['adjustment'] = $adjustment;
  8104. // total price html
  8105. $collectHtml = "";
  8106. $total = 0;
  8107. for($i = 1; $i <= 12; $i ++) {
  8108. $sumPrice = 0;
  8109. foreach ( $receiptCollectList as $key => $value ) {
  8110. if ($value ['month'] == $i) {
  8111. $sumPrice += $value ['price'];
  8112. }
  8113. }
  8114. if ($sumPrice == 0)
  8115. $collectHtml .= '<td class="taR">-</td>';
  8116. else
  8117. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8118. $total += $sumPrice;
  8119. }
  8120. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8121. // statistics html
  8122. $stList = $statistics->statisticsByCid ( $year, $cid );
  8123. if (empty ( $stList ))
  8124. $stList = array (
  8125. 'rePrice' => 0,
  8126. 'agPrice' => 0
  8127. );
  8128. $data ['stList'] = array (
  8129. 'rePrice' => $stList ['rePrice'],
  8130. 'agPrice' => $stList ['agPrice'],
  8131. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8132. );
  8133. $data ['totalYear'] = $total;
  8134. $data ['year'] = $year;
  8135. $data ['cid'] = $cid;
  8136. $data ['memu'] = "receipt";
  8137. $data ['staff'] = $this->staff;
  8138. $data ['receiptMemu'] = 'companyCategoryCollect';
  8139. $data ['verifyId'] = $this->verifyId;
  8140. $data ['executeId'] = $this->executeId;
  8141. // year staff status 2,4
  8142. if ($year < date ( "Y" )) {
  8143. Doo::loadModel ( 'receipt' );
  8144. $receipt = new receipt ();
  8145. $receiptList = $receipt->find ( array (
  8146. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  8147. 'asArray' => true
  8148. ) );
  8149. if (empty ( $receiptList )) {
  8150. ob_start ();
  8151. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  8152. $this->cacheFile ( $path );
  8153. die ();
  8154. }
  8155. }
  8156. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  8157. }
  8158. function staffCollect() {
  8159. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8160. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  8161. // $this->showCache($path);
  8162. Doo::loadModel ( 'statistics' );
  8163. $statistics = new statistics ();
  8164. Doo::loadModel ( "receiptDetail" );
  8165. $receiptDetail = new receiptDetail ();
  8166. Doo::loadModel ( 'L_category' );
  8167. $Lcategory = new L_category ();
  8168. Doo::loadModel ( 'accountItem' );
  8169. $accountItem = new accountItem ();
  8170. Doo::loadModel ( 'staff' );
  8171. $staff = new staff ();
  8172. Doo::loadModel ( 'itemStatistics' );
  8173. $itemStatistics = new itemStatistics ();
  8174. /*
  8175. * $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']));
  8176. */
  8177. // statistics html
  8178. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  8179. if (empty ( $stList ))
  8180. $stList = array (
  8181. 'rePrice' => 0,
  8182. 'agPrice' => 0
  8183. );
  8184. $data ['stList'] = array (
  8185. 'rePrice' => $stList ['rePrice'],
  8186. 'agPrice' => $stList ['agPrice'],
  8187. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8188. );
  8189. // ---
  8190. $staffList = $staff->find ( array (
  8191. 'where' => 'username !="admin"',
  8192. 'asArray' => true
  8193. ) );
  8194. $LcategoryList = $Lcategory->find ( array (
  8195. 'asArray' => true
  8196. ) ); // 'staff='.$this->staff[0]['sid']." and
  8197. $itemStatisticsList = $itemStatistics->find ( array (
  8198. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8199. 'where' => " Year(date)=" . $year,
  8200. 'groupby' => 'staff,Month(date)',
  8201. 'asArray' => true
  8202. ) );
  8203. $categoryList = $staff->find ( array (
  8204. 'select' => 'COUNT(*) as count,cid,category',
  8205. 'where' => 'username !="admin"',
  8206. 'groupby' => 'cid',
  8207. 'asArray' => true
  8208. ) );
  8209. // print_r($itemStatisticsList);die;
  8210. // ceatre companyCollectHtml
  8211. foreach ( $categoryList as $vlu ) {
  8212. $count = $vlu ['count'] + 1;
  8213. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  8214. $m1 = 0;
  8215. $m2 = 0;
  8216. $m3 = 0;
  8217. $m4 = 0;
  8218. $m5 = 0;
  8219. $m6 = 0;
  8220. $m7 = 0;
  8221. $m8 = 0;
  8222. $m9 = 0;
  8223. $m10 = 0;
  8224. $m11 = 0;
  8225. $m12 = 0;
  8226. $m13 = 0;
  8227. foreach ( $staffList as $value ) {
  8228. if ($vlu ['cid'] == $value ['cid']) {
  8229. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  8230. $asum = 0;
  8231. for($i = 1; $i <= 12; $i ++) {
  8232. $falg = true;
  8233. foreach ( $itemStatisticsList as $v ) {
  8234. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  8235. if ($v ['month'] == 1)
  8236. $m1 += $v ['price'];
  8237. if ($v ['month'] == 2)
  8238. $m2 += $v ['price'];
  8239. if ($v ['month'] == 3)
  8240. $m3 += $v ['price'];
  8241. if ($v ['month'] == 4)
  8242. $m4 += $v ['price'];
  8243. if ($v ['month'] == 5)
  8244. $m5 += $v ['price'];
  8245. if ($v ['month'] == 6)
  8246. $m6 += $v ['price'];
  8247. if ($v ['month'] == 7)
  8248. $m7 += $v ['price'];
  8249. if ($v ['month'] == 8)
  8250. $m8 += $v ['price'];
  8251. if ($v ['month'] == 9)
  8252. $m9 += $v ['price'];
  8253. if ($v ['month'] == 10)
  8254. $m10 += $v ['price'];
  8255. if ($v ['month'] == 11)
  8256. $m11 += $v ['price'];
  8257. if ($v ['month'] == 12)
  8258. $m12 += $v ['price'];
  8259. $asum += $v ['price'];
  8260. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8261. $falg = false;
  8262. break;
  8263. }
  8264. }
  8265. if ($falg)
  8266. $html .= '<td class="taR">-</td>';
  8267. }
  8268. $m13 += $asum;
  8269. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8270. $collectHtml [$value ['username'].'_'.$value['sid']] = array (
  8271. 'html' => $html,
  8272. 'sid' => $value ['sid']
  8273. );
  8274. $html = "";
  8275. }
  8276. }
  8277. $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>
  8278. <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>
  8279. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  8280. $collectHtml [$vlu ['cid']] = array (
  8281. 'html' => $hl,
  8282. 'sid' => ''
  8283. );
  8284. }
  8285. $data ['companyHtml'] = $collectHtml;
  8286. // total price html
  8287. $collectHtml = "";
  8288. $total = 0;
  8289. for($i = 1; $i <= 12; $i ++) {
  8290. $sumPrice = 0;
  8291. foreach ( $itemStatisticsList as $key => $value ) {
  8292. if ($value ['month'] == $i) {
  8293. $sumPrice += $value ['price'];
  8294. }
  8295. }
  8296. if ($sumPrice == 0)
  8297. $collectHtml .= '<td class="taR">-</td>';
  8298. else
  8299. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8300. $total += $sumPrice;
  8301. }
  8302. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8303. $data ['companyTotalHtml'] = $collectHtml;
  8304. $data ['total'] = $total;
  8305. $data ['year'] = $year;
  8306. $data ['memu'] = "receipt";
  8307. $data ['staff'] = $this->staff;
  8308. $data ['receiptMemu'] = 'companyCategoryCollect';
  8309. $data ['verifyId'] = $this->verifyId;
  8310. $data ['executeId'] = $this->executeId;
  8311. if ($year <= date ( "Y" )) {
  8312. Doo::loadModel ( 'receipt' );
  8313. $receipt = new receipt ();
  8314. $receiptList = $receipt->find ( array (
  8315. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  8316. 'asArray' => true
  8317. ) );
  8318. if (empty ( $receiptList )) { // generated files
  8319. ob_start ();
  8320. $this->render ( "/admin/saeaStaffCollectB", $data );
  8321. $this->cacheFile ( $path );
  8322. die ();
  8323. }
  8324. }
  8325. $this->render ( "/admin/saeaStaffCollectB", $data );
  8326. }
  8327. function staffCollectBak() {
  8328. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8329. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  8330. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  8331. $this->showCache ( $path );
  8332. Doo::loadModel ( 'statistics' );
  8333. $statistics = new statistics ();
  8334. Doo::loadModel ( "receiptDetail" );
  8335. $receiptDetail = new receiptDetail ();
  8336. Doo::loadModel ( 'L_category' );
  8337. $Lcategory = new L_category ();
  8338. Doo::loadModel ( 'accountItem' );
  8339. $accountItem = new accountItem ();
  8340. Doo::loadModel ( 'staff' );
  8341. $staff = new staff ();
  8342. Doo::loadModel ( 'itemStatistics' );
  8343. $itemStatistics = new itemStatistics ();
  8344. $itemStatisticsList = $itemStatistics->find ( array (
  8345. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8346. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8347. 'groupby' => 'staff,itemCategory,Month(date)',
  8348. 'asArray' => true
  8349. ) );
  8350. $itemCategoryList = $itemStatistics->find ( array (
  8351. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8352. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8353. 'groupby' => 'cid,itemCategory,Month(date)',
  8354. 'asArray' => true
  8355. ) );
  8356. $LcategoryList = $Lcategory->find ( array (
  8357. 'asArray' => true
  8358. ) );
  8359. $staffList = $staff->find ( array (
  8360. 'asArray' => true
  8361. ) );
  8362. $htmlArray = array ();
  8363. foreach ( $LcategoryList as $value ) {
  8364. $htmlArray [$value ['title']] = array ();
  8365. foreach ( $staffList as $v ) {
  8366. if ($value ['cid'] == $v ['cid']) {
  8367. $html = "";
  8368. $falg = true;
  8369. $staffSumPrice = 0;
  8370. foreach ( $itemStatisticsList as $a ) {
  8371. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  8372. if (empty ( $a ['price'] )) {
  8373. $html .= '<td class="taR">-</td>';
  8374. $falg = false;
  8375. break;
  8376. } else {
  8377. $staffSumPrice += $a ['price'];
  8378. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8379. $falg = false;
  8380. break;
  8381. }
  8382. }
  8383. }
  8384. if ($falg) {
  8385. $html .= '<td class="taR">-</td>';
  8386. $falg = true;
  8387. }
  8388. $falg = true;
  8389. foreach ( $itemStatisticsList as $a ) {
  8390. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  8391. if (empty ( $a ['price'] )) {
  8392. $html .= '<td class="taR">-</td>';
  8393. $falg = false;
  8394. break;
  8395. } else {
  8396. $staffSumPrice += $a ['price'];
  8397. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8398. $falg = false;
  8399. break;
  8400. }
  8401. }
  8402. }
  8403. if ($falg) {
  8404. $html .= '<td class="taR">-</td>';
  8405. $falg = true;
  8406. }
  8407. $falg = true;
  8408. foreach ( $itemStatisticsList as $a ) {
  8409. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  8410. if (empty ( $a ['price'] )) {
  8411. $html .= '<td class="taR">-</td>';
  8412. $falg = false;
  8413. break;
  8414. } else {
  8415. $staffSumPrice += $a ['price'];
  8416. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8417. $falg = false;
  8418. break;
  8419. }
  8420. }
  8421. }
  8422. if ($falg) {
  8423. $html .= '<td class="taR">-</td>';
  8424. $falg = true;
  8425. }
  8426. $falg = true;
  8427. foreach ( $itemStatisticsList as $a ) {
  8428. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  8429. if (! empty ( $a ['price'] )) {
  8430. $staffSumPrice += $a ['price'];
  8431. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8432. $falg = false;
  8433. break;
  8434. } else {
  8435. $html .= '<td class="taR">-</td>';
  8436. $falg = false;
  8437. break;
  8438. }
  8439. }
  8440. }
  8441. if ($falg) {
  8442. $html .= '<td class="taR">-</td>';
  8443. $falg = true;
  8444. }
  8445. $falg = true;
  8446. foreach ( $itemStatisticsList as $a ) {
  8447. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  8448. if (! empty ( $a ['price'] )) {
  8449. $staffSumPrice += $a ['price'];
  8450. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8451. $falg = false;
  8452. break;
  8453. } else {
  8454. $html .= '<td class="taR">-</td>';
  8455. $falg = false;
  8456. break;
  8457. }
  8458. }
  8459. }
  8460. if ($falg) {
  8461. $html .= '<td class="taR">-</td>';
  8462. $falg = true;
  8463. }
  8464. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  8465. $htmlArray [$value ['title']] [$v ['username']] = $html;
  8466. }
  8467. }
  8468. /* -- --- */
  8469. // 合计费用
  8470. $cateHtml = "";
  8471. $catePrice = 0;
  8472. $cateFalg = true;
  8473. foreach ( $itemCategoryList as $l ) {
  8474. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  8475. if (empty ( $l ['price'] )) {
  8476. $cateHtml .= '<td class="colGreen taR">-</td>';
  8477. $cateFalg = false;
  8478. break;
  8479. } else {
  8480. $catePrice += $l ['price'];
  8481. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8482. $cateFalg = false;
  8483. break;
  8484. }
  8485. }
  8486. }
  8487. if ($cateFalg) {
  8488. $cateHtml .= '<td class="colGreen taR">-</td>';
  8489. $cateFalg = true;
  8490. }
  8491. $cateFalg = true;
  8492. foreach ( $itemCategoryList as $l ) {
  8493. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  8494. if (empty ( $l ['price'] )) {
  8495. $cateHtml .= '<td class="colGreen taR">-</td>';
  8496. $cateFalg = false;
  8497. break;
  8498. } else {
  8499. $catePrice += $l ['price'];
  8500. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8501. $cateFalg = false;
  8502. break;
  8503. }
  8504. }
  8505. }
  8506. if ($cateFalg) {
  8507. $cateHtml .= '<td class="colGreen taR">-</td>';
  8508. $cateFalg = true;
  8509. }
  8510. $cateFalg = true;
  8511. foreach ( $itemCategoryList as $l ) {
  8512. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  8513. if (empty ( $l ['price'] )) {
  8514. $cateHtml .= '<td class="colGreen taR">-</td>';
  8515. $cateFalg = false;
  8516. break;
  8517. } else {
  8518. $catePrice += $l ['price'];
  8519. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8520. $cateFalg = false;
  8521. break;
  8522. }
  8523. }
  8524. }
  8525. if ($cateFalg) {
  8526. $cateHtml .= '<td class="colGreen taR">-</td>';
  8527. $cateFalg = true;
  8528. }
  8529. $cateFalg = true;
  8530. foreach ( $itemCategoryList as $l ) {
  8531. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  8532. if (empty ( $l ['price'] )) {
  8533. $cateHtml .= '<td class="colGreen taR">-</td>';
  8534. $cateFalg = false;
  8535. break;
  8536. } else {
  8537. $catePrice += $l ['price'];
  8538. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8539. $cateFalg = false;
  8540. break;
  8541. }
  8542. }
  8543. }
  8544. if ($cateFalg) {
  8545. $cateHtml .= '<td class="colGreen taR">-</td>';
  8546. $cateFalg = true;
  8547. }
  8548. $cateFalg = true;
  8549. foreach ( $itemCategoryList as $l ) {
  8550. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  8551. if (empty ( $l ['price'] )) {
  8552. $cateHtml .= '<td class="colGreen taR">-</td>';
  8553. $cateFalg = false;
  8554. break;
  8555. } else {
  8556. $catePrice += $l ['price'];
  8557. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8558. $cateFalg = false;
  8559. break;
  8560. }
  8561. }
  8562. }
  8563. if ($cateFalg) {
  8564. $cateHtml .= '<td class="colGreen taR">-</td>';
  8565. $cateFalg = true;
  8566. }
  8567. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  8568. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  8569. /* -- --- */
  8570. }
  8571. // print_r($htmlArray);die;
  8572. $data ['htmlArray'] = $htmlArray;
  8573. // statistics html
  8574. $stList = $statistics->getOne ( array (
  8575. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8576. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8577. 'groupby' => 'Month(date)',
  8578. 'asArray' => true
  8579. ) );
  8580. if (empty ( $stList ))
  8581. $stList = array (
  8582. 'rePrice' => 0,
  8583. 'agPrice' => 0
  8584. );
  8585. $data ['stList'] = array (
  8586. 'rePrice' => $stList ['rePrice'],
  8587. 'agPrice' => $stList ['agPrice'],
  8588. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8589. );
  8590. $monthHtml = "";
  8591. for($i = 1; $i <= 12; $i ++) {
  8592. if ($i == $month)
  8593. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8594. else
  8595. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8596. }
  8597. $data ['monthHtml'] = $monthHtml;
  8598. $data ['year'] = $year;
  8599. $data ['month'] = $month;
  8600. $data ['memu'] = "receipt";
  8601. $data ['staff'] = $this->staff;
  8602. $data ['receiptMemu'] = 'companyCategoryCollect';
  8603. $data ['verifyId'] = $this->verifyId;
  8604. $data ['executeId'] = $this->executeId;
  8605. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  8606. Doo::loadModel ( 'receipt' );
  8607. $receipt = new receipt ();
  8608. $receiptList = $receipt->find ( array (
  8609. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  8610. 'asArray' => true
  8611. ) );
  8612. if (empty ( $receiptList )) { // generated files
  8613. ob_start ();
  8614. $this->render ( "/admin/saeaStaffCollect", $data );
  8615. $this->cacheFile ( $path );
  8616. die ();
  8617. }
  8618. }
  8619. $this->render ( "/admin/saeaStaffCollect", $data );
  8620. }
  8621. function lyt() {
  8622. Doo::loadModel ( "receiptDetail" );
  8623. $receiptDetail = new receiptDetail ();
  8624. $receiptCollectList = $receiptDetail->find ( array (
  8625. 'where' => 'status=1 ',
  8626. 'asArray' => true
  8627. ) );
  8628. foreach ( $receiptCollectList as $key => $value ) {
  8629. $receiptDetail = new receiptDetail ();
  8630. $receiptDetail->pastDate = $value ['date'];
  8631. $receiptDetail->update ( array (
  8632. 'where' => "rdid= '" . $value ['rdid'] . "'"
  8633. ) );
  8634. }
  8635. }
  8636. function staffCollectMonthDetail() {
  8637. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8638. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8639. if (! $year)
  8640. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8641. if (! $month)
  8642. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8643. Doo::loadModel ( 'staff' );
  8644. $staff = new staff ();
  8645. Doo::loadModel ( "receiptDetail" );
  8646. $receiptDetail = new receiptDetail ();
  8647. Doo::loadModel ( 'accountItem' );
  8648. $accountItem = new accountItem ();
  8649. Doo::loadModel ( 'statistics' );
  8650. $statistics = new statistics ();
  8651. Doo::loadModel ( 'L_category' );
  8652. $lCategory = new L_category ();
  8653. $staffList = $staff->find ( array (
  8654. 'where' => 'username!="admin"',
  8655. 'asArray' => true
  8656. ) );
  8657. $categoryList = $staff->find ( array (
  8658. 'select' => 'COUNT(*) as count,cid,category',
  8659. 'where' => 'username !="admin"',
  8660. 'groupby' => 'cid',
  8661. 'asArray' => true
  8662. ) );
  8663. $list = array ();
  8664. foreach ( $categoryList as $vlu ) {
  8665. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8666. $r1 = 0;
  8667. $r2 = 0;
  8668. $r3 = 0;
  8669. $r4 = 0;
  8670. $r5 = 0;
  8671. $r6 = 0;
  8672. $r7 = 0;
  8673. $r8 = 0;
  8674. $r9 = 0;
  8675. $r10 = 0;
  8676. $r11 = 0;
  8677. $r12 = 0;
  8678. $r13 = 0;
  8679. $r14 = 0;
  8680. $r15 = 0;
  8681. $r16 = 0;
  8682. $r17 = 0;
  8683. $r18 = 0;
  8684. $c1 = 0;
  8685. $c2 = 0;
  8686. $c3 = 0;
  8687. $c4 = 0;
  8688. $c5 = 0;
  8689. $c6 = 0;
  8690. $p1 = 0;
  8691. $p2 = 0;
  8692. $p3 = 0;
  8693. $p4 = 0;
  8694. $p5 = 0;
  8695. $p6 = 0;
  8696. $p7 = 0;
  8697. $p8 = 0;
  8698. $p9 = 0;
  8699. $t1 = 0;
  8700. $t2 = 0;
  8701. $t3 = 0;
  8702. $t4 = 0;
  8703. $t5 = 0;
  8704. $s1 = 0;
  8705. $m1 = 0;
  8706. foreach ( $staffList as $value ) {
  8707. if ($vlu ['cid'] == $value ['cid']) {
  8708. // pastDate
  8709. $receiptCollectList = $receiptDetail->find ( array (
  8710. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8711. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8712. 'groupby' => 'item,Month(pastDate),itemCategory',
  8713. 'asArray' => true
  8714. ) );
  8715. // if ($value['sid']==42){
  8716. // print_r($receiptCollectList);die;
  8717. // }
  8718. if (! empty ( $receiptCollectList )) {
  8719. $receiptL = array (
  8720. '日常相关费用' => array (),
  8721. '差旅相关费用' => array (),
  8722. '培训班费用' => array (),
  8723. '其他' => array ()
  8724. );
  8725. $html = "";
  8726. $psum = 0;
  8727. $item = array (
  8728. '市内交通费',
  8729. '市内出租费',
  8730. '办事处房租',
  8731. '电话费',
  8732. '水费',
  8733. '电费',
  8734. '办公费用',
  8735. '邮寄费',
  8736. '其他费用',
  8737. '车辆费用',
  8738. '广告费',
  8739. '团队建设费',
  8740. '物业管理费',
  8741. '宽带费',
  8742. '人员薪酬',
  8743. '公积金',
  8744. '社保'
  8745. );
  8746. foreach ( $item as $va ) {
  8747. $falg = true;
  8748. foreach ( $receiptCollectList as $v ) {
  8749. if ($v ['itemCategory'] == '日常相关费用') {
  8750. if ($v ['item'] == $va) {
  8751. if ($va == '市内交通费')
  8752. $r1 += $v ['price'];
  8753. if ($va == '市内出租费')
  8754. $r2 += $v ['price'];
  8755. if ($va == '办事处房租')
  8756. $r3 += $v ['price'];
  8757. if ($va == '电话费')
  8758. $r4 += $v ['price'];
  8759. if ($va == '水费')
  8760. $r5 += $v ['price'];
  8761. if ($va == '电费')
  8762. $r6 += $v ['price'];
  8763. if ($va == '办公费用')
  8764. $r7 += $v ['price'];
  8765. if ($va == '邮寄费')
  8766. $r8 += $v ['price'];
  8767. if ($va == '其他费用')
  8768. $r9 += $v ['price'];
  8769. if ($va == '车辆费用')
  8770. $r10 += $v ['price'];
  8771. if ($va == '广告费')
  8772. $r11 += $v ['price'];
  8773. if ($va == '团队建设费')
  8774. $r13 += $v ['price'];
  8775. if ($va == '物业管理费')
  8776. $r14 += $v ['price'];
  8777. if ($va == '宽带费')
  8778. $r15 += $v ['price'];
  8779. if ($va == '公积金')
  8780. $r16 += $v ['price'];
  8781. if ($va == '社保')
  8782. $r17 += $v ['price'];
  8783. if ($va == '人员薪酬')
  8784. $r18 += $v ['price'];
  8785. $psum += $v ['price'];
  8786. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8787. $falg = false;
  8788. break;
  8789. }
  8790. }
  8791. }
  8792. if ($falg)
  8793. $html .= '<td class="taR">-</td>';
  8794. }
  8795. $r12 += $psum;
  8796. if (! empty ( $psum ))
  8797. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8798. else
  8799. $psum = '<td class="colGreen taR">-</td>';
  8800. $receiptL ['日常相关费用'] = $psum . $html;
  8801. /* ----------------------------------- */
  8802. $html = "";
  8803. $psum = 0;
  8804. $item = array (
  8805. '往来交通费',
  8806. '市内交通费',
  8807. '出差住宿费',
  8808. '出差补助',
  8809. '其他费用'
  8810. );
  8811. foreach ( $item as $va ) {
  8812. $falg = true;
  8813. foreach ( $receiptCollectList as $v ) {
  8814. if ($v ['itemCategory'] == '差旅相关费用') {
  8815. if ($v ['item'] == $va) {
  8816. if ($va == '往来交通费')
  8817. $c1 += $v ['price'];
  8818. if ($va == '市内交通费')
  8819. $c2 += $v ['price'];
  8820. if ($va == '出差住宿费')
  8821. $c3 += $v ['price'];
  8822. if ($va == '出差补助')
  8823. $c4 += $v ['price'];
  8824. if ($va == '其他费用')
  8825. $c5 += $v ['price'];
  8826. $psum += $v ['price'];
  8827. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8828. $falg = false;
  8829. break;
  8830. }
  8831. }
  8832. }
  8833. if ($falg)
  8834. $html .= '<td class="taR">-</td>';
  8835. }
  8836. $c6 += $psum;
  8837. if (! empty ( $psum ))
  8838. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8839. else
  8840. $psum = '<td class="colGreen taR">-</td>';
  8841. $receiptL ['差旅相关费用'] = $psum . $html;
  8842. /* ------------------------------------- */
  8843. $html = "";
  8844. $psum = 0;
  8845. $item = array (
  8846. '场租费',
  8847. '薪酬',
  8848. '住宿费',
  8849. '交通费',
  8850. '餐饮费',
  8851. '办公费',
  8852. '公关费',
  8853. '其他'
  8854. );
  8855. foreach ( $item as $va ) {
  8856. $falg = true;
  8857. foreach ( $receiptCollectList as $v ) {
  8858. if ($v ['itemCategory'] == '培训班费用') {
  8859. if ($v ['item'] == $va) {
  8860. if ($va == '场租费')
  8861. $p1 += $v ['price'];
  8862. if ($va == '薪酬')
  8863. $p2 += $v ['price'];
  8864. if ($va == '住宿费')
  8865. $p3 += $v ['price'];
  8866. if ($va == '交通费')
  8867. $p4 += $v ['price'];
  8868. if ($va == '餐饮费')
  8869. $p5 += $v ['price'];
  8870. if ($va == '办公费')
  8871. $p6 += $v ['price'];
  8872. if ($va == '公关费')
  8873. $p7 += $v ['price'];
  8874. if ($va == '其他')
  8875. $p8 += $v ['price'];
  8876. $psum += $v ['price'];
  8877. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8878. $falg = false;
  8879. break;
  8880. }
  8881. }
  8882. }
  8883. if ($falg)
  8884. $html .= '<td class="taR">-</td>';
  8885. }
  8886. $p9 += $psum;
  8887. if (! empty ( $psum ))
  8888. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8889. else
  8890. $psum = '<td class="colGreen taR">-</td>';
  8891. $receiptL ['培训班费用'] = $psum . $html;
  8892. /* ------------------------------------- */
  8893. $html = "";
  8894. $psum = 0;
  8895. $item = array (
  8896. '公关费',
  8897. '广告费',
  8898. '借款',
  8899. '可自加费用'
  8900. );
  8901. foreach ( $item as $va ) {
  8902. $falg = true;
  8903. foreach ( $receiptCollectList as $v ) {
  8904. if ($v ['itemCategory'] == '其他') {
  8905. // if ($value['sid']==42){
  8906. //
  8907. // echo var_dump($v['item']);
  8908. // echo var_dump($va);
  8909. // echo var_dump($v['item']==" ".$va);
  8910. // echo $v['item']."==".$va."/<br/>";
  8911. // //print_r( $receiptCollectList);//echo $va;
  8912. // }
  8913. if (trim ( $v ['item'] ) == $va) {
  8914. if ($va == '公关费')
  8915. $t1 += $v ['price'];
  8916. if ($va == '广告费') {
  8917. $t2 += $v ['price'];
  8918. }
  8919. if ($va == '借款')
  8920. $t3 += $v ['price'];
  8921. if ($va == '可自加费用')
  8922. $t4 += $v ['price'];
  8923. $psum += $v ['price'];
  8924. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8925. $falg = false;
  8926. break;
  8927. }
  8928. }
  8929. }
  8930. if ($falg)
  8931. $html .= '<td class="taR">-</td>';
  8932. }
  8933. $t5 += $psum;
  8934. if (! empty ( $psum ))
  8935. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8936. else
  8937. $psum = '<td class="colGreen taR">-</td>';
  8938. $receiptL ['其他'] = $psum . $html;
  8939. /* ------------------------------------- */
  8940. $html = "";
  8941. $psum = 0;
  8942. foreach ( $receiptCollectList as $v ) {
  8943. if ($v ['itemCategory'] == '报销金额调整') {
  8944. if (! empty ( $v ['price'] )) {
  8945. $psum += $v ['price'];
  8946. }
  8947. }
  8948. }
  8949. $s1 += $psum;
  8950. if (! empty ( $psum ))
  8951. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8952. else
  8953. $psum = '<td class="taR colOrange">-</td>';
  8954. $receiptL ['报销金额调整'] = $psum . $html;
  8955. } else {
  8956. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8957. <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>
  8958. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8959. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  8960. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8961. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8962. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8963. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8964. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  8965. }
  8966. $monthStaffPrice = $receiptDetail->find ( array (
  8967. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8968. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8969. 'groupby' => 'Month(pastDate)',
  8970. 'asArray' => true
  8971. ) );
  8972. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  8973. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  8974. $m1 += $monthStaffPrice [0] ['price'];
  8975. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  8976. } else
  8977. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  8978. $list [$value ['username']] = $receiptL;
  8979. }
  8980. }
  8981. $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>
  8982. <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>
  8983. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td><td class="taR">' . $r18 . '</td> <td class="taR">' . $r16 . '</td><td class="taR">' . $r17 . '</td>';
  8984. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  8985. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  8986. $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>
  8987. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  8988. $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>';
  8989. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  8990. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  8991. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  8992. }
  8993. $data ['list'] = $list;
  8994. $receiptCollectList = $receiptDetail->find ( array (
  8995. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8996. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8997. 'groupby' => 'item,Month(pastDate),itemCategory',
  8998. 'asArray' => true
  8999. ) );
  9000. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9001. // statistics html
  9002. $stList = $statistics->getOne ( array (
  9003. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9004. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9005. 'groupby' => 'Month(date)',
  9006. 'asArray' => true
  9007. ) );
  9008. if (empty ( $stList ))
  9009. $stList = array (
  9010. 'rePrice' => 0,
  9011. 'agPrice' => 0
  9012. );
  9013. $data ['stList'] = array (
  9014. 'rePrice' => $stList ['rePrice'],
  9015. 'agPrice' => $stList ['agPrice'],
  9016. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9017. );
  9018. $monthHtml = "";
  9019. for($i = 1; $i <= 12; $i ++) {
  9020. if ($i == $month)
  9021. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9022. else
  9023. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9024. }
  9025. $data ['monthHtml'] = $monthHtml;
  9026. $data ['year'] = $year;
  9027. $data ['month'] = $month;
  9028. $data ['memu'] = "receipt";
  9029. $data ['staff'] = $this->staff;
  9030. $data ['receiptMemu'] = 'companyCategoryCollect';
  9031. $data ['verifyId'] = $this->verifyId;
  9032. $data ['executeId'] = $this->executeId;
  9033. $this->render ( "/admin/staffCollectMonthDetail", $data );
  9034. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9035. }
  9036. function staffCollectMonthDetail2() {
  9037. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9038. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9039. if (! $year)
  9040. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9041. if (! $month)
  9042. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9043. Doo::loadModel ( 'staff' );
  9044. $staff = new staff ();
  9045. Doo::loadModel ( "receiptDetail" );
  9046. $receiptDetail = new receiptDetail ();
  9047. Doo::loadModel ( 'accountItem' );
  9048. $accountItem = new accountItem ();
  9049. Doo::loadModel ( 'statistics' );
  9050. $statistics = new statistics ();
  9051. Doo::loadModel ( 'L_category' );
  9052. $lCategory = new L_category ();
  9053. $staffList = $staff->find ( array (
  9054. 'where' => 'username!="admin"',
  9055. 'asArray' => true
  9056. ) );
  9057. $categoryList = $staff->find ( array (
  9058. 'select' => 'COUNT(*) as count,cid,category',
  9059. 'where' => 'username !="admin"',
  9060. 'groupby' => 'cid',
  9061. 'asArray' => true
  9062. ) );
  9063. $list = array ();
  9064. foreach ( $categoryList as $vlu ) {
  9065. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  9066. $r1 = 0;
  9067. $r2 = 0;
  9068. $r3 = 0;
  9069. $r4 = 0;
  9070. $r5 = 0;
  9071. $r6 = 0;
  9072. $r7 = 0;
  9073. $r8 = 0;
  9074. $r9 = 0;
  9075. $r10 = 0;
  9076. $r11 = 0;
  9077. $r12 = 0;
  9078. $r13 = 0;
  9079. $r14 = 0;
  9080. $r15 = 0;
  9081. $c1 = 0;
  9082. $c2 = 0;
  9083. $c3 = 0;
  9084. $c4 = 0;
  9085. $c5 = 0;
  9086. $c6 = 0;
  9087. $p1 = 0;
  9088. $p2 = 0;
  9089. $p3 = 0;
  9090. $p4 = 0;
  9091. $p5 = 0;
  9092. $p6 = 0;
  9093. $p7 = 0;
  9094. $p8 = 0;
  9095. $p9 = 0;
  9096. $t1 = 0;
  9097. $t2 = 0;
  9098. $t3 = 0;
  9099. $t4 = 0;
  9100. $t5 = 0;
  9101. $s1 = 0;
  9102. $m1 = 0;
  9103. foreach ( $staffList as $value ) {
  9104. if ($vlu ['cid'] == $value ['cid']) {
  9105. $receiptCollectList = $receiptDetail->find ( array (
  9106. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9107. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9108. 'groupby' => 'item,Month(date),itemCategory',
  9109. 'asArray' => true
  9110. ) );
  9111. if (! empty ( $receiptCollectList )) {
  9112. $receiptL = array (
  9113. '日常相关费用' => array (),
  9114. '差旅相关费用' => array (),
  9115. '培训班费用' => array (),
  9116. '其他' => array ()
  9117. );
  9118. $html = "";
  9119. $psum = 0;
  9120. $item = array (
  9121. '市内交通费',
  9122. '市内出租费',
  9123. '办事处房租',
  9124. '电话费',
  9125. '水费',
  9126. '电费',
  9127. '办公费用',
  9128. '邮寄费',
  9129. '其他费用',
  9130. '车辆费用',
  9131. '广告费',
  9132. '团队建设费',
  9133. '物业管理费',
  9134. '宽带费'
  9135. );
  9136. foreach ( $item as $va ) {
  9137. $falg = true;
  9138. foreach ( $receiptCollectList as $v ) {
  9139. if ($v ['itemCategory'] == '日常相关费用') {
  9140. if ($v ['item'] == $va) {
  9141. if ($va == '市内交通费')
  9142. $r1 += $v ['price'];
  9143. if ($va == '市内出租费')
  9144. $r2 += $v ['price'];
  9145. if ($va == '办事处房租')
  9146. $r3 += $v ['price'];
  9147. if ($va == '电话费')
  9148. $r4 += $v ['price'];
  9149. if ($va == '水费')
  9150. $r5 += $v ['price'];
  9151. if ($va == '电费')
  9152. $r6 += $v ['price'];
  9153. if ($va == '办公费用')
  9154. $r7 += $v ['price'];
  9155. if ($va == '邮寄费')
  9156. $r8 += $v ['price'];
  9157. if ($va == '其他费用')
  9158. $r9 += $v ['price'];
  9159. if ($va == '车辆费用')
  9160. $r10 += $v ['price'];
  9161. if ($va == '广告费')
  9162. $r11 += $v ['price'];
  9163. if ($va == '团队建设费')
  9164. $r13 += $v ['price'];
  9165. if ($va == '物业管理费')
  9166. $r14 += $v ['price'];
  9167. if ($va == '宽带费')
  9168. $r15 += $v ['price'];
  9169. $psum += $v ['price'];
  9170. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9171. $falg = false;
  9172. break;
  9173. }
  9174. }
  9175. }
  9176. if ($falg)
  9177. $html .= '<td class="taR">-</td>';
  9178. }
  9179. $r12 += $psum;
  9180. if (! empty ( $psum ))
  9181. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9182. else
  9183. $psum = '<td class="colGreen taR">-</td>';
  9184. $receiptL ['日常相关费用'] = $psum . $html;
  9185. /* ----------------------------------- */
  9186. $html = "";
  9187. $psum = 0;
  9188. $item = array (
  9189. '往来交通费',
  9190. '市内交通费',
  9191. '出差住宿费',
  9192. '出差补助',
  9193. '其他费用'
  9194. );
  9195. foreach ( $item as $va ) {
  9196. $falg = true;
  9197. foreach ( $receiptCollectList as $v ) {
  9198. if ($v ['itemCategory'] == '差旅相关费用') {
  9199. if ($v ['item'] == $va) {
  9200. if ($va == '往来交通费')
  9201. $c1 += $v ['price'];
  9202. if ($va == '市内交通费')
  9203. $c2 += $v ['price'];
  9204. if ($va == '出差住宿费')
  9205. $c3 += $v ['price'];
  9206. if ($va == '出差补助')
  9207. $c4 += $v ['price'];
  9208. if ($va == '其他费用')
  9209. $c5 += $v ['price'];
  9210. $psum += $v ['price'];
  9211. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9212. $falg = false;
  9213. break;
  9214. }
  9215. }
  9216. }
  9217. if ($falg)
  9218. $html .= '<td class="taR">-</td>';
  9219. }
  9220. $c6 += $psum;
  9221. if (! empty ( $psum ))
  9222. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9223. else
  9224. $psum = '<td class="colGreen taR">-</td>';
  9225. $receiptL ['差旅相关费用'] = $psum . $html;
  9226. /* ------------------------------------- */
  9227. $html = "";
  9228. $psum = 0;
  9229. $item = array (
  9230. '场租费',
  9231. '薪酬',
  9232. '住宿费',
  9233. '交通费',
  9234. '餐饮费',
  9235. '办公费',
  9236. '公关费',
  9237. '其他'
  9238. );
  9239. foreach ( $item as $va ) {
  9240. $falg = true;
  9241. foreach ( $receiptCollectList as $v ) {
  9242. if ($v ['itemCategory'] == '培训班费用') {
  9243. if ($v ['item'] == $va) {
  9244. if ($va == '场租费')
  9245. $p1 += $v ['price'];
  9246. if ($va == '薪酬')
  9247. $p2 += $v ['price'];
  9248. if ($va == '住宿费')
  9249. $p3 += $v ['price'];
  9250. if ($va == '交通费')
  9251. $p4 += $v ['price'];
  9252. if ($va == '餐饮费')
  9253. $p5 += $v ['price'];
  9254. if ($va == '办公费')
  9255. $p6 += $v ['price'];
  9256. if ($va == '公关费')
  9257. $p7 += $v ['price'];
  9258. if ($va == '其他')
  9259. $p8 += $v ['price'];
  9260. $psum += $v ['price'];
  9261. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9262. $falg = false;
  9263. break;
  9264. }
  9265. }
  9266. }
  9267. if ($falg)
  9268. $html .= '<td class="taR">-</td>';
  9269. }
  9270. $p9 += $psum;
  9271. if (! empty ( $psum ))
  9272. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9273. else
  9274. $psum = '<td class="colGreen taR">-</td>';
  9275. $receiptL ['培训班费用'] = $psum . $html;
  9276. /* ------------------------------------- */
  9277. $html = "";
  9278. $psum = 0;
  9279. $item = array (
  9280. '公关费',
  9281. '广告费',
  9282. '借款',
  9283. '可自加费用'
  9284. );
  9285. foreach ( $item as $va ) {
  9286. $falg = true;
  9287. foreach ( $receiptCollectList as $v ) {
  9288. if ($v ['itemCategory'] == '其他') {
  9289. if ($v ['item'] == $va) {
  9290. if ($va == '公关费')
  9291. $t1 += $v ['price'];
  9292. if ($va == '广告费')
  9293. $t2 += $v ['price'];
  9294. if ($va == '借款')
  9295. $t3 += $v ['price'];
  9296. if ($va == '可自加费用')
  9297. $t4 += $v ['price'];
  9298. $psum += $v ['price'];
  9299. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9300. $falg = false;
  9301. break;
  9302. }
  9303. }
  9304. }
  9305. if ($falg)
  9306. $html .= '<td class="taR">-</td>';
  9307. }
  9308. $t5 += $psum;
  9309. if (! empty ( $psum ))
  9310. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9311. else
  9312. $psum = '<td class="colGreen taR">-</td>';
  9313. $receiptL ['其他'] = $psum . $html;
  9314. /* ------------------------------------- */
  9315. $html = "";
  9316. $psum = 0;
  9317. foreach ( $receiptCollectList as $v ) {
  9318. if ($v ['itemCategory'] == '报销金额调整') {
  9319. if (! empty ( $v ['price'] )) {
  9320. $psum += $v ['price'];
  9321. }
  9322. }
  9323. }
  9324. $s1 += $psum;
  9325. if (! empty ( $psum ))
  9326. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9327. else
  9328. $psum = '<td class="taR colOrange">-</td>';
  9329. $receiptL ['报销金额调整'] = $psum . $html;
  9330. } else {
  9331. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9332. <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>';
  9333. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9334. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9335. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9336. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9337. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9338. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9339. }
  9340. $monthStaffPrice = $receiptDetail->find ( array (
  9341. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9342. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9343. 'asArray' => true
  9344. ) );
  9345. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  9346. $m1 += $monthStaffPrice [0] ['price'];
  9347. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9348. } else
  9349. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9350. $list [$value ['username']] = $receiptL;
  9351. }
  9352. }
  9353. $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>
  9354. <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>
  9355. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  9356. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  9357. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  9358. $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>
  9359. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  9360. $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>';
  9361. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  9362. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  9363. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  9364. }
  9365. $data ['list'] = $list;
  9366. $receiptCollectList = $receiptDetail->find ( array (
  9367. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9368. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9369. 'groupby' => 'item,Month(date),itemCategory',
  9370. 'asArray' => true
  9371. ) );
  9372. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9373. // statistics html
  9374. $stList = $statistics->getOne ( array (
  9375. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9376. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9377. 'groupby' => 'Month(date)',
  9378. 'asArray' => true
  9379. ) );
  9380. if (empty ( $stList ))
  9381. $stList = array (
  9382. 'rePrice' => 0,
  9383. 'agPrice' => 0
  9384. );
  9385. $data ['stList'] = array (
  9386. 'rePrice' => $stList ['rePrice'],
  9387. 'agPrice' => $stList ['agPrice'],
  9388. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9389. );
  9390. $monthHtml = "";
  9391. for($i = 1; $i <= 12; $i ++) {
  9392. if ($i == $month)
  9393. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9394. else
  9395. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9396. }
  9397. $data ['monthHtml'] = $monthHtml;
  9398. $data ['year'] = $year;
  9399. $data ['month'] = $month;
  9400. $data ['memu'] = "receipt";
  9401. $data ['staff'] = $this->staff;
  9402. $data ['receiptMemu'] = 'companyCategoryCollect';
  9403. $data ['verifyId'] = $this->verifyId;
  9404. $data ['executeId'] = $this->executeId;
  9405. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  9406. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9407. }
  9408. function companyMonthCollectDetail() {
  9409. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9410. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9411. if (! $year)
  9412. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9413. if (! $month)
  9414. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9415. Doo::loadModel ( 'staff' );
  9416. $staff = new staff ();
  9417. Doo::loadModel ( "receiptDetail" );
  9418. $receiptDetail = new receiptDetail ();
  9419. Doo::loadModel ( 'accountItem' );
  9420. $accountItem = new accountItem ();
  9421. Doo::loadModel ( 'statistics' );
  9422. $statistics = new statistics ();
  9423. Doo::loadModel ( 'L_category' );
  9424. $lCategory = new L_category ();
  9425. $staffList = $staff->find ( array (
  9426. 'where' => 'username!="admin"',
  9427. 'asArray' => true
  9428. ) );
  9429. $categoryList = $lCategory->find ( array (
  9430. 'asArray' => true
  9431. ) );
  9432. $list = array ();
  9433. foreach ( $categoryList as $value ) {
  9434. $receiptCollectList = $receiptDetail->find ( array (
  9435. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9436. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9437. 'groupby' => 'item,Month(pastDate),itemCategory',
  9438. 'asArray' => true
  9439. ) );
  9440. if (! empty ( $receiptCollectList )) {
  9441. $receiptL = array (
  9442. '日常相关费用' => array (),
  9443. '差旅相关费用' => array (),
  9444. '培训班费用' => array (),
  9445. '其他' => array ()
  9446. );
  9447. $html = "";
  9448. $psum = 0;
  9449. $item = array (
  9450. '市内交通费',
  9451. '市内出租费',
  9452. '办事处房租',
  9453. '电话费',
  9454. '水费',
  9455. '电费',
  9456. '办公费用',
  9457. '邮寄费',
  9458. '其他费用',
  9459. '车辆费用',
  9460. '广告费',
  9461. '团队建设费'
  9462. );
  9463. foreach ( $item as $va ) {
  9464. $falg = true;
  9465. foreach ( $receiptCollectList as $v ) {
  9466. if ($v ['itemCategory'] == '日常相关费用') {
  9467. if ($v ['item'] == $va) {
  9468. $psum += $v ['price'];
  9469. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9470. $falg = false;
  9471. break;
  9472. }
  9473. }
  9474. }
  9475. if ($falg)
  9476. $html .= '<td class="taR">-</td>';
  9477. }
  9478. if (! empty ( $psum ))
  9479. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9480. else
  9481. $psum = '<td class="colGreen taR">-</td>';
  9482. $receiptL ['日常相关费用'] = $psum . $html;
  9483. /* ----------------------------------- */
  9484. $html = "";
  9485. $psum = 0;
  9486. $item = array (
  9487. '往来交通费',
  9488. '市内交通费',
  9489. '出差住宿费',
  9490. '出差补助',
  9491. '其他费用'
  9492. );
  9493. foreach ( $item as $va ) {
  9494. $falg = true;
  9495. foreach ( $receiptCollectList as $v ) {
  9496. if ($v ['itemCategory'] == '差旅相关费用') {
  9497. if ($v ['item'] == $va) {
  9498. $psum += $v ['price'];
  9499. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9500. $falg = false;
  9501. break;
  9502. }
  9503. }
  9504. }
  9505. if ($falg)
  9506. $html .= '<td class="taR">-</td>';
  9507. }
  9508. if (! empty ( $psum ))
  9509. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9510. else
  9511. $psum = '<td class="colGreen taR">-</td>';
  9512. $receiptL ['差旅相关费用'] = $psum . $html;
  9513. /* ------------------------------------- */
  9514. $html = "";
  9515. $psum = 0;
  9516. $item = array (
  9517. '场租费',
  9518. '薪酬',
  9519. '住宿费',
  9520. '交通费',
  9521. '餐饮费',
  9522. '办公费',
  9523. '公关费',
  9524. '其他'
  9525. );
  9526. foreach ( $item as $va ) {
  9527. $falg = true;
  9528. foreach ( $receiptCollectList as $v ) {
  9529. if ($v ['itemCategory'] == '培训班费用') {
  9530. if ($v ['item'] == $va) {
  9531. $psum += $v ['price'];
  9532. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9533. $falg = false;
  9534. break;
  9535. }
  9536. }
  9537. }
  9538. if ($falg)
  9539. $html .= '<td class="taR">-</td>';
  9540. }
  9541. if (! empty ( $psum ))
  9542. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9543. else
  9544. $psum = '<td class="colGreen taR">-</td>';
  9545. $receiptL ['培训班费用'] = $psum . $html;
  9546. /* ------------------------------------- */
  9547. $html = "";
  9548. $psum = 0;
  9549. $item = array (
  9550. '公关费',
  9551. '广告费',
  9552. '借款',
  9553. '可自加费用'
  9554. );
  9555. foreach ( $item as $va ) {
  9556. $falg = true;
  9557. foreach ( $receiptCollectList as $v ) {
  9558. if ($v ['itemCategory'] == '其他') {
  9559. if ($v ['item'] == $va) {
  9560. $psum += $v ['price'];
  9561. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9562. $falg = false;
  9563. break;
  9564. }
  9565. }
  9566. }
  9567. if ($falg)
  9568. $html .= '<td class="taR">-</td>';
  9569. }
  9570. if (! empty ( $psum ))
  9571. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9572. else
  9573. $psum = '<td class="colGreen taR">-</td>';
  9574. $receiptL ['其他'] = $psum . $html;
  9575. /* ------------------------------------- */
  9576. $html = "";
  9577. $psum = 0;
  9578. foreach ( $receiptCollectList as $v ) {
  9579. if ($v ['itemCategory'] == '报销金额调整') {
  9580. if (! empty ( $v ['price'] ))
  9581. $psum += $v ['price'];
  9582. }
  9583. }
  9584. if (! empty ( $psum ))
  9585. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9586. else
  9587. $psum = '<td class="taR colOrange">-</td>';
  9588. $receiptL ['报销金额调整'] = $psum . $html;
  9589. } else {
  9590. $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>
  9591. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9592. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9593. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9594. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9595. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9596. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9597. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9598. }
  9599. $monthStaffPrice = $receiptDetail->find ( array (
  9600. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9601. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9602. 'asArray' => true
  9603. ) );
  9604. if (! empty ( $monthStaffPrice [0] ['price'] ))
  9605. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9606. else
  9607. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9608. $list [$value ['title']] = $receiptL;
  9609. }
  9610. $data ['list'] = $list;
  9611. $receiptCollectList = $receiptDetail->find ( array (
  9612. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9613. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9614. 'groupby' => 'item,Month(pastDate),itemCategory',
  9615. 'asArray' => true
  9616. ) );
  9617. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9618. // print_r($data['monthPriceHtml']);
  9619. // foreach ($data['monthPriceHtml'] as $value){
  9620. // echo $value;
  9621. // }
  9622. // die;
  9623. // statistics html
  9624. $stList = $statistics->getOne ( array (
  9625. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9626. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9627. 'groupby' => 'Month(date)',
  9628. 'asArray' => true
  9629. ) );
  9630. if (empty ( $stList ))
  9631. $stList = array (
  9632. 'rePrice' => 0,
  9633. 'agPrice' => 0
  9634. );
  9635. $data ['stList'] = array (
  9636. 'rePrice' => $stList ['rePrice'],
  9637. 'agPrice' => $stList ['agPrice'],
  9638. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9639. );
  9640. $monthHtml = "";
  9641. for($i = 1; $i <= 12; $i ++) {
  9642. if ($i == $month)
  9643. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9644. else
  9645. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9646. }
  9647. $data ['monthHtml'] = $monthHtml;
  9648. $data ['year'] = $year;
  9649. $data ['month'] = $month;
  9650. $data ['memu'] = "receipt";
  9651. $data ['staff'] = $this->staff;
  9652. $data ['receiptMemu'] = 'companyCategoryCollect';
  9653. $data ['verifyId'] = $this->verifyId;
  9654. $data ['executeId'] = $this->executeId;
  9655. $this->render ( "/admin/companyMonthCollectDetail", $data );
  9656. }
  9657. function staffCollectDetail() {
  9658. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9659. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  9660. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  9661. if (! $staffname) {
  9662. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  9663. $staffname = urldecode ( $staffname );
  9664. }
  9665. Doo::loadModel ( 'staff' );
  9666. $staff = new staff ();
  9667. Doo::loadModel ( "receiptDetail" );
  9668. $receiptDetail = new receiptDetail ();
  9669. Doo::loadModel ( 'accountItem' );
  9670. $accountItem = new accountItem ();
  9671. Doo::loadModel ( 'statistics' );
  9672. $statistics = new statistics ();
  9673. Doo::loadModel ( 'L_category' );
  9674. $lCategory = new L_category ();
  9675. $staffList = $staff->find ( array (
  9676. 'asArray' => true
  9677. ) );
  9678. $stHtml = '';
  9679. $stTitle = "";
  9680. $staffId = 0;
  9681. $cid = 0;
  9682. $ocid = 0;
  9683. foreach ( $staffList as $value ) {
  9684. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  9685. $stTitle = $value ['category'] . '-' . $value ['username'];
  9686. $staffId = $value ['sid'];
  9687. $cid = $value ['cid'];
  9688. $ocid = $value ['cid'];
  9689. if (! empty ( $value ['othercid'] ))
  9690. $cid = $value ['cid'] . ',' . $value ['othercid'];
  9691. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9692. } elseif ($value ['username'] != 'admin')
  9693. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9694. }
  9695. $data ['lCategoryHtml'] = $lCategory->find ( array (
  9696. 'where' => 'cid in(' . $cid . ')',
  9697. 'asArray' => true
  9698. ) );
  9699. if (empty ( $pcid ))
  9700. $pcid = $ocid;
  9701. $data ['ocid'] = $pcid;
  9702. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  9703. $this->showCache ( $path );
  9704. //
  9705. $receiptCollectList = $receiptDetail->find ( array (
  9706. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9707. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9708. 'groupby' => 'item,Month(pastDate),itemCategory',
  9709. 'asArray' => true
  9710. ) );
  9711. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  9712. // print_r($receiptCollectList);
  9713. $accountList = $accountItem->find ( array (
  9714. 'asArray' => true
  9715. ) );
  9716. // create CollectDetail HTML
  9717. $collectHtml = array ();
  9718. foreach ( $accountList as $key => $value ) {
  9719. $html = "";
  9720. $asum = 0;
  9721. for($i = 1; $i <= 12; $i ++) {
  9722. $falg = true;
  9723. foreach ( $receiptCollectList as $v ) {
  9724. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9725. if ($v ['item'] == '可自加费用') {
  9726. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  9727. }
  9728. $asum += $v ['price'];
  9729. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9730. $falg = false;
  9731. break;
  9732. }
  9733. }
  9734. if ($falg)
  9735. $html .= '<td class="taR">-</td>';
  9736. }
  9737. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9738. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9739. }
  9740. $data ['collectHtml'] = $collectHtml;
  9741. // print_r($collectHtml);
  9742. // create Adjustment price html
  9743. $receiptCollectList = $receiptDetail->find ( array (
  9744. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9745. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9746. 'groupby' => 'itemCategory,Month(pastDate)',
  9747. 'asArray' => true
  9748. ) );
  9749. $adjustment = array ();
  9750. $collectArray = array (
  9751. '日常相关费用' => array (),
  9752. '差旅相关费用' => array (),
  9753. '培训班费用' => array (),
  9754. '其他' => array ()
  9755. );
  9756. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9757. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9758. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9759. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9760. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9761. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9762. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9763. array_push ( $collectArray ['其他'], $collectHtml );
  9764. $data ['collectArray'] = $collectArray;
  9765. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9766. array_push ( $adjustment, $collectHtml );
  9767. $data ['adjustment'] = $adjustment;
  9768. // total price html
  9769. $collectHtml = "";
  9770. $total = 0;
  9771. for($i = 1; $i <= 12; $i ++) {
  9772. $sumPrice = 0;
  9773. foreach ( $receiptCollectList as $key => $value ) {
  9774. if ($value ['month'] == $i) {
  9775. $sumPrice += $value ['price'];
  9776. }
  9777. }
  9778. if ($sumPrice == 0)
  9779. $collectHtml .= '<td class="taR">-</td>';
  9780. else
  9781. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9782. $total += $sumPrice;
  9783. }
  9784. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9785. // statistics html
  9786. $stList = $statistics->statisticsByYear ( $year, $staffId );
  9787. if (empty ( $stList ))
  9788. $stList = array (
  9789. 'rePrice' => 0,
  9790. 'agPrice' => 0
  9791. );
  9792. $data ['stList'] = array (
  9793. 'rePrice' => $stList ['rePrice'],
  9794. 'agPrice' => $stList ['agPrice'],
  9795. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9796. );
  9797. $data ['totalPrice'] = $collectHtml;
  9798. $data ['totalYear'] = $total;
  9799. $data ['stHtml'] = $stHtml;
  9800. $data ['year'] = $year;
  9801. $data ['stTitle'] = $stTitle;
  9802. $data ['memu'] = "receipt";
  9803. $data ['staff'] = $this->staff;
  9804. $data ['receiptMemu'] = 'companyCategoryCollect';
  9805. $data ['verifyId'] = $this->verifyId;
  9806. $data ['executeId'] = $this->executeId;
  9807. if ($year < date ( "Y" )) {
  9808. Doo::loadModel ( 'receipt' );
  9809. $receipt = new receipt ();
  9810. $receiptList = $receipt->find ( array (
  9811. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  9812. 'asArray' => true
  9813. ) );
  9814. if (empty ( $receiptList )) { // generated files
  9815. ob_start ();
  9816. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9817. $this->cacheFile ( $path );
  9818. die ();
  9819. }
  9820. }
  9821. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9822. }
  9823. function BUGFLAG() {
  9824. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  9825. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  9826. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9827. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9828. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  9829. if (empty ( $status ))
  9830. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  9831. $page_size = 12;
  9832. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  9833. $vidList = array ();
  9834. $button = 0;
  9835. Doo::loadModel ( 'verify' );
  9836. $verify = new verify ();
  9837. Doo::loadModel ( 'receipt' );
  9838. $receipt = new receipt ();
  9839. Doo::loadModel ( 'staff' );
  9840. $staff = new staff ();
  9841. Doo::loadModel ( 'L_category' );
  9842. $Lcategory = new L_category ();
  9843. $dateCondition = " and Year(date) =" . $year;
  9844. if (! empty ( $month ))
  9845. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  9846. $categoryList = $Lcategory->find ( array (
  9847. 'asArray' => true
  9848. ) );
  9849. $staffList = $staff->find ( array (
  9850. 'where' => 'cid=' . $cid,
  9851. 'asArray' => true
  9852. ) );
  9853. $cateCondition = "";
  9854. $staffCondition = "";
  9855. $approvalCondition = "";
  9856. if (! empty ( $cid ))
  9857. $cateCondition = ' and cid=' . $cid;
  9858. if (! empty ( $sid )) {
  9859. $staffCondition = ' and staff=' . $sid;
  9860. $cateCondition = "";
  9861. }
  9862. $approvalCondition = " and status=" . $status;
  9863. if ($status == 2) {
  9864. // 查找角色审批人
  9865. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9866. }
  9867. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  9868. $approvalCondition = ' and status=2 ';
  9869. }
  9870. if ($status == 1) {
  9871. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  9872. }
  9873. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  9874. $pageinfo ['page'] = array (
  9875. 'previous' => ''
  9876. );
  9877. if ($status == 0) {
  9878. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  9879. $receiptList = $receipt->find ( array (
  9880. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  9881. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  9882. 'desc' => 'rid',
  9883. 'asArray' => true
  9884. ) );
  9885. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9886. } else
  9887. $receiptList = $receipt->find ( array (
  9888. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  9889. 'desc' => 'rid',
  9890. 'asArray' => true
  9891. ) );
  9892. $rLRes = $receipt->find ( array (
  9893. '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,
  9894. 'desc' => 'rid',
  9895. 'asArray' => true
  9896. ) );
  9897. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9898. // print_r($pageinfo);
  9899. $Locate = 0;
  9900. foreach ( $receiptList as $key => $value ) {
  9901. $receiptList [$key] ['Locate'] = $Locate;
  9902. $Locate ++;
  9903. $receiptList [$key] ['reviseDetail'] = array ();
  9904. if (! empty ( $value ['reviseDetail'] ))
  9905. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  9906. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  9907. $categoryDetil = $Lcategory->getOne ( array (
  9908. 'where' => 'cid=' . $value ['cid'],
  9909. 'asArray' => true
  9910. ) );
  9911. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  9912. $verifyList = $verify->getOne ( array (
  9913. 'where' => 'vid=' . $value ['verify'],
  9914. 'asArray' => true
  9915. ) );
  9916. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  9917. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  9918. foreach ( $verifyList as $k => $v ) {
  9919. // init verifyStaff
  9920. $verifyList [$k] ['date'] = "";
  9921. $verifyList [$k] ['opinion'] = "";
  9922. $verifyList [$k] ['status'] = "";
  9923. if (empty ( $verifyStaff )) {
  9924. $verifyList [$k] ['date'] = "";
  9925. $verifyList [$k] ['opinion'] = "";
  9926. if ($v [0] == $this->staff [0] ['sid']) {
  9927. $verifyList [$k] ['status'] = 4;
  9928. $button = 4;
  9929. }
  9930. } else {
  9931. $flag = true;
  9932. foreach ( $verifyStaff as $m => $u ) {
  9933. if ($v [0] == $m) {
  9934. $verifyList [$k] ['date'] = $u ['date'];
  9935. $verifyList [$k] ['opinion'] = $u ['opinion'];
  9936. $verifyList [$k] ['status'] = $u ['status'];
  9937. $flag = false;
  9938. break;
  9939. }
  9940. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  9941. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  9942. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  9943. }
  9944. if ($flag) { // 检测可编辑
  9945. if ($v [0] == $this->staff [0] ['sid']) {
  9946. $verifyList [$k] ['status'] = 4;
  9947. $button = 4;
  9948. }
  9949. }
  9950. }
  9951. }
  9952. $receiptList [$key] ['verifyList'] = $verifyList;
  9953. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  9954. 'where' => 'sid=' . $value ['staff'],
  9955. 'asArray' => true
  9956. ) );
  9957. $receiptList [$key] ['button'] = $button;
  9958. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  9959. }
  9960. // print_r($receiptList);die;
  9961. // $data['verifyDetail']=$verifyDetail;
  9962. $mothHtml = "";
  9963. for($i = 1; $i <= 12; $i ++) {
  9964. if ($month == $i)
  9965. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  9966. else
  9967. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  9968. }
  9969. $data ['mothHtml'] = $mothHtml;
  9970. $data ['page'] = $pageinfo;
  9971. $data ['receiptList'] = $receiptList;
  9972. $data ['receiptApprovalCount'] = count ( $rLRes );
  9973. $data ['status'] = $status;
  9974. $data ['year'] = $year;
  9975. $data ['categoryList'] = $categoryList;
  9976. $data ['staffList'] = $staffList;
  9977. $data ['cid'] = $cid;
  9978. $data ['sid'] = $sid;
  9979. // print_r($receiptList);
  9980. $data ['memu'] = "receipt";
  9981. $data ['staff'] = $this->staff;
  9982. $data ['receiptMemu'] = 'approvalExpenses';
  9983. $data ['verifyId'] = $this->verifyId;
  9984. $data ['executeId'] = $this->executeId;
  9985. $this->render ( "/admin/FALG", $data );
  9986. }
  9987. function ajaxGetReceiptOrder() {
  9988. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  9989. if (! empty ( $receiptOrder )) {
  9990. Doo::loadModel ( 'receipt' );
  9991. $receipt = new receipt ();
  9992. Doo::loadModel ( 'staff' );
  9993. $staff = new staff ();
  9994. $receiptInfo = $receipt->getOne ( array (
  9995. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  9996. 'asArray' => true
  9997. ) );
  9998. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  9999. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  10000. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  10001. </tbody></table><table class="table table table-bordered"><tbody>';
  10002. foreach ( $verifyStaff as $key => $value ) {
  10003. $staffInfo = $staff->getOne ( array (
  10004. 'select' => 'username',
  10005. 'where' => ' sid="' . $key . '"',
  10006. 'asArray' => true
  10007. ) );
  10008. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  10009. }
  10010. $html .= '</tbody></table></div></div>';
  10011. echo json_encode ( array (
  10012. 'status' => 1,
  10013. 'receiptHtml' => $html
  10014. ) );
  10015. die ();
  10016. }
  10017. echo json_encode ( array (
  10018. 'status' => 2,
  10019. 'receiptHtml' => ''
  10020. ) );
  10021. die ();
  10022. }
  10023. function _getMonthCollectDetail($receiptCollectList) {
  10024. if (! empty ( $receiptCollectList )) {
  10025. $receiptL = array (
  10026. '日常相关费用' => array (),
  10027. '差旅相关费用' => array (),
  10028. '培训班费用' => array (),
  10029. '其他' => array ()
  10030. );
  10031. $html = "";
  10032. $psum = 0;
  10033. $item = array (
  10034. '市内交通费',
  10035. '市内出租费',
  10036. '办事处房租',
  10037. '电话费',
  10038. '水费',
  10039. '电费',
  10040. '办公费用',
  10041. '邮寄费',
  10042. '其他费用',
  10043. '车辆费用',
  10044. '广告费',
  10045. '团队建设费',
  10046. '物业管理费',
  10047. '宽带费'
  10048. );
  10049. foreach ( $item as $value ) {
  10050. $falg = true;
  10051. foreach ( $receiptCollectList as $v ) {
  10052. if ($v ['itemCategory'] == '日常相关费用') {
  10053. if ($v ['item'] == $value) {
  10054. $psum += $v ['price'];
  10055. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10056. $falg = false;
  10057. break;
  10058. }
  10059. }
  10060. }
  10061. if ($falg)
  10062. $html .= '<td class="taR">-</td>';
  10063. }
  10064. if (! empty ( $psum ))
  10065. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  10066. else
  10067. $psum = '<td class="colGreen taR">-</td>';
  10068. $receiptL ['日常相关费用'] = $psum . $html;
  10069. /* ----------------------------------- */
  10070. $html = "";
  10071. $psum = 0;
  10072. $item = array (
  10073. '往来交通费',
  10074. '市内交通费',
  10075. '出差住宿费',
  10076. '出差补助',
  10077. '其他费用'
  10078. );
  10079. foreach ( $item as $value ) {
  10080. $falg = true;
  10081. foreach ( $receiptCollectList as $v ) {
  10082. if ($v ['itemCategory'] == '差旅相关费用') {
  10083. if ($v ['item'] == $value) {
  10084. $psum += $v ['price'];
  10085. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10086. $falg = false;
  10087. break;
  10088. }
  10089. }
  10090. }
  10091. if ($falg)
  10092. $html .= '<td class="taR">-</td>';
  10093. }
  10094. if (! empty ( $psum ))
  10095. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  10096. else
  10097. $psum = '<td class="colGreen taR">-</td>';
  10098. $receiptL ['差旅相关费用'] = $psum . $html;
  10099. /* ------------------------------------- */
  10100. $html = "";
  10101. $psum = 0;
  10102. $item = array (
  10103. '场租费',
  10104. '薪酬',
  10105. '住宿费',
  10106. '交通费',
  10107. '餐饮费',
  10108. '办公费',
  10109. '公关费',
  10110. '其他'
  10111. );
  10112. foreach ( $item as $value ) {
  10113. $falg = true;
  10114. foreach ( $receiptCollectList as $v ) {
  10115. if ($v ['itemCategory'] == '培训班费用') {
  10116. if ($v ['item'] == $value) {
  10117. $psum += $v ['price'];
  10118. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10119. $falg = false;
  10120. break;
  10121. }
  10122. }
  10123. }
  10124. if ($falg)
  10125. $html .= '<td class="taR">-</td>';
  10126. }
  10127. if (! empty ( $psum ))
  10128. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  10129. else
  10130. $psum = '<td class="colGreen taR">-</td>';
  10131. $receiptL ['培训班费用'] = $psum . $html;
  10132. /* ------------------------------------- */
  10133. $html = "";
  10134. $psum = 0;
  10135. $item = array (
  10136. '公关费',
  10137. '广告费',
  10138. '借款',
  10139. '可自加费用'
  10140. );
  10141. foreach ( $item as $value ) {
  10142. $falg = true;
  10143. foreach ( $receiptCollectList as $v ) {
  10144. if ($v ['itemCategory'] == '其他') {
  10145. if ($v ['item'] == $value) {
  10146. $psum += $v ['price'];
  10147. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10148. $falg = false;
  10149. break;
  10150. }
  10151. }
  10152. }
  10153. if ($falg)
  10154. $html .= '<td class="taR">-</td>';
  10155. }
  10156. if (! empty ( $psum ))
  10157. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  10158. else
  10159. $psum = '<td class="colGreen taR">-</td>';
  10160. $receiptL ['其他'] = $psum . $html;
  10161. /* ------------------------------------- */
  10162. $html = "";
  10163. $psum = 0;
  10164. foreach ( $receiptCollectList as $v ) {
  10165. if ($v ['itemCategory'] == '报销金额调整') {
  10166. if (! empty ( $v ['price'] ))
  10167. $psum += $v ['price'];
  10168. }
  10169. }
  10170. if (! empty ( $psum ))
  10171. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  10172. else
  10173. $psum = '<td class="taR colOrange">-</td>';
  10174. $receiptL ['报销金额调整'] = $psum . $html;
  10175. } else {
  10176. $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>
  10177. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10178. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  10179. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10180. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  10181. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10182. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10183. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  10184. }
  10185. return $receiptL;
  10186. }
  10187. function eMail() {
  10188. Doo::loadModel ( 'staff' );
  10189. $staff = new staff ();
  10190. Doo::loadModel ( 'receipt' );
  10191. $receipt = new receipt ();
  10192. Doo::loadModel ( 'L_category' );
  10193. $Lcategory = new L_category ();
  10194. Doo::loadModel ( "verify" );
  10195. $verify = new verify ();
  10196. $staffList = $staff->find ( array (
  10197. 'asArray' => true
  10198. ) );
  10199. foreach ( $staffList as $key => $value ) {
  10200. if ($value ['username'] != 'admin') {
  10201. // 提交人
  10202. $receiptList = $receipt->find ( array (
  10203. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  10204. 'asArray' => true
  10205. ) );
  10206. if (! empty ( $receiptList )) {
  10207. $html = '<br><div><style></style>
  10208. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  10209. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  10210. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  10211. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  10212. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  10213. <tbody><tr>
  10214. <td style="padding: 0 40px;" align="left">
  10215. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  10216. </td></tr><tr>
  10217. <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>
  10218. </tr>
  10219. </tbody> </table></td> </tr> <tr><td>
  10220. <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">
  10221. <tbody> <tr><td>
  10222. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  10223. 以下报销单完成了审批,等着收款吧:</p>
  10224. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  10225. foreach ( $receiptList as $k => $v ) {
  10226. $category = $Lcategory->getOne ( array (
  10227. 'where' => 'cid=' . $v ['cid'],
  10228. 'asArray' => true
  10229. ) );
  10230. $html .= '
  10231. <tr>
  10232. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  10233. <td align="left">
  10234. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  10235. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  10236. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  10237. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  10238. </tr>';
  10239. }
  10240. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  10241. <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>
  10242. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  10243. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  10244. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  10245. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  10246. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  10247. $receipt = new receipt ();
  10248. $receipt->notice = 1;
  10249. $receipt->update ( array (
  10250. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  10251. ) );
  10252. }
  10253. }
  10254. // 审批人
  10255. $verifyList = $verify->find ( array (
  10256. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  10257. 'asArray' => true
  10258. ) );
  10259. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  10260. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  10261. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  10262. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  10263. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  10264. <tbody><tr><td style="padding: 0 40px;" align="left">
  10265. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  10266. </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>
  10267. </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">
  10268. <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>
  10269. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  10270. foreach ( $verifyList as $k => $v ) {
  10271. $receiptList = $receipt->find ( array (
  10272. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  10273. 'asArray' => true
  10274. ) );
  10275. foreach ( $receiptList as $r => $l ) {
  10276. $category = $Lcategory->getOne ( array (
  10277. 'where' => 'cid=' . $l ['cid'],
  10278. 'asArray' => true
  10279. ) );
  10280. $staffDetile = $staff->getOne ( array (
  10281. 'where' => 'sid=' . $l ['staff'],
  10282. 'asArray' => true
  10283. ) );
  10284. $html .= '
  10285. <tr>
  10286. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  10287. <td align="left">
  10288. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  10289. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  10290. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  10291. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  10292. </tr>';
  10293. }
  10294. }
  10295. $html .= '
  10296. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  10297. <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>
  10298. </tr></tbody></table></td></tr></tbody></table></div><br>';
  10299. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  10300. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  10301. // $receipt=new receipt();
  10302. // $receipt->notice=1;
  10303. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  10304. }
  10305. }
  10306. }
  10307. }
  10308. function setWXMsg($rid, $type) {
  10309. Doo::loadModel ( "receipt" );
  10310. $receipt = new receipt ();
  10311. $receiptDetail = $receipt->getOne ( array (
  10312. 'where' => 'rid=' . $rid,
  10313. 'asArray' => true
  10314. ) );
  10315. if (! empty ( $receiptDetail )) {
  10316. Doo::loadModel ( 'staff' );
  10317. $staff = new staff ();
  10318. $staffmsg = $staff->getOne ( array (
  10319. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  10320. 'asArray' => TRUE
  10321. ) );
  10322. if (! empty ( $staffmsg ['wxid'] )) {
  10323. require_once (SITE_PATH . '/protected/class/client.php');
  10324. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  10325. $user = $staffmsg ['wxid'];
  10326. $receiptName = '';
  10327. $msg = '';
  10328. switch ($receiptDetail ['Rtype']) {
  10329. case 0 :
  10330. $receiptName = '报销';
  10331. break;
  10332. case 1 :
  10333. $receiptName = '借款';
  10334. break;
  10335. case 2 :
  10336. $receiptName = '对公汇款';
  10337. break;
  10338. }
  10339. switch ($type) {
  10340. case 1 :
  10341. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  10342. break;
  10343. case 2 :
  10344. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  10345. break;
  10346. case 3 :
  10347. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  10348. break;
  10349. }
  10350. //$result = $client->SendMsg ( $user, $msg, 'text' );
  10351. }
  10352. }
  10353. }
  10354. // Email发送函数
  10355. function SMail($toemail, $subject, $contents) {
  10356. Doo::loadClass ( 'class.phpmailer' );
  10357. $mail = new PHPMailer ();
  10358. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  10359. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  10360. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  10361. $mail->Password = "cDO1GjtY1seH"; // 密码
  10362. $mail->CharSet = "UTF8";
  10363. $mail->SMTPAuth = true;
  10364. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  10365. $mail->Mailer = "smtp";
  10366. $mail->Port = 25;
  10367. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  10368. $mail->MsgHTML ( $contents );
  10369. $mail->AddAddress ( $toemail );
  10370. $mail->CharSet = "UTF-8";
  10371. return $mail->Send ();
  10372. }
  10373. function swfupload() {
  10374. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  10375. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  10376. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  10377. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  10378. header ( "HTTP/1.1 500 Internal Server Error" );
  10379. echo "POST exceeded maximum allowed size.";
  10380. exit ( 0 );
  10381. }
  10382. // Settings
  10383. $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)
  10384. $upload_name = "Filedata";
  10385. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  10386. $extension_whitelist = array (
  10387. "doc",
  10388. "txt",
  10389. "jpg",
  10390. "gif",
  10391. "png"
  10392. ); // Allowed file extensions
  10393. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  10394. // Other variables
  10395. $MAX_FILENAME_LENGTH = 260;
  10396. $file_name = "";
  10397. $file_extension = "";
  10398. $uploadErrors = array (
  10399. 0 => "文件上传成功",
  10400. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  10401. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  10402. 3 => "上传的文件仅为部分文件",
  10403. 4 => "没有文件上传",
  10404. 6 => "缺少临时文件夹"
  10405. );
  10406. $nk = time ();
  10407. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  10408. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  10409. echo "文件无法保存.";
  10410. exit ( 0 );
  10411. }
  10412. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  10413. echo json_encode ( array (
  10414. 'filename' => $file_name,
  10415. 'id' => $nk
  10416. ) );
  10417. exit ( 0 );
  10418. }
  10419. function _GetFileEXT($filename) {
  10420. $pics = explode ( '.', $filename );
  10421. $num = count ( $pics );
  10422. return $pics [$num - 1];
  10423. }
  10424. /**
  10425. * 获取get或者POST值
  10426. * @param string $name 属性名称
  10427. * @return fixed 值
  10428. */
  10429. function get_args($name) {
  10430. if (isset ( $_GET [$name] )) {
  10431. if (is_array ( $_GET [$name] ))
  10432. return $_GET [$name];
  10433. else
  10434. return addslashes ( $_GET [$name] );
  10435. } elseif (isset ( $_POST [$name] )) {
  10436. if (is_array ( $_POST [$name] ))
  10437. return $_POST [$name];
  10438. else
  10439. return addslashes ( $_POST [$name] );
  10440. } else
  10441. return false;
  10442. }
  10443. function num_to_rmb($num) {
  10444. $c1 = "零壹贰叁肆伍陆柒捌玖";
  10445. $c2 = "分角元拾佰仟万拾佰仟亿";
  10446. // 精确到分后面就不要了,所以只留两个小数位
  10447. $num = round ( $num, 2 );
  10448. // 将数字转化为整数
  10449. $num = $num * 100;
  10450. if (strlen ( $num ) > 10) {
  10451. return "金额太大,请检查";
  10452. }
  10453. $i = 0;
  10454. $c = "";
  10455. while ( 1 ) {
  10456. if ($i == 0) {
  10457. // 获取最后一位数字
  10458. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  10459. } else {
  10460. $n = $num % 10;
  10461. }
  10462. // 每次将最后一位数字转化为中文
  10463. $p1 = substr ( $c1, 3 * $n, 3 );
  10464. $p2 = substr ( $c2, 3 * $i, 3 );
  10465. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  10466. $c = $p1 . $p2 . $c;
  10467. } else {
  10468. $c = $p1 . $c;
  10469. }
  10470. $i = $i + 1;
  10471. // 去掉数字最后一位了
  10472. $num = $num / 10;
  10473. //echo $num.'</br>';
  10474. //$num = (int)$num;
  10475. //$num =floor($num);
  10476. $num=round($num, 0, PHP_ROUND_HALF_DOWN);
  10477. //echo $num.'</br>';
  10478. // 结束循环
  10479. if ($num == 0) {
  10480. break;
  10481. }
  10482. }
  10483. //echo $c.'</br>';
  10484. $j = 0;
  10485. $slen = strlen ( $c );
  10486. while ( $j < $slen ) {
  10487. // utf8一个汉字相当3个字符
  10488. $m = substr ( $c, $j, 6 );
  10489. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  10490. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  10491. $left = substr ( $c, 0, $j );
  10492. $right = substr ( $c, $j + 3 );
  10493. $c = $left . $right;
  10494. $j = $j - 3;
  10495. $slen = $slen - 3;
  10496. }
  10497. $j = $j + 3;
  10498. }
  10499. // 这个是为了去掉类似23.0中最后一个“零”字
  10500. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  10501. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  10502. }
  10503. // 将处理的汉字加上“整”
  10504. if (empty ( $c )) {
  10505. return "零元整";
  10506. } else {
  10507. return $c . "整";
  10508. }
  10509. }
  10510. /**
  10511. * 获得分页数据
  10512. * @param unknown_type $table
  10513. * @param unknown_type $condition
  10514. * @param unknown_type $on_page
  10515. * @param unknown_type $page_size
  10516. */
  10517. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  10518. $page_c = "";
  10519. $page ['previous'] = $this->get_previous ( $on_page );
  10520. $page ['on_page'] = $on_page;
  10521. $total_count = $this->get_table_count ( $table, $condition );
  10522. $total = intval ( $total_count / $page_size );
  10523. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  10524. $page ['total_data'] = $total_count;
  10525. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  10526. $i = 1;
  10527. $page_max = 1;
  10528. $page_width = 3;
  10529. if ($on_page >= $page_width) {
  10530. $page_max = intval ( $on_page / $page_width ) + 1;
  10531. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  10532. }
  10533. for(; $i <= $page ['total_page']; $i ++) {
  10534. if ($i == $on_page)
  10535. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  10536. else
  10537. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  10538. if ($i == ($page_width * $page_max))
  10539. break;
  10540. }
  10541. $page ['page'] = $page_c;
  10542. $page ['lower'] = (-- $on_page) * $page_size;
  10543. return $page;
  10544. }
  10545. /**
  10546. * 获取总页数
  10547. * @param unknown_type $table
  10548. * @param unknown_type $condition
  10549. */
  10550. public function get_table_count($table = "", $condition = "") {
  10551. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10552. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10553. // echo $sql;die;
  10554. $query = Doo::db ()->query ( $sql );
  10555. $result = $query->fetch ();
  10556. return $result ['count'];
  10557. }
  10558. /**
  10559. * 获取上一页
  10560. * @param unknown_type $on_page
  10561. */
  10562. function get_previous($on_page = 1) {
  10563. return $on_page != 0 ? $on_page - 1 : $on_page;
  10564. }
  10565. }
  10566. ?>