ReceiptController.php 372 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class ReceiptController extends DooController {
  6. public $staff;
  7. public $verifyId;
  8. public $executeId;
  9. // public static $NEW2 = 0;
  10. public $AGENCY = "日常相关费用";
  11. public $TRAVEL = "差旅相关费用";
  12. public $TRAIN = "培训班费用";
  13. public $OTHER = "其他";
  14. private $MYREVEIPTCACHEPATH = "protected/cache/myReceipt/";
  15. private $PERSONALCOLLECTCACHEPATH = "protected/cache/personalCollect/";
  16. private $CATEGORYCOLLECTPATH = "protected/cache/categoryCollect/";
  17. private $STAFFCOLLECTPATH = "protected/cache/staffCollect/";
  18. private function showCache($path) {
  19. if (file_exists ( $path )) {
  20. echo "<!DOCTYPE html>";
  21. include $path;
  22. die ();
  23. }
  24. }
  25. private function cacheFile($path) {
  26. $content = ob_get_contents ();
  27. $fp = fopen ( $path, "w" );
  28. fwrite ( $fp, $content );
  29. fclose ( $fp );
  30. }
  31. // private function getExeCount(){
  32. // Doo::loadModel('receipt');
  33. // $receipt=new receipt();
  34. // $receiptList=$receipt->find(array('where'=>'(executeCopy like \'%["'.$this->staff[0]['sid'].'%\' and executeStaff NOT LIKE \'%'.$this->staff[0]['sid'].'%\' ) and (status=1 or status=6)','desc'=>'rid','asArray'=>true));
  35. // return count($receiptList);
  36. // }
  37. // private function getReceiptCount(){
  38. // $status=2;
  39. // $year=date('Y');
  40. // Doo::loadModel('receipt');
  41. // $receipt=new receipt();
  42. // $dateCondition=" and Year(date) =".$year;
  43. // $approvalCondition=' and (nowStaff like "%,'.$this->staff[0]['sid'].'%" or nowStaff like "%'.$this->staff[0]['sid'].',%" or nowStaff='.$this->staff[0]['sid'].' ) ';
  44. // $receiptList=$receipt->find(array('where'=>' status='.$status.$dateCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  45. // return count($receiptList);
  46. // }
  47. private function collectHtml($receiptCollectList = array(), $itemCategory = "日常相关费用", $classType = "b") {
  48. $collectHtml = "";
  49. $sumPrice = 0.00;
  50. for($i = 1; $i <= 12; $i ++) {
  51. $falg = true;
  52. foreach ( $receiptCollectList as $key => $value ) {
  53. if ($value ['itemCategory'] == $itemCategory && $value ['month'] == $i) {
  54. $sumPrice += $value ['price'];
  55. if ($classType == "b") {
  56. $collectHtml .= '<td class="colGreen taR">¥' . $value ['price'] . '</td>';
  57. $falg = false;
  58. break;
  59. } else {
  60. $collectHtml .= '<td class="taR">¥' . $value ['price'] . '</td>';
  61. $falg = false;
  62. break;
  63. }
  64. }
  65. }
  66. if ($falg)
  67. $collectHtml .= '<td class="taR">-</td>';
  68. }
  69. $collectHtml .= '<td class="taR colGreen">¥' . $sumPrice . '</td>';
  70. return $collectHtml;
  71. }
  72. function __construct() {
  73. if (isset ( $_COOKIE ["staff"] )) {
  74. if (! empty ( $_COOKIE ["staff"] )) {
  75. Doo::loadModel ( 'staff' );
  76. Doo::loadModel ( 'verify' );
  77. $verify = new verify ();
  78. $staff = new staff ();
  79. Doo::loadModel ( "execute" );
  80. $execute = new execute ();
  81. $verifyList = $verify->find ( array (
  82. 'select' => 'staff',
  83. 'asArray' => true
  84. ) );
  85. $list = array ();
  86. // 判断角色的审批权限
  87. foreach ( $verifyList as $key => $value ) {
  88. $ver = json_decode ( $value ['staff'] );
  89. foreach ( $ver as $k => $v ) {
  90. if ($v [1] == 'ROLE') {
  91. $roleList = json_decode ( $v [3] );
  92. foreach ( $roleList as $t => $g ) {
  93. $gList = explode ( "_", $g );
  94. array_push ( $list, $gList [0] );
  95. // print_r($list);
  96. }
  97. } else
  98. array_push ( $list, $v [0] );
  99. }
  100. }
  101. // 判断执行人的审批权限
  102. $executeList = $execute->find ( array (
  103. 'select' => 'staff',
  104. 'asArray' => true
  105. ) );
  106. $list2 = array ();
  107. foreach ( $executeList as $key => $value ) {
  108. $ver = json_decode ( $value ['staff'] );
  109. foreach ( $ver as $k => $v ) {
  110. array_push ( $list2, $v [0] );
  111. }
  112. }
  113. $eidList = file_get_contents ( "protected/config/execute/execute.ini" );
  114. $eidList = array_filter ( explode ( ",", $eidList ) );
  115. $this->executeId = array_merge ( $list2, $eidList );
  116. $this->verifyId = $list;
  117. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  118. return "/";
  119. }
  120. }
  121. Doo::loadCore ( 'uri/DooUriRouter' );
  122. $router = new DooUriRouter ();
  123. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  124. if ($routeRs ['1'] != "login") {
  125. header ( 'Content-Type:text/html;charset=utf-8' );
  126. @header ( "Location: /login" );
  127. }
  128. }
  129. function saeaBorad() {
  130. Doo::loadModel ( 'receipt' );
  131. Doo::loadModel ( 'verify' );
  132. $verify = new verify ();
  133. $receipt = new receipt ();
  134. Doo::loadModel ( 'L_category' );
  135. $lCategory = new L_category ();
  136. Doo::loadModel ( "role" );
  137. $role = new role ();
  138. Doo::loadModel ( "receiptLog" );
  139. $receiptLog = new receiptLog ();
  140. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  141. $receiptDetail = $receipt->find ( array (
  142. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  143. 'desc' => 'rid',
  144. 'asArray' => true
  145. ) );
  146. foreach ( $receiptDetail as $key => $value ) {
  147. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  148. $veList = $verify->getOne ( array (
  149. 'where' => 'vid=' . $value ['verify'],
  150. 'asArray' => true
  151. ) );
  152. $v = json_decode ( $veList ['staff'] );
  153. array_push ( $v [0], $veList ['description'] );
  154. foreach ( $v as $n => $m ) {
  155. if ($m ['1'] == 'ROLE') {
  156. $roleInfo = $role->getOne ( array (
  157. 'where' => 'rid=' . $m [0],
  158. 'asArray' => true
  159. ) );
  160. $v [$n] [1] = $roleInfo ['name'];
  161. }
  162. }
  163. $receiptDetail [$key] ['staff'] = $v;
  164. $category = $lCategory->getOne ( array (
  165. 'where' => 'cid=' . $value ['cid'],
  166. 'asArray' => true
  167. ) );
  168. $receiptDetail [$key] ['category'] = $category ['title'];
  169. }
  170. // print_r($receiptLogList);
  171. $data ['receiptLogList'] = $receiptLogList;
  172. $data ['receiptDetail'] = $receiptDetail;
  173. $data ['memu'] = "receipt";
  174. $data ['staff'] = $this->staff;
  175. $data ['receiptMemu'] = 'saeaBorad';
  176. $data ['verifyId'] = $this->verifyId;
  177. $data ['executeId'] = $this->executeId;
  178. $this->render ( "/admin/saeaBorad", $data );
  179. }
  180. function remitAdd() {
  181. Doo::loadModel ( 'accountItem' );
  182. Doo::loadModel ( 'verify' );
  183. Doo::loadModel ( 'receipt' );
  184. Doo::loadModel ( 'L_category' );
  185. $lCategory = new L_category ();
  186. $receipt = new receipt ();
  187. $verify = new verify ();
  188. $accountItem = new accountItem ();
  189. Doo::loadModel ( "role" );
  190. $role = new role ();
  191. $acItem = $accountItem->find ( array (
  192. 'asArray' => true
  193. ) );
  194. $veList = $verify->find ( array (
  195. 'asArray' => true
  196. ) );
  197. foreach ( $veList as $key => $value ) {
  198. $v = json_decode ( $value ['staff'] );
  199. $list = array ();
  200. foreach ( $v as $n => $m ) {
  201. if ($m ['1'] == 'ROLE') {
  202. $roleInfo = $role->getOne ( array (
  203. 'where' => 'rid=' . $m [0],
  204. 'asArray' => true
  205. ) );
  206. $v [$n] [1] = $roleInfo ['name'];
  207. array_push ( $list, $roleInfo ['name'] );
  208. } else {
  209. array_push ( $list, $v [$n] [1] );
  210. }
  211. }
  212. $veList [$key] ['staff'] = implode ( '>', $list );
  213. }
  214. $data ['category'] = $lCategory->find ( array (
  215. 'asArray' => true
  216. ) );
  217. $data ['veList'] = $veList;
  218. $data ['acItem'] = $acItem;
  219. $data ['memu'] = "receipt";
  220. $data ['staff'] = $this->staff;
  221. $data ['receiptMemu'] = 'saeaBorad';
  222. $data ['verifyId'] = $this->verifyId;
  223. $data ['executeId'] = $this->executeId;
  224. $this->render ( "/admin/remitAdd", $data );
  225. }
  226. function remitAddDo() {
  227. $agency = $this->get_args ( 'agency' );
  228. $travel = $this->get_args ( 'travel' );
  229. $train = $this->get_args ( 'train' );
  230. $other = $this->get_args ( 'other' );
  231. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  232. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  233. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  234. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  235. // print_r($agency);die;
  236. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  237. Doo::loadModel ( 'receipt' );
  238. Doo::loadModel ( 'receiptDetail' );
  239. Doo::loadModel ( 'accountItem' );
  240. $accountItem = new accountItem ();
  241. $receipt = new receipt ();
  242. Doo::loadModel ( 'enclosur' );
  243. Doo::loadModel ( 'execute' );
  244. $execute = new execute ();
  245. $executeDetail = $execute->getOne ( array (
  246. 'where' => 'mold="对公汇款执行人"',
  247. 'asArray' => true
  248. ) );
  249. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  250. $aItem = $accountItem->find ( array (
  251. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  252. 'asArray' => true
  253. ) );
  254. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  255. $ag = $tr = $ta = $ot = 0;
  256. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  257. foreach ( $aItem as $key => $value ) {
  258. if ($value ['category'] == $this->AGENCY) {
  259. if (isset ( $agency [$ag] )) {
  260. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  261. array_push ( $accountJson [$this->AGENCY], array (
  262. 'aid' => $value ['aid'],
  263. 'name' => $value ['name'],
  264. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  265. ) );
  266. $sum += $agency [$ag];
  267. $agencySum += $agency [$ag];
  268. }
  269. }
  270. $ag ++;
  271. }
  272. }
  273. $accountJson ['cSum'] = array (
  274. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  275. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  276. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  277. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  278. );
  279. // 报销单
  280. $receipt->accountItem = json_encode ( $accountJson );
  281. $receipt->staff = $this->staff [0] ['sid'];
  282. $receipt->sum = number_format ( $sum, 2, '.', '' );
  283. $receipt->date = date ( "Y-m-d" );
  284. $receipt->cid = $cid;
  285. $receipt->status = 5;
  286. $receipt->Rtype = 2;
  287. // 修改审批流程加入角色
  288. $receipt->verify = $verify;
  289. $receipt->executeCopy = $executeDetail ['staff'];
  290. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  291. $receipt->explanation = $explanation;
  292. $rid = $receipt->insert ();
  293. // 附件
  294. if (! empty ( $enclosurName )) {
  295. $enclosurArray = explode ( '-', $enclosurName );
  296. foreach ( $enclosurArray as $value ) {
  297. $enclosur = new enclosur ();
  298. $enclosur->name = $value;
  299. $enclosur->rid = $rid;
  300. $enclosur->insert ();
  301. }
  302. // print_r($enclosurArray);die;
  303. }
  304. // 报销详情
  305. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  306. $receiptDetail = new receiptDetail ();
  307. $receiptDetail->staff = $this->staff [0] ['sid'];
  308. $receiptDetail->item = $value ['name'];
  309. $receiptDetail->itemCategory = $this->AGENCY;
  310. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  311. $receiptDetail->date = date ( "Y-m-d" );
  312. $receiptDetail->cid = $cid;
  313. $receiptDetail->rid = $rid;
  314. $receiptDetail->status = 4;
  315. $receiptDetail->insert ();
  316. }
  317. }
  318. return "/saeaBorad";
  319. }
  320. function remitEdit() {
  321. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  322. // echo $rid;
  323. Doo::loadModel ( 'accountItem' );
  324. Doo::loadModel ( 'verify' );
  325. Doo::loadModel ( 'receipt' );
  326. $receipt = new receipt ();
  327. $verify = new verify ();
  328. $accountItem = new accountItem ();
  329. Doo::loadModel ( 'L_category' );
  330. $lCategory = new L_category ();
  331. Doo::loadModel ( "role" );
  332. $role = new role ();
  333. $receiptDetail = $receipt->getOne ( array (
  334. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  335. 'asArray' => true
  336. ) );
  337. if (empty ( $receiptDetail ))
  338. return "/saeaCreate";
  339. $acItem = $accountItem->find ( array (
  340. 'asArray' => true
  341. ) );
  342. $veList = $verify->find ( array (
  343. 'asArray' => true
  344. ) );
  345. foreach ( $veList as $key => $value ) {
  346. $v = json_decode ( $value ['staff'] );
  347. $list = array ();
  348. foreach ( $v as $n => $m ) {
  349. if ($m ['1'] == 'ROLE') {
  350. $roleInfo = $role->getOne ( array (
  351. 'where' => 'rid=' . $m [0],
  352. 'asArray' => true
  353. ) );
  354. $v [$n] [1] = $roleInfo ['name'];
  355. array_push ( $list, $roleInfo ['name'] );
  356. } else {
  357. array_push ( $list, $v [$n] [1] );
  358. }
  359. }
  360. $veList [$key] ['staff'] = implode ( '>', $list );
  361. }
  362. // 配置编辑信息
  363. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  364. foreach ( $acItem as $key => $value ) {
  365. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  366. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  367. $acItem [$key] ['price'] = $v ['price'];
  368. }
  369. }
  370. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  371. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  372. $acItem [$key] ['price'] = $v ['price'];
  373. }
  374. }
  375. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  376. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  377. $acItem [$key] ['price'] = $v ['price'];
  378. }
  379. }
  380. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  381. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  382. $acItem [$key] ['price'] = $v ['price'];
  383. }
  384. }
  385. }
  386. $data ['category'] = $lCategory->find ( array (
  387. 'asArray' => true
  388. ) );
  389. $data ['cSum'] = $accountItemList ['cSum'];
  390. $data ['sum'] = $receiptDetail ['sum'];
  391. $data ['receiptDetail'] = $receiptDetail;
  392. $data ['veList'] = $veList;
  393. $data ['acItem'] = $acItem;
  394. $data ['memu'] = "receipt";
  395. $data ['staff'] = $this->staff;
  396. $data ['receiptMemu'] = 'saeaBorad';
  397. $data ['verify'] = $receiptDetail ['verify'];
  398. $data ['verifyId'] = $this->verifyId;
  399. $data ['executeId'] = $this->executeId;
  400. $data ['rid'] = $rid;
  401. $this->render ( "/admin/remitEdit", $data );
  402. }
  403. function remitEdiDo() {
  404. $agency = $this->get_args ( 'agency' );
  405. $travel = $this->get_args ( 'travel' );
  406. $train = $this->get_args ( 'train' );
  407. $other = $this->get_args ( 'other' );
  408. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  409. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  410. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  411. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  412. if (! empty ( $explanation )) {
  413. Doo::loadModel ( 'receipt' );
  414. Doo::loadModel ( 'receiptDetail' );
  415. Doo::loadModel ( 'accountItem' );
  416. $accountItem = new accountItem ();
  417. $receipt = new receipt ();
  418. Doo::loadModel ( 'execute' );
  419. $execute = new execute ();
  420. $executeDetail = $execute->getOne ( array (
  421. 'where' => 'mold="对公汇款执行人"',
  422. 'asArray' => true
  423. ) );
  424. $receiptDetail = $receipt->getOne ( array (
  425. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  426. 'asArray' => true
  427. ) );
  428. if (empty ( $receiptDetail ))
  429. return "/saeaBorad";
  430. $aItem = $accountItem->find ( array (
  431. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  432. 'asArray' => true
  433. ) );
  434. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  435. $ag = $tr = $ta = $ot = 0;
  436. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  437. foreach ( $aItem as $key => $value ) {
  438. if ($value ['category'] == $this->AGENCY) {
  439. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  440. array_push ( $accountJson [$this->AGENCY], array (
  441. 'aid' => $value ['aid'],
  442. 'name' => $value ['name'],
  443. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  444. ) );
  445. $sum += $agency [$ag];
  446. $agencySum += $agency [$ag];
  447. }
  448. $ag ++;
  449. }
  450. }
  451. $accountJson ['cSum'] = array (
  452. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  453. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  454. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  455. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  456. );
  457. // 报销单
  458. $rid = $receipt->rid = $receiptDetail ['rid'];
  459. $receipt->accountItem = json_encode ( $accountJson );
  460. $receipt->staff = $this->staff [0] ['sid'];
  461. $receipt->sum = number_format ( $sum, 2, '.', '' );
  462. $receipt->date = date ( "Y-m-d" );
  463. $receipt->cid = $cid;
  464. if ($receiptDetail ['Rtype'] == 1)
  465. $receipt->status = 7;
  466. else
  467. $receipt->status = 5;
  468. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  469. $receipt->verify = $verify;
  470. $receipt->executeCopy = $executeDetail ['staff'];
  471. $receipt->explanation = $explanation;
  472. $receipt->update ();
  473. $receiptDetail = new receiptDetail ();
  474. $receiptDetail->delete ( array (
  475. 'where' => 'rid=' . $rid
  476. ) );
  477. // 报销详情
  478. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  479. $receiptDetail = new receiptDetail ();
  480. $receiptDetail->staff = $this->staff [0] ['sid'];
  481. $receiptDetail->item = $value ['name'];
  482. $receiptDetail->itemCategory = $this->AGENCY;
  483. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  484. $receiptDetail->date = date ( "Y-m-d" );
  485. $receiptDetail->cid = $cid;
  486. $receiptDetail->rid = $rid;
  487. $receiptDetail->status = 4;
  488. $receiptDetail->insert ();
  489. }
  490. // return "/referReceipt/".$rid;
  491. }
  492. return "/saeaBorad";
  493. }
  494. function remitApproval() {
  495. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  496. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  497. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  498. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  499. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  500. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  501. if (empty ( $status ))
  502. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  503. $vidList = array ();
  504. $button = 0;
  505. Doo::loadModel ( 'verify' );
  506. Doo::loadModel ( 'receipt' );
  507. Doo::loadModel ( 'staff' );
  508. $staff = new staff ();
  509. $receipt = new receipt ();
  510. $verify = new verify ();
  511. Doo::loadModel ( 'L_category' );
  512. $Lcategory = new L_category ();
  513. Doo::loadModel ( 'enclosur' );
  514. $enclosur = new enclosur ();
  515. // user verify ID
  516. $verifyDetail = $verify->find ( array (
  517. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  518. 'asArray' => true
  519. ) );
  520. foreach ( $verifyDetail as $key => $value ) {
  521. array_push ( $vidList, $value ['vid'] );
  522. }
  523. $vid = implode ( ",", $vidList );
  524. if (empty ( $verifyDetail ))
  525. $vid = 0;
  526. $categoryList = $Lcategory->find ( array (
  527. 'asArray' => true
  528. ) );
  529. $staffList = $staff->find ( array (
  530. 'where' => 'cid=' . $cid,
  531. 'asArray' => true
  532. ) );
  533. $ap = "";
  534. if ($status == 4) {
  535. $ap = 4;
  536. $status = 2;
  537. }
  538. // get Receipt By verifyID status 2
  539. $receiptList = $receipt->find ( array (
  540. 'where' => 'rid =' . $rid,
  541. 'desc' => 'rid',
  542. 'asArray' => true
  543. ) );
  544. $Locate = 0;
  545. $roleId = 0;
  546. if ($ap == 4)
  547. $status = 4;
  548. foreach ( $receiptList as $key => $value ) {
  549. $receiptList [$key] ['Locate'] = $Locate;
  550. $Locate ++;
  551. $receiptList [$key] ['reviseDetail'] = array ();
  552. if (! empty ( $value ['reviseDetail'] ))
  553. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  554. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  555. $categoryDetil = $Lcategory->getOne ( array (
  556. 'where' => 'cid=' . $value ['cid'],
  557. 'asArray' => true
  558. ) );
  559. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  560. // 检测编辑状态
  561. $verifyList = $verify->getOne ( array (
  562. 'where' => 'vid=' . $value ['verify'],
  563. 'asArray' => true
  564. ) );
  565. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  566. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  567. Doo::loadModel ( 'role' );
  568. $role = new role ();
  569. // print_r($verifyList);
  570. $flag = true;
  571. $roleKey = 0;
  572. $endStaffArray = array ();
  573. $roleArrayCopy = array ();
  574. foreach ( $verifyList as $k => $v ) {
  575. // init verifyStaff
  576. if ($v [1] == 'ROLE') {
  577. if (! empty ( $verifyStaff )) {
  578. $endStaffArray = end ( $verifyStaff );
  579. if ($v [0] == $endStaffArray ['nextStaff']) {
  580. $roleId = $v [0];
  581. }
  582. }
  583. $roleVerify = json_decode ( $v [3], true );
  584. $roleKey = $k;
  585. $roleArray = array ();
  586. $rolename = $role->getOne ( array (
  587. 'where' => 'rid=' . $v [0],
  588. 'asArray' => true
  589. ) );
  590. foreach ( $roleVerify as $o => $p ) {
  591. $staffID = explode ( '_', $p );
  592. $staffInfo = $staff->getOne ( array (
  593. 'where' => 'sid=' . $staffID [0],
  594. 'asArray' => true
  595. ) );
  596. // print_r($staffID);
  597. $exp = array (
  598. 0 => $staffInfo ['sid'],
  599. 1 => $staffID [1],
  600. 2 => $staffInfo ['avatar'],
  601. 'date' => '',
  602. 'date' => '',
  603. 'opinion' => '',
  604. 'status' => '',
  605. 'rolename' => $rolename ['name']
  606. );
  607. array_push ( $roleArray, $exp );
  608. }
  609. $roleArrayCopy [$v [0]] = $roleArray;
  610. // $verifyList[$k]['roleArray']=$roleArray;
  611. }
  612. // print_r($roleArray);
  613. $verifyList [$k] ['date'] = "";
  614. $verifyList [$k] ['opinion'] = "";
  615. $verifyList [$k] ['status'] = "";
  616. if (empty ( $verifyStaff )) {
  617. $verifyList [$k] ['date'] = "";
  618. $verifyList [$k] ['opinion'] = "";
  619. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  620. $verifyList [$k] ['status'] = 4;
  621. $button = 4;
  622. $flag = false;
  623. }
  624. } else {
  625. foreach ( $verifyStaff as $m => $u ) {
  626. if ($v [0] == $m) {
  627. $verifyList [$k] ['date'] = $u ['date'];
  628. $verifyList [$k] ['opinion'] = $u ['opinion'];
  629. $verifyList [$k] ['status'] = $u ['status'];
  630. $flag = false;
  631. break;
  632. }
  633. }
  634. $endStaffArray = end ( $verifyStaff );
  635. if (isset ( $endStaffArray ['ROLE'] )) {
  636. } else {
  637. $endKey = key ( $verifyStaff );
  638. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  639. $button = 4;
  640. $verifyList [$k] ['status'] = 4;
  641. }
  642. }
  643. }
  644. }
  645. $rolename ['name'] = '';
  646. if (! empty ( $roleId )) {
  647. Doo::loadModel ( 'role' );
  648. $role = new role ();
  649. $rolename = $role->getOne ( array (
  650. 'where' => 'rid=' . $roleId,
  651. 'asArray' => true
  652. ) );
  653. }
  654. if (! empty ( $verifyStaff ))
  655. $endStaffArray = end ( $verifyStaff );
  656. $KOP = false;
  657. foreach ( $roleArrayCopy as $P => $A ) {
  658. foreach ( $A as $MKI => $AVL ) {
  659. if (! empty ( $verifyStaff )) {
  660. // &&$rolename['rid']==$endStaffArray['nextStaff']
  661. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  662. $button = 4;
  663. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  664. }
  665. foreach ( $verifyStaff as $m => $u ) {
  666. $AVLFK = $AVL [0] . '_R';
  667. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  668. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  669. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  670. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  671. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  672. break;
  673. }
  674. }
  675. } else {
  676. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  677. $button = 4;
  678. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  679. }
  680. }
  681. // $roleArray[$MKI]['rolename']=$rolename['name'];
  682. $KOP = true;
  683. }
  684. }
  685. foreach ( $roleArrayCopy as $k => $v ) {
  686. foreach ( $verifyList as $m => $n ) {
  687. if ($n [0] == $k) {
  688. array_splice ( $verifyList, $m, 1, $v );
  689. }
  690. }
  691. }
  692. $receiptList [$key] ['verifyList'] = $verifyList;
  693. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  694. 'where' => 'sid=' . $value ['staff'],
  695. 'asArray' => true
  696. ) );
  697. $receiptList [$key] ['button'] = $button;
  698. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  699. }
  700. $mothHtml = "";
  701. for($i = 1; $i <= 12; $i ++) {
  702. if ($month == $i)
  703. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  704. else
  705. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  706. }
  707. // 获取审批日志
  708. Doo::loadModel ( 'receiptLog' );
  709. $receiptLog = new receiptLog ();
  710. $rlList = array ();
  711. $rlInfo = $receiptLog->getOne ( array (
  712. 'where' => 'rid=' . $rid . ' and status=4',
  713. 'asArray' => true
  714. ) );
  715. $tijdate = $receiptLog->getOne ( array (
  716. 'where' => 'rid=' . $rid . ' and status=2',
  717. 'asc' => 'rlid',
  718. 'asArray' => true
  719. ) );
  720. if (! empty ( $rlInfo )) {
  721. $rlList = $receiptLog->find ( array (
  722. 'where' => 'rid=' . $rid,
  723. 'asc' => 'rlid',
  724. 'asArray' => true
  725. ) );
  726. }
  727. $receiptList [0] ['rlList'] = $rlList;
  728. $enclosurList = $enclosur->find ( array (
  729. 'where' => 'rid=' . $rid,
  730. 'asArray' => true
  731. ) );
  732. $enclosurHtml = '';
  733. foreach ( $enclosurList as $value ) {
  734. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  735. }
  736. // print_r($receiptList);
  737. $data ['enclosurHtml'] = $enclosurHtml;
  738. $data ['rolename'] = $rolename ['name'];
  739. $data ['datetij'] = $tijdate ['date'];
  740. $data ['mothHtml'] = $mothHtml;
  741. $data ['rid'] = $rid;
  742. $data ['receiptList'] = $receiptList;
  743. $data ['receiptApprovalCount'] = count ( $receiptList );
  744. $data ['status'] = $status;
  745. $data ['year'] = $year;
  746. $data ['categoryList'] = $categoryList;
  747. $data ['staffList'] = $staffList;
  748. $data ['cid'] = $cid;
  749. $data ['sid'] = $sid;
  750. $data ['ap'] = $ap;
  751. $data ['memu'] = "receipt";
  752. $data ['staff'] = $this->staff;
  753. $data ['receiptMemu'] = 'approvalExpenses';
  754. $data ['verifyId'] = $this->verifyId;
  755. $data ['executeId'] = $this->executeId;
  756. $this->render ( "/admin/remitApproval", $data );
  757. }
  758. function saeaLoanAdd() {
  759. Doo::loadModel ( 'verify' );
  760. $verify = new verify ();
  761. Doo::loadModel ( "role" );
  762. $role = new role ();
  763. Doo::loadModel ( 'L_category' );
  764. $lCategory = new L_category ();
  765. $veList = $verify->find ( array (
  766. 'asArray' => true
  767. ) );
  768. foreach ( $veList as $key => $value ) {
  769. $v = json_decode ( $value ['staff'] );
  770. $list = array ();
  771. foreach ( $v as $n => $m ) {
  772. if ($m ['1'] == 'ROLE') {
  773. $roleInfo = $role->getOne ( array (
  774. 'where' => 'rid=' . $m [0],
  775. 'asArray' => true
  776. ) );
  777. $v [$n] [1] = $roleInfo ['name'];
  778. array_push ( $list, $roleInfo ['name'] );
  779. } else {
  780. array_push ( $list, $v [$n] [1] );
  781. }
  782. }
  783. $veList [$key] ['staff'] = implode ( '>', $list );
  784. }
  785. $data ['category'] = $lCategory->find ( array (
  786. 'asArray' => true
  787. ) );
  788. $data ['veList'] = $veList;
  789. $data ['memu'] = "receipt";
  790. $data ['staff'] = $this->staff;
  791. $data ['receiptMemu'] = 'saeaBorad';
  792. $data ['verifyId'] = $this->verifyId;
  793. $data ['executeId'] = $this->executeId;
  794. $this->render ( "/admin/saeaLoanAdd", $data );
  795. }
  796. function saeaLoanAddDo() {
  797. $agency = $this->get_args ( 'agency' );
  798. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  799. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  800. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  801. // die;
  802. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  803. Doo::loadModel ( 'receipt' );
  804. Doo::loadModel ( 'receiptDetail' );
  805. Doo::loadModel ( 'accountItem' );
  806. $accountItem = new accountItem ();
  807. $receipt = new receipt ();
  808. Doo::loadModel ( 'loanReceipt' );
  809. $loanReceipt = new loanReceipt ();
  810. Doo::loadModel ( 'execute' );
  811. $execute = new execute ();
  812. Doo::loadModel ( 'enclosur' );
  813. $executeDetail = $execute->getOne ( array (
  814. 'where' => 'mold="借款执行人"',
  815. 'asArray' => true
  816. ) );
  817. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  818. // if(!empty($receiptDetail))
  819. // return "/referReceipt/".$receiptDetail['rid'];
  820. $aItem = $accountItem->find ( array (
  821. 'asArray' => true
  822. ) );
  823. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  824. $ag = $tr = $ta = $ot = 0;
  825. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  826. array_push ( $accountJson ['借款费用'], array (
  827. 'aid' => 0,
  828. 'name' => '申请金额',
  829. 'price' => number_format ( $agency, 2, '.', '' )
  830. ) );
  831. $sum += $agency;
  832. $agencySum += $agency;
  833. $accountJson ['cSum'] = array (
  834. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  835. 'agencySum' => number_format ( 0, 2, '.', '' ),
  836. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  837. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  838. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  839. );
  840. // 借款数据备份
  841. $loanReceipt->loanItem = json_encode ( $accountJson );
  842. $loanReceipt->staff = $this->staff [0] ['sid'];
  843. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  844. $loanReceipt->date = date ( "Y-m-d" );
  845. $loanReceipt->cid = $cid;
  846. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  847. $loanReceipt->status = 5;
  848. $loanReceipt->Rtype = 1;
  849. $loanReceipt->verify = $verify;
  850. $receipt->receiptOrder = $receipt->receiptOrder;
  851. $loanReceipt->explanation = $explanation;
  852. $loanRid = $loanReceipt->insert ();
  853. // 报销单
  854. $receipt->loanItem = json_encode ( $accountJson );
  855. $receipt->staff = $this->staff [0] ['sid'];
  856. $receipt->sum = number_format ( $sum, 2, '.', '' );
  857. $receipt->date = date ( "Y-m-d" );
  858. $receipt->cid = $cid;
  859. // 特殊状态
  860. $receipt->status = 5;
  861. $receipt->Rtype = 1;
  862. $receipt->loanRid = $loanRid;
  863. // 修改审批流程加入角色
  864. $receipt->verify = $verify;
  865. $receipt->executeCopy = $executeDetail ['staff'];
  866. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  867. $receipt->explanation = $explanation;
  868. $rid = $receipt->insert ();
  869. // 执行数据备份
  870. // $executeCopy->rid=$rid;
  871. // $executeCopy->staff=$executeDetail['staff'];
  872. // $executeCopy->eid=$executeDetail['eid'];
  873. // $ecid=$executeCopy->insert();
  874. }
  875. return "/saeaBorad";
  876. }
  877. function saeaLoanEdi() {
  878. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  879. Doo::loadModel ( 'verify' );
  880. $verify = new verify ();
  881. Doo::loadModel ( "role" );
  882. $role = new role ();
  883. Doo::loadModel ( 'L_category' );
  884. $lCategory = new L_category ();
  885. Doo::loadModel ( 'receipt' );
  886. $receipt = new receipt ();
  887. $receiptInfo = $receipt->getOne ( array (
  888. 'where' => 'rid=' . $rid,
  889. 'asArray' => true
  890. ) );
  891. $veList = $verify->find ( array (
  892. 'asArray' => true
  893. ) );
  894. foreach ( $veList as $key => $value ) {
  895. $v = json_decode ( $value ['staff'] );
  896. $list = array ();
  897. foreach ( $v as $n => $m ) {
  898. if ($m ['1'] == 'ROLE') {
  899. $roleInfo = $role->getOne ( array (
  900. 'where' => 'rid=' . $m [0],
  901. 'asArray' => true
  902. ) );
  903. $v [$n] [1] = $roleInfo ['name'];
  904. array_push ( $list, $roleInfo ['name'] );
  905. } else {
  906. array_push ( $list, $v [$n] [1] );
  907. }
  908. }
  909. $veList [$key] ['staff'] = implode ( '>', $list );
  910. }
  911. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  912. $data ['receiptInfo'] = $receiptInfo;
  913. $data ['category'] = $lCategory->find ( array (
  914. 'asArray' => true
  915. ) );
  916. $data ['veList'] = $veList;
  917. $data ['memu'] = "receipt";
  918. $data ['staff'] = $this->staff;
  919. $data ['receiptMemu'] = 'saeaBorad';
  920. $data ['verifyId'] = $this->verifyId;
  921. $data ['executeId'] = $this->executeId;
  922. $this->render ( "/admin/saeaLoanEdi", $data );
  923. }
  924. function saeaLoanEdiDo() {
  925. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  926. $agency = $this->get_args ( 'agency' );
  927. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  928. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  929. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  930. // die;
  931. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )) {
  932. Doo::loadModel ( 'receipt' );
  933. Doo::loadModel ( 'receiptDetail' );
  934. Doo::loadModel ( 'accountItem' );
  935. $accountItem = new accountItem ();
  936. $receipt = new receipt ();
  937. Doo::loadModel ( 'loanReceipt' );
  938. $loanReceipt = new loanReceipt ();
  939. Doo::loadModel ( 'enclosur' );
  940. Doo::loadModel ( 'execute' );
  941. $execute = new execute ();
  942. $executeDetail = $execute->getOne ( array (
  943. 'where' => 'mold="借款执行人"',
  944. 'asArray' => true
  945. ) );
  946. $receiptDetail = $receipt->getOne ( array (
  947. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  948. 'asArray' => true
  949. ) );
  950. if (empty ( $receiptDetail ))
  951. die ( '参数错误' );
  952. $aItem = $accountItem->find ( array (
  953. 'asArray' => true
  954. ) );
  955. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  956. $ag = $tr = $ta = $ot = 0;
  957. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  958. array_push ( $accountJson ['借款费用'], array (
  959. 'aid' => 0,
  960. 'name' => '申请金额',
  961. 'price' => number_format ( $agency, 2, '.', '' )
  962. ) );
  963. $sum += $agency;
  964. $agencySum += $agency;
  965. $accountJson ['cSum'] = array (
  966. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  967. 'agencySum' => number_format ( 0, 2, '.', '' ),
  968. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  969. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  970. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  971. );
  972. // 报销单
  973. $receipt->loanItem = json_encode ( $accountJson );
  974. $receipt->sum = number_format ( $sum, 2, '.', '' );
  975. $receipt->cid = $cid;
  976. // 特殊状态
  977. // 修改审批流程加入角色
  978. if ($receiptDetail ['status'] != 4)
  979. $receipt->verify = $verify;
  980. $receipt->explanation = $explanation;
  981. $receipt->update ( array (
  982. 'where' => 'rid=' . $rid
  983. ) );
  984. // 借款数据更新
  985. $loanReceipt->loanItem = json_encode ( $accountJson );
  986. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  987. $loanReceipt->cid = $cid;
  988. if ($receiptDetail ['status'] != 4)
  989. $loanReceipt->verify = $verify;
  990. $loanReceipt->explanation = $explanation;
  991. $receipt->executeCopy = $executeDetail ['staff'];
  992. $loanReceipt->update ( array (
  993. 'where' => 'rid=' . $receiptDetail ['loanRid']
  994. ) );
  995. }
  996. return "/saeaBorad";
  997. }
  998. function saeaLoanReceiptAdd() {
  999. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1000. Doo::loadModel ( 'receipt' );
  1001. $receipt = new receipt ();
  1002. Doo::loadModel ( 'loanReceipt' );
  1003. $loanReceipt = new loanReceipt ();
  1004. Doo::loadModel ( 'L_category' );
  1005. $Lcategory = new L_category ();
  1006. Doo::loadModel ( 'verify' );
  1007. Doo::loadModel ( 'statistics' );
  1008. $statistics = new statistics ();
  1009. $verify = new verify ();
  1010. Doo::loadModel ( 'staff' );
  1011. $staff = new staff ();
  1012. $receiptDe = $receipt->getOne ( array (
  1013. 'where' => 'rid=' . $rid,
  1014. 'desc' => 'rid',
  1015. 'asArray' => true
  1016. ) );
  1017. $receiptList = $loanReceipt->find ( array (
  1018. 'where' => 'rid=' . $receiptDe ['loanRid'],
  1019. 'desc' => 'rid',
  1020. 'asArray' => true
  1021. ) );
  1022. $Locate = 0;
  1023. $roleId = 0;
  1024. $button = 0;
  1025. foreach ( $receiptList as $key => $value ) {
  1026. $receiptList [$key] ['Locate'] = $Locate;
  1027. $Locate ++;
  1028. $receiptList [$key] ['reviseDetail'] = array ();
  1029. if (! empty ( $value ['reviseDetail'] ))
  1030. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1031. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1032. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1033. $categoryDetil = $Lcategory->getOne ( array (
  1034. 'where' => 'cid=' . $value ['cid'],
  1035. 'asArray' => true
  1036. ) );
  1037. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1038. // 检测编辑状态
  1039. $verifyList = $verify->getOne ( array (
  1040. 'where' => 'vid=' . $value ['verify'],
  1041. 'asArray' => true
  1042. ) );
  1043. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1044. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1045. Doo::loadModel ( 'role' );
  1046. $role = new role ();
  1047. $flag = true;
  1048. $roleKey = 0;
  1049. $endStaffArray = array ();
  1050. $roleArrayCopy = array ();
  1051. foreach ( $verifyList as $k => $v ) {
  1052. // init verifyStaff
  1053. if ($v [1] == 'ROLE') {
  1054. if (! empty ( $verifyStaff )) {
  1055. $endStaffArray = end ( $verifyStaff );
  1056. // if ($v[0]==$endStaffArray['nextStaff']){
  1057. // $roleId=$v[0];
  1058. // }
  1059. }
  1060. $roleVerify = json_decode ( $v [3], true );
  1061. $roleKey = $k;
  1062. $roleArray = array ();
  1063. $rolename = $role->getOne ( array (
  1064. 'where' => 'rid=' . $v [0],
  1065. 'asArray' => true
  1066. ) );
  1067. foreach ( $roleVerify as $o => $p ) {
  1068. $staffID = explode ( '_', $p );
  1069. $staffInfo = $staff->getOne ( array (
  1070. 'where' => 'sid=' . $staffID [0],
  1071. 'asArray' => true
  1072. ) );
  1073. // print_r($staffID);
  1074. $exp = array (
  1075. 0 => $staffInfo ['sid'],
  1076. 1 => $staffID [1],
  1077. 2 => $staffInfo ['avatar'],
  1078. 'date' => '',
  1079. 'date' => '',
  1080. 'opinion' => '',
  1081. 'status' => '',
  1082. 'rolename' => $rolename ['name']
  1083. );
  1084. array_push ( $roleArray, $exp );
  1085. }
  1086. $roleArrayCopy [$v [0]] = $roleArray;
  1087. // $verifyList[$k]['roleArray']=$roleArray;
  1088. }
  1089. $verifyList [$k] ['date'] = "";
  1090. $verifyList [$k] ['opinion'] = "";
  1091. $verifyList [$k] ['status'] = "";
  1092. if (empty ( $verifyStaff )) {
  1093. $verifyList [$k] ['date'] = "";
  1094. $verifyList [$k] ['opinion'] = "";
  1095. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1096. $verifyList [$k] ['status'] = 4;
  1097. $flag = false;
  1098. }
  1099. } else {
  1100. foreach ( $verifyStaff as $m => $u ) {
  1101. if ($v [0] == $m) {
  1102. $verifyList [$k] ['date'] = $u ['date'];
  1103. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1104. $verifyList [$k] ['status'] = $u ['status'];
  1105. $flag = false;
  1106. break;
  1107. }
  1108. }
  1109. $endStaffArray = end ( $verifyStaff );
  1110. if (isset ( $endStaffArray ['ROLE'] )) {
  1111. } else {
  1112. // $endKey=key($verifyStaff);
  1113. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1114. // $button=4;
  1115. // $verifyList[$k]['status']=4;
  1116. // }
  1117. }
  1118. }
  1119. }
  1120. $rolename ['name'] = '';
  1121. if (! empty ( $roleId )) {
  1122. Doo::loadModel ( 'role' );
  1123. $role = new role ();
  1124. $rolename = $role->getOne ( array (
  1125. 'where' => 'rid=' . $roleId,
  1126. 'asArray' => true
  1127. ) );
  1128. }
  1129. if (! empty ( $verifyStaff ))
  1130. $endStaffArray = end ( $verifyStaff );
  1131. $KOP = false;
  1132. foreach ( $roleArrayCopy as $P => $A ) {
  1133. foreach ( $A as $MKI => $AVL ) {
  1134. if (! empty ( $verifyStaff )) {
  1135. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1136. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1137. $button = 4;
  1138. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1139. }
  1140. foreach ( $verifyStaff as $m => $u ) {
  1141. $AVLFK = $AVL [0] . '_R';
  1142. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1143. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1144. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1145. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1146. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1147. break;
  1148. }
  1149. }
  1150. } else {
  1151. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1152. $button = 4;
  1153. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1154. }
  1155. }
  1156. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1157. $KOP = true;
  1158. }
  1159. }
  1160. foreach ( $roleArrayCopy as $k => $v ) {
  1161. foreach ( $verifyList as $m => $n ) {
  1162. if ($n [0] == $k) {
  1163. array_splice ( $verifyList, $m, 1, $v );
  1164. }
  1165. }
  1166. }
  1167. $receiptList [$key] ['verifyList'] = $verifyList;
  1168. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1169. 'where' => 'sid=' . $value ['staff'],
  1170. 'asArray' => true
  1171. ) );
  1172. $receiptList [$key] ['button'] = $button;
  1173. //
  1174. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1175. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1176. }
  1177. $data ['receiptList'] = $receiptList;
  1178. Doo::loadModel ( 'L_category' );
  1179. $lCategory = new L_category ();
  1180. Doo::loadModel ( 'accountItem' );
  1181. $accountItem = new accountItem ();
  1182. $acItem = $accountItem->find ( array (
  1183. 'asArray' => true
  1184. ) );
  1185. $veList = $verify->find ( array (
  1186. 'asArray' => true
  1187. ) );
  1188. foreach ( $veList as $key => $value ) {
  1189. $v = json_decode ( $value ['staff'] );
  1190. $list = array ();
  1191. foreach ( $v as $n => $m ) {
  1192. if ($m ['1'] == 'ROLE') {
  1193. $roleInfo = $role->getOne ( array (
  1194. 'where' => 'rid=' . $m [0],
  1195. 'asArray' => true
  1196. ) );
  1197. $v [$n] [1] = $roleInfo ['name'];
  1198. array_push ( $list, $roleInfo ['name'] );
  1199. } else {
  1200. array_push ( $list, $v [$n] [1] );
  1201. }
  1202. }
  1203. $veList [$key] ['staff'] = implode ( '>', $list );
  1204. }
  1205. $data ['rid'] = $rid;
  1206. $data ['category'] = $lCategory->find ( array (
  1207. 'asArray' => true
  1208. ) );
  1209. $data ['veList'] = $veList;
  1210. $data ['acItem'] = $acItem;
  1211. $data ['memu'] = "receipt";
  1212. $data ['staff'] = $this->staff;
  1213. $data ['receiptMemu'] = 'saeaBorad';
  1214. $data ['verifyId'] = $this->verifyId;
  1215. $data ['executeId'] = $this->executeId;
  1216. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1217. }
  1218. function saeaLoanReceiptAddDo() {
  1219. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1220. $agency = $this->get_args ( 'agency' );
  1221. $travel = $this->get_args ( 'travel' );
  1222. $train = $this->get_args ( 'train' );
  1223. $other = $this->get_args ( 'other' );
  1224. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1225. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1226. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1227. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1228. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )) {
  1229. Doo::loadModel ( 'receipt' );
  1230. Doo::loadModel ( 'receiptDetail' );
  1231. Doo::loadModel ( 'accountItem' );
  1232. $accountItem = new accountItem ();
  1233. $receipt = new receipt ();
  1234. Doo::loadModel ( 'enclosur' );
  1235. Doo::loadModel ( 'execute' );
  1236. $execute = new execute ();
  1237. $executeDetail = $execute->getOne ( array (
  1238. 'where' => 'mold="借款费用执行人"',
  1239. 'asArray' => true
  1240. ) );
  1241. $receiptDet = $receipt->getOne ( array (
  1242. 'where' => 'rid=' . $rid,
  1243. 'asArray' => true
  1244. ) );
  1245. // if(!empty($receiptDetail))
  1246. // return "/referReceipt/".$receiptDetail['rid'];
  1247. $aItem = $accountItem->find ( array (
  1248. 'asArray' => true
  1249. ) );
  1250. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1251. $ag = $tr = $ta = $ot = 0;
  1252. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1253. foreach ( $aItem as $key => $value ) {
  1254. if ($value ['category'] == $this->AGENCY) {
  1255. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1256. array_push ( $accountJson [$this->AGENCY], array (
  1257. 'aid' => $value ['aid'],
  1258. 'name' => $value ['name'],
  1259. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1260. ) );
  1261. $sum += $agency [$ag];
  1262. $agencySum += $agency [$ag];
  1263. }
  1264. $ag ++;
  1265. }
  1266. if ($value ['category'] == $this->TRAVEL) {
  1267. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1268. array_push ( $accountJson [$this->TRAVEL], array (
  1269. 'aid' => $value ['aid'],
  1270. 'name' => $value ['name'],
  1271. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1272. ) );
  1273. $sum += $travel [$tr];
  1274. $travelSum += $travel [$tr];
  1275. }
  1276. $tr ++;
  1277. }
  1278. if ($value ['category'] == $this->TRAIN) {
  1279. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1280. array_push ( $accountJson [$this->TRAIN], array (
  1281. 'aid' => $value ['aid'],
  1282. 'name' => $value ['name'],
  1283. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1284. ) );
  1285. $sum += $train [$ta];
  1286. $trainSum += $train [$ta];
  1287. }
  1288. $ta ++;
  1289. }
  1290. if ($value ['category'] == $this->OTHER) {
  1291. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1292. array_push ( $accountJson [$this->OTHER], array (
  1293. 'aid' => $value ['aid'],
  1294. 'name' => $value ['name'],
  1295. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1296. ) );
  1297. $sum += $other [$ot];
  1298. $otherSum += $other [$ot];
  1299. }
  1300. $ot ++;
  1301. }
  1302. }
  1303. $accountJson ['cSum'] = array (
  1304. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1305. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1306. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1307. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1308. );
  1309. // 报销单
  1310. $receipt->accountItem = json_encode ( $accountJson );
  1311. $receipt->staff = $this->staff [0] ['sid'];
  1312. $receipt->loanSum = $receiptDet ['sum'];
  1313. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1314. $receipt->date = date ( "Y-m-d" );
  1315. $receipt->pastDate = '';
  1316. $receipt->cid = $cid;
  1317. $receipt->status = 7;
  1318. // 修改审批流程加入角色
  1319. $receipt->verify = $verify;
  1320. $receipt->verifyStaff = '';
  1321. $receipt->executeStaff = '';
  1322. $receipt->executeCopy = $executeDetail ['staff'];
  1323. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  1324. $receipt->explanation = $explanation;
  1325. $receipt->update ( array (
  1326. 'where' => 'rid=' . $rid
  1327. ) );
  1328. // 附件
  1329. if (! empty ( $enclosurName )) {
  1330. $enclosurArray = explode ( '-', $enclosurName );
  1331. foreach ( $enclosurArray as $value ) {
  1332. $enclosur = new enclosur ();
  1333. $enclosur->name = $value;
  1334. $enclosur->rid = $rid;
  1335. $enclosur->insert ();
  1336. }
  1337. // print_r($enclosurArray);die;
  1338. }
  1339. // 报销详情
  1340. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1341. $receiptDetail = new receiptDetail ();
  1342. $receiptDetail->staff = $this->staff [0] ['sid'];
  1343. $receiptDetail->item = $value ['name'];
  1344. $receiptDetail->itemCategory = $this->AGENCY;
  1345. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1346. $receiptDetail->date = date ( "Y-m-d" );
  1347. $receiptDetail->cid = $cid;
  1348. $receiptDetail->rid = $rid;
  1349. $receiptDetail->status = 4;
  1350. $receiptDetail->insert ();
  1351. }
  1352. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1353. $receiptDetail = new receiptDetail ();
  1354. $receiptDetail->staff = $this->staff [0] ['sid'];
  1355. $receiptDetail->item = $value ['name'];
  1356. $receiptDetail->itemCategory = $this->TRAVEL;
  1357. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1358. $receiptDetail->date = date ( "Y-m-d" );
  1359. $receiptDetail->cid = $cid;
  1360. $receiptDetail->rid = $rid;
  1361. $receiptDetail->status = 4;
  1362. $receiptDetail->insert ();
  1363. }
  1364. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1365. $receiptDetail = new receiptDetail ();
  1366. $receiptDetail->staff = $this->staff [0] ['sid'];
  1367. $receiptDetail->item = $value ['name'];
  1368. $receiptDetail->itemCategory = $this->TRAIN;
  1369. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1370. $receiptDetail->date = date ( "Y-m-d" );
  1371. $receiptDetail->cid = $cid;
  1372. $receiptDetail->rid = $rid;
  1373. $receiptDetail->status = 4;
  1374. $receiptDetail->insert ();
  1375. }
  1376. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1377. $receiptDetail = new receiptDetail ();
  1378. $receiptDetail->staff = $this->staff [0] ['sid'];
  1379. $receiptDetail->item = $value ['name'];
  1380. $receiptDetail->itemCategory = $this->OTHER;
  1381. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1382. $receiptDetail->date = date ( "Y-m-d" );
  1383. $receiptDetail->cid = $cid;
  1384. $receiptDetail->rid = $rid;
  1385. $receiptDetail->status = 4;
  1386. $receiptDetail->insert ();
  1387. }
  1388. return "/saeaBorad";
  1389. }
  1390. return "/saeaLoanReceiptAdd/" . $rid;
  1391. }
  1392. function saeaLoanReceiptEdi() {
  1393. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1394. // echo $rid;
  1395. Doo::loadModel ( 'accountItem' );
  1396. Doo::loadModel ( 'verify' );
  1397. Doo::loadModel ( 'receipt' );
  1398. $receipt = new receipt ();
  1399. $verify = new verify ();
  1400. $accountItem = new accountItem ();
  1401. Doo::loadModel ( 'L_category' );
  1402. $Lcategory = new L_category ();
  1403. Doo::loadModel ( "role" );
  1404. $role = new role ();
  1405. Doo::loadModel ( 'loanReceipt' );
  1406. $loanReceipt = new loanReceipt ();
  1407. Doo::loadModel ( 'staff' );
  1408. $staff = new staff ();
  1409. $receiptDetail = $receipt->getOne ( array (
  1410. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  1411. 'asArray' => true
  1412. ) );
  1413. if (empty ( $receiptDetail ))
  1414. return "/saeaBorad";
  1415. $receiptList = $loanReceipt->find ( array (
  1416. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1417. 'desc' => 'rid',
  1418. 'asArray' => true
  1419. ) );
  1420. $Locate = 0;
  1421. $roleId = 0;
  1422. $button = 0;
  1423. foreach ( $receiptList as $key => $value ) {
  1424. $receiptList [$key] ['Locate'] = $Locate;
  1425. $Locate ++;
  1426. $receiptList [$key] ['reviseDetail'] = array ();
  1427. if (! empty ( $value ['reviseDetail'] ))
  1428. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1429. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1430. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1431. $categoryDetil = $Lcategory->getOne ( array (
  1432. 'where' => 'cid=' . $value ['cid'],
  1433. 'asArray' => true
  1434. ) );
  1435. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1436. // 检测编辑状态
  1437. $verifyList = $verify->getOne ( array (
  1438. 'where' => 'vid=' . $value ['verify'],
  1439. 'asArray' => true
  1440. ) );
  1441. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1442. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1443. Doo::loadModel ( 'role' );
  1444. $role = new role ();
  1445. $flag = true;
  1446. $roleKey = 0;
  1447. $endStaffArray = array ();
  1448. $roleArrayCopy = array ();
  1449. foreach ( $verifyList as $k => $v ) {
  1450. // init verifyStaff
  1451. if ($v [1] == 'ROLE') {
  1452. if (! empty ( $verifyStaff )) {
  1453. $endStaffArray = end ( $verifyStaff );
  1454. // if ($v[0]==$endStaffArray['nextStaff']){
  1455. // $roleId=$v[0];
  1456. // }
  1457. }
  1458. $roleVerify = json_decode ( $v [3], true );
  1459. $roleKey = $k;
  1460. $roleArray = array ();
  1461. $rolename = $role->getOne ( array (
  1462. 'where' => 'rid=' . $v [0],
  1463. 'asArray' => true
  1464. ) );
  1465. foreach ( $roleVerify as $o => $p ) {
  1466. $staffID = explode ( '_', $p );
  1467. $staffInfo = $staff->getOne ( array (
  1468. 'where' => 'sid=' . $staffID [0],
  1469. 'asArray' => true
  1470. ) );
  1471. // print_r($staffID);
  1472. $exp = array (
  1473. 0 => $staffInfo ['sid'],
  1474. 1 => $staffID [1],
  1475. 2 => $staffInfo ['avatar'],
  1476. 'date' => '',
  1477. 'date' => '',
  1478. 'opinion' => '',
  1479. 'status' => '',
  1480. 'rolename' => $rolename ['name']
  1481. );
  1482. array_push ( $roleArray, $exp );
  1483. }
  1484. $roleArrayCopy [$v [0]] = $roleArray;
  1485. // $verifyList[$k]['roleArray']=$roleArray;
  1486. }
  1487. $verifyList [$k] ['date'] = "";
  1488. $verifyList [$k] ['opinion'] = "";
  1489. $verifyList [$k] ['status'] = "";
  1490. if (empty ( $verifyStaff )) {
  1491. $verifyList [$k] ['date'] = "";
  1492. $verifyList [$k] ['opinion'] = "";
  1493. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1494. $verifyList [$k] ['status'] = 4;
  1495. $flag = false;
  1496. }
  1497. } else {
  1498. foreach ( $verifyStaff as $m => $u ) {
  1499. if ($v [0] == $m) {
  1500. $verifyList [$k] ['date'] = $u ['date'];
  1501. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1502. $verifyList [$k] ['status'] = $u ['status'];
  1503. $flag = false;
  1504. break;
  1505. }
  1506. }
  1507. $endStaffArray = end ( $verifyStaff );
  1508. if (isset ( $endStaffArray ['ROLE'] )) {
  1509. } else {
  1510. // $endKey=key($verifyStaff);
  1511. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1512. // $button=4;
  1513. // $verifyList[$k]['status']=4;
  1514. // }
  1515. }
  1516. }
  1517. }
  1518. $rolename ['name'] = '';
  1519. if (! empty ( $roleId )) {
  1520. Doo::loadModel ( 'role' );
  1521. $role = new role ();
  1522. $rolename = $role->getOne ( array (
  1523. 'where' => 'rid=' . $roleId,
  1524. 'asArray' => true
  1525. ) );
  1526. }
  1527. if (! empty ( $verifyStaff ))
  1528. $endStaffArray = end ( $verifyStaff );
  1529. $KOP = false;
  1530. foreach ( $roleArrayCopy as $P => $A ) {
  1531. foreach ( $A as $MKI => $AVL ) {
  1532. if (! empty ( $verifyStaff )) {
  1533. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1534. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1535. $button = 4;
  1536. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1537. }
  1538. foreach ( $verifyStaff as $m => $u ) {
  1539. $AVLFK = $AVL [0] . '_R';
  1540. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1541. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1542. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1543. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1544. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1545. break;
  1546. }
  1547. }
  1548. } else {
  1549. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1550. $button = 4;
  1551. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1552. }
  1553. }
  1554. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1555. $KOP = true;
  1556. }
  1557. }
  1558. foreach ( $roleArrayCopy as $k => $v ) {
  1559. foreach ( $verifyList as $m => $n ) {
  1560. if ($n [0] == $k) {
  1561. array_splice ( $verifyList, $m, 1, $v );
  1562. }
  1563. }
  1564. }
  1565. $receiptList [$key] ['verifyList'] = $verifyList;
  1566. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1567. 'where' => 'sid=' . $value ['staff'],
  1568. 'asArray' => true
  1569. ) );
  1570. $receiptList [$key] ['button'] = $button;
  1571. //
  1572. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1573. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1574. }
  1575. $data ['receiptList'] = $receiptList;
  1576. $acItem = $accountItem->find ( array (
  1577. 'asArray' => true
  1578. ) );
  1579. $veList = $verify->find ( array (
  1580. 'asArray' => true
  1581. ) );
  1582. foreach ( $veList as $key => $value ) {
  1583. $v = json_decode ( $value ['staff'] );
  1584. $list = array ();
  1585. foreach ( $v as $n => $m ) {
  1586. if ($m ['1'] == 'ROLE') {
  1587. $roleInfo = $role->getOne ( array (
  1588. 'where' => 'rid=' . $m [0],
  1589. 'asArray' => true
  1590. ) );
  1591. $v [$n] [1] = $roleInfo ['name'];
  1592. array_push ( $list, $roleInfo ['name'] );
  1593. } else {
  1594. array_push ( $list, $v [$n] [1] );
  1595. }
  1596. }
  1597. $veList [$key] ['staff'] = implode ( '>', $list );
  1598. }
  1599. // 配置编辑信息
  1600. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1601. foreach ( $acItem as $key => $value ) {
  1602. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1603. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1604. $acItem [$key] ['price'] = $v ['price'];
  1605. }
  1606. }
  1607. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1608. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1609. $acItem [$key] ['price'] = $v ['price'];
  1610. }
  1611. }
  1612. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1613. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1614. $acItem [$key] ['price'] = $v ['price'];
  1615. }
  1616. }
  1617. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1618. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1619. $acItem [$key] ['price'] = $v ['price'];
  1620. }
  1621. }
  1622. }
  1623. $data ['category'] = $Lcategory->find ( array (
  1624. 'asArray' => true
  1625. ) );
  1626. $data ['cSum'] = $accountItemList ['cSum'];
  1627. $data ['sum'] = $receiptDetail ['sum'];
  1628. $data ['receiptDetail'] = $receiptDetail;
  1629. $data ['veList'] = $veList;
  1630. $data ['acItem'] = $acItem;
  1631. $data ['memu'] = "receipt";
  1632. $data ['staff'] = $this->staff;
  1633. $data ['receiptMemu'] = 'saeaBorad';
  1634. $data ['verify'] = $receiptDetail ['verify'];
  1635. $data ['verifyId'] = $this->verifyId;
  1636. $data ['executeId'] = $this->executeId;
  1637. $data ['rid'] = $rid;
  1638. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  1639. }
  1640. function confirmation() {
  1641. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1642. Doo::loadModel ( 'receipt' );
  1643. Doo::loadModel ( 'receiptDetail' );
  1644. $receipt = new receipt ();
  1645. $receiptDetail = new receiptDetail ();
  1646. Doo::loadModel ( 'statistics' );
  1647. Doo::loadModel ( 'itemStatistics' );
  1648. $statistics = new statistics ();
  1649. $itemStatistics = new itemStatistics ();
  1650. Doo::loadModel ( "verify" );
  1651. $verify = new verify ();
  1652. $receiptDetailList = $receipt->getOne ( array (
  1653. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  1654. 'asArray' => true
  1655. ) );
  1656. if (empty ( $receiptDetailList ))
  1657. return "/saeaBorad";
  1658. $verifyDetail = $verify->getOne ( array (
  1659. 'where' => ' vid =' . $receiptDetailList ['verify'],
  1660. 'asArray' => true
  1661. ) );
  1662. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  1663. if (empty ( $receiptDetailList ['nowStaff'] )) {
  1664. $nowStaff = "";
  1665. $nowStaffList = array ();
  1666. if ($verifyDetail [0] [1] == 'ROLE') {
  1667. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  1668. foreach ( $vStaffString as $key => $value ) {
  1669. $staffK = explode ( "_", $value );
  1670. array_push ( $nowStaffList, $staffK [0] );
  1671. }
  1672. $nowStaff = implode ( ',', $nowStaffList );
  1673. } else {
  1674. $nowStaff = $verifyDetail [0] [0];
  1675. }
  1676. $receipt->nowStaff = $nowStaff;
  1677. }
  1678. // echo $nowStaff;
  1679. // print_r($verifyDetail);die;
  1680. $receipt->rid = $receiptDetailList ['rid'];
  1681. $receipt->status = 2;
  1682. $receipt->update ();
  1683. // 操作日志
  1684. Doo::loadModel ( "receiptLog" );
  1685. $receiptLog = new receiptLog ();
  1686. $verify = new verify ();
  1687. $receiptInfo = $receipt->getOne ( array (
  1688. 'where' => 'rid=' . $rid,
  1689. 'asArray' => true
  1690. ) );
  1691. $vr = $verify->getOne ( array (
  1692. 'where' => 'vid=' . $receiptInfo ['verify'],
  1693. 'asArray' => true
  1694. ) );
  1695. $jd = json_decode ( $vr ['staff'] );
  1696. $roleId = 0;
  1697. foreach ( $jd as $key => $value ) {
  1698. if ($value [1] == 'ROLE') {
  1699. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  1700. if ($pos !== false) {
  1701. $roleId = $value [0];
  1702. }
  1703. }
  1704. }
  1705. // 审批日志
  1706. // echo $roleId;die;
  1707. if (! empty ( $roleId )) {
  1708. Doo::loadModel ( "role" );
  1709. $role = new role ();
  1710. $roleInfo = $role->getOne ( array (
  1711. 'where' => 'rid=' . $roleId,
  1712. 'asArray' => true
  1713. ) );
  1714. $receiptLog->rolename = $roleInfo ['name'];
  1715. }
  1716. $receiptLog->username = $this->staff [0] ['username'];
  1717. $receiptLog->uid = $this->staff [0] ['sid'];
  1718. $receiptLog->date = date ( "Y-m-d" );
  1719. $receiptLog->opinion = '提交审批';
  1720. $receiptLog->img = $this->staff [0] ['avatar'];
  1721. $receiptLog->status = 2;
  1722. $receiptLog->rid = $rid;
  1723. $receiptLog->insert ();
  1724. return "/expenses";
  1725. }
  1726. function expenses() {
  1727. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  1728. if (empty ( $item ))
  1729. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  1730. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1731. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  1732. Doo::loadModel ( 'receipt' );
  1733. $receipt = new receipt ();
  1734. Doo::loadModel ( 'L_category' );
  1735. $Lcategory = new L_category ();
  1736. Doo::loadModel ( 'verify' );
  1737. Doo::loadModel ( 'statistics' );
  1738. $statistics = new statistics ();
  1739. $verify = new verify ();
  1740. Doo::loadModel ( 'staff' );
  1741. $staff = new staff ();
  1742. $condition = "";
  1743. if ($item == "expenses")
  1744. $condition = " and Rtype=1 ";
  1745. elseif ($item == "receipts")
  1746. $condition = " and Rtype=0 ";
  1747. elseif ($item == "remits")
  1748. $condition = " and Rtype=2 ";
  1749. $dateCondition = " and Year(date) =" . $year;
  1750. if (! empty ( $moth )) {
  1751. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  1752. $stList = $statistics->getOne ( array (
  1753. 'select' => 'rePrice ,agPrice',
  1754. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  1755. 'asArray' => true
  1756. ) );
  1757. } else
  1758. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  1759. if (empty ( $stList ))
  1760. $stList = array (
  1761. 'rePrice' => 0,
  1762. 'agPrice' => 0
  1763. );
  1764. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  1765. if (! isset ( $noPassSum ['sum'] ))
  1766. $noPassSum ['sum'] = 0;
  1767. $data ['stList'] = array (
  1768. 'rePrice' => $stList ['rePrice'],
  1769. 'agPrice' => $stList ['agPrice'],
  1770. 'skPrice' => ($noPassSum ['sum'])
  1771. );
  1772. $receiptList = $receipt->find ( array (
  1773. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  1774. 'desc' => 'rid',
  1775. 'asArray' => true
  1776. ) );
  1777. $Locate = 0;
  1778. $roleId = 0;
  1779. $button = 0;
  1780. foreach ( $receiptList as $key => $value ) {
  1781. $receiptList [$key] ['Locate'] = $Locate;
  1782. $Locate ++;
  1783. $receiptList [$key] ['reviseDetail'] = array ();
  1784. if (! empty ( $value ['reviseDetail'] ))
  1785. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1786. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1787. $categoryDetil = $Lcategory->getOne ( array (
  1788. 'where' => 'cid=' . $value ['cid'],
  1789. 'asArray' => true
  1790. ) );
  1791. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1792. // 检测编辑状态
  1793. $verifyList = $verify->getOne ( array (
  1794. 'where' => 'vid=' . $value ['verify'],
  1795. 'asArray' => true
  1796. ) );
  1797. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1798. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1799. Doo::loadModel ( 'role' );
  1800. $role = new role ();
  1801. $flag = true;
  1802. $roleKey = 0;
  1803. $endStaffArray = array ();
  1804. $roleArrayCopy = array ();
  1805. foreach ( $verifyList as $k => $v ) {
  1806. // init verifyStaff
  1807. if ($v [1] == 'ROLE') {
  1808. if (! empty ( $verifyStaff )) {
  1809. $endStaffArray = end ( $verifyStaff );
  1810. // if ($v[0]==$endStaffArray['nextStaff']){
  1811. // $roleId=$v[0];
  1812. // }
  1813. }
  1814. $roleVerify = json_decode ( $v [3], true );
  1815. $roleKey = $k;
  1816. $roleArray = array ();
  1817. $rolename = $role->getOne ( array (
  1818. 'where' => 'rid=' . $v [0],
  1819. 'asArray' => true
  1820. ) );
  1821. foreach ( $roleVerify as $o => $p ) {
  1822. $staffID = explode ( '_', $p );
  1823. $staffInfo = $staff->getOne ( array (
  1824. 'where' => 'sid=' . $staffID [0],
  1825. 'asArray' => true
  1826. ) );
  1827. // print_r($staffID);
  1828. $exp = array (
  1829. 0 => $staffInfo ['sid'],
  1830. 1 => $staffID [1],
  1831. 2 => $staffInfo ['avatar'],
  1832. 'date' => '',
  1833. 'date' => '',
  1834. 'opinion' => '',
  1835. 'status' => '',
  1836. 'rolename' => $rolename ['name']
  1837. );
  1838. array_push ( $roleArray, $exp );
  1839. }
  1840. $roleArrayCopy [$v [0]] = $roleArray;
  1841. // $verifyList[$k]['roleArray']=$roleArray;
  1842. }
  1843. $verifyList [$k] ['date'] = "";
  1844. $verifyList [$k] ['opinion'] = "";
  1845. $verifyList [$k] ['status'] = "";
  1846. if (empty ( $verifyStaff )) {
  1847. $verifyList [$k] ['date'] = "";
  1848. $verifyList [$k] ['opinion'] = "";
  1849. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1850. $verifyList [$k] ['status'] = 4;
  1851. $flag = false;
  1852. }
  1853. } else {
  1854. foreach ( $verifyStaff as $m => $u ) {
  1855. if ($v [0] == $m) {
  1856. $verifyList [$k] ['date'] = $u ['date'];
  1857. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1858. $verifyList [$k] ['status'] = $u ['status'];
  1859. $flag = false;
  1860. break;
  1861. }
  1862. }
  1863. $endStaffArray = end ( $verifyStaff );
  1864. if (isset ( $endStaffArray ['ROLE'] )) {
  1865. } else {
  1866. // $endKey=key($verifyStaff);
  1867. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1868. // $button=4;
  1869. // $verifyList[$k]['status']=4;
  1870. // }
  1871. }
  1872. }
  1873. }
  1874. $rolename ['name'] = '';
  1875. if (! empty ( $roleId )) {
  1876. Doo::loadModel ( 'role' );
  1877. $role = new role ();
  1878. $rolename = $role->getOne ( array (
  1879. 'where' => 'rid=' . $roleId,
  1880. 'asArray' => true
  1881. ) );
  1882. }
  1883. if (! empty ( $verifyStaff ))
  1884. $endStaffArray = end ( $verifyStaff );
  1885. $KOP = false;
  1886. foreach ( $roleArrayCopy as $P => $A ) {
  1887. foreach ( $A as $MKI => $AVL ) {
  1888. if (! empty ( $verifyStaff )) {
  1889. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1890. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1891. $button = 4;
  1892. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1893. }
  1894. foreach ( $verifyStaff as $m => $u ) {
  1895. $AVLFK = $AVL [0] . '_R';
  1896. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1897. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1898. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1899. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1900. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1901. break;
  1902. }
  1903. }
  1904. } else {
  1905. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1906. $button = 4;
  1907. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1908. }
  1909. }
  1910. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1911. $KOP = true;
  1912. }
  1913. }
  1914. foreach ( $roleArrayCopy as $k => $v ) {
  1915. foreach ( $verifyList as $m => $n ) {
  1916. if ($n [0] == $k) {
  1917. array_splice ( $verifyList, $m, 1, $v );
  1918. }
  1919. }
  1920. }
  1921. $receiptList [$key] ['verifyList'] = $verifyList;
  1922. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1923. 'where' => 'sid=' . $value ['staff'],
  1924. 'asArray' => true
  1925. ) );
  1926. $receiptList [$key] ['button'] = $button;
  1927. }
  1928. // print_r($receiptList);die;
  1929. $mothHtml = "";
  1930. for($i = 1; $i <= 12; $i ++) {
  1931. if ($moth == $i)
  1932. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  1933. else
  1934. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  1935. }
  1936. $data ['mothHtml'] = $mothHtml;
  1937. $data ['receiptList'] = $receiptList;
  1938. $data ['memu'] = "receipt";
  1939. $data ['staff'] = $this->staff;
  1940. $data ['receiptMemu'] = 'expenses';
  1941. $data ['verifyId'] = $this->verifyId;
  1942. $data ['executeId'] = $this->executeId;
  1943. $data ['item'] = $item;
  1944. $data ['year'] = $year;
  1945. $this->render ( "/admin/expenses", $data );
  1946. }
  1947. function expensesCollect() {
  1948. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1949. Doo::loadModel ( 'receipt' );
  1950. $receipt = new receipt ();
  1951. Doo::loadModel ( 'L_category' );
  1952. $Lcategory = new L_category ();
  1953. Doo::loadModel ( 'verify' );
  1954. Doo::loadModel ( 'statistics' );
  1955. $statistics = new statistics ();
  1956. $verify = new verify ();
  1957. Doo::loadModel ( 'staff' );
  1958. $staff = new staff ();
  1959. Doo::loadModel ( 'loanReceipt' );
  1960. $loanReceipt = new loanReceipt ();
  1961. $receiptList = $receipt->find ( array (
  1962. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  1963. 'desc' => 'rid',
  1964. 'asArray' => true
  1965. ) );
  1966. $loanList = $loanReceipt->find ( array (
  1967. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  1968. 'desc' => 'rid',
  1969. 'asArray' => true
  1970. ) );
  1971. /*
  1972. * $Locate=0;$roleId=0;$button=0; foreach ($loanList as $key=>$value){ $loanList[$key]['Locate']=$Locate;$Locate++; $loanList[$key]['reviseDetail']=array(); if (!empty($value['reviseDetail'])) $loanList[$key]['reviseDetail']=json_decode($value['reviseDetail'],true); $loanList[$key]['accountItem']=json_decode($value['accountItem'],true); $loanList[$key]['loanItem']=json_decode($value['loanItem'],true); $categoryDetil=$Lcategory->getOne(array('where'=>'cid='.$value['cid'],'asArray'=>true)); $loanList[$key]['category']=$categoryDetil['title']; //检测编辑状态 if ($value['status']==3||$value['status']==1||$value['status']==8||$value['status']==9) $verifyList['staff']=$value['verifyBreakup']; else $verifyList=$verify->getOne(array('where'=>'vid='.$value['verify'],'asArray'=>true)); $verifyList=json_decode($verifyList['staff'],true);//status opinion $verifyStaff=json_decode($value['verifyStaff'],true); Doo::loadModel('role'); $role=new role(); $flag=true;$roleKey=0;$endStaffArray=array();$roleArrayCopy=array(); foreach ($verifyList as $k=>$v){ //init verifyStaff if ($v[1]=='ROLE'){ if (!empty($verifyStaff)){ $endStaffArray=end($verifyStaff); // if ($v[0]==$endStaffArray['nextStaff']){ // $roleId=$v[0]; // } } $roleVerify=json_decode($v[3],true); $roleKey=$k;$roleArray=array(); $rolename=$role->getOne(array('where'=>'rid='.$v[0],'asArray'=>true)); foreach ($roleVerify as $o=>$p){ $staffID=explode ('_',$p); $staffInfo=$staff->getOne(array('where'=>'sid='.$staffID[0],'asArray'=>true)); //print_r($staffID); $exp=array(0=>$staffInfo['sid'],1=>$staffID[1],2=>$staffInfo['avatar'],'date'=>'','date'=>'','opinion'=>'','status'=>'','rolename'=>$rolename['name']); array_push($roleArray, $exp); } $roleArrayCopy[$v[0]]=$roleArray; //$verifyList[$k]['roleArray']=$roleArray; } $verifyList[$k]['date']=""; $verifyList[$k]['opinion']=""; $verifyList[$k]['status']=""; if (empty($verifyStaff)){ $verifyList[$k]['date']=""; $verifyList[$k]['opinion']=""; if (($verifyList[0][0]==$this->staff[0]['sid'])&&$flag){ $verifyList[$k]['status']=4; $flag=false; } }else{ foreach ($verifyStaff as $m=>$u){ if ($v[0]==$m){ $verifyList[$k]['date']=$u['date']; $verifyList[$k]['opinion']=$u['opinion']; $verifyList[$k]['status']=$u['status']; $flag=false; break; } } $endStaffArray=end($verifyStaff); if (isset($endStaffArray['ROLE'])){ }else{ // $endKey=key($verifyStaff); // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){ // $button=4; // $verifyList[$k]['status']=4; // } } } } $rolename['name']=''; if (!empty($roleId)){ Doo::loadModel('role'); $role=new role(); $rolename=$role->getOne(array('where'=>'rid='.$roleId,'asArray'=>true)); } if (!empty($verifyStaff)) $endStaffArray=end($verifyStaff); $KOP=false; foreach ($roleArrayCopy as $P=>$A){ foreach ( $A as $MKI=>$AVL){ if (!empty($verifyStaff)){ //&&$rolename['rid']==$endStaffArray['nextStaff'] if ($this->staff[0]['sid']==$AVL[0]&&isset($endStaffArray['ROLE'])&&$rolename['rid']==$endStaffArray['nextStaff']){ $button=4; $roleArrayCopy[$P][$MKI]['status']=4; } foreach ($verifyStaff as $m=>$u){ $AVLFK=$AVL[0].'_R'; //echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>'; if (strcmp($AVLFK,$m)==0){//&&isset($u['ROLE'])&&$u['ROLE']==1 $roleArrayCopy[$P][$MKI]['date']=$u['date']; $roleArrayCopy[$P][$MKI]['opinion']=$u['opinion']; $roleArrayCopy[$P][$MKI]['status']=$u['status']; break; } } }else{ if ($this->staff[0]['sid']==$AVL[0]&&$verifyList[0][1]=='ROLE'){ $button=4; $roleArrayCopy[$P][$MKI]['status']=4; } } //$roleArray[$MKI]['rolename']=$rolename['name']; $KOP=true; } } foreach ($roleArrayCopy as $k=>$v){ foreach ($verifyList as $m=>$n){ if ($n[0]==$k){ array_splice($verifyList,$m,1,$v); } } } $loanList[$key]['verifyList']=$verifyList; $loanList[$key]['staffDetail']=$staff->getOne(array('where'=>'sid='.$value['staff'],'asArray'=>true)); $loanList[$key]['button']=$button; //$loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']); } $data['loanList']=$loanList;
  1973. */
  1974. $Locate = 0;
  1975. $roleId = 0;
  1976. $button = 0;
  1977. foreach ( $receiptList as $key => $value ) {
  1978. $receiptList [$key] ['Locate'] = $Locate;
  1979. $Locate ++;
  1980. $receiptList [$key] ['reviseDetail'] = array ();
  1981. if (! empty ( $value ['reviseDetail'] ))
  1982. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1983. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1984. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1985. $categoryDetil = $Lcategory->getOne ( array (
  1986. 'where' => 'cid=' . $value ['cid'],
  1987. 'asArray' => true
  1988. ) );
  1989. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1990. // 检测编辑状态
  1991. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  1992. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  1993. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  1994. else
  1995. $verifyList ['staff'] = $value ['verifyBreakup'];
  1996. } else
  1997. $verifyList = $verify->getOne ( array (
  1998. 'where' => 'vid=' . $value ['verify'],
  1999. 'asArray' => true
  2000. ) );
  2001. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2002. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2003. Doo::loadModel ( 'role' );
  2004. $role = new role ();
  2005. $flag = true;
  2006. $roleKey = 0;
  2007. $endStaffArray = array ();
  2008. $roleArrayCopy = array ();
  2009. foreach ( $verifyList as $k => $v ) {
  2010. // init verifyStaff
  2011. if ($v [1] == 'ROLE') {
  2012. if (! empty ( $verifyStaff )) {
  2013. $endStaffArray = end ( $verifyStaff );
  2014. // if ($v[0]==$endStaffArray['nextStaff']){
  2015. // $roleId=$v[0];
  2016. // }
  2017. }
  2018. $roleVerify = json_decode ( $v [3], true );
  2019. $roleKey = $k;
  2020. $roleArray = array ();
  2021. $rolename = $role->getOne ( array (
  2022. 'where' => 'rid=' . $v [0],
  2023. 'asArray' => true
  2024. ) );
  2025. foreach ( $roleVerify as $o => $p ) {
  2026. $staffID = explode ( '_', $p );
  2027. $staffInfo = $staff->getOne ( array (
  2028. 'where' => 'sid=' . $staffID [0],
  2029. 'asArray' => true
  2030. ) );
  2031. // print_r($staffID);
  2032. $exp = array (
  2033. 0 => $staffInfo ['sid'],
  2034. 1 => $staffID [1],
  2035. 2 => $staffInfo ['avatar'],
  2036. 'date' => '',
  2037. 'date' => '',
  2038. 'opinion' => '',
  2039. 'status' => '',
  2040. 'rolename' => $rolename ['name']
  2041. );
  2042. array_push ( $roleArray, $exp );
  2043. }
  2044. $roleArrayCopy [$v [0]] = $roleArray;
  2045. // $verifyList[$k]['roleArray']=$roleArray;
  2046. }
  2047. $verifyList [$k] ['date'] = "";
  2048. $verifyList [$k] ['opinion'] = "";
  2049. $verifyList [$k] ['status'] = "";
  2050. if (empty ( $verifyStaff )) {
  2051. $verifyList [$k] ['date'] = "";
  2052. $verifyList [$k] ['opinion'] = "";
  2053. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2054. $verifyList [$k] ['status'] = 4;
  2055. $flag = false;
  2056. }
  2057. } else {
  2058. foreach ( $verifyStaff as $m => $u ) {
  2059. if ($v [0] == $m) {
  2060. $verifyList [$k] ['date'] = $u ['date'];
  2061. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2062. $verifyList [$k] ['status'] = $u ['status'];
  2063. $flag = false;
  2064. break;
  2065. }
  2066. }
  2067. $endStaffArray = end ( $verifyStaff );
  2068. if (isset ( $endStaffArray ['ROLE'] )) {
  2069. } else {
  2070. // $endKey=key($verifyStaff);
  2071. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2072. // $button=4;
  2073. // $verifyList[$k]['status']=4;
  2074. // }
  2075. }
  2076. }
  2077. }
  2078. $rolename ['name'] = '';
  2079. if (! empty ( $roleId )) {
  2080. Doo::loadModel ( 'role' );
  2081. $role = new role ();
  2082. $rolename = $role->getOne ( array (
  2083. 'where' => 'rid=' . $roleId,
  2084. 'asArray' => true
  2085. ) );
  2086. }
  2087. if (! empty ( $verifyStaff ))
  2088. $endStaffArray = end ( $verifyStaff );
  2089. $KOP = false;
  2090. foreach ( $roleArrayCopy as $P => $A ) {
  2091. foreach ( $A as $MKI => $AVL ) {
  2092. if (! empty ( $verifyStaff )) {
  2093. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2094. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2095. $button = 4;
  2096. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2097. }
  2098. foreach ( $verifyStaff as $m => $u ) {
  2099. $AVLFK = $AVL [0] . '_R';
  2100. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2101. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2102. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2103. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2104. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2105. break;
  2106. }
  2107. }
  2108. } else {
  2109. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2110. $button = 4;
  2111. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2112. }
  2113. }
  2114. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2115. $KOP = true;
  2116. }
  2117. }
  2118. foreach ( $roleArrayCopy as $k => $v ) {
  2119. foreach ( $verifyList as $m => $n ) {
  2120. if ($n [0] == $k) {
  2121. array_splice ( $verifyList, $m, 1, $v );
  2122. }
  2123. }
  2124. }
  2125. // 费用执行人相关数据
  2126. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2127. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2128. foreach ( $executeCopy as $k => $v ) {
  2129. $executeCopy [$k] ['date'] = '';
  2130. $executeCopy [$k] ['opinion'] = '';
  2131. $executeCopy [$k] ['status'] = '';
  2132. if (! empty ( $executeStaff ))
  2133. foreach ( $executeStaff as $m => $u ) {
  2134. if ($v [0] == $m) {
  2135. $executeCopy [$k] ['date'] = $u ['date'];
  2136. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2137. $executeCopy [$k] ['status'] = $u ['status'];
  2138. break;
  2139. }
  2140. }
  2141. }
  2142. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2143. $receiptList [$key] ['verifyList'] = $verifyList;
  2144. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2145. 'where' => 'sid=' . $value ['staff'],
  2146. 'asArray' => true
  2147. ) );
  2148. $receiptList [$key] ['button'] = $button;
  2149. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2150. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2151. $relust = $value ['sum'] - $value ['loanSum'];
  2152. $receiptList [$key] ['relust'] = $relust;
  2153. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2154. }
  2155. Doo::loadModel ( 'enclosur' );
  2156. $enclosur = new enclosur ();
  2157. $enclosurList = $enclosur->find ( array (
  2158. 'where' => 'rid=' . $rid,
  2159. 'asArray' => true
  2160. ) );
  2161. $enclosurHtml = '';
  2162. foreach ( $enclosurList as $value ) {
  2163. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2164. }
  2165. $data ['enclosurHtml'] = $enclosurHtml;
  2166. // print_r($receiptList);
  2167. $data ['receiptList'] = $receiptList;
  2168. $data ['memu'] = "receipt";
  2169. $data ['staff'] = $this->staff;
  2170. $data ['receiptMemu'] = 'expenses';
  2171. $data ['verifyId'] = $this->verifyId;
  2172. $data ['executeId'] = $this->executeId;
  2173. $this->render ( "/admin/expensesCollect", $data );
  2174. }
  2175. function approvalExpenses() {
  2176. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  2177. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2178. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2179. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2180. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2181. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  2182. //echo $rdate;
  2183. if (empty ( $status ))
  2184. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  2185. $page_size = 12;
  2186. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2187. $vidList = array ();
  2188. $button = 0;
  2189. Doo::loadModel ( 'verify' );
  2190. $verify = new verify ();
  2191. Doo::loadModel ( 'receipt' );
  2192. $receipt = new receipt ();
  2193. Doo::loadModel ( 'staff' );
  2194. $staff = new staff ();
  2195. Doo::loadModel ( 'L_category' );
  2196. $Lcategory = new L_category ();
  2197. // user verify ID
  2198. $verifyDetail = $verify->find ( array (
  2199. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  2200. 'asArray' => true
  2201. ) );
  2202. foreach ( $verifyDetail as $key => $value ) {
  2203. array_push ( $vidList, $value ['vid'] );
  2204. }
  2205. $vid = implode ( ",", $vidList );
  2206. if (empty ( $verifyDetail ))
  2207. $vid = 0;
  2208. // if ($status==0)
  2209. // $dateCondition="";
  2210. // else
  2211. $dateCondition = " and Year(date) =" . $year;
  2212. /*
  2213. if (! empty ( $month ))
  2214. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  2215. if($status == 'done'){
  2216. $dateCondition = " and Year(pastDate) =" . $year;
  2217. if (! empty ( $month ))
  2218. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  2219. }
  2220. */
  2221. //date ( 'Y-m' )
  2222. if(!empty($rdate)&&$status == 'done')
  2223. $dateCondition=" and date_format(pastDate,'%Y-%m')='".$rdate."' ";
  2224. elseif (!empty($rdate))
  2225. $dateCondition=" and date_format(date,'%Y-%m')='".$rdate."' ";
  2226. $categoryList = $Lcategory->find ( array (
  2227. 'asArray' => true
  2228. ) );
  2229. $staffList = $staff->find ( array (
  2230. 'where' => 'cid=' . $cid,
  2231. 'asArray' => true
  2232. ) );
  2233. $cateCondition = "";
  2234. $staffCondition = "";
  2235. $approvalCondition = "";
  2236. if (! empty ( $cid )){
  2237. $cateCondition = ' and cid=' . $cid;
  2238. }
  2239. if (! empty ( $sid )) {
  2240. $staffCondition = ' and cid=' . $cid.' and staff=' . $sid;
  2241. $cateCondition = "";
  2242. }
  2243. $get="?year=".$year."&month=".$month."&cid=".$cid."&sid=".$sid;
  2244. if ($status == 'pendApproval') {
  2245. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  2246. }
  2247. if ($status == 'ongoing') {
  2248. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  2249. }
  2250. if ($status == 'done') {
  2251. $approvalCondition = ' and (status=8 or status=9 ) ';
  2252. }
  2253. if ($status == 'termination') {
  2254. $approvalCondition = " and status=3";
  2255. }
  2256. // $approvalCondition = " and status=" . $status;
  2257. // if ($status == 2) {
  2258. // // 查找角色审批人
  2259. // }
  2260. // if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  2261. // $approvalCondition = ' and status=2 ';
  2262. // }
  2263. // if ($status == 1) {
  2264. // $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  2265. // }
  2266. // if ($status == 8) {
  2267. // $approvalCondition = ' and (status=' . $status . ' or status=9 ) ';
  2268. // }
  2269. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  2270. $pageinfo ['page'] = array (
  2271. 'previous' => ''
  2272. );
  2273. // if ($status == 0) {
  2274. // $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  2275. // $receiptList = $receipt->find ( array (
  2276. // 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ')',
  2277. // 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2278. // 'desc' => 'rid',
  2279. // 'asArray' => true
  2280. // ) );
  2281. // //echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2282. // } else
  2283. if ($status == 'done' || $status == 'termination') {
  2284. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/".$status, $get, "" );
  2285. $receiptList = $receipt->find ( array (
  2286. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
  2287. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2288. 'desc' => 'rid',
  2289. 'asArray' => true
  2290. ) );
  2291. } else
  2292. $receiptList = $receipt->find ( array (
  2293. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
  2294. 'desc' => 'rid',
  2295. 'asArray' => true
  2296. ) );
  2297. $rLRes = $receipt->find ( array (
  2298. '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,
  2299. 'desc' => 'rid',
  2300. 'asArray' => true
  2301. ) );
  2302. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2303. // print_r($pageinfo);
  2304. $Locate = 0;
  2305. $reportList=array();
  2306. foreach ( $receiptList as $key => $value ) {
  2307. $receiptList [$key] ['Locate'] = $Locate;
  2308. $Locate ++;
  2309. $receiptList [$key] ['reviseDetail'] = array ();
  2310. if (! empty ( $value ['reviseDetail'] ))
  2311. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2312. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2313. $categoryDetil = $Lcategory->getOne ( array (
  2314. 'where' => 'cid=' . $value ['cid'],
  2315. 'asArray' => true
  2316. ) );
  2317. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2318. $verifyList = $verify->getOne ( array (
  2319. 'where' => 'vid=' . $value ['verify'],
  2320. 'asArray' => true
  2321. ) );
  2322. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2323. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2324. foreach ( $verifyList as $k => $v ) {
  2325. // init verifyStaff
  2326. $verifyList [$k] ['date'] = "";
  2327. $verifyList [$k] ['opinion'] = "";
  2328. $verifyList [$k] ['status'] = "";
  2329. if (empty ( $verifyStaff )) {
  2330. $verifyList [$k] ['date'] = "";
  2331. $verifyList [$k] ['opinion'] = "";
  2332. if ($v [0] == $this->staff [0] ['sid']) {
  2333. $verifyList [$k] ['status'] = 4;
  2334. $button = 4;
  2335. }
  2336. } else {
  2337. $flag = true;
  2338. foreach ( $verifyStaff as $m => $u ) {
  2339. if ($v [0] == $m) {
  2340. $verifyList [$k] ['date'] = $u ['date'];
  2341. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2342. $verifyList [$k] ['status'] = $u ['status'];
  2343. $flag = false;
  2344. break;
  2345. }
  2346. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  2347. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  2348. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  2349. }
  2350. if ($flag) { // 检测可编辑
  2351. if ($v [0] == $this->staff [0] ['sid']) {
  2352. $verifyList [$k] ['status'] = 4;
  2353. $button = 4;
  2354. }
  2355. }
  2356. }
  2357. }
  2358. $receiptList [$key] ['verifyList'] = $verifyList;
  2359. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2360. 'where' => 'sid=' . $value ['staff'],
  2361. 'asArray' => true
  2362. ) );
  2363. array_push($reportList, $receiptList [$key] ['staffDetail']['sid'].'-'.$receiptList [$key] ['staffDetail']['username']);
  2364. $receiptList [$key] ['button'] = $button;
  2365. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  2366. }
  2367. $reportList=array_unique($reportList);
  2368. $reportHtml='';
  2369. foreach ($reportList as $key=>$value){
  2370. $v=explode("-", $value);
  2371. $reportHtml.='<option value="'.$v[1].'">'.$v[1].'</option>';
  2372. }
  2373. //print_r($reportList);
  2374. $data['reportHtml']=$reportHtml;
  2375. //$reportHtml.='<option value="ALL">'.$value[''].'</option>';
  2376. // print_r($receiptList);die;
  2377. // $data['verifyDetail']=$verifyDetail;
  2378. $mothHtml = "";
  2379. for($i = 1; $i <= 12; $i ++) {
  2380. if ($month == $i)
  2381. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2382. else
  2383. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2384. }
  2385. $data ['mothHtml'] = $mothHtml;
  2386. $data ['page'] = $pageinfo;
  2387. $data ['receiptList'] = $receiptList;
  2388. $data ['receiptApprovalCount'] = count ( $rLRes );
  2389. $data ['status'] = $status;
  2390. $data ['year'] = $year;
  2391. $data ['categoryList'] = $categoryList;
  2392. $data ['staffList'] = $staffList;
  2393. $data ['cid'] = $cid;
  2394. $data ['sid'] = $sid;
  2395. // print_r($receiptList);
  2396. $data ['memu'] = "receipt";
  2397. $data ['staff'] = $this->staff;
  2398. $data ['receiptMemu'] = 'approvalExpenses';
  2399. $data ['verifyId'] = $this->verifyId;
  2400. $data ['executeId'] = $this->executeId;
  2401. $this->render ( "/admin/approvalExpenses", $data );
  2402. }
  2403. function expensesDoc() {
  2404. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2405. Doo::loadModel ( 'receipt' );
  2406. $receipt = new receipt ();
  2407. Doo::loadModel ( 'L_category' );
  2408. $Lcategory = new L_category ();
  2409. Doo::loadModel ( 'verify' );
  2410. Doo::loadModel ( 'statistics' );
  2411. $statistics = new statistics ();
  2412. $verify = new verify ();
  2413. Doo::loadModel ( 'staff' );
  2414. $staff = new staff ();
  2415. Doo::loadModel ( 'loanReceipt' );
  2416. $loanReceipt = new loanReceipt ();
  2417. $receiptList = $receipt->find ( array (
  2418. 'where' => ' rid=' . $rid,
  2419. 'desc' => 'rid',
  2420. 'asArray' => true
  2421. ) );
  2422. $loanList = array ();
  2423. if (! empty ( $receiptList ))
  2424. $loanList = $loanReceipt->find ( array (
  2425. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2426. 'desc' => 'rid',
  2427. 'asArray' => true
  2428. ) );
  2429. $Locate = 0;
  2430. $roleId = 0;
  2431. $button = 0;
  2432. foreach ( $loanList as $key => $value ) {
  2433. $loanList [$key] ['Locate'] = $Locate;
  2434. $Locate ++;
  2435. $loanList [$key] ['reviseDetail'] = array ();
  2436. if (! empty ( $value ['reviseDetail'] ))
  2437. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2438. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2439. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2440. $categoryDetil = $Lcategory->getOne ( array (
  2441. 'where' => 'cid=' . $value ['cid'],
  2442. 'asArray' => true
  2443. ) );
  2444. $loanList [$key] ['category'] = $categoryDetil ['title'];
  2445. // 检测编辑状态
  2446. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  2447. $verifyList ['staff'] = $value ['verifyBreakup'];
  2448. else
  2449. $verifyList = $verify->getOne ( array (
  2450. 'where' => 'vid=' . $value ['verify'],
  2451. 'asArray' => true
  2452. ) );
  2453. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2454. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2455. Doo::loadModel ( 'role' );
  2456. $role = new role ();
  2457. $flag = true;
  2458. $roleKey = 0;
  2459. $endStaffArray = array ();
  2460. $roleArrayCopy = array ();
  2461. foreach ( $verifyList as $k => $v ) {
  2462. // init verifyStaff
  2463. if ($v [1] == 'ROLE') {
  2464. if (! empty ( $verifyStaff )) {
  2465. $endStaffArray = end ( $verifyStaff );
  2466. // if ($v[0]==$endStaffArray['nextStaff']){
  2467. // $roleId=$v[0];
  2468. // }
  2469. }
  2470. $roleVerify = json_decode ( $v [3], true );
  2471. $roleKey = $k;
  2472. $roleArray = array ();
  2473. $rolename = $role->getOne ( array (
  2474. 'where' => 'rid=' . $v [0],
  2475. 'asArray' => true
  2476. ) );
  2477. foreach ( $roleVerify as $o => $p ) {
  2478. $staffID = explode ( '_', $p );
  2479. $staffInfo = $staff->getOne ( array (
  2480. 'where' => 'sid=' . $staffID [0],
  2481. 'asArray' => true
  2482. ) );
  2483. // print_r($staffID);
  2484. $exp = array (
  2485. 0 => $staffInfo ['sid'],
  2486. 1 => $staffID [1],
  2487. 2 => $staffInfo ['avatar'],
  2488. 'date' => '',
  2489. 'date' => '',
  2490. 'opinion' => '',
  2491. 'status' => '',
  2492. 'rolename' => $rolename ['name']
  2493. );
  2494. array_push ( $roleArray, $exp );
  2495. }
  2496. $roleArrayCopy [$v [0]] = $roleArray;
  2497. // $verifyList[$k]['roleArray']=$roleArray;
  2498. }
  2499. $verifyList [$k] ['date'] = "";
  2500. $verifyList [$k] ['opinion'] = "";
  2501. $verifyList [$k] ['status'] = "";
  2502. if (empty ( $verifyStaff )) {
  2503. $verifyList [$k] ['date'] = "";
  2504. $verifyList [$k] ['opinion'] = "";
  2505. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2506. $verifyList [$k] ['status'] = 4;
  2507. $flag = false;
  2508. }
  2509. } else {
  2510. foreach ( $verifyStaff as $m => $u ) {
  2511. if ($v [0] == $m) {
  2512. $verifyList [$k] ['date'] = $u ['date'];
  2513. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2514. $verifyList [$k] ['status'] = $u ['status'];
  2515. $flag = false;
  2516. break;
  2517. }
  2518. }
  2519. $endStaffArray = end ( $verifyStaff );
  2520. if (isset ( $endStaffArray ['ROLE'] )) {
  2521. } else {
  2522. // $endKey=key($verifyStaff);
  2523. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2524. // $button=4;
  2525. // $verifyList[$k]['status']=4;
  2526. // }
  2527. }
  2528. }
  2529. }
  2530. $rolename ['name'] = '';
  2531. if (! empty ( $roleId )) {
  2532. Doo::loadModel ( 'role' );
  2533. $role = new role ();
  2534. $rolename = $role->getOne ( array (
  2535. 'where' => 'rid=' . $roleId,
  2536. 'asArray' => true
  2537. ) );
  2538. }
  2539. if (! empty ( $verifyStaff ))
  2540. $endStaffArray = end ( $verifyStaff );
  2541. $KOP = false;
  2542. foreach ( $roleArrayCopy as $P => $A ) {
  2543. foreach ( $A as $MKI => $AVL ) {
  2544. if (! empty ( $verifyStaff )) {
  2545. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2546. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2547. $button = 4;
  2548. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2549. }
  2550. foreach ( $verifyStaff as $m => $u ) {
  2551. $AVLFK = $AVL [0] . '_R';
  2552. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2553. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2554. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2555. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2556. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2557. break;
  2558. }
  2559. }
  2560. } else {
  2561. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2562. $button = 4;
  2563. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2564. }
  2565. }
  2566. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2567. $KOP = true;
  2568. }
  2569. }
  2570. foreach ( $roleArrayCopy as $k => $v ) {
  2571. foreach ( $verifyList as $m => $n ) {
  2572. if ($n [0] == $k) {
  2573. array_splice ( $verifyList, $m, 1, $v );
  2574. }
  2575. }
  2576. }
  2577. $loanList [$key] ['verifyList'] = $verifyList;
  2578. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  2579. 'where' => 'sid=' . $value ['staff'],
  2580. 'asArray' => true
  2581. ) );
  2582. $loanList [$key] ['button'] = $button;
  2583. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  2584. }
  2585. $data ['loanList'] = $loanList;
  2586. // print_r($loanList);
  2587. $Locate = 0;
  2588. $roleId = 0;
  2589. $button = 0;
  2590. foreach ( $receiptList as $key => $value ) {
  2591. $receiptList [$key] ['Locate'] = $Locate;
  2592. $Locate ++;
  2593. $receiptList [$key] ['reviseDetail'] = array ();
  2594. if (! empty ( $value ['reviseDetail'] ))
  2595. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2596. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2597. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2598. $categoryDetil = $Lcategory->getOne ( array (
  2599. 'where' => 'cid=' . $value ['cid'],
  2600. 'asArray' => true
  2601. ) );
  2602. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2603. // 检测编辑状态
  2604. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  2605. $verifyList ['staff'] = $value ['verifyBreakup'];
  2606. } else
  2607. $verifyList = $verify->getOne ( array (
  2608. 'where' => 'vid=' . $value ['verify'],
  2609. 'asArray' => true
  2610. ) );
  2611. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2612. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2613. Doo::loadModel ( 'role' );
  2614. $role = new role ();
  2615. if ($verifyList == NULL)
  2616. $verifyList = array ();
  2617. $flag = true;
  2618. $roleKey = 0;
  2619. $endStaffArray = array ();
  2620. $roleArrayCopy = array ();
  2621. foreach ( $verifyList as $k => $v ) {
  2622. // init verifyStaff
  2623. if ($v [1] == 'ROLE') {
  2624. if (! empty ( $verifyStaff )) {
  2625. $endStaffArray = end ( $verifyStaff );
  2626. // if ($v[0]==$endStaffArray['nextStaff']){
  2627. // $roleId=$v[0];
  2628. // }
  2629. }
  2630. $roleVerify = json_decode ( $v [3], true );
  2631. $roleKey = $k;
  2632. $roleArray = array ();
  2633. $rolename = $role->getOne ( array (
  2634. 'where' => 'rid=' . $v [0],
  2635. 'asArray' => true
  2636. ) );
  2637. foreach ( $roleVerify as $o => $p ) {
  2638. $staffID = explode ( '_', $p );
  2639. $staffInfo = $staff->getOne ( array (
  2640. 'where' => 'sid=' . $staffID [0],
  2641. 'asArray' => true
  2642. ) );
  2643. // print_r($staffID);
  2644. $exp = array (
  2645. 0 => $staffInfo ['sid'],
  2646. 1 => $staffID [1],
  2647. 2 => $staffInfo ['avatar'],
  2648. 'date' => '',
  2649. 'date' => '',
  2650. 'opinion' => '',
  2651. 'status' => '',
  2652. 'rolename' => $rolename ['name']
  2653. );
  2654. array_push ( $roleArray, $exp );
  2655. }
  2656. $roleArrayCopy [$v [0]] = $roleArray;
  2657. // $verifyList[$k]['roleArray']=$roleArray;
  2658. }
  2659. $verifyList [$k] ['date'] = "";
  2660. $verifyList [$k] ['opinion'] = "";
  2661. $verifyList [$k] ['status'] = "";
  2662. if (empty ( $verifyStaff )) {
  2663. $verifyList [$k] ['date'] = "";
  2664. $verifyList [$k] ['opinion'] = "";
  2665. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2666. $verifyList [$k] ['status'] = 4;
  2667. $flag = false;
  2668. }
  2669. } else {
  2670. foreach ( $verifyStaff as $m => $u ) {
  2671. if ($v [0] == $m) {
  2672. $verifyList [$k] ['date'] = $u ['date'];
  2673. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2674. $verifyList [$k] ['status'] = $u ['status'];
  2675. $flag = false;
  2676. break;
  2677. }
  2678. }
  2679. $endStaffArray = end ( $verifyStaff );
  2680. if (isset ( $endStaffArray ['ROLE'] )) {
  2681. } else {
  2682. // $endKey=key($verifyStaff);
  2683. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2684. // $button=4;
  2685. // $verifyList[$k]['status']=4;
  2686. // }
  2687. }
  2688. }
  2689. }
  2690. $rolename ['name'] = '';
  2691. if (! empty ( $roleId )) {
  2692. Doo::loadModel ( 'role' );
  2693. $role = new role ();
  2694. $rolename = $role->getOne ( array (
  2695. 'where' => 'rid=' . $roleId,
  2696. 'asArray' => true
  2697. ) );
  2698. }
  2699. if (! empty ( $verifyStaff ))
  2700. $endStaffArray = end ( $verifyStaff );
  2701. $KOP = false;
  2702. foreach ( $roleArrayCopy as $P => $A ) {
  2703. foreach ( $A as $MKI => $AVL ) {
  2704. if (! empty ( $verifyStaff )) {
  2705. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2706. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2707. $button = 4;
  2708. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2709. }
  2710. foreach ( $verifyStaff as $m => $u ) {
  2711. $AVLFK = $AVL [0] . '_R';
  2712. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2713. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2714. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2715. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2716. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2717. break;
  2718. }
  2719. }
  2720. } else {
  2721. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2722. $button = 4;
  2723. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2724. }
  2725. }
  2726. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2727. $KOP = true;
  2728. }
  2729. }
  2730. foreach ( $roleArrayCopy as $k => $v ) {
  2731. foreach ( $verifyList as $m => $n ) {
  2732. if ($n [0] == $k) {
  2733. array_splice ( $verifyList, $m, 1, $v );
  2734. }
  2735. }
  2736. }
  2737. // 费用执行人相关数据
  2738. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2739. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2740. foreach ( $executeCopy as $k => $v ) {
  2741. $executeCopy [$k] ['date'] = '';
  2742. $executeCopy [$k] ['opinion'] = '';
  2743. $executeCopy [$k] ['status'] = '';
  2744. if (! empty ( $executeStaff ))
  2745. foreach ( $executeStaff as $m => $u ) {
  2746. if ($v [0] == $m) {
  2747. $executeCopy [$k] ['date'] = $u ['date'];
  2748. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2749. $executeCopy [$k] ['status'] = $u ['status'];
  2750. break;
  2751. }
  2752. }
  2753. }
  2754. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2755. $receiptList [$key] ['verifyList'] = $verifyList;
  2756. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2757. 'where' => 'sid=' . $value ['staff'],
  2758. 'asArray' => true
  2759. ) );
  2760. $receiptList [$key] ['button'] = $button;
  2761. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2762. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2763. $relust = $value ['sum'] - $value ['loanSum'];
  2764. $receiptList [$key] ['relust'] = $relust;
  2765. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2766. }
  2767. // print_r($receiptList);
  2768. // 获取审批日志
  2769. Doo::loadModel ( 'receiptLog' );
  2770. $receiptLog = new receiptLog ();
  2771. $rlList = array ();
  2772. $rlInfo = $receiptLog->getOne ( array (
  2773. 'where' => 'rid=' . $rid . ' and status=4',
  2774. 'asArray' => true
  2775. ) );
  2776. $tijdate = $receiptLog->getOne ( array (
  2777. 'where' => 'rid=' . $rid . ' and status=2',
  2778. 'asc' => 'rlid',
  2779. 'asArray' => true
  2780. ) );
  2781. if (! empty ( $rlInfo )) {
  2782. $rlList = $receiptLog->find ( array (
  2783. 'where' => 'rid=' . $rid,
  2784. 'asc' => 'rlid',
  2785. 'asArray' => true
  2786. ) );
  2787. }
  2788. Doo::loadModel ( 'enclosur' );
  2789. $enclosur = new enclosur ();
  2790. $enclosurList = $enclosur->find ( array (
  2791. 'where' => 'rid=' . $rid,
  2792. 'asArray' => true
  2793. ) );
  2794. $enclosurHtml = '';
  2795. foreach ( $enclosurList as $value ) {
  2796. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2797. }
  2798. $data ['enclosurHtml'] = $enclosurHtml;
  2799. $receiptList [0] ['rlList'] = $rlList;
  2800. $data ['receiptList'] = $receiptList;
  2801. $data ['memu'] = "receipt";
  2802. $data ['staff'] = $this->staff;
  2803. $data ['receiptMemu'] = 'approvalExpenses';
  2804. $data ['verifyId'] = $this->verifyId;
  2805. $data ['executeId'] = $this->executeId;
  2806. $this->render ( "/admin/expensesDoc", $data );
  2807. }
  2808. function expensesEdi() {
  2809. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2810. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  2811. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2812. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2813. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2814. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2815. if (empty ( $status ))
  2816. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  2817. $vidList = array ();
  2818. $button = 0;
  2819. Doo::loadModel ( 'verify' );
  2820. Doo::loadModel ( 'receipt' );
  2821. Doo::loadModel ( 'staff' );
  2822. $staff = new staff ();
  2823. $receipt = new receipt ();
  2824. $verify = new verify ();
  2825. Doo::loadModel ( 'L_category' );
  2826. $Lcategory = new L_category ();
  2827. Doo::loadModel ( 'enclosur' );
  2828. $enclosur = new enclosur ();
  2829. // user verify ID
  2830. $verifyDetail = $verify->find ( array (
  2831. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  2832. 'asArray' => true
  2833. ) );
  2834. foreach ( $verifyDetail as $key => $value ) {
  2835. array_push ( $vidList, $value ['vid'] );
  2836. }
  2837. $vid = implode ( ",", $vidList );
  2838. if (empty ( $verifyDetail ))
  2839. $vid = 0;
  2840. $categoryList = $Lcategory->find ( array (
  2841. 'asArray' => true
  2842. ) );
  2843. $staffList = $staff->find ( array (
  2844. 'where' => 'cid=' . $cid,
  2845. 'asArray' => true
  2846. ) );
  2847. $ap = "";
  2848. if ($status == 4) {
  2849. $ap = 4;
  2850. $status = 2;
  2851. }
  2852. // get Receipt By verifyID status 2
  2853. $receiptList = $receipt->find ( array (
  2854. 'where' => 'rid =' . $rid,
  2855. 'desc' => 'rid',
  2856. 'asArray' => true
  2857. ) );
  2858. $Locate = 0;
  2859. $roleId = 0;
  2860. if ($ap == 4)
  2861. $status = 4;
  2862. foreach ( $receiptList as $key => $value ) {
  2863. $receiptList [$key] ['Locate'] = $Locate;
  2864. $Locate ++;
  2865. $receiptList [$key] ['reviseDetail'] = array ();
  2866. if (! empty ( $value ['reviseDetail'] ))
  2867. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2868. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2869. $categoryDetil = $Lcategory->getOne ( array (
  2870. 'where' => 'cid=' . $value ['cid'],
  2871. 'asArray' => true
  2872. ) );
  2873. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2874. // 检测编辑状态
  2875. $verifyList = $verify->getOne ( array (
  2876. 'where' => 'vid=' . $value ['verify'],
  2877. 'asArray' => true
  2878. ) );
  2879. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2880. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2881. Doo::loadModel ( 'role' );
  2882. $role = new role ();
  2883. // print_r($verifyList);
  2884. $flag = true;
  2885. $roleKey = 0;
  2886. $endStaffArray = array ();
  2887. $roleArrayCopy = array ();
  2888. foreach ( $verifyList as $k => $v ) {
  2889. // init verifyStaff
  2890. if ($v [1] == 'ROLE') {
  2891. if (! empty ( $verifyStaff )) {
  2892. $endStaffArray = end ( $verifyStaff );
  2893. if ($v [0] == $endStaffArray ['nextStaff']) {
  2894. $roleId = $v [0];
  2895. }
  2896. }
  2897. $roleVerify = json_decode ( $v [3], true );
  2898. $roleKey = $k;
  2899. $roleArray = array ();
  2900. $rolename = $role->getOne ( array (
  2901. 'where' => 'rid=' . $v [0],
  2902. 'asArray' => true
  2903. ) );
  2904. foreach ( $roleVerify as $o => $p ) {
  2905. $staffID = explode ( '_', $p );
  2906. $staffInfo = $staff->getOne ( array (
  2907. 'where' => 'sid=' . $staffID [0],
  2908. 'asArray' => true
  2909. ) );
  2910. // print_r($staffID);
  2911. $exp = array (
  2912. 0 => $staffInfo ['sid'],
  2913. 1 => $staffID [1],
  2914. 2 => $staffInfo ['avatar'],
  2915. 'date' => '',
  2916. 'date' => '',
  2917. 'opinion' => '',
  2918. 'status' => '',
  2919. 'rolename' => $rolename ['name']
  2920. );
  2921. array_push ( $roleArray, $exp );
  2922. }
  2923. $roleArrayCopy [$v [0]] = $roleArray;
  2924. // $verifyList[$k]['roleArray']=$roleArray;
  2925. }
  2926. // print_r($roleArray);
  2927. $verifyList [$k] ['date'] = "";
  2928. $verifyList [$k] ['opinion'] = "";
  2929. $verifyList [$k] ['status'] = "";
  2930. if (empty ( $verifyStaff )) {
  2931. $verifyList [$k] ['date'] = "";
  2932. $verifyList [$k] ['opinion'] = "";
  2933. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2934. $verifyList [$k] ['status'] = 4;
  2935. $button = 4;
  2936. $flag = false;
  2937. }
  2938. } else {
  2939. foreach ( $verifyStaff as $m => $u ) {
  2940. if ($v [0] == $m) {
  2941. $verifyList [$k] ['date'] = $u ['date'];
  2942. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2943. $verifyList [$k] ['status'] = $u ['status'];
  2944. $flag = false;
  2945. break;
  2946. }
  2947. }
  2948. $endStaffArray = end ( $verifyStaff );
  2949. if (isset ( $endStaffArray ['ROLE'] )) {
  2950. } else {
  2951. $endKey = key ( $verifyStaff );
  2952. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  2953. $button = 4;
  2954. $verifyList [$k] ['status'] = 4;
  2955. }
  2956. }
  2957. }
  2958. }
  2959. $rolename ['name'] = '';
  2960. if (! empty ( $roleId )) {
  2961. Doo::loadModel ( 'role' );
  2962. $role = new role ();
  2963. $rolename = $role->getOne ( array (
  2964. 'where' => 'rid=' . $roleId,
  2965. 'asArray' => true
  2966. ) );
  2967. }
  2968. if (! empty ( $verifyStaff ))
  2969. $endStaffArray = end ( $verifyStaff );
  2970. $KOP = false;
  2971. foreach ( $roleArrayCopy as $P => $A ) {
  2972. foreach ( $A as $MKI => $AVL ) {
  2973. if (! empty ( $verifyStaff )) {
  2974. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2975. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2976. $button = 4;
  2977. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2978. }
  2979. foreach ( $verifyStaff as $m => $u ) {
  2980. $AVLFK = $AVL [0] . '_R';
  2981. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2982. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2983. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2984. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2985. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2986. break;
  2987. }
  2988. }
  2989. } else {
  2990. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2991. $button = 4;
  2992. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2993. }
  2994. }
  2995. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2996. $KOP = true;
  2997. }
  2998. }
  2999. // print_r($roleArrayCopy);
  3000. // echo $roleKey;
  3001. foreach ( $roleArrayCopy as $k => $v ) {
  3002. foreach ( $verifyList as $m => $n ) {
  3003. if ($n [0] == $k) {
  3004. array_splice ( $verifyList, $m, 1, $v );
  3005. }
  3006. }
  3007. }
  3008. $receiptList [$key] ['verifyList'] = $verifyList;
  3009. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3010. 'where' => 'sid=' . $value ['staff'],
  3011. 'asArray' => true
  3012. ) );
  3013. $receiptList [$key] ['button'] = $button;
  3014. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  3015. }
  3016. // $data['verifyDetail']=$verifyDetail;
  3017. $mothHtml = "";
  3018. for($i = 1; $i <= 12; $i ++) {
  3019. if ($month == $i)
  3020. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3021. else
  3022. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3023. }
  3024. // 获取审批日志
  3025. Doo::loadModel ( 'receiptLog' );
  3026. $receiptLog = new receiptLog ();
  3027. $rlList = array ();
  3028. $rlInfo = $receiptLog->getOne ( array (
  3029. 'where' => 'rid=' . $rid . ' and status=4',
  3030. 'asArray' => true
  3031. ) );
  3032. $tijdate = $receiptLog->getOne ( array (
  3033. 'where' => 'rid=' . $rid . ' and status=2',
  3034. 'asc' => 'rlid',
  3035. 'asArray' => true
  3036. ) );
  3037. if (! empty ( $rlInfo )) {
  3038. $rlList = $receiptLog->find ( array (
  3039. 'where' => 'rid=' . $rid,
  3040. 'asc' => 'rlid',
  3041. 'asArray' => true
  3042. ) );
  3043. }
  3044. $receiptList [0] ['rlList'] = $rlList;
  3045. $enclosurList = $enclosur->find ( array (
  3046. 'where' => 'rid=' . $rid,
  3047. 'asArray' => true
  3048. ) );
  3049. $enclosurHtml = '';
  3050. foreach ( $enclosurList as $value ) {
  3051. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3052. }
  3053. // print_r($receiptList);
  3054. $data ['rid'] = $rid;
  3055. $data ['enclosurHtml'] = $enclosurHtml;
  3056. $data ['rolename'] = $rolename ['name'];
  3057. $data ['datetij'] = $tijdate ['date'];
  3058. $data ['mothHtml'] = $mothHtml;
  3059. $data ['receiptList'] = $receiptList;
  3060. $data ['receiptApprovalCount'] = count ( $receiptList );
  3061. $data ['status'] = $status;
  3062. $data ['year'] = $year;
  3063. $data ['categoryList'] = $categoryList;
  3064. $data ['staffList'] = $staffList;
  3065. $data ['cid'] = $cid;
  3066. $data ['sid'] = $sid;
  3067. $data ['ap'] = $ap;
  3068. $data ['memu'] = "receipt";
  3069. $data ['staff'] = $this->staff;
  3070. $data ['receiptMemu'] = 'approvalExpenses';
  3071. $data ['verifyId'] = $this->verifyId;
  3072. $data ['executeId'] = $this->executeId;
  3073. $this->render ( "/admin/expensesEdi", $data );
  3074. }
  3075. function expensesDefray() {
  3076. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3077. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3078. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3079. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  3080. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  3081. if (! empty ( $rid )) {
  3082. Doo::loadModel ( "verify" );
  3083. $verify = new verify ();
  3084. Doo::loadModel ( "receiptDetail" );
  3085. $receiptDetailObj = new receiptDetail ();
  3086. Doo::loadModel ( "itemStatistics" );
  3087. Doo::loadModel ( "statistics" );
  3088. $statistics = new statistics ();
  3089. $itemStatistics = new itemStatistics ();
  3090. Doo::loadModel ( "receipt" );
  3091. $receipt = new receipt ();
  3092. Doo::loadModel ( "loanReceipt" );
  3093. $loanReceipt = new loanReceipt ();
  3094. $receiptDetail = $receipt->getOne ( array (
  3095. 'where' => 'rid=' . $rid . ' and status=2 ',
  3096. 'asArray' => true
  3097. ) );
  3098. if (empty ( $receiptDetail ))
  3099. return "/approval";
  3100. $verifyDetail = $verify->getOne ( array (
  3101. 'where' => ' vid =' . $receiptDetail ['verify'],
  3102. 'asArray' => true
  3103. ) );
  3104. $verifyString = $verifyDetail ['staff'];
  3105. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3106. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  3107. if (empty ( $opinion )) {
  3108. if ($status == 3)
  3109. $opinion = "终止";
  3110. else
  3111. $opinion = "同意支付";
  3112. }
  3113. $nowStaff = 0;
  3114. $nowStaffList = array ();
  3115. if (empty ( $verifyStaff )) {
  3116. // 还需加入是否已经进入角色审批
  3117. if ($verifyDetail [0] [1] == 'ROLE') {
  3118. // print_r($verifyDetail);echo "ddd";
  3119. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3120. foreach ( $vStaffString as $key => $value ) {
  3121. $staffK = explode ( "_", $value );
  3122. if ($staffK [0] != $this->staff [0] ['sid'])
  3123. array_push ( $nowStaffList, $staffK [0] );
  3124. }
  3125. // print_r($verifyDetail);
  3126. // die;
  3127. if (! empty ( $nowStaffList )) {
  3128. $nowStaff = implode ( ',', $nowStaffList );
  3129. $verifyStaff = array (
  3130. $this->staff [0] ['sid'] . "_R" => array (
  3131. 'date' => date ( 'Y-m-d' ),
  3132. 'opinion' => $opinion,
  3133. 'status' => $status,
  3134. 'nextStaff' => $verifyDetail [0] [0],
  3135. 'ROLE' => 1
  3136. )
  3137. );
  3138. } else {
  3139. $nowStaff = $verifyDetail [1] [0];
  3140. $verifyStaff = array (
  3141. $this->staff [0] ['sid'] . "_R" => array (
  3142. 'date' => date ( 'Y-m-d' ),
  3143. 'opinion' => $opinion,
  3144. 'status' => $status,
  3145. 'nextStaff' => $verifyDetail [1] [0]
  3146. )
  3147. );
  3148. }
  3149. } else {
  3150. if ($verifyDetail [1] [1] == 'ROLE') {
  3151. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  3152. // echo "dd";
  3153. foreach ( $vStaffString as $key => $value ) {
  3154. $staffK = explode ( "_", $value );
  3155. array_push ( $nowStaffList, $staffK [0] );
  3156. }
  3157. $nowStaff = implode ( ',', $nowStaffList );
  3158. $verifyStaff = array (
  3159. $this->staff [0] ['sid'] => array (
  3160. 'date' => date ( 'Y-m-d' ),
  3161. 'opinion' => $opinion,
  3162. 'status' => $status,
  3163. 'nextStaff' => $verifyDetail [1] [0],
  3164. 'ROLE' => 1
  3165. )
  3166. );
  3167. } else {
  3168. $nowStaff = $verifyDetail [1] [0];
  3169. $verifyStaff = array (
  3170. $this->staff [0] ['sid'] => array (
  3171. 'date' => date ( 'Y-m-d' ),
  3172. 'opinion' => $opinion,
  3173. 'status' => $status,
  3174. 'nextStaff' => $verifyDetail [1] [0]
  3175. )
  3176. );
  3177. }
  3178. }
  3179. if ($status == 3)
  3180. $verifyStaff = array (
  3181. 'final' => $status,
  3182. $this->staff [0] ['sid'] => array (
  3183. 'date' => date ( 'Y-m-d' ),
  3184. 'opinion' => $opinion,
  3185. 'status' => $status
  3186. )
  3187. );
  3188. $vStaffString = json_encode ( $verifyStaff );
  3189. $receipt->nowStaff = $nowStaff;
  3190. $receipt->verifyStaff = $vStaffString;
  3191. $loanReceipt->nowStaff = $nowStaff;
  3192. $loanReceipt->verifyStaff = $vStaffString;
  3193. } else {
  3194. $VS = end ( $verifyStaff );
  3195. // 非角色审批
  3196. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  3197. $nextStaff = 0;
  3198. $roleSTF = false;
  3199. foreach ( $verifyDetail as $key => $value ) {
  3200. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  3201. if (isset ( $verifyDetail [$key + 1] )) {
  3202. $nextStaff = $verifyDetail [$key + 1] [0];
  3203. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  3204. $roleSTF = true;
  3205. }
  3206. break;
  3207. }
  3208. }
  3209. if (! $roleSTF) {
  3210. $nowStaff = $nextStaff;
  3211. $verifyStaff [$this->staff [0] ['sid']] = array (
  3212. 'date' => date ( 'Y-m-d' ),
  3213. 'opinion' => $opinion,
  3214. 'status' => $status,
  3215. 'nextStaff' => $nextStaff
  3216. );
  3217. } else {
  3218. // 获取角色下的所有用户ID
  3219. $nowStaffList = array ();
  3220. foreach ( $verifyDetail as $vfk ) {
  3221. if ($vfk [1] == 'ROLE') {
  3222. $vStaffString = json_decode ( $vfk [3] );
  3223. foreach ( $vStaffString as $key => $value ) {
  3224. $staffK = explode ( "_", $value );
  3225. array_push ( $nowStaffList, $staffK [0] );
  3226. }
  3227. }
  3228. }
  3229. $nowStaff = implode ( ',', $nowStaffList );
  3230. $verifyStaff [$this->staff [0] ['sid']] = array (
  3231. 'date' => date ( 'Y-m-d' ),
  3232. 'opinion' => $opinion,
  3233. 'status' => $status,
  3234. 'nextStaff' => $nextStaff,
  3235. 'ROLE' => 0
  3236. );
  3237. }
  3238. if ($status == 3) {
  3239. $verifyStaff ['final'] = $status;
  3240. $verifyStaff [$this->staff [0] ['sid']] = array (
  3241. 'date' => date ( 'Y-m-d' ),
  3242. 'opinion' => $opinion,
  3243. 'status' => $status
  3244. );
  3245. }
  3246. $vStaffString = json_encode ( $verifyStaff );
  3247. $receipt->nowStaff = $nowStaff;
  3248. $receipt->verifyStaff = $vStaffString;
  3249. $loanReceipt->nowStaff = $nowStaff;
  3250. $loanReceipt->verifyStaff = $vStaffString;
  3251. }
  3252. // 角色审批
  3253. if (isset ( $VS ['ROLE'] )) {
  3254. // 找出角色人 当前审批角色组
  3255. $verifyJSStaff = array ();
  3256. $nowStaffList2 = array ();
  3257. foreach ( $verifyDetail as $key => $value ) {
  3258. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  3259. $verifyJSStaff = json_decode ( $value [3] );
  3260. foreach ( $verifyJSStaff as $m ) {
  3261. $staffK = explode ( "_", $m );
  3262. array_push ( $nowStaffList2, $staffK [0] );
  3263. }
  3264. // print_r($nowStaffList2);
  3265. }
  3266. }
  3267. $RoleVerifyStaff = array ();
  3268. foreach ( $verifyStaff as $key => $value ) {
  3269. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  3270. foreach ( $nowStaffList2 as $m ) {
  3271. if ($key == $m . "_R")
  3272. $RoleVerifyStaff [$key] = $value;
  3273. }
  3274. }
  3275. }
  3276. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  3277. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  3278. // 下一个审批人ID
  3279. $nextStaff = 0;
  3280. $falg = false;
  3281. foreach ( $verifyDetail as $key => $value ) {
  3282. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  3283. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  3284. $falg = true;
  3285. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  3286. $nowStaffList = array ();
  3287. foreach ( $vStaffString as $v ) {
  3288. $staffK = explode ( "_", $v );
  3289. array_push ( $nowStaffList, $staffK [0] );
  3290. }
  3291. $nowStaff = implode ( ',', $nowStaffList );
  3292. $nextStaff = $verifyDetail [$key + 1] [0];
  3293. } elseif (isset ( $verifyDetail [$key + 1] )) {
  3294. $nextStaff = $verifyDetail [$key + 1] [0];
  3295. $nowStaff = $nextStaff;
  3296. } else
  3297. $nowStaff = '';
  3298. break;
  3299. }
  3300. }
  3301. if ($falg)
  3302. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3303. 'date' => date ( 'Y-m-d' ),
  3304. 'opinion' => $opinion,
  3305. 'status' => $status,
  3306. 'nextStaff' => $nextStaff,
  3307. 'ROLE' => 1
  3308. );
  3309. else
  3310. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3311. 'date' => date ( 'Y-m-d' ),
  3312. 'opinion' => $opinion,
  3313. 'status' => $status,
  3314. 'nextStaff' => $nextStaff
  3315. );
  3316. // print_r($verifyStaff);
  3317. // echo $nowStaff;die;
  3318. } else { // 进入下一个角色或者审批人
  3319. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  3320. //
  3321. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  3322. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3323. 'date' => date ( 'Y-m-d' ),
  3324. 'opinion' => $opinion,
  3325. 'status' => $status,
  3326. 'nextStaff' => $VS ['nextStaff'],
  3327. 'ROLE' => 1
  3328. );
  3329. // print_r($verifyStaff);
  3330. // die;
  3331. }
  3332. if ($status == 3) {
  3333. $verifyStaff ['final'] = $status;
  3334. $verifyStaff [$this->staff [0] ['sid']] = array (
  3335. 'date' => date ( 'Y-m-d' ),
  3336. 'opinion' => $opinion,
  3337. 'status' => $status
  3338. );
  3339. }
  3340. $vStaffString = json_encode ( $verifyStaff );
  3341. $receipt->verifyStaff = $vStaffString;
  3342. $receipt->nowStaff = $nowStaff;
  3343. $loanReceipt->nowStaff = $nowStaff;
  3344. $loanReceipt->verifyStaff = $vStaffString;
  3345. // die;
  3346. // }
  3347. // print_r($verifyStaff);
  3348. // die;
  3349. }
  3350. // print_r($verifyStaff);die;
  3351. }
  3352. // print_r($verifyDetail);
  3353. $roleKey = 0;
  3354. $roleId = 0;
  3355. $verifyDetailCopy = array ();
  3356. foreach ( $verifyDetail as $k => $v ) {
  3357. if ($v [1] == 'ROLE') {
  3358. $roleId = $v [0];
  3359. $roleVerify = json_decode ( $v [3], true );
  3360. $roleKey = $k;
  3361. $roleArray = array ();
  3362. foreach ( $roleVerify as $o => $p ) {
  3363. $staffID = explode ( '_', $p );
  3364. $exp = array (
  3365. 0 => $staffID [0],
  3366. 1 => $staffID [1]
  3367. );
  3368. array_push ( $roleArray, $exp );
  3369. }
  3370. $verifyDetailCopy [$v [0]] = $roleArray;
  3371. }
  3372. }
  3373. // print_r($verifyDetail);
  3374. foreach ( $verifyDetailCopy as $k => $v ) {
  3375. foreach ( $verifyDetail as $m => $n ) {
  3376. if ($n [0] == $k) {
  3377. array_splice ( $verifyDetail, $m, 1, $v );
  3378. }
  3379. }
  3380. }
  3381. // 审批日志
  3382. if (! isset ( $verifyStaff ['final'] )) {
  3383. Doo::loadModel ( "receiptLog" );
  3384. $receiptLog = new receiptLog ();
  3385. if (! empty ( $roleId )) {
  3386. Doo::loadModel ( "role" );
  3387. $role = new role ();
  3388. $roleInfo = $role->getOne ( array (
  3389. 'where' => 'rid=' . $roleId,
  3390. 'asArray' => true
  3391. ) );
  3392. $receiptLog->rolename = $roleInfo ['name'];
  3393. }
  3394. $receiptLog->username = $this->staff [0] ['username'];
  3395. $receiptLog->uid = $this->staff [0] ['sid'];
  3396. $receiptLog->date = date ( "Y-m-d" );
  3397. $receiptLog->opinion = $opinion;
  3398. $receiptLog->img = $this->staff [0] ['avatar'];
  3399. $receiptLog->status = 1;
  3400. $receiptLog->rid = $rid;
  3401. $receiptLog->insert ();
  3402. }
  3403. if (isset ( $verifyStaff ['final'] )) { // rDetail
  3404. $receipt->status = 3;
  3405. $receipt->verifyBreakup = $verifyString;
  3406. $receiptDetailObj->status = 3;
  3407. $receiptDetailObj->update ( array (
  3408. 'where' => 'rid=' . $rid
  3409. ) );
  3410. // 微信企业号通知
  3411. $this->setWXMsg ( $rid, 3 );
  3412. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  3413. $receipt->status = 6;
  3414. $receipt->pastDate = date ( "Y-m-d" );
  3415. $receipt->isBK = 1;
  3416. $loanReceipt->verifyBreakup = $verifyString;
  3417. $loanReceipt->status = 1;
  3418. $loanReceipt->pastDate = date ( "Y-m-d" );
  3419. $loanReceipt->update ( array (
  3420. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  3421. ) );
  3422. // 微信企业号通知
  3423. $this->setWXMsg ( $rid, 1 );
  3424. }
  3425. $receipt->amount = $amount;
  3426. $receipt->update ( array (
  3427. 'where' => ' rid = ' . $rid
  3428. ) );
  3429. return "/approvalExpenses/pendApproval";
  3430. }
  3431. }
  3432. function ajaxExamineExe() {
  3433. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3434. Doo::loadModel ( 'receipt' );
  3435. $receipt = new receipt ();
  3436. Doo::loadClass ( 'XDeode' );
  3437. $XDeode = new XDeode ( 5 );
  3438. if (! empty ( $rid )) {
  3439. $rLRes = $receipt->find ( array (
  3440. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  3441. 'asArray' => true
  3442. ) );
  3443. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  3444. echo json_encode ( array (
  3445. 'status' => 1,
  3446. 'receipt' => $rLRes [0]
  3447. ) );
  3448. die ();
  3449. }
  3450. echo json_encode ( array (
  3451. 'status' => 0,
  3452. 'receipt' => array ()
  3453. ) );
  3454. die ();
  3455. }
  3456. function implement() {
  3457. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3458. Doo::loadClass ( 'XDeode' );
  3459. $XDeode = new XDeode ( 5 );
  3460. Doo::loadModel ( 'receipt' );
  3461. $receipt = new receipt ();
  3462. Doo::loadModel ( 'L_category' );
  3463. $Lcategory = new L_category ();
  3464. Doo::loadModel ( 'verify' );
  3465. $verify = new verify ();
  3466. Doo::loadModel ( 'staff' );
  3467. $staff = new staff ();
  3468. Doo::loadModel ( "execute" );
  3469. $execute = new execute ();
  3470. $rid = $XDeode->decode ( $rid );
  3471. $receiptList = $receipt->find ( array (
  3472. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  3473. 'desc' => 'rid',
  3474. 'asArray' => true
  3475. ) );
  3476. Doo::loadModel ( 'loanReceipt' );
  3477. $loanReceipt = new loanReceipt ();
  3478. // print_r($receiptList);
  3479. $loanList = array ();
  3480. if (! isset ( $receiptList ))
  3481. $loanList = $loanReceipt->find ( array (
  3482. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3483. 'desc' => 'rid',
  3484. 'asArray' => true
  3485. ) );
  3486. $Locate = 0;
  3487. $roleId = 0;
  3488. $button = 0;
  3489. foreach ( $loanList as $key => $value ) {
  3490. $loanList [$key] ['Locate'] = $Locate;
  3491. $Locate ++;
  3492. $loanList [$key] ['reviseDetail'] = array ();
  3493. if (! empty ( $value ['reviseDetail'] ))
  3494. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3495. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3496. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3497. $categoryDetil = $Lcategory->getOne ( array (
  3498. 'where' => 'cid=' . $value ['cid'],
  3499. 'asArray' => true
  3500. ) );
  3501. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3502. // 检测编辑状态
  3503. $verifyList = $verify->getOne ( array (
  3504. 'where' => 'vid=' . $value ['verify'],
  3505. 'asArray' => true
  3506. ) );
  3507. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3508. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3509. Doo::loadModel ( 'role' );
  3510. $role = new role ();
  3511. $flag = true;
  3512. $roleKey = 0;
  3513. $endStaffArray = array ();
  3514. $roleArrayCopy = array ();
  3515. foreach ( $verifyList as $k => $v ) {
  3516. // init verifyStaff
  3517. if ($v [1] == 'ROLE') {
  3518. if (! empty ( $verifyStaff )) {
  3519. $endStaffArray = end ( $verifyStaff );
  3520. // if ($v[0]==$endStaffArray['nextStaff']){
  3521. // $roleId=$v[0];
  3522. // }
  3523. }
  3524. $roleVerify = json_decode ( $v [3], true );
  3525. $roleKey = $k;
  3526. $roleArray = array ();
  3527. $rolename = $role->getOne ( array (
  3528. 'where' => 'rid=' . $v [0],
  3529. 'asArray' => true
  3530. ) );
  3531. foreach ( $roleVerify as $o => $p ) {
  3532. $staffID = explode ( '_', $p );
  3533. $staffInfo = $staff->getOne ( array (
  3534. 'where' => 'sid=' . $staffID [0],
  3535. 'asArray' => true
  3536. ) );
  3537. // print_r($staffID);
  3538. $exp = array (
  3539. 0 => $staffInfo ['sid'],
  3540. 1 => $staffID [1],
  3541. 2 => $staffInfo ['avatar'],
  3542. 'date' => '',
  3543. 'date' => '',
  3544. 'opinion' => '',
  3545. 'status' => '',
  3546. 'rolename' => $rolename ['name']
  3547. );
  3548. array_push ( $roleArray, $exp );
  3549. }
  3550. $roleArrayCopy [$v [0]] = $roleArray;
  3551. // $verifyList[$k]['roleArray']=$roleArray;
  3552. }
  3553. $verifyList [$k] ['date'] = "";
  3554. $verifyList [$k] ['opinion'] = "";
  3555. $verifyList [$k] ['status'] = "";
  3556. if (empty ( $verifyStaff )) {
  3557. $verifyList [$k] ['date'] = "";
  3558. $verifyList [$k] ['opinion'] = "";
  3559. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3560. $verifyList [$k] ['status'] = 4;
  3561. $flag = false;
  3562. }
  3563. } else {
  3564. foreach ( $verifyStaff as $m => $u ) {
  3565. if ($v [0] == $m) {
  3566. $verifyList [$k] ['date'] = $u ['date'];
  3567. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3568. $verifyList [$k] ['status'] = $u ['status'];
  3569. $flag = false;
  3570. break;
  3571. }
  3572. }
  3573. $endStaffArray = end ( $verifyStaff );
  3574. if (isset ( $endStaffArray ['ROLE'] )) {
  3575. } else {
  3576. // $endKey=key($verifyStaff);
  3577. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3578. // $button=4;
  3579. // $verifyList[$k]['status']=4;
  3580. // }
  3581. }
  3582. }
  3583. }
  3584. $rolename ['name'] = '';
  3585. if (! empty ( $roleId )) {
  3586. Doo::loadModel ( 'role' );
  3587. $role = new role ();
  3588. $rolename = $role->getOne ( array (
  3589. 'where' => 'rid=' . $roleId,
  3590. 'asArray' => true
  3591. ) );
  3592. }
  3593. if (! empty ( $verifyStaff ))
  3594. $endStaffArray = end ( $verifyStaff );
  3595. $KOP = false;
  3596. foreach ( $roleArrayCopy as $P => $A ) {
  3597. foreach ( $A as $MKI => $AVL ) {
  3598. if (! empty ( $verifyStaff )) {
  3599. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3600. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3601. $button = 4;
  3602. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3603. }
  3604. foreach ( $verifyStaff as $m => $u ) {
  3605. $AVLFK = $AVL [0] . '_R';
  3606. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3607. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3608. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3609. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3610. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3611. break;
  3612. }
  3613. }
  3614. } else {
  3615. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3616. $button = 4;
  3617. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3618. }
  3619. }
  3620. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3621. $KOP = true;
  3622. }
  3623. }
  3624. foreach ( $roleArrayCopy as $k => $v ) {
  3625. foreach ( $verifyList as $m => $n ) {
  3626. if ($n [0] == $k) {
  3627. array_splice ( $verifyList, $m, 1, $v );
  3628. }
  3629. }
  3630. }
  3631. $loanList [$key] ['verifyList'] = $verifyList;
  3632. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3633. 'where' => 'sid=' . $value ['staff'],
  3634. 'asArray' => true
  3635. ) );
  3636. }
  3637. $data ['loanList'] = $loanList;
  3638. $Locate = 0;
  3639. $roleId = 0;
  3640. $button = 0;
  3641. foreach ( $receiptList as $key => $value ) {
  3642. $button2 = 0;
  3643. $receiptList [$key] ['Locate'] = $Locate;
  3644. $Locate ++;
  3645. $receiptList [$key] ['reviseDetail'] = array ();
  3646. if (! empty ( $value ['reviseDetail'] ))
  3647. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3648. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3649. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3650. $categoryDetil = $Lcategory->getOne ( array (
  3651. 'where' => 'cid=' . $value ['cid'],
  3652. 'asArray' => true
  3653. ) );
  3654. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3655. $executeList = json_decode ( $value ['executeCopy'], true );
  3656. $executeStaff = array ();
  3657. if (! empty ( $value ['executeStaff'] ))
  3658. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3659. if (isset ( $executeList )) {
  3660. foreach ( $executeList as $op => $lo ) {
  3661. $executeList [$op] ['date'] = "";
  3662. $executeList [$op] ['opinion'] = "";
  3663. $executeList [$op] ['status'] = "";
  3664. foreach ( $executeStaff as $m => $u ) {
  3665. if ($lo [0] == $m) {
  3666. $executeList [$op] ['date'] = $u ['date'];
  3667. $executeList [$op] ['opinion'] = $u ['opinion'];
  3668. $executeList [$op] ['status'] = $u ['status'];
  3669. break;
  3670. }
  3671. }
  3672. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  3673. $button2 = 1;
  3674. $executeList [$op] ['status'] = 4;
  3675. }
  3676. }
  3677. }
  3678. // 检测编辑状态
  3679. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3680. $verifyList ['staff'] = $value ['verifyBreakup'];
  3681. } else
  3682. $verifyList = $verify->getOne ( array (
  3683. 'where' => 'vid=' . $value ['verify'],
  3684. 'asArray' => true
  3685. ) );
  3686. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3687. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3688. Doo::loadModel ( 'role' );
  3689. $role = new role ();
  3690. if ($verifyList == NULL)
  3691. $verifyList = array ();
  3692. $flag = true;
  3693. $roleKey = 0;
  3694. $endStaffArray = array ();
  3695. $roleArrayCopy = array ();
  3696. foreach ( $verifyList as $k => $v ) {
  3697. // init verifyStaff
  3698. if ($v [1] == 'ROLE') {
  3699. if (! empty ( $verifyStaff )) {
  3700. $endStaffArray = end ( $verifyStaff );
  3701. // if ($v[0]==$endStaffArray['nextStaff']){
  3702. // $roleId=$v[0];
  3703. // }
  3704. }
  3705. $roleVerify = json_decode ( $v [3], true );
  3706. $roleKey = $k;
  3707. $roleArray = array ();
  3708. $rolename = $role->getOne ( array (
  3709. 'where' => 'rid=' . $v [0],
  3710. 'asArray' => true
  3711. ) );
  3712. foreach ( $roleVerify as $o => $p ) {
  3713. $staffID = explode ( '_', $p );
  3714. $staffInfo = $staff->getOne ( array (
  3715. 'where' => 'sid=' . $staffID [0],
  3716. 'asArray' => true
  3717. ) );
  3718. // print_r($staffID);
  3719. $exp = array (
  3720. 0 => $staffInfo ['sid'],
  3721. 1 => $staffID [1],
  3722. 2 => $staffInfo ['avatar'],
  3723. 'date' => '',
  3724. 'date' => '',
  3725. 'opinion' => '',
  3726. 'status' => '',
  3727. 'rolename' => $rolename ['name']
  3728. );
  3729. array_push ( $roleArray, $exp );
  3730. }
  3731. $roleArrayCopy [$v [0]] = $roleArray;
  3732. // $verifyList[$k]['roleArray']=$roleArray;
  3733. }
  3734. $verifyList [$k] ['date'] = "";
  3735. $verifyList [$k] ['opinion'] = "";
  3736. $verifyList [$k] ['status'] = "";
  3737. if (empty ( $verifyStaff )) {
  3738. $verifyList [$k] ['date'] = "";
  3739. $verifyList [$k] ['opinion'] = "";
  3740. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3741. $verifyList [$k] ['status'] = 4;
  3742. $flag = false;
  3743. }
  3744. } else {
  3745. foreach ( $verifyStaff as $m => $u ) {
  3746. if ($v [0] == $m) {
  3747. $verifyList [$k] ['date'] = $u ['date'];
  3748. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3749. $verifyList [$k] ['status'] = $u ['status'];
  3750. $flag = false;
  3751. break;
  3752. }
  3753. }
  3754. $endStaffArray = end ( $verifyStaff );
  3755. if (isset ( $endStaffArray ['ROLE'] )) {
  3756. } else {
  3757. // $endKey=key($verifyStaff);
  3758. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3759. // $button=4;
  3760. // $verifyList[$k]['status']=4;
  3761. // }
  3762. }
  3763. }
  3764. }
  3765. $rolename ['name'] = '';
  3766. if (! empty ( $roleId )) {
  3767. Doo::loadModel ( 'role' );
  3768. $role = new role ();
  3769. $rolename = $role->getOne ( array (
  3770. 'where' => 'rid=' . $roleId,
  3771. 'asArray' => true
  3772. ) );
  3773. }
  3774. if (! empty ( $verifyStaff ))
  3775. $endStaffArray = end ( $verifyStaff );
  3776. $KOP = false;
  3777. foreach ( $roleArrayCopy as $P => $A ) {
  3778. foreach ( $A as $MKI => $AVL ) {
  3779. if (! empty ( $verifyStaff )) {
  3780. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3781. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3782. $button = 4;
  3783. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3784. }
  3785. foreach ( $verifyStaff as $m => $u ) {
  3786. $AVLFK = $AVL [0] . '_R';
  3787. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3788. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3789. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3790. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3791. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3792. break;
  3793. }
  3794. }
  3795. } else {
  3796. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3797. $button = 4;
  3798. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3799. }
  3800. }
  3801. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3802. $KOP = true;
  3803. }
  3804. }
  3805. foreach ( $roleArrayCopy as $k => $v ) {
  3806. foreach ( $verifyList as $m => $n ) {
  3807. if ($n [0] == $k) {
  3808. array_splice ( $verifyList, $m, 1, $v );
  3809. }
  3810. }
  3811. }
  3812. $receiptList [$key] ['verifyList'] = $verifyList;
  3813. $receiptList [$key] ['executeList'] = $executeList;
  3814. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3815. 'where' => 'sid=' . $value ['staff'],
  3816. 'asArray' => true
  3817. ) );
  3818. $receiptList [$key] ['button2'] = $button2;
  3819. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3820. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3821. $relust = $value ['sum'] - $value ['loanSum'];
  3822. $receiptList [$key] ['relust'] = $relust;
  3823. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  3824. }
  3825. // print_r($receiptList[$key]['executeList']);
  3826. $data ['receiptList'] = $receiptList;
  3827. $data ['memu'] = "receipt";
  3828. $data ['staff'] = $this->staff;
  3829. $data ['receiptMemu'] = 'implement';
  3830. $data ['verifyId'] = $this->verifyId;
  3831. $data ['executeId'] = $this->executeId;
  3832. $this->render ( "/admin/implement", $data );
  3833. }
  3834. function implementDo() {
  3835. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3836. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3837. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  3838. if (! empty ( $rid ) && $amount != '') {
  3839. Doo::loadModel ( 'receipt' );
  3840. $receipt = new receipt ();
  3841. Doo::loadClass ( 'XDeode' );
  3842. $XDeode = new XDeode ( 5 );
  3843. $rinfo = $receipt->getOne ( array (
  3844. 'where' => 'rid=' . $rid,
  3845. 'asArray' => true
  3846. ) );
  3847. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  3848. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  3849. if (empty ( $executeStaff )) {
  3850. $executeStaff = array (
  3851. $this->staff [0] ['sid'] => array (
  3852. 'date' => date ( 'Y-m-d' ),
  3853. 'opinion' => $implementOpinions,
  3854. 'status' => 1
  3855. )
  3856. );
  3857. } else {
  3858. $executeStaff [$this->staff [0] ['sid']] = array (
  3859. 'date' => date ( 'Y-m-d' ),
  3860. 'opinion' => $implementOpinions,
  3861. 'status' => 1
  3862. );
  3863. }
  3864. if (count ( $executeStaff ) == count ( $executeCopy )) {
  3865. $receipt->executeStaff = json_encode ( $executeStaff );
  3866. $receipt->status = 8;
  3867. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  3868. $receipt->status = 9;
  3869. if($rinfo ['status']==6){
  3870. $receipt->loanDate=date ( "Y-m-d" );
  3871. }
  3872. $receipt->executeDate = date ( "Y-m-d" );
  3873. } else {
  3874. $receipt->executeStaff = json_encode ( $executeStaff );
  3875. }
  3876. $receipt->amount = $amount;
  3877. $receipt->update ( array (
  3878. 'where' => 'rid=' . $rid
  3879. ) );
  3880. }
  3881. $ridKey = $XDeode->encode ( $rid );
  3882. return "/hisImplement";
  3883. //return "/implement/" . $ridKey . ".html";
  3884. }
  3885. function receiptburEdi() {
  3886. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3887. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  3888. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  3889. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  3890. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3891. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  3892. if (empty ( $status ))
  3893. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  3894. $vidList = array ();
  3895. $button = 0;
  3896. Doo::loadModel ( 'verify' );
  3897. Doo::loadModel ( 'receipt' );
  3898. Doo::loadModel ( 'staff' );
  3899. $staff = new staff ();
  3900. $receipt = new receipt ();
  3901. $verify = new verify ();
  3902. Doo::loadModel ( 'L_category' );
  3903. $Lcategory = new L_category ();
  3904. Doo::loadModel ( 'enclosur' );
  3905. $enclosur = new enclosur ();
  3906. Doo::loadModel ( 'loanReceipt' );
  3907. $loanReceipt = new loanReceipt ();
  3908. // user verify ID
  3909. $verifyDetail = $verify->find ( array (
  3910. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  3911. 'asArray' => true
  3912. ) );
  3913. foreach ( $verifyDetail as $key => $value ) {
  3914. array_push ( $vidList, $value ['vid'] );
  3915. }
  3916. $vid = implode ( ",", $vidList );
  3917. if (empty ( $verifyDetail ))
  3918. $vid = 0;
  3919. $categoryList = $Lcategory->find ( array (
  3920. 'asArray' => true
  3921. ) );
  3922. $staffList = $staff->find ( array (
  3923. 'where' => 'cid=' . $cid,
  3924. 'asArray' => true
  3925. ) );
  3926. $ap = "";
  3927. if ($status == 4) {
  3928. $ap = 4;
  3929. $status = 2;
  3930. }
  3931. // get Receipt By verifyID status 2
  3932. $receiptList = $receipt->find ( array (
  3933. 'where' => 'rid =' . $rid,
  3934. 'desc' => 'rid',
  3935. 'asArray' => true
  3936. ) );
  3937. $loanList = $loanReceipt->find ( array (
  3938. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3939. 'desc' => 'rid',
  3940. 'asArray' => true
  3941. ) );
  3942. $Locate = 0;
  3943. $roleId = 0;
  3944. $button = 0;
  3945. foreach ( $loanList as $key => $value ) {
  3946. $loanList [$key] ['Locate'] = $Locate;
  3947. $Locate ++;
  3948. $loanList [$key] ['reviseDetail'] = array ();
  3949. if (! empty ( $value ['reviseDetail'] ))
  3950. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3951. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3952. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3953. $categoryDetil = $Lcategory->getOne ( array (
  3954. 'where' => 'cid=' . $value ['cid'],
  3955. 'asArray' => true
  3956. ) );
  3957. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3958. // 检测编辑状态
  3959. $verifyList = $verify->getOne ( array (
  3960. 'where' => 'vid=' . $value ['verify'],
  3961. 'asArray' => true
  3962. ) );
  3963. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3964. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3965. Doo::loadModel ( 'role' );
  3966. $role = new role ();
  3967. $flag = true;
  3968. $roleKey = 0;
  3969. $endStaffArray = array ();
  3970. $roleArrayCopy = array ();
  3971. foreach ( $verifyList as $k => $v ) {
  3972. // init verifyStaff
  3973. if ($v [1] == 'ROLE') {
  3974. if (! empty ( $verifyStaff )) {
  3975. $endStaffArray = end ( $verifyStaff );
  3976. }
  3977. $roleVerify = json_decode ( $v [3], true );
  3978. $roleKey = $k;
  3979. $roleArray = array ();
  3980. $rolename = $role->getOne ( array (
  3981. 'where' => 'rid=' . $v [0],
  3982. 'asArray' => true
  3983. ) );
  3984. foreach ( $roleVerify as $o => $p ) {
  3985. $staffID = explode ( '_', $p );
  3986. $staffInfo = $staff->getOne ( array (
  3987. 'where' => 'sid=' . $staffID [0],
  3988. 'asArray' => true
  3989. ) );
  3990. // print_r($staffID);
  3991. $exp = array (
  3992. 0 => $staffInfo ['sid'],
  3993. 1 => $staffID [1],
  3994. 2 => $staffInfo ['avatar'],
  3995. 'date' => '',
  3996. 'date' => '',
  3997. 'opinion' => '',
  3998. 'status' => '',
  3999. 'rolename' => $rolename ['name']
  4000. );
  4001. array_push ( $roleArray, $exp );
  4002. }
  4003. $roleArrayCopy [$v [0]] = $roleArray;
  4004. // $verifyList[$k]['roleArray']=$roleArray;
  4005. }
  4006. $verifyList [$k] ['date'] = "";
  4007. $verifyList [$k] ['opinion'] = "";
  4008. $verifyList [$k] ['status'] = "";
  4009. if (empty ( $verifyStaff )) {
  4010. $verifyList [$k] ['date'] = "";
  4011. $verifyList [$k] ['opinion'] = "";
  4012. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4013. $verifyList [$k] ['status'] = 4;
  4014. $flag = false;
  4015. }
  4016. } else {
  4017. foreach ( $verifyStaff as $m => $u ) {
  4018. if ($v [0] == $m) {
  4019. $verifyList [$k] ['date'] = $u ['date'];
  4020. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4021. $verifyList [$k] ['status'] = $u ['status'];
  4022. $flag = false;
  4023. break;
  4024. }
  4025. }
  4026. $endStaffArray = end ( $verifyStaff );
  4027. if (isset ( $endStaffArray ['ROLE'] )) {
  4028. } else {
  4029. }
  4030. }
  4031. }
  4032. $rolename ['name'] = '';
  4033. if (! empty ( $roleId )) {
  4034. Doo::loadModel ( 'role' );
  4035. $role = new role ();
  4036. $rolename = $role->getOne ( array (
  4037. 'where' => 'rid=' . $roleId,
  4038. 'asArray' => true
  4039. ) );
  4040. }
  4041. if (! empty ( $verifyStaff ))
  4042. $endStaffArray = end ( $verifyStaff );
  4043. $KOP = false;
  4044. foreach ( $roleArrayCopy as $P => $A ) {
  4045. foreach ( $A as $MKI => $AVL ) {
  4046. if (! empty ( $verifyStaff )) {
  4047. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4048. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4049. $button = 4;
  4050. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4051. }
  4052. foreach ( $verifyStaff as $m => $u ) {
  4053. $AVLFK = $AVL [0] . '_R';
  4054. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4055. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4056. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4057. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4058. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4059. break;
  4060. }
  4061. }
  4062. } else {
  4063. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4064. $button = 4;
  4065. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4066. }
  4067. }
  4068. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4069. $KOP = true;
  4070. }
  4071. }
  4072. foreach ( $roleArrayCopy as $k => $v ) {
  4073. foreach ( $verifyList as $m => $n ) {
  4074. if ($n [0] == $k) {
  4075. array_splice ( $verifyList, $m, 1, $v );
  4076. }
  4077. }
  4078. }
  4079. $loanList [$key] ['verifyList'] = $verifyList;
  4080. }
  4081. $htmlLoan = '';
  4082. if (isset ( $loanList [0] )) {
  4083. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  4084. if ($value ['status'] == 1)
  4085. $htmlLoan .= '<li class="done" >';
  4086. elseif ($value ['status'] == 3)
  4087. $htmlLoan .= '<li class="undone" >';
  4088. $htmlLoan .= '<div class="avtra"><img src="' . $value [2] . '_2.jpg"></div>';
  4089. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  4090. if (isset ( $value ['rolename'] ))
  4091. $htmlLoan .= $value ['rolename'];
  4092. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  4093. }
  4094. $data ['loanDate'] = $loanList [0] ['date'];
  4095. }
  4096. $data ['htmlLoan'] = $htmlLoan;
  4097. // print_r($loanList);
  4098. $Locate = 0;
  4099. $roleId = 0;
  4100. $button = 0;
  4101. if ($ap == 4)
  4102. $status = 4;
  4103. foreach ( $receiptList as $key => $value ) {
  4104. $receiptList [$key] ['Locate'] = $Locate;
  4105. $Locate ++;
  4106. $receiptList [$key] ['reviseDetail'] = array ();
  4107. if (! empty ( $value ['reviseDetail'] ))
  4108. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4109. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4110. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4111. $categoryDetil = $Lcategory->getOne ( array (
  4112. 'where' => 'cid=' . $value ['cid'],
  4113. 'asArray' => true
  4114. ) );
  4115. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4116. // 检测编辑状态
  4117. $verifyList = $verify->getOne ( array (
  4118. 'where' => 'vid=' . $value ['verify'],
  4119. 'asArray' => true
  4120. ) );
  4121. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4122. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4123. Doo::loadModel ( 'role' );
  4124. $role = new role ();
  4125. // print_r($verifyList);
  4126. $flag = true;
  4127. $roleKey = 0;
  4128. $endStaffArray = array ();
  4129. $roleArrayCopy = array ();
  4130. foreach ( $verifyList as $k => $v ) {
  4131. // init verifyStaff
  4132. if ($v [1] == 'ROLE') {
  4133. if (! empty ( $verifyStaff )) {
  4134. $endStaffArray = end ( $verifyStaff );
  4135. if ($v [0] == $endStaffArray ['nextStaff']) {
  4136. $roleId = $v [0];
  4137. }
  4138. }
  4139. $roleVerify = json_decode ( $v [3], true );
  4140. $roleKey = $k;
  4141. $roleArray = array ();
  4142. $rolename = $role->getOne ( array (
  4143. 'where' => 'rid=' . $v [0],
  4144. 'asArray' => true
  4145. ) );
  4146. foreach ( $roleVerify as $o => $p ) {
  4147. $staffID = explode ( '_', $p );
  4148. $staffInfo = $staff->getOne ( array (
  4149. 'where' => 'sid=' . $staffID [0],
  4150. 'asArray' => true
  4151. ) );
  4152. // print_r($staffID);
  4153. $exp = array (
  4154. 0 => $staffInfo ['sid'],
  4155. 1 => $staffID [1],
  4156. 2 => $staffInfo ['avatar'],
  4157. 'date' => '',
  4158. 'date' => '',
  4159. 'opinion' => '',
  4160. 'status' => '',
  4161. 'rolename' => $rolename ['name']
  4162. );
  4163. array_push ( $roleArray, $exp );
  4164. }
  4165. $roleArrayCopy [$v [0]] = $roleArray;
  4166. // $verifyList[$k]['roleArray']=$roleArray;
  4167. }
  4168. // print_r($roleArray);
  4169. $verifyList [$k] ['date'] = "";
  4170. $verifyList [$k] ['opinion'] = "";
  4171. $verifyList [$k] ['status'] = "";
  4172. if (empty ( $verifyStaff )) {
  4173. $verifyList [$k] ['date'] = "";
  4174. $verifyList [$k] ['opinion'] = "";
  4175. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4176. $verifyList [$k] ['status'] = 4;
  4177. $button = 4;
  4178. $flag = false;
  4179. }
  4180. } else {
  4181. foreach ( $verifyStaff as $m => $u ) {
  4182. if ($v [0] == $m) {
  4183. $verifyList [$k] ['date'] = $u ['date'];
  4184. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4185. $verifyList [$k] ['status'] = $u ['status'];
  4186. $flag = false;
  4187. break;
  4188. }
  4189. }
  4190. $endStaffArray = end ( $verifyStaff );
  4191. if (isset ( $endStaffArray ['ROLE'] )) {
  4192. } else {
  4193. $endKey = key ( $verifyStaff );
  4194. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4195. $button = 4;
  4196. $verifyList [$k] ['status'] = 4;
  4197. }
  4198. }
  4199. }
  4200. }
  4201. $rolename ['name'] = '';
  4202. if (! empty ( $roleId )) {
  4203. Doo::loadModel ( 'role' );
  4204. $role = new role ();
  4205. $rolename = $role->getOne ( array (
  4206. 'where' => 'rid=' . $roleId,
  4207. 'asArray' => true
  4208. ) );
  4209. }
  4210. if (! empty ( $verifyStaff ))
  4211. $endStaffArray = end ( $verifyStaff );
  4212. $KOP = false;
  4213. foreach ( $roleArrayCopy as $P => $A ) {
  4214. foreach ( $A as $MKI => $AVL ) {
  4215. if (! empty ( $verifyStaff )) {
  4216. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4217. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4218. $button = 4;
  4219. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4220. }
  4221. foreach ( $verifyStaff as $m => $u ) {
  4222. $AVLFK = $AVL [0] . '_R';
  4223. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4224. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4225. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4226. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4227. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4228. break;
  4229. }
  4230. }
  4231. } else {
  4232. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4233. $button = 4;
  4234. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4235. }
  4236. }
  4237. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4238. $KOP = true;
  4239. }
  4240. }
  4241. foreach ( $roleArrayCopy as $k => $v ) {
  4242. foreach ( $verifyList as $m => $n ) {
  4243. if ($n [0] == $k) {
  4244. array_splice ( $verifyList, $m, 1, $v );
  4245. }
  4246. }
  4247. }
  4248. // print_r($verifyList);
  4249. $receiptList [$key] ['verifyList'] = $verifyList;
  4250. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4251. 'where' => 'sid=' . $value ['staff'],
  4252. 'asArray' => true
  4253. ) );
  4254. $receiptList [$key] ['button'] = $button;
  4255. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4256. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4257. $relust = $value ['sum'] - $value ['loanSum'];
  4258. $receiptList [$key] ['relust'] = $relust;
  4259. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4260. }
  4261. // print_r($receiptList);die;
  4262. // $data['verifyDetail']=$verifyDetail;
  4263. $mothHtml = "";
  4264. for($i = 1; $i <= 12; $i ++) {
  4265. if ($month == $i)
  4266. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4267. else
  4268. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4269. }
  4270. // 获取审批日志
  4271. Doo::loadModel ( 'receiptLog' );
  4272. $receiptLog = new receiptLog ();
  4273. $rlList = array ();
  4274. $rlInfo = $receiptLog->getOne ( array (
  4275. 'where' => 'rid=' . $rid . ' and status=4',
  4276. 'asArray' => true
  4277. ) );
  4278. $tijdate = $receiptLog->getOne ( array (
  4279. 'where' => 'rid=' . $rid . ' and status=2',
  4280. 'asc' => 'rlid',
  4281. 'asArray' => true
  4282. ) );
  4283. if (! empty ( $rlInfo )) {
  4284. $rlList = $receiptLog->find ( array (
  4285. 'where' => 'rid=' . $rid,
  4286. 'asc' => 'rlid',
  4287. 'asArray' => true
  4288. ) );
  4289. }
  4290. // echo $rid;
  4291. // print_r($receiptList);
  4292. $receiptList [0] ['rlList'] = $rlList;
  4293. // print_r($receiptList);
  4294. $enclosurList = $enclosur->find ( array (
  4295. 'where' => 'rid=' . $rid,
  4296. 'asArray' => true
  4297. ) );
  4298. $enclosurHtml = '';
  4299. foreach ( $enclosurList as $value ) {
  4300. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4301. }
  4302. $data ['enclosurHtml'] = $enclosurHtml;
  4303. $data ['rolename'] = $rolename ['name'];
  4304. // $data['datetij']=$tijdate['date'];
  4305. $data ['mothHtml'] = $mothHtml;
  4306. // print_r($receiptList);
  4307. $data ['rid'] = $rid;
  4308. $data ['tijdate'] = $tijdate ['date'];
  4309. $data ['receiptList'] = $receiptList;
  4310. $data ['receiptApprovalCount'] = count ( $receiptList );
  4311. $data ['status'] = $status;
  4312. $data ['year'] = $year;
  4313. $data ['categoryList'] = $categoryList;
  4314. $data ['staffList'] = $staffList;
  4315. $data ['cid'] = $cid;
  4316. $data ['sid'] = $sid;
  4317. $data ['ap'] = $ap;
  4318. $data ['memu'] = "receipt";
  4319. $data ['staff'] = $this->staff;
  4320. $data ['receiptMemu'] = 'approvalExpenses';
  4321. $data ['verifyId'] = $this->verifyId;
  4322. $data ['executeId'] = $this->executeId;
  4323. $this->render ( "/admin/receiptburEdi", $data );
  4324. }
  4325. function hisImplement() {
  4326. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4327. if (empty ( $item ))
  4328. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4329. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4330. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  4331. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  4332. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  4333. Doo::loadModel ( 'receipt' );
  4334. $receipt = new receipt ();
  4335. Doo::loadModel ( 'L_category' );
  4336. $Lcategory = new L_category ();
  4337. Doo::loadModel ( 'verify' );
  4338. Doo::loadModel ( 'statistics' );
  4339. $statistics = new statistics ();
  4340. $verify = new verify ();
  4341. Doo::loadModel ( 'staff' );
  4342. $staff = new staff ();
  4343. Doo::loadClass ( 'XDeode' );
  4344. $XDeode = new XDeode ( 5 );
  4345. $condition = "";
  4346. if ($item == "expenses")
  4347. $condition = " and Rtype=1 ";
  4348. elseif ($item == "receipts")
  4349. $condition = " and Rtype=0 ";
  4350. elseif ($item == "remits")
  4351. $condition = " and Rtype=2 ";
  4352. $sopString = "";
  4353. $dateCondition = " and Year(date) =" . $year;
  4354. if ($sop != 'SOP')
  4355. $sopString = " and staff=" . $sop;
  4356. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  4357. if ($item == 'teipts') {
  4358. $statusCon = '(status=1 or status=6 )';
  4359. $dateCondition = " and Year(pastDate) =" . $year;
  4360. if ($moth != 'MONTH')
  4361. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth;
  4362. if ($day != 'DAY')
  4363. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth . " and day(pastDate)=" . $day;
  4364. } elseif ($item == 'alerpts') {
  4365. $statusCon = '(status=8 or status=9 )';
  4366. $dateCondition = " and Year(executeDate) =" . $year;
  4367. if ($moth != 'MONTH')
  4368. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  4369. if ($day != 'DAY')
  4370. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  4371. }
  4372. // $noPassSum=$receipt->receiptByYear($year,$this->staff[0]['sid']); and (status=1 or status=6)
  4373. $receiptList = $receipt->find ( array (
  4374. 'where' => $statusCon . $condition . $dateCondition . $sopString,
  4375. 'desc' => 'rid',
  4376. 'asArray' => true
  4377. ) );
  4378. // 员工筛选
  4379. $receiptList2 = $receipt->find ( array (
  4380. 'where' => $statusCon . $condition . $dateCondition,
  4381. 'desc' => 'rid',
  4382. 'asArray' => true
  4383. ) );
  4384. $sopStaff = array ();
  4385. foreach ( $receiptList2 as $key => $value ) {
  4386. $staffDetail = $staff->getOne ( array (
  4387. 'where' => 'sid=' . $value ['staff'],
  4388. 'asArray' => true
  4389. ) );
  4390. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  4391. }
  4392. $Locate = 0;
  4393. $roleId = 0;
  4394. $button = 0;
  4395. foreach ( $receiptList as $key => $value ) {
  4396. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4397. $receiptList [$key] ['Texe'] = 'false';
  4398. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  4399. $receiptList [$key] ['Texe'] = 'true';
  4400. }
  4401. $receiptList [$key] ['TRexe'] = 'true';
  4402. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  4403. $receiptList [$key] ['TRexe'] = 'false';
  4404. }
  4405. $receiptList [$key] ['Locate'] = $Locate;
  4406. $Locate ++;
  4407. $receiptList [$key] ['reviseDetail'] = array ();
  4408. if (! empty ( $value ['reviseDetail'] ))
  4409. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4410. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4411. $categoryDetil = $Lcategory->getOne ( array (
  4412. 'where' => 'cid=' . $value ['cid'],
  4413. 'asArray' => true
  4414. ) );
  4415. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4416. // 检测编辑状态
  4417. $verifyList = $verify->getOne ( array (
  4418. 'where' => 'vid=' . $value ['verify'],
  4419. 'asArray' => true
  4420. ) );
  4421. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4422. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4423. Doo::loadModel ( 'role' );
  4424. $role = new role ();
  4425. $flag = true;
  4426. $roleKey = 0;
  4427. $endStaffArray = array ();
  4428. $roleArrayCopy = array ();
  4429. foreach ( $verifyList as $k => $v ) {
  4430. // init verifyStaff
  4431. if ($v [1] == 'ROLE') {
  4432. if (! empty ( $verifyStaff )) {
  4433. $endStaffArray = end ( $verifyStaff );
  4434. }
  4435. $roleVerify = json_decode ( $v [3], true );
  4436. $roleKey = $k;
  4437. $roleArray = array ();
  4438. $rolename = $role->getOne ( array (
  4439. 'where' => 'rid=' . $v [0],
  4440. 'asArray' => true
  4441. ) );
  4442. foreach ( $roleVerify as $o => $p ) {
  4443. $staffID = explode ( '_', $p );
  4444. $staffInfo = $staff->getOne ( array (
  4445. 'where' => 'sid=' . $staffID [0],
  4446. 'asArray' => true
  4447. ) );
  4448. $exp = array (
  4449. 0 => $staffInfo ['sid'],
  4450. 1 => $staffID [1],
  4451. 2 => $staffInfo ['avatar'],
  4452. 'date' => '',
  4453. 'date' => '',
  4454. 'opinion' => '',
  4455. 'status' => '',
  4456. 'rolename' => $rolename ['name']
  4457. );
  4458. array_push ( $roleArray, $exp );
  4459. }
  4460. $roleArrayCopy [$v [0]] = $roleArray;
  4461. }
  4462. $verifyList [$k] ['date'] = "";
  4463. $verifyList [$k] ['opinion'] = "";
  4464. $verifyList [$k] ['status'] = "";
  4465. if (empty ( $verifyStaff )) {
  4466. $verifyList [$k] ['date'] = "";
  4467. $verifyList [$k] ['opinion'] = "";
  4468. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4469. $verifyList [$k] ['status'] = 4;
  4470. $flag = false;
  4471. }
  4472. } else {
  4473. foreach ( $verifyStaff as $m => $u ) {
  4474. if ($v [0] == $m) {
  4475. $verifyList [$k] ['date'] = $u ['date'];
  4476. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4477. $verifyList [$k] ['status'] = $u ['status'];
  4478. $flag = false;
  4479. break;
  4480. }
  4481. }
  4482. $endStaffArray = end ( $verifyStaff );
  4483. }
  4484. }
  4485. $rolename ['name'] = '';
  4486. if (! empty ( $roleId )) {
  4487. Doo::loadModel ( 'role' );
  4488. $role = new role ();
  4489. $rolename = $role->getOne ( array (
  4490. 'where' => 'rid=' . $roleId,
  4491. 'asArray' => true
  4492. ) );
  4493. }
  4494. if (! empty ( $verifyStaff ))
  4495. $endStaffArray = end ( $verifyStaff );
  4496. $KOP = false;
  4497. foreach ( $roleArrayCopy as $P => $A ) {
  4498. foreach ( $A as $MKI => $AVL ) {
  4499. if (! empty ( $verifyStaff )) {
  4500. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4501. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4502. $button = 4;
  4503. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4504. }
  4505. foreach ( $verifyStaff as $m => $u ) {
  4506. $AVLFK = $AVL [0] . '_R';
  4507. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4508. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4509. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4510. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4511. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4512. break;
  4513. }
  4514. }
  4515. } else {
  4516. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4517. $button = 4;
  4518. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4519. }
  4520. }
  4521. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4522. $KOP = true;
  4523. }
  4524. }
  4525. foreach ( $roleArrayCopy as $k => $v ) {
  4526. foreach ( $verifyList as $m => $n ) {
  4527. if ($n [0] == $k) {
  4528. array_splice ( $verifyList, $m, 1, $v );
  4529. }
  4530. }
  4531. }
  4532. $receiptList [$key] ['verifyList'] = $verifyList;
  4533. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4534. 'where' => 'sid=' . $value ['staff'],
  4535. 'asArray' => true
  4536. ) );
  4537. $receiptList [$key] ['button'] = $button;
  4538. }
  4539. // print_r($receiptList);
  4540. $mothHtml = "";
  4541. for($i = 1; $i <= 12; $i ++) {
  4542. if ($moth == $i)
  4543. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4544. else
  4545. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4546. }
  4547. $dayHtml = "";
  4548. if ($day != "DAY" || $moth != "MONTH") {
  4549. for($i = 1; $i <= 31; $i ++) {
  4550. if ($day == $i)
  4551. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  4552. else
  4553. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  4554. }
  4555. }
  4556. $sopHtml = "";
  4557. foreach ( $sopStaff as $key => $value ) {
  4558. if ($sop == $key)
  4559. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4560. else
  4561. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4562. }
  4563. $data ['sopHtml'] = $sopHtml;
  4564. $data ['dayHtml'] = $dayHtml;
  4565. $data ['mothHtml'] = $mothHtml;
  4566. $data ['receiptList'] = $receiptList;
  4567. $data ['memu'] = "receipt";
  4568. $data ['staff'] = $this->staff;
  4569. $data ['receiptMemu'] = 'implement';
  4570. $data ['verifyId'] = $this->verifyId;
  4571. $data ['executeId'] = $this->executeId;
  4572. $data ['item'] = $item;
  4573. $data ['year'] = $year;
  4574. $data ['moth'] = $moth;
  4575. $data ['day'] = $day;
  4576. $data ['sop'] = $sop;
  4577. $this->render ( "/admin/hisImplement", $data );
  4578. }
  4579. function ajaxExamine() {
  4580. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4581. Doo::loadModel ( 'receipt' );
  4582. $receipt = new receipt ();
  4583. if (! empty ( $rid )) {
  4584. $rLRes = $receipt->find ( array (
  4585. '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,
  4586. 'asArray' => true
  4587. ) );
  4588. echo json_encode ( array (
  4589. 'status' => 1,
  4590. 'receipt' => $rLRes [0]
  4591. ) );
  4592. die ();
  4593. }
  4594. echo json_encode ( array (
  4595. 'status' => 0,
  4596. 'receipt' => array ()
  4597. ) );
  4598. die ();
  4599. }
  4600. /*
  4601. * 废弃
  4602. */
  4603. function myReceipt() {
  4604. // all approval past withdraw
  4605. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4606. if (empty ( $item ))
  4607. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4608. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4609. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  4610. Doo::loadModel ( 'receipt' );
  4611. $receipt = new receipt ();
  4612. // pre-loaded
  4613. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4614. // have cache
  4615. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  4616. if (! empty ( $moth )) // yearPage
  4617. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  4618. $this->showCache ( $path );
  4619. }
  4620. Doo::loadModel ( 'L_category' );
  4621. $Lcategory = new L_category ();
  4622. Doo::loadModel ( 'verify' );
  4623. Doo::loadModel ( 'statistics' );
  4624. $statistics = new statistics ();
  4625. $verify = new verify ();
  4626. Doo::loadModel ( 'staff' );
  4627. $staff = new staff ();
  4628. $condition = " and status!=0 ";
  4629. if ($item == "approval")
  4630. $condition = " and status=2 ";
  4631. elseif ($item == "withdraw")
  4632. $condition = " and status=3 ";
  4633. elseif ($item == "past")
  4634. $condition = " and status=1 ";
  4635. elseif ($item == "whdw")
  4636. $condition = " and status=4 ";
  4637. $dateCondition = " and Year(date) =" . $year;
  4638. if (! empty ( $moth )) {
  4639. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  4640. $stList = $statistics->getOne ( array (
  4641. 'select' => 'rePrice ,agPrice',
  4642. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  4643. 'asArray' => true
  4644. ) );
  4645. } else
  4646. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  4647. if (empty ( $stList ))
  4648. $stList = array (
  4649. 'rePrice' => 0,
  4650. 'agPrice' => 0
  4651. );
  4652. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  4653. $data ['stList'] = array (
  4654. 'rePrice' => $stList ['rePrice'],
  4655. 'agPrice' => $stList ['agPrice'],
  4656. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  4657. );
  4658. $receiptList = $receipt->find ( array (
  4659. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  4660. 'desc' => 'rid',
  4661. 'asArray' => true
  4662. ) );
  4663. $Locate = 0;
  4664. $roleId = 0;
  4665. $button = 0;
  4666. foreach ( $receiptList as $key => $value ) {
  4667. $receiptList [$key] ['Locate'] = $Locate;
  4668. $Locate ++;
  4669. $receiptList [$key] ['reviseDetail'] = array ();
  4670. if (! empty ( $value ['reviseDetail'] ))
  4671. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4672. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4673. $categoryDetil = $Lcategory->getOne ( array (
  4674. 'where' => 'cid=' . $value ['cid'],
  4675. 'asArray' => true
  4676. ) );
  4677. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4678. // 检测编辑状态
  4679. $verifyList = $verify->getOne ( array (
  4680. 'where' => 'vid=' . $value ['verify'],
  4681. 'asArray' => true
  4682. ) );
  4683. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4684. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4685. Doo::loadModel ( 'role' );
  4686. $role = new role ();
  4687. $flag = true;
  4688. $roleKey = 0;
  4689. $endStaffArray = array ();
  4690. $roleArrayCopy = array ();
  4691. foreach ( $verifyList as $k => $v ) {
  4692. // init verifyStaff
  4693. if ($v [1] == 'ROLE') {
  4694. if (! empty ( $verifyStaff )) {
  4695. $endStaffArray = end ( $verifyStaff );
  4696. // if ($v[0]==$endStaffArray['nextStaff']){
  4697. // $roleId=$v[0];
  4698. // }
  4699. }
  4700. $roleVerify = json_decode ( $v [3], true );
  4701. $roleKey = $k;
  4702. $roleArray = array ();
  4703. $rolename = $role->getOne ( array (
  4704. 'where' => 'rid=' . $v [0],
  4705. 'asArray' => true
  4706. ) );
  4707. foreach ( $roleVerify as $o => $p ) {
  4708. $staffID = explode ( '_', $p );
  4709. $staffInfo = $staff->getOne ( array (
  4710. 'where' => 'sid=' . $staffID [0],
  4711. 'asArray' => true
  4712. ) );
  4713. // print_r($staffID);
  4714. $exp = array (
  4715. 0 => $staffInfo ['sid'],
  4716. 1 => $staffID [1],
  4717. 2 => $staffInfo ['avatar'],
  4718. 'date' => '',
  4719. 'date' => '',
  4720. 'opinion' => '',
  4721. 'status' => '',
  4722. 'rolename' => $rolename ['name']
  4723. );
  4724. array_push ( $roleArray, $exp );
  4725. }
  4726. $roleArrayCopy [$v [0]] = $roleArray;
  4727. // $verifyList[$k]['roleArray']=$roleArray;
  4728. }
  4729. $verifyList [$k] ['date'] = "";
  4730. $verifyList [$k] ['opinion'] = "";
  4731. $verifyList [$k] ['status'] = "";
  4732. if (empty ( $verifyStaff )) {
  4733. $verifyList [$k] ['date'] = "";
  4734. $verifyList [$k] ['opinion'] = "";
  4735. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4736. $verifyList [$k] ['status'] = 4;
  4737. $flag = false;
  4738. }
  4739. } else {
  4740. foreach ( $verifyStaff as $m => $u ) {
  4741. if ($v [0] == $m) {
  4742. $verifyList [$k] ['date'] = $u ['date'];
  4743. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4744. $verifyList [$k] ['status'] = $u ['status'];
  4745. $flag = false;
  4746. break;
  4747. }
  4748. }
  4749. $endStaffArray = end ( $verifyStaff );
  4750. if (isset ( $endStaffArray ['ROLE'] )) {
  4751. } else {
  4752. // $endKey=key($verifyStaff);
  4753. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4754. // $button=4;
  4755. // $verifyList[$k]['status']=4;
  4756. // }
  4757. }
  4758. }
  4759. }
  4760. $rolename ['name'] = '';
  4761. if (! empty ( $roleId )) {
  4762. Doo::loadModel ( 'role' );
  4763. $role = new role ();
  4764. $rolename = $role->getOne ( array (
  4765. 'where' => 'rid=' . $roleId,
  4766. 'asArray' => true
  4767. ) );
  4768. }
  4769. if (! empty ( $verifyStaff ))
  4770. $endStaffArray = end ( $verifyStaff );
  4771. $KOP = false;
  4772. foreach ( $roleArrayCopy as $P => $A ) {
  4773. foreach ( $A as $MKI => $AVL ) {
  4774. if (! empty ( $verifyStaff )) {
  4775. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4776. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4777. $button = 4;
  4778. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4779. }
  4780. foreach ( $verifyStaff as $m => $u ) {
  4781. $AVLFK = $AVL [0] . '_R';
  4782. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4783. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4784. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4785. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4786. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4787. break;
  4788. }
  4789. }
  4790. } else {
  4791. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4792. $button = 4;
  4793. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4794. }
  4795. }
  4796. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4797. $KOP = true;
  4798. }
  4799. }
  4800. foreach ( $roleArrayCopy as $k => $v ) {
  4801. foreach ( $verifyList as $m => $n ) {
  4802. if ($n [0] == $k) {
  4803. array_splice ( $verifyList, $m, 1, $v );
  4804. }
  4805. }
  4806. }
  4807. $receiptList [$key] ['verifyList'] = $verifyList;
  4808. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4809. 'where' => 'sid=' . $value ['staff'],
  4810. 'asArray' => true
  4811. ) );
  4812. $receiptList [$key] ['button'] = $button;
  4813. }
  4814. // print_r($receiptList);die;
  4815. $mothHtml = "";
  4816. for($i = 1; $i <= 12; $i ++) {
  4817. if ($moth == $i)
  4818. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4819. else
  4820. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4821. }
  4822. $data ['mothHtml'] = $mothHtml;
  4823. $data ['receiptList'] = $receiptList;
  4824. $data ['memu'] = "receipt";
  4825. $data ['staff'] = $this->staff;
  4826. $data ['receiptMemu'] = 'receipt';
  4827. $data ['verifyId'] = $this->verifyId;
  4828. $data ['executeId'] = $this->executeId;
  4829. $data ['item'] = $item;
  4830. $data ['year'] = $year;
  4831. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4832. // sufficient condition to generate cache
  4833. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  4834. $receiptList = $receipt->find ( array (
  4835. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  4836. 'asArray' => true
  4837. ) );
  4838. if (empty ( $receiptList )) { // generated files
  4839. ob_start ();
  4840. $this->render ( "/admin/saea_myList", $data );
  4841. $this->cacheFile ( $path );
  4842. die ();
  4843. // $content = ob_get_contents();
  4844. // $fp = fopen($path, "w");
  4845. // fwrite($fp, $content);
  4846. // fclose($fp);
  4847. }
  4848. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  4849. $receiptList = $receipt->find ( array (
  4850. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  4851. 'asArray' => true
  4852. ) );
  4853. if (empty ( $receiptList )) { // generated files
  4854. ob_start ();
  4855. $this->render ( "/admin/saea_myList", $data );
  4856. $this->cacheFile ( $path );
  4857. die ();
  4858. }
  4859. }
  4860. }
  4861. $this->render ( "/admin/saea_myList", $data );
  4862. }
  4863. function saeaCreate() {
  4864. Doo::loadModel ( 'accountItem' );
  4865. Doo::loadModel ( 'verify' );
  4866. Doo::loadModel ( 'receipt' );
  4867. Doo::loadModel ( 'L_category' );
  4868. $lCategory = new L_category ();
  4869. $receipt = new receipt ();
  4870. $verify = new verify ();
  4871. $accountItem = new accountItem ();
  4872. Doo::loadModel ( "role" );
  4873. $role = new role ();
  4874. $acItem = $accountItem->find ( array (
  4875. 'asArray' => true
  4876. ) );
  4877. $veList = $verify->find ( array (
  4878. 'asArray' => true
  4879. ) );
  4880. foreach ( $veList as $key => $value ) {
  4881. $v = json_decode ( $value ['staff'] );
  4882. $list = array ();
  4883. foreach ( $v as $n => $m ) {
  4884. if ($m ['1'] == 'ROLE') {
  4885. $roleInfo = $role->getOne ( array (
  4886. 'where' => 'rid=' . $m [0],
  4887. 'asArray' => true
  4888. ) );
  4889. $v [$n] [1] = $roleInfo ['name'];
  4890. array_push ( $list, $roleInfo ['name'] );
  4891. } else {
  4892. array_push ( $list, $v [$n] [1] );
  4893. }
  4894. }
  4895. $veList [$key] ['staff'] = implode ( '>', $list );
  4896. }
  4897. $data ['category'] = $lCategory->find ( array (
  4898. 'asArray' => true
  4899. ) );
  4900. $data ['veList'] = $veList;
  4901. $data ['acItem'] = $acItem;
  4902. $data ['memu'] = "receipt";
  4903. $data ['staff'] = $this->staff;
  4904. $data ['receiptMemu'] = 'saeaBorad';
  4905. $data ['verifyId'] = $this->verifyId;
  4906. $data ['executeId'] = $this->executeId;
  4907. $this->render ( "/admin/saea_create", $data );
  4908. }
  4909. function addReceipt() {
  4910. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  4911. $agency = $this->get_args ( 'agency' );
  4912. $travel = $this->get_args ( 'travel' );
  4913. $train = $this->get_args ( 'train' );
  4914. $other = $this->get_args ( 'other' );
  4915. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  4916. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  4917. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  4918. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  4919. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  4920. Doo::loadModel ( 'receipt' );
  4921. Doo::loadModel ( 'receiptDetail' );
  4922. Doo::loadModel ( 'accountItem' );
  4923. $accountItem = new accountItem ();
  4924. $receipt = new receipt ();
  4925. Doo::loadModel ( 'enclosur' );
  4926. Doo::loadModel ( 'execute' );
  4927. $execute = new execute ();
  4928. $executeDetail = $execute->getOne ( array (
  4929. 'where' => 'mold="报销单执行人"',
  4930. 'asArray' => true
  4931. ) );
  4932. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  4933. // if(!empty($receiptDetail))
  4934. // return "/referReceipt/".$receiptDetail['rid'];
  4935. $aItem = $accountItem->find ( array (
  4936. 'asArray' => true
  4937. ) );
  4938. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  4939. $ag = $tr = $ta = $ot = 0;
  4940. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  4941. foreach ( $aItem as $key => $value ) {
  4942. if ($value ['category'] == $this->AGENCY) {
  4943. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  4944. array_push ( $accountJson [$this->AGENCY], array (
  4945. 'aid' => $value ['aid'],
  4946. 'name' => $value ['name'],
  4947. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  4948. ) );
  4949. $sum += $agency [$ag];
  4950. $agencySum += $agency [$ag];
  4951. }
  4952. $ag ++;
  4953. }
  4954. if ($value ['category'] == $this->TRAVEL) {
  4955. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  4956. array_push ( $accountJson [$this->TRAVEL], array (
  4957. 'aid' => $value ['aid'],
  4958. 'name' => $value ['name'],
  4959. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  4960. ) );
  4961. $sum += $travel [$tr];
  4962. $travelSum += $travel [$tr];
  4963. }
  4964. $tr ++;
  4965. }
  4966. if ($value ['category'] == $this->TRAIN) {
  4967. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  4968. array_push ( $accountJson [$this->TRAIN], array (
  4969. 'aid' => $value ['aid'],
  4970. 'name' => $value ['name'],
  4971. 'price' => number_format ( $train [$ta], 2, '.', '' )
  4972. ) );
  4973. $sum += $train [$ta];
  4974. $trainSum += $train [$ta];
  4975. }
  4976. $ta ++;
  4977. }
  4978. if ($value ['category'] == $this->OTHER) {
  4979. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  4980. array_push ( $accountJson [$this->OTHER], array (
  4981. 'aid' => $value ['aid'],
  4982. 'name' => $value ['name'],
  4983. 'price' => number_format ( $other [$ot], 2, '.', '' )
  4984. ) );
  4985. $sum += $other [$ot];
  4986. $otherSum += $other [$ot];
  4987. }
  4988. $ot ++;
  4989. }
  4990. }
  4991. $accountJson ['cSum'] = array (
  4992. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  4993. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  4994. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  4995. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  4996. );
  4997. // 报销单
  4998. $receipt->accountItem = json_encode ( $accountJson );
  4999. $receipt->staff = $this->staff [0] ['sid'];
  5000. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5001. $receipt->date = date ( "Y-m-d" );
  5002. $receipt->cid = $cid;
  5003. $receipt->status = 5;
  5004. // 修改审批流程加入角色
  5005. $receipt->verify = $verify;
  5006. $receipt->executeCopy = $executeDetail ['staff'];
  5007. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  5008. $receipt->explanation = $explanation;
  5009. $rid = $receipt->insert ();
  5010. // 附件
  5011. if (! empty ( $enclosurName )) {
  5012. $enclosurArray = explode ( '-', $enclosurName );
  5013. foreach ( $enclosurArray as $value ) {
  5014. $enclosur = new enclosur ();
  5015. $enclosur->name = $value;
  5016. $enclosur->rid = $rid;
  5017. $enclosur->insert ();
  5018. }
  5019. // print_r($enclosurArray);die;
  5020. }
  5021. // 报销详情
  5022. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5023. $receiptDetail = new receiptDetail ();
  5024. $receiptDetail->staff = $this->staff [0] ['sid'];
  5025. $receiptDetail->item = $value ['name'];
  5026. $receiptDetail->itemCategory = $this->AGENCY;
  5027. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5028. $receiptDetail->date = date ( "Y-m-d" );
  5029. $receiptDetail->cid = $cid;
  5030. $receiptDetail->rid = $rid;
  5031. $receiptDetail->status = 4;
  5032. $receiptDetail->insert ();
  5033. }
  5034. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5035. $receiptDetail = new receiptDetail ();
  5036. $receiptDetail->staff = $this->staff [0] ['sid'];
  5037. $receiptDetail->item = $value ['name'];
  5038. $receiptDetail->itemCategory = $this->TRAVEL;
  5039. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5040. $receiptDetail->date = date ( "Y-m-d" );
  5041. $receiptDetail->cid = $cid;
  5042. $receiptDetail->rid = $rid;
  5043. $receiptDetail->status = 4;
  5044. $receiptDetail->insert ();
  5045. }
  5046. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5047. $receiptDetail = new receiptDetail ();
  5048. $receiptDetail->staff = $this->staff [0] ['sid'];
  5049. $receiptDetail->item = $value ['name'];
  5050. $receiptDetail->itemCategory = $this->TRAIN;
  5051. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5052. $receiptDetail->date = date ( "Y-m-d" );
  5053. $receiptDetail->cid = $cid;
  5054. $receiptDetail->rid = $rid;
  5055. $receiptDetail->status = 4;
  5056. $receiptDetail->insert ();
  5057. }
  5058. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5059. $receiptDetail = new receiptDetail ();
  5060. $receiptDetail->staff = $this->staff [0] ['sid'];
  5061. $receiptDetail->item = $value ['name'];
  5062. $receiptDetail->itemCategory = $this->OTHER;
  5063. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5064. $receiptDetail->date = date ( "Y-m-d" );
  5065. $receiptDetail->cid = $cid;
  5066. $receiptDetail->rid = $rid;
  5067. $receiptDetail->status = 4;
  5068. $receiptDetail->insert ();
  5069. }
  5070. // return "/referReceipt/".$rid;
  5071. }
  5072. return "/saeaBorad";
  5073. }
  5074. function referReceipt() {
  5075. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  5076. Doo::loadModel ( 'receipt' );
  5077. Doo::loadModel ( 'verify' );
  5078. $verify = new verify ();
  5079. $receipt = new receipt ();
  5080. Doo::loadModel ( 'L_category' );
  5081. $lCategory = new L_category ();
  5082. Doo::loadModel ( "role" );
  5083. $role = new role ();
  5084. $receiptDetail = $receipt->find ( array (
  5085. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  5086. 'asArray' => true
  5087. ) );
  5088. if (empty ( $receiptDetail ))
  5089. return "/addReceipt";
  5090. foreach ( $receiptDetail as $key => $value ) {
  5091. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5092. $veList = $verify->getOne ( array (
  5093. 'where' => 'vid=' . $value ['verify'],
  5094. 'asArray' => true
  5095. ) );
  5096. $v = json_decode ( $veList ['staff'] );
  5097. array_push ( $v [0], $veList ['description'] );
  5098. foreach ( $v as $n => $m ) {
  5099. if ($m ['1'] == 'ROLE') {
  5100. $roleInfo = $role->getOne ( array (
  5101. 'where' => 'rid=' . $m [0],
  5102. 'asArray' => true
  5103. ) );
  5104. $v [$n] [1] = $roleInfo ['name'];
  5105. }
  5106. }
  5107. $receiptDetail [$key] ['staff'] = $v;
  5108. $category = $lCategory->getOne ( array (
  5109. 'where' => 'cid=' . $value ['cid'],
  5110. 'asArray' => true
  5111. ) );
  5112. $receiptDetail [$key] ['category'] = $category ['title'];
  5113. }
  5114. // print_r($receiptDetail);
  5115. $data ['receiptDetail'] = $receiptDetail;
  5116. $data ['memu'] = "receipt";
  5117. $data ['staff'] = $this->staff;
  5118. $data ['receiptMemu'] = 'saeaCreate';
  5119. $data ['verifyId'] = $this->verifyId;
  5120. $data ['executeId'] = $this->executeId;
  5121. $this->render ( "/admin/saea_confirm", $data );
  5122. }
  5123. function editReceipt() {
  5124. // edit status 4
  5125. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5126. // echo $rid;
  5127. Doo::loadModel ( 'accountItem' );
  5128. Doo::loadModel ( 'verify' );
  5129. Doo::loadModel ( 'receipt' );
  5130. $receipt = new receipt ();
  5131. $verify = new verify ();
  5132. $accountItem = new accountItem ();
  5133. Doo::loadModel ( 'L_category' );
  5134. $lCategory = new L_category ();
  5135. Doo::loadModel ( "role" );
  5136. $role = new role ();
  5137. $receiptDetail = $receipt->getOne ( array (
  5138. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  5139. 'asArray' => true
  5140. ) );
  5141. if (empty ( $receiptDetail ))
  5142. return "/saeaCreate";
  5143. $acItem = $accountItem->find ( array (
  5144. 'asArray' => true
  5145. ) );
  5146. $veList = $verify->find ( array (
  5147. 'asArray' => true
  5148. ) );
  5149. foreach ( $veList as $key => $value ) {
  5150. $v = json_decode ( $value ['staff'] );
  5151. $list = array ();
  5152. foreach ( $v as $n => $m ) {
  5153. if ($m ['1'] == 'ROLE') {
  5154. $roleInfo = $role->getOne ( array (
  5155. 'where' => 'rid=' . $m [0],
  5156. 'asArray' => true
  5157. ) );
  5158. $v [$n] [1] = $roleInfo ['name'];
  5159. array_push ( $list, $roleInfo ['name'] );
  5160. } else {
  5161. array_push ( $list, $v [$n] [1] );
  5162. }
  5163. }
  5164. $veList [$key] ['staff'] = implode ( '>', $list );
  5165. }
  5166. // 配置编辑信息
  5167. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  5168. foreach ( $acItem as $key => $value ) {
  5169. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  5170. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  5171. $acItem [$key] ['price'] = $v ['price'];
  5172. }
  5173. }
  5174. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  5175. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  5176. $acItem [$key] ['price'] = $v ['price'];
  5177. }
  5178. }
  5179. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  5180. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  5181. $acItem [$key] ['price'] = $v ['price'];
  5182. }
  5183. }
  5184. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  5185. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  5186. $acItem [$key] ['price'] = $v ['price'];
  5187. }
  5188. }
  5189. }
  5190. $data ['category'] = $lCategory->find ( array (
  5191. 'asArray' => true
  5192. ) );
  5193. $data ['cSum'] = $accountItemList ['cSum'];
  5194. $data ['sum'] = $receiptDetail ['sum'];
  5195. $data ['receiptDetail'] = $receiptDetail;
  5196. $data ['veList'] = $veList;
  5197. $data ['acItem'] = $acItem;
  5198. $data ['memu'] = "receipt";
  5199. $data ['staff'] = $this->staff;
  5200. $data ['receiptMemu'] = 'saeaBorad';
  5201. $data ['verify'] = $receiptDetail ['verify'];
  5202. $data ['verifyId'] = $this->verifyId;
  5203. $data ['executeId'] = $this->executeId;
  5204. $data ['rid'] = $rid;
  5205. $this->render ( "/admin/saea_edit", $data );
  5206. }
  5207. function updateReceipt() {
  5208. $agency = $this->get_args ( 'agency' );
  5209. $travel = $this->get_args ( 'travel' );
  5210. $train = $this->get_args ( 'train' );
  5211. $other = $this->get_args ( 'other' );
  5212. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5213. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5214. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5215. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5216. if (! empty ( $explanation )) {
  5217. Doo::loadModel ( 'receipt' );
  5218. Doo::loadModel ( 'receiptDetail' );
  5219. Doo::loadModel ( 'accountItem' );
  5220. $accountItem = new accountItem ();
  5221. $receipt = new receipt ();
  5222. Doo::loadModel ( 'execute' );
  5223. $execute = new execute ();
  5224. $receiptDetail = $receipt->getOne ( array (
  5225. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  5226. 'asArray' => true
  5227. ) );
  5228. if (empty ( $receiptDetail ))
  5229. return "/saeaBorad";
  5230. if ($receiptDetail ['Rtype'] == 1)
  5231. $executeDetail = $execute->getOne ( array (
  5232. 'where' => 'mold="借款费用执行人"',
  5233. 'asArray' => true
  5234. ) );
  5235. else
  5236. $executeDetail = $execute->getOne ( array (
  5237. 'where' => 'mold="报销单执行人"',
  5238. 'asArray' => true
  5239. ) );
  5240. $aItem = $accountItem->find ( array (
  5241. 'asArray' => true
  5242. ) );
  5243. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5244. $ag = $tr = $ta = $ot = 0;
  5245. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5246. foreach ( $aItem as $key => $value ) {
  5247. if ($value ['category'] == $this->AGENCY) {
  5248. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5249. array_push ( $accountJson [$this->AGENCY], array (
  5250. 'aid' => $value ['aid'],
  5251. 'name' => $value ['name'],
  5252. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5253. ) );
  5254. $sum += $agency [$ag];
  5255. $agencySum += $agency [$ag];
  5256. }
  5257. $ag ++;
  5258. }
  5259. if ($value ['category'] == $this->TRAVEL) {
  5260. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5261. array_push ( $accountJson [$this->TRAVEL], array (
  5262. 'aid' => $value ['aid'],
  5263. 'name' => $value ['name'],
  5264. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5265. ) );
  5266. $sum += $travel [$tr];
  5267. $travelSum += $travel [$tr];
  5268. }
  5269. $tr ++;
  5270. }
  5271. if ($value ['category'] == $this->TRAIN) {
  5272. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5273. array_push ( $accountJson [$this->TRAIN], array (
  5274. 'aid' => $value ['aid'],
  5275. 'name' => $value ['name'],
  5276. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5277. ) );
  5278. $sum += $train [$ta];
  5279. $trainSum += $train [$ta];
  5280. }
  5281. $ta ++;
  5282. }
  5283. if ($value ['category'] == $this->OTHER) {
  5284. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5285. array_push ( $accountJson [$this->OTHER], array (
  5286. 'aid' => $value ['aid'],
  5287. 'name' => $value ['name'],
  5288. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5289. ) );
  5290. $sum += $other [$ot];
  5291. $otherSum += $other [$ot];
  5292. }
  5293. $ot ++;
  5294. }
  5295. }
  5296. $accountJson ['cSum'] = array (
  5297. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5298. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5299. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5300. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5301. );
  5302. // 报销单
  5303. $rid = $receipt->rid = $receiptDetail ['rid'];
  5304. $receipt->accountItem = json_encode ( $accountJson );
  5305. $receipt->staff = $this->staff [0] ['sid'];
  5306. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5307. $receipt->date = date ( "Y-m-d" );
  5308. $receipt->cid = $cid;
  5309. if (($receiptDetail ['status'] != 4)) {
  5310. if ($receiptDetail ['Rtype'] == 1)
  5311. $receipt->status = 7;
  5312. else
  5313. $receipt->status = 5;
  5314. }
  5315. if ($receiptDetail != 4 && ! empty ( $verify ))
  5316. $receipt->verify = $verify;
  5317. $receipt->executeCopy = $executeDetail ['staff'];
  5318. $receipt->explanation = $explanation;
  5319. $receipt->update ();
  5320. $receiptDetail = new receiptDetail ();
  5321. $receiptDetail->delete ( array (
  5322. 'where' => 'rid=' . $rid
  5323. ) );
  5324. // 报销详情
  5325. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5326. $receiptDetail = new receiptDetail ();
  5327. $receiptDetail->staff = $this->staff [0] ['sid'];
  5328. $receiptDetail->item = $value ['name'];
  5329. $receiptDetail->itemCategory = $this->AGENCY;
  5330. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5331. $receiptDetail->date = date ( "Y-m-d" );
  5332. $receiptDetail->cid = $cid;
  5333. $receiptDetail->rid = $rid;
  5334. $receiptDetail->status = 4;
  5335. $receiptDetail->insert ();
  5336. }
  5337. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5338. $receiptDetail = new receiptDetail ();
  5339. $receiptDetail->staff = $this->staff [0] ['sid'];
  5340. $receiptDetail->item = $value ['name'];
  5341. $receiptDetail->itemCategory = $this->TRAVEL;
  5342. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5343. $receiptDetail->date = date ( "Y-m-d" );
  5344. $receiptDetail->cid = $cid;
  5345. $receiptDetail->rid = $rid;
  5346. $receiptDetail->status = 4;
  5347. $receiptDetail->insert ();
  5348. }
  5349. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5350. $receiptDetail = new receiptDetail ();
  5351. $receiptDetail->staff = $this->staff [0] ['sid'];
  5352. $receiptDetail->item = $value ['name'];
  5353. $receiptDetail->itemCategory = $this->TRAIN;
  5354. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5355. $receiptDetail->date = date ( "Y-m-d" );
  5356. $receiptDetail->cid = $cid;
  5357. $receiptDetail->rid = $rid;
  5358. $receiptDetail->status = 4;
  5359. $receiptDetail->insert ();
  5360. }
  5361. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5362. $receiptDetail = new receiptDetail ();
  5363. $receiptDetail->staff = $this->staff [0] ['sid'];
  5364. $receiptDetail->item = $value ['name'];
  5365. $receiptDetail->itemCategory = $this->OTHER;
  5366. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5367. $receiptDetail->date = date ( "Y-m-d" );
  5368. $receiptDetail->cid = $cid;
  5369. $receiptDetail->rid = $rid;
  5370. $receiptDetail->status = 4;
  5371. $receiptDetail->insert ();
  5372. }
  5373. // return "/referReceipt/".$rid;
  5374. }
  5375. return "/saeaBorad";
  5376. }
  5377. function approvedReceipt() {
  5378. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5379. Doo::loadModel ( 'receipt' );
  5380. Doo::loadModel ( 'receiptDetail' );
  5381. $receipt = new receipt ();
  5382. $receiptDetail = new receiptDetail ();
  5383. Doo::loadModel ( 'statistics' );
  5384. Doo::loadModel ( 'itemStatistics' );
  5385. $statistics = new statistics ();
  5386. $itemStatistics = new itemStatistics ();
  5387. Doo::loadModel ( "verify" );
  5388. $verify = new verify ();
  5389. // 审批状态的判定
  5390. $receiptDetailList = $receipt->getOne ( array (
  5391. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  5392. 'asArray' => true
  5393. ) );
  5394. if (empty ( $receiptDetailList ))
  5395. return "/saeaBorad";
  5396. $verifyDetail = $verify->getOne ( array (
  5397. 'where' => ' vid =' . $receiptDetailList ['verify'],
  5398. 'asArray' => true
  5399. ) );
  5400. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5401. if (empty ( $receiptDetailList ['nowStaff'] )) {
  5402. $nowStaff = "";
  5403. $nowStaffList = array ();
  5404. if ($verifyDetail [0] [1] == 'ROLE') {
  5405. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5406. foreach ( $vStaffString as $key => $value ) {
  5407. $staffK = explode ( "_", $value );
  5408. array_push ( $nowStaffList, $staffK [0] );
  5409. }
  5410. $nowStaff = implode ( ',', $nowStaffList );
  5411. } else {
  5412. $nowStaff = $verifyDetail [0] [0];
  5413. }
  5414. $receipt->nowStaff = $nowStaff;
  5415. }
  5416. // echo $nowStaff;
  5417. // print_r($verifyDetail);die;
  5418. $receipt->rid = $receiptDetailList ['rid'];
  5419. $receipt->date = date ( "Y-m-d" );
  5420. $receipt->status = 2;
  5421. $receipt->update ();
  5422. $receiptDetail->status = 2;
  5423. $receiptDetail->update ( array (
  5424. 'where' => 'rid=' . $receiptDetailList ['rid']
  5425. ) );
  5426. Doo::loadModel ( "receiptLog" );
  5427. $receiptLog = new receiptLog ();
  5428. Doo::loadModel ( "verify" );
  5429. $verify = new verify ();
  5430. $receiptInfo = $receipt->getOne ( array (
  5431. 'where' => 'rid=' . $rid,
  5432. 'asArray' => true
  5433. ) );
  5434. $vr = $verify->getOne ( array (
  5435. 'where' => 'vid=' . $receiptInfo ['verify'],
  5436. 'asArray' => true
  5437. ) );
  5438. $jd = json_decode ( $vr ['staff'] );
  5439. $roleId = 0;
  5440. foreach ( $jd as $key => $value ) {
  5441. if ($value [1] == 'ROLE') {
  5442. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  5443. if ($pos !== false) {
  5444. $roleId = $value [0];
  5445. }
  5446. }
  5447. }
  5448. // 审批日志
  5449. // echo $roleId;die;
  5450. if (! empty ( $roleId )) {
  5451. Doo::loadModel ( "role" );
  5452. $role = new role ();
  5453. $roleInfo = $role->getOne ( array (
  5454. 'where' => 'rid=' . $roleId,
  5455. 'asArray' => true
  5456. ) );
  5457. $receiptLog->rolename = $roleInfo ['name'];
  5458. }
  5459. $receiptLog->username = $this->staff [0] ['username'];
  5460. $receiptLog->uid = $this->staff [0] ['sid'];
  5461. $receiptLog->date = date ( "Y-m-d" );
  5462. $receiptLog->opinion = '提交审批';
  5463. $receiptLog->img = $this->staff [0] ['avatar'];
  5464. $receiptLog->status = 2;
  5465. $receiptLog->rid = $rid;
  5466. $receiptLog->insert ();
  5467. // statistics item
  5468. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  5469. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  5470. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  5471. // print_r($accountItem['cSum']['agencySum']);die;
  5472. // foreach ($accountItem['cSum'] as $key=>$value){
  5473. // if($key=="agencySum"){
  5474. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->AGENCY.'"'.$dateCondition,'asArray'=>true));
  5475. // if(empty($iStatistics)){
  5476. // $itemStatistics->cid=$this->staff[0]['cid'];
  5477. // $itemStatistics->staff=$this->staff[0]['sid'];
  5478. // $itemStatistics->price=$value;
  5479. // $itemStatistics->itemCategory=$this->AGENCY;
  5480. // $itemStatistics->date=date("Y-m-d");
  5481. // $itemStatistics->insert();
  5482. // }else{
  5483. // if (!empty($value)){
  5484. // $itemStatistics->price=$value+$iStatistics['price'];
  5485. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5486. // }
  5487. // }
  5488. // }elseif($key=="travelSum"){
  5489. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->TRAVEL.'"'.$dateCondition,'asArray'=>true));
  5490. // if(empty($iStatistics)){
  5491. // $itemStatistics->cid=$this->staff[0]['cid'];
  5492. // $itemStatistics->staff=$this->staff[0]['sid'];
  5493. // $itemStatistics->price=$value;
  5494. // $itemStatistics->itemCategory=$this->TRAVEL;
  5495. // $itemStatistics->date=date("Y-m-d");
  5496. // $itemStatistics->insert();
  5497. // }else{
  5498. // if (!empty($value)){
  5499. // $itemStatistics->price=$value+$iStatistics['price'];
  5500. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5501. // }
  5502. // }
  5503. // }elseif($key=="trainSum"){
  5504. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->TRAIN.'"'.$dateCondition,'asArray'=>true));
  5505. // if(empty($iStatistics)){
  5506. // $itemStatistics->cid=$this->staff[0]['cid'];
  5507. // $itemStatistics->staff=$this->staff[0]['sid'];
  5508. // $itemStatistics->price=$value;
  5509. // $itemStatistics->itemCategory=$this->TRAIN;
  5510. // $itemStatistics->date=date("Y-m-d");
  5511. // $itemStatistics->insert();
  5512. // }else{
  5513. // if (!empty($value)){
  5514. // $itemStatistics->price=$value+$iStatistics['price'];
  5515. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5516. // }
  5517. // }
  5518. // }elseif($key=="otherSum"){
  5519. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->OTHER.'"'.$dateCondition,'asArray'=>true));
  5520. // if(empty($iStatistics)){
  5521. // $itemStatistics->cid=$this->staff[0]['cid'];
  5522. // $itemStatistics->staff=$this->staff[0]['sid'];
  5523. // $itemStatistics->price=$value;
  5524. // $itemStatistics->itemCategory=$this->OTHER;
  5525. // $itemStatistics->date=date("Y-m-d");
  5526. // $itemStatistics->insert();
  5527. // }else{
  5528. // if (!empty($value)){
  5529. // $itemStatistics->price=$value+$iStatistics['price'];
  5530. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5531. // }
  5532. // }
  5533. // }
  5534. // }
  5535. $stat = $statistics->getOne ( array (
  5536. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5537. 'asArray' => true
  5538. ) );
  5539. if (empty ( $stat )) {
  5540. $statistics->date = date ( "Y-m-d" );
  5541. $statistics->cid = $this->staff [0] ['cid'];
  5542. $statistics->staff = $this->staff [0] ['sid'];
  5543. $statistics->agPrice = 0;
  5544. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5545. $statistics->insert ();
  5546. } else {
  5547. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5548. $statistics->update ( array (
  5549. 'where' => 'sid=' . $stat ['sid']
  5550. ) );
  5551. }
  5552. return "/expenses";
  5553. }
  5554. function approval() {
  5555. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5556. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5557. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5558. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5559. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5560. if (empty ( $status ))
  5561. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5562. $vidList = array ();
  5563. $button = 0;
  5564. Doo::loadModel ( 'verify' );
  5565. $verify = new verify ();
  5566. Doo::loadModel ( 'receipt' );
  5567. $receipt = new receipt ();
  5568. Doo::loadModel ( 'staff' );
  5569. $staff = new staff ();
  5570. Doo::loadModel ( 'L_category' );
  5571. $Lcategory = new L_category ();
  5572. // user verify ID
  5573. $verifyDetail = $verify->find ( array (
  5574. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5575. 'asArray' => true
  5576. ) );
  5577. foreach ( $verifyDetail as $key => $value ) {
  5578. array_push ( $vidList, $value ['vid'] );
  5579. }
  5580. $vid = implode ( ",", $vidList );
  5581. if (empty ( $verifyDetail ))
  5582. $vid = 0;
  5583. /*
  5584. */
  5585. $dateCondition = " and Year(date) =" . $year;
  5586. if (! empty ( $month ))
  5587. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  5588. $categoryList = $Lcategory->find ( array (
  5589. 'asArray' => true
  5590. ) );
  5591. $staffList = $staff->find ( array (
  5592. 'where' => 'cid=' . $cid,
  5593. 'asArray' => true
  5594. ) );
  5595. $cateCondition = "";
  5596. $staffCondition = "";
  5597. $approvalCondition = "";
  5598. if (! empty ( $cid ))
  5599. $cateCondition = ' and cid=' . $cid;
  5600. if (! empty ( $sid )) {
  5601. $staffCondition = ' and staff=' . $sid;
  5602. $cateCondition = "";
  5603. }
  5604. // elseif($status==1){
  5605. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  5606. // }
  5607. if ($status == 2) {
  5608. // 查找角色审批人
  5609. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  5610. }
  5611. $ap = "";
  5612. if ($status == 4) {
  5613. $ap = 4;
  5614. $status = 2;
  5615. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  5616. }
  5617. if ($status == 5) {
  5618. $status = 4;
  5619. $ap = 5;
  5620. }
  5621. // echo $vid;
  5622. // get Receipt By verifyID status 2 .$approvalCondition
  5623. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  5624. $receiptList = $receipt->find ( array (
  5625. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  5626. 'desc' => 'rid',
  5627. 'asArray' => true
  5628. ) );
  5629. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  5630. $Locate = 0;
  5631. if ($ap == 4)
  5632. $status = 4;
  5633. elseif ($ap == 5)
  5634. $status = 5;
  5635. foreach ( $receiptList as $key => $value ) {
  5636. $receiptList [$key] ['Locate'] = $Locate;
  5637. $Locate ++;
  5638. $receiptList [$key] ['reviseDetail'] = array ();
  5639. if (! empty ( $value ['reviseDetail'] ))
  5640. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5641. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5642. $categoryDetil = $Lcategory->getOne ( array (
  5643. 'where' => 'cid=' . $value ['cid'],
  5644. 'asArray' => true
  5645. ) );
  5646. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5647. $verifyList = $verify->getOne ( array (
  5648. 'where' => 'vid=' . $value ['verify'],
  5649. 'asArray' => true
  5650. ) );
  5651. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5652. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5653. foreach ( $verifyList as $k => $v ) {
  5654. // init verifyStaff
  5655. $verifyList [$k] ['date'] = "";
  5656. $verifyList [$k] ['opinion'] = "";
  5657. $verifyList [$k] ['status'] = "";
  5658. if (empty ( $verifyStaff )) {
  5659. $verifyList [$k] ['date'] = "";
  5660. $verifyList [$k] ['opinion'] = "";
  5661. if ($v [0] == $this->staff [0] ['sid']) {
  5662. $verifyList [$k] ['status'] = 4;
  5663. $button = 4;
  5664. }
  5665. } else {
  5666. $flag = true;
  5667. foreach ( $verifyStaff as $m => $u ) {
  5668. if ($v [0] == $m) {
  5669. $verifyList [$k] ['date'] = $u ['date'];
  5670. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5671. $verifyList [$k] ['status'] = $u ['status'];
  5672. $flag = false;
  5673. break;
  5674. }
  5675. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  5676. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  5677. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  5678. }
  5679. if ($flag) { // 检测可编辑
  5680. if ($v [0] == $this->staff [0] ['sid']) {
  5681. $verifyList [$k] ['status'] = 4;
  5682. $button = 4;
  5683. }
  5684. }
  5685. }
  5686. }
  5687. $receiptList [$key] ['verifyList'] = $verifyList;
  5688. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5689. 'where' => 'sid=' . $value ['staff'],
  5690. 'asArray' => true
  5691. ) );
  5692. $receiptList [$key] ['button'] = $button;
  5693. }
  5694. // print_r($receiptList);die;
  5695. // $data['verifyDetail']=$verifyDetail;
  5696. $mothHtml = "";
  5697. for($i = 1; $i <= 12; $i ++) {
  5698. if ($month == $i)
  5699. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5700. else
  5701. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5702. }
  5703. $data ['mothHtml'] = $mothHtml;
  5704. $data ['receiptList'] = $receiptList;
  5705. $data ['receiptApprovalCount'] = count ( $receiptList );
  5706. $data ['status'] = $status;
  5707. $data ['year'] = $year;
  5708. $data ['categoryList'] = $categoryList;
  5709. $data ['staffList'] = $staffList;
  5710. $data ['cid'] = $cid;
  5711. $data ['sid'] = $sid;
  5712. $data ['ap'] = $ap;
  5713. $data ['memu'] = "receipt";
  5714. $data ['staff'] = $this->staff;
  5715. $data ['receiptMemu'] = 'approval';
  5716. $data ['verifyId'] = $this->verifyId;
  5717. $data ['executeId'] = $this->executeId;
  5718. $this->render ( "/admin/saea_reportList", $data );
  5719. }
  5720. function approvalDetails() {
  5721. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5722. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5723. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5724. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5725. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5726. Doo::loadModel ( 'verify' );
  5727. $verify = new verify ();
  5728. Doo::loadModel ( 'receipt' );
  5729. $receipt = new receipt ();
  5730. Doo::loadModel ( 'staff' );
  5731. $staff = new staff ();
  5732. Doo::loadModel ( 'L_category' );
  5733. $Lcategory = new L_category ();
  5734. Doo::loadModel ( 'enclosur' );
  5735. $enclosur = new enclosur ();
  5736. $vidList = array ();
  5737. $verifyDetail = $verify->find ( array (
  5738. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5739. 'asArray' => true
  5740. ) );
  5741. foreach ( $verifyDetail as $key => $value ) {
  5742. array_push ( $vidList, $value ['vid'] );
  5743. }
  5744. $vid = implode ( ",", $vidList );
  5745. if (empty ( $verifyDetail ))
  5746. $vid = 0;
  5747. $categoryList = $Lcategory->find ( array (
  5748. 'asArray' => true
  5749. ) );
  5750. $staffList = $staff->find ( array (
  5751. 'where' => 'cid=' . $cid,
  5752. 'asArray' => true
  5753. ) );
  5754. $ap = 0;
  5755. $receiptList = $receipt->find ( array (
  5756. 'where' => 'rid =' . $rid,
  5757. 'desc' => 'rid',
  5758. 'asArray' => true
  5759. ) );
  5760. $Locate = 0;
  5761. $roleId = 0;
  5762. $button = 0;
  5763. foreach ( $receiptList as $key => $value ) {
  5764. $receiptList [$key] ['Locate'] = $Locate;
  5765. $Locate ++;
  5766. $receiptList [$key] ['reviseDetail'] = array ();
  5767. if (! empty ( $value ['reviseDetail'] ))
  5768. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5769. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5770. $categoryDetil = $Lcategory->getOne ( array (
  5771. 'where' => 'cid=' . $value ['cid'],
  5772. 'asArray' => true
  5773. ) );
  5774. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5775. // 检测编辑状态
  5776. $verifyList = $verify->getOne ( array (
  5777. 'where' => 'vid=' . $value ['verify'],
  5778. 'asArray' => true
  5779. ) );
  5780. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5781. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5782. Doo::loadModel ( 'role' );
  5783. $role = new role ();
  5784. // print_r($verifyList);
  5785. $flag = true;
  5786. $roleKey = 0;
  5787. $endStaffArray = array ();
  5788. $roleArrayCopy = array ();
  5789. foreach ( $verifyList as $k => $v ) {
  5790. // init verifyStaff
  5791. if ($v [1] == 'ROLE') {
  5792. if (! empty ( $verifyStaff )) {
  5793. $endStaffArray = end ( $verifyStaff );
  5794. if ($v [0] == $endStaffArray ['nextStaff']) {
  5795. $roleId = $v [0];
  5796. }
  5797. }
  5798. $roleVerify = json_decode ( $v [3], true );
  5799. $roleKey = $k;
  5800. $roleArray = array ();
  5801. $rolename = $role->getOne ( array (
  5802. 'where' => 'rid=' . $v [0],
  5803. 'asArray' => true
  5804. ) );
  5805. foreach ( $roleVerify as $o => $p ) {
  5806. $staffID = explode ( '_', $p );
  5807. $staffInfo = $staff->getOne ( array (
  5808. 'where' => 'sid=' . $staffID [0],
  5809. 'asArray' => true
  5810. ) );
  5811. // print_r($staffID);
  5812. $exp = array (
  5813. 0 => $staffInfo ['sid'],
  5814. 1 => $staffID [1],
  5815. 2 => $staffInfo ['avatar'],
  5816. 'date' => '',
  5817. 'date' => '',
  5818. 'opinion' => '',
  5819. 'status' => '',
  5820. 'rolename' => $rolename ['name']
  5821. );
  5822. array_push ( $roleArray, $exp );
  5823. }
  5824. $roleArrayCopy [$v [0]] = $roleArray;
  5825. // $verifyList[$k]['roleArray']=$roleArray;
  5826. }
  5827. // print_r($roleArray);
  5828. $verifyList [$k] ['date'] = "";
  5829. $verifyList [$k] ['opinion'] = "";
  5830. $verifyList [$k] ['status'] = "";
  5831. if (empty ( $verifyStaff )) {
  5832. $verifyList [$k] ['date'] = "";
  5833. $verifyList [$k] ['opinion'] = "";
  5834. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5835. $verifyList [$k] ['status'] = 4;
  5836. $button = 4;
  5837. $flag = false;
  5838. }
  5839. } else {
  5840. foreach ( $verifyStaff as $m => $u ) {
  5841. if ($v [0] == $m) {
  5842. $verifyList [$k] ['date'] = $u ['date'];
  5843. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5844. $verifyList [$k] ['status'] = $u ['status'];
  5845. $flag = false;
  5846. break;
  5847. }
  5848. }
  5849. $endStaffArray = end ( $verifyStaff );
  5850. if (isset ( $endStaffArray ['ROLE'] )) {
  5851. } else {
  5852. $endKey = key ( $verifyStaff );
  5853. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5854. $button = 4;
  5855. $verifyList [$k] ['status'] = 4;
  5856. }
  5857. }
  5858. }
  5859. }
  5860. $rolename ['name'] = '';
  5861. if (! empty ( $roleId )) {
  5862. Doo::loadModel ( 'role' );
  5863. $role = new role ();
  5864. $rolename = $role->getOne ( array (
  5865. 'where' => 'rid=' . $roleId,
  5866. 'asArray' => true
  5867. ) );
  5868. }
  5869. if (! empty ( $verifyStaff ))
  5870. $endStaffArray = end ( $verifyStaff );
  5871. $KOP = false;
  5872. foreach ( $roleArrayCopy as $P => $A ) {
  5873. foreach ( $A as $MKI => $AVL ) {
  5874. if (! empty ( $verifyStaff )) {
  5875. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5876. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5877. $button = 4;
  5878. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5879. }
  5880. foreach ( $verifyStaff as $m => $u ) {
  5881. $AVLFK = $AVL [0] . '_R';
  5882. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5883. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5884. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5885. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5886. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5887. break;
  5888. }
  5889. }
  5890. } else {
  5891. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5892. $button = 4;
  5893. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5894. }
  5895. }
  5896. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5897. $KOP = true;
  5898. }
  5899. }
  5900. foreach ( $roleArrayCopy as $k => $v ) {
  5901. foreach ( $verifyList as $m => $n ) {
  5902. if ($n [0] == $k) {
  5903. array_splice ( $verifyList, $m, 1, $v );
  5904. }
  5905. }
  5906. }
  5907. $receiptList [$key] ['verifyList'] = $verifyList;
  5908. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5909. 'where' => 'sid=' . $value ['staff'],
  5910. 'asArray' => true
  5911. ) );
  5912. $receiptList [$key] ['button'] = $button;
  5913. }
  5914. $mothHtml = "";
  5915. for($i = 1; $i <= 12; $i ++) {
  5916. if ($month == $i)
  5917. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5918. else
  5919. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5920. }
  5921. // 获取审批日志
  5922. Doo::loadModel ( 'receiptLog' );
  5923. $receiptLog = new receiptLog ();
  5924. $rlList = array ();
  5925. $rlInfo = $receiptLog->getOne ( array (
  5926. 'where' => 'rid=' . $rid . ' and status=4',
  5927. 'asArray' => true
  5928. ) );
  5929. $tijdate = $receiptLog->getOne ( array (
  5930. 'where' => 'rid=' . $rid . ' and status=2',
  5931. 'asc' => 'rlid',
  5932. 'asArray' => true
  5933. ) );
  5934. if (! empty ( $rlInfo )) {
  5935. $rlList = $receiptLog->find ( array (
  5936. 'where' => 'rid=' . $rid,
  5937. 'asc' => 'rlid',
  5938. 'asArray' => true
  5939. ) );
  5940. }
  5941. $receiptList [0] ['rlList'] = $rlList;
  5942. $enclosurList = $enclosur->find ( array (
  5943. 'where' => 'rid=' . $rid,
  5944. 'asArray' => true
  5945. ) );
  5946. $enclosurHtml = '';
  5947. foreach ( $enclosurList as $value ) {
  5948. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5949. }
  5950. $data ['enclosurHtml'] = $enclosurHtml;
  5951. $data ['rolename'] = $rolename ['name'];
  5952. $data ['datetij'] = $tijdate ['date'];
  5953. $data ['mothHtml'] = $mothHtml;
  5954. $data ['receiptList'] = $receiptList;
  5955. $data ['receiptApprovalCount'] = count ( $receiptList );
  5956. $data ['year'] = $year;
  5957. $data ['categoryList'] = $categoryList;
  5958. $data ['staffList'] = $staffList;
  5959. $data ['cid'] = $cid;
  5960. $data ['sid'] = $sid;
  5961. $data ['status'] = 0;
  5962. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  5963. $ap = 4;
  5964. } else
  5965. $data ['status'] = $receiptList [0] ['status'];
  5966. if ($receiptList [0] ['status'] == 4) {
  5967. $data ['status'] = 5;
  5968. $ap = 0;
  5969. }
  5970. $data ['ap'] = $ap;
  5971. $data ['memu'] = "receipt";
  5972. $data ['staff'] = $this->staff;
  5973. $data ['receiptMemu'] = 'approval';
  5974. $data ['verifyId'] = $this->verifyId;
  5975. $data ['executeId'] = $this->executeId;
  5976. $this->render ( "/admin/saeaReportListReport", $data );
  5977. }
  5978. function approvalEdi() {
  5979. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5980. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5981. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5982. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5983. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5984. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5985. if (empty ( $status ))
  5986. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5987. $vidList = array ();
  5988. $button = 0;
  5989. Doo::loadModel ( 'verify' );
  5990. Doo::loadModel ( 'receipt' );
  5991. Doo::loadModel ( 'staff' );
  5992. $staff = new staff ();
  5993. $receipt = new receipt ();
  5994. $verify = new verify ();
  5995. Doo::loadModel ( 'L_category' );
  5996. $Lcategory = new L_category ();
  5997. Doo::loadModel ( 'enclosur' );
  5998. $enclosur = new enclosur ();
  5999. // user verify ID
  6000. $verifyDetail = $verify->find ( array (
  6001. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6002. 'asArray' => true
  6003. ) );
  6004. foreach ( $verifyDetail as $key => $value ) {
  6005. array_push ( $vidList, $value ['vid'] );
  6006. }
  6007. $vid = implode ( ",", $vidList );
  6008. if (empty ( $verifyDetail ))
  6009. $vid = 0;
  6010. $categoryList = $Lcategory->find ( array (
  6011. 'asArray' => true
  6012. ) );
  6013. $staffList = $staff->find ( array (
  6014. 'where' => 'cid=' . $cid,
  6015. 'asArray' => true
  6016. ) );
  6017. $ap = "";
  6018. if ($status == 4) {
  6019. $ap = 4;
  6020. $status = 2;
  6021. }
  6022. // get Receipt By verifyID status 2
  6023. $receiptList = $receipt->find ( array (
  6024. 'where' => 'rid =' . $rid,
  6025. 'desc' => 'rid',
  6026. 'asArray' => true
  6027. ) );
  6028. $Locate = 0;
  6029. $roleId = 0;
  6030. if ($ap == 4)
  6031. $status = 4;
  6032. foreach ( $receiptList as $key => $value ) {
  6033. $receiptList [$key] ['Locate'] = $Locate;
  6034. $Locate ++;
  6035. $receiptList [$key] ['reviseDetail'] = array ();
  6036. if (! empty ( $value ['reviseDetail'] ))
  6037. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6038. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6039. $categoryDetil = $Lcategory->getOne ( array (
  6040. 'where' => 'cid=' . $value ['cid'],
  6041. 'asArray' => true
  6042. ) );
  6043. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6044. // 检测编辑状态
  6045. $verifyList = $verify->getOne ( array (
  6046. 'where' => 'vid=' . $value ['verify'],
  6047. 'asArray' => true
  6048. ) );
  6049. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6050. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6051. // print_r($verifyList);
  6052. //
  6053. // if (empty($verifyStaff)){
  6054. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6055. // $verifyList[0]['status']=4;$button=4;
  6056. // }
  6057. //
  6058. // }else{
  6059. //
  6060. // }
  6061. // die;
  6062. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  6063. // echo array_search("green",$a);
  6064. //
  6065. Doo::loadModel ( 'role' );
  6066. $role = new role ();
  6067. // print_r($verifyList);
  6068. $flag = true;
  6069. $roleKey = 0;
  6070. $endStaffArray = array ();
  6071. $roleArrayCopy = array ();
  6072. foreach ( $verifyList as $k => $v ) {
  6073. // init verifyStaff
  6074. if ($v [1] == 'ROLE') {
  6075. if (! empty ( $verifyStaff )) {
  6076. $endStaffArray = end ( $verifyStaff );
  6077. if ($v [0] == $endStaffArray ['nextStaff']) {
  6078. $roleId = $v [0];
  6079. }
  6080. }
  6081. $roleVerify = json_decode ( $v [3], true );
  6082. $roleKey = $k;
  6083. $roleArray = array ();
  6084. $rolename = $role->getOne ( array (
  6085. 'where' => 'rid=' . $v [0],
  6086. 'asArray' => true
  6087. ) );
  6088. foreach ( $roleVerify as $o => $p ) {
  6089. $staffID = explode ( '_', $p );
  6090. $staffInfo = $staff->getOne ( array (
  6091. 'where' => 'sid=' . $staffID [0],
  6092. 'asArray' => true
  6093. ) );
  6094. // print_r($staffID);
  6095. $exp = array (
  6096. 0 => $staffInfo ['sid'],
  6097. 1 => $staffID [1],
  6098. 2 => $staffInfo ['avatar'],
  6099. 'date' => '',
  6100. 'date' => '',
  6101. 'opinion' => '',
  6102. 'status' => '',
  6103. 'rolename' => $rolename ['name']
  6104. );
  6105. array_push ( $roleArray, $exp );
  6106. }
  6107. $roleArrayCopy [$v [0]] = $roleArray;
  6108. // $verifyList[$k]['roleArray']=$roleArray;
  6109. }
  6110. // print_r($roleArray);
  6111. $verifyList [$k] ['date'] = "";
  6112. $verifyList [$k] ['opinion'] = "";
  6113. $verifyList [$k] ['status'] = "";
  6114. if (empty ( $verifyStaff )) {
  6115. $verifyList [$k] ['date'] = "";
  6116. $verifyList [$k] ['opinion'] = "";
  6117. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6118. $verifyList [$k] ['status'] = 4;
  6119. $button = 4;
  6120. $flag = false;
  6121. }
  6122. } else {
  6123. foreach ( $verifyStaff as $m => $u ) {
  6124. if ($v [0] == $m) {
  6125. $verifyList [$k] ['date'] = $u ['date'];
  6126. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6127. $verifyList [$k] ['status'] = $u ['status'];
  6128. $flag = false;
  6129. break;
  6130. }
  6131. }
  6132. $endStaffArray = end ( $verifyStaff );
  6133. if (isset ( $endStaffArray ['ROLE'] )) {
  6134. } else {
  6135. $endKey = key ( $verifyStaff );
  6136. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6137. $button = 4;
  6138. $verifyList [$k] ['status'] = 4;
  6139. }
  6140. }
  6141. // print_r($endStaffArray);die;
  6142. // if (empty($verifyStaff)){
  6143. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6144. // $verifyList[$k]['status']=4;$button=4;
  6145. // }
  6146. //
  6147. // }else{
  6148. //
  6149. // }
  6150. // if($flag){//检测可编辑
  6151. // if($v[0]==$this->staff[0]['sid']){
  6152. // $verifyList[$k]['status']=4;$button=4;
  6153. // }
  6154. // }
  6155. }
  6156. }
  6157. $rolename ['name'] = '';
  6158. if (! empty ( $roleId )) {
  6159. Doo::loadModel ( 'role' );
  6160. $role = new role ();
  6161. $rolename = $role->getOne ( array (
  6162. 'where' => 'rid=' . $roleId,
  6163. 'asArray' => true
  6164. ) );
  6165. }
  6166. if (! empty ( $verifyStaff ))
  6167. $endStaffArray = end ( $verifyStaff );
  6168. $KOP = false;
  6169. foreach ( $roleArrayCopy as $P => $A ) {
  6170. foreach ( $A as $MKI => $AVL ) {
  6171. if (! empty ( $verifyStaff )) {
  6172. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6173. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6174. $button = 4;
  6175. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6176. }
  6177. foreach ( $verifyStaff as $m => $u ) {
  6178. $AVLFK = $AVL [0] . '_R';
  6179. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6180. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6181. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6182. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6183. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6184. break;
  6185. }
  6186. }
  6187. } else {
  6188. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6189. $button = 4;
  6190. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6191. }
  6192. }
  6193. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6194. $KOP = true;
  6195. }
  6196. }
  6197. // print_r($roleArrayCopy);
  6198. // echo $roleKey;
  6199. foreach ( $roleArrayCopy as $k => $v ) {
  6200. foreach ( $verifyList as $m => $n ) {
  6201. if ($n [0] == $k) {
  6202. array_splice ( $verifyList, $m, 1, $v );
  6203. }
  6204. }
  6205. }
  6206. // if ($KOP)
  6207. // array_splice($verifyList,$roleKey,1,$roleArray);
  6208. // print_r($verifyList);
  6209. $receiptList [$key] ['verifyList'] = $verifyList;
  6210. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6211. 'where' => 'sid=' . $value ['staff'],
  6212. 'asArray' => true
  6213. ) );
  6214. $receiptList [$key] ['button'] = $button;
  6215. }
  6216. // $data['verifyDetail']=$verifyDetail;
  6217. $mothHtml = "";
  6218. for($i = 1; $i <= 12; $i ++) {
  6219. if ($month == $i)
  6220. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6221. else
  6222. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6223. }
  6224. // 获取审批日志
  6225. Doo::loadModel ( 'receiptLog' );
  6226. $receiptLog = new receiptLog ();
  6227. $rlList = array ();
  6228. $rlInfo = $receiptLog->getOne ( array (
  6229. 'where' => 'rid=' . $rid . ' and status=4',
  6230. 'asArray' => true
  6231. ) );
  6232. $tijdate = $receiptLog->getOne ( array (
  6233. 'where' => 'rid=' . $rid . ' and status=2',
  6234. 'asc' => 'rlid',
  6235. 'asArray' => true
  6236. ) );
  6237. if (! empty ( $rlInfo )) {
  6238. $rlList = $receiptLog->find ( array (
  6239. 'where' => 'rid=' . $rid,
  6240. 'asc' => 'rlid',
  6241. 'asArray' => true
  6242. ) );
  6243. }
  6244. $receiptList [0] ['rlList'] = $rlList;
  6245. $enclosurList = $enclosur->find ( array (
  6246. 'where' => 'rid=' . $rid,
  6247. 'asArray' => true
  6248. ) );
  6249. $enclosurHtml = '';
  6250. foreach ( $enclosurList as $value ) {
  6251. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6252. }
  6253. $data ['enclosurHtml'] = $enclosurHtml;
  6254. $data ['rolename'] = $rolename ['name'];
  6255. $data ['datetij'] = $tijdate ['date'];
  6256. $data ['mothHtml'] = $mothHtml;
  6257. $data ['receiptList'] = $receiptList;
  6258. $data ['receiptApprovalCount'] = count ( $receiptList );
  6259. $data ['status'] = $status;
  6260. $data ['year'] = $year;
  6261. $data ['categoryList'] = $categoryList;
  6262. $data ['staffList'] = $staffList;
  6263. $data ['cid'] = $cid;
  6264. $data ['sid'] = $sid;
  6265. $data ['ap'] = $ap;
  6266. $data ['memu'] = "receipt";
  6267. $data ['staff'] = $this->staff;
  6268. $data ['receiptMemu'] = 'approval';
  6269. $data ['verifyId'] = $this->verifyId;
  6270. $data ['executeId'] = $this->executeId;
  6271. $this->render ( "/admin/saeaReportListReport", $data );
  6272. }
  6273. function remittanceHky() {
  6274. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6275. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  6276. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6277. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  6278. $page_size = 15;
  6279. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  6280. Doo::loadModel ( 'receipt' );
  6281. $receipt = new receipt ();
  6282. Doo::loadModel ( 'staff' );
  6283. $staff = new staff ();
  6284. $dateCondition = " and Year(executeDate) =" . $year;
  6285. if ($moth != 'MONTH')
  6286. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  6287. if ($day != 'DAY' && $moth != 'MONTH')
  6288. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  6289. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  6290. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  6291. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  6292. $limit = $pageinfo ['lower'] . ',' . $page_size;
  6293. $dayList = $receipt->find ( array (
  6294. 'select' => 'executeDate,sum(amount) as amount',
  6295. 'where' => $sql,
  6296. 'desc' => 'executeDate',
  6297. 'groupby' => 'executeDate',
  6298. 'limit' => $limit,
  6299. 'asArray' => true
  6300. ) );
  6301. // print_r($dayList);
  6302. foreach ( $dayList as $key => $value ) {
  6303. $remitString = "";
  6304. $receiptList = $receipt->find ( array (
  6305. 'select' => 'rid,executeDate,amount,staff,cid',
  6306. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  6307. 'desc' => 'executeDate',
  6308. 'asArray' => true
  6309. ) );
  6310. foreach ( $receiptList as $k => $v ) {
  6311. $sinfo = $staff->getOne ( array (
  6312. 'select' => 'username,category',
  6313. 'where' => ' sid=' . $v ['staff'],
  6314. 'asArray' => true
  6315. ) );
  6316. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  6317. }
  6318. $dayList [$key] ['staff'] = $remitString;
  6319. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  6320. }
  6321. // print_r($dayList);
  6322. $mothHtml = "";
  6323. for($i = 1; $i <= 12; $i ++) {
  6324. if ($moth == $i)
  6325. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6326. else
  6327. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6328. }
  6329. $dayHtml = "";
  6330. if ($day != "DAY" || $moth != "MONTH") {
  6331. for($i = 1; $i <= 31; $i ++) {
  6332. if ($day == $i)
  6333. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6334. else
  6335. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6336. }
  6337. }
  6338. $data ['page'] = $pageinfo;
  6339. $data ['year'] = $year;
  6340. $data ['moth'] = $moth;
  6341. $data ['day'] = $day;
  6342. $data ['get'] = $get;
  6343. $data ['dayHtml'] = $dayHtml;
  6344. $data ['mothHtml'] = $mothHtml;
  6345. $data ['receiptList'] = $dayList;
  6346. $data ['memu'] = "receipt";
  6347. $data ['staff'] = $this->staff;
  6348. $data ['receiptMemu'] = 'remittanceHky';
  6349. $data ['verifyId'] = $this->verifyId;
  6350. $data ['executeId'] = $this->executeId;
  6351. $this->render ( "/admin/remittanceHky", $data );
  6352. }
  6353. function remittancep() {
  6354. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  6355. Doo::loadModel ( 'receipt' );
  6356. $receipt = new receipt ();
  6357. Doo::loadModel ( 'staff' );
  6358. $staff = new staff ();
  6359. Doo::loadClass ( 'XDeode' );
  6360. $XDeode = new XDeode ( 5 );
  6361. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  6362. $rplist = $receipt->find ( array (
  6363. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6364. 'asArray' => true
  6365. ) );
  6366. $dayList = $receipt->find ( array (
  6367. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6368. 'desc' => 'executeDate',
  6369. 'groupby' => 'staff',
  6370. 'asArray' => true
  6371. ) );
  6372. $html = '';
  6373. foreach ( $dayList as $key => $value ) {
  6374. $sinfo = $staff->getOne ( array (
  6375. 'select' => 'username,category',
  6376. 'where' => ' sid=' . $value ['staff'],
  6377. 'asArray' => true
  6378. ) );
  6379. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  6380. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  6381. $au = 0;
  6382. foreach ( $rplist as $k => $v ) {
  6383. if ($value ['staff'] == $v ['staff']) {
  6384. $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>';
  6385. $au += $v ['amount'];
  6386. }
  6387. }
  6388. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  6389. }
  6390. $data ['html'] = $html;
  6391. $data ['memu'] = "receipt";
  6392. $data ['staff'] = $this->staff;
  6393. $data ['receiptMemu'] = 'remittanceHky';
  6394. $data ['verifyId'] = $this->verifyId;
  6395. $data ['executeId'] = $this->executeId;
  6396. $this->render ( "/admin/remittancep", $data );
  6397. }
  6398. function ajaxGetReceiptDetails() {
  6399. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  6400. Doo::loadClass ( 'XDeode' );
  6401. $XDeode = new XDeode ( 5 );
  6402. $rid = $XDeode->decode ( $rid );
  6403. if (empty ( $rid )) {
  6404. echo json_encode ( array (
  6405. 'status' => 2,
  6406. 'msg' => 'illegal request'
  6407. ) );
  6408. die ();
  6409. }
  6410. Doo::loadModel ( 'receipt' );
  6411. $receipt = new receipt ();
  6412. Doo::loadModel ( 'staff' );
  6413. $staff = new staff ();
  6414. $rinfo = $receipt->getOne ( array (
  6415. 'where' => 'rid= ' . $rid,
  6416. 'asArray' => true
  6417. ) );
  6418. $sinfo = $staff->getOne ( array (
  6419. 'select' => 'username,category',
  6420. 'where' => ' sid=' . $rinfo ['staff'],
  6421. 'asArray' => true
  6422. ) );
  6423. $rinfo ['reviseDetail'] = array ();
  6424. if (! empty ( $rinfo ['reviseDetail'] ))
  6425. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  6426. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  6427. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  6428. $rinfo ['category'] = $sinfo ['category'];
  6429. $verifyStaff = array ();
  6430. if (! empty ( $rinfo ['verifyStaff'] ))
  6431. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  6432. $relust = $rinfo ['sum'] - $rinfo ['loanSum'];
  6433. $rinfo ['relust'] = $relust;
  6434. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  6435. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  6436. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  6437. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  6438. // 费用执行人相关数据
  6439. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6440. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6441. foreach ( $executeCopy as $k => $v ) {
  6442. $executeCopy [$k] ['date'] = '';
  6443. $executeCopy [$k] ['opinion'] = '';
  6444. $executeCopy [$k] ['status'] = '';
  6445. if (! empty ( $executeStaff ))
  6446. foreach ( $executeStaff as $m => $u ) {
  6447. if ($v [0] == $m) {
  6448. $executeCopy [$k] ['date'] = $u ['date'];
  6449. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  6450. $executeCopy [$k] ['status'] = $u ['status'];
  6451. break;
  6452. }
  6453. }
  6454. }
  6455. $rinfo ['executeCopy'] = $executeCopy;
  6456. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  6457. if ($rinfo ['Rtype'] == 1) { // 借款费用
  6458. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6459. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  6460. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  6461. $html .= '<tr><th>' . $value ['name'] . '</th>
  6462. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6463. }
  6464. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6465. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6466. <tr><th class="taC" colspan="2">费用说明</th>
  6467. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6468. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6469. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  6470. </tbody></table>';
  6471. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  6472. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  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'] ['agencySum'] . '</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'] ['travelSum'] . '</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'] ['trainSum'] . '</td></tr>';
  6494. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6495. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6496. $html .= '<tr><th>' . $value ['name'] . '</th>
  6497. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6498. }
  6499. $html .= '<tr><th class="taR">合计</th>
  6500. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6501. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6502. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6503. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6504. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6505. }
  6506. $html .= '<tr><th class="taR">合计</th>
  6507. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6508. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6509. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6510. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6511. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6512. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6513. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6514. <tr';
  6515. if ($rinfo ['relust'] >= 0) {
  6516. $html .= 'class="success"';
  6517. } else {
  6518. $html .= 'class="error"';
  6519. }
  6520. $html .= '><td class="taR"><b>借款结余</b></td>
  6521. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  6522. </tbody></table>
  6523. ';
  6524. }
  6525. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  6526. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6527. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  6528. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6529. $html .= '<tr><th>' . $value ['name'] . '</th>
  6530. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6531. }
  6532. $html .= '<tr><th class="taR">合计</th>
  6533. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6534. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6535. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6536. <tr><th class="taC" colspan="2">费用说明</th>
  6537. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6538. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6539. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6540. </tbody></table>';
  6541. } else {
  6542. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  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'] ['agencySum'] . '</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'] ['travelSum'] . '</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'] ['trainSum'] . '</td></tr>';
  6564. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6565. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6566. $html .= '<tr><th>' . $value ['name'] . '</th>
  6567. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6568. }
  6569. $html .= '<tr><th class="taR">合计</th>
  6570. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6571. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6572. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6573. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6574. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6575. }
  6576. $html .= '<tr><th class="taR">合计</th>
  6577. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6578. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6579. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6580. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6581. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6582. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6583. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  6584. $html .= '</tbody></table>';
  6585. /*
  6586. * <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>
  6587. * <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>
  6588. * <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>
  6589. * <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>
  6590. * <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>
  6591. * <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>
  6592. * </tbody> </table>
  6593. */
  6594. }
  6595. // print_r($verifyStaff);die;
  6596. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  6597. foreach ( $verifyStaff as $key => $value ) {
  6598. $key = trim ( strtr ( $key, '_R', ' ' ) );
  6599. $sinfo = $staff->getOne ( array (
  6600. 'select' => 'username',
  6601. 'where' => ' sid=' . $key,
  6602. 'asArray' => true
  6603. ) );
  6604. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6605. }
  6606. $html .= '</tbody></table>';
  6607. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  6608. foreach ( $rinfo ['executeCopy'] as $value ) {
  6609. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6610. }
  6611. $html .= '</tbody></table>';
  6612. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  6613. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  6614. </tr></table>';
  6615. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  6616. echo json_encode ( array (
  6617. 'status' => 1,
  6618. 'html' => $html
  6619. ) );
  6620. die ();
  6621. }
  6622. function remittance() {
  6623. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6624. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6625. Doo::loadModel ( 'receipt' );
  6626. $receipt = new receipt ();
  6627. Doo::loadModel ( 'staff' );
  6628. $staff = new staff ();
  6629. $dateCondition = " and Year(pastDate) =" . $year;
  6630. if (! empty ( $month ))
  6631. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  6632. // get Receipt By verifyID status 1
  6633. $receiptList = $receipt->find ( array (
  6634. 'select' => 'sum(sum) as sum,staff,pastDate',
  6635. 'where' => ' status=1' . $dateCondition,
  6636. 'desc' => 'pastDate',
  6637. 'groupby' => 'staff,pastDate',
  6638. 'asArray' => true
  6639. ) );
  6640. $dateList = $receipt->find ( array (
  6641. 'select' => 'pastDate,verifyStaff',
  6642. 'where' => ' status=1' . $dateCondition,
  6643. 'desc' => 'pastDate',
  6644. 'groupby' => 'pastDate',
  6645. 'asArray' => true
  6646. ) );
  6647. $dataList = array ();
  6648. foreach ( $dateList as $d => $a ) {
  6649. $dataList [$a ['pastDate']] = array ();
  6650. $daySum = 0;
  6651. foreach ( $receiptList as $key => $value ) {
  6652. if ($a ['pastDate'] == $value ['pastDate']) {
  6653. $oderList = $receipt->find ( array (
  6654. 'select' => 'receiptOrder',
  6655. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  6656. 'asArray' => true
  6657. ) );
  6658. $list = array ();
  6659. $html = "";
  6660. foreach ( $oderList as $v ) {
  6661. array_push ( $list, $v ['receiptOrder'] );
  6662. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  6663. }
  6664. $receiptList [$key] ['receiptOrder'] = $html;
  6665. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  6666. $sinfo = $staff->getOne ( array (
  6667. 'select' => 'username ',
  6668. 'where' => ' sid=' . $value ['staff'],
  6669. 'asArray' => true
  6670. ) );
  6671. $receiptList [$key] ['username'] = $sinfo ['username'];
  6672. $daySum += $value ['sum'];
  6673. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  6674. }
  6675. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  6676. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  6677. }
  6678. }
  6679. // print_r($dataList);
  6680. $data ['dataList'] = $dataList;
  6681. $mothHtml = "";
  6682. for($i = 1; $i <= 12; $i ++) {
  6683. if ($month == $i)
  6684. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6685. else
  6686. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6687. }
  6688. $data ['year'] = $year;
  6689. $data ['mothHtml'] = $mothHtml;
  6690. $data ['memu'] = "receipt";
  6691. $data ['staff'] = $this->staff;
  6692. $data ['receiptMemu'] = 'approval';
  6693. $data ['verifyId'] = $this->verifyId;
  6694. $data ['executeId'] = $this->executeId;
  6695. $this->render ( "/admin/saeaReportListPay", $data );
  6696. }
  6697. function revocationAdjustment() {
  6698. $sid = isset ( $this->params ['sid'] ) && is_numeric ( $this->params ['sid'] ) ? $this->params ['sid'] : 0;
  6699. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  6700. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6701. // echo $price;die;
  6702. if ((! empty ( $sid )) && ($price != - 99999) && (! empty ( $rid ))) {
  6703. Doo::loadModel ( 'receipt' );
  6704. $receipt = new receipt ();
  6705. $receiptDetail = $receipt->getOne ( array (
  6706. 'where' => 'rid=' . $rid,
  6707. 'asArray' => true
  6708. ) );
  6709. if (empty ( $receiptDetail ['reviseDetail'] ))
  6710. return "/approval";
  6711. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  6712. $RD = array ();
  6713. foreach ( $reviseDetail as $key => $value ) {
  6714. if ($value ['price'] == $price && $value ['sid'] == $sid)
  6715. continue;
  6716. array_push ( $RD, $value );
  6717. }
  6718. $reviseDetailString = json_encode ( $RD );
  6719. $receipt->reviseDetail = $reviseDetailString;
  6720. $receipt->sum = $receiptDetail ['sum'] - $price;
  6721. $receipt->revisePrice = $receiptDetail ['revisePrice'] - $price;
  6722. $receipt->update ( array (
  6723. 'where' => 'rid=' . $rid
  6724. ) );
  6725. }
  6726. // approvalEdi/37
  6727. return "/approvalEdi/" . $rid;
  6728. }
  6729. function updateApprovalReceipt() {
  6730. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6731. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  6732. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6733. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  6734. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  6735. if (! empty ( $rid )) {
  6736. Doo::loadModel ( "verify" );
  6737. $verify = new verify ();
  6738. Doo::loadModel ( "receiptDetail" );
  6739. $receiptDetailObj = new receiptDetail ();
  6740. Doo::loadModel ( "itemStatistics" );
  6741. Doo::loadModel ( "statistics" );
  6742. $statistics = new statistics ();
  6743. $itemStatistics = new itemStatistics ();
  6744. Doo::loadModel ( "receipt" );
  6745. $receipt = new receipt ();
  6746. $receiptDetail = $receipt->getOne ( array (
  6747. 'where' => 'rid=' . $rid . ' and status=2 ',
  6748. 'asArray' => true
  6749. ) );
  6750. if (empty ( $receiptDetail ))
  6751. return "/approval";
  6752. $verifyDetail = $verify->getOne ( array (
  6753. 'where' => ' vid =' . $receiptDetail ['verify'],
  6754. 'asArray' => true
  6755. ) );
  6756. $verifyString = $verifyDetail ['staff'];
  6757. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  6758. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  6759. if (empty ( $opinion )) {
  6760. if ($status == 3)
  6761. $opinion = "终止";
  6762. else
  6763. $opinion = "同意支付";
  6764. }
  6765. $nowStaff = 0;
  6766. $nowStaffList = array ();
  6767. if (empty ( $verifyStaff )) {
  6768. // 还需加入是否已经进入角色审批
  6769. if ($verifyDetail [0] [1] == 'ROLE') {
  6770. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  6771. foreach ( $vStaffString as $key => $value ) {
  6772. $staffK = explode ( "_", $value );
  6773. if ($staffK [0] != $this->staff [0] ['sid'])
  6774. array_push ( $nowStaffList, $staffK [0] );
  6775. }
  6776. // print_r($verifyDetail);
  6777. // die;
  6778. if (! empty ( $nowStaffList )) {
  6779. $nowStaff = implode ( ',', $nowStaffList );
  6780. $verifyStaff = array (
  6781. $this->staff [0] ['sid'] . "_R" => array (
  6782. 'date' => date ( 'Y-m-d' ),
  6783. 'opinion' => $opinion,
  6784. 'status' => $status,
  6785. 'nextStaff' => $verifyDetail [0] [0],
  6786. 'ROLE' => 1
  6787. )
  6788. );
  6789. } else {
  6790. $nowStaff = $verifyDetail [1] [0];
  6791. $verifyStaff = array (
  6792. $this->staff [0] ['sid'] . "_R" => array (
  6793. 'date' => date ( 'Y-m-d' ),
  6794. 'opinion' => $opinion,
  6795. 'status' => $status,
  6796. 'nextStaff' => $verifyDetail [1] [0]
  6797. )
  6798. );
  6799. }
  6800. } else {
  6801. if ($verifyDetail [1] [1] == 'ROLE') {
  6802. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  6803. // echo "dd";
  6804. foreach ( $vStaffString as $key => $value ) {
  6805. $staffK = explode ( "_", $value );
  6806. array_push ( $nowStaffList, $staffK [0] );
  6807. }
  6808. $nowStaff = implode ( ',', $nowStaffList );
  6809. $verifyStaff = array (
  6810. $this->staff [0] ['sid'] => array (
  6811. 'date' => date ( 'Y-m-d' ),
  6812. 'opinion' => $opinion,
  6813. 'status' => $status,
  6814. 'nextStaff' => $verifyDetail [1] [0],
  6815. 'ROLE' => 1
  6816. )
  6817. );
  6818. } else {
  6819. $nowStaff = $verifyDetail [1] [0];
  6820. $verifyStaff = array (
  6821. $this->staff [0] ['sid'] => array (
  6822. 'date' => date ( 'Y-m-d' ),
  6823. 'opinion' => $opinion,
  6824. 'status' => $status,
  6825. 'nextStaff' => $verifyDetail [1] [0]
  6826. )
  6827. );
  6828. }
  6829. }
  6830. if ($status == 3)
  6831. $verifyStaff = array (
  6832. 'final' => $status,
  6833. $this->staff [0] ['sid'] => array (
  6834. 'date' => date ( 'Y-m-d' ),
  6835. 'opinion' => $opinion,
  6836. 'status' => $status
  6837. )
  6838. );
  6839. $vStaffString = json_encode ( $verifyStaff );
  6840. $receipt->nowStaff = $nowStaff;
  6841. $receipt->verifyStaff = $vStaffString;
  6842. } else {
  6843. $VS = end ( $verifyStaff );
  6844. // 非角色审批
  6845. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  6846. $nextStaff = 0;
  6847. $roleSTF = false;
  6848. foreach ( $verifyDetail as $key => $value ) {
  6849. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  6850. if (isset ( $verifyDetail [$key + 1] )) {
  6851. $nextStaff = $verifyDetail [$key + 1] [0];
  6852. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  6853. $roleSTF = true;
  6854. }
  6855. break;
  6856. }
  6857. }
  6858. if (! $roleSTF) {
  6859. $nowStaff = $nextStaff;
  6860. $verifyStaff [$this->staff [0] ['sid']] = array (
  6861. 'date' => date ( 'Y-m-d' ),
  6862. 'opinion' => $opinion,
  6863. 'status' => $status,
  6864. 'nextStaff' => $nextStaff
  6865. );
  6866. } else {
  6867. // 获取角色下的所有用户ID
  6868. $nowStaffList = array ();
  6869. foreach ( $verifyDetail as $vfk ) {
  6870. if ($vfk [1] == 'ROLE') {
  6871. $vStaffString = json_decode ( $vfk [3] );
  6872. foreach ( $vStaffString as $key => $value ) {
  6873. $staffK = explode ( "_", $value );
  6874. array_push ( $nowStaffList, $staffK [0] );
  6875. }
  6876. }
  6877. }
  6878. $nowStaff = implode ( ',', $nowStaffList );
  6879. $verifyStaff [$this->staff [0] ['sid']] = array (
  6880. 'date' => date ( 'Y-m-d' ),
  6881. 'opinion' => $opinion,
  6882. 'status' => $status,
  6883. 'nextStaff' => $nextStaff,
  6884. 'ROLE' => 0
  6885. );
  6886. }
  6887. if ($status == 3) {
  6888. $verifyStaff ['final'] = $status;
  6889. $verifyStaff [$this->staff [0] ['sid']] = array (
  6890. 'date' => date ( 'Y-m-d' ),
  6891. 'opinion' => $opinion,
  6892. 'status' => $status
  6893. );
  6894. }
  6895. $vStaffString = json_encode ( $verifyStaff );
  6896. $receipt->nowStaff = $nowStaff;
  6897. $receipt->verifyStaff = $vStaffString;
  6898. }
  6899. // 角色审批
  6900. if (isset ( $VS ['ROLE'] )) {
  6901. // 找出角色人 当前审批角色组
  6902. $verifyJSStaff = array ();
  6903. $nowStaffList2 = array ();
  6904. foreach ( $verifyDetail as $key => $value ) {
  6905. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  6906. $verifyJSStaff = json_decode ( $value [3] );
  6907. foreach ( $verifyJSStaff as $m ) {
  6908. $staffK = explode ( "_", $m );
  6909. array_push ( $nowStaffList2, $staffK [0] );
  6910. }
  6911. // print_r($nowStaffList2);
  6912. }
  6913. }
  6914. $RoleVerifyStaff = array ();
  6915. foreach ( $verifyStaff as $key => $value ) {
  6916. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  6917. foreach ( $nowStaffList2 as $m ) {
  6918. if ($key == $m . "_R")
  6919. $RoleVerifyStaff [$key] = $value;
  6920. }
  6921. }
  6922. }
  6923. // print_r($verifyStaff);
  6924. // print_r($nowStaffList2);
  6925. // print_r($RoleVerifyStaff);
  6926. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  6927. // print_r($verifyJSStaff);
  6928. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  6929. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  6930. // 下一个审批人ID
  6931. $nextStaff = 0;
  6932. $falg = false;
  6933. foreach ( $verifyDetail as $key => $value ) {
  6934. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  6935. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  6936. $falg = true;
  6937. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  6938. $nowStaffList = array ();
  6939. foreach ( $vStaffString as $v ) {
  6940. $staffK = explode ( "_", $v );
  6941. array_push ( $nowStaffList, $staffK [0] );
  6942. }
  6943. $nowStaff = implode ( ',', $nowStaffList );
  6944. $nextStaff = $verifyDetail [$key + 1] [0];
  6945. } elseif (isset ( $verifyDetail [$key + 1] )) {
  6946. $nextStaff = $verifyDetail [$key + 1] [0];
  6947. $nowStaff = $nextStaff;
  6948. } else
  6949. $nowStaff = '';
  6950. break;
  6951. }
  6952. }
  6953. if ($falg)
  6954. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6955. 'date' => date ( 'Y-m-d' ),
  6956. 'opinion' => $opinion,
  6957. 'status' => $status,
  6958. 'nextStaff' => $nextStaff,
  6959. 'ROLE' => 1
  6960. );
  6961. else
  6962. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6963. 'date' => date ( 'Y-m-d' ),
  6964. 'opinion' => $opinion,
  6965. 'status' => $status,
  6966. 'nextStaff' => $nextStaff
  6967. );
  6968. // print_r($verifyStaff);
  6969. // echo $nowStaff;die;
  6970. } else { // 进入下一个角色或者审批人
  6971. /*
  6972. *
  6973. */
  6974. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  6975. //
  6976. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  6977. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6978. 'date' => date ( 'Y-m-d' ),
  6979. 'opinion' => $opinion,
  6980. 'status' => $status,
  6981. 'nextStaff' => $VS ['nextStaff'],
  6982. 'ROLE' => 1
  6983. );
  6984. // print_r($verifyStaff);
  6985. // die;
  6986. }
  6987. if ($status == 3) {
  6988. $verifyStaff ['final'] = $status;
  6989. $verifyStaff [$this->staff [0] ['sid']] = array (
  6990. 'date' => date ( 'Y-m-d' ),
  6991. 'opinion' => $opinion,
  6992. 'status' => $status
  6993. );
  6994. }
  6995. $vStaffString = json_encode ( $verifyStaff );
  6996. $receipt->verifyStaff = $vStaffString;
  6997. $receipt->nowStaff = $nowStaff;
  6998. // die;
  6999. // }
  7000. // print_r($verifyStaff);
  7001. // die;
  7002. }
  7003. // print_r($verifyStaff);die;
  7004. }
  7005. // print_r($verifyDetail);
  7006. $roleKey = 0;
  7007. $roleId = 0;
  7008. $verifyDetailCopy = array ();
  7009. foreach ( $verifyDetail as $k => $v ) {
  7010. if ($v [1] == 'ROLE') {
  7011. $roleId = $v [0];
  7012. $roleVerify = json_decode ( $v [3], true );
  7013. $roleKey = $k;
  7014. $roleArray = array ();
  7015. foreach ( $roleVerify as $o => $p ) {
  7016. $staffID = explode ( '_', $p );
  7017. $exp = array (
  7018. 0 => $staffID [0],
  7019. 1 => $staffID [1]
  7020. );
  7021. array_push ( $roleArray, $exp );
  7022. }
  7023. $verifyDetailCopy [$v [0]] = $roleArray;
  7024. }
  7025. }
  7026. // print_r($verifyDetail);
  7027. foreach ( $verifyDetailCopy as $k => $v ) {
  7028. foreach ( $verifyDetail as $m => $n ) {
  7029. if ($n [0] == $k) {
  7030. array_splice ( $verifyDetail, $m, 1, $v );
  7031. }
  7032. }
  7033. }
  7034. // die;
  7035. // if (!empty($roleArray))
  7036. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  7037. // echo $roleId;
  7038. // print_r($verifyStaff);
  7039. // print_r($verifyDetail);
  7040. // die;
  7041. Doo::loadModel ( "receiptLog" );
  7042. $receiptLog = new receiptLog ();
  7043. // 审批日志
  7044. if (! isset ( $verifyStaff ['final'] )) {
  7045. if (! empty ( $roleId )) {
  7046. Doo::loadModel ( "role" );
  7047. $role = new role ();
  7048. $roleInfo = $role->getOne ( array (
  7049. 'where' => 'rid=' . $roleId,
  7050. 'asArray' => true
  7051. ) );
  7052. $receiptLog->rolename = $roleInfo ['name'];
  7053. }
  7054. $receiptLog->username = $this->staff [0] ['username'];
  7055. $receiptLog->uid = $this->staff [0] ['sid'];
  7056. $receiptLog->date = date ( "Y-m-d" );
  7057. $receiptLog->opinion = $opinion;
  7058. $receiptLog->img = $this->staff [0] ['avatar'];
  7059. $receiptLog->status = 1;
  7060. $receiptLog->rid = $rid;
  7061. $receiptLog->insert ();
  7062. }
  7063. if (isset ( $verifyStaff ['final'] )) { // rDetail
  7064. $receipt->verifyBreakup = $verifyString;
  7065. $receipt->status = 3;
  7066. $receiptDetailObj->status = 3;
  7067. $receiptDetailObj->update ( array (
  7068. 'where' => 'rid=' . $rid
  7069. ) );
  7070. if (! empty ( $roleId )) {
  7071. Doo::loadModel ( "role" );
  7072. $role = new role ();
  7073. $roleInfo = $role->getOne ( array (
  7074. 'where' => 'rid=' . $roleId,
  7075. 'asArray' => true
  7076. ) );
  7077. $receiptLog->rolename = $roleInfo ['name'];
  7078. }
  7079. $receiptLog->username = $this->staff [0] ['username'];
  7080. $receiptLog->uid = $this->staff [0] ['sid'];
  7081. $receiptLog->date = date ( "Y-m-d" );
  7082. $receiptLog->opinion = $opinion;
  7083. $receiptLog->img = $this->staff [0] ['avatar'];
  7084. $receiptLog->status = 3;
  7085. $receiptLog->rid = $rid;
  7086. $receiptLog->insert ();
  7087. // 微信企业号通知
  7088. $this->setWXMsg ( $rid, 3 );
  7089. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  7090. $receipt->status = 1;
  7091. $reviseSum = 0;
  7092. $receipt->verifyBreakup = $verifyString;
  7093. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  7094. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7095. foreach ( $reviseDetail as $key => $value ) {
  7096. $receiptDetailObj = new receiptDetail ();
  7097. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7098. $receiptDetailObj->item = $value ['description'];
  7099. $receiptDetailObj->itemCategory = "报销金额调整";
  7100. $receiptDetailObj->price = $value ['price'];
  7101. $receiptDetailObj->date = $receiptDetail ['date'];
  7102. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  7103. $receiptDetailObj->rid = $rid;
  7104. $receiptDetailObj->status = 1;
  7105. $receiptDetailObj->insert ();
  7106. $reviseSum += $value ['price'];
  7107. }
  7108. $itemStatistics = new itemStatistics ();
  7109. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7110. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7111. $itemStatistics->price = $reviseSum;
  7112. $itemStatistics->itemCategory = "报销金额调整";
  7113. $itemStatistics->date = $receiptDetail ['date'];
  7114. $itemStatistics->insert ();
  7115. }
  7116. $receiptDetailObj = new receiptDetail ();
  7117. $receiptDetailObj->status = 1;
  7118. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  7119. $receiptDetailObj->update ( array (
  7120. 'where' => 'rid=' . $rid
  7121. ) );
  7122. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7123. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7124. $stat = $statistics->getOne ( array (
  7125. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  7126. 'asArray' => true
  7127. ) );
  7128. if (empty ( $stat )) {
  7129. $statistics->date = $receiptDetail ['date'];
  7130. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7131. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7132. $statistics->agPrice = $receiptDetail ['sum'];
  7133. $statistics->rePrice = $reviseSum;
  7134. $statistics->insert ();
  7135. } else {
  7136. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  7137. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  7138. $statistics->update ( array (
  7139. 'where' => 'sid=' . $stat ['sid']
  7140. ) );
  7141. }
  7142. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7143. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7144. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  7145. foreach ( $accountItem ['cSum'] as $key => $value ) {
  7146. if ($key == "agencySum") {
  7147. $iStatistics = $itemStatistics->getOne ( array (
  7148. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  7149. 'asArray' => true
  7150. ) );
  7151. if (empty ( $iStatistics )) {
  7152. $itemStatistics->cid = $receiptDetail ['cid'];
  7153. ;
  7154. $itemStatistics->staff = $receiptDetail ['staff'];
  7155. $itemStatistics->price = $value;
  7156. $itemStatistics->itemCategory = $this->AGENCY;
  7157. $itemStatistics->date = $receiptDetail ['date'];
  7158. $itemStatistics->insert ();
  7159. } else {
  7160. if (! empty ( $value )) {
  7161. $itemStatistics->price = $value + $iStatistics ['price'];
  7162. $itemStatistics->update ( array (
  7163. 'where' => 'sid=' . $iStatistics ['sid']
  7164. ) );
  7165. }
  7166. }
  7167. } elseif ($key == "travelSum") {
  7168. $iStatistics = $itemStatistics->getOne ( array (
  7169. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  7170. 'asArray' => true
  7171. ) );
  7172. if (empty ( $iStatistics )) {
  7173. $itemStatistics->cid = $receiptDetail ['cid'];
  7174. $itemStatistics->staff = $receiptDetail ['staff'];
  7175. $itemStatistics->price = $value;
  7176. $itemStatistics->itemCategory = $this->TRAVEL;
  7177. $itemStatistics->date = $receiptDetail ['date'];
  7178. $itemStatistics->insert ();
  7179. } else {
  7180. if (! empty ( $value )) {
  7181. $itemStatistics->price = $value + $iStatistics ['price'];
  7182. $itemStatistics->update ( array (
  7183. 'where' => 'sid=' . $iStatistics ['sid']
  7184. ) );
  7185. }
  7186. }
  7187. } elseif ($key == "trainSum") {
  7188. $iStatistics = $itemStatistics->getOne ( array (
  7189. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  7190. 'asArray' => true
  7191. ) );
  7192. if (empty ( $iStatistics )) {
  7193. $itemStatistics->cid = $receiptDetail ['cid'];
  7194. $itemStatistics->staff = $receiptDetail ['staff'];
  7195. $itemStatistics->price = $value;
  7196. $itemStatistics->itemCategory = $this->TRAIN;
  7197. $itemStatistics->date = $receiptDetail ['date'];
  7198. $itemStatistics->insert ();
  7199. } else {
  7200. if (! empty ( $value )) {
  7201. $itemStatistics->price = $value + $iStatistics ['price'];
  7202. $itemStatistics->update ( array (
  7203. 'where' => 'sid=' . $iStatistics ['sid']
  7204. ) );
  7205. }
  7206. }
  7207. } elseif ($key == "otherSum") {
  7208. $iStatistics = $itemStatistics->getOne ( array (
  7209. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  7210. 'asArray' => true
  7211. ) );
  7212. if (empty ( $iStatistics )) {
  7213. $itemStatistics->cid = $receiptDetail ['cid'];
  7214. $itemStatistics->staff = $receiptDetail ['staff'];
  7215. $itemStatistics->price = $value;
  7216. $itemStatistics->itemCategory = $this->OTHER;
  7217. $itemStatistics->date = $receiptDetail ['date'];
  7218. $itemStatistics->insert ();
  7219. } else {
  7220. if (! empty ( $value )) {
  7221. $itemStatistics->price = $value + $iStatistics ['price'];
  7222. $itemStatistics->update ( array (
  7223. 'where' => 'sid=' . $iStatistics ['sid']
  7224. ) );
  7225. }
  7226. }
  7227. }
  7228. }
  7229. $receipt->pastDate = date ( "Y-m-d" );
  7230. // 微信企业号通知
  7231. $this->setWXMsg ( $rid, 1 );
  7232. }
  7233. $receipt->amount = $amount;
  7234. $receipt->update ( array (
  7235. 'where' => ' rid = ' . $rid
  7236. ) );
  7237. return "/approvalExpenses/pendApproval";
  7238. }
  7239. }
  7240. function expensesRetreats() {
  7241. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7242. if (! empty ( $rid )) {
  7243. // 操作记录
  7244. Doo::loadModel ( "receipt" );
  7245. $receipt = new receipt ();
  7246. Doo::loadModel ( "receiptLog" );
  7247. $receiptLog = new receiptLog ();
  7248. Doo::loadModel ( "verify" );
  7249. $verify = new verify ();
  7250. $receiptInfo = $receipt->getOne ( array (
  7251. 'where' => 'rid=' . $rid,
  7252. 'asArray' => true
  7253. ) );
  7254. $vr = $verify->getOne ( array (
  7255. 'where' => 'vid=' . $receiptInfo ['verify'],
  7256. 'asArray' => true
  7257. ) );
  7258. $jd = json_decode ( $vr ['staff'] );
  7259. $roleId = 0;
  7260. foreach ( $jd as $key => $value ) {
  7261. if ($value [1] == 'ROLE') {
  7262. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7263. if ($pos !== false) {
  7264. $roleId = $value [0];
  7265. }
  7266. }
  7267. }
  7268. // 审批日志
  7269. // echo $roleId;die;
  7270. if (! empty ( $roleId )) {
  7271. Doo::loadModel ( "role" );
  7272. $role = new role ();
  7273. $roleInfo = $role->getOne ( array (
  7274. 'where' => 'rid=' . $roleId,
  7275. 'asArray' => true
  7276. ) );
  7277. $receiptLog->rolename = $roleInfo ['name'];
  7278. }
  7279. $receiptLog->username = $this->staff [0] ['username'];
  7280. $receiptLog->uid = $this->staff [0] ['sid'];
  7281. $receiptLog->date = date ( "Y-m-d" );
  7282. $receiptLog->opinion = '撤回';
  7283. $receiptLog->img = $this->staff [0] ['avatar'];
  7284. $receiptLog->status = 4;
  7285. $receiptLog->rid = $rid;
  7286. $receiptLog->insert ();
  7287. $receipt->status = 4;
  7288. $receipt->update ( array (
  7289. 'where' => 'rid=' . $rid
  7290. ) );
  7291. // 微信企业号通知
  7292. $this->setWXMsg ( $rid, 2 );
  7293. }
  7294. // echo "ddd";
  7295. return '/approvalExpenses/pendApproval';
  7296. }
  7297. function updateCheReceipt() {
  7298. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7299. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7300. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  7301. if (! empty ( $rid )) {
  7302. // 操作记录
  7303. Doo::loadModel ( "receipt" );
  7304. $receipt = new receipt ();
  7305. Doo::loadModel ( "receiptLog" );
  7306. $receiptLog = new receiptLog ();
  7307. Doo::loadModel ( "verify" );
  7308. $verify = new verify ();
  7309. $receiptInfo = $receipt->getOne ( array (
  7310. 'where' => 'rid=' . $rid,
  7311. 'asArray' => true
  7312. ) );
  7313. $vr = $verify->getOne ( array (
  7314. 'where' => 'vid=' . $receiptInfo ['verify'],
  7315. 'asArray' => true
  7316. ) );
  7317. $jd = json_decode ( $vr ['staff'] );
  7318. $roleId = 0;
  7319. foreach ( $jd as $key => $value ) {
  7320. if ($value [1] == 'ROLE') {
  7321. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7322. if ($pos !== false) {
  7323. $roleId = $value [0];
  7324. }
  7325. }
  7326. }
  7327. // 审批日志
  7328. // echo $roleId;die;
  7329. if (! empty ( $roleId )) {
  7330. Doo::loadModel ( "role" );
  7331. $role = new role ();
  7332. $roleInfo = $role->getOne ( array (
  7333. 'where' => 'rid=' . $roleId,
  7334. 'asArray' => true
  7335. ) );
  7336. $receiptLog->rolename = $roleInfo ['name'];
  7337. }
  7338. $receiptLog->username = $this->staff [0] ['username'];
  7339. $receiptLog->uid = $this->staff [0] ['sid'];
  7340. $receiptLog->date = date ( "Y-m-d" );
  7341. $receiptLog->opinion = $opinion;
  7342. $receiptLog->img = $this->staff [0] ['avatar'];
  7343. $receiptLog->status = 4;
  7344. $receiptLog->rid = $rid;
  7345. $receiptLog->insert ();
  7346. $receipt->status = 4;
  7347. $receipt->update ( array (
  7348. 'where' => 'rid=' . $rid
  7349. ) );
  7350. // 微信企业号通知
  7351. $this->setWXMsg ( $rid, 2 );
  7352. echo json_encode ( array (
  7353. 'status' => 1
  7354. ) );
  7355. die ();
  7356. }
  7357. echo json_encode ( array (
  7358. 'status' => 2
  7359. ) );
  7360. die ();
  7361. // echo "ddd";
  7362. // return '/saeaBorad';
  7363. }
  7364. function revisePrice() {
  7365. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  7366. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  7367. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7368. // echo $price;die;
  7369. if (! empty ( $rid )) {
  7370. Doo::loadModel ( "receipt" );
  7371. $receipt = new receipt ();
  7372. $receiptDetail = $receipt->getOne ( array (
  7373. 'where' => 'rid=' . $rid . ' and status=2 ',
  7374. 'asArray' => true
  7375. ) );
  7376. if (empty ( $receiptDetail ))
  7377. return "/approval";
  7378. $reviseDetail = array ();
  7379. if (empty ( $receiptDetail ['reviseDetail'] )) {
  7380. array_push ( $reviseDetail, array (
  7381. 'sid' => $this->staff [0] ['sid'],
  7382. 'name' => $this->staff [0] ['username'],
  7383. 'description' => $description,
  7384. 'price' => $price
  7385. ) );
  7386. $reviseDetailString = json_encode ( $reviseDetail );
  7387. $receipt->reviseDetail = $reviseDetailString;
  7388. $receipt->revisePrice = $price;
  7389. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7390. } else {
  7391. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7392. array_push ( $reviseDetail, array (
  7393. 'sid' => $this->staff [0] ['sid'],
  7394. 'name' => $this->staff [0] ['username'],
  7395. 'description' => $description,
  7396. 'price' => $price
  7397. ) );
  7398. $reviseDetailString = json_encode ( $reviseDetail );
  7399. $receipt->reviseDetail = $reviseDetailString;
  7400. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  7401. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7402. }
  7403. $receipt->update ( array (
  7404. 'where' => 'rid=' . $rid
  7405. ) );
  7406. }
  7407. return '/approvalEdi/' . $rid;
  7408. }
  7409. function personalCollect() {
  7410. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7411. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  7412. $this->showCache ( $path );
  7413. Doo::loadModel ( "receiptDetail" );
  7414. Doo::loadModel ( "itemStatistics" );
  7415. Doo::loadModel ( 'statistics' );
  7416. $statistics = new statistics ();
  7417. $itemStatistics = new itemStatistics ();
  7418. $receiptDetail = new receiptDetail ();
  7419. $receiptCollectList = $receiptDetail->find ( array (
  7420. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7421. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7422. 'groupby' => 'itemCategory,Month(date)',
  7423. 'asArray' => true
  7424. ) );
  7425. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  7426. 'where' => 'staff=' . $this->staff [0] ['sid'],
  7427. 'asArray' => true
  7428. ) );
  7429. // create collect html
  7430. $collectArray = array (
  7431. '日常相关费用' => array (),
  7432. '差旅相关费用' => array (),
  7433. '培训班费用' => array (),
  7434. '其他' => array ()
  7435. );
  7436. $adjustment = array ();
  7437. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  7438. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7439. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  7440. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7441. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  7442. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7443. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  7444. array_push ( $collectArray ['其他'], $collectHtml );
  7445. $data ['collectArray'] = $collectArray;
  7446. // statistics html
  7447. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7448. if (empty ( $stList ))
  7449. $stList = array (
  7450. 'rePrice' => 0,
  7451. 'agPrice' => 0
  7452. );
  7453. $data ['stList'] = array (
  7454. 'rePrice' => $stList ['rePrice'],
  7455. 'agPrice' => $stList ['agPrice'],
  7456. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7457. );
  7458. // Adjustment price html
  7459. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7460. array_push ( $adjustment, $collectHtml );
  7461. $data ['adjustment'] = $adjustment;
  7462. // total price html
  7463. $collectHtml = "";
  7464. $total = 0;
  7465. for($i = 1; $i <= 12; $i ++) {
  7466. $sumPrice = 0;
  7467. foreach ( $receiptCollectList as $key => $value ) {
  7468. if ($value ['month'] == $i) {
  7469. $sumPrice += $value ['price'];
  7470. }
  7471. }
  7472. if ($sumPrice == 0)
  7473. $collectHtml .= '<td class="taR">-</td>';
  7474. else
  7475. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7476. $total += $sumPrice;
  7477. }
  7478. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7479. $data ['totalPrice'] = $collectHtml;
  7480. $data ['year'] = $year;
  7481. $data ['totalYear'] = $total;
  7482. $data ['memu'] = "receipt";
  7483. $data ['staff'] = $this->staff;
  7484. $data ['receiptMemu'] = 'personalCollect';
  7485. $data ['verifyId'] = $this->verifyId;
  7486. $data ['executeId'] = $this->executeId;
  7487. // year staff status 2,4
  7488. if ($year < date ( "Y" )) {
  7489. Doo::loadModel ( 'receipt' );
  7490. $receipt = new receipt ();
  7491. $receiptList = $receipt->find ( array (
  7492. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7493. 'asArray' => true
  7494. ) );
  7495. if (empty ( $receiptList )) {
  7496. ob_start ();
  7497. $this->render ( "/admin/saea_slist_collect", $data );
  7498. $this->cacheFile ( $path );
  7499. die ();
  7500. }
  7501. }
  7502. $this->render ( "/admin/saea_slist_collect", $data );
  7503. }
  7504. function personalCollectDetail() {
  7505. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7506. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  7507. $this->showCache ( $path );
  7508. Doo::loadModel ( "receiptDetail" );
  7509. Doo::loadModel ( "itemStatistics" );
  7510. Doo::loadModel ( 'statistics' );
  7511. Doo::loadModel ( 'accountItem' );
  7512. $accountItem = new accountItem ();
  7513. $statistics = new statistics ();
  7514. $itemStatistics = new itemStatistics ();
  7515. $receiptDetail = new receiptDetail ();
  7516. $receiptCollectList = $receiptDetail->find ( array (
  7517. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  7518. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7519. 'groupby' => 'item,Month(date)',
  7520. 'asArray' => true
  7521. ) );
  7522. $accountList = $accountItem->find ( array (
  7523. 'asArray' => true
  7524. ) );
  7525. // create CollectDetail HTML
  7526. $collectHtml = array ();
  7527. foreach ( $accountList as $key => $value ) {
  7528. $html = "";
  7529. $asum = 0;
  7530. for($i = 1; $i <= 12; $i ++) {
  7531. $falg = true;
  7532. foreach ( $receiptCollectList as $v ) {
  7533. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7534. $asum += $v ['price'];
  7535. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7536. $falg = false;
  7537. break;
  7538. }
  7539. }
  7540. if ($falg)
  7541. $html .= '<td class="taR">-</td>';
  7542. }
  7543. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7544. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7545. }
  7546. $data ['collectHtml'] = $collectHtml;
  7547. // create Adjustment price html
  7548. $receiptCollectList = $receiptDetail->find ( array (
  7549. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7550. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7551. 'groupby' => 'itemCategory,Month(date)',
  7552. 'asArray' => true
  7553. ) );
  7554. $adjustment = array ();
  7555. $collectArray = array (
  7556. '日常相关费用' => array (),
  7557. '差旅相关费用' => array (),
  7558. '培训班费用' => array (),
  7559. '其他' => array ()
  7560. );
  7561. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7562. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7563. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7564. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7565. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7566. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7567. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7568. array_push ( $collectArray ['其他'], $collectHtml );
  7569. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7570. array_push ( $adjustment, $collectHtml );
  7571. // total price html
  7572. $collectHtml = "";
  7573. $total = 0;
  7574. for($i = 1; $i <= 12; $i ++) {
  7575. $sumPrice = 0;
  7576. foreach ( $receiptCollectList as $key => $value ) {
  7577. if ($value ['month'] == $i) {
  7578. $sumPrice += $value ['price'];
  7579. }
  7580. }
  7581. if ($sumPrice == 0)
  7582. $collectHtml .= '<td class="taR">-</td>';
  7583. else
  7584. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7585. $total += $sumPrice;
  7586. }
  7587. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7588. // statistics html
  7589. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7590. if (empty ( $stList ))
  7591. $stList = array (
  7592. 'rePrice' => 0,
  7593. 'agPrice' => 0
  7594. );
  7595. $data ['stList'] = array (
  7596. 'rePrice' => $stList ['rePrice'],
  7597. 'agPrice' => $stList ['agPrice'],
  7598. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7599. );
  7600. $data ['collectArray'] = $collectArray;
  7601. $data ['adjustment'] = $adjustment;
  7602. $data ['totalPrice'] = $collectHtml;
  7603. $data ['totalYear'] = $total;
  7604. $data ['year'] = $year;
  7605. $data ['memu'] = "receipt";
  7606. $data ['staff'] = $this->staff;
  7607. $data ['receiptMemu'] = 'personalCollect';
  7608. $data ['verifyId'] = $this->verifyId;
  7609. $data ['executeId'] = $this->executeId;
  7610. // year staff status 2,4
  7611. if ($year < date ( "Y" )) {
  7612. Doo::loadModel ( 'receipt' );
  7613. $receipt = new receipt ();
  7614. $receiptList = $receipt->find ( array (
  7615. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7616. 'asArray' => true
  7617. ) );
  7618. if (empty ( $receiptList )) {
  7619. ob_start ();
  7620. $this->render ( "/admin/saeaCollectArticles", $data );
  7621. $this->cacheFile ( $path );
  7622. die ();
  7623. }
  7624. }
  7625. $this->render ( "/admin/saeaCollectArticles", $data );
  7626. }
  7627. function companyCategoryCollect() {
  7628. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7629. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  7630. $this->showCache ( $path );
  7631. Doo::loadModel ( 'L_category' );
  7632. Doo::loadModel ( 'itemStatistics' );
  7633. Doo::loadModel ( 'statistics' );
  7634. $statistics = new statistics ();
  7635. $Lcategory = new L_category ();
  7636. $itemStatistics = new itemStatistics ();
  7637. $LcategoryList = $Lcategory->find ( array (
  7638. 'asArray' => true
  7639. ) ); // 'staff='.$this->staff[0]['sid']." and
  7640. $itemStatisticsList = $itemStatistics->find ( array (
  7641. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7642. 'where' => " Year(date)=" . $year,
  7643. 'groupby' => 'cid,Month(date)',
  7644. 'asArray' => true
  7645. ) );
  7646. // ceatre companyCollectHtml
  7647. foreach ( $LcategoryList as $value ) {
  7648. $html = "";
  7649. $asum = 0;
  7650. for($i = 1; $i <= 12; $i ++) {
  7651. $falg = true;
  7652. foreach ( $itemStatisticsList as $v ) {
  7653. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  7654. $asum += $v ['price'];
  7655. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7656. $falg = false;
  7657. break;
  7658. }
  7659. }
  7660. if ($falg)
  7661. $html .= '<td class="taR">-</td>';
  7662. }
  7663. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7664. $collectHtml [$value ['title']] = array (
  7665. 'html' => $html,
  7666. 'cid' => $value ['cid']
  7667. );
  7668. }
  7669. $data ['companyHtml'] = $collectHtml;
  7670. // total price html
  7671. $collectHtml = "";
  7672. $total = 0;
  7673. for($i = 1; $i <= 12; $i ++) {
  7674. $sumPrice = 0;
  7675. foreach ( $itemStatisticsList as $key => $value ) {
  7676. if ($value ['month'] == $i) {
  7677. $sumPrice += $value ['price'];
  7678. }
  7679. }
  7680. if ($sumPrice == 0)
  7681. $collectHtml .= '<td class="taR">-</td>';
  7682. else
  7683. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7684. $total += $sumPrice;
  7685. }
  7686. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7687. $data ['companyTotalHtml'] = $collectHtml;
  7688. $data ['total'] = $total;
  7689. // statistics html
  7690. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7691. if (empty ( $stList ))
  7692. $stList = array (
  7693. 'rePrice' => 0,
  7694. 'agPrice' => 0
  7695. );
  7696. $data ['stList'] = array (
  7697. 'rePrice' => $stList ['rePrice'],
  7698. 'agPrice' => $stList ['agPrice'],
  7699. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7700. );
  7701. $data ['year'] = $year;
  7702. $data ['memu'] = "receipt";
  7703. $data ['staff'] = $this->staff;
  7704. $data ['receiptMemu'] = 'companyCategoryCollect';
  7705. $data ['verifyId'] = $this->verifyId;
  7706. $data ['executeId'] = $this->executeId;
  7707. // year staff status 2,4
  7708. if ($year < date ( "Y" )) {
  7709. Doo::loadModel ( 'receipt' );
  7710. $receipt = new receipt ();
  7711. $receiptList = $receipt->find ( array (
  7712. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  7713. 'asArray' => true
  7714. ) );
  7715. if (empty ( $receiptList )) {
  7716. ob_start ();
  7717. $this->render ( "/admin/saeaCompanyCollect", $data );
  7718. $this->cacheFile ( $path );
  7719. die ();
  7720. }
  7721. }
  7722. $this->render ( "/admin/saeaCompanyCollect", $data );
  7723. }
  7724. function categoryCollectDetail() {
  7725. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7726. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  7727. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  7728. $this->showCache ( $path );
  7729. Doo::loadModel ( 'statistics' );
  7730. $statistics = new statistics ();
  7731. Doo::loadModel ( "receiptDetail" );
  7732. $receiptDetail = new receiptDetail ();
  7733. Doo::loadModel ( 'L_category' );
  7734. $Lcategory = new L_category ();
  7735. Doo::loadModel ( 'accountItem' );
  7736. $accountItem = new accountItem ();
  7737. $LcategoryList = $Lcategory->find ( array (
  7738. 'asArray' => true
  7739. ) );
  7740. if ($cid == 0) {
  7741. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7742. if ($cid == 0)
  7743. $cid = $LcategoryList [0] ['cid'];
  7744. }
  7745. $data ['LcategoryList'] = $LcategoryList;
  7746. $receiptCollectList = $receiptDetail->find ( array (
  7747. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  7748. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7749. 'groupby' => 'item,Month(pastDate)',
  7750. 'asArray' => true
  7751. ) );
  7752. $accountList = $accountItem->find ( array (
  7753. 'asArray' => true
  7754. ) );
  7755. // create CollectDetail HTML
  7756. $collectHtml = array ();
  7757. foreach ( $accountList as $key => $value ) {
  7758. $html = "";
  7759. $asum = 0;
  7760. for($i = 1; $i <= 12; $i ++) {
  7761. $falg = true;
  7762. foreach ( $receiptCollectList as $v ) {
  7763. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7764. $asum += $v ['price'];
  7765. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7766. $falg = false;
  7767. break;
  7768. }
  7769. }
  7770. if ($falg)
  7771. $html .= '<td class="taR">-</td>';
  7772. }
  7773. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7774. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7775. }
  7776. $data ['collectHtml'] = $collectHtml;
  7777. // create Adjustment price html
  7778. $receiptCollectList = $receiptDetail->find ( array (
  7779. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  7780. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7781. 'groupby' => 'itemCategory,Month(pastDate)',
  7782. 'asArray' => true
  7783. ) );
  7784. $adjustment = array ();
  7785. $collectArray = array (
  7786. '日常相关费用' => array (),
  7787. '差旅相关费用' => array (),
  7788. '培训班费用' => array (),
  7789. '其他' => array ()
  7790. );
  7791. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7792. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7793. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7794. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7795. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7796. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7797. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7798. array_push ( $collectArray ['其他'], $collectHtml );
  7799. $data ['collectArray'] = $collectArray;
  7800. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7801. array_push ( $adjustment, $collectHtml );
  7802. $data ['adjustment'] = $adjustment;
  7803. // total price html
  7804. $collectHtml = "";
  7805. $total = 0;
  7806. for($i = 1; $i <= 12; $i ++) {
  7807. $sumPrice = 0;
  7808. foreach ( $receiptCollectList as $key => $value ) {
  7809. if ($value ['month'] == $i) {
  7810. $sumPrice += $value ['price'];
  7811. }
  7812. }
  7813. if ($sumPrice == 0)
  7814. $collectHtml .= '<td class="taR">-</td>';
  7815. else
  7816. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7817. $total += $sumPrice;
  7818. }
  7819. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7820. // statistics html
  7821. $stList = $statistics->statisticsByCid ( $year, $cid );
  7822. if (empty ( $stList ))
  7823. $stList = array (
  7824. 'rePrice' => 0,
  7825. 'agPrice' => 0
  7826. );
  7827. $data ['stList'] = array (
  7828. 'rePrice' => $stList ['rePrice'],
  7829. 'agPrice' => $stList ['agPrice'],
  7830. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7831. );
  7832. $data ['totalYear'] = $total;
  7833. $data ['year'] = $year;
  7834. $data ['cid'] = $cid;
  7835. $data ['memu'] = "receipt";
  7836. $data ['staff'] = $this->staff;
  7837. $data ['receiptMemu'] = 'companyCategoryCollect';
  7838. $data ['verifyId'] = $this->verifyId;
  7839. $data ['executeId'] = $this->executeId;
  7840. // year staff status 2,4
  7841. if ($year < date ( "Y" )) {
  7842. Doo::loadModel ( 'receipt' );
  7843. $receipt = new receipt ();
  7844. $receiptList = $receipt->find ( array (
  7845. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  7846. 'asArray' => true
  7847. ) );
  7848. if (empty ( $receiptList )) {
  7849. ob_start ();
  7850. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7851. $this->cacheFile ( $path );
  7852. die ();
  7853. }
  7854. }
  7855. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7856. }
  7857. function staffCollect() {
  7858. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7859. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  7860. // $this->showCache($path);
  7861. Doo::loadModel ( 'statistics' );
  7862. $statistics = new statistics ();
  7863. Doo::loadModel ( "receiptDetail" );
  7864. $receiptDetail = new receiptDetail ();
  7865. Doo::loadModel ( 'L_category' );
  7866. $Lcategory = new L_category ();
  7867. Doo::loadModel ( 'accountItem' );
  7868. $accountItem = new accountItem ();
  7869. Doo::loadModel ( 'staff' );
  7870. $staff = new staff ();
  7871. Doo::loadModel ( 'itemStatistics' );
  7872. $itemStatistics = new itemStatistics ();
  7873. /*
  7874. * $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']));
  7875. */
  7876. // statistics html
  7877. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7878. if (empty ( $stList ))
  7879. $stList = array (
  7880. 'rePrice' => 0,
  7881. 'agPrice' => 0
  7882. );
  7883. $data ['stList'] = array (
  7884. 'rePrice' => $stList ['rePrice'],
  7885. 'agPrice' => $stList ['agPrice'],
  7886. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7887. );
  7888. // ---
  7889. $staffList = $staff->find ( array (
  7890. 'where' => 'username !="admin"',
  7891. 'asArray' => true
  7892. ) );
  7893. $LcategoryList = $Lcategory->find ( array (
  7894. 'asArray' => true
  7895. ) ); // 'staff='.$this->staff[0]['sid']." and
  7896. $itemStatisticsList = $itemStatistics->find ( array (
  7897. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7898. 'where' => " Year(date)=" . $year,
  7899. 'groupby' => 'staff,Month(date)',
  7900. 'asArray' => true
  7901. ) );
  7902. $categoryList = $staff->find ( array (
  7903. 'select' => 'COUNT(*) as count,cid,category',
  7904. 'where' => 'username !="admin"',
  7905. 'groupby' => 'cid',
  7906. 'asArray' => true
  7907. ) );
  7908. // print_r($itemStatisticsList);die;
  7909. // ceatre companyCollectHtml
  7910. foreach ( $categoryList as $vlu ) {
  7911. $count = $vlu ['count'] + 1;
  7912. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  7913. $m1 = 0;
  7914. $m2 = 0;
  7915. $m3 = 0;
  7916. $m4 = 0;
  7917. $m5 = 0;
  7918. $m6 = 0;
  7919. $m7 = 0;
  7920. $m8 = 0;
  7921. $m9 = 0;
  7922. $m10 = 0;
  7923. $m11 = 0;
  7924. $m12 = 0;
  7925. $m13 = 0;
  7926. foreach ( $staffList as $value ) {
  7927. if ($vlu ['cid'] == $value ['cid']) {
  7928. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  7929. $asum = 0;
  7930. for($i = 1; $i <= 12; $i ++) {
  7931. $falg = true;
  7932. foreach ( $itemStatisticsList as $v ) {
  7933. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  7934. if ($v ['month'] == 1)
  7935. $m1 += $v ['price'];
  7936. if ($v ['month'] == 2)
  7937. $m2 += $v ['price'];
  7938. if ($v ['month'] == 3)
  7939. $m3 += $v ['price'];
  7940. if ($v ['month'] == 4)
  7941. $m4 += $v ['price'];
  7942. if ($v ['month'] == 5)
  7943. $m5 += $v ['price'];
  7944. if ($v ['month'] == 6)
  7945. $m6 += $v ['price'];
  7946. if ($v ['month'] == 7)
  7947. $m7 += $v ['price'];
  7948. if ($v ['month'] == 8)
  7949. $m8 += $v ['price'];
  7950. if ($v ['month'] == 9)
  7951. $m9 += $v ['price'];
  7952. if ($v ['month'] == 10)
  7953. $m10 += $v ['price'];
  7954. if ($v ['month'] == 11)
  7955. $m11 += $v ['price'];
  7956. if ($v ['month'] == 12)
  7957. $m12 += $v ['price'];
  7958. $asum += $v ['price'];
  7959. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7960. $falg = false;
  7961. break;
  7962. }
  7963. }
  7964. if ($falg)
  7965. $html .= '<td class="taR">-</td>';
  7966. }
  7967. $m13 += $asum;
  7968. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7969. $collectHtml [$value ['username']] = array (
  7970. 'html' => $html,
  7971. 'sid' => $value ['sid']
  7972. );
  7973. $html = "";
  7974. }
  7975. }
  7976. $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>
  7977. <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>
  7978. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  7979. $collectHtml [$vlu ['cid']] = array (
  7980. 'html' => $hl,
  7981. 'sid' => ''
  7982. );
  7983. }
  7984. $data ['companyHtml'] = $collectHtml;
  7985. // total price html
  7986. $collectHtml = "";
  7987. $total = 0;
  7988. for($i = 1; $i <= 12; $i ++) {
  7989. $sumPrice = 0;
  7990. foreach ( $itemStatisticsList as $key => $value ) {
  7991. if ($value ['month'] == $i) {
  7992. $sumPrice += $value ['price'];
  7993. }
  7994. }
  7995. if ($sumPrice == 0)
  7996. $collectHtml .= '<td class="taR">-</td>';
  7997. else
  7998. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7999. $total += $sumPrice;
  8000. }
  8001. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8002. $data ['companyTotalHtml'] = $collectHtml;
  8003. $data ['total'] = $total;
  8004. $data ['year'] = $year;
  8005. $data ['memu'] = "receipt";
  8006. $data ['staff'] = $this->staff;
  8007. $data ['receiptMemu'] = 'companyCategoryCollect';
  8008. $data ['verifyId'] = $this->verifyId;
  8009. $data ['executeId'] = $this->executeId;
  8010. if ($year <= date ( "Y" )) {
  8011. Doo::loadModel ( 'receipt' );
  8012. $receipt = new receipt ();
  8013. $receiptList = $receipt->find ( array (
  8014. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  8015. 'asArray' => true
  8016. ) );
  8017. if (empty ( $receiptList )) { // generated files
  8018. ob_start ();
  8019. $this->render ( "/admin/saeaStaffCollectB", $data );
  8020. $this->cacheFile ( $path );
  8021. die ();
  8022. }
  8023. }
  8024. $this->render ( "/admin/saeaStaffCollectB", $data );
  8025. }
  8026. function staffCollectBak() {
  8027. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8028. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  8029. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  8030. $this->showCache ( $path );
  8031. Doo::loadModel ( 'statistics' );
  8032. $statistics = new statistics ();
  8033. Doo::loadModel ( "receiptDetail" );
  8034. $receiptDetail = new receiptDetail ();
  8035. Doo::loadModel ( 'L_category' );
  8036. $Lcategory = new L_category ();
  8037. Doo::loadModel ( 'accountItem' );
  8038. $accountItem = new accountItem ();
  8039. Doo::loadModel ( 'staff' );
  8040. $staff = new staff ();
  8041. Doo::loadModel ( 'itemStatistics' );
  8042. $itemStatistics = new itemStatistics ();
  8043. $itemStatisticsList = $itemStatistics->find ( array (
  8044. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8045. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8046. 'groupby' => 'staff,itemCategory,Month(date)',
  8047. 'asArray' => true
  8048. ) );
  8049. $itemCategoryList = $itemStatistics->find ( array (
  8050. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8051. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8052. 'groupby' => 'cid,itemCategory,Month(date)',
  8053. 'asArray' => true
  8054. ) );
  8055. $LcategoryList = $Lcategory->find ( array (
  8056. 'asArray' => true
  8057. ) );
  8058. $staffList = $staff->find ( array (
  8059. 'asArray' => true
  8060. ) );
  8061. $htmlArray = array ();
  8062. foreach ( $LcategoryList as $value ) {
  8063. $htmlArray [$value ['title']] = array ();
  8064. foreach ( $staffList as $v ) {
  8065. if ($value ['cid'] == $v ['cid']) {
  8066. $html = "";
  8067. $falg = true;
  8068. $staffSumPrice = 0;
  8069. foreach ( $itemStatisticsList as $a ) {
  8070. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  8071. if (empty ( $a ['price'] )) {
  8072. $html .= '<td class="taR">-</td>';
  8073. $falg = false;
  8074. break;
  8075. } else {
  8076. $staffSumPrice += $a ['price'];
  8077. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8078. $falg = false;
  8079. break;
  8080. }
  8081. }
  8082. }
  8083. if ($falg) {
  8084. $html .= '<td class="taR">-</td>';
  8085. $falg = true;
  8086. }
  8087. $falg = true;
  8088. foreach ( $itemStatisticsList as $a ) {
  8089. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  8090. if (empty ( $a ['price'] )) {
  8091. $html .= '<td class="taR">-</td>';
  8092. $falg = false;
  8093. break;
  8094. } else {
  8095. $staffSumPrice += $a ['price'];
  8096. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8097. $falg = false;
  8098. break;
  8099. }
  8100. }
  8101. }
  8102. if ($falg) {
  8103. $html .= '<td class="taR">-</td>';
  8104. $falg = true;
  8105. }
  8106. $falg = true;
  8107. foreach ( $itemStatisticsList as $a ) {
  8108. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  8109. if (empty ( $a ['price'] )) {
  8110. $html .= '<td class="taR">-</td>';
  8111. $falg = false;
  8112. break;
  8113. } else {
  8114. $staffSumPrice += $a ['price'];
  8115. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8116. $falg = false;
  8117. break;
  8118. }
  8119. }
  8120. }
  8121. if ($falg) {
  8122. $html .= '<td class="taR">-</td>';
  8123. $falg = true;
  8124. }
  8125. $falg = true;
  8126. foreach ( $itemStatisticsList as $a ) {
  8127. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  8128. if (! empty ( $a ['price'] )) {
  8129. $staffSumPrice += $a ['price'];
  8130. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8131. $falg = false;
  8132. break;
  8133. } else {
  8134. $html .= '<td class="taR">-</td>';
  8135. $falg = false;
  8136. break;
  8137. }
  8138. }
  8139. }
  8140. if ($falg) {
  8141. $html .= '<td class="taR">-</td>';
  8142. $falg = true;
  8143. }
  8144. $falg = true;
  8145. foreach ( $itemStatisticsList as $a ) {
  8146. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  8147. if (! empty ( $a ['price'] )) {
  8148. $staffSumPrice += $a ['price'];
  8149. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8150. $falg = false;
  8151. break;
  8152. } else {
  8153. $html .= '<td class="taR">-</td>';
  8154. $falg = false;
  8155. break;
  8156. }
  8157. }
  8158. }
  8159. if ($falg) {
  8160. $html .= '<td class="taR">-</td>';
  8161. $falg = true;
  8162. }
  8163. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  8164. $htmlArray [$value ['title']] [$v ['username']] = $html;
  8165. }
  8166. }
  8167. /* -- --- */
  8168. // 合计费用
  8169. $cateHtml = "";
  8170. $catePrice = 0;
  8171. $cateFalg = true;
  8172. foreach ( $itemCategoryList as $l ) {
  8173. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  8174. if (empty ( $l ['price'] )) {
  8175. $cateHtml .= '<td class="colGreen taR">-</td>';
  8176. $cateFalg = false;
  8177. break;
  8178. } else {
  8179. $catePrice += $l ['price'];
  8180. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8181. $cateFalg = false;
  8182. break;
  8183. }
  8184. }
  8185. }
  8186. if ($cateFalg) {
  8187. $cateHtml .= '<td class="colGreen taR">-</td>';
  8188. $cateFalg = true;
  8189. }
  8190. $cateFalg = true;
  8191. foreach ( $itemCategoryList as $l ) {
  8192. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  8193. if (empty ( $l ['price'] )) {
  8194. $cateHtml .= '<td class="colGreen taR">-</td>';
  8195. $cateFalg = false;
  8196. break;
  8197. } else {
  8198. $catePrice += $l ['price'];
  8199. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8200. $cateFalg = false;
  8201. break;
  8202. }
  8203. }
  8204. }
  8205. if ($cateFalg) {
  8206. $cateHtml .= '<td class="colGreen taR">-</td>';
  8207. $cateFalg = true;
  8208. }
  8209. $cateFalg = true;
  8210. foreach ( $itemCategoryList as $l ) {
  8211. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  8212. if (empty ( $l ['price'] )) {
  8213. $cateHtml .= '<td class="colGreen taR">-</td>';
  8214. $cateFalg = false;
  8215. break;
  8216. } else {
  8217. $catePrice += $l ['price'];
  8218. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8219. $cateFalg = false;
  8220. break;
  8221. }
  8222. }
  8223. }
  8224. if ($cateFalg) {
  8225. $cateHtml .= '<td class="colGreen taR">-</td>';
  8226. $cateFalg = true;
  8227. }
  8228. $cateFalg = true;
  8229. foreach ( $itemCategoryList as $l ) {
  8230. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  8231. if (empty ( $l ['price'] )) {
  8232. $cateHtml .= '<td class="colGreen taR">-</td>';
  8233. $cateFalg = false;
  8234. break;
  8235. } else {
  8236. $catePrice += $l ['price'];
  8237. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8238. $cateFalg = false;
  8239. break;
  8240. }
  8241. }
  8242. }
  8243. if ($cateFalg) {
  8244. $cateHtml .= '<td class="colGreen taR">-</td>';
  8245. $cateFalg = true;
  8246. }
  8247. $cateFalg = true;
  8248. foreach ( $itemCategoryList as $l ) {
  8249. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  8250. if (empty ( $l ['price'] )) {
  8251. $cateHtml .= '<td class="colGreen taR">-</td>';
  8252. $cateFalg = false;
  8253. break;
  8254. } else {
  8255. $catePrice += $l ['price'];
  8256. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8257. $cateFalg = false;
  8258. break;
  8259. }
  8260. }
  8261. }
  8262. if ($cateFalg) {
  8263. $cateHtml .= '<td class="colGreen taR">-</td>';
  8264. $cateFalg = true;
  8265. }
  8266. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  8267. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  8268. /* -- --- */
  8269. }
  8270. // print_r($htmlArray);die;
  8271. $data ['htmlArray'] = $htmlArray;
  8272. // statistics html
  8273. $stList = $statistics->getOne ( array (
  8274. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8275. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8276. 'groupby' => 'Month(date)',
  8277. 'asArray' => true
  8278. ) );
  8279. if (empty ( $stList ))
  8280. $stList = array (
  8281. 'rePrice' => 0,
  8282. 'agPrice' => 0
  8283. );
  8284. $data ['stList'] = array (
  8285. 'rePrice' => $stList ['rePrice'],
  8286. 'agPrice' => $stList ['agPrice'],
  8287. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8288. );
  8289. $monthHtml = "";
  8290. for($i = 1; $i <= 12; $i ++) {
  8291. if ($i == $month)
  8292. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8293. else
  8294. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8295. }
  8296. $data ['monthHtml'] = $monthHtml;
  8297. $data ['year'] = $year;
  8298. $data ['month'] = $month;
  8299. $data ['memu'] = "receipt";
  8300. $data ['staff'] = $this->staff;
  8301. $data ['receiptMemu'] = 'companyCategoryCollect';
  8302. $data ['verifyId'] = $this->verifyId;
  8303. $data ['executeId'] = $this->executeId;
  8304. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  8305. Doo::loadModel ( 'receipt' );
  8306. $receipt = new receipt ();
  8307. $receiptList = $receipt->find ( array (
  8308. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  8309. 'asArray' => true
  8310. ) );
  8311. if (empty ( $receiptList )) { // generated files
  8312. ob_start ();
  8313. $this->render ( "/admin/saeaStaffCollect", $data );
  8314. $this->cacheFile ( $path );
  8315. die ();
  8316. }
  8317. }
  8318. $this->render ( "/admin/saeaStaffCollect", $data );
  8319. }
  8320. function lyt() {
  8321. Doo::loadModel ( "receiptDetail" );
  8322. $receiptDetail = new receiptDetail ();
  8323. $receiptCollectList = $receiptDetail->find ( array (
  8324. 'where' => 'status=1 ',
  8325. 'asArray' => true
  8326. ) );
  8327. foreach ( $receiptCollectList as $key => $value ) {
  8328. $receiptDetail = new receiptDetail ();
  8329. $receiptDetail->pastDate = $value ['date'];
  8330. $receiptDetail->update ( array (
  8331. 'where' => "rdid= '" . $value ['rdid'] . "'"
  8332. ) );
  8333. }
  8334. }
  8335. function staffCollectMonthDetail() {
  8336. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8337. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8338. if (! $year)
  8339. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8340. if (! $month)
  8341. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8342. Doo::loadModel ( 'staff' );
  8343. $staff = new staff ();
  8344. Doo::loadModel ( "receiptDetail" );
  8345. $receiptDetail = new receiptDetail ();
  8346. Doo::loadModel ( 'accountItem' );
  8347. $accountItem = new accountItem ();
  8348. Doo::loadModel ( 'statistics' );
  8349. $statistics = new statistics ();
  8350. Doo::loadModel ( 'L_category' );
  8351. $lCategory = new L_category ();
  8352. $staffList = $staff->find ( array (
  8353. 'where' => 'username!="admin"',
  8354. 'asArray' => true
  8355. ) );
  8356. $categoryList = $staff->find ( array (
  8357. 'select' => 'COUNT(*) as count,cid,category',
  8358. 'where' => 'username !="admin"',
  8359. 'groupby' => 'cid',
  8360. 'asArray' => true
  8361. ) );
  8362. $list = array ();
  8363. foreach ( $categoryList as $vlu ) {
  8364. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8365. $r1 = 0;
  8366. $r2 = 0;
  8367. $r3 = 0;
  8368. $r4 = 0;
  8369. $r5 = 0;
  8370. $r6 = 0;
  8371. $r7 = 0;
  8372. $r8 = 0;
  8373. $r9 = 0;
  8374. $r10 = 0;
  8375. $r11 = 0;
  8376. $r12 = 0;
  8377. $r13 = 0;
  8378. $r14 = 0;
  8379. $r15 = 0;
  8380. $c1 = 0;
  8381. $c2 = 0;
  8382. $c3 = 0;
  8383. $c4 = 0;
  8384. $c5 = 0;
  8385. $c6 = 0;
  8386. $p1 = 0;
  8387. $p2 = 0;
  8388. $p3 = 0;
  8389. $p4 = 0;
  8390. $p5 = 0;
  8391. $p6 = 0;
  8392. $p7 = 0;
  8393. $p8 = 0;
  8394. $p9 = 0;
  8395. $t1 = 0;
  8396. $t2 = 0;
  8397. $t3 = 0;
  8398. $t4 = 0;
  8399. $t5 = 0;
  8400. $s1 = 0;
  8401. $m1 = 0;
  8402. foreach ( $staffList as $value ) {
  8403. if ($vlu ['cid'] == $value ['cid']) {
  8404. // pastDate
  8405. $receiptCollectList = $receiptDetail->find ( array (
  8406. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8407. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8408. 'groupby' => 'item,Month(pastDate),itemCategory',
  8409. 'asArray' => true
  8410. ) );
  8411. // if ($value['sid']==42){
  8412. // print_r($receiptCollectList);die;
  8413. // }
  8414. if (! empty ( $receiptCollectList )) {
  8415. $receiptL = array (
  8416. '日常相关费用' => array (),
  8417. '差旅相关费用' => array (),
  8418. '培训班费用' => array (),
  8419. '其他' => array ()
  8420. );
  8421. $html = "";
  8422. $psum = 0;
  8423. $item = array (
  8424. '市内交通费',
  8425. '市内出租费',
  8426. '办事处房租',
  8427. '电话费',
  8428. '水费',
  8429. '电费',
  8430. '办公费用',
  8431. '邮寄费',
  8432. '其他费用',
  8433. '车辆费用',
  8434. '广告费',
  8435. '团队建设费',
  8436. '物业管理费',
  8437. '宽带费'
  8438. );
  8439. foreach ( $item as $va ) {
  8440. $falg = true;
  8441. foreach ( $receiptCollectList as $v ) {
  8442. if ($v ['itemCategory'] == '日常相关费用') {
  8443. if ($v ['item'] == $va) {
  8444. if ($va == '市内交通费')
  8445. $r1 += $v ['price'];
  8446. if ($va == '市内出租费')
  8447. $r2 += $v ['price'];
  8448. if ($va == '办事处房租')
  8449. $r3 += $v ['price'];
  8450. if ($va == '电话费')
  8451. $r4 += $v ['price'];
  8452. if ($va == '水费')
  8453. $r5 += $v ['price'];
  8454. if ($va == '电费')
  8455. $r6 += $v ['price'];
  8456. if ($va == '办公费用')
  8457. $r7 += $v ['price'];
  8458. if ($va == '邮寄费')
  8459. $r8 += $v ['price'];
  8460. if ($va == '其他费用')
  8461. $r9 += $v ['price'];
  8462. if ($va == '车辆费用')
  8463. $r10 += $v ['price'];
  8464. if ($va == '广告费')
  8465. $r11 += $v ['price'];
  8466. if ($va == '团队建设费')
  8467. $r13 += $v ['price'];
  8468. if ($va == '物业管理费')
  8469. $r14 += $v ['price'];
  8470. if ($va == '宽带费')
  8471. $r15 += $v ['price'];
  8472. $psum += $v ['price'];
  8473. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8474. $falg = false;
  8475. break;
  8476. }
  8477. }
  8478. }
  8479. if ($falg)
  8480. $html .= '<td class="taR">-</td>';
  8481. }
  8482. $r12 += $psum;
  8483. if (! empty ( $psum ))
  8484. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8485. else
  8486. $psum = '<td class="colGreen taR">-</td>';
  8487. $receiptL ['日常相关费用'] = $psum . $html;
  8488. /* ----------------------------------- */
  8489. $html = "";
  8490. $psum = 0;
  8491. $item = array (
  8492. '往来交通费',
  8493. '市内交通费',
  8494. '出差住宿费',
  8495. '出差补助',
  8496. '其他费用'
  8497. );
  8498. foreach ( $item as $va ) {
  8499. $falg = true;
  8500. foreach ( $receiptCollectList as $v ) {
  8501. if ($v ['itemCategory'] == '差旅相关费用') {
  8502. if ($v ['item'] == $va) {
  8503. if ($va == '往来交通费')
  8504. $c1 += $v ['price'];
  8505. if ($va == '市内交通费')
  8506. $c2 += $v ['price'];
  8507. if ($va == '出差住宿费')
  8508. $c3 += $v ['price'];
  8509. if ($va == '出差补助')
  8510. $c4 += $v ['price'];
  8511. if ($va == '其他费用')
  8512. $c5 += $v ['price'];
  8513. $psum += $v ['price'];
  8514. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8515. $falg = false;
  8516. break;
  8517. }
  8518. }
  8519. }
  8520. if ($falg)
  8521. $html .= '<td class="taR">-</td>';
  8522. }
  8523. $c6 += $psum;
  8524. if (! empty ( $psum ))
  8525. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8526. else
  8527. $psum = '<td class="colGreen taR">-</td>';
  8528. $receiptL ['差旅相关费用'] = $psum . $html;
  8529. /* ------------------------------------- */
  8530. $html = "";
  8531. $psum = 0;
  8532. $item = array (
  8533. '场租费',
  8534. '薪酬',
  8535. '住宿费',
  8536. '交通费',
  8537. '餐饮费',
  8538. '办公费',
  8539. '公关费',
  8540. '其他'
  8541. );
  8542. foreach ( $item as $va ) {
  8543. $falg = true;
  8544. foreach ( $receiptCollectList as $v ) {
  8545. if ($v ['itemCategory'] == '培训班费用') {
  8546. if ($v ['item'] == $va) {
  8547. if ($va == '场租费')
  8548. $p1 += $v ['price'];
  8549. if ($va == '薪酬')
  8550. $p2 += $v ['price'];
  8551. if ($va == '住宿费')
  8552. $p3 += $v ['price'];
  8553. if ($va == '交通费')
  8554. $p4 += $v ['price'];
  8555. if ($va == '餐饮费')
  8556. $p5 += $v ['price'];
  8557. if ($va == '办公费')
  8558. $p6 += $v ['price'];
  8559. if ($va == '公关费')
  8560. $p7 += $v ['price'];
  8561. if ($va == '其他')
  8562. $p8 += $v ['price'];
  8563. $psum += $v ['price'];
  8564. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8565. $falg = false;
  8566. break;
  8567. }
  8568. }
  8569. }
  8570. if ($falg)
  8571. $html .= '<td class="taR">-</td>';
  8572. }
  8573. $p9 += $psum;
  8574. if (! empty ( $psum ))
  8575. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8576. else
  8577. $psum = '<td class="colGreen taR">-</td>';
  8578. $receiptL ['培训班费用'] = $psum . $html;
  8579. /* ------------------------------------- */
  8580. $html = "";
  8581. $psum = 0;
  8582. $item = array (
  8583. '公关费',
  8584. '广告费',
  8585. '借款',
  8586. '可自加费用'
  8587. );
  8588. foreach ( $item as $va ) {
  8589. $falg = true;
  8590. foreach ( $receiptCollectList as $v ) {
  8591. if ($v ['itemCategory'] == '其他') {
  8592. // if ($value['sid']==42){
  8593. //
  8594. // echo var_dump($v['item']);
  8595. // echo var_dump($va);
  8596. // echo var_dump($v['item']==" ".$va);
  8597. // echo $v['item']."==".$va."/<br/>";
  8598. // //print_r( $receiptCollectList);//echo $va;
  8599. // }
  8600. if (trim ( $v ['item'] ) == $va) {
  8601. if ($va == '公关费')
  8602. $t1 += $v ['price'];
  8603. if ($va == '广告费') {
  8604. $t2 += $v ['price'];
  8605. }
  8606. if ($va == '借款')
  8607. $t3 += $v ['price'];
  8608. if ($va == '可自加费用')
  8609. $t4 += $v ['price'];
  8610. $psum += $v ['price'];
  8611. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8612. $falg = false;
  8613. break;
  8614. }
  8615. }
  8616. }
  8617. if ($falg)
  8618. $html .= '<td class="taR">-</td>';
  8619. }
  8620. $t5 += $psum;
  8621. if (! empty ( $psum ))
  8622. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8623. else
  8624. $psum = '<td class="colGreen taR">-</td>';
  8625. $receiptL ['其他'] = $psum . $html;
  8626. /* ------------------------------------- */
  8627. $html = "";
  8628. $psum = 0;
  8629. foreach ( $receiptCollectList as $v ) {
  8630. if ($v ['itemCategory'] == '报销金额调整') {
  8631. if (! empty ( $v ['price'] )) {
  8632. $psum += $v ['price'];
  8633. }
  8634. }
  8635. }
  8636. $s1 += $psum;
  8637. if (! empty ( $psum ))
  8638. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8639. else
  8640. $psum = '<td class="taR colOrange">-</td>';
  8641. $receiptL ['报销金额调整'] = $psum . $html;
  8642. } else {
  8643. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8644. <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>
  8645. <td class="taR">-</td><td class="taR">-</td>';
  8646. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  8647. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8648. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8649. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8650. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8651. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  8652. }
  8653. $monthStaffPrice = $receiptDetail->find ( array (
  8654. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8655. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8656. 'groupby' => 'Month(pastDate)',
  8657. 'asArray' => true
  8658. ) );
  8659. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  8660. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  8661. $m1 += $monthStaffPrice [0] ['price'];
  8662. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  8663. } else
  8664. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  8665. $list [$value ['username']] = $receiptL;
  8666. }
  8667. }
  8668. $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>
  8669. <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>
  8670. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  8671. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  8672. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  8673. $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>
  8674. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  8675. $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>';
  8676. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  8677. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  8678. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  8679. }
  8680. $data ['list'] = $list;
  8681. $receiptCollectList = $receiptDetail->find ( array (
  8682. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8683. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8684. 'groupby' => 'item,Month(pastDate),itemCategory',
  8685. 'asArray' => true
  8686. ) );
  8687. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  8688. // statistics html
  8689. $stList = $statistics->getOne ( array (
  8690. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8691. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8692. 'groupby' => 'Month(date)',
  8693. 'asArray' => true
  8694. ) );
  8695. if (empty ( $stList ))
  8696. $stList = array (
  8697. 'rePrice' => 0,
  8698. 'agPrice' => 0
  8699. );
  8700. $data ['stList'] = array (
  8701. 'rePrice' => $stList ['rePrice'],
  8702. 'agPrice' => $stList ['agPrice'],
  8703. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8704. );
  8705. $monthHtml = "";
  8706. for($i = 1; $i <= 12; $i ++) {
  8707. if ($i == $month)
  8708. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8709. else
  8710. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8711. }
  8712. $data ['monthHtml'] = $monthHtml;
  8713. $data ['year'] = $year;
  8714. $data ['month'] = $month;
  8715. $data ['memu'] = "receipt";
  8716. $data ['staff'] = $this->staff;
  8717. $data ['receiptMemu'] = 'companyCategoryCollect';
  8718. $data ['verifyId'] = $this->verifyId;
  8719. $data ['executeId'] = $this->executeId;
  8720. $this->render ( "/admin/staffCollectMonthDetail", $data );
  8721. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  8722. }
  8723. function staffCollectMonthDetail2() {
  8724. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8725. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8726. if (! $year)
  8727. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8728. if (! $month)
  8729. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8730. Doo::loadModel ( 'staff' );
  8731. $staff = new staff ();
  8732. Doo::loadModel ( "receiptDetail" );
  8733. $receiptDetail = new receiptDetail ();
  8734. Doo::loadModel ( 'accountItem' );
  8735. $accountItem = new accountItem ();
  8736. Doo::loadModel ( 'statistics' );
  8737. $statistics = new statistics ();
  8738. Doo::loadModel ( 'L_category' );
  8739. $lCategory = new L_category ();
  8740. $staffList = $staff->find ( array (
  8741. 'where' => 'username!="admin"',
  8742. 'asArray' => true
  8743. ) );
  8744. $categoryList = $staff->find ( array (
  8745. 'select' => 'COUNT(*) as count,cid,category',
  8746. 'where' => 'username !="admin"',
  8747. 'groupby' => 'cid',
  8748. 'asArray' => true
  8749. ) );
  8750. $list = array ();
  8751. foreach ( $categoryList as $vlu ) {
  8752. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8753. $r1 = 0;
  8754. $r2 = 0;
  8755. $r3 = 0;
  8756. $r4 = 0;
  8757. $r5 = 0;
  8758. $r6 = 0;
  8759. $r7 = 0;
  8760. $r8 = 0;
  8761. $r9 = 0;
  8762. $r10 = 0;
  8763. $r11 = 0;
  8764. $r12 = 0;
  8765. $r13 = 0;
  8766. $r14 = 0;
  8767. $r15 = 0;
  8768. $c1 = 0;
  8769. $c2 = 0;
  8770. $c3 = 0;
  8771. $c4 = 0;
  8772. $c5 = 0;
  8773. $c6 = 0;
  8774. $p1 = 0;
  8775. $p2 = 0;
  8776. $p3 = 0;
  8777. $p4 = 0;
  8778. $p5 = 0;
  8779. $p6 = 0;
  8780. $p7 = 0;
  8781. $p8 = 0;
  8782. $p9 = 0;
  8783. $t1 = 0;
  8784. $t2 = 0;
  8785. $t3 = 0;
  8786. $t4 = 0;
  8787. $t5 = 0;
  8788. $s1 = 0;
  8789. $m1 = 0;
  8790. foreach ( $staffList as $value ) {
  8791. if ($vlu ['cid'] == $value ['cid']) {
  8792. $receiptCollectList = $receiptDetail->find ( array (
  8793. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  8794. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  8795. 'groupby' => 'item,Month(date),itemCategory',
  8796. 'asArray' => true
  8797. ) );
  8798. if (! empty ( $receiptCollectList )) {
  8799. $receiptL = array (
  8800. '日常相关费用' => array (),
  8801. '差旅相关费用' => array (),
  8802. '培训班费用' => array (),
  8803. '其他' => array ()
  8804. );
  8805. $html = "";
  8806. $psum = 0;
  8807. $item = array (
  8808. '市内交通费',
  8809. '市内出租费',
  8810. '办事处房租',
  8811. '电话费',
  8812. '水费',
  8813. '电费',
  8814. '办公费用',
  8815. '邮寄费',
  8816. '其他费用',
  8817. '车辆费用',
  8818. '广告费',
  8819. '团队建设费',
  8820. '物业管理费',
  8821. '宽带费'
  8822. );
  8823. foreach ( $item as $va ) {
  8824. $falg = true;
  8825. foreach ( $receiptCollectList as $v ) {
  8826. if ($v ['itemCategory'] == '日常相关费用') {
  8827. if ($v ['item'] == $va) {
  8828. if ($va == '市内交通费')
  8829. $r1 += $v ['price'];
  8830. if ($va == '市内出租费')
  8831. $r2 += $v ['price'];
  8832. if ($va == '办事处房租')
  8833. $r3 += $v ['price'];
  8834. if ($va == '电话费')
  8835. $r4 += $v ['price'];
  8836. if ($va == '水费')
  8837. $r5 += $v ['price'];
  8838. if ($va == '电费')
  8839. $r6 += $v ['price'];
  8840. if ($va == '办公费用')
  8841. $r7 += $v ['price'];
  8842. if ($va == '邮寄费')
  8843. $r8 += $v ['price'];
  8844. if ($va == '其他费用')
  8845. $r9 += $v ['price'];
  8846. if ($va == '车辆费用')
  8847. $r10 += $v ['price'];
  8848. if ($va == '广告费')
  8849. $r11 += $v ['price'];
  8850. if ($va == '团队建设费')
  8851. $r13 += $v ['price'];
  8852. if ($va == '物业管理费')
  8853. $r14 += $v ['price'];
  8854. if ($va == '宽带费')
  8855. $r15 += $v ['price'];
  8856. $psum += $v ['price'];
  8857. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8858. $falg = false;
  8859. break;
  8860. }
  8861. }
  8862. }
  8863. if ($falg)
  8864. $html .= '<td class="taR">-</td>';
  8865. }
  8866. $r12 += $psum;
  8867. if (! empty ( $psum ))
  8868. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8869. else
  8870. $psum = '<td class="colGreen taR">-</td>';
  8871. $receiptL ['日常相关费用'] = $psum . $html;
  8872. /* ----------------------------------- */
  8873. $html = "";
  8874. $psum = 0;
  8875. $item = array (
  8876. '往来交通费',
  8877. '市内交通费',
  8878. '出差住宿费',
  8879. '出差补助',
  8880. '其他费用'
  8881. );
  8882. foreach ( $item as $va ) {
  8883. $falg = true;
  8884. foreach ( $receiptCollectList as $v ) {
  8885. if ($v ['itemCategory'] == '差旅相关费用') {
  8886. if ($v ['item'] == $va) {
  8887. if ($va == '往来交通费')
  8888. $c1 += $v ['price'];
  8889. if ($va == '市内交通费')
  8890. $c2 += $v ['price'];
  8891. if ($va == '出差住宿费')
  8892. $c3 += $v ['price'];
  8893. if ($va == '出差补助')
  8894. $c4 += $v ['price'];
  8895. if ($va == '其他费用')
  8896. $c5 += $v ['price'];
  8897. $psum += $v ['price'];
  8898. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8899. $falg = false;
  8900. break;
  8901. }
  8902. }
  8903. }
  8904. if ($falg)
  8905. $html .= '<td class="taR">-</td>';
  8906. }
  8907. $c6 += $psum;
  8908. if (! empty ( $psum ))
  8909. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8910. else
  8911. $psum = '<td class="colGreen taR">-</td>';
  8912. $receiptL ['差旅相关费用'] = $psum . $html;
  8913. /* ------------------------------------- */
  8914. $html = "";
  8915. $psum = 0;
  8916. $item = array (
  8917. '场租费',
  8918. '薪酬',
  8919. '住宿费',
  8920. '交通费',
  8921. '餐饮费',
  8922. '办公费',
  8923. '公关费',
  8924. '其他'
  8925. );
  8926. foreach ( $item as $va ) {
  8927. $falg = true;
  8928. foreach ( $receiptCollectList as $v ) {
  8929. if ($v ['itemCategory'] == '培训班费用') {
  8930. if ($v ['item'] == $va) {
  8931. if ($va == '场租费')
  8932. $p1 += $v ['price'];
  8933. if ($va == '薪酬')
  8934. $p2 += $v ['price'];
  8935. if ($va == '住宿费')
  8936. $p3 += $v ['price'];
  8937. if ($va == '交通费')
  8938. $p4 += $v ['price'];
  8939. if ($va == '餐饮费')
  8940. $p5 += $v ['price'];
  8941. if ($va == '办公费')
  8942. $p6 += $v ['price'];
  8943. if ($va == '公关费')
  8944. $p7 += $v ['price'];
  8945. if ($va == '其他')
  8946. $p8 += $v ['price'];
  8947. $psum += $v ['price'];
  8948. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8949. $falg = false;
  8950. break;
  8951. }
  8952. }
  8953. }
  8954. if ($falg)
  8955. $html .= '<td class="taR">-</td>';
  8956. }
  8957. $p9 += $psum;
  8958. if (! empty ( $psum ))
  8959. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8960. else
  8961. $psum = '<td class="colGreen taR">-</td>';
  8962. $receiptL ['培训班费用'] = $psum . $html;
  8963. /* ------------------------------------- */
  8964. $html = "";
  8965. $psum = 0;
  8966. $item = array (
  8967. '公关费',
  8968. '广告费',
  8969. '借款',
  8970. '可自加费用'
  8971. );
  8972. foreach ( $item as $va ) {
  8973. $falg = true;
  8974. foreach ( $receiptCollectList as $v ) {
  8975. if ($v ['itemCategory'] == '其他') {
  8976. if ($v ['item'] == $va) {
  8977. if ($va == '公关费')
  8978. $t1 += $v ['price'];
  8979. if ($va == '广告费')
  8980. $t2 += $v ['price'];
  8981. if ($va == '借款')
  8982. $t3 += $v ['price'];
  8983. if ($va == '可自加费用')
  8984. $t4 += $v ['price'];
  8985. $psum += $v ['price'];
  8986. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8987. $falg = false;
  8988. break;
  8989. }
  8990. }
  8991. }
  8992. if ($falg)
  8993. $html .= '<td class="taR">-</td>';
  8994. }
  8995. $t5 += $psum;
  8996. if (! empty ( $psum ))
  8997. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8998. else
  8999. $psum = '<td class="colGreen taR">-</td>';
  9000. $receiptL ['其他'] = $psum . $html;
  9001. /* ------------------------------------- */
  9002. $html = "";
  9003. $psum = 0;
  9004. foreach ( $receiptCollectList as $v ) {
  9005. if ($v ['itemCategory'] == '报销金额调整') {
  9006. if (! empty ( $v ['price'] )) {
  9007. $psum += $v ['price'];
  9008. }
  9009. }
  9010. }
  9011. $s1 += $psum;
  9012. if (! empty ( $psum ))
  9013. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9014. else
  9015. $psum = '<td class="taR colOrange">-</td>';
  9016. $receiptL ['报销金额调整'] = $psum . $html;
  9017. } else {
  9018. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9019. <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>';
  9020. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9021. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9022. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9023. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9024. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9025. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9026. }
  9027. $monthStaffPrice = $receiptDetail->find ( array (
  9028. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9029. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9030. 'asArray' => true
  9031. ) );
  9032. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  9033. $m1 += $monthStaffPrice [0] ['price'];
  9034. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9035. } else
  9036. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9037. $list [$value ['username']] = $receiptL;
  9038. }
  9039. }
  9040. $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>
  9041. <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>
  9042. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  9043. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  9044. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  9045. $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>
  9046. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  9047. $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>';
  9048. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  9049. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  9050. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  9051. }
  9052. $data ['list'] = $list;
  9053. $receiptCollectList = $receiptDetail->find ( array (
  9054. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9055. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9056. 'groupby' => 'item,Month(date),itemCategory',
  9057. 'asArray' => true
  9058. ) );
  9059. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9060. // statistics html
  9061. $stList = $statistics->getOne ( array (
  9062. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9063. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9064. 'groupby' => 'Month(date)',
  9065. 'asArray' => true
  9066. ) );
  9067. if (empty ( $stList ))
  9068. $stList = array (
  9069. 'rePrice' => 0,
  9070. 'agPrice' => 0
  9071. );
  9072. $data ['stList'] = array (
  9073. 'rePrice' => $stList ['rePrice'],
  9074. 'agPrice' => $stList ['agPrice'],
  9075. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9076. );
  9077. $monthHtml = "";
  9078. for($i = 1; $i <= 12; $i ++) {
  9079. if ($i == $month)
  9080. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9081. else
  9082. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9083. }
  9084. $data ['monthHtml'] = $monthHtml;
  9085. $data ['year'] = $year;
  9086. $data ['month'] = $month;
  9087. $data ['memu'] = "receipt";
  9088. $data ['staff'] = $this->staff;
  9089. $data ['receiptMemu'] = 'companyCategoryCollect';
  9090. $data ['verifyId'] = $this->verifyId;
  9091. $data ['executeId'] = $this->executeId;
  9092. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  9093. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9094. }
  9095. function companyMonthCollectDetail() {
  9096. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9097. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9098. if (! $year)
  9099. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9100. if (! $month)
  9101. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9102. Doo::loadModel ( 'staff' );
  9103. $staff = new staff ();
  9104. Doo::loadModel ( "receiptDetail" );
  9105. $receiptDetail = new receiptDetail ();
  9106. Doo::loadModel ( 'accountItem' );
  9107. $accountItem = new accountItem ();
  9108. Doo::loadModel ( 'statistics' );
  9109. $statistics = new statistics ();
  9110. Doo::loadModel ( 'L_category' );
  9111. $lCategory = new L_category ();
  9112. $staffList = $staff->find ( array (
  9113. 'where' => 'username!="admin"',
  9114. 'asArray' => true
  9115. ) );
  9116. $categoryList = $lCategory->find ( array (
  9117. 'asArray' => true
  9118. ) );
  9119. $list = array ();
  9120. foreach ( $categoryList as $value ) {
  9121. $receiptCollectList = $receiptDetail->find ( array (
  9122. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9123. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9124. 'groupby' => 'item,Month(pastDate),itemCategory',
  9125. 'asArray' => true
  9126. ) );
  9127. if (! empty ( $receiptCollectList )) {
  9128. $receiptL = array (
  9129. '日常相关费用' => array (),
  9130. '差旅相关费用' => array (),
  9131. '培训班费用' => array (),
  9132. '其他' => array ()
  9133. );
  9134. $html = "";
  9135. $psum = 0;
  9136. $item = array (
  9137. '市内交通费',
  9138. '市内出租费',
  9139. '办事处房租',
  9140. '电话费',
  9141. '水费',
  9142. '电费',
  9143. '办公费用',
  9144. '邮寄费',
  9145. '其他费用',
  9146. '车辆费用',
  9147. '广告费',
  9148. '团队建设费'
  9149. );
  9150. foreach ( $item as $va ) {
  9151. $falg = true;
  9152. foreach ( $receiptCollectList as $v ) {
  9153. if ($v ['itemCategory'] == '日常相关费用') {
  9154. if ($v ['item'] == $va) {
  9155. $psum += $v ['price'];
  9156. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9157. $falg = false;
  9158. break;
  9159. }
  9160. }
  9161. }
  9162. if ($falg)
  9163. $html .= '<td class="taR">-</td>';
  9164. }
  9165. if (! empty ( $psum ))
  9166. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9167. else
  9168. $psum = '<td class="colGreen taR">-</td>';
  9169. $receiptL ['日常相关费用'] = $psum . $html;
  9170. /* ----------------------------------- */
  9171. $html = "";
  9172. $psum = 0;
  9173. $item = array (
  9174. '往来交通费',
  9175. '市内交通费',
  9176. '出差住宿费',
  9177. '出差补助',
  9178. '其他费用'
  9179. );
  9180. foreach ( $item as $va ) {
  9181. $falg = true;
  9182. foreach ( $receiptCollectList as $v ) {
  9183. if ($v ['itemCategory'] == '差旅相关费用') {
  9184. if ($v ['item'] == $va) {
  9185. $psum += $v ['price'];
  9186. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9187. $falg = false;
  9188. break;
  9189. }
  9190. }
  9191. }
  9192. if ($falg)
  9193. $html .= '<td class="taR">-</td>';
  9194. }
  9195. if (! empty ( $psum ))
  9196. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9197. else
  9198. $psum = '<td class="colGreen taR">-</td>';
  9199. $receiptL ['差旅相关费用'] = $psum . $html;
  9200. /* ------------------------------------- */
  9201. $html = "";
  9202. $psum = 0;
  9203. $item = array (
  9204. '场租费',
  9205. '薪酬',
  9206. '住宿费',
  9207. '交通费',
  9208. '餐饮费',
  9209. '办公费',
  9210. '公关费',
  9211. '其他'
  9212. );
  9213. foreach ( $item as $va ) {
  9214. $falg = true;
  9215. foreach ( $receiptCollectList as $v ) {
  9216. if ($v ['itemCategory'] == '培训班费用') {
  9217. if ($v ['item'] == $va) {
  9218. $psum += $v ['price'];
  9219. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9220. $falg = false;
  9221. break;
  9222. }
  9223. }
  9224. }
  9225. if ($falg)
  9226. $html .= '<td class="taR">-</td>';
  9227. }
  9228. if (! empty ( $psum ))
  9229. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9230. else
  9231. $psum = '<td class="colGreen taR">-</td>';
  9232. $receiptL ['培训班费用'] = $psum . $html;
  9233. /* ------------------------------------- */
  9234. $html = "";
  9235. $psum = 0;
  9236. $item = array (
  9237. '公关费',
  9238. '广告费',
  9239. '借款',
  9240. '可自加费用'
  9241. );
  9242. foreach ( $item as $va ) {
  9243. $falg = true;
  9244. foreach ( $receiptCollectList as $v ) {
  9245. if ($v ['itemCategory'] == '其他') {
  9246. if ($v ['item'] == $va) {
  9247. $psum += $v ['price'];
  9248. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9249. $falg = false;
  9250. break;
  9251. }
  9252. }
  9253. }
  9254. if ($falg)
  9255. $html .= '<td class="taR">-</td>';
  9256. }
  9257. if (! empty ( $psum ))
  9258. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9259. else
  9260. $psum = '<td class="colGreen taR">-</td>';
  9261. $receiptL ['其他'] = $psum . $html;
  9262. /* ------------------------------------- */
  9263. $html = "";
  9264. $psum = 0;
  9265. foreach ( $receiptCollectList as $v ) {
  9266. if ($v ['itemCategory'] == '报销金额调整') {
  9267. if (! empty ( $v ['price'] ))
  9268. $psum += $v ['price'];
  9269. }
  9270. }
  9271. if (! empty ( $psum ))
  9272. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9273. else
  9274. $psum = '<td class="taR colOrange">-</td>';
  9275. $receiptL ['报销金额调整'] = $psum . $html;
  9276. } else {
  9277. $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>
  9278. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9279. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9280. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9281. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9282. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9283. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9284. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9285. }
  9286. $monthStaffPrice = $receiptDetail->find ( array (
  9287. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9288. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9289. 'asArray' => true
  9290. ) );
  9291. if (! empty ( $monthStaffPrice [0] ['price'] ))
  9292. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9293. else
  9294. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9295. $list [$value ['title']] = $receiptL;
  9296. }
  9297. $data ['list'] = $list;
  9298. $receiptCollectList = $receiptDetail->find ( array (
  9299. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9300. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9301. 'groupby' => 'item,Month(pastDate),itemCategory',
  9302. 'asArray' => true
  9303. ) );
  9304. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9305. // print_r($data['monthPriceHtml']);
  9306. // foreach ($data['monthPriceHtml'] as $value){
  9307. // echo $value;
  9308. // }
  9309. // die;
  9310. // statistics html
  9311. $stList = $statistics->getOne ( array (
  9312. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9313. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9314. 'groupby' => 'Month(date)',
  9315. 'asArray' => true
  9316. ) );
  9317. if (empty ( $stList ))
  9318. $stList = array (
  9319. 'rePrice' => 0,
  9320. 'agPrice' => 0
  9321. );
  9322. $data ['stList'] = array (
  9323. 'rePrice' => $stList ['rePrice'],
  9324. 'agPrice' => $stList ['agPrice'],
  9325. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9326. );
  9327. $monthHtml = "";
  9328. for($i = 1; $i <= 12; $i ++) {
  9329. if ($i == $month)
  9330. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9331. else
  9332. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9333. }
  9334. $data ['monthHtml'] = $monthHtml;
  9335. $data ['year'] = $year;
  9336. $data ['month'] = $month;
  9337. $data ['memu'] = "receipt";
  9338. $data ['staff'] = $this->staff;
  9339. $data ['receiptMemu'] = 'companyCategoryCollect';
  9340. $data ['verifyId'] = $this->verifyId;
  9341. $data ['executeId'] = $this->executeId;
  9342. $this->render ( "/admin/companyMonthCollectDetail", $data );
  9343. }
  9344. function staffCollectDetail() {
  9345. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9346. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  9347. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  9348. if (! $staffname) {
  9349. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  9350. $staffname = urldecode ( $staffname );
  9351. }
  9352. Doo::loadModel ( 'staff' );
  9353. $staff = new staff ();
  9354. Doo::loadModel ( "receiptDetail" );
  9355. $receiptDetail = new receiptDetail ();
  9356. Doo::loadModel ( 'accountItem' );
  9357. $accountItem = new accountItem ();
  9358. Doo::loadModel ( 'statistics' );
  9359. $statistics = new statistics ();
  9360. Doo::loadModel ( 'L_category' );
  9361. $lCategory = new L_category ();
  9362. $staffList = $staff->find ( array (
  9363. 'asArray' => true
  9364. ) );
  9365. $stHtml = '';
  9366. $stTitle = "";
  9367. $staffId = 0;
  9368. $cid = 0;
  9369. $ocid = 0;
  9370. foreach ( $staffList as $value ) {
  9371. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  9372. $stTitle = $value ['category'] . '-' . $value ['username'];
  9373. $staffId = $value ['sid'];
  9374. $cid = $value ['cid'];
  9375. $ocid = $value ['cid'];
  9376. if (! empty ( $value ['othercid'] ))
  9377. $cid = $value ['cid'] . ',' . $value ['othercid'];
  9378. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9379. } elseif ($value ['username'] != 'admin')
  9380. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9381. }
  9382. $data ['lCategoryHtml'] = $lCategory->find ( array (
  9383. 'where' => 'cid in(' . $cid . ')',
  9384. 'asArray' => true
  9385. ) );
  9386. if (empty ( $pcid ))
  9387. $pcid = $ocid;
  9388. $data ['ocid'] = $pcid;
  9389. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  9390. $this->showCache ( $path );
  9391. //
  9392. $receiptCollectList = $receiptDetail->find ( array (
  9393. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9394. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9395. 'groupby' => 'item,Month(pastDate),itemCategory',
  9396. 'asArray' => true
  9397. ) );
  9398. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  9399. // print_r($receiptCollectList);
  9400. $accountList = $accountItem->find ( array (
  9401. 'asArray' => true
  9402. ) );
  9403. // create CollectDetail HTML
  9404. $collectHtml = array ();
  9405. foreach ( $accountList as $key => $value ) {
  9406. $html = "";
  9407. $asum = 0;
  9408. for($i = 1; $i <= 12; $i ++) {
  9409. $falg = true;
  9410. foreach ( $receiptCollectList as $v ) {
  9411. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9412. if ($v ['item'] == '可自加费用') {
  9413. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  9414. }
  9415. $asum += $v ['price'];
  9416. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9417. $falg = false;
  9418. break;
  9419. }
  9420. }
  9421. if ($falg)
  9422. $html .= '<td class="taR">-</td>';
  9423. }
  9424. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9425. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9426. }
  9427. $data ['collectHtml'] = $collectHtml;
  9428. // print_r($collectHtml);
  9429. // create Adjustment price html
  9430. $receiptCollectList = $receiptDetail->find ( array (
  9431. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9432. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9433. 'groupby' => 'itemCategory,Month(pastDate)',
  9434. 'asArray' => true
  9435. ) );
  9436. $adjustment = array ();
  9437. $collectArray = array (
  9438. '日常相关费用' => array (),
  9439. '差旅相关费用' => array (),
  9440. '培训班费用' => array (),
  9441. '其他' => array ()
  9442. );
  9443. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9444. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9445. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9446. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9447. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9448. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9449. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9450. array_push ( $collectArray ['其他'], $collectHtml );
  9451. $data ['collectArray'] = $collectArray;
  9452. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9453. array_push ( $adjustment, $collectHtml );
  9454. $data ['adjustment'] = $adjustment;
  9455. // total price html
  9456. $collectHtml = "";
  9457. $total = 0;
  9458. for($i = 1; $i <= 12; $i ++) {
  9459. $sumPrice = 0;
  9460. foreach ( $receiptCollectList as $key => $value ) {
  9461. if ($value ['month'] == $i) {
  9462. $sumPrice += $value ['price'];
  9463. }
  9464. }
  9465. if ($sumPrice == 0)
  9466. $collectHtml .= '<td class="taR">-</td>';
  9467. else
  9468. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9469. $total += $sumPrice;
  9470. }
  9471. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9472. // statistics html
  9473. $stList = $statistics->statisticsByYear ( $year, $staffId );
  9474. if (empty ( $stList ))
  9475. $stList = array (
  9476. 'rePrice' => 0,
  9477. 'agPrice' => 0
  9478. );
  9479. $data ['stList'] = array (
  9480. 'rePrice' => $stList ['rePrice'],
  9481. 'agPrice' => $stList ['agPrice'],
  9482. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9483. );
  9484. $data ['totalPrice'] = $collectHtml;
  9485. $data ['totalYear'] = $total;
  9486. $data ['stHtml'] = $stHtml;
  9487. $data ['year'] = $year;
  9488. $data ['stTitle'] = $stTitle;
  9489. $data ['memu'] = "receipt";
  9490. $data ['staff'] = $this->staff;
  9491. $data ['receiptMemu'] = 'companyCategoryCollect';
  9492. $data ['verifyId'] = $this->verifyId;
  9493. $data ['executeId'] = $this->executeId;
  9494. if ($year < date ( "Y" )) {
  9495. Doo::loadModel ( 'receipt' );
  9496. $receipt = new receipt ();
  9497. $receiptList = $receipt->find ( array (
  9498. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  9499. 'asArray' => true
  9500. ) );
  9501. if (empty ( $receiptList )) { // generated files
  9502. ob_start ();
  9503. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9504. $this->cacheFile ( $path );
  9505. die ();
  9506. }
  9507. }
  9508. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9509. }
  9510. function BUGFLAG() {
  9511. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  9512. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  9513. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9514. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9515. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  9516. if (empty ( $status ))
  9517. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  9518. $page_size = 12;
  9519. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  9520. $vidList = array ();
  9521. $button = 0;
  9522. Doo::loadModel ( 'verify' );
  9523. $verify = new verify ();
  9524. Doo::loadModel ( 'receipt' );
  9525. $receipt = new receipt ();
  9526. Doo::loadModel ( 'staff' );
  9527. $staff = new staff ();
  9528. Doo::loadModel ( 'L_category' );
  9529. $Lcategory = new L_category ();
  9530. $dateCondition = " and Year(date) =" . $year;
  9531. if (! empty ( $month ))
  9532. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  9533. $categoryList = $Lcategory->find ( array (
  9534. 'asArray' => true
  9535. ) );
  9536. $staffList = $staff->find ( array (
  9537. 'where' => 'cid=' . $cid,
  9538. 'asArray' => true
  9539. ) );
  9540. $cateCondition = "";
  9541. $staffCondition = "";
  9542. $approvalCondition = "";
  9543. if (! empty ( $cid ))
  9544. $cateCondition = ' and cid=' . $cid;
  9545. if (! empty ( $sid )) {
  9546. $staffCondition = ' and staff=' . $sid;
  9547. $cateCondition = "";
  9548. }
  9549. $approvalCondition = " and status=" . $status;
  9550. if ($status == 2) {
  9551. // 查找角色审批人
  9552. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9553. }
  9554. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  9555. $approvalCondition = ' and status=2 ';
  9556. }
  9557. if ($status == 1) {
  9558. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  9559. }
  9560. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  9561. $pageinfo ['page'] = array (
  9562. 'previous' => ''
  9563. );
  9564. if ($status == 0) {
  9565. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  9566. $receiptList = $receipt->find ( array (
  9567. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  9568. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  9569. 'desc' => 'rid',
  9570. 'asArray' => true
  9571. ) );
  9572. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9573. } else
  9574. $receiptList = $receipt->find ( array (
  9575. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  9576. 'desc' => 'rid',
  9577. 'asArray' => true
  9578. ) );
  9579. $rLRes = $receipt->find ( array (
  9580. '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,
  9581. 'desc' => 'rid',
  9582. 'asArray' => true
  9583. ) );
  9584. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9585. // print_r($pageinfo);
  9586. $Locate = 0;
  9587. foreach ( $receiptList as $key => $value ) {
  9588. $receiptList [$key] ['Locate'] = $Locate;
  9589. $Locate ++;
  9590. $receiptList [$key] ['reviseDetail'] = array ();
  9591. if (! empty ( $value ['reviseDetail'] ))
  9592. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  9593. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  9594. $categoryDetil = $Lcategory->getOne ( array (
  9595. 'where' => 'cid=' . $value ['cid'],
  9596. 'asArray' => true
  9597. ) );
  9598. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  9599. $verifyList = $verify->getOne ( array (
  9600. 'where' => 'vid=' . $value ['verify'],
  9601. 'asArray' => true
  9602. ) );
  9603. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  9604. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  9605. foreach ( $verifyList as $k => $v ) {
  9606. // init verifyStaff
  9607. $verifyList [$k] ['date'] = "";
  9608. $verifyList [$k] ['opinion'] = "";
  9609. $verifyList [$k] ['status'] = "";
  9610. if (empty ( $verifyStaff )) {
  9611. $verifyList [$k] ['date'] = "";
  9612. $verifyList [$k] ['opinion'] = "";
  9613. if ($v [0] == $this->staff [0] ['sid']) {
  9614. $verifyList [$k] ['status'] = 4;
  9615. $button = 4;
  9616. }
  9617. } else {
  9618. $flag = true;
  9619. foreach ( $verifyStaff as $m => $u ) {
  9620. if ($v [0] == $m) {
  9621. $verifyList [$k] ['date'] = $u ['date'];
  9622. $verifyList [$k] ['opinion'] = $u ['opinion'];
  9623. $verifyList [$k] ['status'] = $u ['status'];
  9624. $flag = false;
  9625. break;
  9626. }
  9627. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  9628. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  9629. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  9630. }
  9631. if ($flag) { // 检测可编辑
  9632. if ($v [0] == $this->staff [0] ['sid']) {
  9633. $verifyList [$k] ['status'] = 4;
  9634. $button = 4;
  9635. }
  9636. }
  9637. }
  9638. }
  9639. $receiptList [$key] ['verifyList'] = $verifyList;
  9640. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  9641. 'where' => 'sid=' . $value ['staff'],
  9642. 'asArray' => true
  9643. ) );
  9644. $receiptList [$key] ['button'] = $button;
  9645. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  9646. }
  9647. // print_r($receiptList);die;
  9648. // $data['verifyDetail']=$verifyDetail;
  9649. $mothHtml = "";
  9650. for($i = 1; $i <= 12; $i ++) {
  9651. if ($month == $i)
  9652. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  9653. else
  9654. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  9655. }
  9656. $data ['mothHtml'] = $mothHtml;
  9657. $data ['page'] = $pageinfo;
  9658. $data ['receiptList'] = $receiptList;
  9659. $data ['receiptApprovalCount'] = count ( $rLRes );
  9660. $data ['status'] = $status;
  9661. $data ['year'] = $year;
  9662. $data ['categoryList'] = $categoryList;
  9663. $data ['staffList'] = $staffList;
  9664. $data ['cid'] = $cid;
  9665. $data ['sid'] = $sid;
  9666. // print_r($receiptList);
  9667. $data ['memu'] = "receipt";
  9668. $data ['staff'] = $this->staff;
  9669. $data ['receiptMemu'] = 'approvalExpenses';
  9670. $data ['verifyId'] = $this->verifyId;
  9671. $data ['executeId'] = $this->executeId;
  9672. $this->render ( "/admin/FALG", $data );
  9673. }
  9674. function ajaxGetReceiptOrder() {
  9675. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  9676. if (! empty ( $receiptOrder )) {
  9677. Doo::loadModel ( 'receipt' );
  9678. $receipt = new receipt ();
  9679. Doo::loadModel ( 'staff' );
  9680. $staff = new staff ();
  9681. $receiptInfo = $receipt->getOne ( array (
  9682. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  9683. 'asArray' => true
  9684. ) );
  9685. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  9686. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  9687. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  9688. </tbody></table><table class="table table table-bordered"><tbody>';
  9689. foreach ( $verifyStaff as $key => $value ) {
  9690. $staffInfo = $staff->getOne ( array (
  9691. 'select' => 'username',
  9692. 'where' => ' sid="' . $key . '"',
  9693. 'asArray' => true
  9694. ) );
  9695. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  9696. }
  9697. $html .= '</tbody></table></div></div>';
  9698. echo json_encode ( array (
  9699. 'status' => 1,
  9700. 'receiptHtml' => $html
  9701. ) );
  9702. die ();
  9703. }
  9704. echo json_encode ( array (
  9705. 'status' => 2,
  9706. 'receiptHtml' => ''
  9707. ) );
  9708. die ();
  9709. }
  9710. function _getMonthCollectDetail($receiptCollectList) {
  9711. if (! empty ( $receiptCollectList )) {
  9712. $receiptL = array (
  9713. '日常相关费用' => array (),
  9714. '差旅相关费用' => array (),
  9715. '培训班费用' => array (),
  9716. '其他' => array ()
  9717. );
  9718. $html = "";
  9719. $psum = 0;
  9720. $item = array (
  9721. '市内交通费',
  9722. '市内出租费',
  9723. '办事处房租',
  9724. '电话费',
  9725. '水费',
  9726. '电费',
  9727. '办公费用',
  9728. '邮寄费',
  9729. '其他费用',
  9730. '车辆费用',
  9731. '广告费',
  9732. '团队建设费',
  9733. '物业管理费',
  9734. '宽带费'
  9735. );
  9736. foreach ( $item as $value ) {
  9737. $falg = true;
  9738. foreach ( $receiptCollectList as $v ) {
  9739. if ($v ['itemCategory'] == '日常相关费用') {
  9740. if ($v ['item'] == $value) {
  9741. $psum += $v ['price'];
  9742. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9743. $falg = false;
  9744. break;
  9745. }
  9746. }
  9747. }
  9748. if ($falg)
  9749. $html .= '<td class="taR">-</td>';
  9750. }
  9751. if (! empty ( $psum ))
  9752. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9753. else
  9754. $psum = '<td class="colGreen taR">-</td>';
  9755. $receiptL ['日常相关费用'] = $psum . $html;
  9756. /* ----------------------------------- */
  9757. $html = "";
  9758. $psum = 0;
  9759. $item = array (
  9760. '往来交通费',
  9761. '市内交通费',
  9762. '出差住宿费',
  9763. '出差补助',
  9764. '其他费用'
  9765. );
  9766. foreach ( $item as $value ) {
  9767. $falg = true;
  9768. foreach ( $receiptCollectList as $v ) {
  9769. if ($v ['itemCategory'] == '差旅相关费用') {
  9770. if ($v ['item'] == $value) {
  9771. $psum += $v ['price'];
  9772. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9773. $falg = false;
  9774. break;
  9775. }
  9776. }
  9777. }
  9778. if ($falg)
  9779. $html .= '<td class="taR">-</td>';
  9780. }
  9781. if (! empty ( $psum ))
  9782. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9783. else
  9784. $psum = '<td class="colGreen taR">-</td>';
  9785. $receiptL ['差旅相关费用'] = $psum . $html;
  9786. /* ------------------------------------- */
  9787. $html = "";
  9788. $psum = 0;
  9789. $item = array (
  9790. '场租费',
  9791. '薪酬',
  9792. '住宿费',
  9793. '交通费',
  9794. '餐饮费',
  9795. '办公费',
  9796. '公关费',
  9797. '其他'
  9798. );
  9799. foreach ( $item as $value ) {
  9800. $falg = true;
  9801. foreach ( $receiptCollectList as $v ) {
  9802. if ($v ['itemCategory'] == '培训班费用') {
  9803. if ($v ['item'] == $value) {
  9804. $psum += $v ['price'];
  9805. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9806. $falg = false;
  9807. break;
  9808. }
  9809. }
  9810. }
  9811. if ($falg)
  9812. $html .= '<td class="taR">-</td>';
  9813. }
  9814. if (! empty ( $psum ))
  9815. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9816. else
  9817. $psum = '<td class="colGreen taR">-</td>';
  9818. $receiptL ['培训班费用'] = $psum . $html;
  9819. /* ------------------------------------- */
  9820. $html = "";
  9821. $psum = 0;
  9822. $item = array (
  9823. '公关费',
  9824. '广告费',
  9825. '借款',
  9826. '可自加费用'
  9827. );
  9828. foreach ( $item as $value ) {
  9829. $falg = true;
  9830. foreach ( $receiptCollectList as $v ) {
  9831. if ($v ['itemCategory'] == '其他') {
  9832. if ($v ['item'] == $value) {
  9833. $psum += $v ['price'];
  9834. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9835. $falg = false;
  9836. break;
  9837. }
  9838. }
  9839. }
  9840. if ($falg)
  9841. $html .= '<td class="taR">-</td>';
  9842. }
  9843. if (! empty ( $psum ))
  9844. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9845. else
  9846. $psum = '<td class="colGreen taR">-</td>';
  9847. $receiptL ['其他'] = $psum . $html;
  9848. /* ------------------------------------- */
  9849. $html = "";
  9850. $psum = 0;
  9851. foreach ( $receiptCollectList as $v ) {
  9852. if ($v ['itemCategory'] == '报销金额调整') {
  9853. if (! empty ( $v ['price'] ))
  9854. $psum += $v ['price'];
  9855. }
  9856. }
  9857. if (! empty ( $psum ))
  9858. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9859. else
  9860. $psum = '<td class="taR colOrange">-</td>';
  9861. $receiptL ['报销金额调整'] = $psum . $html;
  9862. } else {
  9863. $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>
  9864. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9865. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9866. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9867. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9868. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9869. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9870. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9871. }
  9872. return $receiptL;
  9873. }
  9874. function eMail() {
  9875. Doo::loadModel ( 'staff' );
  9876. $staff = new staff ();
  9877. Doo::loadModel ( 'receipt' );
  9878. $receipt = new receipt ();
  9879. Doo::loadModel ( 'L_category' );
  9880. $Lcategory = new L_category ();
  9881. Doo::loadModel ( "verify" );
  9882. $verify = new verify ();
  9883. $staffList = $staff->find ( array (
  9884. 'asArray' => true
  9885. ) );
  9886. foreach ( $staffList as $key => $value ) {
  9887. if ($value ['username'] != 'admin') {
  9888. // 提交人
  9889. $receiptList = $receipt->find ( array (
  9890. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  9891. 'asArray' => true
  9892. ) );
  9893. if (! empty ( $receiptList )) {
  9894. $html = '<br><div><style></style>
  9895. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  9896. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  9897. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9898. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  9899. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9900. <tbody><tr>
  9901. <td style="padding: 0 40px;" align="left">
  9902. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9903. </td></tr><tr>
  9904. <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>
  9905. </tr>
  9906. </tbody> </table></td> </tr> <tr><td>
  9907. <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">
  9908. <tbody> <tr><td>
  9909. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  9910. 以下报销单完成了审批,等着收款吧:</p>
  9911. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  9912. foreach ( $receiptList as $k => $v ) {
  9913. $category = $Lcategory->getOne ( array (
  9914. 'where' => 'cid=' . $v ['cid'],
  9915. 'asArray' => true
  9916. ) );
  9917. $html .= '
  9918. <tr>
  9919. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  9920. <td align="left">
  9921. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  9922. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  9923. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  9924. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  9925. </tr>';
  9926. }
  9927. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  9928. <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>
  9929. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  9930. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  9931. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  9932. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9933. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9934. $receipt = new receipt ();
  9935. $receipt->notice = 1;
  9936. $receipt->update ( array (
  9937. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  9938. ) );
  9939. }
  9940. }
  9941. // 审批人
  9942. $verifyList = $verify->find ( array (
  9943. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  9944. 'asArray' => true
  9945. ) );
  9946. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  9947. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  9948. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9949. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  9950. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9951. <tbody><tr><td style="padding: 0 40px;" align="left">
  9952. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9953. </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>
  9954. </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">
  9955. <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>
  9956. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  9957. foreach ( $verifyList as $k => $v ) {
  9958. $receiptList = $receipt->find ( array (
  9959. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  9960. 'asArray' => true
  9961. ) );
  9962. foreach ( $receiptList as $r => $l ) {
  9963. $category = $Lcategory->getOne ( array (
  9964. 'where' => 'cid=' . $l ['cid'],
  9965. 'asArray' => true
  9966. ) );
  9967. $staffDetile = $staff->getOne ( array (
  9968. 'where' => 'sid=' . $l ['staff'],
  9969. 'asArray' => true
  9970. ) );
  9971. $html .= '
  9972. <tr>
  9973. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  9974. <td align="left">
  9975. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  9976. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  9977. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  9978. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  9979. </tr>';
  9980. }
  9981. }
  9982. $html .= '
  9983. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  9984. <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>
  9985. </tr></tbody></table></td></tr></tbody></table></div><br>';
  9986. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  9987. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  9988. // $receipt=new receipt();
  9989. // $receipt->notice=1;
  9990. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  9991. }
  9992. }
  9993. }
  9994. }
  9995. function setWXMsg($rid, $type) {
  9996. Doo::loadModel ( "receipt" );
  9997. $receipt = new receipt ();
  9998. $receiptDetail = $receipt->getOne ( array (
  9999. 'where' => 'rid=' . $rid,
  10000. 'asArray' => true
  10001. ) );
  10002. if (! empty ( $receiptDetail )) {
  10003. Doo::loadModel ( 'staff' );
  10004. $staff = new staff ();
  10005. $staffmsg = $staff->getOne ( array (
  10006. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  10007. 'asArray' => TRUE
  10008. ) );
  10009. if (! empty ( $staffmsg ['wxid'] )) {
  10010. require_once (SITE_PATH . '/protected/class/client.php');
  10011. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  10012. $user = $staffmsg ['wxid'];
  10013. $receiptName = '';
  10014. $msg = '';
  10015. switch ($receiptDetail ['Rtype']) {
  10016. case 0 :
  10017. $receiptName = '报销';
  10018. break;
  10019. case 1 :
  10020. $receiptName = '借款';
  10021. break;
  10022. case 2 :
  10023. $receiptName = '对公汇款';
  10024. break;
  10025. }
  10026. switch ($type) {
  10027. case 1 :
  10028. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  10029. break;
  10030. case 2 :
  10031. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  10032. break;
  10033. case 3 :
  10034. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  10035. break;
  10036. }
  10037. $result = $client->SendMsg ( $user, $msg, 'text' );
  10038. }
  10039. }
  10040. }
  10041. // Email发送函数
  10042. function SMail($toemail, $subject, $contents) {
  10043. Doo::loadClass ( 'class.phpmailer' );
  10044. $mail = new PHPMailer ();
  10045. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  10046. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  10047. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  10048. $mail->Password = "cDO1GjtY1seH"; // 密码
  10049. $mail->CharSet = "UTF8";
  10050. $mail->SMTPAuth = true;
  10051. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  10052. $mail->Mailer = "smtp";
  10053. $mail->Port = 25;
  10054. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  10055. $mail->MsgHTML ( $contents );
  10056. $mail->AddAddress ( $toemail );
  10057. $mail->CharSet = "UTF-8";
  10058. return $mail->Send ();
  10059. }
  10060. function swfupload() {
  10061. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  10062. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  10063. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  10064. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  10065. header ( "HTTP/1.1 500 Internal Server Error" );
  10066. echo "POST exceeded maximum allowed size.";
  10067. exit ( 0 );
  10068. }
  10069. // Settings
  10070. $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)
  10071. $upload_name = "Filedata";
  10072. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  10073. $extension_whitelist = array (
  10074. "doc",
  10075. "txt",
  10076. "jpg",
  10077. "gif",
  10078. "png"
  10079. ); // Allowed file extensions
  10080. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  10081. // Other variables
  10082. $MAX_FILENAME_LENGTH = 260;
  10083. $file_name = "";
  10084. $file_extension = "";
  10085. $uploadErrors = array (
  10086. 0 => "文件上传成功",
  10087. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  10088. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  10089. 3 => "上传的文件仅为部分文件",
  10090. 4 => "没有文件上传",
  10091. 6 => "缺少临时文件夹"
  10092. );
  10093. $nk = time ();
  10094. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  10095. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  10096. echo "文件无法保存.";
  10097. exit ( 0 );
  10098. }
  10099. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  10100. echo json_encode ( array (
  10101. 'filename' => $file_name,
  10102. 'id' => $nk
  10103. ) );
  10104. exit ( 0 );
  10105. }
  10106. function _GetFileEXT($filename) {
  10107. $pics = explode ( '.', $filename );
  10108. $num = count ( $pics );
  10109. return $pics [$num - 1];
  10110. }
  10111. /**
  10112. * 获取get或者POST值
  10113. * @param string $name 属性名称
  10114. * @return fixed 值
  10115. */
  10116. function get_args($name) {
  10117. if (isset ( $_GET [$name] )) {
  10118. if (is_array ( $_GET [$name] ))
  10119. return $_GET [$name];
  10120. else
  10121. return addslashes ( $_GET [$name] );
  10122. } elseif (isset ( $_POST [$name] )) {
  10123. if (is_array ( $_POST [$name] ))
  10124. return $_POST [$name];
  10125. else
  10126. return addslashes ( $_POST [$name] );
  10127. } else
  10128. return false;
  10129. }
  10130. function num_to_rmb($num) {
  10131. $c1 = "零壹贰叁肆伍陆柒捌玖";
  10132. $c2 = "分角元拾佰仟万拾佰仟亿";
  10133. // 精确到分后面就不要了,所以只留两个小数位
  10134. $num = round ( $num, 2 );
  10135. // 将数字转化为整数
  10136. $num = $num * 100;
  10137. if (strlen ( $num ) > 10) {
  10138. return "金额太大,请检查";
  10139. }
  10140. $i = 0;
  10141. $c = "";
  10142. while ( 1 ) {
  10143. if ($i == 0) {
  10144. // 获取最后一位数字
  10145. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  10146. } else {
  10147. $n = $num % 10;
  10148. }
  10149. // 每次将最后一位数字转化为中文
  10150. $p1 = substr ( $c1, 3 * $n, 3 );
  10151. $p2 = substr ( $c2, 3 * $i, 3 );
  10152. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  10153. $c = $p1 . $p2 . $c;
  10154. } else {
  10155. $c = $p1 . $c;
  10156. }
  10157. $i = $i + 1;
  10158. // 去掉数字最后一位了
  10159. $num = $num / 10;
  10160. $num = ( int ) $num;
  10161. // 结束循环
  10162. if ($num == 0) {
  10163. break;
  10164. }
  10165. }
  10166. $j = 0;
  10167. $slen = strlen ( $c );
  10168. while ( $j < $slen ) {
  10169. // utf8一个汉字相当3个字符
  10170. $m = substr ( $c, $j, 6 );
  10171. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  10172. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  10173. $left = substr ( $c, 0, $j );
  10174. $right = substr ( $c, $j + 3 );
  10175. $c = $left . $right;
  10176. $j = $j - 3;
  10177. $slen = $slen - 3;
  10178. }
  10179. $j = $j + 3;
  10180. }
  10181. // 这个是为了去掉类似23.0中最后一个“零”字
  10182. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  10183. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  10184. }
  10185. // 将处理的汉字加上“整”
  10186. if (empty ( $c )) {
  10187. return "零元整";
  10188. } else {
  10189. return $c . "整";
  10190. }
  10191. }
  10192. /**
  10193. * 获得分页数据
  10194. * @param unknown_type $table
  10195. * @param unknown_type $condition
  10196. * @param unknown_type $on_page
  10197. * @param unknown_type $page_size
  10198. */
  10199. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  10200. $page_c = "";
  10201. $page ['previous'] = $this->get_previous ( $on_page );
  10202. $page ['on_page'] = $on_page;
  10203. $total_count = $this->get_table_count ( $table, $condition );
  10204. $total = intval ( $total_count / $page_size );
  10205. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  10206. $page ['total_data'] = $total_count;
  10207. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  10208. $i = 1;
  10209. $page_max = 1;
  10210. $page_width = 3;
  10211. if ($on_page >= $page_width) {
  10212. $page_max = intval ( $on_page / $page_width ) + 1;
  10213. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  10214. }
  10215. for(; $i <= $page ['total_page']; $i ++) {
  10216. if ($i == $on_page)
  10217. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  10218. else
  10219. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  10220. if ($i == ($page_width * $page_max))
  10221. break;
  10222. }
  10223. $page ['page'] = $page_c;
  10224. $page ['lower'] = (-- $on_page) * $page_size;
  10225. return $page;
  10226. }
  10227. /**
  10228. * 获取总页数
  10229. * @param unknown_type $table
  10230. * @param unknown_type $condition
  10231. */
  10232. public function get_table_count($table = "", $condition = "") {
  10233. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10234. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10235. // echo $sql;die;
  10236. $query = Doo::db ()->query ( $sql );
  10237. $result = $query->fetch ();
  10238. return $result ['count'];
  10239. }
  10240. /**
  10241. * 获取上一页
  10242. * @param unknown_type $on_page
  10243. */
  10244. function get_previous($on_page = 1) {
  10245. return $on_page != 0 ? $on_page - 1 : $on_page;
  10246. }
  10247. }
  10248. ?>