ReceiptController.php 374 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class ReceiptController extends DooController {
  6. public $staff;
  7. public $verifyId;
  8. public $executeId;
  9. // public static $NEW2 = 0;
  10. public $AGENCY = "日常相关费用";
  11. public $TRAVEL = "差旅相关费用";
  12. public $TRAIN = "培训班费用";
  13. public $OTHER = "其他";
  14. private $MYREVEIPTCACHEPATH = "protected/cache/myReceipt/";
  15. private $PERSONALCOLLECTCACHEPATH = "protected/cache/personalCollect/";
  16. private $CATEGORYCOLLECTPATH = "protected/cache/categoryCollect/";
  17. private $STAFFCOLLECTPATH = "protected/cache/staffCollect/";
  18. private function showCache($path) {
  19. if (file_exists ( $path )) {
  20. echo "<!DOCTYPE html>";
  21. include $path;
  22. die ();
  23. }
  24. }
  25. private function cacheFile($path) {
  26. $content = ob_get_contents ();
  27. $fp = fopen ( $path, "w" );
  28. fwrite ( $fp, $content );
  29. fclose ( $fp );
  30. }
  31. private function collectHtml($receiptCollectList = array(), $itemCategory = "日常相关费用", $classType = "b") {
  32. $collectHtml = "";
  33. $sumPrice = 0.00;
  34. for($i = 1; $i <= 12; $i ++) {
  35. $falg = true;
  36. foreach ( $receiptCollectList as $key => $value ) {
  37. if ($value ['itemCategory'] == $itemCategory && $value ['month'] == $i) {
  38. $sumPrice += $value ['price'];
  39. if ($classType == "b") {
  40. $collectHtml .= '<td class="colGreen taR">¥' . $value ['price'] . '</td>';
  41. $falg = false;
  42. break;
  43. } else {
  44. $collectHtml .= '<td class="taR">¥' . $value ['price'] . '</td>';
  45. $falg = false;
  46. break;
  47. }
  48. }
  49. }
  50. if ($falg)
  51. $collectHtml .= '<td class="taR">-</td>';
  52. }
  53. $collectHtml .= '<td class="taR colGreen">¥' . $sumPrice . '</td>';
  54. return $collectHtml;
  55. }
  56. function __construct() {
  57. if (isset ( $_COOKIE ["staff"] )) {
  58. if (! empty ( $_COOKIE ["staff"] )) {
  59. Doo::loadModel ( 'staff' );
  60. Doo::loadModel ( 'verify' );
  61. $verify = new verify ();
  62. $staff = new staff ();
  63. Doo::loadModel ( "execute" );
  64. $execute = new execute ();
  65. $verifyList = $verify->find ( array (
  66. 'select' => 'staff',
  67. 'asArray' => true
  68. ) );
  69. $list = array ();
  70. // 判断角色的审批权限
  71. foreach ( $verifyList as $key => $value ) {
  72. $ver = json_decode ( $value ['staff'] );
  73. foreach ( $ver as $k => $v ) {
  74. if ($v [1] == 'ROLE') {
  75. $roleList = json_decode ( $v [3] );
  76. foreach ( $roleList as $t => $g ) {
  77. $gList = explode ( "_", $g );
  78. array_push ( $list, $gList [0] );
  79. // print_r($list);
  80. }
  81. } else
  82. array_push ( $list, $v [0] );
  83. }
  84. }
  85. // 判断执行人的审批权限
  86. $executeList = $execute->find ( array (
  87. 'select' => 'staff',
  88. 'asArray' => true
  89. ) );
  90. $list2 = array ();
  91. foreach ( $executeList as $key => $value ) {
  92. $ver = json_decode ( $value ['staff'] );
  93. foreach ( $ver as $k => $v ) {
  94. array_push ( $list2, $v [0] );
  95. }
  96. }
  97. $eidList = file_get_contents ( "protected/config/execute/execute.ini" );
  98. $eidList = array_filter ( explode ( ",", $eidList ) );
  99. $this->executeId = array_merge ( $list2, $eidList );
  100. $this->verifyId = $list;
  101. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  102. return "/";
  103. }
  104. }
  105. Doo::loadCore ( 'uri/DooUriRouter' );
  106. $router = new DooUriRouter ();
  107. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  108. if ($routeRs ['1'] != "login") {
  109. header ( 'Content-Type:text/html;charset=utf-8' );
  110. @header ( "Location: /login" );
  111. }
  112. }
  113. function saeaBorad() {
  114. Doo::loadModel ( 'receipt' );
  115. Doo::loadModel ( 'verify' );
  116. $verify = new verify ();
  117. $receipt = new receipt ();
  118. Doo::loadModel ( 'L_category' );
  119. $lCategory = new L_category ();
  120. Doo::loadModel ( "role" );
  121. $role = new role ();
  122. Doo::loadModel ( "receiptLog" );
  123. $receiptLog = new receiptLog ();
  124. Doo::loadClass ( 'XDeode' );
  125. $XDeode = new XDeode ( 7 );
  126. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  127. $receiptDetail = $receipt->find ( array (
  128. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  129. 'desc' => 'rid',
  130. 'asArray' => true
  131. ) );
  132. foreach ( $receiptDetail as $key => $value ) {
  133. $receiptDetail [$key]['ridKey']=$XDeode->encode ( $value['rid'] );
  134. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  135. $veList = $verify->getOne ( array (
  136. 'where' => 'vid=' . $value ['verify'],
  137. 'asArray' => true
  138. ) );
  139. $v = json_decode ( $veList ['staff'] );
  140. array_push ( $v [0], $veList ['description'] );
  141. foreach ( $v as $n => $m ) {
  142. if ($m ['1'] == 'ROLE') {
  143. $roleInfo = $role->getOne ( array (
  144. 'where' => 'rid=' . $m [0],
  145. 'asArray' => true
  146. ) );
  147. $v [$n] [1] = $roleInfo ['name'];
  148. }
  149. }
  150. $receiptDetail [$key] ['staff'] = $v;
  151. $category = $lCategory->getOne ( array (
  152. 'where' => 'cid=' . $value ['cid'],
  153. 'asArray' => true
  154. ) );
  155. $receiptDetail [$key] ['category'] = $category ['title'];
  156. }
  157. // print_r($receiptLogList);
  158. $data ['receiptLogList'] = $receiptLogList;
  159. $data ['receiptDetail'] = $receiptDetail;
  160. $data ['memu'] = "receipt";
  161. $data ['staff'] = $this->staff;
  162. $data ['receiptMemu'] = 'saeaBorad';
  163. $data ['verifyId'] = $this->verifyId;
  164. $data ['executeId'] = $this->executeId;
  165. $this->render ( "/admin/saeaBorad", $data );
  166. }
  167. function remitAdd() {
  168. Doo::loadModel ( 'accountItem' );
  169. Doo::loadModel ( 'verify' );
  170. Doo::loadModel ( 'receipt' );
  171. Doo::loadModel ( 'L_category' );
  172. $lCategory = new L_category ();
  173. $receipt = new receipt ();
  174. $verify = new verify ();
  175. $accountItem = new accountItem ();
  176. Doo::loadModel ( "role" );
  177. $role = new role ();
  178. $acItem = $accountItem->find ( array (
  179. 'asArray' => true
  180. ) );
  181. $veList = $verify->find ( array (
  182. 'asArray' => true
  183. ) );
  184. foreach ( $veList as $key => $value ) {
  185. $v = json_decode ( $value ['staff'] );
  186. $list = array ();
  187. foreach ( $v as $n => $m ) {
  188. if ($m ['1'] == 'ROLE') {
  189. $roleInfo = $role->getOne ( array (
  190. 'where' => 'rid=' . $m [0],
  191. 'asArray' => true
  192. ) );
  193. $v [$n] [1] = $roleInfo ['name'];
  194. array_push ( $list, $roleInfo ['name'] );
  195. } else {
  196. array_push ( $list, $v [$n] [1] );
  197. }
  198. }
  199. $veList [$key] ['staff'] = implode ( '>', $list );
  200. }
  201. $data ['category'] = $lCategory->find ( array (
  202. 'asArray' => true
  203. ) );
  204. $data ['veList'] = $veList;
  205. $data ['acItem'] = $acItem;
  206. $data ['memu'] = "receipt";
  207. $data ['staff'] = $this->staff;
  208. $data ['receiptMemu'] = 'saeaBorad';
  209. $data ['verifyId'] = $this->verifyId;
  210. $data ['executeId'] = $this->executeId;
  211. $this->render ( "/admin/remitAdd", $data );
  212. }
  213. function remitAddDo() {
  214. $agency = $this->get_args ( 'agency' );
  215. $travel = $this->get_args ( 'travel' );
  216. $train = $this->get_args ( 'train' );
  217. $other = $this->get_args ( 'other' );
  218. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  219. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  220. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  221. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  222. // print_r($agency);die;
  223. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  224. Doo::loadModel ( 'receipt' );
  225. Doo::loadModel ( 'receiptDetail' );
  226. Doo::loadModel ( 'accountItem' );
  227. $accountItem = new accountItem ();
  228. $receipt = new receipt ();
  229. Doo::loadModel ( 'enclosur' );
  230. Doo::loadModel ( 'execute' );
  231. $execute = new execute ();
  232. $executeDetail = $execute->getOne ( array (
  233. 'where' => 'mold="对公汇款执行人"',
  234. 'asArray' => true
  235. ) );
  236. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  237. $aItem = $accountItem->find ( array (
  238. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  239. 'asArray' => true
  240. ) );
  241. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  242. $ag = $tr = $ta = $ot = 0;
  243. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  244. foreach ( $aItem as $key => $value ) {
  245. if ($value ['category'] == $this->AGENCY) {
  246. if (isset ( $agency [$ag] )) {
  247. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  248. array_push ( $accountJson [$this->AGENCY], array (
  249. 'aid' => $value ['aid'],
  250. 'name' => $value ['name'],
  251. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  252. ) );
  253. $sum += $agency [$ag];
  254. $agencySum += $agency [$ag];
  255. }
  256. }
  257. $ag ++;
  258. }
  259. }
  260. $accountJson ['cSum'] = array (
  261. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  262. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  263. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  264. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  265. );
  266. // 报销单
  267. $receipt->accountItem = json_encode ( $accountJson );
  268. $receipt->staff = $this->staff [0] ['sid'];
  269. $receipt->sum = number_format ( $sum, 2, '.', '' );
  270. $receipt->date = date ( "Y-m-d" );
  271. $receipt->cid = $cid;
  272. $receipt->status = 5;
  273. $receipt->Rtype = 2;
  274. // 修改审批流程加入角色
  275. $receipt->verify = $verify;
  276. $receipt->executeCopy = $executeDetail ['staff'];
  277. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  278. $receipt->explanation = $explanation;
  279. $rid = $receipt->insert ();
  280. // 附件
  281. if (! empty ( $enclosurName )) {
  282. $enclosurArray = explode ( '-', $enclosurName );
  283. foreach ( $enclosurArray as $value ) {
  284. $enclosur = new enclosur ();
  285. $enclosur->name = $value;
  286. $enclosur->rid = $rid;
  287. $enclosur->insert ();
  288. }
  289. // print_r($enclosurArray);die;
  290. }
  291. // 报销详情
  292. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  293. $receiptDetail = new receiptDetail ();
  294. $receiptDetail->staff = $this->staff [0] ['sid'];
  295. $receiptDetail->item = $value ['name'];
  296. $receiptDetail->itemCategory = $this->AGENCY;
  297. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  298. $receiptDetail->date = date ( "Y-m-d" );
  299. $receiptDetail->cid = $cid;
  300. $receiptDetail->rid = $rid;
  301. $receiptDetail->status = 4;
  302. $receiptDetail->insert ();
  303. }
  304. return "/saeaBorad";
  305. } else
  306. die ( 'illegal request' );
  307. }
  308. function remitEdit() {
  309. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  310. // echo $rid;
  311. Doo::loadModel ( 'accountItem' );
  312. Doo::loadModel ( 'verify' );
  313. Doo::loadModel ( 'receipt' );
  314. $receipt = new receipt ();
  315. $verify = new verify ();
  316. $accountItem = new accountItem ();
  317. Doo::loadModel ( 'L_category' );
  318. $lCategory = new L_category ();
  319. Doo::loadModel ( "role" );
  320. $role = new role ();
  321. $receiptDetail = $receipt->getOne ( array (
  322. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  323. 'asArray' => true
  324. ) );
  325. if (empty ( $receiptDetail ))
  326. return "/saeaCreate";
  327. $acItem = $accountItem->find ( array (
  328. 'asArray' => true
  329. ) );
  330. $veList = $verify->find ( array (
  331. 'asArray' => true
  332. ) );
  333. foreach ( $veList as $key => $value ) {
  334. $v = json_decode ( $value ['staff'] );
  335. $list = array ();
  336. foreach ( $v as $n => $m ) {
  337. if ($m ['1'] == 'ROLE') {
  338. $roleInfo = $role->getOne ( array (
  339. 'where' => 'rid=' . $m [0],
  340. 'asArray' => true
  341. ) );
  342. $v [$n] [1] = $roleInfo ['name'];
  343. array_push ( $list, $roleInfo ['name'] );
  344. } else {
  345. array_push ( $list, $v [$n] [1] );
  346. }
  347. }
  348. $veList [$key] ['staff'] = implode ( '>', $list );
  349. }
  350. // 配置编辑信息
  351. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  352. foreach ( $acItem as $key => $value ) {
  353. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  354. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  355. $acItem [$key] ['price'] = $v ['price'];
  356. }
  357. }
  358. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  359. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  360. $acItem [$key] ['price'] = $v ['price'];
  361. }
  362. }
  363. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  364. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  365. $acItem [$key] ['price'] = $v ['price'];
  366. }
  367. }
  368. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  369. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  370. $acItem [$key] ['price'] = $v ['price'];
  371. }
  372. }
  373. }
  374. $data ['category'] = $lCategory->find ( array (
  375. 'asArray' => true
  376. ) );
  377. $data ['cSum'] = $accountItemList ['cSum'];
  378. $data ['sum'] = $receiptDetail ['sum'];
  379. $data ['receiptDetail'] = $receiptDetail;
  380. $data ['veList'] = $veList;
  381. $data ['acItem'] = $acItem;
  382. $data ['memu'] = "receipt";
  383. $data ['staff'] = $this->staff;
  384. $data ['receiptMemu'] = 'saeaBorad';
  385. $data ['verify'] = $receiptDetail ['verify'];
  386. $data ['verifyId'] = $this->verifyId;
  387. $data ['executeId'] = $this->executeId;
  388. $data ['rid'] = $rid;
  389. $this->render ( "/admin/remitEdit", $data );
  390. }
  391. function remitEdiDo() {
  392. $agency = $this->get_args ( 'agency' );
  393. $travel = $this->get_args ( 'travel' );
  394. $train = $this->get_args ( 'train' );
  395. $other = $this->get_args ( 'other' );
  396. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  397. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  398. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  399. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  400. if (! empty ( $explanation )) {
  401. Doo::loadModel ( 'receipt' );
  402. Doo::loadModel ( 'receiptDetail' );
  403. Doo::loadModel ( 'accountItem' );
  404. $accountItem = new accountItem ();
  405. $receipt = new receipt ();
  406. Doo::loadModel ( 'execute' );
  407. $execute = new execute ();
  408. $executeDetail = $execute->getOne ( array (
  409. 'where' => 'mold="对公汇款执行人"',
  410. 'asArray' => true
  411. ) );
  412. $receiptDetail = $receipt->getOne ( array (
  413. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  414. 'asArray' => true
  415. ) );
  416. if (empty ( $receiptDetail ))
  417. return "/saeaBorad";
  418. $aItem = $accountItem->find ( array (
  419. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  420. 'asArray' => true
  421. ) );
  422. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  423. $ag = $tr = $ta = $ot = 0;
  424. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  425. foreach ( $aItem as $key => $value ) {
  426. if ($value ['category'] == $this->AGENCY) {
  427. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  428. array_push ( $accountJson [$this->AGENCY], array (
  429. 'aid' => $value ['aid'],
  430. 'name' => $value ['name'],
  431. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  432. ) );
  433. $sum += $agency [$ag];
  434. $agencySum += $agency [$ag];
  435. }
  436. $ag ++;
  437. }
  438. }
  439. $accountJson ['cSum'] = array (
  440. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  441. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  442. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  443. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  444. );
  445. // 报销单
  446. $rid = $receipt->rid = $receiptDetail ['rid'];
  447. $receipt->accountItem = json_encode ( $accountJson );
  448. $receipt->staff = $this->staff [0] ['sid'];
  449. $receipt->sum = number_format ( $sum, 2, '.', '' );
  450. $receipt->date = date ( "Y-m-d" );
  451. $receipt->cid = $cid;
  452. if ($receiptDetail ['Rtype'] == 1)
  453. $receipt->status = 7;
  454. else
  455. $receipt->status = 5;
  456. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  457. $receipt->verify = $verify;
  458. $receipt->executeCopy = $executeDetail ['staff'];
  459. $receipt->explanation = $explanation;
  460. $receipt->update ();
  461. $receiptDetail = new receiptDetail ();
  462. $receiptDetail->delete ( array (
  463. 'where' => 'rid=' . $rid
  464. ) );
  465. // 报销详情
  466. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  467. $receiptDetail = new receiptDetail ();
  468. $receiptDetail->staff = $this->staff [0] ['sid'];
  469. $receiptDetail->item = $value ['name'];
  470. $receiptDetail->itemCategory = $this->AGENCY;
  471. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  472. $receiptDetail->date = date ( "Y-m-d" );
  473. $receiptDetail->cid = $cid;
  474. $receiptDetail->rid = $rid;
  475. $receiptDetail->status = 4;
  476. $receiptDetail->insert ();
  477. }
  478. // return "/referReceipt/".$rid;
  479. }
  480. return "/saeaBorad";
  481. }
  482. function remitApproval() {
  483. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  484. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  485. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  486. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  487. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  488. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  489. if (empty ( $status ))
  490. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  491. $vidList = array ();
  492. $button = 0;
  493. Doo::loadModel ( 'verify' );
  494. Doo::loadModel ( 'receipt' );
  495. Doo::loadModel ( 'staff' );
  496. $staff = new staff ();
  497. $receipt = new receipt ();
  498. $verify = new verify ();
  499. Doo::loadModel ( 'L_category' );
  500. $Lcategory = new L_category ();
  501. Doo::loadModel ( 'enclosur' );
  502. $enclosur = new enclosur ();
  503. // user verify ID
  504. $verifyDetail = $verify->find ( array (
  505. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  506. 'asArray' => true
  507. ) );
  508. foreach ( $verifyDetail as $key => $value ) {
  509. array_push ( $vidList, $value ['vid'] );
  510. }
  511. $vid = implode ( ",", $vidList );
  512. if (empty ( $verifyDetail ))
  513. $vid = 0;
  514. $categoryList = $Lcategory->find ( array (
  515. 'asArray' => true
  516. ) );
  517. $staffList = $staff->find ( array (
  518. 'where' => 'cid=' . $cid,
  519. 'asArray' => true
  520. ) );
  521. $ap = "";
  522. if ($status == 4) {
  523. $ap = 4;
  524. $status = 2;
  525. }
  526. // get Receipt By verifyID status 2
  527. $receiptList = $receipt->find ( array (
  528. 'where' => 'rid =' . $rid . ' and status=2',
  529. 'desc' => 'rid',
  530. 'asArray' => true
  531. ) );
  532. if (empty ( $receiptList )) {
  533. die ( 'illegal request' );
  534. }
  535. $Locate = 0;
  536. $roleId = 0;
  537. if ($ap == 4)
  538. $status = 4;
  539. foreach ( $receiptList as $key => $value ) {
  540. $receiptList [$key] ['Locate'] = $Locate;
  541. $Locate ++;
  542. $receiptList [$key] ['reviseDetail'] = array ();
  543. if (! empty ( $value ['reviseDetail'] ))
  544. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  545. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  546. $categoryDetil = $Lcategory->getOne ( array (
  547. 'where' => 'cid=' . $value ['cid'],
  548. 'asArray' => true
  549. ) );
  550. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  551. // 检测编辑状态
  552. $verifyList = $verify->getOne ( array (
  553. 'where' => 'vid=' . $value ['verify'],
  554. 'asArray' => true
  555. ) );
  556. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  557. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  558. Doo::loadModel ( 'role' );
  559. $role = new role ();
  560. // print_r($verifyList);
  561. $flag = true;
  562. $roleKey = 0;
  563. $endStaffArray = array ();
  564. $roleArrayCopy = array ();
  565. foreach ( $verifyList as $k => $v ) {
  566. // init verifyStaff
  567. if ($v [1] == 'ROLE') {
  568. if (! empty ( $verifyStaff )) {
  569. $endStaffArray = end ( $verifyStaff );
  570. if ($v [0] == $endStaffArray ['nextStaff']) {
  571. $roleId = $v [0];
  572. }
  573. }
  574. $roleVerify = json_decode ( $v [3], true );
  575. $roleKey = $k;
  576. $roleArray = array ();
  577. $rolename = $role->getOne ( array (
  578. 'where' => 'rid=' . $v [0],
  579. 'asArray' => true
  580. ) );
  581. foreach ( $roleVerify as $o => $p ) {
  582. $staffID = explode ( '_', $p );
  583. $staffInfo = $staff->getOne ( array (
  584. 'where' => 'sid=' . $staffID [0],
  585. 'asArray' => true
  586. ) );
  587. // print_r($staffID);
  588. $exp = array (
  589. 0 => $staffInfo ['sid'],
  590. 1 => $staffID [1],
  591. 2 => $staffInfo ['avatar'],
  592. 'date' => '',
  593. 'date' => '',
  594. 'opinion' => '',
  595. 'status' => '',
  596. 'rolename' => $rolename ['name']
  597. );
  598. array_push ( $roleArray, $exp );
  599. }
  600. $roleArrayCopy [$v [0]] = $roleArray;
  601. // $verifyList[$k]['roleArray']=$roleArray;
  602. }
  603. // print_r($roleArray);
  604. $verifyList [$k] ['date'] = "";
  605. $verifyList [$k] ['opinion'] = "";
  606. $verifyList [$k] ['status'] = "";
  607. if (empty ( $verifyStaff )) {
  608. $verifyList [$k] ['date'] = "";
  609. $verifyList [$k] ['opinion'] = "";
  610. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  611. $verifyList [$k] ['status'] = 4;
  612. $button = 4;
  613. $flag = false;
  614. }
  615. } else {
  616. foreach ( $verifyStaff as $m => $u ) {
  617. if ($v [0] == $m) {
  618. $verifyList [$k] ['date'] = $u ['date'];
  619. $verifyList [$k] ['opinion'] = $u ['opinion'];
  620. $verifyList [$k] ['status'] = $u ['status'];
  621. $flag = false;
  622. break;
  623. }
  624. }
  625. $endStaffArray = end ( $verifyStaff );
  626. if (isset ( $endStaffArray ['ROLE'] )) {
  627. } else {
  628. $endKey = key ( $verifyStaff );
  629. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  630. $button = 4;
  631. $verifyList [$k] ['status'] = 4;
  632. }
  633. }
  634. }
  635. }
  636. $rolename ['name'] = '';
  637. if (! empty ( $roleId )) {
  638. Doo::loadModel ( 'role' );
  639. $role = new role ();
  640. $rolename = $role->getOne ( array (
  641. 'where' => 'rid=' . $roleId,
  642. 'asArray' => true
  643. ) );
  644. }
  645. if (! empty ( $verifyStaff ))
  646. $endStaffArray = end ( $verifyStaff );
  647. $KOP = false;
  648. foreach ( $roleArrayCopy as $P => $A ) {
  649. foreach ( $A as $MKI => $AVL ) {
  650. if (! empty ( $verifyStaff )) {
  651. // &&$rolename['rid']==$endStaffArray['nextStaff']
  652. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  653. $button = 4;
  654. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  655. }
  656. foreach ( $verifyStaff as $m => $u ) {
  657. $AVLFK = $AVL [0] . '_R';
  658. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  659. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  660. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  661. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  662. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  663. break;
  664. }
  665. }
  666. } else {
  667. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  668. $button = 4;
  669. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  670. }
  671. }
  672. // $roleArray[$MKI]['rolename']=$rolename['name'];
  673. $KOP = true;
  674. }
  675. }
  676. foreach ( $roleArrayCopy as $k => $v ) {
  677. foreach ( $verifyList as $m => $n ) {
  678. if ($n [0] == $k) {
  679. array_splice ( $verifyList, $m, 1, $v );
  680. }
  681. }
  682. }
  683. $receiptList [$key] ['verifyList'] = $verifyList;
  684. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  685. 'where' => 'sid=' . $value ['staff'],
  686. 'asArray' => true
  687. ) );
  688. $receiptList [$key] ['button'] = $button;
  689. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  690. }
  691. $mothHtml = "";
  692. for($i = 1; $i <= 12; $i ++) {
  693. if ($month == $i)
  694. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  695. else
  696. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  697. }
  698. // 获取审批日志
  699. Doo::loadModel ( 'receiptLog' );
  700. $receiptLog = new receiptLog ();
  701. $rlList = array ();
  702. $rlInfo = $receiptLog->getOne ( array (
  703. 'where' => 'rid=' . $rid . ' and status=4',
  704. 'asArray' => true
  705. ) );
  706. $tijdate = $receiptLog->getOne ( array (
  707. 'where' => 'rid=' . $rid . ' and status=2',
  708. 'asc' => 'rlid',
  709. 'asArray' => true
  710. ) );
  711. if (! empty ( $rlInfo )) {
  712. $rlList = $receiptLog->find ( array (
  713. 'where' => 'rid=' . $rid,
  714. 'asc' => 'rlid',
  715. 'asArray' => true
  716. ) );
  717. }
  718. $receiptList [0] ['rlList'] = $rlList;
  719. $enclosurList = $enclosur->find ( array (
  720. 'where' => 'rid=' . $rid,
  721. 'asArray' => true
  722. ) );
  723. $enclosurHtml = '';
  724. foreach ( $enclosurList as $value ) {
  725. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  726. }
  727. // print_r($receiptList);
  728. $data ['enclosurHtml'] = $enclosurHtml;
  729. $data ['rolename'] = $rolename ['name'];
  730. $data ['datetij'] = $tijdate ['date'];
  731. $data ['mothHtml'] = $mothHtml;
  732. $data ['rid'] = $rid;
  733. $data ['receiptList'] = $receiptList;
  734. $data ['receiptApprovalCount'] = count ( $receiptList );
  735. $data ['status'] = $status;
  736. $data ['year'] = $year;
  737. $data ['categoryList'] = $categoryList;
  738. $data ['staffList'] = $staffList;
  739. $data ['cid'] = $cid;
  740. $data ['sid'] = $sid;
  741. $data ['ap'] = $ap;
  742. $data ['memu'] = "receipt";
  743. $data ['staff'] = $this->staff;
  744. $data ['receiptMemu'] = 'approvalExpenses';
  745. $data ['verifyId'] = $this->verifyId;
  746. $data ['executeId'] = $this->executeId;
  747. $this->render ( "/admin/remitApproval", $data );
  748. }
  749. function saeaLoanAdd() {
  750. Doo::loadModel ( 'verify' );
  751. $verify = new verify ();
  752. Doo::loadModel ( "role" );
  753. $role = new role ();
  754. Doo::loadModel ( 'L_category' );
  755. $lCategory = new L_category ();
  756. $veList = $verify->find ( array (
  757. 'asArray' => true
  758. ) );
  759. foreach ( $veList as $key => $value ) {
  760. $v = json_decode ( $value ['staff'] );
  761. $list = array ();
  762. foreach ( $v as $n => $m ) {
  763. if ($m ['1'] == 'ROLE') {
  764. $roleInfo = $role->getOne ( array (
  765. 'where' => 'rid=' . $m [0],
  766. 'asArray' => true
  767. ) );
  768. $v [$n] [1] = $roleInfo ['name'];
  769. array_push ( $list, $roleInfo ['name'] );
  770. } else {
  771. array_push ( $list, $v [$n] [1] );
  772. }
  773. }
  774. $veList [$key] ['staff'] = implode ( '>', $list );
  775. }
  776. $data ['category'] = $lCategory->find ( array (
  777. 'asArray' => true
  778. ) );
  779. $data ['veList'] = $veList;
  780. $data ['memu'] = "receipt";
  781. $data ['staff'] = $this->staff;
  782. $data ['receiptMemu'] = 'saeaBorad';
  783. $data ['verifyId'] = $this->verifyId;
  784. $data ['executeId'] = $this->executeId;
  785. $this->render ( "/admin/saeaLoanAdd", $data );
  786. }
  787. function saeaLoanAddDo() {
  788. $agency = $this->get_args ( 'agency' );
  789. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  790. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  791. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  792. // die;
  793. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  794. Doo::loadModel ( 'receipt' );
  795. Doo::loadModel ( 'receiptDetail' );
  796. Doo::loadModel ( 'accountItem' );
  797. $accountItem = new accountItem ();
  798. $receipt = new receipt ();
  799. Doo::loadModel ( 'loanReceipt' );
  800. $loanReceipt = new loanReceipt ();
  801. Doo::loadModel ( 'execute' );
  802. $execute = new execute ();
  803. Doo::loadModel ( 'enclosur' );
  804. $executeDetail = $execute->getOne ( array (
  805. 'where' => 'mold="借款执行人"',
  806. 'asArray' => true
  807. ) );
  808. $aItem = $accountItem->find ( array (
  809. 'asArray' => true
  810. ) );
  811. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  812. $ag = $tr = $ta = $ot = 0;
  813. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  814. array_push ( $accountJson ['借款费用'], array (
  815. 'aid' => 0,
  816. 'name' => '申请金额',
  817. 'price' => number_format ( $agency, 2, '.', '' )
  818. ) );
  819. $sum += $agency;
  820. $agencySum += $agency;
  821. $accountJson ['cSum'] = array (
  822. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  823. 'agencySum' => number_format ( 0, 2, '.', '' ),
  824. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  825. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  826. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  827. );
  828. // 借款数据备份
  829. $loanReceipt->loanItem = json_encode ( $accountJson );
  830. $loanReceipt->staff = $this->staff [0] ['sid'];
  831. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  832. $loanReceipt->date = date ( "Y-m-d" );
  833. $loanReceipt->cid = $cid;
  834. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  835. $loanReceipt->status = 5;
  836. $loanReceipt->Rtype = 1;
  837. $loanReceipt->verify = $verify;
  838. $receipt->receiptOrder = $receipt->receiptOrder;
  839. $loanReceipt->explanation = $explanation;
  840. $loanRid = $loanReceipt->insert ();
  841. // 报销单
  842. $receipt->loanItem = json_encode ( $accountJson );
  843. $receipt->staff = $this->staff [0] ['sid'];
  844. $receipt->sum = number_format ( $sum, 2, '.', '' );
  845. $receipt->date = date ( "Y-m-d" );
  846. $receipt->cid = $cid;
  847. // 特殊状态
  848. $receipt->status = 5;
  849. $receipt->Rtype = 1;
  850. $receipt->loanRid = $loanRid;
  851. // 修改审批流程加入角色
  852. $receipt->verify = $verify;
  853. $receipt->executeCopy = $executeDetail ['staff'];
  854. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  855. $receipt->explanation = $explanation;
  856. $rid = $receipt->insert ();
  857. return "/saeaBorad";
  858. } else
  859. die ( 'illegal request' );
  860. }
  861. function saeaLoanEdi() {
  862. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  863. Doo::loadModel ( 'verify' );
  864. $verify = new verify ();
  865. Doo::loadModel ( "role" );
  866. $role = new role ();
  867. Doo::loadModel ( 'L_category' );
  868. $lCategory = new L_category ();
  869. Doo::loadModel ( 'receipt' );
  870. $receipt = new receipt ();
  871. $receiptInfo = $receipt->getOne ( array (
  872. 'where' => 'rid=' . $rid,
  873. 'asArray' => true
  874. ) );
  875. $veList = $verify->find ( array (
  876. 'asArray' => true
  877. ) );
  878. foreach ( $veList as $key => $value ) {
  879. $v = json_decode ( $value ['staff'] );
  880. $list = array ();
  881. foreach ( $v as $n => $m ) {
  882. if ($m ['1'] == 'ROLE') {
  883. $roleInfo = $role->getOne ( array (
  884. 'where' => 'rid=' . $m [0],
  885. 'asArray' => true
  886. ) );
  887. $v [$n] [1] = $roleInfo ['name'];
  888. array_push ( $list, $roleInfo ['name'] );
  889. } else {
  890. array_push ( $list, $v [$n] [1] );
  891. }
  892. }
  893. $veList [$key] ['staff'] = implode ( '>', $list );
  894. }
  895. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  896. $data ['receiptInfo'] = $receiptInfo;
  897. $data ['category'] = $lCategory->find ( array (
  898. 'asArray' => true
  899. ) );
  900. $data ['veList'] = $veList;
  901. $data ['memu'] = "receipt";
  902. $data ['staff'] = $this->staff;
  903. $data ['receiptMemu'] = 'saeaBorad';
  904. $data ['verifyId'] = $this->verifyId;
  905. $data ['executeId'] = $this->executeId;
  906. $this->render ( "/admin/saeaLoanEdi", $data );
  907. }
  908. function saeaLoanEdiDo() {
  909. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  910. $agency = $this->get_args ( 'agency' );
  911. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  912. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  913. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  914. // die;
  915. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )) {
  916. Doo::loadModel ( 'receipt' );
  917. Doo::loadModel ( 'receiptDetail' );
  918. Doo::loadModel ( 'accountItem' );
  919. $accountItem = new accountItem ();
  920. $receipt = new receipt ();
  921. Doo::loadModel ( 'loanReceipt' );
  922. $loanReceipt = new loanReceipt ();
  923. Doo::loadModel ( 'enclosur' );
  924. Doo::loadModel ( 'execute' );
  925. $execute = new execute ();
  926. $executeDetail = $execute->getOne ( array (
  927. 'where' => 'mold="借款执行人"',
  928. 'asArray' => true
  929. ) );
  930. $receiptDetail = $receipt->getOne ( array (
  931. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  932. 'asArray' => true
  933. ) );
  934. if (empty ( $receiptDetail ))
  935. die ( '参数错误' );
  936. $aItem = $accountItem->find ( array (
  937. 'asArray' => true
  938. ) );
  939. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  940. $ag = $tr = $ta = $ot = 0;
  941. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  942. array_push ( $accountJson ['借款费用'], array (
  943. 'aid' => 0,
  944. 'name' => '申请金额',
  945. 'price' => number_format ( $agency, 2, '.', '' )
  946. ) );
  947. $sum += $agency;
  948. $agencySum += $agency;
  949. $accountJson ['cSum'] = array (
  950. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  951. 'agencySum' => number_format ( 0, 2, '.', '' ),
  952. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  953. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  954. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  955. );
  956. // 报销单
  957. $receipt->loanItem = json_encode ( $accountJson );
  958. $receipt->sum = number_format ( $sum, 2, '.', '' );
  959. $receipt->cid = $cid;
  960. // 特殊状态
  961. // 修改审批流程加入角色
  962. if ($receiptDetail ['status'] != 4)
  963. $receipt->verify = $verify;
  964. $receipt->explanation = $explanation;
  965. $receipt->update ( array (
  966. 'where' => 'rid=' . $rid
  967. ) );
  968. // 借款数据更新
  969. $loanReceipt->loanItem = json_encode ( $accountJson );
  970. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  971. $loanReceipt->cid = $cid;
  972. if ($receiptDetail ['status'] != 4)
  973. $loanReceipt->verify = $verify;
  974. $loanReceipt->explanation = $explanation;
  975. $receipt->executeCopy = $executeDetail ['staff'];
  976. $loanReceipt->update ( array (
  977. 'where' => 'rid=' . $receiptDetail ['loanRid']
  978. ) );
  979. }
  980. return "/saeaBorad";
  981. }
  982. function saeaLoanReceiptAdd() {
  983. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  984. Doo::loadModel ( 'receipt' );
  985. $receipt = new receipt ();
  986. Doo::loadModel ( 'loanReceipt' );
  987. $loanReceipt = new loanReceipt ();
  988. Doo::loadModel ( 'L_category' );
  989. $Lcategory = new L_category ();
  990. Doo::loadModel ( 'verify' );
  991. Doo::loadModel ( 'statistics' );
  992. $statistics = new statistics ();
  993. $verify = new verify ();
  994. Doo::loadModel ( 'staff' );
  995. $staff = new staff ();
  996. $receiptDe = $receipt->getOne ( array (
  997. 'where' => 'rid=' . $rid,
  998. 'desc' => 'rid',
  999. 'asArray' => true
  1000. ) );
  1001. $receiptList = $loanReceipt->find ( array (
  1002. 'where' => 'rid=' . $receiptDe ['loanRid'],
  1003. 'desc' => 'rid',
  1004. 'asArray' => true
  1005. ) );
  1006. $Locate = 0;
  1007. $roleId = 0;
  1008. $button = 0;
  1009. foreach ( $receiptList as $key => $value ) {
  1010. $receiptList [$key] ['Locate'] = $Locate;
  1011. $Locate ++;
  1012. $receiptList [$key] ['reviseDetail'] = array ();
  1013. if (! empty ( $value ['reviseDetail'] ))
  1014. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1015. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1016. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1017. $categoryDetil = $Lcategory->getOne ( array (
  1018. 'where' => 'cid=' . $value ['cid'],
  1019. 'asArray' => true
  1020. ) );
  1021. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1022. // 检测编辑状态
  1023. $verifyList = $verify->getOne ( array (
  1024. 'where' => 'vid=' . $value ['verify'],
  1025. 'asArray' => true
  1026. ) );
  1027. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1028. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1029. Doo::loadModel ( 'role' );
  1030. $role = new role ();
  1031. $flag = true;
  1032. $roleKey = 0;
  1033. $endStaffArray = array ();
  1034. $roleArrayCopy = array ();
  1035. foreach ( $verifyList as $k => $v ) {
  1036. // init verifyStaff
  1037. if ($v [1] == 'ROLE') {
  1038. if (! empty ( $verifyStaff )) {
  1039. $endStaffArray = end ( $verifyStaff );
  1040. // if ($v[0]==$endStaffArray['nextStaff']){
  1041. // $roleId=$v[0];
  1042. // }
  1043. }
  1044. $roleVerify = json_decode ( $v [3], true );
  1045. $roleKey = $k;
  1046. $roleArray = array ();
  1047. $rolename = $role->getOne ( array (
  1048. 'where' => 'rid=' . $v [0],
  1049. 'asArray' => true
  1050. ) );
  1051. foreach ( $roleVerify as $o => $p ) {
  1052. $staffID = explode ( '_', $p );
  1053. $staffInfo = $staff->getOne ( array (
  1054. 'where' => 'sid=' . $staffID [0],
  1055. 'asArray' => true
  1056. ) );
  1057. // print_r($staffID);
  1058. $exp = array (
  1059. 0 => $staffInfo ['sid'],
  1060. 1 => $staffID [1],
  1061. 2 => $staffInfo ['avatar'],
  1062. 'date' => '',
  1063. 'date' => '',
  1064. 'opinion' => '',
  1065. 'status' => '',
  1066. 'rolename' => $rolename ['name']
  1067. );
  1068. array_push ( $roleArray, $exp );
  1069. }
  1070. $roleArrayCopy [$v [0]] = $roleArray;
  1071. // $verifyList[$k]['roleArray']=$roleArray;
  1072. }
  1073. $verifyList [$k] ['date'] = "";
  1074. $verifyList [$k] ['opinion'] = "";
  1075. $verifyList [$k] ['status'] = "";
  1076. if (empty ( $verifyStaff )) {
  1077. $verifyList [$k] ['date'] = "";
  1078. $verifyList [$k] ['opinion'] = "";
  1079. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1080. $verifyList [$k] ['status'] = 4;
  1081. $flag = false;
  1082. }
  1083. } else {
  1084. foreach ( $verifyStaff as $m => $u ) {
  1085. if ($v [0] == $m) {
  1086. $verifyList [$k] ['date'] = $u ['date'];
  1087. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1088. $verifyList [$k] ['status'] = $u ['status'];
  1089. $flag = false;
  1090. break;
  1091. }
  1092. }
  1093. $endStaffArray = end ( $verifyStaff );
  1094. if (isset ( $endStaffArray ['ROLE'] )) {
  1095. } else {
  1096. // $endKey=key($verifyStaff);
  1097. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1098. // $button=4;
  1099. // $verifyList[$k]['status']=4;
  1100. // }
  1101. }
  1102. }
  1103. }
  1104. $rolename ['name'] = '';
  1105. if (! empty ( $roleId )) {
  1106. Doo::loadModel ( 'role' );
  1107. $role = new role ();
  1108. $rolename = $role->getOne ( array (
  1109. 'where' => 'rid=' . $roleId,
  1110. 'asArray' => true
  1111. ) );
  1112. }
  1113. if (! empty ( $verifyStaff ))
  1114. $endStaffArray = end ( $verifyStaff );
  1115. $KOP = false;
  1116. foreach ( $roleArrayCopy as $P => $A ) {
  1117. foreach ( $A as $MKI => $AVL ) {
  1118. if (! empty ( $verifyStaff )) {
  1119. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1120. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1121. $button = 4;
  1122. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1123. }
  1124. foreach ( $verifyStaff as $m => $u ) {
  1125. $AVLFK = $AVL [0] . '_R';
  1126. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1127. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1128. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1129. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1130. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1131. break;
  1132. }
  1133. }
  1134. } else {
  1135. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1136. $button = 4;
  1137. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1138. }
  1139. }
  1140. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1141. $KOP = true;
  1142. }
  1143. }
  1144. foreach ( $roleArrayCopy as $k => $v ) {
  1145. foreach ( $verifyList as $m => $n ) {
  1146. if ($n [0] == $k) {
  1147. array_splice ( $verifyList, $m, 1, $v );
  1148. }
  1149. }
  1150. }
  1151. $receiptList [$key] ['verifyList'] = $verifyList;
  1152. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1153. 'where' => 'sid=' . $value ['staff'],
  1154. 'asArray' => true
  1155. ) );
  1156. $receiptList [$key] ['button'] = $button;
  1157. //
  1158. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1159. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1160. }
  1161. $data ['receiptList'] = $receiptList;
  1162. Doo::loadModel ( 'L_category' );
  1163. $lCategory = new L_category ();
  1164. Doo::loadModel ( 'accountItem' );
  1165. $accountItem = new accountItem ();
  1166. $acItem = $accountItem->find ( array (
  1167. 'asArray' => true
  1168. ) );
  1169. $veList = $verify->find ( array (
  1170. 'asArray' => true
  1171. ) );
  1172. foreach ( $veList as $key => $value ) {
  1173. $v = json_decode ( $value ['staff'] );
  1174. $list = array ();
  1175. foreach ( $v as $n => $m ) {
  1176. if ($m ['1'] == 'ROLE') {
  1177. $roleInfo = $role->getOne ( array (
  1178. 'where' => 'rid=' . $m [0],
  1179. 'asArray' => true
  1180. ) );
  1181. $v [$n] [1] = $roleInfo ['name'];
  1182. array_push ( $list, $roleInfo ['name'] );
  1183. } else {
  1184. array_push ( $list, $v [$n] [1] );
  1185. }
  1186. }
  1187. $veList [$key] ['staff'] = implode ( '>', $list );
  1188. }
  1189. $data ['rid'] = $rid;
  1190. $data ['category'] = $lCategory->find ( array (
  1191. 'asArray' => true
  1192. ) );
  1193. $data ['veList'] = $veList;
  1194. $data ['acItem'] = $acItem;
  1195. $data ['memu'] = "receipt";
  1196. $data ['staff'] = $this->staff;
  1197. $data ['receiptMemu'] = 'saeaBorad';
  1198. $data ['verifyId'] = $this->verifyId;
  1199. $data ['executeId'] = $this->executeId;
  1200. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1201. }
  1202. function saeaLoanReceiptAddDo() {
  1203. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1204. $agency = $this->get_args ( 'agency' );
  1205. $travel = $this->get_args ( 'travel' );
  1206. $train = $this->get_args ( 'train' );
  1207. $other = $this->get_args ( 'other' );
  1208. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1209. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1210. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1211. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1212. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )) {
  1213. Doo::loadModel ( 'receipt' );
  1214. Doo::loadModel ( 'receiptDetail' );
  1215. Doo::loadModel ( 'accountItem' );
  1216. $accountItem = new accountItem ();
  1217. $receipt = new receipt ();
  1218. Doo::loadModel ( 'enclosur' );
  1219. Doo::loadModel ( 'execute' );
  1220. $execute = new execute ();
  1221. $executeDetail = $execute->getOne ( array (
  1222. 'where' => 'mold="借款费用执行人"',
  1223. 'asArray' => true
  1224. ) );
  1225. $receiptDet = $receipt->getOne ( array (
  1226. 'where' => 'rid=' . $rid,
  1227. 'asArray' => true
  1228. ) );
  1229. // if(!empty($receiptDetail))
  1230. // return "/referReceipt/".$receiptDetail['rid'];
  1231. $aItem = $accountItem->find ( array (
  1232. 'asArray' => true
  1233. ) );
  1234. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1235. $ag = $tr = $ta = $ot = 0;
  1236. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1237. foreach ( $aItem as $key => $value ) {
  1238. if ($value ['category'] == $this->AGENCY) {
  1239. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1240. array_push ( $accountJson [$this->AGENCY], array (
  1241. 'aid' => $value ['aid'],
  1242. 'name' => $value ['name'],
  1243. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1244. ) );
  1245. $sum += $agency [$ag];
  1246. $agencySum += $agency [$ag];
  1247. }
  1248. $ag ++;
  1249. }
  1250. if ($value ['category'] == $this->TRAVEL) {
  1251. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1252. array_push ( $accountJson [$this->TRAVEL], array (
  1253. 'aid' => $value ['aid'],
  1254. 'name' => $value ['name'],
  1255. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1256. ) );
  1257. $sum += $travel [$tr];
  1258. $travelSum += $travel [$tr];
  1259. }
  1260. $tr ++;
  1261. }
  1262. if ($value ['category'] == $this->TRAIN) {
  1263. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1264. array_push ( $accountJson [$this->TRAIN], array (
  1265. 'aid' => $value ['aid'],
  1266. 'name' => $value ['name'],
  1267. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1268. ) );
  1269. $sum += $train [$ta];
  1270. $trainSum += $train [$ta];
  1271. }
  1272. $ta ++;
  1273. }
  1274. if ($value ['category'] == $this->OTHER) {
  1275. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1276. array_push ( $accountJson [$this->OTHER], array (
  1277. 'aid' => $value ['aid'],
  1278. 'name' => $value ['name'],
  1279. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1280. ) );
  1281. $sum += $other [$ot];
  1282. $otherSum += $other [$ot];
  1283. }
  1284. $ot ++;
  1285. }
  1286. }
  1287. $accountJson ['cSum'] = array (
  1288. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1289. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1290. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1291. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1292. );
  1293. // 报销单
  1294. $receipt->accountItem = json_encode ( $accountJson );
  1295. $receipt->staff = $this->staff [0] ['sid'];
  1296. $receipt->loanSum = $receiptDet ['sum'];
  1297. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1298. $receipt->date = date ( "Y-m-d" );
  1299. $receipt->pastDate = '';
  1300. $receipt->cid = $cid;
  1301. $receipt->status = 7;
  1302. // 修改审批流程加入角色
  1303. $receipt->verify = $verify;
  1304. $receipt->verifyStaff = '';
  1305. $receipt->executeStaff = '';
  1306. $receipt->executeCopy = $executeDetail ['staff'];
  1307. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  1308. $receipt->explanation = $explanation;
  1309. $receipt->update ( array (
  1310. 'where' => 'rid=' . $rid
  1311. ) );
  1312. // 附件
  1313. if (! empty ( $enclosurName )) {
  1314. $enclosurArray = explode ( '-', $enclosurName );
  1315. foreach ( $enclosurArray as $value ) {
  1316. $enclosur = new enclosur ();
  1317. $enclosur->name = $value;
  1318. $enclosur->rid = $rid;
  1319. $enclosur->insert ();
  1320. }
  1321. // print_r($enclosurArray);die;
  1322. }
  1323. // 报销详情
  1324. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1325. $receiptDetail = new receiptDetail ();
  1326. $receiptDetail->staff = $this->staff [0] ['sid'];
  1327. $receiptDetail->item = $value ['name'];
  1328. $receiptDetail->itemCategory = $this->AGENCY;
  1329. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1330. $receiptDetail->date = date ( "Y-m-d" );
  1331. $receiptDetail->cid = $cid;
  1332. $receiptDetail->rid = $rid;
  1333. $receiptDetail->status = 4;
  1334. $receiptDetail->insert ();
  1335. }
  1336. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1337. $receiptDetail = new receiptDetail ();
  1338. $receiptDetail->staff = $this->staff [0] ['sid'];
  1339. $receiptDetail->item = $value ['name'];
  1340. $receiptDetail->itemCategory = $this->TRAVEL;
  1341. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1342. $receiptDetail->date = date ( "Y-m-d" );
  1343. $receiptDetail->cid = $cid;
  1344. $receiptDetail->rid = $rid;
  1345. $receiptDetail->status = 4;
  1346. $receiptDetail->insert ();
  1347. }
  1348. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1349. $receiptDetail = new receiptDetail ();
  1350. $receiptDetail->staff = $this->staff [0] ['sid'];
  1351. $receiptDetail->item = $value ['name'];
  1352. $receiptDetail->itemCategory = $this->TRAIN;
  1353. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1354. $receiptDetail->date = date ( "Y-m-d" );
  1355. $receiptDetail->cid = $cid;
  1356. $receiptDetail->rid = $rid;
  1357. $receiptDetail->status = 4;
  1358. $receiptDetail->insert ();
  1359. }
  1360. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1361. $receiptDetail = new receiptDetail ();
  1362. $receiptDetail->staff = $this->staff [0] ['sid'];
  1363. $receiptDetail->item = $value ['name'];
  1364. $receiptDetail->itemCategory = $this->OTHER;
  1365. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1366. $receiptDetail->date = date ( "Y-m-d" );
  1367. $receiptDetail->cid = $cid;
  1368. $receiptDetail->rid = $rid;
  1369. $receiptDetail->status = 4;
  1370. $receiptDetail->insert ();
  1371. }
  1372. return "/saeaBorad";
  1373. }
  1374. return "/saeaLoanReceiptAdd/" . $rid;
  1375. }
  1376. function saeaLoanReceiptEdi() {
  1377. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1378. // echo $rid;
  1379. Doo::loadModel ( 'accountItem' );
  1380. Doo::loadModel ( 'verify' );
  1381. Doo::loadModel ( 'receipt' );
  1382. $receipt = new receipt ();
  1383. $verify = new verify ();
  1384. $accountItem = new accountItem ();
  1385. Doo::loadModel ( 'L_category' );
  1386. $Lcategory = new L_category ();
  1387. Doo::loadModel ( "role" );
  1388. $role = new role ();
  1389. Doo::loadModel ( 'loanReceipt' );
  1390. $loanReceipt = new loanReceipt ();
  1391. Doo::loadModel ( 'staff' );
  1392. $staff = new staff ();
  1393. $receiptDetail = $receipt->getOne ( array (
  1394. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  1395. 'asArray' => true
  1396. ) );
  1397. if (empty ( $receiptDetail ))
  1398. return "/saeaBorad";
  1399. $receiptList = $loanReceipt->find ( array (
  1400. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1401. 'desc' => 'rid',
  1402. 'asArray' => true
  1403. ) );
  1404. $Locate = 0;
  1405. $roleId = 0;
  1406. $button = 0;
  1407. foreach ( $receiptList as $key => $value ) {
  1408. $receiptList [$key] ['Locate'] = $Locate;
  1409. $Locate ++;
  1410. $receiptList [$key] ['reviseDetail'] = array ();
  1411. if (! empty ( $value ['reviseDetail'] ))
  1412. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1413. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1414. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1415. $categoryDetil = $Lcategory->getOne ( array (
  1416. 'where' => 'cid=' . $value ['cid'],
  1417. 'asArray' => true
  1418. ) );
  1419. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1420. // 检测编辑状态
  1421. $verifyList = $verify->getOne ( array (
  1422. 'where' => 'vid=' . $value ['verify'],
  1423. 'asArray' => true
  1424. ) );
  1425. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1426. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1427. Doo::loadModel ( 'role' );
  1428. $role = new role ();
  1429. $flag = true;
  1430. $roleKey = 0;
  1431. $endStaffArray = array ();
  1432. $roleArrayCopy = array ();
  1433. foreach ( $verifyList as $k => $v ) {
  1434. // init verifyStaff
  1435. if ($v [1] == 'ROLE') {
  1436. if (! empty ( $verifyStaff )) {
  1437. $endStaffArray = end ( $verifyStaff );
  1438. // if ($v[0]==$endStaffArray['nextStaff']){
  1439. // $roleId=$v[0];
  1440. // }
  1441. }
  1442. $roleVerify = json_decode ( $v [3], true );
  1443. $roleKey = $k;
  1444. $roleArray = array ();
  1445. $rolename = $role->getOne ( array (
  1446. 'where' => 'rid=' . $v [0],
  1447. 'asArray' => true
  1448. ) );
  1449. foreach ( $roleVerify as $o => $p ) {
  1450. $staffID = explode ( '_', $p );
  1451. $staffInfo = $staff->getOne ( array (
  1452. 'where' => 'sid=' . $staffID [0],
  1453. 'asArray' => true
  1454. ) );
  1455. // print_r($staffID);
  1456. $exp = array (
  1457. 0 => $staffInfo ['sid'],
  1458. 1 => $staffID [1],
  1459. 2 => $staffInfo ['avatar'],
  1460. 'date' => '',
  1461. 'date' => '',
  1462. 'opinion' => '',
  1463. 'status' => '',
  1464. 'rolename' => $rolename ['name']
  1465. );
  1466. array_push ( $roleArray, $exp );
  1467. }
  1468. $roleArrayCopy [$v [0]] = $roleArray;
  1469. // $verifyList[$k]['roleArray']=$roleArray;
  1470. }
  1471. $verifyList [$k] ['date'] = "";
  1472. $verifyList [$k] ['opinion'] = "";
  1473. $verifyList [$k] ['status'] = "";
  1474. if (empty ( $verifyStaff )) {
  1475. $verifyList [$k] ['date'] = "";
  1476. $verifyList [$k] ['opinion'] = "";
  1477. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1478. $verifyList [$k] ['status'] = 4;
  1479. $flag = false;
  1480. }
  1481. } else {
  1482. foreach ( $verifyStaff as $m => $u ) {
  1483. if ($v [0] == $m) {
  1484. $verifyList [$k] ['date'] = $u ['date'];
  1485. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1486. $verifyList [$k] ['status'] = $u ['status'];
  1487. $flag = false;
  1488. break;
  1489. }
  1490. }
  1491. $endStaffArray = end ( $verifyStaff );
  1492. if (isset ( $endStaffArray ['ROLE'] )) {
  1493. } else {
  1494. // $endKey=key($verifyStaff);
  1495. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1496. // $button=4;
  1497. // $verifyList[$k]['status']=4;
  1498. // }
  1499. }
  1500. }
  1501. }
  1502. $rolename ['name'] = '';
  1503. if (! empty ( $roleId )) {
  1504. Doo::loadModel ( 'role' );
  1505. $role = new role ();
  1506. $rolename = $role->getOne ( array (
  1507. 'where' => 'rid=' . $roleId,
  1508. 'asArray' => true
  1509. ) );
  1510. }
  1511. if (! empty ( $verifyStaff ))
  1512. $endStaffArray = end ( $verifyStaff );
  1513. $KOP = false;
  1514. foreach ( $roleArrayCopy as $P => $A ) {
  1515. foreach ( $A as $MKI => $AVL ) {
  1516. if (! empty ( $verifyStaff )) {
  1517. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1518. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1519. $button = 4;
  1520. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1521. }
  1522. foreach ( $verifyStaff as $m => $u ) {
  1523. $AVLFK = $AVL [0] . '_R';
  1524. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1525. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1526. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1527. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1528. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1529. break;
  1530. }
  1531. }
  1532. } else {
  1533. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1534. $button = 4;
  1535. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1536. }
  1537. }
  1538. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1539. $KOP = true;
  1540. }
  1541. }
  1542. foreach ( $roleArrayCopy as $k => $v ) {
  1543. foreach ( $verifyList as $m => $n ) {
  1544. if ($n [0] == $k) {
  1545. array_splice ( $verifyList, $m, 1, $v );
  1546. }
  1547. }
  1548. }
  1549. $receiptList [$key] ['verifyList'] = $verifyList;
  1550. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1551. 'where' => 'sid=' . $value ['staff'],
  1552. 'asArray' => true
  1553. ) );
  1554. $receiptList [$key] ['button'] = $button;
  1555. //
  1556. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1557. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1558. }
  1559. $data ['receiptList'] = $receiptList;
  1560. $acItem = $accountItem->find ( array (
  1561. 'asArray' => true
  1562. ) );
  1563. $veList = $verify->find ( array (
  1564. 'asArray' => true
  1565. ) );
  1566. foreach ( $veList as $key => $value ) {
  1567. $v = json_decode ( $value ['staff'] );
  1568. $list = array ();
  1569. foreach ( $v as $n => $m ) {
  1570. if ($m ['1'] == 'ROLE') {
  1571. $roleInfo = $role->getOne ( array (
  1572. 'where' => 'rid=' . $m [0],
  1573. 'asArray' => true
  1574. ) );
  1575. $v [$n] [1] = $roleInfo ['name'];
  1576. array_push ( $list, $roleInfo ['name'] );
  1577. } else {
  1578. array_push ( $list, $v [$n] [1] );
  1579. }
  1580. }
  1581. $veList [$key] ['staff'] = implode ( '>', $list );
  1582. }
  1583. // 配置编辑信息
  1584. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1585. foreach ( $acItem as $key => $value ) {
  1586. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1587. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1588. $acItem [$key] ['price'] = $v ['price'];
  1589. }
  1590. }
  1591. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1592. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1593. $acItem [$key] ['price'] = $v ['price'];
  1594. }
  1595. }
  1596. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1597. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1598. $acItem [$key] ['price'] = $v ['price'];
  1599. }
  1600. }
  1601. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1602. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1603. $acItem [$key] ['price'] = $v ['price'];
  1604. }
  1605. }
  1606. }
  1607. $data ['category'] = $Lcategory->find ( array (
  1608. 'asArray' => true
  1609. ) );
  1610. $data ['cSum'] = $accountItemList ['cSum'];
  1611. $data ['sum'] = $receiptDetail ['sum'];
  1612. $data ['receiptDetail'] = $receiptDetail;
  1613. $data ['veList'] = $veList;
  1614. $data ['acItem'] = $acItem;
  1615. $data ['memu'] = "receipt";
  1616. $data ['staff'] = $this->staff;
  1617. $data ['receiptMemu'] = 'saeaBorad';
  1618. $data ['verify'] = $receiptDetail ['verify'];
  1619. $data ['verifyId'] = $this->verifyId;
  1620. $data ['executeId'] = $this->executeId;
  1621. $data ['rid'] = $rid;
  1622. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  1623. }
  1624. function confirmation() {
  1625. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1626. Doo::loadModel ( 'receipt' );
  1627. Doo::loadModel ( 'receiptDetail' );
  1628. $receipt = new receipt ();
  1629. $receiptDetail = new receiptDetail ();
  1630. Doo::loadModel ( 'statistics' );
  1631. Doo::loadModel ( 'itemStatistics' );
  1632. $statistics = new statistics ();
  1633. $itemStatistics = new itemStatistics ();
  1634. Doo::loadModel ( "verify" );
  1635. $verify = new verify ();
  1636. $receiptDetailList = $receipt->getOne ( array (
  1637. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  1638. 'asArray' => true
  1639. ) );
  1640. if (empty ( $receiptDetailList ))
  1641. return "/saeaBorad";
  1642. $verifyDetail = $verify->getOne ( array (
  1643. 'where' => ' vid =' . $receiptDetailList ['verify'],
  1644. 'asArray' => true
  1645. ) );
  1646. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  1647. if (empty ( $receiptDetailList ['nowStaff'] )) {
  1648. $nowStaff = "";
  1649. $nowStaffList = array ();
  1650. if ($verifyDetail [0] [1] == 'ROLE') {
  1651. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  1652. foreach ( $vStaffString as $key => $value ) {
  1653. $staffK = explode ( "_", $value );
  1654. array_push ( $nowStaffList, $staffK [0] );
  1655. }
  1656. $nowStaff = implode ( ',', $nowStaffList );
  1657. } else {
  1658. $nowStaff = $verifyDetail [0] [0];
  1659. }
  1660. $receipt->nowStaff = $nowStaff;
  1661. }
  1662. // echo $nowStaff;
  1663. // print_r($verifyDetail);die;
  1664. $receipt->rid = $receiptDetailList ['rid'];
  1665. $receipt->status = 2;
  1666. $receipt->update ();
  1667. // 操作日志
  1668. Doo::loadModel ( "receiptLog" );
  1669. $receiptLog = new receiptLog ();
  1670. $verify = new verify ();
  1671. $receiptInfo = $receipt->getOne ( array (
  1672. 'where' => 'rid=' . $rid,
  1673. 'asArray' => true
  1674. ) );
  1675. $vr = $verify->getOne ( array (
  1676. 'where' => 'vid=' . $receiptInfo ['verify'],
  1677. 'asArray' => true
  1678. ) );
  1679. $jd = json_decode ( $vr ['staff'] );
  1680. $roleId = 0;
  1681. foreach ( $jd as $key => $value ) {
  1682. if ($value [1] == 'ROLE') {
  1683. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  1684. if ($pos !== false) {
  1685. $roleId = $value [0];
  1686. }
  1687. }
  1688. }
  1689. // 审批日志
  1690. // echo $roleId;die;
  1691. if (! empty ( $roleId )) {
  1692. Doo::loadModel ( "role" );
  1693. $role = new role ();
  1694. $roleInfo = $role->getOne ( array (
  1695. 'where' => 'rid=' . $roleId,
  1696. 'asArray' => true
  1697. ) );
  1698. $receiptLog->rolename = $roleInfo ['name'];
  1699. }
  1700. $receiptLog->username = $this->staff [0] ['username'];
  1701. $receiptLog->uid = $this->staff [0] ['sid'];
  1702. $receiptLog->date = date ( "Y-m-d" );
  1703. $receiptLog->opinion = '提交审批';
  1704. $receiptLog->img = $this->staff [0] ['avatar'];
  1705. $receiptLog->status = 2;
  1706. $receiptLog->rid = $rid;
  1707. $receiptLog->insert ();
  1708. return "/expenses";
  1709. }
  1710. function expenses() {
  1711. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  1712. if (empty ( $item ))
  1713. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  1714. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1715. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  1716. Doo::loadModel ( 'receipt' );
  1717. $receipt = new receipt ();
  1718. Doo::loadModel ( 'L_category' );
  1719. $Lcategory = new L_category ();
  1720. Doo::loadModel ( 'verify' );
  1721. Doo::loadModel ( 'statistics' );
  1722. $statistics = new statistics ();
  1723. $verify = new verify ();
  1724. Doo::loadModel ( 'staff' );
  1725. $staff = new staff ();
  1726. $condition = "";
  1727. if ($item == "expenses")
  1728. $condition = " and Rtype=1 ";
  1729. elseif ($item == "receipts")
  1730. $condition = " and Rtype=0 ";
  1731. elseif ($item == "remits")
  1732. $condition = " and Rtype=2 ";
  1733. $dateCondition = " and Year(date) =" . $year;
  1734. if (! empty ( $moth )) {
  1735. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  1736. $stList = $statistics->getOne ( array (
  1737. 'select' => 'rePrice ,agPrice',
  1738. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  1739. 'asArray' => true
  1740. ) );
  1741. } else
  1742. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  1743. if (empty ( $stList ))
  1744. $stList = array (
  1745. 'rePrice' => 0,
  1746. 'agPrice' => 0
  1747. );
  1748. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  1749. if (! isset ( $noPassSum ['sum'] ))
  1750. $noPassSum ['sum'] = 0;
  1751. $data ['stList'] = array (
  1752. 'rePrice' => $stList ['rePrice'],
  1753. 'agPrice' => $stList ['agPrice'],
  1754. 'skPrice' => ($noPassSum ['sum'])
  1755. );
  1756. $receiptList = $receipt->find ( array (
  1757. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  1758. 'desc' => 'rid',
  1759. 'asArray' => true
  1760. ) );
  1761. $Locate = 0;
  1762. $roleId = 0;
  1763. $button = 0;
  1764. foreach ( $receiptList as $key => $value ) {
  1765. $receiptList [$key] ['Locate'] = $Locate;
  1766. $Locate ++;
  1767. $receiptList [$key] ['reviseDetail'] = array ();
  1768. if (! empty ( $value ['reviseDetail'] ))
  1769. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1770. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1771. $categoryDetil = $Lcategory->getOne ( array (
  1772. 'where' => 'cid=' . $value ['cid'],
  1773. 'asArray' => true
  1774. ) );
  1775. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1776. // 检测编辑状态
  1777. $verifyList = $verify->getOne ( array (
  1778. 'where' => 'vid=' . $value ['verify'],
  1779. 'asArray' => true
  1780. ) );
  1781. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1782. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1783. Doo::loadModel ( 'role' );
  1784. $role = new role ();
  1785. $flag = true;
  1786. $roleKey = 0;
  1787. $endStaffArray = array ();
  1788. $roleArrayCopy = array ();
  1789. foreach ( $verifyList as $k => $v ) {
  1790. // init verifyStaff
  1791. if ($v [1] == 'ROLE') {
  1792. if (! empty ( $verifyStaff )) {
  1793. $endStaffArray = end ( $verifyStaff );
  1794. // if ($v[0]==$endStaffArray['nextStaff']){
  1795. // $roleId=$v[0];
  1796. // }
  1797. }
  1798. $roleVerify = json_decode ( $v [3], true );
  1799. $roleKey = $k;
  1800. $roleArray = array ();
  1801. $rolename = $role->getOne ( array (
  1802. 'where' => 'rid=' . $v [0],
  1803. 'asArray' => true
  1804. ) );
  1805. foreach ( $roleVerify as $o => $p ) {
  1806. $staffID = explode ( '_', $p );
  1807. $staffInfo = $staff->getOne ( array (
  1808. 'where' => 'sid=' . $staffID [0],
  1809. 'asArray' => true
  1810. ) );
  1811. // print_r($staffID);
  1812. $exp = array (
  1813. 0 => $staffInfo ['sid'],
  1814. 1 => $staffID [1],
  1815. 2 => $staffInfo ['avatar'],
  1816. 'date' => '',
  1817. 'date' => '',
  1818. 'opinion' => '',
  1819. 'status' => '',
  1820. 'rolename' => $rolename ['name']
  1821. );
  1822. array_push ( $roleArray, $exp );
  1823. }
  1824. $roleArrayCopy [$v [0]] = $roleArray;
  1825. // $verifyList[$k]['roleArray']=$roleArray;
  1826. }
  1827. $verifyList [$k] ['date'] = "";
  1828. $verifyList [$k] ['opinion'] = "";
  1829. $verifyList [$k] ['status'] = "";
  1830. if (empty ( $verifyStaff )) {
  1831. $verifyList [$k] ['date'] = "";
  1832. $verifyList [$k] ['opinion'] = "";
  1833. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1834. $verifyList [$k] ['status'] = 4;
  1835. $flag = false;
  1836. }
  1837. } else {
  1838. foreach ( $verifyStaff as $m => $u ) {
  1839. if ($v [0] == $m) {
  1840. $verifyList [$k] ['date'] = $u ['date'];
  1841. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1842. $verifyList [$k] ['status'] = $u ['status'];
  1843. $flag = false;
  1844. break;
  1845. }
  1846. }
  1847. $endStaffArray = end ( $verifyStaff );
  1848. if (isset ( $endStaffArray ['ROLE'] )) {
  1849. } else {
  1850. // $endKey=key($verifyStaff);
  1851. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1852. // $button=4;
  1853. // $verifyList[$k]['status']=4;
  1854. // }
  1855. }
  1856. }
  1857. }
  1858. $rolename ['name'] = '';
  1859. if (! empty ( $roleId )) {
  1860. Doo::loadModel ( 'role' );
  1861. $role = new role ();
  1862. $rolename = $role->getOne ( array (
  1863. 'where' => 'rid=' . $roleId,
  1864. 'asArray' => true
  1865. ) );
  1866. }
  1867. if (! empty ( $verifyStaff ))
  1868. $endStaffArray = end ( $verifyStaff );
  1869. $KOP = false;
  1870. foreach ( $roleArrayCopy as $P => $A ) {
  1871. foreach ( $A as $MKI => $AVL ) {
  1872. if (! empty ( $verifyStaff )) {
  1873. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1874. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1875. $button = 4;
  1876. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1877. }
  1878. foreach ( $verifyStaff as $m => $u ) {
  1879. $AVLFK = $AVL [0] . '_R';
  1880. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1881. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1882. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1883. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1884. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1885. break;
  1886. }
  1887. }
  1888. } else {
  1889. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1890. $button = 4;
  1891. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1892. }
  1893. }
  1894. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1895. $KOP = true;
  1896. }
  1897. }
  1898. foreach ( $roleArrayCopy as $k => $v ) {
  1899. foreach ( $verifyList as $m => $n ) {
  1900. if ($n [0] == $k) {
  1901. array_splice ( $verifyList, $m, 1, $v );
  1902. }
  1903. }
  1904. }
  1905. $receiptList [$key] ['verifyList'] = $verifyList;
  1906. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1907. 'where' => 'sid=' . $value ['staff'],
  1908. 'asArray' => true
  1909. ) );
  1910. $receiptList [$key] ['button'] = $button;
  1911. }
  1912. // print_r($receiptList);die;
  1913. $mothHtml = "";
  1914. for($i = 1; $i <= 12; $i ++) {
  1915. if ($moth == $i)
  1916. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  1917. else
  1918. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  1919. }
  1920. $data ['mothHtml'] = $mothHtml;
  1921. $data ['receiptList'] = $receiptList;
  1922. $data ['memu'] = "receipt";
  1923. $data ['staff'] = $this->staff;
  1924. $data ['receiptMemu'] = 'expenses';
  1925. $data ['verifyId'] = $this->verifyId;
  1926. $data ['executeId'] = $this->executeId;
  1927. $data ['item'] = $item;
  1928. $data ['year'] = $year;
  1929. $this->render ( "/admin/expenses", $data );
  1930. }
  1931. function expensesCollect() {
  1932. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1933. Doo::loadModel ( 'receipt' );
  1934. $receipt = new receipt ();
  1935. Doo::loadModel ( 'L_category' );
  1936. $Lcategory = new L_category ();
  1937. Doo::loadModel ( 'verify' );
  1938. Doo::loadModel ( 'statistics' );
  1939. $statistics = new statistics ();
  1940. $verify = new verify ();
  1941. Doo::loadModel ( 'staff' );
  1942. $staff = new staff ();
  1943. Doo::loadModel ( 'loanReceipt' );
  1944. $loanReceipt = new loanReceipt ();
  1945. $receiptList = $receipt->find ( array (
  1946. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  1947. 'desc' => 'rid',
  1948. 'asArray' => true
  1949. ) );
  1950. $loanList = $loanReceipt->find ( array (
  1951. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  1952. 'desc' => 'rid',
  1953. 'asArray' => true
  1954. ) );
  1955. /*
  1956. * $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;
  1957. */
  1958. $Locate = 0;
  1959. $roleId = 0;
  1960. $button = 0;
  1961. foreach ( $receiptList as $key => $value ) {
  1962. $receiptList [$key] ['Locate'] = $Locate;
  1963. $Locate ++;
  1964. $receiptList [$key] ['reviseDetail'] = array ();
  1965. if (! empty ( $value ['reviseDetail'] ))
  1966. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1967. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1968. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1969. $categoryDetil = $Lcategory->getOne ( array (
  1970. 'where' => 'cid=' . $value ['cid'],
  1971. 'asArray' => true
  1972. ) );
  1973. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1974. // 检测编辑状态
  1975. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  1976. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  1977. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  1978. else
  1979. $verifyList ['staff'] = $value ['verifyBreakup'];
  1980. } else
  1981. $verifyList = $verify->getOne ( array (
  1982. 'where' => 'vid=' . $value ['verify'],
  1983. 'asArray' => true
  1984. ) );
  1985. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1986. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1987. Doo::loadModel ( 'role' );
  1988. $role = new role ();
  1989. $flag = true;
  1990. $roleKey = 0;
  1991. $endStaffArray = array ();
  1992. $roleArrayCopy = array ();
  1993. foreach ( $verifyList as $k => $v ) {
  1994. // init verifyStaff
  1995. if ($v [1] == 'ROLE') {
  1996. if (! empty ( $verifyStaff )) {
  1997. $endStaffArray = end ( $verifyStaff );
  1998. // if ($v[0]==$endStaffArray['nextStaff']){
  1999. // $roleId=$v[0];
  2000. // }
  2001. }
  2002. $roleVerify = json_decode ( $v [3], true );
  2003. $roleKey = $k;
  2004. $roleArray = array ();
  2005. $rolename = $role->getOne ( array (
  2006. 'where' => 'rid=' . $v [0],
  2007. 'asArray' => true
  2008. ) );
  2009. foreach ( $roleVerify as $o => $p ) {
  2010. $staffID = explode ( '_', $p );
  2011. $staffInfo = $staff->getOne ( array (
  2012. 'where' => 'sid=' . $staffID [0],
  2013. 'asArray' => true
  2014. ) );
  2015. // print_r($staffID);
  2016. $exp = array (
  2017. 0 => $staffInfo ['sid'],
  2018. 1 => $staffID [1],
  2019. 2 => $staffInfo ['avatar'],
  2020. 'date' => '',
  2021. 'date' => '',
  2022. 'opinion' => '',
  2023. 'status' => '',
  2024. 'rolename' => $rolename ['name']
  2025. );
  2026. array_push ( $roleArray, $exp );
  2027. }
  2028. $roleArrayCopy [$v [0]] = $roleArray;
  2029. // $verifyList[$k]['roleArray']=$roleArray;
  2030. }
  2031. $verifyList [$k] ['date'] = "";
  2032. $verifyList [$k] ['opinion'] = "";
  2033. $verifyList [$k] ['status'] = "";
  2034. if (empty ( $verifyStaff )) {
  2035. $verifyList [$k] ['date'] = "";
  2036. $verifyList [$k] ['opinion'] = "";
  2037. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2038. $verifyList [$k] ['status'] = 4;
  2039. $flag = false;
  2040. }
  2041. } else {
  2042. foreach ( $verifyStaff as $m => $u ) {
  2043. if ($v [0] == $m) {
  2044. $verifyList [$k] ['date'] = $u ['date'];
  2045. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2046. $verifyList [$k] ['status'] = $u ['status'];
  2047. $flag = false;
  2048. break;
  2049. }
  2050. }
  2051. $endStaffArray = end ( $verifyStaff );
  2052. if (isset ( $endStaffArray ['ROLE'] )) {
  2053. } else {
  2054. // $endKey=key($verifyStaff);
  2055. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2056. // $button=4;
  2057. // $verifyList[$k]['status']=4;
  2058. // }
  2059. }
  2060. }
  2061. }
  2062. $rolename ['name'] = '';
  2063. if (! empty ( $roleId )) {
  2064. Doo::loadModel ( 'role' );
  2065. $role = new role ();
  2066. $rolename = $role->getOne ( array (
  2067. 'where' => 'rid=' . $roleId,
  2068. 'asArray' => true
  2069. ) );
  2070. }
  2071. if (! empty ( $verifyStaff ))
  2072. $endStaffArray = end ( $verifyStaff );
  2073. $KOP = false;
  2074. foreach ( $roleArrayCopy as $P => $A ) {
  2075. foreach ( $A as $MKI => $AVL ) {
  2076. if (! empty ( $verifyStaff )) {
  2077. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2078. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2079. $button = 4;
  2080. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2081. }
  2082. foreach ( $verifyStaff as $m => $u ) {
  2083. $AVLFK = $AVL [0] . '_R';
  2084. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2085. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2086. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2087. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2088. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2089. break;
  2090. }
  2091. }
  2092. } else {
  2093. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2094. $button = 4;
  2095. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2096. }
  2097. }
  2098. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2099. $KOP = true;
  2100. }
  2101. }
  2102. foreach ( $roleArrayCopy as $k => $v ) {
  2103. foreach ( $verifyList as $m => $n ) {
  2104. if ($n [0] == $k) {
  2105. array_splice ( $verifyList, $m, 1, $v );
  2106. }
  2107. }
  2108. }
  2109. // 费用执行人相关数据
  2110. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2111. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2112. foreach ( $executeCopy as $k => $v ) {
  2113. $executeCopy [$k] ['date'] = '';
  2114. $executeCopy [$k] ['opinion'] = '';
  2115. $executeCopy [$k] ['status'] = '';
  2116. if (! empty ( $executeStaff ))
  2117. foreach ( $executeStaff as $m => $u ) {
  2118. if ($v [0] == $m) {
  2119. $executeCopy [$k] ['date'] = $u ['date'];
  2120. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2121. $executeCopy [$k] ['status'] = $u ['status'];
  2122. break;
  2123. }
  2124. }
  2125. }
  2126. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2127. $receiptList [$key] ['verifyList'] = $verifyList;
  2128. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2129. 'where' => 'sid=' . $value ['staff'],
  2130. 'asArray' => true
  2131. ) );
  2132. $receiptList [$key] ['button'] = $button;
  2133. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2134. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2135. $relust = $value ['sum'] - $value ['loanSum'];
  2136. $receiptList [$key] ['relust'] = $relust;
  2137. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2138. }
  2139. Doo::loadModel ( 'enclosur' );
  2140. $enclosur = new enclosur ();
  2141. $enclosurList = $enclosur->find ( array (
  2142. 'where' => 'rid=' . $rid,
  2143. 'asArray' => true
  2144. ) );
  2145. $enclosurHtml = '';
  2146. foreach ( $enclosurList as $value ) {
  2147. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2148. }
  2149. $data ['enclosurHtml'] = $enclosurHtml;
  2150. // print_r($receiptList);
  2151. $data ['receiptList'] = $receiptList;
  2152. $data ['memu'] = "receipt";
  2153. $data ['staff'] = $this->staff;
  2154. $data ['receiptMemu'] = 'expenses';
  2155. $data ['verifyId'] = $this->verifyId;
  2156. $data ['executeId'] = $this->executeId;
  2157. $this->render ( "/admin/expensesCollect", $data );
  2158. }
  2159. function approvalExpenses() {
  2160. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  2161. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : '';
  2162. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2163. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2164. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2165. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  2166. // echo $rdate;
  2167. if (empty ( $status ))
  2168. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  2169. $page_size = 12;
  2170. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2171. $vidList = array ();
  2172. $button = 0;
  2173. Doo::loadModel ( 'verify' );
  2174. $verify = new verify ();
  2175. Doo::loadModel ( 'receipt' );
  2176. $receipt = new receipt ();
  2177. Doo::loadModel ( 'staff' );
  2178. $staff = new staff ();
  2179. Doo::loadModel ( 'L_category' );
  2180. $Lcategory = new L_category ();
  2181. // user verify ID
  2182. $verifyDetail = $verify->find ( array (
  2183. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  2184. 'asArray' => true
  2185. ) );
  2186. foreach ( $verifyDetail as $key => $value ) {
  2187. array_push ( $vidList, $value ['vid'] );
  2188. }
  2189. $vid = implode ( ",", $vidList );
  2190. if (empty ( $verifyDetail ))
  2191. $vid = 0;
  2192. // if ($status==0)
  2193. // $dateCondition="";
  2194. // else
  2195. $dateCondition = " ";
  2196. // if (! empty ( $month ))
  2197. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  2198. if ($status == 'done'|| $status == 'termination') {
  2199. if (!empty($year)){
  2200. $dateCondition = " and Year(pastDate) =" . $year;
  2201. if (! empty ( $month ))
  2202. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  2203. }
  2204. }
  2205. // date ( 'Y-m' )
  2206. if (! empty ( $rdate ) && $status == 'done')
  2207. $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  2208. elseif (! empty ( $rdate ))
  2209. $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  2210. $categoryList = $Lcategory->find ( array (
  2211. 'asArray' => true
  2212. ) );
  2213. $staffList = $staff->find ( array (
  2214. 'where' => 'cid=' . $cid,
  2215. 'asArray' => true
  2216. ) );
  2217. $cateCondition = "";
  2218. $staffCondition = "";
  2219. $approvalCondition = "";
  2220. if (! empty ( $cid )) {
  2221. $cateCondition = ' and cid=' . $cid;
  2222. }
  2223. if (! empty ( $sid )) {
  2224. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  2225. $cateCondition = "";
  2226. }
  2227. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  2228. if ($status == 'pendApproval') {
  2229. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  2230. }
  2231. if ($status == 'ongoing') {
  2232. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  2233. }
  2234. if ($status == 'done') {
  2235. $approvalCondition = ' and (status=8 or status=9 ) ';
  2236. }
  2237. if ($status == 'termination') {
  2238. $approvalCondition = " and status=3";
  2239. }
  2240. // $approvalCondition = " and status=" . $status;
  2241. // if ($status == 2) {
  2242. // // 查找角色审批人
  2243. // }
  2244. // if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  2245. // $approvalCondition = ' and status=2 ';
  2246. // }
  2247. // if ($status == 1) {
  2248. // $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  2249. // }
  2250. // if ($status == 8) {
  2251. // $approvalCondition = ' and (status=' . $status . ' or status=9 ) ';
  2252. // }
  2253. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  2254. $pageinfo ['page'] = array (
  2255. 'previous' => ''
  2256. );
  2257. // if ($status == 0) {
  2258. // $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  2259. // $receiptList = $receipt->find ( array (
  2260. // 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ')',
  2261. // 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2262. // 'desc' => 'rid',
  2263. // 'asArray' => true
  2264. // ) );
  2265. // //echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2266. // } else
  2267. if ($status == 'done' || $status == 'termination') { // $dateCondition .
  2268. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  2269. $receiptList = $receipt->find ( array ( // $dateCondition.
  2270. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  2271. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2272. 'desc' => 'rid',
  2273. 'asArray' => true
  2274. ) );
  2275. } else {
  2276. $receiptList = $receipt->find ( array ( // $dateCondition
  2277. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
  2278. 'desc' => 'rid',
  2279. 'asArray' => true
  2280. ) );
  2281. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  2282. }
  2283. $rLRes = $receipt->find ( array (
  2284. 'where' => 'status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )' . $cateCondition . $staffCondition . ' and verify in (' . $vid . ')',
  2285. 'desc' => 'rid',
  2286. 'asArray' => true
  2287. ) );
  2288. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  2289. // print_r($receiptList);
  2290. $Locate = 0;
  2291. $reportList = $reportCateList = array ();
  2292. foreach ( $receiptList as $key => $value ) {
  2293. $receiptList [$key] ['Locate'] = $Locate;
  2294. $Locate ++;
  2295. $receiptList [$key] ['reviseDetail'] = array ();
  2296. if (! empty ( $value ['reviseDetail'] ))
  2297. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2298. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2299. $categoryDetil = $Lcategory->getOne ( array (
  2300. 'where' => 'cid=' . $value ['cid'],
  2301. 'asArray' => true
  2302. ) );
  2303. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2304. $verifyList = $verify->getOne ( array (
  2305. 'where' => 'vid=' . $value ['verify'],
  2306. 'asArray' => true
  2307. ) );
  2308. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2309. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2310. foreach ( $verifyList as $k => $v ) {
  2311. // init verifyStaff
  2312. $verifyList [$k] ['date'] = "";
  2313. $verifyList [$k] ['opinion'] = "";
  2314. $verifyList [$k] ['status'] = "";
  2315. if (empty ( $verifyStaff )) {
  2316. $verifyList [$k] ['date'] = "";
  2317. $verifyList [$k] ['opinion'] = "";
  2318. if ($v [0] == $this->staff [0] ['sid']) {
  2319. $verifyList [$k] ['status'] = 4;
  2320. $button = 4;
  2321. }
  2322. } else {
  2323. $flag = true;
  2324. foreach ( $verifyStaff as $m => $u ) {
  2325. if ($v [0] == $m) {
  2326. $verifyList [$k] ['date'] = $u ['date'];
  2327. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2328. $verifyList [$k] ['status'] = $u ['status'];
  2329. $flag = false;
  2330. break;
  2331. }
  2332. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  2333. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  2334. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  2335. }
  2336. if ($flag) { // 检测可编辑
  2337. if ($v [0] == $this->staff [0] ['sid']) {
  2338. $verifyList [$k] ['status'] = 4;
  2339. $button = 4;
  2340. }
  2341. }
  2342. }
  2343. }
  2344. $receiptList [$key] ['verifyList'] = $verifyList;
  2345. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2346. 'where' => 'sid=' . $value ['staff'],
  2347. 'asArray' => true
  2348. ) );
  2349. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  2350. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  2351. $receiptList [$key] ['button'] = $button;
  2352. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  2353. }
  2354. $reportList = array_unique ( $reportList );
  2355. $reportHtml = '';
  2356. foreach ( $reportList as $key => $value ) {
  2357. $v = explode ( "-", $value );
  2358. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  2359. }
  2360. // print_r($reportList)
  2361. $data ['reportHtml'] = $reportHtml;
  2362. $reportCateList = array_unique ( $reportCateList );
  2363. $reportCateHtml = '';
  2364. foreach ( $reportCateList as $key => $value ) {
  2365. $v = explode ( "-", $value );
  2366. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  2367. }
  2368. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  2369. $data ['reportCateHtml'] = $reportCateHtml;
  2370. // print_r($receiptList);die;
  2371. // $data['verifyDetail']=$verifyDetail;
  2372. $mothHtml = "";
  2373. for($i = 1; $i <= 12; $i ++) {
  2374. if ($month == $i)
  2375. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2376. else
  2377. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2378. }
  2379. $data ['mothHtml'] = $mothHtml;
  2380. $data ['page'] = $pageinfo;
  2381. $data ['receiptList'] = $receiptList;
  2382. $data ['receiptApprovalCount'] = count ( $rLRes );
  2383. $data ['status'] = $status;
  2384. $data ['year'] = $year;
  2385. $data ['categoryList'] = $categoryList;
  2386. $data ['staffList'] = $staffList;
  2387. $data ['cid'] = $cid;
  2388. $data ['sid'] = $sid;
  2389. // print_r($receiptList);
  2390. $data ['memu'] = "receipt";
  2391. $data ['staff'] = $this->staff;
  2392. $data ['receiptMemu'] = 'approvalExpenses';
  2393. $data ['verifyId'] = $this->verifyId;
  2394. $data ['executeId'] = $this->executeId;
  2395. $this->render ( "/admin/approvalExpenses", $data );
  2396. }
  2397. function expensesDoc() {
  2398. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2399. Doo::loadModel ( 'receipt' );
  2400. $receipt = new receipt ();
  2401. Doo::loadModel ( 'L_category' );
  2402. $Lcategory = new L_category ();
  2403. Doo::loadModel ( 'verify' );
  2404. Doo::loadModel ( 'statistics' );
  2405. $statistics = new statistics ();
  2406. $verify = new verify ();
  2407. Doo::loadModel ( 'staff' );
  2408. $staff = new staff ();
  2409. Doo::loadModel ( 'loanReceipt' );
  2410. $loanReceipt = new loanReceipt ();
  2411. $receiptList = $receipt->find ( array (
  2412. 'where' => ' rid=' . $rid,
  2413. 'desc' => 'rid',
  2414. 'asArray' => true
  2415. ) );
  2416. $loanList = array ();
  2417. if (! empty ( $receiptList ))
  2418. $loanList = $loanReceipt->find ( array (
  2419. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2420. 'desc' => 'rid',
  2421. 'asArray' => true
  2422. ) );
  2423. $Locate = 0;
  2424. $roleId = 0;
  2425. $button = 0;
  2426. foreach ( $loanList as $key => $value ) {
  2427. $loanList [$key] ['Locate'] = $Locate;
  2428. $Locate ++;
  2429. $loanList [$key] ['reviseDetail'] = array ();
  2430. if (! empty ( $value ['reviseDetail'] ))
  2431. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2432. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2433. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2434. $categoryDetil = $Lcategory->getOne ( array (
  2435. 'where' => 'cid=' . $value ['cid'],
  2436. 'asArray' => true
  2437. ) );
  2438. $loanList [$key] ['category'] = $categoryDetil ['title'];
  2439. // 检测编辑状态
  2440. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  2441. $verifyList ['staff'] = $value ['verifyBreakup'];
  2442. else
  2443. $verifyList = $verify->getOne ( array (
  2444. 'where' => 'vid=' . $value ['verify'],
  2445. 'asArray' => true
  2446. ) );
  2447. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2448. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2449. Doo::loadModel ( 'role' );
  2450. $role = new role ();
  2451. $flag = true;
  2452. $roleKey = 0;
  2453. $endStaffArray = array ();
  2454. $roleArrayCopy = array ();
  2455. foreach ( $verifyList as $k => $v ) {
  2456. // init verifyStaff
  2457. if ($v [1] == 'ROLE') {
  2458. if (! empty ( $verifyStaff )) {
  2459. $endStaffArray = end ( $verifyStaff );
  2460. // if ($v[0]==$endStaffArray['nextStaff']){
  2461. // $roleId=$v[0];
  2462. // }
  2463. }
  2464. $roleVerify = json_decode ( $v [3], true );
  2465. $roleKey = $k;
  2466. $roleArray = array ();
  2467. $rolename = $role->getOne ( array (
  2468. 'where' => 'rid=' . $v [0],
  2469. 'asArray' => true
  2470. ) );
  2471. foreach ( $roleVerify as $o => $p ) {
  2472. $staffID = explode ( '_', $p );
  2473. $staffInfo = $staff->getOne ( array (
  2474. 'where' => 'sid=' . $staffID [0],
  2475. 'asArray' => true
  2476. ) );
  2477. // print_r($staffID);
  2478. $exp = array (
  2479. 0 => $staffInfo ['sid'],
  2480. 1 => $staffID [1],
  2481. 2 => $staffInfo ['avatar'],
  2482. 'date' => '',
  2483. 'date' => '',
  2484. 'opinion' => '',
  2485. 'status' => '',
  2486. 'rolename' => $rolename ['name']
  2487. );
  2488. array_push ( $roleArray, $exp );
  2489. }
  2490. $roleArrayCopy [$v [0]] = $roleArray;
  2491. // $verifyList[$k]['roleArray']=$roleArray;
  2492. }
  2493. $verifyList [$k] ['date'] = "";
  2494. $verifyList [$k] ['opinion'] = "";
  2495. $verifyList [$k] ['status'] = "";
  2496. if (empty ( $verifyStaff )) {
  2497. $verifyList [$k] ['date'] = "";
  2498. $verifyList [$k] ['opinion'] = "";
  2499. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2500. $verifyList [$k] ['status'] = 4;
  2501. $flag = false;
  2502. }
  2503. } else {
  2504. foreach ( $verifyStaff as $m => $u ) {
  2505. if ($v [0] == $m) {
  2506. $verifyList [$k] ['date'] = $u ['date'];
  2507. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2508. $verifyList [$k] ['status'] = $u ['status'];
  2509. $flag = false;
  2510. break;
  2511. }
  2512. }
  2513. $endStaffArray = end ( $verifyStaff );
  2514. if (isset ( $endStaffArray ['ROLE'] )) {
  2515. } else {
  2516. // $endKey=key($verifyStaff);
  2517. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2518. // $button=4;
  2519. // $verifyList[$k]['status']=4;
  2520. // }
  2521. }
  2522. }
  2523. }
  2524. $rolename ['name'] = '';
  2525. if (! empty ( $roleId )) {
  2526. Doo::loadModel ( 'role' );
  2527. $role = new role ();
  2528. $rolename = $role->getOne ( array (
  2529. 'where' => 'rid=' . $roleId,
  2530. 'asArray' => true
  2531. ) );
  2532. }
  2533. if (! empty ( $verifyStaff ))
  2534. $endStaffArray = end ( $verifyStaff );
  2535. $KOP = false;
  2536. foreach ( $roleArrayCopy as $P => $A ) {
  2537. foreach ( $A as $MKI => $AVL ) {
  2538. if (! empty ( $verifyStaff )) {
  2539. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2540. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2541. $button = 4;
  2542. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2543. }
  2544. foreach ( $verifyStaff as $m => $u ) {
  2545. $AVLFK = $AVL [0] . '_R';
  2546. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2547. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2548. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2549. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2550. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2551. break;
  2552. }
  2553. }
  2554. } else {
  2555. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2556. $button = 4;
  2557. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2558. }
  2559. }
  2560. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2561. $KOP = true;
  2562. }
  2563. }
  2564. foreach ( $roleArrayCopy as $k => $v ) {
  2565. foreach ( $verifyList as $m => $n ) {
  2566. if ($n [0] == $k) {
  2567. array_splice ( $verifyList, $m, 1, $v );
  2568. }
  2569. }
  2570. }
  2571. $loanList [$key] ['verifyList'] = $verifyList;
  2572. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  2573. 'where' => 'sid=' . $value ['staff'],
  2574. 'asArray' => true
  2575. ) );
  2576. $loanList [$key] ['button'] = $button;
  2577. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  2578. }
  2579. $data ['loanList'] = $loanList;
  2580. // print_r($loanList);
  2581. $Locate = 0;
  2582. $roleId = 0;
  2583. $button = 0;
  2584. foreach ( $receiptList as $key => $value ) {
  2585. $receiptList [$key] ['Locate'] = $Locate;
  2586. $Locate ++;
  2587. $receiptList [$key] ['reviseDetail'] = array ();
  2588. if (! empty ( $value ['reviseDetail'] ))
  2589. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2590. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2591. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2592. $categoryDetil = $Lcategory->getOne ( array (
  2593. 'where' => 'cid=' . $value ['cid'],
  2594. 'asArray' => true
  2595. ) );
  2596. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2597. // 检测编辑状态
  2598. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  2599. $verifyList ['staff'] = $value ['verifyBreakup'];
  2600. } else
  2601. $verifyList = $verify->getOne ( array (
  2602. 'where' => 'vid=' . $value ['verify'],
  2603. 'asArray' => true
  2604. ) );
  2605. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2606. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2607. Doo::loadModel ( 'role' );
  2608. $role = new role ();
  2609. if ($verifyList == NULL)
  2610. $verifyList = array ();
  2611. $flag = true;
  2612. $roleKey = 0;
  2613. $endStaffArray = array ();
  2614. $roleArrayCopy = array ();
  2615. foreach ( $verifyList as $k => $v ) {
  2616. // init verifyStaff
  2617. if ($v [1] == 'ROLE') {
  2618. if (! empty ( $verifyStaff )) {
  2619. $endStaffArray = end ( $verifyStaff );
  2620. // if ($v[0]==$endStaffArray['nextStaff']){
  2621. // $roleId=$v[0];
  2622. // }
  2623. }
  2624. $roleVerify = json_decode ( $v [3], true );
  2625. $roleKey = $k;
  2626. $roleArray = array ();
  2627. $rolename = $role->getOne ( array (
  2628. 'where' => 'rid=' . $v [0],
  2629. 'asArray' => true
  2630. ) );
  2631. foreach ( $roleVerify as $o => $p ) {
  2632. $staffID = explode ( '_', $p );
  2633. $staffInfo = $staff->getOne ( array (
  2634. 'where' => 'sid=' . $staffID [0],
  2635. 'asArray' => true
  2636. ) );
  2637. // print_r($staffID);
  2638. $exp = array (
  2639. 0 => $staffInfo ['sid'],
  2640. 1 => $staffID [1],
  2641. 2 => $staffInfo ['avatar'],
  2642. 'date' => '',
  2643. 'date' => '',
  2644. 'opinion' => '',
  2645. 'status' => '',
  2646. 'rolename' => $rolename ['name']
  2647. );
  2648. array_push ( $roleArray, $exp );
  2649. }
  2650. $roleArrayCopy [$v [0]] = $roleArray;
  2651. // $verifyList[$k]['roleArray']=$roleArray;
  2652. }
  2653. $verifyList [$k] ['date'] = "";
  2654. $verifyList [$k] ['opinion'] = "";
  2655. $verifyList [$k] ['status'] = "";
  2656. if (empty ( $verifyStaff )) {
  2657. $verifyList [$k] ['date'] = "";
  2658. $verifyList [$k] ['opinion'] = "";
  2659. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2660. $verifyList [$k] ['status'] = 4;
  2661. $flag = false;
  2662. }
  2663. } else {
  2664. foreach ( $verifyStaff as $m => $u ) {
  2665. if ($v [0] == $m) {
  2666. $verifyList [$k] ['date'] = $u ['date'];
  2667. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2668. $verifyList [$k] ['status'] = $u ['status'];
  2669. $flag = false;
  2670. break;
  2671. }
  2672. }
  2673. $endStaffArray = end ( $verifyStaff );
  2674. if (isset ( $endStaffArray ['ROLE'] )) {
  2675. } else {
  2676. // $endKey=key($verifyStaff);
  2677. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2678. // $button=4;
  2679. // $verifyList[$k]['status']=4;
  2680. // }
  2681. }
  2682. }
  2683. }
  2684. $rolename ['name'] = '';
  2685. if (! empty ( $roleId )) {
  2686. Doo::loadModel ( 'role' );
  2687. $role = new role ();
  2688. $rolename = $role->getOne ( array (
  2689. 'where' => 'rid=' . $roleId,
  2690. 'asArray' => true
  2691. ) );
  2692. }
  2693. if (! empty ( $verifyStaff ))
  2694. $endStaffArray = end ( $verifyStaff );
  2695. $KOP = false;
  2696. foreach ( $roleArrayCopy as $P => $A ) {
  2697. foreach ( $A as $MKI => $AVL ) {
  2698. if (! empty ( $verifyStaff )) {
  2699. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2700. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2701. $button = 4;
  2702. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2703. }
  2704. foreach ( $verifyStaff as $m => $u ) {
  2705. $AVLFK = $AVL [0] . '_R';
  2706. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2707. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2708. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2709. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2710. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2711. break;
  2712. }
  2713. }
  2714. } else {
  2715. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2716. $button = 4;
  2717. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2718. }
  2719. }
  2720. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2721. $KOP = true;
  2722. }
  2723. }
  2724. foreach ( $roleArrayCopy as $k => $v ) {
  2725. foreach ( $verifyList as $m => $n ) {
  2726. if ($n [0] == $k) {
  2727. array_splice ( $verifyList, $m, 1, $v );
  2728. }
  2729. }
  2730. }
  2731. // 费用执行人相关数据
  2732. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2733. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2734. foreach ( $executeCopy as $k => $v ) {
  2735. $executeCopy [$k] ['date'] = '';
  2736. $executeCopy [$k] ['opinion'] = '';
  2737. $executeCopy [$k] ['status'] = '';
  2738. if (! empty ( $executeStaff ))
  2739. foreach ( $executeStaff as $m => $u ) {
  2740. if ($v [0] == $m) {
  2741. $executeCopy [$k] ['date'] = $u ['date'];
  2742. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2743. $executeCopy [$k] ['status'] = $u ['status'];
  2744. break;
  2745. }
  2746. }
  2747. }
  2748. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2749. $receiptList [$key] ['verifyList'] = $verifyList;
  2750. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2751. 'where' => 'sid=' . $value ['staff'],
  2752. 'asArray' => true
  2753. ) );
  2754. $receiptList [$key] ['button'] = $button;
  2755. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2756. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2757. $relust = $value ['sum'] - $value ['loanSum'];
  2758. $receiptList [$key] ['relust'] = $relust;
  2759. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2760. }
  2761. // print_r($receiptList);
  2762. // 获取审批日志
  2763. Doo::loadModel ( 'receiptLog' );
  2764. $receiptLog = new receiptLog ();
  2765. $rlList = array ();
  2766. $rlInfo = $receiptLog->getOne ( array (
  2767. 'where' => 'rid=' . $rid . ' and status=4',
  2768. 'asArray' => true
  2769. ) );
  2770. $tijdate = $receiptLog->getOne ( array (
  2771. 'where' => 'rid=' . $rid . ' and status=2',
  2772. 'asc' => 'rlid',
  2773. 'asArray' => true
  2774. ) );
  2775. if (! empty ( $rlInfo )) {
  2776. $rlList = $receiptLog->find ( array (
  2777. 'where' => 'rid=' . $rid,
  2778. 'asc' => 'rlid',
  2779. 'asArray' => true
  2780. ) );
  2781. }
  2782. Doo::loadModel ( 'enclosur' );
  2783. $enclosur = new enclosur ();
  2784. $enclosurList = $enclosur->find ( array (
  2785. 'where' => 'rid=' . $rid,
  2786. 'asArray' => true
  2787. ) );
  2788. $enclosurHtml = '';
  2789. foreach ( $enclosurList as $value ) {
  2790. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2791. }
  2792. $data ['enclosurHtml'] = $enclosurHtml;
  2793. $receiptList [0] ['rlList'] = $rlList;
  2794. $data ['receiptList'] = $receiptList;
  2795. $data ['memu'] = "receipt";
  2796. $data ['staff'] = $this->staff;
  2797. $data ['receiptMemu'] = 'approvalExpenses';
  2798. $data ['verifyId'] = $this->verifyId;
  2799. $data ['executeId'] = $this->executeId;
  2800. $this->render ( "/admin/expensesDoc", $data );
  2801. }
  2802. function expensesEdi() {
  2803. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2804. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  2805. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2806. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2807. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2808. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2809. if (empty ( $status ))
  2810. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  2811. $vidList = array ();
  2812. $button = 0;
  2813. Doo::loadModel ( 'verify' );
  2814. Doo::loadModel ( 'receipt' );
  2815. Doo::loadModel ( 'staff' );
  2816. $staff = new staff ();
  2817. $receipt = new receipt ();
  2818. $verify = new verify ();
  2819. Doo::loadModel ( 'L_category' );
  2820. $Lcategory = new L_category ();
  2821. Doo::loadModel ( 'enclosur' );
  2822. $enclosur = new enclosur ();
  2823. // user verify ID
  2824. $verifyDetail = $verify->find ( array (
  2825. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  2826. 'asArray' => true
  2827. ) );
  2828. foreach ( $verifyDetail as $key => $value ) {
  2829. array_push ( $vidList, $value ['vid'] );
  2830. }
  2831. $vid = implode ( ",", $vidList );
  2832. if (empty ( $verifyDetail ))
  2833. $vid = 0;
  2834. $categoryList = $Lcategory->find ( array (
  2835. 'asArray' => true
  2836. ) );
  2837. $staffList = $staff->find ( array (
  2838. 'where' => 'cid=' . $cid,
  2839. 'asArray' => true
  2840. ) );
  2841. $ap = "";
  2842. if ($status == 4) {
  2843. $ap = 4;
  2844. $status = 2;
  2845. }
  2846. // get Receipt By verifyID status 2
  2847. $receiptList = $receipt->find ( array (
  2848. 'where' => 'rid =' . $rid . ' and status=2',
  2849. 'desc' => 'rid',
  2850. 'asArray' => true
  2851. ) );
  2852. if (empty ( $receiptList )) {
  2853. die ( 'illegal request' );
  2854. }
  2855. $Locate = 0;
  2856. $roleId = 0;
  2857. if ($ap == 4)
  2858. $status = 4;
  2859. foreach ( $receiptList as $key => $value ) {
  2860. $receiptList [$key] ['Locate'] = $Locate;
  2861. $Locate ++;
  2862. $receiptList [$key] ['reviseDetail'] = array ();
  2863. if (! empty ( $value ['reviseDetail'] ))
  2864. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2865. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2866. $categoryDetil = $Lcategory->getOne ( array (
  2867. 'where' => 'cid=' . $value ['cid'],
  2868. 'asArray' => true
  2869. ) );
  2870. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2871. // 检测编辑状态
  2872. $verifyList = $verify->getOne ( array (
  2873. 'where' => 'vid=' . $value ['verify'],
  2874. 'asArray' => true
  2875. ) );
  2876. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2877. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2878. Doo::loadModel ( 'role' );
  2879. $role = new role ();
  2880. // print_r($verifyList);
  2881. $flag = true;
  2882. $roleKey = 0;
  2883. $endStaffArray = array ();
  2884. $roleArrayCopy = array ();
  2885. foreach ( $verifyList as $k => $v ) {
  2886. // init verifyStaff
  2887. if ($v [1] == 'ROLE') {
  2888. if (! empty ( $verifyStaff )) {
  2889. $endStaffArray = end ( $verifyStaff );
  2890. if ($v [0] == $endStaffArray ['nextStaff']) {
  2891. $roleId = $v [0];
  2892. }
  2893. }
  2894. $roleVerify = json_decode ( $v [3], true );
  2895. $roleKey = $k;
  2896. $roleArray = array ();
  2897. $rolename = $role->getOne ( array (
  2898. 'where' => 'rid=' . $v [0],
  2899. 'asArray' => true
  2900. ) );
  2901. foreach ( $roleVerify as $o => $p ) {
  2902. $staffID = explode ( '_', $p );
  2903. $staffInfo = $staff->getOne ( array (
  2904. 'where' => 'sid=' . $staffID [0],
  2905. 'asArray' => true
  2906. ) );
  2907. // print_r($staffID);
  2908. $exp = array (
  2909. 0 => $staffInfo ['sid'],
  2910. 1 => $staffID [1],
  2911. 2 => $staffInfo ['avatar'],
  2912. 'date' => '',
  2913. 'date' => '',
  2914. 'opinion' => '',
  2915. 'status' => '',
  2916. 'rolename' => $rolename ['name']
  2917. );
  2918. array_push ( $roleArray, $exp );
  2919. }
  2920. $roleArrayCopy [$v [0]] = $roleArray;
  2921. // $verifyList[$k]['roleArray']=$roleArray;
  2922. }
  2923. // print_r($roleArray);
  2924. $verifyList [$k] ['date'] = "";
  2925. $verifyList [$k] ['opinion'] = "";
  2926. $verifyList [$k] ['status'] = "";
  2927. if (empty ( $verifyStaff )) {
  2928. $verifyList [$k] ['date'] = "";
  2929. $verifyList [$k] ['opinion'] = "";
  2930. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2931. $verifyList [$k] ['status'] = 4;
  2932. $button = 4;
  2933. $flag = false;
  2934. }
  2935. } else {
  2936. foreach ( $verifyStaff as $m => $u ) {
  2937. if ($v [0] == $m) {
  2938. $verifyList [$k] ['date'] = $u ['date'];
  2939. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2940. $verifyList [$k] ['status'] = $u ['status'];
  2941. $flag = false;
  2942. break;
  2943. }
  2944. }
  2945. $endStaffArray = end ( $verifyStaff );
  2946. if (isset ( $endStaffArray ['ROLE'] )) {
  2947. } else {
  2948. $endKey = key ( $verifyStaff );
  2949. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  2950. $button = 4;
  2951. $verifyList [$k] ['status'] = 4;
  2952. }
  2953. }
  2954. }
  2955. }
  2956. $rolename ['name'] = '';
  2957. if (! empty ( $roleId )) {
  2958. Doo::loadModel ( 'role' );
  2959. $role = new role ();
  2960. $rolename = $role->getOne ( array (
  2961. 'where' => 'rid=' . $roleId,
  2962. 'asArray' => true
  2963. ) );
  2964. }
  2965. if (! empty ( $verifyStaff ))
  2966. $endStaffArray = end ( $verifyStaff );
  2967. $KOP = false;
  2968. foreach ( $roleArrayCopy as $P => $A ) {
  2969. foreach ( $A as $MKI => $AVL ) {
  2970. if (! empty ( $verifyStaff )) {
  2971. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2972. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2973. $button = 4;
  2974. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2975. }
  2976. foreach ( $verifyStaff as $m => $u ) {
  2977. $AVLFK = $AVL [0] . '_R';
  2978. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2979. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2980. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2981. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2982. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2983. break;
  2984. }
  2985. }
  2986. } else {
  2987. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2988. $button = 4;
  2989. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2990. }
  2991. }
  2992. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2993. $KOP = true;
  2994. }
  2995. }
  2996. // print_r($roleArrayCopy);
  2997. // echo $roleKey;
  2998. foreach ( $roleArrayCopy as $k => $v ) {
  2999. foreach ( $verifyList as $m => $n ) {
  3000. if ($n [0] == $k) {
  3001. array_splice ( $verifyList, $m, 1, $v );
  3002. }
  3003. }
  3004. }
  3005. $receiptList [$key] ['verifyList'] = $verifyList;
  3006. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3007. 'where' => 'sid=' . $value ['staff'],
  3008. 'asArray' => true
  3009. ) );
  3010. $receiptList [$key] ['button'] = $button;
  3011. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  3012. }
  3013. // $data['verifyDetail']=$verifyDetail;
  3014. $mothHtml = "";
  3015. for($i = 1; $i <= 12; $i ++) {
  3016. if ($month == $i)
  3017. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3018. else
  3019. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3020. }
  3021. // 获取审批日志
  3022. Doo::loadModel ( 'receiptLog' );
  3023. $receiptLog = new receiptLog ();
  3024. $rlList = array ();
  3025. $rlInfo = $receiptLog->getOne ( array (
  3026. 'where' => 'rid=' . $rid . ' and status=4',
  3027. 'asArray' => true
  3028. ) );
  3029. $tijdate = $receiptLog->getOne ( array (
  3030. 'where' => 'rid=' . $rid . ' and status=2',
  3031. 'asc' => 'rlid',
  3032. 'asArray' => true
  3033. ) );
  3034. if (! empty ( $rlInfo )) {
  3035. $rlList = $receiptLog->find ( array (
  3036. 'where' => 'rid=' . $rid,
  3037. 'asc' => 'rlid',
  3038. 'asArray' => true
  3039. ) );
  3040. }
  3041. $receiptList [0] ['rlList'] = $rlList;
  3042. $enclosurList = $enclosur->find ( array (
  3043. 'where' => 'rid=' . $rid,
  3044. 'asArray' => true
  3045. ) );
  3046. $enclosurHtml = '';
  3047. foreach ( $enclosurList as $value ) {
  3048. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3049. }
  3050. // print_r($receiptList);
  3051. $data ['rid'] = $rid;
  3052. $data ['enclosurHtml'] = $enclosurHtml;
  3053. $data ['rolename'] = $rolename ['name'];
  3054. $data ['datetij'] = $tijdate ['date'];
  3055. $data ['mothHtml'] = $mothHtml;
  3056. $data ['receiptList'] = $receiptList;
  3057. $data ['receiptApprovalCount'] = count ( $receiptList );
  3058. $data ['status'] = $status;
  3059. $data ['year'] = $year;
  3060. $data ['categoryList'] = $categoryList;
  3061. $data ['staffList'] = $staffList;
  3062. $data ['cid'] = $cid;
  3063. $data ['sid'] = $sid;
  3064. $data ['ap'] = $ap;
  3065. $data ['memu'] = "receipt";
  3066. $data ['staff'] = $this->staff;
  3067. $data ['receiptMemu'] = 'approvalExpenses';
  3068. $data ['verifyId'] = $this->verifyId;
  3069. $data ['executeId'] = $this->executeId;
  3070. $this->render ( "/admin/expensesEdi", $data );
  3071. }
  3072. function expensesDefray() {
  3073. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3074. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3075. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3076. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  3077. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  3078. if (! empty ( $rid )) {
  3079. Doo::loadModel ( "verify" );
  3080. $verify = new verify ();
  3081. Doo::loadModel ( "receiptDetail" );
  3082. $receiptDetailObj = new receiptDetail ();
  3083. Doo::loadModel ( "itemStatistics" );
  3084. Doo::loadModel ( "statistics" );
  3085. $statistics = new statistics ();
  3086. $itemStatistics = new itemStatistics ();
  3087. Doo::loadModel ( "receipt" );
  3088. $receipt = new receipt ();
  3089. Doo::loadModel ( "loanReceipt" );
  3090. $loanReceipt = new loanReceipt ();
  3091. $receiptDetail = $receipt->getOne ( array (
  3092. 'where' => 'rid=' . $rid . ' and status=2 ',
  3093. 'asArray' => true
  3094. ) );
  3095. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  3096. $nsflag = true;
  3097. foreach ( $nslist as $value ) {
  3098. if ($value == $this->staff ['0'] ['sid']) {
  3099. $nsflag = false;
  3100. break;
  3101. }
  3102. }
  3103. // print_r($nslist);die;
  3104. if (empty ( $receiptDetail ) || $nsflag)
  3105. return "/approvalExpenses/pendApproval";
  3106. $verifyDetail = $verify->getOne ( array (
  3107. 'where' => ' vid =' . $receiptDetail ['verify'],
  3108. 'asArray' => true
  3109. ) );
  3110. $verifyString = $verifyDetail ['staff'];
  3111. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3112. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  3113. if (empty ( $opinion )) {
  3114. if ($status == 3)
  3115. $opinion = "终止";
  3116. else
  3117. $opinion = "同意支付";
  3118. }
  3119. $nowStaff = 0;
  3120. $nowStaffList = array ();
  3121. if (empty ( $verifyStaff )) {
  3122. // 还需加入是否已经进入角色审批
  3123. if ($verifyDetail [0] [1] == 'ROLE') {
  3124. // print_r($verifyDetail);echo "ddd";
  3125. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3126. foreach ( $vStaffString as $key => $value ) {
  3127. $staffK = explode ( "_", $value );
  3128. if ($staffK [0] != $this->staff [0] ['sid'])
  3129. array_push ( $nowStaffList, $staffK [0] );
  3130. }
  3131. // print_r($verifyDetail);
  3132. // die;
  3133. if (! empty ( $nowStaffList )) {
  3134. $nowStaff = implode ( ',', $nowStaffList );
  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 [0] [0],
  3141. 'ROLE' => 1
  3142. )
  3143. );
  3144. } else {
  3145. $nowStaff = $verifyDetail [1] [0];
  3146. $verifyStaff = array (
  3147. $this->staff [0] ['sid'] . "_R" => array (
  3148. 'date' => date ( 'Y-m-d' ),
  3149. 'opinion' => $opinion,
  3150. 'status' => $status,
  3151. 'nextStaff' => $verifyDetail [1] [0]
  3152. )
  3153. );
  3154. }
  3155. } else {
  3156. if ($verifyDetail [1] [1] == 'ROLE') {
  3157. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  3158. // echo "dd";
  3159. foreach ( $vStaffString as $key => $value ) {
  3160. $staffK = explode ( "_", $value );
  3161. array_push ( $nowStaffList, $staffK [0] );
  3162. }
  3163. $nowStaff = implode ( ',', $nowStaffList );
  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. 'ROLE' => 1
  3171. )
  3172. );
  3173. } else {
  3174. $nowStaff = $verifyDetail [1] [0];
  3175. $verifyStaff = array (
  3176. $this->staff [0] ['sid'] => array (
  3177. 'date' => date ( 'Y-m-d' ),
  3178. 'opinion' => $opinion,
  3179. 'status' => $status,
  3180. 'nextStaff' => $verifyDetail [1] [0]
  3181. )
  3182. );
  3183. }
  3184. }
  3185. if ($status == 3)
  3186. $verifyStaff = array (
  3187. 'final' => $status,
  3188. $this->staff [0] ['sid'] => array (
  3189. 'date' => date ( 'Y-m-d' ),
  3190. 'opinion' => $opinion,
  3191. 'status' => $status
  3192. )
  3193. );
  3194. $vStaffString = json_encode ( $verifyStaff );
  3195. $receipt->nowStaff = $nowStaff;
  3196. $receipt->verifyStaff = $vStaffString;
  3197. $loanReceipt->nowStaff = $nowStaff;
  3198. $loanReceipt->verifyStaff = $vStaffString;
  3199. } else {
  3200. $VS = end ( $verifyStaff );
  3201. // 非角色审批
  3202. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  3203. $nextStaff = 0;
  3204. $roleSTF = false;
  3205. foreach ( $verifyDetail as $key => $value ) {
  3206. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  3207. if (isset ( $verifyDetail [$key + 1] )) {
  3208. $nextStaff = $verifyDetail [$key + 1] [0];
  3209. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  3210. $roleSTF = true;
  3211. }
  3212. break;
  3213. }
  3214. }
  3215. if (! $roleSTF) {
  3216. $nowStaff = $nextStaff;
  3217. $verifyStaff [$this->staff [0] ['sid']] = array (
  3218. 'date' => date ( 'Y-m-d' ),
  3219. 'opinion' => $opinion,
  3220. 'status' => $status,
  3221. 'nextStaff' => $nextStaff
  3222. );
  3223. } else {
  3224. // 获取角色下的所有用户ID
  3225. $nowStaffList = array ();
  3226. foreach ( $verifyDetail as $vfk ) {
  3227. if ($vfk [1] == 'ROLE') {
  3228. $vStaffString = json_decode ( $vfk [3] );
  3229. foreach ( $vStaffString as $key => $value ) {
  3230. $staffK = explode ( "_", $value );
  3231. array_push ( $nowStaffList, $staffK [0] );
  3232. }
  3233. }
  3234. }
  3235. $nowStaff = implode ( ',', $nowStaffList );
  3236. $verifyStaff [$this->staff [0] ['sid']] = array (
  3237. 'date' => date ( 'Y-m-d' ),
  3238. 'opinion' => $opinion,
  3239. 'status' => $status,
  3240. 'nextStaff' => $nextStaff,
  3241. 'ROLE' => 0
  3242. );
  3243. }
  3244. if ($status == 3) {
  3245. $verifyStaff ['final'] = $status;
  3246. $verifyStaff [$this->staff [0] ['sid']] = array (
  3247. 'date' => date ( 'Y-m-d' ),
  3248. 'opinion' => $opinion,
  3249. 'status' => $status
  3250. );
  3251. }
  3252. $vStaffString = json_encode ( $verifyStaff );
  3253. $receipt->nowStaff = $nowStaff;
  3254. $receipt->verifyStaff = $vStaffString;
  3255. $loanReceipt->nowStaff = $nowStaff;
  3256. $loanReceipt->verifyStaff = $vStaffString;
  3257. }
  3258. // 角色审批
  3259. if (isset ( $VS ['ROLE'] )) {
  3260. // 找出角色人 当前审批角色组
  3261. $verifyJSStaff = array ();
  3262. $nowStaffList2 = array ();
  3263. foreach ( $verifyDetail as $key => $value ) {
  3264. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  3265. $verifyJSStaff = json_decode ( $value [3] );
  3266. foreach ( $verifyJSStaff as $m ) {
  3267. $staffK = explode ( "_", $m );
  3268. array_push ( $nowStaffList2, $staffK [0] );
  3269. }
  3270. // print_r($nowStaffList2);
  3271. }
  3272. }
  3273. $RoleVerifyStaff = array ();
  3274. foreach ( $verifyStaff as $key => $value ) {
  3275. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  3276. foreach ( $nowStaffList2 as $m ) {
  3277. if ($key == $m . "_R")
  3278. $RoleVerifyStaff [$key] = $value;
  3279. }
  3280. }
  3281. }
  3282. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  3283. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  3284. // 下一个审批人ID
  3285. $nextStaff = 0;
  3286. $falg = false;
  3287. foreach ( $verifyDetail as $key => $value ) {
  3288. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  3289. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  3290. $falg = true;
  3291. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  3292. $nowStaffList = array ();
  3293. foreach ( $vStaffString as $v ) {
  3294. $staffK = explode ( "_", $v );
  3295. array_push ( $nowStaffList, $staffK [0] );
  3296. }
  3297. $nowStaff = implode ( ',', $nowStaffList );
  3298. $nextStaff = $verifyDetail [$key + 1] [0];
  3299. } elseif (isset ( $verifyDetail [$key + 1] )) {
  3300. $nextStaff = $verifyDetail [$key + 1] [0];
  3301. $nowStaff = $nextStaff;
  3302. } else
  3303. $nowStaff = '';
  3304. break;
  3305. }
  3306. }
  3307. if ($falg)
  3308. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3309. 'date' => date ( 'Y-m-d' ),
  3310. 'opinion' => $opinion,
  3311. 'status' => $status,
  3312. 'nextStaff' => $nextStaff,
  3313. 'ROLE' => 1
  3314. );
  3315. else
  3316. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3317. 'date' => date ( 'Y-m-d' ),
  3318. 'opinion' => $opinion,
  3319. 'status' => $status,
  3320. 'nextStaff' => $nextStaff
  3321. );
  3322. // print_r($verifyStaff);
  3323. // echo $nowStaff;die;
  3324. } else { // 进入下一个角色或者审批人
  3325. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  3326. //
  3327. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  3328. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3329. 'date' => date ( 'Y-m-d' ),
  3330. 'opinion' => $opinion,
  3331. 'status' => $status,
  3332. 'nextStaff' => $VS ['nextStaff'],
  3333. 'ROLE' => 1
  3334. );
  3335. // print_r($verifyStaff);
  3336. // die;
  3337. }
  3338. if ($status == 3) {
  3339. $verifyStaff ['final'] = $status;
  3340. $verifyStaff [$this->staff [0] ['sid']] = array (
  3341. 'date' => date ( 'Y-m-d' ),
  3342. 'opinion' => $opinion,
  3343. 'status' => $status
  3344. );
  3345. }
  3346. $vStaffString = json_encode ( $verifyStaff );
  3347. $receipt->verifyStaff = $vStaffString;
  3348. $receipt->nowStaff = $nowStaff;
  3349. $loanReceipt->nowStaff = $nowStaff;
  3350. $loanReceipt->verifyStaff = $vStaffString;
  3351. // die;
  3352. // }
  3353. // print_r($verifyStaff);
  3354. // die;
  3355. }
  3356. // print_r($verifyStaff);die;
  3357. }
  3358. // print_r($verifyDetail);
  3359. $roleKey = 0;
  3360. $roleId = 0;
  3361. $verifyDetailCopy = array ();
  3362. foreach ( $verifyDetail as $k => $v ) {
  3363. if ($v [1] == 'ROLE') {
  3364. $roleId = $v [0];
  3365. $roleVerify = json_decode ( $v [3], true );
  3366. $roleKey = $k;
  3367. $roleArray = array ();
  3368. foreach ( $roleVerify as $o => $p ) {
  3369. $staffID = explode ( '_', $p );
  3370. $exp = array (
  3371. 0 => $staffID [0],
  3372. 1 => $staffID [1]
  3373. );
  3374. array_push ( $roleArray, $exp );
  3375. }
  3376. $verifyDetailCopy [$v [0]] = $roleArray;
  3377. }
  3378. }
  3379. // print_r($verifyDetail);
  3380. foreach ( $verifyDetailCopy as $k => $v ) {
  3381. foreach ( $verifyDetail as $m => $n ) {
  3382. if ($n [0] == $k) {
  3383. array_splice ( $verifyDetail, $m, 1, $v );
  3384. }
  3385. }
  3386. }
  3387. // 审批日志
  3388. if (! isset ( $verifyStaff ['final'] )) {
  3389. Doo::loadModel ( "receiptLog" );
  3390. $receiptLog = new receiptLog ();
  3391. if (! empty ( $roleId )) {
  3392. Doo::loadModel ( "role" );
  3393. $role = new role ();
  3394. $roleInfo = $role->getOne ( array (
  3395. 'where' => 'rid=' . $roleId,
  3396. 'asArray' => true
  3397. ) );
  3398. $receiptLog->rolename = $roleInfo ['name'];
  3399. }
  3400. $receiptLog->username = $this->staff [0] ['username'];
  3401. $receiptLog->uid = $this->staff [0] ['sid'];
  3402. $receiptLog->date = date ( "Y-m-d" );
  3403. $receiptLog->opinion = $opinion;
  3404. $receiptLog->img = $this->staff [0] ['avatar'];
  3405. $receiptLog->status = 1;
  3406. $receiptLog->rid = $rid;
  3407. $receiptLog->insert ();
  3408. }
  3409. if (isset ( $verifyStaff ['final'] )) { // rDetail
  3410. $receipt->status = 3;
  3411. $receipt->verifyBreakup = $verifyString;
  3412. $receiptDetailObj->status = 3;
  3413. $receiptDetailObj->update ( array (
  3414. 'where' => 'rid=' . $rid
  3415. ) );
  3416. // 微信企业号通知
  3417. $this->setWXMsg ( $rid, 3 );
  3418. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  3419. $receipt->status = 6;
  3420. $receipt->pastDate = date ( "Y-m-d" );
  3421. $receipt->isBK = 1;
  3422. $loanReceipt->verifyBreakup = $verifyString;
  3423. $loanReceipt->status = 1;
  3424. $loanReceipt->pastDate = date ( "Y-m-d" );
  3425. $loanReceipt->amount = $receiptDetail ['amount'];
  3426. $loanReceipt->update ( array (
  3427. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  3428. ) );
  3429. // 微信企业号通知
  3430. $this->setWXMsg ( $rid, 1 );
  3431. }
  3432. $receipt->amount = $amount;
  3433. $receipt->update ( array (
  3434. 'where' => ' rid = ' . $rid
  3435. ) );
  3436. // 进入下一条审批费用新加需求
  3437. $vidList = array ();
  3438. $verifyDetail = $verify->find ( array (
  3439. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  3440. 'asArray' => true
  3441. ) );
  3442. foreach ( $verifyDetail as $key => $value ) {
  3443. array_push ( $vidList, $value ['vid'] );
  3444. }
  3445. $vid = implode ( ",", $vidList );
  3446. if (empty ( $verifyDetail ))
  3447. $vid = 0;
  3448. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  3449. $receipt = new receipt ();
  3450. $rd = $receipt->getOne ( array (
  3451. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  3452. 'asc' => 'rid',
  3453. 'asArray' => true
  3454. ) );
  3455. if (empty ( $rd )) {
  3456. return '/approvalExpenses/pendApproval';
  3457. }
  3458. if ($rd ['Rtype'] == 1) {
  3459. if ($rd ['isBK'] == 1) {
  3460. return '/receiptburEdi/' . $rd ['rid'];
  3461. } else {
  3462. return '/expensesEdi/' . $rd ['rid'];
  3463. }
  3464. } elseif ($rd ['Rtype'] == 2) {
  3465. return '/remitApproval/' . $rd ['rid'];
  3466. } else {
  3467. return '/receiptburEdi/' . $rd ['rid'];
  3468. }
  3469. // return "/approvalExpenses/pendApproval";
  3470. }
  3471. }
  3472. function ajaxExamineExe() {
  3473. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3474. Doo::loadModel ( 'receipt' );
  3475. $receipt = new receipt ();
  3476. Doo::loadClass ( 'XDeode' );
  3477. $XDeode = new XDeode ( 5 );
  3478. if (! empty ( $rid )) {
  3479. $rLRes = $receipt->find ( array (
  3480. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  3481. 'asArray' => true
  3482. ) );
  3483. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  3484. echo json_encode ( array (
  3485. 'status' => 1,
  3486. 'receipt' => $rLRes [0]
  3487. ) );
  3488. die ();
  3489. }
  3490. echo json_encode ( array (
  3491. 'status' => 0,
  3492. 'receipt' => array ()
  3493. ) );
  3494. die ();
  3495. }
  3496. function implement() {
  3497. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3498. Doo::loadClass ( 'XDeode' );
  3499. $XDeode = new XDeode ( 5 );
  3500. Doo::loadModel ( 'receipt' );
  3501. $receipt = new receipt ();
  3502. Doo::loadModel ( 'L_category' );
  3503. $Lcategory = new L_category ();
  3504. Doo::loadModel ( 'verify' );
  3505. $verify = new verify ();
  3506. Doo::loadModel ( 'staff' );
  3507. $staff = new staff ();
  3508. Doo::loadModel ( "execute" );
  3509. $execute = new execute ();
  3510. $rid = $XDeode->decode ( $rid );
  3511. $receiptList = $receipt->find ( array (
  3512. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  3513. 'desc' => 'rid',
  3514. 'asArray' => true
  3515. ) );
  3516. Doo::loadModel ( 'loanReceipt' );
  3517. $loanReceipt = new loanReceipt ();
  3518. // print_r($receiptList);
  3519. $loanList = array ();
  3520. if (! isset ( $receiptList ))
  3521. $loanList = $loanReceipt->find ( array (
  3522. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3523. 'desc' => 'rid',
  3524. 'asArray' => true
  3525. ) );
  3526. $Locate = 0;
  3527. $roleId = 0;
  3528. $button = 0;
  3529. foreach ( $loanList as $key => $value ) {
  3530. $loanList [$key] ['Locate'] = $Locate;
  3531. $Locate ++;
  3532. $loanList [$key] ['reviseDetail'] = array ();
  3533. if (! empty ( $value ['reviseDetail'] ))
  3534. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3535. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3536. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3537. $categoryDetil = $Lcategory->getOne ( array (
  3538. 'where' => 'cid=' . $value ['cid'],
  3539. 'asArray' => true
  3540. ) );
  3541. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3542. // 检测编辑状态
  3543. $verifyList = $verify->getOne ( array (
  3544. 'where' => 'vid=' . $value ['verify'],
  3545. 'asArray' => true
  3546. ) );
  3547. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3548. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3549. Doo::loadModel ( 'role' );
  3550. $role = new role ();
  3551. $flag = true;
  3552. $roleKey = 0;
  3553. $endStaffArray = array ();
  3554. $roleArrayCopy = array ();
  3555. foreach ( $verifyList as $k => $v ) {
  3556. // init verifyStaff
  3557. if ($v [1] == 'ROLE') {
  3558. if (! empty ( $verifyStaff )) {
  3559. $endStaffArray = end ( $verifyStaff );
  3560. // if ($v[0]==$endStaffArray['nextStaff']){
  3561. // $roleId=$v[0];
  3562. // }
  3563. }
  3564. $roleVerify = json_decode ( $v [3], true );
  3565. $roleKey = $k;
  3566. $roleArray = array ();
  3567. $rolename = $role->getOne ( array (
  3568. 'where' => 'rid=' . $v [0],
  3569. 'asArray' => true
  3570. ) );
  3571. foreach ( $roleVerify as $o => $p ) {
  3572. $staffID = explode ( '_', $p );
  3573. $staffInfo = $staff->getOne ( array (
  3574. 'where' => 'sid=' . $staffID [0],
  3575. 'asArray' => true
  3576. ) );
  3577. // print_r($staffID);
  3578. $exp = array (
  3579. 0 => $staffInfo ['sid'],
  3580. 1 => $staffID [1],
  3581. 2 => $staffInfo ['avatar'],
  3582. 'date' => '',
  3583. 'date' => '',
  3584. 'opinion' => '',
  3585. 'status' => '',
  3586. 'rolename' => $rolename ['name']
  3587. );
  3588. array_push ( $roleArray, $exp );
  3589. }
  3590. $roleArrayCopy [$v [0]] = $roleArray;
  3591. // $verifyList[$k]['roleArray']=$roleArray;
  3592. }
  3593. $verifyList [$k] ['date'] = "";
  3594. $verifyList [$k] ['opinion'] = "";
  3595. $verifyList [$k] ['status'] = "";
  3596. if (empty ( $verifyStaff )) {
  3597. $verifyList [$k] ['date'] = "";
  3598. $verifyList [$k] ['opinion'] = "";
  3599. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3600. $verifyList [$k] ['status'] = 4;
  3601. $flag = false;
  3602. }
  3603. } else {
  3604. foreach ( $verifyStaff as $m => $u ) {
  3605. if ($v [0] == $m) {
  3606. $verifyList [$k] ['date'] = $u ['date'];
  3607. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3608. $verifyList [$k] ['status'] = $u ['status'];
  3609. $flag = false;
  3610. break;
  3611. }
  3612. }
  3613. $endStaffArray = end ( $verifyStaff );
  3614. if (isset ( $endStaffArray ['ROLE'] )) {
  3615. } else {
  3616. // $endKey=key($verifyStaff);
  3617. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3618. // $button=4;
  3619. // $verifyList[$k]['status']=4;
  3620. // }
  3621. }
  3622. }
  3623. }
  3624. $rolename ['name'] = '';
  3625. if (! empty ( $roleId )) {
  3626. Doo::loadModel ( 'role' );
  3627. $role = new role ();
  3628. $rolename = $role->getOne ( array (
  3629. 'where' => 'rid=' . $roleId,
  3630. 'asArray' => true
  3631. ) );
  3632. }
  3633. if (! empty ( $verifyStaff ))
  3634. $endStaffArray = end ( $verifyStaff );
  3635. $KOP = false;
  3636. foreach ( $roleArrayCopy as $P => $A ) {
  3637. foreach ( $A as $MKI => $AVL ) {
  3638. if (! empty ( $verifyStaff )) {
  3639. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3640. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3641. $button = 4;
  3642. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3643. }
  3644. foreach ( $verifyStaff as $m => $u ) {
  3645. $AVLFK = $AVL [0] . '_R';
  3646. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3647. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3648. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3649. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3650. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3651. break;
  3652. }
  3653. }
  3654. } else {
  3655. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3656. $button = 4;
  3657. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3658. }
  3659. }
  3660. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3661. $KOP = true;
  3662. }
  3663. }
  3664. foreach ( $roleArrayCopy as $k => $v ) {
  3665. foreach ( $verifyList as $m => $n ) {
  3666. if ($n [0] == $k) {
  3667. array_splice ( $verifyList, $m, 1, $v );
  3668. }
  3669. }
  3670. }
  3671. $loanList [$key] ['verifyList'] = $verifyList;
  3672. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3673. 'where' => 'sid=' . $value ['staff'],
  3674. 'asArray' => true
  3675. ) );
  3676. }
  3677. $data ['loanList'] = $loanList;
  3678. $Locate = 0;
  3679. $roleId = 0;
  3680. $button = 0;
  3681. foreach ( $receiptList as $key => $value ) {
  3682. $button2 = 0;
  3683. $receiptList [$key] ['Locate'] = $Locate;
  3684. $Locate ++;
  3685. $receiptList [$key] ['reviseDetail'] = array ();
  3686. if (! empty ( $value ['reviseDetail'] ))
  3687. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3688. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3689. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3690. $categoryDetil = $Lcategory->getOne ( array (
  3691. 'where' => 'cid=' . $value ['cid'],
  3692. 'asArray' => true
  3693. ) );
  3694. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3695. $executeList = json_decode ( $value ['executeCopy'], true );
  3696. $executeStaff = array ();
  3697. if (! empty ( $value ['executeStaff'] ))
  3698. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3699. if (isset ( $executeList )) {
  3700. foreach ( $executeList as $op => $lo ) {
  3701. $executeList [$op] ['date'] = "";
  3702. $executeList [$op] ['opinion'] = "";
  3703. $executeList [$op] ['status'] = "";
  3704. foreach ( $executeStaff as $m => $u ) {
  3705. if ($lo [0] == $m) {
  3706. $executeList [$op] ['date'] = $u ['date'];
  3707. $executeList [$op] ['opinion'] = $u ['opinion'];
  3708. $executeList [$op] ['status'] = $u ['status'];
  3709. break;
  3710. }
  3711. }
  3712. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  3713. $button2 = 1;
  3714. $executeList [$op] ['status'] = 4;
  3715. }
  3716. }
  3717. }
  3718. // 检测编辑状态
  3719. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3720. $verifyList ['staff'] = $value ['verifyBreakup'];
  3721. } else
  3722. $verifyList = $verify->getOne ( array (
  3723. 'where' => 'vid=' . $value ['verify'],
  3724. 'asArray' => true
  3725. ) );
  3726. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3727. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3728. Doo::loadModel ( 'role' );
  3729. $role = new role ();
  3730. if ($verifyList == NULL)
  3731. $verifyList = array ();
  3732. $flag = true;
  3733. $roleKey = 0;
  3734. $endStaffArray = array ();
  3735. $roleArrayCopy = array ();
  3736. foreach ( $verifyList as $k => $v ) {
  3737. // init verifyStaff
  3738. if ($v [1] == 'ROLE') {
  3739. if (! empty ( $verifyStaff )) {
  3740. $endStaffArray = end ( $verifyStaff );
  3741. // if ($v[0]==$endStaffArray['nextStaff']){
  3742. // $roleId=$v[0];
  3743. // }
  3744. }
  3745. $roleVerify = json_decode ( $v [3], true );
  3746. $roleKey = $k;
  3747. $roleArray = array ();
  3748. $rolename = $role->getOne ( array (
  3749. 'where' => 'rid=' . $v [0],
  3750. 'asArray' => true
  3751. ) );
  3752. foreach ( $roleVerify as $o => $p ) {
  3753. $staffID = explode ( '_', $p );
  3754. $staffInfo = $staff->getOne ( array (
  3755. 'where' => 'sid=' . $staffID [0],
  3756. 'asArray' => true
  3757. ) );
  3758. // print_r($staffID);
  3759. $exp = array (
  3760. 0 => $staffInfo ['sid'],
  3761. 1 => $staffID [1],
  3762. 2 => $staffInfo ['avatar'],
  3763. 'date' => '',
  3764. 'date' => '',
  3765. 'opinion' => '',
  3766. 'status' => '',
  3767. 'rolename' => $rolename ['name']
  3768. );
  3769. array_push ( $roleArray, $exp );
  3770. }
  3771. $roleArrayCopy [$v [0]] = $roleArray;
  3772. // $verifyList[$k]['roleArray']=$roleArray;
  3773. }
  3774. $verifyList [$k] ['date'] = "";
  3775. $verifyList [$k] ['opinion'] = "";
  3776. $verifyList [$k] ['status'] = "";
  3777. if (empty ( $verifyStaff )) {
  3778. $verifyList [$k] ['date'] = "";
  3779. $verifyList [$k] ['opinion'] = "";
  3780. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3781. $verifyList [$k] ['status'] = 4;
  3782. $flag = false;
  3783. }
  3784. } else {
  3785. foreach ( $verifyStaff as $m => $u ) {
  3786. if ($v [0] == $m) {
  3787. $verifyList [$k] ['date'] = $u ['date'];
  3788. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3789. $verifyList [$k] ['status'] = $u ['status'];
  3790. $flag = false;
  3791. break;
  3792. }
  3793. }
  3794. $endStaffArray = end ( $verifyStaff );
  3795. if (isset ( $endStaffArray ['ROLE'] )) {
  3796. } else {
  3797. // $endKey=key($verifyStaff);
  3798. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3799. // $button=4;
  3800. // $verifyList[$k]['status']=4;
  3801. // }
  3802. }
  3803. }
  3804. }
  3805. $rolename ['name'] = '';
  3806. if (! empty ( $roleId )) {
  3807. Doo::loadModel ( 'role' );
  3808. $role = new role ();
  3809. $rolename = $role->getOne ( array (
  3810. 'where' => 'rid=' . $roleId,
  3811. 'asArray' => true
  3812. ) );
  3813. }
  3814. if (! empty ( $verifyStaff ))
  3815. $endStaffArray = end ( $verifyStaff );
  3816. $KOP = false;
  3817. foreach ( $roleArrayCopy as $P => $A ) {
  3818. foreach ( $A as $MKI => $AVL ) {
  3819. if (! empty ( $verifyStaff )) {
  3820. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3821. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3822. $button = 4;
  3823. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3824. }
  3825. foreach ( $verifyStaff as $m => $u ) {
  3826. $AVLFK = $AVL [0] . '_R';
  3827. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3828. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3829. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3830. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3831. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3832. break;
  3833. }
  3834. }
  3835. } else {
  3836. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3837. $button = 4;
  3838. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3839. }
  3840. }
  3841. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3842. $KOP = true;
  3843. }
  3844. }
  3845. foreach ( $roleArrayCopy as $k => $v ) {
  3846. foreach ( $verifyList as $m => $n ) {
  3847. if ($n [0] == $k) {
  3848. array_splice ( $verifyList, $m, 1, $v );
  3849. }
  3850. }
  3851. }
  3852. $receiptList [$key] ['verifyList'] = $verifyList;
  3853. $receiptList [$key] ['executeList'] = $executeList;
  3854. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3855. 'where' => 'sid=' . $value ['staff'],
  3856. 'asArray' => true
  3857. ) );
  3858. $receiptList [$key] ['button2'] = $button2;
  3859. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3860. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3861. $relust = $value ['sum'] - $value ['loanSum'];
  3862. $receiptList [$key] ['relust'] = $relust;
  3863. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  3864. }
  3865. // print_r($receiptList[$key]['executeList']);
  3866. $data ['receiptList'] = $receiptList;
  3867. $data ['memu'] = "receipt";
  3868. $data ['staff'] = $this->staff;
  3869. $data ['receiptMemu'] = 'implement';
  3870. $data ['verifyId'] = $this->verifyId;
  3871. $data ['executeId'] = $this->executeId;
  3872. $this->render ( "/admin/implement", $data );
  3873. }
  3874. function implementDo() {
  3875. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3876. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3877. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  3878. if (! empty ( $rid ) && $amount != '') {
  3879. Doo::loadModel ( 'receipt' );
  3880. $receipt = new receipt ();
  3881. Doo::loadClass ( 'XDeode' );
  3882. $XDeode = new XDeode ( 5 );
  3883. $rinfo = $receipt->getOne ( array (
  3884. 'where' => 'rid=' . $rid,
  3885. 'asArray' => true
  3886. ) );
  3887. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  3888. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  3889. if (empty ( $executeStaff )) {
  3890. $executeStaff = array (
  3891. $this->staff [0] ['sid'] => array (
  3892. 'date' => date ( 'Y-m-d' ),
  3893. 'opinion' => $implementOpinions,
  3894. 'status' => 1
  3895. )
  3896. );
  3897. } else {
  3898. $executeStaff [$this->staff [0] ['sid']] = array (
  3899. 'date' => date ( 'Y-m-d' ),
  3900. 'opinion' => $implementOpinions,
  3901. 'status' => 1
  3902. );
  3903. }
  3904. if (count ( $executeStaff ) == count ( $executeCopy )) {
  3905. $receipt->executeStaff = json_encode ( $executeStaff );
  3906. $receipt->status = 8;
  3907. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  3908. $receipt->status = 9;
  3909. if ($rinfo ['status'] == 6) {
  3910. $receipt->loanDate = date ( "Y-m-d" );
  3911. }
  3912. $receipt->executeDate = date ( "Y-m-d" );
  3913. } else {
  3914. $receipt->executeStaff = json_encode ( $executeStaff );
  3915. }
  3916. $receipt->amount = $amount;
  3917. $receipt->update ( array (
  3918. 'where' => 'rid=' . $rid
  3919. ) );
  3920. }
  3921. $ridKey = $XDeode->encode ( $rid );
  3922. return "/hisImplement";
  3923. // return "/implement/" . $ridKey . ".html";
  3924. }
  3925. function receiptburEdi() {
  3926. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3927. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  3928. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  3929. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  3930. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3931. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  3932. if (empty ( $status ))
  3933. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  3934. $vidList = array ();
  3935. $button = 0;
  3936. Doo::loadModel ( 'verify' );
  3937. Doo::loadModel ( 'receipt' );
  3938. Doo::loadModel ( 'staff' );
  3939. $staff = new staff ();
  3940. $receipt = new receipt ();
  3941. $verify = new verify ();
  3942. Doo::loadModel ( 'L_category' );
  3943. $Lcategory = new L_category ();
  3944. Doo::loadModel ( 'enclosur' );
  3945. $enclosur = new enclosur ();
  3946. Doo::loadModel ( 'loanReceipt' );
  3947. $loanReceipt = new loanReceipt ();
  3948. // user verify ID
  3949. $verifyDetail = $verify->find ( array (
  3950. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  3951. 'asArray' => true
  3952. ) );
  3953. foreach ( $verifyDetail as $key => $value ) {
  3954. array_push ( $vidList, $value ['vid'] );
  3955. }
  3956. $vid = implode ( ",", $vidList );
  3957. if (empty ( $verifyDetail ))
  3958. $vid = 0;
  3959. $categoryList = $Lcategory->find ( array (
  3960. 'asArray' => true
  3961. ) );
  3962. $staffList = $staff->find ( array (
  3963. 'where' => 'cid=' . $cid,
  3964. 'asArray' => true
  3965. ) );
  3966. $ap = "";
  3967. if ($status == 4) {
  3968. $ap = 4;
  3969. $status = 2;
  3970. }
  3971. // get Receipt By verifyID status 2
  3972. $receiptList = $receipt->find ( array (
  3973. 'where' => 'rid =' . $rid . ' and status=2',
  3974. 'desc' => 'rid',
  3975. 'asArray' => true
  3976. ) );
  3977. if (empty ( $receiptList )) {
  3978. die ( 'illegal request' );
  3979. }
  3980. $loanList = $loanReceipt->find ( array (
  3981. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3982. 'desc' => 'rid',
  3983. 'asArray' => true
  3984. ) );
  3985. $Locate = 0;
  3986. $roleId = 0;
  3987. $button = 0;
  3988. foreach ( $loanList as $key => $value ) {
  3989. $loanList [$key] ['Locate'] = $Locate;
  3990. $Locate ++;
  3991. $loanList [$key] ['reviseDetail'] = array ();
  3992. if (! empty ( $value ['reviseDetail'] ))
  3993. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3994. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3995. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3996. $categoryDetil = $Lcategory->getOne ( array (
  3997. 'where' => 'cid=' . $value ['cid'],
  3998. 'asArray' => true
  3999. ) );
  4000. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4001. // 检测编辑状态
  4002. $verifyList = $verify->getOne ( array (
  4003. 'where' => 'vid=' . $value ['verify'],
  4004. 'asArray' => true
  4005. ) );
  4006. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4007. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4008. Doo::loadModel ( 'role' );
  4009. $role = new role ();
  4010. $flag = true;
  4011. $roleKey = 0;
  4012. $endStaffArray = array ();
  4013. $roleArrayCopy = array ();
  4014. foreach ( $verifyList as $k => $v ) {
  4015. // init verifyStaff
  4016. if ($v [1] == 'ROLE') {
  4017. if (! empty ( $verifyStaff )) {
  4018. $endStaffArray = end ( $verifyStaff );
  4019. }
  4020. $roleVerify = json_decode ( $v [3], true );
  4021. $roleKey = $k;
  4022. $roleArray = array ();
  4023. $rolename = $role->getOne ( array (
  4024. 'where' => 'rid=' . $v [0],
  4025. 'asArray' => true
  4026. ) );
  4027. foreach ( $roleVerify as $o => $p ) {
  4028. $staffID = explode ( '_', $p );
  4029. $staffInfo = $staff->getOne ( array (
  4030. 'where' => 'sid=' . $staffID [0],
  4031. 'asArray' => true
  4032. ) );
  4033. // print_r($staffID);
  4034. $exp = array (
  4035. 0 => $staffInfo ['sid'],
  4036. 1 => $staffID [1],
  4037. 2 => $staffInfo ['avatar'],
  4038. 'date' => '',
  4039. 'date' => '',
  4040. 'opinion' => '',
  4041. 'status' => '',
  4042. 'rolename' => $rolename ['name']
  4043. );
  4044. array_push ( $roleArray, $exp );
  4045. }
  4046. $roleArrayCopy [$v [0]] = $roleArray;
  4047. // $verifyList[$k]['roleArray']=$roleArray;
  4048. }
  4049. $verifyList [$k] ['date'] = "";
  4050. $verifyList [$k] ['opinion'] = "";
  4051. $verifyList [$k] ['status'] = "";
  4052. if (empty ( $verifyStaff )) {
  4053. $verifyList [$k] ['date'] = "";
  4054. $verifyList [$k] ['opinion'] = "";
  4055. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4056. $verifyList [$k] ['status'] = 4;
  4057. $flag = false;
  4058. }
  4059. } else {
  4060. foreach ( $verifyStaff as $m => $u ) {
  4061. if ($v [0] == $m) {
  4062. $verifyList [$k] ['date'] = $u ['date'];
  4063. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4064. $verifyList [$k] ['status'] = $u ['status'];
  4065. $flag = false;
  4066. break;
  4067. }
  4068. }
  4069. $endStaffArray = end ( $verifyStaff );
  4070. if (isset ( $endStaffArray ['ROLE'] )) {
  4071. } else {
  4072. }
  4073. }
  4074. }
  4075. $rolename ['name'] = '';
  4076. if (! empty ( $roleId )) {
  4077. Doo::loadModel ( 'role' );
  4078. $role = new role ();
  4079. $rolename = $role->getOne ( array (
  4080. 'where' => 'rid=' . $roleId,
  4081. 'asArray' => true
  4082. ) );
  4083. }
  4084. if (! empty ( $verifyStaff ))
  4085. $endStaffArray = end ( $verifyStaff );
  4086. $KOP = false;
  4087. foreach ( $roleArrayCopy as $P => $A ) {
  4088. foreach ( $A as $MKI => $AVL ) {
  4089. if (! empty ( $verifyStaff )) {
  4090. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4091. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4092. $button = 4;
  4093. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4094. }
  4095. foreach ( $verifyStaff as $m => $u ) {
  4096. $AVLFK = $AVL [0] . '_R';
  4097. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4098. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4099. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4100. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4101. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4102. break;
  4103. }
  4104. }
  4105. } else {
  4106. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4107. $button = 4;
  4108. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4109. }
  4110. }
  4111. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4112. $KOP = true;
  4113. }
  4114. }
  4115. foreach ( $roleArrayCopy as $k => $v ) {
  4116. foreach ( $verifyList as $m => $n ) {
  4117. if ($n [0] == $k) {
  4118. array_splice ( $verifyList, $m, 1, $v );
  4119. }
  4120. }
  4121. }
  4122. $loanList [$key] ['verifyList'] = $verifyList;
  4123. }
  4124. $htmlLoan = '';
  4125. if (isset ( $loanList [0] )) {
  4126. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  4127. if ($value ['status'] == 1)
  4128. $htmlLoan .= '<li class="done" >';
  4129. elseif ($value ['status'] == 3)
  4130. $htmlLoan .= '<li class="undone" >';
  4131. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  4132. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  4133. if (isset ( $value ['rolename'] ))
  4134. $htmlLoan .= $value ['rolename'];
  4135. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  4136. }
  4137. $data ['loanDate'] = $loanList [0] ['date'];
  4138. }
  4139. $data ['htmlLoan'] = $htmlLoan;
  4140. $data ['loanReceiptDate'] = $loanList [0] ['date'];
  4141. // $data ['LoanReceipt']=$loanList[0];
  4142. // print_r($loanList);
  4143. $Locate = 0;
  4144. $roleId = 0;
  4145. $button = 0;
  4146. if ($ap == 4)
  4147. $status = 4;
  4148. foreach ( $receiptList as $key => $value ) {
  4149. $receiptList [$key] ['Locate'] = $Locate;
  4150. $Locate ++;
  4151. $receiptList [$key] ['reviseDetail'] = array ();
  4152. if (! empty ( $value ['reviseDetail'] ))
  4153. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4154. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4155. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4156. $categoryDetil = $Lcategory->getOne ( array (
  4157. 'where' => 'cid=' . $value ['cid'],
  4158. 'asArray' => true
  4159. ) );
  4160. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4161. // 检测编辑状态
  4162. $verifyList = $verify->getOne ( array (
  4163. 'where' => 'vid=' . $value ['verify'],
  4164. 'asArray' => true
  4165. ) );
  4166. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4167. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4168. Doo::loadModel ( 'role' );
  4169. $role = new role ();
  4170. // print_r($verifyList);
  4171. $flag = true;
  4172. $roleKey = 0;
  4173. $endStaffArray = array ();
  4174. $roleArrayCopy = array ();
  4175. foreach ( $verifyList as $k => $v ) {
  4176. // init verifyStaff
  4177. if ($v [1] == 'ROLE') {
  4178. if (! empty ( $verifyStaff )) {
  4179. $endStaffArray = end ( $verifyStaff );
  4180. if ($v [0] == $endStaffArray ['nextStaff']) {
  4181. $roleId = $v [0];
  4182. }
  4183. }
  4184. $roleVerify = json_decode ( $v [3], true );
  4185. $roleKey = $k;
  4186. $roleArray = array ();
  4187. $rolename = $role->getOne ( array (
  4188. 'where' => 'rid=' . $v [0],
  4189. 'asArray' => true
  4190. ) );
  4191. foreach ( $roleVerify as $o => $p ) {
  4192. $staffID = explode ( '_', $p );
  4193. $staffInfo = $staff->getOne ( array (
  4194. 'where' => 'sid=' . $staffID [0],
  4195. 'asArray' => true
  4196. ) );
  4197. // print_r($staffID);
  4198. $exp = array (
  4199. 0 => $staffInfo ['sid'],
  4200. 1 => $staffID [1],
  4201. 2 => $staffInfo ['avatar'],
  4202. 'date' => '',
  4203. 'date' => '',
  4204. 'opinion' => '',
  4205. 'status' => '',
  4206. 'rolename' => $rolename ['name']
  4207. );
  4208. array_push ( $roleArray, $exp );
  4209. }
  4210. $roleArrayCopy [$v [0]] = $roleArray;
  4211. // $verifyList[$k]['roleArray']=$roleArray;
  4212. }
  4213. // print_r($roleArray);
  4214. $verifyList [$k] ['date'] = "";
  4215. $verifyList [$k] ['opinion'] = "";
  4216. $verifyList [$k] ['status'] = "";
  4217. if (empty ( $verifyStaff )) {
  4218. $verifyList [$k] ['date'] = "";
  4219. $verifyList [$k] ['opinion'] = "";
  4220. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4221. $verifyList [$k] ['status'] = 4;
  4222. $button = 4;
  4223. $flag = false;
  4224. }
  4225. } else {
  4226. foreach ( $verifyStaff as $m => $u ) {
  4227. if ($v [0] == $m) {
  4228. $verifyList [$k] ['date'] = $u ['date'];
  4229. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4230. $verifyList [$k] ['status'] = $u ['status'];
  4231. $flag = false;
  4232. break;
  4233. }
  4234. }
  4235. $endStaffArray = end ( $verifyStaff );
  4236. if (isset ( $endStaffArray ['ROLE'] )) {
  4237. } else {
  4238. $endKey = key ( $verifyStaff );
  4239. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4240. $button = 4;
  4241. $verifyList [$k] ['status'] = 4;
  4242. }
  4243. }
  4244. }
  4245. }
  4246. $rolename ['name'] = '';
  4247. if (! empty ( $roleId )) {
  4248. Doo::loadModel ( 'role' );
  4249. $role = new role ();
  4250. $rolename = $role->getOne ( array (
  4251. 'where' => 'rid=' . $roleId,
  4252. 'asArray' => true
  4253. ) );
  4254. }
  4255. if (! empty ( $verifyStaff ))
  4256. $endStaffArray = end ( $verifyStaff );
  4257. $KOP = false;
  4258. foreach ( $roleArrayCopy as $P => $A ) {
  4259. foreach ( $A as $MKI => $AVL ) {
  4260. if (! empty ( $verifyStaff )) {
  4261. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4262. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4263. $button = 4;
  4264. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4265. }
  4266. foreach ( $verifyStaff as $m => $u ) {
  4267. $AVLFK = $AVL [0] . '_R';
  4268. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4269. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4270. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4271. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4272. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4273. break;
  4274. }
  4275. }
  4276. } else {
  4277. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4278. $button = 4;
  4279. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4280. }
  4281. }
  4282. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4283. $KOP = true;
  4284. }
  4285. }
  4286. foreach ( $roleArrayCopy as $k => $v ) {
  4287. foreach ( $verifyList as $m => $n ) {
  4288. if ($n [0] == $k) {
  4289. array_splice ( $verifyList, $m, 1, $v );
  4290. }
  4291. }
  4292. }
  4293. // print_r($verifyList);
  4294. $receiptList [$key] ['verifyList'] = $verifyList;
  4295. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4296. 'where' => 'sid=' . $value ['staff'],
  4297. 'asArray' => true
  4298. ) );
  4299. $receiptList [$key] ['button'] = $button;
  4300. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4301. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4302. $relust = $value ['sum'] - $value ['loanSum'];
  4303. $receiptList [$key] ['relust'] = $relust;
  4304. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4305. }
  4306. // print_r($receiptList);die;
  4307. // $data['verifyDetail']=$verifyDetail;
  4308. $mothHtml = "";
  4309. for($i = 1; $i <= 12; $i ++) {
  4310. if ($month == $i)
  4311. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4312. else
  4313. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4314. }
  4315. // 获取审批日志
  4316. Doo::loadModel ( 'receiptLog' );
  4317. $receiptLog = new receiptLog ();
  4318. $rlList = array ();
  4319. $rlInfo = $receiptLog->getOne ( array (
  4320. 'where' => 'rid=' . $rid . ' and status=4',
  4321. 'asArray' => true
  4322. ) );
  4323. $tijdate = $receiptLog->getOne ( array (
  4324. 'where' => 'rid=' . $rid . ' and status=2',
  4325. 'asc' => 'rlid',
  4326. 'asArray' => true
  4327. ) );
  4328. if (! empty ( $rlInfo )) {
  4329. $rlList = $receiptLog->find ( array (
  4330. 'where' => 'rid=' . $rid,
  4331. 'asc' => 'rlid',
  4332. 'asArray' => true
  4333. ) );
  4334. }
  4335. // echo $rid;
  4336. // print_r($receiptList);
  4337. $receiptList [0] ['rlList'] = $rlList;
  4338. // print_r($receiptList);
  4339. $enclosurList = $enclosur->find ( array (
  4340. 'where' => 'rid=' . $rid,
  4341. 'asArray' => true
  4342. ) );
  4343. $enclosurHtml = '';
  4344. foreach ( $enclosurList as $value ) {
  4345. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4346. }
  4347. $data ['enclosurHtml'] = $enclosurHtml;
  4348. $data ['rolename'] = $rolename ['name'];
  4349. $data ['mothHtml'] = $mothHtml;
  4350. // print_r($receiptList);
  4351. $data ['rid'] = $rid;
  4352. $data ['tijdate'] = $tijdate ['date'];
  4353. $data ['receiptList'] = $receiptList;
  4354. $data ['receiptApprovalCount'] = count ( $receiptList );
  4355. $data ['status'] = $status;
  4356. $data ['year'] = $year;
  4357. $data ['categoryList'] = $categoryList;
  4358. $data ['staffList'] = $staffList;
  4359. $data ['cid'] = $cid;
  4360. $data ['sid'] = $sid;
  4361. $data ['ap'] = $ap;
  4362. $data ['memu'] = "receipt";
  4363. $data ['staff'] = $this->staff;
  4364. $data ['receiptMemu'] = 'approvalExpenses';
  4365. $data ['verifyId'] = $this->verifyId;
  4366. $data ['executeId'] = $this->executeId;
  4367. $this->render ( "/admin/receiptburEdi", $data );
  4368. }
  4369. function hisImplement() {
  4370. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4371. if (empty ( $item ))
  4372. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "pendImplement";
  4373. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  4374. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4375. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  4376. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  4377. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  4378. Doo::loadModel ( 'receipt' );
  4379. $receipt = new receipt ();
  4380. Doo::loadModel ( 'L_category' );
  4381. $Lcategory = new L_category ();
  4382. Doo::loadModel ( 'verify' );
  4383. Doo::loadModel ( 'statistics' );
  4384. $statistics = new statistics ();
  4385. $verify = new verify ();
  4386. Doo::loadModel ( 'staff' );
  4387. $staff = new staff ();
  4388. Doo::loadClass ( 'XDeode' );
  4389. $XDeode = new XDeode ( 5 );
  4390. $condition = "";
  4391. if ($item == "expenses")
  4392. $condition = " and Rtype=1 ";
  4393. elseif ($item == "receipts")
  4394. $condition = " and Rtype=0 ";
  4395. elseif ($item == "remits")
  4396. $condition = " and Rtype=2 ";
  4397. elseif ($item == "pendImplement") {
  4398. $condition = ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  4399. }
  4400. // 'and (executeCopy like "%["' . $this->staff [0] ['sid'] . '"%" and executeStaff not like "%{"' . $this->staff [0] ['sid'] . '"%" )';
  4401. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  4402. $sopString = "";
  4403. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  4404. if (empty ( $rdate ))
  4405. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  4406. else
  4407. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  4408. if ($item == 'teipts') {
  4409. $statusCon = '(status=1 or status=6 )';
  4410. $dateCondition = " and date_format(pastDate,'%Y-%m-%d')='" . $rdate . "' ";
  4411. } elseif ($item == 'alerpts') {
  4412. $statusCon = '(status=8 or status=9 )';
  4413. if (empty ( $rdate ))
  4414. $dateCondition = " and Year(date) =" . $year;
  4415. else
  4416. $dateCondition = " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  4417. }
  4418. /*
  4419. * 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; }
  4420. */
  4421. if ($sop != 'SOP')
  4422. $sopString = " and staff=" . $sop;
  4423. // $noPassSum=$receipt->receiptByYear($year,$this->staff[0]['sid']); and (status=1 or status=6)
  4424. $receiptList = $receipt->find ( array (
  4425. 'where' => $statusCon . $condition . $dateCondition . $sopString,
  4426. 'desc' => 'rid',
  4427. 'asArray' => true
  4428. ) );
  4429. // 员工筛选
  4430. $receiptList2 = $receipt->find ( array (
  4431. 'where' => $statusCon . $condition . $dateCondition,
  4432. 'desc' => 'rid',
  4433. 'asArray' => true
  4434. ) );
  4435. $sopStaff = array ();
  4436. foreach ( $receiptList2 as $key => $value ) {
  4437. $staffDetail = $staff->getOne ( array (
  4438. 'where' => 'sid=' . $value ['staff'],
  4439. 'asArray' => true
  4440. ) );
  4441. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  4442. }
  4443. $Locate = 0;
  4444. $roleId = 0;
  4445. $button = 0;
  4446. foreach ( $receiptList as $key => $value ) {
  4447. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4448. $receiptList [$key] ['Texe'] = 'false';
  4449. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  4450. $receiptList [$key] ['Texe'] = 'true';
  4451. }
  4452. $receiptList [$key] ['TRexe'] = 'true';
  4453. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  4454. $receiptList [$key] ['TRexe'] = 'false';
  4455. }
  4456. $receiptList [$key] ['Locate'] = $Locate;
  4457. $Locate ++;
  4458. $receiptList [$key] ['reviseDetail'] = array ();
  4459. if (! empty ( $value ['reviseDetail'] ))
  4460. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4461. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4462. $categoryDetil = $Lcategory->getOne ( array (
  4463. 'where' => 'cid=' . $value ['cid'],
  4464. 'asArray' => true
  4465. ) );
  4466. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4467. // 检测编辑状态
  4468. $verifyList = $verify->getOne ( array (
  4469. 'where' => 'vid=' . $value ['verify'],
  4470. 'asArray' => true
  4471. ) );
  4472. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4473. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4474. Doo::loadModel ( 'role' );
  4475. $role = new role ();
  4476. $flag = true;
  4477. $roleKey = 0;
  4478. $endStaffArray = array ();
  4479. $roleArrayCopy = array ();
  4480. foreach ( $verifyList as $k => $v ) {
  4481. // init verifyStaff
  4482. if ($v [1] == 'ROLE') {
  4483. if (! empty ( $verifyStaff )) {
  4484. $endStaffArray = end ( $verifyStaff );
  4485. }
  4486. $roleVerify = json_decode ( $v [3], true );
  4487. $roleKey = $k;
  4488. $roleArray = array ();
  4489. $rolename = $role->getOne ( array (
  4490. 'where' => 'rid=' . $v [0],
  4491. 'asArray' => true
  4492. ) );
  4493. foreach ( $roleVerify as $o => $p ) {
  4494. $staffID = explode ( '_', $p );
  4495. $staffInfo = $staff->getOne ( array (
  4496. 'where' => 'sid=' . $staffID [0],
  4497. 'asArray' => true
  4498. ) );
  4499. $exp = array (
  4500. 0 => $staffInfo ['sid'],
  4501. 1 => $staffID [1],
  4502. 2 => $staffInfo ['avatar'],
  4503. 'date' => '',
  4504. 'date' => '',
  4505. 'opinion' => '',
  4506. 'status' => '',
  4507. 'rolename' => $rolename ['name']
  4508. );
  4509. array_push ( $roleArray, $exp );
  4510. }
  4511. $roleArrayCopy [$v [0]] = $roleArray;
  4512. }
  4513. $verifyList [$k] ['date'] = "";
  4514. $verifyList [$k] ['opinion'] = "";
  4515. $verifyList [$k] ['status'] = "";
  4516. if (empty ( $verifyStaff )) {
  4517. $verifyList [$k] ['date'] = "";
  4518. $verifyList [$k] ['opinion'] = "";
  4519. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4520. $verifyList [$k] ['status'] = 4;
  4521. $flag = false;
  4522. }
  4523. } else {
  4524. foreach ( $verifyStaff as $m => $u ) {
  4525. if ($v [0] == $m) {
  4526. $verifyList [$k] ['date'] = $u ['date'];
  4527. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4528. $verifyList [$k] ['status'] = $u ['status'];
  4529. $flag = false;
  4530. break;
  4531. }
  4532. }
  4533. $endStaffArray = end ( $verifyStaff );
  4534. }
  4535. }
  4536. $rolename ['name'] = '';
  4537. if (! empty ( $roleId )) {
  4538. Doo::loadModel ( 'role' );
  4539. $role = new role ();
  4540. $rolename = $role->getOne ( array (
  4541. 'where' => 'rid=' . $roleId,
  4542. 'asArray' => true
  4543. ) );
  4544. }
  4545. if (! empty ( $verifyStaff ))
  4546. $endStaffArray = end ( $verifyStaff );
  4547. $KOP = false;
  4548. foreach ( $roleArrayCopy as $P => $A ) {
  4549. foreach ( $A as $MKI => $AVL ) {
  4550. if (! empty ( $verifyStaff )) {
  4551. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4552. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4553. $button = 4;
  4554. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4555. }
  4556. foreach ( $verifyStaff as $m => $u ) {
  4557. $AVLFK = $AVL [0] . '_R';
  4558. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4559. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4560. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4561. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4562. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4563. break;
  4564. }
  4565. }
  4566. } else {
  4567. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4568. $button = 4;
  4569. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4570. }
  4571. }
  4572. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4573. $KOP = true;
  4574. }
  4575. }
  4576. foreach ( $roleArrayCopy as $k => $v ) {
  4577. foreach ( $verifyList as $m => $n ) {
  4578. if ($n [0] == $k) {
  4579. array_splice ( $verifyList, $m, 1, $v );
  4580. }
  4581. }
  4582. }
  4583. $receiptList [$key] ['verifyList'] = $verifyList;
  4584. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4585. 'where' => 'sid=' . $value ['staff'],
  4586. 'asArray' => true
  4587. ) );
  4588. $receiptList [$key] ['button'] = $button;
  4589. }
  4590. // print_r($receiptList);
  4591. $mothHtml = "";
  4592. for($i = 1; $i <= 12; $i ++) {
  4593. if ($moth == $i)
  4594. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4595. else
  4596. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4597. }
  4598. $dayHtml = "";
  4599. if ($day != "DAY" || $moth != "MONTH") {
  4600. for($i = 1; $i <= 31; $i ++) {
  4601. if ($day == $i)
  4602. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  4603. else
  4604. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  4605. }
  4606. }
  4607. $sopHtml = "";
  4608. foreach ( $sopStaff as $key => $value ) {
  4609. if ($sop == $key)
  4610. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4611. else
  4612. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4613. }
  4614. $data ['rdate'] = $rdate;
  4615. $data ['sopHtml'] = $sopHtml;
  4616. $data ['dayHtml'] = $dayHtml;
  4617. $data ['mothHtml'] = $mothHtml;
  4618. $data ['receiptList'] = $receiptList;
  4619. $data ['memu'] = "receipt";
  4620. $data ['staff'] = $this->staff;
  4621. $data ['receiptMemu'] = 'implement';
  4622. $data ['verifyId'] = $this->verifyId;
  4623. $data ['executeId'] = $this->executeId;
  4624. $data ['item'] = $item;
  4625. $data ['year'] = $year;
  4626. $data ['moth'] = $moth;
  4627. $data ['day'] = $day;
  4628. $data ['sop'] = $sop;
  4629. $this->render ( "/admin/hisImplement", $data );
  4630. }
  4631. function ajaxExamine() {
  4632. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4633. Doo::loadModel ( 'receipt' );
  4634. $receipt = new receipt ();
  4635. if (! empty ( $rid )) {
  4636. $rLRes = $receipt->find ( array (
  4637. '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,
  4638. 'asArray' => true
  4639. ) );
  4640. echo json_encode ( array (
  4641. 'status' => 1,
  4642. 'receipt' => $rLRes [0]
  4643. ) );
  4644. die ();
  4645. }
  4646. echo json_encode ( array (
  4647. 'status' => 0,
  4648. 'receipt' => array ()
  4649. ) );
  4650. die ();
  4651. }
  4652. /*
  4653. * 废弃
  4654. */
  4655. function myReceipt() {
  4656. // all approval past withdraw
  4657. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4658. if (empty ( $item ))
  4659. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4660. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4661. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  4662. Doo::loadModel ( 'receipt' );
  4663. $receipt = new receipt ();
  4664. // pre-loaded
  4665. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4666. // have cache
  4667. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  4668. if (! empty ( $moth )) // yearPage
  4669. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  4670. $this->showCache ( $path );
  4671. }
  4672. Doo::loadModel ( 'L_category' );
  4673. $Lcategory = new L_category ();
  4674. Doo::loadModel ( 'verify' );
  4675. Doo::loadModel ( 'statistics' );
  4676. $statistics = new statistics ();
  4677. $verify = new verify ();
  4678. Doo::loadModel ( 'staff' );
  4679. $staff = new staff ();
  4680. $condition = " and status!=0 ";
  4681. if ($item == "approval")
  4682. $condition = " and status=2 ";
  4683. elseif ($item == "withdraw")
  4684. $condition = " and status=3 ";
  4685. elseif ($item == "past")
  4686. $condition = " and status=1 ";
  4687. elseif ($item == "whdw")
  4688. $condition = " and status=4 ";
  4689. $dateCondition = " and Year(date) =" . $year;
  4690. if (! empty ( $moth )) {
  4691. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  4692. $stList = $statistics->getOne ( array (
  4693. 'select' => 'rePrice ,agPrice',
  4694. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  4695. 'asArray' => true
  4696. ) );
  4697. } else
  4698. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  4699. if (empty ( $stList ))
  4700. $stList = array (
  4701. 'rePrice' => 0,
  4702. 'agPrice' => 0
  4703. );
  4704. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  4705. $data ['stList'] = array (
  4706. 'rePrice' => $stList ['rePrice'],
  4707. 'agPrice' => $stList ['agPrice'],
  4708. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  4709. );
  4710. $receiptList = $receipt->find ( array (
  4711. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  4712. 'desc' => 'rid',
  4713. 'asArray' => true
  4714. ) );
  4715. $Locate = 0;
  4716. $roleId = 0;
  4717. $button = 0;
  4718. foreach ( $receiptList as $key => $value ) {
  4719. $receiptList [$key] ['Locate'] = $Locate;
  4720. $Locate ++;
  4721. $receiptList [$key] ['reviseDetail'] = array ();
  4722. if (! empty ( $value ['reviseDetail'] ))
  4723. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4724. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4725. $categoryDetil = $Lcategory->getOne ( array (
  4726. 'where' => 'cid=' . $value ['cid'],
  4727. 'asArray' => true
  4728. ) );
  4729. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4730. // 检测编辑状态
  4731. $verifyList = $verify->getOne ( array (
  4732. 'where' => 'vid=' . $value ['verify'],
  4733. 'asArray' => true
  4734. ) );
  4735. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4736. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4737. Doo::loadModel ( 'role' );
  4738. $role = new role ();
  4739. $flag = true;
  4740. $roleKey = 0;
  4741. $endStaffArray = array ();
  4742. $roleArrayCopy = array ();
  4743. foreach ( $verifyList as $k => $v ) {
  4744. // init verifyStaff
  4745. if ($v [1] == 'ROLE') {
  4746. if (! empty ( $verifyStaff )) {
  4747. $endStaffArray = end ( $verifyStaff );
  4748. // if ($v[0]==$endStaffArray['nextStaff']){
  4749. // $roleId=$v[0];
  4750. // }
  4751. }
  4752. $roleVerify = json_decode ( $v [3], true );
  4753. $roleKey = $k;
  4754. $roleArray = array ();
  4755. $rolename = $role->getOne ( array (
  4756. 'where' => 'rid=' . $v [0],
  4757. 'asArray' => true
  4758. ) );
  4759. foreach ( $roleVerify as $o => $p ) {
  4760. $staffID = explode ( '_', $p );
  4761. $staffInfo = $staff->getOne ( array (
  4762. 'where' => 'sid=' . $staffID [0],
  4763. 'asArray' => true
  4764. ) );
  4765. // print_r($staffID);
  4766. $exp = array (
  4767. 0 => $staffInfo ['sid'],
  4768. 1 => $staffID [1],
  4769. 2 => $staffInfo ['avatar'],
  4770. 'date' => '',
  4771. 'date' => '',
  4772. 'opinion' => '',
  4773. 'status' => '',
  4774. 'rolename' => $rolename ['name']
  4775. );
  4776. array_push ( $roleArray, $exp );
  4777. }
  4778. $roleArrayCopy [$v [0]] = $roleArray;
  4779. // $verifyList[$k]['roleArray']=$roleArray;
  4780. }
  4781. $verifyList [$k] ['date'] = "";
  4782. $verifyList [$k] ['opinion'] = "";
  4783. $verifyList [$k] ['status'] = "";
  4784. if (empty ( $verifyStaff )) {
  4785. $verifyList [$k] ['date'] = "";
  4786. $verifyList [$k] ['opinion'] = "";
  4787. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4788. $verifyList [$k] ['status'] = 4;
  4789. $flag = false;
  4790. }
  4791. } else {
  4792. foreach ( $verifyStaff as $m => $u ) {
  4793. if ($v [0] == $m) {
  4794. $verifyList [$k] ['date'] = $u ['date'];
  4795. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4796. $verifyList [$k] ['status'] = $u ['status'];
  4797. $flag = false;
  4798. break;
  4799. }
  4800. }
  4801. $endStaffArray = end ( $verifyStaff );
  4802. if (isset ( $endStaffArray ['ROLE'] )) {
  4803. } else {
  4804. // $endKey=key($verifyStaff);
  4805. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4806. // $button=4;
  4807. // $verifyList[$k]['status']=4;
  4808. // }
  4809. }
  4810. }
  4811. }
  4812. $rolename ['name'] = '';
  4813. if (! empty ( $roleId )) {
  4814. Doo::loadModel ( 'role' );
  4815. $role = new role ();
  4816. $rolename = $role->getOne ( array (
  4817. 'where' => 'rid=' . $roleId,
  4818. 'asArray' => true
  4819. ) );
  4820. }
  4821. if (! empty ( $verifyStaff ))
  4822. $endStaffArray = end ( $verifyStaff );
  4823. $KOP = false;
  4824. foreach ( $roleArrayCopy as $P => $A ) {
  4825. foreach ( $A as $MKI => $AVL ) {
  4826. if (! empty ( $verifyStaff )) {
  4827. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4828. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4829. $button = 4;
  4830. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4831. }
  4832. foreach ( $verifyStaff as $m => $u ) {
  4833. $AVLFK = $AVL [0] . '_R';
  4834. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4835. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4836. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4837. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4838. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4839. break;
  4840. }
  4841. }
  4842. } else {
  4843. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4844. $button = 4;
  4845. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4846. }
  4847. }
  4848. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4849. $KOP = true;
  4850. }
  4851. }
  4852. foreach ( $roleArrayCopy as $k => $v ) {
  4853. foreach ( $verifyList as $m => $n ) {
  4854. if ($n [0] == $k) {
  4855. array_splice ( $verifyList, $m, 1, $v );
  4856. }
  4857. }
  4858. }
  4859. $receiptList [$key] ['verifyList'] = $verifyList;
  4860. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4861. 'where' => 'sid=' . $value ['staff'],
  4862. 'asArray' => true
  4863. ) );
  4864. $receiptList [$key] ['button'] = $button;
  4865. }
  4866. // print_r($receiptList);die;
  4867. $mothHtml = "";
  4868. for($i = 1; $i <= 12; $i ++) {
  4869. if ($moth == $i)
  4870. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4871. else
  4872. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4873. }
  4874. $data ['mothHtml'] = $mothHtml;
  4875. $data ['receiptList'] = $receiptList;
  4876. $data ['memu'] = "receipt";
  4877. $data ['staff'] = $this->staff;
  4878. $data ['receiptMemu'] = 'receipt';
  4879. $data ['verifyId'] = $this->verifyId;
  4880. $data ['executeId'] = $this->executeId;
  4881. $data ['item'] = $item;
  4882. $data ['year'] = $year;
  4883. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4884. // sufficient condition to generate cache
  4885. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  4886. $receiptList = $receipt->find ( array (
  4887. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  4888. 'asArray' => true
  4889. ) );
  4890. if (empty ( $receiptList )) { // generated files
  4891. ob_start ();
  4892. $this->render ( "/admin/saea_myList", $data );
  4893. $this->cacheFile ( $path );
  4894. die ();
  4895. // $content = ob_get_contents();
  4896. // $fp = fopen($path, "w");
  4897. // fwrite($fp, $content);
  4898. // fclose($fp);
  4899. }
  4900. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  4901. $receiptList = $receipt->find ( array (
  4902. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  4903. 'asArray' => true
  4904. ) );
  4905. if (empty ( $receiptList )) { // generated files
  4906. ob_start ();
  4907. $this->render ( "/admin/saea_myList", $data );
  4908. $this->cacheFile ( $path );
  4909. die ();
  4910. }
  4911. }
  4912. }
  4913. $this->render ( "/admin/saea_myList", $data );
  4914. }
  4915. function saeaCreate() {
  4916. Doo::loadModel ( 'accountItem' );
  4917. Doo::loadModel ( 'verify' );
  4918. Doo::loadModel ( 'receipt' );
  4919. Doo::loadModel ( 'L_category' );
  4920. $lCategory = new L_category ();
  4921. $receipt = new receipt ();
  4922. $verify = new verify ();
  4923. $accountItem = new accountItem ();
  4924. Doo::loadModel ( "role" );
  4925. $role = new role ();
  4926. $acItem = $accountItem->find ( array (
  4927. 'asArray' => true
  4928. ) );
  4929. $veList = $verify->find ( array (
  4930. 'asArray' => true
  4931. ) );
  4932. foreach ( $veList as $key => $value ) {
  4933. $v = json_decode ( $value ['staff'] );
  4934. $list = array ();
  4935. foreach ( $v as $n => $m ) {
  4936. if ($m ['1'] == 'ROLE') {
  4937. $roleInfo = $role->getOne ( array (
  4938. 'where' => 'rid=' . $m [0],
  4939. 'asArray' => true
  4940. ) );
  4941. $v [$n] [1] = $roleInfo ['name'];
  4942. array_push ( $list, $roleInfo ['name'] );
  4943. } else {
  4944. array_push ( $list, $v [$n] [1] );
  4945. }
  4946. }
  4947. $veList [$key] ['staff'] = implode ( '>', $list );
  4948. }
  4949. $data ['category'] = $lCategory->find ( array (
  4950. 'asArray' => true
  4951. ) );
  4952. $data ['veList'] = $veList;
  4953. $data ['acItem'] = $acItem;
  4954. $data ['memu'] = "receipt";
  4955. $data ['staff'] = $this->staff;
  4956. $data ['receiptMemu'] = 'saeaBorad';
  4957. $data ['verifyId'] = $this->verifyId;
  4958. $data ['executeId'] = $this->executeId;
  4959. $this->render ( "/admin/saea_create", $data );
  4960. }
  4961. function addReceipt() {
  4962. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  4963. $agency = $this->get_args ( 'agency' );
  4964. $travel = $this->get_args ( 'travel' );
  4965. $train = $this->get_args ( 'train' );
  4966. $other = $this->get_args ( 'other' );
  4967. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  4968. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  4969. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  4970. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  4971. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  4972. Doo::loadModel ( 'receipt' );
  4973. Doo::loadModel ( 'receiptDetail' );
  4974. Doo::loadModel ( 'accountItem' );
  4975. $accountItem = new accountItem ();
  4976. $receipt = new receipt ();
  4977. Doo::loadModel ( 'enclosur' );
  4978. Doo::loadModel ( 'execute' );
  4979. $execute = new execute ();
  4980. $executeDetail = $execute->getOne ( array (
  4981. 'where' => 'mold="报销单执行人"',
  4982. 'asArray' => true
  4983. ) );
  4984. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  4985. // if(!empty($receiptDetail))
  4986. // return "/referReceipt/".$receiptDetail['rid'];
  4987. $aItem = $accountItem->find ( array (
  4988. 'asArray' => true
  4989. ) );
  4990. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  4991. $ag = $tr = $ta = $ot = 0;
  4992. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  4993. foreach ( $aItem as $key => $value ) {
  4994. if ($value ['category'] == $this->AGENCY) {
  4995. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  4996. array_push ( $accountJson [$this->AGENCY], array (
  4997. 'aid' => $value ['aid'],
  4998. 'name' => $value ['name'],
  4999. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5000. ) );
  5001. $sum += $agency [$ag];
  5002. $agencySum += $agency [$ag];
  5003. }
  5004. $ag ++;
  5005. }
  5006. if ($value ['category'] == $this->TRAVEL) {
  5007. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5008. array_push ( $accountJson [$this->TRAVEL], array (
  5009. 'aid' => $value ['aid'],
  5010. 'name' => $value ['name'],
  5011. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5012. ) );
  5013. $sum += $travel [$tr];
  5014. $travelSum += $travel [$tr];
  5015. }
  5016. $tr ++;
  5017. }
  5018. if ($value ['category'] == $this->TRAIN) {
  5019. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5020. array_push ( $accountJson [$this->TRAIN], array (
  5021. 'aid' => $value ['aid'],
  5022. 'name' => $value ['name'],
  5023. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5024. ) );
  5025. $sum += $train [$ta];
  5026. $trainSum += $train [$ta];
  5027. }
  5028. $ta ++;
  5029. }
  5030. if ($value ['category'] == $this->OTHER) {
  5031. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5032. array_push ( $accountJson [$this->OTHER], array (
  5033. 'aid' => $value ['aid'],
  5034. 'name' => $value ['name'],
  5035. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5036. ) );
  5037. $sum += $other [$ot];
  5038. $otherSum += $other [$ot];
  5039. }
  5040. $ot ++;
  5041. }
  5042. }
  5043. $accountJson ['cSum'] = array (
  5044. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5045. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5046. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5047. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5048. );
  5049. // 报销单
  5050. $receipt->accountItem = json_encode ( $accountJson );
  5051. $receipt->staff = $this->staff [0] ['sid'];
  5052. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5053. $receipt->date = date ( "Y-m-d" );
  5054. $receipt->cid = $cid;
  5055. $receipt->status = 5;
  5056. // 修改审批流程加入角色
  5057. $receipt->verify = $verify;
  5058. $receipt->executeCopy = $executeDetail ['staff'];
  5059. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  5060. $receipt->explanation = $explanation;
  5061. $rid = $receipt->insert ();
  5062. // 附件
  5063. if (! empty ( $enclosurName )) {
  5064. $enclosurArray = explode ( '-', $enclosurName );
  5065. foreach ( $enclosurArray as $value ) {
  5066. $enclosur = new enclosur ();
  5067. $enclosur->name = $value;
  5068. $enclosur->rid = $rid;
  5069. $enclosur->insert ();
  5070. }
  5071. // print_r($enclosurArray);die;
  5072. }
  5073. // 报销详情
  5074. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5075. $receiptDetail = new receiptDetail ();
  5076. $receiptDetail->staff = $this->staff [0] ['sid'];
  5077. $receiptDetail->item = $value ['name'];
  5078. $receiptDetail->itemCategory = $this->AGENCY;
  5079. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5080. $receiptDetail->date = date ( "Y-m-d" );
  5081. $receiptDetail->cid = $cid;
  5082. $receiptDetail->rid = $rid;
  5083. $receiptDetail->status = 4;
  5084. $receiptDetail->insert ();
  5085. }
  5086. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5087. $receiptDetail = new receiptDetail ();
  5088. $receiptDetail->staff = $this->staff [0] ['sid'];
  5089. $receiptDetail->item = $value ['name'];
  5090. $receiptDetail->itemCategory = $this->TRAVEL;
  5091. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5092. $receiptDetail->date = date ( "Y-m-d" );
  5093. $receiptDetail->cid = $cid;
  5094. $receiptDetail->rid = $rid;
  5095. $receiptDetail->status = 4;
  5096. $receiptDetail->insert ();
  5097. }
  5098. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5099. $receiptDetail = new receiptDetail ();
  5100. $receiptDetail->staff = $this->staff [0] ['sid'];
  5101. $receiptDetail->item = $value ['name'];
  5102. $receiptDetail->itemCategory = $this->TRAIN;
  5103. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5104. $receiptDetail->date = date ( "Y-m-d" );
  5105. $receiptDetail->cid = $cid;
  5106. $receiptDetail->rid = $rid;
  5107. $receiptDetail->status = 4;
  5108. $receiptDetail->insert ();
  5109. }
  5110. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5111. $receiptDetail = new receiptDetail ();
  5112. $receiptDetail->staff = $this->staff [0] ['sid'];
  5113. $receiptDetail->item = $value ['name'];
  5114. $receiptDetail->itemCategory = $this->OTHER;
  5115. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5116. $receiptDetail->date = date ( "Y-m-d" );
  5117. $receiptDetail->cid = $cid;
  5118. $receiptDetail->rid = $rid;
  5119. $receiptDetail->status = 4;
  5120. $receiptDetail->insert ();
  5121. }
  5122. return "/saeaBorad";
  5123. } else
  5124. die ( 'illegal request' );
  5125. }
  5126. function referReceipt() {
  5127. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  5128. Doo::loadModel ( 'receipt' );
  5129. Doo::loadModel ( 'verify' );
  5130. $verify = new verify ();
  5131. $receipt = new receipt ();
  5132. Doo::loadModel ( 'L_category' );
  5133. $lCategory = new L_category ();
  5134. Doo::loadModel ( "role" );
  5135. $role = new role ();
  5136. $receiptDetail = $receipt->find ( array (
  5137. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  5138. 'asArray' => true
  5139. ) );
  5140. if (empty ( $receiptDetail ))
  5141. return "/addReceipt";
  5142. foreach ( $receiptDetail as $key => $value ) {
  5143. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5144. $veList = $verify->getOne ( array (
  5145. 'where' => 'vid=' . $value ['verify'],
  5146. 'asArray' => true
  5147. ) );
  5148. $v = json_decode ( $veList ['staff'] );
  5149. array_push ( $v [0], $veList ['description'] );
  5150. foreach ( $v as $n => $m ) {
  5151. if ($m ['1'] == 'ROLE') {
  5152. $roleInfo = $role->getOne ( array (
  5153. 'where' => 'rid=' . $m [0],
  5154. 'asArray' => true
  5155. ) );
  5156. $v [$n] [1] = $roleInfo ['name'];
  5157. }
  5158. }
  5159. $receiptDetail [$key] ['staff'] = $v;
  5160. $category = $lCategory->getOne ( array (
  5161. 'where' => 'cid=' . $value ['cid'],
  5162. 'asArray' => true
  5163. ) );
  5164. $receiptDetail [$key] ['category'] = $category ['title'];
  5165. }
  5166. // print_r($receiptDetail);
  5167. $data ['receiptDetail'] = $receiptDetail;
  5168. $data ['memu'] = "receipt";
  5169. $data ['staff'] = $this->staff;
  5170. $data ['receiptMemu'] = 'saeaCreate';
  5171. $data ['verifyId'] = $this->verifyId;
  5172. $data ['executeId'] = $this->executeId;
  5173. $this->render ( "/admin/saea_confirm", $data );
  5174. }
  5175. function editReceipt() {
  5176. // edit status 4
  5177. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  5178. Doo::loadClass ( 'XDeode' );
  5179. $XDeode = new XDeode ( 7 );
  5180. $rid = $XDeode->decode ( $rid );
  5181. if (empty ( $rid ))
  5182. die ( 'illegal request' );
  5183. // echo $rid.'sd';
  5184. Doo::loadModel ( 'accountItem' );
  5185. Doo::loadModel ( 'verify' );
  5186. Doo::loadModel ( 'receipt' );
  5187. $receipt = new receipt ();
  5188. $verify = new verify ();
  5189. $accountItem = new accountItem ();
  5190. Doo::loadModel ( 'L_category' );
  5191. $lCategory = new L_category ();
  5192. Doo::loadModel ( "role" );
  5193. $role = new role ();
  5194. $receiptDetail = $receipt->getOne ( array (
  5195. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  5196. 'asArray' => true
  5197. ) );
  5198. if (empty ( $receiptDetail ))
  5199. die ( 'illegal request' );
  5200. $acItem = $accountItem->find ( array (
  5201. 'asArray' => true
  5202. ) );
  5203. $veList = $verify->find ( array (
  5204. 'asArray' => true
  5205. ) );
  5206. foreach ( $veList as $key => $value ) {
  5207. $v = json_decode ( $value ['staff'] );
  5208. $list = array ();
  5209. foreach ( $v as $n => $m ) {
  5210. if ($m ['1'] == 'ROLE') {
  5211. $roleInfo = $role->getOne ( array (
  5212. 'where' => 'rid=' . $m [0],
  5213. 'asArray' => true
  5214. ) );
  5215. $v [$n] [1] = $roleInfo ['name'];
  5216. array_push ( $list, $roleInfo ['name'] );
  5217. } else {
  5218. array_push ( $list, $v [$n] [1] );
  5219. }
  5220. }
  5221. $veList [$key] ['staff'] = implode ( '>', $list );
  5222. }
  5223. // 配置编辑信息
  5224. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  5225. foreach ( $acItem as $key => $value ) {
  5226. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  5227. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  5228. $acItem [$key] ['price'] = $v ['price'];
  5229. }
  5230. }
  5231. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  5232. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  5233. $acItem [$key] ['price'] = $v ['price'];
  5234. }
  5235. }
  5236. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  5237. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  5238. $acItem [$key] ['price'] = $v ['price'];
  5239. }
  5240. }
  5241. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  5242. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  5243. $acItem [$key] ['price'] = $v ['price'];
  5244. }
  5245. }
  5246. }
  5247. $data ['category'] = $lCategory->find ( array (
  5248. 'asArray' => true
  5249. ) );
  5250. $data ['cSum'] = $accountItemList ['cSum'];
  5251. $data ['sum'] = $receiptDetail ['sum'];
  5252. $data ['receiptDetail'] = $receiptDetail;
  5253. $data ['veList'] = $veList;
  5254. $data ['acItem'] = $acItem;
  5255. $data ['memu'] = "receipt";
  5256. $data ['staff'] = $this->staff;
  5257. $data ['receiptMemu'] = 'saeaBorad';
  5258. $data ['verify'] = $receiptDetail ['verify'];
  5259. $data ['verifyId'] = $this->verifyId;
  5260. $data ['executeId'] = $this->executeId;
  5261. $data ['rid'] = $rid;
  5262. $this->render ( "/admin/saea_edit", $data );
  5263. }
  5264. function updateReceipt() {
  5265. $agency = $this->get_args ( 'agency' );
  5266. $travel = $this->get_args ( 'travel' );
  5267. $train = $this->get_args ( 'train' );
  5268. $other = $this->get_args ( 'other' );
  5269. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5270. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5271. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5272. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5273. if (! empty ( $explanation )) {
  5274. Doo::loadModel ( 'receipt' );
  5275. Doo::loadModel ( 'receiptDetail' );
  5276. Doo::loadModel ( 'accountItem' );
  5277. $accountItem = new accountItem ();
  5278. $receipt = new receipt ();
  5279. Doo::loadModel ( 'execute' );
  5280. $execute = new execute ();
  5281. $receiptDetail = $receipt->getOne ( array (
  5282. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  5283. 'asArray' => true
  5284. ) );
  5285. if (empty ( $receiptDetail ))
  5286. return "/saeaBorad";
  5287. if ($receiptDetail ['Rtype'] == 1)
  5288. $executeDetail = $execute->getOne ( array (
  5289. 'where' => 'mold="借款费用执行人"',
  5290. 'asArray' => true
  5291. ) );
  5292. else
  5293. $executeDetail = $execute->getOne ( array (
  5294. 'where' => 'mold="报销单执行人"',
  5295. 'asArray' => true
  5296. ) );
  5297. $aItem = $accountItem->find ( array (
  5298. 'asArray' => true
  5299. ) );
  5300. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5301. $ag = $tr = $ta = $ot = 0;
  5302. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5303. foreach ( $aItem as $key => $value ) {
  5304. if ($value ['category'] == $this->AGENCY) {
  5305. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5306. array_push ( $accountJson [$this->AGENCY], array (
  5307. 'aid' => $value ['aid'],
  5308. 'name' => $value ['name'],
  5309. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5310. ) );
  5311. $sum += $agency [$ag];
  5312. $agencySum += $agency [$ag];
  5313. }
  5314. $ag ++;
  5315. }
  5316. if ($value ['category'] == $this->TRAVEL) {
  5317. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5318. array_push ( $accountJson [$this->TRAVEL], array (
  5319. 'aid' => $value ['aid'],
  5320. 'name' => $value ['name'],
  5321. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5322. ) );
  5323. $sum += $travel [$tr];
  5324. $travelSum += $travel [$tr];
  5325. }
  5326. $tr ++;
  5327. }
  5328. if ($value ['category'] == $this->TRAIN) {
  5329. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5330. array_push ( $accountJson [$this->TRAIN], array (
  5331. 'aid' => $value ['aid'],
  5332. 'name' => $value ['name'],
  5333. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5334. ) );
  5335. $sum += $train [$ta];
  5336. $trainSum += $train [$ta];
  5337. }
  5338. $ta ++;
  5339. }
  5340. if ($value ['category'] == $this->OTHER) {
  5341. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5342. array_push ( $accountJson [$this->OTHER], array (
  5343. 'aid' => $value ['aid'],
  5344. 'name' => $value ['name'],
  5345. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5346. ) );
  5347. $sum += $other [$ot];
  5348. $otherSum += $other [$ot];
  5349. }
  5350. $ot ++;
  5351. }
  5352. }
  5353. $accountJson ['cSum'] = array (
  5354. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5355. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5356. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5357. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5358. );
  5359. // 报销单
  5360. $rid = $receipt->rid = $receiptDetail ['rid'];
  5361. $receipt->accountItem = json_encode ( $accountJson );
  5362. $receipt->staff = $this->staff [0] ['sid'];
  5363. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5364. $receipt->date = date ( "Y-m-d" );
  5365. $receipt->cid = $cid;
  5366. if (($receiptDetail ['status'] != 4)) {
  5367. if ($receiptDetail ['Rtype'] == 1)
  5368. $receipt->status = 7;
  5369. else
  5370. $receipt->status = 5;
  5371. }
  5372. if ($receiptDetail != 4 && ! empty ( $verify ))
  5373. $receipt->verify = $verify;
  5374. $receipt->executeCopy = $executeDetail ['staff'];
  5375. $receipt->explanation = $explanation;
  5376. $receipt->update ();
  5377. $receiptDetail = new receiptDetail ();
  5378. $receiptDetail->delete ( array (
  5379. 'where' => 'rid=' . $rid
  5380. ) );
  5381. // 报销详情
  5382. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5383. $receiptDetail = new receiptDetail ();
  5384. $receiptDetail->staff = $this->staff [0] ['sid'];
  5385. $receiptDetail->item = $value ['name'];
  5386. $receiptDetail->itemCategory = $this->AGENCY;
  5387. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5388. $receiptDetail->date = date ( "Y-m-d" );
  5389. $receiptDetail->cid = $cid;
  5390. $receiptDetail->rid = $rid;
  5391. $receiptDetail->status = 4;
  5392. $receiptDetail->insert ();
  5393. }
  5394. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5395. $receiptDetail = new receiptDetail ();
  5396. $receiptDetail->staff = $this->staff [0] ['sid'];
  5397. $receiptDetail->item = $value ['name'];
  5398. $receiptDetail->itemCategory = $this->TRAVEL;
  5399. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5400. $receiptDetail->date = date ( "Y-m-d" );
  5401. $receiptDetail->cid = $cid;
  5402. $receiptDetail->rid = $rid;
  5403. $receiptDetail->status = 4;
  5404. $receiptDetail->insert ();
  5405. }
  5406. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5407. $receiptDetail = new receiptDetail ();
  5408. $receiptDetail->staff = $this->staff [0] ['sid'];
  5409. $receiptDetail->item = $value ['name'];
  5410. $receiptDetail->itemCategory = $this->TRAIN;
  5411. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5412. $receiptDetail->date = date ( "Y-m-d" );
  5413. $receiptDetail->cid = $cid;
  5414. $receiptDetail->rid = $rid;
  5415. $receiptDetail->status = 4;
  5416. $receiptDetail->insert ();
  5417. }
  5418. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5419. $receiptDetail = new receiptDetail ();
  5420. $receiptDetail->staff = $this->staff [0] ['sid'];
  5421. $receiptDetail->item = $value ['name'];
  5422. $receiptDetail->itemCategory = $this->OTHER;
  5423. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5424. $receiptDetail->date = date ( "Y-m-d" );
  5425. $receiptDetail->cid = $cid;
  5426. $receiptDetail->rid = $rid;
  5427. $receiptDetail->status = 4;
  5428. $receiptDetail->insert ();
  5429. }
  5430. // return "/referReceipt/".$rid;
  5431. }
  5432. return "/saeaBorad";
  5433. }
  5434. function approvedReceipt() {
  5435. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5436. Doo::loadModel ( 'receipt' );
  5437. Doo::loadModel ( 'receiptDetail' );
  5438. $receipt = new receipt ();
  5439. $receiptDetail = new receiptDetail ();
  5440. Doo::loadModel ( 'statistics' );
  5441. Doo::loadModel ( 'itemStatistics' );
  5442. $statistics = new statistics ();
  5443. $itemStatistics = new itemStatistics ();
  5444. Doo::loadModel ( "verify" );
  5445. $verify = new verify ();
  5446. // 审批状态的判定
  5447. $receiptDetailList = $receipt->getOne ( array (
  5448. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  5449. 'asArray' => true
  5450. ) );
  5451. if (empty ( $receiptDetailList ))
  5452. return "/saeaBorad";
  5453. $verifyDetail = $verify->getOne ( array (
  5454. 'where' => ' vid =' . $receiptDetailList ['verify'],
  5455. 'asArray' => true
  5456. ) );
  5457. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5458. if (empty ( $receiptDetailList ['nowStaff'] )) {
  5459. $nowStaff = "";
  5460. $nowStaffList = array ();
  5461. if ($verifyDetail [0] [1] == 'ROLE') {
  5462. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5463. foreach ( $vStaffString as $key => $value ) {
  5464. $staffK = explode ( "_", $value );
  5465. array_push ( $nowStaffList, $staffK [0] );
  5466. }
  5467. $nowStaff = implode ( ',', $nowStaffList );
  5468. } else {
  5469. $nowStaff = $verifyDetail [0] [0];
  5470. }
  5471. $receipt->nowStaff = $nowStaff;
  5472. }
  5473. // echo $nowStaff;
  5474. // print_r($verifyDetail);die;
  5475. $receipt->rid = $receiptDetailList ['rid'];
  5476. $receipt->date = date ( "Y-m-d" );
  5477. $receipt->status = 2;
  5478. $receipt->update ();
  5479. $receiptDetail->status = 2;
  5480. $receiptDetail->update ( array (
  5481. 'where' => 'rid=' . $receiptDetailList ['rid']
  5482. ) );
  5483. Doo::loadModel ( "receiptLog" );
  5484. $receiptLog = new receiptLog ();
  5485. Doo::loadModel ( "verify" );
  5486. $verify = new verify ();
  5487. $receiptInfo = $receipt->getOne ( array (
  5488. 'where' => 'rid=' . $rid,
  5489. 'asArray' => true
  5490. ) );
  5491. $vr = $verify->getOne ( array (
  5492. 'where' => 'vid=' . $receiptInfo ['verify'],
  5493. 'asArray' => true
  5494. ) );
  5495. $jd = json_decode ( $vr ['staff'] );
  5496. $roleId = 0;
  5497. foreach ( $jd as $key => $value ) {
  5498. if ($value [1] == 'ROLE') {
  5499. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  5500. if ($pos !== false) {
  5501. $roleId = $value [0];
  5502. }
  5503. }
  5504. }
  5505. // 审批日志
  5506. // echo $roleId;die;
  5507. if (! empty ( $roleId )) {
  5508. Doo::loadModel ( "role" );
  5509. $role = new role ();
  5510. $roleInfo = $role->getOne ( array (
  5511. 'where' => 'rid=' . $roleId,
  5512. 'asArray' => true
  5513. ) );
  5514. $receiptLog->rolename = $roleInfo ['name'];
  5515. }
  5516. $receiptLog->username = $this->staff [0] ['username'];
  5517. $receiptLog->uid = $this->staff [0] ['sid'];
  5518. $receiptLog->date = date ( "Y-m-d" );
  5519. $receiptLog->opinion = '提交审批';
  5520. $receiptLog->img = $this->staff [0] ['avatar'];
  5521. $receiptLog->status = 2;
  5522. $receiptLog->rid = $rid;
  5523. $receiptLog->insert ();
  5524. // statistics item
  5525. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  5526. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  5527. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  5528. $stat = $statistics->getOne ( array (
  5529. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5530. 'asArray' => true
  5531. ) );
  5532. if (empty ( $stat )) {
  5533. $statistics->date = date ( "Y-m-d" );
  5534. $statistics->cid = $this->staff [0] ['cid'];
  5535. $statistics->staff = $this->staff [0] ['sid'];
  5536. $statistics->agPrice = 0;
  5537. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5538. $statistics->insert ();
  5539. } else {
  5540. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5541. $statistics->update ( array (
  5542. 'where' => 'sid=' . $stat ['sid']
  5543. ) );
  5544. }
  5545. return "/expenses";
  5546. }
  5547. function approval() {
  5548. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5549. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5550. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5551. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5552. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5553. if (empty ( $status ))
  5554. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5555. $vidList = array ();
  5556. $button = 0;
  5557. Doo::loadModel ( 'verify' );
  5558. $verify = new verify ();
  5559. Doo::loadModel ( 'receipt' );
  5560. $receipt = new receipt ();
  5561. Doo::loadModel ( 'staff' );
  5562. $staff = new staff ();
  5563. Doo::loadModel ( 'L_category' );
  5564. $Lcategory = new L_category ();
  5565. // user verify ID
  5566. $verifyDetail = $verify->find ( array (
  5567. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5568. 'asArray' => true
  5569. ) );
  5570. foreach ( $verifyDetail as $key => $value ) {
  5571. array_push ( $vidList, $value ['vid'] );
  5572. }
  5573. $vid = implode ( ",", $vidList );
  5574. if (empty ( $verifyDetail ))
  5575. $vid = 0;
  5576. /*
  5577. */
  5578. $dateCondition = " and Year(date) =" . $year;
  5579. if (! empty ( $month ))
  5580. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  5581. $categoryList = $Lcategory->find ( array (
  5582. 'asArray' => true
  5583. ) );
  5584. $staffList = $staff->find ( array (
  5585. 'where' => 'cid=' . $cid,
  5586. 'asArray' => true
  5587. ) );
  5588. $cateCondition = "";
  5589. $staffCondition = "";
  5590. $approvalCondition = "";
  5591. if (! empty ( $cid ))
  5592. $cateCondition = ' and cid=' . $cid;
  5593. if (! empty ( $sid )) {
  5594. $staffCondition = ' and staff=' . $sid;
  5595. $cateCondition = "";
  5596. }
  5597. // elseif($status==1){
  5598. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  5599. // }
  5600. if ($status == 2) {
  5601. // 查找角色审批人
  5602. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  5603. }
  5604. $ap = "";
  5605. if ($status == 4) {
  5606. $ap = 4;
  5607. $status = 2;
  5608. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  5609. }
  5610. if ($status == 5) {
  5611. $status = 4;
  5612. $ap = 5;
  5613. }
  5614. // echo $vid;
  5615. // get Receipt By verifyID status 2 .$approvalCondition
  5616. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  5617. $receiptList = $receipt->find ( array (
  5618. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  5619. 'desc' => 'rid',
  5620. 'asArray' => true
  5621. ) );
  5622. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  5623. $Locate = 0;
  5624. if ($ap == 4)
  5625. $status = 4;
  5626. elseif ($ap == 5)
  5627. $status = 5;
  5628. foreach ( $receiptList as $key => $value ) {
  5629. $receiptList [$key] ['Locate'] = $Locate;
  5630. $Locate ++;
  5631. $receiptList [$key] ['reviseDetail'] = array ();
  5632. if (! empty ( $value ['reviseDetail'] ))
  5633. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5634. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5635. $categoryDetil = $Lcategory->getOne ( array (
  5636. 'where' => 'cid=' . $value ['cid'],
  5637. 'asArray' => true
  5638. ) );
  5639. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5640. $verifyList = $verify->getOne ( array (
  5641. 'where' => 'vid=' . $value ['verify'],
  5642. 'asArray' => true
  5643. ) );
  5644. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5645. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5646. foreach ( $verifyList as $k => $v ) {
  5647. // init verifyStaff
  5648. $verifyList [$k] ['date'] = "";
  5649. $verifyList [$k] ['opinion'] = "";
  5650. $verifyList [$k] ['status'] = "";
  5651. if (empty ( $verifyStaff )) {
  5652. $verifyList [$k] ['date'] = "";
  5653. $verifyList [$k] ['opinion'] = "";
  5654. if ($v [0] == $this->staff [0] ['sid']) {
  5655. $verifyList [$k] ['status'] = 4;
  5656. $button = 4;
  5657. }
  5658. } else {
  5659. $flag = true;
  5660. foreach ( $verifyStaff as $m => $u ) {
  5661. if ($v [0] == $m) {
  5662. $verifyList [$k] ['date'] = $u ['date'];
  5663. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5664. $verifyList [$k] ['status'] = $u ['status'];
  5665. $flag = false;
  5666. break;
  5667. }
  5668. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  5669. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  5670. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  5671. }
  5672. if ($flag) { // 检测可编辑
  5673. if ($v [0] == $this->staff [0] ['sid']) {
  5674. $verifyList [$k] ['status'] = 4;
  5675. $button = 4;
  5676. }
  5677. }
  5678. }
  5679. }
  5680. $receiptList [$key] ['verifyList'] = $verifyList;
  5681. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5682. 'where' => 'sid=' . $value ['staff'],
  5683. 'asArray' => true
  5684. ) );
  5685. $receiptList [$key] ['button'] = $button;
  5686. }
  5687. // print_r($receiptList);die;
  5688. // $data['verifyDetail']=$verifyDetail;
  5689. $mothHtml = "";
  5690. for($i = 1; $i <= 12; $i ++) {
  5691. if ($month == $i)
  5692. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5693. else
  5694. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5695. }
  5696. $data ['mothHtml'] = $mothHtml;
  5697. $data ['receiptList'] = $receiptList;
  5698. $data ['receiptApprovalCount'] = count ( $receiptList );
  5699. $data ['status'] = $status;
  5700. $data ['year'] = $year;
  5701. $data ['categoryList'] = $categoryList;
  5702. $data ['staffList'] = $staffList;
  5703. $data ['cid'] = $cid;
  5704. $data ['sid'] = $sid;
  5705. $data ['ap'] = $ap;
  5706. $data ['memu'] = "receipt";
  5707. $data ['staff'] = $this->staff;
  5708. $data ['receiptMemu'] = 'approval';
  5709. $data ['verifyId'] = $this->verifyId;
  5710. $data ['executeId'] = $this->executeId;
  5711. $this->render ( "/admin/saea_reportList", $data );
  5712. }
  5713. function approvalDetails() {
  5714. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5715. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5716. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5717. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5718. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5719. Doo::loadModel ( 'verify' );
  5720. $verify = new verify ();
  5721. Doo::loadModel ( 'receipt' );
  5722. $receipt = new receipt ();
  5723. Doo::loadModel ( 'staff' );
  5724. $staff = new staff ();
  5725. Doo::loadModel ( 'L_category' );
  5726. $Lcategory = new L_category ();
  5727. Doo::loadModel ( 'enclosur' );
  5728. $enclosur = new enclosur ();
  5729. $vidList = array ();
  5730. $verifyDetail = $verify->find ( array (
  5731. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5732. 'asArray' => true
  5733. ) );
  5734. foreach ( $verifyDetail as $key => $value ) {
  5735. array_push ( $vidList, $value ['vid'] );
  5736. }
  5737. $vid = implode ( ",", $vidList );
  5738. if (empty ( $verifyDetail ))
  5739. $vid = 0;
  5740. $categoryList = $Lcategory->find ( array (
  5741. 'asArray' => true
  5742. ) );
  5743. $staffList = $staff->find ( array (
  5744. 'where' => 'cid=' . $cid,
  5745. 'asArray' => true
  5746. ) );
  5747. $ap = 0;
  5748. $receiptList = $receipt->find ( array (
  5749. 'where' => 'rid =' . $rid,
  5750. 'desc' => 'rid',
  5751. 'asArray' => true
  5752. ) );
  5753. $Locate = 0;
  5754. $roleId = 0;
  5755. $button = 0;
  5756. foreach ( $receiptList as $key => $value ) {
  5757. $receiptList [$key] ['Locate'] = $Locate;
  5758. $Locate ++;
  5759. $receiptList [$key] ['reviseDetail'] = array ();
  5760. if (! empty ( $value ['reviseDetail'] ))
  5761. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5762. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5763. $categoryDetil = $Lcategory->getOne ( array (
  5764. 'where' => 'cid=' . $value ['cid'],
  5765. 'asArray' => true
  5766. ) );
  5767. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5768. // 检测编辑状态
  5769. $verifyList = $verify->getOne ( array (
  5770. 'where' => 'vid=' . $value ['verify'],
  5771. 'asArray' => true
  5772. ) );
  5773. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5774. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5775. Doo::loadModel ( 'role' );
  5776. $role = new role ();
  5777. // print_r($verifyList);
  5778. $flag = true;
  5779. $roleKey = 0;
  5780. $endStaffArray = array ();
  5781. $roleArrayCopy = array ();
  5782. foreach ( $verifyList as $k => $v ) {
  5783. // init verifyStaff
  5784. if ($v [1] == 'ROLE') {
  5785. if (! empty ( $verifyStaff )) {
  5786. $endStaffArray = end ( $verifyStaff );
  5787. if ($v [0] == $endStaffArray ['nextStaff']) {
  5788. $roleId = $v [0];
  5789. }
  5790. }
  5791. $roleVerify = json_decode ( $v [3], true );
  5792. $roleKey = $k;
  5793. $roleArray = array ();
  5794. $rolename = $role->getOne ( array (
  5795. 'where' => 'rid=' . $v [0],
  5796. 'asArray' => true
  5797. ) );
  5798. foreach ( $roleVerify as $o => $p ) {
  5799. $staffID = explode ( '_', $p );
  5800. $staffInfo = $staff->getOne ( array (
  5801. 'where' => 'sid=' . $staffID [0],
  5802. 'asArray' => true
  5803. ) );
  5804. // print_r($staffID);
  5805. $exp = array (
  5806. 0 => $staffInfo ['sid'],
  5807. 1 => $staffID [1],
  5808. 2 => $staffInfo ['avatar'],
  5809. 'date' => '',
  5810. 'date' => '',
  5811. 'opinion' => '',
  5812. 'status' => '',
  5813. 'rolename' => $rolename ['name']
  5814. );
  5815. array_push ( $roleArray, $exp );
  5816. }
  5817. $roleArrayCopy [$v [0]] = $roleArray;
  5818. // $verifyList[$k]['roleArray']=$roleArray;
  5819. }
  5820. // print_r($roleArray);
  5821. $verifyList [$k] ['date'] = "";
  5822. $verifyList [$k] ['opinion'] = "";
  5823. $verifyList [$k] ['status'] = "";
  5824. if (empty ( $verifyStaff )) {
  5825. $verifyList [$k] ['date'] = "";
  5826. $verifyList [$k] ['opinion'] = "";
  5827. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5828. $verifyList [$k] ['status'] = 4;
  5829. $button = 4;
  5830. $flag = false;
  5831. }
  5832. } else {
  5833. foreach ( $verifyStaff as $m => $u ) {
  5834. if ($v [0] == $m) {
  5835. $verifyList [$k] ['date'] = $u ['date'];
  5836. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5837. $verifyList [$k] ['status'] = $u ['status'];
  5838. $flag = false;
  5839. break;
  5840. }
  5841. }
  5842. $endStaffArray = end ( $verifyStaff );
  5843. if (isset ( $endStaffArray ['ROLE'] )) {
  5844. } else {
  5845. $endKey = key ( $verifyStaff );
  5846. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5847. $button = 4;
  5848. $verifyList [$k] ['status'] = 4;
  5849. }
  5850. }
  5851. }
  5852. }
  5853. $rolename ['name'] = '';
  5854. if (! empty ( $roleId )) {
  5855. Doo::loadModel ( 'role' );
  5856. $role = new role ();
  5857. $rolename = $role->getOne ( array (
  5858. 'where' => 'rid=' . $roleId,
  5859. 'asArray' => true
  5860. ) );
  5861. }
  5862. if (! empty ( $verifyStaff ))
  5863. $endStaffArray = end ( $verifyStaff );
  5864. $KOP = false;
  5865. foreach ( $roleArrayCopy as $P => $A ) {
  5866. foreach ( $A as $MKI => $AVL ) {
  5867. if (! empty ( $verifyStaff )) {
  5868. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5869. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5870. $button = 4;
  5871. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5872. }
  5873. foreach ( $verifyStaff as $m => $u ) {
  5874. $AVLFK = $AVL [0] . '_R';
  5875. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5876. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5877. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5878. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5879. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5880. break;
  5881. }
  5882. }
  5883. } else {
  5884. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5885. $button = 4;
  5886. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5887. }
  5888. }
  5889. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5890. $KOP = true;
  5891. }
  5892. }
  5893. foreach ( $roleArrayCopy as $k => $v ) {
  5894. foreach ( $verifyList as $m => $n ) {
  5895. if ($n [0] == $k) {
  5896. array_splice ( $verifyList, $m, 1, $v );
  5897. }
  5898. }
  5899. }
  5900. $receiptList [$key] ['verifyList'] = $verifyList;
  5901. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5902. 'where' => 'sid=' . $value ['staff'],
  5903. 'asArray' => true
  5904. ) );
  5905. $receiptList [$key] ['button'] = $button;
  5906. }
  5907. $mothHtml = "";
  5908. for($i = 1; $i <= 12; $i ++) {
  5909. if ($month == $i)
  5910. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5911. else
  5912. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5913. }
  5914. // 获取审批日志
  5915. Doo::loadModel ( 'receiptLog' );
  5916. $receiptLog = new receiptLog ();
  5917. $rlList = array ();
  5918. $rlInfo = $receiptLog->getOne ( array (
  5919. 'where' => 'rid=' . $rid . ' and status=4',
  5920. 'asArray' => true
  5921. ) );
  5922. $tijdate = $receiptLog->getOne ( array (
  5923. 'where' => 'rid=' . $rid . ' and status=2',
  5924. 'asc' => 'rlid',
  5925. 'asArray' => true
  5926. ) );
  5927. if (! empty ( $rlInfo )) {
  5928. $rlList = $receiptLog->find ( array (
  5929. 'where' => 'rid=' . $rid,
  5930. 'asc' => 'rlid',
  5931. 'asArray' => true
  5932. ) );
  5933. }
  5934. $receiptList [0] ['rlList'] = $rlList;
  5935. $enclosurList = $enclosur->find ( array (
  5936. 'where' => 'rid=' . $rid,
  5937. 'asArray' => true
  5938. ) );
  5939. $enclosurHtml = '';
  5940. foreach ( $enclosurList as $value ) {
  5941. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5942. }
  5943. $data ['enclosurHtml'] = $enclosurHtml;
  5944. $data ['rolename'] = $rolename ['name'];
  5945. $data ['datetij'] = $tijdate ['date'];
  5946. $data ['mothHtml'] = $mothHtml;
  5947. $data ['receiptList'] = $receiptList;
  5948. $data ['receiptApprovalCount'] = count ( $receiptList );
  5949. $data ['year'] = $year;
  5950. $data ['categoryList'] = $categoryList;
  5951. $data ['staffList'] = $staffList;
  5952. $data ['cid'] = $cid;
  5953. $data ['sid'] = $sid;
  5954. $data ['status'] = 0;
  5955. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  5956. $ap = 4;
  5957. } else
  5958. $data ['status'] = $receiptList [0] ['status'];
  5959. if ($receiptList [0] ['status'] == 4) {
  5960. $data ['status'] = 5;
  5961. $ap = 0;
  5962. }
  5963. $data ['ap'] = $ap;
  5964. $data ['memu'] = "receipt";
  5965. $data ['staff'] = $this->staff;
  5966. $data ['receiptMemu'] = 'approval';
  5967. $data ['verifyId'] = $this->verifyId;
  5968. $data ['executeId'] = $this->executeId;
  5969. $this->render ( "/admin/saeaReportListReport", $data );
  5970. }
  5971. function approvalEdi() {
  5972. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5973. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5974. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5975. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5976. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5977. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5978. if (empty ( $status ))
  5979. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5980. $vidList = array ();
  5981. $button = 0;
  5982. Doo::loadModel ( 'verify' );
  5983. Doo::loadModel ( 'receipt' );
  5984. Doo::loadModel ( 'staff' );
  5985. $staff = new staff ();
  5986. $receipt = new receipt ();
  5987. $verify = new verify ();
  5988. Doo::loadModel ( 'L_category' );
  5989. $Lcategory = new L_category ();
  5990. Doo::loadModel ( 'enclosur' );
  5991. $enclosur = new enclosur ();
  5992. // user verify ID
  5993. $verifyDetail = $verify->find ( array (
  5994. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5995. 'asArray' => true
  5996. ) );
  5997. foreach ( $verifyDetail as $key => $value ) {
  5998. array_push ( $vidList, $value ['vid'] );
  5999. }
  6000. $vid = implode ( ",", $vidList );
  6001. if (empty ( $verifyDetail ))
  6002. $vid = 0;
  6003. $categoryList = $Lcategory->find ( array (
  6004. 'asArray' => true
  6005. ) );
  6006. $staffList = $staff->find ( array (
  6007. 'where' => 'cid=' . $cid,
  6008. 'asArray' => true
  6009. ) );
  6010. $ap = "";
  6011. if ($status == 4) {
  6012. $ap = 4;
  6013. $status = 2;
  6014. }
  6015. // get Receipt By verifyID status 2
  6016. $receiptList = $receipt->find ( array (
  6017. 'where' => 'rid =' . $rid,
  6018. 'desc' => 'rid',
  6019. 'asArray' => true
  6020. ) );
  6021. $Locate = 0;
  6022. $roleId = 0;
  6023. if ($ap == 4)
  6024. $status = 4;
  6025. foreach ( $receiptList as $key => $value ) {
  6026. $receiptList [$key] ['Locate'] = $Locate;
  6027. $Locate ++;
  6028. $receiptList [$key] ['reviseDetail'] = array ();
  6029. if (! empty ( $value ['reviseDetail'] ))
  6030. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6031. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6032. $categoryDetil = $Lcategory->getOne ( array (
  6033. 'where' => 'cid=' . $value ['cid'],
  6034. 'asArray' => true
  6035. ) );
  6036. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6037. // 检测编辑状态
  6038. $verifyList = $verify->getOne ( array (
  6039. 'where' => 'vid=' . $value ['verify'],
  6040. 'asArray' => true
  6041. ) );
  6042. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6043. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6044. // print_r($verifyList);
  6045. //
  6046. // if (empty($verifyStaff)){
  6047. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6048. // $verifyList[0]['status']=4;$button=4;
  6049. // }
  6050. //
  6051. // }else{
  6052. //
  6053. // }
  6054. // die;
  6055. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  6056. // echo array_search("green",$a);
  6057. //
  6058. Doo::loadModel ( 'role' );
  6059. $role = new role ();
  6060. // print_r($verifyList);
  6061. $flag = true;
  6062. $roleKey = 0;
  6063. $endStaffArray = array ();
  6064. $roleArrayCopy = array ();
  6065. foreach ( $verifyList as $k => $v ) {
  6066. // init verifyStaff
  6067. if ($v [1] == 'ROLE') {
  6068. if (! empty ( $verifyStaff )) {
  6069. $endStaffArray = end ( $verifyStaff );
  6070. if ($v [0] == $endStaffArray ['nextStaff']) {
  6071. $roleId = $v [0];
  6072. }
  6073. }
  6074. $roleVerify = json_decode ( $v [3], true );
  6075. $roleKey = $k;
  6076. $roleArray = array ();
  6077. $rolename = $role->getOne ( array (
  6078. 'where' => 'rid=' . $v [0],
  6079. 'asArray' => true
  6080. ) );
  6081. foreach ( $roleVerify as $o => $p ) {
  6082. $staffID = explode ( '_', $p );
  6083. $staffInfo = $staff->getOne ( array (
  6084. 'where' => 'sid=' . $staffID [0],
  6085. 'asArray' => true
  6086. ) );
  6087. // print_r($staffID);
  6088. $exp = array (
  6089. 0 => $staffInfo ['sid'],
  6090. 1 => $staffID [1],
  6091. 2 => $staffInfo ['avatar'],
  6092. 'date' => '',
  6093. 'date' => '',
  6094. 'opinion' => '',
  6095. 'status' => '',
  6096. 'rolename' => $rolename ['name']
  6097. );
  6098. array_push ( $roleArray, $exp );
  6099. }
  6100. $roleArrayCopy [$v [0]] = $roleArray;
  6101. // $verifyList[$k]['roleArray']=$roleArray;
  6102. }
  6103. // print_r($roleArray);
  6104. $verifyList [$k] ['date'] = "";
  6105. $verifyList [$k] ['opinion'] = "";
  6106. $verifyList [$k] ['status'] = "";
  6107. if (empty ( $verifyStaff )) {
  6108. $verifyList [$k] ['date'] = "";
  6109. $verifyList [$k] ['opinion'] = "";
  6110. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6111. $verifyList [$k] ['status'] = 4;
  6112. $button = 4;
  6113. $flag = false;
  6114. }
  6115. } else {
  6116. foreach ( $verifyStaff as $m => $u ) {
  6117. if ($v [0] == $m) {
  6118. $verifyList [$k] ['date'] = $u ['date'];
  6119. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6120. $verifyList [$k] ['status'] = $u ['status'];
  6121. $flag = false;
  6122. break;
  6123. }
  6124. }
  6125. $endStaffArray = end ( $verifyStaff );
  6126. if (isset ( $endStaffArray ['ROLE'] )) {
  6127. } else {
  6128. $endKey = key ( $verifyStaff );
  6129. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6130. $button = 4;
  6131. $verifyList [$k] ['status'] = 4;
  6132. }
  6133. }
  6134. // print_r($endStaffArray);die;
  6135. // if (empty($verifyStaff)){
  6136. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6137. // $verifyList[$k]['status']=4;$button=4;
  6138. // }
  6139. //
  6140. // }else{
  6141. //
  6142. // }
  6143. // if($flag){//检测可编辑
  6144. // if($v[0]==$this->staff[0]['sid']){
  6145. // $verifyList[$k]['status']=4;$button=4;
  6146. // }
  6147. // }
  6148. }
  6149. }
  6150. $rolename ['name'] = '';
  6151. if (! empty ( $roleId )) {
  6152. Doo::loadModel ( 'role' );
  6153. $role = new role ();
  6154. $rolename = $role->getOne ( array (
  6155. 'where' => 'rid=' . $roleId,
  6156. 'asArray' => true
  6157. ) );
  6158. }
  6159. if (! empty ( $verifyStaff ))
  6160. $endStaffArray = end ( $verifyStaff );
  6161. $KOP = false;
  6162. foreach ( $roleArrayCopy as $P => $A ) {
  6163. foreach ( $A as $MKI => $AVL ) {
  6164. if (! empty ( $verifyStaff )) {
  6165. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6166. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6167. $button = 4;
  6168. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6169. }
  6170. foreach ( $verifyStaff as $m => $u ) {
  6171. $AVLFK = $AVL [0] . '_R';
  6172. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6173. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6174. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6175. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6176. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6177. break;
  6178. }
  6179. }
  6180. } else {
  6181. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6182. $button = 4;
  6183. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6184. }
  6185. }
  6186. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6187. $KOP = true;
  6188. }
  6189. }
  6190. // print_r($roleArrayCopy);
  6191. // echo $roleKey;
  6192. foreach ( $roleArrayCopy as $k => $v ) {
  6193. foreach ( $verifyList as $m => $n ) {
  6194. if ($n [0] == $k) {
  6195. array_splice ( $verifyList, $m, 1, $v );
  6196. }
  6197. }
  6198. }
  6199. // if ($KOP)
  6200. // array_splice($verifyList,$roleKey,1,$roleArray);
  6201. // print_r($verifyList);
  6202. $receiptList [$key] ['verifyList'] = $verifyList;
  6203. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6204. 'where' => 'sid=' . $value ['staff'],
  6205. 'asArray' => true
  6206. ) );
  6207. $receiptList [$key] ['button'] = $button;
  6208. }
  6209. // $data['verifyDetail']=$verifyDetail;
  6210. $mothHtml = "";
  6211. for($i = 1; $i <= 12; $i ++) {
  6212. if ($month == $i)
  6213. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6214. else
  6215. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6216. }
  6217. // 获取审批日志
  6218. Doo::loadModel ( 'receiptLog' );
  6219. $receiptLog = new receiptLog ();
  6220. $rlList = array ();
  6221. $rlInfo = $receiptLog->getOne ( array (
  6222. 'where' => 'rid=' . $rid . ' and status=4',
  6223. 'asArray' => true
  6224. ) );
  6225. $tijdate = $receiptLog->getOne ( array (
  6226. 'where' => 'rid=' . $rid . ' and status=2',
  6227. 'asc' => 'rlid',
  6228. 'asArray' => true
  6229. ) );
  6230. if (! empty ( $rlInfo )) {
  6231. $rlList = $receiptLog->find ( array (
  6232. 'where' => 'rid=' . $rid,
  6233. 'asc' => 'rlid',
  6234. 'asArray' => true
  6235. ) );
  6236. }
  6237. $receiptList [0] ['rlList'] = $rlList;
  6238. $enclosurList = $enclosur->find ( array (
  6239. 'where' => 'rid=' . $rid,
  6240. 'asArray' => true
  6241. ) );
  6242. $enclosurHtml = '';
  6243. foreach ( $enclosurList as $value ) {
  6244. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6245. }
  6246. $data ['enclosurHtml'] = $enclosurHtml;
  6247. $data ['rolename'] = $rolename ['name'];
  6248. $data ['datetij'] = $tijdate ['date'];
  6249. $data ['mothHtml'] = $mothHtml;
  6250. $data ['receiptList'] = $receiptList;
  6251. $data ['receiptApprovalCount'] = count ( $receiptList );
  6252. $data ['status'] = $status;
  6253. $data ['year'] = $year;
  6254. $data ['categoryList'] = $categoryList;
  6255. $data ['staffList'] = $staffList;
  6256. $data ['cid'] = $cid;
  6257. $data ['sid'] = $sid;
  6258. $data ['ap'] = $ap;
  6259. $data ['memu'] = "receipt";
  6260. $data ['staff'] = $this->staff;
  6261. $data ['receiptMemu'] = 'approval';
  6262. $data ['verifyId'] = $this->verifyId;
  6263. $data ['executeId'] = $this->executeId;
  6264. $this->render ( "/admin/saeaReportListReport", $data );
  6265. }
  6266. function remittanceHky() {
  6267. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6268. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  6269. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6270. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  6271. $page_size = 15;
  6272. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  6273. Doo::loadModel ( 'receipt' );
  6274. $receipt = new receipt ();
  6275. Doo::loadModel ( 'staff' );
  6276. $staff = new staff ();
  6277. $dateCondition = " and Year(executeDate) =" . $year;
  6278. if ($moth != 'MONTH')
  6279. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  6280. if ($day != 'DAY' && $moth != 'MONTH')
  6281. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  6282. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  6283. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  6284. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  6285. $limit = $pageinfo ['lower'] . ',' . $page_size;
  6286. $dayList = $receipt->find ( array (
  6287. 'select' => 'executeDate,sum(amount) as amount',
  6288. 'where' => $sql,
  6289. 'desc' => 'executeDate',
  6290. 'groupby' => 'executeDate',
  6291. 'limit' => $limit,
  6292. 'asArray' => true
  6293. ) );
  6294. // print_r($dayList);
  6295. foreach ( $dayList as $key => $value ) {
  6296. $remitString = "";
  6297. $receiptList = $receipt->find ( array (
  6298. 'select' => 'rid,executeDate,amount,staff,cid',
  6299. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  6300. 'desc' => 'executeDate',
  6301. 'asArray' => true
  6302. ) );
  6303. foreach ( $receiptList as $k => $v ) {
  6304. $sinfo = $staff->getOne ( array (
  6305. 'select' => 'username,category',
  6306. 'where' => ' sid=' . $v ['staff'],
  6307. 'asArray' => true
  6308. ) );
  6309. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  6310. }
  6311. $dayList [$key] ['staff'] = $remitString;
  6312. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  6313. }
  6314. // print_r($dayList);
  6315. $mothHtml = "";
  6316. for($i = 1; $i <= 12; $i ++) {
  6317. if ($moth == $i)
  6318. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6319. else
  6320. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6321. }
  6322. $dayHtml = "";
  6323. if ($day != "DAY" || $moth != "MONTH") {
  6324. for($i = 1; $i <= 31; $i ++) {
  6325. if ($day == $i)
  6326. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6327. else
  6328. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6329. }
  6330. }
  6331. $data ['page'] = $pageinfo;
  6332. $data ['year'] = $year;
  6333. $data ['moth'] = $moth;
  6334. $data ['day'] = $day;
  6335. $data ['get'] = $get;
  6336. $data ['dayHtml'] = $dayHtml;
  6337. $data ['mothHtml'] = $mothHtml;
  6338. $data ['receiptList'] = $dayList;
  6339. $data ['memu'] = "receipt";
  6340. $data ['staff'] = $this->staff;
  6341. $data ['receiptMemu'] = 'remittanceHky';
  6342. $data ['verifyId'] = $this->verifyId;
  6343. $data ['executeId'] = $this->executeId;
  6344. $this->render ( "/admin/remittanceHky", $data );
  6345. }
  6346. function remittancep() {
  6347. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  6348. Doo::loadModel ( 'receipt' );
  6349. $receipt = new receipt ();
  6350. Doo::loadModel ( 'staff' );
  6351. $staff = new staff ();
  6352. Doo::loadClass ( 'XDeode' );
  6353. $XDeode = new XDeode ( 5 );
  6354. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  6355. $rplist = $receipt->find ( array (
  6356. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6357. 'asArray' => true
  6358. ) );
  6359. $dayList = $receipt->find ( array (
  6360. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6361. 'desc' => 'executeDate',
  6362. 'groupby' => 'staff',
  6363. 'asArray' => true
  6364. ) );
  6365. $html = '';
  6366. foreach ( $dayList as $key => $value ) {
  6367. $sinfo = $staff->getOne ( array (
  6368. 'select' => 'username,category',
  6369. 'where' => ' sid=' . $value ['staff'],
  6370. 'asArray' => true
  6371. ) );
  6372. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  6373. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  6374. $au = 0;
  6375. foreach ( $rplist as $k => $v ) {
  6376. if ($value ['staff'] == $v ['staff']) {
  6377. $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>';
  6378. $au += $v ['amount'];
  6379. }
  6380. }
  6381. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  6382. }
  6383. $data ['html'] = $html;
  6384. $data ['memu'] = "receipt";
  6385. $data ['staff'] = $this->staff;
  6386. $data ['receiptMemu'] = 'remittanceHky';
  6387. $data ['verifyId'] = $this->verifyId;
  6388. $data ['executeId'] = $this->executeId;
  6389. $this->render ( "/admin/remittancep", $data );
  6390. }
  6391. function ajaxGetReceiptDetails() {
  6392. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  6393. Doo::loadClass ( 'XDeode' );
  6394. $XDeode = new XDeode ( 5 );
  6395. $rid = $XDeode->decode ( $rid );
  6396. if (empty ( $rid )) {
  6397. echo json_encode ( array (
  6398. 'status' => 2,
  6399. 'msg' => 'illegal request'
  6400. ) );
  6401. die ();
  6402. }
  6403. Doo::loadModel ( 'receipt' );
  6404. $receipt = new receipt ();
  6405. Doo::loadModel ( 'staff' );
  6406. $staff = new staff ();
  6407. $rinfo = $receipt->getOne ( array (
  6408. 'where' => 'rid= ' . $rid,
  6409. 'asArray' => true
  6410. ) );
  6411. $sinfo = $staff->getOne ( array (
  6412. 'select' => 'username,category',
  6413. 'where' => ' sid=' . $rinfo ['staff'],
  6414. 'asArray' => true
  6415. ) );
  6416. $rinfo ['reviseDetail'] = array ();
  6417. if (! empty ( $rinfo ['reviseDetail'] ))
  6418. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  6419. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  6420. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  6421. $rinfo ['category'] = $sinfo ['category'];
  6422. $verifyStaff = array ();
  6423. if (! empty ( $rinfo ['verifyStaff'] ))
  6424. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  6425. $relust = $rinfo ['sum'] - $rinfo ['loanSum'];
  6426. $rinfo ['relust'] = $relust;
  6427. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  6428. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  6429. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  6430. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  6431. // 费用执行人相关数据
  6432. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6433. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6434. foreach ( $executeCopy as $k => $v ) {
  6435. $executeCopy [$k] ['date'] = '';
  6436. $executeCopy [$k] ['opinion'] = '';
  6437. $executeCopy [$k] ['status'] = '';
  6438. if (! empty ( $executeStaff ))
  6439. foreach ( $executeStaff as $m => $u ) {
  6440. if ($v [0] == $m) {
  6441. $executeCopy [$k] ['date'] = $u ['date'];
  6442. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  6443. $executeCopy [$k] ['status'] = $u ['status'];
  6444. break;
  6445. }
  6446. }
  6447. }
  6448. $rinfo ['executeCopy'] = $executeCopy;
  6449. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  6450. if ($rinfo ['Rtype'] == 1) { // 借款费用
  6451. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6452. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  6453. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  6454. $html .= '<tr><th>' . $value ['name'] . '</th>
  6455. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6456. }
  6457. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6458. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6459. <tr><th class="taC" colspan="2">费用说明</th>
  6460. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6461. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6462. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  6463. </tbody></table>';
  6464. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  6465. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6466. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6467. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6468. $html .= '<tr><th>' . $value ['name'] . '</th>
  6469. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6470. }
  6471. $html .= '<tr><th class="taR">合计</th>
  6472. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6473. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6474. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6475. $html .= '<tr><th>' . $value ['name'] . '</th>
  6476. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6477. }
  6478. $html .= '<tr><th class="taR">合计</th>
  6479. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6480. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6481. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6482. $html .= '<tr><th>' . $value ['name'] . '</th>
  6483. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6484. }
  6485. $html .= '<tr><th class="taR">合计</th>
  6486. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6487. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6488. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6489. $html .= '<tr><th>' . $value ['name'] . '</th>
  6490. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6491. }
  6492. $html .= '<tr><th class="taR">合计</th>
  6493. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6494. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6495. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6496. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6497. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6498. }
  6499. $html .= '<tr><th class="taR">合计</th>
  6500. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6501. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6502. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6503. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6504. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6505. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6506. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6507. <tr';
  6508. if ($rinfo ['relust'] >= 0) {
  6509. $html .= 'class="success"';
  6510. } else {
  6511. $html .= 'class="error"';
  6512. }
  6513. $html .= '><td class="taR"><b>借款结余</b></td>
  6514. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  6515. </tbody></table>
  6516. ';
  6517. }
  6518. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  6519. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6520. <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 class="taC" colspan="2">产生费用所在办事处</th></tr>
  6528. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6529. <tr><th class="taC" colspan="2">费用说明</th>
  6530. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6531. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6532. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6533. </tbody></table>';
  6534. } else {
  6535. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6536. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6537. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6538. $html .= '<tr><th>' . $value ['name'] . '</th>
  6539. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6540. }
  6541. $html .= '<tr><th class="taR">合计</th>
  6542. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6543. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6544. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6545. $html .= '<tr><th>' . $value ['name'] . '</th>
  6546. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6547. }
  6548. $html .= '<tr><th class="taR">合计</th>
  6549. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6550. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6551. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6552. $html .= '<tr><th>' . $value ['name'] . '</th>
  6553. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6554. }
  6555. $html .= '<tr><th class="taR">合计</th>
  6556. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6557. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6558. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6559. $html .= '<tr><th>' . $value ['name'] . '</th>
  6560. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6561. }
  6562. $html .= '<tr><th class="taR">合计</th>
  6563. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6564. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6565. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6566. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6567. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6568. }
  6569. $html .= '<tr><th class="taR">合计</th>
  6570. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6571. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6572. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6573. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6574. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6575. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6576. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  6577. $html .= '</tbody></table>';
  6578. /*
  6579. * <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>
  6580. */
  6581. }
  6582. // print_r($verifyStaff);die;
  6583. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  6584. foreach ( $verifyStaff as $key => $value ) {
  6585. $key = trim ( strtr ( $key, '_R', ' ' ) );
  6586. $sinfo = $staff->getOne ( array (
  6587. 'select' => 'username',
  6588. 'where' => ' sid=' . $key,
  6589. 'asArray' => true
  6590. ) );
  6591. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6592. }
  6593. $html .= '</tbody></table>';
  6594. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  6595. foreach ( $rinfo ['executeCopy'] as $value ) {
  6596. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6597. }
  6598. $html .= '</tbody></table>';
  6599. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  6600. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  6601. </tr></table>';
  6602. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  6603. echo json_encode ( array (
  6604. 'status' => 1,
  6605. 'html' => $html
  6606. ) );
  6607. die ();
  6608. }
  6609. function remittance() {
  6610. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6611. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6612. Doo::loadModel ( 'receipt' );
  6613. $receipt = new receipt ();
  6614. Doo::loadModel ( 'staff' );
  6615. $staff = new staff ();
  6616. $dateCondition = " and Year(pastDate) =" . $year;
  6617. if (! empty ( $month ))
  6618. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  6619. // get Receipt By verifyID status 1
  6620. $receiptList = $receipt->find ( array (
  6621. 'select' => 'sum(sum) as sum,staff,pastDate',
  6622. 'where' => ' status=1' . $dateCondition,
  6623. 'desc' => 'pastDate',
  6624. 'groupby' => 'staff,pastDate',
  6625. 'asArray' => true
  6626. ) );
  6627. $dateList = $receipt->find ( array (
  6628. 'select' => 'pastDate,verifyStaff',
  6629. 'where' => ' status=1' . $dateCondition,
  6630. 'desc' => 'pastDate',
  6631. 'groupby' => 'pastDate',
  6632. 'asArray' => true
  6633. ) );
  6634. $dataList = array ();
  6635. foreach ( $dateList as $d => $a ) {
  6636. $dataList [$a ['pastDate']] = array ();
  6637. $daySum = 0;
  6638. foreach ( $receiptList as $key => $value ) {
  6639. if ($a ['pastDate'] == $value ['pastDate']) {
  6640. $oderList = $receipt->find ( array (
  6641. 'select' => 'receiptOrder',
  6642. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  6643. 'asArray' => true
  6644. ) );
  6645. $list = array ();
  6646. $html = "";
  6647. foreach ( $oderList as $v ) {
  6648. array_push ( $list, $v ['receiptOrder'] );
  6649. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  6650. }
  6651. $receiptList [$key] ['receiptOrder'] = $html;
  6652. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  6653. $sinfo = $staff->getOne ( array (
  6654. 'select' => 'username ',
  6655. 'where' => ' sid=' . $value ['staff'],
  6656. 'asArray' => true
  6657. ) );
  6658. $receiptList [$key] ['username'] = $sinfo ['username'];
  6659. $daySum += $value ['sum'];
  6660. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  6661. }
  6662. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  6663. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  6664. }
  6665. }
  6666. // print_r($dataList);
  6667. $data ['dataList'] = $dataList;
  6668. $mothHtml = "";
  6669. for($i = 1; $i <= 12; $i ++) {
  6670. if ($month == $i)
  6671. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6672. else
  6673. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6674. }
  6675. $data ['year'] = $year;
  6676. $data ['mothHtml'] = $mothHtml;
  6677. $data ['memu'] = "receipt";
  6678. $data ['staff'] = $this->staff;
  6679. $data ['receiptMemu'] = 'approval';
  6680. $data ['verifyId'] = $this->verifyId;
  6681. $data ['executeId'] = $this->executeId;
  6682. $this->render ( "/admin/saeaReportListPay", $data );
  6683. }
  6684. function revocationAdjustment() {
  6685. $sid = isset ( $this->params ['sid'] ) && is_numeric ( $this->params ['sid'] ) ? $this->params ['sid'] : 0;
  6686. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  6687. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6688. // echo $price;die;
  6689. if ((! empty ( $sid )) && ($price != - 99999) && (! empty ( $rid ))) {
  6690. Doo::loadModel ( 'receipt' );
  6691. $receipt = new receipt ();
  6692. $receiptDetail = $receipt->getOne ( array (
  6693. 'where' => 'rid=' . $rid,
  6694. 'asArray' => true
  6695. ) );
  6696. if (empty ( $receiptDetail ['reviseDetail'] ))
  6697. return "/approval";
  6698. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  6699. $RD = array ();
  6700. foreach ( $reviseDetail as $key => $value ) {
  6701. if ($value ['price'] == $price && $value ['sid'] == $sid)
  6702. continue;
  6703. array_push ( $RD, $value );
  6704. }
  6705. $reviseDetailString = json_encode ( $RD );
  6706. $receipt->reviseDetail = $reviseDetailString;
  6707. $receipt->sum = $receiptDetail ['sum'] - $price;
  6708. $receipt->revisePrice = $receiptDetail ['revisePrice'] - $price;
  6709. $receipt->update ( array (
  6710. 'where' => 'rid=' . $rid
  6711. ) );
  6712. }
  6713. // approvalEdi/37
  6714. return "/approvalEdi/" . $rid;
  6715. }
  6716. function updateApprovalReceipt() {
  6717. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6718. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  6719. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6720. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  6721. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  6722. if (! empty ( $rid )) {
  6723. Doo::loadModel ( "verify" );
  6724. $verify = new verify ();
  6725. Doo::loadModel ( "receiptDetail" );
  6726. $receiptDetailObj = new receiptDetail ();
  6727. Doo::loadModel ( "itemStatistics" );
  6728. Doo::loadModel ( "statistics" );
  6729. $statistics = new statistics ();
  6730. $itemStatistics = new itemStatistics ();
  6731. Doo::loadModel ( "receipt" );
  6732. $receipt = new receipt ();
  6733. $receiptDetail = $receipt->getOne ( array (
  6734. 'where' => 'rid=' . $rid . ' and status=2 ',
  6735. 'asArray' => true
  6736. ) );
  6737. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  6738. $nsflag = true;
  6739. foreach ( $nslist as $value ) {
  6740. if ($value == $this->staff ['0'] ['sid']) {
  6741. $nsflag = false;
  6742. break;
  6743. }
  6744. }
  6745. if (empty ( $receiptDetail ) || $nsflag)
  6746. return "/approval";
  6747. $verifyDetail = $verify->getOne ( array (
  6748. 'where' => ' vid =' . $receiptDetail ['verify'],
  6749. 'asArray' => true
  6750. ) );
  6751. $verifyString = $verifyDetail ['staff'];
  6752. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  6753. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  6754. if (empty ( $opinion )) {
  6755. if ($status == 3)
  6756. $opinion = "终止";
  6757. else
  6758. $opinion = "同意支付";
  6759. }
  6760. $nowStaff = 0;
  6761. $nowStaffList = array ();
  6762. if (empty ( $verifyStaff )) {
  6763. // 还需加入是否已经进入角色审批
  6764. if ($verifyDetail [0] [1] == 'ROLE') {
  6765. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  6766. foreach ( $vStaffString as $key => $value ) {
  6767. $staffK = explode ( "_", $value );
  6768. if ($staffK [0] != $this->staff [0] ['sid'])
  6769. array_push ( $nowStaffList, $staffK [0] );
  6770. }
  6771. // print_r($verifyDetail);
  6772. // die;
  6773. if (! empty ( $nowStaffList )) {
  6774. $nowStaff = implode ( ',', $nowStaffList );
  6775. $verifyStaff = array (
  6776. $this->staff [0] ['sid'] . "_R" => array (
  6777. 'date' => date ( 'Y-m-d' ),
  6778. 'opinion' => $opinion,
  6779. 'status' => $status,
  6780. 'nextStaff' => $verifyDetail [0] [0],
  6781. 'ROLE' => 1
  6782. )
  6783. );
  6784. } else {
  6785. $nowStaff = $verifyDetail [1] [0];
  6786. $verifyStaff = array (
  6787. $this->staff [0] ['sid'] . "_R" => array (
  6788. 'date' => date ( 'Y-m-d' ),
  6789. 'opinion' => $opinion,
  6790. 'status' => $status,
  6791. 'nextStaff' => $verifyDetail [1] [0]
  6792. )
  6793. );
  6794. }
  6795. } else {
  6796. if ($verifyDetail [1] [1] == 'ROLE') {
  6797. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  6798. // echo "dd";
  6799. foreach ( $vStaffString as $key => $value ) {
  6800. $staffK = explode ( "_", $value );
  6801. array_push ( $nowStaffList, $staffK [0] );
  6802. }
  6803. $nowStaff = implode ( ',', $nowStaffList );
  6804. $verifyStaff = array (
  6805. $this->staff [0] ['sid'] => array (
  6806. 'date' => date ( 'Y-m-d' ),
  6807. 'opinion' => $opinion,
  6808. 'status' => $status,
  6809. 'nextStaff' => $verifyDetail [1] [0],
  6810. 'ROLE' => 1
  6811. )
  6812. );
  6813. } else {
  6814. $nowStaff = $verifyDetail [1] [0];
  6815. $verifyStaff = array (
  6816. $this->staff [0] ['sid'] => array (
  6817. 'date' => date ( 'Y-m-d' ),
  6818. 'opinion' => $opinion,
  6819. 'status' => $status,
  6820. 'nextStaff' => $verifyDetail [1] [0]
  6821. )
  6822. );
  6823. }
  6824. }
  6825. if ($status == 3)
  6826. $verifyStaff = array (
  6827. 'final' => $status,
  6828. $this->staff [0] ['sid'] => array (
  6829. 'date' => date ( 'Y-m-d' ),
  6830. 'opinion' => $opinion,
  6831. 'status' => $status
  6832. )
  6833. );
  6834. $vStaffString = json_encode ( $verifyStaff );
  6835. $receipt->nowStaff = $nowStaff;
  6836. $receipt->verifyStaff = $vStaffString;
  6837. } else {
  6838. $VS = end ( $verifyStaff );
  6839. // 非角色审批
  6840. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  6841. $nextStaff = 0;
  6842. $roleSTF = false;
  6843. foreach ( $verifyDetail as $key => $value ) {
  6844. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  6845. if (isset ( $verifyDetail [$key + 1] )) {
  6846. $nextStaff = $verifyDetail [$key + 1] [0];
  6847. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  6848. $roleSTF = true;
  6849. }
  6850. break;
  6851. }
  6852. }
  6853. if (! $roleSTF) {
  6854. $nowStaff = $nextStaff;
  6855. $verifyStaff [$this->staff [0] ['sid']] = array (
  6856. 'date' => date ( 'Y-m-d' ),
  6857. 'opinion' => $opinion,
  6858. 'status' => $status,
  6859. 'nextStaff' => $nextStaff
  6860. );
  6861. } else {
  6862. // 获取角色下的所有用户ID
  6863. $nowStaffList = array ();
  6864. foreach ( $verifyDetail as $vfk ) {
  6865. if ($vfk [1] == 'ROLE') {
  6866. $vStaffString = json_decode ( $vfk [3] );
  6867. foreach ( $vStaffString as $key => $value ) {
  6868. $staffK = explode ( "_", $value );
  6869. array_push ( $nowStaffList, $staffK [0] );
  6870. }
  6871. }
  6872. }
  6873. $nowStaff = implode ( ',', $nowStaffList );
  6874. $verifyStaff [$this->staff [0] ['sid']] = array (
  6875. 'date' => date ( 'Y-m-d' ),
  6876. 'opinion' => $opinion,
  6877. 'status' => $status,
  6878. 'nextStaff' => $nextStaff,
  6879. 'ROLE' => 0
  6880. );
  6881. }
  6882. if ($status == 3) {
  6883. $verifyStaff ['final'] = $status;
  6884. $verifyStaff [$this->staff [0] ['sid']] = array (
  6885. 'date' => date ( 'Y-m-d' ),
  6886. 'opinion' => $opinion,
  6887. 'status' => $status
  6888. );
  6889. }
  6890. $vStaffString = json_encode ( $verifyStaff );
  6891. $receipt->nowStaff = $nowStaff;
  6892. $receipt->verifyStaff = $vStaffString;
  6893. }
  6894. // 角色审批
  6895. if (isset ( $VS ['ROLE'] )) {
  6896. // 找出角色人 当前审批角色组
  6897. $verifyJSStaff = array ();
  6898. $nowStaffList2 = array ();
  6899. foreach ( $verifyDetail as $key => $value ) {
  6900. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  6901. $verifyJSStaff = json_decode ( $value [3] );
  6902. foreach ( $verifyJSStaff as $m ) {
  6903. $staffK = explode ( "_", $m );
  6904. array_push ( $nowStaffList2, $staffK [0] );
  6905. }
  6906. // print_r($nowStaffList2);
  6907. }
  6908. }
  6909. $RoleVerifyStaff = array ();
  6910. foreach ( $verifyStaff as $key => $value ) {
  6911. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  6912. foreach ( $nowStaffList2 as $m ) {
  6913. if ($key == $m . "_R")
  6914. $RoleVerifyStaff [$key] = $value;
  6915. }
  6916. }
  6917. }
  6918. // print_r($verifyStaff);
  6919. // print_r($nowStaffList2);
  6920. // print_r($RoleVerifyStaff);
  6921. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  6922. // print_r($verifyJSStaff);
  6923. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  6924. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  6925. // 下一个审批人ID
  6926. $nextStaff = 0;
  6927. $falg = false;
  6928. foreach ( $verifyDetail as $key => $value ) {
  6929. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  6930. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  6931. $falg = true;
  6932. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  6933. $nowStaffList = array ();
  6934. foreach ( $vStaffString as $v ) {
  6935. $staffK = explode ( "_", $v );
  6936. array_push ( $nowStaffList, $staffK [0] );
  6937. }
  6938. $nowStaff = implode ( ',', $nowStaffList );
  6939. $nextStaff = $verifyDetail [$key + 1] [0];
  6940. } elseif (isset ( $verifyDetail [$key + 1] )) {
  6941. $nextStaff = $verifyDetail [$key + 1] [0];
  6942. $nowStaff = $nextStaff;
  6943. } else
  6944. $nowStaff = '';
  6945. break;
  6946. }
  6947. }
  6948. if ($falg)
  6949. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6950. 'date' => date ( 'Y-m-d' ),
  6951. 'opinion' => $opinion,
  6952. 'status' => $status,
  6953. 'nextStaff' => $nextStaff,
  6954. 'ROLE' => 1
  6955. );
  6956. else
  6957. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6958. 'date' => date ( 'Y-m-d' ),
  6959. 'opinion' => $opinion,
  6960. 'status' => $status,
  6961. 'nextStaff' => $nextStaff
  6962. );
  6963. // print_r($verifyStaff);
  6964. // echo $nowStaff;die;
  6965. } else { // 进入下一个角色或者审批人
  6966. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  6967. //
  6968. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  6969. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6970. 'date' => date ( 'Y-m-d' ),
  6971. 'opinion' => $opinion,
  6972. 'status' => $status,
  6973. 'nextStaff' => $VS ['nextStaff'],
  6974. 'ROLE' => 1
  6975. );
  6976. // print_r($verifyStaff);
  6977. // die;
  6978. }
  6979. if ($status == 3) {
  6980. $verifyStaff ['final'] = $status;
  6981. $verifyStaff [$this->staff [0] ['sid']] = array (
  6982. 'date' => date ( 'Y-m-d' ),
  6983. 'opinion' => $opinion,
  6984. 'status' => $status
  6985. );
  6986. }
  6987. $vStaffString = json_encode ( $verifyStaff );
  6988. $receipt->verifyStaff = $vStaffString;
  6989. $receipt->nowStaff = $nowStaff;
  6990. // die;
  6991. // }
  6992. // print_r($verifyStaff);
  6993. // die;
  6994. }
  6995. // print_r($verifyStaff);die;
  6996. }
  6997. // print_r($verifyDetail);
  6998. $roleKey = 0;
  6999. $roleId = 0;
  7000. $verifyDetailCopy = array ();
  7001. foreach ( $verifyDetail as $k => $v ) {
  7002. if ($v [1] == 'ROLE') {
  7003. $roleId = $v [0];
  7004. $roleVerify = json_decode ( $v [3], true );
  7005. $roleKey = $k;
  7006. $roleArray = array ();
  7007. foreach ( $roleVerify as $o => $p ) {
  7008. $staffID = explode ( '_', $p );
  7009. $exp = array (
  7010. 0 => $staffID [0],
  7011. 1 => $staffID [1]
  7012. );
  7013. array_push ( $roleArray, $exp );
  7014. }
  7015. $verifyDetailCopy [$v [0]] = $roleArray;
  7016. }
  7017. }
  7018. // print_r($verifyDetail);
  7019. foreach ( $verifyDetailCopy as $k => $v ) {
  7020. foreach ( $verifyDetail as $m => $n ) {
  7021. if ($n [0] == $k) {
  7022. array_splice ( $verifyDetail, $m, 1, $v );
  7023. }
  7024. }
  7025. }
  7026. // die;
  7027. // if (!empty($roleArray))
  7028. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  7029. // echo $roleId;
  7030. // print_r($verifyStaff);
  7031. // print_r($verifyDetail);
  7032. // die;
  7033. Doo::loadModel ( "receiptLog" );
  7034. $receiptLog = new receiptLog ();
  7035. // 审批日志
  7036. if (! isset ( $verifyStaff ['final'] )) {
  7037. if (! empty ( $roleId )) {
  7038. Doo::loadModel ( "role" );
  7039. $role = new role ();
  7040. $roleInfo = $role->getOne ( array (
  7041. 'where' => 'rid=' . $roleId,
  7042. 'asArray' => true
  7043. ) );
  7044. $receiptLog->rolename = $roleInfo ['name'];
  7045. }
  7046. $receiptLog->username = $this->staff [0] ['username'];
  7047. $receiptLog->uid = $this->staff [0] ['sid'];
  7048. $receiptLog->date = date ( "Y-m-d" );
  7049. $receiptLog->opinion = $opinion;
  7050. $receiptLog->img = $this->staff [0] ['avatar'];
  7051. $receiptLog->status = 1;
  7052. $receiptLog->rid = $rid;
  7053. $receiptLog->insert ();
  7054. }
  7055. if (isset ( $verifyStaff ['final'] )) { // rDetail
  7056. $receipt->verifyBreakup = $verifyString;
  7057. $receipt->status = 3;
  7058. $receiptDetailObj->status = 3;
  7059. $receiptDetailObj->update ( array (
  7060. 'where' => 'rid=' . $rid
  7061. ) );
  7062. if (! empty ( $roleId )) {
  7063. Doo::loadModel ( "role" );
  7064. $role = new role ();
  7065. $roleInfo = $role->getOne ( array (
  7066. 'where' => 'rid=' . $roleId,
  7067. 'asArray' => true
  7068. ) );
  7069. $receiptLog->rolename = $roleInfo ['name'];
  7070. }
  7071. $receiptLog->username = $this->staff [0] ['username'];
  7072. $receiptLog->uid = $this->staff [0] ['sid'];
  7073. $receiptLog->date = date ( "Y-m-d" );
  7074. $receiptLog->opinion = $opinion;
  7075. $receiptLog->img = $this->staff [0] ['avatar'];
  7076. $receiptLog->status = 3;
  7077. $receiptLog->rid = $rid;
  7078. $receiptLog->insert ();
  7079. // 微信企业号通知
  7080. $this->setWXMsg ( $rid, 3 );
  7081. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  7082. $receipt->status = 1;
  7083. $reviseSum = 0;
  7084. $receipt->verifyBreakup = $verifyString;
  7085. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  7086. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7087. foreach ( $reviseDetail as $key => $value ) {
  7088. $receiptDetailObj = new receiptDetail ();
  7089. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7090. $receiptDetailObj->item = $value ['description'];
  7091. $receiptDetailObj->itemCategory = "报销金额调整";
  7092. $receiptDetailObj->price = $value ['price'];
  7093. $receiptDetailObj->date = $receiptDetail ['date'];
  7094. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  7095. $receiptDetailObj->rid = $rid;
  7096. $receiptDetailObj->status = 1;
  7097. $receiptDetailObj->insert ();
  7098. $reviseSum += $value ['price'];
  7099. }
  7100. $itemStatistics = new itemStatistics ();
  7101. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7102. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7103. $itemStatistics->price = $reviseSum;
  7104. $itemStatistics->itemCategory = "报销金额调整";
  7105. $itemStatistics->date = $receiptDetail ['date'];
  7106. $itemStatistics->insert ();
  7107. }
  7108. $receiptDetailObj = new receiptDetail ();
  7109. $receiptDetailObj->status = 1;
  7110. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  7111. $receiptDetailObj->update ( array (
  7112. 'where' => 'rid=' . $rid
  7113. ) );
  7114. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7115. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7116. $stat = $statistics->getOne ( array (
  7117. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  7118. 'asArray' => true
  7119. ) );
  7120. if (empty ( $stat )) {
  7121. $statistics->date = $receiptDetail ['date'];
  7122. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7123. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7124. $statistics->agPrice = $receiptDetail ['sum'];
  7125. $statistics->rePrice = $reviseSum;
  7126. $statistics->insert ();
  7127. } else {
  7128. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  7129. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  7130. $statistics->update ( array (
  7131. 'where' => 'sid=' . $stat ['sid']
  7132. ) );
  7133. }
  7134. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7135. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7136. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  7137. foreach ( $accountItem ['cSum'] as $key => $value ) {
  7138. if ($key == "agencySum") {
  7139. $iStatistics = $itemStatistics->getOne ( array (
  7140. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  7141. 'asArray' => true
  7142. ) );
  7143. if (empty ( $iStatistics )) {
  7144. $itemStatistics->cid = $receiptDetail ['cid'];
  7145. ;
  7146. $itemStatistics->staff = $receiptDetail ['staff'];
  7147. $itemStatistics->price = $value;
  7148. $itemStatistics->itemCategory = $this->AGENCY;
  7149. $itemStatistics->date = $receiptDetail ['date'];
  7150. $itemStatistics->insert ();
  7151. } else {
  7152. if (! empty ( $value )) {
  7153. $itemStatistics->price = $value + $iStatistics ['price'];
  7154. $itemStatistics->update ( array (
  7155. 'where' => 'sid=' . $iStatistics ['sid']
  7156. ) );
  7157. }
  7158. }
  7159. } elseif ($key == "travelSum") {
  7160. $iStatistics = $itemStatistics->getOne ( array (
  7161. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  7162. 'asArray' => true
  7163. ) );
  7164. if (empty ( $iStatistics )) {
  7165. $itemStatistics->cid = $receiptDetail ['cid'];
  7166. $itemStatistics->staff = $receiptDetail ['staff'];
  7167. $itemStatistics->price = $value;
  7168. $itemStatistics->itemCategory = $this->TRAVEL;
  7169. $itemStatistics->date = $receiptDetail ['date'];
  7170. $itemStatistics->insert ();
  7171. } else {
  7172. if (! empty ( $value )) {
  7173. $itemStatistics->price = $value + $iStatistics ['price'];
  7174. $itemStatistics->update ( array (
  7175. 'where' => 'sid=' . $iStatistics ['sid']
  7176. ) );
  7177. }
  7178. }
  7179. } elseif ($key == "trainSum") {
  7180. $iStatistics = $itemStatistics->getOne ( array (
  7181. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  7182. 'asArray' => true
  7183. ) );
  7184. if (empty ( $iStatistics )) {
  7185. $itemStatistics->cid = $receiptDetail ['cid'];
  7186. $itemStatistics->staff = $receiptDetail ['staff'];
  7187. $itemStatistics->price = $value;
  7188. $itemStatistics->itemCategory = $this->TRAIN;
  7189. $itemStatistics->date = $receiptDetail ['date'];
  7190. $itemStatistics->insert ();
  7191. } else {
  7192. if (! empty ( $value )) {
  7193. $itemStatistics->price = $value + $iStatistics ['price'];
  7194. $itemStatistics->update ( array (
  7195. 'where' => 'sid=' . $iStatistics ['sid']
  7196. ) );
  7197. }
  7198. }
  7199. } elseif ($key == "otherSum") {
  7200. $iStatistics = $itemStatistics->getOne ( array (
  7201. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  7202. 'asArray' => true
  7203. ) );
  7204. if (empty ( $iStatistics )) {
  7205. $itemStatistics->cid = $receiptDetail ['cid'];
  7206. $itemStatistics->staff = $receiptDetail ['staff'];
  7207. $itemStatistics->price = $value;
  7208. $itemStatistics->itemCategory = $this->OTHER;
  7209. $itemStatistics->date = $receiptDetail ['date'];
  7210. $itemStatistics->insert ();
  7211. } else {
  7212. if (! empty ( $value )) {
  7213. $itemStatistics->price = $value + $iStatistics ['price'];
  7214. $itemStatistics->update ( array (
  7215. 'where' => 'sid=' . $iStatistics ['sid']
  7216. ) );
  7217. }
  7218. }
  7219. }
  7220. }
  7221. $receipt->pastDate = date ( "Y-m-d" );
  7222. // 微信企业号通知
  7223. $this->setWXMsg ( $rid, 1 );
  7224. }
  7225. $receipt->amount = $amount;
  7226. $receipt->update ( array (
  7227. 'where' => ' rid = ' . $rid
  7228. ) );
  7229. // 进入下一条审批费用新加需求
  7230. $vidList = array ();
  7231. $verifyDetail = $verify->find ( array (
  7232. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  7233. 'asArray' => true
  7234. ) );
  7235. foreach ( $verifyDetail as $key => $value ) {
  7236. array_push ( $vidList, $value ['vid'] );
  7237. }
  7238. $vid = implode ( ",", $vidList );
  7239. if (empty ( $verifyDetail ))
  7240. $vid = 0;
  7241. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  7242. $receipt = new receipt ();
  7243. $rd = $receipt->getOne ( array (
  7244. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  7245. 'asc' => 'rid',
  7246. 'asArray' => true
  7247. ) );
  7248. if (empty ( $rd )) {
  7249. return '/approvalExpenses/pendApproval';
  7250. }
  7251. if ($rd ['Rtype'] == 1) {
  7252. if ($rd ['isBK'] == 1) {
  7253. return '/receiptburEdi/' . $rd ['rid'];
  7254. } else {
  7255. return '/expensesEdi/' . $rd ['rid'];
  7256. }
  7257. } elseif ($rd ['Rtype'] == 2) {
  7258. return '/remitApproval/' . $rd ['rid'];
  7259. } else {
  7260. return '/receiptburEdi/' . $rd ['rid'];
  7261. }
  7262. // return "/approvalExpenses/pendApproval";
  7263. }
  7264. }
  7265. function expensesRetreats() {
  7266. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7267. if (! empty ( $rid )) {
  7268. // 操作记录
  7269. Doo::loadModel ( "receipt" );
  7270. $receipt = new receipt ();
  7271. Doo::loadModel ( "receiptLog" );
  7272. $receiptLog = new receiptLog ();
  7273. Doo::loadModel ( "verify" );
  7274. $verify = new verify ();
  7275. $receiptInfo = $receipt->getOne ( array (
  7276. 'where' => 'rid=' . $rid,
  7277. 'asArray' => true
  7278. ) );
  7279. $vr = $verify->getOne ( array (
  7280. 'where' => 'vid=' . $receiptInfo ['verify'],
  7281. 'asArray' => true
  7282. ) );
  7283. $jd = json_decode ( $vr ['staff'] );
  7284. $roleId = 0;
  7285. foreach ( $jd as $key => $value ) {
  7286. if ($value [1] == 'ROLE') {
  7287. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7288. if ($pos !== false) {
  7289. $roleId = $value [0];
  7290. }
  7291. }
  7292. }
  7293. // 审批日志
  7294. // echo $roleId;die;
  7295. if (! empty ( $roleId )) {
  7296. Doo::loadModel ( "role" );
  7297. $role = new role ();
  7298. $roleInfo = $role->getOne ( array (
  7299. 'where' => 'rid=' . $roleId,
  7300. 'asArray' => true
  7301. ) );
  7302. $receiptLog->rolename = $roleInfo ['name'];
  7303. }
  7304. $receiptLog->username = $this->staff [0] ['username'];
  7305. $receiptLog->uid = $this->staff [0] ['sid'];
  7306. $receiptLog->date = date ( "Y-m-d" );
  7307. $receiptLog->opinion = '撤回';
  7308. $receiptLog->img = $this->staff [0] ['avatar'];
  7309. $receiptLog->status = 4;
  7310. $receiptLog->rid = $rid;
  7311. $receiptLog->insert ();
  7312. $receipt->status = 4;
  7313. $receipt->update ( array (
  7314. 'where' => 'rid=' . $rid
  7315. ) );
  7316. // 微信企业号通知
  7317. $this->setWXMsg ( $rid, 2 );
  7318. }
  7319. // echo "ddd";
  7320. return '/approvalExpenses/pendApproval';
  7321. }
  7322. function updateCheReceipt() {
  7323. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7324. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7325. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  7326. if (! empty ( $rid )) {
  7327. // 操作记录
  7328. Doo::loadModel ( "receipt" );
  7329. $receipt = new receipt ();
  7330. Doo::loadModel ( "receiptLog" );
  7331. $receiptLog = new receiptLog ();
  7332. Doo::loadModel ( "verify" );
  7333. $verify = new verify ();
  7334. $receiptInfo = $receipt->getOne ( array (
  7335. 'where' => 'rid=' . $rid . ' and status=2',
  7336. 'asArray' => true
  7337. ) );
  7338. if (empty ( $receiptInfo )) {
  7339. echo json_encode ( array (
  7340. 'status' => 2
  7341. ) );
  7342. die ();
  7343. }
  7344. $vr = $verify->getOne ( array (
  7345. 'where' => 'vid=' . $receiptInfo ['verify'],
  7346. 'asArray' => true
  7347. ) );
  7348. $jd = json_decode ( $vr ['staff'] );
  7349. $roleId = 0;
  7350. foreach ( $jd as $key => $value ) {
  7351. if ($value [1] == 'ROLE') {
  7352. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7353. if ($pos !== false) {
  7354. $roleId = $value [0];
  7355. }
  7356. }
  7357. }
  7358. // 审批日志
  7359. // echo $roleId;die;
  7360. if (! empty ( $roleId )) {
  7361. Doo::loadModel ( "role" );
  7362. $role = new role ();
  7363. $roleInfo = $role->getOne ( array (
  7364. 'where' => 'rid=' . $roleId,
  7365. 'asArray' => true
  7366. ) );
  7367. $receiptLog->rolename = $roleInfo ['name'];
  7368. }
  7369. $receiptLog->username = $this->staff [0] ['username'];
  7370. $receiptLog->uid = $this->staff [0] ['sid'];
  7371. $receiptLog->date = date ( "Y-m-d" );
  7372. $receiptLog->opinion = $opinion;
  7373. $receiptLog->img = $this->staff [0] ['avatar'];
  7374. $receiptLog->status = 4;
  7375. $receiptLog->rid = $rid;
  7376. $receiptLog->insert ();
  7377. $receipt->status = 4;
  7378. $receipt->update ( array (
  7379. 'where' => 'rid=' . $rid
  7380. ) );
  7381. // 微信企业号通知
  7382. $this->setWXMsg ( $rid, 2 );
  7383. echo json_encode ( array (
  7384. 'status' => 1
  7385. ) );
  7386. // Header("HTTP/1.1 303 See Other");
  7387. // Header("Location: /approvalExpenses/pendApproval");
  7388. die ();
  7389. }
  7390. echo json_encode ( array (
  7391. 'status' => 2
  7392. ) );
  7393. die ();
  7394. // echo "ddd";
  7395. // return '/saeaBorad';
  7396. }
  7397. function revisePrice() {
  7398. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  7399. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  7400. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7401. // echo $price;die;
  7402. if (! empty ( $rid )) {
  7403. Doo::loadModel ( "receipt" );
  7404. $receipt = new receipt ();
  7405. $receiptDetail = $receipt->getOne ( array (
  7406. 'where' => 'rid=' . $rid . ' and status=2 ',
  7407. 'asArray' => true
  7408. ) );
  7409. if (empty ( $receiptDetail ))
  7410. return "/approval";
  7411. $reviseDetail = array ();
  7412. if (empty ( $receiptDetail ['reviseDetail'] )) {
  7413. array_push ( $reviseDetail, array (
  7414. 'sid' => $this->staff [0] ['sid'],
  7415. 'name' => $this->staff [0] ['username'],
  7416. 'description' => $description,
  7417. 'price' => $price
  7418. ) );
  7419. $reviseDetailString = json_encode ( $reviseDetail );
  7420. $receipt->reviseDetail = $reviseDetailString;
  7421. $receipt->revisePrice = $price;
  7422. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7423. } else {
  7424. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7425. array_push ( $reviseDetail, array (
  7426. 'sid' => $this->staff [0] ['sid'],
  7427. 'name' => $this->staff [0] ['username'],
  7428. 'description' => $description,
  7429. 'price' => $price
  7430. ) );
  7431. $reviseDetailString = json_encode ( $reviseDetail );
  7432. $receipt->reviseDetail = $reviseDetailString;
  7433. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  7434. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7435. }
  7436. $receipt->update ( array (
  7437. 'where' => 'rid=' . $rid
  7438. ) );
  7439. }
  7440. return '/approvalEdi/' . $rid;
  7441. }
  7442. function personalCollect() {
  7443. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7444. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  7445. $this->showCache ( $path );
  7446. Doo::loadModel ( "receiptDetail" );
  7447. Doo::loadModel ( "itemStatistics" );
  7448. Doo::loadModel ( 'statistics' );
  7449. $statistics = new statistics ();
  7450. $itemStatistics = new itemStatistics ();
  7451. $receiptDetail = new receiptDetail ();
  7452. $receiptCollectList = $receiptDetail->find ( array (
  7453. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7454. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7455. 'groupby' => 'itemCategory,Month(date)',
  7456. 'asArray' => true
  7457. ) );
  7458. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  7459. 'where' => 'staff=' . $this->staff [0] ['sid'],
  7460. 'asArray' => true
  7461. ) );
  7462. // create collect html
  7463. $collectArray = array (
  7464. '日常相关费用' => array (),
  7465. '差旅相关费用' => array (),
  7466. '培训班费用' => array (),
  7467. '其他' => array ()
  7468. );
  7469. $adjustment = array ();
  7470. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  7471. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7472. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  7473. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7474. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  7475. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7476. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  7477. array_push ( $collectArray ['其他'], $collectHtml );
  7478. $data ['collectArray'] = $collectArray;
  7479. // statistics html
  7480. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7481. if (empty ( $stList ))
  7482. $stList = array (
  7483. 'rePrice' => 0,
  7484. 'agPrice' => 0
  7485. );
  7486. $data ['stList'] = array (
  7487. 'rePrice' => $stList ['rePrice'],
  7488. 'agPrice' => $stList ['agPrice'],
  7489. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7490. );
  7491. // Adjustment price html
  7492. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7493. array_push ( $adjustment, $collectHtml );
  7494. $data ['adjustment'] = $adjustment;
  7495. // total price html
  7496. $collectHtml = "";
  7497. $total = 0;
  7498. for($i = 1; $i <= 12; $i ++) {
  7499. $sumPrice = 0;
  7500. foreach ( $receiptCollectList as $key => $value ) {
  7501. if ($value ['month'] == $i) {
  7502. $sumPrice += $value ['price'];
  7503. }
  7504. }
  7505. if ($sumPrice == 0)
  7506. $collectHtml .= '<td class="taR">-</td>';
  7507. else
  7508. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7509. $total += $sumPrice;
  7510. }
  7511. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7512. $data ['totalPrice'] = $collectHtml;
  7513. $data ['year'] = $year;
  7514. $data ['totalYear'] = $total;
  7515. $data ['memu'] = "receipt";
  7516. $data ['staff'] = $this->staff;
  7517. $data ['receiptMemu'] = 'personalCollect';
  7518. $data ['verifyId'] = $this->verifyId;
  7519. $data ['executeId'] = $this->executeId;
  7520. // year staff status 2,4
  7521. if ($year < date ( "Y" )) {
  7522. Doo::loadModel ( 'receipt' );
  7523. $receipt = new receipt ();
  7524. $receiptList = $receipt->find ( array (
  7525. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7526. 'asArray' => true
  7527. ) );
  7528. if (empty ( $receiptList )) {
  7529. ob_start ();
  7530. $this->render ( "/admin/saea_slist_collect", $data );
  7531. $this->cacheFile ( $path );
  7532. die ();
  7533. }
  7534. }
  7535. $this->render ( "/admin/saea_slist_collect", $data );
  7536. }
  7537. function personalCollectDetail() {
  7538. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7539. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  7540. $this->showCache ( $path );
  7541. Doo::loadModel ( "receiptDetail" );
  7542. Doo::loadModel ( "itemStatistics" );
  7543. Doo::loadModel ( 'statistics' );
  7544. Doo::loadModel ( 'accountItem' );
  7545. $accountItem = new accountItem ();
  7546. $statistics = new statistics ();
  7547. $itemStatistics = new itemStatistics ();
  7548. $receiptDetail = new receiptDetail ();
  7549. $receiptCollectList = $receiptDetail->find ( array (
  7550. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  7551. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7552. 'groupby' => 'item,Month(date)',
  7553. 'asArray' => true
  7554. ) );
  7555. $accountList = $accountItem->find ( array (
  7556. 'asArray' => true
  7557. ) );
  7558. // create CollectDetail HTML
  7559. $collectHtml = array ();
  7560. foreach ( $accountList as $key => $value ) {
  7561. $html = "";
  7562. $asum = 0;
  7563. for($i = 1; $i <= 12; $i ++) {
  7564. $falg = true;
  7565. foreach ( $receiptCollectList as $v ) {
  7566. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7567. $asum += $v ['price'];
  7568. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7569. $falg = false;
  7570. break;
  7571. }
  7572. }
  7573. if ($falg)
  7574. $html .= '<td class="taR">-</td>';
  7575. }
  7576. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7577. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7578. }
  7579. $data ['collectHtml'] = $collectHtml;
  7580. // create Adjustment price html
  7581. $receiptCollectList = $receiptDetail->find ( array (
  7582. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7583. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7584. 'groupby' => 'itemCategory,Month(date)',
  7585. 'asArray' => true
  7586. ) );
  7587. $adjustment = array ();
  7588. $collectArray = array (
  7589. '日常相关费用' => array (),
  7590. '差旅相关费用' => array (),
  7591. '培训班费用' => array (),
  7592. '其他' => array ()
  7593. );
  7594. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7595. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7596. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7597. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7598. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7599. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7600. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7601. array_push ( $collectArray ['其他'], $collectHtml );
  7602. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7603. array_push ( $adjustment, $collectHtml );
  7604. // total price html
  7605. $collectHtml = "";
  7606. $total = 0;
  7607. for($i = 1; $i <= 12; $i ++) {
  7608. $sumPrice = 0;
  7609. foreach ( $receiptCollectList as $key => $value ) {
  7610. if ($value ['month'] == $i) {
  7611. $sumPrice += $value ['price'];
  7612. }
  7613. }
  7614. if ($sumPrice == 0)
  7615. $collectHtml .= '<td class="taR">-</td>';
  7616. else
  7617. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7618. $total += $sumPrice;
  7619. }
  7620. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7621. // statistics html
  7622. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7623. if (empty ( $stList ))
  7624. $stList = array (
  7625. 'rePrice' => 0,
  7626. 'agPrice' => 0
  7627. );
  7628. $data ['stList'] = array (
  7629. 'rePrice' => $stList ['rePrice'],
  7630. 'agPrice' => $stList ['agPrice'],
  7631. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7632. );
  7633. $data ['collectArray'] = $collectArray;
  7634. $data ['adjustment'] = $adjustment;
  7635. $data ['totalPrice'] = $collectHtml;
  7636. $data ['totalYear'] = $total;
  7637. $data ['year'] = $year;
  7638. $data ['memu'] = "receipt";
  7639. $data ['staff'] = $this->staff;
  7640. $data ['receiptMemu'] = 'personalCollect';
  7641. $data ['verifyId'] = $this->verifyId;
  7642. $data ['executeId'] = $this->executeId;
  7643. // year staff status 2,4
  7644. if ($year < date ( "Y" )) {
  7645. Doo::loadModel ( 'receipt' );
  7646. $receipt = new receipt ();
  7647. $receiptList = $receipt->find ( array (
  7648. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7649. 'asArray' => true
  7650. ) );
  7651. if (empty ( $receiptList )) {
  7652. ob_start ();
  7653. $this->render ( "/admin/saeaCollectArticles", $data );
  7654. $this->cacheFile ( $path );
  7655. die ();
  7656. }
  7657. }
  7658. $this->render ( "/admin/saeaCollectArticles", $data );
  7659. }
  7660. function companyCategoryCollect() {
  7661. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7662. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  7663. $this->showCache ( $path );
  7664. Doo::loadModel ( 'L_category' );
  7665. Doo::loadModel ( 'itemStatistics' );
  7666. Doo::loadModel ( 'statistics' );
  7667. $statistics = new statistics ();
  7668. $Lcategory = new L_category ();
  7669. $itemStatistics = new itemStatistics ();
  7670. $LcategoryList = $Lcategory->find ( array (
  7671. 'asArray' => true
  7672. ) ); // 'staff='.$this->staff[0]['sid']." and
  7673. $itemStatisticsList = $itemStatistics->find ( array (
  7674. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7675. 'where' => " Year(date)=" . $year,
  7676. 'groupby' => 'cid,Month(date)',
  7677. 'asArray' => true
  7678. ) );
  7679. // ceatre companyCollectHtml
  7680. foreach ( $LcategoryList as $value ) {
  7681. $html = "";
  7682. $asum = 0;
  7683. for($i = 1; $i <= 12; $i ++) {
  7684. $falg = true;
  7685. foreach ( $itemStatisticsList as $v ) {
  7686. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  7687. $asum += $v ['price'];
  7688. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7689. $falg = false;
  7690. break;
  7691. }
  7692. }
  7693. if ($falg)
  7694. $html .= '<td class="taR">-</td>';
  7695. }
  7696. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7697. $collectHtml [$value ['title']] = array (
  7698. 'html' => $html,
  7699. 'cid' => $value ['cid']
  7700. );
  7701. }
  7702. $data ['companyHtml'] = $collectHtml;
  7703. // total price html
  7704. $collectHtml = "";
  7705. $total = 0;
  7706. for($i = 1; $i <= 12; $i ++) {
  7707. $sumPrice = 0;
  7708. foreach ( $itemStatisticsList as $key => $value ) {
  7709. if ($value ['month'] == $i) {
  7710. $sumPrice += $value ['price'];
  7711. }
  7712. }
  7713. if ($sumPrice == 0)
  7714. $collectHtml .= '<td class="taR">-</td>';
  7715. else
  7716. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7717. $total += $sumPrice;
  7718. }
  7719. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7720. $data ['companyTotalHtml'] = $collectHtml;
  7721. $data ['total'] = $total;
  7722. // statistics html
  7723. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7724. if (empty ( $stList ))
  7725. $stList = array (
  7726. 'rePrice' => 0,
  7727. 'agPrice' => 0
  7728. );
  7729. $data ['stList'] = array (
  7730. 'rePrice' => $stList ['rePrice'],
  7731. 'agPrice' => $stList ['agPrice'],
  7732. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7733. );
  7734. $data ['year'] = $year;
  7735. $data ['memu'] = "receipt";
  7736. $data ['staff'] = $this->staff;
  7737. $data ['receiptMemu'] = 'companyCategoryCollect';
  7738. $data ['verifyId'] = $this->verifyId;
  7739. $data ['executeId'] = $this->executeId;
  7740. // year staff status 2,4
  7741. if ($year < date ( "Y" )) {
  7742. Doo::loadModel ( 'receipt' );
  7743. $receipt = new receipt ();
  7744. $receiptList = $receipt->find ( array (
  7745. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  7746. 'asArray' => true
  7747. ) );
  7748. if (empty ( $receiptList )) {
  7749. ob_start ();
  7750. $this->render ( "/admin/saeaCompanyCollect", $data );
  7751. $this->cacheFile ( $path );
  7752. die ();
  7753. }
  7754. }
  7755. $this->render ( "/admin/saeaCompanyCollect", $data );
  7756. }
  7757. function categoryCollectDetail() {
  7758. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7759. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  7760. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  7761. $this->showCache ( $path );
  7762. Doo::loadModel ( 'statistics' );
  7763. $statistics = new statistics ();
  7764. Doo::loadModel ( "receiptDetail" );
  7765. $receiptDetail = new receiptDetail ();
  7766. Doo::loadModel ( 'L_category' );
  7767. $Lcategory = new L_category ();
  7768. Doo::loadModel ( 'accountItem' );
  7769. $accountItem = new accountItem ();
  7770. $LcategoryList = $Lcategory->find ( array (
  7771. 'asArray' => true
  7772. ) );
  7773. if ($cid == 0) {
  7774. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7775. if ($cid == 0)
  7776. $cid = $LcategoryList [0] ['cid'];
  7777. }
  7778. $data ['LcategoryList'] = $LcategoryList;
  7779. $receiptCollectList = $receiptDetail->find ( array (
  7780. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  7781. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7782. 'groupby' => 'item,Month(pastDate)',
  7783. 'asArray' => true
  7784. ) );
  7785. $accountList = $accountItem->find ( array (
  7786. 'asArray' => true
  7787. ) );
  7788. // create CollectDetail HTML
  7789. $collectHtml = array ();
  7790. foreach ( $accountList as $key => $value ) {
  7791. $html = "";
  7792. $asum = 0;
  7793. for($i = 1; $i <= 12; $i ++) {
  7794. $falg = true;
  7795. foreach ( $receiptCollectList as $v ) {
  7796. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7797. $asum += $v ['price'];
  7798. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7799. $falg = false;
  7800. break;
  7801. }
  7802. }
  7803. if ($falg)
  7804. $html .= '<td class="taR">-</td>';
  7805. }
  7806. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7807. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7808. }
  7809. $data ['collectHtml'] = $collectHtml;
  7810. // create Adjustment price html
  7811. $receiptCollectList = $receiptDetail->find ( array (
  7812. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  7813. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7814. 'groupby' => 'itemCategory,Month(pastDate)',
  7815. 'asArray' => true
  7816. ) );
  7817. $adjustment = array ();
  7818. $collectArray = array (
  7819. '日常相关费用' => array (),
  7820. '差旅相关费用' => array (),
  7821. '培训班费用' => array (),
  7822. '其他' => array ()
  7823. );
  7824. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7825. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7826. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7827. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7828. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7829. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7830. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7831. array_push ( $collectArray ['其他'], $collectHtml );
  7832. $data ['collectArray'] = $collectArray;
  7833. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7834. array_push ( $adjustment, $collectHtml );
  7835. $data ['adjustment'] = $adjustment;
  7836. // total price html
  7837. $collectHtml = "";
  7838. $total = 0;
  7839. for($i = 1; $i <= 12; $i ++) {
  7840. $sumPrice = 0;
  7841. foreach ( $receiptCollectList as $key => $value ) {
  7842. if ($value ['month'] == $i) {
  7843. $sumPrice += $value ['price'];
  7844. }
  7845. }
  7846. if ($sumPrice == 0)
  7847. $collectHtml .= '<td class="taR">-</td>';
  7848. else
  7849. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7850. $total += $sumPrice;
  7851. }
  7852. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7853. // statistics html
  7854. $stList = $statistics->statisticsByCid ( $year, $cid );
  7855. if (empty ( $stList ))
  7856. $stList = array (
  7857. 'rePrice' => 0,
  7858. 'agPrice' => 0
  7859. );
  7860. $data ['stList'] = array (
  7861. 'rePrice' => $stList ['rePrice'],
  7862. 'agPrice' => $stList ['agPrice'],
  7863. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7864. );
  7865. $data ['totalYear'] = $total;
  7866. $data ['year'] = $year;
  7867. $data ['cid'] = $cid;
  7868. $data ['memu'] = "receipt";
  7869. $data ['staff'] = $this->staff;
  7870. $data ['receiptMemu'] = 'companyCategoryCollect';
  7871. $data ['verifyId'] = $this->verifyId;
  7872. $data ['executeId'] = $this->executeId;
  7873. // year staff status 2,4
  7874. if ($year < date ( "Y" )) {
  7875. Doo::loadModel ( 'receipt' );
  7876. $receipt = new receipt ();
  7877. $receiptList = $receipt->find ( array (
  7878. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  7879. 'asArray' => true
  7880. ) );
  7881. if (empty ( $receiptList )) {
  7882. ob_start ();
  7883. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7884. $this->cacheFile ( $path );
  7885. die ();
  7886. }
  7887. }
  7888. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7889. }
  7890. function staffCollect() {
  7891. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7892. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  7893. // $this->showCache($path);
  7894. Doo::loadModel ( 'statistics' );
  7895. $statistics = new statistics ();
  7896. Doo::loadModel ( "receiptDetail" );
  7897. $receiptDetail = new receiptDetail ();
  7898. Doo::loadModel ( 'L_category' );
  7899. $Lcategory = new L_category ();
  7900. Doo::loadModel ( 'accountItem' );
  7901. $accountItem = new accountItem ();
  7902. Doo::loadModel ( 'staff' );
  7903. $staff = new staff ();
  7904. Doo::loadModel ( 'itemStatistics' );
  7905. $itemStatistics = new itemStatistics ();
  7906. /*
  7907. * $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']));
  7908. */
  7909. // statistics html
  7910. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7911. if (empty ( $stList ))
  7912. $stList = array (
  7913. 'rePrice' => 0,
  7914. 'agPrice' => 0
  7915. );
  7916. $data ['stList'] = array (
  7917. 'rePrice' => $stList ['rePrice'],
  7918. 'agPrice' => $stList ['agPrice'],
  7919. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7920. );
  7921. // ---
  7922. $staffList = $staff->find ( array (
  7923. 'where' => 'username !="admin"',
  7924. 'asArray' => true
  7925. ) );
  7926. $LcategoryList = $Lcategory->find ( array (
  7927. 'asArray' => true
  7928. ) ); // 'staff='.$this->staff[0]['sid']." and
  7929. $itemStatisticsList = $itemStatistics->find ( array (
  7930. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7931. 'where' => " Year(date)=" . $year,
  7932. 'groupby' => 'staff,Month(date)',
  7933. 'asArray' => true
  7934. ) );
  7935. $categoryList = $staff->find ( array (
  7936. 'select' => 'COUNT(*) as count,cid,category',
  7937. 'where' => 'username !="admin"',
  7938. 'groupby' => 'cid',
  7939. 'asArray' => true
  7940. ) );
  7941. // print_r($itemStatisticsList);die;
  7942. // ceatre companyCollectHtml
  7943. foreach ( $categoryList as $vlu ) {
  7944. $count = $vlu ['count'] + 1;
  7945. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  7946. $m1 = 0;
  7947. $m2 = 0;
  7948. $m3 = 0;
  7949. $m4 = 0;
  7950. $m5 = 0;
  7951. $m6 = 0;
  7952. $m7 = 0;
  7953. $m8 = 0;
  7954. $m9 = 0;
  7955. $m10 = 0;
  7956. $m11 = 0;
  7957. $m12 = 0;
  7958. $m13 = 0;
  7959. foreach ( $staffList as $value ) {
  7960. if ($vlu ['cid'] == $value ['cid']) {
  7961. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  7962. $asum = 0;
  7963. for($i = 1; $i <= 12; $i ++) {
  7964. $falg = true;
  7965. foreach ( $itemStatisticsList as $v ) {
  7966. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  7967. if ($v ['month'] == 1)
  7968. $m1 += $v ['price'];
  7969. if ($v ['month'] == 2)
  7970. $m2 += $v ['price'];
  7971. if ($v ['month'] == 3)
  7972. $m3 += $v ['price'];
  7973. if ($v ['month'] == 4)
  7974. $m4 += $v ['price'];
  7975. if ($v ['month'] == 5)
  7976. $m5 += $v ['price'];
  7977. if ($v ['month'] == 6)
  7978. $m6 += $v ['price'];
  7979. if ($v ['month'] == 7)
  7980. $m7 += $v ['price'];
  7981. if ($v ['month'] == 8)
  7982. $m8 += $v ['price'];
  7983. if ($v ['month'] == 9)
  7984. $m9 += $v ['price'];
  7985. if ($v ['month'] == 10)
  7986. $m10 += $v ['price'];
  7987. if ($v ['month'] == 11)
  7988. $m11 += $v ['price'];
  7989. if ($v ['month'] == 12)
  7990. $m12 += $v ['price'];
  7991. $asum += $v ['price'];
  7992. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7993. $falg = false;
  7994. break;
  7995. }
  7996. }
  7997. if ($falg)
  7998. $html .= '<td class="taR">-</td>';
  7999. }
  8000. $m13 += $asum;
  8001. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8002. $collectHtml [$value ['username'].'_'.$value['sid']] = array (
  8003. 'html' => $html,
  8004. 'sid' => $value ['sid']
  8005. );
  8006. $html = "";
  8007. }
  8008. }
  8009. $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>
  8010. <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>
  8011. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  8012. $collectHtml [$vlu ['cid']] = array (
  8013. 'html' => $hl,
  8014. 'sid' => ''
  8015. );
  8016. }
  8017. $data ['companyHtml'] = $collectHtml;
  8018. // total price html
  8019. $collectHtml = "";
  8020. $total = 0;
  8021. for($i = 1; $i <= 12; $i ++) {
  8022. $sumPrice = 0;
  8023. foreach ( $itemStatisticsList as $key => $value ) {
  8024. if ($value ['month'] == $i) {
  8025. $sumPrice += $value ['price'];
  8026. }
  8027. }
  8028. if ($sumPrice == 0)
  8029. $collectHtml .= '<td class="taR">-</td>';
  8030. else
  8031. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8032. $total += $sumPrice;
  8033. }
  8034. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8035. $data ['companyTotalHtml'] = $collectHtml;
  8036. $data ['total'] = $total;
  8037. $data ['year'] = $year;
  8038. $data ['memu'] = "receipt";
  8039. $data ['staff'] = $this->staff;
  8040. $data ['receiptMemu'] = 'companyCategoryCollect';
  8041. $data ['verifyId'] = $this->verifyId;
  8042. $data ['executeId'] = $this->executeId;
  8043. if ($year <= date ( "Y" )) {
  8044. Doo::loadModel ( 'receipt' );
  8045. $receipt = new receipt ();
  8046. $receiptList = $receipt->find ( array (
  8047. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  8048. 'asArray' => true
  8049. ) );
  8050. if (empty ( $receiptList )) { // generated files
  8051. ob_start ();
  8052. $this->render ( "/admin/saeaStaffCollectB", $data );
  8053. $this->cacheFile ( $path );
  8054. die ();
  8055. }
  8056. }
  8057. $this->render ( "/admin/saeaStaffCollectB", $data );
  8058. }
  8059. function staffCollectBak() {
  8060. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8061. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  8062. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  8063. $this->showCache ( $path );
  8064. Doo::loadModel ( 'statistics' );
  8065. $statistics = new statistics ();
  8066. Doo::loadModel ( "receiptDetail" );
  8067. $receiptDetail = new receiptDetail ();
  8068. Doo::loadModel ( 'L_category' );
  8069. $Lcategory = new L_category ();
  8070. Doo::loadModel ( 'accountItem' );
  8071. $accountItem = new accountItem ();
  8072. Doo::loadModel ( 'staff' );
  8073. $staff = new staff ();
  8074. Doo::loadModel ( 'itemStatistics' );
  8075. $itemStatistics = new itemStatistics ();
  8076. $itemStatisticsList = $itemStatistics->find ( array (
  8077. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8078. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8079. 'groupby' => 'staff,itemCategory,Month(date)',
  8080. 'asArray' => true
  8081. ) );
  8082. $itemCategoryList = $itemStatistics->find ( array (
  8083. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8084. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8085. 'groupby' => 'cid,itemCategory,Month(date)',
  8086. 'asArray' => true
  8087. ) );
  8088. $LcategoryList = $Lcategory->find ( array (
  8089. 'asArray' => true
  8090. ) );
  8091. $staffList = $staff->find ( array (
  8092. 'asArray' => true
  8093. ) );
  8094. $htmlArray = array ();
  8095. foreach ( $LcategoryList as $value ) {
  8096. $htmlArray [$value ['title']] = array ();
  8097. foreach ( $staffList as $v ) {
  8098. if ($value ['cid'] == $v ['cid']) {
  8099. $html = "";
  8100. $falg = true;
  8101. $staffSumPrice = 0;
  8102. foreach ( $itemStatisticsList as $a ) {
  8103. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  8104. if (empty ( $a ['price'] )) {
  8105. $html .= '<td class="taR">-</td>';
  8106. $falg = false;
  8107. break;
  8108. } else {
  8109. $staffSumPrice += $a ['price'];
  8110. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8111. $falg = false;
  8112. break;
  8113. }
  8114. }
  8115. }
  8116. if ($falg) {
  8117. $html .= '<td class="taR">-</td>';
  8118. $falg = true;
  8119. }
  8120. $falg = true;
  8121. foreach ( $itemStatisticsList as $a ) {
  8122. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  8123. if (empty ( $a ['price'] )) {
  8124. $html .= '<td class="taR">-</td>';
  8125. $falg = false;
  8126. break;
  8127. } else {
  8128. $staffSumPrice += $a ['price'];
  8129. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8130. $falg = false;
  8131. break;
  8132. }
  8133. }
  8134. }
  8135. if ($falg) {
  8136. $html .= '<td class="taR">-</td>';
  8137. $falg = true;
  8138. }
  8139. $falg = true;
  8140. foreach ( $itemStatisticsList as $a ) {
  8141. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  8142. if (empty ( $a ['price'] )) {
  8143. $html .= '<td class="taR">-</td>';
  8144. $falg = false;
  8145. break;
  8146. } else {
  8147. $staffSumPrice += $a ['price'];
  8148. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8149. $falg = false;
  8150. break;
  8151. }
  8152. }
  8153. }
  8154. if ($falg) {
  8155. $html .= '<td class="taR">-</td>';
  8156. $falg = true;
  8157. }
  8158. $falg = true;
  8159. foreach ( $itemStatisticsList as $a ) {
  8160. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  8161. if (! empty ( $a ['price'] )) {
  8162. $staffSumPrice += $a ['price'];
  8163. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8164. $falg = false;
  8165. break;
  8166. } else {
  8167. $html .= '<td class="taR">-</td>';
  8168. $falg = false;
  8169. break;
  8170. }
  8171. }
  8172. }
  8173. if ($falg) {
  8174. $html .= '<td class="taR">-</td>';
  8175. $falg = true;
  8176. }
  8177. $falg = true;
  8178. foreach ( $itemStatisticsList as $a ) {
  8179. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  8180. if (! empty ( $a ['price'] )) {
  8181. $staffSumPrice += $a ['price'];
  8182. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8183. $falg = false;
  8184. break;
  8185. } else {
  8186. $html .= '<td class="taR">-</td>';
  8187. $falg = false;
  8188. break;
  8189. }
  8190. }
  8191. }
  8192. if ($falg) {
  8193. $html .= '<td class="taR">-</td>';
  8194. $falg = true;
  8195. }
  8196. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  8197. $htmlArray [$value ['title']] [$v ['username']] = $html;
  8198. }
  8199. }
  8200. /* -- --- */
  8201. // 合计费用
  8202. $cateHtml = "";
  8203. $catePrice = 0;
  8204. $cateFalg = true;
  8205. foreach ( $itemCategoryList as $l ) {
  8206. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  8207. if (empty ( $l ['price'] )) {
  8208. $cateHtml .= '<td class="colGreen taR">-</td>';
  8209. $cateFalg = false;
  8210. break;
  8211. } else {
  8212. $catePrice += $l ['price'];
  8213. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8214. $cateFalg = false;
  8215. break;
  8216. }
  8217. }
  8218. }
  8219. if ($cateFalg) {
  8220. $cateHtml .= '<td class="colGreen taR">-</td>';
  8221. $cateFalg = true;
  8222. }
  8223. $cateFalg = true;
  8224. foreach ( $itemCategoryList as $l ) {
  8225. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  8226. if (empty ( $l ['price'] )) {
  8227. $cateHtml .= '<td class="colGreen taR">-</td>';
  8228. $cateFalg = false;
  8229. break;
  8230. } else {
  8231. $catePrice += $l ['price'];
  8232. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8233. $cateFalg = false;
  8234. break;
  8235. }
  8236. }
  8237. }
  8238. if ($cateFalg) {
  8239. $cateHtml .= '<td class="colGreen taR">-</td>';
  8240. $cateFalg = true;
  8241. }
  8242. $cateFalg = true;
  8243. foreach ( $itemCategoryList as $l ) {
  8244. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  8245. if (empty ( $l ['price'] )) {
  8246. $cateHtml .= '<td class="colGreen taR">-</td>';
  8247. $cateFalg = false;
  8248. break;
  8249. } else {
  8250. $catePrice += $l ['price'];
  8251. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8252. $cateFalg = false;
  8253. break;
  8254. }
  8255. }
  8256. }
  8257. if ($cateFalg) {
  8258. $cateHtml .= '<td class="colGreen taR">-</td>';
  8259. $cateFalg = true;
  8260. }
  8261. $cateFalg = true;
  8262. foreach ( $itemCategoryList as $l ) {
  8263. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  8264. if (empty ( $l ['price'] )) {
  8265. $cateHtml .= '<td class="colGreen taR">-</td>';
  8266. $cateFalg = false;
  8267. break;
  8268. } else {
  8269. $catePrice += $l ['price'];
  8270. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8271. $cateFalg = false;
  8272. break;
  8273. }
  8274. }
  8275. }
  8276. if ($cateFalg) {
  8277. $cateHtml .= '<td class="colGreen taR">-</td>';
  8278. $cateFalg = true;
  8279. }
  8280. $cateFalg = true;
  8281. foreach ( $itemCategoryList as $l ) {
  8282. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  8283. if (empty ( $l ['price'] )) {
  8284. $cateHtml .= '<td class="colGreen taR">-</td>';
  8285. $cateFalg = false;
  8286. break;
  8287. } else {
  8288. $catePrice += $l ['price'];
  8289. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8290. $cateFalg = false;
  8291. break;
  8292. }
  8293. }
  8294. }
  8295. if ($cateFalg) {
  8296. $cateHtml .= '<td class="colGreen taR">-</td>';
  8297. $cateFalg = true;
  8298. }
  8299. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  8300. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  8301. /* -- --- */
  8302. }
  8303. // print_r($htmlArray);die;
  8304. $data ['htmlArray'] = $htmlArray;
  8305. // statistics html
  8306. $stList = $statistics->getOne ( array (
  8307. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8308. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8309. 'groupby' => 'Month(date)',
  8310. 'asArray' => true
  8311. ) );
  8312. if (empty ( $stList ))
  8313. $stList = array (
  8314. 'rePrice' => 0,
  8315. 'agPrice' => 0
  8316. );
  8317. $data ['stList'] = array (
  8318. 'rePrice' => $stList ['rePrice'],
  8319. 'agPrice' => $stList ['agPrice'],
  8320. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8321. );
  8322. $monthHtml = "";
  8323. for($i = 1; $i <= 12; $i ++) {
  8324. if ($i == $month)
  8325. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8326. else
  8327. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8328. }
  8329. $data ['monthHtml'] = $monthHtml;
  8330. $data ['year'] = $year;
  8331. $data ['month'] = $month;
  8332. $data ['memu'] = "receipt";
  8333. $data ['staff'] = $this->staff;
  8334. $data ['receiptMemu'] = 'companyCategoryCollect';
  8335. $data ['verifyId'] = $this->verifyId;
  8336. $data ['executeId'] = $this->executeId;
  8337. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  8338. Doo::loadModel ( 'receipt' );
  8339. $receipt = new receipt ();
  8340. $receiptList = $receipt->find ( array (
  8341. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  8342. 'asArray' => true
  8343. ) );
  8344. if (empty ( $receiptList )) { // generated files
  8345. ob_start ();
  8346. $this->render ( "/admin/saeaStaffCollect", $data );
  8347. $this->cacheFile ( $path );
  8348. die ();
  8349. }
  8350. }
  8351. $this->render ( "/admin/saeaStaffCollect", $data );
  8352. }
  8353. function lyt() {
  8354. Doo::loadModel ( "receiptDetail" );
  8355. $receiptDetail = new receiptDetail ();
  8356. $receiptCollectList = $receiptDetail->find ( array (
  8357. 'where' => 'status=1 ',
  8358. 'asArray' => true
  8359. ) );
  8360. foreach ( $receiptCollectList as $key => $value ) {
  8361. $receiptDetail = new receiptDetail ();
  8362. $receiptDetail->pastDate = $value ['date'];
  8363. $receiptDetail->update ( array (
  8364. 'where' => "rdid= '" . $value ['rdid'] . "'"
  8365. ) );
  8366. }
  8367. }
  8368. function staffCollectMonthDetail() {
  8369. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8370. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8371. if (! $year)
  8372. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8373. if (! $month)
  8374. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8375. Doo::loadModel ( 'staff' );
  8376. $staff = new staff ();
  8377. Doo::loadModel ( "receiptDetail" );
  8378. $receiptDetail = new receiptDetail ();
  8379. Doo::loadModel ( 'accountItem' );
  8380. $accountItem = new accountItem ();
  8381. Doo::loadModel ( 'statistics' );
  8382. $statistics = new statistics ();
  8383. Doo::loadModel ( 'L_category' );
  8384. $lCategory = new L_category ();
  8385. $staffList = $staff->find ( array (
  8386. 'where' => 'username!="admin"',
  8387. 'asArray' => true
  8388. ) );
  8389. $categoryList = $staff->find ( array (
  8390. 'select' => 'COUNT(*) as count,cid,category',
  8391. 'where' => 'username !="admin"',
  8392. 'groupby' => 'cid',
  8393. 'asArray' => true
  8394. ) );
  8395. $list = array ();
  8396. foreach ( $categoryList as $vlu ) {
  8397. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8398. $r1 = 0;
  8399. $r2 = 0;
  8400. $r3 = 0;
  8401. $r4 = 0;
  8402. $r5 = 0;
  8403. $r6 = 0;
  8404. $r7 = 0;
  8405. $r8 = 0;
  8406. $r9 = 0;
  8407. $r10 = 0;
  8408. $r11 = 0;
  8409. $r12 = 0;
  8410. $r13 = 0;
  8411. $r14 = 0;
  8412. $r15 = 0;
  8413. $r16 = 0;
  8414. $r17 = 0;
  8415. $r18 = 0;
  8416. $c1 = 0;
  8417. $c2 = 0;
  8418. $c3 = 0;
  8419. $c4 = 0;
  8420. $c5 = 0;
  8421. $c6 = 0;
  8422. $p1 = 0;
  8423. $p2 = 0;
  8424. $p3 = 0;
  8425. $p4 = 0;
  8426. $p5 = 0;
  8427. $p6 = 0;
  8428. $p7 = 0;
  8429. $p8 = 0;
  8430. $p9 = 0;
  8431. $t1 = 0;
  8432. $t2 = 0;
  8433. $t3 = 0;
  8434. $t4 = 0;
  8435. $t5 = 0;
  8436. $s1 = 0;
  8437. $m1 = 0;
  8438. foreach ( $staffList as $value ) {
  8439. if ($vlu ['cid'] == $value ['cid']) {
  8440. // pastDate
  8441. $receiptCollectList = $receiptDetail->find ( array (
  8442. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8443. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8444. 'groupby' => 'item,Month(pastDate),itemCategory',
  8445. 'asArray' => true
  8446. ) );
  8447. // if ($value['sid']==42){
  8448. // print_r($receiptCollectList);die;
  8449. // }
  8450. if (! empty ( $receiptCollectList )) {
  8451. $receiptL = array (
  8452. '日常相关费用' => array (),
  8453. '差旅相关费用' => array (),
  8454. '培训班费用' => array (),
  8455. '其他' => array ()
  8456. );
  8457. $html = "";
  8458. $psum = 0;
  8459. $item = array (
  8460. '市内交通费',
  8461. '市内出租费',
  8462. '办事处房租',
  8463. '电话费',
  8464. '水费',
  8465. '电费',
  8466. '办公费用',
  8467. '邮寄费',
  8468. '其他费用',
  8469. '车辆费用',
  8470. '广告费',
  8471. '团队建设费',
  8472. '物业管理费',
  8473. '宽带费',
  8474. '人员薪酬',
  8475. '公积金',
  8476. '社保'
  8477. );
  8478. foreach ( $item as $va ) {
  8479. $falg = true;
  8480. foreach ( $receiptCollectList as $v ) {
  8481. if ($v ['itemCategory'] == '日常相关费用') {
  8482. if ($v ['item'] == $va) {
  8483. if ($va == '市内交通费')
  8484. $r1 += $v ['price'];
  8485. if ($va == '市内出租费')
  8486. $r2 += $v ['price'];
  8487. if ($va == '办事处房租')
  8488. $r3 += $v ['price'];
  8489. if ($va == '电话费')
  8490. $r4 += $v ['price'];
  8491. if ($va == '水费')
  8492. $r5 += $v ['price'];
  8493. if ($va == '电费')
  8494. $r6 += $v ['price'];
  8495. if ($va == '办公费用')
  8496. $r7 += $v ['price'];
  8497. if ($va == '邮寄费')
  8498. $r8 += $v ['price'];
  8499. if ($va == '其他费用')
  8500. $r9 += $v ['price'];
  8501. if ($va == '车辆费用')
  8502. $r10 += $v ['price'];
  8503. if ($va == '广告费')
  8504. $r11 += $v ['price'];
  8505. if ($va == '团队建设费')
  8506. $r13 += $v ['price'];
  8507. if ($va == '物业管理费')
  8508. $r14 += $v ['price'];
  8509. if ($va == '宽带费')
  8510. $r15 += $v ['price'];
  8511. if ($va == '公积金')
  8512. $r16 += $v ['price'];
  8513. if ($va == '社保')
  8514. $r17 += $v ['price'];
  8515. if ($va == '人员薪酬')
  8516. $r18 += $v ['price'];
  8517. $psum += $v ['price'];
  8518. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8519. $falg = false;
  8520. break;
  8521. }
  8522. }
  8523. }
  8524. if ($falg)
  8525. $html .= '<td class="taR">-</td>';
  8526. }
  8527. $r12 += $psum;
  8528. if (! empty ( $psum ))
  8529. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8530. else
  8531. $psum = '<td class="colGreen taR">-</td>';
  8532. $receiptL ['日常相关费用'] = $psum . $html;
  8533. /* ----------------------------------- */
  8534. $html = "";
  8535. $psum = 0;
  8536. $item = array (
  8537. '往来交通费',
  8538. '市内交通费',
  8539. '出差住宿费',
  8540. '出差补助',
  8541. '其他费用'
  8542. );
  8543. foreach ( $item as $va ) {
  8544. $falg = true;
  8545. foreach ( $receiptCollectList as $v ) {
  8546. if ($v ['itemCategory'] == '差旅相关费用') {
  8547. if ($v ['item'] == $va) {
  8548. if ($va == '往来交通费')
  8549. $c1 += $v ['price'];
  8550. if ($va == '市内交通费')
  8551. $c2 += $v ['price'];
  8552. if ($va == '出差住宿费')
  8553. $c3 += $v ['price'];
  8554. if ($va == '出差补助')
  8555. $c4 += $v ['price'];
  8556. if ($va == '其他费用')
  8557. $c5 += $v ['price'];
  8558. $psum += $v ['price'];
  8559. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8560. $falg = false;
  8561. break;
  8562. }
  8563. }
  8564. }
  8565. if ($falg)
  8566. $html .= '<td class="taR">-</td>';
  8567. }
  8568. $c6 += $psum;
  8569. if (! empty ( $psum ))
  8570. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8571. else
  8572. $psum = '<td class="colGreen taR">-</td>';
  8573. $receiptL ['差旅相关费用'] = $psum . $html;
  8574. /* ------------------------------------- */
  8575. $html = "";
  8576. $psum = 0;
  8577. $item = array (
  8578. '场租费',
  8579. '薪酬',
  8580. '住宿费',
  8581. '交通费',
  8582. '餐饮费',
  8583. '办公费',
  8584. '公关费',
  8585. '其他'
  8586. );
  8587. foreach ( $item as $va ) {
  8588. $falg = true;
  8589. foreach ( $receiptCollectList as $v ) {
  8590. if ($v ['itemCategory'] == '培训班费用') {
  8591. if ($v ['item'] == $va) {
  8592. if ($va == '场租费')
  8593. $p1 += $v ['price'];
  8594. if ($va == '薪酬')
  8595. $p2 += $v ['price'];
  8596. if ($va == '住宿费')
  8597. $p3 += $v ['price'];
  8598. if ($va == '交通费')
  8599. $p4 += $v ['price'];
  8600. if ($va == '餐饮费')
  8601. $p5 += $v ['price'];
  8602. if ($va == '办公费')
  8603. $p6 += $v ['price'];
  8604. if ($va == '公关费')
  8605. $p7 += $v ['price'];
  8606. if ($va == '其他')
  8607. $p8 += $v ['price'];
  8608. $psum += $v ['price'];
  8609. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8610. $falg = false;
  8611. break;
  8612. }
  8613. }
  8614. }
  8615. if ($falg)
  8616. $html .= '<td class="taR">-</td>';
  8617. }
  8618. $p9 += $psum;
  8619. if (! empty ( $psum ))
  8620. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8621. else
  8622. $psum = '<td class="colGreen taR">-</td>';
  8623. $receiptL ['培训班费用'] = $psum . $html;
  8624. /* ------------------------------------- */
  8625. $html = "";
  8626. $psum = 0;
  8627. $item = array (
  8628. '公关费',
  8629. '广告费',
  8630. '借款',
  8631. '可自加费用'
  8632. );
  8633. foreach ( $item as $va ) {
  8634. $falg = true;
  8635. foreach ( $receiptCollectList as $v ) {
  8636. if ($v ['itemCategory'] == '其他') {
  8637. // if ($value['sid']==42){
  8638. //
  8639. // echo var_dump($v['item']);
  8640. // echo var_dump($va);
  8641. // echo var_dump($v['item']==" ".$va);
  8642. // echo $v['item']."==".$va."/<br/>";
  8643. // //print_r( $receiptCollectList);//echo $va;
  8644. // }
  8645. if (trim ( $v ['item'] ) == $va) {
  8646. if ($va == '公关费')
  8647. $t1 += $v ['price'];
  8648. if ($va == '广告费') {
  8649. $t2 += $v ['price'];
  8650. }
  8651. if ($va == '借款')
  8652. $t3 += $v ['price'];
  8653. if ($va == '可自加费用')
  8654. $t4 += $v ['price'];
  8655. $psum += $v ['price'];
  8656. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8657. $falg = false;
  8658. break;
  8659. }
  8660. }
  8661. }
  8662. if ($falg)
  8663. $html .= '<td class="taR">-</td>';
  8664. }
  8665. $t5 += $psum;
  8666. if (! empty ( $psum ))
  8667. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8668. else
  8669. $psum = '<td class="colGreen taR">-</td>';
  8670. $receiptL ['其他'] = $psum . $html;
  8671. /* ------------------------------------- */
  8672. $html = "";
  8673. $psum = 0;
  8674. foreach ( $receiptCollectList as $v ) {
  8675. if ($v ['itemCategory'] == '报销金额调整') {
  8676. if (! empty ( $v ['price'] )) {
  8677. $psum += $v ['price'];
  8678. }
  8679. }
  8680. }
  8681. $s1 += $psum;
  8682. if (! empty ( $psum ))
  8683. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8684. else
  8685. $psum = '<td class="taR colOrange">-</td>';
  8686. $receiptL ['报销金额调整'] = $psum . $html;
  8687. } else {
  8688. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8689. <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>
  8690. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8691. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  8692. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8693. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8694. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8695. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8696. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  8697. }
  8698. $monthStaffPrice = $receiptDetail->find ( array (
  8699. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8700. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8701. 'groupby' => 'Month(pastDate)',
  8702. 'asArray' => true
  8703. ) );
  8704. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  8705. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  8706. $m1 += $monthStaffPrice [0] ['price'];
  8707. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  8708. } else
  8709. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  8710. $list [$value ['username']] = $receiptL;
  8711. }
  8712. }
  8713. $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>
  8714. <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>
  8715. <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>';
  8716. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  8717. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  8718. $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>
  8719. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  8720. $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>';
  8721. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  8722. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  8723. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  8724. }
  8725. $data ['list'] = $list;
  8726. $receiptCollectList = $receiptDetail->find ( array (
  8727. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8728. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8729. 'groupby' => 'item,Month(pastDate),itemCategory',
  8730. 'asArray' => true
  8731. ) );
  8732. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  8733. // statistics html
  8734. $stList = $statistics->getOne ( array (
  8735. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8736. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8737. 'groupby' => 'Month(date)',
  8738. 'asArray' => true
  8739. ) );
  8740. if (empty ( $stList ))
  8741. $stList = array (
  8742. 'rePrice' => 0,
  8743. 'agPrice' => 0
  8744. );
  8745. $data ['stList'] = array (
  8746. 'rePrice' => $stList ['rePrice'],
  8747. 'agPrice' => $stList ['agPrice'],
  8748. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8749. );
  8750. $monthHtml = "";
  8751. for($i = 1; $i <= 12; $i ++) {
  8752. if ($i == $month)
  8753. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8754. else
  8755. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8756. }
  8757. $data ['monthHtml'] = $monthHtml;
  8758. $data ['year'] = $year;
  8759. $data ['month'] = $month;
  8760. $data ['memu'] = "receipt";
  8761. $data ['staff'] = $this->staff;
  8762. $data ['receiptMemu'] = 'companyCategoryCollect';
  8763. $data ['verifyId'] = $this->verifyId;
  8764. $data ['executeId'] = $this->executeId;
  8765. $this->render ( "/admin/staffCollectMonthDetail", $data );
  8766. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  8767. }
  8768. function staffCollectMonthDetail2() {
  8769. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8770. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8771. if (! $year)
  8772. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8773. if (! $month)
  8774. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8775. Doo::loadModel ( 'staff' );
  8776. $staff = new staff ();
  8777. Doo::loadModel ( "receiptDetail" );
  8778. $receiptDetail = new receiptDetail ();
  8779. Doo::loadModel ( 'accountItem' );
  8780. $accountItem = new accountItem ();
  8781. Doo::loadModel ( 'statistics' );
  8782. $statistics = new statistics ();
  8783. Doo::loadModel ( 'L_category' );
  8784. $lCategory = new L_category ();
  8785. $staffList = $staff->find ( array (
  8786. 'where' => 'username!="admin"',
  8787. 'asArray' => true
  8788. ) );
  8789. $categoryList = $staff->find ( array (
  8790. 'select' => 'COUNT(*) as count,cid,category',
  8791. 'where' => 'username !="admin"',
  8792. 'groupby' => 'cid',
  8793. 'asArray' => true
  8794. ) );
  8795. $list = array ();
  8796. foreach ( $categoryList as $vlu ) {
  8797. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8798. $r1 = 0;
  8799. $r2 = 0;
  8800. $r3 = 0;
  8801. $r4 = 0;
  8802. $r5 = 0;
  8803. $r6 = 0;
  8804. $r7 = 0;
  8805. $r8 = 0;
  8806. $r9 = 0;
  8807. $r10 = 0;
  8808. $r11 = 0;
  8809. $r12 = 0;
  8810. $r13 = 0;
  8811. $r14 = 0;
  8812. $r15 = 0;
  8813. $c1 = 0;
  8814. $c2 = 0;
  8815. $c3 = 0;
  8816. $c4 = 0;
  8817. $c5 = 0;
  8818. $c6 = 0;
  8819. $p1 = 0;
  8820. $p2 = 0;
  8821. $p3 = 0;
  8822. $p4 = 0;
  8823. $p5 = 0;
  8824. $p6 = 0;
  8825. $p7 = 0;
  8826. $p8 = 0;
  8827. $p9 = 0;
  8828. $t1 = 0;
  8829. $t2 = 0;
  8830. $t3 = 0;
  8831. $t4 = 0;
  8832. $t5 = 0;
  8833. $s1 = 0;
  8834. $m1 = 0;
  8835. foreach ( $staffList as $value ) {
  8836. if ($vlu ['cid'] == $value ['cid']) {
  8837. $receiptCollectList = $receiptDetail->find ( array (
  8838. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  8839. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  8840. 'groupby' => 'item,Month(date),itemCategory',
  8841. 'asArray' => true
  8842. ) );
  8843. if (! empty ( $receiptCollectList )) {
  8844. $receiptL = array (
  8845. '日常相关费用' => array (),
  8846. '差旅相关费用' => array (),
  8847. '培训班费用' => array (),
  8848. '其他' => array ()
  8849. );
  8850. $html = "";
  8851. $psum = 0;
  8852. $item = array (
  8853. '市内交通费',
  8854. '市内出租费',
  8855. '办事处房租',
  8856. '电话费',
  8857. '水费',
  8858. '电费',
  8859. '办公费用',
  8860. '邮寄费',
  8861. '其他费用',
  8862. '车辆费用',
  8863. '广告费',
  8864. '团队建设费',
  8865. '物业管理费',
  8866. '宽带费'
  8867. );
  8868. foreach ( $item as $va ) {
  8869. $falg = true;
  8870. foreach ( $receiptCollectList as $v ) {
  8871. if ($v ['itemCategory'] == '日常相关费用') {
  8872. if ($v ['item'] == $va) {
  8873. if ($va == '市内交通费')
  8874. $r1 += $v ['price'];
  8875. if ($va == '市内出租费')
  8876. $r2 += $v ['price'];
  8877. if ($va == '办事处房租')
  8878. $r3 += $v ['price'];
  8879. if ($va == '电话费')
  8880. $r4 += $v ['price'];
  8881. if ($va == '水费')
  8882. $r5 += $v ['price'];
  8883. if ($va == '电费')
  8884. $r6 += $v ['price'];
  8885. if ($va == '办公费用')
  8886. $r7 += $v ['price'];
  8887. if ($va == '邮寄费')
  8888. $r8 += $v ['price'];
  8889. if ($va == '其他费用')
  8890. $r9 += $v ['price'];
  8891. if ($va == '车辆费用')
  8892. $r10 += $v ['price'];
  8893. if ($va == '广告费')
  8894. $r11 += $v ['price'];
  8895. if ($va == '团队建设费')
  8896. $r13 += $v ['price'];
  8897. if ($va == '物业管理费')
  8898. $r14 += $v ['price'];
  8899. if ($va == '宽带费')
  8900. $r15 += $v ['price'];
  8901. $psum += $v ['price'];
  8902. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8903. $falg = false;
  8904. break;
  8905. }
  8906. }
  8907. }
  8908. if ($falg)
  8909. $html .= '<td class="taR">-</td>';
  8910. }
  8911. $r12 += $psum;
  8912. if (! empty ( $psum ))
  8913. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8914. else
  8915. $psum = '<td class="colGreen taR">-</td>';
  8916. $receiptL ['日常相关费用'] = $psum . $html;
  8917. /* ----------------------------------- */
  8918. $html = "";
  8919. $psum = 0;
  8920. $item = array (
  8921. '往来交通费',
  8922. '市内交通费',
  8923. '出差住宿费',
  8924. '出差补助',
  8925. '其他费用'
  8926. );
  8927. foreach ( $item as $va ) {
  8928. $falg = true;
  8929. foreach ( $receiptCollectList as $v ) {
  8930. if ($v ['itemCategory'] == '差旅相关费用') {
  8931. if ($v ['item'] == $va) {
  8932. if ($va == '往来交通费')
  8933. $c1 += $v ['price'];
  8934. if ($va == '市内交通费')
  8935. $c2 += $v ['price'];
  8936. if ($va == '出差住宿费')
  8937. $c3 += $v ['price'];
  8938. if ($va == '出差补助')
  8939. $c4 += $v ['price'];
  8940. if ($va == '其他费用')
  8941. $c5 += $v ['price'];
  8942. $psum += $v ['price'];
  8943. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8944. $falg = false;
  8945. break;
  8946. }
  8947. }
  8948. }
  8949. if ($falg)
  8950. $html .= '<td class="taR">-</td>';
  8951. }
  8952. $c6 += $psum;
  8953. if (! empty ( $psum ))
  8954. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8955. else
  8956. $psum = '<td class="colGreen taR">-</td>';
  8957. $receiptL ['差旅相关费用'] = $psum . $html;
  8958. /* ------------------------------------- */
  8959. $html = "";
  8960. $psum = 0;
  8961. $item = array (
  8962. '场租费',
  8963. '薪酬',
  8964. '住宿费',
  8965. '交通费',
  8966. '餐饮费',
  8967. '办公费',
  8968. '公关费',
  8969. '其他'
  8970. );
  8971. foreach ( $item as $va ) {
  8972. $falg = true;
  8973. foreach ( $receiptCollectList as $v ) {
  8974. if ($v ['itemCategory'] == '培训班费用') {
  8975. if ($v ['item'] == $va) {
  8976. if ($va == '场租费')
  8977. $p1 += $v ['price'];
  8978. if ($va == '薪酬')
  8979. $p2 += $v ['price'];
  8980. if ($va == '住宿费')
  8981. $p3 += $v ['price'];
  8982. if ($va == '交通费')
  8983. $p4 += $v ['price'];
  8984. if ($va == '餐饮费')
  8985. $p5 += $v ['price'];
  8986. if ($va == '办公费')
  8987. $p6 += $v ['price'];
  8988. if ($va == '公关费')
  8989. $p7 += $v ['price'];
  8990. if ($va == '其他')
  8991. $p8 += $v ['price'];
  8992. $psum += $v ['price'];
  8993. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8994. $falg = false;
  8995. break;
  8996. }
  8997. }
  8998. }
  8999. if ($falg)
  9000. $html .= '<td class="taR">-</td>';
  9001. }
  9002. $p9 += $psum;
  9003. if (! empty ( $psum ))
  9004. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9005. else
  9006. $psum = '<td class="colGreen taR">-</td>';
  9007. $receiptL ['培训班费用'] = $psum . $html;
  9008. /* ------------------------------------- */
  9009. $html = "";
  9010. $psum = 0;
  9011. $item = array (
  9012. '公关费',
  9013. '广告费',
  9014. '借款',
  9015. '可自加费用'
  9016. );
  9017. foreach ( $item as $va ) {
  9018. $falg = true;
  9019. foreach ( $receiptCollectList as $v ) {
  9020. if ($v ['itemCategory'] == '其他') {
  9021. if ($v ['item'] == $va) {
  9022. if ($va == '公关费')
  9023. $t1 += $v ['price'];
  9024. if ($va == '广告费')
  9025. $t2 += $v ['price'];
  9026. if ($va == '借款')
  9027. $t3 += $v ['price'];
  9028. if ($va == '可自加费用')
  9029. $t4 += $v ['price'];
  9030. $psum += $v ['price'];
  9031. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9032. $falg = false;
  9033. break;
  9034. }
  9035. }
  9036. }
  9037. if ($falg)
  9038. $html .= '<td class="taR">-</td>';
  9039. }
  9040. $t5 += $psum;
  9041. if (! empty ( $psum ))
  9042. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9043. else
  9044. $psum = '<td class="colGreen taR">-</td>';
  9045. $receiptL ['其他'] = $psum . $html;
  9046. /* ------------------------------------- */
  9047. $html = "";
  9048. $psum = 0;
  9049. foreach ( $receiptCollectList as $v ) {
  9050. if ($v ['itemCategory'] == '报销金额调整') {
  9051. if (! empty ( $v ['price'] )) {
  9052. $psum += $v ['price'];
  9053. }
  9054. }
  9055. }
  9056. $s1 += $psum;
  9057. if (! empty ( $psum ))
  9058. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9059. else
  9060. $psum = '<td class="taR colOrange">-</td>';
  9061. $receiptL ['报销金额调整'] = $psum . $html;
  9062. } else {
  9063. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9064. <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>';
  9065. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9066. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9067. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9068. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9069. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9070. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9071. }
  9072. $monthStaffPrice = $receiptDetail->find ( array (
  9073. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9074. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9075. 'asArray' => true
  9076. ) );
  9077. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  9078. $m1 += $monthStaffPrice [0] ['price'];
  9079. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9080. } else
  9081. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9082. $list [$value ['username']] = $receiptL;
  9083. }
  9084. }
  9085. $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>
  9086. <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>
  9087. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  9088. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  9089. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  9090. $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>
  9091. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  9092. $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>';
  9093. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  9094. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  9095. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  9096. }
  9097. $data ['list'] = $list;
  9098. $receiptCollectList = $receiptDetail->find ( array (
  9099. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9100. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9101. 'groupby' => 'item,Month(date),itemCategory',
  9102. 'asArray' => true
  9103. ) );
  9104. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9105. // statistics html
  9106. $stList = $statistics->getOne ( array (
  9107. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9108. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9109. 'groupby' => 'Month(date)',
  9110. 'asArray' => true
  9111. ) );
  9112. if (empty ( $stList ))
  9113. $stList = array (
  9114. 'rePrice' => 0,
  9115. 'agPrice' => 0
  9116. );
  9117. $data ['stList'] = array (
  9118. 'rePrice' => $stList ['rePrice'],
  9119. 'agPrice' => $stList ['agPrice'],
  9120. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9121. );
  9122. $monthHtml = "";
  9123. for($i = 1; $i <= 12; $i ++) {
  9124. if ($i == $month)
  9125. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9126. else
  9127. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9128. }
  9129. $data ['monthHtml'] = $monthHtml;
  9130. $data ['year'] = $year;
  9131. $data ['month'] = $month;
  9132. $data ['memu'] = "receipt";
  9133. $data ['staff'] = $this->staff;
  9134. $data ['receiptMemu'] = 'companyCategoryCollect';
  9135. $data ['verifyId'] = $this->verifyId;
  9136. $data ['executeId'] = $this->executeId;
  9137. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  9138. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9139. }
  9140. function companyMonthCollectDetail() {
  9141. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9142. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9143. if (! $year)
  9144. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9145. if (! $month)
  9146. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9147. Doo::loadModel ( 'staff' );
  9148. $staff = new staff ();
  9149. Doo::loadModel ( "receiptDetail" );
  9150. $receiptDetail = new receiptDetail ();
  9151. Doo::loadModel ( 'accountItem' );
  9152. $accountItem = new accountItem ();
  9153. Doo::loadModel ( 'statistics' );
  9154. $statistics = new statistics ();
  9155. Doo::loadModel ( 'L_category' );
  9156. $lCategory = new L_category ();
  9157. $staffList = $staff->find ( array (
  9158. 'where' => 'username!="admin"',
  9159. 'asArray' => true
  9160. ) );
  9161. $categoryList = $lCategory->find ( array (
  9162. 'asArray' => true
  9163. ) );
  9164. $list = array ();
  9165. foreach ( $categoryList as $value ) {
  9166. $receiptCollectList = $receiptDetail->find ( array (
  9167. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9168. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9169. 'groupby' => 'item,Month(pastDate),itemCategory',
  9170. 'asArray' => true
  9171. ) );
  9172. if (! empty ( $receiptCollectList )) {
  9173. $receiptL = array (
  9174. '日常相关费用' => array (),
  9175. '差旅相关费用' => array (),
  9176. '培训班费用' => array (),
  9177. '其他' => array ()
  9178. );
  9179. $html = "";
  9180. $psum = 0;
  9181. $item = array (
  9182. '市内交通费',
  9183. '市内出租费',
  9184. '办事处房租',
  9185. '电话费',
  9186. '水费',
  9187. '电费',
  9188. '办公费用',
  9189. '邮寄费',
  9190. '其他费用',
  9191. '车辆费用',
  9192. '广告费',
  9193. '团队建设费'
  9194. );
  9195. foreach ( $item as $va ) {
  9196. $falg = true;
  9197. foreach ( $receiptCollectList as $v ) {
  9198. if ($v ['itemCategory'] == '日常相关费用') {
  9199. if ($v ['item'] == $va) {
  9200. $psum += $v ['price'];
  9201. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9202. $falg = false;
  9203. break;
  9204. }
  9205. }
  9206. }
  9207. if ($falg)
  9208. $html .= '<td class="taR">-</td>';
  9209. }
  9210. if (! empty ( $psum ))
  9211. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9212. else
  9213. $psum = '<td class="colGreen taR">-</td>';
  9214. $receiptL ['日常相关费用'] = $psum . $html;
  9215. /* ----------------------------------- */
  9216. $html = "";
  9217. $psum = 0;
  9218. $item = array (
  9219. '往来交通费',
  9220. '市内交通费',
  9221. '出差住宿费',
  9222. '出差补助',
  9223. '其他费用'
  9224. );
  9225. foreach ( $item as $va ) {
  9226. $falg = true;
  9227. foreach ( $receiptCollectList as $v ) {
  9228. if ($v ['itemCategory'] == '差旅相关费用') {
  9229. if ($v ['item'] == $va) {
  9230. $psum += $v ['price'];
  9231. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9232. $falg = false;
  9233. break;
  9234. }
  9235. }
  9236. }
  9237. if ($falg)
  9238. $html .= '<td class="taR">-</td>';
  9239. }
  9240. if (! empty ( $psum ))
  9241. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9242. else
  9243. $psum = '<td class="colGreen taR">-</td>';
  9244. $receiptL ['差旅相关费用'] = $psum . $html;
  9245. /* ------------------------------------- */
  9246. $html = "";
  9247. $psum = 0;
  9248. $item = array (
  9249. '场租费',
  9250. '薪酬',
  9251. '住宿费',
  9252. '交通费',
  9253. '餐饮费',
  9254. '办公费',
  9255. '公关费',
  9256. '其他'
  9257. );
  9258. foreach ( $item as $va ) {
  9259. $falg = true;
  9260. foreach ( $receiptCollectList as $v ) {
  9261. if ($v ['itemCategory'] == '培训班费用') {
  9262. if ($v ['item'] == $va) {
  9263. $psum += $v ['price'];
  9264. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9265. $falg = false;
  9266. break;
  9267. }
  9268. }
  9269. }
  9270. if ($falg)
  9271. $html .= '<td class="taR">-</td>';
  9272. }
  9273. if (! empty ( $psum ))
  9274. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9275. else
  9276. $psum = '<td class="colGreen taR">-</td>';
  9277. $receiptL ['培训班费用'] = $psum . $html;
  9278. /* ------------------------------------- */
  9279. $html = "";
  9280. $psum = 0;
  9281. $item = array (
  9282. '公关费',
  9283. '广告费',
  9284. '借款',
  9285. '可自加费用'
  9286. );
  9287. foreach ( $item as $va ) {
  9288. $falg = true;
  9289. foreach ( $receiptCollectList as $v ) {
  9290. if ($v ['itemCategory'] == '其他') {
  9291. if ($v ['item'] == $va) {
  9292. $psum += $v ['price'];
  9293. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9294. $falg = false;
  9295. break;
  9296. }
  9297. }
  9298. }
  9299. if ($falg)
  9300. $html .= '<td class="taR">-</td>';
  9301. }
  9302. if (! empty ( $psum ))
  9303. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9304. else
  9305. $psum = '<td class="colGreen taR">-</td>';
  9306. $receiptL ['其他'] = $psum . $html;
  9307. /* ------------------------------------- */
  9308. $html = "";
  9309. $psum = 0;
  9310. foreach ( $receiptCollectList as $v ) {
  9311. if ($v ['itemCategory'] == '报销金额调整') {
  9312. if (! empty ( $v ['price'] ))
  9313. $psum += $v ['price'];
  9314. }
  9315. }
  9316. if (! empty ( $psum ))
  9317. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9318. else
  9319. $psum = '<td class="taR colOrange">-</td>';
  9320. $receiptL ['报销金额调整'] = $psum . $html;
  9321. } else {
  9322. $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>
  9323. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9324. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9325. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9326. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9327. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9328. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9329. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9330. }
  9331. $monthStaffPrice = $receiptDetail->find ( array (
  9332. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9333. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9334. 'asArray' => true
  9335. ) );
  9336. if (! empty ( $monthStaffPrice [0] ['price'] ))
  9337. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9338. else
  9339. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9340. $list [$value ['title']] = $receiptL;
  9341. }
  9342. $data ['list'] = $list;
  9343. $receiptCollectList = $receiptDetail->find ( array (
  9344. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9345. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9346. 'groupby' => 'item,Month(pastDate),itemCategory',
  9347. 'asArray' => true
  9348. ) );
  9349. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9350. // print_r($data['monthPriceHtml']);
  9351. // foreach ($data['monthPriceHtml'] as $value){
  9352. // echo $value;
  9353. // }
  9354. // die;
  9355. // statistics html
  9356. $stList = $statistics->getOne ( array (
  9357. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9358. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9359. 'groupby' => 'Month(date)',
  9360. 'asArray' => true
  9361. ) );
  9362. if (empty ( $stList ))
  9363. $stList = array (
  9364. 'rePrice' => 0,
  9365. 'agPrice' => 0
  9366. );
  9367. $data ['stList'] = array (
  9368. 'rePrice' => $stList ['rePrice'],
  9369. 'agPrice' => $stList ['agPrice'],
  9370. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9371. );
  9372. $monthHtml = "";
  9373. for($i = 1; $i <= 12; $i ++) {
  9374. if ($i == $month)
  9375. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9376. else
  9377. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9378. }
  9379. $data ['monthHtml'] = $monthHtml;
  9380. $data ['year'] = $year;
  9381. $data ['month'] = $month;
  9382. $data ['memu'] = "receipt";
  9383. $data ['staff'] = $this->staff;
  9384. $data ['receiptMemu'] = 'companyCategoryCollect';
  9385. $data ['verifyId'] = $this->verifyId;
  9386. $data ['executeId'] = $this->executeId;
  9387. $this->render ( "/admin/companyMonthCollectDetail", $data );
  9388. }
  9389. function staffCollectDetail() {
  9390. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9391. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  9392. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  9393. if (! $staffname) {
  9394. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  9395. $staffname = urldecode ( $staffname );
  9396. }
  9397. Doo::loadModel ( 'staff' );
  9398. $staff = new staff ();
  9399. Doo::loadModel ( "receiptDetail" );
  9400. $receiptDetail = new receiptDetail ();
  9401. Doo::loadModel ( 'accountItem' );
  9402. $accountItem = new accountItem ();
  9403. Doo::loadModel ( 'statistics' );
  9404. $statistics = new statistics ();
  9405. Doo::loadModel ( 'L_category' );
  9406. $lCategory = new L_category ();
  9407. $staffList = $staff->find ( array (
  9408. 'asArray' => true
  9409. ) );
  9410. $stHtml = '';
  9411. $stTitle = "";
  9412. $staffId = 0;
  9413. $cid = 0;
  9414. $ocid = 0;
  9415. foreach ( $staffList as $value ) {
  9416. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  9417. $stTitle = $value ['category'] . '-' . $value ['username'];
  9418. $staffId = $value ['sid'];
  9419. $cid = $value ['cid'];
  9420. $ocid = $value ['cid'];
  9421. if (! empty ( $value ['othercid'] ))
  9422. $cid = $value ['cid'] . ',' . $value ['othercid'];
  9423. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9424. } elseif ($value ['username'] != 'admin')
  9425. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9426. }
  9427. $data ['lCategoryHtml'] = $lCategory->find ( array (
  9428. 'where' => 'cid in(' . $cid . ')',
  9429. 'asArray' => true
  9430. ) );
  9431. if (empty ( $pcid ))
  9432. $pcid = $ocid;
  9433. $data ['ocid'] = $pcid;
  9434. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  9435. $this->showCache ( $path );
  9436. //
  9437. $receiptCollectList = $receiptDetail->find ( array (
  9438. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9439. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9440. 'groupby' => 'item,Month(pastDate),itemCategory',
  9441. 'asArray' => true
  9442. ) );
  9443. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  9444. // print_r($receiptCollectList);
  9445. $accountList = $accountItem->find ( array (
  9446. 'asArray' => true
  9447. ) );
  9448. // create CollectDetail HTML
  9449. $collectHtml = array ();
  9450. foreach ( $accountList as $key => $value ) {
  9451. $html = "";
  9452. $asum = 0;
  9453. for($i = 1; $i <= 12; $i ++) {
  9454. $falg = true;
  9455. foreach ( $receiptCollectList as $v ) {
  9456. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9457. if ($v ['item'] == '可自加费用') {
  9458. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  9459. }
  9460. $asum += $v ['price'];
  9461. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9462. $falg = false;
  9463. break;
  9464. }
  9465. }
  9466. if ($falg)
  9467. $html .= '<td class="taR">-</td>';
  9468. }
  9469. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9470. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9471. }
  9472. $data ['collectHtml'] = $collectHtml;
  9473. // print_r($collectHtml);
  9474. // create Adjustment price html
  9475. $receiptCollectList = $receiptDetail->find ( array (
  9476. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9477. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9478. 'groupby' => 'itemCategory,Month(pastDate)',
  9479. 'asArray' => true
  9480. ) );
  9481. $adjustment = array ();
  9482. $collectArray = array (
  9483. '日常相关费用' => array (),
  9484. '差旅相关费用' => array (),
  9485. '培训班费用' => array (),
  9486. '其他' => array ()
  9487. );
  9488. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9489. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9490. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9491. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9492. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9493. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9494. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9495. array_push ( $collectArray ['其他'], $collectHtml );
  9496. $data ['collectArray'] = $collectArray;
  9497. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9498. array_push ( $adjustment, $collectHtml );
  9499. $data ['adjustment'] = $adjustment;
  9500. // total price html
  9501. $collectHtml = "";
  9502. $total = 0;
  9503. for($i = 1; $i <= 12; $i ++) {
  9504. $sumPrice = 0;
  9505. foreach ( $receiptCollectList as $key => $value ) {
  9506. if ($value ['month'] == $i) {
  9507. $sumPrice += $value ['price'];
  9508. }
  9509. }
  9510. if ($sumPrice == 0)
  9511. $collectHtml .= '<td class="taR">-</td>';
  9512. else
  9513. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9514. $total += $sumPrice;
  9515. }
  9516. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9517. // statistics html
  9518. $stList = $statistics->statisticsByYear ( $year, $staffId );
  9519. if (empty ( $stList ))
  9520. $stList = array (
  9521. 'rePrice' => 0,
  9522. 'agPrice' => 0
  9523. );
  9524. $data ['stList'] = array (
  9525. 'rePrice' => $stList ['rePrice'],
  9526. 'agPrice' => $stList ['agPrice'],
  9527. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9528. );
  9529. $data ['totalPrice'] = $collectHtml;
  9530. $data ['totalYear'] = $total;
  9531. $data ['stHtml'] = $stHtml;
  9532. $data ['year'] = $year;
  9533. $data ['stTitle'] = $stTitle;
  9534. $data ['memu'] = "receipt";
  9535. $data ['staff'] = $this->staff;
  9536. $data ['receiptMemu'] = 'companyCategoryCollect';
  9537. $data ['verifyId'] = $this->verifyId;
  9538. $data ['executeId'] = $this->executeId;
  9539. if ($year < date ( "Y" )) {
  9540. Doo::loadModel ( 'receipt' );
  9541. $receipt = new receipt ();
  9542. $receiptList = $receipt->find ( array (
  9543. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  9544. 'asArray' => true
  9545. ) );
  9546. if (empty ( $receiptList )) { // generated files
  9547. ob_start ();
  9548. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9549. $this->cacheFile ( $path );
  9550. die ();
  9551. }
  9552. }
  9553. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9554. }
  9555. function BUGFLAG() {
  9556. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  9557. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  9558. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9559. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9560. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  9561. if (empty ( $status ))
  9562. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  9563. $page_size = 12;
  9564. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  9565. $vidList = array ();
  9566. $button = 0;
  9567. Doo::loadModel ( 'verify' );
  9568. $verify = new verify ();
  9569. Doo::loadModel ( 'receipt' );
  9570. $receipt = new receipt ();
  9571. Doo::loadModel ( 'staff' );
  9572. $staff = new staff ();
  9573. Doo::loadModel ( 'L_category' );
  9574. $Lcategory = new L_category ();
  9575. $dateCondition = " and Year(date) =" . $year;
  9576. if (! empty ( $month ))
  9577. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  9578. $categoryList = $Lcategory->find ( array (
  9579. 'asArray' => true
  9580. ) );
  9581. $staffList = $staff->find ( array (
  9582. 'where' => 'cid=' . $cid,
  9583. 'asArray' => true
  9584. ) );
  9585. $cateCondition = "";
  9586. $staffCondition = "";
  9587. $approvalCondition = "";
  9588. if (! empty ( $cid ))
  9589. $cateCondition = ' and cid=' . $cid;
  9590. if (! empty ( $sid )) {
  9591. $staffCondition = ' and staff=' . $sid;
  9592. $cateCondition = "";
  9593. }
  9594. $approvalCondition = " and status=" . $status;
  9595. if ($status == 2) {
  9596. // 查找角色审批人
  9597. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9598. }
  9599. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  9600. $approvalCondition = ' and status=2 ';
  9601. }
  9602. if ($status == 1) {
  9603. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  9604. }
  9605. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  9606. $pageinfo ['page'] = array (
  9607. 'previous' => ''
  9608. );
  9609. if ($status == 0) {
  9610. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  9611. $receiptList = $receipt->find ( array (
  9612. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  9613. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  9614. 'desc' => 'rid',
  9615. 'asArray' => true
  9616. ) );
  9617. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9618. } else
  9619. $receiptList = $receipt->find ( array (
  9620. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  9621. 'desc' => 'rid',
  9622. 'asArray' => true
  9623. ) );
  9624. $rLRes = $receipt->find ( array (
  9625. '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,
  9626. 'desc' => 'rid',
  9627. 'asArray' => true
  9628. ) );
  9629. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9630. // print_r($pageinfo);
  9631. $Locate = 0;
  9632. foreach ( $receiptList as $key => $value ) {
  9633. $receiptList [$key] ['Locate'] = $Locate;
  9634. $Locate ++;
  9635. $receiptList [$key] ['reviseDetail'] = array ();
  9636. if (! empty ( $value ['reviseDetail'] ))
  9637. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  9638. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  9639. $categoryDetil = $Lcategory->getOne ( array (
  9640. 'where' => 'cid=' . $value ['cid'],
  9641. 'asArray' => true
  9642. ) );
  9643. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  9644. $verifyList = $verify->getOne ( array (
  9645. 'where' => 'vid=' . $value ['verify'],
  9646. 'asArray' => true
  9647. ) );
  9648. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  9649. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  9650. foreach ( $verifyList as $k => $v ) {
  9651. // init verifyStaff
  9652. $verifyList [$k] ['date'] = "";
  9653. $verifyList [$k] ['opinion'] = "";
  9654. $verifyList [$k] ['status'] = "";
  9655. if (empty ( $verifyStaff )) {
  9656. $verifyList [$k] ['date'] = "";
  9657. $verifyList [$k] ['opinion'] = "";
  9658. if ($v [0] == $this->staff [0] ['sid']) {
  9659. $verifyList [$k] ['status'] = 4;
  9660. $button = 4;
  9661. }
  9662. } else {
  9663. $flag = true;
  9664. foreach ( $verifyStaff as $m => $u ) {
  9665. if ($v [0] == $m) {
  9666. $verifyList [$k] ['date'] = $u ['date'];
  9667. $verifyList [$k] ['opinion'] = $u ['opinion'];
  9668. $verifyList [$k] ['status'] = $u ['status'];
  9669. $flag = false;
  9670. break;
  9671. }
  9672. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  9673. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  9674. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  9675. }
  9676. if ($flag) { // 检测可编辑
  9677. if ($v [0] == $this->staff [0] ['sid']) {
  9678. $verifyList [$k] ['status'] = 4;
  9679. $button = 4;
  9680. }
  9681. }
  9682. }
  9683. }
  9684. $receiptList [$key] ['verifyList'] = $verifyList;
  9685. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  9686. 'where' => 'sid=' . $value ['staff'],
  9687. 'asArray' => true
  9688. ) );
  9689. $receiptList [$key] ['button'] = $button;
  9690. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  9691. }
  9692. // print_r($receiptList);die;
  9693. // $data['verifyDetail']=$verifyDetail;
  9694. $mothHtml = "";
  9695. for($i = 1; $i <= 12; $i ++) {
  9696. if ($month == $i)
  9697. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  9698. else
  9699. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  9700. }
  9701. $data ['mothHtml'] = $mothHtml;
  9702. $data ['page'] = $pageinfo;
  9703. $data ['receiptList'] = $receiptList;
  9704. $data ['receiptApprovalCount'] = count ( $rLRes );
  9705. $data ['status'] = $status;
  9706. $data ['year'] = $year;
  9707. $data ['categoryList'] = $categoryList;
  9708. $data ['staffList'] = $staffList;
  9709. $data ['cid'] = $cid;
  9710. $data ['sid'] = $sid;
  9711. // print_r($receiptList);
  9712. $data ['memu'] = "receipt";
  9713. $data ['staff'] = $this->staff;
  9714. $data ['receiptMemu'] = 'approvalExpenses';
  9715. $data ['verifyId'] = $this->verifyId;
  9716. $data ['executeId'] = $this->executeId;
  9717. $this->render ( "/admin/FALG", $data );
  9718. }
  9719. function ajaxGetReceiptOrder() {
  9720. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  9721. if (! empty ( $receiptOrder )) {
  9722. Doo::loadModel ( 'receipt' );
  9723. $receipt = new receipt ();
  9724. Doo::loadModel ( 'staff' );
  9725. $staff = new staff ();
  9726. $receiptInfo = $receipt->getOne ( array (
  9727. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  9728. 'asArray' => true
  9729. ) );
  9730. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  9731. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  9732. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  9733. </tbody></table><table class="table table table-bordered"><tbody>';
  9734. foreach ( $verifyStaff as $key => $value ) {
  9735. $staffInfo = $staff->getOne ( array (
  9736. 'select' => 'username',
  9737. 'where' => ' sid="' . $key . '"',
  9738. 'asArray' => true
  9739. ) );
  9740. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  9741. }
  9742. $html .= '</tbody></table></div></div>';
  9743. echo json_encode ( array (
  9744. 'status' => 1,
  9745. 'receiptHtml' => $html
  9746. ) );
  9747. die ();
  9748. }
  9749. echo json_encode ( array (
  9750. 'status' => 2,
  9751. 'receiptHtml' => ''
  9752. ) );
  9753. die ();
  9754. }
  9755. function _getMonthCollectDetail($receiptCollectList) {
  9756. if (! empty ( $receiptCollectList )) {
  9757. $receiptL = array (
  9758. '日常相关费用' => array (),
  9759. '差旅相关费用' => array (),
  9760. '培训班费用' => array (),
  9761. '其他' => array ()
  9762. );
  9763. $html = "";
  9764. $psum = 0;
  9765. $item = array (
  9766. '市内交通费',
  9767. '市内出租费',
  9768. '办事处房租',
  9769. '电话费',
  9770. '水费',
  9771. '电费',
  9772. '办公费用',
  9773. '邮寄费',
  9774. '其他费用',
  9775. '车辆费用',
  9776. '广告费',
  9777. '团队建设费',
  9778. '物业管理费',
  9779. '宽带费'
  9780. );
  9781. foreach ( $item as $value ) {
  9782. $falg = true;
  9783. foreach ( $receiptCollectList as $v ) {
  9784. if ($v ['itemCategory'] == '日常相关费用') {
  9785. if ($v ['item'] == $value) {
  9786. $psum += $v ['price'];
  9787. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9788. $falg = false;
  9789. break;
  9790. }
  9791. }
  9792. }
  9793. if ($falg)
  9794. $html .= '<td class="taR">-</td>';
  9795. }
  9796. if (! empty ( $psum ))
  9797. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9798. else
  9799. $psum = '<td class="colGreen taR">-</td>';
  9800. $receiptL ['日常相关费用'] = $psum . $html;
  9801. /* ----------------------------------- */
  9802. $html = "";
  9803. $psum = 0;
  9804. $item = array (
  9805. '往来交通费',
  9806. '市内交通费',
  9807. '出差住宿费',
  9808. '出差补助',
  9809. '其他费用'
  9810. );
  9811. foreach ( $item as $value ) {
  9812. $falg = true;
  9813. foreach ( $receiptCollectList as $v ) {
  9814. if ($v ['itemCategory'] == '差旅相关费用') {
  9815. if ($v ['item'] == $value) {
  9816. $psum += $v ['price'];
  9817. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9818. $falg = false;
  9819. break;
  9820. }
  9821. }
  9822. }
  9823. if ($falg)
  9824. $html .= '<td class="taR">-</td>';
  9825. }
  9826. if (! empty ( $psum ))
  9827. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9828. else
  9829. $psum = '<td class="colGreen taR">-</td>';
  9830. $receiptL ['差旅相关费用'] = $psum . $html;
  9831. /* ------------------------------------- */
  9832. $html = "";
  9833. $psum = 0;
  9834. $item = array (
  9835. '场租费',
  9836. '薪酬',
  9837. '住宿费',
  9838. '交通费',
  9839. '餐饮费',
  9840. '办公费',
  9841. '公关费',
  9842. '其他'
  9843. );
  9844. foreach ( $item as $value ) {
  9845. $falg = true;
  9846. foreach ( $receiptCollectList as $v ) {
  9847. if ($v ['itemCategory'] == '培训班费用') {
  9848. if ($v ['item'] == $value) {
  9849. $psum += $v ['price'];
  9850. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9851. $falg = false;
  9852. break;
  9853. }
  9854. }
  9855. }
  9856. if ($falg)
  9857. $html .= '<td class="taR">-</td>';
  9858. }
  9859. if (! empty ( $psum ))
  9860. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9861. else
  9862. $psum = '<td class="colGreen taR">-</td>';
  9863. $receiptL ['培训班费用'] = $psum . $html;
  9864. /* ------------------------------------- */
  9865. $html = "";
  9866. $psum = 0;
  9867. $item = array (
  9868. '公关费',
  9869. '广告费',
  9870. '借款',
  9871. '可自加费用'
  9872. );
  9873. foreach ( $item as $value ) {
  9874. $falg = true;
  9875. foreach ( $receiptCollectList as $v ) {
  9876. if ($v ['itemCategory'] == '其他') {
  9877. if ($v ['item'] == $value) {
  9878. $psum += $v ['price'];
  9879. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9880. $falg = false;
  9881. break;
  9882. }
  9883. }
  9884. }
  9885. if ($falg)
  9886. $html .= '<td class="taR">-</td>';
  9887. }
  9888. if (! empty ( $psum ))
  9889. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9890. else
  9891. $psum = '<td class="colGreen taR">-</td>';
  9892. $receiptL ['其他'] = $psum . $html;
  9893. /* ------------------------------------- */
  9894. $html = "";
  9895. $psum = 0;
  9896. foreach ( $receiptCollectList as $v ) {
  9897. if ($v ['itemCategory'] == '报销金额调整') {
  9898. if (! empty ( $v ['price'] ))
  9899. $psum += $v ['price'];
  9900. }
  9901. }
  9902. if (! empty ( $psum ))
  9903. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9904. else
  9905. $psum = '<td class="taR colOrange">-</td>';
  9906. $receiptL ['报销金额调整'] = $psum . $html;
  9907. } else {
  9908. $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>
  9909. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9910. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9911. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9912. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9913. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9914. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9915. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9916. }
  9917. return $receiptL;
  9918. }
  9919. function eMail() {
  9920. Doo::loadModel ( 'staff' );
  9921. $staff = new staff ();
  9922. Doo::loadModel ( 'receipt' );
  9923. $receipt = new receipt ();
  9924. Doo::loadModel ( 'L_category' );
  9925. $Lcategory = new L_category ();
  9926. Doo::loadModel ( "verify" );
  9927. $verify = new verify ();
  9928. $staffList = $staff->find ( array (
  9929. 'asArray' => true
  9930. ) );
  9931. foreach ( $staffList as $key => $value ) {
  9932. if ($value ['username'] != 'admin') {
  9933. // 提交人
  9934. $receiptList = $receipt->find ( array (
  9935. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  9936. 'asArray' => true
  9937. ) );
  9938. if (! empty ( $receiptList )) {
  9939. $html = '<br><div><style></style>
  9940. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  9941. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  9942. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9943. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  9944. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9945. <tbody><tr>
  9946. <td style="padding: 0 40px;" align="left">
  9947. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9948. </td></tr><tr>
  9949. <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>
  9950. </tr>
  9951. </tbody> </table></td> </tr> <tr><td>
  9952. <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">
  9953. <tbody> <tr><td>
  9954. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  9955. 以下报销单完成了审批,等着收款吧:</p>
  9956. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  9957. foreach ( $receiptList as $k => $v ) {
  9958. $category = $Lcategory->getOne ( array (
  9959. 'where' => 'cid=' . $v ['cid'],
  9960. 'asArray' => true
  9961. ) );
  9962. $html .= '
  9963. <tr>
  9964. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  9965. <td align="left">
  9966. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  9967. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  9968. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  9969. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  9970. </tr>';
  9971. }
  9972. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  9973. <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>
  9974. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  9975. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  9976. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  9977. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9978. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9979. $receipt = new receipt ();
  9980. $receipt->notice = 1;
  9981. $receipt->update ( array (
  9982. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  9983. ) );
  9984. }
  9985. }
  9986. // 审批人
  9987. $verifyList = $verify->find ( array (
  9988. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  9989. 'asArray' => true
  9990. ) );
  9991. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  9992. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  9993. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9994. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  9995. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9996. <tbody><tr><td style="padding: 0 40px;" align="left">
  9997. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9998. </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>
  9999. </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">
  10000. <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>
  10001. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  10002. foreach ( $verifyList as $k => $v ) {
  10003. $receiptList = $receipt->find ( array (
  10004. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  10005. 'asArray' => true
  10006. ) );
  10007. foreach ( $receiptList as $r => $l ) {
  10008. $category = $Lcategory->getOne ( array (
  10009. 'where' => 'cid=' . $l ['cid'],
  10010. 'asArray' => true
  10011. ) );
  10012. $staffDetile = $staff->getOne ( array (
  10013. 'where' => 'sid=' . $l ['staff'],
  10014. 'asArray' => true
  10015. ) );
  10016. $html .= '
  10017. <tr>
  10018. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  10019. <td align="left">
  10020. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  10021. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  10022. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  10023. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  10024. </tr>';
  10025. }
  10026. }
  10027. $html .= '
  10028. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  10029. <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>
  10030. </tr></tbody></table></td></tr></tbody></table></div><br>';
  10031. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  10032. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  10033. // $receipt=new receipt();
  10034. // $receipt->notice=1;
  10035. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  10036. }
  10037. }
  10038. }
  10039. }
  10040. function setWXMsg($rid, $type) {
  10041. Doo::loadModel ( "receipt" );
  10042. $receipt = new receipt ();
  10043. $receiptDetail = $receipt->getOne ( array (
  10044. 'where' => 'rid=' . $rid,
  10045. 'asArray' => true
  10046. ) );
  10047. if (! empty ( $receiptDetail )) {
  10048. Doo::loadModel ( 'staff' );
  10049. $staff = new staff ();
  10050. $staffmsg = $staff->getOne ( array (
  10051. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  10052. 'asArray' => TRUE
  10053. ) );
  10054. if (! empty ( $staffmsg ['wxid'] )) {
  10055. require_once (SITE_PATH . '/protected/class/client.php');
  10056. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  10057. $user = $staffmsg ['wxid'];
  10058. $receiptName = '';
  10059. $msg = '';
  10060. switch ($receiptDetail ['Rtype']) {
  10061. case 0 :
  10062. $receiptName = '报销';
  10063. break;
  10064. case 1 :
  10065. $receiptName = '借款';
  10066. break;
  10067. case 2 :
  10068. $receiptName = '对公汇款';
  10069. break;
  10070. }
  10071. switch ($type) {
  10072. case 1 :
  10073. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  10074. break;
  10075. case 2 :
  10076. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  10077. break;
  10078. case 3 :
  10079. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  10080. break;
  10081. }
  10082. $result = $client->SendMsg ( $user, $msg, 'text' );
  10083. }
  10084. }
  10085. }
  10086. // Email发送函数
  10087. function SMail($toemail, $subject, $contents) {
  10088. Doo::loadClass ( 'class.phpmailer' );
  10089. $mail = new PHPMailer ();
  10090. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  10091. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  10092. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  10093. $mail->Password = "cDO1GjtY1seH"; // 密码
  10094. $mail->CharSet = "UTF8";
  10095. $mail->SMTPAuth = true;
  10096. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  10097. $mail->Mailer = "smtp";
  10098. $mail->Port = 25;
  10099. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  10100. $mail->MsgHTML ( $contents );
  10101. $mail->AddAddress ( $toemail );
  10102. $mail->CharSet = "UTF-8";
  10103. return $mail->Send ();
  10104. }
  10105. function swfupload() {
  10106. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  10107. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  10108. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  10109. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  10110. header ( "HTTP/1.1 500 Internal Server Error" );
  10111. echo "POST exceeded maximum allowed size.";
  10112. exit ( 0 );
  10113. }
  10114. // Settings
  10115. $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)
  10116. $upload_name = "Filedata";
  10117. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  10118. $extension_whitelist = array (
  10119. "doc",
  10120. "txt",
  10121. "jpg",
  10122. "gif",
  10123. "png"
  10124. ); // Allowed file extensions
  10125. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  10126. // Other variables
  10127. $MAX_FILENAME_LENGTH = 260;
  10128. $file_name = "";
  10129. $file_extension = "";
  10130. $uploadErrors = array (
  10131. 0 => "文件上传成功",
  10132. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  10133. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  10134. 3 => "上传的文件仅为部分文件",
  10135. 4 => "没有文件上传",
  10136. 6 => "缺少临时文件夹"
  10137. );
  10138. $nk = time ();
  10139. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  10140. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  10141. echo "文件无法保存.";
  10142. exit ( 0 );
  10143. }
  10144. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  10145. echo json_encode ( array (
  10146. 'filename' => $file_name,
  10147. 'id' => $nk
  10148. ) );
  10149. exit ( 0 );
  10150. }
  10151. function _GetFileEXT($filename) {
  10152. $pics = explode ( '.', $filename );
  10153. $num = count ( $pics );
  10154. return $pics [$num - 1];
  10155. }
  10156. /**
  10157. * 获取get或者POST值
  10158. * @param string $name 属性名称
  10159. * @return fixed 值
  10160. */
  10161. function get_args($name) {
  10162. if (isset ( $_GET [$name] )) {
  10163. if (is_array ( $_GET [$name] ))
  10164. return $_GET [$name];
  10165. else
  10166. return addslashes ( $_GET [$name] );
  10167. } elseif (isset ( $_POST [$name] )) {
  10168. if (is_array ( $_POST [$name] ))
  10169. return $_POST [$name];
  10170. else
  10171. return addslashes ( $_POST [$name] );
  10172. } else
  10173. return false;
  10174. }
  10175. function num_to_rmb($num) {
  10176. $c1 = "零壹贰叁肆伍陆柒捌玖";
  10177. $c2 = "分角元拾佰仟万拾佰仟亿";
  10178. // 精确到分后面就不要了,所以只留两个小数位
  10179. $num = round ( $num, 2 );
  10180. // 将数字转化为整数
  10181. $num = $num * 100;
  10182. if (strlen ( $num ) > 10) {
  10183. return "金额太大,请检查";
  10184. }
  10185. $i = 0;
  10186. $c = "";
  10187. while ( 1 ) {
  10188. if ($i == 0) {
  10189. // 获取最后一位数字
  10190. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  10191. } else {
  10192. $n = $num % 10;
  10193. }
  10194. // 每次将最后一位数字转化为中文
  10195. $p1 = substr ( $c1, 3 * $n, 3 );
  10196. $p2 = substr ( $c2, 3 * $i, 3 );
  10197. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  10198. $c = $p1 . $p2 . $c;
  10199. } else {
  10200. $c = $p1 . $c;
  10201. }
  10202. $i = $i + 1;
  10203. // 去掉数字最后一位了
  10204. $num = $num / 10;
  10205. $num = ( int ) $num;
  10206. // 结束循环
  10207. if ($num == 0) {
  10208. break;
  10209. }
  10210. }
  10211. $j = 0;
  10212. $slen = strlen ( $c );
  10213. while ( $j < $slen ) {
  10214. // utf8一个汉字相当3个字符
  10215. $m = substr ( $c, $j, 6 );
  10216. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  10217. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  10218. $left = substr ( $c, 0, $j );
  10219. $right = substr ( $c, $j + 3 );
  10220. $c = $left . $right;
  10221. $j = $j - 3;
  10222. $slen = $slen - 3;
  10223. }
  10224. $j = $j + 3;
  10225. }
  10226. // 这个是为了去掉类似23.0中最后一个“零”字
  10227. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  10228. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  10229. }
  10230. // 将处理的汉字加上“整”
  10231. if (empty ( $c )) {
  10232. return "零元整";
  10233. } else {
  10234. return $c . "整";
  10235. }
  10236. }
  10237. /**
  10238. * 获得分页数据
  10239. * @param unknown_type $table
  10240. * @param unknown_type $condition
  10241. * @param unknown_type $on_page
  10242. * @param unknown_type $page_size
  10243. */
  10244. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  10245. $page_c = "";
  10246. $page ['previous'] = $this->get_previous ( $on_page );
  10247. $page ['on_page'] = $on_page;
  10248. $total_count = $this->get_table_count ( $table, $condition );
  10249. $total = intval ( $total_count / $page_size );
  10250. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  10251. $page ['total_data'] = $total_count;
  10252. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  10253. $i = 1;
  10254. $page_max = 1;
  10255. $page_width = 3;
  10256. if ($on_page >= $page_width) {
  10257. $page_max = intval ( $on_page / $page_width ) + 1;
  10258. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  10259. }
  10260. for(; $i <= $page ['total_page']; $i ++) {
  10261. if ($i == $on_page)
  10262. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  10263. else
  10264. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  10265. if ($i == ($page_width * $page_max))
  10266. break;
  10267. }
  10268. $page ['page'] = $page_c;
  10269. $page ['lower'] = (-- $on_page) * $page_size;
  10270. return $page;
  10271. }
  10272. /**
  10273. * 获取总页数
  10274. * @param unknown_type $table
  10275. * @param unknown_type $condition
  10276. */
  10277. public function get_table_count($table = "", $condition = "") {
  10278. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10279. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10280. // echo $sql;die;
  10281. $query = Doo::db ()->query ( $sql );
  10282. $result = $query->fetch ();
  10283. return $result ['count'];
  10284. }
  10285. /**
  10286. * 获取上一页
  10287. * @param unknown_type $on_page
  10288. */
  10289. function get_previous($on_page = 1) {
  10290. return $on_page != 0 ? $on_page - 1 : $on_page;
  10291. }
  10292. }
  10293. ?>