ReceiptController.php 394 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class ReceiptController extends DooController {
  6. public $staff;
  7. public $verifyId;
  8. public $executeId;
  9. // public static $NEW2 = 0;
  10. public $AGENCY = "日常相关费用";
  11. public $TRAVEL = "差旅相关费用";
  12. public $TRAIN = "培训班费用";
  13. public $OTHER = "其他";
  14. private $MYREVEIPTCACHEPATH = "protected/cache/myReceipt/";
  15. private $PERSONALCOLLECTCACHEPATH = "protected/cache/personalCollect/";
  16. private $CATEGORYCOLLECTPATH = "protected/cache/categoryCollect/";
  17. private $STAFFCOLLECTPATH = "protected/cache/staffCollect/";
  18. private function showCache($path) {
  19. if (file_exists ( $path )) {
  20. echo "<!DOCTYPE html>";
  21. include $path;
  22. die ();
  23. }
  24. }
  25. private function cacheFile($path) {
  26. $content = ob_get_contents ();
  27. $fp = fopen ( $path, "w" );
  28. fwrite ( $fp, $content );
  29. fclose ( $fp );
  30. }
  31. private function collectHtml($receiptCollectList = array(), $itemCategory = "日常相关费用", $classType = "b") {
  32. $collectHtml = "";
  33. $sumPrice = 0.00;
  34. for($i = 1; $i <= 12; $i ++) {
  35. $falg = true;
  36. foreach ( $receiptCollectList as $key => $value ) {
  37. if ($value ['itemCategory'] == $itemCategory && $value ['month'] == $i) {
  38. $sumPrice += $value ['price'];
  39. if ($classType == "b") {
  40. $collectHtml .= '<td class="colGreen taR">¥' . $value ['price'] . '</td>';
  41. $falg = false;
  42. break;
  43. } else {
  44. $collectHtml .= '<td class="taR">¥' . $value ['price'] . '</td>';
  45. $falg = false;
  46. break;
  47. }
  48. }
  49. }
  50. if ($falg)
  51. $collectHtml .= '<td class="taR">-</td>';
  52. }
  53. $collectHtml .= '<td class="taR colGreen">¥' . $sumPrice . '</td>';
  54. return $collectHtml;
  55. }
  56. public function beforeRun($resource, $action) {
  57. Doo::loadClass ( 'XDeode' );
  58. $XDeode = new XDeode ( 5 );
  59. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  60. // 单独判断公司汇总的访问权限
  61. if ($action == 'companyCategoryCollect') {
  62. Doo::loadModel ( "receiptAuthorityManage" );
  63. $invoiceCompanyManage = new receiptAuthorityManage ();
  64. $icm = $invoiceCompanyManage->getInvoiceCMByStaff ( $sid );
  65. if (empty ( $icm ))
  66. die ( 'illegal request' );
  67. }
  68. Doo::loadModel ( 'staff' );
  69. $staff = new staff ();
  70. $detail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
  71. $accessModular = 'RECEIPTS';
  72. if (empty ( $detail ['cldAccessArray'] ))
  73. die ( 'illegal request' );
  74. else {
  75. if (in_array ( $accessModular, $detail ['cldAccessArray'] )) {
  76. if (Doo::acl ()->isAllowed ( $accessModular, $resource, $action )) {
  77. $flag = true;
  78. } else {
  79. $flag = false;
  80. }
  81. } else {
  82. die ( 'illegal request' );
  83. }
  84. }
  85. if (! $flag)
  86. die ( 'illegal request' );
  87. }
  88. function __construct() {
  89. if (isset ( $_COOKIE ["staff"] )) {
  90. if (! empty ( $_COOKIE ["staff"] )) {
  91. Doo::loadModel ( 'staff' );
  92. Doo::loadModel ( 'verify' );
  93. $verify = new verify ();
  94. $staff = new staff ();
  95. Doo::loadModel ( "execute" );
  96. $execute = new execute ();
  97. $verifyList = $verify->find ( array (
  98. 'select' => 'staff',
  99. 'asArray' => true
  100. ) );
  101. $list = array ();
  102. // 判断角色的审批权限
  103. foreach ( $verifyList as $key => $value ) {
  104. $ver = json_decode ( $value ['staff'] );
  105. foreach ( $ver as $k => $v ) {
  106. if ($v [1] == 'ROLE') {
  107. $roleList = json_decode ( $v [3] );
  108. foreach ( $roleList as $t => $g ) {
  109. $gList = explode ( "_", $g );
  110. array_push ( $list, $gList [0] );
  111. // print_r($list);
  112. }
  113. } else
  114. array_push ( $list, $v [0] );
  115. }
  116. }
  117. // 判断执行人的审批权限
  118. $executeList = $execute->find ( array (
  119. 'select' => 'staff',
  120. 'asArray' => true
  121. ) );
  122. $list2 = array ();
  123. foreach ( $executeList as $key => $value ) {
  124. $ver = json_decode ( $value ['staff'] );
  125. foreach ( $ver as $k => $v ) {
  126. array_push ( $list2, $v [0] );
  127. }
  128. }
  129. $eidList = file_get_contents ( "protected/config/execute/execute.ini" );
  130. $eidList = array_filter ( explode ( ",", $eidList ) );
  131. $this->executeId = array_merge ( $list2, $eidList );
  132. $this->verifyId = $list;
  133. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  134. return "/";
  135. }
  136. }
  137. Doo::loadCore ( 'uri/DooUriRouter' );
  138. $router = new DooUriRouter ();
  139. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  140. if ($routeRs ['1'] != "login") {
  141. header ( 'Content-Type:text/html;charset=utf-8' );
  142. @header ( "Location: /login" );
  143. }
  144. }
  145. function saeaBorad() {
  146. Doo::loadModel ( 'receipt' );
  147. Doo::loadModel ( 'verify' );
  148. $verify = new verify ();
  149. $receipt = new receipt ();
  150. Doo::loadModel ( 'L_category' );
  151. $lCategory = new L_category ();
  152. Doo::loadModel ( "role" );
  153. $role = new role ();
  154. Doo::loadModel ( "receiptLog" );
  155. $receiptLog = new receiptLog ();
  156. Doo::loadClass ( 'XDeode' );
  157. $XDeode = new XDeode ( 7 );
  158. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  159. $receiptDetail = $receipt->find ( array (
  160. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  161. 'desc' => 'rid',
  162. 'asArray' => true
  163. ) );
  164. foreach ( $receiptDetail as $key => $value ) {
  165. $receiptDetail [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  166. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  167. $veList = $verify->getOne ( array (
  168. 'where' => 'vid=' . $value ['verify'],
  169. 'asArray' => true
  170. ) );
  171. $v = json_decode ( $veList ['staff'] );
  172. array_push ( $v [0], $veList ['description'] );
  173. foreach ( $v as $n => $m ) {
  174. if ($m ['1'] == 'ROLE') {
  175. $roleInfo = $role->getOne ( array (
  176. 'where' => 'rid=' . $m [0],
  177. 'asArray' => true
  178. ) );
  179. $v [$n] [1] = $roleInfo ['name'];
  180. }
  181. }
  182. $receiptDetail [$key] ['staff'] = $v;
  183. $category = $lCategory->getOne ( array (
  184. 'where' => 'cid=' . $value ['cid'],
  185. 'asArray' => true
  186. ) );
  187. $receiptDetail [$key] ['category'] = $category ['title'];
  188. }
  189. // print_r($receiptLogList);
  190. $data ['receiptLogList'] = $receiptLogList;
  191. $data ['receiptDetail'] = $receiptDetail;
  192. $data ['memu'] = "receipt";
  193. $data ['staff'] = $this->staff;
  194. $data ['receiptMemu'] = 'saeaBorad';
  195. $data ['verifyId'] = $this->verifyId;
  196. $data ['executeId'] = $this->executeId;
  197. $this->render ( "/admin/saeaBorad", $data );
  198. }
  199. function remitAdd() {
  200. Doo::loadModel ( 'accountItem' );
  201. Doo::loadModel ( 'verify' );
  202. Doo::loadModel ( 'receipt' );
  203. Doo::loadModel ( 'L_category' );
  204. $lCategory = new L_category ();
  205. $receipt = new receipt ();
  206. $verify = new verify ();
  207. $accountItem = new accountItem ();
  208. Doo::loadModel ( "role" );
  209. $role = new role ();
  210. $acItem = $accountItem->find ( array (
  211. 'asArray' => true
  212. ) );
  213. $veList = $verify->find ( array (
  214. 'asArray' => true
  215. ) );
  216. foreach ( $veList as $key => $value ) {
  217. $v = json_decode ( $value ['staff'] );
  218. $list = array ();
  219. foreach ( $v as $n => $m ) {
  220. if ($m ['1'] == 'ROLE') {
  221. $roleInfo = $role->getOne ( array (
  222. 'where' => 'rid=' . $m [0],
  223. 'asArray' => true
  224. ) );
  225. $v [$n] [1] = $roleInfo ['name'];
  226. array_push ( $list, $roleInfo ['name'] );
  227. } else {
  228. array_push ( $list, $v [$n] [1] );
  229. }
  230. }
  231. $veList [$key] ['staff'] = implode ( '>', $list );
  232. }
  233. $data ['category'] = $lCategory->find ( array (
  234. 'asArray' => true
  235. ) );
  236. $data ['veList'] = $veList;
  237. $data ['acItem'] = $acItem;
  238. $data ['memu'] = "receipt";
  239. $data ['staff'] = $this->staff;
  240. $data ['receiptMemu'] = 'saeaBorad';
  241. $data ['verifyId'] = $this->verifyId;
  242. $data ['executeId'] = $this->executeId;
  243. $this->render ( "/admin/remitAdd", $data );
  244. }
  245. function remitAddDo() {
  246. $agency = $this->get_args ( 'agency' );
  247. $travel = $this->get_args ( 'travel' );
  248. $train = $this->get_args ( 'train' );
  249. $other = $this->get_args ( 'other' );
  250. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  251. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  252. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  253. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  254. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  255. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  256. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  257. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  258. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  259. // print_r($agency);die;
  260. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  261. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  262. header ( 'Content-Type:text/html;charset=utf-8' );
  263. die ( '请填写联行号' );
  264. }
  265. Doo::loadModel ( 'receipt' );
  266. Doo::loadModel ( 'receiptDetail' );
  267. Doo::loadModel ( 'accountItem' );
  268. $accountItem = new accountItem ();
  269. $receipt = new receipt ();
  270. Doo::loadModel ( 'enclosur' );
  271. Doo::loadModel ( 'execute' );
  272. $execute = new execute ();
  273. $executeDetail = $execute->getOne ( array (
  274. 'where' => 'mold="对公汇款执行人"',
  275. 'asArray' => true
  276. ) );
  277. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  278. $aItem = $accountItem->find ( array (
  279. 'where' => 'name like "办公费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保"',
  280. 'asArray' => true
  281. ) );
  282. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  283. $ag = $tr = $ta = $ot = 0;
  284. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  285. foreach ( $aItem as $key => $value ) {
  286. if ($value ['category'] == $this->AGENCY) {
  287. if (isset ( $agency [$ag] )) {
  288. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  289. array_push ( $accountJson [$this->AGENCY], array (
  290. 'aid' => $value ['aid'],
  291. 'name' => $value ['name'],
  292. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  293. ) );
  294. $sum += $agency [$ag];
  295. $agencySum += $agency [$ag];
  296. }
  297. }
  298. $ag ++;
  299. }
  300. }
  301. $accountJson ['cSum'] = array (
  302. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  303. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  304. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  305. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  306. );
  307. // 报销单
  308. $receipt->accountItem = json_encode ( $accountJson );
  309. $receipt->staff = $this->staff [0] ['sid'];
  310. $receipt->sum = number_format ( $sum, 2, '.', '' );
  311. $receipt->date = date ( "Y-m-d" );
  312. $receipt->cid = $cid;
  313. $receipt->status = 5;
  314. $receipt->Rtype = 2;
  315. // 修改审批流程加入角色
  316. $receipt->verify = $verify;
  317. $receipt->executeCopy = $executeDetail ['staff'];
  318. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  319. $receipt->explanation = $explanation;
  320. $receipt->remittanceName = $remittanceName;
  321. $receipt->bankName = $bankName;
  322. $receipt->bankNumber = $bankNumber;
  323. $receipt->remittanceBankType = $remittanceBankType;
  324. if ($remittanceBankType == 1)
  325. $receipt->coupletNumber = $coupletNumber;
  326. $rid = $receipt->insert ();
  327. // 附件
  328. if (! empty ( $enclosurName )) {
  329. $enclosurArray = explode ( '-', $enclosurName );
  330. foreach ( $enclosurArray as $value ) {
  331. $enclosur = new enclosur ();
  332. $enclosur->name = $value;
  333. $enclosur->rid = $rid;
  334. $enclosur->insert ();
  335. }
  336. // print_r($enclosurArray);die;
  337. }
  338. // 报销详情
  339. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  340. $receiptDetail = new receiptDetail ();
  341. $receiptDetail->staff = $this->staff [0] ['sid'];
  342. $receiptDetail->item = $value ['name'];
  343. $receiptDetail->itemCategory = $this->AGENCY;
  344. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  345. $receiptDetail->date = date ( "Y-m-d" );
  346. $receiptDetail->cid = $cid;
  347. $receiptDetail->rid = $rid;
  348. $receiptDetail->status = 4;
  349. $receiptDetail->insert ();
  350. }
  351. return "/saeaBorad";
  352. } else
  353. die ( 'illegal request' );
  354. }
  355. function remitEdit() {
  356. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  357. Doo::loadClass ( 'XDeode' );
  358. $XDeode = new XDeode ( 7 );
  359. $rid = $XDeode->decode ( $ridKey );
  360. if (! is_numeric ( $rid ))
  361. die ( 'illegal request' );
  362. Doo::loadModel ( 'accountItem' );
  363. Doo::loadModel ( 'verify' );
  364. Doo::loadModel ( 'receipt' );
  365. $receipt = new receipt ();
  366. $verify = new verify ();
  367. $accountItem = new accountItem ();
  368. Doo::loadModel ( 'L_category' );
  369. $lCategory = new L_category ();
  370. Doo::loadModel ( "role" );
  371. $role = new role ();
  372. Doo::loadModel ( 'enclosur' );
  373. $enclosur = new enclosur ();
  374. $receiptDetail = $receipt->getOne ( array (
  375. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  376. 'asArray' => true
  377. ) );
  378. if (empty ( $receiptDetail ))
  379. return "/saeaCreate";
  380. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  381. $acItem = $accountItem->find ( array (
  382. 'asArray' => true
  383. ) );
  384. $veList = $verify->find ( array (
  385. 'asArray' => true
  386. ) );
  387. foreach ( $veList as $key => $value ) {
  388. $v = json_decode ( $value ['staff'] );
  389. $list = array ();
  390. foreach ( $v as $n => $m ) {
  391. if ($m ['1'] == 'ROLE') {
  392. $roleInfo = $role->getOne ( array (
  393. 'where' => 'rid=' . $m [0],
  394. 'asArray' => true
  395. ) );
  396. $v [$n] [1] = $roleInfo ['name'];
  397. array_push ( $list, $roleInfo ['name'] );
  398. } else {
  399. array_push ( $list, $v [$n] [1] );
  400. }
  401. }
  402. $veList [$key] ['staff'] = implode ( '>', $list );
  403. }
  404. // 配置编辑信息
  405. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  406. foreach ( $acItem as $key => $value ) {
  407. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  408. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  409. $acItem [$key] ['price'] = $v ['price'];
  410. }
  411. }
  412. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  413. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  414. $acItem [$key] ['price'] = $v ['price'];
  415. }
  416. }
  417. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  418. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  419. $acItem [$key] ['price'] = $v ['price'];
  420. }
  421. }
  422. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  423. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  424. $acItem [$key] ['price'] = $v ['price'];
  425. }
  426. }
  427. }
  428. $data ['category'] = $lCategory->find ( array (
  429. 'asArray' => true
  430. ) );
  431. $data ['enclosurList'] = $enclosurList;
  432. $data ['cSum'] = $accountItemList ['cSum'];
  433. $data ['sum'] = $receiptDetail ['sum'];
  434. $data ['receiptDetail'] = $receiptDetail;
  435. $data ['veList'] = $veList;
  436. $data ['acItem'] = $acItem;
  437. $data ['memu'] = "receipt";
  438. $data ['staff'] = $this->staff;
  439. $data ['receiptMemu'] = 'saeaBorad';
  440. $data ['verify'] = $receiptDetail ['verify'];
  441. $data ['verifyId'] = $this->verifyId;
  442. $data ['executeId'] = $this->executeId;
  443. $data ['rid'] = $rid;
  444. $data ['ridKey'] = $ridKey;
  445. $this->render ( "/admin/remitEdit", $data );
  446. }
  447. function remitEdiDo() {
  448. $agency = $this->get_args ( 'agency' );
  449. $travel = $this->get_args ( 'travel' );
  450. $train = $this->get_args ( 'train' );
  451. $other = $this->get_args ( 'other' );
  452. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  453. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  454. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  455. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  456. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  457. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  458. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  459. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  460. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  461. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  462. Doo::loadClass ( 'XDeode' );
  463. $XDeode = new XDeode ( 7 );
  464. $rid = $XDeode->decode ( $ridKey );
  465. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  466. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  467. header ( 'Content-Type:text/html;charset=utf-8' );
  468. die ( '请填写联行号' );
  469. }
  470. Doo::loadModel ( 'receipt' );
  471. Doo::loadModel ( 'receiptDetail' );
  472. Doo::loadModel ( 'accountItem' );
  473. $accountItem = new accountItem ();
  474. $receipt = new receipt ();
  475. Doo::loadModel ( 'enclosur' );
  476. $enclosur = new enclosur ();
  477. Doo::loadModel ( 'execute' );
  478. $execute = new execute ();
  479. $executeDetail = $execute->getOne ( array (
  480. 'where' => 'mold="对公汇款执行人"',
  481. 'asArray' => true
  482. ) );
  483. $receiptDetail = $receipt->getOne ( array (
  484. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  485. 'asArray' => true
  486. ) );
  487. if (empty ( $receiptDetail ))
  488. return "/saeaBorad";
  489. $aItem = $accountItem->find ( array (
  490. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  491. 'asArray' => true
  492. ) );
  493. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  494. $ag = $tr = $ta = $ot = 0;
  495. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  496. foreach ( $aItem as $key => $value ) {
  497. if ($value ['category'] == $this->AGENCY) {
  498. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  499. array_push ( $accountJson [$this->AGENCY], array (
  500. 'aid' => $value ['aid'],
  501. 'name' => $value ['name'],
  502. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  503. ) );
  504. $sum += $agency [$ag];
  505. $agencySum += $agency [$ag];
  506. }
  507. $ag ++;
  508. }
  509. }
  510. $accountJson ['cSum'] = array (
  511. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  512. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  513. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  514. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  515. );
  516. // 报销单
  517. $rid = $receipt->rid = $receiptDetail ['rid'];
  518. $receipt->accountItem = json_encode ( $accountJson );
  519. $receipt->staff = $this->staff [0] ['sid'];
  520. $receipt->sum = number_format ( $sum, 2, '.', '' );
  521. $receipt->date = date ( "Y-m-d" );
  522. $receipt->cid = $cid;
  523. if ($receiptDetail ['Rtype'] == 1)
  524. $receipt->status = 7;
  525. else
  526. $receipt->status = 5;
  527. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  528. $receipt->verify = $verify;
  529. $receipt->executeCopy = $executeDetail ['staff'];
  530. $receipt->explanation = $explanation;
  531. $receipt->remittanceName = $remittanceName;
  532. $receipt->bankName = $bankName;
  533. $receipt->bankNumber = $bankNumber;
  534. $receipt->remittanceBankType = $remittanceBankType;
  535. if ($remittanceBankType == 1)
  536. $receipt->coupletNumber = $coupletNumber;
  537. $receipt->update ();
  538. $receiptDetail = new receiptDetail ();
  539. $receiptDetail->delete ( array (
  540. 'where' => 'rid=' . $rid
  541. ) );
  542. // 报销详情
  543. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  544. $receiptDetail = new receiptDetail ();
  545. $receiptDetail->staff = $this->staff [0] ['sid'];
  546. $receiptDetail->item = $value ['name'];
  547. $receiptDetail->itemCategory = $this->AGENCY;
  548. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  549. $receiptDetail->date = date ( "Y-m-d" );
  550. $receiptDetail->cid = $cid;
  551. $receiptDetail->rid = $rid;
  552. $receiptDetail->status = 4;
  553. $receiptDetail->insert ();
  554. }
  555. // 附件
  556. if (! empty ( $enclosurName )) {
  557. $enclosurArray = explode ( '-', $enclosurName );
  558. foreach ( $enclosurArray as $value ) {
  559. $enclosur = new enclosur ();
  560. $enclosur->name = $value;
  561. $enclosur->rid = $rid;
  562. $enclosur->insert ();
  563. }
  564. }
  565. }
  566. return "/saeaBorad";
  567. }
  568. function remitApproval() {
  569. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  570. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  571. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  572. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  573. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  574. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  575. if (empty ( $status ))
  576. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  577. $vidList = array ();
  578. $button = 0;
  579. Doo::loadModel ( 'verify' );
  580. Doo::loadModel ( 'receipt' );
  581. Doo::loadModel ( 'staff' );
  582. $staff = new staff ();
  583. $receipt = new receipt ();
  584. $verify = new verify ();
  585. Doo::loadModel ( 'L_category' );
  586. $Lcategory = new L_category ();
  587. Doo::loadModel ( 'enclosur' );
  588. $enclosur = new enclosur ();
  589. // user verify ID
  590. $verifyDetail = $verify->find ( array (
  591. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  592. 'asArray' => true
  593. ) );
  594. foreach ( $verifyDetail as $key => $value ) {
  595. array_push ( $vidList, $value ['vid'] );
  596. }
  597. $vid = implode ( ",", $vidList );
  598. if (empty ( $verifyDetail ))
  599. $vid = 0;
  600. $categoryList = $Lcategory->find ( array (
  601. 'asArray' => true
  602. ) );
  603. $staffList = $staff->find ( array (
  604. 'where' => 'cid=' . $cid,
  605. 'asArray' => true
  606. ) );
  607. $ap = "";
  608. if ($status == 4) {
  609. $ap = 4;
  610. $status = 2;
  611. }
  612. // get Receipt By verifyID status 2
  613. $receiptList = $receipt->find ( array (
  614. 'where' => 'rid =' . $rid . ' and status=2',
  615. 'desc' => 'rid',
  616. 'asArray' => true
  617. ) );
  618. if (empty ( $receiptList )) {
  619. die ( 'illegal request' );
  620. }
  621. $Locate = 0;
  622. $roleId = 0;
  623. if ($ap == 4)
  624. $status = 4;
  625. foreach ( $receiptList as $key => $value ) {
  626. $receiptList [$key] ['Locate'] = $Locate;
  627. $Locate ++;
  628. $receiptList [$key] ['reviseDetail'] = array ();
  629. if (! empty ( $value ['reviseDetail'] ))
  630. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  631. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  632. $categoryDetil = $Lcategory->getOne ( array (
  633. 'where' => 'cid=' . $value ['cid'],
  634. 'asArray' => true
  635. ) );
  636. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  637. // 检测编辑状态
  638. $verifyList = $verify->getOne ( array (
  639. 'where' => 'vid=' . $value ['verify'],
  640. 'asArray' => true
  641. ) );
  642. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  643. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  644. Doo::loadModel ( 'role' );
  645. $role = new role ();
  646. // print_r($verifyList);
  647. $flag = true;
  648. $roleKey = 0;
  649. $endStaffArray = array ();
  650. $roleArrayCopy = array ();
  651. foreach ( $verifyList as $k => $v ) {
  652. // init verifyStaff
  653. if ($v [1] == 'ROLE') {
  654. if (! empty ( $verifyStaff )) {
  655. $endStaffArray = end ( $verifyStaff );
  656. if ($v [0] == $endStaffArray ['nextStaff']) {
  657. $roleId = $v [0];
  658. }
  659. }
  660. $roleVerify = json_decode ( $v [3], true );
  661. $roleKey = $k;
  662. $roleArray = array ();
  663. $rolename = $role->getOne ( array (
  664. 'where' => 'rid=' . $v [0],
  665. 'asArray' => true
  666. ) );
  667. foreach ( $roleVerify as $o => $p ) {
  668. $staffID = explode ( '_', $p );
  669. $staffInfo = $staff->getOne ( array (
  670. 'where' => 'sid=' . $staffID [0],
  671. 'asArray' => true
  672. ) );
  673. // print_r($staffID);
  674. $exp = array (
  675. 0 => $staffInfo ['sid'],
  676. 1 => $staffID [1],
  677. 2 => $staffInfo ['avatar'],
  678. 'date' => '',
  679. 'date' => '',
  680. 'opinion' => '',
  681. 'status' => '',
  682. 'rolename' => $rolename ['name']
  683. );
  684. array_push ( $roleArray, $exp );
  685. }
  686. $roleArrayCopy [$v [0]] = $roleArray;
  687. // $verifyList[$k]['roleArray']=$roleArray;
  688. }
  689. // print_r($roleArray);
  690. $verifyList [$k] ['date'] = "";
  691. $verifyList [$k] ['opinion'] = "";
  692. $verifyList [$k] ['status'] = "";
  693. if (empty ( $verifyStaff )) {
  694. $verifyList [$k] ['date'] = "";
  695. $verifyList [$k] ['opinion'] = "";
  696. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  697. $verifyList [$k] ['status'] = 4;
  698. $button = 4;
  699. $flag = false;
  700. }
  701. } else {
  702. foreach ( $verifyStaff as $m => $u ) {
  703. if ($v [0] == $m) {
  704. $verifyList [$k] ['date'] = $u ['date'];
  705. $verifyList [$k] ['opinion'] = $u ['opinion'];
  706. $verifyList [$k] ['status'] = $u ['status'];
  707. $flag = false;
  708. break;
  709. }
  710. }
  711. $endStaffArray = end ( $verifyStaff );
  712. if (isset ( $endStaffArray ['ROLE'] )) {
  713. } else {
  714. $endKey = key ( $verifyStaff );
  715. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  716. $button = 4;
  717. $verifyList [$k] ['status'] = 4;
  718. }
  719. }
  720. }
  721. }
  722. $rolename ['name'] = '';
  723. if (! empty ( $roleId )) {
  724. Doo::loadModel ( 'role' );
  725. $role = new role ();
  726. $rolename = $role->getOne ( array (
  727. 'where' => 'rid=' . $roleId,
  728. 'asArray' => true
  729. ) );
  730. }
  731. if (! empty ( $verifyStaff ))
  732. $endStaffArray = end ( $verifyStaff );
  733. $KOP = false;
  734. foreach ( $roleArrayCopy as $P => $A ) {
  735. foreach ( $A as $MKI => $AVL ) {
  736. if (! empty ( $verifyStaff )) {
  737. // &&$rolename['rid']==$endStaffArray['nextStaff']
  738. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  739. $button = 4;
  740. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  741. }
  742. foreach ( $verifyStaff as $m => $u ) {
  743. $AVLFK = $AVL [0] . '_R';
  744. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  745. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  746. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  747. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  748. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  749. break;
  750. }
  751. }
  752. } else {
  753. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  754. $button = 4;
  755. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  756. }
  757. }
  758. // $roleArray[$MKI]['rolename']=$rolename['name'];
  759. $KOP = true;
  760. }
  761. }
  762. foreach ( $roleArrayCopy as $k => $v ) {
  763. foreach ( $verifyList as $m => $n ) {
  764. if ($n [0] == $k) {
  765. array_splice ( $verifyList, $m, 1, $v );
  766. }
  767. }
  768. }
  769. $receiptList [$key] ['verifyList'] = $verifyList;
  770. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  771. 'where' => 'sid=' . $value ['staff'],
  772. 'asArray' => true
  773. ) );
  774. $receiptList [$key] ['button'] = $button;
  775. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  776. }
  777. $mothHtml = "";
  778. for($i = 1; $i <= 12; $i ++) {
  779. if ($month == $i)
  780. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  781. else
  782. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  783. }
  784. // 获取审批日志
  785. Doo::loadModel ( 'receiptLog' );
  786. $receiptLog = new receiptLog ();
  787. $rlList = array ();
  788. $rlInfo = $receiptLog->getOne ( array (
  789. 'where' => 'rid=' . $rid . ' and status=4',
  790. 'asArray' => true
  791. ) );
  792. $tijdate = $receiptLog->getOne ( array (
  793. 'where' => 'rid=' . $rid . ' and status=2',
  794. 'asc' => 'rlid',
  795. 'asArray' => true
  796. ) );
  797. if (! empty ( $rlInfo )) {
  798. $rlList = $receiptLog->find ( array (
  799. 'where' => 'rid=' . $rid,
  800. 'asc' => 'rlid',
  801. 'asArray' => true
  802. ) );
  803. }
  804. $receiptList [0] ['rlList'] = $rlList;
  805. $enclosurList = $enclosur->find ( array (
  806. 'where' => 'rid=' . $rid,
  807. 'asArray' => true
  808. ) );
  809. $enclosurHtml = '';
  810. foreach ( $enclosurList as $value ) {
  811. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  812. }
  813. // print_r($receiptList);
  814. $data ['enclosurHtml'] = $enclosurHtml;
  815. $data ['rolename'] = $rolename ['name'];
  816. $data ['datetij'] = $tijdate ['date'];
  817. $data ['mothHtml'] = $mothHtml;
  818. $data ['rid'] = $rid;
  819. $data ['receiptList'] = $receiptList;
  820. $data ['receiptApprovalCount'] = count ( $receiptList );
  821. $data ['status'] = $status;
  822. $data ['year'] = $year;
  823. $data ['categoryList'] = $categoryList;
  824. $data ['staffList'] = $staffList;
  825. $data ['cid'] = $cid;
  826. $data ['sid'] = $sid;
  827. $data ['ap'] = $ap;
  828. $data ['memu'] = "receipt";
  829. $data ['staff'] = $this->staff;
  830. $data ['receiptMemu'] = 'approvalExpenses';
  831. $data ['verifyId'] = $this->verifyId;
  832. $data ['executeId'] = $this->executeId;
  833. $this->render ( "/admin/remitApproval", $data );
  834. }
  835. function saeaLoanAdd() {
  836. Doo::loadModel ( 'verify' );
  837. $verify = new verify ();
  838. Doo::loadModel ( "role" );
  839. $role = new role ();
  840. Doo::loadModel ( 'L_category' );
  841. $lCategory = new L_category ();
  842. $veList = $verify->find ( array (
  843. 'asArray' => true
  844. ) );
  845. foreach ( $veList as $key => $value ) {
  846. $v = json_decode ( $value ['staff'] );
  847. $list = array ();
  848. foreach ( $v as $n => $m ) {
  849. if ($m ['1'] == 'ROLE') {
  850. $roleInfo = $role->getOne ( array (
  851. 'where' => 'rid=' . $m [0],
  852. 'asArray' => true
  853. ) );
  854. $v [$n] [1] = $roleInfo ['name'];
  855. array_push ( $list, $roleInfo ['name'] );
  856. } else {
  857. array_push ( $list, $v [$n] [1] );
  858. }
  859. }
  860. $veList [$key] ['staff'] = implode ( '>', $list );
  861. }
  862. $data ['category'] = $lCategory->find ( array (
  863. 'asArray' => true
  864. ) );
  865. $data ['veList'] = $veList;
  866. $data ['memu'] = "receipt";
  867. $data ['staff'] = $this->staff;
  868. $data ['receiptMemu'] = 'saeaBorad';
  869. $data ['verifyId'] = $this->verifyId;
  870. $data ['executeId'] = $this->executeId;
  871. $this->render ( "/admin/saeaLoanAdd", $data );
  872. }
  873. function saeaLoanAddDo() {
  874. $agency = $this->get_args ( 'agency' );
  875. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  876. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  877. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  878. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  879. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  880. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  881. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  882. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  883. // die;
  884. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  885. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  886. header ( 'Content-Type:text/html;charset=utf-8' );
  887. die ( '请填写联行号' );
  888. }
  889. Doo::loadModel ( 'receipt' );
  890. Doo::loadModel ( 'receiptDetail' );
  891. Doo::loadModel ( 'accountItem' );
  892. $accountItem = new accountItem ();
  893. $receipt = new receipt ();
  894. Doo::loadModel ( 'loanReceipt' );
  895. $loanReceipt = new loanReceipt ();
  896. Doo::loadModel ( 'execute' );
  897. $execute = new execute ();
  898. Doo::loadModel ( 'enclosur' );
  899. $executeDetail = $execute->getOne ( array (
  900. 'where' => 'mold="借款执行人"',
  901. 'asArray' => true
  902. ) );
  903. $aItem = $accountItem->find ( array (
  904. 'asArray' => true
  905. ) );
  906. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  907. $ag = $tr = $ta = $ot = 0;
  908. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  909. array_push ( $accountJson ['借款费用'], array (
  910. 'aid' => 0,
  911. 'name' => '申请金额',
  912. 'price' => number_format ( $agency, 2, '.', '' )
  913. ) );
  914. $sum += $agency;
  915. $agencySum += $agency;
  916. $accountJson ['cSum'] = array (
  917. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  918. 'agencySum' => number_format ( 0, 2, '.', '' ),
  919. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  920. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  921. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  922. );
  923. // 借款数据备份
  924. $loanReceipt->loanItem = json_encode ( $accountJson );
  925. $loanReceipt->staff = $this->staff [0] ['sid'];
  926. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  927. $loanReceipt->date = date ( "Y-m-d" );
  928. $loanReceipt->cid = $cid;
  929. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  930. $loanReceipt->status = 5;
  931. $loanReceipt->Rtype = 1;
  932. $loanReceipt->verify = $verify;
  933. $receipt->receiptOrder = $receipt->receiptOrder;
  934. $loanReceipt->explanation = $explanation;
  935. $loanRid = $loanReceipt->insert ();
  936. // 报销单
  937. $receipt->loanItem = json_encode ( $accountJson );
  938. $receipt->staff = $this->staff [0] ['sid'];
  939. $receipt->sum = number_format ( $sum, 2, '.', '' );
  940. $receipt->date = date ( "Y-m-d" );
  941. $receipt->cid = $cid;
  942. // 特殊状态
  943. $receipt->status = 5;
  944. $receipt->Rtype = 1;
  945. $receipt->loanRid = $loanRid;
  946. // 修改审批流程加入角色
  947. $receipt->verify = $verify;
  948. $receipt->executeCopy = $executeDetail ['staff'];
  949. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  950. $receipt->explanation = $explanation;
  951. $receipt->remittanceName = $remittanceName;
  952. $receipt->bankName = $bankName;
  953. $receipt->bankNumber = $bankNumber;
  954. $receipt->remittanceBankType = $remittanceBankType;
  955. if ($remittanceBankType == 1)
  956. $receipt->coupletNumber = $coupletNumber;
  957. $rid = $receipt->insert ();
  958. return "/saeaBorad";
  959. } else
  960. die ( 'illegal request' );
  961. }
  962. function saeaLoanEdi() {
  963. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  964. Doo::loadClass ( 'XDeode' );
  965. $XDeode = new XDeode ( 7 );
  966. $rid = $XDeode->decode ( $ridKey );
  967. if (! is_numeric ( $rid ))
  968. die ( 'illegal request' );
  969. Doo::loadModel ( 'verify' );
  970. $verify = new verify ();
  971. Doo::loadModel ( "role" );
  972. $role = new role ();
  973. Doo::loadModel ( 'L_category' );
  974. $lCategory = new L_category ();
  975. Doo::loadModel ( 'receipt' );
  976. $receipt = new receipt ();
  977. $receiptInfo = $receipt->getOne ( array (
  978. 'where' => 'rid=' . $rid,
  979. 'asArray' => true
  980. ) );
  981. $veList = $verify->find ( array (
  982. 'asArray' => true
  983. ) );
  984. foreach ( $veList as $key => $value ) {
  985. $v = json_decode ( $value ['staff'] );
  986. $list = array ();
  987. foreach ( $v as $n => $m ) {
  988. if ($m ['1'] == 'ROLE') {
  989. $roleInfo = $role->getOne ( array (
  990. 'where' => 'rid=' . $m [0],
  991. 'asArray' => true
  992. ) );
  993. $v [$n] [1] = $roleInfo ['name'];
  994. array_push ( $list, $roleInfo ['name'] );
  995. } else {
  996. array_push ( $list, $v [$n] [1] );
  997. }
  998. }
  999. $veList [$key] ['staff'] = implode ( '>', $list );
  1000. }
  1001. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  1002. // print_r($receiptInfo);
  1003. $data ['receiptInfo'] = $receiptInfo;
  1004. $data ['category'] = $lCategory->find ( array (
  1005. 'asArray' => true
  1006. ) );
  1007. $data ['veList'] = $veList;
  1008. $data ['ridKey'] = $ridKey;
  1009. $data ['memu'] = "receipt";
  1010. $data ['staff'] = $this->staff;
  1011. $data ['receiptMemu'] = 'saeaBorad';
  1012. $data ['verifyId'] = $this->verifyId;
  1013. $data ['executeId'] = $this->executeId;
  1014. $this->render ( "/admin/saeaLoanEdi", $data );
  1015. }
  1016. function saeaLoanEdiDo() {
  1017. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1018. $agency = $this->get_args ( 'agency' );
  1019. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1020. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1021. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1022. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1023. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1024. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1025. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1026. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1027. // die;
  1028. Doo::loadClass ( 'XDeode' );
  1029. $XDeode = new XDeode ( 7 );
  1030. $rid = $XDeode->decode ( $ridKey );
  1031. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1032. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1033. header ( 'Content-Type:text/html;charset=utf-8' );
  1034. die ( '请填写联行号' );
  1035. }
  1036. Doo::loadModel ( 'receipt' );
  1037. Doo::loadModel ( 'receiptDetail' );
  1038. Doo::loadModel ( 'accountItem' );
  1039. $accountItem = new accountItem ();
  1040. $receipt = new receipt ();
  1041. Doo::loadModel ( 'loanReceipt' );
  1042. $loanReceipt = new loanReceipt ();
  1043. Doo::loadModel ( 'enclosur' );
  1044. Doo::loadModel ( 'execute' );
  1045. $execute = new execute ();
  1046. $executeDetail = $execute->getOne ( array (
  1047. 'where' => 'mold="借款执行人"',
  1048. 'asArray' => true
  1049. ) );
  1050. $receiptDetail = $receipt->getOne ( array (
  1051. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  1052. 'asArray' => true
  1053. ) );
  1054. if (empty ( $receiptDetail ))
  1055. die ( '参数错误' );
  1056. $aItem = $accountItem->find ( array (
  1057. 'asArray' => true
  1058. ) );
  1059. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1060. $ag = $tr = $ta = $ot = 0;
  1061. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1062. array_push ( $accountJson ['借款费用'], array (
  1063. 'aid' => 0,
  1064. 'name' => '申请金额',
  1065. 'price' => number_format ( $agency, 2, '.', '' )
  1066. ) );
  1067. $sum += $agency;
  1068. $agencySum += $agency;
  1069. $accountJson ['cSum'] = array (
  1070. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1071. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1072. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1073. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1074. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1075. );
  1076. // 报销单
  1077. $receipt->loanItem = json_encode ( $accountJson );
  1078. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1079. $receipt->cid = $cid;
  1080. // 特殊状态
  1081. // 修改审批流程加入角色
  1082. if ($receiptDetail ['status'] != 4)
  1083. $receipt->verify = $verify;
  1084. $receipt->explanation = $explanation;
  1085. $receipt->remittanceName = $remittanceName;
  1086. $receipt->bankName = $bankName;
  1087. $receipt->bankNumber = $bankNumber;
  1088. $receipt->remittanceBankType = $remittanceBankType;
  1089. if ($remittanceBankType == 1)
  1090. $receipt->coupletNumber = $coupletNumber;
  1091. $receipt->update ( array (
  1092. 'where' => 'rid=' . $rid
  1093. ) );
  1094. // 借款数据更新
  1095. $loanReceipt->loanItem = json_encode ( $accountJson );
  1096. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1097. $loanReceipt->cid = $cid;
  1098. if ($receiptDetail ['status'] != 4)
  1099. $loanReceipt->verify = $verify;
  1100. $loanReceipt->explanation = $explanation;
  1101. $receipt->executeCopy = $executeDetail ['staff'];
  1102. $loanReceipt->update ( array (
  1103. 'where' => 'rid=' . $receiptDetail ['loanRid']
  1104. ) );
  1105. }
  1106. return "/saeaBorad";
  1107. }
  1108. function saeaLoanReceiptAdd() {
  1109. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1110. Doo::loadModel ( 'receipt' );
  1111. $receipt = new receipt ();
  1112. Doo::loadModel ( 'loanReceipt' );
  1113. $loanReceipt = new loanReceipt ();
  1114. Doo::loadModel ( 'L_category' );
  1115. $Lcategory = new L_category ();
  1116. Doo::loadModel ( 'verify' );
  1117. Doo::loadModel ( 'statistics' );
  1118. $statistics = new statistics ();
  1119. $verify = new verify ();
  1120. Doo::loadModel ( 'staff' );
  1121. $staff = new staff ();
  1122. $receiptDetail = $receipt->getOne ( array (
  1123. 'where' => 'rid=' . $rid,
  1124. 'desc' => 'rid',
  1125. 'asArray' => true
  1126. ) );
  1127. $receiptList = $loanReceipt->find ( array (
  1128. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1129. 'desc' => 'rid',
  1130. 'asArray' => true
  1131. ) );
  1132. $Locate = 0;
  1133. $roleId = 0;
  1134. $button = 0;
  1135. foreach ( $receiptList as $key => $value ) {
  1136. $receiptList [$key] ['Locate'] = $Locate;
  1137. $Locate ++;
  1138. $receiptList [$key] ['reviseDetail'] = array ();
  1139. if (! empty ( $value ['reviseDetail'] ))
  1140. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1141. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1142. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1143. $categoryDetil = $Lcategory->getOne ( array (
  1144. 'where' => 'cid=' . $value ['cid'],
  1145. 'asArray' => true
  1146. ) );
  1147. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1148. // 检测编辑状态
  1149. $verifyList = $verify->getOne ( array (
  1150. 'where' => 'vid=' . $value ['verify'],
  1151. 'asArray' => true
  1152. ) );
  1153. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1154. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1155. Doo::loadModel ( 'role' );
  1156. $role = new role ();
  1157. $flag = true;
  1158. $roleKey = 0;
  1159. $endStaffArray = array ();
  1160. $roleArrayCopy = array ();
  1161. foreach ( $verifyList as $k => $v ) {
  1162. // init verifyStaff
  1163. if ($v [1] == 'ROLE') {
  1164. if (! empty ( $verifyStaff )) {
  1165. $endStaffArray = end ( $verifyStaff );
  1166. // if ($v[0]==$endStaffArray['nextStaff']){
  1167. // $roleId=$v[0];
  1168. // }
  1169. }
  1170. $roleVerify = json_decode ( $v [3], true );
  1171. $roleKey = $k;
  1172. $roleArray = array ();
  1173. $rolename = $role->getOne ( array (
  1174. 'where' => 'rid=' . $v [0],
  1175. 'asArray' => true
  1176. ) );
  1177. foreach ( $roleVerify as $o => $p ) {
  1178. $staffID = explode ( '_', $p );
  1179. $staffInfo = $staff->getOne ( array (
  1180. 'where' => 'sid=' . $staffID [0],
  1181. 'asArray' => true
  1182. ) );
  1183. // print_r($staffID);
  1184. $exp = array (
  1185. 0 => $staffInfo ['sid'],
  1186. 1 => $staffID [1],
  1187. 2 => $staffInfo ['avatar'],
  1188. 'date' => '',
  1189. 'date' => '',
  1190. 'opinion' => '',
  1191. 'status' => '',
  1192. 'rolename' => $rolename ['name']
  1193. );
  1194. array_push ( $roleArray, $exp );
  1195. }
  1196. $roleArrayCopy [$v [0]] = $roleArray;
  1197. // $verifyList[$k]['roleArray']=$roleArray;
  1198. }
  1199. $verifyList [$k] ['date'] = "";
  1200. $verifyList [$k] ['opinion'] = "";
  1201. $verifyList [$k] ['status'] = "";
  1202. if (empty ( $verifyStaff )) {
  1203. $verifyList [$k] ['date'] = "";
  1204. $verifyList [$k] ['opinion'] = "";
  1205. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1206. $verifyList [$k] ['status'] = 4;
  1207. $flag = false;
  1208. }
  1209. } else {
  1210. foreach ( $verifyStaff as $m => $u ) {
  1211. if ($v [0] == $m) {
  1212. $verifyList [$k] ['date'] = $u ['date'];
  1213. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1214. $verifyList [$k] ['status'] = $u ['status'];
  1215. $flag = false;
  1216. break;
  1217. }
  1218. }
  1219. $endStaffArray = end ( $verifyStaff );
  1220. if (isset ( $endStaffArray ['ROLE'] )) {
  1221. } else {
  1222. // $endKey=key($verifyStaff);
  1223. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1224. // $button=4;
  1225. // $verifyList[$k]['status']=4;
  1226. // }
  1227. }
  1228. }
  1229. }
  1230. $rolename ['name'] = '';
  1231. if (! empty ( $roleId )) {
  1232. Doo::loadModel ( 'role' );
  1233. $role = new role ();
  1234. $rolename = $role->getOne ( array (
  1235. 'where' => 'rid=' . $roleId,
  1236. 'asArray' => true
  1237. ) );
  1238. }
  1239. if (! empty ( $verifyStaff ))
  1240. $endStaffArray = end ( $verifyStaff );
  1241. $KOP = false;
  1242. foreach ( $roleArrayCopy as $P => $A ) {
  1243. foreach ( $A as $MKI => $AVL ) {
  1244. if (! empty ( $verifyStaff )) {
  1245. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1246. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1247. $button = 4;
  1248. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1249. }
  1250. foreach ( $verifyStaff as $m => $u ) {
  1251. $AVLFK = $AVL [0] . '_R';
  1252. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1253. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1254. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1255. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1256. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1257. break;
  1258. }
  1259. }
  1260. } else {
  1261. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1262. $button = 4;
  1263. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1264. }
  1265. }
  1266. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1267. $KOP = true;
  1268. }
  1269. }
  1270. foreach ( $roleArrayCopy as $k => $v ) {
  1271. foreach ( $verifyList as $m => $n ) {
  1272. if ($n [0] == $k) {
  1273. array_splice ( $verifyList, $m, 1, $v );
  1274. }
  1275. }
  1276. }
  1277. $receiptList [$key] ['verifyList'] = $verifyList;
  1278. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1279. 'where' => 'sid=' . $value ['staff'],
  1280. 'asArray' => true
  1281. ) );
  1282. $receiptList [$key] ['button'] = $button;
  1283. //
  1284. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1285. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1286. }
  1287. $data ['receiptList'] = $receiptList;
  1288. $data ['receiptDetail'] = $receiptDetail;
  1289. Doo::loadModel ( 'L_category' );
  1290. $lCategory = new L_category ();
  1291. Doo::loadModel ( 'accountItem' );
  1292. $accountItem = new accountItem ();
  1293. $acItem = $accountItem->find ( array (
  1294. 'asArray' => true
  1295. ) );
  1296. $veList = $verify->find ( array (
  1297. 'asArray' => true
  1298. ) );
  1299. foreach ( $veList as $key => $value ) {
  1300. $v = json_decode ( $value ['staff'] );
  1301. $list = array ();
  1302. foreach ( $v as $n => $m ) {
  1303. if ($m ['1'] == 'ROLE') {
  1304. $roleInfo = $role->getOne ( array (
  1305. 'where' => 'rid=' . $m [0],
  1306. 'asArray' => true
  1307. ) );
  1308. $v [$n] [1] = $roleInfo ['name'];
  1309. array_push ( $list, $roleInfo ['name'] );
  1310. } else {
  1311. array_push ( $list, $v [$n] [1] );
  1312. }
  1313. }
  1314. $veList [$key] ['staff'] = implode ( '>', $list );
  1315. }
  1316. $data ['rid'] = $rid;
  1317. $data ['category'] = $lCategory->find ( array (
  1318. 'asArray' => true
  1319. ) );
  1320. $data ['veList'] = $veList;
  1321. $data ['acItem'] = $acItem;
  1322. $data ['memu'] = "receipt";
  1323. $data ['staff'] = $this->staff;
  1324. $data ['receiptMemu'] = 'saeaBorad';
  1325. $data ['verifyId'] = $this->verifyId;
  1326. $data ['executeId'] = $this->executeId;
  1327. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1328. }
  1329. function saeaLoanReceiptAddDo() {
  1330. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1331. $agency = $this->get_args ( 'agency' );
  1332. $travel = $this->get_args ( 'travel' );
  1333. $train = $this->get_args ( 'train' );
  1334. $other = $this->get_args ( 'other' );
  1335. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1336. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1337. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1338. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1339. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1340. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1341. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1342. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1343. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1344. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1345. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1346. header ( 'Content-Type:text/html;charset=utf-8' );
  1347. die ( '请填写联行号' );
  1348. }
  1349. Doo::loadModel ( 'receipt' );
  1350. Doo::loadModel ( 'receiptDetail' );
  1351. Doo::loadModel ( 'accountItem' );
  1352. $accountItem = new accountItem ();
  1353. $receipt = new receipt ();
  1354. Doo::loadModel ( 'enclosur' );
  1355. Doo::loadModel ( 'execute' );
  1356. $execute = new execute ();
  1357. $executeDetail = $execute->getOne ( array (
  1358. 'where' => 'mold="借款费用执行人"',
  1359. 'asArray' => true
  1360. ) );
  1361. $receiptDet = $receipt->getOne ( array (
  1362. 'where' => 'rid=' . $rid,
  1363. 'asArray' => true
  1364. ) );
  1365. // if(!empty($receiptDetail))
  1366. // return "/referReceipt/".$receiptDetail['rid'];
  1367. $aItem = $accountItem->find ( array (
  1368. 'asArray' => true
  1369. ) );
  1370. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1371. $ag = $tr = $ta = $ot = 0;
  1372. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1373. foreach ( $aItem as $key => $value ) {
  1374. if ($value ['category'] == $this->AGENCY) {
  1375. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1376. array_push ( $accountJson [$this->AGENCY], array (
  1377. 'aid' => $value ['aid'],
  1378. 'name' => $value ['name'],
  1379. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1380. ) );
  1381. $sum += $agency [$ag];
  1382. $agencySum += $agency [$ag];
  1383. }
  1384. $ag ++;
  1385. }
  1386. if ($value ['category'] == $this->TRAVEL) {
  1387. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1388. array_push ( $accountJson [$this->TRAVEL], array (
  1389. 'aid' => $value ['aid'],
  1390. 'name' => $value ['name'],
  1391. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1392. ) );
  1393. $sum += $travel [$tr];
  1394. $travelSum += $travel [$tr];
  1395. }
  1396. $tr ++;
  1397. }
  1398. if ($value ['category'] == $this->TRAIN) {
  1399. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1400. array_push ( $accountJson [$this->TRAIN], array (
  1401. 'aid' => $value ['aid'],
  1402. 'name' => $value ['name'],
  1403. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1404. ) );
  1405. $sum += $train [$ta];
  1406. $trainSum += $train [$ta];
  1407. }
  1408. $ta ++;
  1409. }
  1410. if ($value ['category'] == $this->OTHER) {
  1411. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1412. array_push ( $accountJson [$this->OTHER], array (
  1413. 'aid' => $value ['aid'],
  1414. 'name' => $value ['name'],
  1415. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1416. ) );
  1417. $sum += $other [$ot];
  1418. $otherSum += $other [$ot];
  1419. }
  1420. $ot ++;
  1421. }
  1422. }
  1423. $accountJson ['cSum'] = array (
  1424. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1425. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1426. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1427. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1428. );
  1429. // 报销单
  1430. $receipt->accountItem = json_encode ( $accountJson );
  1431. $receipt->staff = $this->staff [0] ['sid'];
  1432. $receipt->loanSum = $receiptDet ['sum'];
  1433. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1434. $receipt->date = date ( "Y-m-d" );
  1435. $receipt->pastDate = '';
  1436. $receipt->cid = $cid;
  1437. $receipt->status = 7;
  1438. // 修改审批流程加入角色
  1439. $receipt->verify = $verify;
  1440. $receipt->verifyStaff = '';
  1441. $receipt->executeStaff = '';
  1442. $receipt->executeCopy = $executeDetail ['staff'];
  1443. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  1444. $receipt->explanation = $explanation;
  1445. $receipt->remittanceName = $remittanceName;
  1446. $receipt->bankName = $bankName;
  1447. $receipt->bankNumber = $bankNumber;
  1448. $receipt->remittanceBankType = $remittanceBankType;
  1449. if ($remittanceBankType == 1)
  1450. $receipt->coupletNumber = $coupletNumber;
  1451. $receipt->update ( array (
  1452. 'where' => 'rid=' . $rid
  1453. ) );
  1454. // 附件
  1455. if (! empty ( $enclosurName )) {
  1456. $enclosurArray = explode ( '-', $enclosurName );
  1457. foreach ( $enclosurArray as $value ) {
  1458. $enclosur = new enclosur ();
  1459. $enclosur->name = $value;
  1460. $enclosur->rid = $rid;
  1461. $enclosur->insert ();
  1462. }
  1463. // print_r($enclosurArray);die;
  1464. }
  1465. // 报销详情
  1466. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1467. $receiptDetail = new receiptDetail ();
  1468. $receiptDetail->staff = $this->staff [0] ['sid'];
  1469. $receiptDetail->item = $value ['name'];
  1470. $receiptDetail->itemCategory = $this->AGENCY;
  1471. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1472. $receiptDetail->date = date ( "Y-m-d" );
  1473. $receiptDetail->cid = $cid;
  1474. $receiptDetail->rid = $rid;
  1475. $receiptDetail->status = 4;
  1476. $receiptDetail->insert ();
  1477. }
  1478. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1479. $receiptDetail = new receiptDetail ();
  1480. $receiptDetail->staff = $this->staff [0] ['sid'];
  1481. $receiptDetail->item = $value ['name'];
  1482. $receiptDetail->itemCategory = $this->TRAVEL;
  1483. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1484. $receiptDetail->date = date ( "Y-m-d" );
  1485. $receiptDetail->cid = $cid;
  1486. $receiptDetail->rid = $rid;
  1487. $receiptDetail->status = 4;
  1488. $receiptDetail->insert ();
  1489. }
  1490. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1491. $receiptDetail = new receiptDetail ();
  1492. $receiptDetail->staff = $this->staff [0] ['sid'];
  1493. $receiptDetail->item = $value ['name'];
  1494. $receiptDetail->itemCategory = $this->TRAIN;
  1495. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1496. $receiptDetail->date = date ( "Y-m-d" );
  1497. $receiptDetail->cid = $cid;
  1498. $receiptDetail->rid = $rid;
  1499. $receiptDetail->status = 4;
  1500. $receiptDetail->insert ();
  1501. }
  1502. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1503. $receiptDetail = new receiptDetail ();
  1504. $receiptDetail->staff = $this->staff [0] ['sid'];
  1505. $receiptDetail->item = $value ['name'];
  1506. $receiptDetail->itemCategory = $this->OTHER;
  1507. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1508. $receiptDetail->date = date ( "Y-m-d" );
  1509. $receiptDetail->cid = $cid;
  1510. $receiptDetail->rid = $rid;
  1511. $receiptDetail->status = 4;
  1512. $receiptDetail->insert ();
  1513. }
  1514. return "/saeaBorad";
  1515. }
  1516. return "/saeaLoanReceiptAdd/" . $rid;
  1517. }
  1518. function saeaLoanReceiptEdi() {
  1519. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1520. Doo::loadClass ( 'XDeode' );
  1521. $XDeode = new XDeode ( 7 );
  1522. $rid = $XDeode->decode ( $ridKey );
  1523. if (! is_numeric ( $rid ))
  1524. die ( 'illegal request' );
  1525. Doo::loadModel ( 'accountItem' );
  1526. Doo::loadModel ( 'verify' );
  1527. Doo::loadModel ( 'receipt' );
  1528. $receipt = new receipt ();
  1529. $verify = new verify ();
  1530. $accountItem = new accountItem ();
  1531. Doo::loadModel ( 'L_category' );
  1532. $Lcategory = new L_category ();
  1533. Doo::loadModel ( "role" );
  1534. $role = new role ();
  1535. Doo::loadModel ( 'loanReceipt' );
  1536. $loanReceipt = new loanReceipt ();
  1537. Doo::loadModel ( 'staff' );
  1538. $staff = new staff ();
  1539. $receiptDetail = $receipt->getOne ( array (
  1540. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  1541. 'asArray' => true
  1542. ) );
  1543. if (empty ( $receiptDetail ))
  1544. return "/saeaBorad";
  1545. $receiptList = $loanReceipt->find ( array (
  1546. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1547. 'desc' => 'rid',
  1548. 'asArray' => true
  1549. ) );
  1550. $Locate = 0;
  1551. $roleId = 0;
  1552. $button = 0;
  1553. foreach ( $receiptList as $key => $value ) {
  1554. $receiptList [$key] ['Locate'] = $Locate;
  1555. $Locate ++;
  1556. $receiptList [$key] ['reviseDetail'] = array ();
  1557. if (! empty ( $value ['reviseDetail'] ))
  1558. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1559. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1560. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1561. $categoryDetil = $Lcategory->getOne ( array (
  1562. 'where' => 'cid=' . $value ['cid'],
  1563. 'asArray' => true
  1564. ) );
  1565. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1566. // 检测编辑状态
  1567. $verifyList = $verify->getOne ( array (
  1568. 'where' => 'vid=' . $value ['verify'],
  1569. 'asArray' => true
  1570. ) );
  1571. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1572. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1573. Doo::loadModel ( 'role' );
  1574. $role = new role ();
  1575. $flag = true;
  1576. $roleKey = 0;
  1577. $endStaffArray = array ();
  1578. $roleArrayCopy = array ();
  1579. foreach ( $verifyList as $k => $v ) {
  1580. // init verifyStaff
  1581. if ($v [1] == 'ROLE') {
  1582. if (! empty ( $verifyStaff )) {
  1583. $endStaffArray = end ( $verifyStaff );
  1584. // if ($v[0]==$endStaffArray['nextStaff']){
  1585. // $roleId=$v[0];
  1586. // }
  1587. }
  1588. $roleVerify = json_decode ( $v [3], true );
  1589. $roleKey = $k;
  1590. $roleArray = array ();
  1591. $rolename = $role->getOne ( array (
  1592. 'where' => 'rid=' . $v [0],
  1593. 'asArray' => true
  1594. ) );
  1595. foreach ( $roleVerify as $o => $p ) {
  1596. $staffID = explode ( '_', $p );
  1597. $staffInfo = $staff->getOne ( array (
  1598. 'where' => 'sid=' . $staffID [0],
  1599. 'asArray' => true
  1600. ) );
  1601. // print_r($staffID);
  1602. $exp = array (
  1603. 0 => $staffInfo ['sid'],
  1604. 1 => $staffID [1],
  1605. 2 => $staffInfo ['avatar'],
  1606. 'date' => '',
  1607. 'date' => '',
  1608. 'opinion' => '',
  1609. 'status' => '',
  1610. 'rolename' => $rolename ['name']
  1611. );
  1612. array_push ( $roleArray, $exp );
  1613. }
  1614. $roleArrayCopy [$v [0]] = $roleArray;
  1615. // $verifyList[$k]['roleArray']=$roleArray;
  1616. }
  1617. $verifyList [$k] ['date'] = "";
  1618. $verifyList [$k] ['opinion'] = "";
  1619. $verifyList [$k] ['status'] = "";
  1620. if (empty ( $verifyStaff )) {
  1621. $verifyList [$k] ['date'] = "";
  1622. $verifyList [$k] ['opinion'] = "";
  1623. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1624. $verifyList [$k] ['status'] = 4;
  1625. $flag = false;
  1626. }
  1627. } else {
  1628. foreach ( $verifyStaff as $m => $u ) {
  1629. if ($v [0] == $m) {
  1630. $verifyList [$k] ['date'] = $u ['date'];
  1631. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1632. $verifyList [$k] ['status'] = $u ['status'];
  1633. $flag = false;
  1634. break;
  1635. }
  1636. }
  1637. $endStaffArray = end ( $verifyStaff );
  1638. if (isset ( $endStaffArray ['ROLE'] )) {
  1639. } else {
  1640. // $endKey=key($verifyStaff);
  1641. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1642. // $button=4;
  1643. // $verifyList[$k]['status']=4;
  1644. // }
  1645. }
  1646. }
  1647. }
  1648. $rolename ['name'] = '';
  1649. if (! empty ( $roleId )) {
  1650. Doo::loadModel ( 'role' );
  1651. $role = new role ();
  1652. $rolename = $role->getOne ( array (
  1653. 'where' => 'rid=' . $roleId,
  1654. 'asArray' => true
  1655. ) );
  1656. }
  1657. if (! empty ( $verifyStaff ))
  1658. $endStaffArray = end ( $verifyStaff );
  1659. $KOP = false;
  1660. foreach ( $roleArrayCopy as $P => $A ) {
  1661. foreach ( $A as $MKI => $AVL ) {
  1662. if (! empty ( $verifyStaff )) {
  1663. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1664. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1665. $button = 4;
  1666. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1667. }
  1668. foreach ( $verifyStaff as $m => $u ) {
  1669. $AVLFK = $AVL [0] . '_R';
  1670. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1671. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1672. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1673. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1674. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1675. break;
  1676. }
  1677. }
  1678. } else {
  1679. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1680. $button = 4;
  1681. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1682. }
  1683. }
  1684. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1685. $KOP = true;
  1686. }
  1687. }
  1688. foreach ( $roleArrayCopy as $k => $v ) {
  1689. foreach ( $verifyList as $m => $n ) {
  1690. if ($n [0] == $k) {
  1691. array_splice ( $verifyList, $m, 1, $v );
  1692. }
  1693. }
  1694. }
  1695. $receiptList [$key] ['verifyList'] = $verifyList;
  1696. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1697. 'where' => 'sid=' . $value ['staff'],
  1698. 'asArray' => true
  1699. ) );
  1700. $receiptList [$key] ['button'] = $button;
  1701. //
  1702. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1703. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1704. }
  1705. $data ['receiptList'] = $receiptList;
  1706. $acItem = $accountItem->find ( array (
  1707. 'asArray' => true
  1708. ) );
  1709. $veList = $verify->find ( array (
  1710. 'asArray' => true
  1711. ) );
  1712. foreach ( $veList as $key => $value ) {
  1713. $v = json_decode ( $value ['staff'] );
  1714. $list = array ();
  1715. foreach ( $v as $n => $m ) {
  1716. if ($m ['1'] == 'ROLE') {
  1717. $roleInfo = $role->getOne ( array (
  1718. 'where' => 'rid=' . $m [0],
  1719. 'asArray' => true
  1720. ) );
  1721. $v [$n] [1] = $roleInfo ['name'];
  1722. array_push ( $list, $roleInfo ['name'] );
  1723. } else {
  1724. array_push ( $list, $v [$n] [1] );
  1725. }
  1726. }
  1727. $veList [$key] ['staff'] = implode ( '>', $list );
  1728. }
  1729. // 配置编辑信息
  1730. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1731. foreach ( $acItem as $key => $value ) {
  1732. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1733. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1734. $acItem [$key] ['price'] = $v ['price'];
  1735. }
  1736. }
  1737. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1738. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1739. $acItem [$key] ['price'] = $v ['price'];
  1740. }
  1741. }
  1742. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1743. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1744. $acItem [$key] ['price'] = $v ['price'];
  1745. }
  1746. }
  1747. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1748. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1749. $acItem [$key] ['price'] = $v ['price'];
  1750. }
  1751. }
  1752. }
  1753. $data ['category'] = $Lcategory->find ( array (
  1754. 'asArray' => true
  1755. ) );
  1756. $data ['ridKey'] = $ridKey;
  1757. $data ['cSum'] = $accountItemList ['cSum'];
  1758. $data ['sum'] = $receiptDetail ['sum'];
  1759. $data ['receiptDetail'] = $receiptDetail;
  1760. $data ['veList'] = $veList;
  1761. $data ['acItem'] = $acItem;
  1762. $data ['memu'] = "receipt";
  1763. $data ['staff'] = $this->staff;
  1764. $data ['receiptMemu'] = 'saeaBorad';
  1765. $data ['verify'] = $receiptDetail ['verify'];
  1766. $data ['verifyId'] = $this->verifyId;
  1767. $data ['executeId'] = $this->executeId;
  1768. $data ['rid'] = $rid;
  1769. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  1770. }
  1771. function confirmation() {
  1772. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1773. Doo::loadModel ( 'receipt' );
  1774. Doo::loadModel ( 'receiptDetail' );
  1775. $receipt = new receipt ();
  1776. $receiptDetail = new receiptDetail ();
  1777. Doo::loadModel ( 'statistics' );
  1778. Doo::loadModel ( 'itemStatistics' );
  1779. $statistics = new statistics ();
  1780. $itemStatistics = new itemStatistics ();
  1781. Doo::loadModel ( "verify" );
  1782. $verify = new verify ();
  1783. $receiptDetailList = $receipt->getOne ( array (
  1784. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  1785. 'asArray' => true
  1786. ) );
  1787. if (empty ( $receiptDetailList ))
  1788. return "/saeaBorad";
  1789. $verifyDetail = $verify->getOne ( array (
  1790. 'where' => ' vid =' . $receiptDetailList ['verify'],
  1791. 'asArray' => true
  1792. ) );
  1793. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  1794. if (empty ( $receiptDetailList ['nowStaff'] )) {
  1795. $nowStaff = "";
  1796. $nowStaffList = array ();
  1797. if ($verifyDetail [0] [1] == 'ROLE') {
  1798. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  1799. foreach ( $vStaffString as $key => $value ) {
  1800. $staffK = explode ( "_", $value );
  1801. array_push ( $nowStaffList, $staffK [0] );
  1802. }
  1803. $nowStaff = implode ( ',', $nowStaffList );
  1804. } else {
  1805. $nowStaff = $verifyDetail [0] [0];
  1806. }
  1807. $receipt->nowStaff = $nowStaff;
  1808. }
  1809. // echo $nowStaff;
  1810. // print_r($verifyDetail);die;
  1811. $receipt->rid = $receiptDetailList ['rid'];
  1812. $receipt->status = 2;
  1813. $receipt->update ();
  1814. // 操作日志
  1815. Doo::loadModel ( "receiptLog" );
  1816. $receiptLog = new receiptLog ();
  1817. $verify = new verify ();
  1818. $receiptInfo = $receipt->getOne ( array (
  1819. 'where' => 'rid=' . $rid,
  1820. 'asArray' => true
  1821. ) );
  1822. $vr = $verify->getOne ( array (
  1823. 'where' => 'vid=' . $receiptInfo ['verify'],
  1824. 'asArray' => true
  1825. ) );
  1826. $jd = json_decode ( $vr ['staff'] );
  1827. $roleId = 0;
  1828. foreach ( $jd as $key => $value ) {
  1829. if ($value [1] == 'ROLE') {
  1830. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  1831. if ($pos !== false) {
  1832. $roleId = $value [0];
  1833. }
  1834. }
  1835. }
  1836. // 审批日志
  1837. // echo $roleId;die;
  1838. if (! empty ( $roleId )) {
  1839. Doo::loadModel ( "role" );
  1840. $role = new role ();
  1841. $roleInfo = $role->getOne ( array (
  1842. 'where' => 'rid=' . $roleId,
  1843. 'asArray' => true
  1844. ) );
  1845. $receiptLog->rolename = $roleInfo ['name'];
  1846. }
  1847. $receiptLog->username = $this->staff [0] ['username'];
  1848. $receiptLog->uid = $this->staff [0] ['sid'];
  1849. $receiptLog->date = date ( "Y-m-d" );
  1850. $receiptLog->opinion = '提交审批';
  1851. $receiptLog->img = $this->staff [0] ['avatar'];
  1852. $receiptLog->status = 2;
  1853. $receiptLog->rid = $rid;
  1854. $receiptLog->insert ();
  1855. return "/expenses";
  1856. }
  1857. function expenses() {
  1858. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  1859. if (empty ( $item ))
  1860. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  1861. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1862. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  1863. Doo::loadModel ( 'receipt' );
  1864. $receipt = new receipt ();
  1865. Doo::loadModel ( 'L_category' );
  1866. $Lcategory = new L_category ();
  1867. Doo::loadModel ( 'verify' );
  1868. Doo::loadModel ( 'statistics' );
  1869. $statistics = new statistics ();
  1870. $verify = new verify ();
  1871. Doo::loadModel ( 'staff' );
  1872. $staff = new staff ();
  1873. $condition = "";
  1874. if ($item == "expenses")
  1875. $condition = " and Rtype=1 ";
  1876. elseif ($item == "receipts")
  1877. $condition = " and Rtype=0 ";
  1878. elseif ($item == "remits")
  1879. $condition = " and Rtype=2 ";
  1880. $dateCondition = " and Year(date) =" . $year;
  1881. if (! empty ( $moth )) {
  1882. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  1883. $stList = $statistics->getOne ( array (
  1884. 'select' => 'rePrice ,agPrice',
  1885. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  1886. 'asArray' => true
  1887. ) );
  1888. } else
  1889. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  1890. if (empty ( $stList ))
  1891. $stList = array (
  1892. 'rePrice' => 0,
  1893. 'agPrice' => 0
  1894. );
  1895. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  1896. if (! isset ( $noPassSum ['sum'] ))
  1897. $noPassSum ['sum'] = 0;
  1898. $data ['stList'] = array (
  1899. 'rePrice' => $stList ['rePrice'],
  1900. 'agPrice' => $stList ['agPrice'],
  1901. 'skPrice' => ($noPassSum ['sum'])
  1902. );
  1903. $receiptList = $receipt->find ( array (
  1904. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  1905. 'desc' => 'rid',
  1906. 'asArray' => true
  1907. ) );
  1908. $Locate = 0;
  1909. $roleId = 0;
  1910. $button = 0;
  1911. foreach ( $receiptList as $key => $value ) {
  1912. $receiptList [$key] ['Locate'] = $Locate;
  1913. $Locate ++;
  1914. $receiptList [$key] ['reviseDetail'] = array ();
  1915. if (! empty ( $value ['reviseDetail'] ))
  1916. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1917. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1918. $categoryDetil = $Lcategory->getOne ( array (
  1919. 'where' => 'cid=' . $value ['cid'],
  1920. 'asArray' => true
  1921. ) );
  1922. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1923. // 检测编辑状态
  1924. $verifyList = $verify->getOne ( array (
  1925. 'where' => 'vid=' . $value ['verify'],
  1926. 'asArray' => true
  1927. ) );
  1928. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1929. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1930. Doo::loadModel ( 'role' );
  1931. $role = new role ();
  1932. $flag = true;
  1933. $roleKey = 0;
  1934. $endStaffArray = array ();
  1935. $roleArrayCopy = array ();
  1936. foreach ( $verifyList as $k => $v ) {
  1937. // init verifyStaff
  1938. if ($v [1] == 'ROLE') {
  1939. if (! empty ( $verifyStaff )) {
  1940. $endStaffArray = end ( $verifyStaff );
  1941. // if ($v[0]==$endStaffArray['nextStaff']){
  1942. // $roleId=$v[0];
  1943. // }
  1944. }
  1945. $roleVerify = json_decode ( $v [3], true );
  1946. $roleKey = $k;
  1947. $roleArray = array ();
  1948. $rolename = $role->getOne ( array (
  1949. 'where' => 'rid=' . $v [0],
  1950. 'asArray' => true
  1951. ) );
  1952. foreach ( $roleVerify as $o => $p ) {
  1953. $staffID = explode ( '_', $p );
  1954. $staffInfo = $staff->getOne ( array (
  1955. 'where' => 'sid=' . $staffID [0],
  1956. 'asArray' => true
  1957. ) );
  1958. // print_r($staffID);
  1959. $exp = array (
  1960. 0 => $staffInfo ['sid'],
  1961. 1 => $staffID [1],
  1962. 2 => $staffInfo ['avatar'],
  1963. 'date' => '',
  1964. 'date' => '',
  1965. 'opinion' => '',
  1966. 'status' => '',
  1967. 'rolename' => $rolename ['name']
  1968. );
  1969. array_push ( $roleArray, $exp );
  1970. }
  1971. $roleArrayCopy [$v [0]] = $roleArray;
  1972. // $verifyList[$k]['roleArray']=$roleArray;
  1973. }
  1974. $verifyList [$k] ['date'] = "";
  1975. $verifyList [$k] ['opinion'] = "";
  1976. $verifyList [$k] ['status'] = "";
  1977. if (empty ( $verifyStaff )) {
  1978. $verifyList [$k] ['date'] = "";
  1979. $verifyList [$k] ['opinion'] = "";
  1980. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1981. $verifyList [$k] ['status'] = 4;
  1982. $flag = false;
  1983. }
  1984. } else {
  1985. foreach ( $verifyStaff as $m => $u ) {
  1986. if ($v [0] == $m) {
  1987. $verifyList [$k] ['date'] = $u ['date'];
  1988. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1989. $verifyList [$k] ['status'] = $u ['status'];
  1990. $flag = false;
  1991. break;
  1992. }
  1993. }
  1994. $endStaffArray = end ( $verifyStaff );
  1995. if (isset ( $endStaffArray ['ROLE'] )) {
  1996. } else {
  1997. // $endKey=key($verifyStaff);
  1998. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1999. // $button=4;
  2000. // $verifyList[$k]['status']=4;
  2001. // }
  2002. }
  2003. }
  2004. }
  2005. $rolename ['name'] = '';
  2006. if (! empty ( $roleId )) {
  2007. Doo::loadModel ( 'role' );
  2008. $role = new role ();
  2009. $rolename = $role->getOne ( array (
  2010. 'where' => 'rid=' . $roleId,
  2011. 'asArray' => true
  2012. ) );
  2013. }
  2014. if (! empty ( $verifyStaff ))
  2015. $endStaffArray = end ( $verifyStaff );
  2016. $KOP = false;
  2017. foreach ( $roleArrayCopy as $P => $A ) {
  2018. foreach ( $A as $MKI => $AVL ) {
  2019. if (! empty ( $verifyStaff )) {
  2020. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2021. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2022. $button = 4;
  2023. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2024. }
  2025. foreach ( $verifyStaff as $m => $u ) {
  2026. $AVLFK = $AVL [0] . '_R';
  2027. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2028. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2029. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2030. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2031. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2032. break;
  2033. }
  2034. }
  2035. } else {
  2036. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2037. $button = 4;
  2038. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2039. }
  2040. }
  2041. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2042. $KOP = true;
  2043. }
  2044. }
  2045. foreach ( $roleArrayCopy as $k => $v ) {
  2046. foreach ( $verifyList as $m => $n ) {
  2047. if ($n [0] == $k) {
  2048. array_splice ( $verifyList, $m, 1, $v );
  2049. }
  2050. }
  2051. }
  2052. $receiptList [$key] ['verifyList'] = $verifyList;
  2053. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2054. 'where' => 'sid=' . $value ['staff'],
  2055. 'asArray' => true
  2056. ) );
  2057. $receiptList [$key] ['button'] = $button;
  2058. }
  2059. // print_r($receiptList);die;
  2060. $mothHtml = "";
  2061. for($i = 1; $i <= 12; $i ++) {
  2062. if ($moth == $i)
  2063. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2064. else
  2065. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2066. }
  2067. $data ['mothHtml'] = $mothHtml;
  2068. $data ['receiptList'] = $receiptList;
  2069. $data ['memu'] = "receipt";
  2070. $data ['staff'] = $this->staff;
  2071. $data ['receiptMemu'] = 'expenses';
  2072. $data ['verifyId'] = $this->verifyId;
  2073. $data ['executeId'] = $this->executeId;
  2074. $data ['item'] = $item;
  2075. $data ['year'] = $year;
  2076. $this->render ( "/admin/expenses", $data );
  2077. }
  2078. function expensesCollect() {
  2079. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2080. Doo::loadModel ( 'receipt' );
  2081. $receipt = new receipt ();
  2082. Doo::loadModel ( 'L_category' );
  2083. $Lcategory = new L_category ();
  2084. Doo::loadModel ( 'verify' );
  2085. Doo::loadModel ( 'statistics' );
  2086. $statistics = new statistics ();
  2087. $verify = new verify ();
  2088. Doo::loadModel ( 'staff' );
  2089. $staff = new staff ();
  2090. Doo::loadModel ( 'loanReceipt' );
  2091. $loanReceipt = new loanReceipt ();
  2092. $receiptList = $receipt->find ( array (
  2093. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  2094. 'desc' => 'rid',
  2095. 'asArray' => true
  2096. ) );
  2097. $loanList = $loanReceipt->find ( array (
  2098. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2099. 'desc' => 'rid',
  2100. 'asArray' => true
  2101. ) );
  2102. /*
  2103. * $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;
  2104. */
  2105. $data ['explanation'] = '';
  2106. if (! empty ( $loanList ))
  2107. $data ['explanation'] = $loanList [0] ['explanation'];
  2108. $Locate = 0;
  2109. $roleId = 0;
  2110. $button = 0;
  2111. foreach ( $receiptList as $key => $value ) {
  2112. $receiptList [$key] ['Locate'] = $Locate;
  2113. $Locate ++;
  2114. $receiptList [$key] ['reviseDetail'] = array ();
  2115. if (! empty ( $value ['reviseDetail'] ))
  2116. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2117. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2118. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2119. $categoryDetil = $Lcategory->getOne ( array (
  2120. 'where' => 'cid=' . $value ['cid'],
  2121. 'asArray' => true
  2122. ) );
  2123. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2124. // 检测编辑状态
  2125. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  2126. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  2127. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  2128. else
  2129. $verifyList ['staff'] = $value ['verifyBreakup'];
  2130. } else
  2131. $verifyList = $verify->getOne ( array (
  2132. 'where' => 'vid=' . $value ['verify'],
  2133. 'asArray' => true
  2134. ) );
  2135. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2136. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2137. Doo::loadModel ( 'role' );
  2138. $role = new role ();
  2139. $flag = true;
  2140. $roleKey = 0;
  2141. $endStaffArray = array ();
  2142. $roleArrayCopy = array ();
  2143. foreach ( $verifyList as $k => $v ) {
  2144. // init verifyStaff
  2145. if ($v [1] == 'ROLE') {
  2146. if (! empty ( $verifyStaff )) {
  2147. $endStaffArray = end ( $verifyStaff );
  2148. // if ($v[0]==$endStaffArray['nextStaff']){
  2149. // $roleId=$v[0];
  2150. // }
  2151. }
  2152. $roleVerify = json_decode ( $v [3], true );
  2153. $roleKey = $k;
  2154. $roleArray = array ();
  2155. $rolename = $role->getOne ( array (
  2156. 'where' => 'rid=' . $v [0],
  2157. 'asArray' => true
  2158. ) );
  2159. foreach ( $roleVerify as $o => $p ) {
  2160. $staffID = explode ( '_', $p );
  2161. $staffInfo = $staff->getOne ( array (
  2162. 'where' => 'sid=' . $staffID [0],
  2163. 'asArray' => true
  2164. ) );
  2165. // print_r($staffID);
  2166. $exp = array (
  2167. 0 => $staffInfo ['sid'],
  2168. 1 => $staffID [1],
  2169. 2 => $staffInfo ['avatar'],
  2170. 'date' => '',
  2171. 'date' => '',
  2172. 'opinion' => '',
  2173. 'status' => '',
  2174. 'rolename' => $rolename ['name']
  2175. );
  2176. array_push ( $roleArray, $exp );
  2177. }
  2178. $roleArrayCopy [$v [0]] = $roleArray;
  2179. // $verifyList[$k]['roleArray']=$roleArray;
  2180. }
  2181. $verifyList [$k] ['date'] = "";
  2182. $verifyList [$k] ['opinion'] = "";
  2183. $verifyList [$k] ['status'] = "";
  2184. if (empty ( $verifyStaff )) {
  2185. $verifyList [$k] ['date'] = "";
  2186. $verifyList [$k] ['opinion'] = "";
  2187. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2188. $verifyList [$k] ['status'] = 4;
  2189. $flag = false;
  2190. }
  2191. } else {
  2192. foreach ( $verifyStaff as $m => $u ) {
  2193. if ($v [0] == $m) {
  2194. $verifyList [$k] ['date'] = $u ['date'];
  2195. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2196. $verifyList [$k] ['status'] = $u ['status'];
  2197. $flag = false;
  2198. break;
  2199. }
  2200. }
  2201. $endStaffArray = end ( $verifyStaff );
  2202. if (isset ( $endStaffArray ['ROLE'] )) {
  2203. } else {
  2204. // $endKey=key($verifyStaff);
  2205. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2206. // $button=4;
  2207. // $verifyList[$k]['status']=4;
  2208. // }
  2209. }
  2210. }
  2211. }
  2212. $rolename ['name'] = '';
  2213. if (! empty ( $roleId )) {
  2214. Doo::loadModel ( 'role' );
  2215. $role = new role ();
  2216. $rolename = $role->getOne ( array (
  2217. 'where' => 'rid=' . $roleId,
  2218. 'asArray' => true
  2219. ) );
  2220. }
  2221. if (! empty ( $verifyStaff ))
  2222. $endStaffArray = end ( $verifyStaff );
  2223. $KOP = false;
  2224. foreach ( $roleArrayCopy as $P => $A ) {
  2225. foreach ( $A as $MKI => $AVL ) {
  2226. if (! empty ( $verifyStaff )) {
  2227. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2228. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2229. $button = 4;
  2230. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2231. }
  2232. foreach ( $verifyStaff as $m => $u ) {
  2233. $AVLFK = $AVL [0] . '_R';
  2234. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2235. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2236. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2237. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2238. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2239. break;
  2240. }
  2241. }
  2242. } else {
  2243. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2244. $button = 4;
  2245. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2246. }
  2247. }
  2248. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2249. $KOP = true;
  2250. }
  2251. }
  2252. foreach ( $roleArrayCopy as $k => $v ) {
  2253. foreach ( $verifyList as $m => $n ) {
  2254. if ($n [0] == $k) {
  2255. array_splice ( $verifyList, $m, 1, $v );
  2256. }
  2257. }
  2258. }
  2259. // 费用执行人相关数据
  2260. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2261. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2262. foreach ( $executeCopy as $k => $v ) {
  2263. $executeCopy [$k] ['date'] = '';
  2264. $executeCopy [$k] ['opinion'] = '';
  2265. $executeCopy [$k] ['status'] = '';
  2266. if (! empty ( $executeStaff ))
  2267. foreach ( $executeStaff as $m => $u ) {
  2268. if ($v [0] == $m) {
  2269. $executeCopy [$k] ['date'] = $u ['date'];
  2270. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2271. $executeCopy [$k] ['status'] = $u ['status'];
  2272. break;
  2273. }
  2274. }
  2275. }
  2276. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2277. $receiptList [$key] ['verifyList'] = $verifyList;
  2278. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2279. 'where' => 'sid=' . $value ['staff'],
  2280. 'asArray' => true
  2281. ) );
  2282. $receiptList [$key] ['button'] = $button;
  2283. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2284. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2285. $relust = $value ['sum'] - $value ['loanSum'];
  2286. $receiptList [$key] ['relust'] = $relust;
  2287. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2288. }
  2289. Doo::loadModel ( 'enclosur' );
  2290. $enclosur = new enclosur ();
  2291. $enclosurList = $enclosur->find ( array (
  2292. 'where' => 'rid=' . $rid,
  2293. 'asArray' => true
  2294. ) );
  2295. $enclosurHtml = '';
  2296. foreach ( $enclosurList as $value ) {
  2297. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2298. }
  2299. $data ['enclosurHtml'] = $enclosurHtml;
  2300. // print_r($receiptList);
  2301. $data ['receiptList'] = $receiptList;
  2302. $data ['memu'] = "receipt";
  2303. $data ['staff'] = $this->staff;
  2304. $data ['receiptMemu'] = 'expenses';
  2305. $data ['verifyId'] = $this->verifyId;
  2306. $data ['executeId'] = $this->executeId;
  2307. $this->render ( "/admin/expensesCollect", $data );
  2308. }
  2309. function approvalExpenses() {
  2310. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  2311. $year = $rdate = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2312. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2313. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2314. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2315. // $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) :"";
  2316. // echo $rdate;
  2317. if (empty ( $status ))
  2318. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  2319. $page_size = 12;
  2320. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2321. $vidList = array ();
  2322. $button = 0;
  2323. Doo::loadModel ( 'verify' );
  2324. $verify = new verify ();
  2325. Doo::loadModel ( 'receipt' );
  2326. $receipt = new receipt ();
  2327. Doo::loadModel ( 'staff' );
  2328. $staff = new staff ();
  2329. Doo::loadModel ( 'L_category' );
  2330. $Lcategory = new L_category ();
  2331. // user verify ID
  2332. $verifyDetail = $verify->find ( array (
  2333. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  2334. 'asArray' => true
  2335. ) );
  2336. foreach ( $verifyDetail as $key => $value ) {
  2337. array_push ( $vidList, $value ['vid'] );
  2338. }
  2339. $vid = implode ( ",", $vidList );
  2340. if (empty ( $verifyDetail ))
  2341. $vid = 0;
  2342. // if ($status==0)
  2343. // $dateCondition="";
  2344. // else
  2345. $dateCondition = " ";
  2346. // if (! empty ( $month ))
  2347. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  2348. if ($status == 'done' || $status == 'termination') {
  2349. if (! empty ( $year )) {
  2350. $dateCondition = " and Year(pastDate) =" . $year;
  2351. if (! empty ( $month ))
  2352. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  2353. }
  2354. } elseif ($status == 'finish') {
  2355. if (! empty ( $year )) {
  2356. $dateCondition = " and Year(pastDate) =" . $year;
  2357. if (! empty ( $month ))
  2358. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  2359. }
  2360. }
  2361. // date ( 'Y-m' )
  2362. // if (! empty ( $rdate ) && $status == 'done')
  2363. // $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  2364. // elseif (! empty ( $rdate ))
  2365. // $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  2366. $categoryList = $Lcategory->find ( array (
  2367. 'asArray' => true
  2368. ) );
  2369. $staffList = $staff->find ( array (
  2370. 'where' => 'cid=' . $cid,
  2371. 'asArray' => true
  2372. ) );
  2373. $cateCondition = "";
  2374. $staffCondition = "";
  2375. $approvalCondition = "";
  2376. if (! empty ( $cid )) {
  2377. $cateCondition = ' and cid=' . $cid;
  2378. }
  2379. if (! empty ( $sid )) {
  2380. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  2381. $cateCondition = "";
  2382. }
  2383. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  2384. if ($status == 'pendApproval') {
  2385. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  2386. }
  2387. if ($status == 'ongoing') {
  2388. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  2389. }
  2390. if ($status == 'done') {
  2391. $approvalCondition = ' and (status=8 or status=9 ) ';
  2392. }
  2393. if ($status == 'termination') {
  2394. $approvalCondition = " and status=3";
  2395. }
  2396. if ($status == 'finish') {
  2397. $approvalCondition = " and (status=1 or status=8 or status=9)";
  2398. }
  2399. $pageinfo ['page'] = array (
  2400. 'previous' => ''
  2401. );
  2402. if ($status == 'done' || $status == 'termination' || $status == 'finish') { // $dateCondition .
  2403. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  2404. $receiptList = $receipt->find ( array ( // $dateCondition.
  2405. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  2406. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2407. 'desc' => 'rid',
  2408. 'asArray' => true
  2409. ) );
  2410. } else {
  2411. $receiptList = $receipt->find ( array ( // $dateCondition
  2412. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  2413. 'desc' => 'rid',
  2414. 'asArray' => true
  2415. ) );
  2416. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  2417. }
  2418. $rLRes = $receipt->find ( array (
  2419. 'where' => 'status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )' . $cateCondition . $staffCondition . ' and verify in (' . $vid . ')',
  2420. 'desc' => 'rid',
  2421. 'asArray' => true
  2422. ) );
  2423. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  2424. // print_r($receiptList);
  2425. $Locate = 0;
  2426. $reportList = $reportCateList = array ();
  2427. foreach ( $receiptList as $key => $value ) {
  2428. $receiptList [$key] ['Locate'] = $Locate;
  2429. $Locate ++;
  2430. $receiptList [$key] ['reviseDetail'] = array ();
  2431. if (! empty ( $value ['reviseDetail'] ))
  2432. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2433. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2434. $categoryDetil = $Lcategory->getOne ( array (
  2435. 'where' => 'cid=' . $value ['cid'],
  2436. 'asArray' => true
  2437. ) );
  2438. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2439. $verifyList = $verify->getOne ( array (
  2440. 'where' => 'vid=' . $value ['verify'],
  2441. 'asArray' => true
  2442. ) );
  2443. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2444. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2445. foreach ( $verifyList as $k => $v ) {
  2446. // init verifyStaff
  2447. $verifyList [$k] ['date'] = "";
  2448. $verifyList [$k] ['opinion'] = "";
  2449. $verifyList [$k] ['status'] = "";
  2450. if (empty ( $verifyStaff )) {
  2451. $verifyList [$k] ['date'] = "";
  2452. $verifyList [$k] ['opinion'] = "";
  2453. if ($v [0] == $this->staff [0] ['sid']) {
  2454. $verifyList [$k] ['status'] = 4;
  2455. $button = 4;
  2456. }
  2457. } else {
  2458. $flag = true;
  2459. foreach ( $verifyStaff as $m => $u ) {
  2460. if ($v [0] == $m) {
  2461. $verifyList [$k] ['date'] = $u ['date'];
  2462. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2463. $verifyList [$k] ['status'] = $u ['status'];
  2464. $flag = false;
  2465. break;
  2466. }
  2467. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  2468. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  2469. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  2470. }
  2471. if ($flag) { // 检测可编辑
  2472. if ($v [0] == $this->staff [0] ['sid']) {
  2473. $verifyList [$k] ['status'] = 4;
  2474. $button = 4;
  2475. }
  2476. }
  2477. }
  2478. }
  2479. $receiptList [$key] ['verifyList'] = $verifyList;
  2480. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2481. 'where' => 'sid=' . $value ['staff'],
  2482. 'asArray' => true
  2483. ) );
  2484. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  2485. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  2486. $receiptList [$key] ['button'] = $button;
  2487. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  2488. }
  2489. $reportList = array_unique ( $reportList );
  2490. $reportHtml = '';
  2491. foreach ( $reportList as $key => $value ) {
  2492. $v = explode ( "-", $value );
  2493. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  2494. }
  2495. // print_r($reportList)
  2496. $data ['reportHtml'] = $reportHtml;
  2497. $reportCateList = array_unique ( $reportCateList );
  2498. $reportCateHtml = '';
  2499. foreach ( $reportCateList as $key => $value ) {
  2500. $v = explode ( "-", $value );
  2501. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  2502. }
  2503. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  2504. $data ['reportCateHtml'] = $reportCateHtml;
  2505. // print_r($receiptList);die;
  2506. // $data['verifyDetail']=$verifyDetail;
  2507. $mothHtml = "";
  2508. for($i = 1; $i <= 12; $i ++) {
  2509. if ($month == $i)
  2510. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2511. else
  2512. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2513. }
  2514. $data ['mothHtml'] = $mothHtml;
  2515. $data ['page'] = $pageinfo;
  2516. $data ['receiptList'] = $receiptList;
  2517. $data ['receiptApprovalCount'] = count ( $rLRes );
  2518. $data ['status'] = $status;
  2519. $data ['year'] = $year;
  2520. $data ['categoryList'] = $categoryList;
  2521. $data ['staffList'] = $staffList;
  2522. $data ['cid'] = $cid;
  2523. $data ['sid'] = $sid;
  2524. // print_r($receiptList);
  2525. $data ['memu'] = "receipt";
  2526. $data ['staff'] = $this->staff;
  2527. $data ['receiptMemu'] = 'approvalExpenses';
  2528. $data ['verifyId'] = $this->verifyId;
  2529. $data ['executeId'] = $this->executeId;
  2530. $this->render ( "/admin/approvalExpenses", $data );
  2531. }
  2532. function expensesDoc() {
  2533. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2534. Doo::loadClass ( 'XDeode' );
  2535. $XDeode = new XDeode ( 5 );
  2536. if (! empty ( $rid ) && ! is_numeric ( $rid ))
  2537. $rid = $XDeode->decode ( $rid );
  2538. if (! is_numeric ( $rid ))
  2539. die ( 'illegal request' );
  2540. Doo::loadModel ( 'receipt' );
  2541. $receipt = new receipt ();
  2542. Doo::loadModel ( 'L_category' );
  2543. $Lcategory = new L_category ();
  2544. Doo::loadModel ( 'verify' );
  2545. Doo::loadModel ( 'statistics' );
  2546. $statistics = new statistics ();
  2547. $verify = new verify ();
  2548. Doo::loadModel ( 'staff' );
  2549. $staff = new staff ();
  2550. Doo::loadModel ( 'loanReceipt' );
  2551. $loanReceipt = new loanReceipt ();
  2552. $receiptList = $receipt->find ( array (
  2553. 'where' => ' rid=' . $rid,
  2554. 'desc' => 'rid',
  2555. 'asArray' => true
  2556. ) );
  2557. $loanList = array ();
  2558. if (! empty ( $receiptList ))
  2559. $loanList = $loanReceipt->find ( array (
  2560. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2561. 'desc' => 'rid',
  2562. 'asArray' => true
  2563. ) );
  2564. $Locate = 0;
  2565. $roleId = 0;
  2566. $button = 0;
  2567. foreach ( $loanList as $key => $value ) {
  2568. $loanList [$key] ['Locate'] = $Locate;
  2569. $Locate ++;
  2570. $loanList [$key] ['reviseDetail'] = array ();
  2571. if (! empty ( $value ['reviseDetail'] ))
  2572. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2573. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2574. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2575. $categoryDetil = $Lcategory->getOne ( array (
  2576. 'where' => 'cid=' . $value ['cid'],
  2577. 'asArray' => true
  2578. ) );
  2579. $loanList [$key] ['category'] = $categoryDetil ['title'];
  2580. // 检测编辑状态
  2581. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  2582. $verifyList ['staff'] = $value ['verifyBreakup'];
  2583. else
  2584. $verifyList = $verify->getOne ( array (
  2585. 'where' => 'vid=' . $value ['verify'],
  2586. 'asArray' => true
  2587. ) );
  2588. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2589. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2590. Doo::loadModel ( 'role' );
  2591. $role = new role ();
  2592. $flag = true;
  2593. $roleKey = 0;
  2594. $endStaffArray = array ();
  2595. $roleArrayCopy = array ();
  2596. foreach ( $verifyList as $k => $v ) {
  2597. // init verifyStaff
  2598. if ($v [1] == 'ROLE') {
  2599. if (! empty ( $verifyStaff )) {
  2600. $endStaffArray = end ( $verifyStaff );
  2601. // if ($v[0]==$endStaffArray['nextStaff']){
  2602. // $roleId=$v[0];
  2603. // }
  2604. }
  2605. $roleVerify = json_decode ( $v [3], true );
  2606. $roleKey = $k;
  2607. $roleArray = array ();
  2608. $rolename = $role->getOne ( array (
  2609. 'where' => 'rid=' . $v [0],
  2610. 'asArray' => true
  2611. ) );
  2612. foreach ( $roleVerify as $o => $p ) {
  2613. $staffID = explode ( '_', $p );
  2614. $staffInfo = $staff->getOne ( array (
  2615. 'where' => 'sid=' . $staffID [0],
  2616. 'asArray' => true
  2617. ) );
  2618. // print_r($staffID);
  2619. $exp = array (
  2620. 0 => $staffInfo ['sid'],
  2621. 1 => $staffID [1],
  2622. 2 => $staffInfo ['avatar'],
  2623. 'date' => '',
  2624. 'date' => '',
  2625. 'opinion' => '',
  2626. 'status' => '',
  2627. 'rolename' => $rolename ['name']
  2628. );
  2629. array_push ( $roleArray, $exp );
  2630. }
  2631. $roleArrayCopy [$v [0]] = $roleArray;
  2632. // $verifyList[$k]['roleArray']=$roleArray;
  2633. }
  2634. $verifyList [$k] ['date'] = "";
  2635. $verifyList [$k] ['opinion'] = "";
  2636. $verifyList [$k] ['status'] = "";
  2637. if (empty ( $verifyStaff )) {
  2638. $verifyList [$k] ['date'] = "";
  2639. $verifyList [$k] ['opinion'] = "";
  2640. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2641. $verifyList [$k] ['status'] = 4;
  2642. $flag = false;
  2643. }
  2644. } else {
  2645. foreach ( $verifyStaff as $m => $u ) {
  2646. if ($v [0] == $m) {
  2647. $verifyList [$k] ['date'] = $u ['date'];
  2648. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2649. $verifyList [$k] ['status'] = $u ['status'];
  2650. $flag = false;
  2651. break;
  2652. }
  2653. }
  2654. $endStaffArray = end ( $verifyStaff );
  2655. if (isset ( $endStaffArray ['ROLE'] )) {
  2656. } else {
  2657. // $endKey=key($verifyStaff);
  2658. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2659. // $button=4;
  2660. // $verifyList[$k]['status']=4;
  2661. // }
  2662. }
  2663. }
  2664. }
  2665. $rolename ['name'] = '';
  2666. if (! empty ( $roleId )) {
  2667. Doo::loadModel ( 'role' );
  2668. $role = new role ();
  2669. $rolename = $role->getOne ( array (
  2670. 'where' => 'rid=' . $roleId,
  2671. 'asArray' => true
  2672. ) );
  2673. }
  2674. if (! empty ( $verifyStaff ))
  2675. $endStaffArray = end ( $verifyStaff );
  2676. $KOP = false;
  2677. foreach ( $roleArrayCopy as $P => $A ) {
  2678. foreach ( $A as $MKI => $AVL ) {
  2679. if (! empty ( $verifyStaff )) {
  2680. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2681. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2682. $button = 4;
  2683. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2684. }
  2685. foreach ( $verifyStaff as $m => $u ) {
  2686. $AVLFK = $AVL [0] . '_R';
  2687. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2688. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2689. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2690. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2691. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2692. break;
  2693. }
  2694. }
  2695. } else {
  2696. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2697. $button = 4;
  2698. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2699. }
  2700. }
  2701. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2702. $KOP = true;
  2703. }
  2704. }
  2705. foreach ( $roleArrayCopy as $k => $v ) {
  2706. foreach ( $verifyList as $m => $n ) {
  2707. if ($n [0] == $k) {
  2708. array_splice ( $verifyList, $m, 1, $v );
  2709. }
  2710. }
  2711. }
  2712. $loanList [$key] ['verifyList'] = $verifyList;
  2713. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  2714. 'where' => 'sid=' . $value ['staff'],
  2715. 'asArray' => true
  2716. ) );
  2717. $loanList [$key] ['button'] = $button;
  2718. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  2719. }
  2720. $data ['loanList'] = $loanList;
  2721. // print_r($loanList);
  2722. $Locate = 0;
  2723. $roleId = 0;
  2724. $button = 0;
  2725. foreach ( $receiptList as $key => $value ) {
  2726. $receiptList [$key] ['Locate'] = $Locate;
  2727. $Locate ++;
  2728. $receiptList [$key] ['reviseDetail'] = array ();
  2729. if (! empty ( $value ['reviseDetail'] ))
  2730. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2731. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2732. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2733. $categoryDetil = $Lcategory->getOne ( array (
  2734. 'where' => 'cid=' . $value ['cid'],
  2735. 'asArray' => true
  2736. ) );
  2737. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2738. // 检测编辑状态
  2739. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  2740. $verifyList ['staff'] = $value ['verifyBreakup'];
  2741. } else
  2742. $verifyList = $verify->getOne ( array (
  2743. 'where' => 'vid=' . $value ['verify'],
  2744. 'asArray' => true
  2745. ) );
  2746. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2747. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2748. Doo::loadModel ( 'role' );
  2749. $role = new role ();
  2750. if ($verifyList == NULL)
  2751. $verifyList = array ();
  2752. $flag = true;
  2753. $roleKey = 0;
  2754. $endStaffArray = array ();
  2755. $roleArrayCopy = array ();
  2756. foreach ( $verifyList as $k => $v ) {
  2757. // init verifyStaff
  2758. if ($v [1] == 'ROLE') {
  2759. if (! empty ( $verifyStaff )) {
  2760. $endStaffArray = end ( $verifyStaff );
  2761. // if ($v[0]==$endStaffArray['nextStaff']){
  2762. // $roleId=$v[0];
  2763. // }
  2764. }
  2765. $roleVerify = json_decode ( $v [3], true );
  2766. $roleKey = $k;
  2767. $roleArray = array ();
  2768. $rolename = $role->getOne ( array (
  2769. 'where' => 'rid=' . $v [0],
  2770. 'asArray' => true
  2771. ) );
  2772. foreach ( $roleVerify as $o => $p ) {
  2773. $staffID = explode ( '_', $p );
  2774. $staffInfo = $staff->getOne ( array (
  2775. 'where' => 'sid=' . $staffID [0],
  2776. 'asArray' => true
  2777. ) );
  2778. // print_r($staffID);
  2779. $exp = array (
  2780. 0 => $staffInfo ['sid'],
  2781. 1 => $staffID [1],
  2782. 2 => $staffInfo ['avatar'],
  2783. 'date' => '',
  2784. 'date' => '',
  2785. 'opinion' => '',
  2786. 'status' => '',
  2787. 'rolename' => $rolename ['name']
  2788. );
  2789. array_push ( $roleArray, $exp );
  2790. }
  2791. $roleArrayCopy [$v [0]] = $roleArray;
  2792. // $verifyList[$k]['roleArray']=$roleArray;
  2793. }
  2794. $verifyList [$k] ['date'] = "";
  2795. $verifyList [$k] ['opinion'] = "";
  2796. $verifyList [$k] ['status'] = "";
  2797. if (empty ( $verifyStaff )) {
  2798. $verifyList [$k] ['date'] = "";
  2799. $verifyList [$k] ['opinion'] = "";
  2800. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2801. $verifyList [$k] ['status'] = 4;
  2802. $flag = false;
  2803. }
  2804. } else {
  2805. foreach ( $verifyStaff as $m => $u ) {
  2806. if ($v [0] == $m) {
  2807. $verifyList [$k] ['date'] = $u ['date'];
  2808. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2809. $verifyList [$k] ['status'] = $u ['status'];
  2810. $flag = false;
  2811. break;
  2812. }
  2813. }
  2814. $endStaffArray = end ( $verifyStaff );
  2815. if (isset ( $endStaffArray ['ROLE'] )) {
  2816. } else {
  2817. // $endKey=key($verifyStaff);
  2818. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2819. // $button=4;
  2820. // $verifyList[$k]['status']=4;
  2821. // }
  2822. }
  2823. }
  2824. }
  2825. $rolename ['name'] = '';
  2826. if (! empty ( $roleId )) {
  2827. Doo::loadModel ( 'role' );
  2828. $role = new role ();
  2829. $rolename = $role->getOne ( array (
  2830. 'where' => 'rid=' . $roleId,
  2831. 'asArray' => true
  2832. ) );
  2833. }
  2834. if (! empty ( $verifyStaff ))
  2835. $endStaffArray = end ( $verifyStaff );
  2836. $KOP = false;
  2837. foreach ( $roleArrayCopy as $P => $A ) {
  2838. foreach ( $A as $MKI => $AVL ) {
  2839. if (! empty ( $verifyStaff )) {
  2840. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2841. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2842. $button = 4;
  2843. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2844. }
  2845. foreach ( $verifyStaff as $m => $u ) {
  2846. $AVLFK = $AVL [0] . '_R';
  2847. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2848. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2849. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2850. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2851. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2852. break;
  2853. }
  2854. }
  2855. } else {
  2856. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2857. $button = 4;
  2858. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2859. }
  2860. }
  2861. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2862. $KOP = true;
  2863. }
  2864. }
  2865. foreach ( $roleArrayCopy as $k => $v ) {
  2866. foreach ( $verifyList as $m => $n ) {
  2867. if ($n [0] == $k) {
  2868. array_splice ( $verifyList, $m, 1, $v );
  2869. }
  2870. }
  2871. }
  2872. // 费用执行人相关数据
  2873. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2874. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2875. foreach ( $executeCopy as $k => $v ) {
  2876. $executeCopy [$k] ['date'] = '';
  2877. $executeCopy [$k] ['opinion'] = '';
  2878. $executeCopy [$k] ['status'] = '';
  2879. if (! empty ( $executeStaff ))
  2880. foreach ( $executeStaff as $m => $u ) {
  2881. if ($v [0] == $m) {
  2882. $executeCopy [$k] ['date'] = $u ['date'];
  2883. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2884. $executeCopy [$k] ['status'] = $u ['status'];
  2885. break;
  2886. }
  2887. }
  2888. }
  2889. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2890. $receiptList [$key] ['verifyList'] = $verifyList;
  2891. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2892. 'where' => 'sid=' . $value ['staff'],
  2893. 'asArray' => true
  2894. ) );
  2895. $receiptList [$key] ['button'] = $button;
  2896. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2897. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2898. $relust = $value ['sum'] - $value ['loanSum'];
  2899. $receiptList [$key] ['relust'] = $relust;
  2900. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2901. }
  2902. // print_r($receiptList);
  2903. // 获取审批日志
  2904. Doo::loadModel ( 'receiptLog' );
  2905. $receiptLog = new receiptLog ();
  2906. $rlList = array ();
  2907. $rlInfo = $receiptLog->getOne ( array (
  2908. 'where' => 'rid=' . $rid . ' and status=4',
  2909. 'asArray' => true
  2910. ) );
  2911. $tijdate = $receiptLog->getOne ( array (
  2912. 'where' => 'rid=' . $rid . ' and status=2',
  2913. 'asc' => 'rlid',
  2914. 'asArray' => true
  2915. ) );
  2916. if (! empty ( $rlInfo )) {
  2917. $rlList = $receiptLog->find ( array (
  2918. 'where' => 'rid=' . $rid,
  2919. 'asc' => 'rlid',
  2920. 'asArray' => true
  2921. ) );
  2922. }
  2923. Doo::loadModel ( 'enclosur' );
  2924. $enclosur = new enclosur ();
  2925. $enclosurList = $enclosur->find ( array (
  2926. 'where' => 'rid=' . $rid,
  2927. 'asArray' => true
  2928. ) );
  2929. $enclosurHtml = '';
  2930. foreach ( $enclosurList as $value ) {
  2931. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2932. }
  2933. $data ['enclosurHtml'] = $enclosurHtml;
  2934. $receiptList [0] ['rlList'] = $rlList;
  2935. $data ['receiptList'] = $receiptList;
  2936. // print_r($receiptList);
  2937. $data ['memu'] = "receipt";
  2938. $data ['staff'] = $this->staff;
  2939. $data ['receiptMemu'] = 'approvalExpenses';
  2940. $data ['verifyId'] = $this->verifyId;
  2941. $data ['executeId'] = $this->executeId;
  2942. $this->render ( "/admin/expensesDoc", $data );
  2943. }
  2944. function expensesEdi() {
  2945. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2946. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  2947. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2948. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2949. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2950. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2951. if (empty ( $status ))
  2952. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  2953. $vidList = array ();
  2954. $button = 0;
  2955. Doo::loadModel ( 'verify' );
  2956. Doo::loadModel ( 'receipt' );
  2957. Doo::loadModel ( 'staff' );
  2958. $staff = new staff ();
  2959. $receipt = new receipt ();
  2960. $verify = new verify ();
  2961. Doo::loadModel ( 'L_category' );
  2962. $Lcategory = new L_category ();
  2963. Doo::loadModel ( 'enclosur' );
  2964. $enclosur = new enclosur ();
  2965. // user verify ID
  2966. $verifyDetail = $verify->find ( array (
  2967. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  2968. 'asArray' => true
  2969. ) );
  2970. foreach ( $verifyDetail as $key => $value ) {
  2971. array_push ( $vidList, $value ['vid'] );
  2972. }
  2973. $vid = implode ( ",", $vidList );
  2974. if (empty ( $verifyDetail ))
  2975. $vid = 0;
  2976. $categoryList = $Lcategory->find ( array (
  2977. 'asArray' => true
  2978. ) );
  2979. $staffList = $staff->find ( array (
  2980. 'where' => 'cid=' . $cid,
  2981. 'asArray' => true
  2982. ) );
  2983. $ap = "";
  2984. if ($status == 4) {
  2985. $ap = 4;
  2986. $status = 2;
  2987. }
  2988. // get Receipt By verifyID status 2
  2989. $receiptList = $receipt->find ( array (
  2990. 'where' => 'rid =' . $rid . ' and status=2',
  2991. 'desc' => 'rid',
  2992. 'asArray' => true
  2993. ) );
  2994. if (empty ( $receiptList )) {
  2995. die ( 'illegal request' );
  2996. }
  2997. $Locate = 0;
  2998. $roleId = 0;
  2999. if ($ap == 4)
  3000. $status = 4;
  3001. foreach ( $receiptList as $key => $value ) {
  3002. $receiptList [$key] ['Locate'] = $Locate;
  3003. $Locate ++;
  3004. $receiptList [$key] ['reviseDetail'] = array ();
  3005. if (! empty ( $value ['reviseDetail'] ))
  3006. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3007. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3008. $categoryDetil = $Lcategory->getOne ( array (
  3009. 'where' => 'cid=' . $value ['cid'],
  3010. 'asArray' => true
  3011. ) );
  3012. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3013. // 检测编辑状态
  3014. $verifyList = $verify->getOne ( array (
  3015. 'where' => 'vid=' . $value ['verify'],
  3016. 'asArray' => true
  3017. ) );
  3018. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3019. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3020. Doo::loadModel ( 'role' );
  3021. $role = new role ();
  3022. // print_r($verifyList);
  3023. $flag = true;
  3024. $roleKey = 0;
  3025. $endStaffArray = array ();
  3026. $roleArrayCopy = array ();
  3027. foreach ( $verifyList as $k => $v ) {
  3028. // init verifyStaff
  3029. if ($v [1] == 'ROLE') {
  3030. if (! empty ( $verifyStaff )) {
  3031. $endStaffArray = end ( $verifyStaff );
  3032. if ($v [0] == $endStaffArray ['nextStaff']) {
  3033. $roleId = $v [0];
  3034. }
  3035. }
  3036. $roleVerify = json_decode ( $v [3], true );
  3037. $roleKey = $k;
  3038. $roleArray = array ();
  3039. $rolename = $role->getOne ( array (
  3040. 'where' => 'rid=' . $v [0],
  3041. 'asArray' => true
  3042. ) );
  3043. foreach ( $roleVerify as $o => $p ) {
  3044. $staffID = explode ( '_', $p );
  3045. $staffInfo = $staff->getOne ( array (
  3046. 'where' => 'sid=' . $staffID [0],
  3047. 'asArray' => true
  3048. ) );
  3049. // print_r($staffID);
  3050. $exp = array (
  3051. 0 => $staffInfo ['sid'],
  3052. 1 => $staffID [1],
  3053. 2 => $staffInfo ['avatar'],
  3054. 'date' => '',
  3055. 'date' => '',
  3056. 'opinion' => '',
  3057. 'status' => '',
  3058. 'rolename' => $rolename ['name']
  3059. );
  3060. array_push ( $roleArray, $exp );
  3061. }
  3062. $roleArrayCopy [$v [0]] = $roleArray;
  3063. // $verifyList[$k]['roleArray']=$roleArray;
  3064. }
  3065. // print_r($roleArray);
  3066. $verifyList [$k] ['date'] = "";
  3067. $verifyList [$k] ['opinion'] = "";
  3068. $verifyList [$k] ['status'] = "";
  3069. if (empty ( $verifyStaff )) {
  3070. $verifyList [$k] ['date'] = "";
  3071. $verifyList [$k] ['opinion'] = "";
  3072. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3073. $verifyList [$k] ['status'] = 4;
  3074. $button = 4;
  3075. $flag = false;
  3076. }
  3077. } else {
  3078. foreach ( $verifyStaff as $m => $u ) {
  3079. if ($v [0] == $m) {
  3080. $verifyList [$k] ['date'] = $u ['date'];
  3081. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3082. $verifyList [$k] ['status'] = $u ['status'];
  3083. $flag = false;
  3084. break;
  3085. }
  3086. }
  3087. $endStaffArray = end ( $verifyStaff );
  3088. if (isset ( $endStaffArray ['ROLE'] )) {
  3089. } else {
  3090. $endKey = key ( $verifyStaff );
  3091. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  3092. $button = 4;
  3093. $verifyList [$k] ['status'] = 4;
  3094. }
  3095. }
  3096. }
  3097. }
  3098. $rolename ['name'] = '';
  3099. if (! empty ( $roleId )) {
  3100. Doo::loadModel ( 'role' );
  3101. $role = new role ();
  3102. $rolename = $role->getOne ( array (
  3103. 'where' => 'rid=' . $roleId,
  3104. 'asArray' => true
  3105. ) );
  3106. }
  3107. if (! empty ( $verifyStaff ))
  3108. $endStaffArray = end ( $verifyStaff );
  3109. $KOP = false;
  3110. foreach ( $roleArrayCopy as $P => $A ) {
  3111. foreach ( $A as $MKI => $AVL ) {
  3112. if (! empty ( $verifyStaff )) {
  3113. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3114. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3115. $button = 4;
  3116. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3117. }
  3118. foreach ( $verifyStaff as $m => $u ) {
  3119. $AVLFK = $AVL [0] . '_R';
  3120. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3121. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3122. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3123. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3124. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3125. break;
  3126. }
  3127. }
  3128. } else {
  3129. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3130. $button = 4;
  3131. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3132. }
  3133. }
  3134. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3135. $KOP = true;
  3136. }
  3137. }
  3138. // print_r($roleArrayCopy);
  3139. // echo $roleKey;
  3140. foreach ( $roleArrayCopy as $k => $v ) {
  3141. foreach ( $verifyList as $m => $n ) {
  3142. if ($n [0] == $k) {
  3143. array_splice ( $verifyList, $m, 1, $v );
  3144. }
  3145. }
  3146. }
  3147. $receiptList [$key] ['verifyList'] = $verifyList;
  3148. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3149. 'where' => 'sid=' . $value ['staff'],
  3150. 'asArray' => true
  3151. ) );
  3152. $receiptList [$key] ['button'] = $button;
  3153. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  3154. }
  3155. // $data['verifyDetail']=$verifyDetail;
  3156. $mothHtml = "";
  3157. for($i = 1; $i <= 12; $i ++) {
  3158. if ($month == $i)
  3159. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3160. else
  3161. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3162. }
  3163. // 获取审批日志
  3164. Doo::loadModel ( 'receiptLog' );
  3165. $receiptLog = new receiptLog ();
  3166. $rlList = array ();
  3167. $rlInfo = $receiptLog->getOne ( array (
  3168. 'where' => 'rid=' . $rid . ' and status=4',
  3169. 'asArray' => true
  3170. ) );
  3171. $tijdate = $receiptLog->getOne ( array (
  3172. 'where' => 'rid=' . $rid . ' and status=2',
  3173. 'asc' => 'rlid',
  3174. 'asArray' => true
  3175. ) );
  3176. if (! empty ( $rlInfo )) {
  3177. $rlList = $receiptLog->find ( array (
  3178. 'where' => 'rid=' . $rid,
  3179. 'asc' => 'rlid',
  3180. 'asArray' => true
  3181. ) );
  3182. }
  3183. $receiptList [0] ['rlList'] = $rlList;
  3184. $enclosurList = $enclosur->find ( array (
  3185. 'where' => 'rid=' . $rid,
  3186. 'asArray' => true
  3187. ) );
  3188. $enclosurHtml = '';
  3189. foreach ( $enclosurList as $value ) {
  3190. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3191. }
  3192. // print_r($receiptList);
  3193. $data ['rid'] = $rid;
  3194. $data ['enclosurHtml'] = $enclosurHtml;
  3195. $data ['rolename'] = $rolename ['name'];
  3196. $data ['datetij'] = $tijdate ['date'];
  3197. $data ['mothHtml'] = $mothHtml;
  3198. $data ['receiptList'] = $receiptList;
  3199. $data ['receiptApprovalCount'] = count ( $receiptList );
  3200. $data ['status'] = $status;
  3201. $data ['year'] = $year;
  3202. $data ['categoryList'] = $categoryList;
  3203. $data ['staffList'] = $staffList;
  3204. $data ['cid'] = $cid;
  3205. $data ['sid'] = $sid;
  3206. $data ['ap'] = $ap;
  3207. $data ['memu'] = "receipt";
  3208. $data ['staff'] = $this->staff;
  3209. $data ['receiptMemu'] = 'approvalExpenses';
  3210. $data ['verifyId'] = $this->verifyId;
  3211. $data ['executeId'] = $this->executeId;
  3212. $this->render ( "/admin/expensesEdi", $data );
  3213. }
  3214. function expensesDefray() {
  3215. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3216. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3217. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3218. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  3219. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  3220. if (! empty ( $rid )) {
  3221. Doo::loadModel ( "verify" );
  3222. $verify = new verify ();
  3223. Doo::loadModel ( "receiptDetail" );
  3224. $receiptDetailObj = new receiptDetail ();
  3225. Doo::loadModel ( "itemStatistics" );
  3226. Doo::loadModel ( "statistics" );
  3227. $statistics = new statistics ();
  3228. $itemStatistics = new itemStatistics ();
  3229. Doo::loadModel ( "receipt" );
  3230. $receipt = new receipt ();
  3231. Doo::loadModel ( "loanReceipt" );
  3232. $loanReceipt = new loanReceipt ();
  3233. $receiptDetail = $receipt->getOne ( array (
  3234. 'where' => 'rid=' . $rid . ' and status=2 ',
  3235. 'asArray' => true
  3236. ) );
  3237. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  3238. $nsflag = true;
  3239. foreach ( $nslist as $value ) {
  3240. if ($value == $this->staff ['0'] ['sid']) {
  3241. $nsflag = false;
  3242. break;
  3243. }
  3244. }
  3245. // print_r($nslist);die;
  3246. if (empty ( $receiptDetail ) || $nsflag)
  3247. return "/approvalExpenses/pendApproval";
  3248. $verifyDetail = $verify->getOne ( array (
  3249. 'where' => ' vid =' . $receiptDetail ['verify'],
  3250. 'asArray' => true
  3251. ) );
  3252. $verifyString = $verifyDetail ['staff'];
  3253. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3254. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  3255. if (empty ( $opinion )) {
  3256. if ($status == 3)
  3257. $opinion = "终止";
  3258. else
  3259. $opinion = "同意支付";
  3260. }
  3261. $nowStaff = 0;
  3262. $nowStaffList = array ();
  3263. if (empty ( $verifyStaff )) {
  3264. // 还需加入是否已经进入角色审批
  3265. if ($verifyDetail [0] [1] == 'ROLE') {
  3266. // print_r($verifyDetail);echo "ddd";
  3267. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3268. foreach ( $vStaffString as $key => $value ) {
  3269. $staffK = explode ( "_", $value );
  3270. if ($staffK [0] != $this->staff [0] ['sid'])
  3271. array_push ( $nowStaffList, $staffK [0] );
  3272. }
  3273. // print_r($verifyDetail);
  3274. // die;
  3275. if (! empty ( $nowStaffList )) {
  3276. $nowStaff = implode ( ',', $nowStaffList );
  3277. $verifyStaff = array (
  3278. $this->staff [0] ['sid'] . "_R" => array (
  3279. 'date' => date ( 'Y-m-d' ),
  3280. 'opinion' => $opinion,
  3281. 'status' => $status,
  3282. 'nextStaff' => $verifyDetail [0] [0],
  3283. 'ROLE' => 1
  3284. )
  3285. );
  3286. } else {
  3287. $nowStaff = $verifyDetail [1] [0];
  3288. $verifyStaff = array (
  3289. $this->staff [0] ['sid'] . "_R" => array (
  3290. 'date' => date ( 'Y-m-d' ),
  3291. 'opinion' => $opinion,
  3292. 'status' => $status,
  3293. 'nextStaff' => $verifyDetail [1] [0]
  3294. )
  3295. );
  3296. }
  3297. } else {
  3298. if ($verifyDetail [1] [1] == 'ROLE') {
  3299. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  3300. // echo "dd";
  3301. foreach ( $vStaffString as $key => $value ) {
  3302. $staffK = explode ( "_", $value );
  3303. array_push ( $nowStaffList, $staffK [0] );
  3304. }
  3305. $nowStaff = implode ( ',', $nowStaffList );
  3306. $verifyStaff = array (
  3307. $this->staff [0] ['sid'] => array (
  3308. 'date' => date ( 'Y-m-d' ),
  3309. 'opinion' => $opinion,
  3310. 'status' => $status,
  3311. 'nextStaff' => $verifyDetail [1] [0],
  3312. 'ROLE' => 1
  3313. )
  3314. );
  3315. } else {
  3316. $nowStaff = $verifyDetail [1] [0];
  3317. $verifyStaff = array (
  3318. $this->staff [0] ['sid'] => array (
  3319. 'date' => date ( 'Y-m-d' ),
  3320. 'opinion' => $opinion,
  3321. 'status' => $status,
  3322. 'nextStaff' => $verifyDetail [1] [0]
  3323. )
  3324. );
  3325. }
  3326. }
  3327. if ($status == 3)
  3328. $verifyStaff = array (
  3329. 'final' => $status,
  3330. $this->staff [0] ['sid'] => array (
  3331. 'date' => date ( 'Y-m-d' ),
  3332. 'opinion' => $opinion,
  3333. 'status' => $status
  3334. )
  3335. );
  3336. $vStaffString = json_encode ( $verifyStaff );
  3337. $receipt->nowStaff = $nowStaff;
  3338. $receipt->verifyStaff = $vStaffString;
  3339. $loanReceipt->nowStaff = $nowStaff;
  3340. $loanReceipt->verifyStaff = $vStaffString;
  3341. } else {
  3342. $VS = end ( $verifyStaff );
  3343. // 非角色审批
  3344. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  3345. $nextStaff = 0;
  3346. $roleSTF = false;
  3347. foreach ( $verifyDetail as $key => $value ) {
  3348. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  3349. if (isset ( $verifyDetail [$key + 1] )) {
  3350. $nextStaff = $verifyDetail [$key + 1] [0];
  3351. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  3352. $roleSTF = true;
  3353. }
  3354. break;
  3355. }
  3356. }
  3357. if (! $roleSTF) {
  3358. $nowStaff = $nextStaff;
  3359. $verifyStaff [$this->staff [0] ['sid']] = array (
  3360. 'date' => date ( 'Y-m-d' ),
  3361. 'opinion' => $opinion,
  3362. 'status' => $status,
  3363. 'nextStaff' => $nextStaff
  3364. );
  3365. } else {
  3366. // 获取角色下的所有用户ID
  3367. $nowStaffList = array ();
  3368. foreach ( $verifyDetail as $vfk ) {
  3369. if ($vfk [1] == 'ROLE') {
  3370. $vStaffString = json_decode ( $vfk [3] );
  3371. foreach ( $vStaffString as $key => $value ) {
  3372. $staffK = explode ( "_", $value );
  3373. array_push ( $nowStaffList, $staffK [0] );
  3374. }
  3375. }
  3376. }
  3377. $nowStaff = implode ( ',', $nowStaffList );
  3378. $verifyStaff [$this->staff [0] ['sid']] = array (
  3379. 'date' => date ( 'Y-m-d' ),
  3380. 'opinion' => $opinion,
  3381. 'status' => $status,
  3382. 'nextStaff' => $nextStaff,
  3383. 'ROLE' => 0
  3384. );
  3385. }
  3386. if ($status == 3) {
  3387. $verifyStaff ['final'] = $status;
  3388. $verifyStaff [$this->staff [0] ['sid']] = array (
  3389. 'date' => date ( 'Y-m-d' ),
  3390. 'opinion' => $opinion,
  3391. 'status' => $status
  3392. );
  3393. }
  3394. $vStaffString = json_encode ( $verifyStaff );
  3395. $receipt->nowStaff = $nowStaff;
  3396. $receipt->verifyStaff = $vStaffString;
  3397. $loanReceipt->nowStaff = $nowStaff;
  3398. $loanReceipt->verifyStaff = $vStaffString;
  3399. }
  3400. // 角色审批
  3401. if (isset ( $VS ['ROLE'] )) {
  3402. // 找出角色人 当前审批角色组
  3403. $verifyJSStaff = array ();
  3404. $nowStaffList2 = array ();
  3405. foreach ( $verifyDetail as $key => $value ) {
  3406. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  3407. $verifyJSStaff = json_decode ( $value [3] );
  3408. foreach ( $verifyJSStaff as $m ) {
  3409. $staffK = explode ( "_", $m );
  3410. array_push ( $nowStaffList2, $staffK [0] );
  3411. }
  3412. // print_r($nowStaffList2);
  3413. }
  3414. }
  3415. $RoleVerifyStaff = array ();
  3416. foreach ( $verifyStaff as $key => $value ) {
  3417. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  3418. foreach ( $nowStaffList2 as $m ) {
  3419. if ($key == $m . "_R")
  3420. $RoleVerifyStaff [$key] = $value;
  3421. }
  3422. }
  3423. }
  3424. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  3425. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  3426. // 下一个审批人ID
  3427. $nextStaff = 0;
  3428. $falg = false;
  3429. foreach ( $verifyDetail as $key => $value ) {
  3430. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  3431. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  3432. $falg = true;
  3433. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  3434. $nowStaffList = array ();
  3435. foreach ( $vStaffString as $v ) {
  3436. $staffK = explode ( "_", $v );
  3437. array_push ( $nowStaffList, $staffK [0] );
  3438. }
  3439. $nowStaff = implode ( ',', $nowStaffList );
  3440. $nextStaff = $verifyDetail [$key + 1] [0];
  3441. } elseif (isset ( $verifyDetail [$key + 1] )) {
  3442. $nextStaff = $verifyDetail [$key + 1] [0];
  3443. $nowStaff = $nextStaff;
  3444. } else
  3445. $nowStaff = '';
  3446. break;
  3447. }
  3448. }
  3449. if ($falg)
  3450. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3451. 'date' => date ( 'Y-m-d' ),
  3452. 'opinion' => $opinion,
  3453. 'status' => $status,
  3454. 'nextStaff' => $nextStaff,
  3455. 'ROLE' => 1
  3456. );
  3457. else
  3458. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3459. 'date' => date ( 'Y-m-d' ),
  3460. 'opinion' => $opinion,
  3461. 'status' => $status,
  3462. 'nextStaff' => $nextStaff
  3463. );
  3464. // print_r($verifyStaff);
  3465. // echo $nowStaff;die;
  3466. } else { // 进入下一个角色或者审批人
  3467. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  3468. //
  3469. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  3470. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3471. 'date' => date ( 'Y-m-d' ),
  3472. 'opinion' => $opinion,
  3473. 'status' => $status,
  3474. 'nextStaff' => $VS ['nextStaff'],
  3475. 'ROLE' => 1
  3476. );
  3477. // print_r($verifyStaff);
  3478. // die;
  3479. }
  3480. if ($status == 3) {
  3481. $verifyStaff ['final'] = $status;
  3482. $verifyStaff [$this->staff [0] ['sid']] = array (
  3483. 'date' => date ( 'Y-m-d' ),
  3484. 'opinion' => $opinion,
  3485. 'status' => $status
  3486. );
  3487. }
  3488. $vStaffString = json_encode ( $verifyStaff );
  3489. $receipt->verifyStaff = $vStaffString;
  3490. $receipt->nowStaff = $nowStaff;
  3491. $loanReceipt->nowStaff = $nowStaff;
  3492. $loanReceipt->verifyStaff = $vStaffString;
  3493. // die;
  3494. // }
  3495. // print_r($verifyStaff);
  3496. // die;
  3497. }
  3498. // print_r($verifyStaff);die;
  3499. }
  3500. // print_r($verifyDetail);
  3501. $roleKey = 0;
  3502. $roleId = 0;
  3503. $verifyDetailCopy = array ();
  3504. foreach ( $verifyDetail as $k => $v ) {
  3505. if ($v [1] == 'ROLE') {
  3506. $roleId = $v [0];
  3507. $roleVerify = json_decode ( $v [3], true );
  3508. $roleKey = $k;
  3509. $roleArray = array ();
  3510. foreach ( $roleVerify as $o => $p ) {
  3511. $staffID = explode ( '_', $p );
  3512. $exp = array (
  3513. 0 => $staffID [0],
  3514. 1 => $staffID [1]
  3515. );
  3516. array_push ( $roleArray, $exp );
  3517. }
  3518. $verifyDetailCopy [$v [0]] = $roleArray;
  3519. }
  3520. }
  3521. // print_r($verifyDetail);
  3522. foreach ( $verifyDetailCopy as $k => $v ) {
  3523. foreach ( $verifyDetail as $m => $n ) {
  3524. if ($n [0] == $k) {
  3525. array_splice ( $verifyDetail, $m, 1, $v );
  3526. }
  3527. }
  3528. }
  3529. // 审批日志
  3530. if (! isset ( $verifyStaff ['final'] )) {
  3531. Doo::loadModel ( "receiptLog" );
  3532. $receiptLog = new receiptLog ();
  3533. if (! empty ( $roleId )) {
  3534. Doo::loadModel ( "role" );
  3535. $role = new role ();
  3536. $roleInfo = $role->getOne ( array (
  3537. 'where' => 'rid=' . $roleId,
  3538. 'asArray' => true
  3539. ) );
  3540. $receiptLog->rolename = $roleInfo ['name'];
  3541. }
  3542. $receiptLog->username = $this->staff [0] ['username'];
  3543. $receiptLog->uid = $this->staff [0] ['sid'];
  3544. $receiptLog->date = date ( "Y-m-d" );
  3545. $receiptLog->opinion = $opinion;
  3546. $receiptLog->img = $this->staff [0] ['avatar'];
  3547. $receiptLog->status = 1;
  3548. $receiptLog->rid = $rid;
  3549. $receiptLog->insert ();
  3550. }
  3551. if (isset ( $verifyStaff ['final'] )) { // rDetail
  3552. $receipt->status = 3;
  3553. $receipt->verifyBreakup = $verifyString;
  3554. $receiptDetailObj->status = 3;
  3555. $receiptDetailObj->update ( array (
  3556. 'where' => 'rid=' . $rid
  3557. ) );
  3558. // 微信企业号通知
  3559. $this->setWXMsg ( $rid, 3 );
  3560. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  3561. $receipt->status = 6;
  3562. $receipt->pastDate = date ( "Y-m-d" );
  3563. $receipt->isBK = 1;
  3564. $loanReceipt->verifyBreakup = $verifyString;
  3565. $loanReceipt->status = 1;
  3566. $loanReceipt->pastDate = date ( "Y-m-d" );
  3567. $loanReceipt->amount = $receiptDetail ['amount'];
  3568. $loanReceipt->update ( array (
  3569. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  3570. ) );
  3571. // 微信企业号通知
  3572. $this->setWXMsg ( $rid, 1 );
  3573. }
  3574. $receipt->amount = $amount;
  3575. $receipt->update ( array (
  3576. 'where' => ' rid = ' . $rid
  3577. ) );
  3578. // 进入下一条审批费用新加需求
  3579. $vidList = array ();
  3580. $verifyDetail = $verify->find ( array (
  3581. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  3582. 'asArray' => true
  3583. ) );
  3584. foreach ( $verifyDetail as $key => $value ) {
  3585. array_push ( $vidList, $value ['vid'] );
  3586. }
  3587. $vid = implode ( ",", $vidList );
  3588. if (empty ( $verifyDetail ))
  3589. $vid = 0;
  3590. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  3591. $receipt = new receipt ();
  3592. $rd = $receipt->getOne ( array (
  3593. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  3594. 'asc' => 'rid',
  3595. 'asArray' => true
  3596. ) );
  3597. if (empty ( $rd )) {
  3598. return '/approvalExpenses/pendApproval';
  3599. }
  3600. if ($rd ['Rtype'] == 1) {
  3601. if ($rd ['isBK'] == 1) {
  3602. return '/receiptburEdi/' . $rd ['rid'];
  3603. } else {
  3604. return '/expensesEdi/' . $rd ['rid'];
  3605. }
  3606. } elseif ($rd ['Rtype'] == 2) {
  3607. return '/remitApproval/' . $rd ['rid'];
  3608. } else {
  3609. return '/receiptburEdi/' . $rd ['rid'];
  3610. }
  3611. // return "/approvalExpenses/pendApproval";
  3612. }
  3613. }
  3614. function ajaxExamineExe() {
  3615. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3616. Doo::loadModel ( 'receipt' );
  3617. $receipt = new receipt ();
  3618. Doo::loadClass ( 'XDeode' );
  3619. $XDeode = new XDeode ( 5 );
  3620. if (! empty ( $rid )) {
  3621. $rLRes = $receipt->find ( array (
  3622. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  3623. 'asArray' => true
  3624. ) );
  3625. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  3626. echo json_encode ( array (
  3627. 'status' => 1,
  3628. 'receipt' => $rLRes [0]
  3629. ) );
  3630. die ();
  3631. }
  3632. echo json_encode ( array (
  3633. 'status' => 0,
  3634. 'receipt' => array ()
  3635. ) );
  3636. die ();
  3637. }
  3638. function implement() {
  3639. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3640. Doo::loadClass ( 'XDeode' );
  3641. $XDeode = new XDeode ( 5 );
  3642. Doo::loadModel ( 'receipt' );
  3643. $receipt = new receipt ();
  3644. Doo::loadModel ( 'L_category' );
  3645. $Lcategory = new L_category ();
  3646. Doo::loadModel ( 'verify' );
  3647. $verify = new verify ();
  3648. Doo::loadModel ( 'staff' );
  3649. $staff = new staff ();
  3650. Doo::loadModel ( "execute" );
  3651. $execute = new execute ();
  3652. $rid = $XDeode->decode ( $rid );
  3653. $receiptList = $receipt->find ( array (
  3654. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  3655. 'desc' => 'rid',
  3656. 'asArray' => true
  3657. ) );
  3658. Doo::loadModel ( 'loanReceipt' );
  3659. $loanReceipt = new loanReceipt ();
  3660. // print_r($receiptList);
  3661. $loanList = array ();
  3662. if (! isset ( $receiptList ))
  3663. $loanList = $loanReceipt->find ( array (
  3664. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3665. 'desc' => 'rid',
  3666. 'asArray' => true
  3667. ) );
  3668. $Locate = 0;
  3669. $roleId = 0;
  3670. $button = 0;
  3671. foreach ( $loanList as $key => $value ) {
  3672. $loanList [$key] ['Locate'] = $Locate;
  3673. $Locate ++;
  3674. $loanList [$key] ['reviseDetail'] = array ();
  3675. if (! empty ( $value ['reviseDetail'] ))
  3676. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3677. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3678. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3679. $categoryDetil = $Lcategory->getOne ( array (
  3680. 'where' => 'cid=' . $value ['cid'],
  3681. 'asArray' => true
  3682. ) );
  3683. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3684. // 检测编辑状态
  3685. $verifyList = $verify->getOne ( array (
  3686. 'where' => 'vid=' . $value ['verify'],
  3687. 'asArray' => true
  3688. ) );
  3689. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3690. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3691. Doo::loadModel ( 'role' );
  3692. $role = new role ();
  3693. $flag = true;
  3694. $roleKey = 0;
  3695. $endStaffArray = array ();
  3696. $roleArrayCopy = array ();
  3697. foreach ( $verifyList as $k => $v ) {
  3698. // init verifyStaff
  3699. if ($v [1] == 'ROLE') {
  3700. if (! empty ( $verifyStaff )) {
  3701. $endStaffArray = end ( $verifyStaff );
  3702. // if ($v[0]==$endStaffArray['nextStaff']){
  3703. // $roleId=$v[0];
  3704. // }
  3705. }
  3706. $roleVerify = json_decode ( $v [3], true );
  3707. $roleKey = $k;
  3708. $roleArray = array ();
  3709. $rolename = $role->getOne ( array (
  3710. 'where' => 'rid=' . $v [0],
  3711. 'asArray' => true
  3712. ) );
  3713. foreach ( $roleVerify as $o => $p ) {
  3714. $staffID = explode ( '_', $p );
  3715. $staffInfo = $staff->getOne ( array (
  3716. 'where' => 'sid=' . $staffID [0],
  3717. 'asArray' => true
  3718. ) );
  3719. // print_r($staffID);
  3720. $exp = array (
  3721. 0 => $staffInfo ['sid'],
  3722. 1 => $staffID [1],
  3723. 2 => $staffInfo ['avatar'],
  3724. 'date' => '',
  3725. 'date' => '',
  3726. 'opinion' => '',
  3727. 'status' => '',
  3728. 'rolename' => $rolename ['name']
  3729. );
  3730. array_push ( $roleArray, $exp );
  3731. }
  3732. $roleArrayCopy [$v [0]] = $roleArray;
  3733. // $verifyList[$k]['roleArray']=$roleArray;
  3734. }
  3735. $verifyList [$k] ['date'] = "";
  3736. $verifyList [$k] ['opinion'] = "";
  3737. $verifyList [$k] ['status'] = "";
  3738. if (empty ( $verifyStaff )) {
  3739. $verifyList [$k] ['date'] = "";
  3740. $verifyList [$k] ['opinion'] = "";
  3741. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3742. $verifyList [$k] ['status'] = 4;
  3743. $flag = false;
  3744. }
  3745. } else {
  3746. foreach ( $verifyStaff as $m => $u ) {
  3747. if ($v [0] == $m) {
  3748. $verifyList [$k] ['date'] = $u ['date'];
  3749. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3750. $verifyList [$k] ['status'] = $u ['status'];
  3751. $flag = false;
  3752. break;
  3753. }
  3754. }
  3755. $endStaffArray = end ( $verifyStaff );
  3756. if (isset ( $endStaffArray ['ROLE'] )) {
  3757. } else {
  3758. // $endKey=key($verifyStaff);
  3759. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3760. // $button=4;
  3761. // $verifyList[$k]['status']=4;
  3762. // }
  3763. }
  3764. }
  3765. }
  3766. $rolename ['name'] = '';
  3767. if (! empty ( $roleId )) {
  3768. Doo::loadModel ( 'role' );
  3769. $role = new role ();
  3770. $rolename = $role->getOne ( array (
  3771. 'where' => 'rid=' . $roleId,
  3772. 'asArray' => true
  3773. ) );
  3774. }
  3775. if (! empty ( $verifyStaff ))
  3776. $endStaffArray = end ( $verifyStaff );
  3777. $KOP = false;
  3778. foreach ( $roleArrayCopy as $P => $A ) {
  3779. foreach ( $A as $MKI => $AVL ) {
  3780. if (! empty ( $verifyStaff )) {
  3781. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3782. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3783. $button = 4;
  3784. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3785. }
  3786. foreach ( $verifyStaff as $m => $u ) {
  3787. $AVLFK = $AVL [0] . '_R';
  3788. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3789. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3790. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3791. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3792. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3793. break;
  3794. }
  3795. }
  3796. } else {
  3797. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3798. $button = 4;
  3799. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3800. }
  3801. }
  3802. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3803. $KOP = true;
  3804. }
  3805. }
  3806. foreach ( $roleArrayCopy as $k => $v ) {
  3807. foreach ( $verifyList as $m => $n ) {
  3808. if ($n [0] == $k) {
  3809. array_splice ( $verifyList, $m, 1, $v );
  3810. }
  3811. }
  3812. }
  3813. $loanList [$key] ['verifyList'] = $verifyList;
  3814. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3815. 'where' => 'sid=' . $value ['staff'],
  3816. 'asArray' => true
  3817. ) );
  3818. }
  3819. $data ['loanList'] = $loanList;
  3820. $Locate = 0;
  3821. $roleId = 0;
  3822. $button = 0;
  3823. foreach ( $receiptList as $key => $value ) {
  3824. $button2 = 0;
  3825. $receiptList [$key] ['Locate'] = $Locate;
  3826. $Locate ++;
  3827. $receiptList [$key] ['reviseDetail'] = array ();
  3828. if (! empty ( $value ['reviseDetail'] ))
  3829. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3830. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3831. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3832. $categoryDetil = $Lcategory->getOne ( array (
  3833. 'where' => 'cid=' . $value ['cid'],
  3834. 'asArray' => true
  3835. ) );
  3836. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3837. $executeList = json_decode ( $value ['executeCopy'], true );
  3838. $executeStaff = array ();
  3839. if (! empty ( $value ['executeStaff'] ))
  3840. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3841. if (isset ( $executeList )) {
  3842. foreach ( $executeList as $op => $lo ) {
  3843. $executeList [$op] ['date'] = "";
  3844. $executeList [$op] ['opinion'] = "";
  3845. $executeList [$op] ['status'] = "";
  3846. foreach ( $executeStaff as $m => $u ) {
  3847. if ($lo [0] == $m) {
  3848. $executeList [$op] ['date'] = $u ['date'];
  3849. $executeList [$op] ['opinion'] = $u ['opinion'];
  3850. $executeList [$op] ['status'] = $u ['status'];
  3851. break;
  3852. }
  3853. }
  3854. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  3855. $button2 = 1;
  3856. $executeList [$op] ['status'] = 4;
  3857. }
  3858. }
  3859. }
  3860. // 检测编辑状态
  3861. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3862. $verifyList ['staff'] = $value ['verifyBreakup'];
  3863. } else
  3864. $verifyList = $verify->getOne ( array (
  3865. 'where' => 'vid=' . $value ['verify'],
  3866. 'asArray' => true
  3867. ) );
  3868. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3869. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3870. Doo::loadModel ( 'role' );
  3871. $role = new role ();
  3872. if ($verifyList == NULL)
  3873. $verifyList = array ();
  3874. $flag = true;
  3875. $roleKey = 0;
  3876. $endStaffArray = array ();
  3877. $roleArrayCopy = array ();
  3878. foreach ( $verifyList as $k => $v ) {
  3879. // init verifyStaff
  3880. if ($v [1] == 'ROLE') {
  3881. if (! empty ( $verifyStaff )) {
  3882. $endStaffArray = end ( $verifyStaff );
  3883. // if ($v[0]==$endStaffArray['nextStaff']){
  3884. // $roleId=$v[0];
  3885. // }
  3886. }
  3887. $roleVerify = json_decode ( $v [3], true );
  3888. $roleKey = $k;
  3889. $roleArray = array ();
  3890. $rolename = $role->getOne ( array (
  3891. 'where' => 'rid=' . $v [0],
  3892. 'asArray' => true
  3893. ) );
  3894. foreach ( $roleVerify as $o => $p ) {
  3895. $staffID = explode ( '_', $p );
  3896. $staffInfo = $staff->getOne ( array (
  3897. 'where' => 'sid=' . $staffID [0],
  3898. 'asArray' => true
  3899. ) );
  3900. // print_r($staffID);
  3901. $exp = array (
  3902. 0 => $staffInfo ['sid'],
  3903. 1 => $staffID [1],
  3904. 2 => $staffInfo ['avatar'],
  3905. 'date' => '',
  3906. 'date' => '',
  3907. 'opinion' => '',
  3908. 'status' => '',
  3909. 'rolename' => $rolename ['name']
  3910. );
  3911. array_push ( $roleArray, $exp );
  3912. }
  3913. $roleArrayCopy [$v [0]] = $roleArray;
  3914. // $verifyList[$k]['roleArray']=$roleArray;
  3915. }
  3916. $verifyList [$k] ['date'] = "";
  3917. $verifyList [$k] ['opinion'] = "";
  3918. $verifyList [$k] ['status'] = "";
  3919. if (empty ( $verifyStaff )) {
  3920. $verifyList [$k] ['date'] = "";
  3921. $verifyList [$k] ['opinion'] = "";
  3922. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3923. $verifyList [$k] ['status'] = 4;
  3924. $flag = false;
  3925. }
  3926. } else {
  3927. foreach ( $verifyStaff as $m => $u ) {
  3928. if ($v [0] == $m) {
  3929. $verifyList [$k] ['date'] = $u ['date'];
  3930. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3931. $verifyList [$k] ['status'] = $u ['status'];
  3932. $flag = false;
  3933. break;
  3934. }
  3935. }
  3936. $endStaffArray = end ( $verifyStaff );
  3937. if (isset ( $endStaffArray ['ROLE'] )) {
  3938. } else {
  3939. // $endKey=key($verifyStaff);
  3940. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3941. // $button=4;
  3942. // $verifyList[$k]['status']=4;
  3943. // }
  3944. }
  3945. }
  3946. }
  3947. $rolename ['name'] = '';
  3948. if (! empty ( $roleId )) {
  3949. Doo::loadModel ( 'role' );
  3950. $role = new role ();
  3951. $rolename = $role->getOne ( array (
  3952. 'where' => 'rid=' . $roleId,
  3953. 'asArray' => true
  3954. ) );
  3955. }
  3956. if (! empty ( $verifyStaff ))
  3957. $endStaffArray = end ( $verifyStaff );
  3958. $KOP = false;
  3959. foreach ( $roleArrayCopy as $P => $A ) {
  3960. foreach ( $A as $MKI => $AVL ) {
  3961. if (! empty ( $verifyStaff )) {
  3962. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3963. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3964. $button = 4;
  3965. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3966. }
  3967. foreach ( $verifyStaff as $m => $u ) {
  3968. $AVLFK = $AVL [0] . '_R';
  3969. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3970. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3971. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3972. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3973. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3974. break;
  3975. }
  3976. }
  3977. } else {
  3978. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3979. $button = 4;
  3980. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3981. }
  3982. }
  3983. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3984. $KOP = true;
  3985. }
  3986. }
  3987. foreach ( $roleArrayCopy as $k => $v ) {
  3988. foreach ( $verifyList as $m => $n ) {
  3989. if ($n [0] == $k) {
  3990. array_splice ( $verifyList, $m, 1, $v );
  3991. }
  3992. }
  3993. }
  3994. $receiptList [$key] ['verifyList'] = $verifyList;
  3995. $receiptList [$key] ['executeList'] = $executeList;
  3996. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3997. 'where' => 'sid=' . $value ['staff'],
  3998. 'asArray' => true
  3999. ) );
  4000. $receiptList [$key] ['button2'] = $button2;
  4001. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4002. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4003. $relust = $value ['sum'] - $value ['loanSum'];
  4004. $receiptList [$key] ['relust'] = $relust;
  4005. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  4006. }
  4007. // print_r($receiptList[$key]['executeList']);
  4008. $data ['receiptList'] = $receiptList;
  4009. $data ['memu'] = "receipt";
  4010. $data ['staff'] = $this->staff;
  4011. $data ['receiptMemu'] = 'implement';
  4012. $data ['verifyId'] = $this->verifyId;
  4013. $data ['executeId'] = $this->executeId;
  4014. $this->render ( "/admin/implement", $data );
  4015. }
  4016. function implementDo() {
  4017. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4018. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  4019. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  4020. if (! empty ( $rid ) && $amount != '') {
  4021. Doo::loadModel ( 'receipt' );
  4022. $receipt = new receipt ();
  4023. Doo::loadClass ( 'XDeode' );
  4024. $XDeode = new XDeode ( 5 );
  4025. $rinfo = $receipt->getOne ( array (
  4026. 'where' => 'rid=' . $rid,
  4027. 'asArray' => true
  4028. ) );
  4029. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  4030. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  4031. if (empty ( $executeStaff )) {
  4032. $executeStaff = array (
  4033. $this->staff [0] ['sid'] => array (
  4034. 'date' => date ( 'Y-m-d' ),
  4035. 'opinion' => $implementOpinions,
  4036. 'status' => 1
  4037. )
  4038. );
  4039. } else {
  4040. $executeStaff [$this->staff [0] ['sid']] = array (
  4041. 'date' => date ( 'Y-m-d' ),
  4042. 'opinion' => $implementOpinions,
  4043. 'status' => 1
  4044. );
  4045. }
  4046. if (count ( $executeStaff ) == count ( $executeCopy )) {
  4047. $receipt->executeStaff = json_encode ( $executeStaff );
  4048. $receipt->status = 8;
  4049. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  4050. $receipt->status = 9;
  4051. if ($rinfo ['status'] == 6) {
  4052. $receipt->loanDate = date ( "Y-m-d" );
  4053. }
  4054. $receipt->executeDate = date ( "Y-m-d" );
  4055. } else {
  4056. $receipt->executeStaff = json_encode ( $executeStaff );
  4057. }
  4058. $receipt->amount = $amount;
  4059. $receipt->update ( array (
  4060. 'where' => 'rid=' . $rid
  4061. ) );
  4062. }
  4063. $ridKey = $XDeode->encode ( $rid );
  4064. return "/hisImplement";
  4065. // return "/implement/" . $ridKey . ".html";
  4066. }
  4067. function receiptburEdi() {
  4068. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4069. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  4070. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4071. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4072. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4073. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4074. if (empty ( $status ))
  4075. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  4076. $vidList = array ();
  4077. $button = 0;
  4078. Doo::loadModel ( 'verify' );
  4079. Doo::loadModel ( 'receipt' );
  4080. Doo::loadModel ( 'staff' );
  4081. $staff = new staff ();
  4082. $receipt = new receipt ();
  4083. $verify = new verify ();
  4084. Doo::loadModel ( 'L_category' );
  4085. $Lcategory = new L_category ();
  4086. Doo::loadModel ( 'enclosur' );
  4087. $enclosur = new enclosur ();
  4088. Doo::loadModel ( 'loanReceipt' );
  4089. $loanReceipt = new loanReceipt ();
  4090. // user verify ID
  4091. $verifyDetail = $verify->find ( array (
  4092. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  4093. 'asArray' => true
  4094. ) );
  4095. foreach ( $verifyDetail as $key => $value ) {
  4096. array_push ( $vidList, $value ['vid'] );
  4097. }
  4098. $vid = implode ( ",", $vidList );
  4099. if (empty ( $verifyDetail ))
  4100. $vid = 0;
  4101. $categoryList = $Lcategory->find ( array (
  4102. 'asArray' => true
  4103. ) );
  4104. $staffList = $staff->find ( array (
  4105. 'where' => 'cid=' . $cid,
  4106. 'asArray' => true
  4107. ) );
  4108. $ap = "";
  4109. if ($status == 4) {
  4110. $ap = 4;
  4111. $status = 2;
  4112. }
  4113. // get Receipt By verifyID status 2
  4114. $receiptList = $receipt->find ( array (
  4115. 'where' => 'rid =' . $rid . ' and status=2',
  4116. 'desc' => 'rid',
  4117. 'asArray' => true
  4118. ) );
  4119. if (empty ( $receiptList )) {
  4120. die ( 'illegal request' );
  4121. }
  4122. $loanList = $loanReceipt->find ( array (
  4123. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4124. 'desc' => 'rid',
  4125. 'asArray' => true
  4126. ) );
  4127. $data ['explanation'] = '';
  4128. if (! empty ( $loanList ))
  4129. $data ['explanation'] = $loanList [0] ['explanation'];
  4130. $Locate = 0;
  4131. $roleId = 0;
  4132. $button = 0;
  4133. foreach ( $loanList as $key => $value ) {
  4134. $loanList [$key] ['Locate'] = $Locate;
  4135. $Locate ++;
  4136. $loanList [$key] ['reviseDetail'] = array ();
  4137. if (! empty ( $value ['reviseDetail'] ))
  4138. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4139. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4140. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4141. $categoryDetil = $Lcategory->getOne ( array (
  4142. 'where' => 'cid=' . $value ['cid'],
  4143. 'asArray' => true
  4144. ) );
  4145. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4146. // 检测编辑状态
  4147. $verifyList = $verify->getOne ( array (
  4148. 'where' => 'vid=' . $value ['verify'],
  4149. 'asArray' => true
  4150. ) );
  4151. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4152. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4153. Doo::loadModel ( 'role' );
  4154. $role = new role ();
  4155. $flag = true;
  4156. $roleKey = 0;
  4157. $endStaffArray = array ();
  4158. $roleArrayCopy = array ();
  4159. foreach ( $verifyList as $k => $v ) {
  4160. // init verifyStaff
  4161. if ($v [1] == 'ROLE') {
  4162. if (! empty ( $verifyStaff )) {
  4163. $endStaffArray = end ( $verifyStaff );
  4164. }
  4165. $roleVerify = json_decode ( $v [3], true );
  4166. $roleKey = $k;
  4167. $roleArray = array ();
  4168. $rolename = $role->getOne ( array (
  4169. 'where' => 'rid=' . $v [0],
  4170. 'asArray' => true
  4171. ) );
  4172. foreach ( $roleVerify as $o => $p ) {
  4173. $staffID = explode ( '_', $p );
  4174. $staffInfo = $staff->getOne ( array (
  4175. 'where' => 'sid=' . $staffID [0],
  4176. 'asArray' => true
  4177. ) );
  4178. // print_r($staffID);
  4179. $exp = array (
  4180. 0 => $staffInfo ['sid'],
  4181. 1 => $staffID [1],
  4182. 2 => $staffInfo ['avatar'],
  4183. 'date' => '',
  4184. 'date' => '',
  4185. 'opinion' => '',
  4186. 'status' => '',
  4187. 'rolename' => $rolename ['name']
  4188. );
  4189. array_push ( $roleArray, $exp );
  4190. }
  4191. $roleArrayCopy [$v [0]] = $roleArray;
  4192. // $verifyList[$k]['roleArray']=$roleArray;
  4193. }
  4194. $verifyList [$k] ['date'] = "";
  4195. $verifyList [$k] ['opinion'] = "";
  4196. $verifyList [$k] ['status'] = "";
  4197. if (empty ( $verifyStaff )) {
  4198. $verifyList [$k] ['date'] = "";
  4199. $verifyList [$k] ['opinion'] = "";
  4200. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4201. $verifyList [$k] ['status'] = 4;
  4202. $flag = false;
  4203. }
  4204. } else {
  4205. foreach ( $verifyStaff as $m => $u ) {
  4206. if ($v [0] == $m) {
  4207. $verifyList [$k] ['date'] = $u ['date'];
  4208. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4209. $verifyList [$k] ['status'] = $u ['status'];
  4210. $flag = false;
  4211. break;
  4212. }
  4213. }
  4214. $endStaffArray = end ( $verifyStaff );
  4215. if (isset ( $endStaffArray ['ROLE'] )) {
  4216. } else {
  4217. }
  4218. }
  4219. }
  4220. $rolename ['name'] = '';
  4221. if (! empty ( $roleId )) {
  4222. Doo::loadModel ( 'role' );
  4223. $role = new role ();
  4224. $rolename = $role->getOne ( array (
  4225. 'where' => 'rid=' . $roleId,
  4226. 'asArray' => true
  4227. ) );
  4228. }
  4229. if (! empty ( $verifyStaff ))
  4230. $endStaffArray = end ( $verifyStaff );
  4231. $KOP = false;
  4232. foreach ( $roleArrayCopy as $P => $A ) {
  4233. foreach ( $A as $MKI => $AVL ) {
  4234. if (! empty ( $verifyStaff )) {
  4235. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4236. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4237. $button = 4;
  4238. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4239. }
  4240. foreach ( $verifyStaff as $m => $u ) {
  4241. $AVLFK = $AVL [0] . '_R';
  4242. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4243. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4244. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4245. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4246. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4247. break;
  4248. }
  4249. }
  4250. } else {
  4251. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4252. $button = 4;
  4253. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4254. }
  4255. }
  4256. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4257. $KOP = true;
  4258. }
  4259. }
  4260. foreach ( $roleArrayCopy as $k => $v ) {
  4261. foreach ( $verifyList as $m => $n ) {
  4262. if ($n [0] == $k) {
  4263. array_splice ( $verifyList, $m, 1, $v );
  4264. }
  4265. }
  4266. }
  4267. $loanList [$key] ['verifyList'] = $verifyList;
  4268. }
  4269. $htmlLoan = '';
  4270. if (isset ( $loanList [0] )) {
  4271. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  4272. if ($value ['status'] == 1)
  4273. $htmlLoan .= '<li class="done" >';
  4274. elseif ($value ['status'] == 3)
  4275. $htmlLoan .= '<li class="undone" >';
  4276. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  4277. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  4278. if (isset ( $value ['rolename'] ))
  4279. $htmlLoan .= $value ['rolename'];
  4280. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  4281. }
  4282. $data ['loanDate'] = $loanList [0] ['date'];
  4283. } else {
  4284. $data ['loanReceiptDate'] = ''; // $loanList [0] ['date'];
  4285. }
  4286. $data ['htmlLoan'] = $htmlLoan;
  4287. // $data ['LoanReceipt']=$loanList[0];
  4288. // print_r($loanList);
  4289. $Locate = 0;
  4290. $roleId = 0;
  4291. $button = 0;
  4292. if ($ap == 4)
  4293. $status = 4;
  4294. Doo::loadClass ( 'XDeode' );
  4295. $XDeode = new XDeode ( 5 );
  4296. foreach ( $receiptList as $key => $value ) {
  4297. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4298. $receiptList [$key] ['Locate'] = $Locate;
  4299. $Locate ++;
  4300. $receiptList [$key] ['reviseDetail'] = array ();
  4301. // 调整金额 代码调整
  4302. if (! empty ( $value ['reviseDetail'] )) {
  4303. $reviseDetail = json_decode ( $value ['reviseDetail'], true );
  4304. foreach ( $reviseDetail as $ry => $re ) {
  4305. $reviseDetail [$ry] ['sidKey'] = $XDeode->encode ( $re ['sid'] );
  4306. $reviseDetail [$ry] ['reviseKey'] = $XDeode->encode ( $ry );
  4307. }
  4308. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  4309. // print_r($reviseDetail);
  4310. }
  4311. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4312. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4313. $categoryDetil = $Lcategory->getOne ( array (
  4314. 'where' => 'cid=' . $value ['cid'],
  4315. 'asArray' => true
  4316. ) );
  4317. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4318. // 检测编辑状态
  4319. $verifyList = $verify->getOne ( array (
  4320. 'where' => 'vid=' . $value ['verify'],
  4321. 'asArray' => true
  4322. ) );
  4323. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4324. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4325. Doo::loadModel ( 'role' );
  4326. $role = new role ();
  4327. // print_r($verifyList);
  4328. $flag = true;
  4329. $roleKey = 0;
  4330. $endStaffArray = array ();
  4331. $roleArrayCopy = array ();
  4332. foreach ( $verifyList as $k => $v ) {
  4333. // init verifyStaff
  4334. if ($v [1] == 'ROLE') {
  4335. if (! empty ( $verifyStaff )) {
  4336. $endStaffArray = end ( $verifyStaff );
  4337. if ($v [0] == $endStaffArray ['nextStaff']) {
  4338. $roleId = $v [0];
  4339. }
  4340. }
  4341. $roleVerify = json_decode ( $v [3], true );
  4342. $roleKey = $k;
  4343. $roleArray = array ();
  4344. $rolename = $role->getOne ( array (
  4345. 'where' => 'rid=' . $v [0],
  4346. 'asArray' => true
  4347. ) );
  4348. foreach ( $roleVerify as $o => $p ) {
  4349. $staffID = explode ( '_', $p );
  4350. $staffInfo = $staff->getOne ( array (
  4351. 'where' => 'sid=' . $staffID [0],
  4352. 'asArray' => true
  4353. ) );
  4354. // print_r($staffID);
  4355. $exp = array (
  4356. 0 => $staffInfo ['sid'],
  4357. 1 => $staffID [1],
  4358. 2 => $staffInfo ['avatar'],
  4359. 'date' => '',
  4360. 'date' => '',
  4361. 'opinion' => '',
  4362. 'status' => '',
  4363. 'rolename' => $rolename ['name']
  4364. );
  4365. array_push ( $roleArray, $exp );
  4366. }
  4367. $roleArrayCopy [$v [0]] = $roleArray;
  4368. // $verifyList[$k]['roleArray']=$roleArray;
  4369. }
  4370. // print_r($roleArray);
  4371. $verifyList [$k] ['date'] = "";
  4372. $verifyList [$k] ['opinion'] = "";
  4373. $verifyList [$k] ['status'] = "";
  4374. if (empty ( $verifyStaff )) {
  4375. $verifyList [$k] ['date'] = "";
  4376. $verifyList [$k] ['opinion'] = "";
  4377. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4378. $verifyList [$k] ['status'] = 4;
  4379. $button = 4;
  4380. $flag = false;
  4381. }
  4382. } else {
  4383. foreach ( $verifyStaff as $m => $u ) {
  4384. if ($v [0] == $m) {
  4385. $verifyList [$k] ['date'] = $u ['date'];
  4386. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4387. $verifyList [$k] ['status'] = $u ['status'];
  4388. $flag = false;
  4389. break;
  4390. }
  4391. }
  4392. $endStaffArray = end ( $verifyStaff );
  4393. if (isset ( $endStaffArray ['ROLE'] )) {
  4394. } else {
  4395. $endKey = key ( $verifyStaff );
  4396. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4397. $button = 4;
  4398. $verifyList [$k] ['status'] = 4;
  4399. }
  4400. }
  4401. }
  4402. }
  4403. $rolename ['name'] = '';
  4404. if (! empty ( $roleId )) {
  4405. Doo::loadModel ( 'role' );
  4406. $role = new role ();
  4407. $rolename = $role->getOne ( array (
  4408. 'where' => 'rid=' . $roleId,
  4409. 'asArray' => true
  4410. ) );
  4411. }
  4412. if (! empty ( $verifyStaff ))
  4413. $endStaffArray = end ( $verifyStaff );
  4414. $KOP = false;
  4415. foreach ( $roleArrayCopy as $P => $A ) {
  4416. foreach ( $A as $MKI => $AVL ) {
  4417. if (! empty ( $verifyStaff )) {
  4418. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4419. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4420. $button = 4;
  4421. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4422. }
  4423. foreach ( $verifyStaff as $m => $u ) {
  4424. $AVLFK = $AVL [0] . '_R';
  4425. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4426. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4427. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4428. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4429. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4430. break;
  4431. }
  4432. }
  4433. } else {
  4434. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4435. $button = 4;
  4436. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4437. }
  4438. }
  4439. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4440. $KOP = true;
  4441. }
  4442. }
  4443. foreach ( $roleArrayCopy as $k => $v ) {
  4444. foreach ( $verifyList as $m => $n ) {
  4445. if ($n [0] == $k) {
  4446. array_splice ( $verifyList, $m, 1, $v );
  4447. }
  4448. }
  4449. }
  4450. // print_r($verifyList);
  4451. $receiptList [$key] ['verifyList'] = $verifyList;
  4452. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4453. 'where' => 'sid=' . $value ['staff'],
  4454. 'asArray' => true
  4455. ) );
  4456. $receiptList [$key] ['button'] = $button;
  4457. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4458. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4459. $relust = $value ['sum'] - $value ['loanSum'];
  4460. $receiptList [$key] ['relust'] = $relust;
  4461. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4462. }
  4463. // print_r($receiptList);die;
  4464. // $data['verifyDetail']=$verifyDetail;
  4465. $mothHtml = "";
  4466. for($i = 1; $i <= 12; $i ++) {
  4467. if ($month == $i)
  4468. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4469. else
  4470. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4471. }
  4472. // 获取审批日志
  4473. Doo::loadModel ( 'receiptLog' );
  4474. $receiptLog = new receiptLog ();
  4475. $rlList = array ();
  4476. $rlInfo = $receiptLog->getOne ( array (
  4477. 'where' => 'rid=' . $rid . ' and status=4',
  4478. 'asArray' => true
  4479. ) );
  4480. $tijdate = $receiptLog->getOne ( array (
  4481. 'where' => 'rid=' . $rid . ' and status=2',
  4482. 'asc' => 'rlid',
  4483. 'asArray' => true
  4484. ) );
  4485. if (! empty ( $rlInfo )) {
  4486. $rlList = $receiptLog->find ( array (
  4487. 'where' => 'rid=' . $rid,
  4488. 'asc' => 'rlid',
  4489. 'asArray' => true
  4490. ) );
  4491. }
  4492. // echo $rid;
  4493. // print_r($receiptList);
  4494. $receiptList [0] ['rlList'] = $rlList;
  4495. // print_r($receiptList);
  4496. $enclosurList = $enclosur->find ( array (
  4497. 'where' => 'rid=' . $rid,
  4498. 'asArray' => true
  4499. ) );
  4500. $enclosurHtml = '';
  4501. foreach ( $enclosurList as $value ) {
  4502. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4503. }
  4504. $data ['enclosurHtml'] = $enclosurHtml;
  4505. $data ['rolename'] = $rolename ['name'];
  4506. $data ['mothHtml'] = $mothHtml;
  4507. // print_r($receiptList);
  4508. $data ['rid'] = $rid;
  4509. $data ['tijdate'] = $tijdate ['date'];
  4510. $data ['receiptList'] = $receiptList;
  4511. $data ['receiptApprovalCount'] = count ( $receiptList );
  4512. $data ['status'] = $status;
  4513. $data ['year'] = $year;
  4514. $data ['categoryList'] = $categoryList;
  4515. $data ['staffList'] = $staffList;
  4516. $data ['cid'] = $cid;
  4517. $data ['sid'] = $sid;
  4518. $data ['ap'] = $ap;
  4519. $data ['memu'] = "receipt";
  4520. $data ['staff'] = $this->staff;
  4521. $data ['receiptMemu'] = 'approvalExpenses';
  4522. $data ['verifyId'] = $this->verifyId;
  4523. $data ['executeId'] = $this->executeId;
  4524. $this->render ( "/admin/receiptburEdi", $data );
  4525. }
  4526. function hisImplement() {
  4527. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4528. if (empty ( $item ))
  4529. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "expenses";
  4530. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  4531. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4532. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  4533. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  4534. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  4535. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'pendImplement';
  4536. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  4537. Doo::loadClass ( 'XDeode' );
  4538. $XDeode = new XDeode ( 5 );
  4539. Doo::loadModel ( 'receipt' );
  4540. $receipt = new receipt ();
  4541. Doo::loadModel ( 'L_category' );
  4542. $Lcategory = new L_category ();
  4543. Doo::loadModel ( 'verify' );
  4544. Doo::loadModel ( 'statistics' );
  4545. $statistics = new statistics ();
  4546. $verify = new verify ();
  4547. Doo::loadModel ( 'staff' );
  4548. $staff = new staff ();
  4549. Doo::loadClass ( 'XDeode' );
  4550. $XDeode = new XDeode ( 5 );
  4551. $cid = $XDeode->decode ( $cidKey );
  4552. $condition = "";
  4553. if ($item == "expenses")
  4554. $condition = " and Rtype=1 ";
  4555. elseif ($item == "receipts")
  4556. $condition = " and Rtype=0 ";
  4557. elseif ($item == "remits")
  4558. $condition = " and Rtype=2 ";
  4559. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  4560. $sopString = $cidString = "";
  4561. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  4562. if (empty ( $rdate ))
  4563. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  4564. else
  4565. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  4566. if ($status == 'pendImplement') {
  4567. $condition .= ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  4568. } elseif ($status == 'alerpts') {
  4569. $statusCon = '(status=8 or status=9 )';
  4570. if (empty ( $rdate ))
  4571. $dateCondition .= " and Year(date) =" . $year;
  4572. else
  4573. $dateCondition .= " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  4574. }
  4575. if ($sop != 'SOP')
  4576. $sopString = " and staff=" . $sop;
  4577. if ($cidKey != 'ALL')
  4578. $cidString = " and cid=" . $cid;
  4579. $receiptList = $receipt->find ( array (
  4580. 'where' => $statusCon . $condition . $dateCondition . $sopString . $cidString,
  4581. 'desc' => 'rid',
  4582. 'asArray' => true
  4583. ) );
  4584. // 员工筛选
  4585. $receiptList2 = $receipt->find ( array (
  4586. 'where' => $statusCon . $condition . $dateCondition,
  4587. 'desc' => 'rid',
  4588. 'asArray' => true
  4589. ) );
  4590. $sopStaff = array ();
  4591. foreach ( $receiptList2 as $key => $value ) {
  4592. $staffDetail = $staff->getOne ( array (
  4593. 'select' => 'username',
  4594. 'where' => 'sid=' . $value ['staff'],
  4595. 'asArray' => true
  4596. ) );
  4597. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  4598. }
  4599. // 办事处筛选
  4600. $categoryScreen = array ();
  4601. $categorList = $Lcategory->getCategory ();
  4602. foreach ( $receiptList2 as $key => $value ) {
  4603. foreach ( $categorList as $k => $v ) {
  4604. if ($value ['cid'] == $v ['cid']) {
  4605. $categoryScreen [$v ['cidKey']] = $v ['title'];
  4606. break;
  4607. }
  4608. }
  4609. }
  4610. $categoryScreenHtml = "";
  4611. foreach ( $categoryScreen as $key => $value ) {
  4612. if ($cidKey == $key)
  4613. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4614. else
  4615. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4616. }
  4617. $data ['categoryScreenHtml'] = $categoryScreenHtml;
  4618. $data ['cidKey'] = $cidKey;
  4619. $Locate = 0;
  4620. $roleId = 0;
  4621. $button = 0;
  4622. $staffBatchNumber = 100001;
  4623. $remittanceList = array ();
  4624. foreach ( $receiptList as $key => $value ) {
  4625. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4626. $receiptList [$key] ['Texe'] = 'false';
  4627. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  4628. $receiptList [$key] ['Texe'] = 'true';
  4629. }
  4630. $receiptList [$key] ['TRexe'] = 'true';
  4631. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  4632. $receiptList [$key] ['TRexe'] = 'false';
  4633. }
  4634. $receiptList [$key] ['Locate'] = $Locate;
  4635. $Locate ++;
  4636. $receiptList [$key] ['reviseDetail'] = array ();
  4637. if (! empty ( $value ['reviseDetail'] ))
  4638. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4639. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4640. $categoryDetil = $Lcategory->getOne ( array (
  4641. 'where' => 'cid=' . $value ['cid'],
  4642. 'asArray' => true
  4643. ) );
  4644. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4645. // 检测编辑状态
  4646. $verifyList = $verify->getOne ( array (
  4647. 'where' => 'vid=' . $value ['verify'],
  4648. 'asArray' => true
  4649. ) );
  4650. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4651. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4652. Doo::loadModel ( 'role' );
  4653. $role = new role ();
  4654. $flag = true;
  4655. $roleKey = 0;
  4656. $endStaffArray = array ();
  4657. $roleArrayCopy = array ();
  4658. foreach ( $verifyList as $k => $v ) {
  4659. // init verifyStaff
  4660. if ($v [1] == 'ROLE') {
  4661. if (! empty ( $verifyStaff )) {
  4662. $endStaffArray = end ( $verifyStaff );
  4663. }
  4664. $roleVerify = json_decode ( $v [3], true );
  4665. $roleKey = $k;
  4666. $roleArray = array ();
  4667. $rolename = $role->getOne ( array (
  4668. 'where' => 'rid=' . $v [0],
  4669. 'asArray' => true
  4670. ) );
  4671. foreach ( $roleVerify as $o => $p ) {
  4672. $staffID = explode ( '_', $p );
  4673. $staffInfo = $staff->getOne ( array (
  4674. 'where' => 'sid=' . $staffID [0],
  4675. 'asArray' => true
  4676. ) );
  4677. $exp = array (
  4678. 0 => $staffInfo ['sid'],
  4679. 1 => $staffID [1],
  4680. 2 => $staffInfo ['avatar'],
  4681. 'date' => '',
  4682. 'date' => '',
  4683. 'opinion' => '',
  4684. 'status' => '',
  4685. 'rolename' => $rolename ['name']
  4686. );
  4687. array_push ( $roleArray, $exp );
  4688. }
  4689. $roleArrayCopy [$v [0]] = $roleArray;
  4690. }
  4691. $verifyList [$k] ['date'] = "";
  4692. $verifyList [$k] ['opinion'] = "";
  4693. $verifyList [$k] ['status'] = "";
  4694. if (empty ( $verifyStaff )) {
  4695. $verifyList [$k] ['date'] = "";
  4696. $verifyList [$k] ['opinion'] = "";
  4697. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4698. $verifyList [$k] ['status'] = 4;
  4699. $flag = false;
  4700. }
  4701. } else {
  4702. foreach ( $verifyStaff as $m => $u ) {
  4703. if ($v [0] == $m) {
  4704. $verifyList [$k] ['date'] = $u ['date'];
  4705. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4706. $verifyList [$k] ['status'] = $u ['status'];
  4707. $flag = false;
  4708. break;
  4709. }
  4710. }
  4711. $endStaffArray = end ( $verifyStaff );
  4712. }
  4713. }
  4714. $rolename ['name'] = '';
  4715. if (! empty ( $roleId )) {
  4716. Doo::loadModel ( 'role' );
  4717. $role = new role ();
  4718. $rolename = $role->getOne ( array (
  4719. 'where' => 'rid=' . $roleId,
  4720. 'asArray' => true
  4721. ) );
  4722. }
  4723. if (! empty ( $verifyStaff ))
  4724. $endStaffArray = end ( $verifyStaff );
  4725. $KOP = false;
  4726. foreach ( $roleArrayCopy as $P => $A ) {
  4727. foreach ( $A as $MKI => $AVL ) {
  4728. if (! empty ( $verifyStaff )) {
  4729. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4730. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4731. $button = 4;
  4732. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4733. }
  4734. foreach ( $verifyStaff as $m => $u ) {
  4735. $AVLFK = $AVL [0] . '_R';
  4736. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4737. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4738. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4739. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4740. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4741. break;
  4742. }
  4743. }
  4744. } else {
  4745. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4746. $button = 4;
  4747. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4748. }
  4749. }
  4750. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4751. $KOP = true;
  4752. }
  4753. }
  4754. foreach ( $roleArrayCopy as $k => $v ) {
  4755. foreach ( $verifyList as $m => $n ) {
  4756. if ($n [0] == $k) {
  4757. array_splice ( $verifyList, $m, 1, $v );
  4758. }
  4759. }
  4760. }
  4761. $receiptList [$key] ['verifyList'] = $verifyList;
  4762. $staffDetail = $staff->getOne ( array (
  4763. 'where' => 'sid=' . $value ['staff'],
  4764. 'asArray' => true
  4765. ) );
  4766. $receiptList [$key] ['staffDetail'] = $staffDetail;
  4767. $receiptList [$key] ['button'] = $button;
  4768. // 设置导出汇款execl
  4769. if (! empty ( $value ['remittanceName'] ) && ! empty ( $value ['bankName'] ) && ! empty ( $value ['bankNumber'] )) {
  4770. $remittanceDetail = array (
  4771. $staffBatchNumber,
  4772. $value ['remittanceName'],
  4773. $value ['bankNumber'],
  4774. $value ['bankName'],
  4775. $value ['remittanceBankType'],
  4776. $value ['coupletNumber'],
  4777. $value ['sum']
  4778. );
  4779. array_push ( $remittanceList, $remittanceDetail );
  4780. $staffBatchNumber ++;
  4781. }
  4782. }
  4783. $data ['remittanceList'] = json_encode ( $remittanceList );
  4784. // print_r($receiptList);
  4785. $mothHtml = "";
  4786. for($i = 1; $i <= 12; $i ++) {
  4787. if ($moth == $i)
  4788. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4789. else
  4790. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4791. }
  4792. $dayHtml = "";
  4793. if ($day != "DAY" || $moth != "MONTH") {
  4794. for($i = 1; $i <= 31; $i ++) {
  4795. if ($day == $i)
  4796. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  4797. else
  4798. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  4799. }
  4800. }
  4801. $sopHtml = "";
  4802. foreach ( $sopStaff as $key => $value ) {
  4803. if ($sop == $key)
  4804. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4805. else
  4806. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4807. }
  4808. $data ['status'] = $status;
  4809. $data ['rdate'] = $rdate;
  4810. $data ['sopHtml'] = $sopHtml;
  4811. $data ['dayHtml'] = $dayHtml;
  4812. $data ['mothHtml'] = $mothHtml;
  4813. $data ['receiptList'] = $receiptList;
  4814. $data ['memu'] = "receipt";
  4815. $data ['staff'] = $this->staff;
  4816. $data ['receiptMemu'] = 'implement';
  4817. $data ['verifyId'] = $this->verifyId;
  4818. $data ['executeId'] = $this->executeId;
  4819. $data ['item'] = $item;
  4820. $data ['year'] = $year;
  4821. $data ['moth'] = $moth;
  4822. $data ['day'] = $day;
  4823. $data ['sop'] = $sop;
  4824. $this->render ( "/admin/hisImplement", $data );
  4825. }
  4826. /**
  4827. * 导出汇款信息的exelc
  4828. */
  4829. function exportRemittance() {
  4830. $remittanceInfo = $_POST ['remittanceInfo']; // $this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  4831. if (empty ( $remittanceInfo ))
  4832. die ( 'illegal request' );
  4833. $title = array (
  4834. '员工编号',
  4835. '姓名',
  4836. '员工账号',
  4837. '员工账户开户行',
  4838. '转账类型',
  4839. '联行号',
  4840. '金额'
  4841. );
  4842. $data = json_decode ( $remittanceInfo, true );
  4843. if (empty ( $data ))
  4844. die ( 'illegal request' );
  4845. Doo::loadClass ( 'receipt.func' );
  4846. exportExcel ( $title, $data, '批量日常报销-公司账号', './', true );
  4847. header ( 'Content-Type:text/html;charset=utf-8' );
  4848. die ( '导出' . count ( $data ) . '条数据,<a href="/hisImplement">返回</a>' );
  4849. }
  4850. function ajaxExamine() {
  4851. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4852. Doo::loadModel ( 'receipt' );
  4853. $receipt = new receipt ();
  4854. if (! empty ( $rid )) {
  4855. $rLRes = $receipt->find ( array (
  4856. '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,
  4857. 'asArray' => true
  4858. ) );
  4859. echo json_encode ( array (
  4860. 'status' => 1,
  4861. 'receipt' => $rLRes [0]
  4862. ) );
  4863. die ();
  4864. }
  4865. echo json_encode ( array (
  4866. 'status' => 0,
  4867. 'receipt' => array ()
  4868. ) );
  4869. die ();
  4870. }
  4871. /*
  4872. * 废弃
  4873. */
  4874. function myReceipt() {
  4875. // all approval past withdraw
  4876. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4877. if (empty ( $item ))
  4878. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4879. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4880. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  4881. Doo::loadModel ( 'receipt' );
  4882. $receipt = new receipt ();
  4883. // pre-loaded
  4884. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4885. // have cache
  4886. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  4887. if (! empty ( $moth )) // yearPage
  4888. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  4889. $this->showCache ( $path );
  4890. }
  4891. Doo::loadModel ( 'L_category' );
  4892. $Lcategory = new L_category ();
  4893. Doo::loadModel ( 'verify' );
  4894. Doo::loadModel ( 'statistics' );
  4895. $statistics = new statistics ();
  4896. $verify = new verify ();
  4897. Doo::loadModel ( 'staff' );
  4898. $staff = new staff ();
  4899. $condition = " and status!=0 ";
  4900. if ($item == "approval")
  4901. $condition = " and status=2 ";
  4902. elseif ($item == "withdraw")
  4903. $condition = " and status=3 ";
  4904. elseif ($item == "past")
  4905. $condition = " and status=1 ";
  4906. elseif ($item == "whdw")
  4907. $condition = " and status=4 ";
  4908. $dateCondition = " and Year(date) =" . $year;
  4909. if (! empty ( $moth )) {
  4910. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  4911. $stList = $statistics->getOne ( array (
  4912. 'select' => 'rePrice ,agPrice',
  4913. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  4914. 'asArray' => true
  4915. ) );
  4916. } else
  4917. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  4918. if (empty ( $stList ))
  4919. $stList = array (
  4920. 'rePrice' => 0,
  4921. 'agPrice' => 0
  4922. );
  4923. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  4924. $data ['stList'] = array (
  4925. 'rePrice' => $stList ['rePrice'],
  4926. 'agPrice' => $stList ['agPrice'],
  4927. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  4928. );
  4929. $receiptList = $receipt->find ( array (
  4930. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  4931. 'desc' => 'rid',
  4932. 'asArray' => true
  4933. ) );
  4934. $Locate = 0;
  4935. $roleId = 0;
  4936. $button = 0;
  4937. foreach ( $receiptList as $key => $value ) {
  4938. $receiptList [$key] ['Locate'] = $Locate;
  4939. $Locate ++;
  4940. $receiptList [$key] ['reviseDetail'] = array ();
  4941. if (! empty ( $value ['reviseDetail'] ))
  4942. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4943. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4944. $categoryDetil = $Lcategory->getOne ( array (
  4945. 'where' => 'cid=' . $value ['cid'],
  4946. 'asArray' => true
  4947. ) );
  4948. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4949. // 检测编辑状态
  4950. $verifyList = $verify->getOne ( array (
  4951. 'where' => 'vid=' . $value ['verify'],
  4952. 'asArray' => true
  4953. ) );
  4954. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4955. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4956. Doo::loadModel ( 'role' );
  4957. $role = new role ();
  4958. $flag = true;
  4959. $roleKey = 0;
  4960. $endStaffArray = array ();
  4961. $roleArrayCopy = array ();
  4962. foreach ( $verifyList as $k => $v ) {
  4963. // init verifyStaff
  4964. if ($v [1] == 'ROLE') {
  4965. if (! empty ( $verifyStaff )) {
  4966. $endStaffArray = end ( $verifyStaff );
  4967. // if ($v[0]==$endStaffArray['nextStaff']){
  4968. // $roleId=$v[0];
  4969. // }
  4970. }
  4971. $roleVerify = json_decode ( $v [3], true );
  4972. $roleKey = $k;
  4973. $roleArray = array ();
  4974. $rolename = $role->getOne ( array (
  4975. 'where' => 'rid=' . $v [0],
  4976. 'asArray' => true
  4977. ) );
  4978. foreach ( $roleVerify as $o => $p ) {
  4979. $staffID = explode ( '_', $p );
  4980. $staffInfo = $staff->getOne ( array (
  4981. 'where' => 'sid=' . $staffID [0],
  4982. 'asArray' => true
  4983. ) );
  4984. // print_r($staffID);
  4985. $exp = array (
  4986. 0 => $staffInfo ['sid'],
  4987. 1 => $staffID [1],
  4988. 2 => $staffInfo ['avatar'],
  4989. 'date' => '',
  4990. 'date' => '',
  4991. 'opinion' => '',
  4992. 'status' => '',
  4993. 'rolename' => $rolename ['name']
  4994. );
  4995. array_push ( $roleArray, $exp );
  4996. }
  4997. $roleArrayCopy [$v [0]] = $roleArray;
  4998. // $verifyList[$k]['roleArray']=$roleArray;
  4999. }
  5000. $verifyList [$k] ['date'] = "";
  5001. $verifyList [$k] ['opinion'] = "";
  5002. $verifyList [$k] ['status'] = "";
  5003. if (empty ( $verifyStaff )) {
  5004. $verifyList [$k] ['date'] = "";
  5005. $verifyList [$k] ['opinion'] = "";
  5006. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5007. $verifyList [$k] ['status'] = 4;
  5008. $flag = false;
  5009. }
  5010. } else {
  5011. foreach ( $verifyStaff as $m => $u ) {
  5012. if ($v [0] == $m) {
  5013. $verifyList [$k] ['date'] = $u ['date'];
  5014. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5015. $verifyList [$k] ['status'] = $u ['status'];
  5016. $flag = false;
  5017. break;
  5018. }
  5019. }
  5020. $endStaffArray = end ( $verifyStaff );
  5021. if (isset ( $endStaffArray ['ROLE'] )) {
  5022. } else {
  5023. // $endKey=key($verifyStaff);
  5024. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5025. // $button=4;
  5026. // $verifyList[$k]['status']=4;
  5027. // }
  5028. }
  5029. }
  5030. }
  5031. $rolename ['name'] = '';
  5032. if (! empty ( $roleId )) {
  5033. Doo::loadModel ( 'role' );
  5034. $role = new role ();
  5035. $rolename = $role->getOne ( array (
  5036. 'where' => 'rid=' . $roleId,
  5037. 'asArray' => true
  5038. ) );
  5039. }
  5040. if (! empty ( $verifyStaff ))
  5041. $endStaffArray = end ( $verifyStaff );
  5042. $KOP = false;
  5043. foreach ( $roleArrayCopy as $P => $A ) {
  5044. foreach ( $A as $MKI => $AVL ) {
  5045. if (! empty ( $verifyStaff )) {
  5046. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5047. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5048. $button = 4;
  5049. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5050. }
  5051. foreach ( $verifyStaff as $m => $u ) {
  5052. $AVLFK = $AVL [0] . '_R';
  5053. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5054. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5055. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5056. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5057. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5058. break;
  5059. }
  5060. }
  5061. } else {
  5062. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5063. $button = 4;
  5064. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5065. }
  5066. }
  5067. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5068. $KOP = true;
  5069. }
  5070. }
  5071. foreach ( $roleArrayCopy as $k => $v ) {
  5072. foreach ( $verifyList as $m => $n ) {
  5073. if ($n [0] == $k) {
  5074. array_splice ( $verifyList, $m, 1, $v );
  5075. }
  5076. }
  5077. }
  5078. $receiptList [$key] ['verifyList'] = $verifyList;
  5079. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5080. 'where' => 'sid=' . $value ['staff'],
  5081. 'asArray' => true
  5082. ) );
  5083. $receiptList [$key] ['button'] = $button;
  5084. }
  5085. // print_r($receiptList);die;
  5086. $mothHtml = "";
  5087. for($i = 1; $i <= 12; $i ++) {
  5088. if ($moth == $i)
  5089. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5090. else
  5091. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5092. }
  5093. $data ['mothHtml'] = $mothHtml;
  5094. $data ['receiptList'] = $receiptList;
  5095. $data ['memu'] = "receipt";
  5096. $data ['staff'] = $this->staff;
  5097. $data ['receiptMemu'] = 'receipt';
  5098. $data ['verifyId'] = $this->verifyId;
  5099. $data ['executeId'] = $this->executeId;
  5100. $data ['item'] = $item;
  5101. $data ['year'] = $year;
  5102. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  5103. // sufficient condition to generate cache
  5104. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  5105. $receiptList = $receipt->find ( array (
  5106. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  5107. 'asArray' => true
  5108. ) );
  5109. if (empty ( $receiptList )) { // generated files
  5110. ob_start ();
  5111. $this->render ( "/admin/saea_myList", $data );
  5112. $this->cacheFile ( $path );
  5113. die ();
  5114. // $content = ob_get_contents();
  5115. // $fp = fopen($path, "w");
  5116. // fwrite($fp, $content);
  5117. // fclose($fp);
  5118. }
  5119. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  5120. $receiptList = $receipt->find ( array (
  5121. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  5122. 'asArray' => true
  5123. ) );
  5124. if (empty ( $receiptList )) { // generated files
  5125. ob_start ();
  5126. $this->render ( "/admin/saea_myList", $data );
  5127. $this->cacheFile ( $path );
  5128. die ();
  5129. }
  5130. }
  5131. }
  5132. $this->render ( "/admin/saea_myList", $data );
  5133. }
  5134. function saeaCreate() {
  5135. Doo::loadModel ( 'accountItem' );
  5136. Doo::loadModel ( 'verify' );
  5137. Doo::loadModel ( 'receipt' );
  5138. Doo::loadModel ( 'L_category' );
  5139. $lCategory = new L_category ();
  5140. $receipt = new receipt ();
  5141. $verify = new verify ();
  5142. $accountItem = new accountItem ();
  5143. Doo::loadModel ( "role" );
  5144. $role = new role ();
  5145. $acItem = $accountItem->find ( array (
  5146. 'asArray' => true
  5147. ) );
  5148. $veList = $verify->find ( array (
  5149. 'asArray' => true
  5150. ) );
  5151. foreach ( $veList as $key => $value ) {
  5152. $v = json_decode ( $value ['staff'] );
  5153. $list = array ();
  5154. foreach ( $v as $n => $m ) {
  5155. if ($m ['1'] == 'ROLE') {
  5156. $roleInfo = $role->getOne ( array (
  5157. 'where' => 'rid=' . $m [0],
  5158. 'asArray' => true
  5159. ) );
  5160. $v [$n] [1] = $roleInfo ['name'];
  5161. array_push ( $list, $roleInfo ['name'] );
  5162. } else {
  5163. array_push ( $list, $v [$n] [1] );
  5164. }
  5165. }
  5166. $veList [$key] ['staff'] = implode ( '>', $list );
  5167. }
  5168. $data ['category'] = $lCategory->find ( array (
  5169. 'asArray' => true
  5170. ) );
  5171. $data ['veList'] = $veList;
  5172. $data ['acItem'] = $acItem;
  5173. $data ['memu'] = "receipt";
  5174. $data ['staff'] = $this->staff;
  5175. $data ['receiptMemu'] = 'saeaBorad';
  5176. $data ['verifyId'] = $this->verifyId;
  5177. $data ['executeId'] = $this->executeId;
  5178. $this->render ( "/admin/saea_create", $data );
  5179. }
  5180. function addReceipt() {
  5181. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  5182. $agency = $this->get_args ( 'agency' );
  5183. $travel = $this->get_args ( 'travel' );
  5184. $train = $this->get_args ( 'train' );
  5185. $other = $this->get_args ( 'other' );
  5186. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5187. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5188. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5189. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  5190. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  5191. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  5192. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  5193. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  5194. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  5195. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  5196. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  5197. header ( 'Content-Type:text/html;charset=utf-8' );
  5198. die ( '请填写联行号' );
  5199. }
  5200. Doo::loadModel ( 'receipt' );
  5201. Doo::loadModel ( 'receiptDetail' );
  5202. Doo::loadModel ( 'accountItem' );
  5203. $accountItem = new accountItem ();
  5204. $receipt = new receipt ();
  5205. Doo::loadModel ( 'enclosur' );
  5206. Doo::loadModel ( 'execute' );
  5207. $execute = new execute ();
  5208. $executeDetail = $execute->getOne ( array (
  5209. 'where' => 'mold="报销单执行人"',
  5210. 'asArray' => true
  5211. ) );
  5212. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  5213. // if(!empty($receiptDetail))
  5214. // return "/referReceipt/".$receiptDetail['rid'];
  5215. $aItem = $accountItem->find ( array (
  5216. 'asArray' => true
  5217. ) );
  5218. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5219. $ag = $tr = $ta = $ot = 0;
  5220. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5221. foreach ( $aItem as $key => $value ) {
  5222. if ($value ['category'] == $this->AGENCY) {
  5223. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5224. array_push ( $accountJson [$this->AGENCY], array (
  5225. 'aid' => $value ['aid'],
  5226. 'name' => $value ['name'],
  5227. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5228. ) );
  5229. $sum += $agency [$ag];
  5230. $agencySum += $agency [$ag];
  5231. }
  5232. $ag ++;
  5233. }
  5234. if ($value ['category'] == $this->TRAVEL) {
  5235. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5236. array_push ( $accountJson [$this->TRAVEL], array (
  5237. 'aid' => $value ['aid'],
  5238. 'name' => $value ['name'],
  5239. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5240. ) );
  5241. $sum += $travel [$tr];
  5242. $travelSum += $travel [$tr];
  5243. }
  5244. $tr ++;
  5245. }
  5246. if ($value ['category'] == $this->TRAIN) {
  5247. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5248. array_push ( $accountJson [$this->TRAIN], array (
  5249. 'aid' => $value ['aid'],
  5250. 'name' => $value ['name'],
  5251. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5252. ) );
  5253. $sum += $train [$ta];
  5254. $trainSum += $train [$ta];
  5255. }
  5256. $ta ++;
  5257. }
  5258. if ($value ['category'] == $this->OTHER) {
  5259. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5260. array_push ( $accountJson [$this->OTHER], array (
  5261. 'aid' => $value ['aid'],
  5262. 'name' => $value ['name'],
  5263. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5264. ) );
  5265. $sum += $other [$ot];
  5266. $otherSum += $other [$ot];
  5267. }
  5268. $ot ++;
  5269. }
  5270. }
  5271. $accountJson ['cSum'] = array (
  5272. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5273. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5274. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5275. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5276. );
  5277. // 报销单
  5278. $receipt->accountItem = json_encode ( $accountJson );
  5279. $receipt->staff = $this->staff [0] ['sid'];
  5280. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5281. $receipt->date = date ( "Y-m-d" );
  5282. $receipt->cid = $cid;
  5283. $receipt->status = 5;
  5284. // 修改审批流程加入角色
  5285. $receipt->verify = $verify;
  5286. $receipt->executeCopy = $executeDetail ['staff'];
  5287. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  5288. $receipt->explanation = $explanation;
  5289. $receipt->remittanceName = $remittanceName;
  5290. $receipt->bankName = $bankName;
  5291. $receipt->bankNumber = $bankNumber;
  5292. $receipt->remittanceBankType = $remittanceBankType;
  5293. if ($remittanceBankType == 1)
  5294. $receipt->coupletNumber = $coupletNumber;
  5295. $rid = $receipt->insert ();
  5296. // 附件
  5297. if (! empty ( $enclosurName )) {
  5298. $enclosurArray = explode ( '-', $enclosurName );
  5299. foreach ( $enclosurArray as $value ) {
  5300. $enclosur = new enclosur ();
  5301. $enclosur->name = $value;
  5302. $enclosur->rid = $rid;
  5303. $enclosur->insert ();
  5304. }
  5305. // print_r($enclosurArray);die;
  5306. }
  5307. // 报销详情
  5308. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5309. $receiptDetail = new receiptDetail ();
  5310. $receiptDetail->staff = $this->staff [0] ['sid'];
  5311. $receiptDetail->item = $value ['name'];
  5312. $receiptDetail->itemCategory = $this->AGENCY;
  5313. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5314. $receiptDetail->date = date ( "Y-m-d" );
  5315. $receiptDetail->cid = $cid;
  5316. $receiptDetail->rid = $rid;
  5317. $receiptDetail->status = 4;
  5318. $receiptDetail->insert ();
  5319. }
  5320. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5321. $receiptDetail = new receiptDetail ();
  5322. $receiptDetail->staff = $this->staff [0] ['sid'];
  5323. $receiptDetail->item = $value ['name'];
  5324. $receiptDetail->itemCategory = $this->TRAVEL;
  5325. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5326. $receiptDetail->date = date ( "Y-m-d" );
  5327. $receiptDetail->cid = $cid;
  5328. $receiptDetail->rid = $rid;
  5329. $receiptDetail->status = 4;
  5330. $receiptDetail->insert ();
  5331. }
  5332. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5333. $receiptDetail = new receiptDetail ();
  5334. $receiptDetail->staff = $this->staff [0] ['sid'];
  5335. $receiptDetail->item = $value ['name'];
  5336. $receiptDetail->itemCategory = $this->TRAIN;
  5337. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5338. $receiptDetail->date = date ( "Y-m-d" );
  5339. $receiptDetail->cid = $cid;
  5340. $receiptDetail->rid = $rid;
  5341. $receiptDetail->status = 4;
  5342. $receiptDetail->insert ();
  5343. }
  5344. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5345. $receiptDetail = new receiptDetail ();
  5346. $receiptDetail->staff = $this->staff [0] ['sid'];
  5347. $receiptDetail->item = $value ['name'];
  5348. $receiptDetail->itemCategory = $this->OTHER;
  5349. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5350. $receiptDetail->date = date ( "Y-m-d" );
  5351. $receiptDetail->cid = $cid;
  5352. $receiptDetail->rid = $rid;
  5353. $receiptDetail->status = 4;
  5354. $receiptDetail->insert ();
  5355. }
  5356. return "/saeaBorad";
  5357. } else
  5358. die ( 'illegal request' );
  5359. }
  5360. function referReceipt() {
  5361. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  5362. Doo::loadModel ( 'receipt' );
  5363. Doo::loadModel ( 'verify' );
  5364. $verify = new verify ();
  5365. $receipt = new receipt ();
  5366. Doo::loadModel ( 'L_category' );
  5367. $lCategory = new L_category ();
  5368. Doo::loadModel ( "role" );
  5369. $role = new role ();
  5370. $receiptDetail = $receipt->find ( array (
  5371. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  5372. 'asArray' => true
  5373. ) );
  5374. if (empty ( $receiptDetail ))
  5375. return "/addReceipt";
  5376. foreach ( $receiptDetail as $key => $value ) {
  5377. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5378. $veList = $verify->getOne ( array (
  5379. 'where' => 'vid=' . $value ['verify'],
  5380. 'asArray' => true
  5381. ) );
  5382. $v = json_decode ( $veList ['staff'] );
  5383. array_push ( $v [0], $veList ['description'] );
  5384. foreach ( $v as $n => $m ) {
  5385. if ($m ['1'] == 'ROLE') {
  5386. $roleInfo = $role->getOne ( array (
  5387. 'where' => 'rid=' . $m [0],
  5388. 'asArray' => true
  5389. ) );
  5390. $v [$n] [1] = $roleInfo ['name'];
  5391. }
  5392. }
  5393. $receiptDetail [$key] ['staff'] = $v;
  5394. $category = $lCategory->getOne ( array (
  5395. 'where' => 'cid=' . $value ['cid'],
  5396. 'asArray' => true
  5397. ) );
  5398. $receiptDetail [$key] ['category'] = $category ['title'];
  5399. }
  5400. // print_r($receiptDetail);
  5401. $data ['receiptDetail'] = $receiptDetail;
  5402. $data ['memu'] = "receipt";
  5403. $data ['staff'] = $this->staff;
  5404. $data ['receiptMemu'] = 'saeaCreate';
  5405. $data ['verifyId'] = $this->verifyId;
  5406. $data ['executeId'] = $this->executeId;
  5407. $this->render ( "/admin/saea_confirm", $data );
  5408. }
  5409. function editReceipt() {
  5410. // edit status 4
  5411. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  5412. Doo::loadClass ( 'XDeode' );
  5413. $XDeode = new XDeode ( 7 );
  5414. $rid = $XDeode->decode ( $ridKey );
  5415. if (empty ( $rid ))
  5416. die ( 'illegal request' );
  5417. // echo $rid.'sd';
  5418. Doo::loadModel ( 'accountItem' );
  5419. Doo::loadModel ( 'verify' );
  5420. Doo::loadModel ( 'receipt' );
  5421. $receipt = new receipt ();
  5422. $verify = new verify ();
  5423. $accountItem = new accountItem ();
  5424. Doo::loadModel ( 'L_category' );
  5425. $lCategory = new L_category ();
  5426. Doo::loadModel ( "role" );
  5427. $role = new role ();
  5428. Doo::loadModel ( 'enclosur' );
  5429. $enclosur = new enclosur ();
  5430. $receiptDetail = $receipt->getOne ( array (
  5431. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  5432. 'asArray' => true
  5433. ) );
  5434. if (empty ( $receiptDetail ))
  5435. die ( 'illegal request' );
  5436. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  5437. $acItem = $accountItem->find ( array (
  5438. 'asArray' => true
  5439. ) );
  5440. $veList = $verify->find ( array (
  5441. 'asArray' => true
  5442. ) );
  5443. foreach ( $veList as $key => $value ) {
  5444. $v = json_decode ( $value ['staff'] );
  5445. $list = array ();
  5446. foreach ( $v as $n => $m ) {
  5447. if ($m ['1'] == 'ROLE') {
  5448. $roleInfo = $role->getOne ( array (
  5449. 'where' => 'rid=' . $m [0],
  5450. 'asArray' => true
  5451. ) );
  5452. $v [$n] [1] = $roleInfo ['name'];
  5453. array_push ( $list, $roleInfo ['name'] );
  5454. } else {
  5455. array_push ( $list, $v [$n] [1] );
  5456. }
  5457. }
  5458. $veList [$key] ['staff'] = implode ( '>', $list );
  5459. }
  5460. // 配置编辑信息
  5461. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  5462. foreach ( $acItem as $key => $value ) {
  5463. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  5464. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  5465. $acItem [$key] ['price'] = $v ['price'];
  5466. }
  5467. }
  5468. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  5469. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  5470. $acItem [$key] ['price'] = $v ['price'];
  5471. }
  5472. }
  5473. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  5474. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  5475. $acItem [$key] ['price'] = $v ['price'];
  5476. }
  5477. }
  5478. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  5479. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  5480. $acItem [$key] ['price'] = $v ['price'];
  5481. }
  5482. }
  5483. }
  5484. $data ['category'] = $lCategory->find ( array (
  5485. 'asArray' => true
  5486. ) );
  5487. $data ['cSum'] = $accountItemList ['cSum'];
  5488. $data ['sum'] = $receiptDetail ['sum'];
  5489. $data ['enclosurList'] = $enclosurList;
  5490. $data ['receiptDetail'] = $receiptDetail;
  5491. $data ['veList'] = $veList;
  5492. $data ['acItem'] = $acItem;
  5493. $data ['memu'] = "receipt";
  5494. $data ['staff'] = $this->staff;
  5495. $data ['receiptMemu'] = 'saeaBorad';
  5496. $data ['verify'] = $receiptDetail ['verify'];
  5497. $data ['verifyId'] = $this->verifyId;
  5498. $data ['executeId'] = $this->executeId;
  5499. $data ['rid'] = $ridKey;
  5500. $this->render ( "/admin/saea_edit", $data );
  5501. }
  5502. function updateReceipt() {
  5503. $agency = $this->get_args ( 'agency' );
  5504. $travel = $this->get_args ( 'travel' );
  5505. $train = $this->get_args ( 'train' );
  5506. $other = $this->get_args ( 'other' );
  5507. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5508. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5509. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5510. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  5511. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  5512. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  5513. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  5514. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  5515. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  5516. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  5517. Doo::loadClass ( 'XDeode' );
  5518. $XDeode = new XDeode ( 7 );
  5519. $rid = $XDeode->decode ( $ridKey );
  5520. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  5521. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  5522. header ( 'Content-Type:text/html;charset=utf-8' );
  5523. die ( '请填写联行号' );
  5524. }
  5525. Doo::loadModel ( 'receipt' );
  5526. Doo::loadModel ( 'receiptDetail' );
  5527. Doo::loadModel ( 'accountItem' );
  5528. $accountItem = new accountItem ();
  5529. $receipt = new receipt ();
  5530. Doo::loadModel ( 'enclosur' );
  5531. Doo::loadModel ( 'execute' );
  5532. $execute = new execute ();
  5533. $receiptDetail = $receipt->getOne ( array (
  5534. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  5535. 'asArray' => true
  5536. ) );
  5537. if (empty ( $receiptDetail ))
  5538. return "/saeaBorad";
  5539. if ($receiptDetail ['Rtype'] == 1)
  5540. $executeDetail = $execute->getOne ( array (
  5541. 'where' => 'mold="借款费用执行人"',
  5542. 'asArray' => true
  5543. ) );
  5544. else
  5545. $executeDetail = $execute->getOne ( array (
  5546. 'where' => 'mold="报销单执行人"',
  5547. 'asArray' => true
  5548. ) );
  5549. $aItem = $accountItem->find ( array (
  5550. 'asArray' => true
  5551. ) );
  5552. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5553. $ag = $tr = $ta = $ot = 0;
  5554. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5555. foreach ( $aItem as $key => $value ) {
  5556. if ($value ['category'] == $this->AGENCY) {
  5557. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5558. array_push ( $accountJson [$this->AGENCY], array (
  5559. 'aid' => $value ['aid'],
  5560. 'name' => $value ['name'],
  5561. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5562. ) );
  5563. $sum += $agency [$ag];
  5564. $agencySum += $agency [$ag];
  5565. }
  5566. $ag ++;
  5567. }
  5568. if ($value ['category'] == $this->TRAVEL) {
  5569. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5570. array_push ( $accountJson [$this->TRAVEL], array (
  5571. 'aid' => $value ['aid'],
  5572. 'name' => $value ['name'],
  5573. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5574. ) );
  5575. $sum += $travel [$tr];
  5576. $travelSum += $travel [$tr];
  5577. }
  5578. $tr ++;
  5579. }
  5580. if ($value ['category'] == $this->TRAIN) {
  5581. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5582. array_push ( $accountJson [$this->TRAIN], array (
  5583. 'aid' => $value ['aid'],
  5584. 'name' => $value ['name'],
  5585. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5586. ) );
  5587. $sum += $train [$ta];
  5588. $trainSum += $train [$ta];
  5589. }
  5590. $ta ++;
  5591. }
  5592. if ($value ['category'] == $this->OTHER) {
  5593. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5594. array_push ( $accountJson [$this->OTHER], array (
  5595. 'aid' => $value ['aid'],
  5596. 'name' => $value ['name'],
  5597. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5598. ) );
  5599. $sum += $other [$ot];
  5600. $otherSum += $other [$ot];
  5601. }
  5602. $ot ++;
  5603. }
  5604. }
  5605. $accountJson ['cSum'] = array (
  5606. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5607. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5608. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5609. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5610. );
  5611. // 报销单
  5612. $rid = $receipt->rid = $receiptDetail ['rid'];
  5613. $receipt->accountItem = json_encode ( $accountJson );
  5614. $receipt->staff = $this->staff [0] ['sid'];
  5615. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5616. $receipt->date = date ( "Y-m-d" );
  5617. $receipt->cid = $cid;
  5618. if (($receiptDetail ['status'] != 4)) {
  5619. if ($receiptDetail ['Rtype'] == 1)
  5620. $receipt->status = 7;
  5621. else
  5622. $receipt->status = 5;
  5623. }
  5624. if ($receiptDetail != 4 && ! empty ( $verify ))
  5625. $receipt->verify = $verify;
  5626. $receipt->executeCopy = $executeDetail ['staff'];
  5627. $receipt->explanation = $explanation;
  5628. $receipt->remittanceName = $remittanceName;
  5629. $receipt->bankName = $bankName;
  5630. $receipt->bankNumber = $bankNumber;
  5631. $receipt->remittanceBankType = $remittanceBankType;
  5632. if ($remittanceBankType == 1)
  5633. $receipt->coupletNumber = $coupletNumber;
  5634. $receipt->update ();
  5635. $receiptDetail = new receiptDetail ();
  5636. $receiptDetail->delete ( array (
  5637. 'where' => 'rid=' . $rid
  5638. ) );
  5639. // 报销详情
  5640. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5641. $receiptDetail = new receiptDetail ();
  5642. $receiptDetail->staff = $this->staff [0] ['sid'];
  5643. $receiptDetail->item = $value ['name'];
  5644. $receiptDetail->itemCategory = $this->AGENCY;
  5645. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5646. $receiptDetail->date = date ( "Y-m-d" );
  5647. $receiptDetail->cid = $cid;
  5648. $receiptDetail->rid = $rid;
  5649. $receiptDetail->status = 4;
  5650. $receiptDetail->insert ();
  5651. }
  5652. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5653. $receiptDetail = new receiptDetail ();
  5654. $receiptDetail->staff = $this->staff [0] ['sid'];
  5655. $receiptDetail->item = $value ['name'];
  5656. $receiptDetail->itemCategory = $this->TRAVEL;
  5657. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5658. $receiptDetail->date = date ( "Y-m-d" );
  5659. $receiptDetail->cid = $cid;
  5660. $receiptDetail->rid = $rid;
  5661. $receiptDetail->status = 4;
  5662. $receiptDetail->insert ();
  5663. }
  5664. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5665. $receiptDetail = new receiptDetail ();
  5666. $receiptDetail->staff = $this->staff [0] ['sid'];
  5667. $receiptDetail->item = $value ['name'];
  5668. $receiptDetail->itemCategory = $this->TRAIN;
  5669. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5670. $receiptDetail->date = date ( "Y-m-d" );
  5671. $receiptDetail->cid = $cid;
  5672. $receiptDetail->rid = $rid;
  5673. $receiptDetail->status = 4;
  5674. $receiptDetail->insert ();
  5675. }
  5676. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5677. $receiptDetail = new receiptDetail ();
  5678. $receiptDetail->staff = $this->staff [0] ['sid'];
  5679. $receiptDetail->item = $value ['name'];
  5680. $receiptDetail->itemCategory = $this->OTHER;
  5681. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5682. $receiptDetail->date = date ( "Y-m-d" );
  5683. $receiptDetail->cid = $cid;
  5684. $receiptDetail->rid = $rid;
  5685. $receiptDetail->status = 4;
  5686. $receiptDetail->insert ();
  5687. }
  5688. // 附件
  5689. if (! empty ( $enclosurName )) {
  5690. $enclosurArray = explode ( '-', $enclosurName );
  5691. foreach ( $enclosurArray as $value ) {
  5692. $enclosur = new enclosur ();
  5693. $enclosur->name = $value;
  5694. $enclosur->rid = $rid;
  5695. $enclosur->insert ();
  5696. }
  5697. }
  5698. // return "/referReceipt/".$rid;
  5699. }
  5700. return "/saeaBorad";
  5701. }
  5702. function approvedReceipt() {
  5703. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5704. Doo::loadModel ( 'receipt' );
  5705. Doo::loadModel ( 'receiptDetail' );
  5706. $receipt = new receipt ();
  5707. $receiptDetail = new receiptDetail ();
  5708. Doo::loadModel ( 'statistics' );
  5709. Doo::loadModel ( 'itemStatistics' );
  5710. $statistics = new statistics ();
  5711. $itemStatistics = new itemStatistics ();
  5712. Doo::loadModel ( "verify" );
  5713. $verify = new verify ();
  5714. // 审批状态的判定
  5715. $receiptDetailList = $receipt->getOne ( array (
  5716. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  5717. 'asArray' => true
  5718. ) );
  5719. if (empty ( $receiptDetailList ))
  5720. return "/saeaBorad";
  5721. $verifyDetail = $verify->getOne ( array (
  5722. 'where' => ' vid =' . $receiptDetailList ['verify'],
  5723. 'asArray' => true
  5724. ) );
  5725. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5726. if (empty ( $receiptDetailList ['nowStaff'] )) {
  5727. $nowStaff = "";
  5728. $nowStaffList = array ();
  5729. if ($verifyDetail [0] [1] == 'ROLE') {
  5730. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5731. foreach ( $vStaffString as $key => $value ) {
  5732. $staffK = explode ( "_", $value );
  5733. array_push ( $nowStaffList, $staffK [0] );
  5734. }
  5735. $nowStaff = implode ( ',', $nowStaffList );
  5736. } else {
  5737. $nowStaff = $verifyDetail [0] [0];
  5738. }
  5739. $receipt->nowStaff = $nowStaff;
  5740. }
  5741. // echo $nowStaff;
  5742. // print_r($verifyDetail);die;
  5743. $receipt->rid = $receiptDetailList ['rid'];
  5744. $receipt->date = date ( "Y-m-d" );
  5745. $receipt->status = 2;
  5746. $receipt->update ();
  5747. $receiptDetail->status = 2;
  5748. $receiptDetail->update ( array (
  5749. 'where' => 'rid=' . $receiptDetailList ['rid']
  5750. ) );
  5751. Doo::loadModel ( "receiptLog" );
  5752. $receiptLog = new receiptLog ();
  5753. Doo::loadModel ( "verify" );
  5754. $verify = new verify ();
  5755. $receiptInfo = $receipt->getOne ( array (
  5756. 'where' => 'rid=' . $rid,
  5757. 'asArray' => true
  5758. ) );
  5759. $vr = $verify->getOne ( array (
  5760. 'where' => 'vid=' . $receiptInfo ['verify'],
  5761. 'asArray' => true
  5762. ) );
  5763. $jd = json_decode ( $vr ['staff'] );
  5764. $roleId = 0;
  5765. foreach ( $jd as $key => $value ) {
  5766. if ($value [1] == 'ROLE') {
  5767. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  5768. if ($pos !== false) {
  5769. $roleId = $value [0];
  5770. }
  5771. }
  5772. }
  5773. // 审批日志
  5774. // echo $roleId;die;
  5775. if (! empty ( $roleId )) {
  5776. Doo::loadModel ( "role" );
  5777. $role = new role ();
  5778. $roleInfo = $role->getOne ( array (
  5779. 'where' => 'rid=' . $roleId,
  5780. 'asArray' => true
  5781. ) );
  5782. $receiptLog->rolename = $roleInfo ['name'];
  5783. }
  5784. $receiptLog->username = $this->staff [0] ['username'];
  5785. $receiptLog->uid = $this->staff [0] ['sid'];
  5786. $receiptLog->date = date ( "Y-m-d" );
  5787. $receiptLog->opinion = '提交审批';
  5788. $receiptLog->img = $this->staff [0] ['avatar'];
  5789. $receiptLog->status = 2;
  5790. $receiptLog->rid = $rid;
  5791. $receiptLog->insert ();
  5792. // statistics item
  5793. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  5794. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  5795. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  5796. $stat = $statistics->getOne ( array (
  5797. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5798. 'asArray' => true
  5799. ) );
  5800. if (empty ( $stat )) {
  5801. $statistics->date = date ( "Y-m-d" );
  5802. $statistics->cid = $this->staff [0] ['cid'];
  5803. $statistics->staff = $this->staff [0] ['sid'];
  5804. $statistics->agPrice = 0;
  5805. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5806. $statistics->insert ();
  5807. } else {
  5808. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5809. $statistics->update ( array (
  5810. 'where' => 'sid=' . $stat ['sid']
  5811. ) );
  5812. }
  5813. return "/expenses";
  5814. }
  5815. function approval() {
  5816. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5817. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5818. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5819. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5820. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5821. if (empty ( $status ))
  5822. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5823. $vidList = array ();
  5824. $button = 0;
  5825. Doo::loadModel ( 'verify' );
  5826. $verify = new verify ();
  5827. Doo::loadModel ( 'receipt' );
  5828. $receipt = new receipt ();
  5829. Doo::loadModel ( 'staff' );
  5830. $staff = new staff ();
  5831. Doo::loadModel ( 'L_category' );
  5832. $Lcategory = new L_category ();
  5833. // user verify ID
  5834. $verifyDetail = $verify->find ( array (
  5835. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5836. 'asArray' => true
  5837. ) );
  5838. foreach ( $verifyDetail as $key => $value ) {
  5839. array_push ( $vidList, $value ['vid'] );
  5840. }
  5841. $vid = implode ( ",", $vidList );
  5842. if (empty ( $verifyDetail ))
  5843. $vid = 0;
  5844. /*
  5845. */
  5846. $dateCondition = " and Year(date) =" . $year;
  5847. if (! empty ( $month ))
  5848. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  5849. $categoryList = $Lcategory->find ( array (
  5850. 'asArray' => true
  5851. ) );
  5852. $staffList = $staff->find ( array (
  5853. 'where' => 'cid=' . $cid,
  5854. 'asArray' => true
  5855. ) );
  5856. $cateCondition = "";
  5857. $staffCondition = "";
  5858. $approvalCondition = "";
  5859. if (! empty ( $cid ))
  5860. $cateCondition = ' and cid=' . $cid;
  5861. if (! empty ( $sid )) {
  5862. $staffCondition = ' and staff=' . $sid;
  5863. $cateCondition = "";
  5864. }
  5865. // elseif($status==1){
  5866. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  5867. // }
  5868. if ($status == 2) {
  5869. // 查找角色审批人
  5870. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  5871. }
  5872. $ap = "";
  5873. if ($status == 4) {
  5874. $ap = 4;
  5875. $status = 2;
  5876. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  5877. }
  5878. if ($status == 5) {
  5879. $status = 4;
  5880. $ap = 5;
  5881. }
  5882. // echo $vid;
  5883. // get Receipt By verifyID status 2 .$approvalCondition
  5884. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  5885. $receiptList = $receipt->find ( array (
  5886. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  5887. 'desc' => 'rid',
  5888. 'asArray' => true
  5889. ) );
  5890. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  5891. $Locate = 0;
  5892. if ($ap == 4)
  5893. $status = 4;
  5894. elseif ($ap == 5)
  5895. $status = 5;
  5896. foreach ( $receiptList as $key => $value ) {
  5897. $receiptList [$key] ['Locate'] = $Locate;
  5898. $Locate ++;
  5899. $receiptList [$key] ['reviseDetail'] = array ();
  5900. if (! empty ( $value ['reviseDetail'] ))
  5901. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5902. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5903. $categoryDetil = $Lcategory->getOne ( array (
  5904. 'where' => 'cid=' . $value ['cid'],
  5905. 'asArray' => true
  5906. ) );
  5907. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5908. $verifyList = $verify->getOne ( array (
  5909. 'where' => 'vid=' . $value ['verify'],
  5910. 'asArray' => true
  5911. ) );
  5912. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5913. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5914. foreach ( $verifyList as $k => $v ) {
  5915. // init verifyStaff
  5916. $verifyList [$k] ['date'] = "";
  5917. $verifyList [$k] ['opinion'] = "";
  5918. $verifyList [$k] ['status'] = "";
  5919. if (empty ( $verifyStaff )) {
  5920. $verifyList [$k] ['date'] = "";
  5921. $verifyList [$k] ['opinion'] = "";
  5922. if ($v [0] == $this->staff [0] ['sid']) {
  5923. $verifyList [$k] ['status'] = 4;
  5924. $button = 4;
  5925. }
  5926. } else {
  5927. $flag = true;
  5928. foreach ( $verifyStaff as $m => $u ) {
  5929. if ($v [0] == $m) {
  5930. $verifyList [$k] ['date'] = $u ['date'];
  5931. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5932. $verifyList [$k] ['status'] = $u ['status'];
  5933. $flag = false;
  5934. break;
  5935. }
  5936. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  5937. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  5938. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  5939. }
  5940. if ($flag) { // 检测可编辑
  5941. if ($v [0] == $this->staff [0] ['sid']) {
  5942. $verifyList [$k] ['status'] = 4;
  5943. $button = 4;
  5944. }
  5945. }
  5946. }
  5947. }
  5948. $receiptList [$key] ['verifyList'] = $verifyList;
  5949. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5950. 'where' => 'sid=' . $value ['staff'],
  5951. 'asArray' => true
  5952. ) );
  5953. $receiptList [$key] ['button'] = $button;
  5954. }
  5955. // print_r($receiptList);die;
  5956. // $data['verifyDetail']=$verifyDetail;
  5957. $mothHtml = "";
  5958. for($i = 1; $i <= 12; $i ++) {
  5959. if ($month == $i)
  5960. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5961. else
  5962. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5963. }
  5964. $data ['mothHtml'] = $mothHtml;
  5965. $data ['receiptList'] = $receiptList;
  5966. $data ['receiptApprovalCount'] = count ( $receiptList );
  5967. $data ['status'] = $status;
  5968. $data ['year'] = $year;
  5969. $data ['categoryList'] = $categoryList;
  5970. $data ['staffList'] = $staffList;
  5971. $data ['cid'] = $cid;
  5972. $data ['sid'] = $sid;
  5973. $data ['ap'] = $ap;
  5974. $data ['memu'] = "receipt";
  5975. $data ['staff'] = $this->staff;
  5976. $data ['receiptMemu'] = 'approval';
  5977. $data ['verifyId'] = $this->verifyId;
  5978. $data ['executeId'] = $this->executeId;
  5979. $this->render ( "/admin/saea_reportList", $data );
  5980. }
  5981. function approvalDetails() {
  5982. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5983. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5984. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5985. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5986. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5987. Doo::loadModel ( 'verify' );
  5988. $verify = new verify ();
  5989. Doo::loadModel ( 'receipt' );
  5990. $receipt = new receipt ();
  5991. Doo::loadModel ( 'staff' );
  5992. $staff = new staff ();
  5993. Doo::loadModel ( 'L_category' );
  5994. $Lcategory = new L_category ();
  5995. Doo::loadModel ( 'enclosur' );
  5996. $enclosur = new enclosur ();
  5997. $vidList = array ();
  5998. $verifyDetail = $verify->find ( array (
  5999. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6000. 'asArray' => true
  6001. ) );
  6002. foreach ( $verifyDetail as $key => $value ) {
  6003. array_push ( $vidList, $value ['vid'] );
  6004. }
  6005. $vid = implode ( ",", $vidList );
  6006. if (empty ( $verifyDetail ))
  6007. $vid = 0;
  6008. $categoryList = $Lcategory->find ( array (
  6009. 'asArray' => true
  6010. ) );
  6011. $staffList = $staff->find ( array (
  6012. 'where' => 'cid=' . $cid,
  6013. 'asArray' => true
  6014. ) );
  6015. $ap = 0;
  6016. $receiptList = $receipt->find ( array (
  6017. 'where' => 'rid =' . $rid,
  6018. 'desc' => 'rid',
  6019. 'asArray' => true
  6020. ) );
  6021. $Locate = 0;
  6022. $roleId = 0;
  6023. $button = 0;
  6024. foreach ( $receiptList as $key => $value ) {
  6025. $receiptList [$key] ['Locate'] = $Locate;
  6026. $Locate ++;
  6027. $receiptList [$key] ['reviseDetail'] = array ();
  6028. if (! empty ( $value ['reviseDetail'] ))
  6029. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6030. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6031. $categoryDetil = $Lcategory->getOne ( array (
  6032. 'where' => 'cid=' . $value ['cid'],
  6033. 'asArray' => true
  6034. ) );
  6035. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6036. // 检测编辑状态
  6037. $verifyList = $verify->getOne ( array (
  6038. 'where' => 'vid=' . $value ['verify'],
  6039. 'asArray' => true
  6040. ) );
  6041. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6042. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6043. Doo::loadModel ( 'role' );
  6044. $role = new role ();
  6045. // print_r($verifyList);
  6046. $flag = true;
  6047. $roleKey = 0;
  6048. $endStaffArray = array ();
  6049. $roleArrayCopy = array ();
  6050. foreach ( $verifyList as $k => $v ) {
  6051. // init verifyStaff
  6052. if ($v [1] == 'ROLE') {
  6053. if (! empty ( $verifyStaff )) {
  6054. $endStaffArray = end ( $verifyStaff );
  6055. if ($v [0] == $endStaffArray ['nextStaff']) {
  6056. $roleId = $v [0];
  6057. }
  6058. }
  6059. $roleVerify = json_decode ( $v [3], true );
  6060. $roleKey = $k;
  6061. $roleArray = array ();
  6062. $rolename = $role->getOne ( array (
  6063. 'where' => 'rid=' . $v [0],
  6064. 'asArray' => true
  6065. ) );
  6066. foreach ( $roleVerify as $o => $p ) {
  6067. $staffID = explode ( '_', $p );
  6068. $staffInfo = $staff->getOne ( array (
  6069. 'where' => 'sid=' . $staffID [0],
  6070. 'asArray' => true
  6071. ) );
  6072. // print_r($staffID);
  6073. $exp = array (
  6074. 0 => $staffInfo ['sid'],
  6075. 1 => $staffID [1],
  6076. 2 => $staffInfo ['avatar'],
  6077. 'date' => '',
  6078. 'date' => '',
  6079. 'opinion' => '',
  6080. 'status' => '',
  6081. 'rolename' => $rolename ['name']
  6082. );
  6083. array_push ( $roleArray, $exp );
  6084. }
  6085. $roleArrayCopy [$v [0]] = $roleArray;
  6086. // $verifyList[$k]['roleArray']=$roleArray;
  6087. }
  6088. // print_r($roleArray);
  6089. $verifyList [$k] ['date'] = "";
  6090. $verifyList [$k] ['opinion'] = "";
  6091. $verifyList [$k] ['status'] = "";
  6092. if (empty ( $verifyStaff )) {
  6093. $verifyList [$k] ['date'] = "";
  6094. $verifyList [$k] ['opinion'] = "";
  6095. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6096. $verifyList [$k] ['status'] = 4;
  6097. $button = 4;
  6098. $flag = false;
  6099. }
  6100. } else {
  6101. foreach ( $verifyStaff as $m => $u ) {
  6102. if ($v [0] == $m) {
  6103. $verifyList [$k] ['date'] = $u ['date'];
  6104. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6105. $verifyList [$k] ['status'] = $u ['status'];
  6106. $flag = false;
  6107. break;
  6108. }
  6109. }
  6110. $endStaffArray = end ( $verifyStaff );
  6111. if (isset ( $endStaffArray ['ROLE'] )) {
  6112. } else {
  6113. $endKey = key ( $verifyStaff );
  6114. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6115. $button = 4;
  6116. $verifyList [$k] ['status'] = 4;
  6117. }
  6118. }
  6119. }
  6120. }
  6121. $rolename ['name'] = '';
  6122. if (! empty ( $roleId )) {
  6123. Doo::loadModel ( 'role' );
  6124. $role = new role ();
  6125. $rolename = $role->getOne ( array (
  6126. 'where' => 'rid=' . $roleId,
  6127. 'asArray' => true
  6128. ) );
  6129. }
  6130. if (! empty ( $verifyStaff ))
  6131. $endStaffArray = end ( $verifyStaff );
  6132. $KOP = false;
  6133. foreach ( $roleArrayCopy as $P => $A ) {
  6134. foreach ( $A as $MKI => $AVL ) {
  6135. if (! empty ( $verifyStaff )) {
  6136. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6137. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6138. $button = 4;
  6139. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6140. }
  6141. foreach ( $verifyStaff as $m => $u ) {
  6142. $AVLFK = $AVL [0] . '_R';
  6143. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6144. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6145. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6146. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6147. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6148. break;
  6149. }
  6150. }
  6151. } else {
  6152. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6153. $button = 4;
  6154. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6155. }
  6156. }
  6157. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6158. $KOP = true;
  6159. }
  6160. }
  6161. foreach ( $roleArrayCopy as $k => $v ) {
  6162. foreach ( $verifyList as $m => $n ) {
  6163. if ($n [0] == $k) {
  6164. array_splice ( $verifyList, $m, 1, $v );
  6165. }
  6166. }
  6167. }
  6168. $receiptList [$key] ['verifyList'] = $verifyList;
  6169. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6170. 'where' => 'sid=' . $value ['staff'],
  6171. 'asArray' => true
  6172. ) );
  6173. $receiptList [$key] ['button'] = $button;
  6174. }
  6175. $mothHtml = "";
  6176. for($i = 1; $i <= 12; $i ++) {
  6177. if ($month == $i)
  6178. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6179. else
  6180. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6181. }
  6182. // 获取审批日志
  6183. Doo::loadModel ( 'receiptLog' );
  6184. $receiptLog = new receiptLog ();
  6185. $rlList = array ();
  6186. $rlInfo = $receiptLog->getOne ( array (
  6187. 'where' => 'rid=' . $rid . ' and status=4',
  6188. 'asArray' => true
  6189. ) );
  6190. $tijdate = $receiptLog->getOne ( array (
  6191. 'where' => 'rid=' . $rid . ' and status=2',
  6192. 'asc' => 'rlid',
  6193. 'asArray' => true
  6194. ) );
  6195. if (! empty ( $rlInfo )) {
  6196. $rlList = $receiptLog->find ( array (
  6197. 'where' => 'rid=' . $rid,
  6198. 'asc' => 'rlid',
  6199. 'asArray' => true
  6200. ) );
  6201. }
  6202. $receiptList [0] ['rlList'] = $rlList;
  6203. $enclosurList = $enclosur->find ( array (
  6204. 'where' => 'rid=' . $rid,
  6205. 'asArray' => true
  6206. ) );
  6207. $enclosurHtml = '';
  6208. foreach ( $enclosurList as $value ) {
  6209. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6210. }
  6211. $data ['enclosurHtml'] = $enclosurHtml;
  6212. $data ['rolename'] = $rolename ['name'];
  6213. $data ['datetij'] = $tijdate ['date'];
  6214. $data ['mothHtml'] = $mothHtml;
  6215. $data ['receiptList'] = $receiptList;
  6216. $data ['receiptApprovalCount'] = count ( $receiptList );
  6217. $data ['year'] = $year;
  6218. $data ['categoryList'] = $categoryList;
  6219. $data ['staffList'] = $staffList;
  6220. $data ['cid'] = $cid;
  6221. $data ['sid'] = $sid;
  6222. $data ['status'] = 0;
  6223. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  6224. $ap = 4;
  6225. } else
  6226. $data ['status'] = $receiptList [0] ['status'];
  6227. if ($receiptList [0] ['status'] == 4) {
  6228. $data ['status'] = 5;
  6229. $ap = 0;
  6230. }
  6231. $data ['ap'] = $ap;
  6232. $data ['memu'] = "receipt";
  6233. $data ['staff'] = $this->staff;
  6234. $data ['receiptMemu'] = 'approval';
  6235. $data ['verifyId'] = $this->verifyId;
  6236. $data ['executeId'] = $this->executeId;
  6237. $this->render ( "/admin/saeaReportListReport", $data );
  6238. }
  6239. function approvalEdi() {
  6240. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6241. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  6242. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6243. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6244. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6245. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6246. if (empty ( $status ))
  6247. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  6248. $vidList = array ();
  6249. $button = 0;
  6250. Doo::loadModel ( 'verify' );
  6251. Doo::loadModel ( 'receipt' );
  6252. Doo::loadModel ( 'staff' );
  6253. $staff = new staff ();
  6254. $receipt = new receipt ();
  6255. $verify = new verify ();
  6256. Doo::loadModel ( 'L_category' );
  6257. $Lcategory = new L_category ();
  6258. Doo::loadModel ( 'enclosur' );
  6259. $enclosur = new enclosur ();
  6260. // user verify ID
  6261. $verifyDetail = $verify->find ( array (
  6262. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6263. 'asArray' => true
  6264. ) );
  6265. foreach ( $verifyDetail as $key => $value ) {
  6266. array_push ( $vidList, $value ['vid'] );
  6267. }
  6268. $vid = implode ( ",", $vidList );
  6269. if (empty ( $verifyDetail ))
  6270. $vid = 0;
  6271. $categoryList = $Lcategory->find ( array (
  6272. 'asArray' => true
  6273. ) );
  6274. $staffList = $staff->find ( array (
  6275. 'where' => 'cid=' . $cid,
  6276. 'asArray' => true
  6277. ) );
  6278. $ap = "";
  6279. if ($status == 4) {
  6280. $ap = 4;
  6281. $status = 2;
  6282. }
  6283. // get Receipt By verifyID status 2
  6284. $receiptList = $receipt->find ( array (
  6285. 'where' => 'rid =' . $rid,
  6286. 'desc' => 'rid',
  6287. 'asArray' => true
  6288. ) );
  6289. $Locate = 0;
  6290. $roleId = 0;
  6291. if ($ap == 4)
  6292. $status = 4;
  6293. foreach ( $receiptList as $key => $value ) {
  6294. $receiptList [$key] ['Locate'] = $Locate;
  6295. $Locate ++;
  6296. $receiptList [$key] ['reviseDetail'] = array ();
  6297. if (! empty ( $value ['reviseDetail'] ))
  6298. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6299. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6300. $categoryDetil = $Lcategory->getOne ( array (
  6301. 'where' => 'cid=' . $value ['cid'],
  6302. 'asArray' => true
  6303. ) );
  6304. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6305. // 检测编辑状态
  6306. $verifyList = $verify->getOne ( array (
  6307. 'where' => 'vid=' . $value ['verify'],
  6308. 'asArray' => true
  6309. ) );
  6310. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6311. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6312. // print_r($verifyList);
  6313. //
  6314. // if (empty($verifyStaff)){
  6315. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6316. // $verifyList[0]['status']=4;$button=4;
  6317. // }
  6318. //
  6319. // }else{
  6320. //
  6321. // }
  6322. // die;
  6323. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  6324. // echo array_search("green",$a);
  6325. //
  6326. Doo::loadModel ( 'role' );
  6327. $role = new role ();
  6328. // print_r($verifyList);
  6329. $flag = true;
  6330. $roleKey = 0;
  6331. $endStaffArray = array ();
  6332. $roleArrayCopy = array ();
  6333. foreach ( $verifyList as $k => $v ) {
  6334. // init verifyStaff
  6335. if ($v [1] == 'ROLE') {
  6336. if (! empty ( $verifyStaff )) {
  6337. $endStaffArray = end ( $verifyStaff );
  6338. if ($v [0] == $endStaffArray ['nextStaff']) {
  6339. $roleId = $v [0];
  6340. }
  6341. }
  6342. $roleVerify = json_decode ( $v [3], true );
  6343. $roleKey = $k;
  6344. $roleArray = array ();
  6345. $rolename = $role->getOne ( array (
  6346. 'where' => 'rid=' . $v [0],
  6347. 'asArray' => true
  6348. ) );
  6349. foreach ( $roleVerify as $o => $p ) {
  6350. $staffID = explode ( '_', $p );
  6351. $staffInfo = $staff->getOne ( array (
  6352. 'where' => 'sid=' . $staffID [0],
  6353. 'asArray' => true
  6354. ) );
  6355. // print_r($staffID);
  6356. $exp = array (
  6357. 0 => $staffInfo ['sid'],
  6358. 1 => $staffID [1],
  6359. 2 => $staffInfo ['avatar'],
  6360. 'date' => '',
  6361. 'date' => '',
  6362. 'opinion' => '',
  6363. 'status' => '',
  6364. 'rolename' => $rolename ['name']
  6365. );
  6366. array_push ( $roleArray, $exp );
  6367. }
  6368. $roleArrayCopy [$v [0]] = $roleArray;
  6369. // $verifyList[$k]['roleArray']=$roleArray;
  6370. }
  6371. // print_r($roleArray);
  6372. $verifyList [$k] ['date'] = "";
  6373. $verifyList [$k] ['opinion'] = "";
  6374. $verifyList [$k] ['status'] = "";
  6375. if (empty ( $verifyStaff )) {
  6376. $verifyList [$k] ['date'] = "";
  6377. $verifyList [$k] ['opinion'] = "";
  6378. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6379. $verifyList [$k] ['status'] = 4;
  6380. $button = 4;
  6381. $flag = false;
  6382. }
  6383. } else {
  6384. foreach ( $verifyStaff as $m => $u ) {
  6385. if ($v [0] == $m) {
  6386. $verifyList [$k] ['date'] = $u ['date'];
  6387. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6388. $verifyList [$k] ['status'] = $u ['status'];
  6389. $flag = false;
  6390. break;
  6391. }
  6392. }
  6393. $endStaffArray = end ( $verifyStaff );
  6394. if (isset ( $endStaffArray ['ROLE'] )) {
  6395. } else {
  6396. $endKey = key ( $verifyStaff );
  6397. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6398. $button = 4;
  6399. $verifyList [$k] ['status'] = 4;
  6400. }
  6401. }
  6402. // print_r($endStaffArray);die;
  6403. // if (empty($verifyStaff)){
  6404. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6405. // $verifyList[$k]['status']=4;$button=4;
  6406. // }
  6407. //
  6408. // }else{
  6409. //
  6410. // }
  6411. // if($flag){//检测可编辑
  6412. // if($v[0]==$this->staff[0]['sid']){
  6413. // $verifyList[$k]['status']=4;$button=4;
  6414. // }
  6415. // }
  6416. }
  6417. }
  6418. $rolename ['name'] = '';
  6419. if (! empty ( $roleId )) {
  6420. Doo::loadModel ( 'role' );
  6421. $role = new role ();
  6422. $rolename = $role->getOne ( array (
  6423. 'where' => 'rid=' . $roleId,
  6424. 'asArray' => true
  6425. ) );
  6426. }
  6427. if (! empty ( $verifyStaff ))
  6428. $endStaffArray = end ( $verifyStaff );
  6429. $KOP = false;
  6430. foreach ( $roleArrayCopy as $P => $A ) {
  6431. foreach ( $A as $MKI => $AVL ) {
  6432. if (! empty ( $verifyStaff )) {
  6433. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6434. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6435. $button = 4;
  6436. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6437. }
  6438. foreach ( $verifyStaff as $m => $u ) {
  6439. $AVLFK = $AVL [0] . '_R';
  6440. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6441. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6442. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6443. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6444. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6445. break;
  6446. }
  6447. }
  6448. } else {
  6449. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6450. $button = 4;
  6451. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6452. }
  6453. }
  6454. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6455. $KOP = true;
  6456. }
  6457. }
  6458. // print_r($roleArrayCopy);
  6459. // echo $roleKey;
  6460. foreach ( $roleArrayCopy as $k => $v ) {
  6461. foreach ( $verifyList as $m => $n ) {
  6462. if ($n [0] == $k) {
  6463. array_splice ( $verifyList, $m, 1, $v );
  6464. }
  6465. }
  6466. }
  6467. // if ($KOP)
  6468. // array_splice($verifyList,$roleKey,1,$roleArray);
  6469. // print_r($verifyList);
  6470. $receiptList [$key] ['verifyList'] = $verifyList;
  6471. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6472. 'where' => 'sid=' . $value ['staff'],
  6473. 'asArray' => true
  6474. ) );
  6475. $receiptList [$key] ['button'] = $button;
  6476. }
  6477. // $data['verifyDetail']=$verifyDetail;
  6478. $mothHtml = "";
  6479. for($i = 1; $i <= 12; $i ++) {
  6480. if ($month == $i)
  6481. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6482. else
  6483. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6484. }
  6485. // 获取审批日志
  6486. Doo::loadModel ( 'receiptLog' );
  6487. $receiptLog = new receiptLog ();
  6488. $rlList = array ();
  6489. $rlInfo = $receiptLog->getOne ( array (
  6490. 'where' => 'rid=' . $rid . ' and status=4',
  6491. 'asArray' => true
  6492. ) );
  6493. $tijdate = $receiptLog->getOne ( array (
  6494. 'where' => 'rid=' . $rid . ' and status=2',
  6495. 'asc' => 'rlid',
  6496. 'asArray' => true
  6497. ) );
  6498. if (! empty ( $rlInfo )) {
  6499. $rlList = $receiptLog->find ( array (
  6500. 'where' => 'rid=' . $rid,
  6501. 'asc' => 'rlid',
  6502. 'asArray' => true
  6503. ) );
  6504. }
  6505. $receiptList [0] ['rlList'] = $rlList;
  6506. $enclosurList = $enclosur->find ( array (
  6507. 'where' => 'rid=' . $rid,
  6508. 'asArray' => true
  6509. ) );
  6510. $enclosurHtml = '';
  6511. foreach ( $enclosurList as $value ) {
  6512. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6513. }
  6514. $data ['enclosurHtml'] = $enclosurHtml;
  6515. $data ['rolename'] = $rolename ['name'];
  6516. $data ['datetij'] = $tijdate ['date'];
  6517. $data ['mothHtml'] = $mothHtml;
  6518. $data ['receiptList'] = $receiptList;
  6519. $data ['receiptApprovalCount'] = count ( $receiptList );
  6520. $data ['status'] = $status;
  6521. $data ['year'] = $year;
  6522. $data ['categoryList'] = $categoryList;
  6523. $data ['staffList'] = $staffList;
  6524. $data ['cid'] = $cid;
  6525. $data ['sid'] = $sid;
  6526. $data ['ap'] = $ap;
  6527. $data ['memu'] = "receipt";
  6528. $data ['staff'] = $this->staff;
  6529. $data ['receiptMemu'] = 'approval';
  6530. $data ['verifyId'] = $this->verifyId;
  6531. $data ['executeId'] = $this->executeId;
  6532. $this->render ( "/admin/saeaReportListReport", $data );
  6533. }
  6534. function remittanceHky() {
  6535. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6536. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  6537. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6538. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  6539. $page_size = 15;
  6540. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  6541. Doo::loadModel ( 'receipt' );
  6542. $receipt = new receipt ();
  6543. Doo::loadModel ( 'staff' );
  6544. $staff = new staff ();
  6545. $dateCondition = " and Year(executeDate) =" . $year;
  6546. if ($moth != 'MONTH')
  6547. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  6548. if ($day != 'DAY' && $moth != 'MONTH')
  6549. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  6550. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  6551. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  6552. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  6553. $limit = $pageinfo ['lower'] . ',' . $page_size;
  6554. $dayList = $receipt->find ( array (
  6555. 'select' => 'executeDate,sum(amount) as amount',
  6556. 'where' => $sql,
  6557. 'desc' => 'executeDate',
  6558. 'groupby' => 'executeDate',
  6559. 'limit' => $limit,
  6560. 'asArray' => true
  6561. ) );
  6562. // print_r($dayList);
  6563. foreach ( $dayList as $key => $value ) {
  6564. $remitString = "";
  6565. $receiptList = $receipt->find ( array (
  6566. 'select' => 'rid,executeDate,amount,staff,cid',
  6567. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  6568. 'desc' => 'executeDate',
  6569. 'asArray' => true
  6570. ) );
  6571. foreach ( $receiptList as $k => $v ) {
  6572. $sinfo = $staff->getOne ( array (
  6573. 'select' => 'username,category',
  6574. 'where' => ' sid=' . $v ['staff'],
  6575. 'asArray' => true
  6576. ) );
  6577. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  6578. }
  6579. $dayList [$key] ['staff'] = $remitString;
  6580. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  6581. }
  6582. // print_r($dayList);
  6583. $mothHtml = "";
  6584. for($i = 1; $i <= 12; $i ++) {
  6585. if ($moth == $i)
  6586. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6587. else
  6588. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6589. }
  6590. $dayHtml = "";
  6591. if ($day != "DAY" || $moth != "MONTH") {
  6592. for($i = 1; $i <= 31; $i ++) {
  6593. if ($day == $i)
  6594. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6595. else
  6596. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6597. }
  6598. }
  6599. $data ['page'] = $pageinfo;
  6600. $data ['year'] = $year;
  6601. $data ['moth'] = $moth;
  6602. $data ['day'] = $day;
  6603. $data ['get'] = $get;
  6604. $data ['dayHtml'] = $dayHtml;
  6605. $data ['mothHtml'] = $mothHtml;
  6606. $data ['receiptList'] = $dayList;
  6607. $data ['memu'] = "receipt";
  6608. $data ['staff'] = $this->staff;
  6609. $data ['receiptMemu'] = 'remittanceHky';
  6610. $data ['verifyId'] = $this->verifyId;
  6611. $data ['executeId'] = $this->executeId;
  6612. $this->render ( "/admin/remittanceHky", $data );
  6613. }
  6614. function remittancep() {
  6615. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  6616. Doo::loadModel ( 'receipt' );
  6617. $receipt = new receipt ();
  6618. Doo::loadModel ( 'staff' );
  6619. $staff = new staff ();
  6620. Doo::loadClass ( 'XDeode' );
  6621. $XDeode = new XDeode ( 5 );
  6622. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  6623. $rplist = $receipt->find ( array (
  6624. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6625. 'asArray' => true
  6626. ) );
  6627. $dayList = $receipt->find ( array (
  6628. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6629. 'desc' => 'executeDate',
  6630. 'groupby' => 'staff',
  6631. 'asArray' => true
  6632. ) );
  6633. $html = '';
  6634. foreach ( $dayList as $key => $value ) {
  6635. $sinfo = $staff->getOne ( array (
  6636. 'select' => 'username,category',
  6637. 'where' => ' sid=' . $value ['staff'],
  6638. 'asArray' => true
  6639. ) );
  6640. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  6641. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  6642. $au = 0;
  6643. foreach ( $rplist as $k => $v ) {
  6644. if ($value ['staff'] == $v ['staff']) {
  6645. $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>';
  6646. $au += $v ['amount'];
  6647. }
  6648. }
  6649. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  6650. }
  6651. $data ['html'] = $html;
  6652. $data ['memu'] = "receipt";
  6653. $data ['staff'] = $this->staff;
  6654. $data ['receiptMemu'] = 'remittanceHky';
  6655. $data ['verifyId'] = $this->verifyId;
  6656. $data ['executeId'] = $this->executeId;
  6657. $this->render ( "/admin/remittancep", $data );
  6658. }
  6659. function ajaxGetReceiptDetails() {
  6660. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  6661. Doo::loadClass ( 'XDeode' );
  6662. $XDeode = new XDeode ( 5 );
  6663. $rid = $XDeode->decode ( $rid );
  6664. if (empty ( $rid )) {
  6665. echo json_encode ( array (
  6666. 'status' => 2,
  6667. 'msg' => 'illegal request'
  6668. ) );
  6669. die ();
  6670. }
  6671. Doo::loadModel ( 'receipt' );
  6672. $receipt = new receipt ();
  6673. Doo::loadModel ( 'staff' );
  6674. $staff = new staff ();
  6675. $rinfo = $receipt->getOne ( array (
  6676. 'where' => 'rid= ' . $rid,
  6677. 'asArray' => true
  6678. ) );
  6679. $sinfo = $staff->getOne ( array (
  6680. 'select' => 'username,category',
  6681. 'where' => ' sid=' . $rinfo ['staff'],
  6682. 'asArray' => true
  6683. ) );
  6684. $rinfo ['reviseDetail'] = array ();
  6685. if (! empty ( $rinfo ['reviseDetail'] ))
  6686. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  6687. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  6688. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  6689. $rinfo ['category'] = $sinfo ['category'];
  6690. $verifyStaff = array ();
  6691. if (! empty ( $rinfo ['verifyStaff'] ))
  6692. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  6693. $relust = $rinfo ['sum'] - $rinfo ['loanSum'];
  6694. $rinfo ['relust'] = $relust;
  6695. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  6696. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  6697. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  6698. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  6699. // 费用执行人相关数据
  6700. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6701. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6702. foreach ( $executeCopy as $k => $v ) {
  6703. $executeCopy [$k] ['date'] = '';
  6704. $executeCopy [$k] ['opinion'] = '';
  6705. $executeCopy [$k] ['status'] = '';
  6706. if (! empty ( $executeStaff ))
  6707. foreach ( $executeStaff as $m => $u ) {
  6708. if ($v [0] == $m) {
  6709. $executeCopy [$k] ['date'] = $u ['date'];
  6710. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  6711. $executeCopy [$k] ['status'] = $u ['status'];
  6712. break;
  6713. }
  6714. }
  6715. }
  6716. $rinfo ['executeCopy'] = $executeCopy;
  6717. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  6718. if ($rinfo ['Rtype'] == 1) { // 借款费用
  6719. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6720. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  6721. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  6722. $html .= '<tr><th>' . $value ['name'] . '</th>
  6723. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6724. }
  6725. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6726. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6727. <tr><th class="taC" colspan="2">费用说明</th>
  6728. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6729. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6730. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  6731. </tbody></table>';
  6732. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  6733. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6734. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6735. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6736. $html .= '<tr><th>' . $value ['name'] . '</th>
  6737. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6738. }
  6739. $html .= '<tr><th class="taR">合计</th>
  6740. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6741. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6742. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6743. $html .= '<tr><th>' . $value ['name'] . '</th>
  6744. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6745. }
  6746. $html .= '<tr><th class="taR">合计</th>
  6747. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6748. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6749. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6750. $html .= '<tr><th>' . $value ['name'] . '</th>
  6751. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6752. }
  6753. $html .= '<tr><th class="taR">合计</th>
  6754. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6755. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6756. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6757. $html .= '<tr><th>' . $value ['name'] . '</th>
  6758. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6759. }
  6760. $html .= '<tr><th class="taR">合计</th>
  6761. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6762. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6763. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6764. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6765. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6766. }
  6767. $html .= '<tr><th class="taR">合计</th>
  6768. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6769. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6770. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6771. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6772. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6773. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6774. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6775. <tr';
  6776. if ($rinfo ['relust'] >= 0) {
  6777. $html .= 'class="success"';
  6778. } else {
  6779. $html .= 'class="error"';
  6780. }
  6781. $html .= '><td class="taR"><b>借款结余</b></td>
  6782. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  6783. </tbody></table>
  6784. ';
  6785. }
  6786. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  6787. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6788. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  6789. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6790. $html .= '<tr><th>' . $value ['name'] . '</th>
  6791. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6792. }
  6793. $html .= '<tr><th class="taR">合计</th>
  6794. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6795. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6796. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6797. <tr><th class="taC" colspan="2">费用说明</th>
  6798. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6799. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6800. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6801. </tbody></table>';
  6802. } else {
  6803. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6804. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6805. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6806. $html .= '<tr><th>' . $value ['name'] . '</th>
  6807. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6808. }
  6809. $html .= '<tr><th class="taR">合计</th>
  6810. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6811. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6812. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6813. $html .= '<tr><th>' . $value ['name'] . '</th>
  6814. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6815. }
  6816. $html .= '<tr><th class="taR">合计</th>
  6817. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6818. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6819. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6820. $html .= '<tr><th>' . $value ['name'] . '</th>
  6821. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6822. }
  6823. $html .= '<tr><th class="taR">合计</th>
  6824. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6825. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6826. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6827. $html .= '<tr><th>' . $value ['name'] . '</th>
  6828. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6829. }
  6830. $html .= '<tr><th class="taR">合计</th>
  6831. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6832. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6833. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6834. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6835. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6836. }
  6837. $html .= '<tr><th class="taR">合计</th>
  6838. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6839. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6840. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6841. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6842. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6843. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6844. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  6845. $html .= '</tbody></table>';
  6846. /*
  6847. * <table class="table table-bordered table-condensed table-hover"> <tbody> <tr><th colspan="2" class="taC">日常相关费用</th></tr> <!-- loop receiptList' value.accountItem.日常相关费用 --> <tr><th>{{receiptList' value' value.name}}</th><td width="140" class="taR">¥{{receiptList' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptList' value.accountItem.cSum.agencySum}}</td></tr> <tr><th colspan="2" class="taC">差旅相关费用</th></tr> <!-- loop receiptDetail' value.accountItem.差旅相关费用 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.travelSum}}</td></tr> <tr><th colspan="2" class="taC">培训班费用</th></tr> <!-- loop receiptDetail' value.accountItem.培训班费用 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.trainSum}}</td></tr> <tr><th colspan="2" class="taC">其他</th></tr> <!-- loop receiptDetail' value.accountItem.其他 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.otherSum}}</td></tr> <tr><th colspan="2" class="taC">报销金额调整</th></tr> <!-- loop receiptList' value.reviseDetail --> <tr><th><span class="interval">|</span>{{receiptList' value' value.name}}:{{receiptList' value' value.description}}</th><td class="taR">¥{{receiptList' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colOrange taR">¥{{receiptList' value.revisePrice}}</td></tr> <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr> <tr><th style="text-align:center" colspan="2">{{receiptDetail' value.category}}</th></tr> <tr><th class="taC" colspan="2">报销说明</th></tr> <tr><td colspan="2">{{receiptDetail' value.explanation}}</td></tr> <tr class="warning"><td class="taR"><b>({{receiptDetail' value.receiptOrder}})本次报销费用合计</b></td> <td class="colGreed taR"><b style="font-size:24px">¥{{receiptDetail' value.sum}}</b><br>{{receiptDetail' value.sumCN}}</td></tr> </tbody> </table>
  6848. */
  6849. }
  6850. // print_r($verifyStaff);die;
  6851. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  6852. foreach ( $verifyStaff as $key => $value ) {
  6853. $key = trim ( strtr ( $key, '_R', ' ' ) );
  6854. $sinfo = $staff->getOne ( array (
  6855. 'select' => 'username',
  6856. 'where' => ' sid=' . $key,
  6857. 'asArray' => true
  6858. ) );
  6859. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6860. }
  6861. $html .= '</tbody></table>';
  6862. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  6863. foreach ( $rinfo ['executeCopy'] as $value ) {
  6864. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6865. }
  6866. $html .= '</tbody></table>';
  6867. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  6868. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  6869. </tr></table>';
  6870. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  6871. echo json_encode ( array (
  6872. 'status' => 1,
  6873. 'html' => $html
  6874. ) );
  6875. die ();
  6876. }
  6877. /**
  6878. * 删除附件
  6879. */
  6880. function ajaxRemEnclousur() {
  6881. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  6882. if (empty ( $key ))
  6883. echo json_encode ( array (
  6884. 'status' => 2
  6885. ) );
  6886. Doo::loadModel ( 'enclosur' );
  6887. $enclosur = new enclosur ();
  6888. $enclosur->delEnclosurByEid ( $key );
  6889. echo json_encode ( array (
  6890. 'status' => 1
  6891. ) );
  6892. }
  6893. function remittance() {
  6894. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6895. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6896. Doo::loadModel ( 'receipt' );
  6897. $receipt = new receipt ();
  6898. Doo::loadModel ( 'staff' );
  6899. $staff = new staff ();
  6900. $dateCondition = " and Year(pastDate) =" . $year;
  6901. if (! empty ( $month ))
  6902. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  6903. // get Receipt By verifyID status 1
  6904. $receiptList = $receipt->find ( array (
  6905. 'select' => 'sum(sum) as sum,staff,pastDate',
  6906. 'where' => ' status=1' . $dateCondition,
  6907. 'desc' => 'pastDate',
  6908. 'groupby' => 'staff,pastDate',
  6909. 'asArray' => true
  6910. ) );
  6911. $dateList = $receipt->find ( array (
  6912. 'select' => 'pastDate,verifyStaff',
  6913. 'where' => ' status=1' . $dateCondition,
  6914. 'desc' => 'pastDate',
  6915. 'groupby' => 'pastDate',
  6916. 'asArray' => true
  6917. ) );
  6918. $dataList = array ();
  6919. foreach ( $dateList as $d => $a ) {
  6920. $dataList [$a ['pastDate']] = array ();
  6921. $daySum = 0;
  6922. foreach ( $receiptList as $key => $value ) {
  6923. if ($a ['pastDate'] == $value ['pastDate']) {
  6924. $oderList = $receipt->find ( array (
  6925. 'select' => 'receiptOrder',
  6926. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  6927. 'asArray' => true
  6928. ) );
  6929. $list = array ();
  6930. $html = "";
  6931. foreach ( $oderList as $v ) {
  6932. array_push ( $list, $v ['receiptOrder'] );
  6933. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  6934. }
  6935. $receiptList [$key] ['receiptOrder'] = $html;
  6936. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  6937. $sinfo = $staff->getOne ( array (
  6938. 'select' => 'username ',
  6939. 'where' => ' sid=' . $value ['staff'],
  6940. 'asArray' => true
  6941. ) );
  6942. $receiptList [$key] ['username'] = $sinfo ['username'];
  6943. $daySum += $value ['sum'];
  6944. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  6945. }
  6946. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  6947. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  6948. }
  6949. }
  6950. // print_r($dataList);
  6951. $data ['dataList'] = $dataList;
  6952. $mothHtml = "";
  6953. for($i = 1; $i <= 12; $i ++) {
  6954. if ($month == $i)
  6955. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6956. else
  6957. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6958. }
  6959. $data ['year'] = $year;
  6960. $data ['mothHtml'] = $mothHtml;
  6961. $data ['memu'] = "receipt";
  6962. $data ['staff'] = $this->staff;
  6963. $data ['receiptMemu'] = 'approval';
  6964. $data ['verifyId'] = $this->verifyId;
  6965. $data ['executeId'] = $this->executeId;
  6966. $this->render ( "/admin/saeaReportListPay", $data );
  6967. }
  6968. /**
  6969. * 金额调整,提高稳定性
  6970. * @return string
  6971. */
  6972. function revocationAdjustment() {
  6973. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  6974. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  6975. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  6976. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  6977. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey ) && (! empty ( $reviseKey )))) {
  6978. Doo::loadClass ( 'XDeode' );
  6979. $XDeode = new XDeode ( 5 );
  6980. Doo::loadModel ( 'receipt' );
  6981. $receipt = new receipt ();
  6982. $sid = $XDeode->decode ( $sidKey );
  6983. $rid = $XDeode->decode ( $ridKey );
  6984. $reviseKey = $XDeode->decode ( $reviseKey );
  6985. if (! is_numeric ( $sid ) && ! is_numeric ( $rid ) && ! is_numeric ( $reviseKey ))
  6986. die ( 'illegal request' );
  6987. $receiptDetail = $receipt->getOne ( array (
  6988. 'where' => 'rid=' . $rid,
  6989. 'asArray' => true
  6990. ) );
  6991. if (empty ( $receiptDetail ) || empty ( $receiptDetail ['reviseDetail'] ))
  6992. die ( 'illegal request' );
  6993. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  6994. if (! isset ( $reviseDetail [$reviseKey] ))
  6995. die ( 'illegal request' );
  6996. if ($reviseDetail [$reviseKey] ['sid'] == $sid && $reviseDetail [$reviseKey] ['price'] == $price)
  6997. unset ( $reviseDetail [$reviseKey] );
  6998. $revisePrice = 0;
  6999. foreach ( $reviseDetail as $key => $value ) {
  7000. $revisePrice += $value ['price'];
  7001. }
  7002. $reviseDetailString = json_encode ( $reviseDetail );
  7003. $receipt->reviseDetail = $reviseDetailString;
  7004. $receipt->sum = $receiptDetail ['sum'] - $price;
  7005. $receipt->revisePrice = $revisePrice;
  7006. $receipt->update ( array (
  7007. 'where' => 'rid=' . $rid
  7008. ) );
  7009. return '/receiptburEdi/' . $rid;
  7010. } else
  7011. die ( 'illegal request2' );
  7012. }
  7013. function updateApprovalReceipt() {
  7014. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7015. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  7016. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7017. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  7018. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  7019. if (! empty ( $rid )) {
  7020. Doo::loadModel ( "verify" );
  7021. $verify = new verify ();
  7022. Doo::loadModel ( "receiptDetail" );
  7023. $receiptDetailObj = new receiptDetail ();
  7024. Doo::loadModel ( "itemStatistics" );
  7025. Doo::loadModel ( "statistics" );
  7026. $statistics = new statistics ();
  7027. $itemStatistics = new itemStatistics ();
  7028. Doo::loadModel ( "receipt" );
  7029. $receipt = new receipt ();
  7030. $receiptDetail = $receipt->getOne ( array (
  7031. 'where' => 'rid=' . $rid . ' and status=2 ',
  7032. 'asArray' => true
  7033. ) );
  7034. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  7035. $nsflag = true;
  7036. foreach ( $nslist as $value ) {
  7037. if ($value == $this->staff ['0'] ['sid']) {
  7038. $nsflag = false;
  7039. break;
  7040. }
  7041. }
  7042. if (empty ( $receiptDetail ) || $nsflag)
  7043. return "/approval";
  7044. $verifyDetail = $verify->getOne ( array (
  7045. 'where' => ' vid =' . $receiptDetail ['verify'],
  7046. 'asArray' => true
  7047. ) );
  7048. $verifyString = $verifyDetail ['staff'];
  7049. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  7050. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  7051. if (empty ( $opinion )) {
  7052. if ($status == 3)
  7053. $opinion = "终止";
  7054. else
  7055. $opinion = "同意支付";
  7056. }
  7057. $nowStaff = 0;
  7058. $nowStaffList = array ();
  7059. if (empty ( $verifyStaff )) {
  7060. // 还需加入是否已经进入角色审批
  7061. if ($verifyDetail [0] [1] == 'ROLE') {
  7062. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  7063. foreach ( $vStaffString as $key => $value ) {
  7064. $staffK = explode ( "_", $value );
  7065. if ($staffK [0] != $this->staff [0] ['sid'])
  7066. array_push ( $nowStaffList, $staffK [0] );
  7067. }
  7068. // print_r($verifyDetail);
  7069. // die;
  7070. if (! empty ( $nowStaffList )) {
  7071. $nowStaff = implode ( ',', $nowStaffList );
  7072. $verifyStaff = array (
  7073. $this->staff [0] ['sid'] . "_R" => array (
  7074. 'date' => date ( 'Y-m-d' ),
  7075. 'opinion' => $opinion,
  7076. 'status' => $status,
  7077. 'nextStaff' => $verifyDetail [0] [0],
  7078. 'ROLE' => 1
  7079. )
  7080. );
  7081. } else {
  7082. $nowStaff = $verifyDetail [1] [0];
  7083. $verifyStaff = array (
  7084. $this->staff [0] ['sid'] . "_R" => array (
  7085. 'date' => date ( 'Y-m-d' ),
  7086. 'opinion' => $opinion,
  7087. 'status' => $status,
  7088. 'nextStaff' => $verifyDetail [1] [0]
  7089. )
  7090. );
  7091. }
  7092. } else {
  7093. if ($verifyDetail [1] [1] == 'ROLE') {
  7094. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  7095. // echo "dd";
  7096. foreach ( $vStaffString as $key => $value ) {
  7097. $staffK = explode ( "_", $value );
  7098. array_push ( $nowStaffList, $staffK [0] );
  7099. }
  7100. $nowStaff = implode ( ',', $nowStaffList );
  7101. $verifyStaff = array (
  7102. $this->staff [0] ['sid'] => array (
  7103. 'date' => date ( 'Y-m-d' ),
  7104. 'opinion' => $opinion,
  7105. 'status' => $status,
  7106. 'nextStaff' => $verifyDetail [1] [0],
  7107. 'ROLE' => 1
  7108. )
  7109. );
  7110. } else {
  7111. $nowStaff = $verifyDetail [1] [0];
  7112. $verifyStaff = array (
  7113. $this->staff [0] ['sid'] => array (
  7114. 'date' => date ( 'Y-m-d' ),
  7115. 'opinion' => $opinion,
  7116. 'status' => $status,
  7117. 'nextStaff' => $verifyDetail [1] [0]
  7118. )
  7119. );
  7120. }
  7121. }
  7122. if ($status == 3)
  7123. $verifyStaff = array (
  7124. 'final' => $status,
  7125. $this->staff [0] ['sid'] => array (
  7126. 'date' => date ( 'Y-m-d' ),
  7127. 'opinion' => $opinion,
  7128. 'status' => $status
  7129. )
  7130. );
  7131. $vStaffString = json_encode ( $verifyStaff );
  7132. $receipt->nowStaff = $nowStaff;
  7133. $receipt->verifyStaff = $vStaffString;
  7134. } else {
  7135. $VS = end ( $verifyStaff );
  7136. // 非角色审批
  7137. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  7138. $nextStaff = 0;
  7139. $roleSTF = false;
  7140. foreach ( $verifyDetail as $key => $value ) {
  7141. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  7142. if (isset ( $verifyDetail [$key + 1] )) {
  7143. $nextStaff = $verifyDetail [$key + 1] [0];
  7144. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  7145. $roleSTF = true;
  7146. }
  7147. break;
  7148. }
  7149. }
  7150. if (! $roleSTF) {
  7151. $nowStaff = $nextStaff;
  7152. $verifyStaff [$this->staff [0] ['sid']] = array (
  7153. 'date' => date ( 'Y-m-d' ),
  7154. 'opinion' => $opinion,
  7155. 'status' => $status,
  7156. 'nextStaff' => $nextStaff
  7157. );
  7158. } else {
  7159. // 获取角色下的所有用户ID
  7160. $nowStaffList = array ();
  7161. foreach ( $verifyDetail as $vfk ) {
  7162. if ($vfk [1] == 'ROLE') {
  7163. $vStaffString = json_decode ( $vfk [3] );
  7164. foreach ( $vStaffString as $key => $value ) {
  7165. $staffK = explode ( "_", $value );
  7166. array_push ( $nowStaffList, $staffK [0] );
  7167. }
  7168. }
  7169. }
  7170. $nowStaff = implode ( ',', $nowStaffList );
  7171. $verifyStaff [$this->staff [0] ['sid']] = array (
  7172. 'date' => date ( 'Y-m-d' ),
  7173. 'opinion' => $opinion,
  7174. 'status' => $status,
  7175. 'nextStaff' => $nextStaff,
  7176. 'ROLE' => 0
  7177. );
  7178. }
  7179. if ($status == 3) {
  7180. $verifyStaff ['final'] = $status;
  7181. $verifyStaff [$this->staff [0] ['sid']] = array (
  7182. 'date' => date ( 'Y-m-d' ),
  7183. 'opinion' => $opinion,
  7184. 'status' => $status
  7185. );
  7186. }
  7187. $vStaffString = json_encode ( $verifyStaff );
  7188. $receipt->nowStaff = $nowStaff;
  7189. $receipt->verifyStaff = $vStaffString;
  7190. }
  7191. // 角色审批
  7192. if (isset ( $VS ['ROLE'] )) {
  7193. // 找出角色人 当前审批角色组
  7194. $verifyJSStaff = array ();
  7195. $nowStaffList2 = array ();
  7196. foreach ( $verifyDetail as $key => $value ) {
  7197. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  7198. $verifyJSStaff = json_decode ( $value [3] );
  7199. foreach ( $verifyJSStaff as $m ) {
  7200. $staffK = explode ( "_", $m );
  7201. array_push ( $nowStaffList2, $staffK [0] );
  7202. }
  7203. // print_r($nowStaffList2);
  7204. }
  7205. }
  7206. $RoleVerifyStaff = array ();
  7207. foreach ( $verifyStaff as $key => $value ) {
  7208. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  7209. foreach ( $nowStaffList2 as $m ) {
  7210. if ($key == $m . "_R")
  7211. $RoleVerifyStaff [$key] = $value;
  7212. }
  7213. }
  7214. }
  7215. // print_r($verifyStaff);
  7216. // print_r($nowStaffList2);
  7217. // print_r($RoleVerifyStaff);
  7218. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  7219. // print_r($verifyJSStaff);
  7220. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  7221. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  7222. // 下一个审批人ID
  7223. $nextStaff = 0;
  7224. $falg = false;
  7225. foreach ( $verifyDetail as $key => $value ) {
  7226. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  7227. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  7228. $falg = true;
  7229. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  7230. $nowStaffList = array ();
  7231. foreach ( $vStaffString as $v ) {
  7232. $staffK = explode ( "_", $v );
  7233. array_push ( $nowStaffList, $staffK [0] );
  7234. }
  7235. $nowStaff = implode ( ',', $nowStaffList );
  7236. $nextStaff = $verifyDetail [$key + 1] [0];
  7237. } elseif (isset ( $verifyDetail [$key + 1] )) {
  7238. $nextStaff = $verifyDetail [$key + 1] [0];
  7239. $nowStaff = $nextStaff;
  7240. } else
  7241. $nowStaff = '';
  7242. break;
  7243. }
  7244. }
  7245. if ($falg)
  7246. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7247. 'date' => date ( 'Y-m-d' ),
  7248. 'opinion' => $opinion,
  7249. 'status' => $status,
  7250. 'nextStaff' => $nextStaff,
  7251. 'ROLE' => 1
  7252. );
  7253. else
  7254. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7255. 'date' => date ( 'Y-m-d' ),
  7256. 'opinion' => $opinion,
  7257. 'status' => $status,
  7258. 'nextStaff' => $nextStaff
  7259. );
  7260. // print_r($verifyStaff);
  7261. // echo $nowStaff;die;
  7262. } else { // 进入下一个角色或者审批人
  7263. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  7264. //
  7265. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  7266. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7267. 'date' => date ( 'Y-m-d' ),
  7268. 'opinion' => $opinion,
  7269. 'status' => $status,
  7270. 'nextStaff' => $VS ['nextStaff'],
  7271. 'ROLE' => 1
  7272. );
  7273. // print_r($verifyStaff);
  7274. // die;
  7275. }
  7276. if ($status == 3) {
  7277. $verifyStaff ['final'] = $status;
  7278. $verifyStaff [$this->staff [0] ['sid']] = array (
  7279. 'date' => date ( 'Y-m-d' ),
  7280. 'opinion' => $opinion,
  7281. 'status' => $status
  7282. );
  7283. }
  7284. $vStaffString = json_encode ( $verifyStaff );
  7285. $receipt->verifyStaff = $vStaffString;
  7286. $receipt->nowStaff = $nowStaff;
  7287. // die;
  7288. // }
  7289. // print_r($verifyStaff);
  7290. // die;
  7291. }
  7292. // print_r($verifyStaff);die;
  7293. }
  7294. // print_r($verifyDetail);
  7295. $roleKey = 0;
  7296. $roleId = 0;
  7297. $verifyDetailCopy = array ();
  7298. foreach ( $verifyDetail as $k => $v ) {
  7299. if ($v [1] == 'ROLE') {
  7300. $roleId = $v [0];
  7301. $roleVerify = json_decode ( $v [3], true );
  7302. $roleKey = $k;
  7303. $roleArray = array ();
  7304. foreach ( $roleVerify as $o => $p ) {
  7305. $staffID = explode ( '_', $p );
  7306. $exp = array (
  7307. 0 => $staffID [0],
  7308. 1 => $staffID [1]
  7309. );
  7310. array_push ( $roleArray, $exp );
  7311. }
  7312. $verifyDetailCopy [$v [0]] = $roleArray;
  7313. }
  7314. }
  7315. // print_r($verifyDetail);
  7316. foreach ( $verifyDetailCopy as $k => $v ) {
  7317. foreach ( $verifyDetail as $m => $n ) {
  7318. if ($n [0] == $k) {
  7319. array_splice ( $verifyDetail, $m, 1, $v );
  7320. }
  7321. }
  7322. }
  7323. // die;
  7324. // if (!empty($roleArray))
  7325. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  7326. // echo $roleId;
  7327. // print_r($verifyStaff);
  7328. // print_r($verifyDetail);
  7329. // die;
  7330. Doo::loadModel ( "receiptLog" );
  7331. $receiptLog = new receiptLog ();
  7332. // 审批日志
  7333. if (! isset ( $verifyStaff ['final'] )) {
  7334. if (! empty ( $roleId )) {
  7335. Doo::loadModel ( "role" );
  7336. $role = new role ();
  7337. $roleInfo = $role->getOne ( array (
  7338. 'where' => 'rid=' . $roleId,
  7339. 'asArray' => true
  7340. ) );
  7341. $receiptLog->rolename = $roleInfo ['name'];
  7342. }
  7343. $receiptLog->username = $this->staff [0] ['username'];
  7344. $receiptLog->uid = $this->staff [0] ['sid'];
  7345. $receiptLog->date = date ( "Y-m-d" );
  7346. $receiptLog->opinion = $opinion;
  7347. $receiptLog->img = $this->staff [0] ['avatar'];
  7348. $receiptLog->status = 1;
  7349. $receiptLog->rid = $rid;
  7350. $receiptLog->insert ();
  7351. }
  7352. if (isset ( $verifyStaff ['final'] )) { // rDetail
  7353. $receipt->verifyBreakup = $verifyString;
  7354. $receipt->status = 3;
  7355. $receiptDetailObj->status = 3;
  7356. $receiptDetailObj->update ( array (
  7357. 'where' => 'rid=' . $rid
  7358. ) );
  7359. if (! empty ( $roleId )) {
  7360. Doo::loadModel ( "role" );
  7361. $role = new role ();
  7362. $roleInfo = $role->getOne ( array (
  7363. 'where' => 'rid=' . $roleId,
  7364. 'asArray' => true
  7365. ) );
  7366. $receiptLog->rolename = $roleInfo ['name'];
  7367. }
  7368. $receiptLog->username = $this->staff [0] ['username'];
  7369. $receiptLog->uid = $this->staff [0] ['sid'];
  7370. $receiptLog->date = date ( "Y-m-d" );
  7371. $receiptLog->opinion = $opinion;
  7372. $receiptLog->img = $this->staff [0] ['avatar'];
  7373. $receiptLog->status = 3;
  7374. $receiptLog->rid = $rid;
  7375. $receiptLog->insert ();
  7376. // 微信企业号通知
  7377. $this->setWXMsg ( $rid, 3 );
  7378. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  7379. $receipt->status = 1;
  7380. $reviseSum = 0;
  7381. $receipt->verifyBreakup = $verifyString;
  7382. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  7383. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7384. foreach ( $reviseDetail as $key => $value ) {
  7385. $receiptDetailObj = new receiptDetail ();
  7386. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7387. $receiptDetailObj->item = $value ['description'];
  7388. $receiptDetailObj->itemCategory = "报销金额调整";
  7389. $receiptDetailObj->price = $value ['price'];
  7390. $receiptDetailObj->date = $receiptDetail ['date'];
  7391. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  7392. $receiptDetailObj->rid = $rid;
  7393. $receiptDetailObj->status = 1;
  7394. $receiptDetailObj->insert ();
  7395. $reviseSum += $value ['price'];
  7396. }
  7397. $itemStatistics = new itemStatistics ();
  7398. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7399. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7400. $itemStatistics->price = $reviseSum;
  7401. $itemStatistics->itemCategory = "报销金额调整";
  7402. $itemStatistics->date = $receiptDetail ['date'];
  7403. $itemStatistics->insert ();
  7404. }
  7405. $receiptDetailObj = new receiptDetail ();
  7406. $receiptDetailObj->status = 1;
  7407. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  7408. $receiptDetailObj->update ( array (
  7409. 'where' => 'rid=' . $rid
  7410. ) );
  7411. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7412. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7413. $stat = $statistics->getOne ( array (
  7414. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  7415. 'asArray' => true
  7416. ) );
  7417. if (empty ( $stat )) {
  7418. $statistics->date = $receiptDetail ['date'];
  7419. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7420. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7421. $statistics->agPrice = $receiptDetail ['sum'];
  7422. $statistics->rePrice = $reviseSum;
  7423. $statistics->insert ();
  7424. } else {
  7425. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  7426. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  7427. $statistics->update ( array (
  7428. 'where' => 'sid=' . $stat ['sid']
  7429. ) );
  7430. }
  7431. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7432. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7433. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  7434. foreach ( $accountItem ['cSum'] as $key => $value ) {
  7435. if ($key == "agencySum") {
  7436. $iStatistics = $itemStatistics->getOne ( array (
  7437. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  7438. 'asArray' => true
  7439. ) );
  7440. if (empty ( $iStatistics )) {
  7441. $itemStatistics->cid = $receiptDetail ['cid'];
  7442. ;
  7443. $itemStatistics->staff = $receiptDetail ['staff'];
  7444. $itemStatistics->price = $value;
  7445. $itemStatistics->itemCategory = $this->AGENCY;
  7446. $itemStatistics->date = $receiptDetail ['date'];
  7447. $itemStatistics->insert ();
  7448. } else {
  7449. if (! empty ( $value )) {
  7450. $itemStatistics->price = $value + $iStatistics ['price'];
  7451. $itemStatistics->update ( array (
  7452. 'where' => 'sid=' . $iStatistics ['sid']
  7453. ) );
  7454. }
  7455. }
  7456. } elseif ($key == "travelSum") {
  7457. $iStatistics = $itemStatistics->getOne ( array (
  7458. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  7459. 'asArray' => true
  7460. ) );
  7461. if (empty ( $iStatistics )) {
  7462. $itemStatistics->cid = $receiptDetail ['cid'];
  7463. $itemStatistics->staff = $receiptDetail ['staff'];
  7464. $itemStatistics->price = $value;
  7465. $itemStatistics->itemCategory = $this->TRAVEL;
  7466. $itemStatistics->date = $receiptDetail ['date'];
  7467. $itemStatistics->insert ();
  7468. } else {
  7469. if (! empty ( $value )) {
  7470. $itemStatistics->price = $value + $iStatistics ['price'];
  7471. $itemStatistics->update ( array (
  7472. 'where' => 'sid=' . $iStatistics ['sid']
  7473. ) );
  7474. }
  7475. }
  7476. } elseif ($key == "trainSum") {
  7477. $iStatistics = $itemStatistics->getOne ( array (
  7478. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  7479. 'asArray' => true
  7480. ) );
  7481. if (empty ( $iStatistics )) {
  7482. $itemStatistics->cid = $receiptDetail ['cid'];
  7483. $itemStatistics->staff = $receiptDetail ['staff'];
  7484. $itemStatistics->price = $value;
  7485. $itemStatistics->itemCategory = $this->TRAIN;
  7486. $itemStatistics->date = $receiptDetail ['date'];
  7487. $itemStatistics->insert ();
  7488. } else {
  7489. if (! empty ( $value )) {
  7490. $itemStatistics->price = $value + $iStatistics ['price'];
  7491. $itemStatistics->update ( array (
  7492. 'where' => 'sid=' . $iStatistics ['sid']
  7493. ) );
  7494. }
  7495. }
  7496. } elseif ($key == "otherSum") {
  7497. $iStatistics = $itemStatistics->getOne ( array (
  7498. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  7499. 'asArray' => true
  7500. ) );
  7501. if (empty ( $iStatistics )) {
  7502. $itemStatistics->cid = $receiptDetail ['cid'];
  7503. $itemStatistics->staff = $receiptDetail ['staff'];
  7504. $itemStatistics->price = $value;
  7505. $itemStatistics->itemCategory = $this->OTHER;
  7506. $itemStatistics->date = $receiptDetail ['date'];
  7507. $itemStatistics->insert ();
  7508. } else {
  7509. if (! empty ( $value )) {
  7510. $itemStatistics->price = $value + $iStatistics ['price'];
  7511. $itemStatistics->update ( array (
  7512. 'where' => 'sid=' . $iStatistics ['sid']
  7513. ) );
  7514. }
  7515. }
  7516. }
  7517. }
  7518. $receipt->pastDate = date ( "Y-m-d" );
  7519. // 微信企业号通知
  7520. $this->setWXMsg ( $rid, 1 );
  7521. }
  7522. $receipt->amount = $amount;
  7523. $receipt->update ( array (
  7524. 'where' => ' rid = ' . $rid
  7525. ) );
  7526. // 进入下一条审批费用新加需求
  7527. $vidList = array ();
  7528. $verifyDetail = $verify->find ( array (
  7529. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  7530. 'asArray' => true
  7531. ) );
  7532. foreach ( $verifyDetail as $key => $value ) {
  7533. array_push ( $vidList, $value ['vid'] );
  7534. }
  7535. $vid = implode ( ",", $vidList );
  7536. if (empty ( $verifyDetail ))
  7537. $vid = 0;
  7538. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  7539. $receipt = new receipt ();
  7540. $rd = $receipt->getOne ( array (
  7541. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  7542. 'asc' => 'rid',
  7543. 'asArray' => true
  7544. ) );
  7545. if (empty ( $rd )) {
  7546. return '/approvalExpenses/pendApproval';
  7547. }
  7548. if ($rd ['Rtype'] == 1) {
  7549. if ($rd ['isBK'] == 1) {
  7550. return '/receiptburEdi/' . $rd ['rid'];
  7551. } else {
  7552. return '/expensesEdi/' . $rd ['rid'];
  7553. }
  7554. } elseif ($rd ['Rtype'] == 2) {
  7555. return '/remitApproval/' . $rd ['rid'];
  7556. } else {
  7557. return '/receiptburEdi/' . $rd ['rid'];
  7558. }
  7559. // return "/approvalExpenses/pendApproval";
  7560. }
  7561. }
  7562. function expensesRetreats() {
  7563. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7564. if (! empty ( $rid )) {
  7565. // 操作记录
  7566. Doo::loadModel ( "receipt" );
  7567. $receipt = new receipt ();
  7568. Doo::loadModel ( "receiptLog" );
  7569. $receiptLog = new receiptLog ();
  7570. Doo::loadModel ( "verify" );
  7571. $verify = new verify ();
  7572. $receiptInfo = $receipt->getOne ( array (
  7573. 'where' => 'rid=' . $rid,
  7574. 'asArray' => true
  7575. ) );
  7576. $vr = $verify->getOne ( array (
  7577. 'where' => 'vid=' . $receiptInfo ['verify'],
  7578. 'asArray' => true
  7579. ) );
  7580. $jd = json_decode ( $vr ['staff'] );
  7581. $roleId = 0;
  7582. foreach ( $jd as $key => $value ) {
  7583. if ($value [1] == 'ROLE') {
  7584. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7585. if ($pos !== false) {
  7586. $roleId = $value [0];
  7587. }
  7588. }
  7589. }
  7590. // 审批日志
  7591. // echo $roleId;die;
  7592. if (! empty ( $roleId )) {
  7593. Doo::loadModel ( "role" );
  7594. $role = new role ();
  7595. $roleInfo = $role->getOne ( array (
  7596. 'where' => 'rid=' . $roleId,
  7597. 'asArray' => true
  7598. ) );
  7599. $receiptLog->rolename = $roleInfo ['name'];
  7600. }
  7601. $receiptLog->username = $this->staff [0] ['username'];
  7602. $receiptLog->uid = $this->staff [0] ['sid'];
  7603. $receiptLog->date = date ( "Y-m-d" );
  7604. $receiptLog->opinion = '撤回';
  7605. $receiptLog->img = $this->staff [0] ['avatar'];
  7606. $receiptLog->status = 4;
  7607. $receiptLog->rid = $rid;
  7608. $receiptLog->insert ();
  7609. $receipt->status = 4;
  7610. $receipt->update ( array (
  7611. 'where' => 'rid=' . $rid
  7612. ) );
  7613. // 微信企业号通知
  7614. $this->setWXMsg ( $rid, 2 );
  7615. }
  7616. // echo "ddd";
  7617. return '/approvalExpenses/pendApproval';
  7618. }
  7619. function updateCheReceipt() {
  7620. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7621. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7622. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  7623. if (! empty ( $rid )) {
  7624. // 操作记录
  7625. Doo::loadModel ( "receipt" );
  7626. $receipt = new receipt ();
  7627. Doo::loadModel ( "receiptLog" );
  7628. $receiptLog = new receiptLog ();
  7629. Doo::loadModel ( "verify" );
  7630. $verify = new verify ();
  7631. $receiptInfo = $receipt->getOne ( array (
  7632. 'where' => 'rid=' . $rid . ' and status=2',
  7633. 'asArray' => true
  7634. ) );
  7635. if (empty ( $receiptInfo )) {
  7636. echo json_encode ( array (
  7637. 'status' => 2
  7638. ) );
  7639. die ();
  7640. }
  7641. $vr = $verify->getOne ( array (
  7642. 'where' => 'vid=' . $receiptInfo ['verify'],
  7643. 'asArray' => true
  7644. ) );
  7645. $jd = json_decode ( $vr ['staff'] );
  7646. $roleId = 0;
  7647. foreach ( $jd as $key => $value ) {
  7648. if ($value [1] == 'ROLE') {
  7649. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7650. if ($pos !== false) {
  7651. $roleId = $value [0];
  7652. }
  7653. }
  7654. }
  7655. // 审批日志
  7656. // echo $roleId;die;
  7657. if (! empty ( $roleId )) {
  7658. Doo::loadModel ( "role" );
  7659. $role = new role ();
  7660. $roleInfo = $role->getOne ( array (
  7661. 'where' => 'rid=' . $roleId,
  7662. 'asArray' => true
  7663. ) );
  7664. $receiptLog->rolename = $roleInfo ['name'];
  7665. }
  7666. $receiptLog->username = $this->staff [0] ['username'];
  7667. $receiptLog->uid = $this->staff [0] ['sid'];
  7668. $receiptLog->date = date ( "Y-m-d" );
  7669. $receiptLog->opinion = $opinion;
  7670. $receiptLog->img = $this->staff [0] ['avatar'];
  7671. $receiptLog->status = 4;
  7672. $receiptLog->rid = $rid;
  7673. $receiptLog->insert ();
  7674. $receipt->status = 4;
  7675. $receipt->update ( array (
  7676. 'where' => 'rid=' . $rid
  7677. ) );
  7678. // 微信企业号通知
  7679. $this->setWXMsg ( $rid, 2 );
  7680. echo json_encode ( array (
  7681. 'status' => 1
  7682. ) );
  7683. // Header("HTTP/1.1 303 See Other");
  7684. // Header("Location: /approvalExpenses/pendApproval");
  7685. die ();
  7686. }
  7687. echo json_encode ( array (
  7688. 'status' => 2
  7689. ) );
  7690. die ();
  7691. // echo "ddd";
  7692. // return '/saeaBorad';
  7693. }
  7694. function revisePrice() {
  7695. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  7696. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  7697. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7698. // echo $price;die;
  7699. if (! empty ( $rid )) {
  7700. Doo::loadModel ( "receipt" );
  7701. $receipt = new receipt ();
  7702. $receiptDetail = $receipt->getOne ( array (
  7703. 'where' => 'rid=' . $rid . ' and status=2 ',
  7704. 'asArray' => true
  7705. ) );
  7706. if (empty ( $receiptDetail ))
  7707. die ( 'illegal request' );
  7708. $reviseDetail = array ();
  7709. if (empty ( $receiptDetail ['reviseDetail'] )) {
  7710. array_push ( $reviseDetail, array (
  7711. 'sid' => $this->staff [0] ['sid'],
  7712. 'name' => $this->staff [0] ['username'],
  7713. 'description' => $description,
  7714. 'price' => $price
  7715. ) );
  7716. $reviseDetailString = json_encode ( $reviseDetail );
  7717. $receipt->reviseDetail = $reviseDetailString;
  7718. $receipt->revisePrice = $price;
  7719. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7720. } else {
  7721. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7722. array_push ( $reviseDetail, array (
  7723. 'sid' => $this->staff [0] ['sid'],
  7724. 'name' => $this->staff [0] ['username'],
  7725. 'description' => $description,
  7726. 'price' => $price
  7727. ) );
  7728. $reviseDetailString = json_encode ( $reviseDetail );
  7729. $receipt->reviseDetail = $reviseDetailString;
  7730. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  7731. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7732. }
  7733. $receipt->update ( array (
  7734. 'where' => 'rid=' . $rid
  7735. ) );
  7736. if ($receiptDetail ['Rtype'] == 1) {
  7737. if ($receiptDetail ['isBK'] == 1) {
  7738. return '/receiptburEdi/' . $receiptDetail ['rid'];
  7739. }
  7740. } elseif ($receiptDetail ['Rtype'] == 2) {
  7741. } else {
  7742. return '/receiptburEdi/' . $receiptDetail ['rid'];
  7743. }
  7744. }
  7745. die ( 'illegal request' );
  7746. }
  7747. function personalCollect() {
  7748. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7749. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  7750. $this->showCache ( $path );
  7751. Doo::loadModel ( "receiptDetail" );
  7752. Doo::loadModel ( "itemStatistics" );
  7753. Doo::loadModel ( 'statistics' );
  7754. $statistics = new statistics ();
  7755. $itemStatistics = new itemStatistics ();
  7756. $receiptDetail = new receiptDetail ();
  7757. $receiptCollectList = $receiptDetail->find ( array (
  7758. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7759. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7760. 'groupby' => 'itemCategory,Month(date)',
  7761. 'asArray' => true
  7762. ) );
  7763. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  7764. 'where' => 'staff=' . $this->staff [0] ['sid'],
  7765. 'asArray' => true
  7766. ) );
  7767. // create collect html
  7768. $collectArray = array (
  7769. '日常相关费用' => array (),
  7770. '差旅相关费用' => array (),
  7771. '培训班费用' => array (),
  7772. '其他' => array ()
  7773. );
  7774. $adjustment = array ();
  7775. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  7776. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7777. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  7778. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7779. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  7780. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7781. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  7782. array_push ( $collectArray ['其他'], $collectHtml );
  7783. $data ['collectArray'] = $collectArray;
  7784. // statistics html
  7785. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7786. if (empty ( $stList ))
  7787. $stList = array (
  7788. 'rePrice' => 0,
  7789. 'agPrice' => 0
  7790. );
  7791. $data ['stList'] = array (
  7792. 'rePrice' => $stList ['rePrice'],
  7793. 'agPrice' => $stList ['agPrice'],
  7794. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7795. );
  7796. // Adjustment price html
  7797. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7798. array_push ( $adjustment, $collectHtml );
  7799. $data ['adjustment'] = $adjustment;
  7800. // total price html
  7801. $collectHtml = "";
  7802. $total = 0;
  7803. for($i = 1; $i <= 12; $i ++) {
  7804. $sumPrice = 0;
  7805. foreach ( $receiptCollectList as $key => $value ) {
  7806. if ($value ['month'] == $i) {
  7807. $sumPrice += $value ['price'];
  7808. }
  7809. }
  7810. if ($sumPrice == 0)
  7811. $collectHtml .= '<td class="taR">-</td>';
  7812. else
  7813. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7814. $total += $sumPrice;
  7815. }
  7816. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7817. $data ['totalPrice'] = $collectHtml;
  7818. $data ['year'] = $year;
  7819. $data ['totalYear'] = $total;
  7820. $data ['memu'] = "receipt";
  7821. $data ['staff'] = $this->staff;
  7822. $data ['receiptMemu'] = 'personalCollect';
  7823. $data ['verifyId'] = $this->verifyId;
  7824. $data ['executeId'] = $this->executeId;
  7825. // year staff status 2,4
  7826. if ($year < date ( "Y" )) {
  7827. Doo::loadModel ( 'receipt' );
  7828. $receipt = new receipt ();
  7829. $receiptList = $receipt->find ( array (
  7830. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7831. 'asArray' => true
  7832. ) );
  7833. if (empty ( $receiptList )) {
  7834. ob_start ();
  7835. $this->render ( "/admin/saea_slist_collect", $data );
  7836. $this->cacheFile ( $path );
  7837. die ();
  7838. }
  7839. }
  7840. $this->render ( "/admin/saea_slist_collect", $data );
  7841. }
  7842. function personalCollectDetail() {
  7843. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7844. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  7845. $this->showCache ( $path );
  7846. Doo::loadModel ( "receiptDetail" );
  7847. Doo::loadModel ( "itemStatistics" );
  7848. Doo::loadModel ( 'statistics' );
  7849. Doo::loadModel ( 'accountItem' );
  7850. $accountItem = new accountItem ();
  7851. $statistics = new statistics ();
  7852. $itemStatistics = new itemStatistics ();
  7853. $receiptDetail = new receiptDetail ();
  7854. $receiptCollectList = $receiptDetail->find ( array (
  7855. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  7856. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7857. 'groupby' => 'item,Month(date)',
  7858. 'asArray' => true
  7859. ) );
  7860. $accountList = $accountItem->find ( array (
  7861. 'asArray' => true
  7862. ) );
  7863. // create CollectDetail HTML
  7864. $collectHtml = array ();
  7865. foreach ( $accountList as $key => $value ) {
  7866. $html = "";
  7867. $asum = 0;
  7868. for($i = 1; $i <= 12; $i ++) {
  7869. $falg = true;
  7870. foreach ( $receiptCollectList as $v ) {
  7871. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7872. $asum += $v ['price'];
  7873. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7874. $falg = false;
  7875. break;
  7876. }
  7877. }
  7878. if ($falg)
  7879. $html .= '<td class="taR">-</td>';
  7880. }
  7881. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7882. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7883. }
  7884. $data ['collectHtml'] = $collectHtml;
  7885. // create Adjustment price html
  7886. $receiptCollectList = $receiptDetail->find ( array (
  7887. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7888. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7889. 'groupby' => 'itemCategory,Month(date)',
  7890. 'asArray' => true
  7891. ) );
  7892. $adjustment = array ();
  7893. $collectArray = array (
  7894. '日常相关费用' => array (),
  7895. '差旅相关费用' => array (),
  7896. '培训班费用' => array (),
  7897. '其他' => array ()
  7898. );
  7899. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7900. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7901. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7902. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7903. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7904. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7905. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7906. array_push ( $collectArray ['其他'], $collectHtml );
  7907. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7908. array_push ( $adjustment, $collectHtml );
  7909. // total price html
  7910. $collectHtml = "";
  7911. $total = 0;
  7912. for($i = 1; $i <= 12; $i ++) {
  7913. $sumPrice = 0;
  7914. foreach ( $receiptCollectList as $key => $value ) {
  7915. if ($value ['month'] == $i) {
  7916. $sumPrice += $value ['price'];
  7917. }
  7918. }
  7919. if ($sumPrice == 0)
  7920. $collectHtml .= '<td class="taR">-</td>';
  7921. else
  7922. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7923. $total += $sumPrice;
  7924. }
  7925. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7926. // statistics html
  7927. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7928. if (empty ( $stList ))
  7929. $stList = array (
  7930. 'rePrice' => 0,
  7931. 'agPrice' => 0
  7932. );
  7933. $data ['stList'] = array (
  7934. 'rePrice' => $stList ['rePrice'],
  7935. 'agPrice' => $stList ['agPrice'],
  7936. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7937. );
  7938. $data ['collectArray'] = $collectArray;
  7939. $data ['adjustment'] = $adjustment;
  7940. $data ['totalPrice'] = $collectHtml;
  7941. $data ['totalYear'] = $total;
  7942. $data ['year'] = $year;
  7943. $data ['memu'] = "receipt";
  7944. $data ['staff'] = $this->staff;
  7945. $data ['receiptMemu'] = 'personalCollect';
  7946. $data ['verifyId'] = $this->verifyId;
  7947. $data ['executeId'] = $this->executeId;
  7948. // year staff status 2,4
  7949. if ($year < date ( "Y" )) {
  7950. Doo::loadModel ( 'receipt' );
  7951. $receipt = new receipt ();
  7952. $receiptList = $receipt->find ( array (
  7953. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7954. 'asArray' => true
  7955. ) );
  7956. if (empty ( $receiptList )) {
  7957. ob_start ();
  7958. $this->render ( "/admin/saeaCollectArticles", $data );
  7959. $this->cacheFile ( $path );
  7960. die ();
  7961. }
  7962. }
  7963. $this->render ( "/admin/saeaCollectArticles", $data );
  7964. }
  7965. function companyCategoryCollect() {
  7966. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7967. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  7968. $this->showCache ( $path );
  7969. Doo::loadModel ( 'L_category' );
  7970. Doo::loadModel ( 'itemStatistics' );
  7971. Doo::loadModel ( 'statistics' );
  7972. $statistics = new statistics ();
  7973. $Lcategory = new L_category ();
  7974. $itemStatistics = new itemStatistics ();
  7975. Doo::loadModel ( "receiptAuthorityManage" );
  7976. $receiptAuthorityManage = new receiptAuthorityManage ();
  7977. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  7978. $cidList = array ();
  7979. foreach ( $imcStaff as $key => $value ) {
  7980. array_push ( $cidList, $value ['cid'] );
  7981. }
  7982. $cidString = implode ( ',', $cidList );
  7983. $LcategoryList = $Lcategory->find ( array (
  7984. 'where' => ' cid in (' . $cidString . ')',
  7985. 'asArray' => true
  7986. ) ); // 'staff='.$this->staff[0]['sid']." and
  7987. $itemStatisticsList = $itemStatistics->find ( array (
  7988. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7989. 'where' => " Year(date)=" . $year,
  7990. 'groupby' => 'cid,Month(date)',
  7991. 'asArray' => true
  7992. ) );
  7993. // ceatre companyCollectHtml
  7994. foreach ( $LcategoryList as $value ) {
  7995. $html = "";
  7996. $asum = 0;
  7997. for($i = 1; $i <= 12; $i ++) {
  7998. $falg = true;
  7999. foreach ( $itemStatisticsList as $v ) {
  8000. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  8001. $asum += $v ['price'];
  8002. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8003. $falg = false;
  8004. break;
  8005. }
  8006. }
  8007. if ($falg)
  8008. $html .= '<td class="taR">-</td>';
  8009. }
  8010. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8011. $collectHtml [$value ['title']] = array (
  8012. 'html' => $html,
  8013. 'cid' => $value ['cid']
  8014. );
  8015. }
  8016. $data ['companyHtml'] = $collectHtml;
  8017. // total price html
  8018. $collectHtml = "";
  8019. $total = 0;
  8020. for($i = 1; $i <= 12; $i ++) {
  8021. $sumPrice = 0;
  8022. foreach ( $itemStatisticsList as $key => $value ) {
  8023. if ($value ['month'] == $i) {
  8024. $sumPrice += $value ['price'];
  8025. }
  8026. }
  8027. if ($sumPrice == 0)
  8028. $collectHtml .= '<td class="taR">-</td>';
  8029. else
  8030. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8031. $total += $sumPrice;
  8032. }
  8033. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8034. $data ['companyTotalHtml'] = $collectHtml;
  8035. $data ['total'] = $total;
  8036. // statistics html
  8037. // echo $cidString;
  8038. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  8039. if (empty ( $stList ))
  8040. $stList = array (
  8041. 'rePrice' => 0,
  8042. 'agPrice' => 0
  8043. );
  8044. $data ['stList'] = array (
  8045. 'rePrice' => $stList ['rePrice'],
  8046. 'agPrice' => $stList ['agPrice'],
  8047. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8048. );
  8049. $data ['year'] = $year;
  8050. $data ['memu'] = "receipt";
  8051. $data ['staff'] = $this->staff;
  8052. $data ['receiptMemu'] = 'companyCategoryCollect';
  8053. $data ['verifyId'] = $this->verifyId;
  8054. $data ['executeId'] = $this->executeId;
  8055. // year staff status 2,4
  8056. if ($year < date ( "Y" )) {
  8057. Doo::loadModel ( 'receipt' );
  8058. $receipt = new receipt ();
  8059. $receiptList = $receipt->find ( array (
  8060. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  8061. 'asArray' => true
  8062. ) );
  8063. if (empty ( $receiptList )) {
  8064. ob_start ();
  8065. $this->render ( "/admin/saeaCompanyCollect", $data );
  8066. $this->cacheFile ( $path );
  8067. die ();
  8068. }
  8069. }
  8070. $this->render ( "/admin/saeaCompanyCollect", $data );
  8071. }
  8072. function categoryCollectDetail() {
  8073. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8074. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  8075. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  8076. $this->showCache ( $path );
  8077. Doo::loadModel ( 'statistics' );
  8078. $statistics = new statistics ();
  8079. Doo::loadModel ( "receiptDetail" );
  8080. $receiptDetail = new receiptDetail ();
  8081. Doo::loadModel ( 'L_category' );
  8082. $Lcategory = new L_category ();
  8083. Doo::loadModel ( 'accountItem' );
  8084. $accountItem = new accountItem ();
  8085. Doo::loadModel ( "receiptAuthorityManage" );
  8086. $receiptAuthorityManage = new receiptAuthorityManage ();
  8087. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  8088. $cidList = array ();
  8089. foreach ( $imcStaff as $key => $value ) {
  8090. array_push ( $cidList, $value ['cid'] );
  8091. }
  8092. $cidString = implode ( ',', $cidList );
  8093. $LcategoryList = $Lcategory->find ( array (
  8094. 'where' => 'cid in (' . $cidString . ')',
  8095. 'asArray' => true
  8096. ) );
  8097. if ($cid == 0) {
  8098. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  8099. if ($cid == 0)
  8100. $cid = $LcategoryList [0] ['cid'];
  8101. }
  8102. $data ['LcategoryList'] = $LcategoryList;
  8103. $receiptCollectList = $receiptDetail->find ( array (
  8104. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8105. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  8106. 'groupby' => 'item,Month(pastDate)',
  8107. 'asArray' => true
  8108. ) );
  8109. $accountList = $accountItem->find ( array (
  8110. 'asArray' => true
  8111. ) );
  8112. // create CollectDetail HTML
  8113. $collectHtml = array ();
  8114. foreach ( $accountList as $key => $value ) {
  8115. $html = "";
  8116. $asum = 0;
  8117. for($i = 1; $i <= 12; $i ++) {
  8118. $falg = true;
  8119. foreach ( $receiptCollectList as $v ) {
  8120. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  8121. $asum += $v ['price'];
  8122. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8123. $falg = false;
  8124. break;
  8125. }
  8126. }
  8127. if ($falg)
  8128. $html .= '<td class="taR">-</td>';
  8129. }
  8130. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8131. $collectHtml [$value ['category']] [$value ['name']] = $html;
  8132. }
  8133. $data ['collectHtml'] = $collectHtml;
  8134. // create Adjustment price html
  8135. $receiptCollectList = $receiptDetail->find ( array (
  8136. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  8137. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  8138. 'groupby' => 'itemCategory,Month(pastDate)',
  8139. 'asArray' => true
  8140. ) );
  8141. $adjustment = array ();
  8142. $collectArray = array (
  8143. '日常相关费用' => array (),
  8144. '差旅相关费用' => array (),
  8145. '培训班费用' => array (),
  8146. '其他' => array ()
  8147. );
  8148. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  8149. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  8150. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  8151. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  8152. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  8153. array_push ( $collectArray ['培训班费用'], $collectHtml );
  8154. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  8155. array_push ( $collectArray ['其他'], $collectHtml );
  8156. $data ['collectArray'] = $collectArray;
  8157. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  8158. array_push ( $adjustment, $collectHtml );
  8159. $data ['adjustment'] = $adjustment;
  8160. // total price html
  8161. $collectHtml = "";
  8162. $total = 0;
  8163. for($i = 1; $i <= 12; $i ++) {
  8164. $sumPrice = 0;
  8165. foreach ( $receiptCollectList as $key => $value ) {
  8166. if ($value ['month'] == $i) {
  8167. $sumPrice += $value ['price'];
  8168. }
  8169. }
  8170. if ($sumPrice == 0)
  8171. $collectHtml .= '<td class="taR">-</td>';
  8172. else
  8173. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8174. $total += $sumPrice;
  8175. }
  8176. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8177. // statistics html
  8178. $stList = $statistics->statisticsByCid ( $year, $cid );
  8179. if (empty ( $stList ))
  8180. $stList = array (
  8181. 'rePrice' => 0,
  8182. 'agPrice' => 0
  8183. );
  8184. $data ['stList'] = array (
  8185. 'rePrice' => $stList ['rePrice'],
  8186. 'agPrice' => $stList ['agPrice'],
  8187. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8188. );
  8189. $data ['totalYear'] = $total;
  8190. $data ['year'] = $year;
  8191. $data ['cid'] = $cid;
  8192. $data ['memu'] = "receipt";
  8193. $data ['staff'] = $this->staff;
  8194. $data ['receiptMemu'] = 'companyCategoryCollect';
  8195. $data ['verifyId'] = $this->verifyId;
  8196. $data ['executeId'] = $this->executeId;
  8197. // year staff status 2,4
  8198. if ($year < date ( "Y" )) {
  8199. Doo::loadModel ( 'receipt' );
  8200. $receipt = new receipt ();
  8201. $receiptList = $receipt->find ( array (
  8202. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  8203. 'asArray' => true
  8204. ) );
  8205. if (empty ( $receiptList )) {
  8206. ob_start ();
  8207. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  8208. $this->cacheFile ( $path );
  8209. die ();
  8210. }
  8211. }
  8212. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  8213. }
  8214. function staffCollect() {
  8215. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8216. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  8217. // $this->showCache($path);
  8218. Doo::loadModel ( 'statistics' );
  8219. $statistics = new statistics ();
  8220. Doo::loadModel ( "receiptDetail" );
  8221. $receiptDetail = new receiptDetail ();
  8222. Doo::loadModel ( 'L_category' );
  8223. $Lcategory = new L_category ();
  8224. Doo::loadModel ( 'accountItem' );
  8225. $accountItem = new accountItem ();
  8226. Doo::loadModel ( 'staff' );
  8227. $staff = new staff ();
  8228. Doo::loadModel ( 'itemStatistics' );
  8229. $itemStatistics = new itemStatistics ();
  8230. Doo::loadModel ( "receiptAuthorityManage" );
  8231. $receiptAuthorityManage = new receiptAuthorityManage ();
  8232. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  8233. $cidList = array ();
  8234. foreach ( $imcStaff as $key => $value ) {
  8235. array_push ( $cidList, $value ['cid'] );
  8236. }
  8237. $cidString = implode ( ',', $cidList );
  8238. // statistics html
  8239. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  8240. if (empty ( $stList ))
  8241. $stList = array (
  8242. 'rePrice' => 0,
  8243. 'agPrice' => 0
  8244. );
  8245. $data ['stList'] = array (
  8246. 'rePrice' => $stList ['rePrice'],
  8247. 'agPrice' => $stList ['agPrice'],
  8248. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8249. );
  8250. // ---
  8251. $staffList = $staff->find ( array (
  8252. 'where' => 'username !="admin"',
  8253. 'asArray' => true
  8254. ) );
  8255. $LcategoryList = $Lcategory->find ( array (
  8256. 'asArray' => true
  8257. ) ); // 'staff='.$this->staff[0]['sid']." and
  8258. $itemStatisticsList = $itemStatistics->find ( array (
  8259. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8260. 'where' => " Year(date)=" . $year . ' and cid in (' . $cidString . ')',
  8261. 'groupby' => 'staff,Month(date)',
  8262. 'asArray' => true
  8263. ) );
  8264. $categoryList = $staff->find ( array (
  8265. 'select' => 'COUNT(*) as count,cid,category',
  8266. 'where' => 'username !="admin" and cid in (' . $cidString . ')',
  8267. 'groupby' => 'cid',
  8268. 'asArray' => true
  8269. ) );
  8270. // print_r($itemStatisticsList);die;
  8271. // ceatre companyCollectHtml
  8272. foreach ( $categoryList as $vlu ) {
  8273. $count = $vlu ['count'] + 1;
  8274. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  8275. $m1 = 0;
  8276. $m2 = 0;
  8277. $m3 = 0;
  8278. $m4 = 0;
  8279. $m5 = 0;
  8280. $m6 = 0;
  8281. $m7 = 0;
  8282. $m8 = 0;
  8283. $m9 = 0;
  8284. $m10 = 0;
  8285. $m11 = 0;
  8286. $m12 = 0;
  8287. $m13 = 0;
  8288. foreach ( $staffList as $value ) {
  8289. if ($vlu ['cid'] == $value ['cid']) {
  8290. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  8291. $asum = 0;
  8292. for($i = 1; $i <= 12; $i ++) {
  8293. $falg = true;
  8294. foreach ( $itemStatisticsList as $v ) {
  8295. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  8296. if ($v ['month'] == 1)
  8297. $m1 += $v ['price'];
  8298. if ($v ['month'] == 2)
  8299. $m2 += $v ['price'];
  8300. if ($v ['month'] == 3)
  8301. $m3 += $v ['price'];
  8302. if ($v ['month'] == 4)
  8303. $m4 += $v ['price'];
  8304. if ($v ['month'] == 5)
  8305. $m5 += $v ['price'];
  8306. if ($v ['month'] == 6)
  8307. $m6 += $v ['price'];
  8308. if ($v ['month'] == 7)
  8309. $m7 += $v ['price'];
  8310. if ($v ['month'] == 8)
  8311. $m8 += $v ['price'];
  8312. if ($v ['month'] == 9)
  8313. $m9 += $v ['price'];
  8314. if ($v ['month'] == 10)
  8315. $m10 += $v ['price'];
  8316. if ($v ['month'] == 11)
  8317. $m11 += $v ['price'];
  8318. if ($v ['month'] == 12)
  8319. $m12 += $v ['price'];
  8320. $asum += $v ['price'];
  8321. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8322. $falg = false;
  8323. break;
  8324. }
  8325. }
  8326. if ($falg)
  8327. $html .= '<td class="taR">-</td>';
  8328. }
  8329. $m13 += $asum;
  8330. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8331. $collectHtml [$value ['username'] . '_' . $value ['sid']] = array (
  8332. 'html' => $html,
  8333. 'sid' => $value ['sid']
  8334. );
  8335. $html = "";
  8336. }
  8337. }
  8338. $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>
  8339. <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>
  8340. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  8341. $collectHtml [$vlu ['cid']] = array (
  8342. 'html' => $hl,
  8343. 'sid' => ''
  8344. );
  8345. }
  8346. $data ['companyHtml'] = $collectHtml;
  8347. // total price html
  8348. $collectHtml = "";
  8349. $total = 0;
  8350. for($i = 1; $i <= 12; $i ++) {
  8351. $sumPrice = 0;
  8352. foreach ( $itemStatisticsList as $key => $value ) {
  8353. if ($value ['month'] == $i) {
  8354. $sumPrice += $value ['price'];
  8355. }
  8356. }
  8357. if ($sumPrice == 0)
  8358. $collectHtml .= '<td class="taR">-</td>';
  8359. else
  8360. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8361. $total += $sumPrice;
  8362. }
  8363. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8364. $data ['companyTotalHtml'] = $collectHtml;
  8365. $data ['total'] = $total;
  8366. $data ['year'] = $year;
  8367. $data ['memu'] = "receipt";
  8368. $data ['staff'] = $this->staff;
  8369. $data ['receiptMemu'] = 'companyCategoryCollect';
  8370. $data ['verifyId'] = $this->verifyId;
  8371. $data ['executeId'] = $this->executeId;
  8372. if ($year <= date ( "Y" )) {
  8373. Doo::loadModel ( 'receipt' );
  8374. $receipt = new receipt ();
  8375. $receiptList = $receipt->find ( array (
  8376. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  8377. 'asArray' => true
  8378. ) );
  8379. if (empty ( $receiptList )) { // generated files
  8380. ob_start ();
  8381. $this->render ( "/admin/saeaStaffCollectB", $data );
  8382. $this->cacheFile ( $path );
  8383. die ();
  8384. }
  8385. }
  8386. $this->render ( "/admin/saeaStaffCollectB", $data );
  8387. }
  8388. function staffCollectBak() {
  8389. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8390. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  8391. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  8392. $this->showCache ( $path );
  8393. Doo::loadModel ( 'statistics' );
  8394. $statistics = new statistics ();
  8395. Doo::loadModel ( "receiptDetail" );
  8396. $receiptDetail = new receiptDetail ();
  8397. Doo::loadModel ( 'L_category' );
  8398. $Lcategory = new L_category ();
  8399. Doo::loadModel ( 'accountItem' );
  8400. $accountItem = new accountItem ();
  8401. Doo::loadModel ( 'staff' );
  8402. $staff = new staff ();
  8403. Doo::loadModel ( 'itemStatistics' );
  8404. $itemStatistics = new itemStatistics ();
  8405. $itemStatisticsList = $itemStatistics->find ( array (
  8406. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8407. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8408. 'groupby' => 'staff,itemCategory,Month(date)',
  8409. 'asArray' => true
  8410. ) );
  8411. $itemCategoryList = $itemStatistics->find ( array (
  8412. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8413. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8414. 'groupby' => 'cid,itemCategory,Month(date)',
  8415. 'asArray' => true
  8416. ) );
  8417. $LcategoryList = $Lcategory->find ( array (
  8418. 'asArray' => true
  8419. ) );
  8420. $staffList = $staff->find ( array (
  8421. 'asArray' => true
  8422. ) );
  8423. $htmlArray = array ();
  8424. foreach ( $LcategoryList as $value ) {
  8425. $htmlArray [$value ['title']] = array ();
  8426. foreach ( $staffList as $v ) {
  8427. if ($value ['cid'] == $v ['cid']) {
  8428. $html = "";
  8429. $falg = true;
  8430. $staffSumPrice = 0;
  8431. foreach ( $itemStatisticsList as $a ) {
  8432. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  8433. if (empty ( $a ['price'] )) {
  8434. $html .= '<td class="taR">-</td>';
  8435. $falg = false;
  8436. break;
  8437. } else {
  8438. $staffSumPrice += $a ['price'];
  8439. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8440. $falg = false;
  8441. break;
  8442. }
  8443. }
  8444. }
  8445. if ($falg) {
  8446. $html .= '<td class="taR">-</td>';
  8447. $falg = true;
  8448. }
  8449. $falg = true;
  8450. foreach ( $itemStatisticsList as $a ) {
  8451. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  8452. if (empty ( $a ['price'] )) {
  8453. $html .= '<td class="taR">-</td>';
  8454. $falg = false;
  8455. break;
  8456. } else {
  8457. $staffSumPrice += $a ['price'];
  8458. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8459. $falg = false;
  8460. break;
  8461. }
  8462. }
  8463. }
  8464. if ($falg) {
  8465. $html .= '<td class="taR">-</td>';
  8466. $falg = true;
  8467. }
  8468. $falg = true;
  8469. foreach ( $itemStatisticsList as $a ) {
  8470. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  8471. if (empty ( $a ['price'] )) {
  8472. $html .= '<td class="taR">-</td>';
  8473. $falg = false;
  8474. break;
  8475. } else {
  8476. $staffSumPrice += $a ['price'];
  8477. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8478. $falg = false;
  8479. break;
  8480. }
  8481. }
  8482. }
  8483. if ($falg) {
  8484. $html .= '<td class="taR">-</td>';
  8485. $falg = true;
  8486. }
  8487. $falg = true;
  8488. foreach ( $itemStatisticsList as $a ) {
  8489. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  8490. if (! empty ( $a ['price'] )) {
  8491. $staffSumPrice += $a ['price'];
  8492. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8493. $falg = false;
  8494. break;
  8495. } else {
  8496. $html .= '<td class="taR">-</td>';
  8497. $falg = false;
  8498. break;
  8499. }
  8500. }
  8501. }
  8502. if ($falg) {
  8503. $html .= '<td class="taR">-</td>';
  8504. $falg = true;
  8505. }
  8506. $falg = true;
  8507. foreach ( $itemStatisticsList as $a ) {
  8508. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  8509. if (! empty ( $a ['price'] )) {
  8510. $staffSumPrice += $a ['price'];
  8511. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8512. $falg = false;
  8513. break;
  8514. } else {
  8515. $html .= '<td class="taR">-</td>';
  8516. $falg = false;
  8517. break;
  8518. }
  8519. }
  8520. }
  8521. if ($falg) {
  8522. $html .= '<td class="taR">-</td>';
  8523. $falg = true;
  8524. }
  8525. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  8526. $htmlArray [$value ['title']] [$v ['username']] = $html;
  8527. }
  8528. }
  8529. /* -- --- */
  8530. // 合计费用
  8531. $cateHtml = "";
  8532. $catePrice = 0;
  8533. $cateFalg = true;
  8534. foreach ( $itemCategoryList as $l ) {
  8535. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  8536. if (empty ( $l ['price'] )) {
  8537. $cateHtml .= '<td class="colGreen taR">-</td>';
  8538. $cateFalg = false;
  8539. break;
  8540. } else {
  8541. $catePrice += $l ['price'];
  8542. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8543. $cateFalg = false;
  8544. break;
  8545. }
  8546. }
  8547. }
  8548. if ($cateFalg) {
  8549. $cateHtml .= '<td class="colGreen taR">-</td>';
  8550. $cateFalg = true;
  8551. }
  8552. $cateFalg = true;
  8553. foreach ( $itemCategoryList as $l ) {
  8554. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  8555. if (empty ( $l ['price'] )) {
  8556. $cateHtml .= '<td class="colGreen taR">-</td>';
  8557. $cateFalg = false;
  8558. break;
  8559. } else {
  8560. $catePrice += $l ['price'];
  8561. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8562. $cateFalg = false;
  8563. break;
  8564. }
  8565. }
  8566. }
  8567. if ($cateFalg) {
  8568. $cateHtml .= '<td class="colGreen taR">-</td>';
  8569. $cateFalg = true;
  8570. }
  8571. $cateFalg = true;
  8572. foreach ( $itemCategoryList as $l ) {
  8573. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  8574. if (empty ( $l ['price'] )) {
  8575. $cateHtml .= '<td class="colGreen taR">-</td>';
  8576. $cateFalg = false;
  8577. break;
  8578. } else {
  8579. $catePrice += $l ['price'];
  8580. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8581. $cateFalg = false;
  8582. break;
  8583. }
  8584. }
  8585. }
  8586. if ($cateFalg) {
  8587. $cateHtml .= '<td class="colGreen taR">-</td>';
  8588. $cateFalg = true;
  8589. }
  8590. $cateFalg = true;
  8591. foreach ( $itemCategoryList as $l ) {
  8592. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  8593. if (empty ( $l ['price'] )) {
  8594. $cateHtml .= '<td class="colGreen taR">-</td>';
  8595. $cateFalg = false;
  8596. break;
  8597. } else {
  8598. $catePrice += $l ['price'];
  8599. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8600. $cateFalg = false;
  8601. break;
  8602. }
  8603. }
  8604. }
  8605. if ($cateFalg) {
  8606. $cateHtml .= '<td class="colGreen taR">-</td>';
  8607. $cateFalg = true;
  8608. }
  8609. $cateFalg = true;
  8610. foreach ( $itemCategoryList as $l ) {
  8611. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  8612. if (empty ( $l ['price'] )) {
  8613. $cateHtml .= '<td class="colGreen taR">-</td>';
  8614. $cateFalg = false;
  8615. break;
  8616. } else {
  8617. $catePrice += $l ['price'];
  8618. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8619. $cateFalg = false;
  8620. break;
  8621. }
  8622. }
  8623. }
  8624. if ($cateFalg) {
  8625. $cateHtml .= '<td class="colGreen taR">-</td>';
  8626. $cateFalg = true;
  8627. }
  8628. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  8629. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  8630. /* -- --- */
  8631. }
  8632. // print_r($htmlArray);die;
  8633. $data ['htmlArray'] = $htmlArray;
  8634. // statistics html
  8635. $stList = $statistics->getOne ( array (
  8636. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8637. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8638. 'groupby' => 'Month(date)',
  8639. 'asArray' => true
  8640. ) );
  8641. if (empty ( $stList ))
  8642. $stList = array (
  8643. 'rePrice' => 0,
  8644. 'agPrice' => 0
  8645. );
  8646. $data ['stList'] = array (
  8647. 'rePrice' => $stList ['rePrice'],
  8648. 'agPrice' => $stList ['agPrice'],
  8649. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8650. );
  8651. $monthHtml = "";
  8652. for($i = 1; $i <= 12; $i ++) {
  8653. if ($i == $month)
  8654. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8655. else
  8656. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8657. }
  8658. $data ['monthHtml'] = $monthHtml;
  8659. $data ['year'] = $year;
  8660. $data ['month'] = $month;
  8661. $data ['memu'] = "receipt";
  8662. $data ['staff'] = $this->staff;
  8663. $data ['receiptMemu'] = 'companyCategoryCollect';
  8664. $data ['verifyId'] = $this->verifyId;
  8665. $data ['executeId'] = $this->executeId;
  8666. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  8667. Doo::loadModel ( 'receipt' );
  8668. $receipt = new receipt ();
  8669. $receiptList = $receipt->find ( array (
  8670. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  8671. 'asArray' => true
  8672. ) );
  8673. if (empty ( $receiptList )) { // generated files
  8674. ob_start ();
  8675. $this->render ( "/admin/saeaStaffCollect", $data );
  8676. $this->cacheFile ( $path );
  8677. die ();
  8678. }
  8679. }
  8680. $this->render ( "/admin/saeaStaffCollect", $data );
  8681. }
  8682. function lyt() {
  8683. Doo::loadModel ( "receiptDetail" );
  8684. $receiptDetail = new receiptDetail ();
  8685. $receiptCollectList = $receiptDetail->find ( array (
  8686. 'where' => 'status=1 ',
  8687. 'asArray' => true
  8688. ) );
  8689. foreach ( $receiptCollectList as $key => $value ) {
  8690. $receiptDetail = new receiptDetail ();
  8691. $receiptDetail->pastDate = $value ['date'];
  8692. $receiptDetail->update ( array (
  8693. 'where' => "rdid= '" . $value ['rdid'] . "'"
  8694. ) );
  8695. }
  8696. }
  8697. function staffCollectMonthDetail() {
  8698. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8699. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8700. if (! $year)
  8701. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8702. if (! $month)
  8703. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8704. Doo::loadModel ( 'staff' );
  8705. $staff = new staff ();
  8706. Doo::loadModel ( "receiptDetail" );
  8707. $receiptDetail = new receiptDetail ();
  8708. Doo::loadModel ( 'accountItem' );
  8709. $accountItem = new accountItem ();
  8710. Doo::loadModel ( 'statistics' );
  8711. $statistics = new statistics ();
  8712. Doo::loadModel ( 'L_category' );
  8713. $lCategory = new L_category ();
  8714. Doo::loadModel ( "receiptAuthorityManage" );
  8715. $receiptAuthorityManage = new receiptAuthorityManage ();
  8716. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  8717. $cidList = array ();
  8718. foreach ( $imcStaff as $key => $value ) {
  8719. array_push ( $cidList, $value ['cid'] );
  8720. }
  8721. $cidString = implode ( ',', $cidList );
  8722. $staffList = $staff->find ( array (
  8723. 'where' => 'username!="admin" and cid in (' . $cidString . ')',
  8724. 'asArray' => true
  8725. ) );
  8726. $categoryList = $staff->find ( array (
  8727. 'select' => 'COUNT(*) as count,cid,category',
  8728. 'where' => 'username !="admin" and cid in (' . $cidString . ')',
  8729. 'groupby' => 'cid',
  8730. 'asArray' => true
  8731. ) );
  8732. $list = array ();
  8733. foreach ( $categoryList as $vlu ) {
  8734. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8735. $r1 = 0;
  8736. $r2 = 0;
  8737. $r3 = 0;
  8738. $r4 = 0;
  8739. $r5 = 0;
  8740. $r6 = 0;
  8741. $r7 = 0;
  8742. $r8 = 0;
  8743. $r9 = 0;
  8744. $r10 = 0;
  8745. $r11 = 0;
  8746. $r12 = 0;
  8747. $r13 = 0;
  8748. $r14 = 0;
  8749. $r15 = 0;
  8750. $r16 = 0;
  8751. $r17 = 0;
  8752. $r18 = 0;
  8753. $c1 = 0;
  8754. $c2 = 0;
  8755. $c3 = 0;
  8756. $c4 = 0;
  8757. $c5 = 0;
  8758. $c6 = 0;
  8759. $p1 = 0;
  8760. $p2 = 0;
  8761. $p3 = 0;
  8762. $p4 = 0;
  8763. $p5 = 0;
  8764. $p6 = 0;
  8765. $p7 = 0;
  8766. $p8 = 0;
  8767. $p9 = 0;
  8768. $t1 = 0;
  8769. $t2 = 0;
  8770. $t3 = 0;
  8771. $t4 = 0;
  8772. $t5 = 0;
  8773. $s1 = 0;
  8774. $m1 = 0;
  8775. foreach ( $staffList as $value ) {
  8776. if ($vlu ['cid'] == $value ['cid']) {
  8777. // pastDate
  8778. $receiptCollectList = $receiptDetail->find ( array (
  8779. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8780. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8781. 'groupby' => 'item,Month(pastDate),itemCategory',
  8782. 'asArray' => true
  8783. ) );
  8784. // if ($value['sid']==42){
  8785. // print_r($receiptCollectList);die;
  8786. // }
  8787. if (! empty ( $receiptCollectList )) {
  8788. $receiptL = array (
  8789. '日常相关费用' => array (),
  8790. '差旅相关费用' => array (),
  8791. '培训班费用' => array (),
  8792. '其他' => array ()
  8793. );
  8794. $html = "";
  8795. $psum = 0;
  8796. $item = array (
  8797. '市内交通费',
  8798. '市内出租费',
  8799. '办事处房租',
  8800. '电话费',
  8801. '水费',
  8802. '电费',
  8803. '办公费用',
  8804. '邮寄费',
  8805. '其他费用',
  8806. '车辆费用',
  8807. '广告费',
  8808. '团队建设费',
  8809. '物业管理费',
  8810. '宽带费',
  8811. '人员薪酬',
  8812. '公积金',
  8813. '社保'
  8814. );
  8815. foreach ( $item as $va ) {
  8816. $falg = true;
  8817. foreach ( $receiptCollectList as $v ) {
  8818. if ($v ['itemCategory'] == '日常相关费用') {
  8819. if ($v ['item'] == $va) {
  8820. if ($va == '市内交通费')
  8821. $r1 += $v ['price'];
  8822. if ($va == '市内出租费')
  8823. $r2 += $v ['price'];
  8824. if ($va == '办事处房租')
  8825. $r3 += $v ['price'];
  8826. if ($va == '电话费')
  8827. $r4 += $v ['price'];
  8828. if ($va == '水费')
  8829. $r5 += $v ['price'];
  8830. if ($va == '电费')
  8831. $r6 += $v ['price'];
  8832. if ($va == '办公费用')
  8833. $r7 += $v ['price'];
  8834. if ($va == '邮寄费')
  8835. $r8 += $v ['price'];
  8836. if ($va == '其他费用')
  8837. $r9 += $v ['price'];
  8838. if ($va == '车辆费用')
  8839. $r10 += $v ['price'];
  8840. if ($va == '广告费')
  8841. $r11 += $v ['price'];
  8842. if ($va == '团队建设费')
  8843. $r13 += $v ['price'];
  8844. if ($va == '物业管理费')
  8845. $r14 += $v ['price'];
  8846. if ($va == '宽带费')
  8847. $r15 += $v ['price'];
  8848. if ($va == '公积金')
  8849. $r16 += $v ['price'];
  8850. if ($va == '社保')
  8851. $r17 += $v ['price'];
  8852. if ($va == '人员薪酬')
  8853. $r18 += $v ['price'];
  8854. $psum += $v ['price'];
  8855. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8856. $falg = false;
  8857. break;
  8858. }
  8859. }
  8860. }
  8861. if ($falg)
  8862. $html .= '<td class="taR">-</td>';
  8863. }
  8864. $r12 += $psum;
  8865. if (! empty ( $psum ))
  8866. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8867. else
  8868. $psum = '<td class="colGreen taR">-</td>';
  8869. $receiptL ['日常相关费用'] = $psum . $html;
  8870. /* ----------------------------------- */
  8871. $html = "";
  8872. $psum = 0;
  8873. $item = array (
  8874. '往来交通费',
  8875. '市内交通费',
  8876. '出差住宿费',
  8877. '出差补助',
  8878. '其他费用'
  8879. );
  8880. foreach ( $item as $va ) {
  8881. $falg = true;
  8882. foreach ( $receiptCollectList as $v ) {
  8883. if ($v ['itemCategory'] == '差旅相关费用') {
  8884. if ($v ['item'] == $va) {
  8885. if ($va == '往来交通费')
  8886. $c1 += $v ['price'];
  8887. if ($va == '市内交通费')
  8888. $c2 += $v ['price'];
  8889. if ($va == '出差住宿费')
  8890. $c3 += $v ['price'];
  8891. if ($va == '出差补助')
  8892. $c4 += $v ['price'];
  8893. if ($va == '其他费用')
  8894. $c5 += $v ['price'];
  8895. $psum += $v ['price'];
  8896. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8897. $falg = false;
  8898. break;
  8899. }
  8900. }
  8901. }
  8902. if ($falg)
  8903. $html .= '<td class="taR">-</td>';
  8904. }
  8905. $c6 += $psum;
  8906. if (! empty ( $psum ))
  8907. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8908. else
  8909. $psum = '<td class="colGreen taR">-</td>';
  8910. $receiptL ['差旅相关费用'] = $psum . $html;
  8911. /* ------------------------------------- */
  8912. $html = "";
  8913. $psum = 0;
  8914. $item = array (
  8915. '场租费',
  8916. '薪酬',
  8917. '住宿费',
  8918. '交通费',
  8919. '餐饮费',
  8920. '办公费',
  8921. '公关费',
  8922. '其他'
  8923. );
  8924. foreach ( $item as $va ) {
  8925. $falg = true;
  8926. foreach ( $receiptCollectList as $v ) {
  8927. if ($v ['itemCategory'] == '培训班费用') {
  8928. if ($v ['item'] == $va) {
  8929. if ($va == '场租费')
  8930. $p1 += $v ['price'];
  8931. if ($va == '薪酬')
  8932. $p2 += $v ['price'];
  8933. if ($va == '住宿费')
  8934. $p3 += $v ['price'];
  8935. if ($va == '交通费')
  8936. $p4 += $v ['price'];
  8937. if ($va == '餐饮费')
  8938. $p5 += $v ['price'];
  8939. if ($va == '办公费')
  8940. $p6 += $v ['price'];
  8941. if ($va == '公关费')
  8942. $p7 += $v ['price'];
  8943. if ($va == '其他')
  8944. $p8 += $v ['price'];
  8945. $psum += $v ['price'];
  8946. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8947. $falg = false;
  8948. break;
  8949. }
  8950. }
  8951. }
  8952. if ($falg)
  8953. $html .= '<td class="taR">-</td>';
  8954. }
  8955. $p9 += $psum;
  8956. if (! empty ( $psum ))
  8957. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8958. else
  8959. $psum = '<td class="colGreen taR">-</td>';
  8960. $receiptL ['培训班费用'] = $psum . $html;
  8961. /* ------------------------------------- */
  8962. $html = "";
  8963. $psum = 0;
  8964. $item = array (
  8965. '公关费',
  8966. '广告费',
  8967. '借款',
  8968. '可自加费用'
  8969. );
  8970. foreach ( $item as $va ) {
  8971. $falg = true;
  8972. foreach ( $receiptCollectList as $v ) {
  8973. if ($v ['itemCategory'] == '其他') {
  8974. // if ($value['sid']==42){
  8975. //
  8976. // echo var_dump($v['item']);
  8977. // echo var_dump($va);
  8978. // echo var_dump($v['item']==" ".$va);
  8979. // echo $v['item']."==".$va."/<br/>";
  8980. // //print_r( $receiptCollectList);//echo $va;
  8981. // }
  8982. if (trim ( $v ['item'] ) == $va) {
  8983. if ($va == '公关费')
  8984. $t1 += $v ['price'];
  8985. if ($va == '广告费') {
  8986. $t2 += $v ['price'];
  8987. }
  8988. if ($va == '借款')
  8989. $t3 += $v ['price'];
  8990. if ($va == '可自加费用')
  8991. $t4 += $v ['price'];
  8992. $psum += $v ['price'];
  8993. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8994. $falg = false;
  8995. break;
  8996. }
  8997. }
  8998. }
  8999. if ($falg)
  9000. $html .= '<td class="taR">-</td>';
  9001. }
  9002. $t5 += $psum;
  9003. if (! empty ( $psum ))
  9004. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9005. else
  9006. $psum = '<td class="colGreen taR">-</td>';
  9007. $receiptL ['其他'] = $psum . $html;
  9008. /* ------------------------------------- */
  9009. $html = "";
  9010. $psum = 0;
  9011. foreach ( $receiptCollectList as $v ) {
  9012. if ($v ['itemCategory'] == '报销金额调整') {
  9013. if (! empty ( $v ['price'] )) {
  9014. $psum += $v ['price'];
  9015. }
  9016. }
  9017. }
  9018. $s1 += $psum;
  9019. if (! empty ( $psum ))
  9020. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9021. else
  9022. $psum = '<td class="taR colOrange">-</td>';
  9023. $receiptL ['报销金额调整'] = $psum . $html;
  9024. } else {
  9025. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9026. <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>
  9027. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9028. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9029. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9030. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9031. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9032. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9033. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9034. }
  9035. $monthStaffPrice = $receiptDetail->find ( array (
  9036. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9037. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9038. 'groupby' => 'Month(pastDate)',
  9039. 'asArray' => true
  9040. ) );
  9041. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  9042. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  9043. $m1 += $monthStaffPrice [0] ['price'];
  9044. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9045. } else
  9046. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9047. $receiptL ['usernameEn'] = urlencode ( $value ['username'] );
  9048. $list [$value ['username']] = $receiptL;
  9049. }
  9050. }
  9051. $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>
  9052. <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>
  9053. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td><td class="taR">' . $r18 . '</td> <td class="taR">' . $r16 . '</td><td class="taR">' . $r17 . '</td>';
  9054. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  9055. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  9056. $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>
  9057. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  9058. $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>';
  9059. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  9060. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  9061. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  9062. }
  9063. $data ['list'] = $list;
  9064. // print_r($list);
  9065. $receiptCollectList = $receiptDetail->find ( array (
  9066. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9067. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9068. 'groupby' => 'item,Month(pastDate),itemCategory',
  9069. 'asArray' => true
  9070. ) );
  9071. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9072. // statistics html
  9073. $stList = $statistics->getOne ( array (
  9074. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9075. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9076. 'groupby' => 'Month(date)',
  9077. 'asArray' => true
  9078. ) );
  9079. if (empty ( $stList ))
  9080. $stList = array (
  9081. 'rePrice' => 0,
  9082. 'agPrice' => 0
  9083. );
  9084. $data ['stList'] = array (
  9085. 'rePrice' => $stList ['rePrice'],
  9086. 'agPrice' => $stList ['agPrice'],
  9087. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9088. );
  9089. $monthHtml = "";
  9090. for($i = 1; $i <= 12; $i ++) {
  9091. if ($i == $month)
  9092. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9093. else
  9094. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9095. }
  9096. $data ['monthHtml'] = $monthHtml;
  9097. $data ['year'] = $year;
  9098. $data ['month'] = $month;
  9099. $data ['memu'] = "receipt";
  9100. $data ['staff'] = $this->staff;
  9101. $data ['receiptMemu'] = 'companyCategoryCollect';
  9102. $data ['verifyId'] = $this->verifyId;
  9103. $data ['executeId'] = $this->executeId;
  9104. $this->render ( "/admin/staffCollectMonthDetail", $data );
  9105. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9106. }
  9107. function staffCollectMonthDetail2() {
  9108. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9109. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9110. if (! $year)
  9111. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9112. if (! $month)
  9113. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9114. Doo::loadModel ( 'staff' );
  9115. $staff = new staff ();
  9116. Doo::loadModel ( "receiptDetail" );
  9117. $receiptDetail = new receiptDetail ();
  9118. Doo::loadModel ( 'accountItem' );
  9119. $accountItem = new accountItem ();
  9120. Doo::loadModel ( 'statistics' );
  9121. $statistics = new statistics ();
  9122. Doo::loadModel ( 'L_category' );
  9123. $lCategory = new L_category ();
  9124. $staffList = $staff->find ( array (
  9125. 'where' => 'username!="admin"',
  9126. 'asArray' => true
  9127. ) );
  9128. $categoryList = $staff->find ( array (
  9129. 'select' => 'COUNT(*) as count,cid,category',
  9130. 'where' => 'username !="admin"',
  9131. 'groupby' => 'cid',
  9132. 'asArray' => true
  9133. ) );
  9134. $list = array ();
  9135. foreach ( $categoryList as $vlu ) {
  9136. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  9137. $r1 = 0;
  9138. $r2 = 0;
  9139. $r3 = 0;
  9140. $r4 = 0;
  9141. $r5 = 0;
  9142. $r6 = 0;
  9143. $r7 = 0;
  9144. $r8 = 0;
  9145. $r9 = 0;
  9146. $r10 = 0;
  9147. $r11 = 0;
  9148. $r12 = 0;
  9149. $r13 = 0;
  9150. $r14 = 0;
  9151. $r15 = 0;
  9152. $c1 = 0;
  9153. $c2 = 0;
  9154. $c3 = 0;
  9155. $c4 = 0;
  9156. $c5 = 0;
  9157. $c6 = 0;
  9158. $p1 = 0;
  9159. $p2 = 0;
  9160. $p3 = 0;
  9161. $p4 = 0;
  9162. $p5 = 0;
  9163. $p6 = 0;
  9164. $p7 = 0;
  9165. $p8 = 0;
  9166. $p9 = 0;
  9167. $t1 = 0;
  9168. $t2 = 0;
  9169. $t3 = 0;
  9170. $t4 = 0;
  9171. $t5 = 0;
  9172. $s1 = 0;
  9173. $m1 = 0;
  9174. foreach ( $staffList as $value ) {
  9175. if ($vlu ['cid'] == $value ['cid']) {
  9176. $receiptCollectList = $receiptDetail->find ( array (
  9177. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9178. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9179. 'groupby' => 'item,Month(date),itemCategory',
  9180. 'asArray' => true
  9181. ) );
  9182. if (! empty ( $receiptCollectList )) {
  9183. $receiptL = array (
  9184. '日常相关费用' => array (),
  9185. '差旅相关费用' => array (),
  9186. '培训班费用' => array (),
  9187. '其他' => array ()
  9188. );
  9189. $html = "";
  9190. $psum = 0;
  9191. $item = array (
  9192. '市内交通费',
  9193. '市内出租费',
  9194. '办事处房租',
  9195. '电话费',
  9196. '水费',
  9197. '电费',
  9198. '办公费用',
  9199. '邮寄费',
  9200. '其他费用',
  9201. '车辆费用',
  9202. '广告费',
  9203. '团队建设费',
  9204. '物业管理费',
  9205. '宽带费'
  9206. );
  9207. foreach ( $item as $va ) {
  9208. $falg = true;
  9209. foreach ( $receiptCollectList as $v ) {
  9210. if ($v ['itemCategory'] == '日常相关费用') {
  9211. if ($v ['item'] == $va) {
  9212. if ($va == '市内交通费')
  9213. $r1 += $v ['price'];
  9214. if ($va == '市内出租费')
  9215. $r2 += $v ['price'];
  9216. if ($va == '办事处房租')
  9217. $r3 += $v ['price'];
  9218. if ($va == '电话费')
  9219. $r4 += $v ['price'];
  9220. if ($va == '水费')
  9221. $r5 += $v ['price'];
  9222. if ($va == '电费')
  9223. $r6 += $v ['price'];
  9224. if ($va == '办公费用')
  9225. $r7 += $v ['price'];
  9226. if ($va == '邮寄费')
  9227. $r8 += $v ['price'];
  9228. if ($va == '其他费用')
  9229. $r9 += $v ['price'];
  9230. if ($va == '车辆费用')
  9231. $r10 += $v ['price'];
  9232. if ($va == '广告费')
  9233. $r11 += $v ['price'];
  9234. if ($va == '团队建设费')
  9235. $r13 += $v ['price'];
  9236. if ($va == '物业管理费')
  9237. $r14 += $v ['price'];
  9238. if ($va == '宽带费')
  9239. $r15 += $v ['price'];
  9240. $psum += $v ['price'];
  9241. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9242. $falg = false;
  9243. break;
  9244. }
  9245. }
  9246. }
  9247. if ($falg)
  9248. $html .= '<td class="taR">-</td>';
  9249. }
  9250. $r12 += $psum;
  9251. if (! empty ( $psum ))
  9252. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9253. else
  9254. $psum = '<td class="colGreen taR">-</td>';
  9255. $receiptL ['日常相关费用'] = $psum . $html;
  9256. /* ----------------------------------- */
  9257. $html = "";
  9258. $psum = 0;
  9259. $item = array (
  9260. '往来交通费',
  9261. '市内交通费',
  9262. '出差住宿费',
  9263. '出差补助',
  9264. '其他费用'
  9265. );
  9266. foreach ( $item as $va ) {
  9267. $falg = true;
  9268. foreach ( $receiptCollectList as $v ) {
  9269. if ($v ['itemCategory'] == '差旅相关费用') {
  9270. if ($v ['item'] == $va) {
  9271. if ($va == '往来交通费')
  9272. $c1 += $v ['price'];
  9273. if ($va == '市内交通费')
  9274. $c2 += $v ['price'];
  9275. if ($va == '出差住宿费')
  9276. $c3 += $v ['price'];
  9277. if ($va == '出差补助')
  9278. $c4 += $v ['price'];
  9279. if ($va == '其他费用')
  9280. $c5 += $v ['price'];
  9281. $psum += $v ['price'];
  9282. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9283. $falg = false;
  9284. break;
  9285. }
  9286. }
  9287. }
  9288. if ($falg)
  9289. $html .= '<td class="taR">-</td>';
  9290. }
  9291. $c6 += $psum;
  9292. if (! empty ( $psum ))
  9293. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9294. else
  9295. $psum = '<td class="colGreen taR">-</td>';
  9296. $receiptL ['差旅相关费用'] = $psum . $html;
  9297. /* ------------------------------------- */
  9298. $html = "";
  9299. $psum = 0;
  9300. $item = array (
  9301. '场租费',
  9302. '薪酬',
  9303. '住宿费',
  9304. '交通费',
  9305. '餐饮费',
  9306. '办公费',
  9307. '公关费',
  9308. '其他'
  9309. );
  9310. foreach ( $item as $va ) {
  9311. $falg = true;
  9312. foreach ( $receiptCollectList as $v ) {
  9313. if ($v ['itemCategory'] == '培训班费用') {
  9314. if ($v ['item'] == $va) {
  9315. if ($va == '场租费')
  9316. $p1 += $v ['price'];
  9317. if ($va == '薪酬')
  9318. $p2 += $v ['price'];
  9319. if ($va == '住宿费')
  9320. $p3 += $v ['price'];
  9321. if ($va == '交通费')
  9322. $p4 += $v ['price'];
  9323. if ($va == '餐饮费')
  9324. $p5 += $v ['price'];
  9325. if ($va == '办公费')
  9326. $p6 += $v ['price'];
  9327. if ($va == '公关费')
  9328. $p7 += $v ['price'];
  9329. if ($va == '其他')
  9330. $p8 += $v ['price'];
  9331. $psum += $v ['price'];
  9332. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9333. $falg = false;
  9334. break;
  9335. }
  9336. }
  9337. }
  9338. if ($falg)
  9339. $html .= '<td class="taR">-</td>';
  9340. }
  9341. $p9 += $psum;
  9342. if (! empty ( $psum ))
  9343. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9344. else
  9345. $psum = '<td class="colGreen taR">-</td>';
  9346. $receiptL ['培训班费用'] = $psum . $html;
  9347. /* ------------------------------------- */
  9348. $html = "";
  9349. $psum = 0;
  9350. $item = array (
  9351. '公关费',
  9352. '广告费',
  9353. '借款',
  9354. '可自加费用'
  9355. );
  9356. foreach ( $item as $va ) {
  9357. $falg = true;
  9358. foreach ( $receiptCollectList as $v ) {
  9359. if ($v ['itemCategory'] == '其他') {
  9360. if ($v ['item'] == $va) {
  9361. if ($va == '公关费')
  9362. $t1 += $v ['price'];
  9363. if ($va == '广告费')
  9364. $t2 += $v ['price'];
  9365. if ($va == '借款')
  9366. $t3 += $v ['price'];
  9367. if ($va == '可自加费用')
  9368. $t4 += $v ['price'];
  9369. $psum += $v ['price'];
  9370. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9371. $falg = false;
  9372. break;
  9373. }
  9374. }
  9375. }
  9376. if ($falg)
  9377. $html .= '<td class="taR">-</td>';
  9378. }
  9379. $t5 += $psum;
  9380. if (! empty ( $psum ))
  9381. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9382. else
  9383. $psum = '<td class="colGreen taR">-</td>';
  9384. $receiptL ['其他'] = $psum . $html;
  9385. /* ------------------------------------- */
  9386. $html = "";
  9387. $psum = 0;
  9388. foreach ( $receiptCollectList as $v ) {
  9389. if ($v ['itemCategory'] == '报销金额调整') {
  9390. if (! empty ( $v ['price'] )) {
  9391. $psum += $v ['price'];
  9392. }
  9393. }
  9394. }
  9395. $s1 += $psum;
  9396. if (! empty ( $psum ))
  9397. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9398. else
  9399. $psum = '<td class="taR colOrange">-</td>';
  9400. $receiptL ['报销金额调整'] = $psum . $html;
  9401. } else {
  9402. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9403. <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>';
  9404. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9405. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9406. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9407. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9408. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9409. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9410. }
  9411. $monthStaffPrice = $receiptDetail->find ( array (
  9412. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9413. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9414. 'asArray' => true
  9415. ) );
  9416. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  9417. $m1 += $monthStaffPrice [0] ['price'];
  9418. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9419. } else
  9420. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9421. $list [$value ['username']] = $receiptL;
  9422. }
  9423. }
  9424. $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>
  9425. <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>
  9426. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  9427. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  9428. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  9429. $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>
  9430. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  9431. $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>';
  9432. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  9433. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  9434. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  9435. }
  9436. $data ['list'] = $list;
  9437. $receiptCollectList = $receiptDetail->find ( array (
  9438. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9439. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9440. 'groupby' => 'item,Month(date),itemCategory',
  9441. 'asArray' => true
  9442. ) );
  9443. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9444. // statistics html
  9445. $stList = $statistics->getOne ( array (
  9446. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9447. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9448. 'groupby' => 'Month(date)',
  9449. 'asArray' => true
  9450. ) );
  9451. if (empty ( $stList ))
  9452. $stList = array (
  9453. 'rePrice' => 0,
  9454. 'agPrice' => 0
  9455. );
  9456. $data ['stList'] = array (
  9457. 'rePrice' => $stList ['rePrice'],
  9458. 'agPrice' => $stList ['agPrice'],
  9459. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9460. );
  9461. $monthHtml = "";
  9462. for($i = 1; $i <= 12; $i ++) {
  9463. if ($i == $month)
  9464. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9465. else
  9466. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9467. }
  9468. $data ['monthHtml'] = $monthHtml;
  9469. $data ['year'] = $year;
  9470. $data ['month'] = $month;
  9471. $data ['memu'] = "receipt";
  9472. $data ['staff'] = $this->staff;
  9473. $data ['receiptMemu'] = 'companyCategoryCollect';
  9474. $data ['verifyId'] = $this->verifyId;
  9475. $data ['executeId'] = $this->executeId;
  9476. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  9477. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9478. }
  9479. /**
  9480. * 用户报销单列表
  9481. */
  9482. function receiptStatisticsStaffDetail() {
  9483. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9484. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9485. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  9486. Doo::loadModel ( "receipt" );
  9487. $receipt = new receipt ();
  9488. Doo::loadModel ( "receiptDetail" );
  9489. $receiptDetail = new receiptDetail ();
  9490. Doo::loadModel ( 'staff' );
  9491. $staff = new staff ();
  9492. Doo::loadModel ( 'accountItem' );
  9493. $accountItem = new accountItem ();
  9494. Doo::loadModel ( 'statistics' );
  9495. $statistics = new statistics ();
  9496. if (! empty ( $username )) {
  9497. $username = addslashes ( urldecode ( $username ) );
  9498. $staffDetail = $staff->getStaffByName ( $username );
  9499. if (empty ( $staffDetail ))
  9500. die ( 'illegal request' );
  9501. $list = $receipt->getReceiptBySid ( $staffDetail ['sid'], $year, $month );
  9502. $itemList = $accountItem->getAccountItem ();
  9503. $itemHtml = '';
  9504. $categoryHtml = '';
  9505. $itemKeyList = array_keys ( $itemList );
  9506. $revisePrice = 0;
  9507. // 报销单内容详情
  9508. foreach ( $list as $key => $value ) {
  9509. $accountItemList = json_decode ( $value ['accountItem'], true );
  9510. $list [$key] ['accountItemList'] = $accountItemList;
  9511. $receiptItemHtml = '';
  9512. foreach ( $itemKeyList as $v ) {
  9513. if ($v == '日常相关费用')
  9514. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['agencySum'] . '</td>';
  9515. elseif ($v == '差旅相关费用')
  9516. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['travelSum'] . '</td>';
  9517. elseif ($v == '培训班费用')
  9518. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['trainSum'] . '</td>';
  9519. elseif ($v == '其他')
  9520. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['otherSum'] . '</td>';
  9521. foreach ( $itemList [$v] as $ke => $va ) {
  9522. $falg = true;
  9523. if (! empty ( $accountItemList [$v] )) {
  9524. foreach ( $accountItemList [$v] as $ve ) {
  9525. if ($va ['name'] == $ve ['name']) {
  9526. $receiptItemHtml .= '<td class="taR">' . $ve ['price'] . '</td>';
  9527. $falg = false;
  9528. break;
  9529. }
  9530. }
  9531. }
  9532. if ($falg)
  9533. $receiptItemHtml .= '<td class="taR"></td>';
  9534. }
  9535. }
  9536. // 金额调整和费用查看
  9537. $revisePrice += $value ['revisePrice'];
  9538. $receiptItemHtml .= '<td class="taR">' . $value ['revisePrice'] . '</td>';
  9539. $receiptItemHtml .= '<td class="taR"><a href="#detail" data-toggle="modal" onclick=showExplanation("' . $value ['explanation'] . '")>查看</a></td>';
  9540. $list [$key] ['receiptItemHtml'] = $receiptItemHtml;
  9541. }
  9542. // 报销单合计
  9543. $receiptTotalList = $receiptDetail->getReceiptTotalItem ( $staffDetail ['sid'], $year, $month );
  9544. $rtl = $receiptDetail->getReceiptTotalItemCategory ( $staffDetail ['sid'], $year, $month );
  9545. $receiptTotalHtml = '';
  9546. // 报销单项目抬头
  9547. foreach ( $itemKeyList as $value ) {
  9548. $count = count ( $itemList [$value] ) + 1;
  9549. $itemHtml .= '<th class="taC" colspan="' . $count . '">' . $value . '</th>';
  9550. $categoryHtml .= '<th class="taC">合计</th>';
  9551. foreach ( $rtl as $rtlValue ) {
  9552. if ($rtlValue ['itemCategory'] == $value) {
  9553. $receiptTotalHtml .= '<th>' . $rtlValue ['price'] . '</th>';
  9554. break;
  9555. }
  9556. }
  9557. foreach ( $itemList [$value] as $k => $v ) {
  9558. $categoryHtml .= '<th class="taC">' . $v ['name'] . '</th>';
  9559. // 合计
  9560. $falg = true;
  9561. foreach ( $receiptTotalList as $ve ) {
  9562. if ($ve ['itemCategory'] == $value && $ve ['item'] == $v ['name']) {
  9563. $receiptTotalHtml .= '<th >' . $ve ['price'] . '</th>';
  9564. $falg = false;
  9565. break;
  9566. }
  9567. }
  9568. if ($falg)
  9569. $receiptTotalHtml .= '<th></th>';
  9570. }
  9571. }
  9572. $receiptTotalHtml .= '<th>' . $revisePrice . '</th>';
  9573. $stList = $statistics->getStatisticsBySid ( $staffDetail ['sid'], $year, $month );
  9574. if (empty ( $stList ))
  9575. $stList = array (
  9576. 'rePrice' => 0,
  9577. 'agPrice' => 0
  9578. );
  9579. $data ['stList'] = array (
  9580. 'rePrice' => $stList ['rePrice'],
  9581. 'agPrice' => $stList ['agPrice'],
  9582. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9583. );
  9584. $monthHtml = "";
  9585. for($i = 1; $i <= 12; $i ++) {
  9586. if ($i == $month)
  9587. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9588. else
  9589. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9590. }
  9591. $data ['username'] = urlencode ( $username );
  9592. $data ['usernameEN'] = $username;
  9593. $data ['monthHtml'] = $monthHtml;
  9594. $data ['receiptTotalHtml'] = $receiptTotalHtml;
  9595. $data ['list'] = $list;
  9596. $data ['categoryHtml'] = $categoryHtml;
  9597. $data ['itemHtml'] = $itemHtml;
  9598. $data ['itemList'] = $itemList;
  9599. $data ['year'] = $year;
  9600. $data ['month'] = $month;
  9601. $data ['memu'] = "receipt";
  9602. $data ['staff'] = $this->staff;
  9603. $data ['receiptMemu'] = 'companyCategoryCollect';
  9604. $data ['verifyId'] = $this->verifyId;
  9605. $data ['executeId'] = $this->executeId;
  9606. $this->render ( "/admin/receiptStatisticsStaffDetail", $data );
  9607. }
  9608. die ( 'illegal request' );
  9609. }
  9610. function companyMonthCollectDetail() {
  9611. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9612. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9613. if (! $year)
  9614. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9615. if (! $month)
  9616. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9617. Doo::loadModel ( 'staff' );
  9618. $staff = new staff ();
  9619. Doo::loadModel ( "receiptDetail" );
  9620. $receiptDetail = new receiptDetail ();
  9621. Doo::loadModel ( 'accountItem' );
  9622. $accountItem = new accountItem ();
  9623. Doo::loadModel ( 'statistics' );
  9624. $statistics = new statistics ();
  9625. Doo::loadModel ( 'L_category' );
  9626. $lCategory = new L_category ();
  9627. $staffList = $staff->find ( array (
  9628. 'where' => 'username!="admin"',
  9629. 'asArray' => true
  9630. ) );
  9631. $categoryList = $lCategory->find ( array (
  9632. 'asArray' => true
  9633. ) );
  9634. $list = array ();
  9635. foreach ( $categoryList as $value ) {
  9636. $receiptCollectList = $receiptDetail->find ( array (
  9637. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9638. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9639. 'groupby' => 'item,Month(pastDate),itemCategory',
  9640. 'asArray' => true
  9641. ) );
  9642. if (! empty ( $receiptCollectList )) {
  9643. $receiptL = array (
  9644. '日常相关费用' => array (),
  9645. '差旅相关费用' => array (),
  9646. '培训班费用' => array (),
  9647. '其他' => array ()
  9648. );
  9649. $html = "";
  9650. $psum = 0;
  9651. $item = array (
  9652. '市内交通费',
  9653. '市内出租费',
  9654. '办事处房租',
  9655. '电话费',
  9656. '水费',
  9657. '电费',
  9658. '办公费用',
  9659. '邮寄费',
  9660. '其他费用',
  9661. '车辆费用',
  9662. '广告费',
  9663. '团队建设费'
  9664. );
  9665. foreach ( $item as $va ) {
  9666. $falg = true;
  9667. foreach ( $receiptCollectList as $v ) {
  9668. if ($v ['itemCategory'] == '日常相关费用') {
  9669. if ($v ['item'] == $va) {
  9670. $psum += $v ['price'];
  9671. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9672. $falg = false;
  9673. break;
  9674. }
  9675. }
  9676. }
  9677. if ($falg)
  9678. $html .= '<td class="taR">-</td>';
  9679. }
  9680. if (! empty ( $psum ))
  9681. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  9682. else
  9683. $psum = '<td class="colGreen taR">-</td>';
  9684. $receiptL ['日常相关费用'] = $psum . $html;
  9685. /* ----------------------------------- */
  9686. $html = "";
  9687. $psum = 0;
  9688. $item = array (
  9689. '往来交通费',
  9690. '市内交通费',
  9691. '出差住宿费',
  9692. '出差补助',
  9693. '其他费用'
  9694. );
  9695. foreach ( $item as $va ) {
  9696. $falg = true;
  9697. foreach ( $receiptCollectList as $v ) {
  9698. if ($v ['itemCategory'] == '差旅相关费用') {
  9699. if ($v ['item'] == $va) {
  9700. $psum += $v ['price'];
  9701. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9702. $falg = false;
  9703. break;
  9704. }
  9705. }
  9706. }
  9707. if ($falg)
  9708. $html .= '<td class="taR">-</td>';
  9709. }
  9710. if (! empty ( $psum ))
  9711. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  9712. else
  9713. $psum = '<td class="colGreen taR">-</td>';
  9714. $receiptL ['差旅相关费用'] = $psum . $html;
  9715. /* ------------------------------------- */
  9716. $html = "";
  9717. $psum = 0;
  9718. $item = array (
  9719. '场租费',
  9720. '薪酬',
  9721. '住宿费',
  9722. '交通费',
  9723. '餐饮费',
  9724. '办公费',
  9725. '公关费',
  9726. '其他'
  9727. );
  9728. foreach ( $item as $va ) {
  9729. $falg = true;
  9730. foreach ( $receiptCollectList as $v ) {
  9731. if ($v ['itemCategory'] == '培训班费用') {
  9732. if ($v ['item'] == $va) {
  9733. $psum += $v ['price'];
  9734. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9735. $falg = false;
  9736. break;
  9737. }
  9738. }
  9739. }
  9740. if ($falg)
  9741. $html .= '<td class="taR">-</td>';
  9742. }
  9743. if (! empty ( $psum ))
  9744. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  9745. else
  9746. $psum = '<td class="colGreen taR">-</td>';
  9747. $receiptL ['培训班费用'] = $psum . $html;
  9748. /* ------------------------------------- */
  9749. $html = "";
  9750. $psum = 0;
  9751. $item = array (
  9752. '公关费',
  9753. '广告费',
  9754. '借款',
  9755. '可自加费用'
  9756. );
  9757. foreach ( $item as $va ) {
  9758. $falg = true;
  9759. foreach ( $receiptCollectList as $v ) {
  9760. if ($v ['itemCategory'] == '其他') {
  9761. if ($v ['item'] == $va) {
  9762. $psum += $v ['price'];
  9763. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9764. $falg = false;
  9765. break;
  9766. }
  9767. }
  9768. }
  9769. if ($falg)
  9770. $html .= '<td class="taR">-</td>';
  9771. }
  9772. if (! empty ( $psum ))
  9773. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  9774. else
  9775. $psum = '<td class="colGreen taR">-</td>';
  9776. $receiptL ['其他'] = $psum . $html;
  9777. /* ------------------------------------- */
  9778. $html = "";
  9779. $psum = 0;
  9780. foreach ( $receiptCollectList as $v ) {
  9781. if ($v ['itemCategory'] == '报销金额调整') {
  9782. if (! empty ( $v ['price'] ))
  9783. $psum += $v ['price'];
  9784. }
  9785. }
  9786. if (! empty ( $psum ))
  9787. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  9788. else
  9789. $psum = '<td class="taR colOrange">-</td>';
  9790. $receiptL ['报销金额调整'] = $psum . $html;
  9791. } else {
  9792. $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>
  9793. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9794. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9795. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9796. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9797. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9798. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9799. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9800. }
  9801. $monthStaffPrice = $receiptDetail->find ( array (
  9802. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9803. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9804. 'asArray' => true
  9805. ) );
  9806. if (! empty ( $monthStaffPrice [0] ['price'] ))
  9807. $receiptL ['monthStaffPrice'] = '<td><b>' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9808. else
  9809. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9810. $list [$value ['title']] = $receiptL;
  9811. }
  9812. $data ['list'] = $list;
  9813. $receiptCollectList = $receiptDetail->find ( array (
  9814. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9815. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9816. 'groupby' => 'item,Month(pastDate),itemCategory',
  9817. 'asArray' => true
  9818. ) );
  9819. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9820. // print_r($data['monthPriceHtml']);
  9821. // foreach ($data['monthPriceHtml'] as $value){
  9822. // echo $value;
  9823. // }
  9824. // die;
  9825. // statistics html
  9826. $stList = $statistics->getOne ( array (
  9827. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9828. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9829. 'groupby' => 'Month(date)',
  9830. 'asArray' => true
  9831. ) );
  9832. if (empty ( $stList ))
  9833. $stList = array (
  9834. 'rePrice' => 0,
  9835. 'agPrice' => 0
  9836. );
  9837. $data ['stList'] = array (
  9838. 'rePrice' => $stList ['rePrice'],
  9839. 'agPrice' => $stList ['agPrice'],
  9840. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9841. );
  9842. $monthHtml = "";
  9843. for($i = 1; $i <= 12; $i ++) {
  9844. if ($i == $month)
  9845. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9846. else
  9847. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9848. }
  9849. $data ['monthHtml'] = $monthHtml;
  9850. $data ['year'] = $year;
  9851. $data ['month'] = $month;
  9852. $data ['memu'] = "receipt";
  9853. $data ['staff'] = $this->staff;
  9854. $data ['receiptMemu'] = 'companyCategoryCollect';
  9855. $data ['verifyId'] = $this->verifyId;
  9856. $data ['executeId'] = $this->executeId;
  9857. $this->render ( "/admin/companyMonthCollectDetail", $data );
  9858. }
  9859. function staffCollectDetail() {
  9860. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9861. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  9862. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  9863. if (! $staffname) {
  9864. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  9865. $staffname = urldecode ( $staffname );
  9866. }
  9867. Doo::loadModel ( 'staff' );
  9868. $staff = new staff ();
  9869. Doo::loadModel ( "receiptDetail" );
  9870. $receiptDetail = new receiptDetail ();
  9871. Doo::loadModel ( 'accountItem' );
  9872. $accountItem = new accountItem ();
  9873. Doo::loadModel ( 'statistics' );
  9874. $statistics = new statistics ();
  9875. Doo::loadModel ( 'L_category' );
  9876. $lCategory = new L_category ();
  9877. Doo::loadModel ( "receiptAuthorityManage" );
  9878. $receiptAuthorityManage = new receiptAuthorityManage ();
  9879. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9880. $cidList = array ();
  9881. foreach ( $imcStaff as $key => $value ) {
  9882. array_push ( $cidList, $value ['cid'] );
  9883. }
  9884. $cidString = implode ( ',', $cidList );
  9885. $staffList = $staff->find ( array (
  9886. 'where' => ' cid in (' . $cidString . ')',
  9887. 'asArray' => true
  9888. ) );
  9889. $stHtml = '';
  9890. $stTitle = "";
  9891. $staffId = 0;
  9892. $cid = 0;
  9893. $ocid = 0;
  9894. foreach ( $staffList as $value ) {
  9895. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  9896. $stTitle = $value ['category'] . '-' . $value ['username'];
  9897. $staffId = $value ['sid'];
  9898. $cid = $value ['cid'];
  9899. $ocid = $value ['cid'];
  9900. if (! empty ( $value ['othercid'] ))
  9901. $cid = $value ['cid'] . ',' . $value ['othercid'];
  9902. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9903. } elseif ($value ['username'] != 'admin')
  9904. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9905. }
  9906. $data ['lCategoryHtml'] = $lCategory->find ( array (
  9907. 'where' => 'cid in(' . $cid . ')',
  9908. 'asArray' => true
  9909. ) );
  9910. if (empty ( $pcid ))
  9911. $pcid = $ocid;
  9912. $data ['ocid'] = $pcid;
  9913. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  9914. $this->showCache ( $path );
  9915. //
  9916. $receiptCollectList = $receiptDetail->find ( array (
  9917. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9918. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9919. 'groupby' => 'item,Month(pastDate),itemCategory',
  9920. 'asArray' => true
  9921. ) );
  9922. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  9923. // print_r($receiptCollectList);
  9924. $accountList = $accountItem->find ( array (
  9925. 'asArray' => true
  9926. ) );
  9927. // create CollectDetail HTML
  9928. $collectHtml = array ();
  9929. foreach ( $accountList as $key => $value ) {
  9930. $html = "";
  9931. $asum = 0;
  9932. for($i = 1; $i <= 12; $i ++) {
  9933. $falg = true;
  9934. foreach ( $receiptCollectList as $v ) {
  9935. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9936. if ($v ['item'] == '可自加费用') {
  9937. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  9938. }
  9939. $asum += $v ['price'];
  9940. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9941. $falg = false;
  9942. break;
  9943. }
  9944. }
  9945. if ($falg)
  9946. $html .= '<td class="taR">-</td>';
  9947. }
  9948. $html .= '<td class="taR colGreen"><b>' . $asum . '</b></td>';
  9949. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9950. }
  9951. $data ['collectHtml'] = $collectHtml;
  9952. // print_r($collectHtml);
  9953. // create Adjustment price html
  9954. $receiptCollectList = $receiptDetail->find ( array (
  9955. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9956. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9957. 'groupby' => 'itemCategory,Month(pastDate)',
  9958. 'asArray' => true
  9959. ) );
  9960. $adjustment = array ();
  9961. $collectArray = array (
  9962. '日常相关费用' => array (),
  9963. '差旅相关费用' => array (),
  9964. '培训班费用' => array (),
  9965. '其他' => array ()
  9966. );
  9967. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9968. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9969. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9970. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9971. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9972. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9973. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9974. array_push ( $collectArray ['其他'], $collectHtml );
  9975. $data ['collectArray'] = $collectArray;
  9976. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9977. array_push ( $adjustment, $collectHtml );
  9978. $data ['adjustment'] = $adjustment;
  9979. // total price html
  9980. $collectHtml = "";
  9981. $total = 0;
  9982. for($i = 1; $i <= 12; $i ++) {
  9983. $sumPrice = 0;
  9984. foreach ( $receiptCollectList as $key => $value ) {
  9985. if ($value ['month'] == $i) {
  9986. $sumPrice += $value ['price'];
  9987. }
  9988. }
  9989. if ($sumPrice == 0)
  9990. $collectHtml .= '<td class="taR">-</td>';
  9991. else
  9992. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9993. $total += $sumPrice;
  9994. }
  9995. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9996. // statistics html
  9997. $stList = $statistics->statisticsByYear ( $year, $staffId );
  9998. if (empty ( $stList ))
  9999. $stList = array (
  10000. 'rePrice' => 0,
  10001. 'agPrice' => 0
  10002. );
  10003. $data ['stList'] = array (
  10004. 'rePrice' => $stList ['rePrice'],
  10005. 'agPrice' => $stList ['agPrice'],
  10006. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10007. );
  10008. $data ['totalPrice'] = $collectHtml;
  10009. $data ['totalYear'] = $total;
  10010. $data ['stHtml'] = $stHtml;
  10011. $data ['year'] = $year;
  10012. $data ['stTitle'] = $stTitle;
  10013. $data ['staffname'] = urlencode ( $staffname );
  10014. $data ['memu'] = "receipt";
  10015. $data ['staff'] = $this->staff;
  10016. $data ['receiptMemu'] = 'companyCategoryCollect';
  10017. $data ['verifyId'] = $this->verifyId;
  10018. $data ['executeId'] = $this->executeId;
  10019. if ($year < date ( "Y" )) {
  10020. Doo::loadModel ( 'receipt' );
  10021. $receipt = new receipt ();
  10022. $receiptList = $receipt->find ( array (
  10023. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  10024. 'asArray' => true
  10025. ) );
  10026. if (empty ( $receiptList )) { // generated files
  10027. ob_start ();
  10028. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  10029. $this->cacheFile ( $path );
  10030. die ();
  10031. }
  10032. }
  10033. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  10034. }
  10035. function BUGFLAG() {
  10036. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  10037. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  10038. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  10039. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  10040. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  10041. if (empty ( $status ))
  10042. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  10043. $page_size = 12;
  10044. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  10045. $vidList = array ();
  10046. $button = 0;
  10047. Doo::loadModel ( 'verify' );
  10048. $verify = new verify ();
  10049. Doo::loadModel ( 'receipt' );
  10050. $receipt = new receipt ();
  10051. Doo::loadModel ( 'staff' );
  10052. $staff = new staff ();
  10053. Doo::loadModel ( 'L_category' );
  10054. $Lcategory = new L_category ();
  10055. $dateCondition = " and Year(date) =" . $year;
  10056. if (! empty ( $month ))
  10057. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  10058. $categoryList = $Lcategory->find ( array (
  10059. 'asArray' => true
  10060. ) );
  10061. $staffList = $staff->find ( array (
  10062. 'where' => 'cid=' . $cid,
  10063. 'asArray' => true
  10064. ) );
  10065. $cateCondition = "";
  10066. $staffCondition = "";
  10067. $approvalCondition = "";
  10068. if (! empty ( $cid ))
  10069. $cateCondition = ' and cid=' . $cid;
  10070. if (! empty ( $sid )) {
  10071. $staffCondition = ' and staff=' . $sid;
  10072. $cateCondition = "";
  10073. }
  10074. $approvalCondition = " and status=" . $status;
  10075. if ($status == 2) {
  10076. // 查找角色审批人
  10077. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  10078. }
  10079. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  10080. $approvalCondition = ' and status=2 ';
  10081. }
  10082. if ($status == 1) {
  10083. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  10084. }
  10085. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  10086. $pageinfo ['page'] = array (
  10087. 'previous' => ''
  10088. );
  10089. if ($status == 0) {
  10090. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  10091. $receiptList = $receipt->find ( array (
  10092. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  10093. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  10094. 'desc' => 'rid',
  10095. 'asArray' => true
  10096. ) );
  10097. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  10098. } else
  10099. $receiptList = $receipt->find ( array (
  10100. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  10101. 'desc' => 'rid',
  10102. 'asArray' => true
  10103. ) );
  10104. $rLRes = $receipt->find ( array (
  10105. '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,
  10106. 'desc' => 'rid',
  10107. 'asArray' => true
  10108. ) );
  10109. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  10110. // print_r($pageinfo);
  10111. $Locate = 0;
  10112. foreach ( $receiptList as $key => $value ) {
  10113. $receiptList [$key] ['Locate'] = $Locate;
  10114. $Locate ++;
  10115. $receiptList [$key] ['reviseDetail'] = array ();
  10116. if (! empty ( $value ['reviseDetail'] ))
  10117. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  10118. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  10119. $categoryDetil = $Lcategory->getOne ( array (
  10120. 'where' => 'cid=' . $value ['cid'],
  10121. 'asArray' => true
  10122. ) );
  10123. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  10124. $verifyList = $verify->getOne ( array (
  10125. 'where' => 'vid=' . $value ['verify'],
  10126. 'asArray' => true
  10127. ) );
  10128. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  10129. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  10130. foreach ( $verifyList as $k => $v ) {
  10131. // init verifyStaff
  10132. $verifyList [$k] ['date'] = "";
  10133. $verifyList [$k] ['opinion'] = "";
  10134. $verifyList [$k] ['status'] = "";
  10135. if (empty ( $verifyStaff )) {
  10136. $verifyList [$k] ['date'] = "";
  10137. $verifyList [$k] ['opinion'] = "";
  10138. if ($v [0] == $this->staff [0] ['sid']) {
  10139. $verifyList [$k] ['status'] = 4;
  10140. $button = 4;
  10141. }
  10142. } else {
  10143. $flag = true;
  10144. foreach ( $verifyStaff as $m => $u ) {
  10145. if ($v [0] == $m) {
  10146. $verifyList [$k] ['date'] = $u ['date'];
  10147. $verifyList [$k] ['opinion'] = $u ['opinion'];
  10148. $verifyList [$k] ['status'] = $u ['status'];
  10149. $flag = false;
  10150. break;
  10151. }
  10152. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  10153. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  10154. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  10155. }
  10156. if ($flag) { // 检测可编辑
  10157. if ($v [0] == $this->staff [0] ['sid']) {
  10158. $verifyList [$k] ['status'] = 4;
  10159. $button = 4;
  10160. }
  10161. }
  10162. }
  10163. }
  10164. $receiptList [$key] ['verifyList'] = $verifyList;
  10165. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  10166. 'where' => 'sid=' . $value ['staff'],
  10167. 'asArray' => true
  10168. ) );
  10169. $receiptList [$key] ['button'] = $button;
  10170. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  10171. }
  10172. // print_r($receiptList);die;
  10173. // $data['verifyDetail']=$verifyDetail;
  10174. $mothHtml = "";
  10175. for($i = 1; $i <= 12; $i ++) {
  10176. if ($month == $i)
  10177. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  10178. else
  10179. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  10180. }
  10181. $data ['mothHtml'] = $mothHtml;
  10182. $data ['page'] = $pageinfo;
  10183. $data ['receiptList'] = $receiptList;
  10184. $data ['receiptApprovalCount'] = count ( $rLRes );
  10185. $data ['status'] = $status;
  10186. $data ['year'] = $year;
  10187. $data ['categoryList'] = $categoryList;
  10188. $data ['staffList'] = $staffList;
  10189. $data ['cid'] = $cid;
  10190. $data ['sid'] = $sid;
  10191. // print_r($receiptList);
  10192. $data ['memu'] = "receipt";
  10193. $data ['staff'] = $this->staff;
  10194. $data ['receiptMemu'] = 'approvalExpenses';
  10195. $data ['verifyId'] = $this->verifyId;
  10196. $data ['executeId'] = $this->executeId;
  10197. $this->render ( "/admin/FALG", $data );
  10198. }
  10199. function ajaxGetReceiptOrder() {
  10200. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  10201. if (! empty ( $receiptOrder )) {
  10202. Doo::loadModel ( 'receipt' );
  10203. $receipt = new receipt ();
  10204. Doo::loadModel ( 'staff' );
  10205. $staff = new staff ();
  10206. $receiptInfo = $receipt->getOne ( array (
  10207. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  10208. 'asArray' => true
  10209. ) );
  10210. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  10211. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  10212. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  10213. </tbody></table><table class="table table table-bordered"><tbody>';
  10214. foreach ( $verifyStaff as $key => $value ) {
  10215. $staffInfo = $staff->getOne ( array (
  10216. 'select' => 'username',
  10217. 'where' => ' sid="' . $key . '"',
  10218. 'asArray' => true
  10219. ) );
  10220. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  10221. }
  10222. $html .= '</tbody></table></div></div>';
  10223. echo json_encode ( array (
  10224. 'status' => 1,
  10225. 'receiptHtml' => $html
  10226. ) );
  10227. die ();
  10228. }
  10229. echo json_encode ( array (
  10230. 'status' => 2,
  10231. 'receiptHtml' => ''
  10232. ) );
  10233. die ();
  10234. }
  10235. function _getMonthCollectDetail($receiptCollectList) {
  10236. if (! empty ( $receiptCollectList )) {
  10237. $receiptL = array (
  10238. '日常相关费用' => array (),
  10239. '差旅相关费用' => array (),
  10240. '培训班费用' => array (),
  10241. '其他' => array ()
  10242. );
  10243. $html = "";
  10244. $psum = 0;
  10245. $item = array (
  10246. '市内交通费',
  10247. '市内出租费',
  10248. '办事处房租',
  10249. '电话费',
  10250. '水费',
  10251. '电费',
  10252. '办公费用',
  10253. '邮寄费',
  10254. '其他费用',
  10255. '车辆费用',
  10256. '广告费',
  10257. '团队建设费',
  10258. '物业管理费',
  10259. '宽带费'
  10260. );
  10261. foreach ( $item as $value ) {
  10262. $falg = true;
  10263. foreach ( $receiptCollectList as $v ) {
  10264. if ($v ['itemCategory'] == '日常相关费用') {
  10265. if ($v ['item'] == $value) {
  10266. $psum += $v ['price'];
  10267. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10268. $falg = false;
  10269. break;
  10270. }
  10271. }
  10272. }
  10273. if ($falg)
  10274. $html .= '<td class="taR">-</td>';
  10275. }
  10276. if (! empty ( $psum ))
  10277. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  10278. else
  10279. $psum = '<td class="colGreen taR">-</td>';
  10280. $receiptL ['日常相关费用'] = $psum . $html;
  10281. /* ----------------------------------- */
  10282. $html = "";
  10283. $psum = 0;
  10284. $item = array (
  10285. '往来交通费',
  10286. '市内交通费',
  10287. '出差住宿费',
  10288. '出差补助',
  10289. '其他费用'
  10290. );
  10291. foreach ( $item as $value ) {
  10292. $falg = true;
  10293. foreach ( $receiptCollectList as $v ) {
  10294. if ($v ['itemCategory'] == '差旅相关费用') {
  10295. if ($v ['item'] == $value) {
  10296. $psum += $v ['price'];
  10297. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10298. $falg = false;
  10299. break;
  10300. }
  10301. }
  10302. }
  10303. if ($falg)
  10304. $html .= '<td class="taR">-</td>';
  10305. }
  10306. if (! empty ( $psum ))
  10307. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  10308. else
  10309. $psum = '<td class="colGreen taR">-</td>';
  10310. $receiptL ['差旅相关费用'] = $psum . $html;
  10311. /* ------------------------------------- */
  10312. $html = "";
  10313. $psum = 0;
  10314. $item = array (
  10315. '场租费',
  10316. '薪酬',
  10317. '住宿费',
  10318. '交通费',
  10319. '餐饮费',
  10320. '办公费',
  10321. '公关费',
  10322. '其他'
  10323. );
  10324. foreach ( $item as $value ) {
  10325. $falg = true;
  10326. foreach ( $receiptCollectList as $v ) {
  10327. if ($v ['itemCategory'] == '培训班费用') {
  10328. if ($v ['item'] == $value) {
  10329. $psum += $v ['price'];
  10330. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10331. $falg = false;
  10332. break;
  10333. }
  10334. }
  10335. }
  10336. if ($falg)
  10337. $html .= '<td class="taR">-</td>';
  10338. }
  10339. if (! empty ( $psum ))
  10340. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  10341. else
  10342. $psum = '<td class="colGreen taR">-</td>';
  10343. $receiptL ['培训班费用'] = $psum . $html;
  10344. /* ------------------------------------- */
  10345. $html = "";
  10346. $psum = 0;
  10347. $item = array (
  10348. '公关费',
  10349. '广告费',
  10350. '借款',
  10351. '可自加费用'
  10352. );
  10353. foreach ( $item as $value ) {
  10354. $falg = true;
  10355. foreach ( $receiptCollectList as $v ) {
  10356. if ($v ['itemCategory'] == '其他') {
  10357. if ($v ['item'] == $value) {
  10358. $psum += $v ['price'];
  10359. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10360. $falg = false;
  10361. break;
  10362. }
  10363. }
  10364. }
  10365. if ($falg)
  10366. $html .= '<td class="taR">-</td>';
  10367. }
  10368. if (! empty ( $psum ))
  10369. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  10370. else
  10371. $psum = '<td class="colGreen taR">-</td>';
  10372. $receiptL ['其他'] = $psum . $html;
  10373. /* ------------------------------------- */
  10374. $html = "";
  10375. $psum = 0;
  10376. foreach ( $receiptCollectList as $v ) {
  10377. if ($v ['itemCategory'] == '报销金额调整') {
  10378. if (! empty ( $v ['price'] ))
  10379. $psum += $v ['price'];
  10380. }
  10381. }
  10382. if (! empty ( $psum ))
  10383. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  10384. else
  10385. $psum = '<td class="taR colOrange">-</td>';
  10386. $receiptL ['报销金额调整'] = $psum . $html;
  10387. } else {
  10388. $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>
  10389. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10390. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  10391. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10392. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  10393. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10394. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10395. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  10396. }
  10397. return $receiptL;
  10398. }
  10399. function eMail() {
  10400. Doo::loadModel ( 'staff' );
  10401. $staff = new staff ();
  10402. Doo::loadModel ( 'receipt' );
  10403. $receipt = new receipt ();
  10404. Doo::loadModel ( 'L_category' );
  10405. $Lcategory = new L_category ();
  10406. Doo::loadModel ( "verify" );
  10407. $verify = new verify ();
  10408. $staffList = $staff->find ( array (
  10409. 'asArray' => true
  10410. ) );
  10411. foreach ( $staffList as $key => $value ) {
  10412. if ($value ['username'] != 'admin') {
  10413. // 提交人
  10414. $receiptList = $receipt->find ( array (
  10415. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  10416. 'asArray' => true
  10417. ) );
  10418. if (! empty ( $receiptList )) {
  10419. $html = '<br><div><style></style>
  10420. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  10421. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  10422. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  10423. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  10424. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  10425. <tbody><tr>
  10426. <td style="padding: 0 40px;" align="left">
  10427. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  10428. </td></tr><tr>
  10429. <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>
  10430. </tr>
  10431. </tbody> </table></td> </tr> <tr><td>
  10432. <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">
  10433. <tbody> <tr><td>
  10434. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  10435. 以下报销单完成了审批,等着收款吧:</p>
  10436. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  10437. foreach ( $receiptList as $k => $v ) {
  10438. $category = $Lcategory->getOne ( array (
  10439. 'where' => 'cid=' . $v ['cid'],
  10440. 'asArray' => true
  10441. ) );
  10442. $html .= '
  10443. <tr>
  10444. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  10445. <td align="left">
  10446. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  10447. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  10448. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  10449. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  10450. </tr>';
  10451. }
  10452. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  10453. <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>
  10454. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  10455. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  10456. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  10457. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  10458. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  10459. $receipt = new receipt ();
  10460. $receipt->notice = 1;
  10461. $receipt->update ( array (
  10462. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  10463. ) );
  10464. }
  10465. }
  10466. // 审批人
  10467. $verifyList = $verify->find ( array (
  10468. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  10469. 'asArray' => true
  10470. ) );
  10471. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  10472. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  10473. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  10474. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  10475. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  10476. <tbody><tr><td style="padding: 0 40px;" align="left">
  10477. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  10478. </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>
  10479. </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">
  10480. <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>
  10481. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  10482. foreach ( $verifyList as $k => $v ) {
  10483. $receiptList = $receipt->find ( array (
  10484. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  10485. 'asArray' => true
  10486. ) );
  10487. foreach ( $receiptList as $r => $l ) {
  10488. $category = $Lcategory->getOne ( array (
  10489. 'where' => 'cid=' . $l ['cid'],
  10490. 'asArray' => true
  10491. ) );
  10492. $staffDetile = $staff->getOne ( array (
  10493. 'where' => 'sid=' . $l ['staff'],
  10494. 'asArray' => true
  10495. ) );
  10496. $html .= '
  10497. <tr>
  10498. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  10499. <td align="left">
  10500. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  10501. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  10502. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  10503. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  10504. </tr>';
  10505. }
  10506. }
  10507. $html .= '
  10508. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  10509. <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>
  10510. </tr></tbody></table></td></tr></tbody></table></div><br>';
  10511. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  10512. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  10513. // $receipt=new receipt();
  10514. // $receipt->notice=1;
  10515. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  10516. }
  10517. }
  10518. }
  10519. }
  10520. function setWXMsg($rid, $type) {
  10521. Doo::loadModel ( "receipt" );
  10522. $receipt = new receipt ();
  10523. $receiptDetail = $receipt->getOne ( array (
  10524. 'where' => 'rid=' . $rid,
  10525. 'asArray' => true
  10526. ) );
  10527. if (! empty ( $receiptDetail )) {
  10528. Doo::loadModel ( 'staff' );
  10529. $staff = new staff ();
  10530. $staffmsg = $staff->getOne ( array (
  10531. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  10532. 'asArray' => TRUE
  10533. ) );
  10534. if (! empty ( $staffmsg ['wxid'] )) {
  10535. require_once (SITE_PATH . '/protected/class/client.php');
  10536. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  10537. $user = $staffmsg ['wxid'];
  10538. $receiptName = '';
  10539. $msg = '';
  10540. switch ($receiptDetail ['Rtype']) {
  10541. case 0 :
  10542. $receiptName = '报销';
  10543. break;
  10544. case 1 :
  10545. $receiptName = '借款';
  10546. break;
  10547. case 2 :
  10548. $receiptName = '对公汇款';
  10549. break;
  10550. }
  10551. switch ($type) {
  10552. case 1 :
  10553. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  10554. break;
  10555. case 2 :
  10556. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  10557. break;
  10558. case 3 :
  10559. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  10560. break;
  10561. }
  10562. // $result = $client->SendMsg ( $user, $msg, 'text' );
  10563. }
  10564. }
  10565. }
  10566. // Email发送函数
  10567. function SMail($toemail, $subject, $contents) {
  10568. Doo::loadClass ( 'class.phpmailer' );
  10569. $mail = new PHPMailer ();
  10570. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  10571. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  10572. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  10573. $mail->Password = "cDO1GjtY1seH"; // 密码
  10574. $mail->CharSet = "UTF8";
  10575. $mail->SMTPAuth = true;
  10576. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  10577. $mail->Mailer = "smtp";
  10578. $mail->Port = 25;
  10579. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  10580. $mail->MsgHTML ( $contents );
  10581. $mail->AddAddress ( $toemail );
  10582. $mail->CharSet = "UTF-8";
  10583. return $mail->Send ();
  10584. }
  10585. function swfupload() {
  10586. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  10587. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  10588. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  10589. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  10590. header ( "HTTP/1.1 500 Internal Server Error" );
  10591. echo "POST exceeded maximum allowed size.";
  10592. exit ( 0 );
  10593. }
  10594. // Settings
  10595. $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)
  10596. $upload_name = "Filedata";
  10597. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  10598. $extension_whitelist = array (
  10599. "doc",
  10600. "txt",
  10601. "jpg",
  10602. "gif",
  10603. "png"
  10604. ); // Allowed file extensions
  10605. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  10606. // Other variables
  10607. $MAX_FILENAME_LENGTH = 260;
  10608. $file_name = "";
  10609. $file_extension = "";
  10610. $uploadErrors = array (
  10611. 0 => "文件上传成功",
  10612. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  10613. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  10614. 3 => "上传的文件仅为部分文件",
  10615. 4 => "没有文件上传",
  10616. 6 => "缺少临时文件夹"
  10617. );
  10618. $nk = time ();
  10619. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  10620. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  10621. echo "文件无法保存.";
  10622. exit ( 0 );
  10623. }
  10624. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  10625. echo json_encode ( array (
  10626. 'filename' => $file_name,
  10627. 'id' => $nk
  10628. ) );
  10629. exit ( 0 );
  10630. }
  10631. function _GetFileEXT($filename) {
  10632. $pics = explode ( '.', $filename );
  10633. $num = count ( $pics );
  10634. return $pics [$num - 1];
  10635. }
  10636. /**
  10637. * 获取get或者POST值
  10638. * @param string $name 属性名称
  10639. * @return fixed 值
  10640. */
  10641. function get_args($name) {
  10642. if (isset ( $_GET [$name] )) {
  10643. if (is_array ( $_GET [$name] ))
  10644. return $_GET [$name];
  10645. else
  10646. return addslashes ( $_GET [$name] );
  10647. } elseif (isset ( $_POST [$name] )) {
  10648. if (is_array ( $_POST [$name] ))
  10649. return $_POST [$name];
  10650. else
  10651. return addslashes ( $_POST [$name] );
  10652. } else
  10653. return false;
  10654. }
  10655. function num_to_rmb($num) {
  10656. $c1 = "零壹贰叁肆伍陆柒捌玖";
  10657. $c2 = "分角元拾佰仟万拾佰仟亿";
  10658. // 精确到分后面就不要了,所以只留两个小数位
  10659. $num = round ( $num, 2 );
  10660. // 将数字转化为整数
  10661. $num = $num * 100;
  10662. if (strlen ( $num ) > 10) {
  10663. return "金额太大,请检查";
  10664. }
  10665. $i = 0;
  10666. $c = "";
  10667. while ( 1 ) {
  10668. if ($i == 0) {
  10669. // 获取最后一位数字
  10670. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  10671. } else {
  10672. $n = $num % 10;
  10673. }
  10674. // 每次将最后一位数字转化为中文
  10675. $p1 = substr ( $c1, 3 * $n, 3 );
  10676. $p2 = substr ( $c2, 3 * $i, 3 );
  10677. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  10678. $c = $p1 . $p2 . $c;
  10679. } else {
  10680. $c = $p1 . $c;
  10681. }
  10682. $i = $i + 1;
  10683. // 去掉数字最后一位了
  10684. $num = $num / 10;
  10685. // echo $num.'</br>';
  10686. $num = ( int ) $num;
  10687. // $num =floor($num);
  10688. // $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  10689. // echo $num.'</br>';
  10690. // 结束循环
  10691. if ($num == 0) {
  10692. break;
  10693. }
  10694. }
  10695. // echo $c.'</br>';
  10696. $j = 0;
  10697. $slen = strlen ( $c );
  10698. while ( $j < $slen ) {
  10699. // utf8一个汉字相当3个字符
  10700. $m = substr ( $c, $j, 6 );
  10701. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  10702. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  10703. $left = substr ( $c, 0, $j );
  10704. $right = substr ( $c, $j + 3 );
  10705. $c = $left . $right;
  10706. $j = $j - 3;
  10707. $slen = $slen - 3;
  10708. }
  10709. $j = $j + 3;
  10710. }
  10711. // 这个是为了去掉类似23.0中最后一个“零”字
  10712. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  10713. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  10714. }
  10715. // 将处理的汉字加上“整”
  10716. if (empty ( $c )) {
  10717. return "零元整";
  10718. } else {
  10719. return $c . "整";
  10720. }
  10721. }
  10722. /**
  10723. * 获得分页数据
  10724. * @param unknown_type $table
  10725. * @param unknown_type $condition
  10726. * @param unknown_type $on_page
  10727. * @param unknown_type $page_size
  10728. */
  10729. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  10730. $page_c = "";
  10731. $page ['previous'] = $this->get_previous ( $on_page );
  10732. $page ['on_page'] = $on_page;
  10733. $total_count = $this->get_table_count ( $table, $condition );
  10734. $total = intval ( $total_count / $page_size );
  10735. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  10736. $page ['total_data'] = $total_count;
  10737. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  10738. $i = 1;
  10739. $page_max = 1;
  10740. $page_width = 3;
  10741. if ($on_page >= $page_width) {
  10742. $page_max = intval ( $on_page / $page_width ) + 1;
  10743. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  10744. }
  10745. for(; $i <= $page ['total_page']; $i ++) {
  10746. if ($i == $on_page)
  10747. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  10748. else
  10749. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  10750. if ($i == ($page_width * $page_max))
  10751. break;
  10752. }
  10753. $page ['page'] = $page_c;
  10754. $page ['lower'] = (-- $on_page) * $page_size;
  10755. return $page;
  10756. }
  10757. /**
  10758. * 获取总页数
  10759. * @param unknown_type $table
  10760. * @param unknown_type $condition
  10761. */
  10762. public function get_table_count($table = "", $condition = "") {
  10763. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10764. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10765. // echo $sql;die;
  10766. $query = Doo::db ()->query ( $sql );
  10767. $result = $query->fetch ();
  10768. return $result ['count'];
  10769. }
  10770. /**
  10771. * 获取上一页
  10772. * @param unknown_type $on_page
  10773. */
  10774. function get_previous($on_page = 1) {
  10775. return $on_page != 0 ? $on_page - 1 : $on_page;
  10776. }
  10777. }
  10778. ?>