ReceiptController.php 374 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611
  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. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  125. $receiptDetail = $receipt->find ( array (
  126. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  127. 'desc' => 'rid',
  128. 'asArray' => true
  129. ) );
  130. foreach ( $receiptDetail as $key => $value ) {
  131. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  132. $veList = $verify->getOne ( array (
  133. 'where' => 'vid=' . $value ['verify'],
  134. 'asArray' => true
  135. ) );
  136. $v = json_decode ( $veList ['staff'] );
  137. array_push ( $v [0], $veList ['description'] );
  138. foreach ( $v as $n => $m ) {
  139. if ($m ['1'] == 'ROLE') {
  140. $roleInfo = $role->getOne ( array (
  141. 'where' => 'rid=' . $m [0],
  142. 'asArray' => true
  143. ) );
  144. $v [$n] [1] = $roleInfo ['name'];
  145. }
  146. }
  147. $receiptDetail [$key] ['staff'] = $v;
  148. $category = $lCategory->getOne ( array (
  149. 'where' => 'cid=' . $value ['cid'],
  150. 'asArray' => true
  151. ) );
  152. $receiptDetail [$key] ['category'] = $category ['title'];
  153. }
  154. // print_r($receiptLogList);
  155. $data ['receiptLogList'] = $receiptLogList;
  156. $data ['receiptDetail'] = $receiptDetail;
  157. $data ['memu'] = "receipt";
  158. $data ['staff'] = $this->staff;
  159. $data ['receiptMemu'] = 'saeaBorad';
  160. $data ['verifyId'] = $this->verifyId;
  161. $data ['executeId'] = $this->executeId;
  162. $this->render ( "/admin/saeaBorad", $data );
  163. }
  164. function remitAdd() {
  165. Doo::loadModel ( 'accountItem' );
  166. Doo::loadModel ( 'verify' );
  167. Doo::loadModel ( 'receipt' );
  168. Doo::loadModel ( 'L_category' );
  169. $lCategory = new L_category ();
  170. $receipt = new receipt ();
  171. $verify = new verify ();
  172. $accountItem = new accountItem ();
  173. Doo::loadModel ( "role" );
  174. $role = new role ();
  175. $acItem = $accountItem->find ( array (
  176. 'asArray' => true
  177. ) );
  178. $veList = $verify->find ( array (
  179. 'asArray' => true
  180. ) );
  181. foreach ( $veList as $key => $value ) {
  182. $v = json_decode ( $value ['staff'] );
  183. $list = array ();
  184. foreach ( $v as $n => $m ) {
  185. if ($m ['1'] == 'ROLE') {
  186. $roleInfo = $role->getOne ( array (
  187. 'where' => 'rid=' . $m [0],
  188. 'asArray' => true
  189. ) );
  190. $v [$n] [1] = $roleInfo ['name'];
  191. array_push ( $list, $roleInfo ['name'] );
  192. } else {
  193. array_push ( $list, $v [$n] [1] );
  194. }
  195. }
  196. $veList [$key] ['staff'] = implode ( '>', $list );
  197. }
  198. $data ['category'] = $lCategory->find ( array (
  199. 'asArray' => true
  200. ) );
  201. $data ['veList'] = $veList;
  202. $data ['acItem'] = $acItem;
  203. $data ['memu'] = "receipt";
  204. $data ['staff'] = $this->staff;
  205. $data ['receiptMemu'] = 'saeaBorad';
  206. $data ['verifyId'] = $this->verifyId;
  207. $data ['executeId'] = $this->executeId;
  208. $this->render ( "/admin/remitAdd", $data );
  209. }
  210. function remitAddDo() {
  211. $agency = $this->get_args ( 'agency' );
  212. $travel = $this->get_args ( 'travel' );
  213. $train = $this->get_args ( 'train' );
  214. $other = $this->get_args ( 'other' );
  215. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  216. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  217. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  218. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  219. // print_r($agency);die;
  220. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  221. Doo::loadModel ( 'receipt' );
  222. Doo::loadModel ( 'receiptDetail' );
  223. Doo::loadModel ( 'accountItem' );
  224. $accountItem = new accountItem ();
  225. $receipt = new receipt ();
  226. Doo::loadModel ( 'enclosur' );
  227. Doo::loadModel ( 'execute' );
  228. $execute = new execute ();
  229. $executeDetail = $execute->getOne ( array (
  230. 'where' => 'mold="对公汇款执行人"',
  231. 'asArray' => true
  232. ) );
  233. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  234. $aItem = $accountItem->find ( array (
  235. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  236. 'asArray' => true
  237. ) );
  238. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  239. $ag = $tr = $ta = $ot = 0;
  240. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  241. foreach ( $aItem as $key => $value ) {
  242. if ($value ['category'] == $this->AGENCY) {
  243. if (isset ( $agency [$ag] )) {
  244. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  245. array_push ( $accountJson [$this->AGENCY], array (
  246. 'aid' => $value ['aid'],
  247. 'name' => $value ['name'],
  248. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  249. ) );
  250. $sum += $agency [$ag];
  251. $agencySum += $agency [$ag];
  252. }
  253. }
  254. $ag ++;
  255. }
  256. }
  257. $accountJson ['cSum'] = array (
  258. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  259. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  260. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  261. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  262. );
  263. // 报销单
  264. $receipt->accountItem = json_encode ( $accountJson );
  265. $receipt->staff = $this->staff [0] ['sid'];
  266. $receipt->sum = number_format ( $sum, 2, '.', '' );
  267. $receipt->date = date ( "Y-m-d" );
  268. $receipt->cid = $cid;
  269. $receipt->status = 5;
  270. $receipt->Rtype = 2;
  271. // 修改审批流程加入角色
  272. $receipt->verify = $verify;
  273. $receipt->executeCopy = $executeDetail ['staff'];
  274. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  275. $receipt->explanation = $explanation;
  276. $rid = $receipt->insert ();
  277. // 附件
  278. if (! empty ( $enclosurName )) {
  279. $enclosurArray = explode ( '-', $enclosurName );
  280. foreach ( $enclosurArray as $value ) {
  281. $enclosur = new enclosur ();
  282. $enclosur->name = $value;
  283. $enclosur->rid = $rid;
  284. $enclosur->insert ();
  285. }
  286. // print_r($enclosurArray);die;
  287. }
  288. // 报销详情
  289. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  290. $receiptDetail = new receiptDetail ();
  291. $receiptDetail->staff = $this->staff [0] ['sid'];
  292. $receiptDetail->item = $value ['name'];
  293. $receiptDetail->itemCategory = $this->AGENCY;
  294. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  295. $receiptDetail->date = date ( "Y-m-d" );
  296. $receiptDetail->cid = $cid;
  297. $receiptDetail->rid = $rid;
  298. $receiptDetail->status = 4;
  299. $receiptDetail->insert ();
  300. }
  301. return "/saeaBorad";
  302. } else
  303. die ( 'illegal request' );
  304. }
  305. function remitEdit() {
  306. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  307. // echo $rid;
  308. Doo::loadModel ( 'accountItem' );
  309. Doo::loadModel ( 'verify' );
  310. Doo::loadModel ( 'receipt' );
  311. $receipt = new receipt ();
  312. $verify = new verify ();
  313. $accountItem = new accountItem ();
  314. Doo::loadModel ( 'L_category' );
  315. $lCategory = new L_category ();
  316. Doo::loadModel ( "role" );
  317. $role = new role ();
  318. $receiptDetail = $receipt->getOne ( array (
  319. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  320. 'asArray' => true
  321. ) );
  322. if (empty ( $receiptDetail ))
  323. return "/saeaCreate";
  324. $acItem = $accountItem->find ( array (
  325. 'asArray' => true
  326. ) );
  327. $veList = $verify->find ( array (
  328. 'asArray' => true
  329. ) );
  330. foreach ( $veList as $key => $value ) {
  331. $v = json_decode ( $value ['staff'] );
  332. $list = array ();
  333. foreach ( $v as $n => $m ) {
  334. if ($m ['1'] == 'ROLE') {
  335. $roleInfo = $role->getOne ( array (
  336. 'where' => 'rid=' . $m [0],
  337. 'asArray' => true
  338. ) );
  339. $v [$n] [1] = $roleInfo ['name'];
  340. array_push ( $list, $roleInfo ['name'] );
  341. } else {
  342. array_push ( $list, $v [$n] [1] );
  343. }
  344. }
  345. $veList [$key] ['staff'] = implode ( '>', $list );
  346. }
  347. // 配置编辑信息
  348. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  349. foreach ( $acItem as $key => $value ) {
  350. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  351. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  352. $acItem [$key] ['price'] = $v ['price'];
  353. }
  354. }
  355. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  356. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  357. $acItem [$key] ['price'] = $v ['price'];
  358. }
  359. }
  360. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  361. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  362. $acItem [$key] ['price'] = $v ['price'];
  363. }
  364. }
  365. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  366. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  367. $acItem [$key] ['price'] = $v ['price'];
  368. }
  369. }
  370. }
  371. $data ['category'] = $lCategory->find ( array (
  372. 'asArray' => true
  373. ) );
  374. $data ['cSum'] = $accountItemList ['cSum'];
  375. $data ['sum'] = $receiptDetail ['sum'];
  376. $data ['receiptDetail'] = $receiptDetail;
  377. $data ['veList'] = $veList;
  378. $data ['acItem'] = $acItem;
  379. $data ['memu'] = "receipt";
  380. $data ['staff'] = $this->staff;
  381. $data ['receiptMemu'] = 'saeaBorad';
  382. $data ['verify'] = $receiptDetail ['verify'];
  383. $data ['verifyId'] = $this->verifyId;
  384. $data ['executeId'] = $this->executeId;
  385. $data ['rid'] = $rid;
  386. $this->render ( "/admin/remitEdit", $data );
  387. }
  388. function remitEdiDo() {
  389. $agency = $this->get_args ( 'agency' );
  390. $travel = $this->get_args ( 'travel' );
  391. $train = $this->get_args ( 'train' );
  392. $other = $this->get_args ( 'other' );
  393. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  394. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  395. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  396. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  397. if (! empty ( $explanation )) {
  398. Doo::loadModel ( 'receipt' );
  399. Doo::loadModel ( 'receiptDetail' );
  400. Doo::loadModel ( 'accountItem' );
  401. $accountItem = new accountItem ();
  402. $receipt = new receipt ();
  403. Doo::loadModel ( 'execute' );
  404. $execute = new execute ();
  405. $executeDetail = $execute->getOne ( array (
  406. 'where' => 'mold="对公汇款执行人"',
  407. 'asArray' => true
  408. ) );
  409. $receiptDetail = $receipt->getOne ( array (
  410. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  411. 'asArray' => true
  412. ) );
  413. if (empty ( $receiptDetail ))
  414. return "/saeaBorad";
  415. $aItem = $accountItem->find ( array (
  416. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  417. 'asArray' => true
  418. ) );
  419. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  420. $ag = $tr = $ta = $ot = 0;
  421. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  422. foreach ( $aItem as $key => $value ) {
  423. if ($value ['category'] == $this->AGENCY) {
  424. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  425. array_push ( $accountJson [$this->AGENCY], array (
  426. 'aid' => $value ['aid'],
  427. 'name' => $value ['name'],
  428. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  429. ) );
  430. $sum += $agency [$ag];
  431. $agencySum += $agency [$ag];
  432. }
  433. $ag ++;
  434. }
  435. }
  436. $accountJson ['cSum'] = array (
  437. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  438. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  439. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  440. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  441. );
  442. // 报销单
  443. $rid = $receipt->rid = $receiptDetail ['rid'];
  444. $receipt->accountItem = json_encode ( $accountJson );
  445. $receipt->staff = $this->staff [0] ['sid'];
  446. $receipt->sum = number_format ( $sum, 2, '.', '' );
  447. $receipt->date = date ( "Y-m-d" );
  448. $receipt->cid = $cid;
  449. if ($receiptDetail ['Rtype'] == 1)
  450. $receipt->status = 7;
  451. else
  452. $receipt->status = 5;
  453. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  454. $receipt->verify = $verify;
  455. $receipt->executeCopy = $executeDetail ['staff'];
  456. $receipt->explanation = $explanation;
  457. $receipt->update ();
  458. $receiptDetail = new receiptDetail ();
  459. $receiptDetail->delete ( array (
  460. 'where' => 'rid=' . $rid
  461. ) );
  462. // 报销详情
  463. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  464. $receiptDetail = new receiptDetail ();
  465. $receiptDetail->staff = $this->staff [0] ['sid'];
  466. $receiptDetail->item = $value ['name'];
  467. $receiptDetail->itemCategory = $this->AGENCY;
  468. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  469. $receiptDetail->date = date ( "Y-m-d" );
  470. $receiptDetail->cid = $cid;
  471. $receiptDetail->rid = $rid;
  472. $receiptDetail->status = 4;
  473. $receiptDetail->insert ();
  474. }
  475. // return "/referReceipt/".$rid;
  476. }
  477. return "/saeaBorad";
  478. }
  479. function remitApproval() {
  480. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  481. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  482. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  483. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  484. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  485. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  486. if (empty ( $status ))
  487. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  488. $vidList = array ();
  489. $button = 0;
  490. Doo::loadModel ( 'verify' );
  491. Doo::loadModel ( 'receipt' );
  492. Doo::loadModel ( 'staff' );
  493. $staff = new staff ();
  494. $receipt = new receipt ();
  495. $verify = new verify ();
  496. Doo::loadModel ( 'L_category' );
  497. $Lcategory = new L_category ();
  498. Doo::loadModel ( 'enclosur' );
  499. $enclosur = new enclosur ();
  500. // user verify ID
  501. $verifyDetail = $verify->find ( array (
  502. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  503. 'asArray' => true
  504. ) );
  505. foreach ( $verifyDetail as $key => $value ) {
  506. array_push ( $vidList, $value ['vid'] );
  507. }
  508. $vid = implode ( ",", $vidList );
  509. if (empty ( $verifyDetail ))
  510. $vid = 0;
  511. $categoryList = $Lcategory->find ( array (
  512. 'asArray' => true
  513. ) );
  514. $staffList = $staff->find ( array (
  515. 'where' => 'cid=' . $cid,
  516. 'asArray' => true
  517. ) );
  518. $ap = "";
  519. if ($status == 4) {
  520. $ap = 4;
  521. $status = 2;
  522. }
  523. // get Receipt By verifyID status 2
  524. $receiptList = $receipt->find ( array (
  525. 'where' => 'rid =' . $rid . ' and status=2',
  526. 'desc' => 'rid',
  527. 'asArray' => true
  528. ) );
  529. if (empty ( $receiptList )) {
  530. die ( 'illegal request' );
  531. }
  532. $Locate = 0;
  533. $roleId = 0;
  534. if ($ap == 4)
  535. $status = 4;
  536. foreach ( $receiptList as $key => $value ) {
  537. $receiptList [$key] ['Locate'] = $Locate;
  538. $Locate ++;
  539. $receiptList [$key] ['reviseDetail'] = array ();
  540. if (! empty ( $value ['reviseDetail'] ))
  541. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  542. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  543. $categoryDetil = $Lcategory->getOne ( array (
  544. 'where' => 'cid=' . $value ['cid'],
  545. 'asArray' => true
  546. ) );
  547. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  548. // 检测编辑状态
  549. $verifyList = $verify->getOne ( array (
  550. 'where' => 'vid=' . $value ['verify'],
  551. 'asArray' => true
  552. ) );
  553. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  554. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  555. Doo::loadModel ( 'role' );
  556. $role = new role ();
  557. // print_r($verifyList);
  558. $flag = true;
  559. $roleKey = 0;
  560. $endStaffArray = array ();
  561. $roleArrayCopy = array ();
  562. foreach ( $verifyList as $k => $v ) {
  563. // init verifyStaff
  564. if ($v [1] == 'ROLE') {
  565. if (! empty ( $verifyStaff )) {
  566. $endStaffArray = end ( $verifyStaff );
  567. if ($v [0] == $endStaffArray ['nextStaff']) {
  568. $roleId = $v [0];
  569. }
  570. }
  571. $roleVerify = json_decode ( $v [3], true );
  572. $roleKey = $k;
  573. $roleArray = array ();
  574. $rolename = $role->getOne ( array (
  575. 'where' => 'rid=' . $v [0],
  576. 'asArray' => true
  577. ) );
  578. foreach ( $roleVerify as $o => $p ) {
  579. $staffID = explode ( '_', $p );
  580. $staffInfo = $staff->getOne ( array (
  581. 'where' => 'sid=' . $staffID [0],
  582. 'asArray' => true
  583. ) );
  584. // print_r($staffID);
  585. $exp = array (
  586. 0 => $staffInfo ['sid'],
  587. 1 => $staffID [1],
  588. 2 => $staffInfo ['avatar'],
  589. 'date' => '',
  590. 'date' => '',
  591. 'opinion' => '',
  592. 'status' => '',
  593. 'rolename' => $rolename ['name']
  594. );
  595. array_push ( $roleArray, $exp );
  596. }
  597. $roleArrayCopy [$v [0]] = $roleArray;
  598. // $verifyList[$k]['roleArray']=$roleArray;
  599. }
  600. // print_r($roleArray);
  601. $verifyList [$k] ['date'] = "";
  602. $verifyList [$k] ['opinion'] = "";
  603. $verifyList [$k] ['status'] = "";
  604. if (empty ( $verifyStaff )) {
  605. $verifyList [$k] ['date'] = "";
  606. $verifyList [$k] ['opinion'] = "";
  607. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  608. $verifyList [$k] ['status'] = 4;
  609. $button = 4;
  610. $flag = false;
  611. }
  612. } else {
  613. foreach ( $verifyStaff as $m => $u ) {
  614. if ($v [0] == $m) {
  615. $verifyList [$k] ['date'] = $u ['date'];
  616. $verifyList [$k] ['opinion'] = $u ['opinion'];
  617. $verifyList [$k] ['status'] = $u ['status'];
  618. $flag = false;
  619. break;
  620. }
  621. }
  622. $endStaffArray = end ( $verifyStaff );
  623. if (isset ( $endStaffArray ['ROLE'] )) {
  624. } else {
  625. $endKey = key ( $verifyStaff );
  626. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  627. $button = 4;
  628. $verifyList [$k] ['status'] = 4;
  629. }
  630. }
  631. }
  632. }
  633. $rolename ['name'] = '';
  634. if (! empty ( $roleId )) {
  635. Doo::loadModel ( 'role' );
  636. $role = new role ();
  637. $rolename = $role->getOne ( array (
  638. 'where' => 'rid=' . $roleId,
  639. 'asArray' => true
  640. ) );
  641. }
  642. if (! empty ( $verifyStaff ))
  643. $endStaffArray = end ( $verifyStaff );
  644. $KOP = false;
  645. foreach ( $roleArrayCopy as $P => $A ) {
  646. foreach ( $A as $MKI => $AVL ) {
  647. if (! empty ( $verifyStaff )) {
  648. // &&$rolename['rid']==$endStaffArray['nextStaff']
  649. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  650. $button = 4;
  651. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  652. }
  653. foreach ( $verifyStaff as $m => $u ) {
  654. $AVLFK = $AVL [0] . '_R';
  655. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  656. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  657. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  658. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  659. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  660. break;
  661. }
  662. }
  663. } else {
  664. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  665. $button = 4;
  666. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  667. }
  668. }
  669. // $roleArray[$MKI]['rolename']=$rolename['name'];
  670. $KOP = true;
  671. }
  672. }
  673. foreach ( $roleArrayCopy as $k => $v ) {
  674. foreach ( $verifyList as $m => $n ) {
  675. if ($n [0] == $k) {
  676. array_splice ( $verifyList, $m, 1, $v );
  677. }
  678. }
  679. }
  680. $receiptList [$key] ['verifyList'] = $verifyList;
  681. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  682. 'where' => 'sid=' . $value ['staff'],
  683. 'asArray' => true
  684. ) );
  685. $receiptList [$key] ['button'] = $button;
  686. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  687. }
  688. $mothHtml = "";
  689. for($i = 1; $i <= 12; $i ++) {
  690. if ($month == $i)
  691. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  692. else
  693. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  694. }
  695. // 获取审批日志
  696. Doo::loadModel ( 'receiptLog' );
  697. $receiptLog = new receiptLog ();
  698. $rlList = array ();
  699. $rlInfo = $receiptLog->getOne ( array (
  700. 'where' => 'rid=' . $rid . ' and status=4',
  701. 'asArray' => true
  702. ) );
  703. $tijdate = $receiptLog->getOne ( array (
  704. 'where' => 'rid=' . $rid . ' and status=2',
  705. 'asc' => 'rlid',
  706. 'asArray' => true
  707. ) );
  708. if (! empty ( $rlInfo )) {
  709. $rlList = $receiptLog->find ( array (
  710. 'where' => 'rid=' . $rid,
  711. 'asc' => 'rlid',
  712. 'asArray' => true
  713. ) );
  714. }
  715. $receiptList [0] ['rlList'] = $rlList;
  716. $enclosurList = $enclosur->find ( array (
  717. 'where' => 'rid=' . $rid,
  718. 'asArray' => true
  719. ) );
  720. $enclosurHtml = '';
  721. foreach ( $enclosurList as $value ) {
  722. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  723. }
  724. // print_r($receiptList);
  725. $data ['enclosurHtml'] = $enclosurHtml;
  726. $data ['rolename'] = $rolename ['name'];
  727. $data ['datetij'] = $tijdate ['date'];
  728. $data ['mothHtml'] = $mothHtml;
  729. $data ['rid'] = $rid;
  730. $data ['receiptList'] = $receiptList;
  731. $data ['receiptApprovalCount'] = count ( $receiptList );
  732. $data ['status'] = $status;
  733. $data ['year'] = $year;
  734. $data ['categoryList'] = $categoryList;
  735. $data ['staffList'] = $staffList;
  736. $data ['cid'] = $cid;
  737. $data ['sid'] = $sid;
  738. $data ['ap'] = $ap;
  739. $data ['memu'] = "receipt";
  740. $data ['staff'] = $this->staff;
  741. $data ['receiptMemu'] = 'approvalExpenses';
  742. $data ['verifyId'] = $this->verifyId;
  743. $data ['executeId'] = $this->executeId;
  744. $this->render ( "/admin/remitApproval", $data );
  745. }
  746. function saeaLoanAdd() {
  747. Doo::loadModel ( 'verify' );
  748. $verify = new verify ();
  749. Doo::loadModel ( "role" );
  750. $role = new role ();
  751. Doo::loadModel ( 'L_category' );
  752. $lCategory = new L_category ();
  753. $veList = $verify->find ( array (
  754. 'asArray' => true
  755. ) );
  756. foreach ( $veList as $key => $value ) {
  757. $v = json_decode ( $value ['staff'] );
  758. $list = array ();
  759. foreach ( $v as $n => $m ) {
  760. if ($m ['1'] == 'ROLE') {
  761. $roleInfo = $role->getOne ( array (
  762. 'where' => 'rid=' . $m [0],
  763. 'asArray' => true
  764. ) );
  765. $v [$n] [1] = $roleInfo ['name'];
  766. array_push ( $list, $roleInfo ['name'] );
  767. } else {
  768. array_push ( $list, $v [$n] [1] );
  769. }
  770. }
  771. $veList [$key] ['staff'] = implode ( '>', $list );
  772. }
  773. $data ['category'] = $lCategory->find ( array (
  774. 'asArray' => true
  775. ) );
  776. $data ['veList'] = $veList;
  777. $data ['memu'] = "receipt";
  778. $data ['staff'] = $this->staff;
  779. $data ['receiptMemu'] = 'saeaBorad';
  780. $data ['verifyId'] = $this->verifyId;
  781. $data ['executeId'] = $this->executeId;
  782. $this->render ( "/admin/saeaLoanAdd", $data );
  783. }
  784. function saeaLoanAddDo() {
  785. $agency = $this->get_args ( 'agency' );
  786. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  787. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  788. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  789. // die;
  790. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  791. Doo::loadModel ( 'receipt' );
  792. Doo::loadModel ( 'receiptDetail' );
  793. Doo::loadModel ( 'accountItem' );
  794. $accountItem = new accountItem ();
  795. $receipt = new receipt ();
  796. Doo::loadModel ( 'loanReceipt' );
  797. $loanReceipt = new loanReceipt ();
  798. Doo::loadModel ( 'execute' );
  799. $execute = new execute ();
  800. Doo::loadModel ( 'enclosur' );
  801. $executeDetail = $execute->getOne ( array (
  802. 'where' => 'mold="借款执行人"',
  803. 'asArray' => true
  804. ) );
  805. $aItem = $accountItem->find ( array (
  806. 'asArray' => true
  807. ) );
  808. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  809. $ag = $tr = $ta = $ot = 0;
  810. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  811. array_push ( $accountJson ['借款费用'], array (
  812. 'aid' => 0,
  813. 'name' => '申请金额',
  814. 'price' => number_format ( $agency, 2, '.', '' )
  815. ) );
  816. $sum += $agency;
  817. $agencySum += $agency;
  818. $accountJson ['cSum'] = array (
  819. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  820. 'agencySum' => number_format ( 0, 2, '.', '' ),
  821. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  822. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  823. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  824. );
  825. // 借款数据备份
  826. $loanReceipt->loanItem = json_encode ( $accountJson );
  827. $loanReceipt->staff = $this->staff [0] ['sid'];
  828. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  829. $loanReceipt->date = date ( "Y-m-d" );
  830. $loanReceipt->cid = $cid;
  831. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  832. $loanReceipt->status = 5;
  833. $loanReceipt->Rtype = 1;
  834. $loanReceipt->verify = $verify;
  835. $receipt->receiptOrder = $receipt->receiptOrder;
  836. $loanReceipt->explanation = $explanation;
  837. $loanRid = $loanReceipt->insert ();
  838. // 报销单
  839. $receipt->loanItem = json_encode ( $accountJson );
  840. $receipt->staff = $this->staff [0] ['sid'];
  841. $receipt->sum = number_format ( $sum, 2, '.', '' );
  842. $receipt->date = date ( "Y-m-d" );
  843. $receipt->cid = $cid;
  844. // 特殊状态
  845. $receipt->status = 5;
  846. $receipt->Rtype = 1;
  847. $receipt->loanRid = $loanRid;
  848. // 修改审批流程加入角色
  849. $receipt->verify = $verify;
  850. $receipt->executeCopy = $executeDetail ['staff'];
  851. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  852. $receipt->explanation = $explanation;
  853. $rid = $receipt->insert ();
  854. return "/saeaBorad";
  855. } else
  856. die ( 'illegal request' );
  857. }
  858. function saeaLoanEdi() {
  859. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  860. Doo::loadModel ( 'verify' );
  861. $verify = new verify ();
  862. Doo::loadModel ( "role" );
  863. $role = new role ();
  864. Doo::loadModel ( 'L_category' );
  865. $lCategory = new L_category ();
  866. Doo::loadModel ( 'receipt' );
  867. $receipt = new receipt ();
  868. $receiptInfo = $receipt->getOne ( array (
  869. 'where' => 'rid=' . $rid,
  870. 'asArray' => true
  871. ) );
  872. $veList = $verify->find ( array (
  873. 'asArray' => true
  874. ) );
  875. foreach ( $veList as $key => $value ) {
  876. $v = json_decode ( $value ['staff'] );
  877. $list = array ();
  878. foreach ( $v as $n => $m ) {
  879. if ($m ['1'] == 'ROLE') {
  880. $roleInfo = $role->getOne ( array (
  881. 'where' => 'rid=' . $m [0],
  882. 'asArray' => true
  883. ) );
  884. $v [$n] [1] = $roleInfo ['name'];
  885. array_push ( $list, $roleInfo ['name'] );
  886. } else {
  887. array_push ( $list, $v [$n] [1] );
  888. }
  889. }
  890. $veList [$key] ['staff'] = implode ( '>', $list );
  891. }
  892. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  893. $data ['receiptInfo'] = $receiptInfo;
  894. $data ['category'] = $lCategory->find ( array (
  895. 'asArray' => true
  896. ) );
  897. $data ['veList'] = $veList;
  898. $data ['memu'] = "receipt";
  899. $data ['staff'] = $this->staff;
  900. $data ['receiptMemu'] = 'saeaBorad';
  901. $data ['verifyId'] = $this->verifyId;
  902. $data ['executeId'] = $this->executeId;
  903. $this->render ( "/admin/saeaLoanEdi", $data );
  904. }
  905. function saeaLoanEdiDo() {
  906. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  907. $agency = $this->get_args ( 'agency' );
  908. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  909. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  910. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  911. // die;
  912. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )) {
  913. Doo::loadModel ( 'receipt' );
  914. Doo::loadModel ( 'receiptDetail' );
  915. Doo::loadModel ( 'accountItem' );
  916. $accountItem = new accountItem ();
  917. $receipt = new receipt ();
  918. Doo::loadModel ( 'loanReceipt' );
  919. $loanReceipt = new loanReceipt ();
  920. Doo::loadModel ( 'enclosur' );
  921. Doo::loadModel ( 'execute' );
  922. $execute = new execute ();
  923. $executeDetail = $execute->getOne ( array (
  924. 'where' => 'mold="借款执行人"',
  925. 'asArray' => true
  926. ) );
  927. $receiptDetail = $receipt->getOne ( array (
  928. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  929. 'asArray' => true
  930. ) );
  931. if (empty ( $receiptDetail ))
  932. die ( '参数错误' );
  933. $aItem = $accountItem->find ( array (
  934. 'asArray' => true
  935. ) );
  936. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  937. $ag = $tr = $ta = $ot = 0;
  938. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  939. array_push ( $accountJson ['借款费用'], array (
  940. 'aid' => 0,
  941. 'name' => '申请金额',
  942. 'price' => number_format ( $agency, 2, '.', '' )
  943. ) );
  944. $sum += $agency;
  945. $agencySum += $agency;
  946. $accountJson ['cSum'] = array (
  947. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  948. 'agencySum' => number_format ( 0, 2, '.', '' ),
  949. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  950. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  951. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  952. );
  953. // 报销单
  954. $receipt->loanItem = json_encode ( $accountJson );
  955. $receipt->sum = number_format ( $sum, 2, '.', '' );
  956. $receipt->cid = $cid;
  957. // 特殊状态
  958. // 修改审批流程加入角色
  959. if ($receiptDetail ['status'] != 4)
  960. $receipt->verify = $verify;
  961. $receipt->explanation = $explanation;
  962. $receipt->update ( array (
  963. 'where' => 'rid=' . $rid
  964. ) );
  965. // 借款数据更新
  966. $loanReceipt->loanItem = json_encode ( $accountJson );
  967. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  968. $loanReceipt->cid = $cid;
  969. if ($receiptDetail ['status'] != 4)
  970. $loanReceipt->verify = $verify;
  971. $loanReceipt->explanation = $explanation;
  972. $receipt->executeCopy = $executeDetail ['staff'];
  973. $loanReceipt->update ( array (
  974. 'where' => 'rid=' . $receiptDetail ['loanRid']
  975. ) );
  976. }
  977. return "/saeaBorad";
  978. }
  979. function saeaLoanReceiptAdd() {
  980. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  981. Doo::loadModel ( 'receipt' );
  982. $receipt = new receipt ();
  983. Doo::loadModel ( 'loanReceipt' );
  984. $loanReceipt = new loanReceipt ();
  985. Doo::loadModel ( 'L_category' );
  986. $Lcategory = new L_category ();
  987. Doo::loadModel ( 'verify' );
  988. Doo::loadModel ( 'statistics' );
  989. $statistics = new statistics ();
  990. $verify = new verify ();
  991. Doo::loadModel ( 'staff' );
  992. $staff = new staff ();
  993. $receiptDe = $receipt->getOne ( array (
  994. 'where' => 'rid=' . $rid,
  995. 'desc' => 'rid',
  996. 'asArray' => true
  997. ) );
  998. $receiptList = $loanReceipt->find ( array (
  999. 'where' => 'rid=' . $receiptDe ['loanRid'],
  1000. 'desc' => 'rid',
  1001. 'asArray' => true
  1002. ) );
  1003. $Locate = 0;
  1004. $roleId = 0;
  1005. $button = 0;
  1006. foreach ( $receiptList as $key => $value ) {
  1007. $receiptList [$key] ['Locate'] = $Locate;
  1008. $Locate ++;
  1009. $receiptList [$key] ['reviseDetail'] = array ();
  1010. if (! empty ( $value ['reviseDetail'] ))
  1011. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1012. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1013. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1014. $categoryDetil = $Lcategory->getOne ( array (
  1015. 'where' => 'cid=' . $value ['cid'],
  1016. 'asArray' => true
  1017. ) );
  1018. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1019. // 检测编辑状态
  1020. $verifyList = $verify->getOne ( array (
  1021. 'where' => 'vid=' . $value ['verify'],
  1022. 'asArray' => true
  1023. ) );
  1024. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1025. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1026. Doo::loadModel ( 'role' );
  1027. $role = new role ();
  1028. $flag = true;
  1029. $roleKey = 0;
  1030. $endStaffArray = array ();
  1031. $roleArrayCopy = array ();
  1032. foreach ( $verifyList as $k => $v ) {
  1033. // init verifyStaff
  1034. if ($v [1] == 'ROLE') {
  1035. if (! empty ( $verifyStaff )) {
  1036. $endStaffArray = end ( $verifyStaff );
  1037. // if ($v[0]==$endStaffArray['nextStaff']){
  1038. // $roleId=$v[0];
  1039. // }
  1040. }
  1041. $roleVerify = json_decode ( $v [3], true );
  1042. $roleKey = $k;
  1043. $roleArray = array ();
  1044. $rolename = $role->getOne ( array (
  1045. 'where' => 'rid=' . $v [0],
  1046. 'asArray' => true
  1047. ) );
  1048. foreach ( $roleVerify as $o => $p ) {
  1049. $staffID = explode ( '_', $p );
  1050. $staffInfo = $staff->getOne ( array (
  1051. 'where' => 'sid=' . $staffID [0],
  1052. 'asArray' => true
  1053. ) );
  1054. // print_r($staffID);
  1055. $exp = array (
  1056. 0 => $staffInfo ['sid'],
  1057. 1 => $staffID [1],
  1058. 2 => $staffInfo ['avatar'],
  1059. 'date' => '',
  1060. 'date' => '',
  1061. 'opinion' => '',
  1062. 'status' => '',
  1063. 'rolename' => $rolename ['name']
  1064. );
  1065. array_push ( $roleArray, $exp );
  1066. }
  1067. $roleArrayCopy [$v [0]] = $roleArray;
  1068. // $verifyList[$k]['roleArray']=$roleArray;
  1069. }
  1070. $verifyList [$k] ['date'] = "";
  1071. $verifyList [$k] ['opinion'] = "";
  1072. $verifyList [$k] ['status'] = "";
  1073. if (empty ( $verifyStaff )) {
  1074. $verifyList [$k] ['date'] = "";
  1075. $verifyList [$k] ['opinion'] = "";
  1076. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1077. $verifyList [$k] ['status'] = 4;
  1078. $flag = false;
  1079. }
  1080. } else {
  1081. foreach ( $verifyStaff as $m => $u ) {
  1082. if ($v [0] == $m) {
  1083. $verifyList [$k] ['date'] = $u ['date'];
  1084. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1085. $verifyList [$k] ['status'] = $u ['status'];
  1086. $flag = false;
  1087. break;
  1088. }
  1089. }
  1090. $endStaffArray = end ( $verifyStaff );
  1091. if (isset ( $endStaffArray ['ROLE'] )) {
  1092. } else {
  1093. // $endKey=key($verifyStaff);
  1094. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1095. // $button=4;
  1096. // $verifyList[$k]['status']=4;
  1097. // }
  1098. }
  1099. }
  1100. }
  1101. $rolename ['name'] = '';
  1102. if (! empty ( $roleId )) {
  1103. Doo::loadModel ( 'role' );
  1104. $role = new role ();
  1105. $rolename = $role->getOne ( array (
  1106. 'where' => 'rid=' . $roleId,
  1107. 'asArray' => true
  1108. ) );
  1109. }
  1110. if (! empty ( $verifyStaff ))
  1111. $endStaffArray = end ( $verifyStaff );
  1112. $KOP = false;
  1113. foreach ( $roleArrayCopy as $P => $A ) {
  1114. foreach ( $A as $MKI => $AVL ) {
  1115. if (! empty ( $verifyStaff )) {
  1116. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1117. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1118. $button = 4;
  1119. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1120. }
  1121. foreach ( $verifyStaff as $m => $u ) {
  1122. $AVLFK = $AVL [0] . '_R';
  1123. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1124. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1125. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1126. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1127. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1128. break;
  1129. }
  1130. }
  1131. } else {
  1132. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1133. $button = 4;
  1134. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1135. }
  1136. }
  1137. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1138. $KOP = true;
  1139. }
  1140. }
  1141. foreach ( $roleArrayCopy as $k => $v ) {
  1142. foreach ( $verifyList as $m => $n ) {
  1143. if ($n [0] == $k) {
  1144. array_splice ( $verifyList, $m, 1, $v );
  1145. }
  1146. }
  1147. }
  1148. $receiptList [$key] ['verifyList'] = $verifyList;
  1149. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1150. 'where' => 'sid=' . $value ['staff'],
  1151. 'asArray' => true
  1152. ) );
  1153. $receiptList [$key] ['button'] = $button;
  1154. //
  1155. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1156. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1157. }
  1158. $data ['receiptList'] = $receiptList;
  1159. Doo::loadModel ( 'L_category' );
  1160. $lCategory = new L_category ();
  1161. Doo::loadModel ( 'accountItem' );
  1162. $accountItem = new accountItem ();
  1163. $acItem = $accountItem->find ( array (
  1164. 'asArray' => true
  1165. ) );
  1166. $veList = $verify->find ( array (
  1167. 'asArray' => true
  1168. ) );
  1169. foreach ( $veList as $key => $value ) {
  1170. $v = json_decode ( $value ['staff'] );
  1171. $list = array ();
  1172. foreach ( $v as $n => $m ) {
  1173. if ($m ['1'] == 'ROLE') {
  1174. $roleInfo = $role->getOne ( array (
  1175. 'where' => 'rid=' . $m [0],
  1176. 'asArray' => true
  1177. ) );
  1178. $v [$n] [1] = $roleInfo ['name'];
  1179. array_push ( $list, $roleInfo ['name'] );
  1180. } else {
  1181. array_push ( $list, $v [$n] [1] );
  1182. }
  1183. }
  1184. $veList [$key] ['staff'] = implode ( '>', $list );
  1185. }
  1186. $data ['rid'] = $rid;
  1187. $data ['category'] = $lCategory->find ( array (
  1188. 'asArray' => true
  1189. ) );
  1190. $data ['veList'] = $veList;
  1191. $data ['acItem'] = $acItem;
  1192. $data ['memu'] = "receipt";
  1193. $data ['staff'] = $this->staff;
  1194. $data ['receiptMemu'] = 'saeaBorad';
  1195. $data ['verifyId'] = $this->verifyId;
  1196. $data ['executeId'] = $this->executeId;
  1197. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1198. }
  1199. function saeaLoanReceiptAddDo() {
  1200. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1201. $agency = $this->get_args ( 'agency' );
  1202. $travel = $this->get_args ( 'travel' );
  1203. $train = $this->get_args ( 'train' );
  1204. $other = $this->get_args ( 'other' );
  1205. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1206. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1207. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1208. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1209. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )) {
  1210. Doo::loadModel ( 'receipt' );
  1211. Doo::loadModel ( 'receiptDetail' );
  1212. Doo::loadModel ( 'accountItem' );
  1213. $accountItem = new accountItem ();
  1214. $receipt = new receipt ();
  1215. Doo::loadModel ( 'enclosur' );
  1216. Doo::loadModel ( 'execute' );
  1217. $execute = new execute ();
  1218. $executeDetail = $execute->getOne ( array (
  1219. 'where' => 'mold="借款费用执行人"',
  1220. 'asArray' => true
  1221. ) );
  1222. $receiptDet = $receipt->getOne ( array (
  1223. 'where' => 'rid=' . $rid,
  1224. 'asArray' => true
  1225. ) );
  1226. // if(!empty($receiptDetail))
  1227. // return "/referReceipt/".$receiptDetail['rid'];
  1228. $aItem = $accountItem->find ( array (
  1229. 'asArray' => true
  1230. ) );
  1231. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1232. $ag = $tr = $ta = $ot = 0;
  1233. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1234. foreach ( $aItem as $key => $value ) {
  1235. if ($value ['category'] == $this->AGENCY) {
  1236. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1237. array_push ( $accountJson [$this->AGENCY], array (
  1238. 'aid' => $value ['aid'],
  1239. 'name' => $value ['name'],
  1240. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1241. ) );
  1242. $sum += $agency [$ag];
  1243. $agencySum += $agency [$ag];
  1244. }
  1245. $ag ++;
  1246. }
  1247. if ($value ['category'] == $this->TRAVEL) {
  1248. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1249. array_push ( $accountJson [$this->TRAVEL], array (
  1250. 'aid' => $value ['aid'],
  1251. 'name' => $value ['name'],
  1252. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1253. ) );
  1254. $sum += $travel [$tr];
  1255. $travelSum += $travel [$tr];
  1256. }
  1257. $tr ++;
  1258. }
  1259. if ($value ['category'] == $this->TRAIN) {
  1260. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1261. array_push ( $accountJson [$this->TRAIN], array (
  1262. 'aid' => $value ['aid'],
  1263. 'name' => $value ['name'],
  1264. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1265. ) );
  1266. $sum += $train [$ta];
  1267. $trainSum += $train [$ta];
  1268. }
  1269. $ta ++;
  1270. }
  1271. if ($value ['category'] == $this->OTHER) {
  1272. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1273. array_push ( $accountJson [$this->OTHER], array (
  1274. 'aid' => $value ['aid'],
  1275. 'name' => $value ['name'],
  1276. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1277. ) );
  1278. $sum += $other [$ot];
  1279. $otherSum += $other [$ot];
  1280. }
  1281. $ot ++;
  1282. }
  1283. }
  1284. $accountJson ['cSum'] = array (
  1285. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1286. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1287. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1288. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1289. );
  1290. // 报销单
  1291. $receipt->accountItem = json_encode ( $accountJson );
  1292. $receipt->staff = $this->staff [0] ['sid'];
  1293. $receipt->loanSum = $receiptDet ['sum'];
  1294. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1295. $receipt->date = date ( "Y-m-d" );
  1296. $receipt->pastDate = '';
  1297. $receipt->cid = $cid;
  1298. $receipt->status = 7;
  1299. // 修改审批流程加入角色
  1300. $receipt->verify = $verify;
  1301. $receipt->verifyStaff = '';
  1302. $receipt->executeStaff = '';
  1303. $receipt->executeCopy = $executeDetail ['staff'];
  1304. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  1305. $receipt->explanation = $explanation;
  1306. $receipt->update ( array (
  1307. 'where' => 'rid=' . $rid
  1308. ) );
  1309. // 附件
  1310. if (! empty ( $enclosurName )) {
  1311. $enclosurArray = explode ( '-', $enclosurName );
  1312. foreach ( $enclosurArray as $value ) {
  1313. $enclosur = new enclosur ();
  1314. $enclosur->name = $value;
  1315. $enclosur->rid = $rid;
  1316. $enclosur->insert ();
  1317. }
  1318. // print_r($enclosurArray);die;
  1319. }
  1320. // 报销详情
  1321. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1322. $receiptDetail = new receiptDetail ();
  1323. $receiptDetail->staff = $this->staff [0] ['sid'];
  1324. $receiptDetail->item = $value ['name'];
  1325. $receiptDetail->itemCategory = $this->AGENCY;
  1326. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1327. $receiptDetail->date = date ( "Y-m-d" );
  1328. $receiptDetail->cid = $cid;
  1329. $receiptDetail->rid = $rid;
  1330. $receiptDetail->status = 4;
  1331. $receiptDetail->insert ();
  1332. }
  1333. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1334. $receiptDetail = new receiptDetail ();
  1335. $receiptDetail->staff = $this->staff [0] ['sid'];
  1336. $receiptDetail->item = $value ['name'];
  1337. $receiptDetail->itemCategory = $this->TRAVEL;
  1338. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1339. $receiptDetail->date = date ( "Y-m-d" );
  1340. $receiptDetail->cid = $cid;
  1341. $receiptDetail->rid = $rid;
  1342. $receiptDetail->status = 4;
  1343. $receiptDetail->insert ();
  1344. }
  1345. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1346. $receiptDetail = new receiptDetail ();
  1347. $receiptDetail->staff = $this->staff [0] ['sid'];
  1348. $receiptDetail->item = $value ['name'];
  1349. $receiptDetail->itemCategory = $this->TRAIN;
  1350. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1351. $receiptDetail->date = date ( "Y-m-d" );
  1352. $receiptDetail->cid = $cid;
  1353. $receiptDetail->rid = $rid;
  1354. $receiptDetail->status = 4;
  1355. $receiptDetail->insert ();
  1356. }
  1357. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1358. $receiptDetail = new receiptDetail ();
  1359. $receiptDetail->staff = $this->staff [0] ['sid'];
  1360. $receiptDetail->item = $value ['name'];
  1361. $receiptDetail->itemCategory = $this->OTHER;
  1362. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1363. $receiptDetail->date = date ( "Y-m-d" );
  1364. $receiptDetail->cid = $cid;
  1365. $receiptDetail->rid = $rid;
  1366. $receiptDetail->status = 4;
  1367. $receiptDetail->insert ();
  1368. }
  1369. return "/saeaBorad";
  1370. }
  1371. return "/saeaLoanReceiptAdd/" . $rid;
  1372. }
  1373. function saeaLoanReceiptEdi() {
  1374. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1375. // echo $rid;
  1376. Doo::loadModel ( 'accountItem' );
  1377. Doo::loadModel ( 'verify' );
  1378. Doo::loadModel ( 'receipt' );
  1379. $receipt = new receipt ();
  1380. $verify = new verify ();
  1381. $accountItem = new accountItem ();
  1382. Doo::loadModel ( 'L_category' );
  1383. $Lcategory = new L_category ();
  1384. Doo::loadModel ( "role" );
  1385. $role = new role ();
  1386. Doo::loadModel ( 'loanReceipt' );
  1387. $loanReceipt = new loanReceipt ();
  1388. Doo::loadModel ( 'staff' );
  1389. $staff = new staff ();
  1390. $receiptDetail = $receipt->getOne ( array (
  1391. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  1392. 'asArray' => true
  1393. ) );
  1394. if (empty ( $receiptDetail ))
  1395. return "/saeaBorad";
  1396. $receiptList = $loanReceipt->find ( array (
  1397. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1398. 'desc' => 'rid',
  1399. 'asArray' => true
  1400. ) );
  1401. $Locate = 0;
  1402. $roleId = 0;
  1403. $button = 0;
  1404. foreach ( $receiptList as $key => $value ) {
  1405. $receiptList [$key] ['Locate'] = $Locate;
  1406. $Locate ++;
  1407. $receiptList [$key] ['reviseDetail'] = array ();
  1408. if (! empty ( $value ['reviseDetail'] ))
  1409. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1410. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1411. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1412. $categoryDetil = $Lcategory->getOne ( array (
  1413. 'where' => 'cid=' . $value ['cid'],
  1414. 'asArray' => true
  1415. ) );
  1416. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1417. // 检测编辑状态
  1418. $verifyList = $verify->getOne ( array (
  1419. 'where' => 'vid=' . $value ['verify'],
  1420. 'asArray' => true
  1421. ) );
  1422. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1423. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1424. Doo::loadModel ( 'role' );
  1425. $role = new role ();
  1426. $flag = true;
  1427. $roleKey = 0;
  1428. $endStaffArray = array ();
  1429. $roleArrayCopy = array ();
  1430. foreach ( $verifyList as $k => $v ) {
  1431. // init verifyStaff
  1432. if ($v [1] == 'ROLE') {
  1433. if (! empty ( $verifyStaff )) {
  1434. $endStaffArray = end ( $verifyStaff );
  1435. // if ($v[0]==$endStaffArray['nextStaff']){
  1436. // $roleId=$v[0];
  1437. // }
  1438. }
  1439. $roleVerify = json_decode ( $v [3], true );
  1440. $roleKey = $k;
  1441. $roleArray = array ();
  1442. $rolename = $role->getOne ( array (
  1443. 'where' => 'rid=' . $v [0],
  1444. 'asArray' => true
  1445. ) );
  1446. foreach ( $roleVerify as $o => $p ) {
  1447. $staffID = explode ( '_', $p );
  1448. $staffInfo = $staff->getOne ( array (
  1449. 'where' => 'sid=' . $staffID [0],
  1450. 'asArray' => true
  1451. ) );
  1452. // print_r($staffID);
  1453. $exp = array (
  1454. 0 => $staffInfo ['sid'],
  1455. 1 => $staffID [1],
  1456. 2 => $staffInfo ['avatar'],
  1457. 'date' => '',
  1458. 'date' => '',
  1459. 'opinion' => '',
  1460. 'status' => '',
  1461. 'rolename' => $rolename ['name']
  1462. );
  1463. array_push ( $roleArray, $exp );
  1464. }
  1465. $roleArrayCopy [$v [0]] = $roleArray;
  1466. // $verifyList[$k]['roleArray']=$roleArray;
  1467. }
  1468. $verifyList [$k] ['date'] = "";
  1469. $verifyList [$k] ['opinion'] = "";
  1470. $verifyList [$k] ['status'] = "";
  1471. if (empty ( $verifyStaff )) {
  1472. $verifyList [$k] ['date'] = "";
  1473. $verifyList [$k] ['opinion'] = "";
  1474. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1475. $verifyList [$k] ['status'] = 4;
  1476. $flag = false;
  1477. }
  1478. } else {
  1479. foreach ( $verifyStaff as $m => $u ) {
  1480. if ($v [0] == $m) {
  1481. $verifyList [$k] ['date'] = $u ['date'];
  1482. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1483. $verifyList [$k] ['status'] = $u ['status'];
  1484. $flag = false;
  1485. break;
  1486. }
  1487. }
  1488. $endStaffArray = end ( $verifyStaff );
  1489. if (isset ( $endStaffArray ['ROLE'] )) {
  1490. } else {
  1491. // $endKey=key($verifyStaff);
  1492. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1493. // $button=4;
  1494. // $verifyList[$k]['status']=4;
  1495. // }
  1496. }
  1497. }
  1498. }
  1499. $rolename ['name'] = '';
  1500. if (! empty ( $roleId )) {
  1501. Doo::loadModel ( 'role' );
  1502. $role = new role ();
  1503. $rolename = $role->getOne ( array (
  1504. 'where' => 'rid=' . $roleId,
  1505. 'asArray' => true
  1506. ) );
  1507. }
  1508. if (! empty ( $verifyStaff ))
  1509. $endStaffArray = end ( $verifyStaff );
  1510. $KOP = false;
  1511. foreach ( $roleArrayCopy as $P => $A ) {
  1512. foreach ( $A as $MKI => $AVL ) {
  1513. if (! empty ( $verifyStaff )) {
  1514. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1515. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1516. $button = 4;
  1517. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1518. }
  1519. foreach ( $verifyStaff as $m => $u ) {
  1520. $AVLFK = $AVL [0] . '_R';
  1521. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1522. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1523. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1524. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1525. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1526. break;
  1527. }
  1528. }
  1529. } else {
  1530. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1531. $button = 4;
  1532. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1533. }
  1534. }
  1535. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1536. $KOP = true;
  1537. }
  1538. }
  1539. foreach ( $roleArrayCopy as $k => $v ) {
  1540. foreach ( $verifyList as $m => $n ) {
  1541. if ($n [0] == $k) {
  1542. array_splice ( $verifyList, $m, 1, $v );
  1543. }
  1544. }
  1545. }
  1546. $receiptList [$key] ['verifyList'] = $verifyList;
  1547. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1548. 'where' => 'sid=' . $value ['staff'],
  1549. 'asArray' => true
  1550. ) );
  1551. $receiptList [$key] ['button'] = $button;
  1552. //
  1553. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1554. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1555. }
  1556. $data ['receiptList'] = $receiptList;
  1557. $acItem = $accountItem->find ( array (
  1558. 'asArray' => true
  1559. ) );
  1560. $veList = $verify->find ( array (
  1561. 'asArray' => true
  1562. ) );
  1563. foreach ( $veList as $key => $value ) {
  1564. $v = json_decode ( $value ['staff'] );
  1565. $list = array ();
  1566. foreach ( $v as $n => $m ) {
  1567. if ($m ['1'] == 'ROLE') {
  1568. $roleInfo = $role->getOne ( array (
  1569. 'where' => 'rid=' . $m [0],
  1570. 'asArray' => true
  1571. ) );
  1572. $v [$n] [1] = $roleInfo ['name'];
  1573. array_push ( $list, $roleInfo ['name'] );
  1574. } else {
  1575. array_push ( $list, $v [$n] [1] );
  1576. }
  1577. }
  1578. $veList [$key] ['staff'] = implode ( '>', $list );
  1579. }
  1580. // 配置编辑信息
  1581. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1582. foreach ( $acItem as $key => $value ) {
  1583. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1584. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1585. $acItem [$key] ['price'] = $v ['price'];
  1586. }
  1587. }
  1588. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1589. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1590. $acItem [$key] ['price'] = $v ['price'];
  1591. }
  1592. }
  1593. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1594. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1595. $acItem [$key] ['price'] = $v ['price'];
  1596. }
  1597. }
  1598. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1599. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1600. $acItem [$key] ['price'] = $v ['price'];
  1601. }
  1602. }
  1603. }
  1604. $data ['category'] = $Lcategory->find ( array (
  1605. 'asArray' => true
  1606. ) );
  1607. $data ['cSum'] = $accountItemList ['cSum'];
  1608. $data ['sum'] = $receiptDetail ['sum'];
  1609. $data ['receiptDetail'] = $receiptDetail;
  1610. $data ['veList'] = $veList;
  1611. $data ['acItem'] = $acItem;
  1612. $data ['memu'] = "receipt";
  1613. $data ['staff'] = $this->staff;
  1614. $data ['receiptMemu'] = 'saeaBorad';
  1615. $data ['verify'] = $receiptDetail ['verify'];
  1616. $data ['verifyId'] = $this->verifyId;
  1617. $data ['executeId'] = $this->executeId;
  1618. $data ['rid'] = $rid;
  1619. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  1620. }
  1621. function confirmation() {
  1622. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1623. Doo::loadModel ( 'receipt' );
  1624. Doo::loadModel ( 'receiptDetail' );
  1625. $receipt = new receipt ();
  1626. $receiptDetail = new receiptDetail ();
  1627. Doo::loadModel ( 'statistics' );
  1628. Doo::loadModel ( 'itemStatistics' );
  1629. $statistics = new statistics ();
  1630. $itemStatistics = new itemStatistics ();
  1631. Doo::loadModel ( "verify" );
  1632. $verify = new verify ();
  1633. $receiptDetailList = $receipt->getOne ( array (
  1634. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  1635. 'asArray' => true
  1636. ) );
  1637. if (empty ( $receiptDetailList ))
  1638. return "/saeaBorad";
  1639. $verifyDetail = $verify->getOne ( array (
  1640. 'where' => ' vid =' . $receiptDetailList ['verify'],
  1641. 'asArray' => true
  1642. ) );
  1643. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  1644. if (empty ( $receiptDetailList ['nowStaff'] )) {
  1645. $nowStaff = "";
  1646. $nowStaffList = array ();
  1647. if ($verifyDetail [0] [1] == 'ROLE') {
  1648. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  1649. foreach ( $vStaffString as $key => $value ) {
  1650. $staffK = explode ( "_", $value );
  1651. array_push ( $nowStaffList, $staffK [0] );
  1652. }
  1653. $nowStaff = implode ( ',', $nowStaffList );
  1654. } else {
  1655. $nowStaff = $verifyDetail [0] [0];
  1656. }
  1657. $receipt->nowStaff = $nowStaff;
  1658. }
  1659. // echo $nowStaff;
  1660. // print_r($verifyDetail);die;
  1661. $receipt->rid = $receiptDetailList ['rid'];
  1662. $receipt->status = 2;
  1663. $receipt->update ();
  1664. // 操作日志
  1665. Doo::loadModel ( "receiptLog" );
  1666. $receiptLog = new receiptLog ();
  1667. $verify = new verify ();
  1668. $receiptInfo = $receipt->getOne ( array (
  1669. 'where' => 'rid=' . $rid,
  1670. 'asArray' => true
  1671. ) );
  1672. $vr = $verify->getOne ( array (
  1673. 'where' => 'vid=' . $receiptInfo ['verify'],
  1674. 'asArray' => true
  1675. ) );
  1676. $jd = json_decode ( $vr ['staff'] );
  1677. $roleId = 0;
  1678. foreach ( $jd as $key => $value ) {
  1679. if ($value [1] == 'ROLE') {
  1680. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  1681. if ($pos !== false) {
  1682. $roleId = $value [0];
  1683. }
  1684. }
  1685. }
  1686. // 审批日志
  1687. // echo $roleId;die;
  1688. if (! empty ( $roleId )) {
  1689. Doo::loadModel ( "role" );
  1690. $role = new role ();
  1691. $roleInfo = $role->getOne ( array (
  1692. 'where' => 'rid=' . $roleId,
  1693. 'asArray' => true
  1694. ) );
  1695. $receiptLog->rolename = $roleInfo ['name'];
  1696. }
  1697. $receiptLog->username = $this->staff [0] ['username'];
  1698. $receiptLog->uid = $this->staff [0] ['sid'];
  1699. $receiptLog->date = date ( "Y-m-d" );
  1700. $receiptLog->opinion = '提交审批';
  1701. $receiptLog->img = $this->staff [0] ['avatar'];
  1702. $receiptLog->status = 2;
  1703. $receiptLog->rid = $rid;
  1704. $receiptLog->insert ();
  1705. return "/expenses";
  1706. }
  1707. function expenses() {
  1708. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  1709. if (empty ( $item ))
  1710. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  1711. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1712. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  1713. Doo::loadModel ( 'receipt' );
  1714. $receipt = new receipt ();
  1715. Doo::loadModel ( 'L_category' );
  1716. $Lcategory = new L_category ();
  1717. Doo::loadModel ( 'verify' );
  1718. Doo::loadModel ( 'statistics' );
  1719. $statistics = new statistics ();
  1720. $verify = new verify ();
  1721. Doo::loadModel ( 'staff' );
  1722. $staff = new staff ();
  1723. $condition = "";
  1724. if ($item == "expenses")
  1725. $condition = " and Rtype=1 ";
  1726. elseif ($item == "receipts")
  1727. $condition = " and Rtype=0 ";
  1728. elseif ($item == "remits")
  1729. $condition = " and Rtype=2 ";
  1730. $dateCondition = " and Year(date) =" . $year;
  1731. if (! empty ( $moth )) {
  1732. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  1733. $stList = $statistics->getOne ( array (
  1734. 'select' => 'rePrice ,agPrice',
  1735. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  1736. 'asArray' => true
  1737. ) );
  1738. } else
  1739. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  1740. if (empty ( $stList ))
  1741. $stList = array (
  1742. 'rePrice' => 0,
  1743. 'agPrice' => 0
  1744. );
  1745. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  1746. if (! isset ( $noPassSum ['sum'] ))
  1747. $noPassSum ['sum'] = 0;
  1748. $data ['stList'] = array (
  1749. 'rePrice' => $stList ['rePrice'],
  1750. 'agPrice' => $stList ['agPrice'],
  1751. 'skPrice' => ($noPassSum ['sum'])
  1752. );
  1753. $receiptList = $receipt->find ( array (
  1754. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  1755. 'desc' => 'rid',
  1756. 'asArray' => true
  1757. ) );
  1758. $Locate = 0;
  1759. $roleId = 0;
  1760. $button = 0;
  1761. foreach ( $receiptList as $key => $value ) {
  1762. $receiptList [$key] ['Locate'] = $Locate;
  1763. $Locate ++;
  1764. $receiptList [$key] ['reviseDetail'] = array ();
  1765. if (! empty ( $value ['reviseDetail'] ))
  1766. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1767. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1768. $categoryDetil = $Lcategory->getOne ( array (
  1769. 'where' => 'cid=' . $value ['cid'],
  1770. 'asArray' => true
  1771. ) );
  1772. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1773. // 检测编辑状态
  1774. $verifyList = $verify->getOne ( array (
  1775. 'where' => 'vid=' . $value ['verify'],
  1776. 'asArray' => true
  1777. ) );
  1778. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1779. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1780. Doo::loadModel ( 'role' );
  1781. $role = new role ();
  1782. $flag = true;
  1783. $roleKey = 0;
  1784. $endStaffArray = array ();
  1785. $roleArrayCopy = array ();
  1786. foreach ( $verifyList as $k => $v ) {
  1787. // init verifyStaff
  1788. if ($v [1] == 'ROLE') {
  1789. if (! empty ( $verifyStaff )) {
  1790. $endStaffArray = end ( $verifyStaff );
  1791. // if ($v[0]==$endStaffArray['nextStaff']){
  1792. // $roleId=$v[0];
  1793. // }
  1794. }
  1795. $roleVerify = json_decode ( $v [3], true );
  1796. $roleKey = $k;
  1797. $roleArray = array ();
  1798. $rolename = $role->getOne ( array (
  1799. 'where' => 'rid=' . $v [0],
  1800. 'asArray' => true
  1801. ) );
  1802. foreach ( $roleVerify as $o => $p ) {
  1803. $staffID = explode ( '_', $p );
  1804. $staffInfo = $staff->getOne ( array (
  1805. 'where' => 'sid=' . $staffID [0],
  1806. 'asArray' => true
  1807. ) );
  1808. // print_r($staffID);
  1809. $exp = array (
  1810. 0 => $staffInfo ['sid'],
  1811. 1 => $staffID [1],
  1812. 2 => $staffInfo ['avatar'],
  1813. 'date' => '',
  1814. 'date' => '',
  1815. 'opinion' => '',
  1816. 'status' => '',
  1817. 'rolename' => $rolename ['name']
  1818. );
  1819. array_push ( $roleArray, $exp );
  1820. }
  1821. $roleArrayCopy [$v [0]] = $roleArray;
  1822. // $verifyList[$k]['roleArray']=$roleArray;
  1823. }
  1824. $verifyList [$k] ['date'] = "";
  1825. $verifyList [$k] ['opinion'] = "";
  1826. $verifyList [$k] ['status'] = "";
  1827. if (empty ( $verifyStaff )) {
  1828. $verifyList [$k] ['date'] = "";
  1829. $verifyList [$k] ['opinion'] = "";
  1830. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1831. $verifyList [$k] ['status'] = 4;
  1832. $flag = false;
  1833. }
  1834. } else {
  1835. foreach ( $verifyStaff as $m => $u ) {
  1836. if ($v [0] == $m) {
  1837. $verifyList [$k] ['date'] = $u ['date'];
  1838. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1839. $verifyList [$k] ['status'] = $u ['status'];
  1840. $flag = false;
  1841. break;
  1842. }
  1843. }
  1844. $endStaffArray = end ( $verifyStaff );
  1845. if (isset ( $endStaffArray ['ROLE'] )) {
  1846. } else {
  1847. // $endKey=key($verifyStaff);
  1848. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1849. // $button=4;
  1850. // $verifyList[$k]['status']=4;
  1851. // }
  1852. }
  1853. }
  1854. }
  1855. $rolename ['name'] = '';
  1856. if (! empty ( $roleId )) {
  1857. Doo::loadModel ( 'role' );
  1858. $role = new role ();
  1859. $rolename = $role->getOne ( array (
  1860. 'where' => 'rid=' . $roleId,
  1861. 'asArray' => true
  1862. ) );
  1863. }
  1864. if (! empty ( $verifyStaff ))
  1865. $endStaffArray = end ( $verifyStaff );
  1866. $KOP = false;
  1867. foreach ( $roleArrayCopy as $P => $A ) {
  1868. foreach ( $A as $MKI => $AVL ) {
  1869. if (! empty ( $verifyStaff )) {
  1870. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1871. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1872. $button = 4;
  1873. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1874. }
  1875. foreach ( $verifyStaff as $m => $u ) {
  1876. $AVLFK = $AVL [0] . '_R';
  1877. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1878. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1879. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1880. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1881. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1882. break;
  1883. }
  1884. }
  1885. } else {
  1886. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1887. $button = 4;
  1888. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1889. }
  1890. }
  1891. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1892. $KOP = true;
  1893. }
  1894. }
  1895. foreach ( $roleArrayCopy as $k => $v ) {
  1896. foreach ( $verifyList as $m => $n ) {
  1897. if ($n [0] == $k) {
  1898. array_splice ( $verifyList, $m, 1, $v );
  1899. }
  1900. }
  1901. }
  1902. $receiptList [$key] ['verifyList'] = $verifyList;
  1903. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1904. 'where' => 'sid=' . $value ['staff'],
  1905. 'asArray' => true
  1906. ) );
  1907. $receiptList [$key] ['button'] = $button;
  1908. }
  1909. // print_r($receiptList);die;
  1910. $mothHtml = "";
  1911. for($i = 1; $i <= 12; $i ++) {
  1912. if ($moth == $i)
  1913. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  1914. else
  1915. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  1916. }
  1917. $data ['mothHtml'] = $mothHtml;
  1918. $data ['receiptList'] = $receiptList;
  1919. $data ['memu'] = "receipt";
  1920. $data ['staff'] = $this->staff;
  1921. $data ['receiptMemu'] = 'expenses';
  1922. $data ['verifyId'] = $this->verifyId;
  1923. $data ['executeId'] = $this->executeId;
  1924. $data ['item'] = $item;
  1925. $data ['year'] = $year;
  1926. $this->render ( "/admin/expenses", $data );
  1927. }
  1928. function expensesCollect() {
  1929. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1930. Doo::loadModel ( 'receipt' );
  1931. $receipt = new receipt ();
  1932. Doo::loadModel ( 'L_category' );
  1933. $Lcategory = new L_category ();
  1934. Doo::loadModel ( 'verify' );
  1935. Doo::loadModel ( 'statistics' );
  1936. $statistics = new statistics ();
  1937. $verify = new verify ();
  1938. Doo::loadModel ( 'staff' );
  1939. $staff = new staff ();
  1940. Doo::loadModel ( 'loanReceipt' );
  1941. $loanReceipt = new loanReceipt ();
  1942. $receiptList = $receipt->find ( array (
  1943. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  1944. 'desc' => 'rid',
  1945. 'asArray' => true
  1946. ) );
  1947. $loanList = $loanReceipt->find ( array (
  1948. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  1949. 'desc' => 'rid',
  1950. 'asArray' => true
  1951. ) );
  1952. /*
  1953. * $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;
  1954. */
  1955. $Locate = 0;
  1956. $roleId = 0;
  1957. $button = 0;
  1958. foreach ( $receiptList as $key => $value ) {
  1959. $receiptList [$key] ['Locate'] = $Locate;
  1960. $Locate ++;
  1961. $receiptList [$key] ['reviseDetail'] = array ();
  1962. if (! empty ( $value ['reviseDetail'] ))
  1963. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1964. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1965. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1966. $categoryDetil = $Lcategory->getOne ( array (
  1967. 'where' => 'cid=' . $value ['cid'],
  1968. 'asArray' => true
  1969. ) );
  1970. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1971. // 检测编辑状态
  1972. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  1973. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  1974. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  1975. else
  1976. $verifyList ['staff'] = $value ['verifyBreakup'];
  1977. } else
  1978. $verifyList = $verify->getOne ( array (
  1979. 'where' => 'vid=' . $value ['verify'],
  1980. 'asArray' => true
  1981. ) );
  1982. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1983. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1984. Doo::loadModel ( 'role' );
  1985. $role = new role ();
  1986. $flag = true;
  1987. $roleKey = 0;
  1988. $endStaffArray = array ();
  1989. $roleArrayCopy = array ();
  1990. foreach ( $verifyList as $k => $v ) {
  1991. // init verifyStaff
  1992. if ($v [1] == 'ROLE') {
  1993. if (! empty ( $verifyStaff )) {
  1994. $endStaffArray = end ( $verifyStaff );
  1995. // if ($v[0]==$endStaffArray['nextStaff']){
  1996. // $roleId=$v[0];
  1997. // }
  1998. }
  1999. $roleVerify = json_decode ( $v [3], true );
  2000. $roleKey = $k;
  2001. $roleArray = array ();
  2002. $rolename = $role->getOne ( array (
  2003. 'where' => 'rid=' . $v [0],
  2004. 'asArray' => true
  2005. ) );
  2006. foreach ( $roleVerify as $o => $p ) {
  2007. $staffID = explode ( '_', $p );
  2008. $staffInfo = $staff->getOne ( array (
  2009. 'where' => 'sid=' . $staffID [0],
  2010. 'asArray' => true
  2011. ) );
  2012. // print_r($staffID);
  2013. $exp = array (
  2014. 0 => $staffInfo ['sid'],
  2015. 1 => $staffID [1],
  2016. 2 => $staffInfo ['avatar'],
  2017. 'date' => '',
  2018. 'date' => '',
  2019. 'opinion' => '',
  2020. 'status' => '',
  2021. 'rolename' => $rolename ['name']
  2022. );
  2023. array_push ( $roleArray, $exp );
  2024. }
  2025. $roleArrayCopy [$v [0]] = $roleArray;
  2026. // $verifyList[$k]['roleArray']=$roleArray;
  2027. }
  2028. $verifyList [$k] ['date'] = "";
  2029. $verifyList [$k] ['opinion'] = "";
  2030. $verifyList [$k] ['status'] = "";
  2031. if (empty ( $verifyStaff )) {
  2032. $verifyList [$k] ['date'] = "";
  2033. $verifyList [$k] ['opinion'] = "";
  2034. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2035. $verifyList [$k] ['status'] = 4;
  2036. $flag = false;
  2037. }
  2038. } else {
  2039. foreach ( $verifyStaff as $m => $u ) {
  2040. if ($v [0] == $m) {
  2041. $verifyList [$k] ['date'] = $u ['date'];
  2042. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2043. $verifyList [$k] ['status'] = $u ['status'];
  2044. $flag = false;
  2045. break;
  2046. }
  2047. }
  2048. $endStaffArray = end ( $verifyStaff );
  2049. if (isset ( $endStaffArray ['ROLE'] )) {
  2050. } else {
  2051. // $endKey=key($verifyStaff);
  2052. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2053. // $button=4;
  2054. // $verifyList[$k]['status']=4;
  2055. // }
  2056. }
  2057. }
  2058. }
  2059. $rolename ['name'] = '';
  2060. if (! empty ( $roleId )) {
  2061. Doo::loadModel ( 'role' );
  2062. $role = new role ();
  2063. $rolename = $role->getOne ( array (
  2064. 'where' => 'rid=' . $roleId,
  2065. 'asArray' => true
  2066. ) );
  2067. }
  2068. if (! empty ( $verifyStaff ))
  2069. $endStaffArray = end ( $verifyStaff );
  2070. $KOP = false;
  2071. foreach ( $roleArrayCopy as $P => $A ) {
  2072. foreach ( $A as $MKI => $AVL ) {
  2073. if (! empty ( $verifyStaff )) {
  2074. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2075. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2076. $button = 4;
  2077. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2078. }
  2079. foreach ( $verifyStaff as $m => $u ) {
  2080. $AVLFK = $AVL [0] . '_R';
  2081. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2082. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2083. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2084. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2085. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2086. break;
  2087. }
  2088. }
  2089. } else {
  2090. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2091. $button = 4;
  2092. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2093. }
  2094. }
  2095. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2096. $KOP = true;
  2097. }
  2098. }
  2099. foreach ( $roleArrayCopy as $k => $v ) {
  2100. foreach ( $verifyList as $m => $n ) {
  2101. if ($n [0] == $k) {
  2102. array_splice ( $verifyList, $m, 1, $v );
  2103. }
  2104. }
  2105. }
  2106. // 费用执行人相关数据
  2107. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2108. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2109. foreach ( $executeCopy as $k => $v ) {
  2110. $executeCopy [$k] ['date'] = '';
  2111. $executeCopy [$k] ['opinion'] = '';
  2112. $executeCopy [$k] ['status'] = '';
  2113. if (! empty ( $executeStaff ))
  2114. foreach ( $executeStaff as $m => $u ) {
  2115. if ($v [0] == $m) {
  2116. $executeCopy [$k] ['date'] = $u ['date'];
  2117. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2118. $executeCopy [$k] ['status'] = $u ['status'];
  2119. break;
  2120. }
  2121. }
  2122. }
  2123. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2124. $receiptList [$key] ['verifyList'] = $verifyList;
  2125. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2126. 'where' => 'sid=' . $value ['staff'],
  2127. 'asArray' => true
  2128. ) );
  2129. $receiptList [$key] ['button'] = $button;
  2130. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2131. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2132. $relust = $value ['sum'] - $value ['loanSum'];
  2133. $receiptList [$key] ['relust'] = $relust;
  2134. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2135. }
  2136. Doo::loadModel ( 'enclosur' );
  2137. $enclosur = new enclosur ();
  2138. $enclosurList = $enclosur->find ( array (
  2139. 'where' => 'rid=' . $rid,
  2140. 'asArray' => true
  2141. ) );
  2142. $enclosurHtml = '';
  2143. foreach ( $enclosurList as $value ) {
  2144. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2145. }
  2146. $data ['enclosurHtml'] = $enclosurHtml;
  2147. // print_r($receiptList);
  2148. $data ['receiptList'] = $receiptList;
  2149. $data ['memu'] = "receipt";
  2150. $data ['staff'] = $this->staff;
  2151. $data ['receiptMemu'] = 'expenses';
  2152. $data ['verifyId'] = $this->verifyId;
  2153. $data ['executeId'] = $this->executeId;
  2154. $this->render ( "/admin/expensesCollect", $data );
  2155. }
  2156. function approvalExpenses() {
  2157. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  2158. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2159. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2160. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2161. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2162. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  2163. // echo $rdate;
  2164. if (empty ( $status ))
  2165. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  2166. $page_size = 12;
  2167. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2168. $vidList = array ();
  2169. $button = 0;
  2170. Doo::loadModel ( 'verify' );
  2171. $verify = new verify ();
  2172. Doo::loadModel ( 'receipt' );
  2173. $receipt = new receipt ();
  2174. Doo::loadModel ( 'staff' );
  2175. $staff = new staff ();
  2176. Doo::loadModel ( 'L_category' );
  2177. $Lcategory = new L_category ();
  2178. // user verify ID
  2179. $verifyDetail = $verify->find ( array (
  2180. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  2181. 'asArray' => true
  2182. ) );
  2183. foreach ( $verifyDetail as $key => $value ) {
  2184. array_push ( $vidList, $value ['vid'] );
  2185. }
  2186. $vid = implode ( ",", $vidList );
  2187. if (empty ( $verifyDetail ))
  2188. $vid = 0;
  2189. // if ($status==0)
  2190. // $dateCondition="";
  2191. // else
  2192. $dateCondition = " and Year(date) =" . $year;
  2193. /*
  2194. * if (! empty ( $month )) $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month; if($status == 'done'){ $dateCondition = " and Year(pastDate) =" . $year; if (! empty ( $month )) $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month; }
  2195. */
  2196. // date ( 'Y-m' )
  2197. if (! empty ( $rdate ) && $status == 'done')
  2198. $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  2199. elseif (! empty ( $rdate ))
  2200. $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  2201. $categoryList = $Lcategory->find ( array (
  2202. 'asArray' => true
  2203. ) );
  2204. $staffList = $staff->find ( array (
  2205. 'where' => 'cid=' . $cid,
  2206. 'asArray' => true
  2207. ) );
  2208. $cateCondition = "";
  2209. $staffCondition = "";
  2210. $approvalCondition = "";
  2211. if (! empty ( $cid )) {
  2212. $cateCondition = ' and cid=' . $cid;
  2213. }
  2214. if (! empty ( $sid )) {
  2215. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  2216. $cateCondition = "";
  2217. }
  2218. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  2219. if ($status == 'pendApproval') {
  2220. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  2221. }
  2222. if ($status == 'ongoing') {
  2223. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  2224. }
  2225. if ($status == 'done') {
  2226. $approvalCondition = ' and (status=8 or status=9 ) ';
  2227. }
  2228. if ($status == 'termination') {
  2229. $approvalCondition = " and status=3";
  2230. }
  2231. // $approvalCondition = " and status=" . $status;
  2232. // if ($status == 2) {
  2233. // // 查找角色审批人
  2234. // }
  2235. // if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  2236. // $approvalCondition = ' and status=2 ';
  2237. // }
  2238. // if ($status == 1) {
  2239. // $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  2240. // }
  2241. // if ($status == 8) {
  2242. // $approvalCondition = ' and (status=' . $status . ' or status=9 ) ';
  2243. // }
  2244. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  2245. $pageinfo ['page'] = array (
  2246. 'previous' => ''
  2247. );
  2248. // if ($status == 0) {
  2249. // $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  2250. // $receiptList = $receipt->find ( array (
  2251. // 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ')',
  2252. // 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2253. // 'desc' => 'rid',
  2254. // 'asArray' => true
  2255. // ) );
  2256. // //echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2257. // } else
  2258. if ($status == 'done' || $status == 'termination') {//$dateCondition .
  2259. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  2260. $receiptList = $receipt->find ( array (//$dateCondition.
  2261. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
  2262. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2263. 'desc' => 'rid',
  2264. 'asArray' => true
  2265. ) );
  2266. } else
  2267. $receiptList = $receipt->find ( array (//$dateCondition
  2268. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
  2269. 'desc' => 'rid',
  2270. 'asArray' => true
  2271. ) );
  2272. $rLRes = $receipt->find ( array (
  2273. '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,
  2274. 'desc' => 'rid',
  2275. 'asArray' => true
  2276. ) );
  2277. //echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  2278. //print_r($receiptList);
  2279. $Locate = 0;
  2280. $reportList = $reportCateList = array ();
  2281. foreach ( $receiptList as $key => $value ) {
  2282. $receiptList [$key] ['Locate'] = $Locate;
  2283. $Locate ++;
  2284. $receiptList [$key] ['reviseDetail'] = array ();
  2285. if (! empty ( $value ['reviseDetail'] ))
  2286. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2287. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2288. $categoryDetil = $Lcategory->getOne ( array (
  2289. 'where' => 'cid=' . $value ['cid'],
  2290. 'asArray' => true
  2291. ) );
  2292. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2293. $verifyList = $verify->getOne ( array (
  2294. 'where' => 'vid=' . $value ['verify'],
  2295. 'asArray' => true
  2296. ) );
  2297. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2298. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2299. foreach ( $verifyList as $k => $v ) {
  2300. // init verifyStaff
  2301. $verifyList [$k] ['date'] = "";
  2302. $verifyList [$k] ['opinion'] = "";
  2303. $verifyList [$k] ['status'] = "";
  2304. if (empty ( $verifyStaff )) {
  2305. $verifyList [$k] ['date'] = "";
  2306. $verifyList [$k] ['opinion'] = "";
  2307. if ($v [0] == $this->staff [0] ['sid']) {
  2308. $verifyList [$k] ['status'] = 4;
  2309. $button = 4;
  2310. }
  2311. } else {
  2312. $flag = true;
  2313. foreach ( $verifyStaff as $m => $u ) {
  2314. if ($v [0] == $m) {
  2315. $verifyList [$k] ['date'] = $u ['date'];
  2316. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2317. $verifyList [$k] ['status'] = $u ['status'];
  2318. $flag = false;
  2319. break;
  2320. }
  2321. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  2322. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  2323. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  2324. }
  2325. if ($flag) { // 检测可编辑
  2326. if ($v [0] == $this->staff [0] ['sid']) {
  2327. $verifyList [$k] ['status'] = 4;
  2328. $button = 4;
  2329. }
  2330. }
  2331. }
  2332. }
  2333. $receiptList [$key] ['verifyList'] = $verifyList;
  2334. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2335. 'where' => 'sid=' . $value ['staff'],
  2336. 'asArray' => true
  2337. ) );
  2338. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  2339. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  2340. $receiptList [$key] ['button'] = $button;
  2341. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  2342. }
  2343. $reportList = array_unique ( $reportList );
  2344. $reportHtml = '';
  2345. foreach ( $reportList as $key => $value ) {
  2346. $v = explode ( "-", $value );
  2347. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  2348. }
  2349. // print_r($reportList)
  2350. $data ['reportHtml'] = $reportHtml;
  2351. $reportCateList = array_unique ( $reportCateList );
  2352. $reportCateHtml = '';
  2353. foreach ( $reportCateList as $key => $value ) {
  2354. $v = explode ( "-", $value );
  2355. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  2356. }
  2357. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  2358. $data ['reportCateHtml'] = $reportCateHtml;
  2359. // print_r($receiptList);die;
  2360. // $data['verifyDetail']=$verifyDetail;
  2361. $mothHtml = "";
  2362. for($i = 1; $i <= 12; $i ++) {
  2363. if ($month == $i)
  2364. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2365. else
  2366. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2367. }
  2368. $data ['mothHtml'] = $mothHtml;
  2369. $data ['page'] = $pageinfo;
  2370. $data ['receiptList'] = $receiptList;
  2371. $data ['receiptApprovalCount'] = count ( $rLRes );
  2372. $data ['status'] = $status;
  2373. $data ['year'] = $year;
  2374. $data ['categoryList'] = $categoryList;
  2375. $data ['staffList'] = $staffList;
  2376. $data ['cid'] = $cid;
  2377. $data ['sid'] = $sid;
  2378. // print_r($receiptList);
  2379. $data ['memu'] = "receipt";
  2380. $data ['staff'] = $this->staff;
  2381. $data ['receiptMemu'] = 'approvalExpenses';
  2382. $data ['verifyId'] = $this->verifyId;
  2383. $data ['executeId'] = $this->executeId;
  2384. $this->render ( "/admin/approvalExpenses", $data );
  2385. }
  2386. function expensesDoc() {
  2387. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2388. Doo::loadModel ( 'receipt' );
  2389. $receipt = new receipt ();
  2390. Doo::loadModel ( 'L_category' );
  2391. $Lcategory = new L_category ();
  2392. Doo::loadModel ( 'verify' );
  2393. Doo::loadModel ( 'statistics' );
  2394. $statistics = new statistics ();
  2395. $verify = new verify ();
  2396. Doo::loadModel ( 'staff' );
  2397. $staff = new staff ();
  2398. Doo::loadModel ( 'loanReceipt' );
  2399. $loanReceipt = new loanReceipt ();
  2400. $receiptList = $receipt->find ( array (
  2401. 'where' => ' rid=' . $rid,
  2402. 'desc' => 'rid',
  2403. 'asArray' => true
  2404. ) );
  2405. $loanList = array ();
  2406. if (! empty ( $receiptList ))
  2407. $loanList = $loanReceipt->find ( array (
  2408. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2409. 'desc' => 'rid',
  2410. 'asArray' => true
  2411. ) );
  2412. $Locate = 0;
  2413. $roleId = 0;
  2414. $button = 0;
  2415. foreach ( $loanList as $key => $value ) {
  2416. $loanList [$key] ['Locate'] = $Locate;
  2417. $Locate ++;
  2418. $loanList [$key] ['reviseDetail'] = array ();
  2419. if (! empty ( $value ['reviseDetail'] ))
  2420. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2421. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2422. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2423. $categoryDetil = $Lcategory->getOne ( array (
  2424. 'where' => 'cid=' . $value ['cid'],
  2425. 'asArray' => true
  2426. ) );
  2427. $loanList [$key] ['category'] = $categoryDetil ['title'];
  2428. // 检测编辑状态
  2429. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  2430. $verifyList ['staff'] = $value ['verifyBreakup'];
  2431. else
  2432. $verifyList = $verify->getOne ( array (
  2433. 'where' => 'vid=' . $value ['verify'],
  2434. 'asArray' => true
  2435. ) );
  2436. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2437. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2438. Doo::loadModel ( 'role' );
  2439. $role = new role ();
  2440. $flag = true;
  2441. $roleKey = 0;
  2442. $endStaffArray = array ();
  2443. $roleArrayCopy = array ();
  2444. foreach ( $verifyList as $k => $v ) {
  2445. // init verifyStaff
  2446. if ($v [1] == 'ROLE') {
  2447. if (! empty ( $verifyStaff )) {
  2448. $endStaffArray = end ( $verifyStaff );
  2449. // if ($v[0]==$endStaffArray['nextStaff']){
  2450. // $roleId=$v[0];
  2451. // }
  2452. }
  2453. $roleVerify = json_decode ( $v [3], true );
  2454. $roleKey = $k;
  2455. $roleArray = array ();
  2456. $rolename = $role->getOne ( array (
  2457. 'where' => 'rid=' . $v [0],
  2458. 'asArray' => true
  2459. ) );
  2460. foreach ( $roleVerify as $o => $p ) {
  2461. $staffID = explode ( '_', $p );
  2462. $staffInfo = $staff->getOne ( array (
  2463. 'where' => 'sid=' . $staffID [0],
  2464. 'asArray' => true
  2465. ) );
  2466. // print_r($staffID);
  2467. $exp = array (
  2468. 0 => $staffInfo ['sid'],
  2469. 1 => $staffID [1],
  2470. 2 => $staffInfo ['avatar'],
  2471. 'date' => '',
  2472. 'date' => '',
  2473. 'opinion' => '',
  2474. 'status' => '',
  2475. 'rolename' => $rolename ['name']
  2476. );
  2477. array_push ( $roleArray, $exp );
  2478. }
  2479. $roleArrayCopy [$v [0]] = $roleArray;
  2480. // $verifyList[$k]['roleArray']=$roleArray;
  2481. }
  2482. $verifyList [$k] ['date'] = "";
  2483. $verifyList [$k] ['opinion'] = "";
  2484. $verifyList [$k] ['status'] = "";
  2485. if (empty ( $verifyStaff )) {
  2486. $verifyList [$k] ['date'] = "";
  2487. $verifyList [$k] ['opinion'] = "";
  2488. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2489. $verifyList [$k] ['status'] = 4;
  2490. $flag = false;
  2491. }
  2492. } else {
  2493. foreach ( $verifyStaff as $m => $u ) {
  2494. if ($v [0] == $m) {
  2495. $verifyList [$k] ['date'] = $u ['date'];
  2496. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2497. $verifyList [$k] ['status'] = $u ['status'];
  2498. $flag = false;
  2499. break;
  2500. }
  2501. }
  2502. $endStaffArray = end ( $verifyStaff );
  2503. if (isset ( $endStaffArray ['ROLE'] )) {
  2504. } else {
  2505. // $endKey=key($verifyStaff);
  2506. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2507. // $button=4;
  2508. // $verifyList[$k]['status']=4;
  2509. // }
  2510. }
  2511. }
  2512. }
  2513. $rolename ['name'] = '';
  2514. if (! empty ( $roleId )) {
  2515. Doo::loadModel ( 'role' );
  2516. $role = new role ();
  2517. $rolename = $role->getOne ( array (
  2518. 'where' => 'rid=' . $roleId,
  2519. 'asArray' => true
  2520. ) );
  2521. }
  2522. if (! empty ( $verifyStaff ))
  2523. $endStaffArray = end ( $verifyStaff );
  2524. $KOP = false;
  2525. foreach ( $roleArrayCopy as $P => $A ) {
  2526. foreach ( $A as $MKI => $AVL ) {
  2527. if (! empty ( $verifyStaff )) {
  2528. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2529. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2530. $button = 4;
  2531. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2532. }
  2533. foreach ( $verifyStaff as $m => $u ) {
  2534. $AVLFK = $AVL [0] . '_R';
  2535. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2536. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2537. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2538. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2539. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2540. break;
  2541. }
  2542. }
  2543. } else {
  2544. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2545. $button = 4;
  2546. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2547. }
  2548. }
  2549. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2550. $KOP = true;
  2551. }
  2552. }
  2553. foreach ( $roleArrayCopy as $k => $v ) {
  2554. foreach ( $verifyList as $m => $n ) {
  2555. if ($n [0] == $k) {
  2556. array_splice ( $verifyList, $m, 1, $v );
  2557. }
  2558. }
  2559. }
  2560. $loanList [$key] ['verifyList'] = $verifyList;
  2561. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  2562. 'where' => 'sid=' . $value ['staff'],
  2563. 'asArray' => true
  2564. ) );
  2565. $loanList [$key] ['button'] = $button;
  2566. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  2567. }
  2568. $data ['loanList'] = $loanList;
  2569. // print_r($loanList);
  2570. $Locate = 0;
  2571. $roleId = 0;
  2572. $button = 0;
  2573. foreach ( $receiptList as $key => $value ) {
  2574. $receiptList [$key] ['Locate'] = $Locate;
  2575. $Locate ++;
  2576. $receiptList [$key] ['reviseDetail'] = array ();
  2577. if (! empty ( $value ['reviseDetail'] ))
  2578. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2579. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2580. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2581. $categoryDetil = $Lcategory->getOne ( array (
  2582. 'where' => 'cid=' . $value ['cid'],
  2583. 'asArray' => true
  2584. ) );
  2585. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2586. // 检测编辑状态
  2587. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  2588. $verifyList ['staff'] = $value ['verifyBreakup'];
  2589. } else
  2590. $verifyList = $verify->getOne ( array (
  2591. 'where' => 'vid=' . $value ['verify'],
  2592. 'asArray' => true
  2593. ) );
  2594. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2595. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2596. Doo::loadModel ( 'role' );
  2597. $role = new role ();
  2598. if ($verifyList == NULL)
  2599. $verifyList = array ();
  2600. $flag = true;
  2601. $roleKey = 0;
  2602. $endStaffArray = array ();
  2603. $roleArrayCopy = array ();
  2604. foreach ( $verifyList as $k => $v ) {
  2605. // init verifyStaff
  2606. if ($v [1] == 'ROLE') {
  2607. if (! empty ( $verifyStaff )) {
  2608. $endStaffArray = end ( $verifyStaff );
  2609. // if ($v[0]==$endStaffArray['nextStaff']){
  2610. // $roleId=$v[0];
  2611. // }
  2612. }
  2613. $roleVerify = json_decode ( $v [3], true );
  2614. $roleKey = $k;
  2615. $roleArray = array ();
  2616. $rolename = $role->getOne ( array (
  2617. 'where' => 'rid=' . $v [0],
  2618. 'asArray' => true
  2619. ) );
  2620. foreach ( $roleVerify as $o => $p ) {
  2621. $staffID = explode ( '_', $p );
  2622. $staffInfo = $staff->getOne ( array (
  2623. 'where' => 'sid=' . $staffID [0],
  2624. 'asArray' => true
  2625. ) );
  2626. // print_r($staffID);
  2627. $exp = array (
  2628. 0 => $staffInfo ['sid'],
  2629. 1 => $staffID [1],
  2630. 2 => $staffInfo ['avatar'],
  2631. 'date' => '',
  2632. 'date' => '',
  2633. 'opinion' => '',
  2634. 'status' => '',
  2635. 'rolename' => $rolename ['name']
  2636. );
  2637. array_push ( $roleArray, $exp );
  2638. }
  2639. $roleArrayCopy [$v [0]] = $roleArray;
  2640. // $verifyList[$k]['roleArray']=$roleArray;
  2641. }
  2642. $verifyList [$k] ['date'] = "";
  2643. $verifyList [$k] ['opinion'] = "";
  2644. $verifyList [$k] ['status'] = "";
  2645. if (empty ( $verifyStaff )) {
  2646. $verifyList [$k] ['date'] = "";
  2647. $verifyList [$k] ['opinion'] = "";
  2648. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2649. $verifyList [$k] ['status'] = 4;
  2650. $flag = false;
  2651. }
  2652. } else {
  2653. foreach ( $verifyStaff as $m => $u ) {
  2654. if ($v [0] == $m) {
  2655. $verifyList [$k] ['date'] = $u ['date'];
  2656. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2657. $verifyList [$k] ['status'] = $u ['status'];
  2658. $flag = false;
  2659. break;
  2660. }
  2661. }
  2662. $endStaffArray = end ( $verifyStaff );
  2663. if (isset ( $endStaffArray ['ROLE'] )) {
  2664. } else {
  2665. // $endKey=key($verifyStaff);
  2666. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2667. // $button=4;
  2668. // $verifyList[$k]['status']=4;
  2669. // }
  2670. }
  2671. }
  2672. }
  2673. $rolename ['name'] = '';
  2674. if (! empty ( $roleId )) {
  2675. Doo::loadModel ( 'role' );
  2676. $role = new role ();
  2677. $rolename = $role->getOne ( array (
  2678. 'where' => 'rid=' . $roleId,
  2679. 'asArray' => true
  2680. ) );
  2681. }
  2682. if (! empty ( $verifyStaff ))
  2683. $endStaffArray = end ( $verifyStaff );
  2684. $KOP = false;
  2685. foreach ( $roleArrayCopy as $P => $A ) {
  2686. foreach ( $A as $MKI => $AVL ) {
  2687. if (! empty ( $verifyStaff )) {
  2688. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2689. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2690. $button = 4;
  2691. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2692. }
  2693. foreach ( $verifyStaff as $m => $u ) {
  2694. $AVLFK = $AVL [0] . '_R';
  2695. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2696. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2697. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2698. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2699. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2700. break;
  2701. }
  2702. }
  2703. } else {
  2704. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2705. $button = 4;
  2706. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2707. }
  2708. }
  2709. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2710. $KOP = true;
  2711. }
  2712. }
  2713. foreach ( $roleArrayCopy as $k => $v ) {
  2714. foreach ( $verifyList as $m => $n ) {
  2715. if ($n [0] == $k) {
  2716. array_splice ( $verifyList, $m, 1, $v );
  2717. }
  2718. }
  2719. }
  2720. // 费用执行人相关数据
  2721. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2722. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2723. foreach ( $executeCopy as $k => $v ) {
  2724. $executeCopy [$k] ['date'] = '';
  2725. $executeCopy [$k] ['opinion'] = '';
  2726. $executeCopy [$k] ['status'] = '';
  2727. if (! empty ( $executeStaff ))
  2728. foreach ( $executeStaff as $m => $u ) {
  2729. if ($v [0] == $m) {
  2730. $executeCopy [$k] ['date'] = $u ['date'];
  2731. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2732. $executeCopy [$k] ['status'] = $u ['status'];
  2733. break;
  2734. }
  2735. }
  2736. }
  2737. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2738. $receiptList [$key] ['verifyList'] = $verifyList;
  2739. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2740. 'where' => 'sid=' . $value ['staff'],
  2741. 'asArray' => true
  2742. ) );
  2743. $receiptList [$key] ['button'] = $button;
  2744. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2745. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2746. $relust = $value ['sum'] - $value ['loanSum'];
  2747. $receiptList [$key] ['relust'] = $relust;
  2748. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2749. }
  2750. // print_r($receiptList);
  2751. // 获取审批日志
  2752. Doo::loadModel ( 'receiptLog' );
  2753. $receiptLog = new receiptLog ();
  2754. $rlList = array ();
  2755. $rlInfo = $receiptLog->getOne ( array (
  2756. 'where' => 'rid=' . $rid . ' and status=4',
  2757. 'asArray' => true
  2758. ) );
  2759. $tijdate = $receiptLog->getOne ( array (
  2760. 'where' => 'rid=' . $rid . ' and status=2',
  2761. 'asc' => 'rlid',
  2762. 'asArray' => true
  2763. ) );
  2764. if (! empty ( $rlInfo )) {
  2765. $rlList = $receiptLog->find ( array (
  2766. 'where' => 'rid=' . $rid,
  2767. 'asc' => 'rlid',
  2768. 'asArray' => true
  2769. ) );
  2770. }
  2771. Doo::loadModel ( 'enclosur' );
  2772. $enclosur = new enclosur ();
  2773. $enclosurList = $enclosur->find ( array (
  2774. 'where' => 'rid=' . $rid,
  2775. 'asArray' => true
  2776. ) );
  2777. $enclosurHtml = '';
  2778. foreach ( $enclosurList as $value ) {
  2779. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2780. }
  2781. $data ['enclosurHtml'] = $enclosurHtml;
  2782. $receiptList [0] ['rlList'] = $rlList;
  2783. $data ['receiptList'] = $receiptList;
  2784. $data ['memu'] = "receipt";
  2785. $data ['staff'] = $this->staff;
  2786. $data ['receiptMemu'] = 'approvalExpenses';
  2787. $data ['verifyId'] = $this->verifyId;
  2788. $data ['executeId'] = $this->executeId;
  2789. $this->render ( "/admin/expensesDoc", $data );
  2790. }
  2791. function expensesEdi() {
  2792. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2793. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  2794. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2795. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2796. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2797. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2798. if (empty ( $status ))
  2799. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  2800. $vidList = array ();
  2801. $button = 0;
  2802. Doo::loadModel ( 'verify' );
  2803. Doo::loadModel ( 'receipt' );
  2804. Doo::loadModel ( 'staff' );
  2805. $staff = new staff ();
  2806. $receipt = new receipt ();
  2807. $verify = new verify ();
  2808. Doo::loadModel ( 'L_category' );
  2809. $Lcategory = new L_category ();
  2810. Doo::loadModel ( 'enclosur' );
  2811. $enclosur = new enclosur ();
  2812. // user verify ID
  2813. $verifyDetail = $verify->find ( array (
  2814. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  2815. 'asArray' => true
  2816. ) );
  2817. foreach ( $verifyDetail as $key => $value ) {
  2818. array_push ( $vidList, $value ['vid'] );
  2819. }
  2820. $vid = implode ( ",", $vidList );
  2821. if (empty ( $verifyDetail ))
  2822. $vid = 0;
  2823. $categoryList = $Lcategory->find ( array (
  2824. 'asArray' => true
  2825. ) );
  2826. $staffList = $staff->find ( array (
  2827. 'where' => 'cid=' . $cid,
  2828. 'asArray' => true
  2829. ) );
  2830. $ap = "";
  2831. if ($status == 4) {
  2832. $ap = 4;
  2833. $status = 2;
  2834. }
  2835. // get Receipt By verifyID status 2
  2836. $receiptList = $receipt->find ( array (
  2837. 'where' => 'rid =' . $rid . ' and status=2',
  2838. 'desc' => 'rid',
  2839. 'asArray' => true
  2840. ) );
  2841. if (empty ( $receiptList )) {
  2842. die ( 'illegal request' );
  2843. }
  2844. $Locate = 0;
  2845. $roleId = 0;
  2846. if ($ap == 4)
  2847. $status = 4;
  2848. foreach ( $receiptList as $key => $value ) {
  2849. $receiptList [$key] ['Locate'] = $Locate;
  2850. $Locate ++;
  2851. $receiptList [$key] ['reviseDetail'] = array ();
  2852. if (! empty ( $value ['reviseDetail'] ))
  2853. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2854. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2855. $categoryDetil = $Lcategory->getOne ( array (
  2856. 'where' => 'cid=' . $value ['cid'],
  2857. 'asArray' => true
  2858. ) );
  2859. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2860. // 检测编辑状态
  2861. $verifyList = $verify->getOne ( array (
  2862. 'where' => 'vid=' . $value ['verify'],
  2863. 'asArray' => true
  2864. ) );
  2865. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2866. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2867. Doo::loadModel ( 'role' );
  2868. $role = new role ();
  2869. // print_r($verifyList);
  2870. $flag = true;
  2871. $roleKey = 0;
  2872. $endStaffArray = array ();
  2873. $roleArrayCopy = array ();
  2874. foreach ( $verifyList as $k => $v ) {
  2875. // init verifyStaff
  2876. if ($v [1] == 'ROLE') {
  2877. if (! empty ( $verifyStaff )) {
  2878. $endStaffArray = end ( $verifyStaff );
  2879. if ($v [0] == $endStaffArray ['nextStaff']) {
  2880. $roleId = $v [0];
  2881. }
  2882. }
  2883. $roleVerify = json_decode ( $v [3], true );
  2884. $roleKey = $k;
  2885. $roleArray = array ();
  2886. $rolename = $role->getOne ( array (
  2887. 'where' => 'rid=' . $v [0],
  2888. 'asArray' => true
  2889. ) );
  2890. foreach ( $roleVerify as $o => $p ) {
  2891. $staffID = explode ( '_', $p );
  2892. $staffInfo = $staff->getOne ( array (
  2893. 'where' => 'sid=' . $staffID [0],
  2894. 'asArray' => true
  2895. ) );
  2896. // print_r($staffID);
  2897. $exp = array (
  2898. 0 => $staffInfo ['sid'],
  2899. 1 => $staffID [1],
  2900. 2 => $staffInfo ['avatar'],
  2901. 'date' => '',
  2902. 'date' => '',
  2903. 'opinion' => '',
  2904. 'status' => '',
  2905. 'rolename' => $rolename ['name']
  2906. );
  2907. array_push ( $roleArray, $exp );
  2908. }
  2909. $roleArrayCopy [$v [0]] = $roleArray;
  2910. // $verifyList[$k]['roleArray']=$roleArray;
  2911. }
  2912. // print_r($roleArray);
  2913. $verifyList [$k] ['date'] = "";
  2914. $verifyList [$k] ['opinion'] = "";
  2915. $verifyList [$k] ['status'] = "";
  2916. if (empty ( $verifyStaff )) {
  2917. $verifyList [$k] ['date'] = "";
  2918. $verifyList [$k] ['opinion'] = "";
  2919. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2920. $verifyList [$k] ['status'] = 4;
  2921. $button = 4;
  2922. $flag = false;
  2923. }
  2924. } else {
  2925. foreach ( $verifyStaff as $m => $u ) {
  2926. if ($v [0] == $m) {
  2927. $verifyList [$k] ['date'] = $u ['date'];
  2928. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2929. $verifyList [$k] ['status'] = $u ['status'];
  2930. $flag = false;
  2931. break;
  2932. }
  2933. }
  2934. $endStaffArray = end ( $verifyStaff );
  2935. if (isset ( $endStaffArray ['ROLE'] )) {
  2936. } else {
  2937. $endKey = key ( $verifyStaff );
  2938. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  2939. $button = 4;
  2940. $verifyList [$k] ['status'] = 4;
  2941. }
  2942. }
  2943. }
  2944. }
  2945. $rolename ['name'] = '';
  2946. if (! empty ( $roleId )) {
  2947. Doo::loadModel ( 'role' );
  2948. $role = new role ();
  2949. $rolename = $role->getOne ( array (
  2950. 'where' => 'rid=' . $roleId,
  2951. 'asArray' => true
  2952. ) );
  2953. }
  2954. if (! empty ( $verifyStaff ))
  2955. $endStaffArray = end ( $verifyStaff );
  2956. $KOP = false;
  2957. foreach ( $roleArrayCopy as $P => $A ) {
  2958. foreach ( $A as $MKI => $AVL ) {
  2959. if (! empty ( $verifyStaff )) {
  2960. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2961. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2962. $button = 4;
  2963. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2964. }
  2965. foreach ( $verifyStaff as $m => $u ) {
  2966. $AVLFK = $AVL [0] . '_R';
  2967. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2968. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2969. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2970. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2971. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2972. break;
  2973. }
  2974. }
  2975. } else {
  2976. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2977. $button = 4;
  2978. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2979. }
  2980. }
  2981. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2982. $KOP = true;
  2983. }
  2984. }
  2985. // print_r($roleArrayCopy);
  2986. // echo $roleKey;
  2987. foreach ( $roleArrayCopy as $k => $v ) {
  2988. foreach ( $verifyList as $m => $n ) {
  2989. if ($n [0] == $k) {
  2990. array_splice ( $verifyList, $m, 1, $v );
  2991. }
  2992. }
  2993. }
  2994. $receiptList [$key] ['verifyList'] = $verifyList;
  2995. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2996. 'where' => 'sid=' . $value ['staff'],
  2997. 'asArray' => true
  2998. ) );
  2999. $receiptList [$key] ['button'] = $button;
  3000. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  3001. }
  3002. // $data['verifyDetail']=$verifyDetail;
  3003. $mothHtml = "";
  3004. for($i = 1; $i <= 12; $i ++) {
  3005. if ($month == $i)
  3006. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3007. else
  3008. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3009. }
  3010. // 获取审批日志
  3011. Doo::loadModel ( 'receiptLog' );
  3012. $receiptLog = new receiptLog ();
  3013. $rlList = array ();
  3014. $rlInfo = $receiptLog->getOne ( array (
  3015. 'where' => 'rid=' . $rid . ' and status=4',
  3016. 'asArray' => true
  3017. ) );
  3018. $tijdate = $receiptLog->getOne ( array (
  3019. 'where' => 'rid=' . $rid . ' and status=2',
  3020. 'asc' => 'rlid',
  3021. 'asArray' => true
  3022. ) );
  3023. if (! empty ( $rlInfo )) {
  3024. $rlList = $receiptLog->find ( array (
  3025. 'where' => 'rid=' . $rid,
  3026. 'asc' => 'rlid',
  3027. 'asArray' => true
  3028. ) );
  3029. }
  3030. $receiptList [0] ['rlList'] = $rlList;
  3031. $enclosurList = $enclosur->find ( array (
  3032. 'where' => 'rid=' . $rid,
  3033. 'asArray' => true
  3034. ) );
  3035. $enclosurHtml = '';
  3036. foreach ( $enclosurList as $value ) {
  3037. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3038. }
  3039. // print_r($receiptList);
  3040. $data ['rid'] = $rid;
  3041. $data ['enclosurHtml'] = $enclosurHtml;
  3042. $data ['rolename'] = $rolename ['name'];
  3043. $data ['datetij'] = $tijdate ['date'];
  3044. $data ['mothHtml'] = $mothHtml;
  3045. $data ['receiptList'] = $receiptList;
  3046. $data ['receiptApprovalCount'] = count ( $receiptList );
  3047. $data ['status'] = $status;
  3048. $data ['year'] = $year;
  3049. $data ['categoryList'] = $categoryList;
  3050. $data ['staffList'] = $staffList;
  3051. $data ['cid'] = $cid;
  3052. $data ['sid'] = $sid;
  3053. $data ['ap'] = $ap;
  3054. $data ['memu'] = "receipt";
  3055. $data ['staff'] = $this->staff;
  3056. $data ['receiptMemu'] = 'approvalExpenses';
  3057. $data ['verifyId'] = $this->verifyId;
  3058. $data ['executeId'] = $this->executeId;
  3059. $this->render ( "/admin/expensesEdi", $data );
  3060. }
  3061. function expensesDefray() {
  3062. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3063. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3064. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3065. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  3066. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  3067. if (! empty ( $rid )) {
  3068. Doo::loadModel ( "verify" );
  3069. $verify = new verify ();
  3070. Doo::loadModel ( "receiptDetail" );
  3071. $receiptDetailObj = new receiptDetail ();
  3072. Doo::loadModel ( "itemStatistics" );
  3073. Doo::loadModel ( "statistics" );
  3074. $statistics = new statistics ();
  3075. $itemStatistics = new itemStatistics ();
  3076. Doo::loadModel ( "receipt" );
  3077. $receipt = new receipt ();
  3078. Doo::loadModel ( "loanReceipt" );
  3079. $loanReceipt = new loanReceipt ();
  3080. $receiptDetail = $receipt->getOne ( array (
  3081. 'where' => 'rid=' . $rid . ' and status=2 ',
  3082. 'asArray' => true
  3083. ) );
  3084. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  3085. $nsflag = true;
  3086. foreach ( $nslist as $value ) {
  3087. if ($value == $this->staff ['0'] ['sid']) {
  3088. $nsflag = false;
  3089. break;
  3090. }
  3091. }
  3092. // print_r($nslist);die;
  3093. if (empty ( $receiptDetail ) || $nsflag)
  3094. return "/approvalExpenses/pendApproval";
  3095. $verifyDetail = $verify->getOne ( array (
  3096. 'where' => ' vid =' . $receiptDetail ['verify'],
  3097. 'asArray' => true
  3098. ) );
  3099. $verifyString = $verifyDetail ['staff'];
  3100. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3101. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  3102. if (empty ( $opinion )) {
  3103. if ($status == 3)
  3104. $opinion = "终止";
  3105. else
  3106. $opinion = "同意支付";
  3107. }
  3108. $nowStaff = 0;
  3109. $nowStaffList = array ();
  3110. if (empty ( $verifyStaff )) {
  3111. // 还需加入是否已经进入角色审批
  3112. if ($verifyDetail [0] [1] == 'ROLE') {
  3113. // print_r($verifyDetail);echo "ddd";
  3114. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3115. foreach ( $vStaffString as $key => $value ) {
  3116. $staffK = explode ( "_", $value );
  3117. if ($staffK [0] != $this->staff [0] ['sid'])
  3118. array_push ( $nowStaffList, $staffK [0] );
  3119. }
  3120. // print_r($verifyDetail);
  3121. // die;
  3122. if (! empty ( $nowStaffList )) {
  3123. $nowStaff = implode ( ',', $nowStaffList );
  3124. $verifyStaff = array (
  3125. $this->staff [0] ['sid'] . "_R" => array (
  3126. 'date' => date ( 'Y-m-d' ),
  3127. 'opinion' => $opinion,
  3128. 'status' => $status,
  3129. 'nextStaff' => $verifyDetail [0] [0],
  3130. 'ROLE' => 1
  3131. )
  3132. );
  3133. } else {
  3134. $nowStaff = $verifyDetail [1] [0];
  3135. $verifyStaff = array (
  3136. $this->staff [0] ['sid'] . "_R" => array (
  3137. 'date' => date ( 'Y-m-d' ),
  3138. 'opinion' => $opinion,
  3139. 'status' => $status,
  3140. 'nextStaff' => $verifyDetail [1] [0]
  3141. )
  3142. );
  3143. }
  3144. } else {
  3145. if ($verifyDetail [1] [1] == 'ROLE') {
  3146. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  3147. // echo "dd";
  3148. foreach ( $vStaffString as $key => $value ) {
  3149. $staffK = explode ( "_", $value );
  3150. array_push ( $nowStaffList, $staffK [0] );
  3151. }
  3152. $nowStaff = implode ( ',', $nowStaffList );
  3153. $verifyStaff = array (
  3154. $this->staff [0] ['sid'] => array (
  3155. 'date' => date ( 'Y-m-d' ),
  3156. 'opinion' => $opinion,
  3157. 'status' => $status,
  3158. 'nextStaff' => $verifyDetail [1] [0],
  3159. 'ROLE' => 1
  3160. )
  3161. );
  3162. } else {
  3163. $nowStaff = $verifyDetail [1] [0];
  3164. $verifyStaff = array (
  3165. $this->staff [0] ['sid'] => array (
  3166. 'date' => date ( 'Y-m-d' ),
  3167. 'opinion' => $opinion,
  3168. 'status' => $status,
  3169. 'nextStaff' => $verifyDetail [1] [0]
  3170. )
  3171. );
  3172. }
  3173. }
  3174. if ($status == 3)
  3175. $verifyStaff = array (
  3176. 'final' => $status,
  3177. $this->staff [0] ['sid'] => array (
  3178. 'date' => date ( 'Y-m-d' ),
  3179. 'opinion' => $opinion,
  3180. 'status' => $status
  3181. )
  3182. );
  3183. $vStaffString = json_encode ( $verifyStaff );
  3184. $receipt->nowStaff = $nowStaff;
  3185. $receipt->verifyStaff = $vStaffString;
  3186. $loanReceipt->nowStaff = $nowStaff;
  3187. $loanReceipt->verifyStaff = $vStaffString;
  3188. } else {
  3189. $VS = end ( $verifyStaff );
  3190. // 非角色审批
  3191. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  3192. $nextStaff = 0;
  3193. $roleSTF = false;
  3194. foreach ( $verifyDetail as $key => $value ) {
  3195. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  3196. if (isset ( $verifyDetail [$key + 1] )) {
  3197. $nextStaff = $verifyDetail [$key + 1] [0];
  3198. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  3199. $roleSTF = true;
  3200. }
  3201. break;
  3202. }
  3203. }
  3204. if (! $roleSTF) {
  3205. $nowStaff = $nextStaff;
  3206. $verifyStaff [$this->staff [0] ['sid']] = array (
  3207. 'date' => date ( 'Y-m-d' ),
  3208. 'opinion' => $opinion,
  3209. 'status' => $status,
  3210. 'nextStaff' => $nextStaff
  3211. );
  3212. } else {
  3213. // 获取角色下的所有用户ID
  3214. $nowStaffList = array ();
  3215. foreach ( $verifyDetail as $vfk ) {
  3216. if ($vfk [1] == 'ROLE') {
  3217. $vStaffString = json_decode ( $vfk [3] );
  3218. foreach ( $vStaffString as $key => $value ) {
  3219. $staffK = explode ( "_", $value );
  3220. array_push ( $nowStaffList, $staffK [0] );
  3221. }
  3222. }
  3223. }
  3224. $nowStaff = implode ( ',', $nowStaffList );
  3225. $verifyStaff [$this->staff [0] ['sid']] = array (
  3226. 'date' => date ( 'Y-m-d' ),
  3227. 'opinion' => $opinion,
  3228. 'status' => $status,
  3229. 'nextStaff' => $nextStaff,
  3230. 'ROLE' => 0
  3231. );
  3232. }
  3233. if ($status == 3) {
  3234. $verifyStaff ['final'] = $status;
  3235. $verifyStaff [$this->staff [0] ['sid']] = array (
  3236. 'date' => date ( 'Y-m-d' ),
  3237. 'opinion' => $opinion,
  3238. 'status' => $status
  3239. );
  3240. }
  3241. $vStaffString = json_encode ( $verifyStaff );
  3242. $receipt->nowStaff = $nowStaff;
  3243. $receipt->verifyStaff = $vStaffString;
  3244. $loanReceipt->nowStaff = $nowStaff;
  3245. $loanReceipt->verifyStaff = $vStaffString;
  3246. }
  3247. // 角色审批
  3248. if (isset ( $VS ['ROLE'] )) {
  3249. // 找出角色人 当前审批角色组
  3250. $verifyJSStaff = array ();
  3251. $nowStaffList2 = array ();
  3252. foreach ( $verifyDetail as $key => $value ) {
  3253. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  3254. $verifyJSStaff = json_decode ( $value [3] );
  3255. foreach ( $verifyJSStaff as $m ) {
  3256. $staffK = explode ( "_", $m );
  3257. array_push ( $nowStaffList2, $staffK [0] );
  3258. }
  3259. // print_r($nowStaffList2);
  3260. }
  3261. }
  3262. $RoleVerifyStaff = array ();
  3263. foreach ( $verifyStaff as $key => $value ) {
  3264. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  3265. foreach ( $nowStaffList2 as $m ) {
  3266. if ($key == $m . "_R")
  3267. $RoleVerifyStaff [$key] = $value;
  3268. }
  3269. }
  3270. }
  3271. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  3272. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  3273. // 下一个审批人ID
  3274. $nextStaff = 0;
  3275. $falg = false;
  3276. foreach ( $verifyDetail as $key => $value ) {
  3277. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  3278. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  3279. $falg = true;
  3280. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  3281. $nowStaffList = array ();
  3282. foreach ( $vStaffString as $v ) {
  3283. $staffK = explode ( "_", $v );
  3284. array_push ( $nowStaffList, $staffK [0] );
  3285. }
  3286. $nowStaff = implode ( ',', $nowStaffList );
  3287. $nextStaff = $verifyDetail [$key + 1] [0];
  3288. } elseif (isset ( $verifyDetail [$key + 1] )) {
  3289. $nextStaff = $verifyDetail [$key + 1] [0];
  3290. $nowStaff = $nextStaff;
  3291. } else
  3292. $nowStaff = '';
  3293. break;
  3294. }
  3295. }
  3296. if ($falg)
  3297. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3298. 'date' => date ( 'Y-m-d' ),
  3299. 'opinion' => $opinion,
  3300. 'status' => $status,
  3301. 'nextStaff' => $nextStaff,
  3302. 'ROLE' => 1
  3303. );
  3304. else
  3305. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3306. 'date' => date ( 'Y-m-d' ),
  3307. 'opinion' => $opinion,
  3308. 'status' => $status,
  3309. 'nextStaff' => $nextStaff
  3310. );
  3311. // print_r($verifyStaff);
  3312. // echo $nowStaff;die;
  3313. } else { // 进入下一个角色或者审批人
  3314. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  3315. //
  3316. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  3317. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3318. 'date' => date ( 'Y-m-d' ),
  3319. 'opinion' => $opinion,
  3320. 'status' => $status,
  3321. 'nextStaff' => $VS ['nextStaff'],
  3322. 'ROLE' => 1
  3323. );
  3324. // print_r($verifyStaff);
  3325. // die;
  3326. }
  3327. if ($status == 3) {
  3328. $verifyStaff ['final'] = $status;
  3329. $verifyStaff [$this->staff [0] ['sid']] = array (
  3330. 'date' => date ( 'Y-m-d' ),
  3331. 'opinion' => $opinion,
  3332. 'status' => $status
  3333. );
  3334. }
  3335. $vStaffString = json_encode ( $verifyStaff );
  3336. $receipt->verifyStaff = $vStaffString;
  3337. $receipt->nowStaff = $nowStaff;
  3338. $loanReceipt->nowStaff = $nowStaff;
  3339. $loanReceipt->verifyStaff = $vStaffString;
  3340. // die;
  3341. // }
  3342. // print_r($verifyStaff);
  3343. // die;
  3344. }
  3345. // print_r($verifyStaff);die;
  3346. }
  3347. // print_r($verifyDetail);
  3348. $roleKey = 0;
  3349. $roleId = 0;
  3350. $verifyDetailCopy = array ();
  3351. foreach ( $verifyDetail as $k => $v ) {
  3352. if ($v [1] == 'ROLE') {
  3353. $roleId = $v [0];
  3354. $roleVerify = json_decode ( $v [3], true );
  3355. $roleKey = $k;
  3356. $roleArray = array ();
  3357. foreach ( $roleVerify as $o => $p ) {
  3358. $staffID = explode ( '_', $p );
  3359. $exp = array (
  3360. 0 => $staffID [0],
  3361. 1 => $staffID [1]
  3362. );
  3363. array_push ( $roleArray, $exp );
  3364. }
  3365. $verifyDetailCopy [$v [0]] = $roleArray;
  3366. }
  3367. }
  3368. // print_r($verifyDetail);
  3369. foreach ( $verifyDetailCopy as $k => $v ) {
  3370. foreach ( $verifyDetail as $m => $n ) {
  3371. if ($n [0] == $k) {
  3372. array_splice ( $verifyDetail, $m, 1, $v );
  3373. }
  3374. }
  3375. }
  3376. // 审批日志
  3377. if (! isset ( $verifyStaff ['final'] )) {
  3378. Doo::loadModel ( "receiptLog" );
  3379. $receiptLog = new receiptLog ();
  3380. if (! empty ( $roleId )) {
  3381. Doo::loadModel ( "role" );
  3382. $role = new role ();
  3383. $roleInfo = $role->getOne ( array (
  3384. 'where' => 'rid=' . $roleId,
  3385. 'asArray' => true
  3386. ) );
  3387. $receiptLog->rolename = $roleInfo ['name'];
  3388. }
  3389. $receiptLog->username = $this->staff [0] ['username'];
  3390. $receiptLog->uid = $this->staff [0] ['sid'];
  3391. $receiptLog->date = date ( "Y-m-d" );
  3392. $receiptLog->opinion = $opinion;
  3393. $receiptLog->img = $this->staff [0] ['avatar'];
  3394. $receiptLog->status = 1;
  3395. $receiptLog->rid = $rid;
  3396. $receiptLog->insert ();
  3397. }
  3398. if (isset ( $verifyStaff ['final'] )) { // rDetail
  3399. $receipt->status = 3;
  3400. $receipt->verifyBreakup = $verifyString;
  3401. $receiptDetailObj->status = 3;
  3402. $receiptDetailObj->update ( array (
  3403. 'where' => 'rid=' . $rid
  3404. ) );
  3405. // 微信企业号通知
  3406. $this->setWXMsg ( $rid, 3 );
  3407. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  3408. $receipt->status = 6;
  3409. $receipt->pastDate = date ( "Y-m-d" );
  3410. $receipt->isBK = 1;
  3411. $loanReceipt->verifyBreakup = $verifyString;
  3412. $loanReceipt->status = 1;
  3413. $loanReceipt->pastDate = date ( "Y-m-d" );
  3414. $loanReceipt->amount = $receiptDetail ['amount'];
  3415. $loanReceipt->update ( array (
  3416. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  3417. ) );
  3418. // 微信企业号通知
  3419. $this->setWXMsg ( $rid, 1 );
  3420. }
  3421. $receipt->amount = $amount;
  3422. $receipt->update ( array (
  3423. 'where' => ' rid = ' . $rid
  3424. ) );
  3425. // 进入下一条审批费用新加需求
  3426. $vidList = array ();
  3427. $verifyDetail = $verify->find ( array (
  3428. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  3429. 'asArray' => true
  3430. ) );
  3431. foreach ( $verifyDetail as $key => $value ) {
  3432. array_push ( $vidList, $value ['vid'] );
  3433. }
  3434. $vid = implode ( ",", $vidList );
  3435. if (empty ( $verifyDetail ))
  3436. $vid = 0;
  3437. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  3438. $receipt=new receipt();
  3439. $rd = $receipt->getOne ( array (
  3440. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  3441. 'asc' => 'rid',
  3442. 'asArray' => true
  3443. ) );
  3444. if (empty ( $rd )) {
  3445. return '/approvalExpenses/pendApproval';
  3446. }
  3447. if ($rd ['Rtype'] == 1) {
  3448. if ($rd ['isBK'] == 1) {
  3449. return '/receiptburEdi/' . $rd ['rid'];
  3450. } else {
  3451. return '/expensesEdi/' . $rd ['rid'];
  3452. }
  3453. } elseif ($rd ['Rtype'] == 2) {
  3454. return '/remitApproval/' . $rd ['rid'];
  3455. } else {
  3456. return '/receiptburEdi/' . $rd ['rid'];
  3457. }
  3458. // return "/approvalExpenses/pendApproval";
  3459. }
  3460. }
  3461. function ajaxExamineExe() {
  3462. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3463. Doo::loadModel ( 'receipt' );
  3464. $receipt = new receipt ();
  3465. Doo::loadClass ( 'XDeode' );
  3466. $XDeode = new XDeode ( 5 );
  3467. if (! empty ( $rid )) {
  3468. $rLRes = $receipt->find ( array (
  3469. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  3470. 'asArray' => true
  3471. ) );
  3472. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  3473. echo json_encode ( array (
  3474. 'status' => 1,
  3475. 'receipt' => $rLRes [0]
  3476. ) );
  3477. die ();
  3478. }
  3479. echo json_encode ( array (
  3480. 'status' => 0,
  3481. 'receipt' => array ()
  3482. ) );
  3483. die ();
  3484. }
  3485. function implement() {
  3486. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3487. Doo::loadClass ( 'XDeode' );
  3488. $XDeode = new XDeode ( 5 );
  3489. Doo::loadModel ( 'receipt' );
  3490. $receipt = new receipt ();
  3491. Doo::loadModel ( 'L_category' );
  3492. $Lcategory = new L_category ();
  3493. Doo::loadModel ( 'verify' );
  3494. $verify = new verify ();
  3495. Doo::loadModel ( 'staff' );
  3496. $staff = new staff ();
  3497. Doo::loadModel ( "execute" );
  3498. $execute = new execute ();
  3499. $rid = $XDeode->decode ( $rid );
  3500. $receiptList = $receipt->find ( array (
  3501. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  3502. 'desc' => 'rid',
  3503. 'asArray' => true
  3504. ) );
  3505. Doo::loadModel ( 'loanReceipt' );
  3506. $loanReceipt = new loanReceipt ();
  3507. // print_r($receiptList);
  3508. $loanList = array ();
  3509. if (! isset ( $receiptList ))
  3510. $loanList = $loanReceipt->find ( array (
  3511. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3512. 'desc' => 'rid',
  3513. 'asArray' => true
  3514. ) );
  3515. $Locate = 0;
  3516. $roleId = 0;
  3517. $button = 0;
  3518. foreach ( $loanList as $key => $value ) {
  3519. $loanList [$key] ['Locate'] = $Locate;
  3520. $Locate ++;
  3521. $loanList [$key] ['reviseDetail'] = array ();
  3522. if (! empty ( $value ['reviseDetail'] ))
  3523. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3524. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3525. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3526. $categoryDetil = $Lcategory->getOne ( array (
  3527. 'where' => 'cid=' . $value ['cid'],
  3528. 'asArray' => true
  3529. ) );
  3530. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3531. // 检测编辑状态
  3532. $verifyList = $verify->getOne ( array (
  3533. 'where' => 'vid=' . $value ['verify'],
  3534. 'asArray' => true
  3535. ) );
  3536. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3537. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3538. Doo::loadModel ( 'role' );
  3539. $role = new role ();
  3540. $flag = true;
  3541. $roleKey = 0;
  3542. $endStaffArray = array ();
  3543. $roleArrayCopy = array ();
  3544. foreach ( $verifyList as $k => $v ) {
  3545. // init verifyStaff
  3546. if ($v [1] == 'ROLE') {
  3547. if (! empty ( $verifyStaff )) {
  3548. $endStaffArray = end ( $verifyStaff );
  3549. // if ($v[0]==$endStaffArray['nextStaff']){
  3550. // $roleId=$v[0];
  3551. // }
  3552. }
  3553. $roleVerify = json_decode ( $v [3], true );
  3554. $roleKey = $k;
  3555. $roleArray = array ();
  3556. $rolename = $role->getOne ( array (
  3557. 'where' => 'rid=' . $v [0],
  3558. 'asArray' => true
  3559. ) );
  3560. foreach ( $roleVerify as $o => $p ) {
  3561. $staffID = explode ( '_', $p );
  3562. $staffInfo = $staff->getOne ( array (
  3563. 'where' => 'sid=' . $staffID [0],
  3564. 'asArray' => true
  3565. ) );
  3566. // print_r($staffID);
  3567. $exp = array (
  3568. 0 => $staffInfo ['sid'],
  3569. 1 => $staffID [1],
  3570. 2 => $staffInfo ['avatar'],
  3571. 'date' => '',
  3572. 'date' => '',
  3573. 'opinion' => '',
  3574. 'status' => '',
  3575. 'rolename' => $rolename ['name']
  3576. );
  3577. array_push ( $roleArray, $exp );
  3578. }
  3579. $roleArrayCopy [$v [0]] = $roleArray;
  3580. // $verifyList[$k]['roleArray']=$roleArray;
  3581. }
  3582. $verifyList [$k] ['date'] = "";
  3583. $verifyList [$k] ['opinion'] = "";
  3584. $verifyList [$k] ['status'] = "";
  3585. if (empty ( $verifyStaff )) {
  3586. $verifyList [$k] ['date'] = "";
  3587. $verifyList [$k] ['opinion'] = "";
  3588. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3589. $verifyList [$k] ['status'] = 4;
  3590. $flag = false;
  3591. }
  3592. } else {
  3593. foreach ( $verifyStaff as $m => $u ) {
  3594. if ($v [0] == $m) {
  3595. $verifyList [$k] ['date'] = $u ['date'];
  3596. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3597. $verifyList [$k] ['status'] = $u ['status'];
  3598. $flag = false;
  3599. break;
  3600. }
  3601. }
  3602. $endStaffArray = end ( $verifyStaff );
  3603. if (isset ( $endStaffArray ['ROLE'] )) {
  3604. } else {
  3605. // $endKey=key($verifyStaff);
  3606. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3607. // $button=4;
  3608. // $verifyList[$k]['status']=4;
  3609. // }
  3610. }
  3611. }
  3612. }
  3613. $rolename ['name'] = '';
  3614. if (! empty ( $roleId )) {
  3615. Doo::loadModel ( 'role' );
  3616. $role = new role ();
  3617. $rolename = $role->getOne ( array (
  3618. 'where' => 'rid=' . $roleId,
  3619. 'asArray' => true
  3620. ) );
  3621. }
  3622. if (! empty ( $verifyStaff ))
  3623. $endStaffArray = end ( $verifyStaff );
  3624. $KOP = false;
  3625. foreach ( $roleArrayCopy as $P => $A ) {
  3626. foreach ( $A as $MKI => $AVL ) {
  3627. if (! empty ( $verifyStaff )) {
  3628. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3629. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3630. $button = 4;
  3631. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3632. }
  3633. foreach ( $verifyStaff as $m => $u ) {
  3634. $AVLFK = $AVL [0] . '_R';
  3635. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3636. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3637. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3638. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3639. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3640. break;
  3641. }
  3642. }
  3643. } else {
  3644. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3645. $button = 4;
  3646. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3647. }
  3648. }
  3649. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3650. $KOP = true;
  3651. }
  3652. }
  3653. foreach ( $roleArrayCopy as $k => $v ) {
  3654. foreach ( $verifyList as $m => $n ) {
  3655. if ($n [0] == $k) {
  3656. array_splice ( $verifyList, $m, 1, $v );
  3657. }
  3658. }
  3659. }
  3660. $loanList [$key] ['verifyList'] = $verifyList;
  3661. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3662. 'where' => 'sid=' . $value ['staff'],
  3663. 'asArray' => true
  3664. ) );
  3665. }
  3666. $data ['loanList'] = $loanList;
  3667. $Locate = 0;
  3668. $roleId = 0;
  3669. $button = 0;
  3670. foreach ( $receiptList as $key => $value ) {
  3671. $button2 = 0;
  3672. $receiptList [$key] ['Locate'] = $Locate;
  3673. $Locate ++;
  3674. $receiptList [$key] ['reviseDetail'] = array ();
  3675. if (! empty ( $value ['reviseDetail'] ))
  3676. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3677. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3678. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3679. $categoryDetil = $Lcategory->getOne ( array (
  3680. 'where' => 'cid=' . $value ['cid'],
  3681. 'asArray' => true
  3682. ) );
  3683. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3684. $executeList = json_decode ( $value ['executeCopy'], true );
  3685. $executeStaff = array ();
  3686. if (! empty ( $value ['executeStaff'] ))
  3687. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3688. if (isset ( $executeList )) {
  3689. foreach ( $executeList as $op => $lo ) {
  3690. $executeList [$op] ['date'] = "";
  3691. $executeList [$op] ['opinion'] = "";
  3692. $executeList [$op] ['status'] = "";
  3693. foreach ( $executeStaff as $m => $u ) {
  3694. if ($lo [0] == $m) {
  3695. $executeList [$op] ['date'] = $u ['date'];
  3696. $executeList [$op] ['opinion'] = $u ['opinion'];
  3697. $executeList [$op] ['status'] = $u ['status'];
  3698. break;
  3699. }
  3700. }
  3701. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  3702. $button2 = 1;
  3703. $executeList [$op] ['status'] = 4;
  3704. }
  3705. }
  3706. }
  3707. // 检测编辑状态
  3708. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3709. $verifyList ['staff'] = $value ['verifyBreakup'];
  3710. } else
  3711. $verifyList = $verify->getOne ( array (
  3712. 'where' => 'vid=' . $value ['verify'],
  3713. 'asArray' => true
  3714. ) );
  3715. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3716. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3717. Doo::loadModel ( 'role' );
  3718. $role = new role ();
  3719. if ($verifyList == NULL)
  3720. $verifyList = array ();
  3721. $flag = true;
  3722. $roleKey = 0;
  3723. $endStaffArray = array ();
  3724. $roleArrayCopy = array ();
  3725. foreach ( $verifyList as $k => $v ) {
  3726. // init verifyStaff
  3727. if ($v [1] == 'ROLE') {
  3728. if (! empty ( $verifyStaff )) {
  3729. $endStaffArray = end ( $verifyStaff );
  3730. // if ($v[0]==$endStaffArray['nextStaff']){
  3731. // $roleId=$v[0];
  3732. // }
  3733. }
  3734. $roleVerify = json_decode ( $v [3], true );
  3735. $roleKey = $k;
  3736. $roleArray = array ();
  3737. $rolename = $role->getOne ( array (
  3738. 'where' => 'rid=' . $v [0],
  3739. 'asArray' => true
  3740. ) );
  3741. foreach ( $roleVerify as $o => $p ) {
  3742. $staffID = explode ( '_', $p );
  3743. $staffInfo = $staff->getOne ( array (
  3744. 'where' => 'sid=' . $staffID [0],
  3745. 'asArray' => true
  3746. ) );
  3747. // print_r($staffID);
  3748. $exp = array (
  3749. 0 => $staffInfo ['sid'],
  3750. 1 => $staffID [1],
  3751. 2 => $staffInfo ['avatar'],
  3752. 'date' => '',
  3753. 'date' => '',
  3754. 'opinion' => '',
  3755. 'status' => '',
  3756. 'rolename' => $rolename ['name']
  3757. );
  3758. array_push ( $roleArray, $exp );
  3759. }
  3760. $roleArrayCopy [$v [0]] = $roleArray;
  3761. // $verifyList[$k]['roleArray']=$roleArray;
  3762. }
  3763. $verifyList [$k] ['date'] = "";
  3764. $verifyList [$k] ['opinion'] = "";
  3765. $verifyList [$k] ['status'] = "";
  3766. if (empty ( $verifyStaff )) {
  3767. $verifyList [$k] ['date'] = "";
  3768. $verifyList [$k] ['opinion'] = "";
  3769. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3770. $verifyList [$k] ['status'] = 4;
  3771. $flag = false;
  3772. }
  3773. } else {
  3774. foreach ( $verifyStaff as $m => $u ) {
  3775. if ($v [0] == $m) {
  3776. $verifyList [$k] ['date'] = $u ['date'];
  3777. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3778. $verifyList [$k] ['status'] = $u ['status'];
  3779. $flag = false;
  3780. break;
  3781. }
  3782. }
  3783. $endStaffArray = end ( $verifyStaff );
  3784. if (isset ( $endStaffArray ['ROLE'] )) {
  3785. } else {
  3786. // $endKey=key($verifyStaff);
  3787. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3788. // $button=4;
  3789. // $verifyList[$k]['status']=4;
  3790. // }
  3791. }
  3792. }
  3793. }
  3794. $rolename ['name'] = '';
  3795. if (! empty ( $roleId )) {
  3796. Doo::loadModel ( 'role' );
  3797. $role = new role ();
  3798. $rolename = $role->getOne ( array (
  3799. 'where' => 'rid=' . $roleId,
  3800. 'asArray' => true
  3801. ) );
  3802. }
  3803. if (! empty ( $verifyStaff ))
  3804. $endStaffArray = end ( $verifyStaff );
  3805. $KOP = false;
  3806. foreach ( $roleArrayCopy as $P => $A ) {
  3807. foreach ( $A as $MKI => $AVL ) {
  3808. if (! empty ( $verifyStaff )) {
  3809. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3810. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3811. $button = 4;
  3812. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3813. }
  3814. foreach ( $verifyStaff as $m => $u ) {
  3815. $AVLFK = $AVL [0] . '_R';
  3816. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3817. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3818. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3819. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3820. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3821. break;
  3822. }
  3823. }
  3824. } else {
  3825. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3826. $button = 4;
  3827. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3828. }
  3829. }
  3830. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3831. $KOP = true;
  3832. }
  3833. }
  3834. foreach ( $roleArrayCopy as $k => $v ) {
  3835. foreach ( $verifyList as $m => $n ) {
  3836. if ($n [0] == $k) {
  3837. array_splice ( $verifyList, $m, 1, $v );
  3838. }
  3839. }
  3840. }
  3841. $receiptList [$key] ['verifyList'] = $verifyList;
  3842. $receiptList [$key] ['executeList'] = $executeList;
  3843. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3844. 'where' => 'sid=' . $value ['staff'],
  3845. 'asArray' => true
  3846. ) );
  3847. $receiptList [$key] ['button2'] = $button2;
  3848. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3849. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3850. $relust = $value ['sum'] - $value ['loanSum'];
  3851. $receiptList [$key] ['relust'] = $relust;
  3852. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  3853. }
  3854. // print_r($receiptList[$key]['executeList']);
  3855. $data ['receiptList'] = $receiptList;
  3856. $data ['memu'] = "receipt";
  3857. $data ['staff'] = $this->staff;
  3858. $data ['receiptMemu'] = 'implement';
  3859. $data ['verifyId'] = $this->verifyId;
  3860. $data ['executeId'] = $this->executeId;
  3861. $this->render ( "/admin/implement", $data );
  3862. }
  3863. function implementDo() {
  3864. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3865. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3866. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  3867. if (! empty ( $rid ) && $amount != '') {
  3868. Doo::loadModel ( 'receipt' );
  3869. $receipt = new receipt ();
  3870. Doo::loadClass ( 'XDeode' );
  3871. $XDeode = new XDeode ( 5 );
  3872. $rinfo = $receipt->getOne ( array (
  3873. 'where' => 'rid=' . $rid,
  3874. 'asArray' => true
  3875. ) );
  3876. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  3877. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  3878. if (empty ( $executeStaff )) {
  3879. $executeStaff = array (
  3880. $this->staff [0] ['sid'] => array (
  3881. 'date' => date ( 'Y-m-d' ),
  3882. 'opinion' => $implementOpinions,
  3883. 'status' => 1
  3884. )
  3885. );
  3886. } else {
  3887. $executeStaff [$this->staff [0] ['sid']] = array (
  3888. 'date' => date ( 'Y-m-d' ),
  3889. 'opinion' => $implementOpinions,
  3890. 'status' => 1
  3891. );
  3892. }
  3893. if (count ( $executeStaff ) == count ( $executeCopy )) {
  3894. $receipt->executeStaff = json_encode ( $executeStaff );
  3895. $receipt->status = 8;
  3896. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  3897. $receipt->status = 9;
  3898. if ($rinfo ['status'] == 6) {
  3899. $receipt->loanDate = date ( "Y-m-d" );
  3900. }
  3901. $receipt->executeDate = date ( "Y-m-d" );
  3902. } else {
  3903. $receipt->executeStaff = json_encode ( $executeStaff );
  3904. }
  3905. $receipt->amount = $amount;
  3906. $receipt->update ( array (
  3907. 'where' => 'rid=' . $rid
  3908. ) );
  3909. }
  3910. $ridKey = $XDeode->encode ( $rid );
  3911. return "/hisImplement";
  3912. // return "/implement/" . $ridKey . ".html";
  3913. }
  3914. function receiptburEdi() {
  3915. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3916. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  3917. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  3918. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  3919. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3920. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  3921. if (empty ( $status ))
  3922. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  3923. $vidList = array ();
  3924. $button = 0;
  3925. Doo::loadModel ( 'verify' );
  3926. Doo::loadModel ( 'receipt' );
  3927. Doo::loadModel ( 'staff' );
  3928. $staff = new staff ();
  3929. $receipt = new receipt ();
  3930. $verify = new verify ();
  3931. Doo::loadModel ( 'L_category' );
  3932. $Lcategory = new L_category ();
  3933. Doo::loadModel ( 'enclosur' );
  3934. $enclosur = new enclosur ();
  3935. Doo::loadModel ( 'loanReceipt' );
  3936. $loanReceipt = new loanReceipt ();
  3937. // user verify ID
  3938. $verifyDetail = $verify->find ( array (
  3939. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  3940. 'asArray' => true
  3941. ) );
  3942. foreach ( $verifyDetail as $key => $value ) {
  3943. array_push ( $vidList, $value ['vid'] );
  3944. }
  3945. $vid = implode ( ",", $vidList );
  3946. if (empty ( $verifyDetail ))
  3947. $vid = 0;
  3948. $categoryList = $Lcategory->find ( array (
  3949. 'asArray' => true
  3950. ) );
  3951. $staffList = $staff->find ( array (
  3952. 'where' => 'cid=' . $cid,
  3953. 'asArray' => true
  3954. ) );
  3955. $ap = "";
  3956. if ($status == 4) {
  3957. $ap = 4;
  3958. $status = 2;
  3959. }
  3960. // get Receipt By verifyID status 2
  3961. $receiptList = $receipt->find ( array (
  3962. 'where' => 'rid =' . $rid . ' and status=2',
  3963. 'desc' => 'rid',
  3964. 'asArray' => true
  3965. ) );
  3966. if (empty ( $receiptList )) {
  3967. die ( 'illegal request' );
  3968. }
  3969. $loanList = $loanReceipt->find ( array (
  3970. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3971. 'desc' => 'rid',
  3972. 'asArray' => true
  3973. ) );
  3974. $Locate = 0;
  3975. $roleId = 0;
  3976. $button = 0;
  3977. foreach ( $loanList as $key => $value ) {
  3978. $loanList [$key] ['Locate'] = $Locate;
  3979. $Locate ++;
  3980. $loanList [$key] ['reviseDetail'] = array ();
  3981. if (! empty ( $value ['reviseDetail'] ))
  3982. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3983. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3984. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3985. $categoryDetil = $Lcategory->getOne ( array (
  3986. 'where' => 'cid=' . $value ['cid'],
  3987. 'asArray' => true
  3988. ) );
  3989. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3990. // 检测编辑状态
  3991. $verifyList = $verify->getOne ( array (
  3992. 'where' => 'vid=' . $value ['verify'],
  3993. 'asArray' => true
  3994. ) );
  3995. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3996. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3997. Doo::loadModel ( 'role' );
  3998. $role = new role ();
  3999. $flag = true;
  4000. $roleKey = 0;
  4001. $endStaffArray = array ();
  4002. $roleArrayCopy = array ();
  4003. foreach ( $verifyList as $k => $v ) {
  4004. // init verifyStaff
  4005. if ($v [1] == 'ROLE') {
  4006. if (! empty ( $verifyStaff )) {
  4007. $endStaffArray = end ( $verifyStaff );
  4008. }
  4009. $roleVerify = json_decode ( $v [3], true );
  4010. $roleKey = $k;
  4011. $roleArray = array ();
  4012. $rolename = $role->getOne ( array (
  4013. 'where' => 'rid=' . $v [0],
  4014. 'asArray' => true
  4015. ) );
  4016. foreach ( $roleVerify as $o => $p ) {
  4017. $staffID = explode ( '_', $p );
  4018. $staffInfo = $staff->getOne ( array (
  4019. 'where' => 'sid=' . $staffID [0],
  4020. 'asArray' => true
  4021. ) );
  4022. // print_r($staffID);
  4023. $exp = array (
  4024. 0 => $staffInfo ['sid'],
  4025. 1 => $staffID [1],
  4026. 2 => $staffInfo ['avatar'],
  4027. 'date' => '',
  4028. 'date' => '',
  4029. 'opinion' => '',
  4030. 'status' => '',
  4031. 'rolename' => $rolename ['name']
  4032. );
  4033. array_push ( $roleArray, $exp );
  4034. }
  4035. $roleArrayCopy [$v [0]] = $roleArray;
  4036. // $verifyList[$k]['roleArray']=$roleArray;
  4037. }
  4038. $verifyList [$k] ['date'] = "";
  4039. $verifyList [$k] ['opinion'] = "";
  4040. $verifyList [$k] ['status'] = "";
  4041. if (empty ( $verifyStaff )) {
  4042. $verifyList [$k] ['date'] = "";
  4043. $verifyList [$k] ['opinion'] = "";
  4044. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4045. $verifyList [$k] ['status'] = 4;
  4046. $flag = false;
  4047. }
  4048. } else {
  4049. foreach ( $verifyStaff as $m => $u ) {
  4050. if ($v [0] == $m) {
  4051. $verifyList [$k] ['date'] = $u ['date'];
  4052. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4053. $verifyList [$k] ['status'] = $u ['status'];
  4054. $flag = false;
  4055. break;
  4056. }
  4057. }
  4058. $endStaffArray = end ( $verifyStaff );
  4059. if (isset ( $endStaffArray ['ROLE'] )) {
  4060. } else {
  4061. }
  4062. }
  4063. }
  4064. $rolename ['name'] = '';
  4065. if (! empty ( $roleId )) {
  4066. Doo::loadModel ( 'role' );
  4067. $role = new role ();
  4068. $rolename = $role->getOne ( array (
  4069. 'where' => 'rid=' . $roleId,
  4070. 'asArray' => true
  4071. ) );
  4072. }
  4073. if (! empty ( $verifyStaff ))
  4074. $endStaffArray = end ( $verifyStaff );
  4075. $KOP = false;
  4076. foreach ( $roleArrayCopy as $P => $A ) {
  4077. foreach ( $A as $MKI => $AVL ) {
  4078. if (! empty ( $verifyStaff )) {
  4079. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4080. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4081. $button = 4;
  4082. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4083. }
  4084. foreach ( $verifyStaff as $m => $u ) {
  4085. $AVLFK = $AVL [0] . '_R';
  4086. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4087. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4088. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4089. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4090. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4091. break;
  4092. }
  4093. }
  4094. } else {
  4095. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4096. $button = 4;
  4097. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4098. }
  4099. }
  4100. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4101. $KOP = true;
  4102. }
  4103. }
  4104. foreach ( $roleArrayCopy as $k => $v ) {
  4105. foreach ( $verifyList as $m => $n ) {
  4106. if ($n [0] == $k) {
  4107. array_splice ( $verifyList, $m, 1, $v );
  4108. }
  4109. }
  4110. }
  4111. $loanList [$key] ['verifyList'] = $verifyList;
  4112. }
  4113. $htmlLoan = '';
  4114. if (isset ( $loanList [0] )) {
  4115. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  4116. if ($value ['status'] == 1)
  4117. $htmlLoan .= '<li class="done" >';
  4118. elseif ($value ['status'] == 3)
  4119. $htmlLoan .= '<li class="undone" >';
  4120. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  4121. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  4122. if (isset ( $value ['rolename'] ))
  4123. $htmlLoan .= $value ['rolename'];
  4124. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  4125. }
  4126. $data ['loanDate'] = $loanList [0] ['date'];
  4127. }
  4128. $data ['htmlLoan'] = $htmlLoan;
  4129. $data ['loanReceiptDate'] = $loanList [0] ['date'];
  4130. // $data ['LoanReceipt']=$loanList[0];
  4131. // print_r($loanList);
  4132. $Locate = 0;
  4133. $roleId = 0;
  4134. $button = 0;
  4135. if ($ap == 4)
  4136. $status = 4;
  4137. foreach ( $receiptList as $key => $value ) {
  4138. $receiptList [$key] ['Locate'] = $Locate;
  4139. $Locate ++;
  4140. $receiptList [$key] ['reviseDetail'] = array ();
  4141. if (! empty ( $value ['reviseDetail'] ))
  4142. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4143. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4144. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4145. $categoryDetil = $Lcategory->getOne ( array (
  4146. 'where' => 'cid=' . $value ['cid'],
  4147. 'asArray' => true
  4148. ) );
  4149. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4150. // 检测编辑状态
  4151. $verifyList = $verify->getOne ( array (
  4152. 'where' => 'vid=' . $value ['verify'],
  4153. 'asArray' => true
  4154. ) );
  4155. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4156. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4157. Doo::loadModel ( 'role' );
  4158. $role = new role ();
  4159. // print_r($verifyList);
  4160. $flag = true;
  4161. $roleKey = 0;
  4162. $endStaffArray = array ();
  4163. $roleArrayCopy = array ();
  4164. foreach ( $verifyList as $k => $v ) {
  4165. // init verifyStaff
  4166. if ($v [1] == 'ROLE') {
  4167. if (! empty ( $verifyStaff )) {
  4168. $endStaffArray = end ( $verifyStaff );
  4169. if ($v [0] == $endStaffArray ['nextStaff']) {
  4170. $roleId = $v [0];
  4171. }
  4172. }
  4173. $roleVerify = json_decode ( $v [3], true );
  4174. $roleKey = $k;
  4175. $roleArray = array ();
  4176. $rolename = $role->getOne ( array (
  4177. 'where' => 'rid=' . $v [0],
  4178. 'asArray' => true
  4179. ) );
  4180. foreach ( $roleVerify as $o => $p ) {
  4181. $staffID = explode ( '_', $p );
  4182. $staffInfo = $staff->getOne ( array (
  4183. 'where' => 'sid=' . $staffID [0],
  4184. 'asArray' => true
  4185. ) );
  4186. // print_r($staffID);
  4187. $exp = array (
  4188. 0 => $staffInfo ['sid'],
  4189. 1 => $staffID [1],
  4190. 2 => $staffInfo ['avatar'],
  4191. 'date' => '',
  4192. 'date' => '',
  4193. 'opinion' => '',
  4194. 'status' => '',
  4195. 'rolename' => $rolename ['name']
  4196. );
  4197. array_push ( $roleArray, $exp );
  4198. }
  4199. $roleArrayCopy [$v [0]] = $roleArray;
  4200. // $verifyList[$k]['roleArray']=$roleArray;
  4201. }
  4202. // print_r($roleArray);
  4203. $verifyList [$k] ['date'] = "";
  4204. $verifyList [$k] ['opinion'] = "";
  4205. $verifyList [$k] ['status'] = "";
  4206. if (empty ( $verifyStaff )) {
  4207. $verifyList [$k] ['date'] = "";
  4208. $verifyList [$k] ['opinion'] = "";
  4209. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4210. $verifyList [$k] ['status'] = 4;
  4211. $button = 4;
  4212. $flag = false;
  4213. }
  4214. } else {
  4215. foreach ( $verifyStaff as $m => $u ) {
  4216. if ($v [0] == $m) {
  4217. $verifyList [$k] ['date'] = $u ['date'];
  4218. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4219. $verifyList [$k] ['status'] = $u ['status'];
  4220. $flag = false;
  4221. break;
  4222. }
  4223. }
  4224. $endStaffArray = end ( $verifyStaff );
  4225. if (isset ( $endStaffArray ['ROLE'] )) {
  4226. } else {
  4227. $endKey = key ( $verifyStaff );
  4228. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4229. $button = 4;
  4230. $verifyList [$k] ['status'] = 4;
  4231. }
  4232. }
  4233. }
  4234. }
  4235. $rolename ['name'] = '';
  4236. if (! empty ( $roleId )) {
  4237. Doo::loadModel ( 'role' );
  4238. $role = new role ();
  4239. $rolename = $role->getOne ( array (
  4240. 'where' => 'rid=' . $roleId,
  4241. 'asArray' => true
  4242. ) );
  4243. }
  4244. if (! empty ( $verifyStaff ))
  4245. $endStaffArray = end ( $verifyStaff );
  4246. $KOP = false;
  4247. foreach ( $roleArrayCopy as $P => $A ) {
  4248. foreach ( $A as $MKI => $AVL ) {
  4249. if (! empty ( $verifyStaff )) {
  4250. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4251. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4252. $button = 4;
  4253. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4254. }
  4255. foreach ( $verifyStaff as $m => $u ) {
  4256. $AVLFK = $AVL [0] . '_R';
  4257. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4258. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4259. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4260. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4261. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4262. break;
  4263. }
  4264. }
  4265. } else {
  4266. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4267. $button = 4;
  4268. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4269. }
  4270. }
  4271. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4272. $KOP = true;
  4273. }
  4274. }
  4275. foreach ( $roleArrayCopy as $k => $v ) {
  4276. foreach ( $verifyList as $m => $n ) {
  4277. if ($n [0] == $k) {
  4278. array_splice ( $verifyList, $m, 1, $v );
  4279. }
  4280. }
  4281. }
  4282. // print_r($verifyList);
  4283. $receiptList [$key] ['verifyList'] = $verifyList;
  4284. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4285. 'where' => 'sid=' . $value ['staff'],
  4286. 'asArray' => true
  4287. ) );
  4288. $receiptList [$key] ['button'] = $button;
  4289. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4290. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4291. $relust = $value ['sum'] - $value ['loanSum'];
  4292. $receiptList [$key] ['relust'] = $relust;
  4293. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4294. }
  4295. // print_r($receiptList);die;
  4296. // $data['verifyDetail']=$verifyDetail;
  4297. $mothHtml = "";
  4298. for($i = 1; $i <= 12; $i ++) {
  4299. if ($month == $i)
  4300. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4301. else
  4302. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4303. }
  4304. // 获取审批日志
  4305. Doo::loadModel ( 'receiptLog' );
  4306. $receiptLog = new receiptLog ();
  4307. $rlList = array ();
  4308. $rlInfo = $receiptLog->getOne ( array (
  4309. 'where' => 'rid=' . $rid . ' and status=4',
  4310. 'asArray' => true
  4311. ) );
  4312. $tijdate = $receiptLog->getOne ( array (
  4313. 'where' => 'rid=' . $rid . ' and status=2',
  4314. 'asc' => 'rlid',
  4315. 'asArray' => true
  4316. ) );
  4317. if (! empty ( $rlInfo )) {
  4318. $rlList = $receiptLog->find ( array (
  4319. 'where' => 'rid=' . $rid,
  4320. 'asc' => 'rlid',
  4321. 'asArray' => true
  4322. ) );
  4323. }
  4324. // echo $rid;
  4325. // print_r($receiptList);
  4326. $receiptList [0] ['rlList'] = $rlList;
  4327. // print_r($receiptList);
  4328. $enclosurList = $enclosur->find ( array (
  4329. 'where' => 'rid=' . $rid,
  4330. 'asArray' => true
  4331. ) );
  4332. $enclosurHtml = '';
  4333. foreach ( $enclosurList as $value ) {
  4334. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4335. }
  4336. $data ['enclosurHtml'] = $enclosurHtml;
  4337. $data ['rolename'] = $rolename ['name'];
  4338. $data ['mothHtml'] = $mothHtml;
  4339. // print_r($receiptList);
  4340. $data ['rid'] = $rid;
  4341. $data ['tijdate'] = $tijdate ['date'];
  4342. $data ['receiptList'] = $receiptList;
  4343. $data ['receiptApprovalCount'] = count ( $receiptList );
  4344. $data ['status'] = $status;
  4345. $data ['year'] = $year;
  4346. $data ['categoryList'] = $categoryList;
  4347. $data ['staffList'] = $staffList;
  4348. $data ['cid'] = $cid;
  4349. $data ['sid'] = $sid;
  4350. $data ['ap'] = $ap;
  4351. $data ['memu'] = "receipt";
  4352. $data ['staff'] = $this->staff;
  4353. $data ['receiptMemu'] = 'approvalExpenses';
  4354. $data ['verifyId'] = $this->verifyId;
  4355. $data ['executeId'] = $this->executeId;
  4356. $this->render ( "/admin/receiptburEdi", $data );
  4357. }
  4358. function hisImplement() {
  4359. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4360. if (empty ( $item ))
  4361. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "pendImplement";
  4362. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  4363. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4364. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  4365. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  4366. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  4367. Doo::loadModel ( 'receipt' );
  4368. $receipt = new receipt ();
  4369. Doo::loadModel ( 'L_category' );
  4370. $Lcategory = new L_category ();
  4371. Doo::loadModel ( 'verify' );
  4372. Doo::loadModel ( 'statistics' );
  4373. $statistics = new statistics ();
  4374. $verify = new verify ();
  4375. Doo::loadModel ( 'staff' );
  4376. $staff = new staff ();
  4377. Doo::loadClass ( 'XDeode' );
  4378. $XDeode = new XDeode ( 5 );
  4379. $condition = "";
  4380. if ($item == "expenses")
  4381. $condition = " and Rtype=1 ";
  4382. elseif ($item == "receipts")
  4383. $condition = " and Rtype=0 ";
  4384. elseif ($item == "remits")
  4385. $condition = " and Rtype=2 ";
  4386. elseif ($item == "pendImplement") {
  4387. $condition = ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  4388. }
  4389. // 'and (executeCopy like "%["' . $this->staff [0] ['sid'] . '"%" and executeStaff not like "%{"' . $this->staff [0] ['sid'] . '"%" )';
  4390. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  4391. $sopString = "";
  4392. $lastYear=date("Y", strtotime("-1 year"));
  4393. if (empty ( $rdate ))
  4394. $dateCondition = " and (Year(date) =" . $year." or Year(date) = ".$lastYear.") ";
  4395. else
  4396. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  4397. if ($item == 'teipts') {
  4398. $statusCon = '(status=1 or status=6 )';
  4399. $dateCondition = " and date_format(pastDate,'%Y-%m-%d')='" . $rdate . "' ";
  4400. } elseif ($item == 'alerpts') {
  4401. $statusCon = '(status=8 or status=9 )';
  4402. if (empty ( $rdate ))
  4403. $dateCondition = " and Year(date) =" . $year;
  4404. else
  4405. $dateCondition = " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  4406. }
  4407. /*
  4408. * if ($item == 'teipts') { $statusCon = '(status=1 or status=6 )'; $dateCondition = " and Year(pastDate) =" . $year; if ($moth != 'MONTH') $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth; if ($day != 'DAY') $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth . " and day(pastDate)=" . $day; } elseif ($item == 'alerpts') { $statusCon = '(status=8 or status=9 )'; $dateCondition = " and Year(executeDate) =" . $year; if ($moth != 'MONTH') $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth; if ($day != 'DAY') $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day; }
  4409. */
  4410. if ($sop != 'SOP')
  4411. $sopString = " and staff=" . $sop;
  4412. // $noPassSum=$receipt->receiptByYear($year,$this->staff[0]['sid']); and (status=1 or status=6)
  4413. $receiptList = $receipt->find ( array (
  4414. 'where' => $statusCon . $condition . $dateCondition . $sopString,
  4415. 'desc' => 'rid',
  4416. 'asArray' => true
  4417. ) );
  4418. // 员工筛选
  4419. $receiptList2 = $receipt->find ( array (
  4420. 'where' => $statusCon . $condition . $dateCondition,
  4421. 'desc' => 'rid',
  4422. 'asArray' => true
  4423. ) );
  4424. $sopStaff = array ();
  4425. foreach ( $receiptList2 as $key => $value ) {
  4426. $staffDetail = $staff->getOne ( array (
  4427. 'where' => 'sid=' . $value ['staff'],
  4428. 'asArray' => true
  4429. ) );
  4430. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  4431. }
  4432. $Locate = 0;
  4433. $roleId = 0;
  4434. $button = 0;
  4435. foreach ( $receiptList as $key => $value ) {
  4436. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4437. $receiptList [$key] ['Texe'] = 'false';
  4438. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  4439. $receiptList [$key] ['Texe'] = 'true';
  4440. }
  4441. $receiptList [$key] ['TRexe'] = 'true';
  4442. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  4443. $receiptList [$key] ['TRexe'] = 'false';
  4444. }
  4445. $receiptList [$key] ['Locate'] = $Locate;
  4446. $Locate ++;
  4447. $receiptList [$key] ['reviseDetail'] = array ();
  4448. if (! empty ( $value ['reviseDetail'] ))
  4449. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4450. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4451. $categoryDetil = $Lcategory->getOne ( array (
  4452. 'where' => 'cid=' . $value ['cid'],
  4453. 'asArray' => true
  4454. ) );
  4455. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4456. // 检测编辑状态
  4457. $verifyList = $verify->getOne ( array (
  4458. 'where' => 'vid=' . $value ['verify'],
  4459. 'asArray' => true
  4460. ) );
  4461. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4462. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4463. Doo::loadModel ( 'role' );
  4464. $role = new role ();
  4465. $flag = true;
  4466. $roleKey = 0;
  4467. $endStaffArray = array ();
  4468. $roleArrayCopy = array ();
  4469. foreach ( $verifyList as $k => $v ) {
  4470. // init verifyStaff
  4471. if ($v [1] == 'ROLE') {
  4472. if (! empty ( $verifyStaff )) {
  4473. $endStaffArray = end ( $verifyStaff );
  4474. }
  4475. $roleVerify = json_decode ( $v [3], true );
  4476. $roleKey = $k;
  4477. $roleArray = array ();
  4478. $rolename = $role->getOne ( array (
  4479. 'where' => 'rid=' . $v [0],
  4480. 'asArray' => true
  4481. ) );
  4482. foreach ( $roleVerify as $o => $p ) {
  4483. $staffID = explode ( '_', $p );
  4484. $staffInfo = $staff->getOne ( array (
  4485. 'where' => 'sid=' . $staffID [0],
  4486. 'asArray' => true
  4487. ) );
  4488. $exp = array (
  4489. 0 => $staffInfo ['sid'],
  4490. 1 => $staffID [1],
  4491. 2 => $staffInfo ['avatar'],
  4492. 'date' => '',
  4493. 'date' => '',
  4494. 'opinion' => '',
  4495. 'status' => '',
  4496. 'rolename' => $rolename ['name']
  4497. );
  4498. array_push ( $roleArray, $exp );
  4499. }
  4500. $roleArrayCopy [$v [0]] = $roleArray;
  4501. }
  4502. $verifyList [$k] ['date'] = "";
  4503. $verifyList [$k] ['opinion'] = "";
  4504. $verifyList [$k] ['status'] = "";
  4505. if (empty ( $verifyStaff )) {
  4506. $verifyList [$k] ['date'] = "";
  4507. $verifyList [$k] ['opinion'] = "";
  4508. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4509. $verifyList [$k] ['status'] = 4;
  4510. $flag = false;
  4511. }
  4512. } else {
  4513. foreach ( $verifyStaff as $m => $u ) {
  4514. if ($v [0] == $m) {
  4515. $verifyList [$k] ['date'] = $u ['date'];
  4516. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4517. $verifyList [$k] ['status'] = $u ['status'];
  4518. $flag = false;
  4519. break;
  4520. }
  4521. }
  4522. $endStaffArray = end ( $verifyStaff );
  4523. }
  4524. }
  4525. $rolename ['name'] = '';
  4526. if (! empty ( $roleId )) {
  4527. Doo::loadModel ( 'role' );
  4528. $role = new role ();
  4529. $rolename = $role->getOne ( array (
  4530. 'where' => 'rid=' . $roleId,
  4531. 'asArray' => true
  4532. ) );
  4533. }
  4534. if (! empty ( $verifyStaff ))
  4535. $endStaffArray = end ( $verifyStaff );
  4536. $KOP = false;
  4537. foreach ( $roleArrayCopy as $P => $A ) {
  4538. foreach ( $A as $MKI => $AVL ) {
  4539. if (! empty ( $verifyStaff )) {
  4540. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4541. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4542. $button = 4;
  4543. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4544. }
  4545. foreach ( $verifyStaff as $m => $u ) {
  4546. $AVLFK = $AVL [0] . '_R';
  4547. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4548. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4549. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4550. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4551. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4552. break;
  4553. }
  4554. }
  4555. } else {
  4556. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4557. $button = 4;
  4558. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4559. }
  4560. }
  4561. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4562. $KOP = true;
  4563. }
  4564. }
  4565. foreach ( $roleArrayCopy as $k => $v ) {
  4566. foreach ( $verifyList as $m => $n ) {
  4567. if ($n [0] == $k) {
  4568. array_splice ( $verifyList, $m, 1, $v );
  4569. }
  4570. }
  4571. }
  4572. $receiptList [$key] ['verifyList'] = $verifyList;
  4573. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4574. 'where' => 'sid=' . $value ['staff'],
  4575. 'asArray' => true
  4576. ) );
  4577. $receiptList [$key] ['button'] = $button;
  4578. }
  4579. // print_r($receiptList);
  4580. $mothHtml = "";
  4581. for($i = 1; $i <= 12; $i ++) {
  4582. if ($moth == $i)
  4583. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4584. else
  4585. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4586. }
  4587. $dayHtml = "";
  4588. if ($day != "DAY" || $moth != "MONTH") {
  4589. for($i = 1; $i <= 31; $i ++) {
  4590. if ($day == $i)
  4591. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  4592. else
  4593. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  4594. }
  4595. }
  4596. $sopHtml = "";
  4597. foreach ( $sopStaff as $key => $value ) {
  4598. if ($sop == $key)
  4599. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4600. else
  4601. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4602. }
  4603. $data ['rdate'] = $rdate;
  4604. $data ['sopHtml'] = $sopHtml;
  4605. $data ['dayHtml'] = $dayHtml;
  4606. $data ['mothHtml'] = $mothHtml;
  4607. $data ['receiptList'] = $receiptList;
  4608. $data ['memu'] = "receipt";
  4609. $data ['staff'] = $this->staff;
  4610. $data ['receiptMemu'] = 'implement';
  4611. $data ['verifyId'] = $this->verifyId;
  4612. $data ['executeId'] = $this->executeId;
  4613. $data ['item'] = $item;
  4614. $data ['year'] = $year;
  4615. $data ['moth'] = $moth;
  4616. $data ['day'] = $day;
  4617. $data ['sop'] = $sop;
  4618. $this->render ( "/admin/hisImplement", $data );
  4619. }
  4620. function ajaxExamine() {
  4621. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4622. Doo::loadModel ( 'receipt' );
  4623. $receipt = new receipt ();
  4624. if (! empty ( $rid )) {
  4625. $rLRes = $receipt->find ( array (
  4626. '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,
  4627. 'asArray' => true
  4628. ) );
  4629. echo json_encode ( array (
  4630. 'status' => 1,
  4631. 'receipt' => $rLRes [0]
  4632. ) );
  4633. die ();
  4634. }
  4635. echo json_encode ( array (
  4636. 'status' => 0,
  4637. 'receipt' => array ()
  4638. ) );
  4639. die ();
  4640. }
  4641. /*
  4642. * 废弃
  4643. */
  4644. function myReceipt() {
  4645. // all approval past withdraw
  4646. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4647. if (empty ( $item ))
  4648. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4649. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4650. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  4651. Doo::loadModel ( 'receipt' );
  4652. $receipt = new receipt ();
  4653. // pre-loaded
  4654. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4655. // have cache
  4656. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  4657. if (! empty ( $moth )) // yearPage
  4658. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  4659. $this->showCache ( $path );
  4660. }
  4661. Doo::loadModel ( 'L_category' );
  4662. $Lcategory = new L_category ();
  4663. Doo::loadModel ( 'verify' );
  4664. Doo::loadModel ( 'statistics' );
  4665. $statistics = new statistics ();
  4666. $verify = new verify ();
  4667. Doo::loadModel ( 'staff' );
  4668. $staff = new staff ();
  4669. $condition = " and status!=0 ";
  4670. if ($item == "approval")
  4671. $condition = " and status=2 ";
  4672. elseif ($item == "withdraw")
  4673. $condition = " and status=3 ";
  4674. elseif ($item == "past")
  4675. $condition = " and status=1 ";
  4676. elseif ($item == "whdw")
  4677. $condition = " and status=4 ";
  4678. $dateCondition = " and Year(date) =" . $year;
  4679. if (! empty ( $moth )) {
  4680. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  4681. $stList = $statistics->getOne ( array (
  4682. 'select' => 'rePrice ,agPrice',
  4683. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  4684. 'asArray' => true
  4685. ) );
  4686. } else
  4687. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  4688. if (empty ( $stList ))
  4689. $stList = array (
  4690. 'rePrice' => 0,
  4691. 'agPrice' => 0
  4692. );
  4693. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  4694. $data ['stList'] = array (
  4695. 'rePrice' => $stList ['rePrice'],
  4696. 'agPrice' => $stList ['agPrice'],
  4697. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  4698. );
  4699. $receiptList = $receipt->find ( array (
  4700. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  4701. 'desc' => 'rid',
  4702. 'asArray' => true
  4703. ) );
  4704. $Locate = 0;
  4705. $roleId = 0;
  4706. $button = 0;
  4707. foreach ( $receiptList as $key => $value ) {
  4708. $receiptList [$key] ['Locate'] = $Locate;
  4709. $Locate ++;
  4710. $receiptList [$key] ['reviseDetail'] = array ();
  4711. if (! empty ( $value ['reviseDetail'] ))
  4712. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4713. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4714. $categoryDetil = $Lcategory->getOne ( array (
  4715. 'where' => 'cid=' . $value ['cid'],
  4716. 'asArray' => true
  4717. ) );
  4718. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4719. // 检测编辑状态
  4720. $verifyList = $verify->getOne ( array (
  4721. 'where' => 'vid=' . $value ['verify'],
  4722. 'asArray' => true
  4723. ) );
  4724. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4725. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4726. Doo::loadModel ( 'role' );
  4727. $role = new role ();
  4728. $flag = true;
  4729. $roleKey = 0;
  4730. $endStaffArray = array ();
  4731. $roleArrayCopy = array ();
  4732. foreach ( $verifyList as $k => $v ) {
  4733. // init verifyStaff
  4734. if ($v [1] == 'ROLE') {
  4735. if (! empty ( $verifyStaff )) {
  4736. $endStaffArray = end ( $verifyStaff );
  4737. // if ($v[0]==$endStaffArray['nextStaff']){
  4738. // $roleId=$v[0];
  4739. // }
  4740. }
  4741. $roleVerify = json_decode ( $v [3], true );
  4742. $roleKey = $k;
  4743. $roleArray = array ();
  4744. $rolename = $role->getOne ( array (
  4745. 'where' => 'rid=' . $v [0],
  4746. 'asArray' => true
  4747. ) );
  4748. foreach ( $roleVerify as $o => $p ) {
  4749. $staffID = explode ( '_', $p );
  4750. $staffInfo = $staff->getOne ( array (
  4751. 'where' => 'sid=' . $staffID [0],
  4752. 'asArray' => true
  4753. ) );
  4754. // print_r($staffID);
  4755. $exp = array (
  4756. 0 => $staffInfo ['sid'],
  4757. 1 => $staffID [1],
  4758. 2 => $staffInfo ['avatar'],
  4759. 'date' => '',
  4760. 'date' => '',
  4761. 'opinion' => '',
  4762. 'status' => '',
  4763. 'rolename' => $rolename ['name']
  4764. );
  4765. array_push ( $roleArray, $exp );
  4766. }
  4767. $roleArrayCopy [$v [0]] = $roleArray;
  4768. // $verifyList[$k]['roleArray']=$roleArray;
  4769. }
  4770. $verifyList [$k] ['date'] = "";
  4771. $verifyList [$k] ['opinion'] = "";
  4772. $verifyList [$k] ['status'] = "";
  4773. if (empty ( $verifyStaff )) {
  4774. $verifyList [$k] ['date'] = "";
  4775. $verifyList [$k] ['opinion'] = "";
  4776. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4777. $verifyList [$k] ['status'] = 4;
  4778. $flag = false;
  4779. }
  4780. } else {
  4781. foreach ( $verifyStaff as $m => $u ) {
  4782. if ($v [0] == $m) {
  4783. $verifyList [$k] ['date'] = $u ['date'];
  4784. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4785. $verifyList [$k] ['status'] = $u ['status'];
  4786. $flag = false;
  4787. break;
  4788. }
  4789. }
  4790. $endStaffArray = end ( $verifyStaff );
  4791. if (isset ( $endStaffArray ['ROLE'] )) {
  4792. } else {
  4793. // $endKey=key($verifyStaff);
  4794. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4795. // $button=4;
  4796. // $verifyList[$k]['status']=4;
  4797. // }
  4798. }
  4799. }
  4800. }
  4801. $rolename ['name'] = '';
  4802. if (! empty ( $roleId )) {
  4803. Doo::loadModel ( 'role' );
  4804. $role = new role ();
  4805. $rolename = $role->getOne ( array (
  4806. 'where' => 'rid=' . $roleId,
  4807. 'asArray' => true
  4808. ) );
  4809. }
  4810. if (! empty ( $verifyStaff ))
  4811. $endStaffArray = end ( $verifyStaff );
  4812. $KOP = false;
  4813. foreach ( $roleArrayCopy as $P => $A ) {
  4814. foreach ( $A as $MKI => $AVL ) {
  4815. if (! empty ( $verifyStaff )) {
  4816. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4817. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4818. $button = 4;
  4819. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4820. }
  4821. foreach ( $verifyStaff as $m => $u ) {
  4822. $AVLFK = $AVL [0] . '_R';
  4823. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4824. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4825. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4826. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4827. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4828. break;
  4829. }
  4830. }
  4831. } else {
  4832. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4833. $button = 4;
  4834. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4835. }
  4836. }
  4837. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4838. $KOP = true;
  4839. }
  4840. }
  4841. foreach ( $roleArrayCopy as $k => $v ) {
  4842. foreach ( $verifyList as $m => $n ) {
  4843. if ($n [0] == $k) {
  4844. array_splice ( $verifyList, $m, 1, $v );
  4845. }
  4846. }
  4847. }
  4848. $receiptList [$key] ['verifyList'] = $verifyList;
  4849. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4850. 'where' => 'sid=' . $value ['staff'],
  4851. 'asArray' => true
  4852. ) );
  4853. $receiptList [$key] ['button'] = $button;
  4854. }
  4855. // print_r($receiptList);die;
  4856. $mothHtml = "";
  4857. for($i = 1; $i <= 12; $i ++) {
  4858. if ($moth == $i)
  4859. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4860. else
  4861. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4862. }
  4863. $data ['mothHtml'] = $mothHtml;
  4864. $data ['receiptList'] = $receiptList;
  4865. $data ['memu'] = "receipt";
  4866. $data ['staff'] = $this->staff;
  4867. $data ['receiptMemu'] = 'receipt';
  4868. $data ['verifyId'] = $this->verifyId;
  4869. $data ['executeId'] = $this->executeId;
  4870. $data ['item'] = $item;
  4871. $data ['year'] = $year;
  4872. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4873. // sufficient condition to generate cache
  4874. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  4875. $receiptList = $receipt->find ( array (
  4876. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  4877. 'asArray' => true
  4878. ) );
  4879. if (empty ( $receiptList )) { // generated files
  4880. ob_start ();
  4881. $this->render ( "/admin/saea_myList", $data );
  4882. $this->cacheFile ( $path );
  4883. die ();
  4884. // $content = ob_get_contents();
  4885. // $fp = fopen($path, "w");
  4886. // fwrite($fp, $content);
  4887. // fclose($fp);
  4888. }
  4889. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  4890. $receiptList = $receipt->find ( array (
  4891. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  4892. 'asArray' => true
  4893. ) );
  4894. if (empty ( $receiptList )) { // generated files
  4895. ob_start ();
  4896. $this->render ( "/admin/saea_myList", $data );
  4897. $this->cacheFile ( $path );
  4898. die ();
  4899. }
  4900. }
  4901. }
  4902. $this->render ( "/admin/saea_myList", $data );
  4903. }
  4904. function saeaCreate() {
  4905. Doo::loadModel ( 'accountItem' );
  4906. Doo::loadModel ( 'verify' );
  4907. Doo::loadModel ( 'receipt' );
  4908. Doo::loadModel ( 'L_category' );
  4909. $lCategory = new L_category ();
  4910. $receipt = new receipt ();
  4911. $verify = new verify ();
  4912. $accountItem = new accountItem ();
  4913. Doo::loadModel ( "role" );
  4914. $role = new role ();
  4915. $acItem = $accountItem->find ( array (
  4916. 'asArray' => true
  4917. ) );
  4918. $veList = $verify->find ( array (
  4919. 'asArray' => true
  4920. ) );
  4921. foreach ( $veList as $key => $value ) {
  4922. $v = json_decode ( $value ['staff'] );
  4923. $list = array ();
  4924. foreach ( $v as $n => $m ) {
  4925. if ($m ['1'] == 'ROLE') {
  4926. $roleInfo = $role->getOne ( array (
  4927. 'where' => 'rid=' . $m [0],
  4928. 'asArray' => true
  4929. ) );
  4930. $v [$n] [1] = $roleInfo ['name'];
  4931. array_push ( $list, $roleInfo ['name'] );
  4932. } else {
  4933. array_push ( $list, $v [$n] [1] );
  4934. }
  4935. }
  4936. $veList [$key] ['staff'] = implode ( '>', $list );
  4937. }
  4938. $data ['category'] = $lCategory->find ( array (
  4939. 'asArray' => true
  4940. ) );
  4941. $data ['veList'] = $veList;
  4942. $data ['acItem'] = $acItem;
  4943. $data ['memu'] = "receipt";
  4944. $data ['staff'] = $this->staff;
  4945. $data ['receiptMemu'] = 'saeaBorad';
  4946. $data ['verifyId'] = $this->verifyId;
  4947. $data ['executeId'] = $this->executeId;
  4948. $this->render ( "/admin/saea_create", $data );
  4949. }
  4950. function addReceipt() {
  4951. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  4952. $agency = $this->get_args ( 'agency' );
  4953. $travel = $this->get_args ( 'travel' );
  4954. $train = $this->get_args ( 'train' );
  4955. $other = $this->get_args ( 'other' );
  4956. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  4957. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  4958. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  4959. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  4960. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  4961. Doo::loadModel ( 'receipt' );
  4962. Doo::loadModel ( 'receiptDetail' );
  4963. Doo::loadModel ( 'accountItem' );
  4964. $accountItem = new accountItem ();
  4965. $receipt = new receipt ();
  4966. Doo::loadModel ( 'enclosur' );
  4967. Doo::loadModel ( 'execute' );
  4968. $execute = new execute ();
  4969. $executeDetail = $execute->getOne ( array (
  4970. 'where' => 'mold="报销单执行人"',
  4971. 'asArray' => true
  4972. ) );
  4973. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  4974. // if(!empty($receiptDetail))
  4975. // return "/referReceipt/".$receiptDetail['rid'];
  4976. $aItem = $accountItem->find ( array (
  4977. 'asArray' => true
  4978. ) );
  4979. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  4980. $ag = $tr = $ta = $ot = 0;
  4981. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  4982. foreach ( $aItem as $key => $value ) {
  4983. if ($value ['category'] == $this->AGENCY) {
  4984. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  4985. array_push ( $accountJson [$this->AGENCY], array (
  4986. 'aid' => $value ['aid'],
  4987. 'name' => $value ['name'],
  4988. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  4989. ) );
  4990. $sum += $agency [$ag];
  4991. $agencySum += $agency [$ag];
  4992. }
  4993. $ag ++;
  4994. }
  4995. if ($value ['category'] == $this->TRAVEL) {
  4996. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  4997. array_push ( $accountJson [$this->TRAVEL], array (
  4998. 'aid' => $value ['aid'],
  4999. 'name' => $value ['name'],
  5000. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5001. ) );
  5002. $sum += $travel [$tr];
  5003. $travelSum += $travel [$tr];
  5004. }
  5005. $tr ++;
  5006. }
  5007. if ($value ['category'] == $this->TRAIN) {
  5008. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5009. array_push ( $accountJson [$this->TRAIN], array (
  5010. 'aid' => $value ['aid'],
  5011. 'name' => $value ['name'],
  5012. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5013. ) );
  5014. $sum += $train [$ta];
  5015. $trainSum += $train [$ta];
  5016. }
  5017. $ta ++;
  5018. }
  5019. if ($value ['category'] == $this->OTHER) {
  5020. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5021. array_push ( $accountJson [$this->OTHER], array (
  5022. 'aid' => $value ['aid'],
  5023. 'name' => $value ['name'],
  5024. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5025. ) );
  5026. $sum += $other [$ot];
  5027. $otherSum += $other [$ot];
  5028. }
  5029. $ot ++;
  5030. }
  5031. }
  5032. $accountJson ['cSum'] = array (
  5033. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5034. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5035. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5036. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5037. );
  5038. // 报销单
  5039. $receipt->accountItem = json_encode ( $accountJson );
  5040. $receipt->staff = $this->staff [0] ['sid'];
  5041. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5042. $receipt->date = date ( "Y-m-d" );
  5043. $receipt->cid = $cid;
  5044. $receipt->status = 5;
  5045. // 修改审批流程加入角色
  5046. $receipt->verify = $verify;
  5047. $receipt->executeCopy = $executeDetail ['staff'];
  5048. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  5049. $receipt->explanation = $explanation;
  5050. $rid = $receipt->insert ();
  5051. // 附件
  5052. if (! empty ( $enclosurName )) {
  5053. $enclosurArray = explode ( '-', $enclosurName );
  5054. foreach ( $enclosurArray as $value ) {
  5055. $enclosur = new enclosur ();
  5056. $enclosur->name = $value;
  5057. $enclosur->rid = $rid;
  5058. $enclosur->insert ();
  5059. }
  5060. // print_r($enclosurArray);die;
  5061. }
  5062. // 报销详情
  5063. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5064. $receiptDetail = new receiptDetail ();
  5065. $receiptDetail->staff = $this->staff [0] ['sid'];
  5066. $receiptDetail->item = $value ['name'];
  5067. $receiptDetail->itemCategory = $this->AGENCY;
  5068. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5069. $receiptDetail->date = date ( "Y-m-d" );
  5070. $receiptDetail->cid = $cid;
  5071. $receiptDetail->rid = $rid;
  5072. $receiptDetail->status = 4;
  5073. $receiptDetail->insert ();
  5074. }
  5075. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5076. $receiptDetail = new receiptDetail ();
  5077. $receiptDetail->staff = $this->staff [0] ['sid'];
  5078. $receiptDetail->item = $value ['name'];
  5079. $receiptDetail->itemCategory = $this->TRAVEL;
  5080. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5081. $receiptDetail->date = date ( "Y-m-d" );
  5082. $receiptDetail->cid = $cid;
  5083. $receiptDetail->rid = $rid;
  5084. $receiptDetail->status = 4;
  5085. $receiptDetail->insert ();
  5086. }
  5087. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5088. $receiptDetail = new receiptDetail ();
  5089. $receiptDetail->staff = $this->staff [0] ['sid'];
  5090. $receiptDetail->item = $value ['name'];
  5091. $receiptDetail->itemCategory = $this->TRAIN;
  5092. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5093. $receiptDetail->date = date ( "Y-m-d" );
  5094. $receiptDetail->cid = $cid;
  5095. $receiptDetail->rid = $rid;
  5096. $receiptDetail->status = 4;
  5097. $receiptDetail->insert ();
  5098. }
  5099. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5100. $receiptDetail = new receiptDetail ();
  5101. $receiptDetail->staff = $this->staff [0] ['sid'];
  5102. $receiptDetail->item = $value ['name'];
  5103. $receiptDetail->itemCategory = $this->OTHER;
  5104. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5105. $receiptDetail->date = date ( "Y-m-d" );
  5106. $receiptDetail->cid = $cid;
  5107. $receiptDetail->rid = $rid;
  5108. $receiptDetail->status = 4;
  5109. $receiptDetail->insert ();
  5110. }
  5111. return "/saeaBorad";
  5112. } else
  5113. die ( 'illegal request' );
  5114. }
  5115. function referReceipt() {
  5116. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  5117. Doo::loadModel ( 'receipt' );
  5118. Doo::loadModel ( 'verify' );
  5119. $verify = new verify ();
  5120. $receipt = new receipt ();
  5121. Doo::loadModel ( 'L_category' );
  5122. $lCategory = new L_category ();
  5123. Doo::loadModel ( "role" );
  5124. $role = new role ();
  5125. $receiptDetail = $receipt->find ( array (
  5126. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  5127. 'asArray' => true
  5128. ) );
  5129. if (empty ( $receiptDetail ))
  5130. return "/addReceipt";
  5131. foreach ( $receiptDetail as $key => $value ) {
  5132. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5133. $veList = $verify->getOne ( array (
  5134. 'where' => 'vid=' . $value ['verify'],
  5135. 'asArray' => true
  5136. ) );
  5137. $v = json_decode ( $veList ['staff'] );
  5138. array_push ( $v [0], $veList ['description'] );
  5139. foreach ( $v as $n => $m ) {
  5140. if ($m ['1'] == 'ROLE') {
  5141. $roleInfo = $role->getOne ( array (
  5142. 'where' => 'rid=' . $m [0],
  5143. 'asArray' => true
  5144. ) );
  5145. $v [$n] [1] = $roleInfo ['name'];
  5146. }
  5147. }
  5148. $receiptDetail [$key] ['staff'] = $v;
  5149. $category = $lCategory->getOne ( array (
  5150. 'where' => 'cid=' . $value ['cid'],
  5151. 'asArray' => true
  5152. ) );
  5153. $receiptDetail [$key] ['category'] = $category ['title'];
  5154. }
  5155. // print_r($receiptDetail);
  5156. $data ['receiptDetail'] = $receiptDetail;
  5157. $data ['memu'] = "receipt";
  5158. $data ['staff'] = $this->staff;
  5159. $data ['receiptMemu'] = 'saeaCreate';
  5160. $data ['verifyId'] = $this->verifyId;
  5161. $data ['executeId'] = $this->executeId;
  5162. $this->render ( "/admin/saea_confirm", $data );
  5163. }
  5164. function editReceipt() {
  5165. // edit status 4
  5166. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5167. // echo $rid;
  5168. Doo::loadModel ( 'accountItem' );
  5169. Doo::loadModel ( 'verify' );
  5170. Doo::loadModel ( 'receipt' );
  5171. $receipt = new receipt ();
  5172. $verify = new verify ();
  5173. $accountItem = new accountItem ();
  5174. Doo::loadModel ( 'L_category' );
  5175. $lCategory = new L_category ();
  5176. Doo::loadModel ( "role" );
  5177. $role = new role ();
  5178. $receiptDetail = $receipt->getOne ( array (
  5179. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  5180. 'asArray' => true
  5181. ) );
  5182. if (empty ( $receiptDetail ))
  5183. return "/saeaCreate";
  5184. $acItem = $accountItem->find ( array (
  5185. 'asArray' => true
  5186. ) );
  5187. $veList = $verify->find ( array (
  5188. 'asArray' => true
  5189. ) );
  5190. foreach ( $veList as $key => $value ) {
  5191. $v = json_decode ( $value ['staff'] );
  5192. $list = array ();
  5193. foreach ( $v as $n => $m ) {
  5194. if ($m ['1'] == 'ROLE') {
  5195. $roleInfo = $role->getOne ( array (
  5196. 'where' => 'rid=' . $m [0],
  5197. 'asArray' => true
  5198. ) );
  5199. $v [$n] [1] = $roleInfo ['name'];
  5200. array_push ( $list, $roleInfo ['name'] );
  5201. } else {
  5202. array_push ( $list, $v [$n] [1] );
  5203. }
  5204. }
  5205. $veList [$key] ['staff'] = implode ( '>', $list );
  5206. }
  5207. // 配置编辑信息
  5208. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  5209. foreach ( $acItem as $key => $value ) {
  5210. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  5211. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  5212. $acItem [$key] ['price'] = $v ['price'];
  5213. }
  5214. }
  5215. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  5216. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  5217. $acItem [$key] ['price'] = $v ['price'];
  5218. }
  5219. }
  5220. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  5221. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  5222. $acItem [$key] ['price'] = $v ['price'];
  5223. }
  5224. }
  5225. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  5226. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  5227. $acItem [$key] ['price'] = $v ['price'];
  5228. }
  5229. }
  5230. }
  5231. $data ['category'] = $lCategory->find ( array (
  5232. 'asArray' => true
  5233. ) );
  5234. $data ['cSum'] = $accountItemList ['cSum'];
  5235. $data ['sum'] = $receiptDetail ['sum'];
  5236. $data ['receiptDetail'] = $receiptDetail;
  5237. $data ['veList'] = $veList;
  5238. $data ['acItem'] = $acItem;
  5239. $data ['memu'] = "receipt";
  5240. $data ['staff'] = $this->staff;
  5241. $data ['receiptMemu'] = 'saeaBorad';
  5242. $data ['verify'] = $receiptDetail ['verify'];
  5243. $data ['verifyId'] = $this->verifyId;
  5244. $data ['executeId'] = $this->executeId;
  5245. $data ['rid'] = $rid;
  5246. $this->render ( "/admin/saea_edit", $data );
  5247. }
  5248. function updateReceipt() {
  5249. $agency = $this->get_args ( 'agency' );
  5250. $travel = $this->get_args ( 'travel' );
  5251. $train = $this->get_args ( 'train' );
  5252. $other = $this->get_args ( 'other' );
  5253. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5254. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5255. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5256. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5257. if (! empty ( $explanation )) {
  5258. Doo::loadModel ( 'receipt' );
  5259. Doo::loadModel ( 'receiptDetail' );
  5260. Doo::loadModel ( 'accountItem' );
  5261. $accountItem = new accountItem ();
  5262. $receipt = new receipt ();
  5263. Doo::loadModel ( 'execute' );
  5264. $execute = new execute ();
  5265. $receiptDetail = $receipt->getOne ( array (
  5266. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  5267. 'asArray' => true
  5268. ) );
  5269. if (empty ( $receiptDetail ))
  5270. return "/saeaBorad";
  5271. if ($receiptDetail ['Rtype'] == 1)
  5272. $executeDetail = $execute->getOne ( array (
  5273. 'where' => 'mold="借款费用执行人"',
  5274. 'asArray' => true
  5275. ) );
  5276. else
  5277. $executeDetail = $execute->getOne ( array (
  5278. 'where' => 'mold="报销单执行人"',
  5279. 'asArray' => true
  5280. ) );
  5281. $aItem = $accountItem->find ( array (
  5282. 'asArray' => true
  5283. ) );
  5284. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5285. $ag = $tr = $ta = $ot = 0;
  5286. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5287. foreach ( $aItem as $key => $value ) {
  5288. if ($value ['category'] == $this->AGENCY) {
  5289. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5290. array_push ( $accountJson [$this->AGENCY], array (
  5291. 'aid' => $value ['aid'],
  5292. 'name' => $value ['name'],
  5293. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5294. ) );
  5295. $sum += $agency [$ag];
  5296. $agencySum += $agency [$ag];
  5297. }
  5298. $ag ++;
  5299. }
  5300. if ($value ['category'] == $this->TRAVEL) {
  5301. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5302. array_push ( $accountJson [$this->TRAVEL], array (
  5303. 'aid' => $value ['aid'],
  5304. 'name' => $value ['name'],
  5305. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5306. ) );
  5307. $sum += $travel [$tr];
  5308. $travelSum += $travel [$tr];
  5309. }
  5310. $tr ++;
  5311. }
  5312. if ($value ['category'] == $this->TRAIN) {
  5313. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5314. array_push ( $accountJson [$this->TRAIN], array (
  5315. 'aid' => $value ['aid'],
  5316. 'name' => $value ['name'],
  5317. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5318. ) );
  5319. $sum += $train [$ta];
  5320. $trainSum += $train [$ta];
  5321. }
  5322. $ta ++;
  5323. }
  5324. if ($value ['category'] == $this->OTHER) {
  5325. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5326. array_push ( $accountJson [$this->OTHER], array (
  5327. 'aid' => $value ['aid'],
  5328. 'name' => $value ['name'],
  5329. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5330. ) );
  5331. $sum += $other [$ot];
  5332. $otherSum += $other [$ot];
  5333. }
  5334. $ot ++;
  5335. }
  5336. }
  5337. $accountJson ['cSum'] = array (
  5338. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5339. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5340. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5341. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5342. );
  5343. // 报销单
  5344. $rid = $receipt->rid = $receiptDetail ['rid'];
  5345. $receipt->accountItem = json_encode ( $accountJson );
  5346. $receipt->staff = $this->staff [0] ['sid'];
  5347. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5348. $receipt->date = date ( "Y-m-d" );
  5349. $receipt->cid = $cid;
  5350. if (($receiptDetail ['status'] != 4)) {
  5351. if ($receiptDetail ['Rtype'] == 1)
  5352. $receipt->status = 7;
  5353. else
  5354. $receipt->status = 5;
  5355. }
  5356. if ($receiptDetail != 4 && ! empty ( $verify ))
  5357. $receipt->verify = $verify;
  5358. $receipt->executeCopy = $executeDetail ['staff'];
  5359. $receipt->explanation = $explanation;
  5360. $receipt->update ();
  5361. $receiptDetail = new receiptDetail ();
  5362. $receiptDetail->delete ( array (
  5363. 'where' => 'rid=' . $rid
  5364. ) );
  5365. // 报销详情
  5366. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5367. $receiptDetail = new receiptDetail ();
  5368. $receiptDetail->staff = $this->staff [0] ['sid'];
  5369. $receiptDetail->item = $value ['name'];
  5370. $receiptDetail->itemCategory = $this->AGENCY;
  5371. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5372. $receiptDetail->date = date ( "Y-m-d" );
  5373. $receiptDetail->cid = $cid;
  5374. $receiptDetail->rid = $rid;
  5375. $receiptDetail->status = 4;
  5376. $receiptDetail->insert ();
  5377. }
  5378. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5379. $receiptDetail = new receiptDetail ();
  5380. $receiptDetail->staff = $this->staff [0] ['sid'];
  5381. $receiptDetail->item = $value ['name'];
  5382. $receiptDetail->itemCategory = $this->TRAVEL;
  5383. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5384. $receiptDetail->date = date ( "Y-m-d" );
  5385. $receiptDetail->cid = $cid;
  5386. $receiptDetail->rid = $rid;
  5387. $receiptDetail->status = 4;
  5388. $receiptDetail->insert ();
  5389. }
  5390. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5391. $receiptDetail = new receiptDetail ();
  5392. $receiptDetail->staff = $this->staff [0] ['sid'];
  5393. $receiptDetail->item = $value ['name'];
  5394. $receiptDetail->itemCategory = $this->TRAIN;
  5395. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5396. $receiptDetail->date = date ( "Y-m-d" );
  5397. $receiptDetail->cid = $cid;
  5398. $receiptDetail->rid = $rid;
  5399. $receiptDetail->status = 4;
  5400. $receiptDetail->insert ();
  5401. }
  5402. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5403. $receiptDetail = new receiptDetail ();
  5404. $receiptDetail->staff = $this->staff [0] ['sid'];
  5405. $receiptDetail->item = $value ['name'];
  5406. $receiptDetail->itemCategory = $this->OTHER;
  5407. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5408. $receiptDetail->date = date ( "Y-m-d" );
  5409. $receiptDetail->cid = $cid;
  5410. $receiptDetail->rid = $rid;
  5411. $receiptDetail->status = 4;
  5412. $receiptDetail->insert ();
  5413. }
  5414. // return "/referReceipt/".$rid;
  5415. }
  5416. return "/saeaBorad";
  5417. }
  5418. function approvedReceipt() {
  5419. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5420. Doo::loadModel ( 'receipt' );
  5421. Doo::loadModel ( 'receiptDetail' );
  5422. $receipt = new receipt ();
  5423. $receiptDetail = new receiptDetail ();
  5424. Doo::loadModel ( 'statistics' );
  5425. Doo::loadModel ( 'itemStatistics' );
  5426. $statistics = new statistics ();
  5427. $itemStatistics = new itemStatistics ();
  5428. Doo::loadModel ( "verify" );
  5429. $verify = new verify ();
  5430. // 审批状态的判定
  5431. $receiptDetailList = $receipt->getOne ( array (
  5432. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  5433. 'asArray' => true
  5434. ) );
  5435. if (empty ( $receiptDetailList ))
  5436. return "/saeaBorad";
  5437. $verifyDetail = $verify->getOne ( array (
  5438. 'where' => ' vid =' . $receiptDetailList ['verify'],
  5439. 'asArray' => true
  5440. ) );
  5441. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5442. if (empty ( $receiptDetailList ['nowStaff'] )) {
  5443. $nowStaff = "";
  5444. $nowStaffList = array ();
  5445. if ($verifyDetail [0] [1] == 'ROLE') {
  5446. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5447. foreach ( $vStaffString as $key => $value ) {
  5448. $staffK = explode ( "_", $value );
  5449. array_push ( $nowStaffList, $staffK [0] );
  5450. }
  5451. $nowStaff = implode ( ',', $nowStaffList );
  5452. } else {
  5453. $nowStaff = $verifyDetail [0] [0];
  5454. }
  5455. $receipt->nowStaff = $nowStaff;
  5456. }
  5457. // echo $nowStaff;
  5458. // print_r($verifyDetail);die;
  5459. $receipt->rid = $receiptDetailList ['rid'];
  5460. $receipt->date = date ( "Y-m-d" );
  5461. $receipt->status = 2;
  5462. $receipt->update ();
  5463. $receiptDetail->status = 2;
  5464. $receiptDetail->update ( array (
  5465. 'where' => 'rid=' . $receiptDetailList ['rid']
  5466. ) );
  5467. Doo::loadModel ( "receiptLog" );
  5468. $receiptLog = new receiptLog ();
  5469. Doo::loadModel ( "verify" );
  5470. $verify = new verify ();
  5471. $receiptInfo = $receipt->getOne ( array (
  5472. 'where' => 'rid=' . $rid,
  5473. 'asArray' => true
  5474. ) );
  5475. $vr = $verify->getOne ( array (
  5476. 'where' => 'vid=' . $receiptInfo ['verify'],
  5477. 'asArray' => true
  5478. ) );
  5479. $jd = json_decode ( $vr ['staff'] );
  5480. $roleId = 0;
  5481. foreach ( $jd as $key => $value ) {
  5482. if ($value [1] == 'ROLE') {
  5483. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  5484. if ($pos !== false) {
  5485. $roleId = $value [0];
  5486. }
  5487. }
  5488. }
  5489. // 审批日志
  5490. // echo $roleId;die;
  5491. if (! empty ( $roleId )) {
  5492. Doo::loadModel ( "role" );
  5493. $role = new role ();
  5494. $roleInfo = $role->getOne ( array (
  5495. 'where' => 'rid=' . $roleId,
  5496. 'asArray' => true
  5497. ) );
  5498. $receiptLog->rolename = $roleInfo ['name'];
  5499. }
  5500. $receiptLog->username = $this->staff [0] ['username'];
  5501. $receiptLog->uid = $this->staff [0] ['sid'];
  5502. $receiptLog->date = date ( "Y-m-d" );
  5503. $receiptLog->opinion = '提交审批';
  5504. $receiptLog->img = $this->staff [0] ['avatar'];
  5505. $receiptLog->status = 2;
  5506. $receiptLog->rid = $rid;
  5507. $receiptLog->insert ();
  5508. // statistics item
  5509. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  5510. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  5511. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  5512. $stat = $statistics->getOne ( array (
  5513. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5514. 'asArray' => true
  5515. ) );
  5516. if (empty ( $stat )) {
  5517. $statistics->date = date ( "Y-m-d" );
  5518. $statistics->cid = $this->staff [0] ['cid'];
  5519. $statistics->staff = $this->staff [0] ['sid'];
  5520. $statistics->agPrice = 0;
  5521. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5522. $statistics->insert ();
  5523. } else {
  5524. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5525. $statistics->update ( array (
  5526. 'where' => 'sid=' . $stat ['sid']
  5527. ) );
  5528. }
  5529. return "/expenses";
  5530. }
  5531. function approval() {
  5532. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5533. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5534. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5535. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5536. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5537. if (empty ( $status ))
  5538. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5539. $vidList = array ();
  5540. $button = 0;
  5541. Doo::loadModel ( 'verify' );
  5542. $verify = new verify ();
  5543. Doo::loadModel ( 'receipt' );
  5544. $receipt = new receipt ();
  5545. Doo::loadModel ( 'staff' );
  5546. $staff = new staff ();
  5547. Doo::loadModel ( 'L_category' );
  5548. $Lcategory = new L_category ();
  5549. // user verify ID
  5550. $verifyDetail = $verify->find ( array (
  5551. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5552. 'asArray' => true
  5553. ) );
  5554. foreach ( $verifyDetail as $key => $value ) {
  5555. array_push ( $vidList, $value ['vid'] );
  5556. }
  5557. $vid = implode ( ",", $vidList );
  5558. if (empty ( $verifyDetail ))
  5559. $vid = 0;
  5560. /*
  5561. */
  5562. $dateCondition = " and Year(date) =" . $year;
  5563. if (! empty ( $month ))
  5564. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  5565. $categoryList = $Lcategory->find ( array (
  5566. 'asArray' => true
  5567. ) );
  5568. $staffList = $staff->find ( array (
  5569. 'where' => 'cid=' . $cid,
  5570. 'asArray' => true
  5571. ) );
  5572. $cateCondition = "";
  5573. $staffCondition = "";
  5574. $approvalCondition = "";
  5575. if (! empty ( $cid ))
  5576. $cateCondition = ' and cid=' . $cid;
  5577. if (! empty ( $sid )) {
  5578. $staffCondition = ' and staff=' . $sid;
  5579. $cateCondition = "";
  5580. }
  5581. // elseif($status==1){
  5582. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  5583. // }
  5584. if ($status == 2) {
  5585. // 查找角色审批人
  5586. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  5587. }
  5588. $ap = "";
  5589. if ($status == 4) {
  5590. $ap = 4;
  5591. $status = 2;
  5592. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  5593. }
  5594. if ($status == 5) {
  5595. $status = 4;
  5596. $ap = 5;
  5597. }
  5598. // echo $vid;
  5599. // get Receipt By verifyID status 2 .$approvalCondition
  5600. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  5601. $receiptList = $receipt->find ( array (
  5602. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  5603. 'desc' => 'rid',
  5604. 'asArray' => true
  5605. ) );
  5606. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  5607. $Locate = 0;
  5608. if ($ap == 4)
  5609. $status = 4;
  5610. elseif ($ap == 5)
  5611. $status = 5;
  5612. foreach ( $receiptList as $key => $value ) {
  5613. $receiptList [$key] ['Locate'] = $Locate;
  5614. $Locate ++;
  5615. $receiptList [$key] ['reviseDetail'] = array ();
  5616. if (! empty ( $value ['reviseDetail'] ))
  5617. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5618. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5619. $categoryDetil = $Lcategory->getOne ( array (
  5620. 'where' => 'cid=' . $value ['cid'],
  5621. 'asArray' => true
  5622. ) );
  5623. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5624. $verifyList = $verify->getOne ( array (
  5625. 'where' => 'vid=' . $value ['verify'],
  5626. 'asArray' => true
  5627. ) );
  5628. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5629. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5630. foreach ( $verifyList as $k => $v ) {
  5631. // init verifyStaff
  5632. $verifyList [$k] ['date'] = "";
  5633. $verifyList [$k] ['opinion'] = "";
  5634. $verifyList [$k] ['status'] = "";
  5635. if (empty ( $verifyStaff )) {
  5636. $verifyList [$k] ['date'] = "";
  5637. $verifyList [$k] ['opinion'] = "";
  5638. if ($v [0] == $this->staff [0] ['sid']) {
  5639. $verifyList [$k] ['status'] = 4;
  5640. $button = 4;
  5641. }
  5642. } else {
  5643. $flag = true;
  5644. foreach ( $verifyStaff as $m => $u ) {
  5645. if ($v [0] == $m) {
  5646. $verifyList [$k] ['date'] = $u ['date'];
  5647. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5648. $verifyList [$k] ['status'] = $u ['status'];
  5649. $flag = false;
  5650. break;
  5651. }
  5652. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  5653. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  5654. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  5655. }
  5656. if ($flag) { // 检测可编辑
  5657. if ($v [0] == $this->staff [0] ['sid']) {
  5658. $verifyList [$k] ['status'] = 4;
  5659. $button = 4;
  5660. }
  5661. }
  5662. }
  5663. }
  5664. $receiptList [$key] ['verifyList'] = $verifyList;
  5665. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5666. 'where' => 'sid=' . $value ['staff'],
  5667. 'asArray' => true
  5668. ) );
  5669. $receiptList [$key] ['button'] = $button;
  5670. }
  5671. // print_r($receiptList);die;
  5672. // $data['verifyDetail']=$verifyDetail;
  5673. $mothHtml = "";
  5674. for($i = 1; $i <= 12; $i ++) {
  5675. if ($month == $i)
  5676. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5677. else
  5678. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5679. }
  5680. $data ['mothHtml'] = $mothHtml;
  5681. $data ['receiptList'] = $receiptList;
  5682. $data ['receiptApprovalCount'] = count ( $receiptList );
  5683. $data ['status'] = $status;
  5684. $data ['year'] = $year;
  5685. $data ['categoryList'] = $categoryList;
  5686. $data ['staffList'] = $staffList;
  5687. $data ['cid'] = $cid;
  5688. $data ['sid'] = $sid;
  5689. $data ['ap'] = $ap;
  5690. $data ['memu'] = "receipt";
  5691. $data ['staff'] = $this->staff;
  5692. $data ['receiptMemu'] = 'approval';
  5693. $data ['verifyId'] = $this->verifyId;
  5694. $data ['executeId'] = $this->executeId;
  5695. $this->render ( "/admin/saea_reportList", $data );
  5696. }
  5697. function approvalDetails() {
  5698. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5699. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5700. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5701. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5702. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5703. Doo::loadModel ( 'verify' );
  5704. $verify = new verify ();
  5705. Doo::loadModel ( 'receipt' );
  5706. $receipt = new receipt ();
  5707. Doo::loadModel ( 'staff' );
  5708. $staff = new staff ();
  5709. Doo::loadModel ( 'L_category' );
  5710. $Lcategory = new L_category ();
  5711. Doo::loadModel ( 'enclosur' );
  5712. $enclosur = new enclosur ();
  5713. $vidList = array ();
  5714. $verifyDetail = $verify->find ( array (
  5715. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5716. 'asArray' => true
  5717. ) );
  5718. foreach ( $verifyDetail as $key => $value ) {
  5719. array_push ( $vidList, $value ['vid'] );
  5720. }
  5721. $vid = implode ( ",", $vidList );
  5722. if (empty ( $verifyDetail ))
  5723. $vid = 0;
  5724. $categoryList = $Lcategory->find ( array (
  5725. 'asArray' => true
  5726. ) );
  5727. $staffList = $staff->find ( array (
  5728. 'where' => 'cid=' . $cid,
  5729. 'asArray' => true
  5730. ) );
  5731. $ap = 0;
  5732. $receiptList = $receipt->find ( array (
  5733. 'where' => 'rid =' . $rid,
  5734. 'desc' => 'rid',
  5735. 'asArray' => true
  5736. ) );
  5737. $Locate = 0;
  5738. $roleId = 0;
  5739. $button = 0;
  5740. foreach ( $receiptList as $key => $value ) {
  5741. $receiptList [$key] ['Locate'] = $Locate;
  5742. $Locate ++;
  5743. $receiptList [$key] ['reviseDetail'] = array ();
  5744. if (! empty ( $value ['reviseDetail'] ))
  5745. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5746. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5747. $categoryDetil = $Lcategory->getOne ( array (
  5748. 'where' => 'cid=' . $value ['cid'],
  5749. 'asArray' => true
  5750. ) );
  5751. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5752. // 检测编辑状态
  5753. $verifyList = $verify->getOne ( array (
  5754. 'where' => 'vid=' . $value ['verify'],
  5755. 'asArray' => true
  5756. ) );
  5757. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5758. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5759. Doo::loadModel ( 'role' );
  5760. $role = new role ();
  5761. // print_r($verifyList);
  5762. $flag = true;
  5763. $roleKey = 0;
  5764. $endStaffArray = array ();
  5765. $roleArrayCopy = array ();
  5766. foreach ( $verifyList as $k => $v ) {
  5767. // init verifyStaff
  5768. if ($v [1] == 'ROLE') {
  5769. if (! empty ( $verifyStaff )) {
  5770. $endStaffArray = end ( $verifyStaff );
  5771. if ($v [0] == $endStaffArray ['nextStaff']) {
  5772. $roleId = $v [0];
  5773. }
  5774. }
  5775. $roleVerify = json_decode ( $v [3], true );
  5776. $roleKey = $k;
  5777. $roleArray = array ();
  5778. $rolename = $role->getOne ( array (
  5779. 'where' => 'rid=' . $v [0],
  5780. 'asArray' => true
  5781. ) );
  5782. foreach ( $roleVerify as $o => $p ) {
  5783. $staffID = explode ( '_', $p );
  5784. $staffInfo = $staff->getOne ( array (
  5785. 'where' => 'sid=' . $staffID [0],
  5786. 'asArray' => true
  5787. ) );
  5788. // print_r($staffID);
  5789. $exp = array (
  5790. 0 => $staffInfo ['sid'],
  5791. 1 => $staffID [1],
  5792. 2 => $staffInfo ['avatar'],
  5793. 'date' => '',
  5794. 'date' => '',
  5795. 'opinion' => '',
  5796. 'status' => '',
  5797. 'rolename' => $rolename ['name']
  5798. );
  5799. array_push ( $roleArray, $exp );
  5800. }
  5801. $roleArrayCopy [$v [0]] = $roleArray;
  5802. // $verifyList[$k]['roleArray']=$roleArray;
  5803. }
  5804. // print_r($roleArray);
  5805. $verifyList [$k] ['date'] = "";
  5806. $verifyList [$k] ['opinion'] = "";
  5807. $verifyList [$k] ['status'] = "";
  5808. if (empty ( $verifyStaff )) {
  5809. $verifyList [$k] ['date'] = "";
  5810. $verifyList [$k] ['opinion'] = "";
  5811. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5812. $verifyList [$k] ['status'] = 4;
  5813. $button = 4;
  5814. $flag = false;
  5815. }
  5816. } else {
  5817. foreach ( $verifyStaff as $m => $u ) {
  5818. if ($v [0] == $m) {
  5819. $verifyList [$k] ['date'] = $u ['date'];
  5820. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5821. $verifyList [$k] ['status'] = $u ['status'];
  5822. $flag = false;
  5823. break;
  5824. }
  5825. }
  5826. $endStaffArray = end ( $verifyStaff );
  5827. if (isset ( $endStaffArray ['ROLE'] )) {
  5828. } else {
  5829. $endKey = key ( $verifyStaff );
  5830. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5831. $button = 4;
  5832. $verifyList [$k] ['status'] = 4;
  5833. }
  5834. }
  5835. }
  5836. }
  5837. $rolename ['name'] = '';
  5838. if (! empty ( $roleId )) {
  5839. Doo::loadModel ( 'role' );
  5840. $role = new role ();
  5841. $rolename = $role->getOne ( array (
  5842. 'where' => 'rid=' . $roleId,
  5843. 'asArray' => true
  5844. ) );
  5845. }
  5846. if (! empty ( $verifyStaff ))
  5847. $endStaffArray = end ( $verifyStaff );
  5848. $KOP = false;
  5849. foreach ( $roleArrayCopy as $P => $A ) {
  5850. foreach ( $A as $MKI => $AVL ) {
  5851. if (! empty ( $verifyStaff )) {
  5852. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5853. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5854. $button = 4;
  5855. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5856. }
  5857. foreach ( $verifyStaff as $m => $u ) {
  5858. $AVLFK = $AVL [0] . '_R';
  5859. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5860. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5861. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5862. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5863. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5864. break;
  5865. }
  5866. }
  5867. } else {
  5868. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5869. $button = 4;
  5870. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5871. }
  5872. }
  5873. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5874. $KOP = true;
  5875. }
  5876. }
  5877. foreach ( $roleArrayCopy as $k => $v ) {
  5878. foreach ( $verifyList as $m => $n ) {
  5879. if ($n [0] == $k) {
  5880. array_splice ( $verifyList, $m, 1, $v );
  5881. }
  5882. }
  5883. }
  5884. $receiptList [$key] ['verifyList'] = $verifyList;
  5885. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5886. 'where' => 'sid=' . $value ['staff'],
  5887. 'asArray' => true
  5888. ) );
  5889. $receiptList [$key] ['button'] = $button;
  5890. }
  5891. $mothHtml = "";
  5892. for($i = 1; $i <= 12; $i ++) {
  5893. if ($month == $i)
  5894. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5895. else
  5896. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5897. }
  5898. // 获取审批日志
  5899. Doo::loadModel ( 'receiptLog' );
  5900. $receiptLog = new receiptLog ();
  5901. $rlList = array ();
  5902. $rlInfo = $receiptLog->getOne ( array (
  5903. 'where' => 'rid=' . $rid . ' and status=4',
  5904. 'asArray' => true
  5905. ) );
  5906. $tijdate = $receiptLog->getOne ( array (
  5907. 'where' => 'rid=' . $rid . ' and status=2',
  5908. 'asc' => 'rlid',
  5909. 'asArray' => true
  5910. ) );
  5911. if (! empty ( $rlInfo )) {
  5912. $rlList = $receiptLog->find ( array (
  5913. 'where' => 'rid=' . $rid,
  5914. 'asc' => 'rlid',
  5915. 'asArray' => true
  5916. ) );
  5917. }
  5918. $receiptList [0] ['rlList'] = $rlList;
  5919. $enclosurList = $enclosur->find ( array (
  5920. 'where' => 'rid=' . $rid,
  5921. 'asArray' => true
  5922. ) );
  5923. $enclosurHtml = '';
  5924. foreach ( $enclosurList as $value ) {
  5925. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5926. }
  5927. $data ['enclosurHtml'] = $enclosurHtml;
  5928. $data ['rolename'] = $rolename ['name'];
  5929. $data ['datetij'] = $tijdate ['date'];
  5930. $data ['mothHtml'] = $mothHtml;
  5931. $data ['receiptList'] = $receiptList;
  5932. $data ['receiptApprovalCount'] = count ( $receiptList );
  5933. $data ['year'] = $year;
  5934. $data ['categoryList'] = $categoryList;
  5935. $data ['staffList'] = $staffList;
  5936. $data ['cid'] = $cid;
  5937. $data ['sid'] = $sid;
  5938. $data ['status'] = 0;
  5939. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  5940. $ap = 4;
  5941. } else
  5942. $data ['status'] = $receiptList [0] ['status'];
  5943. if ($receiptList [0] ['status'] == 4) {
  5944. $data ['status'] = 5;
  5945. $ap = 0;
  5946. }
  5947. $data ['ap'] = $ap;
  5948. $data ['memu'] = "receipt";
  5949. $data ['staff'] = $this->staff;
  5950. $data ['receiptMemu'] = 'approval';
  5951. $data ['verifyId'] = $this->verifyId;
  5952. $data ['executeId'] = $this->executeId;
  5953. $this->render ( "/admin/saeaReportListReport", $data );
  5954. }
  5955. function approvalEdi() {
  5956. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5957. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5958. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5959. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5960. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5961. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5962. if (empty ( $status ))
  5963. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5964. $vidList = array ();
  5965. $button = 0;
  5966. Doo::loadModel ( 'verify' );
  5967. Doo::loadModel ( 'receipt' );
  5968. Doo::loadModel ( 'staff' );
  5969. $staff = new staff ();
  5970. $receipt = new receipt ();
  5971. $verify = new verify ();
  5972. Doo::loadModel ( 'L_category' );
  5973. $Lcategory = new L_category ();
  5974. Doo::loadModel ( 'enclosur' );
  5975. $enclosur = new enclosur ();
  5976. // user verify ID
  5977. $verifyDetail = $verify->find ( array (
  5978. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5979. 'asArray' => true
  5980. ) );
  5981. foreach ( $verifyDetail as $key => $value ) {
  5982. array_push ( $vidList, $value ['vid'] );
  5983. }
  5984. $vid = implode ( ",", $vidList );
  5985. if (empty ( $verifyDetail ))
  5986. $vid = 0;
  5987. $categoryList = $Lcategory->find ( array (
  5988. 'asArray' => true
  5989. ) );
  5990. $staffList = $staff->find ( array (
  5991. 'where' => 'cid=' . $cid,
  5992. 'asArray' => true
  5993. ) );
  5994. $ap = "";
  5995. if ($status == 4) {
  5996. $ap = 4;
  5997. $status = 2;
  5998. }
  5999. // get Receipt By verifyID status 2
  6000. $receiptList = $receipt->find ( array (
  6001. 'where' => 'rid =' . $rid,
  6002. 'desc' => 'rid',
  6003. 'asArray' => true
  6004. ) );
  6005. $Locate = 0;
  6006. $roleId = 0;
  6007. if ($ap == 4)
  6008. $status = 4;
  6009. foreach ( $receiptList as $key => $value ) {
  6010. $receiptList [$key] ['Locate'] = $Locate;
  6011. $Locate ++;
  6012. $receiptList [$key] ['reviseDetail'] = array ();
  6013. if (! empty ( $value ['reviseDetail'] ))
  6014. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6015. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6016. $categoryDetil = $Lcategory->getOne ( array (
  6017. 'where' => 'cid=' . $value ['cid'],
  6018. 'asArray' => true
  6019. ) );
  6020. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6021. // 检测编辑状态
  6022. $verifyList = $verify->getOne ( array (
  6023. 'where' => 'vid=' . $value ['verify'],
  6024. 'asArray' => true
  6025. ) );
  6026. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6027. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6028. // print_r($verifyList);
  6029. //
  6030. // if (empty($verifyStaff)){
  6031. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6032. // $verifyList[0]['status']=4;$button=4;
  6033. // }
  6034. //
  6035. // }else{
  6036. //
  6037. // }
  6038. // die;
  6039. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  6040. // echo array_search("green",$a);
  6041. //
  6042. Doo::loadModel ( 'role' );
  6043. $role = new role ();
  6044. // print_r($verifyList);
  6045. $flag = true;
  6046. $roleKey = 0;
  6047. $endStaffArray = array ();
  6048. $roleArrayCopy = array ();
  6049. foreach ( $verifyList as $k => $v ) {
  6050. // init verifyStaff
  6051. if ($v [1] == 'ROLE') {
  6052. if (! empty ( $verifyStaff )) {
  6053. $endStaffArray = end ( $verifyStaff );
  6054. if ($v [0] == $endStaffArray ['nextStaff']) {
  6055. $roleId = $v [0];
  6056. }
  6057. }
  6058. $roleVerify = json_decode ( $v [3], true );
  6059. $roleKey = $k;
  6060. $roleArray = array ();
  6061. $rolename = $role->getOne ( array (
  6062. 'where' => 'rid=' . $v [0],
  6063. 'asArray' => true
  6064. ) );
  6065. foreach ( $roleVerify as $o => $p ) {
  6066. $staffID = explode ( '_', $p );
  6067. $staffInfo = $staff->getOne ( array (
  6068. 'where' => 'sid=' . $staffID [0],
  6069. 'asArray' => true
  6070. ) );
  6071. // print_r($staffID);
  6072. $exp = array (
  6073. 0 => $staffInfo ['sid'],
  6074. 1 => $staffID [1],
  6075. 2 => $staffInfo ['avatar'],
  6076. 'date' => '',
  6077. 'date' => '',
  6078. 'opinion' => '',
  6079. 'status' => '',
  6080. 'rolename' => $rolename ['name']
  6081. );
  6082. array_push ( $roleArray, $exp );
  6083. }
  6084. $roleArrayCopy [$v [0]] = $roleArray;
  6085. // $verifyList[$k]['roleArray']=$roleArray;
  6086. }
  6087. // print_r($roleArray);
  6088. $verifyList [$k] ['date'] = "";
  6089. $verifyList [$k] ['opinion'] = "";
  6090. $verifyList [$k] ['status'] = "";
  6091. if (empty ( $verifyStaff )) {
  6092. $verifyList [$k] ['date'] = "";
  6093. $verifyList [$k] ['opinion'] = "";
  6094. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6095. $verifyList [$k] ['status'] = 4;
  6096. $button = 4;
  6097. $flag = false;
  6098. }
  6099. } else {
  6100. foreach ( $verifyStaff as $m => $u ) {
  6101. if ($v [0] == $m) {
  6102. $verifyList [$k] ['date'] = $u ['date'];
  6103. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6104. $verifyList [$k] ['status'] = $u ['status'];
  6105. $flag = false;
  6106. break;
  6107. }
  6108. }
  6109. $endStaffArray = end ( $verifyStaff );
  6110. if (isset ( $endStaffArray ['ROLE'] )) {
  6111. } else {
  6112. $endKey = key ( $verifyStaff );
  6113. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6114. $button = 4;
  6115. $verifyList [$k] ['status'] = 4;
  6116. }
  6117. }
  6118. // print_r($endStaffArray);die;
  6119. // if (empty($verifyStaff)){
  6120. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6121. // $verifyList[$k]['status']=4;$button=4;
  6122. // }
  6123. //
  6124. // }else{
  6125. //
  6126. // }
  6127. // if($flag){//检测可编辑
  6128. // if($v[0]==$this->staff[0]['sid']){
  6129. // $verifyList[$k]['status']=4;$button=4;
  6130. // }
  6131. // }
  6132. }
  6133. }
  6134. $rolename ['name'] = '';
  6135. if (! empty ( $roleId )) {
  6136. Doo::loadModel ( 'role' );
  6137. $role = new role ();
  6138. $rolename = $role->getOne ( array (
  6139. 'where' => 'rid=' . $roleId,
  6140. 'asArray' => true
  6141. ) );
  6142. }
  6143. if (! empty ( $verifyStaff ))
  6144. $endStaffArray = end ( $verifyStaff );
  6145. $KOP = false;
  6146. foreach ( $roleArrayCopy as $P => $A ) {
  6147. foreach ( $A as $MKI => $AVL ) {
  6148. if (! empty ( $verifyStaff )) {
  6149. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6150. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6151. $button = 4;
  6152. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6153. }
  6154. foreach ( $verifyStaff as $m => $u ) {
  6155. $AVLFK = $AVL [0] . '_R';
  6156. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6157. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6158. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6159. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6160. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6161. break;
  6162. }
  6163. }
  6164. } else {
  6165. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6166. $button = 4;
  6167. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6168. }
  6169. }
  6170. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6171. $KOP = true;
  6172. }
  6173. }
  6174. // print_r($roleArrayCopy);
  6175. // echo $roleKey;
  6176. foreach ( $roleArrayCopy as $k => $v ) {
  6177. foreach ( $verifyList as $m => $n ) {
  6178. if ($n [0] == $k) {
  6179. array_splice ( $verifyList, $m, 1, $v );
  6180. }
  6181. }
  6182. }
  6183. // if ($KOP)
  6184. // array_splice($verifyList,$roleKey,1,$roleArray);
  6185. // print_r($verifyList);
  6186. $receiptList [$key] ['verifyList'] = $verifyList;
  6187. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6188. 'where' => 'sid=' . $value ['staff'],
  6189. 'asArray' => true
  6190. ) );
  6191. $receiptList [$key] ['button'] = $button;
  6192. }
  6193. // $data['verifyDetail']=$verifyDetail;
  6194. $mothHtml = "";
  6195. for($i = 1; $i <= 12; $i ++) {
  6196. if ($month == $i)
  6197. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6198. else
  6199. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6200. }
  6201. // 获取审批日志
  6202. Doo::loadModel ( 'receiptLog' );
  6203. $receiptLog = new receiptLog ();
  6204. $rlList = array ();
  6205. $rlInfo = $receiptLog->getOne ( array (
  6206. 'where' => 'rid=' . $rid . ' and status=4',
  6207. 'asArray' => true
  6208. ) );
  6209. $tijdate = $receiptLog->getOne ( array (
  6210. 'where' => 'rid=' . $rid . ' and status=2',
  6211. 'asc' => 'rlid',
  6212. 'asArray' => true
  6213. ) );
  6214. if (! empty ( $rlInfo )) {
  6215. $rlList = $receiptLog->find ( array (
  6216. 'where' => 'rid=' . $rid,
  6217. 'asc' => 'rlid',
  6218. 'asArray' => true
  6219. ) );
  6220. }
  6221. $receiptList [0] ['rlList'] = $rlList;
  6222. $enclosurList = $enclosur->find ( array (
  6223. 'where' => 'rid=' . $rid,
  6224. 'asArray' => true
  6225. ) );
  6226. $enclosurHtml = '';
  6227. foreach ( $enclosurList as $value ) {
  6228. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6229. }
  6230. $data ['enclosurHtml'] = $enclosurHtml;
  6231. $data ['rolename'] = $rolename ['name'];
  6232. $data ['datetij'] = $tijdate ['date'];
  6233. $data ['mothHtml'] = $mothHtml;
  6234. $data ['receiptList'] = $receiptList;
  6235. $data ['receiptApprovalCount'] = count ( $receiptList );
  6236. $data ['status'] = $status;
  6237. $data ['year'] = $year;
  6238. $data ['categoryList'] = $categoryList;
  6239. $data ['staffList'] = $staffList;
  6240. $data ['cid'] = $cid;
  6241. $data ['sid'] = $sid;
  6242. $data ['ap'] = $ap;
  6243. $data ['memu'] = "receipt";
  6244. $data ['staff'] = $this->staff;
  6245. $data ['receiptMemu'] = 'approval';
  6246. $data ['verifyId'] = $this->verifyId;
  6247. $data ['executeId'] = $this->executeId;
  6248. $this->render ( "/admin/saeaReportListReport", $data );
  6249. }
  6250. function remittanceHky() {
  6251. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6252. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  6253. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6254. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  6255. $page_size = 15;
  6256. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  6257. Doo::loadModel ( 'receipt' );
  6258. $receipt = new receipt ();
  6259. Doo::loadModel ( 'staff' );
  6260. $staff = new staff ();
  6261. $dateCondition = " and Year(executeDate) =" . $year;
  6262. if ($moth != 'MONTH')
  6263. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  6264. if ($day != 'DAY' && $moth != 'MONTH')
  6265. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  6266. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  6267. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  6268. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  6269. $limit = $pageinfo ['lower'] . ',' . $page_size;
  6270. $dayList = $receipt->find ( array (
  6271. 'select' => 'executeDate,sum(amount) as amount',
  6272. 'where' => $sql,
  6273. 'desc' => 'executeDate',
  6274. 'groupby' => 'executeDate',
  6275. 'limit' => $limit,
  6276. 'asArray' => true
  6277. ) );
  6278. // print_r($dayList);
  6279. foreach ( $dayList as $key => $value ) {
  6280. $remitString = "";
  6281. $receiptList = $receipt->find ( array (
  6282. 'select' => 'rid,executeDate,amount,staff,cid',
  6283. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  6284. 'desc' => 'executeDate',
  6285. 'asArray' => true
  6286. ) );
  6287. foreach ( $receiptList as $k => $v ) {
  6288. $sinfo = $staff->getOne ( array (
  6289. 'select' => 'username,category',
  6290. 'where' => ' sid=' . $v ['staff'],
  6291. 'asArray' => true
  6292. ) );
  6293. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  6294. }
  6295. $dayList [$key] ['staff'] = $remitString;
  6296. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  6297. }
  6298. // print_r($dayList);
  6299. $mothHtml = "";
  6300. for($i = 1; $i <= 12; $i ++) {
  6301. if ($moth == $i)
  6302. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6303. else
  6304. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6305. }
  6306. $dayHtml = "";
  6307. if ($day != "DAY" || $moth != "MONTH") {
  6308. for($i = 1; $i <= 31; $i ++) {
  6309. if ($day == $i)
  6310. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6311. else
  6312. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6313. }
  6314. }
  6315. $data ['page'] = $pageinfo;
  6316. $data ['year'] = $year;
  6317. $data ['moth'] = $moth;
  6318. $data ['day'] = $day;
  6319. $data ['get'] = $get;
  6320. $data ['dayHtml'] = $dayHtml;
  6321. $data ['mothHtml'] = $mothHtml;
  6322. $data ['receiptList'] = $dayList;
  6323. $data ['memu'] = "receipt";
  6324. $data ['staff'] = $this->staff;
  6325. $data ['receiptMemu'] = 'remittanceHky';
  6326. $data ['verifyId'] = $this->verifyId;
  6327. $data ['executeId'] = $this->executeId;
  6328. $this->render ( "/admin/remittanceHky", $data );
  6329. }
  6330. function remittancep() {
  6331. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  6332. Doo::loadModel ( 'receipt' );
  6333. $receipt = new receipt ();
  6334. Doo::loadModel ( 'staff' );
  6335. $staff = new staff ();
  6336. Doo::loadClass ( 'XDeode' );
  6337. $XDeode = new XDeode ( 5 );
  6338. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  6339. $rplist = $receipt->find ( array (
  6340. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6341. 'asArray' => true
  6342. ) );
  6343. $dayList = $receipt->find ( array (
  6344. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6345. 'desc' => 'executeDate',
  6346. 'groupby' => 'staff',
  6347. 'asArray' => true
  6348. ) );
  6349. $html = '';
  6350. foreach ( $dayList as $key => $value ) {
  6351. $sinfo = $staff->getOne ( array (
  6352. 'select' => 'username,category',
  6353. 'where' => ' sid=' . $value ['staff'],
  6354. 'asArray' => true
  6355. ) );
  6356. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  6357. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  6358. $au = 0;
  6359. foreach ( $rplist as $k => $v ) {
  6360. if ($value ['staff'] == $v ['staff']) {
  6361. $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>';
  6362. $au += $v ['amount'];
  6363. }
  6364. }
  6365. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  6366. }
  6367. $data ['html'] = $html;
  6368. $data ['memu'] = "receipt";
  6369. $data ['staff'] = $this->staff;
  6370. $data ['receiptMemu'] = 'remittanceHky';
  6371. $data ['verifyId'] = $this->verifyId;
  6372. $data ['executeId'] = $this->executeId;
  6373. $this->render ( "/admin/remittancep", $data );
  6374. }
  6375. function ajaxGetReceiptDetails() {
  6376. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  6377. Doo::loadClass ( 'XDeode' );
  6378. $XDeode = new XDeode ( 5 );
  6379. $rid = $XDeode->decode ( $rid );
  6380. if (empty ( $rid )) {
  6381. echo json_encode ( array (
  6382. 'status' => 2,
  6383. 'msg' => 'illegal request'
  6384. ) );
  6385. die ();
  6386. }
  6387. Doo::loadModel ( 'receipt' );
  6388. $receipt = new receipt ();
  6389. Doo::loadModel ( 'staff' );
  6390. $staff = new staff ();
  6391. $rinfo = $receipt->getOne ( array (
  6392. 'where' => 'rid= ' . $rid,
  6393. 'asArray' => true
  6394. ) );
  6395. $sinfo = $staff->getOne ( array (
  6396. 'select' => 'username,category',
  6397. 'where' => ' sid=' . $rinfo ['staff'],
  6398. 'asArray' => true
  6399. ) );
  6400. $rinfo ['reviseDetail'] = array ();
  6401. if (! empty ( $rinfo ['reviseDetail'] ))
  6402. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  6403. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  6404. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  6405. $rinfo ['category'] = $sinfo ['category'];
  6406. $verifyStaff = array ();
  6407. if (! empty ( $rinfo ['verifyStaff'] ))
  6408. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  6409. $relust = $rinfo ['sum'] - $rinfo ['loanSum'];
  6410. $rinfo ['relust'] = $relust;
  6411. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  6412. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  6413. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  6414. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  6415. // 费用执行人相关数据
  6416. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6417. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6418. foreach ( $executeCopy as $k => $v ) {
  6419. $executeCopy [$k] ['date'] = '';
  6420. $executeCopy [$k] ['opinion'] = '';
  6421. $executeCopy [$k] ['status'] = '';
  6422. if (! empty ( $executeStaff ))
  6423. foreach ( $executeStaff as $m => $u ) {
  6424. if ($v [0] == $m) {
  6425. $executeCopy [$k] ['date'] = $u ['date'];
  6426. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  6427. $executeCopy [$k] ['status'] = $u ['status'];
  6428. break;
  6429. }
  6430. }
  6431. }
  6432. $rinfo ['executeCopy'] = $executeCopy;
  6433. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  6434. if ($rinfo ['Rtype'] == 1) { // 借款费用
  6435. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6436. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  6437. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  6438. $html .= '<tr><th>' . $value ['name'] . '</th>
  6439. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6440. }
  6441. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6442. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6443. <tr><th class="taC" colspan="2">费用说明</th>
  6444. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6445. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6446. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  6447. </tbody></table>';
  6448. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  6449. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6450. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6451. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6452. $html .= '<tr><th>' . $value ['name'] . '</th>
  6453. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6454. }
  6455. $html .= '<tr><th class="taR">合计</th>
  6456. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6457. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6458. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6459. $html .= '<tr><th>' . $value ['name'] . '</th>
  6460. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6461. }
  6462. $html .= '<tr><th class="taR">合计</th>
  6463. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6464. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6465. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6466. $html .= '<tr><th>' . $value ['name'] . '</th>
  6467. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6468. }
  6469. $html .= '<tr><th class="taR">合计</th>
  6470. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6471. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6472. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6473. $html .= '<tr><th>' . $value ['name'] . '</th>
  6474. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6475. }
  6476. $html .= '<tr><th class="taR">合计</th>
  6477. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6478. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6479. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6480. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6481. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6482. }
  6483. $html .= '<tr><th class="taR">合计</th>
  6484. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6485. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6486. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6487. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6488. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6489. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6490. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6491. <tr';
  6492. if ($rinfo ['relust'] >= 0) {
  6493. $html .= 'class="success"';
  6494. } else {
  6495. $html .= 'class="error"';
  6496. }
  6497. $html .= '><td class="taR"><b>借款结余</b></td>
  6498. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  6499. </tbody></table>
  6500. ';
  6501. }
  6502. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  6503. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6504. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  6505. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6506. $html .= '<tr><th>' . $value ['name'] . '</th>
  6507. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6508. }
  6509. $html .= '<tr><th class="taR">合计</th>
  6510. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6511. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6512. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6513. <tr><th class="taC" colspan="2">费用说明</th>
  6514. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6515. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6516. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6517. </tbody></table>';
  6518. } else {
  6519. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6520. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6521. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6522. $html .= '<tr><th>' . $value ['name'] . '</th>
  6523. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6524. }
  6525. $html .= '<tr><th class="taR">合计</th>
  6526. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6527. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6528. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6529. $html .= '<tr><th>' . $value ['name'] . '</th>
  6530. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6531. }
  6532. $html .= '<tr><th class="taR">合计</th>
  6533. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6534. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6535. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6536. $html .= '<tr><th>' . $value ['name'] . '</th>
  6537. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6538. }
  6539. $html .= '<tr><th class="taR">合计</th>
  6540. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6541. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6542. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6543. $html .= '<tr><th>' . $value ['name'] . '</th>
  6544. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6545. }
  6546. $html .= '<tr><th class="taR">合计</th>
  6547. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6548. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6549. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6550. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6551. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6552. }
  6553. $html .= '<tr><th class="taR">合计</th>
  6554. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6555. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6556. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6557. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6558. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6559. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6560. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  6561. $html .= '</tbody></table>';
  6562. /*
  6563. * <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>
  6564. */
  6565. }
  6566. // print_r($verifyStaff);die;
  6567. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  6568. foreach ( $verifyStaff as $key => $value ) {
  6569. $key = trim ( strtr ( $key, '_R', ' ' ) );
  6570. $sinfo = $staff->getOne ( array (
  6571. 'select' => 'username',
  6572. 'where' => ' sid=' . $key,
  6573. 'asArray' => true
  6574. ) );
  6575. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6576. }
  6577. $html .= '</tbody></table>';
  6578. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  6579. foreach ( $rinfo ['executeCopy'] as $value ) {
  6580. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6581. }
  6582. $html .= '</tbody></table>';
  6583. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  6584. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  6585. </tr></table>';
  6586. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  6587. echo json_encode ( array (
  6588. 'status' => 1,
  6589. 'html' => $html
  6590. ) );
  6591. die ();
  6592. }
  6593. function remittance() {
  6594. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6595. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6596. Doo::loadModel ( 'receipt' );
  6597. $receipt = new receipt ();
  6598. Doo::loadModel ( 'staff' );
  6599. $staff = new staff ();
  6600. $dateCondition = " and Year(pastDate) =" . $year;
  6601. if (! empty ( $month ))
  6602. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  6603. // get Receipt By verifyID status 1
  6604. $receiptList = $receipt->find ( array (
  6605. 'select' => 'sum(sum) as sum,staff,pastDate',
  6606. 'where' => ' status=1' . $dateCondition,
  6607. 'desc' => 'pastDate',
  6608. 'groupby' => 'staff,pastDate',
  6609. 'asArray' => true
  6610. ) );
  6611. $dateList = $receipt->find ( array (
  6612. 'select' => 'pastDate,verifyStaff',
  6613. 'where' => ' status=1' . $dateCondition,
  6614. 'desc' => 'pastDate',
  6615. 'groupby' => 'pastDate',
  6616. 'asArray' => true
  6617. ) );
  6618. $dataList = array ();
  6619. foreach ( $dateList as $d => $a ) {
  6620. $dataList [$a ['pastDate']] = array ();
  6621. $daySum = 0;
  6622. foreach ( $receiptList as $key => $value ) {
  6623. if ($a ['pastDate'] == $value ['pastDate']) {
  6624. $oderList = $receipt->find ( array (
  6625. 'select' => 'receiptOrder',
  6626. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  6627. 'asArray' => true
  6628. ) );
  6629. $list = array ();
  6630. $html = "";
  6631. foreach ( $oderList as $v ) {
  6632. array_push ( $list, $v ['receiptOrder'] );
  6633. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  6634. }
  6635. $receiptList [$key] ['receiptOrder'] = $html;
  6636. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  6637. $sinfo = $staff->getOne ( array (
  6638. 'select' => 'username ',
  6639. 'where' => ' sid=' . $value ['staff'],
  6640. 'asArray' => true
  6641. ) );
  6642. $receiptList [$key] ['username'] = $sinfo ['username'];
  6643. $daySum += $value ['sum'];
  6644. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  6645. }
  6646. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  6647. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  6648. }
  6649. }
  6650. // print_r($dataList);
  6651. $data ['dataList'] = $dataList;
  6652. $mothHtml = "";
  6653. for($i = 1; $i <= 12; $i ++) {
  6654. if ($month == $i)
  6655. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6656. else
  6657. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6658. }
  6659. $data ['year'] = $year;
  6660. $data ['mothHtml'] = $mothHtml;
  6661. $data ['memu'] = "receipt";
  6662. $data ['staff'] = $this->staff;
  6663. $data ['receiptMemu'] = 'approval';
  6664. $data ['verifyId'] = $this->verifyId;
  6665. $data ['executeId'] = $this->executeId;
  6666. $this->render ( "/admin/saeaReportListPay", $data );
  6667. }
  6668. function revocationAdjustment() {
  6669. $sid = isset ( $this->params ['sid'] ) && is_numeric ( $this->params ['sid'] ) ? $this->params ['sid'] : 0;
  6670. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  6671. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6672. // echo $price;die;
  6673. if ((! empty ( $sid )) && ($price != - 99999) && (! empty ( $rid ))) {
  6674. Doo::loadModel ( 'receipt' );
  6675. $receipt = new receipt ();
  6676. $receiptDetail = $receipt->getOne ( array (
  6677. 'where' => 'rid=' . $rid,
  6678. 'asArray' => true
  6679. ) );
  6680. if (empty ( $receiptDetail ['reviseDetail'] ))
  6681. return "/approval";
  6682. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  6683. $RD = array ();
  6684. foreach ( $reviseDetail as $key => $value ) {
  6685. if ($value ['price'] == $price && $value ['sid'] == $sid)
  6686. continue;
  6687. array_push ( $RD, $value );
  6688. }
  6689. $reviseDetailString = json_encode ( $RD );
  6690. $receipt->reviseDetail = $reviseDetailString;
  6691. $receipt->sum = $receiptDetail ['sum'] - $price;
  6692. $receipt->revisePrice = $receiptDetail ['revisePrice'] - $price;
  6693. $receipt->update ( array (
  6694. 'where' => 'rid=' . $rid
  6695. ) );
  6696. }
  6697. // approvalEdi/37
  6698. return "/approvalEdi/" . $rid;
  6699. }
  6700. function updateApprovalReceipt() {
  6701. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6702. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  6703. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6704. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  6705. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  6706. if (! empty ( $rid )) {
  6707. Doo::loadModel ( "verify" );
  6708. $verify = new verify ();
  6709. Doo::loadModel ( "receiptDetail" );
  6710. $receiptDetailObj = new receiptDetail ();
  6711. Doo::loadModel ( "itemStatistics" );
  6712. Doo::loadModel ( "statistics" );
  6713. $statistics = new statistics ();
  6714. $itemStatistics = new itemStatistics ();
  6715. Doo::loadModel ( "receipt" );
  6716. $receipt = new receipt ();
  6717. $receiptDetail = $receipt->getOne ( array (
  6718. 'where' => 'rid=' . $rid . ' and status=2 ',
  6719. 'asArray' => true
  6720. ) );
  6721. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  6722. $nsflag = true;
  6723. foreach ( $nslist as $value ) {
  6724. if ($value == $this->staff ['0'] ['sid']) {
  6725. $nsflag = false;
  6726. break;
  6727. }
  6728. }
  6729. if (empty ( $receiptDetail ) || $nsflag)
  6730. return "/approval";
  6731. $verifyDetail = $verify->getOne ( array (
  6732. 'where' => ' vid =' . $receiptDetail ['verify'],
  6733. 'asArray' => true
  6734. ) );
  6735. $verifyString = $verifyDetail ['staff'];
  6736. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  6737. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  6738. if (empty ( $opinion )) {
  6739. if ($status == 3)
  6740. $opinion = "终止";
  6741. else
  6742. $opinion = "同意支付";
  6743. }
  6744. $nowStaff = 0;
  6745. $nowStaffList = array ();
  6746. if (empty ( $verifyStaff )) {
  6747. // 还需加入是否已经进入角色审批
  6748. if ($verifyDetail [0] [1] == 'ROLE') {
  6749. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  6750. foreach ( $vStaffString as $key => $value ) {
  6751. $staffK = explode ( "_", $value );
  6752. if ($staffK [0] != $this->staff [0] ['sid'])
  6753. array_push ( $nowStaffList, $staffK [0] );
  6754. }
  6755. // print_r($verifyDetail);
  6756. // die;
  6757. if (! empty ( $nowStaffList )) {
  6758. $nowStaff = implode ( ',', $nowStaffList );
  6759. $verifyStaff = array (
  6760. $this->staff [0] ['sid'] . "_R" => array (
  6761. 'date' => date ( 'Y-m-d' ),
  6762. 'opinion' => $opinion,
  6763. 'status' => $status,
  6764. 'nextStaff' => $verifyDetail [0] [0],
  6765. 'ROLE' => 1
  6766. )
  6767. );
  6768. } else {
  6769. $nowStaff = $verifyDetail [1] [0];
  6770. $verifyStaff = array (
  6771. $this->staff [0] ['sid'] . "_R" => array (
  6772. 'date' => date ( 'Y-m-d' ),
  6773. 'opinion' => $opinion,
  6774. 'status' => $status,
  6775. 'nextStaff' => $verifyDetail [1] [0]
  6776. )
  6777. );
  6778. }
  6779. } else {
  6780. if ($verifyDetail [1] [1] == 'ROLE') {
  6781. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  6782. // echo "dd";
  6783. foreach ( $vStaffString as $key => $value ) {
  6784. $staffK = explode ( "_", $value );
  6785. array_push ( $nowStaffList, $staffK [0] );
  6786. }
  6787. $nowStaff = implode ( ',', $nowStaffList );
  6788. $verifyStaff = array (
  6789. $this->staff [0] ['sid'] => array (
  6790. 'date' => date ( 'Y-m-d' ),
  6791. 'opinion' => $opinion,
  6792. 'status' => $status,
  6793. 'nextStaff' => $verifyDetail [1] [0],
  6794. 'ROLE' => 1
  6795. )
  6796. );
  6797. } else {
  6798. $nowStaff = $verifyDetail [1] [0];
  6799. $verifyStaff = array (
  6800. $this->staff [0] ['sid'] => array (
  6801. 'date' => date ( 'Y-m-d' ),
  6802. 'opinion' => $opinion,
  6803. 'status' => $status,
  6804. 'nextStaff' => $verifyDetail [1] [0]
  6805. )
  6806. );
  6807. }
  6808. }
  6809. if ($status == 3)
  6810. $verifyStaff = array (
  6811. 'final' => $status,
  6812. $this->staff [0] ['sid'] => array (
  6813. 'date' => date ( 'Y-m-d' ),
  6814. 'opinion' => $opinion,
  6815. 'status' => $status
  6816. )
  6817. );
  6818. $vStaffString = json_encode ( $verifyStaff );
  6819. $receipt->nowStaff = $nowStaff;
  6820. $receipt->verifyStaff = $vStaffString;
  6821. } else {
  6822. $VS = end ( $verifyStaff );
  6823. // 非角色审批
  6824. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  6825. $nextStaff = 0;
  6826. $roleSTF = false;
  6827. foreach ( $verifyDetail as $key => $value ) {
  6828. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  6829. if (isset ( $verifyDetail [$key + 1] )) {
  6830. $nextStaff = $verifyDetail [$key + 1] [0];
  6831. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  6832. $roleSTF = true;
  6833. }
  6834. break;
  6835. }
  6836. }
  6837. if (! $roleSTF) {
  6838. $nowStaff = $nextStaff;
  6839. $verifyStaff [$this->staff [0] ['sid']] = array (
  6840. 'date' => date ( 'Y-m-d' ),
  6841. 'opinion' => $opinion,
  6842. 'status' => $status,
  6843. 'nextStaff' => $nextStaff
  6844. );
  6845. } else {
  6846. // 获取角色下的所有用户ID
  6847. $nowStaffList = array ();
  6848. foreach ( $verifyDetail as $vfk ) {
  6849. if ($vfk [1] == 'ROLE') {
  6850. $vStaffString = json_decode ( $vfk [3] );
  6851. foreach ( $vStaffString as $key => $value ) {
  6852. $staffK = explode ( "_", $value );
  6853. array_push ( $nowStaffList, $staffK [0] );
  6854. }
  6855. }
  6856. }
  6857. $nowStaff = implode ( ',', $nowStaffList );
  6858. $verifyStaff [$this->staff [0] ['sid']] = array (
  6859. 'date' => date ( 'Y-m-d' ),
  6860. 'opinion' => $opinion,
  6861. 'status' => $status,
  6862. 'nextStaff' => $nextStaff,
  6863. 'ROLE' => 0
  6864. );
  6865. }
  6866. if ($status == 3) {
  6867. $verifyStaff ['final'] = $status;
  6868. $verifyStaff [$this->staff [0] ['sid']] = array (
  6869. 'date' => date ( 'Y-m-d' ),
  6870. 'opinion' => $opinion,
  6871. 'status' => $status
  6872. );
  6873. }
  6874. $vStaffString = json_encode ( $verifyStaff );
  6875. $receipt->nowStaff = $nowStaff;
  6876. $receipt->verifyStaff = $vStaffString;
  6877. }
  6878. // 角色审批
  6879. if (isset ( $VS ['ROLE'] )) {
  6880. // 找出角色人 当前审批角色组
  6881. $verifyJSStaff = array ();
  6882. $nowStaffList2 = array ();
  6883. foreach ( $verifyDetail as $key => $value ) {
  6884. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  6885. $verifyJSStaff = json_decode ( $value [3] );
  6886. foreach ( $verifyJSStaff as $m ) {
  6887. $staffK = explode ( "_", $m );
  6888. array_push ( $nowStaffList2, $staffK [0] );
  6889. }
  6890. // print_r($nowStaffList2);
  6891. }
  6892. }
  6893. $RoleVerifyStaff = array ();
  6894. foreach ( $verifyStaff as $key => $value ) {
  6895. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  6896. foreach ( $nowStaffList2 as $m ) {
  6897. if ($key == $m . "_R")
  6898. $RoleVerifyStaff [$key] = $value;
  6899. }
  6900. }
  6901. }
  6902. // print_r($verifyStaff);
  6903. // print_r($nowStaffList2);
  6904. // print_r($RoleVerifyStaff);
  6905. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  6906. // print_r($verifyJSStaff);
  6907. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  6908. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  6909. // 下一个审批人ID
  6910. $nextStaff = 0;
  6911. $falg = false;
  6912. foreach ( $verifyDetail as $key => $value ) {
  6913. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  6914. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  6915. $falg = true;
  6916. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  6917. $nowStaffList = array ();
  6918. foreach ( $vStaffString as $v ) {
  6919. $staffK = explode ( "_", $v );
  6920. array_push ( $nowStaffList, $staffK [0] );
  6921. }
  6922. $nowStaff = implode ( ',', $nowStaffList );
  6923. $nextStaff = $verifyDetail [$key + 1] [0];
  6924. } elseif (isset ( $verifyDetail [$key + 1] )) {
  6925. $nextStaff = $verifyDetail [$key + 1] [0];
  6926. $nowStaff = $nextStaff;
  6927. } else
  6928. $nowStaff = '';
  6929. break;
  6930. }
  6931. }
  6932. if ($falg)
  6933. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6934. 'date' => date ( 'Y-m-d' ),
  6935. 'opinion' => $opinion,
  6936. 'status' => $status,
  6937. 'nextStaff' => $nextStaff,
  6938. 'ROLE' => 1
  6939. );
  6940. else
  6941. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6942. 'date' => date ( 'Y-m-d' ),
  6943. 'opinion' => $opinion,
  6944. 'status' => $status,
  6945. 'nextStaff' => $nextStaff
  6946. );
  6947. // print_r($verifyStaff);
  6948. // echo $nowStaff;die;
  6949. } else { // 进入下一个角色或者审批人
  6950. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  6951. //
  6952. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  6953. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6954. 'date' => date ( 'Y-m-d' ),
  6955. 'opinion' => $opinion,
  6956. 'status' => $status,
  6957. 'nextStaff' => $VS ['nextStaff'],
  6958. 'ROLE' => 1
  6959. );
  6960. // print_r($verifyStaff);
  6961. // die;
  6962. }
  6963. if ($status == 3) {
  6964. $verifyStaff ['final'] = $status;
  6965. $verifyStaff [$this->staff [0] ['sid']] = array (
  6966. 'date' => date ( 'Y-m-d' ),
  6967. 'opinion' => $opinion,
  6968. 'status' => $status
  6969. );
  6970. }
  6971. $vStaffString = json_encode ( $verifyStaff );
  6972. $receipt->verifyStaff = $vStaffString;
  6973. $receipt->nowStaff = $nowStaff;
  6974. // die;
  6975. // }
  6976. // print_r($verifyStaff);
  6977. // die;
  6978. }
  6979. // print_r($verifyStaff);die;
  6980. }
  6981. // print_r($verifyDetail);
  6982. $roleKey = 0;
  6983. $roleId = 0;
  6984. $verifyDetailCopy = array ();
  6985. foreach ( $verifyDetail as $k => $v ) {
  6986. if ($v [1] == 'ROLE') {
  6987. $roleId = $v [0];
  6988. $roleVerify = json_decode ( $v [3], true );
  6989. $roleKey = $k;
  6990. $roleArray = array ();
  6991. foreach ( $roleVerify as $o => $p ) {
  6992. $staffID = explode ( '_', $p );
  6993. $exp = array (
  6994. 0 => $staffID [0],
  6995. 1 => $staffID [1]
  6996. );
  6997. array_push ( $roleArray, $exp );
  6998. }
  6999. $verifyDetailCopy [$v [0]] = $roleArray;
  7000. }
  7001. }
  7002. // print_r($verifyDetail);
  7003. foreach ( $verifyDetailCopy as $k => $v ) {
  7004. foreach ( $verifyDetail as $m => $n ) {
  7005. if ($n [0] == $k) {
  7006. array_splice ( $verifyDetail, $m, 1, $v );
  7007. }
  7008. }
  7009. }
  7010. // die;
  7011. // if (!empty($roleArray))
  7012. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  7013. // echo $roleId;
  7014. // print_r($verifyStaff);
  7015. // print_r($verifyDetail);
  7016. // die;
  7017. Doo::loadModel ( "receiptLog" );
  7018. $receiptLog = new receiptLog ();
  7019. // 审批日志
  7020. if (! isset ( $verifyStaff ['final'] )) {
  7021. if (! empty ( $roleId )) {
  7022. Doo::loadModel ( "role" );
  7023. $role = new role ();
  7024. $roleInfo = $role->getOne ( array (
  7025. 'where' => 'rid=' . $roleId,
  7026. 'asArray' => true
  7027. ) );
  7028. $receiptLog->rolename = $roleInfo ['name'];
  7029. }
  7030. $receiptLog->username = $this->staff [0] ['username'];
  7031. $receiptLog->uid = $this->staff [0] ['sid'];
  7032. $receiptLog->date = date ( "Y-m-d" );
  7033. $receiptLog->opinion = $opinion;
  7034. $receiptLog->img = $this->staff [0] ['avatar'];
  7035. $receiptLog->status = 1;
  7036. $receiptLog->rid = $rid;
  7037. $receiptLog->insert ();
  7038. }
  7039. if (isset ( $verifyStaff ['final'] )) { // rDetail
  7040. $receipt->verifyBreakup = $verifyString;
  7041. $receipt->status = 3;
  7042. $receiptDetailObj->status = 3;
  7043. $receiptDetailObj->update ( array (
  7044. 'where' => 'rid=' . $rid
  7045. ) );
  7046. if (! empty ( $roleId )) {
  7047. Doo::loadModel ( "role" );
  7048. $role = new role ();
  7049. $roleInfo = $role->getOne ( array (
  7050. 'where' => 'rid=' . $roleId,
  7051. 'asArray' => true
  7052. ) );
  7053. $receiptLog->rolename = $roleInfo ['name'];
  7054. }
  7055. $receiptLog->username = $this->staff [0] ['username'];
  7056. $receiptLog->uid = $this->staff [0] ['sid'];
  7057. $receiptLog->date = date ( "Y-m-d" );
  7058. $receiptLog->opinion = $opinion;
  7059. $receiptLog->img = $this->staff [0] ['avatar'];
  7060. $receiptLog->status = 3;
  7061. $receiptLog->rid = $rid;
  7062. $receiptLog->insert ();
  7063. // 微信企业号通知
  7064. $this->setWXMsg ( $rid, 3 );
  7065. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  7066. $receipt->status = 1;
  7067. $reviseSum = 0;
  7068. $receipt->verifyBreakup = $verifyString;
  7069. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  7070. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7071. foreach ( $reviseDetail as $key => $value ) {
  7072. $receiptDetailObj = new receiptDetail ();
  7073. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7074. $receiptDetailObj->item = $value ['description'];
  7075. $receiptDetailObj->itemCategory = "报销金额调整";
  7076. $receiptDetailObj->price = $value ['price'];
  7077. $receiptDetailObj->date = $receiptDetail ['date'];
  7078. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  7079. $receiptDetailObj->rid = $rid;
  7080. $receiptDetailObj->status = 1;
  7081. $receiptDetailObj->insert ();
  7082. $reviseSum += $value ['price'];
  7083. }
  7084. $itemStatistics = new itemStatistics ();
  7085. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7086. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7087. $itemStatistics->price = $reviseSum;
  7088. $itemStatistics->itemCategory = "报销金额调整";
  7089. $itemStatistics->date = $receiptDetail ['date'];
  7090. $itemStatistics->insert ();
  7091. }
  7092. $receiptDetailObj = new receiptDetail ();
  7093. $receiptDetailObj->status = 1;
  7094. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  7095. $receiptDetailObj->update ( array (
  7096. 'where' => 'rid=' . $rid
  7097. ) );
  7098. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7099. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7100. $stat = $statistics->getOne ( array (
  7101. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  7102. 'asArray' => true
  7103. ) );
  7104. if (empty ( $stat )) {
  7105. $statistics->date = $receiptDetail ['date'];
  7106. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7107. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7108. $statistics->agPrice = $receiptDetail ['sum'];
  7109. $statistics->rePrice = $reviseSum;
  7110. $statistics->insert ();
  7111. } else {
  7112. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  7113. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  7114. $statistics->update ( array (
  7115. 'where' => 'sid=' . $stat ['sid']
  7116. ) );
  7117. }
  7118. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7119. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7120. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  7121. foreach ( $accountItem ['cSum'] as $key => $value ) {
  7122. if ($key == "agencySum") {
  7123. $iStatistics = $itemStatistics->getOne ( array (
  7124. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  7125. 'asArray' => true
  7126. ) );
  7127. if (empty ( $iStatistics )) {
  7128. $itemStatistics->cid = $receiptDetail ['cid'];
  7129. ;
  7130. $itemStatistics->staff = $receiptDetail ['staff'];
  7131. $itemStatistics->price = $value;
  7132. $itemStatistics->itemCategory = $this->AGENCY;
  7133. $itemStatistics->date = $receiptDetail ['date'];
  7134. $itemStatistics->insert ();
  7135. } else {
  7136. if (! empty ( $value )) {
  7137. $itemStatistics->price = $value + $iStatistics ['price'];
  7138. $itemStatistics->update ( array (
  7139. 'where' => 'sid=' . $iStatistics ['sid']
  7140. ) );
  7141. }
  7142. }
  7143. } elseif ($key == "travelSum") {
  7144. $iStatistics = $itemStatistics->getOne ( array (
  7145. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  7146. 'asArray' => true
  7147. ) );
  7148. if (empty ( $iStatistics )) {
  7149. $itemStatistics->cid = $receiptDetail ['cid'];
  7150. $itemStatistics->staff = $receiptDetail ['staff'];
  7151. $itemStatistics->price = $value;
  7152. $itemStatistics->itemCategory = $this->TRAVEL;
  7153. $itemStatistics->date = $receiptDetail ['date'];
  7154. $itemStatistics->insert ();
  7155. } else {
  7156. if (! empty ( $value )) {
  7157. $itemStatistics->price = $value + $iStatistics ['price'];
  7158. $itemStatistics->update ( array (
  7159. 'where' => 'sid=' . $iStatistics ['sid']
  7160. ) );
  7161. }
  7162. }
  7163. } elseif ($key == "trainSum") {
  7164. $iStatistics = $itemStatistics->getOne ( array (
  7165. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  7166. 'asArray' => true
  7167. ) );
  7168. if (empty ( $iStatistics )) {
  7169. $itemStatistics->cid = $receiptDetail ['cid'];
  7170. $itemStatistics->staff = $receiptDetail ['staff'];
  7171. $itemStatistics->price = $value;
  7172. $itemStatistics->itemCategory = $this->TRAIN;
  7173. $itemStatistics->date = $receiptDetail ['date'];
  7174. $itemStatistics->insert ();
  7175. } else {
  7176. if (! empty ( $value )) {
  7177. $itemStatistics->price = $value + $iStatistics ['price'];
  7178. $itemStatistics->update ( array (
  7179. 'where' => 'sid=' . $iStatistics ['sid']
  7180. ) );
  7181. }
  7182. }
  7183. } elseif ($key == "otherSum") {
  7184. $iStatistics = $itemStatistics->getOne ( array (
  7185. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  7186. 'asArray' => true
  7187. ) );
  7188. if (empty ( $iStatistics )) {
  7189. $itemStatistics->cid = $receiptDetail ['cid'];
  7190. $itemStatistics->staff = $receiptDetail ['staff'];
  7191. $itemStatistics->price = $value;
  7192. $itemStatistics->itemCategory = $this->OTHER;
  7193. $itemStatistics->date = $receiptDetail ['date'];
  7194. $itemStatistics->insert ();
  7195. } else {
  7196. if (! empty ( $value )) {
  7197. $itemStatistics->price = $value + $iStatistics ['price'];
  7198. $itemStatistics->update ( array (
  7199. 'where' => 'sid=' . $iStatistics ['sid']
  7200. ) );
  7201. }
  7202. }
  7203. }
  7204. }
  7205. $receipt->pastDate = date ( "Y-m-d" );
  7206. // 微信企业号通知
  7207. $this->setWXMsg ( $rid, 1 );
  7208. }
  7209. $receipt->amount = $amount;
  7210. $receipt->update ( array (
  7211. 'where' => ' rid = ' . $rid
  7212. ) );
  7213. // 进入下一条审批费用新加需求
  7214. $vidList = array ();
  7215. $verifyDetail = $verify->find ( array (
  7216. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  7217. 'asArray' => true
  7218. ) );
  7219. foreach ( $verifyDetail as $key => $value ) {
  7220. array_push ( $vidList, $value ['vid'] );
  7221. }
  7222. $vid = implode ( ",", $vidList );
  7223. if (empty ( $verifyDetail ))
  7224. $vid = 0;
  7225. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  7226. $receipt=new receipt();
  7227. $rd = $receipt->getOne ( array (
  7228. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  7229. 'asc' => 'rid',
  7230. 'asArray' => true
  7231. ) );
  7232. if (empty ( $rd )) {
  7233. return '/approvalExpenses/pendApproval';
  7234. }
  7235. if ($rd ['Rtype'] == 1) {
  7236. if ($rd ['isBK'] == 1) {
  7237. return '/receiptburEdi/' . $rd ['rid'];
  7238. } else {
  7239. return '/expensesEdi/' . $rd ['rid'];
  7240. }
  7241. } elseif ($rd ['Rtype'] == 2) {
  7242. return '/remitApproval/' . $rd ['rid'];
  7243. } else {
  7244. return '/receiptburEdi/' . $rd ['rid'];
  7245. }
  7246. //return "/approvalExpenses/pendApproval";
  7247. }
  7248. }
  7249. function expensesRetreats() {
  7250. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7251. if (! empty ( $rid )) {
  7252. // 操作记录
  7253. Doo::loadModel ( "receipt" );
  7254. $receipt = new receipt ();
  7255. Doo::loadModel ( "receiptLog" );
  7256. $receiptLog = new receiptLog ();
  7257. Doo::loadModel ( "verify" );
  7258. $verify = new verify ();
  7259. $receiptInfo = $receipt->getOne ( array (
  7260. 'where' => 'rid=' . $rid,
  7261. 'asArray' => true
  7262. ) );
  7263. $vr = $verify->getOne ( array (
  7264. 'where' => 'vid=' . $receiptInfo ['verify'],
  7265. 'asArray' => true
  7266. ) );
  7267. $jd = json_decode ( $vr ['staff'] );
  7268. $roleId = 0;
  7269. foreach ( $jd as $key => $value ) {
  7270. if ($value [1] == 'ROLE') {
  7271. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7272. if ($pos !== false) {
  7273. $roleId = $value [0];
  7274. }
  7275. }
  7276. }
  7277. // 审批日志
  7278. // echo $roleId;die;
  7279. if (! empty ( $roleId )) {
  7280. Doo::loadModel ( "role" );
  7281. $role = new role ();
  7282. $roleInfo = $role->getOne ( array (
  7283. 'where' => 'rid=' . $roleId,
  7284. 'asArray' => true
  7285. ) );
  7286. $receiptLog->rolename = $roleInfo ['name'];
  7287. }
  7288. $receiptLog->username = $this->staff [0] ['username'];
  7289. $receiptLog->uid = $this->staff [0] ['sid'];
  7290. $receiptLog->date = date ( "Y-m-d" );
  7291. $receiptLog->opinion = '撤回';
  7292. $receiptLog->img = $this->staff [0] ['avatar'];
  7293. $receiptLog->status = 4;
  7294. $receiptLog->rid = $rid;
  7295. $receiptLog->insert ();
  7296. $receipt->status = 4;
  7297. $receipt->update ( array (
  7298. 'where' => 'rid=' . $rid
  7299. ) );
  7300. // 微信企业号通知
  7301. $this->setWXMsg ( $rid, 2 );
  7302. }
  7303. // echo "ddd";
  7304. return '/approvalExpenses/pendApproval';
  7305. }
  7306. function updateCheReceipt() {
  7307. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7308. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7309. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  7310. if (! empty ( $rid )) {
  7311. // 操作记录
  7312. Doo::loadModel ( "receipt" );
  7313. $receipt = new receipt ();
  7314. Doo::loadModel ( "receiptLog" );
  7315. $receiptLog = new receiptLog ();
  7316. Doo::loadModel ( "verify" );
  7317. $verify = new verify ();
  7318. $receiptInfo = $receipt->getOne ( array (
  7319. 'where' => 'rid=' . $rid . ' and status=2',
  7320. 'asArray' => true
  7321. ) );
  7322. if (empty ( $receiptInfo )) {
  7323. echo json_encode ( array (
  7324. 'status' => 2
  7325. ) );
  7326. die ();
  7327. }
  7328. $vr = $verify->getOne ( array (
  7329. 'where' => 'vid=' . $receiptInfo ['verify'],
  7330. 'asArray' => true
  7331. ) );
  7332. $jd = json_decode ( $vr ['staff'] );
  7333. $roleId = 0;
  7334. foreach ( $jd as $key => $value ) {
  7335. if ($value [1] == 'ROLE') {
  7336. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7337. if ($pos !== false) {
  7338. $roleId = $value [0];
  7339. }
  7340. }
  7341. }
  7342. // 审批日志
  7343. // echo $roleId;die;
  7344. if (! empty ( $roleId )) {
  7345. Doo::loadModel ( "role" );
  7346. $role = new role ();
  7347. $roleInfo = $role->getOne ( array (
  7348. 'where' => 'rid=' . $roleId,
  7349. 'asArray' => true
  7350. ) );
  7351. $receiptLog->rolename = $roleInfo ['name'];
  7352. }
  7353. $receiptLog->username = $this->staff [0] ['username'];
  7354. $receiptLog->uid = $this->staff [0] ['sid'];
  7355. $receiptLog->date = date ( "Y-m-d" );
  7356. $receiptLog->opinion = $opinion;
  7357. $receiptLog->img = $this->staff [0] ['avatar'];
  7358. $receiptLog->status = 4;
  7359. $receiptLog->rid = $rid;
  7360. $receiptLog->insert ();
  7361. $receipt->status = 4;
  7362. $receipt->update ( array (
  7363. 'where' => 'rid=' . $rid
  7364. ) );
  7365. // 微信企业号通知
  7366. $this->setWXMsg ( $rid, 2 );
  7367. echo json_encode ( array (
  7368. 'status' => 1
  7369. ) );
  7370. // Header("HTTP/1.1 303 See Other");
  7371. // Header("Location: /approvalExpenses/pendApproval");
  7372. die ();
  7373. }
  7374. echo json_encode ( array (
  7375. 'status' => 2
  7376. ) );
  7377. die ();
  7378. // echo "ddd";
  7379. // return '/saeaBorad';
  7380. }
  7381. function revisePrice() {
  7382. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  7383. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  7384. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7385. // echo $price;die;
  7386. if (! empty ( $rid )) {
  7387. Doo::loadModel ( "receipt" );
  7388. $receipt = new receipt ();
  7389. $receiptDetail = $receipt->getOne ( array (
  7390. 'where' => 'rid=' . $rid . ' and status=2 ',
  7391. 'asArray' => true
  7392. ) );
  7393. if (empty ( $receiptDetail ))
  7394. return "/approval";
  7395. $reviseDetail = array ();
  7396. if (empty ( $receiptDetail ['reviseDetail'] )) {
  7397. array_push ( $reviseDetail, array (
  7398. 'sid' => $this->staff [0] ['sid'],
  7399. 'name' => $this->staff [0] ['username'],
  7400. 'description' => $description,
  7401. 'price' => $price
  7402. ) );
  7403. $reviseDetailString = json_encode ( $reviseDetail );
  7404. $receipt->reviseDetail = $reviseDetailString;
  7405. $receipt->revisePrice = $price;
  7406. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7407. } else {
  7408. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7409. array_push ( $reviseDetail, array (
  7410. 'sid' => $this->staff [0] ['sid'],
  7411. 'name' => $this->staff [0] ['username'],
  7412. 'description' => $description,
  7413. 'price' => $price
  7414. ) );
  7415. $reviseDetailString = json_encode ( $reviseDetail );
  7416. $receipt->reviseDetail = $reviseDetailString;
  7417. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  7418. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7419. }
  7420. $receipt->update ( array (
  7421. 'where' => 'rid=' . $rid
  7422. ) );
  7423. }
  7424. return '/approvalEdi/' . $rid;
  7425. }
  7426. function personalCollect() {
  7427. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7428. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  7429. $this->showCache ( $path );
  7430. Doo::loadModel ( "receiptDetail" );
  7431. Doo::loadModel ( "itemStatistics" );
  7432. Doo::loadModel ( 'statistics' );
  7433. $statistics = new statistics ();
  7434. $itemStatistics = new itemStatistics ();
  7435. $receiptDetail = new receiptDetail ();
  7436. $receiptCollectList = $receiptDetail->find ( array (
  7437. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7438. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7439. 'groupby' => 'itemCategory,Month(date)',
  7440. 'asArray' => true
  7441. ) );
  7442. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  7443. 'where' => 'staff=' . $this->staff [0] ['sid'],
  7444. 'asArray' => true
  7445. ) );
  7446. // create collect html
  7447. $collectArray = array (
  7448. '日常相关费用' => array (),
  7449. '差旅相关费用' => array (),
  7450. '培训班费用' => array (),
  7451. '其他' => array ()
  7452. );
  7453. $adjustment = array ();
  7454. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  7455. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7456. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  7457. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7458. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  7459. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7460. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  7461. array_push ( $collectArray ['其他'], $collectHtml );
  7462. $data ['collectArray'] = $collectArray;
  7463. // statistics html
  7464. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7465. if (empty ( $stList ))
  7466. $stList = array (
  7467. 'rePrice' => 0,
  7468. 'agPrice' => 0
  7469. );
  7470. $data ['stList'] = array (
  7471. 'rePrice' => $stList ['rePrice'],
  7472. 'agPrice' => $stList ['agPrice'],
  7473. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7474. );
  7475. // Adjustment price html
  7476. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7477. array_push ( $adjustment, $collectHtml );
  7478. $data ['adjustment'] = $adjustment;
  7479. // total price html
  7480. $collectHtml = "";
  7481. $total = 0;
  7482. for($i = 1; $i <= 12; $i ++) {
  7483. $sumPrice = 0;
  7484. foreach ( $receiptCollectList as $key => $value ) {
  7485. if ($value ['month'] == $i) {
  7486. $sumPrice += $value ['price'];
  7487. }
  7488. }
  7489. if ($sumPrice == 0)
  7490. $collectHtml .= '<td class="taR">-</td>';
  7491. else
  7492. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7493. $total += $sumPrice;
  7494. }
  7495. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7496. $data ['totalPrice'] = $collectHtml;
  7497. $data ['year'] = $year;
  7498. $data ['totalYear'] = $total;
  7499. $data ['memu'] = "receipt";
  7500. $data ['staff'] = $this->staff;
  7501. $data ['receiptMemu'] = 'personalCollect';
  7502. $data ['verifyId'] = $this->verifyId;
  7503. $data ['executeId'] = $this->executeId;
  7504. // year staff status 2,4
  7505. if ($year < date ( "Y" )) {
  7506. Doo::loadModel ( 'receipt' );
  7507. $receipt = new receipt ();
  7508. $receiptList = $receipt->find ( array (
  7509. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7510. 'asArray' => true
  7511. ) );
  7512. if (empty ( $receiptList )) {
  7513. ob_start ();
  7514. $this->render ( "/admin/saea_slist_collect", $data );
  7515. $this->cacheFile ( $path );
  7516. die ();
  7517. }
  7518. }
  7519. $this->render ( "/admin/saea_slist_collect", $data );
  7520. }
  7521. function personalCollectDetail() {
  7522. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7523. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  7524. $this->showCache ( $path );
  7525. Doo::loadModel ( "receiptDetail" );
  7526. Doo::loadModel ( "itemStatistics" );
  7527. Doo::loadModel ( 'statistics' );
  7528. Doo::loadModel ( 'accountItem' );
  7529. $accountItem = new accountItem ();
  7530. $statistics = new statistics ();
  7531. $itemStatistics = new itemStatistics ();
  7532. $receiptDetail = new receiptDetail ();
  7533. $receiptCollectList = $receiptDetail->find ( array (
  7534. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  7535. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7536. 'groupby' => 'item,Month(date)',
  7537. 'asArray' => true
  7538. ) );
  7539. $accountList = $accountItem->find ( array (
  7540. 'asArray' => true
  7541. ) );
  7542. // create CollectDetail HTML
  7543. $collectHtml = array ();
  7544. foreach ( $accountList as $key => $value ) {
  7545. $html = "";
  7546. $asum = 0;
  7547. for($i = 1; $i <= 12; $i ++) {
  7548. $falg = true;
  7549. foreach ( $receiptCollectList as $v ) {
  7550. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7551. $asum += $v ['price'];
  7552. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7553. $falg = false;
  7554. break;
  7555. }
  7556. }
  7557. if ($falg)
  7558. $html .= '<td class="taR">-</td>';
  7559. }
  7560. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7561. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7562. }
  7563. $data ['collectHtml'] = $collectHtml;
  7564. // create Adjustment price html
  7565. $receiptCollectList = $receiptDetail->find ( array (
  7566. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7567. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7568. 'groupby' => 'itemCategory,Month(date)',
  7569. 'asArray' => true
  7570. ) );
  7571. $adjustment = array ();
  7572. $collectArray = array (
  7573. '日常相关费用' => array (),
  7574. '差旅相关费用' => array (),
  7575. '培训班费用' => array (),
  7576. '其他' => array ()
  7577. );
  7578. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7579. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7580. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7581. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7582. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7583. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7584. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7585. array_push ( $collectArray ['其他'], $collectHtml );
  7586. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7587. array_push ( $adjustment, $collectHtml );
  7588. // total price html
  7589. $collectHtml = "";
  7590. $total = 0;
  7591. for($i = 1; $i <= 12; $i ++) {
  7592. $sumPrice = 0;
  7593. foreach ( $receiptCollectList as $key => $value ) {
  7594. if ($value ['month'] == $i) {
  7595. $sumPrice += $value ['price'];
  7596. }
  7597. }
  7598. if ($sumPrice == 0)
  7599. $collectHtml .= '<td class="taR">-</td>';
  7600. else
  7601. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7602. $total += $sumPrice;
  7603. }
  7604. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7605. // statistics html
  7606. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7607. if (empty ( $stList ))
  7608. $stList = array (
  7609. 'rePrice' => 0,
  7610. 'agPrice' => 0
  7611. );
  7612. $data ['stList'] = array (
  7613. 'rePrice' => $stList ['rePrice'],
  7614. 'agPrice' => $stList ['agPrice'],
  7615. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7616. );
  7617. $data ['collectArray'] = $collectArray;
  7618. $data ['adjustment'] = $adjustment;
  7619. $data ['totalPrice'] = $collectHtml;
  7620. $data ['totalYear'] = $total;
  7621. $data ['year'] = $year;
  7622. $data ['memu'] = "receipt";
  7623. $data ['staff'] = $this->staff;
  7624. $data ['receiptMemu'] = 'personalCollect';
  7625. $data ['verifyId'] = $this->verifyId;
  7626. $data ['executeId'] = $this->executeId;
  7627. // year staff status 2,4
  7628. if ($year < date ( "Y" )) {
  7629. Doo::loadModel ( 'receipt' );
  7630. $receipt = new receipt ();
  7631. $receiptList = $receipt->find ( array (
  7632. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7633. 'asArray' => true
  7634. ) );
  7635. if (empty ( $receiptList )) {
  7636. ob_start ();
  7637. $this->render ( "/admin/saeaCollectArticles", $data );
  7638. $this->cacheFile ( $path );
  7639. die ();
  7640. }
  7641. }
  7642. $this->render ( "/admin/saeaCollectArticles", $data );
  7643. }
  7644. function companyCategoryCollect() {
  7645. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7646. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  7647. $this->showCache ( $path );
  7648. Doo::loadModel ( 'L_category' );
  7649. Doo::loadModel ( 'itemStatistics' );
  7650. Doo::loadModel ( 'statistics' );
  7651. $statistics = new statistics ();
  7652. $Lcategory = new L_category ();
  7653. $itemStatistics = new itemStatistics ();
  7654. $LcategoryList = $Lcategory->find ( array (
  7655. 'asArray' => true
  7656. ) ); // 'staff='.$this->staff[0]['sid']." and
  7657. $itemStatisticsList = $itemStatistics->find ( array (
  7658. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7659. 'where' => " Year(date)=" . $year,
  7660. 'groupby' => 'cid,Month(date)',
  7661. 'asArray' => true
  7662. ) );
  7663. // ceatre companyCollectHtml
  7664. foreach ( $LcategoryList as $value ) {
  7665. $html = "";
  7666. $asum = 0;
  7667. for($i = 1; $i <= 12; $i ++) {
  7668. $falg = true;
  7669. foreach ( $itemStatisticsList as $v ) {
  7670. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  7671. $asum += $v ['price'];
  7672. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7673. $falg = false;
  7674. break;
  7675. }
  7676. }
  7677. if ($falg)
  7678. $html .= '<td class="taR">-</td>';
  7679. }
  7680. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7681. $collectHtml [$value ['title']] = array (
  7682. 'html' => $html,
  7683. 'cid' => $value ['cid']
  7684. );
  7685. }
  7686. $data ['companyHtml'] = $collectHtml;
  7687. // total price html
  7688. $collectHtml = "";
  7689. $total = 0;
  7690. for($i = 1; $i <= 12; $i ++) {
  7691. $sumPrice = 0;
  7692. foreach ( $itemStatisticsList as $key => $value ) {
  7693. if ($value ['month'] == $i) {
  7694. $sumPrice += $value ['price'];
  7695. }
  7696. }
  7697. if ($sumPrice == 0)
  7698. $collectHtml .= '<td class="taR">-</td>';
  7699. else
  7700. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7701. $total += $sumPrice;
  7702. }
  7703. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7704. $data ['companyTotalHtml'] = $collectHtml;
  7705. $data ['total'] = $total;
  7706. // statistics html
  7707. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7708. if (empty ( $stList ))
  7709. $stList = array (
  7710. 'rePrice' => 0,
  7711. 'agPrice' => 0
  7712. );
  7713. $data ['stList'] = array (
  7714. 'rePrice' => $stList ['rePrice'],
  7715. 'agPrice' => $stList ['agPrice'],
  7716. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7717. );
  7718. $data ['year'] = $year;
  7719. $data ['memu'] = "receipt";
  7720. $data ['staff'] = $this->staff;
  7721. $data ['receiptMemu'] = 'companyCategoryCollect';
  7722. $data ['verifyId'] = $this->verifyId;
  7723. $data ['executeId'] = $this->executeId;
  7724. // year staff status 2,4
  7725. if ($year < date ( "Y" )) {
  7726. Doo::loadModel ( 'receipt' );
  7727. $receipt = new receipt ();
  7728. $receiptList = $receipt->find ( array (
  7729. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  7730. 'asArray' => true
  7731. ) );
  7732. if (empty ( $receiptList )) {
  7733. ob_start ();
  7734. $this->render ( "/admin/saeaCompanyCollect", $data );
  7735. $this->cacheFile ( $path );
  7736. die ();
  7737. }
  7738. }
  7739. $this->render ( "/admin/saeaCompanyCollect", $data );
  7740. }
  7741. function categoryCollectDetail() {
  7742. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7743. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  7744. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  7745. $this->showCache ( $path );
  7746. Doo::loadModel ( 'statistics' );
  7747. $statistics = new statistics ();
  7748. Doo::loadModel ( "receiptDetail" );
  7749. $receiptDetail = new receiptDetail ();
  7750. Doo::loadModel ( 'L_category' );
  7751. $Lcategory = new L_category ();
  7752. Doo::loadModel ( 'accountItem' );
  7753. $accountItem = new accountItem ();
  7754. $LcategoryList = $Lcategory->find ( array (
  7755. 'asArray' => true
  7756. ) );
  7757. if ($cid == 0) {
  7758. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7759. if ($cid == 0)
  7760. $cid = $LcategoryList [0] ['cid'];
  7761. }
  7762. $data ['LcategoryList'] = $LcategoryList;
  7763. $receiptCollectList = $receiptDetail->find ( array (
  7764. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  7765. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7766. 'groupby' => 'item,Month(pastDate)',
  7767. 'asArray' => true
  7768. ) );
  7769. $accountList = $accountItem->find ( array (
  7770. 'asArray' => true
  7771. ) );
  7772. // create CollectDetail HTML
  7773. $collectHtml = array ();
  7774. foreach ( $accountList as $key => $value ) {
  7775. $html = "";
  7776. $asum = 0;
  7777. for($i = 1; $i <= 12; $i ++) {
  7778. $falg = true;
  7779. foreach ( $receiptCollectList as $v ) {
  7780. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7781. $asum += $v ['price'];
  7782. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7783. $falg = false;
  7784. break;
  7785. }
  7786. }
  7787. if ($falg)
  7788. $html .= '<td class="taR">-</td>';
  7789. }
  7790. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7791. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7792. }
  7793. $data ['collectHtml'] = $collectHtml;
  7794. // create Adjustment price html
  7795. $receiptCollectList = $receiptDetail->find ( array (
  7796. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  7797. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7798. 'groupby' => 'itemCategory,Month(pastDate)',
  7799. 'asArray' => true
  7800. ) );
  7801. $adjustment = array ();
  7802. $collectArray = array (
  7803. '日常相关费用' => array (),
  7804. '差旅相关费用' => array (),
  7805. '培训班费用' => array (),
  7806. '其他' => array ()
  7807. );
  7808. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7809. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7810. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7811. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7812. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7813. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7814. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7815. array_push ( $collectArray ['其他'], $collectHtml );
  7816. $data ['collectArray'] = $collectArray;
  7817. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7818. array_push ( $adjustment, $collectHtml );
  7819. $data ['adjustment'] = $adjustment;
  7820. // total price html
  7821. $collectHtml = "";
  7822. $total = 0;
  7823. for($i = 1; $i <= 12; $i ++) {
  7824. $sumPrice = 0;
  7825. foreach ( $receiptCollectList as $key => $value ) {
  7826. if ($value ['month'] == $i) {
  7827. $sumPrice += $value ['price'];
  7828. }
  7829. }
  7830. if ($sumPrice == 0)
  7831. $collectHtml .= '<td class="taR">-</td>';
  7832. else
  7833. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7834. $total += $sumPrice;
  7835. }
  7836. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7837. // statistics html
  7838. $stList = $statistics->statisticsByCid ( $year, $cid );
  7839. if (empty ( $stList ))
  7840. $stList = array (
  7841. 'rePrice' => 0,
  7842. 'agPrice' => 0
  7843. );
  7844. $data ['stList'] = array (
  7845. 'rePrice' => $stList ['rePrice'],
  7846. 'agPrice' => $stList ['agPrice'],
  7847. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7848. );
  7849. $data ['totalYear'] = $total;
  7850. $data ['year'] = $year;
  7851. $data ['cid'] = $cid;
  7852. $data ['memu'] = "receipt";
  7853. $data ['staff'] = $this->staff;
  7854. $data ['receiptMemu'] = 'companyCategoryCollect';
  7855. $data ['verifyId'] = $this->verifyId;
  7856. $data ['executeId'] = $this->executeId;
  7857. // year staff status 2,4
  7858. if ($year < date ( "Y" )) {
  7859. Doo::loadModel ( 'receipt' );
  7860. $receipt = new receipt ();
  7861. $receiptList = $receipt->find ( array (
  7862. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  7863. 'asArray' => true
  7864. ) );
  7865. if (empty ( $receiptList )) {
  7866. ob_start ();
  7867. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7868. $this->cacheFile ( $path );
  7869. die ();
  7870. }
  7871. }
  7872. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7873. }
  7874. function staffCollect() {
  7875. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7876. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  7877. // $this->showCache($path);
  7878. Doo::loadModel ( 'statistics' );
  7879. $statistics = new statistics ();
  7880. Doo::loadModel ( "receiptDetail" );
  7881. $receiptDetail = new receiptDetail ();
  7882. Doo::loadModel ( 'L_category' );
  7883. $Lcategory = new L_category ();
  7884. Doo::loadModel ( 'accountItem' );
  7885. $accountItem = new accountItem ();
  7886. Doo::loadModel ( 'staff' );
  7887. $staff = new staff ();
  7888. Doo::loadModel ( 'itemStatistics' );
  7889. $itemStatistics = new itemStatistics ();
  7890. /*
  7891. * $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']));
  7892. */
  7893. // statistics html
  7894. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7895. if (empty ( $stList ))
  7896. $stList = array (
  7897. 'rePrice' => 0,
  7898. 'agPrice' => 0
  7899. );
  7900. $data ['stList'] = array (
  7901. 'rePrice' => $stList ['rePrice'],
  7902. 'agPrice' => $stList ['agPrice'],
  7903. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7904. );
  7905. // ---
  7906. $staffList = $staff->find ( array (
  7907. 'where' => 'username !="admin"',
  7908. 'asArray' => true
  7909. ) );
  7910. $LcategoryList = $Lcategory->find ( array (
  7911. 'asArray' => true
  7912. ) ); // 'staff='.$this->staff[0]['sid']." and
  7913. $itemStatisticsList = $itemStatistics->find ( array (
  7914. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7915. 'where' => " Year(date)=" . $year,
  7916. 'groupby' => 'staff,Month(date)',
  7917. 'asArray' => true
  7918. ) );
  7919. $categoryList = $staff->find ( array (
  7920. 'select' => 'COUNT(*) as count,cid,category',
  7921. 'where' => 'username !="admin"',
  7922. 'groupby' => 'cid',
  7923. 'asArray' => true
  7924. ) );
  7925. // print_r($itemStatisticsList);die;
  7926. // ceatre companyCollectHtml
  7927. foreach ( $categoryList as $vlu ) {
  7928. $count = $vlu ['count'] + 1;
  7929. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  7930. $m1 = 0;
  7931. $m2 = 0;
  7932. $m3 = 0;
  7933. $m4 = 0;
  7934. $m5 = 0;
  7935. $m6 = 0;
  7936. $m7 = 0;
  7937. $m8 = 0;
  7938. $m9 = 0;
  7939. $m10 = 0;
  7940. $m11 = 0;
  7941. $m12 = 0;
  7942. $m13 = 0;
  7943. foreach ( $staffList as $value ) {
  7944. if ($vlu ['cid'] == $value ['cid']) {
  7945. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  7946. $asum = 0;
  7947. for($i = 1; $i <= 12; $i ++) {
  7948. $falg = true;
  7949. foreach ( $itemStatisticsList as $v ) {
  7950. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  7951. if ($v ['month'] == 1)
  7952. $m1 += $v ['price'];
  7953. if ($v ['month'] == 2)
  7954. $m2 += $v ['price'];
  7955. if ($v ['month'] == 3)
  7956. $m3 += $v ['price'];
  7957. if ($v ['month'] == 4)
  7958. $m4 += $v ['price'];
  7959. if ($v ['month'] == 5)
  7960. $m5 += $v ['price'];
  7961. if ($v ['month'] == 6)
  7962. $m6 += $v ['price'];
  7963. if ($v ['month'] == 7)
  7964. $m7 += $v ['price'];
  7965. if ($v ['month'] == 8)
  7966. $m8 += $v ['price'];
  7967. if ($v ['month'] == 9)
  7968. $m9 += $v ['price'];
  7969. if ($v ['month'] == 10)
  7970. $m10 += $v ['price'];
  7971. if ($v ['month'] == 11)
  7972. $m11 += $v ['price'];
  7973. if ($v ['month'] == 12)
  7974. $m12 += $v ['price'];
  7975. $asum += $v ['price'];
  7976. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7977. $falg = false;
  7978. break;
  7979. }
  7980. }
  7981. if ($falg)
  7982. $html .= '<td class="taR">-</td>';
  7983. }
  7984. $m13 += $asum;
  7985. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7986. $collectHtml [$value ['username']] = array (
  7987. 'html' => $html,
  7988. 'sid' => $value ['sid']
  7989. );
  7990. $html = "";
  7991. }
  7992. }
  7993. $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>
  7994. <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>
  7995. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  7996. $collectHtml [$vlu ['cid']] = array (
  7997. 'html' => $hl,
  7998. 'sid' => ''
  7999. );
  8000. }
  8001. $data ['companyHtml'] = $collectHtml;
  8002. // total price html
  8003. $collectHtml = "";
  8004. $total = 0;
  8005. for($i = 1; $i <= 12; $i ++) {
  8006. $sumPrice = 0;
  8007. foreach ( $itemStatisticsList as $key => $value ) {
  8008. if ($value ['month'] == $i) {
  8009. $sumPrice += $value ['price'];
  8010. }
  8011. }
  8012. if ($sumPrice == 0)
  8013. $collectHtml .= '<td class="taR">-</td>';
  8014. else
  8015. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8016. $total += $sumPrice;
  8017. }
  8018. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8019. $data ['companyTotalHtml'] = $collectHtml;
  8020. $data ['total'] = $total;
  8021. $data ['year'] = $year;
  8022. $data ['memu'] = "receipt";
  8023. $data ['staff'] = $this->staff;
  8024. $data ['receiptMemu'] = 'companyCategoryCollect';
  8025. $data ['verifyId'] = $this->verifyId;
  8026. $data ['executeId'] = $this->executeId;
  8027. if ($year <= date ( "Y" )) {
  8028. Doo::loadModel ( 'receipt' );
  8029. $receipt = new receipt ();
  8030. $receiptList = $receipt->find ( array (
  8031. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  8032. 'asArray' => true
  8033. ) );
  8034. if (empty ( $receiptList )) { // generated files
  8035. ob_start ();
  8036. $this->render ( "/admin/saeaStaffCollectB", $data );
  8037. $this->cacheFile ( $path );
  8038. die ();
  8039. }
  8040. }
  8041. $this->render ( "/admin/saeaStaffCollectB", $data );
  8042. }
  8043. function staffCollectBak() {
  8044. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8045. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  8046. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  8047. $this->showCache ( $path );
  8048. Doo::loadModel ( 'statistics' );
  8049. $statistics = new statistics ();
  8050. Doo::loadModel ( "receiptDetail" );
  8051. $receiptDetail = new receiptDetail ();
  8052. Doo::loadModel ( 'L_category' );
  8053. $Lcategory = new L_category ();
  8054. Doo::loadModel ( 'accountItem' );
  8055. $accountItem = new accountItem ();
  8056. Doo::loadModel ( 'staff' );
  8057. $staff = new staff ();
  8058. Doo::loadModel ( 'itemStatistics' );
  8059. $itemStatistics = new itemStatistics ();
  8060. $itemStatisticsList = $itemStatistics->find ( array (
  8061. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8062. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8063. 'groupby' => 'staff,itemCategory,Month(date)',
  8064. 'asArray' => true
  8065. ) );
  8066. $itemCategoryList = $itemStatistics->find ( array (
  8067. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8068. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8069. 'groupby' => 'cid,itemCategory,Month(date)',
  8070. 'asArray' => true
  8071. ) );
  8072. $LcategoryList = $Lcategory->find ( array (
  8073. 'asArray' => true
  8074. ) );
  8075. $staffList = $staff->find ( array (
  8076. 'asArray' => true
  8077. ) );
  8078. $htmlArray = array ();
  8079. foreach ( $LcategoryList as $value ) {
  8080. $htmlArray [$value ['title']] = array ();
  8081. foreach ( $staffList as $v ) {
  8082. if ($value ['cid'] == $v ['cid']) {
  8083. $html = "";
  8084. $falg = true;
  8085. $staffSumPrice = 0;
  8086. foreach ( $itemStatisticsList as $a ) {
  8087. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  8088. if (empty ( $a ['price'] )) {
  8089. $html .= '<td class="taR">-</td>';
  8090. $falg = false;
  8091. break;
  8092. } else {
  8093. $staffSumPrice += $a ['price'];
  8094. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8095. $falg = false;
  8096. break;
  8097. }
  8098. }
  8099. }
  8100. if ($falg) {
  8101. $html .= '<td class="taR">-</td>';
  8102. $falg = true;
  8103. }
  8104. $falg = true;
  8105. foreach ( $itemStatisticsList as $a ) {
  8106. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  8107. if (empty ( $a ['price'] )) {
  8108. $html .= '<td class="taR">-</td>';
  8109. $falg = false;
  8110. break;
  8111. } else {
  8112. $staffSumPrice += $a ['price'];
  8113. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8114. $falg = false;
  8115. break;
  8116. }
  8117. }
  8118. }
  8119. if ($falg) {
  8120. $html .= '<td class="taR">-</td>';
  8121. $falg = true;
  8122. }
  8123. $falg = true;
  8124. foreach ( $itemStatisticsList as $a ) {
  8125. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  8126. if (empty ( $a ['price'] )) {
  8127. $html .= '<td class="taR">-</td>';
  8128. $falg = false;
  8129. break;
  8130. } else {
  8131. $staffSumPrice += $a ['price'];
  8132. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8133. $falg = false;
  8134. break;
  8135. }
  8136. }
  8137. }
  8138. if ($falg) {
  8139. $html .= '<td class="taR">-</td>';
  8140. $falg = true;
  8141. }
  8142. $falg = true;
  8143. foreach ( $itemStatisticsList as $a ) {
  8144. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  8145. if (! empty ( $a ['price'] )) {
  8146. $staffSumPrice += $a ['price'];
  8147. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8148. $falg = false;
  8149. break;
  8150. } else {
  8151. $html .= '<td class="taR">-</td>';
  8152. $falg = false;
  8153. break;
  8154. }
  8155. }
  8156. }
  8157. if ($falg) {
  8158. $html .= '<td class="taR">-</td>';
  8159. $falg = true;
  8160. }
  8161. $falg = true;
  8162. foreach ( $itemStatisticsList as $a ) {
  8163. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  8164. if (! empty ( $a ['price'] )) {
  8165. $staffSumPrice += $a ['price'];
  8166. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8167. $falg = false;
  8168. break;
  8169. } else {
  8170. $html .= '<td class="taR">-</td>';
  8171. $falg = false;
  8172. break;
  8173. }
  8174. }
  8175. }
  8176. if ($falg) {
  8177. $html .= '<td class="taR">-</td>';
  8178. $falg = true;
  8179. }
  8180. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  8181. $htmlArray [$value ['title']] [$v ['username']] = $html;
  8182. }
  8183. }
  8184. /* -- --- */
  8185. // 合计费用
  8186. $cateHtml = "";
  8187. $catePrice = 0;
  8188. $cateFalg = true;
  8189. foreach ( $itemCategoryList as $l ) {
  8190. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  8191. if (empty ( $l ['price'] )) {
  8192. $cateHtml .= '<td class="colGreen taR">-</td>';
  8193. $cateFalg = false;
  8194. break;
  8195. } else {
  8196. $catePrice += $l ['price'];
  8197. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8198. $cateFalg = false;
  8199. break;
  8200. }
  8201. }
  8202. }
  8203. if ($cateFalg) {
  8204. $cateHtml .= '<td class="colGreen taR">-</td>';
  8205. $cateFalg = true;
  8206. }
  8207. $cateFalg = true;
  8208. foreach ( $itemCategoryList as $l ) {
  8209. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  8210. if (empty ( $l ['price'] )) {
  8211. $cateHtml .= '<td class="colGreen taR">-</td>';
  8212. $cateFalg = false;
  8213. break;
  8214. } else {
  8215. $catePrice += $l ['price'];
  8216. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8217. $cateFalg = false;
  8218. break;
  8219. }
  8220. }
  8221. }
  8222. if ($cateFalg) {
  8223. $cateHtml .= '<td class="colGreen taR">-</td>';
  8224. $cateFalg = true;
  8225. }
  8226. $cateFalg = true;
  8227. foreach ( $itemCategoryList as $l ) {
  8228. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  8229. if (empty ( $l ['price'] )) {
  8230. $cateHtml .= '<td class="colGreen taR">-</td>';
  8231. $cateFalg = false;
  8232. break;
  8233. } else {
  8234. $catePrice += $l ['price'];
  8235. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8236. $cateFalg = false;
  8237. break;
  8238. }
  8239. }
  8240. }
  8241. if ($cateFalg) {
  8242. $cateHtml .= '<td class="colGreen taR">-</td>';
  8243. $cateFalg = true;
  8244. }
  8245. $cateFalg = true;
  8246. foreach ( $itemCategoryList as $l ) {
  8247. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  8248. if (empty ( $l ['price'] )) {
  8249. $cateHtml .= '<td class="colGreen taR">-</td>';
  8250. $cateFalg = false;
  8251. break;
  8252. } else {
  8253. $catePrice += $l ['price'];
  8254. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8255. $cateFalg = false;
  8256. break;
  8257. }
  8258. }
  8259. }
  8260. if ($cateFalg) {
  8261. $cateHtml .= '<td class="colGreen taR">-</td>';
  8262. $cateFalg = true;
  8263. }
  8264. $cateFalg = true;
  8265. foreach ( $itemCategoryList as $l ) {
  8266. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  8267. if (empty ( $l ['price'] )) {
  8268. $cateHtml .= '<td class="colGreen taR">-</td>';
  8269. $cateFalg = false;
  8270. break;
  8271. } else {
  8272. $catePrice += $l ['price'];
  8273. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8274. $cateFalg = false;
  8275. break;
  8276. }
  8277. }
  8278. }
  8279. if ($cateFalg) {
  8280. $cateHtml .= '<td class="colGreen taR">-</td>';
  8281. $cateFalg = true;
  8282. }
  8283. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  8284. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  8285. /* -- --- */
  8286. }
  8287. // print_r($htmlArray);die;
  8288. $data ['htmlArray'] = $htmlArray;
  8289. // statistics html
  8290. $stList = $statistics->getOne ( array (
  8291. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8292. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8293. 'groupby' => 'Month(date)',
  8294. 'asArray' => true
  8295. ) );
  8296. if (empty ( $stList ))
  8297. $stList = array (
  8298. 'rePrice' => 0,
  8299. 'agPrice' => 0
  8300. );
  8301. $data ['stList'] = array (
  8302. 'rePrice' => $stList ['rePrice'],
  8303. 'agPrice' => $stList ['agPrice'],
  8304. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8305. );
  8306. $monthHtml = "";
  8307. for($i = 1; $i <= 12; $i ++) {
  8308. if ($i == $month)
  8309. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8310. else
  8311. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8312. }
  8313. $data ['monthHtml'] = $monthHtml;
  8314. $data ['year'] = $year;
  8315. $data ['month'] = $month;
  8316. $data ['memu'] = "receipt";
  8317. $data ['staff'] = $this->staff;
  8318. $data ['receiptMemu'] = 'companyCategoryCollect';
  8319. $data ['verifyId'] = $this->verifyId;
  8320. $data ['executeId'] = $this->executeId;
  8321. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  8322. Doo::loadModel ( 'receipt' );
  8323. $receipt = new receipt ();
  8324. $receiptList = $receipt->find ( array (
  8325. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  8326. 'asArray' => true
  8327. ) );
  8328. if (empty ( $receiptList )) { // generated files
  8329. ob_start ();
  8330. $this->render ( "/admin/saeaStaffCollect", $data );
  8331. $this->cacheFile ( $path );
  8332. die ();
  8333. }
  8334. }
  8335. $this->render ( "/admin/saeaStaffCollect", $data );
  8336. }
  8337. function lyt() {
  8338. Doo::loadModel ( "receiptDetail" );
  8339. $receiptDetail = new receiptDetail ();
  8340. $receiptCollectList = $receiptDetail->find ( array (
  8341. 'where' => 'status=1 ',
  8342. 'asArray' => true
  8343. ) );
  8344. foreach ( $receiptCollectList as $key => $value ) {
  8345. $receiptDetail = new receiptDetail ();
  8346. $receiptDetail->pastDate = $value ['date'];
  8347. $receiptDetail->update ( array (
  8348. 'where' => "rdid= '" . $value ['rdid'] . "'"
  8349. ) );
  8350. }
  8351. }
  8352. function staffCollectMonthDetail() {
  8353. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8354. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8355. if (! $year)
  8356. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8357. if (! $month)
  8358. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8359. Doo::loadModel ( 'staff' );
  8360. $staff = new staff ();
  8361. Doo::loadModel ( "receiptDetail" );
  8362. $receiptDetail = new receiptDetail ();
  8363. Doo::loadModel ( 'accountItem' );
  8364. $accountItem = new accountItem ();
  8365. Doo::loadModel ( 'statistics' );
  8366. $statistics = new statistics ();
  8367. Doo::loadModel ( 'L_category' );
  8368. $lCategory = new L_category ();
  8369. $staffList = $staff->find ( array (
  8370. 'where' => 'username!="admin"',
  8371. 'asArray' => true
  8372. ) );
  8373. $categoryList = $staff->find ( array (
  8374. 'select' => 'COUNT(*) as count,cid,category',
  8375. 'where' => 'username !="admin"',
  8376. 'groupby' => 'cid',
  8377. 'asArray' => true
  8378. ) );
  8379. $list = array ();
  8380. foreach ( $categoryList as $vlu ) {
  8381. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8382. $r1 = 0;
  8383. $r2 = 0;
  8384. $r3 = 0;
  8385. $r4 = 0;
  8386. $r5 = 0;
  8387. $r6 = 0;
  8388. $r7 = 0;
  8389. $r8 = 0;
  8390. $r9 = 0;
  8391. $r10 = 0;
  8392. $r11 = 0;
  8393. $r12 = 0;
  8394. $r13 = 0;
  8395. $r14 = 0;
  8396. $r15 = 0;
  8397. $r16 = 0;
  8398. $r17 = 0;
  8399. $r18 = 0;
  8400. $c1 = 0;
  8401. $c2 = 0;
  8402. $c3 = 0;
  8403. $c4 = 0;
  8404. $c5 = 0;
  8405. $c6 = 0;
  8406. $p1 = 0;
  8407. $p2 = 0;
  8408. $p3 = 0;
  8409. $p4 = 0;
  8410. $p5 = 0;
  8411. $p6 = 0;
  8412. $p7 = 0;
  8413. $p8 = 0;
  8414. $p9 = 0;
  8415. $t1 = 0;
  8416. $t2 = 0;
  8417. $t3 = 0;
  8418. $t4 = 0;
  8419. $t5 = 0;
  8420. $s1 = 0;
  8421. $m1 = 0;
  8422. foreach ( $staffList as $value ) {
  8423. if ($vlu ['cid'] == $value ['cid']) {
  8424. // pastDate
  8425. $receiptCollectList = $receiptDetail->find ( array (
  8426. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8427. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8428. 'groupby' => 'item,Month(pastDate),itemCategory',
  8429. 'asArray' => true
  8430. ) );
  8431. // if ($value['sid']==42){
  8432. // print_r($receiptCollectList);die;
  8433. // }
  8434. if (! empty ( $receiptCollectList )) {
  8435. $receiptL = array (
  8436. '日常相关费用' => array (),
  8437. '差旅相关费用' => array (),
  8438. '培训班费用' => array (),
  8439. '其他' => array ()
  8440. );
  8441. $html = "";
  8442. $psum = 0;
  8443. $item = array (
  8444. '市内交通费',
  8445. '市内出租费',
  8446. '办事处房租',
  8447. '电话费',
  8448. '水费',
  8449. '电费',
  8450. '办公费用',
  8451. '邮寄费',
  8452. '其他费用',
  8453. '车辆费用',
  8454. '广告费',
  8455. '团队建设费',
  8456. '物业管理费',
  8457. '宽带费',
  8458. '人员薪酬',
  8459. '公积金',
  8460. '社保'
  8461. );
  8462. foreach ( $item as $va ) {
  8463. $falg = true;
  8464. foreach ( $receiptCollectList as $v ) {
  8465. if ($v ['itemCategory'] == '日常相关费用') {
  8466. if ($v ['item'] == $va) {
  8467. if ($va == '市内交通费')
  8468. $r1 += $v ['price'];
  8469. if ($va == '市内出租费')
  8470. $r2 += $v ['price'];
  8471. if ($va == '办事处房租')
  8472. $r3 += $v ['price'];
  8473. if ($va == '电话费')
  8474. $r4 += $v ['price'];
  8475. if ($va == '水费')
  8476. $r5 += $v ['price'];
  8477. if ($va == '电费')
  8478. $r6 += $v ['price'];
  8479. if ($va == '办公费用')
  8480. $r7 += $v ['price'];
  8481. if ($va == '邮寄费')
  8482. $r8 += $v ['price'];
  8483. if ($va == '其他费用')
  8484. $r9 += $v ['price'];
  8485. if ($va == '车辆费用')
  8486. $r10 += $v ['price'];
  8487. if ($va == '广告费')
  8488. $r11 += $v ['price'];
  8489. if ($va == '团队建设费')
  8490. $r13 += $v ['price'];
  8491. if ($va == '物业管理费')
  8492. $r14 += $v ['price'];
  8493. if ($va == '宽带费')
  8494. $r15 += $v ['price'];
  8495. if ($va == '公积金')
  8496. $r16 += $v ['price'];
  8497. if ($va == '社保')
  8498. $r17 += $v ['price'];
  8499. if ($va == '人员薪酬')
  8500. $r18 += $v ['price'];
  8501. $psum += $v ['price'];
  8502. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8503. $falg = false;
  8504. break;
  8505. }
  8506. }
  8507. }
  8508. if ($falg)
  8509. $html .= '<td class="taR">-</td>';
  8510. }
  8511. $r12 += $psum;
  8512. if (! empty ( $psum ))
  8513. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8514. else
  8515. $psum = '<td class="colGreen taR">-</td>';
  8516. $receiptL ['日常相关费用'] = $psum . $html;
  8517. /* ----------------------------------- */
  8518. $html = "";
  8519. $psum = 0;
  8520. $item = array (
  8521. '往来交通费',
  8522. '市内交通费',
  8523. '出差住宿费',
  8524. '出差补助',
  8525. '其他费用'
  8526. );
  8527. foreach ( $item as $va ) {
  8528. $falg = true;
  8529. foreach ( $receiptCollectList as $v ) {
  8530. if ($v ['itemCategory'] == '差旅相关费用') {
  8531. if ($v ['item'] == $va) {
  8532. if ($va == '往来交通费')
  8533. $c1 += $v ['price'];
  8534. if ($va == '市内交通费')
  8535. $c2 += $v ['price'];
  8536. if ($va == '出差住宿费')
  8537. $c3 += $v ['price'];
  8538. if ($va == '出差补助')
  8539. $c4 += $v ['price'];
  8540. if ($va == '其他费用')
  8541. $c5 += $v ['price'];
  8542. $psum += $v ['price'];
  8543. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8544. $falg = false;
  8545. break;
  8546. }
  8547. }
  8548. }
  8549. if ($falg)
  8550. $html .= '<td class="taR">-</td>';
  8551. }
  8552. $c6 += $psum;
  8553. if (! empty ( $psum ))
  8554. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8555. else
  8556. $psum = '<td class="colGreen taR">-</td>';
  8557. $receiptL ['差旅相关费用'] = $psum . $html;
  8558. /* ------------------------------------- */
  8559. $html = "";
  8560. $psum = 0;
  8561. $item = array (
  8562. '场租费',
  8563. '薪酬',
  8564. '住宿费',
  8565. '交通费',
  8566. '餐饮费',
  8567. '办公费',
  8568. '公关费',
  8569. '其他'
  8570. );
  8571. foreach ( $item as $va ) {
  8572. $falg = true;
  8573. foreach ( $receiptCollectList as $v ) {
  8574. if ($v ['itemCategory'] == '培训班费用') {
  8575. if ($v ['item'] == $va) {
  8576. if ($va == '场租费')
  8577. $p1 += $v ['price'];
  8578. if ($va == '薪酬')
  8579. $p2 += $v ['price'];
  8580. if ($va == '住宿费')
  8581. $p3 += $v ['price'];
  8582. if ($va == '交通费')
  8583. $p4 += $v ['price'];
  8584. if ($va == '餐饮费')
  8585. $p5 += $v ['price'];
  8586. if ($va == '办公费')
  8587. $p6 += $v ['price'];
  8588. if ($va == '公关费')
  8589. $p7 += $v ['price'];
  8590. if ($va == '其他')
  8591. $p8 += $v ['price'];
  8592. $psum += $v ['price'];
  8593. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8594. $falg = false;
  8595. break;
  8596. }
  8597. }
  8598. }
  8599. if ($falg)
  8600. $html .= '<td class="taR">-</td>';
  8601. }
  8602. $p9 += $psum;
  8603. if (! empty ( $psum ))
  8604. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8605. else
  8606. $psum = '<td class="colGreen taR">-</td>';
  8607. $receiptL ['培训班费用'] = $psum . $html;
  8608. /* ------------------------------------- */
  8609. $html = "";
  8610. $psum = 0;
  8611. $item = array (
  8612. '公关费',
  8613. '广告费',
  8614. '借款',
  8615. '可自加费用'
  8616. );
  8617. foreach ( $item as $va ) {
  8618. $falg = true;
  8619. foreach ( $receiptCollectList as $v ) {
  8620. if ($v ['itemCategory'] == '其他') {
  8621. // if ($value['sid']==42){
  8622. //
  8623. // echo var_dump($v['item']);
  8624. // echo var_dump($va);
  8625. // echo var_dump($v['item']==" ".$va);
  8626. // echo $v['item']."==".$va."/<br/>";
  8627. // //print_r( $receiptCollectList);//echo $va;
  8628. // }
  8629. if (trim ( $v ['item'] ) == $va) {
  8630. if ($va == '公关费')
  8631. $t1 += $v ['price'];
  8632. if ($va == '广告费') {
  8633. $t2 += $v ['price'];
  8634. }
  8635. if ($va == '借款')
  8636. $t3 += $v ['price'];
  8637. if ($va == '可自加费用')
  8638. $t4 += $v ['price'];
  8639. $psum += $v ['price'];
  8640. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8641. $falg = false;
  8642. break;
  8643. }
  8644. }
  8645. }
  8646. if ($falg)
  8647. $html .= '<td class="taR">-</td>';
  8648. }
  8649. $t5 += $psum;
  8650. if (! empty ( $psum ))
  8651. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8652. else
  8653. $psum = '<td class="colGreen taR">-</td>';
  8654. $receiptL ['其他'] = $psum . $html;
  8655. /* ------------------------------------- */
  8656. $html = "";
  8657. $psum = 0;
  8658. foreach ( $receiptCollectList as $v ) {
  8659. if ($v ['itemCategory'] == '报销金额调整') {
  8660. if (! empty ( $v ['price'] )) {
  8661. $psum += $v ['price'];
  8662. }
  8663. }
  8664. }
  8665. $s1 += $psum;
  8666. if (! empty ( $psum ))
  8667. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8668. else
  8669. $psum = '<td class="taR colOrange">-</td>';
  8670. $receiptL ['报销金额调整'] = $psum . $html;
  8671. } else {
  8672. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8673. <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>
  8674. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8675. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  8676. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8677. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8678. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8679. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8680. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  8681. }
  8682. $monthStaffPrice = $receiptDetail->find ( array (
  8683. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8684. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8685. 'groupby' => 'Month(pastDate)',
  8686. 'asArray' => true
  8687. ) );
  8688. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  8689. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  8690. $m1 += $monthStaffPrice [0] ['price'];
  8691. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  8692. } else
  8693. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  8694. $list [$value ['username']] = $receiptL;
  8695. }
  8696. }
  8697. $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>
  8698. <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>
  8699. <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>';
  8700. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  8701. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  8702. $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>
  8703. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  8704. $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>';
  8705. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  8706. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  8707. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  8708. }
  8709. $data ['list'] = $list;
  8710. $receiptCollectList = $receiptDetail->find ( array (
  8711. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8712. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8713. 'groupby' => 'item,Month(pastDate),itemCategory',
  8714. 'asArray' => true
  8715. ) );
  8716. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  8717. // statistics html
  8718. $stList = $statistics->getOne ( array (
  8719. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8720. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8721. 'groupby' => 'Month(date)',
  8722. 'asArray' => true
  8723. ) );
  8724. if (empty ( $stList ))
  8725. $stList = array (
  8726. 'rePrice' => 0,
  8727. 'agPrice' => 0
  8728. );
  8729. $data ['stList'] = array (
  8730. 'rePrice' => $stList ['rePrice'],
  8731. 'agPrice' => $stList ['agPrice'],
  8732. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8733. );
  8734. $monthHtml = "";
  8735. for($i = 1; $i <= 12; $i ++) {
  8736. if ($i == $month)
  8737. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8738. else
  8739. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8740. }
  8741. $data ['monthHtml'] = $monthHtml;
  8742. $data ['year'] = $year;
  8743. $data ['month'] = $month;
  8744. $data ['memu'] = "receipt";
  8745. $data ['staff'] = $this->staff;
  8746. $data ['receiptMemu'] = 'companyCategoryCollect';
  8747. $data ['verifyId'] = $this->verifyId;
  8748. $data ['executeId'] = $this->executeId;
  8749. $this->render ( "/admin/staffCollectMonthDetail", $data );
  8750. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  8751. }
  8752. function staffCollectMonthDetail2() {
  8753. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8754. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8755. if (! $year)
  8756. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8757. if (! $month)
  8758. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8759. Doo::loadModel ( 'staff' );
  8760. $staff = new staff ();
  8761. Doo::loadModel ( "receiptDetail" );
  8762. $receiptDetail = new receiptDetail ();
  8763. Doo::loadModel ( 'accountItem' );
  8764. $accountItem = new accountItem ();
  8765. Doo::loadModel ( 'statistics' );
  8766. $statistics = new statistics ();
  8767. Doo::loadModel ( 'L_category' );
  8768. $lCategory = new L_category ();
  8769. $staffList = $staff->find ( array (
  8770. 'where' => 'username!="admin"',
  8771. 'asArray' => true
  8772. ) );
  8773. $categoryList = $staff->find ( array (
  8774. 'select' => 'COUNT(*) as count,cid,category',
  8775. 'where' => 'username !="admin"',
  8776. 'groupby' => 'cid',
  8777. 'asArray' => true
  8778. ) );
  8779. $list = array ();
  8780. foreach ( $categoryList as $vlu ) {
  8781. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8782. $r1 = 0;
  8783. $r2 = 0;
  8784. $r3 = 0;
  8785. $r4 = 0;
  8786. $r5 = 0;
  8787. $r6 = 0;
  8788. $r7 = 0;
  8789. $r8 = 0;
  8790. $r9 = 0;
  8791. $r10 = 0;
  8792. $r11 = 0;
  8793. $r12 = 0;
  8794. $r13 = 0;
  8795. $r14 = 0;
  8796. $r15 = 0;
  8797. $c1 = 0;
  8798. $c2 = 0;
  8799. $c3 = 0;
  8800. $c4 = 0;
  8801. $c5 = 0;
  8802. $c6 = 0;
  8803. $p1 = 0;
  8804. $p2 = 0;
  8805. $p3 = 0;
  8806. $p4 = 0;
  8807. $p5 = 0;
  8808. $p6 = 0;
  8809. $p7 = 0;
  8810. $p8 = 0;
  8811. $p9 = 0;
  8812. $t1 = 0;
  8813. $t2 = 0;
  8814. $t3 = 0;
  8815. $t4 = 0;
  8816. $t5 = 0;
  8817. $s1 = 0;
  8818. $m1 = 0;
  8819. foreach ( $staffList as $value ) {
  8820. if ($vlu ['cid'] == $value ['cid']) {
  8821. $receiptCollectList = $receiptDetail->find ( array (
  8822. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  8823. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  8824. 'groupby' => 'item,Month(date),itemCategory',
  8825. 'asArray' => true
  8826. ) );
  8827. if (! empty ( $receiptCollectList )) {
  8828. $receiptL = array (
  8829. '日常相关费用' => array (),
  8830. '差旅相关费用' => array (),
  8831. '培训班费用' => array (),
  8832. '其他' => array ()
  8833. );
  8834. $html = "";
  8835. $psum = 0;
  8836. $item = array (
  8837. '市内交通费',
  8838. '市内出租费',
  8839. '办事处房租',
  8840. '电话费',
  8841. '水费',
  8842. '电费',
  8843. '办公费用',
  8844. '邮寄费',
  8845. '其他费用',
  8846. '车辆费用',
  8847. '广告费',
  8848. '团队建设费',
  8849. '物业管理费',
  8850. '宽带费'
  8851. );
  8852. foreach ( $item as $va ) {
  8853. $falg = true;
  8854. foreach ( $receiptCollectList as $v ) {
  8855. if ($v ['itemCategory'] == '日常相关费用') {
  8856. if ($v ['item'] == $va) {
  8857. if ($va == '市内交通费')
  8858. $r1 += $v ['price'];
  8859. if ($va == '市内出租费')
  8860. $r2 += $v ['price'];
  8861. if ($va == '办事处房租')
  8862. $r3 += $v ['price'];
  8863. if ($va == '电话费')
  8864. $r4 += $v ['price'];
  8865. if ($va == '水费')
  8866. $r5 += $v ['price'];
  8867. if ($va == '电费')
  8868. $r6 += $v ['price'];
  8869. if ($va == '办公费用')
  8870. $r7 += $v ['price'];
  8871. if ($va == '邮寄费')
  8872. $r8 += $v ['price'];
  8873. if ($va == '其他费用')
  8874. $r9 += $v ['price'];
  8875. if ($va == '车辆费用')
  8876. $r10 += $v ['price'];
  8877. if ($va == '广告费')
  8878. $r11 += $v ['price'];
  8879. if ($va == '团队建设费')
  8880. $r13 += $v ['price'];
  8881. if ($va == '物业管理费')
  8882. $r14 += $v ['price'];
  8883. if ($va == '宽带费')
  8884. $r15 += $v ['price'];
  8885. $psum += $v ['price'];
  8886. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8887. $falg = false;
  8888. break;
  8889. }
  8890. }
  8891. }
  8892. if ($falg)
  8893. $html .= '<td class="taR">-</td>';
  8894. }
  8895. $r12 += $psum;
  8896. if (! empty ( $psum ))
  8897. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8898. else
  8899. $psum = '<td class="colGreen taR">-</td>';
  8900. $receiptL ['日常相关费用'] = $psum . $html;
  8901. /* ----------------------------------- */
  8902. $html = "";
  8903. $psum = 0;
  8904. $item = array (
  8905. '往来交通费',
  8906. '市内交通费',
  8907. '出差住宿费',
  8908. '出差补助',
  8909. '其他费用'
  8910. );
  8911. foreach ( $item as $va ) {
  8912. $falg = true;
  8913. foreach ( $receiptCollectList as $v ) {
  8914. if ($v ['itemCategory'] == '差旅相关费用') {
  8915. if ($v ['item'] == $va) {
  8916. if ($va == '往来交通费')
  8917. $c1 += $v ['price'];
  8918. if ($va == '市内交通费')
  8919. $c2 += $v ['price'];
  8920. if ($va == '出差住宿费')
  8921. $c3 += $v ['price'];
  8922. if ($va == '出差补助')
  8923. $c4 += $v ['price'];
  8924. if ($va == '其他费用')
  8925. $c5 += $v ['price'];
  8926. $psum += $v ['price'];
  8927. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8928. $falg = false;
  8929. break;
  8930. }
  8931. }
  8932. }
  8933. if ($falg)
  8934. $html .= '<td class="taR">-</td>';
  8935. }
  8936. $c6 += $psum;
  8937. if (! empty ( $psum ))
  8938. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8939. else
  8940. $psum = '<td class="colGreen taR">-</td>';
  8941. $receiptL ['差旅相关费用'] = $psum . $html;
  8942. /* ------------------------------------- */
  8943. $html = "";
  8944. $psum = 0;
  8945. $item = array (
  8946. '场租费',
  8947. '薪酬',
  8948. '住宿费',
  8949. '交通费',
  8950. '餐饮费',
  8951. '办公费',
  8952. '公关费',
  8953. '其他'
  8954. );
  8955. foreach ( $item as $va ) {
  8956. $falg = true;
  8957. foreach ( $receiptCollectList as $v ) {
  8958. if ($v ['itemCategory'] == '培训班费用') {
  8959. if ($v ['item'] == $va) {
  8960. if ($va == '场租费')
  8961. $p1 += $v ['price'];
  8962. if ($va == '薪酬')
  8963. $p2 += $v ['price'];
  8964. if ($va == '住宿费')
  8965. $p3 += $v ['price'];
  8966. if ($va == '交通费')
  8967. $p4 += $v ['price'];
  8968. if ($va == '餐饮费')
  8969. $p5 += $v ['price'];
  8970. if ($va == '办公费')
  8971. $p6 += $v ['price'];
  8972. if ($va == '公关费')
  8973. $p7 += $v ['price'];
  8974. if ($va == '其他')
  8975. $p8 += $v ['price'];
  8976. $psum += $v ['price'];
  8977. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8978. $falg = false;
  8979. break;
  8980. }
  8981. }
  8982. }
  8983. if ($falg)
  8984. $html .= '<td class="taR">-</td>';
  8985. }
  8986. $p9 += $psum;
  8987. if (! empty ( $psum ))
  8988. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8989. else
  8990. $psum = '<td class="colGreen taR">-</td>';
  8991. $receiptL ['培训班费用'] = $psum . $html;
  8992. /* ------------------------------------- */
  8993. $html = "";
  8994. $psum = 0;
  8995. $item = array (
  8996. '公关费',
  8997. '广告费',
  8998. '借款',
  8999. '可自加费用'
  9000. );
  9001. foreach ( $item as $va ) {
  9002. $falg = true;
  9003. foreach ( $receiptCollectList as $v ) {
  9004. if ($v ['itemCategory'] == '其他') {
  9005. if ($v ['item'] == $va) {
  9006. if ($va == '公关费')
  9007. $t1 += $v ['price'];
  9008. if ($va == '广告费')
  9009. $t2 += $v ['price'];
  9010. if ($va == '借款')
  9011. $t3 += $v ['price'];
  9012. if ($va == '可自加费用')
  9013. $t4 += $v ['price'];
  9014. $psum += $v ['price'];
  9015. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9016. $falg = false;
  9017. break;
  9018. }
  9019. }
  9020. }
  9021. if ($falg)
  9022. $html .= '<td class="taR">-</td>';
  9023. }
  9024. $t5 += $psum;
  9025. if (! empty ( $psum ))
  9026. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9027. else
  9028. $psum = '<td class="colGreen taR">-</td>';
  9029. $receiptL ['其他'] = $psum . $html;
  9030. /* ------------------------------------- */
  9031. $html = "";
  9032. $psum = 0;
  9033. foreach ( $receiptCollectList as $v ) {
  9034. if ($v ['itemCategory'] == '报销金额调整') {
  9035. if (! empty ( $v ['price'] )) {
  9036. $psum += $v ['price'];
  9037. }
  9038. }
  9039. }
  9040. $s1 += $psum;
  9041. if (! empty ( $psum ))
  9042. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9043. else
  9044. $psum = '<td class="taR colOrange">-</td>';
  9045. $receiptL ['报销金额调整'] = $psum . $html;
  9046. } else {
  9047. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9048. <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>';
  9049. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9050. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9051. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9052. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9053. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9054. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9055. }
  9056. $monthStaffPrice = $receiptDetail->find ( array (
  9057. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9058. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9059. 'asArray' => true
  9060. ) );
  9061. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  9062. $m1 += $monthStaffPrice [0] ['price'];
  9063. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9064. } else
  9065. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9066. $list [$value ['username']] = $receiptL;
  9067. }
  9068. }
  9069. $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>
  9070. <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>
  9071. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  9072. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  9073. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  9074. $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>
  9075. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  9076. $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>';
  9077. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  9078. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  9079. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  9080. }
  9081. $data ['list'] = $list;
  9082. $receiptCollectList = $receiptDetail->find ( array (
  9083. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9084. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9085. 'groupby' => 'item,Month(date),itemCategory',
  9086. 'asArray' => true
  9087. ) );
  9088. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9089. // statistics html
  9090. $stList = $statistics->getOne ( array (
  9091. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9092. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9093. 'groupby' => 'Month(date)',
  9094. 'asArray' => true
  9095. ) );
  9096. if (empty ( $stList ))
  9097. $stList = array (
  9098. 'rePrice' => 0,
  9099. 'agPrice' => 0
  9100. );
  9101. $data ['stList'] = array (
  9102. 'rePrice' => $stList ['rePrice'],
  9103. 'agPrice' => $stList ['agPrice'],
  9104. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9105. );
  9106. $monthHtml = "";
  9107. for($i = 1; $i <= 12; $i ++) {
  9108. if ($i == $month)
  9109. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9110. else
  9111. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9112. }
  9113. $data ['monthHtml'] = $monthHtml;
  9114. $data ['year'] = $year;
  9115. $data ['month'] = $month;
  9116. $data ['memu'] = "receipt";
  9117. $data ['staff'] = $this->staff;
  9118. $data ['receiptMemu'] = 'companyCategoryCollect';
  9119. $data ['verifyId'] = $this->verifyId;
  9120. $data ['executeId'] = $this->executeId;
  9121. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  9122. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9123. }
  9124. function companyMonthCollectDetail() {
  9125. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9126. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9127. if (! $year)
  9128. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9129. if (! $month)
  9130. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9131. Doo::loadModel ( 'staff' );
  9132. $staff = new staff ();
  9133. Doo::loadModel ( "receiptDetail" );
  9134. $receiptDetail = new receiptDetail ();
  9135. Doo::loadModel ( 'accountItem' );
  9136. $accountItem = new accountItem ();
  9137. Doo::loadModel ( 'statistics' );
  9138. $statistics = new statistics ();
  9139. Doo::loadModel ( 'L_category' );
  9140. $lCategory = new L_category ();
  9141. $staffList = $staff->find ( array (
  9142. 'where' => 'username!="admin"',
  9143. 'asArray' => true
  9144. ) );
  9145. $categoryList = $lCategory->find ( array (
  9146. 'asArray' => true
  9147. ) );
  9148. $list = array ();
  9149. foreach ( $categoryList as $value ) {
  9150. $receiptCollectList = $receiptDetail->find ( array (
  9151. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9152. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9153. 'groupby' => 'item,Month(pastDate),itemCategory',
  9154. 'asArray' => true
  9155. ) );
  9156. if (! empty ( $receiptCollectList )) {
  9157. $receiptL = array (
  9158. '日常相关费用' => array (),
  9159. '差旅相关费用' => array (),
  9160. '培训班费用' => array (),
  9161. '其他' => array ()
  9162. );
  9163. $html = "";
  9164. $psum = 0;
  9165. $item = array (
  9166. '市内交通费',
  9167. '市内出租费',
  9168. '办事处房租',
  9169. '电话费',
  9170. '水费',
  9171. '电费',
  9172. '办公费用',
  9173. '邮寄费',
  9174. '其他费用',
  9175. '车辆费用',
  9176. '广告费',
  9177. '团队建设费'
  9178. );
  9179. foreach ( $item as $va ) {
  9180. $falg = true;
  9181. foreach ( $receiptCollectList as $v ) {
  9182. if ($v ['itemCategory'] == '日常相关费用') {
  9183. if ($v ['item'] == $va) {
  9184. $psum += $v ['price'];
  9185. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9186. $falg = false;
  9187. break;
  9188. }
  9189. }
  9190. }
  9191. if ($falg)
  9192. $html .= '<td class="taR">-</td>';
  9193. }
  9194. if (! empty ( $psum ))
  9195. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9196. else
  9197. $psum = '<td class="colGreen taR">-</td>';
  9198. $receiptL ['日常相关费用'] = $psum . $html;
  9199. /* ----------------------------------- */
  9200. $html = "";
  9201. $psum = 0;
  9202. $item = array (
  9203. '往来交通费',
  9204. '市内交通费',
  9205. '出差住宿费',
  9206. '出差补助',
  9207. '其他费用'
  9208. );
  9209. foreach ( $item as $va ) {
  9210. $falg = true;
  9211. foreach ( $receiptCollectList as $v ) {
  9212. if ($v ['itemCategory'] == '差旅相关费用') {
  9213. if ($v ['item'] == $va) {
  9214. $psum += $v ['price'];
  9215. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9216. $falg = false;
  9217. break;
  9218. }
  9219. }
  9220. }
  9221. if ($falg)
  9222. $html .= '<td class="taR">-</td>';
  9223. }
  9224. if (! empty ( $psum ))
  9225. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9226. else
  9227. $psum = '<td class="colGreen taR">-</td>';
  9228. $receiptL ['差旅相关费用'] = $psum . $html;
  9229. /* ------------------------------------- */
  9230. $html = "";
  9231. $psum = 0;
  9232. $item = array (
  9233. '场租费',
  9234. '薪酬',
  9235. '住宿费',
  9236. '交通费',
  9237. '餐饮费',
  9238. '办公费',
  9239. '公关费',
  9240. '其他'
  9241. );
  9242. foreach ( $item as $va ) {
  9243. $falg = true;
  9244. foreach ( $receiptCollectList as $v ) {
  9245. if ($v ['itemCategory'] == '培训班费用') {
  9246. if ($v ['item'] == $va) {
  9247. $psum += $v ['price'];
  9248. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9249. $falg = false;
  9250. break;
  9251. }
  9252. }
  9253. }
  9254. if ($falg)
  9255. $html .= '<td class="taR">-</td>';
  9256. }
  9257. if (! empty ( $psum ))
  9258. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9259. else
  9260. $psum = '<td class="colGreen taR">-</td>';
  9261. $receiptL ['培训班费用'] = $psum . $html;
  9262. /* ------------------------------------- */
  9263. $html = "";
  9264. $psum = 0;
  9265. $item = array (
  9266. '公关费',
  9267. '广告费',
  9268. '借款',
  9269. '可自加费用'
  9270. );
  9271. foreach ( $item as $va ) {
  9272. $falg = true;
  9273. foreach ( $receiptCollectList as $v ) {
  9274. if ($v ['itemCategory'] == '其他') {
  9275. if ($v ['item'] == $va) {
  9276. $psum += $v ['price'];
  9277. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9278. $falg = false;
  9279. break;
  9280. }
  9281. }
  9282. }
  9283. if ($falg)
  9284. $html .= '<td class="taR">-</td>';
  9285. }
  9286. if (! empty ( $psum ))
  9287. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9288. else
  9289. $psum = '<td class="colGreen taR">-</td>';
  9290. $receiptL ['其他'] = $psum . $html;
  9291. /* ------------------------------------- */
  9292. $html = "";
  9293. $psum = 0;
  9294. foreach ( $receiptCollectList as $v ) {
  9295. if ($v ['itemCategory'] == '报销金额调整') {
  9296. if (! empty ( $v ['price'] ))
  9297. $psum += $v ['price'];
  9298. }
  9299. }
  9300. if (! empty ( $psum ))
  9301. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9302. else
  9303. $psum = '<td class="taR colOrange">-</td>';
  9304. $receiptL ['报销金额调整'] = $psum . $html;
  9305. } else {
  9306. $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>
  9307. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9308. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9309. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9310. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9311. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9312. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9313. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9314. }
  9315. $monthStaffPrice = $receiptDetail->find ( array (
  9316. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9317. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9318. 'asArray' => true
  9319. ) );
  9320. if (! empty ( $monthStaffPrice [0] ['price'] ))
  9321. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9322. else
  9323. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9324. $list [$value ['title']] = $receiptL;
  9325. }
  9326. $data ['list'] = $list;
  9327. $receiptCollectList = $receiptDetail->find ( array (
  9328. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9329. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9330. 'groupby' => 'item,Month(pastDate),itemCategory',
  9331. 'asArray' => true
  9332. ) );
  9333. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9334. // print_r($data['monthPriceHtml']);
  9335. // foreach ($data['monthPriceHtml'] as $value){
  9336. // echo $value;
  9337. // }
  9338. // die;
  9339. // statistics html
  9340. $stList = $statistics->getOne ( array (
  9341. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9342. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9343. 'groupby' => 'Month(date)',
  9344. 'asArray' => true
  9345. ) );
  9346. if (empty ( $stList ))
  9347. $stList = array (
  9348. 'rePrice' => 0,
  9349. 'agPrice' => 0
  9350. );
  9351. $data ['stList'] = array (
  9352. 'rePrice' => $stList ['rePrice'],
  9353. 'agPrice' => $stList ['agPrice'],
  9354. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9355. );
  9356. $monthHtml = "";
  9357. for($i = 1; $i <= 12; $i ++) {
  9358. if ($i == $month)
  9359. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9360. else
  9361. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9362. }
  9363. $data ['monthHtml'] = $monthHtml;
  9364. $data ['year'] = $year;
  9365. $data ['month'] = $month;
  9366. $data ['memu'] = "receipt";
  9367. $data ['staff'] = $this->staff;
  9368. $data ['receiptMemu'] = 'companyCategoryCollect';
  9369. $data ['verifyId'] = $this->verifyId;
  9370. $data ['executeId'] = $this->executeId;
  9371. $this->render ( "/admin/companyMonthCollectDetail", $data );
  9372. }
  9373. function staffCollectDetail() {
  9374. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9375. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  9376. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  9377. if (! $staffname) {
  9378. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  9379. $staffname = urldecode ( $staffname );
  9380. }
  9381. Doo::loadModel ( 'staff' );
  9382. $staff = new staff ();
  9383. Doo::loadModel ( "receiptDetail" );
  9384. $receiptDetail = new receiptDetail ();
  9385. Doo::loadModel ( 'accountItem' );
  9386. $accountItem = new accountItem ();
  9387. Doo::loadModel ( 'statistics' );
  9388. $statistics = new statistics ();
  9389. Doo::loadModel ( 'L_category' );
  9390. $lCategory = new L_category ();
  9391. $staffList = $staff->find ( array (
  9392. 'asArray' => true
  9393. ) );
  9394. $stHtml = '';
  9395. $stTitle = "";
  9396. $staffId = 0;
  9397. $cid = 0;
  9398. $ocid = 0;
  9399. foreach ( $staffList as $value ) {
  9400. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  9401. $stTitle = $value ['category'] . '-' . $value ['username'];
  9402. $staffId = $value ['sid'];
  9403. $cid = $value ['cid'];
  9404. $ocid = $value ['cid'];
  9405. if (! empty ( $value ['othercid'] ))
  9406. $cid = $value ['cid'] . ',' . $value ['othercid'];
  9407. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9408. } elseif ($value ['username'] != 'admin')
  9409. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9410. }
  9411. $data ['lCategoryHtml'] = $lCategory->find ( array (
  9412. 'where' => 'cid in(' . $cid . ')',
  9413. 'asArray' => true
  9414. ) );
  9415. if (empty ( $pcid ))
  9416. $pcid = $ocid;
  9417. $data ['ocid'] = $pcid;
  9418. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  9419. $this->showCache ( $path );
  9420. //
  9421. $receiptCollectList = $receiptDetail->find ( array (
  9422. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9423. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9424. 'groupby' => 'item,Month(pastDate),itemCategory',
  9425. 'asArray' => true
  9426. ) );
  9427. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  9428. // print_r($receiptCollectList);
  9429. $accountList = $accountItem->find ( array (
  9430. 'asArray' => true
  9431. ) );
  9432. // create CollectDetail HTML
  9433. $collectHtml = array ();
  9434. foreach ( $accountList as $key => $value ) {
  9435. $html = "";
  9436. $asum = 0;
  9437. for($i = 1; $i <= 12; $i ++) {
  9438. $falg = true;
  9439. foreach ( $receiptCollectList as $v ) {
  9440. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9441. if ($v ['item'] == '可自加费用') {
  9442. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  9443. }
  9444. $asum += $v ['price'];
  9445. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9446. $falg = false;
  9447. break;
  9448. }
  9449. }
  9450. if ($falg)
  9451. $html .= '<td class="taR">-</td>';
  9452. }
  9453. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9454. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9455. }
  9456. $data ['collectHtml'] = $collectHtml;
  9457. // print_r($collectHtml);
  9458. // create Adjustment price html
  9459. $receiptCollectList = $receiptDetail->find ( array (
  9460. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9461. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9462. 'groupby' => 'itemCategory,Month(pastDate)',
  9463. 'asArray' => true
  9464. ) );
  9465. $adjustment = array ();
  9466. $collectArray = array (
  9467. '日常相关费用' => array (),
  9468. '差旅相关费用' => array (),
  9469. '培训班费用' => array (),
  9470. '其他' => array ()
  9471. );
  9472. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9473. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9474. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9475. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9476. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9477. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9478. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9479. array_push ( $collectArray ['其他'], $collectHtml );
  9480. $data ['collectArray'] = $collectArray;
  9481. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9482. array_push ( $adjustment, $collectHtml );
  9483. $data ['adjustment'] = $adjustment;
  9484. // total price html
  9485. $collectHtml = "";
  9486. $total = 0;
  9487. for($i = 1; $i <= 12; $i ++) {
  9488. $sumPrice = 0;
  9489. foreach ( $receiptCollectList as $key => $value ) {
  9490. if ($value ['month'] == $i) {
  9491. $sumPrice += $value ['price'];
  9492. }
  9493. }
  9494. if ($sumPrice == 0)
  9495. $collectHtml .= '<td class="taR">-</td>';
  9496. else
  9497. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9498. $total += $sumPrice;
  9499. }
  9500. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9501. // statistics html
  9502. $stList = $statistics->statisticsByYear ( $year, $staffId );
  9503. if (empty ( $stList ))
  9504. $stList = array (
  9505. 'rePrice' => 0,
  9506. 'agPrice' => 0
  9507. );
  9508. $data ['stList'] = array (
  9509. 'rePrice' => $stList ['rePrice'],
  9510. 'agPrice' => $stList ['agPrice'],
  9511. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9512. );
  9513. $data ['totalPrice'] = $collectHtml;
  9514. $data ['totalYear'] = $total;
  9515. $data ['stHtml'] = $stHtml;
  9516. $data ['year'] = $year;
  9517. $data ['stTitle'] = $stTitle;
  9518. $data ['memu'] = "receipt";
  9519. $data ['staff'] = $this->staff;
  9520. $data ['receiptMemu'] = 'companyCategoryCollect';
  9521. $data ['verifyId'] = $this->verifyId;
  9522. $data ['executeId'] = $this->executeId;
  9523. if ($year < date ( "Y" )) {
  9524. Doo::loadModel ( 'receipt' );
  9525. $receipt = new receipt ();
  9526. $receiptList = $receipt->find ( array (
  9527. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  9528. 'asArray' => true
  9529. ) );
  9530. if (empty ( $receiptList )) { // generated files
  9531. ob_start ();
  9532. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9533. $this->cacheFile ( $path );
  9534. die ();
  9535. }
  9536. }
  9537. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9538. }
  9539. function BUGFLAG() {
  9540. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  9541. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  9542. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9543. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9544. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  9545. if (empty ( $status ))
  9546. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  9547. $page_size = 12;
  9548. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  9549. $vidList = array ();
  9550. $button = 0;
  9551. Doo::loadModel ( 'verify' );
  9552. $verify = new verify ();
  9553. Doo::loadModel ( 'receipt' );
  9554. $receipt = new receipt ();
  9555. Doo::loadModel ( 'staff' );
  9556. $staff = new staff ();
  9557. Doo::loadModel ( 'L_category' );
  9558. $Lcategory = new L_category ();
  9559. $dateCondition = " and Year(date) =" . $year;
  9560. if (! empty ( $month ))
  9561. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  9562. $categoryList = $Lcategory->find ( array (
  9563. 'asArray' => true
  9564. ) );
  9565. $staffList = $staff->find ( array (
  9566. 'where' => 'cid=' . $cid,
  9567. 'asArray' => true
  9568. ) );
  9569. $cateCondition = "";
  9570. $staffCondition = "";
  9571. $approvalCondition = "";
  9572. if (! empty ( $cid ))
  9573. $cateCondition = ' and cid=' . $cid;
  9574. if (! empty ( $sid )) {
  9575. $staffCondition = ' and staff=' . $sid;
  9576. $cateCondition = "";
  9577. }
  9578. $approvalCondition = " and status=" . $status;
  9579. if ($status == 2) {
  9580. // 查找角色审批人
  9581. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9582. }
  9583. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  9584. $approvalCondition = ' and status=2 ';
  9585. }
  9586. if ($status == 1) {
  9587. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  9588. }
  9589. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  9590. $pageinfo ['page'] = array (
  9591. 'previous' => ''
  9592. );
  9593. if ($status == 0) {
  9594. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  9595. $receiptList = $receipt->find ( array (
  9596. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  9597. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  9598. 'desc' => 'rid',
  9599. 'asArray' => true
  9600. ) );
  9601. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9602. } else
  9603. $receiptList = $receipt->find ( array (
  9604. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  9605. 'desc' => 'rid',
  9606. 'asArray' => true
  9607. ) );
  9608. $rLRes = $receipt->find ( array (
  9609. '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,
  9610. 'desc' => 'rid',
  9611. 'asArray' => true
  9612. ) );
  9613. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9614. // print_r($pageinfo);
  9615. $Locate = 0;
  9616. foreach ( $receiptList as $key => $value ) {
  9617. $receiptList [$key] ['Locate'] = $Locate;
  9618. $Locate ++;
  9619. $receiptList [$key] ['reviseDetail'] = array ();
  9620. if (! empty ( $value ['reviseDetail'] ))
  9621. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  9622. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  9623. $categoryDetil = $Lcategory->getOne ( array (
  9624. 'where' => 'cid=' . $value ['cid'],
  9625. 'asArray' => true
  9626. ) );
  9627. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  9628. $verifyList = $verify->getOne ( array (
  9629. 'where' => 'vid=' . $value ['verify'],
  9630. 'asArray' => true
  9631. ) );
  9632. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  9633. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  9634. foreach ( $verifyList as $k => $v ) {
  9635. // init verifyStaff
  9636. $verifyList [$k] ['date'] = "";
  9637. $verifyList [$k] ['opinion'] = "";
  9638. $verifyList [$k] ['status'] = "";
  9639. if (empty ( $verifyStaff )) {
  9640. $verifyList [$k] ['date'] = "";
  9641. $verifyList [$k] ['opinion'] = "";
  9642. if ($v [0] == $this->staff [0] ['sid']) {
  9643. $verifyList [$k] ['status'] = 4;
  9644. $button = 4;
  9645. }
  9646. } else {
  9647. $flag = true;
  9648. foreach ( $verifyStaff as $m => $u ) {
  9649. if ($v [0] == $m) {
  9650. $verifyList [$k] ['date'] = $u ['date'];
  9651. $verifyList [$k] ['opinion'] = $u ['opinion'];
  9652. $verifyList [$k] ['status'] = $u ['status'];
  9653. $flag = false;
  9654. break;
  9655. }
  9656. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  9657. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  9658. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  9659. }
  9660. if ($flag) { // 检测可编辑
  9661. if ($v [0] == $this->staff [0] ['sid']) {
  9662. $verifyList [$k] ['status'] = 4;
  9663. $button = 4;
  9664. }
  9665. }
  9666. }
  9667. }
  9668. $receiptList [$key] ['verifyList'] = $verifyList;
  9669. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  9670. 'where' => 'sid=' . $value ['staff'],
  9671. 'asArray' => true
  9672. ) );
  9673. $receiptList [$key] ['button'] = $button;
  9674. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  9675. }
  9676. // print_r($receiptList);die;
  9677. // $data['verifyDetail']=$verifyDetail;
  9678. $mothHtml = "";
  9679. for($i = 1; $i <= 12; $i ++) {
  9680. if ($month == $i)
  9681. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  9682. else
  9683. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  9684. }
  9685. $data ['mothHtml'] = $mothHtml;
  9686. $data ['page'] = $pageinfo;
  9687. $data ['receiptList'] = $receiptList;
  9688. $data ['receiptApprovalCount'] = count ( $rLRes );
  9689. $data ['status'] = $status;
  9690. $data ['year'] = $year;
  9691. $data ['categoryList'] = $categoryList;
  9692. $data ['staffList'] = $staffList;
  9693. $data ['cid'] = $cid;
  9694. $data ['sid'] = $sid;
  9695. // print_r($receiptList);
  9696. $data ['memu'] = "receipt";
  9697. $data ['staff'] = $this->staff;
  9698. $data ['receiptMemu'] = 'approvalExpenses';
  9699. $data ['verifyId'] = $this->verifyId;
  9700. $data ['executeId'] = $this->executeId;
  9701. $this->render ( "/admin/FALG", $data );
  9702. }
  9703. function ajaxGetReceiptOrder() {
  9704. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  9705. if (! empty ( $receiptOrder )) {
  9706. Doo::loadModel ( 'receipt' );
  9707. $receipt = new receipt ();
  9708. Doo::loadModel ( 'staff' );
  9709. $staff = new staff ();
  9710. $receiptInfo = $receipt->getOne ( array (
  9711. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  9712. 'asArray' => true
  9713. ) );
  9714. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  9715. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  9716. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  9717. </tbody></table><table class="table table table-bordered"><tbody>';
  9718. foreach ( $verifyStaff as $key => $value ) {
  9719. $staffInfo = $staff->getOne ( array (
  9720. 'select' => 'username',
  9721. 'where' => ' sid="' . $key . '"',
  9722. 'asArray' => true
  9723. ) );
  9724. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  9725. }
  9726. $html .= '</tbody></table></div></div>';
  9727. echo json_encode ( array (
  9728. 'status' => 1,
  9729. 'receiptHtml' => $html
  9730. ) );
  9731. die ();
  9732. }
  9733. echo json_encode ( array (
  9734. 'status' => 2,
  9735. 'receiptHtml' => ''
  9736. ) );
  9737. die ();
  9738. }
  9739. function _getMonthCollectDetail($receiptCollectList) {
  9740. if (! empty ( $receiptCollectList )) {
  9741. $receiptL = array (
  9742. '日常相关费用' => array (),
  9743. '差旅相关费用' => array (),
  9744. '培训班费用' => array (),
  9745. '其他' => array ()
  9746. );
  9747. $html = "";
  9748. $psum = 0;
  9749. $item = array (
  9750. '市内交通费',
  9751. '市内出租费',
  9752. '办事处房租',
  9753. '电话费',
  9754. '水费',
  9755. '电费',
  9756. '办公费用',
  9757. '邮寄费',
  9758. '其他费用',
  9759. '车辆费用',
  9760. '广告费',
  9761. '团队建设费',
  9762. '物业管理费',
  9763. '宽带费'
  9764. );
  9765. foreach ( $item as $value ) {
  9766. $falg = true;
  9767. foreach ( $receiptCollectList as $v ) {
  9768. if ($v ['itemCategory'] == '日常相关费用') {
  9769. if ($v ['item'] == $value) {
  9770. $psum += $v ['price'];
  9771. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9772. $falg = false;
  9773. break;
  9774. }
  9775. }
  9776. }
  9777. if ($falg)
  9778. $html .= '<td class="taR">-</td>';
  9779. }
  9780. if (! empty ( $psum ))
  9781. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9782. else
  9783. $psum = '<td class="colGreen taR">-</td>';
  9784. $receiptL ['日常相关费用'] = $psum . $html;
  9785. /* ----------------------------------- */
  9786. $html = "";
  9787. $psum = 0;
  9788. $item = array (
  9789. '往来交通费',
  9790. '市内交通费',
  9791. '出差住宿费',
  9792. '出差补助',
  9793. '其他费用'
  9794. );
  9795. foreach ( $item as $value ) {
  9796. $falg = true;
  9797. foreach ( $receiptCollectList as $v ) {
  9798. if ($v ['itemCategory'] == '差旅相关费用') {
  9799. if ($v ['item'] == $value) {
  9800. $psum += $v ['price'];
  9801. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9802. $falg = false;
  9803. break;
  9804. }
  9805. }
  9806. }
  9807. if ($falg)
  9808. $html .= '<td class="taR">-</td>';
  9809. }
  9810. if (! empty ( $psum ))
  9811. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9812. else
  9813. $psum = '<td class="colGreen taR">-</td>';
  9814. $receiptL ['差旅相关费用'] = $psum . $html;
  9815. /* ------------------------------------- */
  9816. $html = "";
  9817. $psum = 0;
  9818. $item = array (
  9819. '场租费',
  9820. '薪酬',
  9821. '住宿费',
  9822. '交通费',
  9823. '餐饮费',
  9824. '办公费',
  9825. '公关费',
  9826. '其他'
  9827. );
  9828. foreach ( $item as $value ) {
  9829. $falg = true;
  9830. foreach ( $receiptCollectList as $v ) {
  9831. if ($v ['itemCategory'] == '培训班费用') {
  9832. if ($v ['item'] == $value) {
  9833. $psum += $v ['price'];
  9834. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9835. $falg = false;
  9836. break;
  9837. }
  9838. }
  9839. }
  9840. if ($falg)
  9841. $html .= '<td class="taR">-</td>';
  9842. }
  9843. if (! empty ( $psum ))
  9844. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9845. else
  9846. $psum = '<td class="colGreen taR">-</td>';
  9847. $receiptL ['培训班费用'] = $psum . $html;
  9848. /* ------------------------------------- */
  9849. $html = "";
  9850. $psum = 0;
  9851. $item = array (
  9852. '公关费',
  9853. '广告费',
  9854. '借款',
  9855. '可自加费用'
  9856. );
  9857. foreach ( $item as $value ) {
  9858. $falg = true;
  9859. foreach ( $receiptCollectList as $v ) {
  9860. if ($v ['itemCategory'] == '其他') {
  9861. if ($v ['item'] == $value) {
  9862. $psum += $v ['price'];
  9863. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9864. $falg = false;
  9865. break;
  9866. }
  9867. }
  9868. }
  9869. if ($falg)
  9870. $html .= '<td class="taR">-</td>';
  9871. }
  9872. if (! empty ( $psum ))
  9873. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9874. else
  9875. $psum = '<td class="colGreen taR">-</td>';
  9876. $receiptL ['其他'] = $psum . $html;
  9877. /* ------------------------------------- */
  9878. $html = "";
  9879. $psum = 0;
  9880. foreach ( $receiptCollectList as $v ) {
  9881. if ($v ['itemCategory'] == '报销金额调整') {
  9882. if (! empty ( $v ['price'] ))
  9883. $psum += $v ['price'];
  9884. }
  9885. }
  9886. if (! empty ( $psum ))
  9887. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9888. else
  9889. $psum = '<td class="taR colOrange">-</td>';
  9890. $receiptL ['报销金额调整'] = $psum . $html;
  9891. } else {
  9892. $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>
  9893. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9894. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9895. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9896. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9897. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9898. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9899. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9900. }
  9901. return $receiptL;
  9902. }
  9903. function eMail() {
  9904. Doo::loadModel ( 'staff' );
  9905. $staff = new staff ();
  9906. Doo::loadModel ( 'receipt' );
  9907. $receipt = new receipt ();
  9908. Doo::loadModel ( 'L_category' );
  9909. $Lcategory = new L_category ();
  9910. Doo::loadModel ( "verify" );
  9911. $verify = new verify ();
  9912. $staffList = $staff->find ( array (
  9913. 'asArray' => true
  9914. ) );
  9915. foreach ( $staffList as $key => $value ) {
  9916. if ($value ['username'] != 'admin') {
  9917. // 提交人
  9918. $receiptList = $receipt->find ( array (
  9919. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  9920. 'asArray' => true
  9921. ) );
  9922. if (! empty ( $receiptList )) {
  9923. $html = '<br><div><style></style>
  9924. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  9925. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  9926. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9927. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  9928. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9929. <tbody><tr>
  9930. <td style="padding: 0 40px;" align="left">
  9931. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9932. </td></tr><tr>
  9933. <td style="padding: 0 40px;" align="left"><p style="margin-top:0px;margin-bottom:40px;color:#383838;font-size:20px;line-height:32px;">美好的一天从今天开始,您需要关注以下事项:</p></td>
  9934. </tr>
  9935. </tbody> </table></td> </tr> <tr><td>
  9936. <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">
  9937. <tbody> <tr><td>
  9938. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  9939. 以下报销单完成了审批,等着收款吧:</p>
  9940. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  9941. foreach ( $receiptList as $k => $v ) {
  9942. $category = $Lcategory->getOne ( array (
  9943. 'where' => 'cid=' . $v ['cid'],
  9944. 'asArray' => true
  9945. ) );
  9946. $html .= '
  9947. <tr>
  9948. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  9949. <td align="left">
  9950. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  9951. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  9952. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  9953. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  9954. </tr>';
  9955. }
  9956. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  9957. <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>
  9958. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  9959. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  9960. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  9961. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9962. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9963. $receipt = new receipt ();
  9964. $receipt->notice = 1;
  9965. $receipt->update ( array (
  9966. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  9967. ) );
  9968. }
  9969. }
  9970. // 审批人
  9971. $verifyList = $verify->find ( array (
  9972. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  9973. 'asArray' => true
  9974. ) );
  9975. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  9976. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  9977. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9978. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  9979. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9980. <tbody><tr><td style="padding: 0 40px;" align="left">
  9981. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9982. </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>
  9983. </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">
  9984. <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>
  9985. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  9986. foreach ( $verifyList as $k => $v ) {
  9987. $receiptList = $receipt->find ( array (
  9988. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  9989. 'asArray' => true
  9990. ) );
  9991. foreach ( $receiptList as $r => $l ) {
  9992. $category = $Lcategory->getOne ( array (
  9993. 'where' => 'cid=' . $l ['cid'],
  9994. 'asArray' => true
  9995. ) );
  9996. $staffDetile = $staff->getOne ( array (
  9997. 'where' => 'sid=' . $l ['staff'],
  9998. 'asArray' => true
  9999. ) );
  10000. $html .= '
  10001. <tr>
  10002. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  10003. <td align="left">
  10004. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  10005. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  10006. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  10007. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  10008. </tr>';
  10009. }
  10010. }
  10011. $html .= '
  10012. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  10013. <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>
  10014. </tr></tbody></table></td></tr></tbody></table></div><br>';
  10015. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  10016. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  10017. // $receipt=new receipt();
  10018. // $receipt->notice=1;
  10019. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  10020. }
  10021. }
  10022. }
  10023. }
  10024. function setWXMsg($rid, $type) {
  10025. Doo::loadModel ( "receipt" );
  10026. $receipt = new receipt ();
  10027. $receiptDetail = $receipt->getOne ( array (
  10028. 'where' => 'rid=' . $rid,
  10029. 'asArray' => true
  10030. ) );
  10031. if (! empty ( $receiptDetail )) {
  10032. Doo::loadModel ( 'staff' );
  10033. $staff = new staff ();
  10034. $staffmsg = $staff->getOne ( array (
  10035. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  10036. 'asArray' => TRUE
  10037. ) );
  10038. if (! empty ( $staffmsg ['wxid'] )) {
  10039. require_once (SITE_PATH . '/protected/class/client.php');
  10040. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  10041. $user = $staffmsg ['wxid'];
  10042. $receiptName = '';
  10043. $msg = '';
  10044. switch ($receiptDetail ['Rtype']) {
  10045. case 0 :
  10046. $receiptName = '报销';
  10047. break;
  10048. case 1 :
  10049. $receiptName = '借款';
  10050. break;
  10051. case 2 :
  10052. $receiptName = '对公汇款';
  10053. break;
  10054. }
  10055. switch ($type) {
  10056. case 1 :
  10057. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  10058. break;
  10059. case 2 :
  10060. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  10061. break;
  10062. case 3 :
  10063. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  10064. break;
  10065. }
  10066. $result = $client->SendMsg ( $user, $msg, 'text' );
  10067. }
  10068. }
  10069. }
  10070. // Email发送函数
  10071. function SMail($toemail, $subject, $contents) {
  10072. Doo::loadClass ( 'class.phpmailer' );
  10073. $mail = new PHPMailer ();
  10074. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  10075. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  10076. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  10077. $mail->Password = "cDO1GjtY1seH"; // 密码
  10078. $mail->CharSet = "UTF8";
  10079. $mail->SMTPAuth = true;
  10080. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  10081. $mail->Mailer = "smtp";
  10082. $mail->Port = 25;
  10083. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  10084. $mail->MsgHTML ( $contents );
  10085. $mail->AddAddress ( $toemail );
  10086. $mail->CharSet = "UTF-8";
  10087. return $mail->Send ();
  10088. }
  10089. function swfupload() {
  10090. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  10091. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  10092. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  10093. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  10094. header ( "HTTP/1.1 500 Internal Server Error" );
  10095. echo "POST exceeded maximum allowed size.";
  10096. exit ( 0 );
  10097. }
  10098. // Settings
  10099. $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)
  10100. $upload_name = "Filedata";
  10101. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  10102. $extension_whitelist = array (
  10103. "doc",
  10104. "txt",
  10105. "jpg",
  10106. "gif",
  10107. "png"
  10108. ); // Allowed file extensions
  10109. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  10110. // Other variables
  10111. $MAX_FILENAME_LENGTH = 260;
  10112. $file_name = "";
  10113. $file_extension = "";
  10114. $uploadErrors = array (
  10115. 0 => "文件上传成功",
  10116. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  10117. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  10118. 3 => "上传的文件仅为部分文件",
  10119. 4 => "没有文件上传",
  10120. 6 => "缺少临时文件夹"
  10121. );
  10122. $nk = time ();
  10123. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  10124. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  10125. echo "文件无法保存.";
  10126. exit ( 0 );
  10127. }
  10128. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  10129. echo json_encode ( array (
  10130. 'filename' => $file_name,
  10131. 'id' => $nk
  10132. ) );
  10133. exit ( 0 );
  10134. }
  10135. function _GetFileEXT($filename) {
  10136. $pics = explode ( '.', $filename );
  10137. $num = count ( $pics );
  10138. return $pics [$num - 1];
  10139. }
  10140. /**
  10141. * 获取get或者POST值
  10142. * @param string $name 属性名称
  10143. * @return fixed 值
  10144. */
  10145. function get_args($name) {
  10146. if (isset ( $_GET [$name] )) {
  10147. if (is_array ( $_GET [$name] ))
  10148. return $_GET [$name];
  10149. else
  10150. return addslashes ( $_GET [$name] );
  10151. } elseif (isset ( $_POST [$name] )) {
  10152. if (is_array ( $_POST [$name] ))
  10153. return $_POST [$name];
  10154. else
  10155. return addslashes ( $_POST [$name] );
  10156. } else
  10157. return false;
  10158. }
  10159. function num_to_rmb($num) {
  10160. $c1 = "零壹贰叁肆伍陆柒捌玖";
  10161. $c2 = "分角元拾佰仟万拾佰仟亿";
  10162. // 精确到分后面就不要了,所以只留两个小数位
  10163. $num = round ( $num, 2 );
  10164. // 将数字转化为整数
  10165. $num = $num * 100;
  10166. if (strlen ( $num ) > 10) {
  10167. return "金额太大,请检查";
  10168. }
  10169. $i = 0;
  10170. $c = "";
  10171. while ( 1 ) {
  10172. if ($i == 0) {
  10173. // 获取最后一位数字
  10174. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  10175. } else {
  10176. $n = $num % 10;
  10177. }
  10178. // 每次将最后一位数字转化为中文
  10179. $p1 = substr ( $c1, 3 * $n, 3 );
  10180. $p2 = substr ( $c2, 3 * $i, 3 );
  10181. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  10182. $c = $p1 . $p2 . $c;
  10183. } else {
  10184. $c = $p1 . $c;
  10185. }
  10186. $i = $i + 1;
  10187. // 去掉数字最后一位了
  10188. $num = $num / 10;
  10189. $num = ( int ) $num;
  10190. // 结束循环
  10191. if ($num == 0) {
  10192. break;
  10193. }
  10194. }
  10195. $j = 0;
  10196. $slen = strlen ( $c );
  10197. while ( $j < $slen ) {
  10198. // utf8一个汉字相当3个字符
  10199. $m = substr ( $c, $j, 6 );
  10200. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  10201. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  10202. $left = substr ( $c, 0, $j );
  10203. $right = substr ( $c, $j + 3 );
  10204. $c = $left . $right;
  10205. $j = $j - 3;
  10206. $slen = $slen - 3;
  10207. }
  10208. $j = $j + 3;
  10209. }
  10210. // 这个是为了去掉类似23.0中最后一个“零”字
  10211. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  10212. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  10213. }
  10214. // 将处理的汉字加上“整”
  10215. if (empty ( $c )) {
  10216. return "零元整";
  10217. } else {
  10218. return $c . "整";
  10219. }
  10220. }
  10221. /**
  10222. * 获得分页数据
  10223. * @param unknown_type $table
  10224. * @param unknown_type $condition
  10225. * @param unknown_type $on_page
  10226. * @param unknown_type $page_size
  10227. */
  10228. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  10229. $page_c = "";
  10230. $page ['previous'] = $this->get_previous ( $on_page );
  10231. $page ['on_page'] = $on_page;
  10232. $total_count = $this->get_table_count ( $table, $condition );
  10233. $total = intval ( $total_count / $page_size );
  10234. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  10235. $page ['total_data'] = $total_count;
  10236. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  10237. $i = 1;
  10238. $page_max = 1;
  10239. $page_width = 3;
  10240. if ($on_page >= $page_width) {
  10241. $page_max = intval ( $on_page / $page_width ) + 1;
  10242. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  10243. }
  10244. for(; $i <= $page ['total_page']; $i ++) {
  10245. if ($i == $on_page)
  10246. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  10247. else
  10248. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  10249. if ($i == ($page_width * $page_max))
  10250. break;
  10251. }
  10252. $page ['page'] = $page_c;
  10253. $page ['lower'] = (-- $on_page) * $page_size;
  10254. return $page;
  10255. }
  10256. /**
  10257. * 获取总页数
  10258. * @param unknown_type $table
  10259. * @param unknown_type $condition
  10260. */
  10261. public function get_table_count($table = "", $condition = "") {
  10262. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10263. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10264. // echo $sql;die;
  10265. $query = Doo::db ()->query ( $sql );
  10266. $result = $query->fetch ();
  10267. return $result ['count'];
  10268. }
  10269. /**
  10270. * 获取上一页
  10271. * @param unknown_type $on_page
  10272. */
  10273. function get_previous($on_page = 1) {
  10274. return $on_page != 0 ? $on_page - 1 : $on_page;
  10275. }
  10276. }
  10277. ?>