ReceiptController.php 480 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914
  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. // 检测用户信息完成
  135. $this->data ['isStaffCompleteMsg'] = false;
  136. $detail = $staff->checkStaffInfoIsComplete ( $_COOKIE ["staff"] );
  137. if (! empty ( $detail ))
  138. $this->data ['isStaffCompleteMsg'] = true;
  139. return "/";
  140. }
  141. }
  142. Doo::loadCore ( 'uri/DooUriRouter' );
  143. $router = new DooUriRouter ();
  144. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  145. if ($routeRs ['1'] != "login") {
  146. header ( 'Content-Type:text/html;charset=utf-8' );
  147. @header ( "Location: /login" );
  148. }
  149. }
  150. function saeaBorad() {
  151. Doo::loadModel ( 'receipt' );
  152. Doo::loadModel ( 'verify' );
  153. $verify = new verify ();
  154. $receipt = new receipt ();
  155. Doo::loadModel ( 'L_category' );
  156. $lCategory = new L_category ();
  157. Doo::loadModel ( "role" );
  158. $role = new role ();
  159. Doo::loadModel ( "receiptLog" );
  160. $receiptLog = new receiptLog ();
  161. Doo::loadClass ( 'XDeode' );
  162. $XDeode = new XDeode ( 7 );
  163. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  164. $receiptDetail = $receipt->find ( array (
  165. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  166. 'desc' => 'rid',
  167. 'asArray' => true
  168. ) );
  169. foreach ( $receiptDetail as $key => $value ) {
  170. $receiptDetail [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  171. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  172. $veList = $verify->getOne ( array (
  173. 'where' => 'vid=' . $value ['verify'],
  174. 'asArray' => true
  175. ) );
  176. $v = json_decode ( $veList ['staff'] );
  177. array_push ( $v [0], $veList ['description'] );
  178. foreach ( $v as $n => $m ) {
  179. if ($m ['1'] == 'ROLE') {
  180. $roleInfo = $role->getOne ( array (
  181. 'where' => 'rid=' . $m [0],
  182. 'asArray' => true
  183. ) );
  184. $v [$n] [1] = $roleInfo ['name'];
  185. }
  186. }
  187. $receiptDetail [$key] ['staff'] = $v;
  188. $category = $lCategory->getOne ( array (
  189. 'where' => 'cid=' . $value ['cid'],
  190. 'asArray' => true
  191. ) );
  192. $receiptDetail [$key] ['category'] = $category ['title'];
  193. }
  194. // print_r($receiptLogList);
  195. $data ['receiptLogList'] = $receiptLogList;
  196. $data ['receiptDetail'] = $receiptDetail;
  197. $data ['memu'] = "receipt";
  198. $data ['staff'] = $this->staff;
  199. $data ['receiptMemu'] = 'saeaBorad';
  200. $data ['verifyId'] = $this->verifyId;
  201. $data ['executeId'] = $this->executeId;
  202. $this->render ( "/admin/saeaBorad", $data );
  203. }
  204. function remitAdd() {
  205. Doo::loadModel ( 'accountItem' );
  206. Doo::loadModel ( 'verify' );
  207. Doo::loadModel ( 'receipt' );
  208. Doo::loadModel ( 'L_category' );
  209. $lCategory = new L_category ();
  210. $receipt = new receipt ();
  211. $verify = new verify ();
  212. $accountItem = new accountItem ();
  213. Doo::loadModel ( "role" );
  214. $role = new role ();
  215. $acItem = $accountItem->find ( array (
  216. 'asArray' => true
  217. ) );
  218. $veList = $verify->find ( array (
  219. 'asArray' => true
  220. ) );
  221. foreach ( $veList as $key => $value ) {
  222. $v = json_decode ( $value ['staff'] );
  223. $list = array ();
  224. foreach ( $v as $n => $m ) {
  225. if ($m ['1'] == 'ROLE') {
  226. $roleInfo = $role->getOne ( array (
  227. 'where' => 'rid=' . $m [0],
  228. 'asArray' => true
  229. ) );
  230. $v [$n] [1] = $roleInfo ['name'];
  231. array_push ( $list, $roleInfo ['name'] );
  232. } else {
  233. array_push ( $list, $v [$n] [1] );
  234. }
  235. }
  236. $veList [$key] ['staff'] = implode ( '>', $list );
  237. }
  238. $data ['category'] = $lCategory->find ( array (
  239. 'asArray' => true
  240. ) );
  241. $data ['veList'] = $veList;
  242. $data ['acItem'] = $acItem;
  243. $data ['memu'] = "receipt";
  244. $data ['staff'] = $this->staff;
  245. $data ['receiptMemu'] = 'saeaBorad';
  246. $data ['verifyId'] = $this->verifyId;
  247. $data ['executeId'] = $this->executeId;
  248. $this->render ( "/admin/remitAdd", $data );
  249. }
  250. function remitAddDo() {
  251. $agency = $this->get_args ( 'agency' );
  252. $travel = $this->get_args ( 'travel' );
  253. $train = $this->get_args ( 'train' );
  254. $other = $this->get_args ( 'other' );
  255. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  256. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  257. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  258. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  259. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  260. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  261. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  262. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  263. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  264. // print_r($agency);die;
  265. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  266. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  267. header ( 'Content-Type:text/html;charset=utf-8' );
  268. die ( '请填写联行号' );
  269. }
  270. Doo::loadModel ( 'receipt' );
  271. Doo::loadModel ( 'receiptDetail' );
  272. Doo::loadModel ( 'accountItem' );
  273. $accountItem = new accountItem ();
  274. $receipt = new receipt ();
  275. Doo::loadModel ( 'enclosur' );
  276. Doo::loadModel ( 'execute' );
  277. $execute = new execute ();
  278. $executeDetail = $execute->getOne ( array (
  279. 'where' => 'mold="对公汇款执行人"',
  280. 'asArray' => true
  281. ) );
  282. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  283. $aItem = $accountItem->find ( array (
  284. 'where' => 'name like "办公费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保"',
  285. 'asArray' => true
  286. ) );
  287. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  288. $ag = $tr = $ta = $ot = 0;
  289. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  290. foreach ( $aItem as $key => $value ) {
  291. if ($value ['category'] == $this->AGENCY) {
  292. if (isset ( $agency [$ag] )) {
  293. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  294. array_push ( $accountJson [$this->AGENCY], array (
  295. 'aid' => $value ['aid'],
  296. 'name' => $value ['name'],
  297. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  298. ) );
  299. $sum += $agency [$ag];
  300. $agencySum += $agency [$ag];
  301. }
  302. }
  303. $ag ++;
  304. }
  305. }
  306. $accountJson ['cSum'] = array (
  307. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  308. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  309. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  310. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  311. );
  312. // 报销单
  313. $receipt->accountItem = json_encode ( $accountJson );
  314. $receipt->staff = $this->staff [0] ['sid'];
  315. $receipt->sum = number_format ( $sum, 2, '.', '' );
  316. $receipt->date = date ( "Y-m-d" );
  317. $receipt->cid = $cid;
  318. $receipt->status = 5;
  319. $receipt->Rtype = 2;
  320. // 修改审批流程加入角色
  321. $receipt->verify = $verify;
  322. $receipt->executeCopy = $executeDetail ['staff'];
  323. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  324. $order = array (
  325. "\r\n",
  326. "\n",
  327. "\r"
  328. );
  329. $replace = '<br/>';
  330. $explanation = str_replace ( $order, $replace, $explanation );
  331. $receipt->explanation = $explanation;
  332. $receipt->remittanceName = $remittanceName;
  333. $receipt->bankName = $bankName;
  334. $receipt->bankNumber = $bankNumber;
  335. $receipt->remittanceBankType = $remittanceBankType;
  336. if ($remittanceBankType == 1)
  337. $receipt->coupletNumber = $coupletNumber;
  338. $rid = $receipt->insert ();
  339. // 附件
  340. if (! empty ( $enclosurName )) {
  341. $enclosurArray = explode ( '-', $enclosurName );
  342. foreach ( $enclosurArray as $value ) {
  343. $enclosur = new enclosur ();
  344. $enclosur->name = $value;
  345. $enclosur->rid = $rid;
  346. $enclosur->insert ();
  347. }
  348. // print_r($enclosurArray);die;
  349. }
  350. // 报销详情
  351. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  352. $receiptDetail = new receiptDetail ();
  353. $receiptDetail->staff = $this->staff [0] ['sid'];
  354. $receiptDetail->item = $value ['name'];
  355. $receiptDetail->itemCategory = $this->AGENCY;
  356. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  357. $receiptDetail->date = date ( "Y-m-d" );
  358. $receiptDetail->cid = $cid;
  359. $receiptDetail->rid = $rid;
  360. $receiptDetail->status = 4;
  361. $receiptDetail->insert ();
  362. }
  363. return "/saeaBorad";
  364. } else
  365. die ( 'illegal request' );
  366. }
  367. function remitEdit() {
  368. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  369. Doo::loadClass ( 'XDeode' );
  370. $XDeode = new XDeode ( 7 );
  371. $rid = $XDeode->decode ( $ridKey );
  372. if (! is_numeric ( $rid ))
  373. die ( 'illegal request' );
  374. Doo::loadModel ( 'accountItem' );
  375. Doo::loadModel ( 'verify' );
  376. Doo::loadModel ( 'receipt' );
  377. $receipt = new receipt ();
  378. $verify = new verify ();
  379. $accountItem = new accountItem ();
  380. Doo::loadModel ( 'L_category' );
  381. $lCategory = new L_category ();
  382. Doo::loadModel ( "role" );
  383. $role = new role ();
  384. Doo::loadModel ( 'enclosur' );
  385. $enclosur = new enclosur ();
  386. $receiptDetail = $receipt->getOne ( array (
  387. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  388. 'asArray' => true
  389. ) );
  390. if (empty ( $receiptDetail ))
  391. return "/saeaCreate";
  392. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  393. $acItem = $accountItem->find ( array (
  394. 'asArray' => true
  395. ) );
  396. $veList = $verify->find ( array (
  397. 'asArray' => true
  398. ) );
  399. foreach ( $veList as $key => $value ) {
  400. $v = json_decode ( $value ['staff'] );
  401. $list = array ();
  402. foreach ( $v as $n => $m ) {
  403. if ($m ['1'] == 'ROLE') {
  404. $roleInfo = $role->getOne ( array (
  405. 'where' => 'rid=' . $m [0],
  406. 'asArray' => true
  407. ) );
  408. $v [$n] [1] = $roleInfo ['name'];
  409. array_push ( $list, $roleInfo ['name'] );
  410. } else {
  411. array_push ( $list, $v [$n] [1] );
  412. }
  413. }
  414. $veList [$key] ['staff'] = implode ( '>', $list );
  415. }
  416. // 配置编辑信息
  417. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  418. foreach ( $acItem as $key => $value ) {
  419. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  420. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  421. $acItem [$key] ['price'] = $v ['price'];
  422. }
  423. }
  424. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  425. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  426. $acItem [$key] ['price'] = $v ['price'];
  427. }
  428. }
  429. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  430. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  431. $acItem [$key] ['price'] = $v ['price'];
  432. }
  433. }
  434. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  435. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  436. $acItem [$key] ['price'] = $v ['price'];
  437. }
  438. }
  439. }
  440. $data ['category'] = $lCategory->find ( array (
  441. 'asArray' => true
  442. ) );
  443. $data ['enclosurList'] = $enclosurList;
  444. $data ['cSum'] = $accountItemList ['cSum'];
  445. $data ['sum'] = $receiptDetail ['sum'];
  446. $data ['receiptDetail'] = $receiptDetail;
  447. $data ['veList'] = $veList;
  448. $data ['acItem'] = $acItem;
  449. $data ['memu'] = "receipt";
  450. $data ['staff'] = $this->staff;
  451. $data ['receiptMemu'] = 'saeaBorad';
  452. $data ['verify'] = $receiptDetail ['verify'];
  453. $data ['verifyId'] = $this->verifyId;
  454. $data ['executeId'] = $this->executeId;
  455. $data ['rid'] = $rid;
  456. $data ['ridKey'] = $ridKey;
  457. $this->render ( "/admin/remitEdit", $data );
  458. }
  459. function remitEdiDo() {
  460. $agency = $this->get_args ( 'agency' );
  461. $travel = $this->get_args ( 'travel' );
  462. $train = $this->get_args ( 'train' );
  463. $other = $this->get_args ( 'other' );
  464. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  465. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  466. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  467. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  468. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  469. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  470. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  471. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  472. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  473. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  474. Doo::loadClass ( 'XDeode' );
  475. $XDeode = new XDeode ( 7 );
  476. $rid = $XDeode->decode ( $ridKey );
  477. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  478. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  479. header ( 'Content-Type:text/html;charset=utf-8' );
  480. die ( '请填写联行号' );
  481. }
  482. Doo::loadModel ( 'receipt' );
  483. Doo::loadModel ( 'receiptDetail' );
  484. Doo::loadModel ( 'accountItem' );
  485. $accountItem = new accountItem ();
  486. $receipt = new receipt ();
  487. Doo::loadModel ( 'enclosur' );
  488. $enclosur = new enclosur ();
  489. Doo::loadModel ( 'execute' );
  490. $execute = new execute ();
  491. $executeDetail = $execute->getOne ( array (
  492. 'where' => 'mold="对公汇款执行人"',
  493. 'asArray' => true
  494. ) );
  495. $receiptDetail = $receipt->getOne ( array (
  496. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  497. 'asArray' => true
  498. ) );
  499. if (empty ( $receiptDetail ))
  500. return "/saeaBorad";
  501. $aItem = $accountItem->find ( array (
  502. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  503. 'asArray' => true
  504. ) );
  505. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  506. $ag = $tr = $ta = $ot = 0;
  507. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  508. foreach ( $aItem as $key => $value ) {
  509. if ($value ['category'] == $this->AGENCY) {
  510. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  511. array_push ( $accountJson [$this->AGENCY], array (
  512. 'aid' => $value ['aid'],
  513. 'name' => $value ['name'],
  514. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  515. ) );
  516. $sum += $agency [$ag];
  517. $agencySum += $agency [$ag];
  518. }
  519. $ag ++;
  520. }
  521. }
  522. $accountJson ['cSum'] = array (
  523. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  524. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  525. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  526. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  527. );
  528. // 报销单
  529. $rid = $receipt->rid = $receiptDetail ['rid'];
  530. $receipt->accountItem = json_encode ( $accountJson );
  531. $receipt->staff = $this->staff [0] ['sid'];
  532. $receipt->sum = number_format ( $sum, 2, '.', '' );
  533. $receipt->date = date ( "Y-m-d" );
  534. $receipt->cid = $cid;
  535. if ($receiptDetail ['Rtype'] == 1)
  536. $receipt->status = 7;
  537. else
  538. $receipt->status = 5;
  539. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  540. $receipt->verify = $verify;
  541. $receipt->executeCopy = $executeDetail ['staff'];
  542. $order = array (
  543. "\r\n",
  544. "\n",
  545. "\r"
  546. );
  547. $replace = '<br/>';
  548. $explanation = str_replace ( $order, $replace, $explanation );
  549. $receipt->explanation = $explanation;
  550. $receipt->remittanceName = $remittanceName;
  551. $receipt->bankName = $bankName;
  552. $receipt->bankNumber = $bankNumber;
  553. $receipt->remittanceBankType = $remittanceBankType;
  554. if ($remittanceBankType == 1)
  555. $receipt->coupletNumber = $coupletNumber;
  556. $receipt->update ();
  557. $receiptDetail = new receiptDetail ();
  558. $receiptDetail->delete ( array (
  559. 'where' => 'rid=' . $rid
  560. ) );
  561. // 报销详情
  562. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  563. $receiptDetail = new receiptDetail ();
  564. $receiptDetail->staff = $this->staff [0] ['sid'];
  565. $receiptDetail->item = $value ['name'];
  566. $receiptDetail->itemCategory = $this->AGENCY;
  567. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  568. $receiptDetail->date = date ( "Y-m-d" );
  569. $receiptDetail->cid = $cid;
  570. $receiptDetail->rid = $rid;
  571. $receiptDetail->status = 4;
  572. $receiptDetail->insert ();
  573. }
  574. // 附件
  575. if (! empty ( $enclosurName )) {
  576. $enclosurArray = explode ( '-', $enclosurName );
  577. foreach ( $enclosurArray as $value ) {
  578. $enclosur = new enclosur ();
  579. $enclosur->name = $value;
  580. $enclosur->rid = $rid;
  581. $enclosur->insert ();
  582. }
  583. }
  584. }
  585. return "/saeaBorad";
  586. }
  587. function remitApproval() {
  588. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  589. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  590. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  591. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  592. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  593. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  594. if (empty ( $status ))
  595. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  596. $vidList = array ();
  597. $button = 0;
  598. Doo::loadModel ( 'verify' );
  599. Doo::loadModel ( 'receipt' );
  600. Doo::loadModel ( 'staff' );
  601. $staff = new staff ();
  602. $receipt = new receipt ();
  603. $verify = new verify ();
  604. Doo::loadModel ( 'L_category' );
  605. $Lcategory = new L_category ();
  606. Doo::loadModel ( 'enclosur' );
  607. $enclosur = new enclosur ();
  608. // user verify ID
  609. $verifyDetail = $verify->find ( array (
  610. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  611. 'asArray' => true
  612. ) );
  613. foreach ( $verifyDetail as $key => $value ) {
  614. array_push ( $vidList, $value ['vid'] );
  615. }
  616. $vid = implode ( ",", $vidList );
  617. if (empty ( $verifyDetail ))
  618. $vid = 0;
  619. $categoryList = $Lcategory->find ( array (
  620. 'asArray' => true
  621. ) );
  622. $staffList = $staff->find ( array (
  623. 'where' => 'cid=' . $cid,
  624. 'asArray' => true
  625. ) );
  626. $ap = "";
  627. if ($status == 4) {
  628. $ap = 4;
  629. $status = 2;
  630. }
  631. // get Receipt By verifyID status 2
  632. $receiptList = $receipt->find ( array (
  633. 'where' => 'rid =' . $rid . ' and status=2',
  634. 'desc' => 'rid',
  635. 'asArray' => true
  636. ) );
  637. if (empty ( $receiptList )) {
  638. die ( 'illegal request' );
  639. }
  640. $Locate = 0;
  641. $roleId = 0;
  642. if ($ap == 4)
  643. $status = 4;
  644. foreach ( $receiptList as $key => $value ) {
  645. $receiptList [$key] ['Locate'] = $Locate;
  646. $Locate ++;
  647. $receiptList [$key] ['reviseDetail'] = array ();
  648. if (! empty ( $value ['reviseDetail'] ))
  649. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  650. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  651. $categoryDetil = $Lcategory->getOne ( array (
  652. 'where' => 'cid=' . $value ['cid'],
  653. 'asArray' => true
  654. ) );
  655. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  656. // 检测编辑状态
  657. $verifyList = $verify->getOne ( array (
  658. 'where' => 'vid=' . $value ['verify'],
  659. 'asArray' => true
  660. ) );
  661. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  662. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  663. Doo::loadModel ( 'role' );
  664. $role = new role ();
  665. // print_r($verifyList);
  666. $flag = true;
  667. $roleKey = 0;
  668. $endStaffArray = array ();
  669. $roleArrayCopy = array ();
  670. foreach ( $verifyList as $k => $v ) {
  671. // init verifyStaff
  672. if ($v [1] == 'ROLE') {
  673. if (! empty ( $verifyStaff )) {
  674. $endStaffArray = end ( $verifyStaff );
  675. if ($v [0] == $endStaffArray ['nextStaff']) {
  676. $roleId = $v [0];
  677. }
  678. }
  679. $roleVerify = json_decode ( $v [3], true );
  680. $roleKey = $k;
  681. $roleArray = array ();
  682. $rolename = $role->getOne ( array (
  683. 'where' => 'rid=' . $v [0],
  684. 'asArray' => true
  685. ) );
  686. foreach ( $roleVerify as $o => $p ) {
  687. $staffID = explode ( '_', $p );
  688. $staffInfo = $staff->getOne ( array (
  689. 'where' => 'sid=' . $staffID [0],
  690. 'asArray' => true
  691. ) );
  692. // print_r($staffID);
  693. $exp = array (
  694. 0 => $staffInfo ['sid'],
  695. 1 => $staffID [1],
  696. 2 => $staffInfo ['avatar'],
  697. 'date' => '',
  698. 'date' => '',
  699. 'opinion' => '',
  700. 'status' => '',
  701. 'rolename' => $rolename ['name']
  702. );
  703. array_push ( $roleArray, $exp );
  704. }
  705. $roleArrayCopy [$v [0]] = $roleArray;
  706. // $verifyList[$k]['roleArray']=$roleArray;
  707. }
  708. // print_r($roleArray);
  709. $verifyList [$k] ['date'] = "";
  710. $verifyList [$k] ['opinion'] = "";
  711. $verifyList [$k] ['status'] = "";
  712. if (empty ( $verifyStaff )) {
  713. $verifyList [$k] ['date'] = "";
  714. $verifyList [$k] ['opinion'] = "";
  715. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  716. $verifyList [$k] ['status'] = 4;
  717. $button = 4;
  718. $flag = false;
  719. }
  720. } else {
  721. foreach ( $verifyStaff as $m => $u ) {
  722. if ($v [0] == $m) {
  723. $verifyList [$k] ['date'] = $u ['date'];
  724. $verifyList [$k] ['opinion'] = $u ['opinion'];
  725. $verifyList [$k] ['status'] = $u ['status'];
  726. $flag = false;
  727. break;
  728. }
  729. }
  730. $endStaffArray = end ( $verifyStaff );
  731. if (isset ( $endStaffArray ['ROLE'] )) {
  732. } else {
  733. $endKey = key ( $verifyStaff );
  734. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  735. $button = 4;
  736. $verifyList [$k] ['status'] = 4;
  737. }
  738. }
  739. }
  740. }
  741. $rolename ['name'] = '';
  742. if (! empty ( $roleId )) {
  743. Doo::loadModel ( 'role' );
  744. $role = new role ();
  745. $rolename = $role->getOne ( array (
  746. 'where' => 'rid=' . $roleId,
  747. 'asArray' => true
  748. ) );
  749. }
  750. if (! empty ( $verifyStaff ))
  751. $endStaffArray = end ( $verifyStaff );
  752. $KOP = false;
  753. foreach ( $roleArrayCopy as $P => $A ) {
  754. foreach ( $A as $MKI => $AVL ) {
  755. if (! empty ( $verifyStaff )) {
  756. // &&$rolename['rid']==$endStaffArray['nextStaff']
  757. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  758. $button = 4;
  759. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  760. }
  761. foreach ( $verifyStaff as $m => $u ) {
  762. $AVLFK = $AVL [0] . '_R';
  763. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  764. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  765. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  766. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  767. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  768. break;
  769. }
  770. }
  771. } else {
  772. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  773. $button = 4;
  774. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  775. }
  776. }
  777. // $roleArray[$MKI]['rolename']=$rolename['name'];
  778. $KOP = true;
  779. }
  780. }
  781. foreach ( $roleArrayCopy as $k => $v ) {
  782. foreach ( $verifyList as $m => $n ) {
  783. if ($n [0] == $k) {
  784. array_splice ( $verifyList, $m, 1, $v );
  785. }
  786. }
  787. }
  788. $receiptList [$key] ['verifyList'] = $verifyList;
  789. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  790. 'where' => 'sid=' . $value ['staff'],
  791. 'asArray' => true
  792. ) );
  793. $receiptList [$key] ['button'] = $button;
  794. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  795. }
  796. $mothHtml = "";
  797. for($i = 1; $i <= 12; $i ++) {
  798. if ($month == $i)
  799. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  800. else
  801. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  802. }
  803. // 获取审批日志
  804. Doo::loadModel ( 'receiptLog' );
  805. $receiptLog = new receiptLog ();
  806. $rlList = array ();
  807. $rlInfo = $receiptLog->getOne ( array (
  808. 'where' => 'rid=' . $rid . ' and status=4',
  809. 'asArray' => true
  810. ) );
  811. $tijdate = $receiptLog->getOne ( array (
  812. 'where' => 'rid=' . $rid . ' and status=2',
  813. 'asc' => 'rlid',
  814. 'asArray' => true
  815. ) );
  816. if (! empty ( $rlInfo )) {
  817. $rlList = $receiptLog->find ( array (
  818. 'where' => 'rid=' . $rid,
  819. 'asc' => 'rlid',
  820. 'asArray' => true
  821. ) );
  822. }
  823. $receiptList [0] ['rlList'] = $rlList;
  824. $enclosurList = $enclosur->find ( array (
  825. 'where' => 'rid=' . $rid,
  826. 'asArray' => true
  827. ) );
  828. $enclosurHtml = '';
  829. foreach ( $enclosurList as $value ) {
  830. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  831. }
  832. // print_r($receiptList);
  833. $data ['enclosurHtml'] = $enclosurHtml;
  834. $data ['rolename'] = $rolename ['name'];
  835. $data ['datetij'] = $tijdate ['date'];
  836. $data ['mothHtml'] = $mothHtml;
  837. $data ['rid'] = $rid;
  838. $data ['receiptList'] = $receiptList;
  839. $data ['receiptApprovalCount'] = count ( $receiptList );
  840. $data ['status'] = $status;
  841. $data ['year'] = $year;
  842. $data ['categoryList'] = $categoryList;
  843. $data ['staffList'] = $staffList;
  844. $data ['cid'] = $cid;
  845. $data ['sid'] = $sid;
  846. $data ['ap'] = $ap;
  847. $data ['memu'] = "receipt";
  848. $data ['staff'] = $this->staff;
  849. $data ['receiptMemu'] = 'approvalExpenses';
  850. $data ['verifyId'] = $this->verifyId;
  851. $data ['executeId'] = $this->executeId;
  852. $this->render ( "/admin/remitApproval", $data );
  853. }
  854. function saeaLoanAdd() {
  855. Doo::loadModel ( 'verify' );
  856. $verify = new verify ();
  857. Doo::loadModel ( "role" );
  858. $role = new role ();
  859. Doo::loadModel ( 'L_category' );
  860. $lCategory = new L_category ();
  861. $veList = $verify->find ( array (
  862. 'asArray' => true
  863. ) );
  864. foreach ( $veList as $key => $value ) {
  865. $v = json_decode ( $value ['staff'] );
  866. $list = array ();
  867. foreach ( $v as $n => $m ) {
  868. if ($m ['1'] == 'ROLE') {
  869. $roleInfo = $role->getOne ( array (
  870. 'where' => 'rid=' . $m [0],
  871. 'asArray' => true
  872. ) );
  873. $v [$n] [1] = $roleInfo ['name'];
  874. array_push ( $list, $roleInfo ['name'] );
  875. } else {
  876. array_push ( $list, $v [$n] [1] );
  877. }
  878. }
  879. $veList [$key] ['staff'] = implode ( '>', $list );
  880. }
  881. $data ['category'] = $lCategory->find ( array (
  882. 'asArray' => true
  883. ) );
  884. $data ['veList'] = $veList;
  885. $data ['memu'] = "receipt";
  886. $data ['staff'] = $this->staff;
  887. $data ['receiptMemu'] = 'saeaBorad';
  888. $data ['verifyId'] = $this->verifyId;
  889. $data ['executeId'] = $this->executeId;
  890. $this->render ( "/admin/saeaLoanAdd", $data );
  891. }
  892. function saeaLoanAddDo() {
  893. $agency = $this->get_args ( 'agency' );
  894. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  895. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  896. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  897. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  898. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  899. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  900. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  901. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  902. // die;
  903. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  904. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  905. header ( 'Content-Type:text/html;charset=utf-8' );
  906. die ( '请填写联行号' );
  907. }
  908. Doo::loadModel ( 'receipt' );
  909. Doo::loadModel ( 'receiptDetail' );
  910. Doo::loadModel ( 'accountItem' );
  911. $accountItem = new accountItem ();
  912. $receipt = new receipt ();
  913. Doo::loadModel ( 'loanReceipt' );
  914. $loanReceipt = new loanReceipt ();
  915. Doo::loadModel ( 'execute' );
  916. $execute = new execute ();
  917. Doo::loadModel ( 'enclosur' );
  918. $executeDetail = $execute->getOne ( array (
  919. 'where' => 'mold="借款执行人"',
  920. 'asArray' => true
  921. ) );
  922. $aItem = $accountItem->find ( array (
  923. 'asArray' => true
  924. ) );
  925. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  926. $ag = $tr = $ta = $ot = 0;
  927. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  928. array_push ( $accountJson ['借款费用'], array (
  929. 'aid' => 0,
  930. 'name' => '申请金额',
  931. 'price' => number_format ( $agency, 2, '.', '' )
  932. ) );
  933. $sum += $agency;
  934. $agencySum += $agency;
  935. $accountJson ['cSum'] = array (
  936. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  937. 'agencySum' => number_format ( 0, 2, '.', '' ),
  938. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  939. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  940. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  941. );
  942. // 借款数据备份
  943. $loanReceipt->loanItem = json_encode ( $accountJson );
  944. $loanReceipt->staff = $this->staff [0] ['sid'];
  945. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  946. $loanReceipt->date = date ( "Y-m-d" );
  947. $loanReceipt->cid = $cid;
  948. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  949. $loanReceipt->status = 5;
  950. $loanReceipt->Rtype = 1;
  951. $loanReceipt->verify = $verify;
  952. $receipt->receiptOrder = $receipt->receiptOrder;
  953. // 添加HTML换行符
  954. // var_dump($explanation);
  955. $order = array (
  956. "\r\n",
  957. "\n",
  958. "\r"
  959. );
  960. $replace = '<br/>';
  961. $explanation = str_replace ( $order, $replace, $explanation );
  962. // $explanation=str_replace('\r',"<br/>",$explanation);
  963. // $explanation=str_replace('\r\n',"<br/>",$explanation);
  964. $loanReceipt->explanation = $explanation;
  965. $loanRid = $loanReceipt->insert ();
  966. // 报销单
  967. $receipt->loanItem = json_encode ( $accountJson );
  968. $receipt->staff = $this->staff [0] ['sid'];
  969. $receipt->sum = number_format ( $sum, 2, '.', '' );
  970. $receipt->date = date ( "Y-m-d" );
  971. $receipt->cid = $cid;
  972. // 特殊状态
  973. $receipt->status = 5;
  974. $receipt->Rtype = 1;
  975. $receipt->loanRid = $loanRid;
  976. // 修改审批流程加入角色
  977. $receipt->verify = $verify;
  978. $receipt->executeCopy = $executeDetail ['staff'];
  979. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  980. $receipt->explanation = $explanation;
  981. $receipt->remittanceName = $remittanceName;
  982. $receipt->bankName = $bankName;
  983. $receipt->bankNumber = $bankNumber;
  984. $receipt->remittanceBankType = $remittanceBankType;
  985. if ($remittanceBankType == 1)
  986. $receipt->coupletNumber = $coupletNumber;
  987. $rid = $receipt->insert ();
  988. return "/saeaBorad";
  989. } else
  990. die ( 'illegal request' );
  991. }
  992. function saeaLoanEdi() {
  993. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  994. Doo::loadClass ( 'XDeode' );
  995. $XDeode = new XDeode ( 7 );
  996. $rid = $XDeode->decode ( $ridKey );
  997. if (! is_numeric ( $rid ))
  998. die ( 'illegal request' );
  999. Doo::loadModel ( 'verify' );
  1000. $verify = new verify ();
  1001. Doo::loadModel ( "role" );
  1002. $role = new role ();
  1003. Doo::loadModel ( 'L_category' );
  1004. $lCategory = new L_category ();
  1005. Doo::loadModel ( 'receipt' );
  1006. $receipt = new receipt ();
  1007. $receiptInfo = $receipt->getOne ( array (
  1008. 'where' => 'rid=' . $rid,
  1009. 'asArray' => true
  1010. ) );
  1011. $veList = $verify->find ( array (
  1012. 'asArray' => true
  1013. ) );
  1014. foreach ( $veList as $key => $value ) {
  1015. $v = json_decode ( $value ['staff'] );
  1016. $list = array ();
  1017. foreach ( $v as $n => $m ) {
  1018. if ($m ['1'] == 'ROLE') {
  1019. $roleInfo = $role->getOne ( array (
  1020. 'where' => 'rid=' . $m [0],
  1021. 'asArray' => true
  1022. ) );
  1023. $v [$n] [1] = $roleInfo ['name'];
  1024. array_push ( $list, $roleInfo ['name'] );
  1025. } else {
  1026. array_push ( $list, $v [$n] [1] );
  1027. }
  1028. }
  1029. $veList [$key] ['staff'] = implode ( '>', $list );
  1030. }
  1031. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  1032. // print_r($receiptInfo);
  1033. $data ['receiptInfo'] = $receiptInfo;
  1034. $data ['category'] = $lCategory->find ( array (
  1035. 'asArray' => true
  1036. ) );
  1037. $data ['veList'] = $veList;
  1038. $data ['ridKey'] = $ridKey;
  1039. $data ['memu'] = "receipt";
  1040. $data ['staff'] = $this->staff;
  1041. $data ['receiptMemu'] = 'saeaBorad';
  1042. $data ['verifyId'] = $this->verifyId;
  1043. $data ['executeId'] = $this->executeId;
  1044. $this->render ( "/admin/saeaLoanEdi", $data );
  1045. }
  1046. function saeaLoanEdiDo() {
  1047. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1048. $agency = $this->get_args ( 'agency' );
  1049. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1050. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1051. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1052. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1053. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1054. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1055. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1056. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1057. // die;
  1058. Doo::loadClass ( 'XDeode' );
  1059. $XDeode = new XDeode ( 7 );
  1060. $rid = $XDeode->decode ( $ridKey );
  1061. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1062. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1063. header ( 'Content-Type:text/html;charset=utf-8' );
  1064. die ( '请填写联行号' );
  1065. }
  1066. Doo::loadModel ( 'receipt' );
  1067. Doo::loadModel ( 'receiptDetail' );
  1068. Doo::loadModel ( 'accountItem' );
  1069. $accountItem = new accountItem ();
  1070. $receipt = new receipt ();
  1071. Doo::loadModel ( 'loanReceipt' );
  1072. $loanReceipt = new loanReceipt ();
  1073. Doo::loadModel ( 'enclosur' );
  1074. Doo::loadModel ( 'execute' );
  1075. $execute = new execute ();
  1076. $executeDetail = $execute->getOne ( array (
  1077. 'where' => 'mold="借款执行人"',
  1078. 'asArray' => true
  1079. ) );
  1080. $receiptDetail = $receipt->getOne ( array (
  1081. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  1082. 'asArray' => true
  1083. ) );
  1084. if (empty ( $receiptDetail ))
  1085. die ( '参数错误' );
  1086. $aItem = $accountItem->find ( array (
  1087. 'asArray' => true
  1088. ) );
  1089. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1090. $ag = $tr = $ta = $ot = 0;
  1091. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1092. array_push ( $accountJson ['借款费用'], array (
  1093. 'aid' => 0,
  1094. 'name' => '申请金额',
  1095. 'price' => number_format ( $agency, 2, '.', '' )
  1096. ) );
  1097. $sum += $agency;
  1098. $agencySum += $agency;
  1099. $accountJson ['cSum'] = array (
  1100. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1101. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1102. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1103. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1104. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1105. );
  1106. // 报销单
  1107. $receipt->loanItem = json_encode ( $accountJson );
  1108. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1109. $receipt->cid = $cid;
  1110. // 特殊状态
  1111. // 修改审批流程加入角色
  1112. if ($receiptDetail ['status'] != 4)
  1113. $receipt->verify = $verify;
  1114. $order = array (
  1115. "\r\n",
  1116. "\n",
  1117. "\r"
  1118. );
  1119. $replace = '<br/>';
  1120. $explanation = str_replace ( $order, $replace, $explanation );
  1121. $receipt->explanation = $explanation;
  1122. $receipt->remittanceName = $remittanceName;
  1123. $receipt->bankName = $bankName;
  1124. $receipt->bankNumber = $bankNumber;
  1125. $receipt->remittanceBankType = $remittanceBankType;
  1126. if ($remittanceBankType == 1)
  1127. $receipt->coupletNumber = $coupletNumber;
  1128. $receipt->update ( array (
  1129. 'where' => 'rid=' . $rid
  1130. ) );
  1131. // 借款数据更新
  1132. $loanReceipt->loanItem = json_encode ( $accountJson );
  1133. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1134. $loanReceipt->cid = $cid;
  1135. if ($receiptDetail ['status'] != 4)
  1136. $loanReceipt->verify = $verify;
  1137. $loanReceipt->explanation = $explanation;
  1138. $receipt->executeCopy = $executeDetail ['staff'];
  1139. $loanReceipt->update ( array (
  1140. 'where' => 'rid=' . $receiptDetail ['loanRid']
  1141. ) );
  1142. }
  1143. return "/saeaBorad";
  1144. }
  1145. function saeaLoanReceiptAdd() {
  1146. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1147. Doo::loadModel ( 'receipt' );
  1148. $receipt = new receipt ();
  1149. Doo::loadModel ( 'loanReceipt' );
  1150. $loanReceipt = new loanReceipt ();
  1151. Doo::loadModel ( 'L_category' );
  1152. $Lcategory = new L_category ();
  1153. Doo::loadModel ( 'verify' );
  1154. Doo::loadModel ( 'statistics' );
  1155. $statistics = new statistics ();
  1156. $verify = new verify ();
  1157. Doo::loadModel ( 'staff' );
  1158. $staff = new staff ();
  1159. $receiptDetail = $receipt->getOne ( array (
  1160. 'where' => 'rid=' . $rid,
  1161. 'desc' => 'rid',
  1162. 'asArray' => true
  1163. ) );
  1164. $receiptList = $loanReceipt->find ( array (
  1165. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1166. 'desc' => 'rid',
  1167. 'asArray' => true
  1168. ) );
  1169. $Locate = 0;
  1170. $roleId = 0;
  1171. $button = 0;
  1172. foreach ( $receiptList as $key => $value ) {
  1173. $receiptList [$key] ['Locate'] = $Locate;
  1174. $Locate ++;
  1175. $receiptList [$key] ['reviseDetail'] = array ();
  1176. if (! empty ( $value ['reviseDetail'] ))
  1177. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1178. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1179. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1180. $categoryDetil = $Lcategory->getOne ( array (
  1181. 'where' => 'cid=' . $value ['cid'],
  1182. 'asArray' => true
  1183. ) );
  1184. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1185. // 检测编辑状态
  1186. $verifyList = $verify->getOne ( array (
  1187. 'where' => 'vid=' . $value ['verify'],
  1188. 'asArray' => true
  1189. ) );
  1190. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1191. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1192. Doo::loadModel ( 'role' );
  1193. $role = new role ();
  1194. $flag = true;
  1195. $roleKey = 0;
  1196. $endStaffArray = array ();
  1197. $roleArrayCopy = array ();
  1198. foreach ( $verifyList as $k => $v ) {
  1199. // init verifyStaff
  1200. if ($v [1] == 'ROLE') {
  1201. if (! empty ( $verifyStaff )) {
  1202. $endStaffArray = end ( $verifyStaff );
  1203. // if ($v[0]==$endStaffArray['nextStaff']){
  1204. // $roleId=$v[0];
  1205. // }
  1206. }
  1207. $roleVerify = json_decode ( $v [3], true );
  1208. $roleKey = $k;
  1209. $roleArray = array ();
  1210. $rolename = $role->getOne ( array (
  1211. 'where' => 'rid=' . $v [0],
  1212. 'asArray' => true
  1213. ) );
  1214. foreach ( $roleVerify as $o => $p ) {
  1215. $staffID = explode ( '_', $p );
  1216. $staffInfo = $staff->getOne ( array (
  1217. 'where' => 'sid=' . $staffID [0],
  1218. 'asArray' => true
  1219. ) );
  1220. // print_r($staffID);
  1221. $exp = array (
  1222. 0 => $staffInfo ['sid'],
  1223. 1 => $staffID [1],
  1224. 2 => $staffInfo ['avatar'],
  1225. 'date' => '',
  1226. 'date' => '',
  1227. 'opinion' => '',
  1228. 'status' => '',
  1229. 'rolename' => $rolename ['name']
  1230. );
  1231. array_push ( $roleArray, $exp );
  1232. }
  1233. $roleArrayCopy [$v [0]] = $roleArray;
  1234. // $verifyList[$k]['roleArray']=$roleArray;
  1235. }
  1236. $verifyList [$k] ['date'] = "";
  1237. $verifyList [$k] ['opinion'] = "";
  1238. $verifyList [$k] ['status'] = "";
  1239. if (empty ( $verifyStaff )) {
  1240. $verifyList [$k] ['date'] = "";
  1241. $verifyList [$k] ['opinion'] = "";
  1242. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1243. $verifyList [$k] ['status'] = 4;
  1244. $flag = false;
  1245. }
  1246. } else {
  1247. foreach ( $verifyStaff as $m => $u ) {
  1248. if ($v [0] == $m) {
  1249. $verifyList [$k] ['date'] = $u ['date'];
  1250. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1251. $verifyList [$k] ['status'] = $u ['status'];
  1252. $flag = false;
  1253. break;
  1254. }
  1255. }
  1256. $endStaffArray = end ( $verifyStaff );
  1257. if (isset ( $endStaffArray ['ROLE'] )) {
  1258. } else {
  1259. // $endKey=key($verifyStaff);
  1260. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1261. // $button=4;
  1262. // $verifyList[$k]['status']=4;
  1263. // }
  1264. }
  1265. }
  1266. }
  1267. $rolename ['name'] = '';
  1268. if (! empty ( $roleId )) {
  1269. Doo::loadModel ( 'role' );
  1270. $role = new role ();
  1271. $rolename = $role->getOne ( array (
  1272. 'where' => 'rid=' . $roleId,
  1273. 'asArray' => true
  1274. ) );
  1275. }
  1276. if (! empty ( $verifyStaff ))
  1277. $endStaffArray = end ( $verifyStaff );
  1278. $KOP = false;
  1279. foreach ( $roleArrayCopy as $P => $A ) {
  1280. foreach ( $A as $MKI => $AVL ) {
  1281. if (! empty ( $verifyStaff )) {
  1282. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1283. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1284. $button = 4;
  1285. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1286. }
  1287. foreach ( $verifyStaff as $m => $u ) {
  1288. $AVLFK = $AVL [0] . '_R';
  1289. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1290. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1291. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1292. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1293. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1294. break;
  1295. }
  1296. }
  1297. } else {
  1298. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1299. $button = 4;
  1300. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1301. }
  1302. }
  1303. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1304. $KOP = true;
  1305. }
  1306. }
  1307. foreach ( $roleArrayCopy as $k => $v ) {
  1308. foreach ( $verifyList as $m => $n ) {
  1309. if ($n [0] == $k) {
  1310. array_splice ( $verifyList, $m, 1, $v );
  1311. }
  1312. }
  1313. }
  1314. $receiptList [$key] ['verifyList'] = $verifyList;
  1315. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1316. 'where' => 'sid=' . $value ['staff'],
  1317. 'asArray' => true
  1318. ) );
  1319. $receiptList [$key] ['button'] = $button;
  1320. //
  1321. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1322. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1323. }
  1324. $data ['receiptList'] = $receiptList;
  1325. $data ['receiptDetail'] = $receiptDetail;
  1326. Doo::loadModel ( 'L_category' );
  1327. $lCategory = new L_category ();
  1328. Doo::loadModel ( 'accountItem' );
  1329. $accountItem = new accountItem ();
  1330. $acItem = $accountItem->find ( array (
  1331. 'asArray' => true
  1332. ) );
  1333. $veList = $verify->find ( array (
  1334. 'asArray' => true
  1335. ) );
  1336. foreach ( $veList as $key => $value ) {
  1337. $v = json_decode ( $value ['staff'] );
  1338. $list = array ();
  1339. foreach ( $v as $n => $m ) {
  1340. if ($m ['1'] == 'ROLE') {
  1341. $roleInfo = $role->getOne ( array (
  1342. 'where' => 'rid=' . $m [0],
  1343. 'asArray' => true
  1344. ) );
  1345. $v [$n] [1] = $roleInfo ['name'];
  1346. array_push ( $list, $roleInfo ['name'] );
  1347. } else {
  1348. array_push ( $list, $v [$n] [1] );
  1349. }
  1350. }
  1351. $veList [$key] ['staff'] = implode ( '>', $list );
  1352. }
  1353. $data ['rid'] = $rid;
  1354. $data ['category'] = $lCategory->find ( array (
  1355. 'asArray' => true
  1356. ) );
  1357. $data ['veList'] = $veList;
  1358. $data ['acItem'] = $acItem;
  1359. $data ['memu'] = "receipt";
  1360. $data ['staff'] = $this->staff;
  1361. $data ['receiptMemu'] = 'saeaBorad';
  1362. $data ['verifyId'] = $this->verifyId;
  1363. $data ['executeId'] = $this->executeId;
  1364. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1365. }
  1366. function saeaLoanReceiptAddDo() {
  1367. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1368. $agency = $this->get_args ( 'agency' );
  1369. $travel = $this->get_args ( 'travel' );
  1370. $train = $this->get_args ( 'train' );
  1371. $other = $this->get_args ( 'other' );
  1372. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1373. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1374. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1375. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1376. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1377. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1378. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1379. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1380. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1381. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1382. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1383. header ( 'Content-Type:text/html;charset=utf-8' );
  1384. die ( '请填写联行号' );
  1385. }
  1386. Doo::loadModel ( 'receipt' );
  1387. Doo::loadModel ( 'receiptDetail' );
  1388. Doo::loadModel ( 'accountItem' );
  1389. $accountItem = new accountItem ();
  1390. $receipt = new receipt ();
  1391. Doo::loadModel ( 'enclosur' );
  1392. Doo::loadModel ( 'execute' );
  1393. $execute = new execute ();
  1394. $executeDetail = $execute->getOne ( array (
  1395. 'where' => 'mold="借款费用执行人"',
  1396. 'asArray' => true
  1397. ) );
  1398. $receiptDet = $receipt->getOne ( array (
  1399. 'where' => 'rid=' . $rid,
  1400. 'asArray' => true
  1401. ) );
  1402. // if(!empty($receiptDetail))
  1403. // return "/referReceipt/".$receiptDetail['rid'];
  1404. $aItem = $accountItem->find ( array (
  1405. 'asArray' => true
  1406. ) );
  1407. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1408. $ag = $tr = $ta = $ot = 0;
  1409. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1410. foreach ( $aItem as $key => $value ) {
  1411. if ($value ['category'] == $this->AGENCY) {
  1412. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1413. array_push ( $accountJson [$this->AGENCY], array (
  1414. 'aid' => $value ['aid'],
  1415. 'name' => $value ['name'],
  1416. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1417. ) );
  1418. $sum += $agency [$ag];
  1419. $agencySum += $agency [$ag];
  1420. }
  1421. $ag ++;
  1422. }
  1423. if ($value ['category'] == $this->TRAVEL) {
  1424. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1425. array_push ( $accountJson [$this->TRAVEL], array (
  1426. 'aid' => $value ['aid'],
  1427. 'name' => $value ['name'],
  1428. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1429. ) );
  1430. $sum += $travel [$tr];
  1431. $travelSum += $travel [$tr];
  1432. }
  1433. $tr ++;
  1434. }
  1435. if ($value ['category'] == $this->TRAIN) {
  1436. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1437. array_push ( $accountJson [$this->TRAIN], array (
  1438. 'aid' => $value ['aid'],
  1439. 'name' => $value ['name'],
  1440. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1441. ) );
  1442. $sum += $train [$ta];
  1443. $trainSum += $train [$ta];
  1444. }
  1445. $ta ++;
  1446. }
  1447. if ($value ['category'] == $this->OTHER) {
  1448. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1449. array_push ( $accountJson [$this->OTHER], array (
  1450. 'aid' => $value ['aid'],
  1451. 'name' => $value ['name'],
  1452. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1453. ) );
  1454. $sum += $other [$ot];
  1455. $otherSum += $other [$ot];
  1456. }
  1457. $ot ++;
  1458. }
  1459. }
  1460. $accountJson ['cSum'] = array (
  1461. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1462. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1463. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1464. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1465. );
  1466. // 报销单
  1467. $receipt->accountItem = json_encode ( $accountJson );
  1468. $receipt->staff = $this->staff [0] ['sid'];
  1469. $receipt->loanSum = $receiptDet ['sum'];
  1470. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1471. $receipt->date = date ( "Y-m-d" );
  1472. $receipt->pastDate = '';
  1473. $receipt->cid = $cid;
  1474. $receipt->status = 7;
  1475. // 修改审批流程加入角色
  1476. $receipt->verify = $verify;
  1477. $receipt->verifyStaff = '';
  1478. $receipt->executeStaff = '';
  1479. $receipt->executeCopy = $executeDetail ['staff'];
  1480. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  1481. $receipt->explanation = $explanation;
  1482. $receipt->remittanceName = $remittanceName;
  1483. $receipt->bankName = $bankName;
  1484. $receipt->bankNumber = $bankNumber;
  1485. $receipt->remittanceBankType = $remittanceBankType;
  1486. if ($remittanceBankType == 1)
  1487. $receipt->coupletNumber = $coupletNumber;
  1488. $receipt->update ( array (
  1489. 'where' => 'rid=' . $rid
  1490. ) );
  1491. // 附件
  1492. if (! empty ( $enclosurName )) {
  1493. $enclosurArray = explode ( '-', $enclosurName );
  1494. foreach ( $enclosurArray as $value ) {
  1495. $enclosur = new enclosur ();
  1496. $enclosur->name = $value;
  1497. $enclosur->rid = $rid;
  1498. $enclosur->insert ();
  1499. }
  1500. // print_r($enclosurArray);die;
  1501. }
  1502. // 报销详情
  1503. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1504. $receiptDetail = new receiptDetail ();
  1505. $receiptDetail->staff = $this->staff [0] ['sid'];
  1506. $receiptDetail->item = $value ['name'];
  1507. $receiptDetail->itemCategory = $this->AGENCY;
  1508. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1509. $receiptDetail->date = date ( "Y-m-d" );
  1510. $receiptDetail->cid = $cid;
  1511. $receiptDetail->rid = $rid;
  1512. $receiptDetail->status = 4;
  1513. $receiptDetail->insert ();
  1514. }
  1515. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1516. $receiptDetail = new receiptDetail ();
  1517. $receiptDetail->staff = $this->staff [0] ['sid'];
  1518. $receiptDetail->item = $value ['name'];
  1519. $receiptDetail->itemCategory = $this->TRAVEL;
  1520. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1521. $receiptDetail->date = date ( "Y-m-d" );
  1522. $receiptDetail->cid = $cid;
  1523. $receiptDetail->rid = $rid;
  1524. $receiptDetail->status = 4;
  1525. $receiptDetail->insert ();
  1526. }
  1527. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1528. $receiptDetail = new receiptDetail ();
  1529. $receiptDetail->staff = $this->staff [0] ['sid'];
  1530. $receiptDetail->item = $value ['name'];
  1531. $receiptDetail->itemCategory = $this->TRAIN;
  1532. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1533. $receiptDetail->date = date ( "Y-m-d" );
  1534. $receiptDetail->cid = $cid;
  1535. $receiptDetail->rid = $rid;
  1536. $receiptDetail->status = 4;
  1537. $receiptDetail->insert ();
  1538. }
  1539. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1540. $receiptDetail = new receiptDetail ();
  1541. $receiptDetail->staff = $this->staff [0] ['sid'];
  1542. $receiptDetail->item = $value ['name'];
  1543. $receiptDetail->itemCategory = $this->OTHER;
  1544. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1545. $receiptDetail->date = date ( "Y-m-d" );
  1546. $receiptDetail->cid = $cid;
  1547. $receiptDetail->rid = $rid;
  1548. $receiptDetail->status = 4;
  1549. $receiptDetail->insert ();
  1550. }
  1551. return "/saeaBorad";
  1552. }
  1553. return "/saeaLoanReceiptAdd/" . $rid;
  1554. }
  1555. function saeaLoanReceiptEdi() {
  1556. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1557. Doo::loadClass ( 'XDeode' );
  1558. $XDeode = new XDeode ( 7 );
  1559. $rid = $XDeode->decode ( $ridKey );
  1560. if (! is_numeric ( $rid ))
  1561. die ( 'illegal request' );
  1562. Doo::loadModel ( 'accountItem' );
  1563. Doo::loadModel ( 'verify' );
  1564. Doo::loadModel ( 'receipt' );
  1565. $receipt = new receipt ();
  1566. $verify = new verify ();
  1567. $accountItem = new accountItem ();
  1568. Doo::loadModel ( 'L_category' );
  1569. $Lcategory = new L_category ();
  1570. Doo::loadModel ( "role" );
  1571. $role = new role ();
  1572. Doo::loadModel ( 'loanReceipt' );
  1573. $loanReceipt = new loanReceipt ();
  1574. Doo::loadModel ( 'staff' );
  1575. $staff = new staff ();
  1576. $receiptDetail = $receipt->getOne ( array (
  1577. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  1578. 'asArray' => true
  1579. ) );
  1580. if (empty ( $receiptDetail ))
  1581. return "/saeaBorad";
  1582. $receiptList = $loanReceipt->find ( array (
  1583. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1584. 'desc' => 'rid',
  1585. 'asArray' => true
  1586. ) );
  1587. $Locate = 0;
  1588. $roleId = 0;
  1589. $button = 0;
  1590. foreach ( $receiptList as $key => $value ) {
  1591. $receiptList [$key] ['Locate'] = $Locate;
  1592. $Locate ++;
  1593. $receiptList [$key] ['reviseDetail'] = array ();
  1594. if (! empty ( $value ['reviseDetail'] ))
  1595. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1596. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1597. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1598. $categoryDetil = $Lcategory->getOne ( array (
  1599. 'where' => 'cid=' . $value ['cid'],
  1600. 'asArray' => true
  1601. ) );
  1602. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1603. // 检测编辑状态
  1604. $verifyList = $verify->getOne ( array (
  1605. 'where' => 'vid=' . $value ['verify'],
  1606. 'asArray' => true
  1607. ) );
  1608. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1609. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1610. Doo::loadModel ( 'role' );
  1611. $role = new role ();
  1612. $flag = true;
  1613. $roleKey = 0;
  1614. $endStaffArray = array ();
  1615. $roleArrayCopy = array ();
  1616. foreach ( $verifyList as $k => $v ) {
  1617. // init verifyStaff
  1618. if ($v [1] == 'ROLE') {
  1619. if (! empty ( $verifyStaff )) {
  1620. $endStaffArray = end ( $verifyStaff );
  1621. // if ($v[0]==$endStaffArray['nextStaff']){
  1622. // $roleId=$v[0];
  1623. // }
  1624. }
  1625. $roleVerify = json_decode ( $v [3], true );
  1626. $roleKey = $k;
  1627. $roleArray = array ();
  1628. $rolename = $role->getOne ( array (
  1629. 'where' => 'rid=' . $v [0],
  1630. 'asArray' => true
  1631. ) );
  1632. foreach ( $roleVerify as $o => $p ) {
  1633. $staffID = explode ( '_', $p );
  1634. $staffInfo = $staff->getOne ( array (
  1635. 'where' => 'sid=' . $staffID [0],
  1636. 'asArray' => true
  1637. ) );
  1638. // print_r($staffID);
  1639. $exp = array (
  1640. 0 => $staffInfo ['sid'],
  1641. 1 => $staffID [1],
  1642. 2 => $staffInfo ['avatar'],
  1643. 'date' => '',
  1644. 'date' => '',
  1645. 'opinion' => '',
  1646. 'status' => '',
  1647. 'rolename' => $rolename ['name']
  1648. );
  1649. array_push ( $roleArray, $exp );
  1650. }
  1651. $roleArrayCopy [$v [0]] = $roleArray;
  1652. // $verifyList[$k]['roleArray']=$roleArray;
  1653. }
  1654. $verifyList [$k] ['date'] = "";
  1655. $verifyList [$k] ['opinion'] = "";
  1656. $verifyList [$k] ['status'] = "";
  1657. if (empty ( $verifyStaff )) {
  1658. $verifyList [$k] ['date'] = "";
  1659. $verifyList [$k] ['opinion'] = "";
  1660. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1661. $verifyList [$k] ['status'] = 4;
  1662. $flag = false;
  1663. }
  1664. } else {
  1665. foreach ( $verifyStaff as $m => $u ) {
  1666. if ($v [0] == $m) {
  1667. $verifyList [$k] ['date'] = $u ['date'];
  1668. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1669. $verifyList [$k] ['status'] = $u ['status'];
  1670. $flag = false;
  1671. break;
  1672. }
  1673. }
  1674. $endStaffArray = end ( $verifyStaff );
  1675. if (isset ( $endStaffArray ['ROLE'] )) {
  1676. } else {
  1677. // $endKey=key($verifyStaff);
  1678. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1679. // $button=4;
  1680. // $verifyList[$k]['status']=4;
  1681. // }
  1682. }
  1683. }
  1684. }
  1685. $rolename ['name'] = '';
  1686. if (! empty ( $roleId )) {
  1687. Doo::loadModel ( 'role' );
  1688. $role = new role ();
  1689. $rolename = $role->getOne ( array (
  1690. 'where' => 'rid=' . $roleId,
  1691. 'asArray' => true
  1692. ) );
  1693. }
  1694. if (! empty ( $verifyStaff ))
  1695. $endStaffArray = end ( $verifyStaff );
  1696. $KOP = false;
  1697. foreach ( $roleArrayCopy as $P => $A ) {
  1698. foreach ( $A as $MKI => $AVL ) {
  1699. if (! empty ( $verifyStaff )) {
  1700. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1701. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1702. $button = 4;
  1703. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1704. }
  1705. foreach ( $verifyStaff as $m => $u ) {
  1706. $AVLFK = $AVL [0] . '_R';
  1707. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1708. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1709. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1710. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1711. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1712. break;
  1713. }
  1714. }
  1715. } else {
  1716. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1717. $button = 4;
  1718. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1719. }
  1720. }
  1721. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1722. $KOP = true;
  1723. }
  1724. }
  1725. foreach ( $roleArrayCopy as $k => $v ) {
  1726. foreach ( $verifyList as $m => $n ) {
  1727. if ($n [0] == $k) {
  1728. array_splice ( $verifyList, $m, 1, $v );
  1729. }
  1730. }
  1731. }
  1732. $receiptList [$key] ['verifyList'] = $verifyList;
  1733. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1734. 'where' => 'sid=' . $value ['staff'],
  1735. 'asArray' => true
  1736. ) );
  1737. $receiptList [$key] ['button'] = $button;
  1738. //
  1739. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1740. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1741. }
  1742. $data ['receiptList'] = $receiptList;
  1743. $acItem = $accountItem->find ( array (
  1744. 'asArray' => true
  1745. ) );
  1746. $veList = $verify->find ( array (
  1747. 'asArray' => true
  1748. ) );
  1749. foreach ( $veList as $key => $value ) {
  1750. $v = json_decode ( $value ['staff'] );
  1751. $list = array ();
  1752. foreach ( $v as $n => $m ) {
  1753. if ($m ['1'] == 'ROLE') {
  1754. $roleInfo = $role->getOne ( array (
  1755. 'where' => 'rid=' . $m [0],
  1756. 'asArray' => true
  1757. ) );
  1758. $v [$n] [1] = $roleInfo ['name'];
  1759. array_push ( $list, $roleInfo ['name'] );
  1760. } else {
  1761. array_push ( $list, $v [$n] [1] );
  1762. }
  1763. }
  1764. $veList [$key] ['staff'] = implode ( '>', $list );
  1765. }
  1766. // 配置编辑信息
  1767. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1768. foreach ( $acItem as $key => $value ) {
  1769. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1770. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1771. $acItem [$key] ['price'] = $v ['price'];
  1772. }
  1773. }
  1774. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1775. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1776. $acItem [$key] ['price'] = $v ['price'];
  1777. }
  1778. }
  1779. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1780. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1781. $acItem [$key] ['price'] = $v ['price'];
  1782. }
  1783. }
  1784. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1785. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1786. $acItem [$key] ['price'] = $v ['price'];
  1787. }
  1788. }
  1789. }
  1790. $data ['category'] = $Lcategory->find ( array (
  1791. 'asArray' => true
  1792. ) );
  1793. $data ['ridKey'] = $ridKey;
  1794. $data ['cSum'] = $accountItemList ['cSum'];
  1795. $data ['sum'] = $receiptDetail ['sum'];
  1796. $data ['receiptDetail'] = $receiptDetail;
  1797. $data ['veList'] = $veList;
  1798. $data ['acItem'] = $acItem;
  1799. $data ['memu'] = "receipt";
  1800. $data ['staff'] = $this->staff;
  1801. $data ['receiptMemu'] = 'saeaBorad';
  1802. $data ['verify'] = $receiptDetail ['verify'];
  1803. $data ['verifyId'] = $this->verifyId;
  1804. $data ['executeId'] = $this->executeId;
  1805. $data ['rid'] = $rid;
  1806. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  1807. }
  1808. function confirmation() {
  1809. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1810. Doo::loadModel ( 'receipt' );
  1811. Doo::loadModel ( 'receiptDetail' );
  1812. $receipt = new receipt ();
  1813. $receiptDetail = new receiptDetail ();
  1814. Doo::loadModel ( 'statistics' );
  1815. Doo::loadModel ( 'itemStatistics' );
  1816. $statistics = new statistics ();
  1817. $itemStatistics = new itemStatistics ();
  1818. Doo::loadModel ( "verify" );
  1819. $verify = new verify ();
  1820. $receiptDetailList = $receipt->getOne ( array (
  1821. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  1822. 'asArray' => true
  1823. ) );
  1824. if (empty ( $receiptDetailList ))
  1825. return "/saeaBorad";
  1826. $verifyDetail = $verify->getOne ( array (
  1827. 'where' => ' vid =' . $receiptDetailList ['verify'],
  1828. 'asArray' => true
  1829. ) );
  1830. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  1831. if (empty ( $receiptDetailList ['nowStaff'] )) {
  1832. $nowStaff = "";
  1833. $nowStaffList = array ();
  1834. if ($verifyDetail [0] [1] == 'ROLE') {
  1835. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  1836. foreach ( $vStaffString as $key => $value ) {
  1837. $staffK = explode ( "_", $value );
  1838. array_push ( $nowStaffList, $staffK [0] );
  1839. }
  1840. $nowStaff = implode ( ',', $nowStaffList );
  1841. } else {
  1842. $nowStaff = $verifyDetail [0] [0];
  1843. }
  1844. $receipt->nowStaff = $nowStaff;
  1845. }
  1846. // echo $nowStaff;
  1847. // print_r($verifyDetail);die;
  1848. $receipt->rid = $receiptDetailList ['rid'];
  1849. $receipt->status = 2;
  1850. $receipt->update ();
  1851. // 操作日志
  1852. Doo::loadModel ( "receiptLog" );
  1853. $receiptLog = new receiptLog ();
  1854. $verify = new verify ();
  1855. $receiptInfo = $receipt->getOne ( array (
  1856. 'where' => 'rid=' . $rid,
  1857. 'asArray' => true
  1858. ) );
  1859. $vr = $verify->getOne ( array (
  1860. 'where' => 'vid=' . $receiptInfo ['verify'],
  1861. 'asArray' => true
  1862. ) );
  1863. $jd = json_decode ( $vr ['staff'] );
  1864. $roleId = 0;
  1865. foreach ( $jd as $key => $value ) {
  1866. if ($value [1] == 'ROLE') {
  1867. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  1868. if ($pos !== false) {
  1869. $roleId = $value [0];
  1870. }
  1871. }
  1872. }
  1873. // 审批日志
  1874. // echo $roleId;die;
  1875. if (! empty ( $roleId )) {
  1876. Doo::loadModel ( "role" );
  1877. $role = new role ();
  1878. $roleInfo = $role->getOne ( array (
  1879. 'where' => 'rid=' . $roleId,
  1880. 'asArray' => true
  1881. ) );
  1882. // $receiptLog->rolename = $roleInfo ['name'];
  1883. }
  1884. $receiptLog->username = $this->staff [0] ['username'];
  1885. $receiptLog->uid = $this->staff [0] ['sid'];
  1886. $receiptLog->date = date ( "Y-m-d" );
  1887. $receiptLog->opinion = '提交审批';
  1888. $receiptLog->img = $this->staff [0] ['avatar'];
  1889. $receiptLog->status = 2;
  1890. $receiptLog->rid = $rid;
  1891. $receiptLog->insert ();
  1892. return "/expenses";
  1893. }
  1894. function expenses() {
  1895. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  1896. if (empty ( $item ))
  1897. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  1898. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1899. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  1900. Doo::loadModel ( 'receipt' );
  1901. $receipt = new receipt ();
  1902. Doo::loadModel ( 'L_category' );
  1903. $Lcategory = new L_category ();
  1904. Doo::loadModel ( 'verify' );
  1905. Doo::loadModel ( 'statistics' );
  1906. $statistics = new statistics ();
  1907. $verify = new verify ();
  1908. Doo::loadModel ( 'staff' );
  1909. $staff = new staff ();
  1910. $condition = "";
  1911. if ($item == "expenses")
  1912. $condition = " and Rtype=1 ";
  1913. elseif ($item == "receipts")
  1914. $condition = " and Rtype=0 ";
  1915. elseif ($item == "remits")
  1916. $condition = " and Rtype=2 ";
  1917. $dateCondition = " and Year(date) =" . $year;
  1918. if (! empty ( $moth )) {
  1919. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  1920. $stList = $statistics->getOne ( array (
  1921. 'select' => 'rePrice ,agPrice',
  1922. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  1923. 'asArray' => true
  1924. ) );
  1925. } else
  1926. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  1927. if (empty ( $stList ))
  1928. $stList = array (
  1929. 'rePrice' => 0,
  1930. 'agPrice' => 0
  1931. );
  1932. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  1933. if (! isset ( $noPassSum ['sum'] ))
  1934. $noPassSum ['sum'] = 0;
  1935. $data ['stList'] = array (
  1936. 'rePrice' => $stList ['rePrice'],
  1937. 'agPrice' => $stList ['agPrice'],
  1938. 'skPrice' => ($noPassSum ['sum'])
  1939. );
  1940. $receiptList = $receipt->find ( array (
  1941. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  1942. 'desc' => 'rid',
  1943. 'asArray' => true
  1944. ) );
  1945. $Locate = 0;
  1946. $roleId = 0;
  1947. $button = 0;
  1948. foreach ( $receiptList as $key => $value ) {
  1949. $receiptList [$key] ['Locate'] = $Locate;
  1950. $Locate ++;
  1951. $receiptList [$key] ['reviseDetail'] = array ();
  1952. if (! empty ( $value ['reviseDetail'] ))
  1953. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1954. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1955. $categoryDetil = $Lcategory->getOne ( array (
  1956. 'where' => 'cid=' . $value ['cid'],
  1957. 'asArray' => true
  1958. ) );
  1959. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1960. // 检测编辑状态
  1961. $verifyList = $verify->getOne ( array (
  1962. 'where' => 'vid=' . $value ['verify'],
  1963. 'asArray' => true
  1964. ) );
  1965. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1966. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1967. Doo::loadModel ( 'role' );
  1968. $role = new role ();
  1969. $flag = true;
  1970. $roleKey = 0;
  1971. $endStaffArray = array ();
  1972. $roleArrayCopy = array ();
  1973. foreach ( $verifyList as $k => $v ) {
  1974. // init verifyStaff
  1975. if ($v [1] == 'ROLE') {
  1976. if (! empty ( $verifyStaff )) {
  1977. $endStaffArray = end ( $verifyStaff );
  1978. // if ($v[0]==$endStaffArray['nextStaff']){
  1979. // $roleId=$v[0];
  1980. // }
  1981. }
  1982. $roleVerify = json_decode ( $v [3], true );
  1983. $roleKey = $k;
  1984. $roleArray = array ();
  1985. $rolename = $role->getOne ( array (
  1986. 'where' => 'rid=' . $v [0],
  1987. 'asArray' => true
  1988. ) );
  1989. foreach ( $roleVerify as $o => $p ) {
  1990. $staffID = explode ( '_', $p );
  1991. $staffInfo = $staff->getOne ( array (
  1992. 'where' => 'sid=' . $staffID [0],
  1993. 'asArray' => true
  1994. ) );
  1995. // print_r($staffID);
  1996. $exp = array (
  1997. 0 => $staffInfo ['sid'],
  1998. 1 => $staffID [1],
  1999. 2 => $staffInfo ['avatar'],
  2000. 'date' => '',
  2001. 'date' => '',
  2002. 'opinion' => '',
  2003. 'status' => '',
  2004. 'rolename' => $rolename ['name']
  2005. );
  2006. array_push ( $roleArray, $exp );
  2007. }
  2008. $roleArrayCopy [$v [0]] = $roleArray;
  2009. // $verifyList[$k]['roleArray']=$roleArray;
  2010. }
  2011. $verifyList [$k] ['date'] = "";
  2012. $verifyList [$k] ['opinion'] = "";
  2013. $verifyList [$k] ['status'] = "";
  2014. if (empty ( $verifyStaff )) {
  2015. $verifyList [$k] ['date'] = "";
  2016. $verifyList [$k] ['opinion'] = "";
  2017. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2018. $verifyList [$k] ['status'] = 4;
  2019. $flag = false;
  2020. }
  2021. } else {
  2022. foreach ( $verifyStaff as $m => $u ) {
  2023. if ($v [0] == $m) {
  2024. $verifyList [$k] ['date'] = $u ['date'];
  2025. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2026. $verifyList [$k] ['status'] = $u ['status'];
  2027. $flag = false;
  2028. break;
  2029. }
  2030. }
  2031. $endStaffArray = end ( $verifyStaff );
  2032. if (isset ( $endStaffArray ['ROLE'] )) {
  2033. } else {
  2034. // $endKey=key($verifyStaff);
  2035. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2036. // $button=4;
  2037. // $verifyList[$k]['status']=4;
  2038. // }
  2039. }
  2040. }
  2041. }
  2042. $rolename ['name'] = '';
  2043. if (! empty ( $roleId )) {
  2044. Doo::loadModel ( 'role' );
  2045. $role = new role ();
  2046. $rolename = $role->getOne ( array (
  2047. 'where' => 'rid=' . $roleId,
  2048. 'asArray' => true
  2049. ) );
  2050. }
  2051. if (! empty ( $verifyStaff ))
  2052. $endStaffArray = end ( $verifyStaff );
  2053. $KOP = false;
  2054. foreach ( $roleArrayCopy as $P => $A ) {
  2055. foreach ( $A as $MKI => $AVL ) {
  2056. if (! empty ( $verifyStaff )) {
  2057. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2058. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2059. $button = 4;
  2060. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2061. }
  2062. foreach ( $verifyStaff as $m => $u ) {
  2063. $AVLFK = $AVL [0] . '_R';
  2064. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2065. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2066. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2067. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2068. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2069. break;
  2070. }
  2071. }
  2072. } else {
  2073. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2074. $button = 4;
  2075. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2076. }
  2077. }
  2078. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2079. $KOP = true;
  2080. }
  2081. }
  2082. foreach ( $roleArrayCopy as $k => $v ) {
  2083. foreach ( $verifyList as $m => $n ) {
  2084. if ($n [0] == $k) {
  2085. array_splice ( $verifyList, $m, 1, $v );
  2086. }
  2087. }
  2088. }
  2089. $receiptList [$key] ['verifyList'] = $verifyList;
  2090. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2091. 'where' => 'sid=' . $value ['staff'],
  2092. 'asArray' => true
  2093. ) );
  2094. $receiptList [$key] ['button'] = $button;
  2095. }
  2096. // print_r($receiptList);die;
  2097. $mothHtml = "";
  2098. for($i = 1; $i <= 12; $i ++) {
  2099. if ($moth == $i)
  2100. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2101. else
  2102. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2103. }
  2104. $dateHtml = "";
  2105. $now = date ( "Y" );
  2106. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  2107. if ($YEARD <= $now) {
  2108. $dateHtml .= '<option ';
  2109. if ($year == $YEARD) {
  2110. $dateHtml .= 'selected ';
  2111. }
  2112. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  2113. }
  2114. }
  2115. $data ['dateHtml'] = $dateHtml;
  2116. $data ['mothHtml'] = $mothHtml;
  2117. $data ['receiptList'] = $receiptList;
  2118. $data ['memu'] = "receipt";
  2119. $data ['staff'] = $this->staff;
  2120. $data ['receiptMemu'] = 'expenses';
  2121. $data ['verifyId'] = $this->verifyId;
  2122. $data ['executeId'] = $this->executeId;
  2123. $data ['item'] = $item;
  2124. $data ['year'] = $year;
  2125. $this->render ( "/admin/expenses", $data );
  2126. }
  2127. function expensesCollect() {
  2128. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2129. Doo::loadModel ( 'receipt' );
  2130. $receipt = new receipt ();
  2131. Doo::loadModel ( 'L_category' );
  2132. $Lcategory = new L_category ();
  2133. Doo::loadModel ( 'verify' );
  2134. Doo::loadModel ( 'statistics' );
  2135. $statistics = new statistics ();
  2136. $verify = new verify ();
  2137. Doo::loadModel ( 'staff' );
  2138. $staff = new staff ();
  2139. Doo::loadModel ( 'loanReceipt' );
  2140. $loanReceipt = new loanReceipt ();
  2141. $receiptList = $receipt->find ( array (
  2142. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  2143. 'desc' => 'rid',
  2144. 'asArray' => true
  2145. ) );
  2146. $loanList = $loanReceipt->find ( array (
  2147. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2148. 'desc' => 'rid',
  2149. 'asArray' => true
  2150. ) );
  2151. /*
  2152. * $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;
  2153. */
  2154. $data ['explanation'] = '';
  2155. if (! empty ( $loanList ))
  2156. $data ['explanation'] = $loanList [0] ['explanation'];
  2157. $Locate = 0;
  2158. $roleId = 0;
  2159. $button = 0;
  2160. foreach ( $receiptList as $key => $value ) {
  2161. $receiptList [$key] ['Locate'] = $Locate;
  2162. $Locate ++;
  2163. $receiptList [$key] ['reviseDetail'] = array ();
  2164. if (! empty ( $value ['reviseDetail'] ))
  2165. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2166. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2167. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2168. $categoryDetil = $Lcategory->getOne ( array (
  2169. 'where' => 'cid=' . $value ['cid'],
  2170. 'asArray' => true
  2171. ) );
  2172. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2173. // 检测编辑状态
  2174. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  2175. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  2176. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  2177. else
  2178. $verifyList ['staff'] = $value ['verifyBreakup'];
  2179. } else
  2180. $verifyList = $verify->getOne ( array (
  2181. 'where' => 'vid=' . $value ['verify'],
  2182. 'asArray' => true
  2183. ) );
  2184. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2185. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2186. Doo::loadModel ( 'role' );
  2187. $role = new role ();
  2188. $flag = true;
  2189. $roleKey = 0;
  2190. $endStaffArray = array ();
  2191. $roleArrayCopy = array ();
  2192. foreach ( $verifyList as $k => $v ) {
  2193. // init verifyStaff
  2194. if ($v [1] == 'ROLE') {
  2195. if (! empty ( $verifyStaff )) {
  2196. $endStaffArray = end ( $verifyStaff );
  2197. // if ($v[0]==$endStaffArray['nextStaff']){
  2198. // $roleId=$v[0];
  2199. // }
  2200. }
  2201. $roleVerify = json_decode ( $v [3], true );
  2202. $roleKey = $k;
  2203. $roleArray = array ();
  2204. $rolename = $role->getOne ( array (
  2205. 'where' => 'rid=' . $v [0],
  2206. 'asArray' => true
  2207. ) );
  2208. foreach ( $roleVerify as $o => $p ) {
  2209. $staffID = explode ( '_', $p );
  2210. $staffInfo = $staff->getOne ( array (
  2211. 'where' => 'sid=' . $staffID [0],
  2212. 'asArray' => true
  2213. ) );
  2214. // print_r($staffID);
  2215. $exp = array (
  2216. 0 => $staffInfo ['sid'],
  2217. 1 => $staffID [1],
  2218. 2 => $staffInfo ['avatar'],
  2219. 'date' => '',
  2220. 'date' => '',
  2221. 'opinion' => '',
  2222. 'status' => '',
  2223. 'rolename' => $rolename ['name']
  2224. );
  2225. array_push ( $roleArray, $exp );
  2226. }
  2227. $roleArrayCopy [$v [0]] = $roleArray;
  2228. // $verifyList[$k]['roleArray']=$roleArray;
  2229. }
  2230. $verifyList [$k] ['date'] = "";
  2231. $verifyList [$k] ['opinion'] = "";
  2232. $verifyList [$k] ['status'] = "";
  2233. if (empty ( $verifyStaff )) {
  2234. $verifyList [$k] ['date'] = "";
  2235. $verifyList [$k] ['opinion'] = "";
  2236. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2237. $verifyList [$k] ['status'] = 4;
  2238. $flag = false;
  2239. }
  2240. } else {
  2241. foreach ( $verifyStaff as $m => $u ) {
  2242. if ($v [0] == $m) {
  2243. $verifyList [$k] ['date'] = $u ['date'];
  2244. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2245. $verifyList [$k] ['status'] = $u ['status'];
  2246. $flag = false;
  2247. break;
  2248. }
  2249. }
  2250. $endStaffArray = end ( $verifyStaff );
  2251. if (isset ( $endStaffArray ['ROLE'] )) {
  2252. } else {
  2253. // $endKey=key($verifyStaff);
  2254. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2255. // $button=4;
  2256. // $verifyList[$k]['status']=4;
  2257. // }
  2258. }
  2259. }
  2260. }
  2261. $rolename ['name'] = '';
  2262. if (! empty ( $roleId )) {
  2263. Doo::loadModel ( 'role' );
  2264. $role = new role ();
  2265. $rolename = $role->getOne ( array (
  2266. 'where' => 'rid=' . $roleId,
  2267. 'asArray' => true
  2268. ) );
  2269. }
  2270. if (! empty ( $verifyStaff ))
  2271. $endStaffArray = end ( $verifyStaff );
  2272. $KOP = false;
  2273. foreach ( $roleArrayCopy as $P => $A ) {
  2274. foreach ( $A as $MKI => $AVL ) {
  2275. if (! empty ( $verifyStaff )) {
  2276. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2277. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2278. $button = 4;
  2279. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2280. }
  2281. foreach ( $verifyStaff as $m => $u ) {
  2282. $AVLFK = $AVL [0] . '_R';
  2283. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2284. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2285. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2286. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2287. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2288. break;
  2289. }
  2290. }
  2291. } else {
  2292. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2293. $button = 4;
  2294. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2295. }
  2296. }
  2297. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2298. $KOP = true;
  2299. }
  2300. }
  2301. foreach ( $roleArrayCopy as $k => $v ) {
  2302. foreach ( $verifyList as $m => $n ) {
  2303. if ($n [0] == $k) {
  2304. array_splice ( $verifyList, $m, 1, $v );
  2305. }
  2306. }
  2307. }
  2308. // 费用执行人相关数据
  2309. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2310. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2311. foreach ( $executeCopy as $k => $v ) {
  2312. $executeCopy [$k] ['date'] = '';
  2313. $executeCopy [$k] ['opinion'] = '';
  2314. $executeCopy [$k] ['status'] = '';
  2315. if (! empty ( $executeStaff ))
  2316. foreach ( $executeStaff as $m => $u ) {
  2317. if ($v [0] == $m) {
  2318. $executeCopy [$k] ['date'] = $u ['date'];
  2319. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2320. $executeCopy [$k] ['status'] = $u ['status'];
  2321. break;
  2322. }
  2323. }
  2324. }
  2325. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2326. $receiptList [$key] ['verifyList'] = $verifyList;
  2327. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2328. 'where' => 'sid=' . $value ['staff'],
  2329. 'asArray' => true
  2330. ) );
  2331. $receiptList [$key] ['button'] = $button;
  2332. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2333. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2334. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  2335. $receiptList [$key] ['relust'] = $relust;
  2336. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2337. }
  2338. Doo::loadModel ( 'enclosur' );
  2339. $enclosur = new enclosur ();
  2340. $enclosurList = $enclosur->find ( array (
  2341. 'where' => 'rid=' . $rid,
  2342. 'asArray' => true
  2343. ) );
  2344. $enclosurHtml = '';
  2345. foreach ( $enclosurList as $value ) {
  2346. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2347. }
  2348. $data ['enclosurHtml'] = $enclosurHtml;
  2349. // print_r($receiptList);
  2350. $data ['receiptList'] = $receiptList;
  2351. $data ['memu'] = "receipt";
  2352. $data ['staff'] = $this->staff;
  2353. $data ['receiptMemu'] = 'expenses';
  2354. $data ['verifyId'] = $this->verifyId;
  2355. $data ['executeId'] = $this->executeId;
  2356. $this->render ( "/admin/expensesCollect", $data );
  2357. }
  2358. function approvalExpenses() {
  2359. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  2360. $year = $rdate = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2361. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2362. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2363. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2364. // $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) :"";
  2365. // echo $rdate;
  2366. if (empty ( $status ))
  2367. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  2368. $page_size = 12;
  2369. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2370. $vidList = array ();
  2371. $button = 0;
  2372. Doo::loadModel ( 'verify' );
  2373. $verify = new verify ();
  2374. Doo::loadModel ( 'receipt' );
  2375. $receipt = new receipt ();
  2376. Doo::loadModel ( 'staff' );
  2377. $staff = new staff ();
  2378. Doo::loadModel ( 'L_category' );
  2379. $Lcategory = new L_category ();
  2380. // user verify ID
  2381. $verifyDetail = $verify->find ( array (
  2382. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  2383. 'asArray' => true
  2384. ) );
  2385. foreach ( $verifyDetail as $key => $value ) {
  2386. array_push ( $vidList, $value ['vid'] );
  2387. }
  2388. $vid = implode ( ",", $vidList );
  2389. if (empty ( $verifyDetail ))
  2390. $vid = 0;
  2391. // if ($status==0)
  2392. // $dateCondition="";
  2393. // else
  2394. $dateCondition = " ";
  2395. // if (! empty ( $month ))
  2396. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  2397. if ($status == 'done' || $status == 'termination') {
  2398. if (! empty ( $year )) {
  2399. $dateCondition = " and Year(pastDate) =" . $year;
  2400. if (! empty ( $month ))
  2401. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  2402. }
  2403. } elseif ($status == 'finish') {
  2404. if (! empty ( $year )) {
  2405. $dateCondition = " and Year(pastDate) =" . $year;
  2406. if (! empty ( $month ))
  2407. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  2408. }
  2409. }
  2410. // date ( 'Y-m' )
  2411. // if (! empty ( $rdate ) && $status == 'done')
  2412. // $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  2413. // elseif (! empty ( $rdate ))
  2414. // $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  2415. $categoryList = $Lcategory->find ( array (
  2416. 'asArray' => true
  2417. ) );
  2418. $staffList = $staff->find ( array (
  2419. 'where' => 'cid=' . $cid,
  2420. 'asArray' => true
  2421. ) );
  2422. $cateCondition = "";
  2423. $staffCondition = "";
  2424. $approvalCondition = "";
  2425. if (! empty ( $cid )) {
  2426. $cateCondition = ' and cid=' . $cid;
  2427. }
  2428. if (! empty ( $sid )) {
  2429. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  2430. $cateCondition = "";
  2431. }
  2432. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  2433. if ($status == 'pendApproval') {
  2434. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  2435. }
  2436. if ($status == 'ongoing') {
  2437. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  2438. }
  2439. if ($status == 'done') {
  2440. $approvalCondition = ' and (status=8 or status=9 ) ';
  2441. }
  2442. if ($status == 'termination') {
  2443. $approvalCondition = " and status=3";
  2444. }
  2445. if ($status == 'finish') {
  2446. $approvalCondition = " and (status=1 or status=8 or status=9)";
  2447. }
  2448. $pageinfo ['page'] = array (
  2449. 'previous' => ''
  2450. );
  2451. if ($status == 'done' || $status == 'termination' || $status == 'finish') { // $dateCondition .
  2452. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  2453. $receiptList = $receipt->find ( array ( // $dateCondition.
  2454. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  2455. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2456. 'desc' => 'rid',
  2457. 'asArray' => true
  2458. ) );
  2459. } else {
  2460. $receiptList = $receipt->find ( array ( // $dateCondition
  2461. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  2462. 'desc' => 'rid',
  2463. 'asArray' => true
  2464. ) );
  2465. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  2466. }
  2467. $rLRes = $receipt->find ( array (
  2468. '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 . ')',
  2469. 'desc' => 'rid',
  2470. 'asArray' => true
  2471. ) );
  2472. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  2473. // print_r($receiptList);
  2474. $Locate = 0;
  2475. $reportList = $reportCateList = array ();
  2476. foreach ( $receiptList as $key => $value ) {
  2477. $receiptList [$key] ['Locate'] = $Locate;
  2478. $Locate ++;
  2479. $receiptList [$key] ['reviseDetail'] = array ();
  2480. if (! empty ( $value ['reviseDetail'] ))
  2481. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2482. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2483. $categoryDetil = $Lcategory->getOne ( array (
  2484. 'where' => 'cid=' . $value ['cid'],
  2485. 'asArray' => true
  2486. ) );
  2487. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2488. $verifyList = $verify->getOne ( array (
  2489. 'where' => 'vid=' . $value ['verify'],
  2490. 'asArray' => true
  2491. ) );
  2492. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2493. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2494. foreach ( $verifyList as $k => $v ) {
  2495. // init verifyStaff
  2496. $verifyList [$k] ['date'] = "";
  2497. $verifyList [$k] ['opinion'] = "";
  2498. $verifyList [$k] ['status'] = "";
  2499. if (empty ( $verifyStaff )) {
  2500. $verifyList [$k] ['date'] = "";
  2501. $verifyList [$k] ['opinion'] = "";
  2502. if ($v [0] == $this->staff [0] ['sid']) {
  2503. $verifyList [$k] ['status'] = 4;
  2504. $button = 4;
  2505. }
  2506. } else {
  2507. $flag = true;
  2508. foreach ( $verifyStaff as $m => $u ) {
  2509. if ($v [0] == $m) {
  2510. $verifyList [$k] ['date'] = $u ['date'];
  2511. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2512. $verifyList [$k] ['status'] = $u ['status'];
  2513. $flag = false;
  2514. break;
  2515. }
  2516. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  2517. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  2518. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  2519. }
  2520. if ($flag) { // 检测可编辑
  2521. if ($v [0] == $this->staff [0] ['sid']) {
  2522. $verifyList [$k] ['status'] = 4;
  2523. $button = 4;
  2524. }
  2525. }
  2526. }
  2527. }
  2528. $receiptList [$key] ['verifyList'] = $verifyList;
  2529. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2530. 'where' => 'sid=' . $value ['staff'],
  2531. 'asArray' => true
  2532. ) );
  2533. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  2534. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  2535. $receiptList [$key] ['button'] = $button;
  2536. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  2537. }
  2538. $reportList = array_unique ( $reportList );
  2539. $reportHtml = '';
  2540. foreach ( $reportList as $key => $value ) {
  2541. $v = explode ( "-", $value );
  2542. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  2543. }
  2544. // print_r($reportList)
  2545. $data ['reportHtml'] = $reportHtml;
  2546. $reportCateList = array_unique ( $reportCateList );
  2547. $reportCateHtml = '';
  2548. foreach ( $reportCateList as $key => $value ) {
  2549. $v = explode ( "-", $value );
  2550. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  2551. }
  2552. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  2553. $data ['reportCateHtml'] = $reportCateHtml;
  2554. // print_r($receiptList);die;
  2555. // $data['verifyDetail']=$verifyDetail;
  2556. $mothHtml = "";
  2557. for($i = 1; $i <= 12; $i ++) {
  2558. if ($month == $i)
  2559. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2560. else
  2561. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2562. }
  2563. $data ['mothHtml'] = $mothHtml;
  2564. $dateHtml = "";
  2565. $now = date ( "Y" );
  2566. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  2567. if ($YEARD <= $now) {
  2568. $dateHtml .= '<option ';
  2569. if ($year == $YEARD) {
  2570. $dateHtml .= 'selected ';
  2571. }
  2572. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  2573. }
  2574. }
  2575. $data ['dateHtml'] = $dateHtml;
  2576. $data ['page'] = $pageinfo;
  2577. $data ['receiptList'] = $receiptList;
  2578. $data ['receiptApprovalCount'] = count ( $rLRes );
  2579. $data ['status'] = $status;
  2580. $data ['year'] = $year;
  2581. $data ['categoryList'] = $categoryList;
  2582. $data ['staffList'] = $staffList;
  2583. $data ['cid'] = $cid;
  2584. $data ['sid'] = $sid;
  2585. // print_r($receiptList);
  2586. $data ['memu'] = "receipt";
  2587. $data ['staff'] = $this->staff;
  2588. $data ['receiptMemu'] = 'approvalExpenses';
  2589. $data ['verifyId'] = $this->verifyId;
  2590. $data ['executeId'] = $this->executeId;
  2591. $this->render ( "/admin/approvalExpenses", $data );
  2592. }
  2593. function expensesDoc() {
  2594. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2595. Doo::loadClass ( 'XDeode' );
  2596. $XDeode = new XDeode ( 5 );
  2597. if (! empty ( $rid ) && ! is_numeric ( $rid ))
  2598. $rid = $XDeode->decode ( $rid );
  2599. if (! is_numeric ( $rid ))
  2600. die ( 'illegal request' );
  2601. Doo::loadModel ( 'receipt' );
  2602. $receipt = new receipt ();
  2603. Doo::loadModel ( 'L_category' );
  2604. $Lcategory = new L_category ();
  2605. Doo::loadModel ( 'verify' );
  2606. Doo::loadModel ( 'statistics' );
  2607. $statistics = new statistics ();
  2608. $verify = new verify ();
  2609. Doo::loadModel ( 'staff' );
  2610. $staff = new staff ();
  2611. Doo::loadModel ( 'loanReceipt' );
  2612. $loanReceipt = new loanReceipt ();
  2613. $receiptList = $receipt->find ( array (
  2614. 'where' => ' rid=' . $rid,
  2615. 'desc' => 'rid',
  2616. 'asArray' => true
  2617. ) );
  2618. $loanList = array ();
  2619. if (! empty ( $receiptList ))
  2620. $loanList = $loanReceipt->find ( array (
  2621. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2622. 'desc' => 'rid',
  2623. 'asArray' => true
  2624. ) );
  2625. $Locate = 0;
  2626. $roleId = 0;
  2627. $button = 0;
  2628. foreach ( $loanList as $key => $value ) {
  2629. $loanList [$key] ['Locate'] = $Locate;
  2630. $Locate ++;
  2631. $loanList [$key] ['reviseDetail'] = array ();
  2632. if (! empty ( $value ['reviseDetail'] ))
  2633. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2634. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2635. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2636. $categoryDetil = $Lcategory->getOne ( array (
  2637. 'where' => 'cid=' . $value ['cid'],
  2638. 'asArray' => true
  2639. ) );
  2640. $loanList [$key] ['category'] = $categoryDetil ['title'];
  2641. // 检测编辑状态
  2642. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  2643. $verifyList ['staff'] = $value ['verifyBreakup'];
  2644. else
  2645. $verifyList = $verify->getOne ( array (
  2646. 'where' => 'vid=' . $value ['verify'],
  2647. 'asArray' => true
  2648. ) );
  2649. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2650. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2651. Doo::loadModel ( 'role' );
  2652. $role = new role ();
  2653. $flag = true;
  2654. $roleKey = 0;
  2655. $endStaffArray = array ();
  2656. $roleArrayCopy = array ();
  2657. foreach ( $verifyList as $k => $v ) {
  2658. // init verifyStaff
  2659. if ($v [1] == 'ROLE') {
  2660. if (! empty ( $verifyStaff )) {
  2661. $endStaffArray = end ( $verifyStaff );
  2662. // if ($v[0]==$endStaffArray['nextStaff']){
  2663. // $roleId=$v[0];
  2664. // }
  2665. }
  2666. $roleVerify = json_decode ( $v [3], true );
  2667. $roleKey = $k;
  2668. $roleArray = array ();
  2669. $rolename = $role->getOne ( array (
  2670. 'where' => 'rid=' . $v [0],
  2671. 'asArray' => true
  2672. ) );
  2673. foreach ( $roleVerify as $o => $p ) {
  2674. $staffID = explode ( '_', $p );
  2675. $staffInfo = $staff->getOne ( array (
  2676. 'where' => 'sid=' . $staffID [0],
  2677. 'asArray' => true
  2678. ) );
  2679. // print_r($staffID);
  2680. $exp = array (
  2681. 0 => $staffInfo ['sid'],
  2682. 1 => $staffID [1],
  2683. 2 => $staffInfo ['avatar'],
  2684. 'date' => '',
  2685. 'date' => '',
  2686. 'opinion' => '',
  2687. 'status' => '',
  2688. 'rolename' => $rolename ['name']
  2689. );
  2690. array_push ( $roleArray, $exp );
  2691. }
  2692. $roleArrayCopy [$v [0]] = $roleArray;
  2693. // $verifyList[$k]['roleArray']=$roleArray;
  2694. }
  2695. $verifyList [$k] ['date'] = "";
  2696. $verifyList [$k] ['opinion'] = "";
  2697. $verifyList [$k] ['status'] = "";
  2698. if (empty ( $verifyStaff )) {
  2699. $verifyList [$k] ['date'] = "";
  2700. $verifyList [$k] ['opinion'] = "";
  2701. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2702. $verifyList [$k] ['status'] = 4;
  2703. $flag = false;
  2704. }
  2705. } else {
  2706. foreach ( $verifyStaff as $m => $u ) {
  2707. if ($v [0] == $m) {
  2708. $verifyList [$k] ['date'] = $u ['date'];
  2709. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2710. $verifyList [$k] ['status'] = $u ['status'];
  2711. $flag = false;
  2712. break;
  2713. }
  2714. }
  2715. $endStaffArray = end ( $verifyStaff );
  2716. if (isset ( $endStaffArray ['ROLE'] )) {
  2717. } else {
  2718. // $endKey=key($verifyStaff);
  2719. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2720. // $button=4;
  2721. // $verifyList[$k]['status']=4;
  2722. // }
  2723. }
  2724. }
  2725. }
  2726. $rolename ['name'] = '';
  2727. if (! empty ( $roleId )) {
  2728. Doo::loadModel ( 'role' );
  2729. $role = new role ();
  2730. $rolename = $role->getOne ( array (
  2731. 'where' => 'rid=' . $roleId,
  2732. 'asArray' => true
  2733. ) );
  2734. }
  2735. if (! empty ( $verifyStaff ))
  2736. $endStaffArray = end ( $verifyStaff );
  2737. $KOP = false;
  2738. foreach ( $roleArrayCopy as $P => $A ) {
  2739. foreach ( $A as $MKI => $AVL ) {
  2740. if (! empty ( $verifyStaff )) {
  2741. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2742. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2743. $button = 4;
  2744. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2745. }
  2746. foreach ( $verifyStaff as $m => $u ) {
  2747. $AVLFK = $AVL [0] . '_R';
  2748. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2749. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2750. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2751. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2752. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2753. break;
  2754. }
  2755. }
  2756. } else {
  2757. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2758. $button = 4;
  2759. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2760. }
  2761. }
  2762. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2763. $KOP = true;
  2764. }
  2765. }
  2766. foreach ( $roleArrayCopy as $k => $v ) {
  2767. foreach ( $verifyList as $m => $n ) {
  2768. if ($n [0] == $k) {
  2769. array_splice ( $verifyList, $m, 1, $v );
  2770. }
  2771. }
  2772. }
  2773. $loanList [$key] ['verifyList'] = $verifyList;
  2774. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  2775. 'where' => 'sid=' . $value ['staff'],
  2776. 'asArray' => true
  2777. ) );
  2778. $loanList [$key] ['button'] = $button;
  2779. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  2780. }
  2781. $data ['loanList'] = $loanList;
  2782. // print_r($loanList);
  2783. $Locate = 0;
  2784. $roleId = 0;
  2785. $button = 0;
  2786. foreach ( $receiptList as $key => $value ) {
  2787. $receiptList [$key] ['Locate'] = $Locate;
  2788. $Locate ++;
  2789. $receiptList [$key] ['reviseDetail'] = array ();
  2790. if (! empty ( $value ['reviseDetail'] ))
  2791. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2792. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2793. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2794. $categoryDetil = $Lcategory->getOne ( array (
  2795. 'where' => 'cid=' . $value ['cid'],
  2796. 'asArray' => true
  2797. ) );
  2798. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2799. // 检测编辑状态
  2800. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  2801. $verifyList ['staff'] = $value ['verifyBreakup'];
  2802. } else
  2803. $verifyList = $verify->getOne ( array (
  2804. 'where' => 'vid=' . $value ['verify'],
  2805. 'asArray' => true
  2806. ) );
  2807. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2808. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2809. Doo::loadModel ( 'role' );
  2810. $role = new role ();
  2811. if ($verifyList == NULL)
  2812. $verifyList = array ();
  2813. $flag = true;
  2814. $roleKey = 0;
  2815. $endStaffArray = array ();
  2816. $roleArrayCopy = array ();
  2817. foreach ( $verifyList as $k => $v ) {
  2818. // init verifyStaff
  2819. if ($v [1] == 'ROLE') {
  2820. if (! empty ( $verifyStaff )) {
  2821. $endStaffArray = end ( $verifyStaff );
  2822. // if ($v[0]==$endStaffArray['nextStaff']){
  2823. // $roleId=$v[0];
  2824. // }
  2825. }
  2826. $roleVerify = json_decode ( $v [3], true );
  2827. $roleKey = $k;
  2828. $roleArray = array ();
  2829. $rolename = $role->getOne ( array (
  2830. 'where' => 'rid=' . $v [0],
  2831. 'asArray' => true
  2832. ) );
  2833. foreach ( $roleVerify as $o => $p ) {
  2834. $staffID = explode ( '_', $p );
  2835. $staffInfo = $staff->getOne ( array (
  2836. 'where' => 'sid=' . $staffID [0],
  2837. 'asArray' => true
  2838. ) );
  2839. // print_r($staffID);
  2840. $exp = array (
  2841. 0 => $staffInfo ['sid'],
  2842. 1 => $staffID [1],
  2843. 2 => $staffInfo ['avatar'],
  2844. 'date' => '',
  2845. 'date' => '',
  2846. 'opinion' => '',
  2847. 'status' => '',
  2848. 'rolename' => $rolename ['name']
  2849. );
  2850. array_push ( $roleArray, $exp );
  2851. }
  2852. $roleArrayCopy [$v [0]] = $roleArray;
  2853. // $verifyList[$k]['roleArray']=$roleArray;
  2854. }
  2855. $verifyList [$k] ['date'] = "";
  2856. $verifyList [$k] ['opinion'] = "";
  2857. $verifyList [$k] ['status'] = "";
  2858. if (empty ( $verifyStaff )) {
  2859. $verifyList [$k] ['date'] = "";
  2860. $verifyList [$k] ['opinion'] = "";
  2861. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2862. $verifyList [$k] ['status'] = 4;
  2863. $flag = false;
  2864. }
  2865. } else {
  2866. foreach ( $verifyStaff as $m => $u ) {
  2867. if ($v [0] == $m) {
  2868. $verifyList [$k] ['date'] = $u ['date'];
  2869. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2870. $verifyList [$k] ['status'] = $u ['status'];
  2871. $flag = false;
  2872. break;
  2873. }
  2874. }
  2875. $endStaffArray = end ( $verifyStaff );
  2876. if (isset ( $endStaffArray ['ROLE'] )) {
  2877. } else {
  2878. // $endKey=key($verifyStaff);
  2879. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2880. // $button=4;
  2881. // $verifyList[$k]['status']=4;
  2882. // }
  2883. }
  2884. }
  2885. }
  2886. $FC = @$rolename ['name'];
  2887. $rolename ['name'] = '';
  2888. if (! empty ( $roleId )) {
  2889. Doo::loadModel ( 'role' );
  2890. $role = new role ();
  2891. $rolename = $role->getOne ( array (
  2892. 'where' => 'rid=' . $roleId,
  2893. 'asArray' => true
  2894. ) );
  2895. }
  2896. if (! empty ( $verifyStaff ))
  2897. $endStaffArray = end ( $verifyStaff );
  2898. $KOP = false;
  2899. foreach ( $roleArrayCopy as $P => $A ) {
  2900. foreach ( $A as $MKI => $AVL ) {
  2901. if (! empty ( $verifyStaff )) {
  2902. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2903. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2904. $button = 4;
  2905. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2906. }
  2907. foreach ( $verifyStaff as $m => $u ) {
  2908. $AVLFK = $AVL [0] . '_R';
  2909. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2910. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2911. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2912. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2913. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2914. break;
  2915. }
  2916. }
  2917. } else {
  2918. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2919. $button = 4;
  2920. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2921. }
  2922. }
  2923. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2924. $KOP = true;
  2925. }
  2926. }
  2927. foreach ( $roleArrayCopy as $k => $v ) {
  2928. foreach ( $verifyList as $m => $n ) {
  2929. if ($n [0] == $k) {
  2930. array_splice ( $verifyList, $m, 1, $v );
  2931. }
  2932. }
  2933. }
  2934. // 费用执行人相关数据
  2935. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2936. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2937. foreach ( $executeCopy as $k => $v ) {
  2938. $executeCopy [$k] ['date'] = '';
  2939. $executeCopy [$k] ['opinion'] = '';
  2940. $executeCopy [$k] ['status'] = '';
  2941. if (! empty ( $executeStaff ))
  2942. foreach ( $executeStaff as $m => $u ) {
  2943. if ($v [0] == $m) {
  2944. $executeCopy [$k] ['date'] = $u ['date'];
  2945. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2946. $executeCopy [$k] ['status'] = $u ['status'];
  2947. break;
  2948. }
  2949. }
  2950. }
  2951. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2952. // print_r($verifyList);
  2953. $receiptList [$key] ['verifyList'] = $verifyList;
  2954. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2955. 'where' => 'sid=' . $value ['staff'],
  2956. 'asArray' => true
  2957. ) );
  2958. $receiptList [$key] ['button'] = $button;
  2959. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2960. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2961. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  2962. $receiptList [$key] ['relust'] = $relust;
  2963. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2964. }
  2965. // print_r($receiptList);
  2966. // 获取审批日志
  2967. Doo::loadModel ( 'receiptLog' );
  2968. $receiptLog = new receiptLog ();
  2969. $rlList = array ();
  2970. $rlInfo = $receiptLog->getOne ( array (
  2971. 'where' => 'rid=' . $rid . ' and status=4',
  2972. 'asArray' => true
  2973. ) );
  2974. $tijdate = $receiptLog->getOne ( array (
  2975. 'where' => 'rid=' . $rid . ' and status=2',
  2976. 'asc' => 'rlid',
  2977. 'asArray' => true
  2978. ) );
  2979. if (! empty ( $rlInfo )) {
  2980. $rlList = $receiptLog->find ( array (
  2981. 'where' => 'rid=' . $rid,
  2982. 'asc' => 'rlid',
  2983. 'asArray' => true
  2984. ) );
  2985. }
  2986. $RN = @json_decode ( $rolename ['staff'] );
  2987. //
  2988. foreach ( $rlList as $key => $value ) {
  2989. $rlList [$key] ['rolename'] = '';
  2990. foreach ( $RN as $k => $v ) {
  2991. $id = explode ( "_", $v );
  2992. if ($id [0] == $value ['uid']) {
  2993. $rlList [$key] ['rolename'] = $FC;
  2994. break;
  2995. }
  2996. }
  2997. }
  2998. Doo::loadModel ( 'enclosur' );
  2999. $enclosur = new enclosur ();
  3000. $enclosurList = $enclosur->find ( array (
  3001. 'where' => 'rid=' . $rid,
  3002. 'asArray' => true
  3003. ) );
  3004. $enclosurHtml = '';
  3005. foreach ( $enclosurList as $value ) {
  3006. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3007. }
  3008. $data ['enclosurHtml'] = $enclosurHtml;
  3009. $receiptList [0] ['rlList'] = $rlList;
  3010. $data ['receiptList'] = $receiptList;
  3011. // print_r($receiptList);
  3012. $data ['memu'] = "receipt";
  3013. $data ['staff'] = $this->staff;
  3014. $data ['receiptMemu'] = 'approvalExpenses';
  3015. $data ['verifyId'] = $this->verifyId;
  3016. $data ['executeId'] = $this->executeId;
  3017. $this->render ( "/admin/expensesDoc", $data );
  3018. }
  3019. function expensesEdi() {
  3020. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3021. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  3022. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  3023. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  3024. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3025. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  3026. if (empty ( $status ))
  3027. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  3028. $vidList = array ();
  3029. $button = 0;
  3030. Doo::loadModel ( 'verify' );
  3031. Doo::loadModel ( 'receipt' );
  3032. Doo::loadModel ( 'staff' );
  3033. $staff = new staff ();
  3034. $receipt = new receipt ();
  3035. $verify = new verify ();
  3036. Doo::loadModel ( 'L_category' );
  3037. $Lcategory = new L_category ();
  3038. Doo::loadModel ( 'enclosur' );
  3039. $enclosur = new enclosur ();
  3040. // user verify ID
  3041. $verifyDetail = $verify->find ( array (
  3042. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  3043. 'asArray' => true
  3044. ) );
  3045. foreach ( $verifyDetail as $key => $value ) {
  3046. array_push ( $vidList, $value ['vid'] );
  3047. }
  3048. $vid = implode ( ",", $vidList );
  3049. if (empty ( $verifyDetail ))
  3050. $vid = 0;
  3051. $categoryList = $Lcategory->find ( array (
  3052. 'asArray' => true
  3053. ) );
  3054. $staffList = $staff->find ( array (
  3055. 'where' => 'cid=' . $cid,
  3056. 'asArray' => true
  3057. ) );
  3058. $ap = "";
  3059. if ($status == 4) {
  3060. $ap = 4;
  3061. $status = 2;
  3062. }
  3063. // get Receipt By verifyID status 2
  3064. $receiptList = $receipt->find ( array (
  3065. 'where' => 'rid =' . $rid . ' and status=2',
  3066. 'desc' => 'rid',
  3067. 'asArray' => true
  3068. ) );
  3069. if (empty ( $receiptList )) {
  3070. die ( 'illegal request' );
  3071. }
  3072. $Locate = 0;
  3073. $roleId = 0;
  3074. if ($ap == 4)
  3075. $status = 4;
  3076. foreach ( $receiptList as $key => $value ) {
  3077. $receiptList [$key] ['Locate'] = $Locate;
  3078. $Locate ++;
  3079. $receiptList [$key] ['reviseDetail'] = array ();
  3080. if (! empty ( $value ['reviseDetail'] ))
  3081. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3082. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3083. $categoryDetil = $Lcategory->getOne ( array (
  3084. 'where' => 'cid=' . $value ['cid'],
  3085. 'asArray' => true
  3086. ) );
  3087. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3088. // 检测编辑状态
  3089. $verifyList = $verify->getOne ( array (
  3090. 'where' => 'vid=' . $value ['verify'],
  3091. 'asArray' => true
  3092. ) );
  3093. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3094. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3095. Doo::loadModel ( 'role' );
  3096. $role = new role ();
  3097. // print_r($verifyList);
  3098. $flag = true;
  3099. $roleKey = 0;
  3100. $endStaffArray = array ();
  3101. $roleArrayCopy = array ();
  3102. foreach ( $verifyList as $k => $v ) {
  3103. // init verifyStaff
  3104. if ($v [1] == 'ROLE') {
  3105. if (! empty ( $verifyStaff )) {
  3106. $endStaffArray = end ( $verifyStaff );
  3107. if ($v [0] == $endStaffArray ['nextStaff']) {
  3108. $roleId = $v [0];
  3109. }
  3110. }
  3111. $roleVerify = json_decode ( $v [3], true );
  3112. $roleKey = $k;
  3113. $roleArray = array ();
  3114. $rolename = $role->getOne ( array (
  3115. 'where' => 'rid=' . $v [0],
  3116. 'asArray' => true
  3117. ) );
  3118. foreach ( $roleVerify as $o => $p ) {
  3119. $staffID = explode ( '_', $p );
  3120. $staffInfo = $staff->getOne ( array (
  3121. 'where' => 'sid=' . $staffID [0],
  3122. 'asArray' => true
  3123. ) );
  3124. // print_r($staffID);
  3125. $exp = array (
  3126. 0 => $staffInfo ['sid'],
  3127. 1 => $staffID [1],
  3128. 2 => $staffInfo ['avatar'],
  3129. 'date' => '',
  3130. 'date' => '',
  3131. 'opinion' => '',
  3132. 'status' => '',
  3133. 'rolename' => $rolename ['name']
  3134. );
  3135. array_push ( $roleArray, $exp );
  3136. }
  3137. $roleArrayCopy [$v [0]] = $roleArray;
  3138. // $verifyList[$k]['roleArray']=$roleArray;
  3139. }
  3140. // print_r($roleArray);
  3141. $verifyList [$k] ['date'] = "";
  3142. $verifyList [$k] ['opinion'] = "";
  3143. $verifyList [$k] ['status'] = "";
  3144. if (empty ( $verifyStaff )) {
  3145. $verifyList [$k] ['date'] = "";
  3146. $verifyList [$k] ['opinion'] = "";
  3147. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3148. $verifyList [$k] ['status'] = 4;
  3149. $button = 4;
  3150. $flag = false;
  3151. }
  3152. } else {
  3153. foreach ( $verifyStaff as $m => $u ) {
  3154. if ($v [0] == $m) {
  3155. $verifyList [$k] ['date'] = $u ['date'];
  3156. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3157. $verifyList [$k] ['status'] = $u ['status'];
  3158. $flag = false;
  3159. break;
  3160. }
  3161. }
  3162. $endStaffArray = end ( $verifyStaff );
  3163. if (isset ( $endStaffArray ['ROLE'] )) {
  3164. } else {
  3165. $endKey = key ( $verifyStaff );
  3166. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  3167. $button = 4;
  3168. $verifyList [$k] ['status'] = 4;
  3169. }
  3170. }
  3171. }
  3172. }
  3173. $rolename ['name'] = '';
  3174. if (! empty ( $roleId )) {
  3175. Doo::loadModel ( 'role' );
  3176. $role = new role ();
  3177. $rolename = $role->getOne ( array (
  3178. 'where' => 'rid=' . $roleId,
  3179. 'asArray' => true
  3180. ) );
  3181. }
  3182. if (! empty ( $verifyStaff ))
  3183. $endStaffArray = end ( $verifyStaff );
  3184. $KOP = false;
  3185. foreach ( $roleArrayCopy as $P => $A ) {
  3186. foreach ( $A as $MKI => $AVL ) {
  3187. if (! empty ( $verifyStaff )) {
  3188. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3189. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3190. $button = 4;
  3191. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3192. }
  3193. foreach ( $verifyStaff as $m => $u ) {
  3194. $AVLFK = $AVL [0] . '_R';
  3195. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3196. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3197. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3198. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3199. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3200. break;
  3201. }
  3202. }
  3203. } else {
  3204. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3205. $button = 4;
  3206. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3207. }
  3208. }
  3209. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3210. $KOP = true;
  3211. }
  3212. }
  3213. // print_r($roleArrayCopy);
  3214. // echo $roleKey;
  3215. foreach ( $roleArrayCopy as $k => $v ) {
  3216. foreach ( $verifyList as $m => $n ) {
  3217. if ($n [0] == $k) {
  3218. array_splice ( $verifyList, $m, 1, $v );
  3219. }
  3220. }
  3221. }
  3222. $receiptList [$key] ['verifyList'] = $verifyList;
  3223. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3224. 'where' => 'sid=' . $value ['staff'],
  3225. 'asArray' => true
  3226. ) );
  3227. $receiptList [$key] ['button'] = $button;
  3228. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  3229. }
  3230. // $data['verifyDetail']=$verifyDetail;
  3231. $mothHtml = "";
  3232. for($i = 1; $i <= 12; $i ++) {
  3233. if ($month == $i)
  3234. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3235. else
  3236. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3237. }
  3238. // 获取审批日志
  3239. Doo::loadModel ( 'receiptLog' );
  3240. $receiptLog = new receiptLog ();
  3241. $rlList = array ();
  3242. $rlInfo = $receiptLog->getOne ( array (
  3243. 'where' => 'rid=' . $rid . ' and status=4',
  3244. 'asArray' => true
  3245. ) );
  3246. $tijdate = $receiptLog->getOne ( array (
  3247. 'where' => 'rid=' . $rid . ' and status=2',
  3248. 'asc' => 'rlid',
  3249. 'asArray' => true
  3250. ) );
  3251. if (! empty ( $rlInfo )) {
  3252. $rlList = $receiptLog->find ( array (
  3253. 'where' => 'rid=' . $rid,
  3254. 'asc' => 'rlid',
  3255. 'asArray' => true
  3256. ) );
  3257. }
  3258. $receiptList [0] ['rlList'] = $rlList;
  3259. $enclosurList = $enclosur->find ( array (
  3260. 'where' => 'rid=' . $rid,
  3261. 'asArray' => true
  3262. ) );
  3263. $enclosurHtml = '';
  3264. foreach ( $enclosurList as $value ) {
  3265. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3266. }
  3267. // print_r($receiptList);
  3268. $data ['rid'] = $rid;
  3269. $data ['enclosurHtml'] = $enclosurHtml;
  3270. $data ['rolename'] = $rolename ['name'];
  3271. $data ['datetij'] = $tijdate ['date'];
  3272. $data ['mothHtml'] = $mothHtml;
  3273. $data ['receiptList'] = $receiptList;
  3274. $data ['receiptApprovalCount'] = count ( $receiptList );
  3275. $data ['status'] = $status;
  3276. $data ['year'] = $year;
  3277. $data ['categoryList'] = $categoryList;
  3278. $data ['staffList'] = $staffList;
  3279. $data ['cid'] = $cid;
  3280. $data ['sid'] = $sid;
  3281. $data ['ap'] = $ap;
  3282. $data ['memu'] = "receipt";
  3283. $data ['staff'] = $this->staff;
  3284. $data ['receiptMemu'] = 'approvalExpenses';
  3285. $data ['verifyId'] = $this->verifyId;
  3286. $data ['executeId'] = $this->executeId;
  3287. $this->render ( "/admin/expensesEdi", $data );
  3288. }
  3289. function expensesDefray() {
  3290. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3291. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3292. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3293. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  3294. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  3295. if (! empty ( $rid )) {
  3296. Doo::loadModel ( "verify" );
  3297. $verify = new verify ();
  3298. Doo::loadModel ( "receiptDetail" );
  3299. $receiptDetailObj = new receiptDetail ();
  3300. Doo::loadModel ( "itemStatistics" );
  3301. Doo::loadModel ( "statistics" );
  3302. $statistics = new statistics ();
  3303. $itemStatistics = new itemStatistics ();
  3304. Doo::loadModel ( "receipt" );
  3305. $receipt = new receipt ();
  3306. Doo::loadModel ( "loanReceipt" );
  3307. $loanReceipt = new loanReceipt ();
  3308. $receiptDetail = $receipt->getOne ( array (
  3309. 'where' => 'rid=' . $rid . ' and status=2 ',
  3310. 'asArray' => true
  3311. ) );
  3312. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  3313. $nsflag = true;
  3314. foreach ( $nslist as $value ) {
  3315. if ($value == $this->staff ['0'] ['sid']) {
  3316. $nsflag = false;
  3317. break;
  3318. }
  3319. }
  3320. // print_r($nslist);die;
  3321. if (empty ( $receiptDetail ) || $nsflag)
  3322. return "/approvalExpenses/pendApproval";
  3323. $verifyDetail = $verify->getOne ( array (
  3324. 'where' => ' vid =' . $receiptDetail ['verify'],
  3325. 'asArray' => true
  3326. ) );
  3327. $verifyString = $verifyDetail ['staff'];
  3328. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3329. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  3330. if (empty ( $opinion )) {
  3331. if ($status == 3)
  3332. $opinion = "终止";
  3333. else
  3334. $opinion = "同意支付";
  3335. }
  3336. $nowStaff = 0;
  3337. $nowStaffList = array ();
  3338. if (empty ( $verifyStaff )) {
  3339. // 还需加入是否已经进入角色审批
  3340. if ($verifyDetail [0] [1] == 'ROLE') {
  3341. // print_r($verifyDetail);echo "ddd";
  3342. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3343. foreach ( $vStaffString as $key => $value ) {
  3344. $staffK = explode ( "_", $value );
  3345. if ($staffK [0] != $this->staff [0] ['sid'])
  3346. array_push ( $nowStaffList, $staffK [0] );
  3347. }
  3348. // print_r($verifyDetail);
  3349. // die;
  3350. if (! empty ( $nowStaffList )) {
  3351. $nowStaff = implode ( ',', $nowStaffList );
  3352. $verifyStaff = array (
  3353. $this->staff [0] ['sid'] . "_R" => array (
  3354. 'date' => date ( 'Y-m-d' ),
  3355. 'opinion' => $opinion,
  3356. 'status' => $status,
  3357. 'nextStaff' => $verifyDetail [0] [0],
  3358. 'ROLE' => 1
  3359. )
  3360. );
  3361. } else {
  3362. $nowStaff = $verifyDetail [1] [0];
  3363. $verifyStaff = array (
  3364. $this->staff [0] ['sid'] . "_R" => array (
  3365. 'date' => date ( 'Y-m-d' ),
  3366. 'opinion' => $opinion,
  3367. 'status' => $status,
  3368. 'nextStaff' => $verifyDetail [1] [0]
  3369. )
  3370. );
  3371. }
  3372. } else {
  3373. if ($verifyDetail [1] [1] == 'ROLE') {
  3374. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  3375. // echo "dd";
  3376. foreach ( $vStaffString as $key => $value ) {
  3377. $staffK = explode ( "_", $value );
  3378. array_push ( $nowStaffList, $staffK [0] );
  3379. }
  3380. $nowStaff = implode ( ',', $nowStaffList );
  3381. $verifyStaff = array (
  3382. $this->staff [0] ['sid'] => array (
  3383. 'date' => date ( 'Y-m-d' ),
  3384. 'opinion' => $opinion,
  3385. 'status' => $status,
  3386. 'nextStaff' => $verifyDetail [1] [0],
  3387. 'ROLE' => 1
  3388. )
  3389. );
  3390. } else {
  3391. $nowStaff = $verifyDetail [1] [0];
  3392. $verifyStaff = array (
  3393. $this->staff [0] ['sid'] => array (
  3394. 'date' => date ( 'Y-m-d' ),
  3395. 'opinion' => $opinion,
  3396. 'status' => $status,
  3397. 'nextStaff' => $verifyDetail [1] [0]
  3398. )
  3399. );
  3400. }
  3401. }
  3402. if ($status == 3)
  3403. $verifyStaff = array (
  3404. 'final' => $status,
  3405. $this->staff [0] ['sid'] => array (
  3406. 'date' => date ( 'Y-m-d' ),
  3407. 'opinion' => $opinion,
  3408. 'status' => $status
  3409. )
  3410. );
  3411. $vStaffString = json_encode ( $verifyStaff );
  3412. $receipt->nowStaff = $nowStaff;
  3413. $receipt->verifyStaff = $vStaffString;
  3414. $loanReceipt->nowStaff = $nowStaff;
  3415. $loanReceipt->verifyStaff = $vStaffString;
  3416. } else {
  3417. $VS = end ( $verifyStaff );
  3418. // 非角色审批
  3419. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  3420. $nextStaff = 0;
  3421. $roleSTF = false;
  3422. foreach ( $verifyDetail as $key => $value ) {
  3423. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  3424. if (isset ( $verifyDetail [$key + 1] )) {
  3425. $nextStaff = $verifyDetail [$key + 1] [0];
  3426. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  3427. $roleSTF = true;
  3428. }
  3429. break;
  3430. }
  3431. }
  3432. if (! $roleSTF) {
  3433. $nowStaff = $nextStaff;
  3434. $verifyStaff [$this->staff [0] ['sid']] = array (
  3435. 'date' => date ( 'Y-m-d' ),
  3436. 'opinion' => $opinion,
  3437. 'status' => $status,
  3438. 'nextStaff' => $nextStaff
  3439. );
  3440. } else {
  3441. // 获取角色下的所有用户ID
  3442. $nowStaffList = array ();
  3443. foreach ( $verifyDetail as $vfk ) {
  3444. if ($vfk [1] == 'ROLE') {
  3445. $vStaffString = json_decode ( $vfk [3] );
  3446. foreach ( $vStaffString as $key => $value ) {
  3447. $staffK = explode ( "_", $value );
  3448. array_push ( $nowStaffList, $staffK [0] );
  3449. }
  3450. }
  3451. }
  3452. $nowStaff = implode ( ',', $nowStaffList );
  3453. $verifyStaff [$this->staff [0] ['sid']] = array (
  3454. 'date' => date ( 'Y-m-d' ),
  3455. 'opinion' => $opinion,
  3456. 'status' => $status,
  3457. 'nextStaff' => $nextStaff,
  3458. 'ROLE' => 0
  3459. );
  3460. }
  3461. if ($status == 3) {
  3462. $verifyStaff ['final'] = $status;
  3463. $verifyStaff [$this->staff [0] ['sid']] = array (
  3464. 'date' => date ( 'Y-m-d' ),
  3465. 'opinion' => $opinion,
  3466. 'status' => $status
  3467. );
  3468. }
  3469. $vStaffString = json_encode ( $verifyStaff );
  3470. $receipt->nowStaff = $nowStaff;
  3471. $receipt->verifyStaff = $vStaffString;
  3472. $loanReceipt->nowStaff = $nowStaff;
  3473. $loanReceipt->verifyStaff = $vStaffString;
  3474. }
  3475. // 角色审批
  3476. if (isset ( $VS ['ROLE'] )) {
  3477. // 找出角色人 当前审批角色组
  3478. $verifyJSStaff = array ();
  3479. $nowStaffList2 = array ();
  3480. foreach ( $verifyDetail as $key => $value ) {
  3481. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  3482. $verifyJSStaff = json_decode ( $value [3] );
  3483. foreach ( $verifyJSStaff as $m ) {
  3484. $staffK = explode ( "_", $m );
  3485. array_push ( $nowStaffList2, $staffK [0] );
  3486. }
  3487. // print_r($nowStaffList2);
  3488. }
  3489. }
  3490. $RoleVerifyStaff = array ();
  3491. foreach ( $verifyStaff as $key => $value ) {
  3492. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  3493. foreach ( $nowStaffList2 as $m ) {
  3494. if ($key == $m . "_R")
  3495. $RoleVerifyStaff [$key] = $value;
  3496. }
  3497. }
  3498. }
  3499. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  3500. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  3501. // 下一个审批人ID
  3502. $nextStaff = 0;
  3503. $falg = false;
  3504. foreach ( $verifyDetail as $key => $value ) {
  3505. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  3506. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  3507. $falg = true;
  3508. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  3509. $nowStaffList = array ();
  3510. foreach ( $vStaffString as $v ) {
  3511. $staffK = explode ( "_", $v );
  3512. array_push ( $nowStaffList, $staffK [0] );
  3513. }
  3514. $nowStaff = implode ( ',', $nowStaffList );
  3515. $nextStaff = $verifyDetail [$key + 1] [0];
  3516. } elseif (isset ( $verifyDetail [$key + 1] )) {
  3517. $nextStaff = $verifyDetail [$key + 1] [0];
  3518. $nowStaff = $nextStaff;
  3519. } else
  3520. $nowStaff = '';
  3521. break;
  3522. }
  3523. }
  3524. if ($falg)
  3525. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3526. 'date' => date ( 'Y-m-d' ),
  3527. 'opinion' => $opinion,
  3528. 'status' => $status,
  3529. 'nextStaff' => $nextStaff,
  3530. 'ROLE' => 1
  3531. );
  3532. else
  3533. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3534. 'date' => date ( 'Y-m-d' ),
  3535. 'opinion' => $opinion,
  3536. 'status' => $status,
  3537. 'nextStaff' => $nextStaff
  3538. );
  3539. // print_r($verifyStaff);
  3540. // echo $nowStaff;die;
  3541. } else { // 进入下一个角色或者审批人
  3542. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  3543. //
  3544. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  3545. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3546. 'date' => date ( 'Y-m-d' ),
  3547. 'opinion' => $opinion,
  3548. 'status' => $status,
  3549. 'nextStaff' => $VS ['nextStaff'],
  3550. 'ROLE' => 1
  3551. );
  3552. // print_r($verifyStaff);
  3553. // die;
  3554. }
  3555. if ($status == 3) {
  3556. $verifyStaff ['final'] = $status;
  3557. $verifyStaff [$this->staff [0] ['sid']] = array (
  3558. 'date' => date ( 'Y-m-d' ),
  3559. 'opinion' => $opinion,
  3560. 'status' => $status
  3561. );
  3562. }
  3563. $vStaffString = json_encode ( $verifyStaff );
  3564. $receipt->verifyStaff = $vStaffString;
  3565. $receipt->nowStaff = $nowStaff;
  3566. $loanReceipt->nowStaff = $nowStaff;
  3567. $loanReceipt->verifyStaff = $vStaffString;
  3568. // die;
  3569. // }
  3570. // print_r($verifyStaff);
  3571. // die;
  3572. }
  3573. // print_r($verifyStaff);die;
  3574. }
  3575. // print_r($verifyDetail);
  3576. $roleKey = 0;
  3577. $roleId = 0;
  3578. $verifyDetailCopy = array ();
  3579. foreach ( $verifyDetail as $k => $v ) {
  3580. if ($v [1] == 'ROLE') {
  3581. $roleId = $v [0];
  3582. $roleVerify = json_decode ( $v [3], true );
  3583. $roleKey = $k;
  3584. $roleArray = array ();
  3585. foreach ( $roleVerify as $o => $p ) {
  3586. $staffID = explode ( '_', $p );
  3587. $exp = array (
  3588. 0 => $staffID [0],
  3589. 1 => $staffID [1]
  3590. );
  3591. array_push ( $roleArray, $exp );
  3592. }
  3593. $verifyDetailCopy [$v [0]] = $roleArray;
  3594. }
  3595. }
  3596. // print_r($verifyDetail);
  3597. foreach ( $verifyDetailCopy as $k => $v ) {
  3598. foreach ( $verifyDetail as $m => $n ) {
  3599. if ($n [0] == $k) {
  3600. array_splice ( $verifyDetail, $m, 1, $v );
  3601. }
  3602. }
  3603. }
  3604. // 审批日志
  3605. if (! isset ( $verifyStaff ['final'] )) {
  3606. Doo::loadModel ( "receiptLog" );
  3607. $receiptLog = new receiptLog ();
  3608. if (! empty ( $roleId )) {
  3609. Doo::loadModel ( "role" );
  3610. $role = new role ();
  3611. $roleInfo = $role->getOne ( array (
  3612. 'where' => 'rid=' . $roleId,
  3613. 'asArray' => true
  3614. ) );
  3615. $receiptLog->rolename = $roleInfo ['name'];
  3616. }
  3617. $receiptLog->username = $this->staff [0] ['username'];
  3618. $receiptLog->uid = $this->staff [0] ['sid'];
  3619. $receiptLog->date = date ( "Y-m-d" );
  3620. $receiptLog->opinion = $opinion;
  3621. $receiptLog->img = $this->staff [0] ['avatar'];
  3622. $receiptLog->status = 1;
  3623. $receiptLog->rid = $rid;
  3624. $receiptLog->insert ();
  3625. }
  3626. if (isset ( $verifyStaff ['final'] )) { // rDetail
  3627. $receipt->status = 3;
  3628. $receipt->verifyBreakup = $verifyString;
  3629. $receiptDetailObj->status = 3;
  3630. $receiptDetailObj->update ( array (
  3631. 'where' => 'rid=' . $rid
  3632. ) );
  3633. // 微信企业号通知
  3634. $this->setWXMsg ( $rid, 3 );
  3635. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  3636. $receipt->status = 6;
  3637. $receipt->pastDate = date ( "Y-m-d" );
  3638. $receipt->isBK = 1;
  3639. $loanReceipt->verifyBreakup = $verifyString;
  3640. $loanReceipt->status = 1;
  3641. $loanReceipt->pastDate = date ( "Y-m-d" );
  3642. $loanReceipt->amount = $receiptDetail ['amount'];
  3643. $loanReceipt->update ( array (
  3644. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  3645. ) );
  3646. // 微信企业号通知
  3647. $this->setWXMsg ( $rid, 1 );
  3648. }
  3649. $receipt->amount = $amount;
  3650. $receipt->update ( array (
  3651. 'where' => ' rid = ' . $rid
  3652. ) );
  3653. // 进入下一条审批费用新加需求
  3654. $vidList = array ();
  3655. $verifyDetail = $verify->find ( array (
  3656. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  3657. 'asArray' => true
  3658. ) );
  3659. foreach ( $verifyDetail as $key => $value ) {
  3660. array_push ( $vidList, $value ['vid'] );
  3661. }
  3662. $vid = implode ( ",", $vidList );
  3663. if (empty ( $verifyDetail ))
  3664. $vid = 0;
  3665. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  3666. $receipt = new receipt ();
  3667. $rd = $receipt->getOne ( array (
  3668. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  3669. 'asc' => 'rid',
  3670. 'asArray' => true
  3671. ) );
  3672. if (empty ( $rd )) {
  3673. return '/approvalExpenses/pendApproval';
  3674. }
  3675. if ($rd ['Rtype'] == 1) {
  3676. if ($rd ['isBK'] == 1) {
  3677. return '/receiptburEdi/' . $rd ['rid'];
  3678. } else {
  3679. return '/expensesEdi/' . $rd ['rid'];
  3680. }
  3681. } elseif ($rd ['Rtype'] == 2) {
  3682. return '/remitApproval/' . $rd ['rid'];
  3683. } else {
  3684. return '/receiptburEdi/' . $rd ['rid'];
  3685. }
  3686. // return "/approvalExpenses/pendApproval";
  3687. }
  3688. }
  3689. function ajaxExamineExe() {
  3690. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3691. Doo::loadModel ( 'receipt' );
  3692. $receipt = new receipt ();
  3693. Doo::loadClass ( 'XDeode' );
  3694. $XDeode = new XDeode ( 5 );
  3695. if (! empty ( $rid )) {
  3696. $rLRes = $receipt->find ( array (
  3697. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  3698. 'asArray' => true
  3699. ) );
  3700. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  3701. echo json_encode ( array (
  3702. 'status' => 1,
  3703. 'receipt' => $rLRes [0]
  3704. ) );
  3705. die ();
  3706. }
  3707. echo json_encode ( array (
  3708. 'status' => 0,
  3709. 'receipt' => array ()
  3710. ) );
  3711. die ();
  3712. }
  3713. function implement() {
  3714. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3715. Doo::loadClass ( 'XDeode' );
  3716. $XDeode = new XDeode ( 5 );
  3717. Doo::loadModel ( 'receipt' );
  3718. $receipt = new receipt ();
  3719. Doo::loadModel ( 'L_category' );
  3720. $Lcategory = new L_category ();
  3721. Doo::loadModel ( 'verify' );
  3722. $verify = new verify ();
  3723. Doo::loadModel ( 'staff' );
  3724. $staff = new staff ();
  3725. Doo::loadModel ( "execute" );
  3726. $execute = new execute ();
  3727. $rid = $XDeode->decode ( $rid );
  3728. $receiptList = $receipt->find ( array (
  3729. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  3730. 'desc' => 'rid',
  3731. 'asArray' => true
  3732. ) );
  3733. Doo::loadModel ( 'loanReceipt' );
  3734. $loanReceipt = new loanReceipt ();
  3735. // print_r($receiptList);
  3736. $loanList = array ();
  3737. if (! isset ( $receiptList ))
  3738. $loanList = $loanReceipt->find ( array (
  3739. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3740. 'desc' => 'rid',
  3741. 'asArray' => true
  3742. ) );
  3743. $Locate = 0;
  3744. $roleId = 0;
  3745. $button = 0;
  3746. foreach ( $loanList as $key => $value ) {
  3747. $loanList [$key] ['Locate'] = $Locate;
  3748. $Locate ++;
  3749. $loanList [$key] ['reviseDetail'] = array ();
  3750. if (! empty ( $value ['reviseDetail'] ))
  3751. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3752. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3753. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3754. $categoryDetil = $Lcategory->getOne ( array (
  3755. 'where' => 'cid=' . $value ['cid'],
  3756. 'asArray' => true
  3757. ) );
  3758. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3759. // 检测编辑状态
  3760. $verifyList = $verify->getOne ( array (
  3761. 'where' => 'vid=' . $value ['verify'],
  3762. 'asArray' => true
  3763. ) );
  3764. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3765. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3766. Doo::loadModel ( 'role' );
  3767. $role = new role ();
  3768. $flag = true;
  3769. $roleKey = 0;
  3770. $endStaffArray = array ();
  3771. $roleArrayCopy = array ();
  3772. foreach ( $verifyList as $k => $v ) {
  3773. // init verifyStaff
  3774. if ($v [1] == 'ROLE') {
  3775. if (! empty ( $verifyStaff )) {
  3776. $endStaffArray = end ( $verifyStaff );
  3777. // if ($v[0]==$endStaffArray['nextStaff']){
  3778. // $roleId=$v[0];
  3779. // }
  3780. }
  3781. $roleVerify = json_decode ( $v [3], true );
  3782. $roleKey = $k;
  3783. $roleArray = array ();
  3784. $rolename = $role->getOne ( array (
  3785. 'where' => 'rid=' . $v [0],
  3786. 'asArray' => true
  3787. ) );
  3788. foreach ( $roleVerify as $o => $p ) {
  3789. $staffID = explode ( '_', $p );
  3790. $staffInfo = $staff->getOne ( array (
  3791. 'where' => 'sid=' . $staffID [0],
  3792. 'asArray' => true
  3793. ) );
  3794. // print_r($staffID);
  3795. $exp = array (
  3796. 0 => $staffInfo ['sid'],
  3797. 1 => $staffID [1],
  3798. 2 => $staffInfo ['avatar'],
  3799. 'date' => '',
  3800. 'date' => '',
  3801. 'opinion' => '',
  3802. 'status' => '',
  3803. 'rolename' => $rolename ['name']
  3804. );
  3805. array_push ( $roleArray, $exp );
  3806. }
  3807. $roleArrayCopy [$v [0]] = $roleArray;
  3808. // $verifyList[$k]['roleArray']=$roleArray;
  3809. }
  3810. $verifyList [$k] ['date'] = "";
  3811. $verifyList [$k] ['opinion'] = "";
  3812. $verifyList [$k] ['status'] = "";
  3813. if (empty ( $verifyStaff )) {
  3814. $verifyList [$k] ['date'] = "";
  3815. $verifyList [$k] ['opinion'] = "";
  3816. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3817. $verifyList [$k] ['status'] = 4;
  3818. $flag = false;
  3819. }
  3820. } else {
  3821. foreach ( $verifyStaff as $m => $u ) {
  3822. if ($v [0] == $m) {
  3823. $verifyList [$k] ['date'] = $u ['date'];
  3824. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3825. $verifyList [$k] ['status'] = $u ['status'];
  3826. $flag = false;
  3827. break;
  3828. }
  3829. }
  3830. $endStaffArray = end ( $verifyStaff );
  3831. if (isset ( $endStaffArray ['ROLE'] )) {
  3832. } else {
  3833. // $endKey=key($verifyStaff);
  3834. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3835. // $button=4;
  3836. // $verifyList[$k]['status']=4;
  3837. // }
  3838. }
  3839. }
  3840. }
  3841. $rolename ['name'] = '';
  3842. if (! empty ( $roleId )) {
  3843. Doo::loadModel ( 'role' );
  3844. $role = new role ();
  3845. $rolename = $role->getOne ( array (
  3846. 'where' => 'rid=' . $roleId,
  3847. 'asArray' => true
  3848. ) );
  3849. }
  3850. if (! empty ( $verifyStaff ))
  3851. $endStaffArray = end ( $verifyStaff );
  3852. $KOP = false;
  3853. foreach ( $roleArrayCopy as $P => $A ) {
  3854. foreach ( $A as $MKI => $AVL ) {
  3855. if (! empty ( $verifyStaff )) {
  3856. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3857. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3858. $button = 4;
  3859. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3860. }
  3861. foreach ( $verifyStaff as $m => $u ) {
  3862. $AVLFK = $AVL [0] . '_R';
  3863. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3864. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3865. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3866. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3867. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3868. break;
  3869. }
  3870. }
  3871. } else {
  3872. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3873. $button = 4;
  3874. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3875. }
  3876. }
  3877. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3878. $KOP = true;
  3879. }
  3880. }
  3881. foreach ( $roleArrayCopy as $k => $v ) {
  3882. foreach ( $verifyList as $m => $n ) {
  3883. if ($n [0] == $k) {
  3884. array_splice ( $verifyList, $m, 1, $v );
  3885. }
  3886. }
  3887. }
  3888. $loanList [$key] ['verifyList'] = $verifyList;
  3889. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3890. 'where' => 'sid=' . $value ['staff'],
  3891. 'asArray' => true
  3892. ) );
  3893. }
  3894. $data ['loanList'] = $loanList;
  3895. $Locate = 0;
  3896. $roleId = 0;
  3897. $button = 0;
  3898. foreach ( $receiptList as $key => $value ) {
  3899. $button2 = 0;
  3900. $receiptList [$key] ['Locate'] = $Locate;
  3901. $Locate ++;
  3902. $receiptList [$key] ['reviseDetail'] = array ();
  3903. if (! empty ( $value ['reviseDetail'] ))
  3904. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3905. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3906. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3907. $categoryDetil = $Lcategory->getOne ( array (
  3908. 'where' => 'cid=' . $value ['cid'],
  3909. 'asArray' => true
  3910. ) );
  3911. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3912. $executeList = json_decode ( $value ['executeCopy'], true );
  3913. $executeStaff = array ();
  3914. if (! empty ( $value ['executeStaff'] ))
  3915. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3916. if (isset ( $executeList )) {
  3917. foreach ( $executeList as $op => $lo ) {
  3918. $executeList [$op] ['date'] = "";
  3919. $executeList [$op] ['opinion'] = "";
  3920. $executeList [$op] ['status'] = "";
  3921. foreach ( $executeStaff as $m => $u ) {
  3922. if ($lo [0] == $m) {
  3923. $executeList [$op] ['date'] = $u ['date'];
  3924. $executeList [$op] ['opinion'] = $u ['opinion'];
  3925. $executeList [$op] ['status'] = $u ['status'];
  3926. break;
  3927. }
  3928. }
  3929. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  3930. $button2 = 1;
  3931. $executeList [$op] ['status'] = 4;
  3932. }
  3933. }
  3934. }
  3935. // 检测编辑状态
  3936. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3937. $verifyList ['staff'] = $value ['verifyBreakup'];
  3938. } else
  3939. $verifyList = $verify->getOne ( array (
  3940. 'where' => 'vid=' . $value ['verify'],
  3941. 'asArray' => true
  3942. ) );
  3943. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3944. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3945. Doo::loadModel ( 'role' );
  3946. $role = new role ();
  3947. if ($verifyList == NULL)
  3948. $verifyList = array ();
  3949. $flag = true;
  3950. $roleKey = 0;
  3951. $endStaffArray = array ();
  3952. $roleArrayCopy = array ();
  3953. foreach ( $verifyList as $k => $v ) {
  3954. // init verifyStaff
  3955. if ($v [1] == 'ROLE') {
  3956. if (! empty ( $verifyStaff )) {
  3957. $endStaffArray = end ( $verifyStaff );
  3958. // if ($v[0]==$endStaffArray['nextStaff']){
  3959. // $roleId=$v[0];
  3960. // }
  3961. }
  3962. $roleVerify = json_decode ( $v [3], true );
  3963. $roleKey = $k;
  3964. $roleArray = array ();
  3965. $rolename = $role->getOne ( array (
  3966. 'where' => 'rid=' . $v [0],
  3967. 'asArray' => true
  3968. ) );
  3969. foreach ( $roleVerify as $o => $p ) {
  3970. $staffID = explode ( '_', $p );
  3971. $staffInfo = $staff->getOne ( array (
  3972. 'where' => 'sid=' . $staffID [0],
  3973. 'asArray' => true
  3974. ) );
  3975. // print_r($staffID);
  3976. $exp = array (
  3977. 0 => $staffInfo ['sid'],
  3978. 1 => $staffID [1],
  3979. 2 => $staffInfo ['avatar'],
  3980. 'date' => '',
  3981. 'date' => '',
  3982. 'opinion' => '',
  3983. 'status' => '',
  3984. 'rolename' => $rolename ['name']
  3985. );
  3986. array_push ( $roleArray, $exp );
  3987. }
  3988. $roleArrayCopy [$v [0]] = $roleArray;
  3989. // $verifyList[$k]['roleArray']=$roleArray;
  3990. }
  3991. $verifyList [$k] ['date'] = "";
  3992. $verifyList [$k] ['opinion'] = "";
  3993. $verifyList [$k] ['status'] = "";
  3994. if (empty ( $verifyStaff )) {
  3995. $verifyList [$k] ['date'] = "";
  3996. $verifyList [$k] ['opinion'] = "";
  3997. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3998. $verifyList [$k] ['status'] = 4;
  3999. $flag = false;
  4000. }
  4001. } else {
  4002. foreach ( $verifyStaff as $m => $u ) {
  4003. if ($v [0] == $m) {
  4004. $verifyList [$k] ['date'] = $u ['date'];
  4005. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4006. $verifyList [$k] ['status'] = $u ['status'];
  4007. $flag = false;
  4008. break;
  4009. }
  4010. }
  4011. $endStaffArray = end ( $verifyStaff );
  4012. if (isset ( $endStaffArray ['ROLE'] )) {
  4013. } else {
  4014. // $endKey=key($verifyStaff);
  4015. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4016. // $button=4;
  4017. // $verifyList[$k]['status']=4;
  4018. // }
  4019. }
  4020. }
  4021. }
  4022. $rolename ['name'] = '';
  4023. if (! empty ( $roleId )) {
  4024. Doo::loadModel ( 'role' );
  4025. $role = new role ();
  4026. $rolename = $role->getOne ( array (
  4027. 'where' => 'rid=' . $roleId,
  4028. 'asArray' => true
  4029. ) );
  4030. }
  4031. if (! empty ( $verifyStaff ))
  4032. $endStaffArray = end ( $verifyStaff );
  4033. $KOP = false;
  4034. foreach ( $roleArrayCopy as $P => $A ) {
  4035. foreach ( $A as $MKI => $AVL ) {
  4036. if (! empty ( $verifyStaff )) {
  4037. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4038. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4039. $button = 4;
  4040. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4041. }
  4042. foreach ( $verifyStaff as $m => $u ) {
  4043. $AVLFK = $AVL [0] . '_R';
  4044. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4045. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4046. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4047. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4048. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4049. break;
  4050. }
  4051. }
  4052. } else {
  4053. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4054. $button = 4;
  4055. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4056. }
  4057. }
  4058. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4059. $KOP = true;
  4060. }
  4061. }
  4062. foreach ( $roleArrayCopy as $k => $v ) {
  4063. foreach ( $verifyList as $m => $n ) {
  4064. if ($n [0] == $k) {
  4065. array_splice ( $verifyList, $m, 1, $v );
  4066. }
  4067. }
  4068. }
  4069. $receiptList [$key] ['verifyList'] = $verifyList;
  4070. $receiptList [$key] ['executeList'] = $executeList;
  4071. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4072. 'where' => 'sid=' . $value ['staff'],
  4073. 'asArray' => true
  4074. ) );
  4075. $receiptList [$key] ['button2'] = $button2;
  4076. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4077. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4078. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  4079. $receiptList [$key] ['relust'] = $relust;
  4080. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  4081. }
  4082. // print_r($receiptList[$key]['executeList']);
  4083. $data ['receiptList'] = $receiptList;
  4084. $data ['memu'] = "receipt";
  4085. $data ['staff'] = $this->staff;
  4086. $data ['receiptMemu'] = 'implement';
  4087. $data ['verifyId'] = $this->verifyId;
  4088. $data ['executeId'] = $this->executeId;
  4089. $this->render ( "/admin/implement", $data );
  4090. }
  4091. function implementDo() {
  4092. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4093. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  4094. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  4095. $accountBank = $this->get_args ( 'accountBank' ) ? $this->get_args ( 'accountBank' ) : "";
  4096. $ab = '';
  4097. if ($accountBank == 'CGBDeposit')
  4098. $ab = '纵横广发';
  4099. elseif ($accountBank == 'ICBCDeposit')
  4100. $ab = '纵横工行';
  4101. elseif ($accountBank == 'HUADeposit')
  4102. $ab = '华润银行';
  4103. elseif ($accountBank == 'PersonalDeposit')
  4104. $ab = '个人广发';
  4105. if (empty ( $ab ))
  4106. die ( 'illegal request' );
  4107. if (! empty ( $rid ) && $amount != '') {
  4108. Doo::loadModel ( 'receipt' );
  4109. $receipt = new receipt ();
  4110. Doo::loadClass ( 'XDeode' );
  4111. $XDeode = new XDeode ( 5 );
  4112. // $rinfo = $receipt->getOne ( array (
  4113. // 'where' => 'rid=' . $rid,
  4114. // 'asArray' => true
  4115. // ) );
  4116. $rinfo = $receipt->getReceiptByRid ( $rid );
  4117. $accountType = '';
  4118. if ($rinfo ['Rtype'] == 1) {
  4119. if ($rinfo ['loanRid'] != 0)
  4120. $accountType = 2;
  4121. else
  4122. $accountType = 1;
  4123. } elseif ($rinfo ['Rtype'] == 2) {
  4124. $accountType = 4;
  4125. } elseif ($rinfo ['Rtype'] == 0)
  4126. $accountType = 3;
  4127. if (empty ( $accountType ))
  4128. die ( 'illegal request' );
  4129. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  4130. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  4131. if (empty ( $executeStaff )) {
  4132. $executeStaff = array (
  4133. $this->staff [0] ['sid'] => array (
  4134. 'date' => date ( 'Y-m-d' ),
  4135. 'opinion' => $implementOpinions,
  4136. 'status' => 1
  4137. )
  4138. );
  4139. } else {
  4140. $executeStaff [$this->staff [0] ['sid']] = array (
  4141. 'date' => date ( 'Y-m-d' ),
  4142. 'opinion' => $implementOpinions,
  4143. 'status' => 1
  4144. );
  4145. }
  4146. if (count ( $executeStaff ) == count ( $executeCopy )) {
  4147. $receipt->executeStaff = json_encode ( $executeStaff );
  4148. $receipt->status = 8;
  4149. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  4150. $receipt->status = 9;
  4151. if ($rinfo ['status'] == 6) {
  4152. $receipt->loanDate = date ( "Y-m-d" );
  4153. }
  4154. $receipt->executeDate = date ( "Y-m-d" );
  4155. } else {
  4156. $receipt->executeStaff = json_encode ( $executeStaff );
  4157. }
  4158. $receipt->amount = $amount;
  4159. $receipt->update ( array (
  4160. 'where' => 'rid=' . $rid
  4161. ) );
  4162. // 公司流水记录
  4163. Doo::loadModel ( 'wasteBook' );
  4164. $wasteBook = new wasteBook ();
  4165. $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountType, $rid );
  4166. // 银行
  4167. if (empty ( $abDetail )&&!empty($amount)) {
  4168. $item = array (
  4169. 'dataID' => $rid,
  4170. 'expensesType' => 2,
  4171. 'accountType' => $accountType,
  4172. 'accountPriceShow' => $amount,
  4173. 'accountPrice' => - $amount,
  4174. 'accountBank' => $accountBank,
  4175. 'category' => $rinfo ['category'] [0] ['title'],
  4176. 'cid' => $rinfo ['category'] [0] ['cid'],
  4177. 'name' => $rinfo ['staffDetail'] ['username'],
  4178. 'sid' => $rinfo ['staffDetail'] ['sid'],
  4179. 'inputDate' => date ( "Y-m-d H:i:s" )
  4180. );
  4181. $wasteBook->setAccountBookStatistics ( $item );
  4182. }
  4183. }
  4184. $ridKey = $XDeode->encode ( $rid );
  4185. return "/hisImplement";
  4186. // return "/implement/" . $ridKey . ".html";
  4187. }
  4188. function receiptburEdi() {
  4189. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4190. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  4191. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4192. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4193. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4194. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4195. if (empty ( $status ))
  4196. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  4197. $vidList = array ();
  4198. $button = 0;
  4199. Doo::loadModel ( 'verify' );
  4200. Doo::loadModel ( 'receipt' );
  4201. Doo::loadModel ( 'staff' );
  4202. $staff = new staff ();
  4203. $receipt = new receipt ();
  4204. $verify = new verify ();
  4205. Doo::loadModel ( 'L_category' );
  4206. $Lcategory = new L_category ();
  4207. Doo::loadModel ( 'enclosur' );
  4208. $enclosur = new enclosur ();
  4209. Doo::loadModel ( 'loanReceipt' );
  4210. $loanReceipt = new loanReceipt ();
  4211. // user verify ID
  4212. $verifyDetail = $verify->find ( array (
  4213. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  4214. 'asArray' => true
  4215. ) );
  4216. foreach ( $verifyDetail as $key => $value ) {
  4217. array_push ( $vidList, $value ['vid'] );
  4218. }
  4219. $vid = implode ( ",", $vidList );
  4220. if (empty ( $verifyDetail ))
  4221. $vid = 0;
  4222. $categoryList = $Lcategory->find ( array (
  4223. 'asArray' => true
  4224. ) );
  4225. $staffList = $staff->find ( array (
  4226. 'where' => 'cid=' . $cid,
  4227. 'asArray' => true
  4228. ) );
  4229. $ap = "";
  4230. if ($status == 4) {
  4231. $ap = 4;
  4232. $status = 2;
  4233. }
  4234. // get Receipt By verifyID status 2
  4235. $receiptList = $receipt->find ( array (
  4236. 'where' => 'rid =' . $rid . ' and status=2',
  4237. 'desc' => 'rid',
  4238. 'asArray' => true
  4239. ) );
  4240. if (empty ( $receiptList )) {
  4241. die ( 'illegal request' );
  4242. }
  4243. $loanList = $loanReceipt->find ( array (
  4244. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4245. 'desc' => 'rid',
  4246. 'asArray' => true
  4247. ) );
  4248. $data ['explanation'] = '';
  4249. if (! empty ( $loanList ))
  4250. $data ['explanation'] = $loanList [0] ['explanation'];
  4251. $Locate = 0;
  4252. $roleId = 0;
  4253. $button = 0;
  4254. foreach ( $loanList as $key => $value ) {
  4255. $loanList [$key] ['Locate'] = $Locate;
  4256. $Locate ++;
  4257. $loanList [$key] ['reviseDetail'] = array ();
  4258. if (! empty ( $value ['reviseDetail'] ))
  4259. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4260. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4261. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4262. $categoryDetil = $Lcategory->getOne ( array (
  4263. 'where' => 'cid=' . $value ['cid'],
  4264. 'asArray' => true
  4265. ) );
  4266. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4267. // 检测编辑状态
  4268. $verifyList = $verify->getOne ( array (
  4269. 'where' => 'vid=' . $value ['verify'],
  4270. 'asArray' => true
  4271. ) );
  4272. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4273. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4274. Doo::loadModel ( 'role' );
  4275. $role = new role ();
  4276. $flag = true;
  4277. $roleKey = 0;
  4278. $endStaffArray = array ();
  4279. $roleArrayCopy = array ();
  4280. foreach ( $verifyList as $k => $v ) {
  4281. // init verifyStaff
  4282. if ($v [1] == 'ROLE') {
  4283. if (! empty ( $verifyStaff )) {
  4284. $endStaffArray = end ( $verifyStaff );
  4285. }
  4286. $roleVerify = json_decode ( $v [3], true );
  4287. $roleKey = $k;
  4288. $roleArray = array ();
  4289. $rolename = $role->getOne ( array (
  4290. 'where' => 'rid=' . $v [0],
  4291. 'asArray' => true
  4292. ) );
  4293. foreach ( $roleVerify as $o => $p ) {
  4294. $staffID = explode ( '_', $p );
  4295. $staffInfo = $staff->getOne ( array (
  4296. 'where' => 'sid=' . $staffID [0],
  4297. 'asArray' => true
  4298. ) );
  4299. // print_r($staffID);
  4300. $exp = array (
  4301. 0 => $staffInfo ['sid'],
  4302. 1 => $staffID [1],
  4303. 2 => $staffInfo ['avatar'],
  4304. 'date' => '',
  4305. 'date' => '',
  4306. 'opinion' => '',
  4307. 'status' => '',
  4308. 'rolename' => $rolename ['name']
  4309. );
  4310. array_push ( $roleArray, $exp );
  4311. }
  4312. $roleArrayCopy [$v [0]] = $roleArray;
  4313. // $verifyList[$k]['roleArray']=$roleArray;
  4314. }
  4315. $verifyList [$k] ['date'] = "";
  4316. $verifyList [$k] ['opinion'] = "";
  4317. $verifyList [$k] ['status'] = "";
  4318. if (empty ( $verifyStaff )) {
  4319. $verifyList [$k] ['date'] = "";
  4320. $verifyList [$k] ['opinion'] = "";
  4321. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4322. $verifyList [$k] ['status'] = 4;
  4323. $flag = false;
  4324. }
  4325. } else {
  4326. foreach ( $verifyStaff as $m => $u ) {
  4327. if ($v [0] == $m) {
  4328. $verifyList [$k] ['date'] = $u ['date'];
  4329. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4330. $verifyList [$k] ['status'] = $u ['status'];
  4331. $flag = false;
  4332. break;
  4333. }
  4334. }
  4335. $endStaffArray = end ( $verifyStaff );
  4336. if (isset ( $endStaffArray ['ROLE'] )) {
  4337. } else {
  4338. }
  4339. }
  4340. }
  4341. $rolename ['name'] = '';
  4342. if (! empty ( $roleId )) {
  4343. Doo::loadModel ( 'role' );
  4344. $role = new role ();
  4345. $rolename = $role->getOne ( array (
  4346. 'where' => 'rid=' . $roleId,
  4347. 'asArray' => true
  4348. ) );
  4349. }
  4350. if (! empty ( $verifyStaff ))
  4351. $endStaffArray = end ( $verifyStaff );
  4352. $KOP = false;
  4353. foreach ( $roleArrayCopy as $P => $A ) {
  4354. foreach ( $A as $MKI => $AVL ) {
  4355. if (! empty ( $verifyStaff )) {
  4356. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4357. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4358. $button = 4;
  4359. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4360. }
  4361. foreach ( $verifyStaff as $m => $u ) {
  4362. $AVLFK = $AVL [0] . '_R';
  4363. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4364. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4365. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4366. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4367. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4368. break;
  4369. }
  4370. }
  4371. } else {
  4372. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4373. $button = 4;
  4374. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4375. }
  4376. }
  4377. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4378. $KOP = true;
  4379. }
  4380. }
  4381. foreach ( $roleArrayCopy as $k => $v ) {
  4382. foreach ( $verifyList as $m => $n ) {
  4383. if ($n [0] == $k) {
  4384. array_splice ( $verifyList, $m, 1, $v );
  4385. }
  4386. }
  4387. }
  4388. $loanList [$key] ['verifyList'] = $verifyList;
  4389. }
  4390. $htmlLoan = '';
  4391. $data ['loanReceiptDate'] = '';
  4392. if (isset ( $loanList [0] )) {
  4393. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  4394. if ($value ['status'] == 1)
  4395. $htmlLoan .= '<li class="done" >';
  4396. elseif ($value ['status'] == 3)
  4397. $htmlLoan .= '<li class="undone" >';
  4398. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  4399. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  4400. if (isset ( $value ['rolename'] ))
  4401. $htmlLoan .= $value ['rolename'];
  4402. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  4403. }
  4404. $data ['loanDate'] = $loanList [0] ['date'];
  4405. } else {
  4406. $data ['loanReceiptDate'] = ''; // $loanList [0] ['date'];
  4407. }
  4408. $data ['htmlLoan'] = $htmlLoan;
  4409. // $data ['LoanReceipt']=$loanList[0];
  4410. // print_r($loanList);
  4411. $Locate = 0;
  4412. $roleId = 0;
  4413. $button = 0;
  4414. if ($ap == 4)
  4415. $status = 4;
  4416. Doo::loadClass ( 'XDeode' );
  4417. $XDeode = new XDeode ( 5 );
  4418. foreach ( $receiptList as $key => $value ) {
  4419. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4420. $receiptList [$key] ['Locate'] = $Locate;
  4421. $Locate ++;
  4422. $receiptList [$key] ['reviseDetail'] = array ();
  4423. // 调整金额 代码调整
  4424. if (! empty ( $value ['reviseDetail'] )) {
  4425. $reviseDetail = json_decode ( $value ['reviseDetail'], true );
  4426. foreach ( $reviseDetail as $ry => $re ) {
  4427. $reviseDetail [$ry] ['sidKey'] = $XDeode->encode ( $re ['sid'] );
  4428. $reviseDetail [$ry] ['reviseKey'] = $XDeode->encode ( $ry );
  4429. }
  4430. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  4431. // print_r($reviseDetail);
  4432. }
  4433. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4434. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4435. $categoryDetil = $Lcategory->getOne ( array (
  4436. 'where' => 'cid=' . $value ['cid'],
  4437. 'asArray' => true
  4438. ) );
  4439. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4440. // 检测编辑状态
  4441. $verifyList = $verify->getOne ( array (
  4442. 'where' => 'vid=' . $value ['verify'],
  4443. 'asArray' => true
  4444. ) );
  4445. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4446. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4447. Doo::loadModel ( 'role' );
  4448. $role = new role ();
  4449. // print_r($verifyList);
  4450. $flag = true;
  4451. $roleKey = 0;
  4452. $endStaffArray = array ();
  4453. $roleArrayCopy = array ();
  4454. foreach ( $verifyList as $k => $v ) {
  4455. // init verifyStaff
  4456. if ($v [1] == 'ROLE') {
  4457. if (! empty ( $verifyStaff )) {
  4458. $endStaffArray = end ( $verifyStaff );
  4459. if ($v [0] == $endStaffArray ['nextStaff']) {
  4460. $roleId = $v [0];
  4461. }
  4462. }
  4463. $roleVerify = json_decode ( $v [3], true );
  4464. $roleKey = $k;
  4465. $roleArray = array ();
  4466. $rolename = $role->getOne ( array (
  4467. 'where' => 'rid=' . $v [0],
  4468. 'asArray' => true
  4469. ) );
  4470. foreach ( $roleVerify as $o => $p ) {
  4471. $staffID = explode ( '_', $p );
  4472. $staffInfo = $staff->getOne ( array (
  4473. 'where' => 'sid=' . $staffID [0],
  4474. 'asArray' => true
  4475. ) );
  4476. // print_r($staffID);
  4477. $exp = array (
  4478. 0 => $staffInfo ['sid'],
  4479. 1 => $staffID [1],
  4480. 2 => $staffInfo ['avatar'],
  4481. 'date' => '',
  4482. 'date' => '',
  4483. 'opinion' => '',
  4484. 'status' => '',
  4485. 'rolename' => $rolename ['name']
  4486. );
  4487. array_push ( $roleArray, $exp );
  4488. }
  4489. $roleArrayCopy [$v [0]] = $roleArray;
  4490. // $verifyList[$k]['roleArray']=$roleArray;
  4491. }
  4492. // print_r($roleArray);
  4493. $verifyList [$k] ['date'] = "";
  4494. $verifyList [$k] ['opinion'] = "";
  4495. $verifyList [$k] ['status'] = "";
  4496. if (empty ( $verifyStaff )) {
  4497. $verifyList [$k] ['date'] = "";
  4498. $verifyList [$k] ['opinion'] = "";
  4499. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4500. $verifyList [$k] ['status'] = 4;
  4501. $button = 4;
  4502. $flag = false;
  4503. }
  4504. } else {
  4505. foreach ( $verifyStaff as $m => $u ) {
  4506. if ($v [0] == $m) {
  4507. $verifyList [$k] ['date'] = $u ['date'];
  4508. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4509. $verifyList [$k] ['status'] = $u ['status'];
  4510. $flag = false;
  4511. break;
  4512. }
  4513. }
  4514. $endStaffArray = end ( $verifyStaff );
  4515. if (isset ( $endStaffArray ['ROLE'] )) {
  4516. } else {
  4517. $endKey = key ( $verifyStaff );
  4518. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4519. $button = 4;
  4520. $verifyList [$k] ['status'] = 4;
  4521. }
  4522. }
  4523. }
  4524. }
  4525. $rolename ['name'] = '';
  4526. if (! empty ( $roleId )) {
  4527. Doo::loadModel ( 'role' );
  4528. $role = new role ();
  4529. $rolename = $role->getOne ( array (
  4530. 'where' => 'rid=' . $roleId,
  4531. 'asArray' => true
  4532. ) );
  4533. }
  4534. if (! empty ( $verifyStaff ))
  4535. $endStaffArray = end ( $verifyStaff );
  4536. $KOP = false;
  4537. foreach ( $roleArrayCopy as $P => $A ) {
  4538. foreach ( $A as $MKI => $AVL ) {
  4539. if (! empty ( $verifyStaff )) {
  4540. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4541. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4542. $button = 4;
  4543. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4544. }
  4545. foreach ( $verifyStaff as $m => $u ) {
  4546. $AVLFK = $AVL [0] . '_R';
  4547. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4548. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4549. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4550. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4551. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4552. break;
  4553. }
  4554. }
  4555. } else {
  4556. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4557. $button = 4;
  4558. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4559. }
  4560. }
  4561. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4562. $KOP = true;
  4563. }
  4564. }
  4565. foreach ( $roleArrayCopy as $k => $v ) {
  4566. foreach ( $verifyList as $m => $n ) {
  4567. if ($n [0] == $k) {
  4568. array_splice ( $verifyList, $m, 1, $v );
  4569. }
  4570. }
  4571. }
  4572. // print_r($verifyList);
  4573. $receiptList [$key] ['verifyList'] = $verifyList;
  4574. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4575. 'where' => 'sid=' . $value ['staff'],
  4576. 'asArray' => true
  4577. ) );
  4578. $receiptList [$key] ['button'] = $button;
  4579. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4580. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4581. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  4582. $receiptList [$key] ['relust'] = $relust;
  4583. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4584. }
  4585. // print_r($receiptList);die;
  4586. // $data['verifyDetail']=$verifyDetail;
  4587. $mothHtml = "";
  4588. for($i = 1; $i <= 12; $i ++) {
  4589. if ($month == $i)
  4590. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4591. else
  4592. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4593. }
  4594. // 获取审批日志
  4595. Doo::loadModel ( 'receiptLog' );
  4596. $receiptLog = new receiptLog ();
  4597. $rlList = array ();
  4598. $rlInfo = $receiptLog->getOne ( array (
  4599. 'where' => 'rid=' . $rid . ' and status=4',
  4600. 'asArray' => true
  4601. ) );
  4602. $tijdate = $receiptLog->getOne ( array (
  4603. 'where' => 'rid=' . $rid . ' and status=2',
  4604. 'asc' => 'rlid',
  4605. 'asArray' => true
  4606. ) );
  4607. if (! empty ( $rlInfo )) {
  4608. $rlList = $receiptLog->find ( array (
  4609. 'where' => 'rid=' . $rid,
  4610. 'asc' => 'rlid',
  4611. 'asArray' => true
  4612. ) );
  4613. }
  4614. // echo $rid;
  4615. // print_r($receiptList);
  4616. $receiptList [0] ['rlList'] = $rlList;
  4617. // print_r($receiptList);
  4618. $enclosurList = $enclosur->find ( array (
  4619. 'where' => 'rid=' . $rid,
  4620. 'asArray' => true
  4621. ) );
  4622. $enclosurHtml = '';
  4623. foreach ( $enclosurList as $value ) {
  4624. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4625. }
  4626. $data ['enclosurHtml'] = $enclosurHtml;
  4627. $data ['rolename'] = $rolename ['name'];
  4628. $data ['mothHtml'] = $mothHtml;
  4629. // print_r($receiptList);
  4630. $data ['rid'] = $rid;
  4631. $data ['tijdate'] = $tijdate ['date'];
  4632. $data ['receiptList'] = $receiptList;
  4633. $data ['receiptApprovalCount'] = count ( $receiptList );
  4634. $data ['status'] = $status;
  4635. $data ['year'] = $year;
  4636. $data ['categoryList'] = $categoryList;
  4637. $data ['staffList'] = $staffList;
  4638. $data ['cid'] = $cid;
  4639. $data ['sid'] = $sid;
  4640. $data ['ap'] = $ap;
  4641. $data ['memu'] = "receipt";
  4642. $data ['staff'] = $this->staff;
  4643. $data ['receiptMemu'] = 'approvalExpenses';
  4644. $data ['verifyId'] = $this->verifyId;
  4645. $data ['executeId'] = $this->executeId;
  4646. $this->render ( "/admin/receiptburEdi", $data );
  4647. }
  4648. function hisImplement() {
  4649. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4650. if (empty ( $item ))
  4651. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "expenses";
  4652. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  4653. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4654. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  4655. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  4656. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  4657. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'pendImplement';
  4658. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  4659. Doo::loadClass ( 'XDeode' );
  4660. $XDeode = new XDeode ( 5 );
  4661. Doo::loadModel ( 'receipt' );
  4662. $receipt = new receipt ();
  4663. Doo::loadModel ( 'L_category' );
  4664. $Lcategory = new L_category ();
  4665. Doo::loadModel ( 'verify' );
  4666. Doo::loadModel ( 'statistics' );
  4667. $statistics = new statistics ();
  4668. $verify = new verify ();
  4669. Doo::loadModel ( 'staff' );
  4670. $staff = new staff ();
  4671. Doo::loadClass ( 'XDeode' );
  4672. $XDeode = new XDeode ( 5 );
  4673. $cid = $XDeode->decode ( $cidKey );
  4674. $condition = "";
  4675. if ($item == "expenses")
  4676. $condition = " and Rtype=1 ";
  4677. elseif ($item == "receipts")
  4678. $condition = " and Rtype=0 ";
  4679. elseif ($item == "remits")
  4680. $condition = " and Rtype=2 ";
  4681. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  4682. $sopString = $cidString = "";
  4683. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  4684. if (empty ( $rdate ))
  4685. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  4686. else
  4687. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  4688. if ($status == 'pendImplement') {
  4689. $condition .= ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  4690. } elseif ($status == 'alerpts') {
  4691. $statusCon = '(status=8 or status=9 )';
  4692. if (empty ( $rdate ))
  4693. $dateCondition .= " and Year(date) =" . $year;
  4694. else
  4695. $dateCondition .= " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  4696. }
  4697. if ($sop != 'SOP')
  4698. $sopString = " and staff=" . $sop;
  4699. if ($cidKey != 'ALL')
  4700. $cidString = " and cid=" . $cid;
  4701. $receiptList = $receipt->find ( array (
  4702. 'where' => $statusCon . $condition . $dateCondition . $sopString . $cidString,
  4703. 'desc' => 'rid',
  4704. 'asArray' => true
  4705. ) );
  4706. // 员工筛选
  4707. $receiptList2 = $receipt->find ( array (
  4708. 'where' => $statusCon . $condition . $dateCondition,
  4709. 'desc' => 'rid',
  4710. 'asArray' => true
  4711. ) );
  4712. $sopStaff = array ();
  4713. foreach ( $receiptList2 as $key => $value ) {
  4714. $staffDetail = $staff->getOne ( array (
  4715. 'select' => 'username',
  4716. 'where' => 'sid=' . $value ['staff'],
  4717. 'asArray' => true
  4718. ) );
  4719. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  4720. }
  4721. // 办事处筛选
  4722. $categoryScreen = array ();
  4723. $categorList = $Lcategory->getCategory ();
  4724. foreach ( $receiptList2 as $key => $value ) {
  4725. foreach ( $categorList as $k => $v ) {
  4726. if ($value ['cid'] == $v ['cid']) {
  4727. $categoryScreen [$v ['cidKey']] = $v ['title'];
  4728. break;
  4729. }
  4730. }
  4731. }
  4732. $categoryScreenHtml = "";
  4733. foreach ( $categoryScreen as $key => $value ) {
  4734. if ($cidKey == $key)
  4735. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4736. else
  4737. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4738. }
  4739. $data ['categoryScreenHtml'] = $categoryScreenHtml;
  4740. $data ['cidKey'] = $cidKey;
  4741. $Locate = 0;
  4742. $roleId = 0;
  4743. $button = 0;
  4744. $staffBatchNumber = 100001;
  4745. $remittanceList = array ();
  4746. foreach ( $receiptList as $key => $value ) {
  4747. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4748. $receiptList [$key] ['Texe'] = 'false';
  4749. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  4750. $receiptList [$key] ['Texe'] = 'true';
  4751. }
  4752. $receiptList [$key] ['TRexe'] = 'true';
  4753. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  4754. $receiptList [$key] ['TRexe'] = 'false';
  4755. }
  4756. $receiptList [$key] ['Locate'] = $Locate;
  4757. $Locate ++;
  4758. $receiptList [$key] ['reviseDetail'] = array ();
  4759. if (! empty ( $value ['reviseDetail'] ))
  4760. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4761. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4762. $categoryDetil = $Lcategory->getOne ( array (
  4763. 'where' => 'cid=' . $value ['cid'],
  4764. 'asArray' => true
  4765. ) );
  4766. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4767. // 检测编辑状态
  4768. $verifyList = $verify->getOne ( array (
  4769. 'where' => 'vid=' . $value ['verify'],
  4770. 'asArray' => true
  4771. ) );
  4772. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4773. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4774. Doo::loadModel ( 'role' );
  4775. $role = new role ();
  4776. $flag = true;
  4777. $roleKey = 0;
  4778. $endStaffArray = array ();
  4779. $roleArrayCopy = array ();
  4780. foreach ( $verifyList as $k => $v ) {
  4781. // init verifyStaff
  4782. if ($v [1] == 'ROLE') {
  4783. if (! empty ( $verifyStaff )) {
  4784. $endStaffArray = end ( $verifyStaff );
  4785. }
  4786. $roleVerify = json_decode ( $v [3], true );
  4787. $roleKey = $k;
  4788. $roleArray = array ();
  4789. $rolename = $role->getOne ( array (
  4790. 'where' => 'rid=' . $v [0],
  4791. 'asArray' => true
  4792. ) );
  4793. foreach ( $roleVerify as $o => $p ) {
  4794. $staffID = explode ( '_', $p );
  4795. $staffInfo = $staff->getOne ( array (
  4796. 'where' => 'sid=' . $staffID [0],
  4797. 'asArray' => true
  4798. ) );
  4799. $exp = array (
  4800. 0 => $staffInfo ['sid'],
  4801. 1 => $staffID [1],
  4802. 2 => $staffInfo ['avatar'],
  4803. 'date' => '',
  4804. 'date' => '',
  4805. 'opinion' => '',
  4806. 'status' => '',
  4807. 'rolename' => $rolename ['name']
  4808. );
  4809. array_push ( $roleArray, $exp );
  4810. }
  4811. $roleArrayCopy [$v [0]] = $roleArray;
  4812. }
  4813. $verifyList [$k] ['date'] = "";
  4814. $verifyList [$k] ['opinion'] = "";
  4815. $verifyList [$k] ['status'] = "";
  4816. if (empty ( $verifyStaff )) {
  4817. $verifyList [$k] ['date'] = "";
  4818. $verifyList [$k] ['opinion'] = "";
  4819. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4820. $verifyList [$k] ['status'] = 4;
  4821. $flag = false;
  4822. }
  4823. } else {
  4824. foreach ( $verifyStaff as $m => $u ) {
  4825. if ($v [0] == $m) {
  4826. $verifyList [$k] ['date'] = $u ['date'];
  4827. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4828. $verifyList [$k] ['status'] = $u ['status'];
  4829. $flag = false;
  4830. break;
  4831. }
  4832. }
  4833. $endStaffArray = end ( $verifyStaff );
  4834. }
  4835. }
  4836. $rolename ['name'] = '';
  4837. if (! empty ( $roleId )) {
  4838. Doo::loadModel ( 'role' );
  4839. $role = new role ();
  4840. $rolename = $role->getOne ( array (
  4841. 'where' => 'rid=' . $roleId,
  4842. 'asArray' => true
  4843. ) );
  4844. }
  4845. if (! empty ( $verifyStaff ))
  4846. $endStaffArray = end ( $verifyStaff );
  4847. $KOP = false;
  4848. foreach ( $roleArrayCopy as $P => $A ) {
  4849. foreach ( $A as $MKI => $AVL ) {
  4850. if (! empty ( $verifyStaff )) {
  4851. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4852. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4853. $button = 4;
  4854. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4855. }
  4856. foreach ( $verifyStaff as $m => $u ) {
  4857. $AVLFK = $AVL [0] . '_R';
  4858. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4859. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4860. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4861. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4862. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4863. break;
  4864. }
  4865. }
  4866. } else {
  4867. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4868. $button = 4;
  4869. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4870. }
  4871. }
  4872. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4873. $KOP = true;
  4874. }
  4875. }
  4876. foreach ( $roleArrayCopy as $k => $v ) {
  4877. foreach ( $verifyList as $m => $n ) {
  4878. if ($n [0] == $k) {
  4879. array_splice ( $verifyList, $m, 1, $v );
  4880. }
  4881. }
  4882. }
  4883. $receiptList [$key] ['verifyList'] = $verifyList;
  4884. $staffDetail = $staff->getOne ( array (
  4885. 'where' => 'sid=' . $value ['staff'],
  4886. 'asArray' => true
  4887. ) );
  4888. $receiptList [$key] ['staffDetail'] = $staffDetail;
  4889. $receiptList [$key] ['button'] = $button;
  4890. // 设置导出汇款execl
  4891. if (! empty ( $value ['remittanceName'] ) && ! empty ( $value ['bankName'] ) && ! empty ( $value ['bankNumber'] )) {
  4892. $remittanceDetail = array (
  4893. $staffBatchNumber,
  4894. $value ['remittanceName'],
  4895. $value ['bankNumber'],
  4896. $value ['bankName'],
  4897. $value ['remittanceBankType'],
  4898. $value ['coupletNumber'],
  4899. $value ['sum']
  4900. );
  4901. array_push ( $remittanceList, $remittanceDetail );
  4902. $staffBatchNumber ++;
  4903. }
  4904. }
  4905. $data ['remittanceList'] = json_encode ( $remittanceList );
  4906. // print_r($receiptList);
  4907. $mothHtml = "";
  4908. for($i = 1; $i <= 12; $i ++) {
  4909. if ($moth == $i)
  4910. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4911. else
  4912. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4913. }
  4914. $dayHtml = "";
  4915. if ($day != "DAY" || $moth != "MONTH") {
  4916. for($i = 1; $i <= 31; $i ++) {
  4917. if ($day == $i)
  4918. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  4919. else
  4920. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  4921. }
  4922. }
  4923. $sopHtml = "";
  4924. foreach ( $sopStaff as $key => $value ) {
  4925. if ($sop == $key)
  4926. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4927. else
  4928. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4929. }
  4930. $data ['status'] = $status;
  4931. $data ['rdate'] = $rdate;
  4932. $data ['sopHtml'] = $sopHtml;
  4933. $data ['dayHtml'] = $dayHtml;
  4934. $data ['mothHtml'] = $mothHtml;
  4935. $data ['receiptList'] = $receiptList;
  4936. $data ['memu'] = "receipt";
  4937. $data ['staff'] = $this->staff;
  4938. $data ['receiptMemu'] = 'implement';
  4939. $data ['verifyId'] = $this->verifyId;
  4940. $data ['executeId'] = $this->executeId;
  4941. $data ['item'] = $item;
  4942. $data ['year'] = $year;
  4943. $data ['moth'] = $moth;
  4944. $data ['day'] = $day;
  4945. $data ['sop'] = $sop;
  4946. $this->render ( "/admin/hisImplement", $data );
  4947. }
  4948. /**
  4949. * 导出汇款信息的exelc
  4950. */
  4951. function exportRemittance() {
  4952. $remittanceInfo = $_POST ['remittanceInfo']; // $this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  4953. if (empty ( $remittanceInfo ))
  4954. die ( 'illegal request' );
  4955. $title = array (
  4956. '员工编号',
  4957. '姓名',
  4958. '员工账号',
  4959. '员工账户开户行',
  4960. '转账类型',
  4961. '联行号',
  4962. '金额'
  4963. );
  4964. $data = json_decode ( $remittanceInfo, true );
  4965. if (empty ( $data ))
  4966. die ( 'illegal request' );
  4967. Doo::loadClass ( 'receipt.func' );
  4968. exportExcel ( $title, $data, '批量日常报销-公司账号', './', true );
  4969. header ( 'Content-Type:text/html;charset=utf-8' );
  4970. die ( '导出' . count ( $data ) . '条数据,<a href="/hisImplement">返回</a>' );
  4971. }
  4972. function ajaxExamine() {
  4973. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4974. Doo::loadModel ( 'receipt' );
  4975. $receipt = new receipt ();
  4976. if (! empty ( $rid )) {
  4977. $rLRes = $receipt->find ( array (
  4978. '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,
  4979. 'asArray' => true
  4980. ) );
  4981. echo json_encode ( array (
  4982. 'status' => 1,
  4983. 'receipt' => $rLRes [0]
  4984. ) );
  4985. die ();
  4986. }
  4987. echo json_encode ( array (
  4988. 'status' => 0,
  4989. 'receipt' => array ()
  4990. ) );
  4991. die ();
  4992. }
  4993. /*
  4994. * 废弃
  4995. */
  4996. function myReceipt() {
  4997. // all approval past withdraw
  4998. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4999. if (empty ( $item ))
  5000. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  5001. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  5002. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  5003. Doo::loadModel ( 'receipt' );
  5004. $receipt = new receipt ();
  5005. // pre-loaded
  5006. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  5007. // have cache
  5008. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  5009. if (! empty ( $moth )) // yearPage
  5010. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  5011. $this->showCache ( $path );
  5012. }
  5013. Doo::loadModel ( 'L_category' );
  5014. $Lcategory = new L_category ();
  5015. Doo::loadModel ( 'verify' );
  5016. Doo::loadModel ( 'statistics' );
  5017. $statistics = new statistics ();
  5018. $verify = new verify ();
  5019. Doo::loadModel ( 'staff' );
  5020. $staff = new staff ();
  5021. $condition = " and status!=0 ";
  5022. if ($item == "approval")
  5023. $condition = " and status=2 ";
  5024. elseif ($item == "withdraw")
  5025. $condition = " and status=3 ";
  5026. elseif ($item == "past")
  5027. $condition = " and status=1 ";
  5028. elseif ($item == "whdw")
  5029. $condition = " and status=4 ";
  5030. $dateCondition = " and Year(date) =" . $year;
  5031. if (! empty ( $moth )) {
  5032. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  5033. $stList = $statistics->getOne ( array (
  5034. 'select' => 'rePrice ,agPrice',
  5035. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5036. 'asArray' => true
  5037. ) );
  5038. } else
  5039. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  5040. if (empty ( $stList ))
  5041. $stList = array (
  5042. 'rePrice' => 0,
  5043. 'agPrice' => 0
  5044. );
  5045. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  5046. $data ['stList'] = array (
  5047. 'rePrice' => $stList ['rePrice'],
  5048. 'agPrice' => $stList ['agPrice'],
  5049. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  5050. );
  5051. $receiptList = $receipt->find ( array (
  5052. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  5053. 'desc' => 'rid',
  5054. 'asArray' => true
  5055. ) );
  5056. $Locate = 0;
  5057. $roleId = 0;
  5058. $button = 0;
  5059. foreach ( $receiptList as $key => $value ) {
  5060. $receiptList [$key] ['Locate'] = $Locate;
  5061. $Locate ++;
  5062. $receiptList [$key] ['reviseDetail'] = array ();
  5063. if (! empty ( $value ['reviseDetail'] ))
  5064. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5065. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5066. $categoryDetil = $Lcategory->getOne ( array (
  5067. 'where' => 'cid=' . $value ['cid'],
  5068. 'asArray' => true
  5069. ) );
  5070. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5071. // 检测编辑状态
  5072. $verifyList = $verify->getOne ( array (
  5073. 'where' => 'vid=' . $value ['verify'],
  5074. 'asArray' => true
  5075. ) );
  5076. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5077. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5078. Doo::loadModel ( 'role' );
  5079. $role = new role ();
  5080. $flag = true;
  5081. $roleKey = 0;
  5082. $endStaffArray = array ();
  5083. $roleArrayCopy = array ();
  5084. foreach ( $verifyList as $k => $v ) {
  5085. // init verifyStaff
  5086. if ($v [1] == 'ROLE') {
  5087. if (! empty ( $verifyStaff )) {
  5088. $endStaffArray = end ( $verifyStaff );
  5089. // if ($v[0]==$endStaffArray['nextStaff']){
  5090. // $roleId=$v[0];
  5091. // }
  5092. }
  5093. $roleVerify = json_decode ( $v [3], true );
  5094. $roleKey = $k;
  5095. $roleArray = array ();
  5096. $rolename = $role->getOne ( array (
  5097. 'where' => 'rid=' . $v [0],
  5098. 'asArray' => true
  5099. ) );
  5100. foreach ( $roleVerify as $o => $p ) {
  5101. $staffID = explode ( '_', $p );
  5102. $staffInfo = $staff->getOne ( array (
  5103. 'where' => 'sid=' . $staffID [0],
  5104. 'asArray' => true
  5105. ) );
  5106. // print_r($staffID);
  5107. $exp = array (
  5108. 0 => $staffInfo ['sid'],
  5109. 1 => $staffID [1],
  5110. 2 => $staffInfo ['avatar'],
  5111. 'date' => '',
  5112. 'date' => '',
  5113. 'opinion' => '',
  5114. 'status' => '',
  5115. 'rolename' => $rolename ['name']
  5116. );
  5117. array_push ( $roleArray, $exp );
  5118. }
  5119. $roleArrayCopy [$v [0]] = $roleArray;
  5120. // $verifyList[$k]['roleArray']=$roleArray;
  5121. }
  5122. $verifyList [$k] ['date'] = "";
  5123. $verifyList [$k] ['opinion'] = "";
  5124. $verifyList [$k] ['status'] = "";
  5125. if (empty ( $verifyStaff )) {
  5126. $verifyList [$k] ['date'] = "";
  5127. $verifyList [$k] ['opinion'] = "";
  5128. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5129. $verifyList [$k] ['status'] = 4;
  5130. $flag = false;
  5131. }
  5132. } else {
  5133. foreach ( $verifyStaff as $m => $u ) {
  5134. if ($v [0] == $m) {
  5135. $verifyList [$k] ['date'] = $u ['date'];
  5136. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5137. $verifyList [$k] ['status'] = $u ['status'];
  5138. $flag = false;
  5139. break;
  5140. }
  5141. }
  5142. $endStaffArray = end ( $verifyStaff );
  5143. if (isset ( $endStaffArray ['ROLE'] )) {
  5144. } else {
  5145. // $endKey=key($verifyStaff);
  5146. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5147. // $button=4;
  5148. // $verifyList[$k]['status']=4;
  5149. // }
  5150. }
  5151. }
  5152. }
  5153. $rolename ['name'] = '';
  5154. if (! empty ( $roleId )) {
  5155. Doo::loadModel ( 'role' );
  5156. $role = new role ();
  5157. $rolename = $role->getOne ( array (
  5158. 'where' => 'rid=' . $roleId,
  5159. 'asArray' => true
  5160. ) );
  5161. }
  5162. if (! empty ( $verifyStaff ))
  5163. $endStaffArray = end ( $verifyStaff );
  5164. $KOP = false;
  5165. foreach ( $roleArrayCopy as $P => $A ) {
  5166. foreach ( $A as $MKI => $AVL ) {
  5167. if (! empty ( $verifyStaff )) {
  5168. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5169. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5170. $button = 4;
  5171. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5172. }
  5173. foreach ( $verifyStaff as $m => $u ) {
  5174. $AVLFK = $AVL [0] . '_R';
  5175. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5176. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5177. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5178. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5179. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5180. break;
  5181. }
  5182. }
  5183. } else {
  5184. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5185. $button = 4;
  5186. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5187. }
  5188. }
  5189. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5190. $KOP = true;
  5191. }
  5192. }
  5193. foreach ( $roleArrayCopy as $k => $v ) {
  5194. foreach ( $verifyList as $m => $n ) {
  5195. if ($n [0] == $k) {
  5196. array_splice ( $verifyList, $m, 1, $v );
  5197. }
  5198. }
  5199. }
  5200. $receiptList [$key] ['verifyList'] = $verifyList;
  5201. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5202. 'where' => 'sid=' . $value ['staff'],
  5203. 'asArray' => true
  5204. ) );
  5205. $receiptList [$key] ['button'] = $button;
  5206. }
  5207. // print_r($receiptList);die;
  5208. $mothHtml = "";
  5209. for($i = 1; $i <= 12; $i ++) {
  5210. if ($moth == $i)
  5211. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5212. else
  5213. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5214. }
  5215. $data ['mothHtml'] = $mothHtml;
  5216. $data ['receiptList'] = $receiptList;
  5217. $data ['memu'] = "receipt";
  5218. $data ['staff'] = $this->staff;
  5219. $data ['receiptMemu'] = 'receipt';
  5220. $data ['verifyId'] = $this->verifyId;
  5221. $data ['executeId'] = $this->executeId;
  5222. $data ['item'] = $item;
  5223. $data ['year'] = $year;
  5224. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  5225. // sufficient condition to generate cache
  5226. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  5227. $receiptList = $receipt->find ( array (
  5228. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  5229. 'asArray' => true
  5230. ) );
  5231. if (empty ( $receiptList )) { // generated files
  5232. ob_start ();
  5233. $this->render ( "/admin/saea_myList", $data );
  5234. $this->cacheFile ( $path );
  5235. die ();
  5236. // $content = ob_get_contents();
  5237. // $fp = fopen($path, "w");
  5238. // fwrite($fp, $content);
  5239. // fclose($fp);
  5240. }
  5241. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  5242. $receiptList = $receipt->find ( array (
  5243. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  5244. 'asArray' => true
  5245. ) );
  5246. if (empty ( $receiptList )) { // generated files
  5247. ob_start ();
  5248. $this->render ( "/admin/saea_myList", $data );
  5249. $this->cacheFile ( $path );
  5250. die ();
  5251. }
  5252. }
  5253. }
  5254. $this->render ( "/admin/saea_myList", $data );
  5255. }
  5256. function saeaCreate() {
  5257. Doo::loadModel ( 'accountItem' );
  5258. Doo::loadModel ( 'verify' );
  5259. Doo::loadModel ( 'receipt' );
  5260. Doo::loadModel ( 'L_category' );
  5261. $lCategory = new L_category ();
  5262. $receipt = new receipt ();
  5263. $verify = new verify ();
  5264. $accountItem = new accountItem ();
  5265. Doo::loadModel ( "role" );
  5266. $role = new role ();
  5267. $acItem = $accountItem->find ( array (
  5268. 'asArray' => true
  5269. ) );
  5270. $veList = $verify->find ( array (
  5271. 'asArray' => true
  5272. ) );
  5273. foreach ( $veList as $key => $value ) {
  5274. $v = json_decode ( $value ['staff'] );
  5275. $list = array ();
  5276. foreach ( $v as $n => $m ) {
  5277. if ($m ['1'] == 'ROLE') {
  5278. $roleInfo = $role->getOne ( array (
  5279. 'where' => 'rid=' . $m [0],
  5280. 'asArray' => true
  5281. ) );
  5282. $v [$n] [1] = $roleInfo ['name'];
  5283. array_push ( $list, $roleInfo ['name'] );
  5284. } else {
  5285. array_push ( $list, $v [$n] [1] );
  5286. }
  5287. }
  5288. $veList [$key] ['staff'] = implode ( '>', $list );
  5289. }
  5290. $data ['category'] = $lCategory->find ( array (
  5291. 'asArray' => true
  5292. ) );
  5293. $data ['veList'] = $veList;
  5294. $data ['acItem'] = $acItem;
  5295. $data ['memu'] = "receipt";
  5296. $data ['staff'] = $this->staff;
  5297. $data ['receiptMemu'] = 'saeaBorad';
  5298. $data ['verifyId'] = $this->verifyId;
  5299. $data ['executeId'] = $this->executeId;
  5300. $this->render ( "/admin/saea_create", $data );
  5301. }
  5302. function addReceipt() {
  5303. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  5304. $agency = $this->get_args ( 'agency' );
  5305. $travel = $this->get_args ( 'travel' );
  5306. $train = $this->get_args ( 'train' );
  5307. $other = $this->get_args ( 'other' );
  5308. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5309. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5310. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5311. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  5312. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  5313. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  5314. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  5315. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  5316. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  5317. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  5318. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  5319. header ( 'Content-Type:text/html;charset=utf-8' );
  5320. die ( '请填写联行号' );
  5321. }
  5322. Doo::loadModel ( 'receipt' );
  5323. Doo::loadModel ( 'receiptDetail' );
  5324. Doo::loadModel ( 'accountItem' );
  5325. $accountItem = new accountItem ();
  5326. $receipt = new receipt ();
  5327. Doo::loadModel ( 'enclosur' );
  5328. Doo::loadModel ( 'execute' );
  5329. $execute = new execute ();
  5330. $executeDetail = $execute->getOne ( array (
  5331. 'where' => 'mold="报销单执行人"',
  5332. 'asArray' => true
  5333. ) );
  5334. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  5335. // if(!empty($receiptDetail))
  5336. // return "/referReceipt/".$receiptDetail['rid'];
  5337. $aItem = $accountItem->find ( array (
  5338. 'asArray' => true
  5339. ) );
  5340. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5341. $ag = $tr = $ta = $ot = 0;
  5342. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5343. foreach ( $aItem as $key => $value ) {
  5344. if ($value ['category'] == $this->AGENCY) {
  5345. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5346. array_push ( $accountJson [$this->AGENCY], array (
  5347. 'aid' => $value ['aid'],
  5348. 'name' => $value ['name'],
  5349. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5350. ) );
  5351. $sum += $agency [$ag];
  5352. $agencySum += $agency [$ag];
  5353. }
  5354. $ag ++;
  5355. }
  5356. if ($value ['category'] == $this->TRAVEL) {
  5357. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5358. array_push ( $accountJson [$this->TRAVEL], array (
  5359. 'aid' => $value ['aid'],
  5360. 'name' => $value ['name'],
  5361. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5362. ) );
  5363. $sum += $travel [$tr];
  5364. $travelSum += $travel [$tr];
  5365. }
  5366. $tr ++;
  5367. }
  5368. if ($value ['category'] == $this->TRAIN) {
  5369. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5370. array_push ( $accountJson [$this->TRAIN], array (
  5371. 'aid' => $value ['aid'],
  5372. 'name' => $value ['name'],
  5373. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5374. ) );
  5375. $sum += $train [$ta];
  5376. $trainSum += $train [$ta];
  5377. }
  5378. $ta ++;
  5379. }
  5380. if ($value ['category'] == $this->OTHER) {
  5381. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5382. array_push ( $accountJson [$this->OTHER], array (
  5383. 'aid' => $value ['aid'],
  5384. 'name' => $value ['name'],
  5385. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5386. ) );
  5387. $sum += $other [$ot];
  5388. $otherSum += $other [$ot];
  5389. }
  5390. $ot ++;
  5391. }
  5392. }
  5393. $accountJson ['cSum'] = array (
  5394. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5395. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5396. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5397. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5398. );
  5399. // 报销单
  5400. $receipt->accountItem = json_encode ( $accountJson );
  5401. $receipt->staff = $this->staff [0] ['sid'];
  5402. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5403. $receipt->date = date ( "Y-m-d" );
  5404. $receipt->cid = $cid;
  5405. $receipt->status = 5;
  5406. // 修改审批流程加入角色
  5407. $receipt->verify = $verify;
  5408. $receipt->executeCopy = $executeDetail ['staff'];
  5409. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  5410. $order = array (
  5411. "\r\n",
  5412. "\n",
  5413. "\r"
  5414. );
  5415. $replace = '<br/>';
  5416. $explanation = str_replace ( $order, $replace, $explanation );
  5417. $receipt->explanation = $explanation;
  5418. $receipt->remittanceName = $remittanceName;
  5419. $receipt->bankName = $bankName;
  5420. $receipt->bankNumber = $bankNumber;
  5421. $receipt->remittanceBankType = $remittanceBankType;
  5422. if ($remittanceBankType == 1)
  5423. $receipt->coupletNumber = $coupletNumber;
  5424. $rid = $receipt->insert ();
  5425. // 附件
  5426. if (! empty ( $enclosurName )) {
  5427. $enclosurArray = explode ( '-', $enclosurName );
  5428. foreach ( $enclosurArray as $value ) {
  5429. $enclosur = new enclosur ();
  5430. $enclosur->name = $value;
  5431. $enclosur->rid = $rid;
  5432. $enclosur->insert ();
  5433. }
  5434. // print_r($enclosurArray);die;
  5435. }
  5436. // 报销详情
  5437. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5438. $receiptDetail = new receiptDetail ();
  5439. $receiptDetail->staff = $this->staff [0] ['sid'];
  5440. $receiptDetail->item = $value ['name'];
  5441. $receiptDetail->itemCategory = $this->AGENCY;
  5442. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5443. $receiptDetail->date = date ( "Y-m-d" );
  5444. $receiptDetail->cid = $cid;
  5445. $receiptDetail->rid = $rid;
  5446. $receiptDetail->status = 4;
  5447. $receiptDetail->insert ();
  5448. }
  5449. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5450. $receiptDetail = new receiptDetail ();
  5451. $receiptDetail->staff = $this->staff [0] ['sid'];
  5452. $receiptDetail->item = $value ['name'];
  5453. $receiptDetail->itemCategory = $this->TRAVEL;
  5454. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5455. $receiptDetail->date = date ( "Y-m-d" );
  5456. $receiptDetail->cid = $cid;
  5457. $receiptDetail->rid = $rid;
  5458. $receiptDetail->status = 4;
  5459. $receiptDetail->insert ();
  5460. }
  5461. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5462. $receiptDetail = new receiptDetail ();
  5463. $receiptDetail->staff = $this->staff [0] ['sid'];
  5464. $receiptDetail->item = $value ['name'];
  5465. $receiptDetail->itemCategory = $this->TRAIN;
  5466. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5467. $receiptDetail->date = date ( "Y-m-d" );
  5468. $receiptDetail->cid = $cid;
  5469. $receiptDetail->rid = $rid;
  5470. $receiptDetail->status = 4;
  5471. $receiptDetail->insert ();
  5472. }
  5473. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5474. $receiptDetail = new receiptDetail ();
  5475. $receiptDetail->staff = $this->staff [0] ['sid'];
  5476. $receiptDetail->item = $value ['name'];
  5477. $receiptDetail->itemCategory = $this->OTHER;
  5478. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5479. $receiptDetail->date = date ( "Y-m-d" );
  5480. $receiptDetail->cid = $cid;
  5481. $receiptDetail->rid = $rid;
  5482. $receiptDetail->status = 4;
  5483. $receiptDetail->insert ();
  5484. }
  5485. return "/saeaBorad";
  5486. } else
  5487. die ( 'illegal request' );
  5488. }
  5489. function referReceipt() {
  5490. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  5491. Doo::loadModel ( 'receipt' );
  5492. Doo::loadModel ( 'verify' );
  5493. $verify = new verify ();
  5494. $receipt = new receipt ();
  5495. Doo::loadModel ( 'L_category' );
  5496. $lCategory = new L_category ();
  5497. Doo::loadModel ( "role" );
  5498. $role = new role ();
  5499. $receiptDetail = $receipt->find ( array (
  5500. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  5501. 'asArray' => true
  5502. ) );
  5503. if (empty ( $receiptDetail ))
  5504. return "/addReceipt";
  5505. foreach ( $receiptDetail as $key => $value ) {
  5506. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5507. $veList = $verify->getOne ( array (
  5508. 'where' => 'vid=' . $value ['verify'],
  5509. 'asArray' => true
  5510. ) );
  5511. $v = json_decode ( $veList ['staff'] );
  5512. array_push ( $v [0], $veList ['description'] );
  5513. foreach ( $v as $n => $m ) {
  5514. if ($m ['1'] == 'ROLE') {
  5515. $roleInfo = $role->getOne ( array (
  5516. 'where' => 'rid=' . $m [0],
  5517. 'asArray' => true
  5518. ) );
  5519. $v [$n] [1] = $roleInfo ['name'];
  5520. }
  5521. }
  5522. $receiptDetail [$key] ['staff'] = $v;
  5523. $category = $lCategory->getOne ( array (
  5524. 'where' => 'cid=' . $value ['cid'],
  5525. 'asArray' => true
  5526. ) );
  5527. $receiptDetail [$key] ['category'] = $category ['title'];
  5528. }
  5529. // print_r($receiptDetail);
  5530. $data ['receiptDetail'] = $receiptDetail;
  5531. $data ['memu'] = "receipt";
  5532. $data ['staff'] = $this->staff;
  5533. $data ['receiptMemu'] = 'saeaCreate';
  5534. $data ['verifyId'] = $this->verifyId;
  5535. $data ['executeId'] = $this->executeId;
  5536. $this->render ( "/admin/saea_confirm", $data );
  5537. }
  5538. function editReceipt() {
  5539. // edit status 4
  5540. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  5541. Doo::loadClass ( 'XDeode' );
  5542. $XDeode = new XDeode ( 7 );
  5543. $rid = $XDeode->decode ( $ridKey );
  5544. if (empty ( $rid ))
  5545. die ( 'illegal request' );
  5546. // echo $rid.'sd';
  5547. Doo::loadModel ( 'accountItem' );
  5548. Doo::loadModel ( 'verify' );
  5549. Doo::loadModel ( 'receipt' );
  5550. $receipt = new receipt ();
  5551. $verify = new verify ();
  5552. $accountItem = new accountItem ();
  5553. Doo::loadModel ( 'L_category' );
  5554. $lCategory = new L_category ();
  5555. Doo::loadModel ( "role" );
  5556. $role = new role ();
  5557. Doo::loadModel ( 'enclosur' );
  5558. $enclosur = new enclosur ();
  5559. $receiptDetail = $receipt->getOne ( array (
  5560. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  5561. 'asArray' => true
  5562. ) );
  5563. if (empty ( $receiptDetail ))
  5564. die ( 'illegal request' );
  5565. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  5566. $acItem = $accountItem->find ( array (
  5567. 'asArray' => true
  5568. ) );
  5569. $veList = $verify->find ( array (
  5570. 'asArray' => true
  5571. ) );
  5572. foreach ( $veList as $key => $value ) {
  5573. $v = json_decode ( $value ['staff'] );
  5574. $list = array ();
  5575. foreach ( $v as $n => $m ) {
  5576. if ($m ['1'] == 'ROLE') {
  5577. $roleInfo = $role->getOne ( array (
  5578. 'where' => 'rid=' . $m [0],
  5579. 'asArray' => true
  5580. ) );
  5581. $v [$n] [1] = $roleInfo ['name'];
  5582. array_push ( $list, $roleInfo ['name'] );
  5583. } else {
  5584. array_push ( $list, $v [$n] [1] );
  5585. }
  5586. }
  5587. $veList [$key] ['staff'] = implode ( '>', $list );
  5588. }
  5589. // 配置编辑信息
  5590. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  5591. foreach ( $acItem as $key => $value ) {
  5592. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  5593. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  5594. $acItem [$key] ['price'] = $v ['price'];
  5595. }
  5596. }
  5597. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  5598. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  5599. $acItem [$key] ['price'] = $v ['price'];
  5600. }
  5601. }
  5602. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  5603. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  5604. $acItem [$key] ['price'] = $v ['price'];
  5605. }
  5606. }
  5607. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  5608. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  5609. $acItem [$key] ['price'] = $v ['price'];
  5610. }
  5611. }
  5612. }
  5613. $data ['category'] = $lCategory->find ( array (
  5614. 'asArray' => true
  5615. ) );
  5616. $data ['cSum'] = $accountItemList ['cSum'];
  5617. $data ['sum'] = $receiptDetail ['sum'];
  5618. $data ['enclosurList'] = $enclosurList;
  5619. $data ['receiptDetail'] = $receiptDetail;
  5620. $data ['veList'] = $veList;
  5621. $data ['acItem'] = $acItem;
  5622. $data ['memu'] = "receipt";
  5623. $data ['staff'] = $this->staff;
  5624. $data ['receiptMemu'] = 'saeaBorad';
  5625. $data ['verify'] = $receiptDetail ['verify'];
  5626. $data ['verifyId'] = $this->verifyId;
  5627. $data ['executeId'] = $this->executeId;
  5628. $data ['rid'] = $ridKey;
  5629. $this->render ( "/admin/saea_edit", $data );
  5630. }
  5631. function updateReceipt() {
  5632. $agency = $this->get_args ( 'agency' );
  5633. $travel = $this->get_args ( 'travel' );
  5634. $train = $this->get_args ( 'train' );
  5635. $other = $this->get_args ( 'other' );
  5636. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5637. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5638. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5639. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  5640. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  5641. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  5642. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  5643. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  5644. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  5645. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  5646. Doo::loadClass ( 'XDeode' );
  5647. $XDeode = new XDeode ( 7 );
  5648. $rid = $XDeode->decode ( $ridKey );
  5649. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  5650. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  5651. header ( 'Content-Type:text/html;charset=utf-8' );
  5652. die ( '请填写联行号' );
  5653. }
  5654. Doo::loadModel ( 'receipt' );
  5655. Doo::loadModel ( 'receiptDetail' );
  5656. Doo::loadModel ( 'accountItem' );
  5657. $accountItem = new accountItem ();
  5658. $receipt = new receipt ();
  5659. Doo::loadModel ( 'enclosur' );
  5660. Doo::loadModel ( 'execute' );
  5661. $execute = new execute ();
  5662. $receiptDetail = $receipt->getOne ( array (
  5663. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  5664. 'asArray' => true
  5665. ) );
  5666. if (empty ( $receiptDetail ))
  5667. return "/saeaBorad";
  5668. if ($receiptDetail ['Rtype'] == 1)
  5669. $executeDetail = $execute->getOne ( array (
  5670. 'where' => 'mold="借款费用执行人"',
  5671. 'asArray' => true
  5672. ) );
  5673. else
  5674. $executeDetail = $execute->getOne ( array (
  5675. 'where' => 'mold="报销单执行人"',
  5676. 'asArray' => true
  5677. ) );
  5678. $aItem = $accountItem->find ( array (
  5679. 'asArray' => true
  5680. ) );
  5681. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5682. $ag = $tr = $ta = $ot = 0;
  5683. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5684. foreach ( $aItem as $key => $value ) {
  5685. if ($value ['category'] == $this->AGENCY) {
  5686. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5687. array_push ( $accountJson [$this->AGENCY], array (
  5688. 'aid' => $value ['aid'],
  5689. 'name' => $value ['name'],
  5690. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5691. ) );
  5692. $sum += $agency [$ag];
  5693. $agencySum += $agency [$ag];
  5694. }
  5695. $ag ++;
  5696. }
  5697. if ($value ['category'] == $this->TRAVEL) {
  5698. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5699. array_push ( $accountJson [$this->TRAVEL], array (
  5700. 'aid' => $value ['aid'],
  5701. 'name' => $value ['name'],
  5702. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5703. ) );
  5704. $sum += $travel [$tr];
  5705. $travelSum += $travel [$tr];
  5706. }
  5707. $tr ++;
  5708. }
  5709. if ($value ['category'] == $this->TRAIN) {
  5710. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5711. array_push ( $accountJson [$this->TRAIN], array (
  5712. 'aid' => $value ['aid'],
  5713. 'name' => $value ['name'],
  5714. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5715. ) );
  5716. $sum += $train [$ta];
  5717. $trainSum += $train [$ta];
  5718. }
  5719. $ta ++;
  5720. }
  5721. if ($value ['category'] == $this->OTHER) {
  5722. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5723. array_push ( $accountJson [$this->OTHER], array (
  5724. 'aid' => $value ['aid'],
  5725. 'name' => $value ['name'],
  5726. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5727. ) );
  5728. $sum += $other [$ot];
  5729. $otherSum += $other [$ot];
  5730. }
  5731. $ot ++;
  5732. }
  5733. }
  5734. $accountJson ['cSum'] = array (
  5735. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5736. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5737. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5738. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5739. );
  5740. // 报销单
  5741. $rid = $receipt->rid = $receiptDetail ['rid'];
  5742. $receipt->accountItem = json_encode ( $accountJson );
  5743. $receipt->staff = $this->staff [0] ['sid'];
  5744. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5745. $receipt->date = date ( "Y-m-d" );
  5746. $receipt->cid = $cid;
  5747. if (($receiptDetail ['status'] != 4)) {
  5748. if ($receiptDetail ['Rtype'] == 1)
  5749. $receipt->status = 7;
  5750. else
  5751. $receipt->status = 5;
  5752. }
  5753. if ($receiptDetail != 4 && ! empty ( $verify ))
  5754. $receipt->verify = $verify;
  5755. $receipt->executeCopy = $executeDetail ['staff'];
  5756. $order = array (
  5757. "\r\n",
  5758. "\n",
  5759. "\r"
  5760. );
  5761. $replace = '<br/>';
  5762. $explanation = str_replace ( $order, $replace, $explanation );
  5763. $receipt->explanation = $explanation;
  5764. $receipt->remittanceName = $remittanceName;
  5765. $receipt->bankName = $bankName;
  5766. $receipt->bankNumber = $bankNumber;
  5767. $receipt->remittanceBankType = $remittanceBankType;
  5768. if ($remittanceBankType == 1)
  5769. $receipt->coupletNumber = $coupletNumber;
  5770. $receipt->update ();
  5771. $receiptDetail = new receiptDetail ();
  5772. $receiptDetail->delete ( array (
  5773. 'where' => 'rid=' . $rid
  5774. ) );
  5775. // 报销详情
  5776. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5777. $receiptDetail = new receiptDetail ();
  5778. $receiptDetail->staff = $this->staff [0] ['sid'];
  5779. $receiptDetail->item = $value ['name'];
  5780. $receiptDetail->itemCategory = $this->AGENCY;
  5781. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5782. $receiptDetail->date = date ( "Y-m-d" );
  5783. $receiptDetail->cid = $cid;
  5784. $receiptDetail->rid = $rid;
  5785. $receiptDetail->status = 4;
  5786. $receiptDetail->insert ();
  5787. }
  5788. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5789. $receiptDetail = new receiptDetail ();
  5790. $receiptDetail->staff = $this->staff [0] ['sid'];
  5791. $receiptDetail->item = $value ['name'];
  5792. $receiptDetail->itemCategory = $this->TRAVEL;
  5793. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5794. $receiptDetail->date = date ( "Y-m-d" );
  5795. $receiptDetail->cid = $cid;
  5796. $receiptDetail->rid = $rid;
  5797. $receiptDetail->status = 4;
  5798. $receiptDetail->insert ();
  5799. }
  5800. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5801. $receiptDetail = new receiptDetail ();
  5802. $receiptDetail->staff = $this->staff [0] ['sid'];
  5803. $receiptDetail->item = $value ['name'];
  5804. $receiptDetail->itemCategory = $this->TRAIN;
  5805. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5806. $receiptDetail->date = date ( "Y-m-d" );
  5807. $receiptDetail->cid = $cid;
  5808. $receiptDetail->rid = $rid;
  5809. $receiptDetail->status = 4;
  5810. $receiptDetail->insert ();
  5811. }
  5812. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5813. $receiptDetail = new receiptDetail ();
  5814. $receiptDetail->staff = $this->staff [0] ['sid'];
  5815. $receiptDetail->item = $value ['name'];
  5816. $receiptDetail->itemCategory = $this->OTHER;
  5817. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5818. $receiptDetail->date = date ( "Y-m-d" );
  5819. $receiptDetail->cid = $cid;
  5820. $receiptDetail->rid = $rid;
  5821. $receiptDetail->status = 4;
  5822. $receiptDetail->insert ();
  5823. }
  5824. // 附件
  5825. if (! empty ( $enclosurName )) {
  5826. $enclosurArray = explode ( '-', $enclosurName );
  5827. foreach ( $enclosurArray as $value ) {
  5828. $enclosur = new enclosur ();
  5829. $enclosur->name = $value;
  5830. $enclosur->rid = $rid;
  5831. $enclosur->insert ();
  5832. }
  5833. }
  5834. // return "/referReceipt/".$rid;
  5835. }
  5836. return "/saeaBorad";
  5837. }
  5838. function approvedReceipt() {
  5839. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5840. Doo::loadModel ( 'receipt' );
  5841. Doo::loadModel ( 'receiptDetail' );
  5842. $receipt = new receipt ();
  5843. $receiptDetail = new receiptDetail ();
  5844. Doo::loadModel ( 'statistics' );
  5845. Doo::loadModel ( 'itemStatistics' );
  5846. $statistics = new statistics ();
  5847. $itemStatistics = new itemStatistics ();
  5848. Doo::loadModel ( "verify" );
  5849. $verify = new verify ();
  5850. // 审批状态的判定
  5851. $receiptDetailList = $receipt->getOne ( array (
  5852. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  5853. 'asArray' => true
  5854. ) );
  5855. if (empty ( $receiptDetailList ))
  5856. return "/saeaBorad";
  5857. $verifyDetail = $verify->getOne ( array (
  5858. 'where' => ' vid =' . $receiptDetailList ['verify'],
  5859. 'asArray' => true
  5860. ) );
  5861. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5862. if (empty ( $receiptDetailList ['nowStaff'] )) {
  5863. $nowStaff = "";
  5864. $nowStaffList = array ();
  5865. if ($verifyDetail [0] [1] == 'ROLE') {
  5866. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5867. foreach ( $vStaffString as $key => $value ) {
  5868. $staffK = explode ( "_", $value );
  5869. array_push ( $nowStaffList, $staffK [0] );
  5870. }
  5871. $nowStaff = implode ( ',', $nowStaffList );
  5872. } else {
  5873. $nowStaff = $verifyDetail [0] [0];
  5874. }
  5875. $receipt->nowStaff = $nowStaff;
  5876. }
  5877. // echo $nowStaff;
  5878. // print_r($verifyDetail);die;
  5879. $receipt->rid = $receiptDetailList ['rid'];
  5880. $receipt->date = date ( "Y-m-d" );
  5881. $receipt->status = 2;
  5882. $receipt->update ();
  5883. $receiptDetail->status = 2;
  5884. $receiptDetail->update ( array (
  5885. 'where' => 'rid=' . $receiptDetailList ['rid']
  5886. ) );
  5887. Doo::loadModel ( "receiptLog" );
  5888. $receiptLog = new receiptLog ();
  5889. Doo::loadModel ( "verify" );
  5890. $verify = new verify ();
  5891. $receiptInfo = $receipt->getOne ( array (
  5892. 'where' => 'rid=' . $rid,
  5893. 'asArray' => true
  5894. ) );
  5895. $vr = $verify->getOne ( array (
  5896. 'where' => 'vid=' . $receiptInfo ['verify'],
  5897. 'asArray' => true
  5898. ) );
  5899. $jd = json_decode ( $vr ['staff'] );
  5900. $roleId = 0;
  5901. foreach ( $jd as $key => $value ) {
  5902. if ($value [1] == 'ROLE') {
  5903. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  5904. if ($pos !== false) {
  5905. $roleId = $value [0];
  5906. }
  5907. }
  5908. }
  5909. // 审批日志
  5910. // echo $roleId;die;
  5911. if (! empty ( $roleId )) {
  5912. Doo::loadModel ( "role" );
  5913. $role = new role ();
  5914. $roleInfo = $role->getOne ( array (
  5915. 'where' => 'rid=' . $roleId,
  5916. 'asArray' => true
  5917. ) );
  5918. // $receiptLog->rolename = $roleInfo ['name'];
  5919. }
  5920. $receiptLog->username = $this->staff [0] ['username'];
  5921. $receiptLog->uid = $this->staff [0] ['sid'];
  5922. $receiptLog->date = date ( "Y-m-d" );
  5923. $receiptLog->opinion = '提交审批';
  5924. $receiptLog->img = $this->staff [0] ['avatar'];
  5925. $receiptLog->status = 2;
  5926. $receiptLog->rid = $rid;
  5927. $receiptLog->insert ();
  5928. // statistics item
  5929. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  5930. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  5931. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  5932. $stat = $statistics->getOne ( array (
  5933. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5934. 'asArray' => true
  5935. ) );
  5936. if (empty ( $stat )) {
  5937. $statistics->date = date ( "Y-m-d" );
  5938. $statistics->cid = $this->staff [0] ['cid'];
  5939. $statistics->staff = $this->staff [0] ['sid'];
  5940. $statistics->agPrice = 0;
  5941. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5942. $statistics->insert ();
  5943. } else {
  5944. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5945. $statistics->update ( array (
  5946. 'where' => 'sid=' . $stat ['sid']
  5947. ) );
  5948. }
  5949. return "/expenses";
  5950. }
  5951. function approval() {
  5952. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5953. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5954. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5955. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5956. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5957. if (empty ( $status ))
  5958. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5959. $vidList = array ();
  5960. $button = 0;
  5961. Doo::loadModel ( 'verify' );
  5962. $verify = new verify ();
  5963. Doo::loadModel ( 'receipt' );
  5964. $receipt = new receipt ();
  5965. Doo::loadModel ( 'staff' );
  5966. $staff = new staff ();
  5967. Doo::loadModel ( 'L_category' );
  5968. $Lcategory = new L_category ();
  5969. // user verify ID
  5970. $verifyDetail = $verify->find ( array (
  5971. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5972. 'asArray' => true
  5973. ) );
  5974. foreach ( $verifyDetail as $key => $value ) {
  5975. array_push ( $vidList, $value ['vid'] );
  5976. }
  5977. $vid = implode ( ",", $vidList );
  5978. if (empty ( $verifyDetail ))
  5979. $vid = 0;
  5980. /*
  5981. */
  5982. $dateCondition = " and Year(date) =" . $year;
  5983. if (! empty ( $month ))
  5984. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  5985. $categoryList = $Lcategory->find ( array (
  5986. 'asArray' => true
  5987. ) );
  5988. $staffList = $staff->find ( array (
  5989. 'where' => 'cid=' . $cid,
  5990. 'asArray' => true
  5991. ) );
  5992. $cateCondition = "";
  5993. $staffCondition = "";
  5994. $approvalCondition = "";
  5995. if (! empty ( $cid ))
  5996. $cateCondition = ' and cid=' . $cid;
  5997. if (! empty ( $sid )) {
  5998. $staffCondition = ' and staff=' . $sid;
  5999. $cateCondition = "";
  6000. }
  6001. // elseif($status==1){
  6002. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  6003. // }
  6004. if ($status == 2) {
  6005. // 查找角色审批人
  6006. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  6007. }
  6008. $ap = "";
  6009. if ($status == 4) {
  6010. $ap = 4;
  6011. $status = 2;
  6012. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  6013. }
  6014. if ($status == 5) {
  6015. $status = 4;
  6016. $ap = 5;
  6017. }
  6018. // echo $vid;
  6019. // get Receipt By verifyID status 2 .$approvalCondition
  6020. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  6021. $receiptList = $receipt->find ( array (
  6022. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  6023. 'desc' => 'rid',
  6024. 'asArray' => true
  6025. ) );
  6026. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  6027. $Locate = 0;
  6028. if ($ap == 4)
  6029. $status = 4;
  6030. elseif ($ap == 5)
  6031. $status = 5;
  6032. foreach ( $receiptList as $key => $value ) {
  6033. $receiptList [$key] ['Locate'] = $Locate;
  6034. $Locate ++;
  6035. $receiptList [$key] ['reviseDetail'] = array ();
  6036. if (! empty ( $value ['reviseDetail'] ))
  6037. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6038. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6039. $categoryDetil = $Lcategory->getOne ( array (
  6040. 'where' => 'cid=' . $value ['cid'],
  6041. 'asArray' => true
  6042. ) );
  6043. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6044. $verifyList = $verify->getOne ( array (
  6045. 'where' => 'vid=' . $value ['verify'],
  6046. 'asArray' => true
  6047. ) );
  6048. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6049. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6050. foreach ( $verifyList as $k => $v ) {
  6051. // init verifyStaff
  6052. $verifyList [$k] ['date'] = "";
  6053. $verifyList [$k] ['opinion'] = "";
  6054. $verifyList [$k] ['status'] = "";
  6055. if (empty ( $verifyStaff )) {
  6056. $verifyList [$k] ['date'] = "";
  6057. $verifyList [$k] ['opinion'] = "";
  6058. if ($v [0] == $this->staff [0] ['sid']) {
  6059. $verifyList [$k] ['status'] = 4;
  6060. $button = 4;
  6061. }
  6062. } else {
  6063. $flag = true;
  6064. foreach ( $verifyStaff as $m => $u ) {
  6065. if ($v [0] == $m) {
  6066. $verifyList [$k] ['date'] = $u ['date'];
  6067. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6068. $verifyList [$k] ['status'] = $u ['status'];
  6069. $flag = false;
  6070. break;
  6071. }
  6072. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  6073. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  6074. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  6075. }
  6076. if ($flag) { // 检测可编辑
  6077. if ($v [0] == $this->staff [0] ['sid']) {
  6078. $verifyList [$k] ['status'] = 4;
  6079. $button = 4;
  6080. }
  6081. }
  6082. }
  6083. }
  6084. $receiptList [$key] ['verifyList'] = $verifyList;
  6085. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6086. 'where' => 'sid=' . $value ['staff'],
  6087. 'asArray' => true
  6088. ) );
  6089. $receiptList [$key] ['button'] = $button;
  6090. }
  6091. // print_r($receiptList);die;
  6092. // $data['verifyDetail']=$verifyDetail;
  6093. $mothHtml = "";
  6094. for($i = 1; $i <= 12; $i ++) {
  6095. if ($month == $i)
  6096. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6097. else
  6098. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6099. }
  6100. $data ['mothHtml'] = $mothHtml;
  6101. $data ['receiptList'] = $receiptList;
  6102. $data ['receiptApprovalCount'] = count ( $receiptList );
  6103. $data ['status'] = $status;
  6104. $data ['year'] = $year;
  6105. $data ['categoryList'] = $categoryList;
  6106. $data ['staffList'] = $staffList;
  6107. $data ['cid'] = $cid;
  6108. $data ['sid'] = $sid;
  6109. $data ['ap'] = $ap;
  6110. $data ['memu'] = "receipt";
  6111. $data ['staff'] = $this->staff;
  6112. $data ['receiptMemu'] = 'approval';
  6113. $data ['verifyId'] = $this->verifyId;
  6114. $data ['executeId'] = $this->executeId;
  6115. $this->render ( "/admin/saea_reportList", $data );
  6116. }
  6117. function approvalDetails() {
  6118. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6119. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6120. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6121. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6122. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6123. Doo::loadModel ( 'verify' );
  6124. $verify = new verify ();
  6125. Doo::loadModel ( 'receipt' );
  6126. $receipt = new receipt ();
  6127. Doo::loadModel ( 'staff' );
  6128. $staff = new staff ();
  6129. Doo::loadModel ( 'L_category' );
  6130. $Lcategory = new L_category ();
  6131. Doo::loadModel ( 'enclosur' );
  6132. $enclosur = new enclosur ();
  6133. $vidList = array ();
  6134. $verifyDetail = $verify->find ( array (
  6135. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6136. 'asArray' => true
  6137. ) );
  6138. foreach ( $verifyDetail as $key => $value ) {
  6139. array_push ( $vidList, $value ['vid'] );
  6140. }
  6141. $vid = implode ( ",", $vidList );
  6142. if (empty ( $verifyDetail ))
  6143. $vid = 0;
  6144. $categoryList = $Lcategory->find ( array (
  6145. 'asArray' => true
  6146. ) );
  6147. $staffList = $staff->find ( array (
  6148. 'where' => 'cid=' . $cid,
  6149. 'asArray' => true
  6150. ) );
  6151. $ap = 0;
  6152. $receiptList = $receipt->find ( array (
  6153. 'where' => 'rid =' . $rid,
  6154. 'desc' => 'rid',
  6155. 'asArray' => true
  6156. ) );
  6157. $Locate = 0;
  6158. $roleId = 0;
  6159. $button = 0;
  6160. foreach ( $receiptList as $key => $value ) {
  6161. $receiptList [$key] ['Locate'] = $Locate;
  6162. $Locate ++;
  6163. $receiptList [$key] ['reviseDetail'] = array ();
  6164. if (! empty ( $value ['reviseDetail'] ))
  6165. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6166. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6167. $categoryDetil = $Lcategory->getOne ( array (
  6168. 'where' => 'cid=' . $value ['cid'],
  6169. 'asArray' => true
  6170. ) );
  6171. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6172. // 检测编辑状态
  6173. $verifyList = $verify->getOne ( array (
  6174. 'where' => 'vid=' . $value ['verify'],
  6175. 'asArray' => true
  6176. ) );
  6177. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6178. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6179. Doo::loadModel ( 'role' );
  6180. $role = new role ();
  6181. // print_r($verifyList);
  6182. $flag = true;
  6183. $roleKey = 0;
  6184. $endStaffArray = array ();
  6185. $roleArrayCopy = array ();
  6186. foreach ( $verifyList as $k => $v ) {
  6187. // init verifyStaff
  6188. if ($v [1] == 'ROLE') {
  6189. if (! empty ( $verifyStaff )) {
  6190. $endStaffArray = end ( $verifyStaff );
  6191. if ($v [0] == $endStaffArray ['nextStaff']) {
  6192. $roleId = $v [0];
  6193. }
  6194. }
  6195. $roleVerify = json_decode ( $v [3], true );
  6196. $roleKey = $k;
  6197. $roleArray = array ();
  6198. $rolename = $role->getOne ( array (
  6199. 'where' => 'rid=' . $v [0],
  6200. 'asArray' => true
  6201. ) );
  6202. foreach ( $roleVerify as $o => $p ) {
  6203. $staffID = explode ( '_', $p );
  6204. $staffInfo = $staff->getOne ( array (
  6205. 'where' => 'sid=' . $staffID [0],
  6206. 'asArray' => true
  6207. ) );
  6208. // print_r($staffID);
  6209. $exp = array (
  6210. 0 => $staffInfo ['sid'],
  6211. 1 => $staffID [1],
  6212. 2 => $staffInfo ['avatar'],
  6213. 'date' => '',
  6214. 'date' => '',
  6215. 'opinion' => '',
  6216. 'status' => '',
  6217. 'rolename' => $rolename ['name']
  6218. );
  6219. array_push ( $roleArray, $exp );
  6220. }
  6221. $roleArrayCopy [$v [0]] = $roleArray;
  6222. // $verifyList[$k]['roleArray']=$roleArray;
  6223. }
  6224. // print_r($roleArray);
  6225. $verifyList [$k] ['date'] = "";
  6226. $verifyList [$k] ['opinion'] = "";
  6227. $verifyList [$k] ['status'] = "";
  6228. if (empty ( $verifyStaff )) {
  6229. $verifyList [$k] ['date'] = "";
  6230. $verifyList [$k] ['opinion'] = "";
  6231. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6232. $verifyList [$k] ['status'] = 4;
  6233. $button = 4;
  6234. $flag = false;
  6235. }
  6236. } else {
  6237. foreach ( $verifyStaff as $m => $u ) {
  6238. if ($v [0] == $m) {
  6239. $verifyList [$k] ['date'] = $u ['date'];
  6240. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6241. $verifyList [$k] ['status'] = $u ['status'];
  6242. $flag = false;
  6243. break;
  6244. }
  6245. }
  6246. $endStaffArray = end ( $verifyStaff );
  6247. if (isset ( $endStaffArray ['ROLE'] )) {
  6248. } else {
  6249. $endKey = key ( $verifyStaff );
  6250. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6251. $button = 4;
  6252. $verifyList [$k] ['status'] = 4;
  6253. }
  6254. }
  6255. }
  6256. }
  6257. $rolename ['name'] = '';
  6258. if (! empty ( $roleId )) {
  6259. Doo::loadModel ( 'role' );
  6260. $role = new role ();
  6261. $rolename = $role->getOne ( array (
  6262. 'where' => 'rid=' . $roleId,
  6263. 'asArray' => true
  6264. ) );
  6265. }
  6266. if (! empty ( $verifyStaff ))
  6267. $endStaffArray = end ( $verifyStaff );
  6268. $KOP = false;
  6269. foreach ( $roleArrayCopy as $P => $A ) {
  6270. foreach ( $A as $MKI => $AVL ) {
  6271. if (! empty ( $verifyStaff )) {
  6272. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6273. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6274. $button = 4;
  6275. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6276. }
  6277. foreach ( $verifyStaff as $m => $u ) {
  6278. $AVLFK = $AVL [0] . '_R';
  6279. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6280. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6281. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6282. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6283. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6284. break;
  6285. }
  6286. }
  6287. } else {
  6288. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6289. $button = 4;
  6290. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6291. }
  6292. }
  6293. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6294. $KOP = true;
  6295. }
  6296. }
  6297. foreach ( $roleArrayCopy as $k => $v ) {
  6298. foreach ( $verifyList as $m => $n ) {
  6299. if ($n [0] == $k) {
  6300. array_splice ( $verifyList, $m, 1, $v );
  6301. }
  6302. }
  6303. }
  6304. $receiptList [$key] ['verifyList'] = $verifyList;
  6305. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6306. 'where' => 'sid=' . $value ['staff'],
  6307. 'asArray' => true
  6308. ) );
  6309. $receiptList [$key] ['button'] = $button;
  6310. }
  6311. $mothHtml = "";
  6312. for($i = 1; $i <= 12; $i ++) {
  6313. if ($month == $i)
  6314. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6315. else
  6316. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6317. }
  6318. // 获取审批日志
  6319. Doo::loadModel ( 'receiptLog' );
  6320. $receiptLog = new receiptLog ();
  6321. $rlList = array ();
  6322. $rlInfo = $receiptLog->getOne ( array (
  6323. 'where' => 'rid=' . $rid . ' and status=4',
  6324. 'asArray' => true
  6325. ) );
  6326. $tijdate = $receiptLog->getOne ( array (
  6327. 'where' => 'rid=' . $rid . ' and status=2',
  6328. 'asc' => 'rlid',
  6329. 'asArray' => true
  6330. ) );
  6331. if (! empty ( $rlInfo )) {
  6332. $rlList = $receiptLog->find ( array (
  6333. 'where' => 'rid=' . $rid,
  6334. 'asc' => 'rlid',
  6335. 'asArray' => true
  6336. ) );
  6337. }
  6338. $receiptList [0] ['rlList'] = $rlList;
  6339. $enclosurList = $enclosur->find ( array (
  6340. 'where' => 'rid=' . $rid,
  6341. 'asArray' => true
  6342. ) );
  6343. $enclosurHtml = '';
  6344. foreach ( $enclosurList as $value ) {
  6345. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6346. }
  6347. $data ['enclosurHtml'] = $enclosurHtml;
  6348. $data ['rolename'] = $rolename ['name'];
  6349. $data ['datetij'] = $tijdate ['date'];
  6350. $data ['mothHtml'] = $mothHtml;
  6351. $data ['receiptList'] = $receiptList;
  6352. $data ['receiptApprovalCount'] = count ( $receiptList );
  6353. $data ['year'] = $year;
  6354. $data ['categoryList'] = $categoryList;
  6355. $data ['staffList'] = $staffList;
  6356. $data ['cid'] = $cid;
  6357. $data ['sid'] = $sid;
  6358. $data ['status'] = 0;
  6359. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  6360. $ap = 4;
  6361. } else
  6362. $data ['status'] = $receiptList [0] ['status'];
  6363. if ($receiptList [0] ['status'] == 4) {
  6364. $data ['status'] = 5;
  6365. $ap = 0;
  6366. }
  6367. $data ['ap'] = $ap;
  6368. $data ['memu'] = "receipt";
  6369. $data ['staff'] = $this->staff;
  6370. $data ['receiptMemu'] = 'approval';
  6371. $data ['verifyId'] = $this->verifyId;
  6372. $data ['executeId'] = $this->executeId;
  6373. $this->render ( "/admin/saeaReportListReport", $data );
  6374. }
  6375. function approvalEdi() {
  6376. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6377. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  6378. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6379. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6380. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6381. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6382. if (empty ( $status ))
  6383. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  6384. $vidList = array ();
  6385. $button = 0;
  6386. Doo::loadModel ( 'verify' );
  6387. Doo::loadModel ( 'receipt' );
  6388. Doo::loadModel ( 'staff' );
  6389. $staff = new staff ();
  6390. $receipt = new receipt ();
  6391. $verify = new verify ();
  6392. Doo::loadModel ( 'L_category' );
  6393. $Lcategory = new L_category ();
  6394. Doo::loadModel ( 'enclosur' );
  6395. $enclosur = new enclosur ();
  6396. // user verify ID
  6397. $verifyDetail = $verify->find ( array (
  6398. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6399. 'asArray' => true
  6400. ) );
  6401. foreach ( $verifyDetail as $key => $value ) {
  6402. array_push ( $vidList, $value ['vid'] );
  6403. }
  6404. $vid = implode ( ",", $vidList );
  6405. if (empty ( $verifyDetail ))
  6406. $vid = 0;
  6407. $categoryList = $Lcategory->find ( array (
  6408. 'asArray' => true
  6409. ) );
  6410. $staffList = $staff->find ( array (
  6411. 'where' => 'cid=' . $cid,
  6412. 'asArray' => true
  6413. ) );
  6414. $ap = "";
  6415. if ($status == 4) {
  6416. $ap = 4;
  6417. $status = 2;
  6418. }
  6419. // get Receipt By verifyID status 2
  6420. $receiptList = $receipt->find ( array (
  6421. 'where' => 'rid =' . $rid,
  6422. 'desc' => 'rid',
  6423. 'asArray' => true
  6424. ) );
  6425. $Locate = 0;
  6426. $roleId = 0;
  6427. if ($ap == 4)
  6428. $status = 4;
  6429. foreach ( $receiptList as $key => $value ) {
  6430. $receiptList [$key] ['Locate'] = $Locate;
  6431. $Locate ++;
  6432. $receiptList [$key] ['reviseDetail'] = array ();
  6433. if (! empty ( $value ['reviseDetail'] ))
  6434. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6435. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6436. $categoryDetil = $Lcategory->getOne ( array (
  6437. 'where' => 'cid=' . $value ['cid'],
  6438. 'asArray' => true
  6439. ) );
  6440. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6441. // 检测编辑状态
  6442. $verifyList = $verify->getOne ( array (
  6443. 'where' => 'vid=' . $value ['verify'],
  6444. 'asArray' => true
  6445. ) );
  6446. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6447. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6448. // print_r($verifyList);
  6449. //
  6450. // if (empty($verifyStaff)){
  6451. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6452. // $verifyList[0]['status']=4;$button=4;
  6453. // }
  6454. //
  6455. // }else{
  6456. //
  6457. // }
  6458. // die;
  6459. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  6460. // echo array_search("green",$a);
  6461. //
  6462. Doo::loadModel ( 'role' );
  6463. $role = new role ();
  6464. // print_r($verifyList);
  6465. $flag = true;
  6466. $roleKey = 0;
  6467. $endStaffArray = array ();
  6468. $roleArrayCopy = array ();
  6469. foreach ( $verifyList as $k => $v ) {
  6470. // init verifyStaff
  6471. if ($v [1] == 'ROLE') {
  6472. if (! empty ( $verifyStaff )) {
  6473. $endStaffArray = end ( $verifyStaff );
  6474. if ($v [0] == $endStaffArray ['nextStaff']) {
  6475. $roleId = $v [0];
  6476. }
  6477. }
  6478. $roleVerify = json_decode ( $v [3], true );
  6479. $roleKey = $k;
  6480. $roleArray = array ();
  6481. $rolename = $role->getOne ( array (
  6482. 'where' => 'rid=' . $v [0],
  6483. 'asArray' => true
  6484. ) );
  6485. foreach ( $roleVerify as $o => $p ) {
  6486. $staffID = explode ( '_', $p );
  6487. $staffInfo = $staff->getOne ( array (
  6488. 'where' => 'sid=' . $staffID [0],
  6489. 'asArray' => true
  6490. ) );
  6491. // print_r($staffID);
  6492. $exp = array (
  6493. 0 => $staffInfo ['sid'],
  6494. 1 => $staffID [1],
  6495. 2 => $staffInfo ['avatar'],
  6496. 'date' => '',
  6497. 'date' => '',
  6498. 'opinion' => '',
  6499. 'status' => '',
  6500. 'rolename' => $rolename ['name']
  6501. );
  6502. array_push ( $roleArray, $exp );
  6503. }
  6504. $roleArrayCopy [$v [0]] = $roleArray;
  6505. // $verifyList[$k]['roleArray']=$roleArray;
  6506. }
  6507. // print_r($roleArray);
  6508. $verifyList [$k] ['date'] = "";
  6509. $verifyList [$k] ['opinion'] = "";
  6510. $verifyList [$k] ['status'] = "";
  6511. if (empty ( $verifyStaff )) {
  6512. $verifyList [$k] ['date'] = "";
  6513. $verifyList [$k] ['opinion'] = "";
  6514. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6515. $verifyList [$k] ['status'] = 4;
  6516. $button = 4;
  6517. $flag = false;
  6518. }
  6519. } else {
  6520. foreach ( $verifyStaff as $m => $u ) {
  6521. if ($v [0] == $m) {
  6522. $verifyList [$k] ['date'] = $u ['date'];
  6523. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6524. $verifyList [$k] ['status'] = $u ['status'];
  6525. $flag = false;
  6526. break;
  6527. }
  6528. }
  6529. $endStaffArray = end ( $verifyStaff );
  6530. if (isset ( $endStaffArray ['ROLE'] )) {
  6531. } else {
  6532. $endKey = key ( $verifyStaff );
  6533. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6534. $button = 4;
  6535. $verifyList [$k] ['status'] = 4;
  6536. }
  6537. }
  6538. // print_r($endStaffArray);die;
  6539. // if (empty($verifyStaff)){
  6540. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6541. // $verifyList[$k]['status']=4;$button=4;
  6542. // }
  6543. //
  6544. // }else{
  6545. //
  6546. // }
  6547. // if($flag){//检测可编辑
  6548. // if($v[0]==$this->staff[0]['sid']){
  6549. // $verifyList[$k]['status']=4;$button=4;
  6550. // }
  6551. // }
  6552. }
  6553. }
  6554. $rolename ['name'] = '';
  6555. if (! empty ( $roleId )) {
  6556. Doo::loadModel ( 'role' );
  6557. $role = new role ();
  6558. $rolename = $role->getOne ( array (
  6559. 'where' => 'rid=' . $roleId,
  6560. 'asArray' => true
  6561. ) );
  6562. }
  6563. if (! empty ( $verifyStaff ))
  6564. $endStaffArray = end ( $verifyStaff );
  6565. $KOP = false;
  6566. foreach ( $roleArrayCopy as $P => $A ) {
  6567. foreach ( $A as $MKI => $AVL ) {
  6568. if (! empty ( $verifyStaff )) {
  6569. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6570. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6571. $button = 4;
  6572. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6573. }
  6574. foreach ( $verifyStaff as $m => $u ) {
  6575. $AVLFK = $AVL [0] . '_R';
  6576. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6577. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6578. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6579. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6580. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6581. break;
  6582. }
  6583. }
  6584. } else {
  6585. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6586. $button = 4;
  6587. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6588. }
  6589. }
  6590. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6591. $KOP = true;
  6592. }
  6593. }
  6594. // print_r($roleArrayCopy);
  6595. // echo $roleKey;
  6596. foreach ( $roleArrayCopy as $k => $v ) {
  6597. foreach ( $verifyList as $m => $n ) {
  6598. if ($n [0] == $k) {
  6599. array_splice ( $verifyList, $m, 1, $v );
  6600. }
  6601. }
  6602. }
  6603. // if ($KOP)
  6604. // array_splice($verifyList,$roleKey,1,$roleArray);
  6605. // print_r($verifyList);
  6606. $receiptList [$key] ['verifyList'] = $verifyList;
  6607. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6608. 'where' => 'sid=' . $value ['staff'],
  6609. 'asArray' => true
  6610. ) );
  6611. $receiptList [$key] ['button'] = $button;
  6612. }
  6613. // $data['verifyDetail']=$verifyDetail;
  6614. $mothHtml = "";
  6615. for($i = 1; $i <= 12; $i ++) {
  6616. if ($month == $i)
  6617. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6618. else
  6619. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6620. }
  6621. // 获取审批日志
  6622. Doo::loadModel ( 'receiptLog' );
  6623. $receiptLog = new receiptLog ();
  6624. $rlList = array ();
  6625. $rlInfo = $receiptLog->getOne ( array (
  6626. 'where' => 'rid=' . $rid . ' and status=4',
  6627. 'asArray' => true
  6628. ) );
  6629. $tijdate = $receiptLog->getOne ( array (
  6630. 'where' => 'rid=' . $rid . ' and status=2',
  6631. 'asc' => 'rlid',
  6632. 'asArray' => true
  6633. ) );
  6634. if (! empty ( $rlInfo )) {
  6635. $rlList = $receiptLog->find ( array (
  6636. 'where' => 'rid=' . $rid,
  6637. 'asc' => 'rlid',
  6638. 'asArray' => true
  6639. ) );
  6640. }
  6641. $receiptList [0] ['rlList'] = $rlList;
  6642. $enclosurList = $enclosur->find ( array (
  6643. 'where' => 'rid=' . $rid,
  6644. 'asArray' => true
  6645. ) );
  6646. $enclosurHtml = '';
  6647. foreach ( $enclosurList as $value ) {
  6648. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6649. }
  6650. $data ['enclosurHtml'] = $enclosurHtml;
  6651. $data ['rolename'] = $rolename ['name'];
  6652. $data ['datetij'] = $tijdate ['date'];
  6653. $data ['mothHtml'] = $mothHtml;
  6654. $data ['receiptList'] = $receiptList;
  6655. $data ['receiptApprovalCount'] = count ( $receiptList );
  6656. $data ['status'] = $status;
  6657. $data ['year'] = $year;
  6658. $data ['categoryList'] = $categoryList;
  6659. $data ['staffList'] = $staffList;
  6660. $data ['cid'] = $cid;
  6661. $data ['sid'] = $sid;
  6662. $data ['ap'] = $ap;
  6663. $data ['memu'] = "receipt";
  6664. $data ['staff'] = $this->staff;
  6665. $data ['receiptMemu'] = 'approval';
  6666. $data ['verifyId'] = $this->verifyId;
  6667. $data ['executeId'] = $this->executeId;
  6668. $this->render ( "/admin/saeaReportListReport", $data );
  6669. }
  6670. function remittanceHky() {
  6671. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6672. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  6673. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6674. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  6675. $page_size = 15;
  6676. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  6677. Doo::loadModel ( 'receipt' );
  6678. $receipt = new receipt ();
  6679. Doo::loadModel ( 'staff' );
  6680. $staff = new staff ();
  6681. $dateCondition = " and Year(executeDate) =" . $year;
  6682. if ($moth != 'MONTH')
  6683. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  6684. if ($day != 'DAY' && $moth != 'MONTH')
  6685. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  6686. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  6687. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  6688. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  6689. $limit = $pageinfo ['lower'] . ',' . $page_size;
  6690. $dayList = $receipt->find ( array (
  6691. 'select' => 'executeDate,sum(amount) as amount',
  6692. 'where' => $sql,
  6693. 'desc' => 'executeDate',
  6694. 'groupby' => 'executeDate',
  6695. 'limit' => $limit,
  6696. 'asArray' => true
  6697. ) );
  6698. // print_r($dayList);
  6699. foreach ( $dayList as $key => $value ) {
  6700. $remitString = "";
  6701. $receiptList = $receipt->find ( array (
  6702. 'select' => 'rid,executeDate,amount,staff,cid',
  6703. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  6704. 'desc' => 'executeDate',
  6705. 'asArray' => true
  6706. ) );
  6707. foreach ( $receiptList as $k => $v ) {
  6708. $sinfo = $staff->getOne ( array (
  6709. 'select' => 'username,category',
  6710. 'where' => ' sid=' . $v ['staff'],
  6711. 'asArray' => true
  6712. ) );
  6713. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  6714. }
  6715. $dayList [$key] ['staff'] = $remitString;
  6716. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  6717. }
  6718. // print_r($dayList);
  6719. $mothHtml = "";
  6720. for($i = 1; $i <= 12; $i ++) {
  6721. if ($moth == $i)
  6722. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6723. else
  6724. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6725. }
  6726. $dayHtml = "";
  6727. if ($day != "DAY" || $moth != "MONTH") {
  6728. for($i = 1; $i <= 31; $i ++) {
  6729. if ($day == $i)
  6730. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6731. else
  6732. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6733. }
  6734. }
  6735. $dateHtml = "";
  6736. $now = date ( "Y" );
  6737. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  6738. if ($YEARD <= $now) {
  6739. $dateHtml .= '<option ';
  6740. if ($year == $YEARD) {
  6741. $dateHtml .= 'selected ';
  6742. }
  6743. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  6744. }
  6745. }
  6746. $data ['dateHtml'] = $dateHtml;
  6747. $data ['page'] = $pageinfo;
  6748. $data ['year'] = $year;
  6749. $data ['moth'] = $moth;
  6750. $data ['day'] = $day;
  6751. $data ['get'] = $get;
  6752. $data ['dayHtml'] = $dayHtml;
  6753. $data ['mothHtml'] = $mothHtml;
  6754. $data ['receiptList'] = $dayList;
  6755. $data ['memu'] = "receipt";
  6756. $data ['staff'] = $this->staff;
  6757. $data ['receiptMemu'] = 'remittanceHky';
  6758. $data ['verifyId'] = $this->verifyId;
  6759. $data ['executeId'] = $this->executeId;
  6760. $this->render ( "/admin/remittanceHky", $data );
  6761. }
  6762. function remittancep() {
  6763. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  6764. Doo::loadModel ( 'receipt' );
  6765. $receipt = new receipt ();
  6766. Doo::loadModel ( 'staff' );
  6767. $staff = new staff ();
  6768. Doo::loadClass ( 'XDeode' );
  6769. $XDeode = new XDeode ( 5 );
  6770. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  6771. $rplist = $receipt->find ( array (
  6772. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6773. 'asArray' => true
  6774. ) );
  6775. $dayList = $receipt->find ( array (
  6776. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6777. 'desc' => 'executeDate',
  6778. 'groupby' => 'staff',
  6779. 'asArray' => true
  6780. ) );
  6781. $html = '';
  6782. foreach ( $dayList as $key => $value ) {
  6783. $sinfo = $staff->getOne ( array (
  6784. 'select' => 'username,category',
  6785. 'where' => ' sid=' . $value ['staff'],
  6786. 'asArray' => true
  6787. ) );
  6788. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  6789. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  6790. $au = 0;
  6791. foreach ( $rplist as $k => $v ) {
  6792. if ($value ['staff'] == $v ['staff']) {
  6793. $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>';
  6794. $au += $v ['amount'];
  6795. }
  6796. }
  6797. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  6798. }
  6799. $data ['html'] = $html;
  6800. $data ['memu'] = "receipt";
  6801. $data ['staff'] = $this->staff;
  6802. $data ['receiptMemu'] = 'remittanceHky';
  6803. $data ['verifyId'] = $this->verifyId;
  6804. $data ['executeId'] = $this->executeId;
  6805. $this->render ( "/admin/remittancep", $data );
  6806. }
  6807. function ajaxGetReceiptDetails() {
  6808. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  6809. Doo::loadClass ( 'XDeode' );
  6810. $XDeode = new XDeode ( 5 );
  6811. $rid = $XDeode->decode ( $rid );
  6812. if (empty ( $rid )) {
  6813. echo json_encode ( array (
  6814. 'status' => 2,
  6815. 'msg' => 'illegal request'
  6816. ) );
  6817. die ();
  6818. }
  6819. Doo::loadModel ( 'receipt' );
  6820. $receipt = new receipt ();
  6821. Doo::loadModel ( 'staff' );
  6822. $staff = new staff ();
  6823. $rinfo = $receipt->getOne ( array (
  6824. 'where' => 'rid= ' . $rid,
  6825. 'asArray' => true
  6826. ) );
  6827. $sinfo = $staff->getOne ( array (
  6828. 'select' => 'username,category',
  6829. 'where' => ' sid=' . $rinfo ['staff'],
  6830. 'asArray' => true
  6831. ) );
  6832. $rinfo ['reviseDetail'] = array ();
  6833. if (! empty ( $rinfo ['reviseDetail'] ))
  6834. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  6835. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  6836. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  6837. $rinfo ['category'] = $sinfo ['category'];
  6838. $verifyStaff = array ();
  6839. if (! empty ( $rinfo ['verifyStaff'] ))
  6840. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  6841. $relust = bcsub ( $rinfo ['sum'], $rinfo ['loanSum'], 2 );
  6842. $rinfo ['relust'] = $relust;
  6843. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  6844. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  6845. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  6846. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  6847. // 费用执行人相关数据
  6848. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6849. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6850. foreach ( $executeCopy as $k => $v ) {
  6851. $executeCopy [$k] ['date'] = '';
  6852. $executeCopy [$k] ['opinion'] = '';
  6853. $executeCopy [$k] ['status'] = '';
  6854. if (! empty ( $executeStaff ))
  6855. foreach ( $executeStaff as $m => $u ) {
  6856. if ($v [0] == $m) {
  6857. $executeCopy [$k] ['date'] = $u ['date'];
  6858. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  6859. $executeCopy [$k] ['status'] = $u ['status'];
  6860. break;
  6861. }
  6862. }
  6863. }
  6864. $rinfo ['executeCopy'] = $executeCopy;
  6865. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  6866. if ($rinfo ['Rtype'] == 1) { // 借款费用
  6867. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6868. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  6869. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  6870. $html .= '<tr><th>' . $value ['name'] . '</th>
  6871. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6872. }
  6873. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6874. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6875. <tr><th class="taC" colspan="2">费用说明</th>
  6876. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6877. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6878. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  6879. </tbody></table>';
  6880. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  6881. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6882. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6883. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6884. $html .= '<tr><th>' . $value ['name'] . '</th>
  6885. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6886. }
  6887. $html .= '<tr><th class="taR">合计</th>
  6888. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6889. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6890. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6891. $html .= '<tr><th>' . $value ['name'] . '</th>
  6892. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6893. }
  6894. $html .= '<tr><th class="taR">合计</th>
  6895. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6896. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6897. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6898. $html .= '<tr><th>' . $value ['name'] . '</th>
  6899. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6900. }
  6901. $html .= '<tr><th class="taR">合计</th>
  6902. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6903. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6904. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6905. $html .= '<tr><th>' . $value ['name'] . '</th>
  6906. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6907. }
  6908. $html .= '<tr><th class="taR">合计</th>
  6909. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6910. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6911. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6912. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6913. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6914. }
  6915. $html .= '<tr><th class="taR">合计</th>
  6916. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6917. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6918. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6919. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6920. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6921. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6922. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6923. <tr';
  6924. if ($rinfo ['relust'] >= 0) {
  6925. $html .= 'class="success"';
  6926. } else {
  6927. $html .= 'class="error"';
  6928. }
  6929. $html .= '><td class="taR"><b>借款结余</b></td>
  6930. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  6931. </tbody></table>
  6932. ';
  6933. }
  6934. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  6935. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6936. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  6937. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6938. $html .= '<tr><th>' . $value ['name'] . '</th>
  6939. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6940. }
  6941. $html .= '<tr><th class="taR">合计</th>
  6942. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6943. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6944. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6945. <tr><th class="taC" colspan="2">费用说明</th>
  6946. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6947. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6948. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6949. </tbody></table>';
  6950. } else {
  6951. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6952. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6953. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6954. $html .= '<tr><th>' . $value ['name'] . '</th>
  6955. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6956. }
  6957. $html .= '<tr><th class="taR">合计</th>
  6958. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6959. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6960. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6961. $html .= '<tr><th>' . $value ['name'] . '</th>
  6962. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6963. }
  6964. $html .= '<tr><th class="taR">合计</th>
  6965. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6966. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6967. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6968. $html .= '<tr><th>' . $value ['name'] . '</th>
  6969. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6970. }
  6971. $html .= '<tr><th class="taR">合计</th>
  6972. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6973. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6974. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6975. $html .= '<tr><th>' . $value ['name'] . '</th>
  6976. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6977. }
  6978. $html .= '<tr><th class="taR">合计</th>
  6979. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6980. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6981. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6982. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6983. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6984. }
  6985. $html .= '<tr><th class="taR">合计</th>
  6986. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6987. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6988. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6989. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6990. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6991. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6992. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  6993. $html .= '</tbody></table>';
  6994. /*
  6995. * <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>
  6996. */
  6997. }
  6998. // print_r($verifyStaff);die;
  6999. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  7000. foreach ( $verifyStaff as $key => $value ) {
  7001. $key = trim ( strtr ( $key, '_R', ' ' ) );
  7002. $sinfo = $staff->getOne ( array (
  7003. 'select' => 'username',
  7004. 'where' => ' sid=' . $key,
  7005. 'asArray' => true
  7006. ) );
  7007. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  7008. }
  7009. $html .= '</tbody></table>';
  7010. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  7011. foreach ( $rinfo ['executeCopy'] as $value ) {
  7012. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  7013. }
  7014. $html .= '</tbody></table>';
  7015. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  7016. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  7017. </tr></table>';
  7018. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  7019. echo json_encode ( array (
  7020. 'status' => 1,
  7021. 'html' => $html
  7022. ) );
  7023. die ();
  7024. }
  7025. /**
  7026. * 删除附件
  7027. */
  7028. function ajaxRemEnclousur() {
  7029. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  7030. if (empty ( $key ))
  7031. echo json_encode ( array (
  7032. 'status' => 2
  7033. ) );
  7034. Doo::loadModel ( 'enclosur' );
  7035. $enclosur = new enclosur ();
  7036. $enclosur->delEnclosurByEid ( $key );
  7037. echo json_encode ( array (
  7038. 'status' => 1
  7039. ) );
  7040. }
  7041. function remittance() {
  7042. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7043. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7044. Doo::loadModel ( 'receipt' );
  7045. $receipt = new receipt ();
  7046. Doo::loadModel ( 'staff' );
  7047. $staff = new staff ();
  7048. $dateCondition = " and Year(pastDate) =" . $year;
  7049. if (! empty ( $month ))
  7050. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  7051. // get Receipt By verifyID status 1
  7052. $receiptList = $receipt->find ( array (
  7053. 'select' => 'sum(sum) as sum,staff,pastDate',
  7054. 'where' => ' status=1' . $dateCondition,
  7055. 'desc' => 'pastDate',
  7056. 'groupby' => 'staff,pastDate',
  7057. 'asArray' => true
  7058. ) );
  7059. $dateList = $receipt->find ( array (
  7060. 'select' => 'pastDate,verifyStaff',
  7061. 'where' => ' status=1' . $dateCondition,
  7062. 'desc' => 'pastDate',
  7063. 'groupby' => 'pastDate',
  7064. 'asArray' => true
  7065. ) );
  7066. $dataList = array ();
  7067. foreach ( $dateList as $d => $a ) {
  7068. $dataList [$a ['pastDate']] = array ();
  7069. $daySum = 0;
  7070. foreach ( $receiptList as $key => $value ) {
  7071. if ($a ['pastDate'] == $value ['pastDate']) {
  7072. $oderList = $receipt->find ( array (
  7073. 'select' => 'receiptOrder',
  7074. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  7075. 'asArray' => true
  7076. ) );
  7077. $list = array ();
  7078. $html = "";
  7079. foreach ( $oderList as $v ) {
  7080. array_push ( $list, $v ['receiptOrder'] );
  7081. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  7082. }
  7083. $receiptList [$key] ['receiptOrder'] = $html;
  7084. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  7085. $sinfo = $staff->getOne ( array (
  7086. 'select' => 'username ',
  7087. 'where' => ' sid=' . $value ['staff'],
  7088. 'asArray' => true
  7089. ) );
  7090. $receiptList [$key] ['username'] = $sinfo ['username'];
  7091. $daySum += $value ['sum'];
  7092. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  7093. }
  7094. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  7095. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  7096. }
  7097. }
  7098. // print_r($dataList);
  7099. $data ['dataList'] = $dataList;
  7100. $mothHtml = "";
  7101. for($i = 1; $i <= 12; $i ++) {
  7102. if ($month == $i)
  7103. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7104. else
  7105. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7106. }
  7107. $data ['year'] = $year;
  7108. $data ['mothHtml'] = $mothHtml;
  7109. $data ['memu'] = "receipt";
  7110. $data ['staff'] = $this->staff;
  7111. $data ['receiptMemu'] = 'approval';
  7112. $data ['verifyId'] = $this->verifyId;
  7113. $data ['executeId'] = $this->executeId;
  7114. $this->render ( "/admin/saeaReportListPay", $data );
  7115. }
  7116. /**
  7117. * 金额调整,提高稳定性
  7118. * @return string
  7119. */
  7120. function revocationAdjustment() {
  7121. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  7122. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  7123. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  7124. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  7125. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey ) && (! empty ( $reviseKey )))) {
  7126. Doo::loadClass ( 'XDeode' );
  7127. $XDeode = new XDeode ( 5 );
  7128. Doo::loadModel ( 'receipt' );
  7129. $receipt = new receipt ();
  7130. $sid = $XDeode->decode ( $sidKey );
  7131. $rid = $XDeode->decode ( $ridKey );
  7132. $reviseKey = $XDeode->decode ( $reviseKey );
  7133. if (! is_numeric ( $sid ) && ! is_numeric ( $rid ) && ! is_numeric ( $reviseKey ))
  7134. die ( 'illegal request' );
  7135. $receiptDetail = $receipt->getOne ( array (
  7136. 'where' => 'rid=' . $rid,
  7137. 'asArray' => true
  7138. ) );
  7139. if (empty ( $receiptDetail ) || empty ( $receiptDetail ['reviseDetail'] ))
  7140. die ( 'illegal request' );
  7141. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7142. if (! isset ( $reviseDetail [$reviseKey] ))
  7143. die ( 'illegal request' );
  7144. if ($reviseDetail [$reviseKey] ['sid'] == $sid && $reviseDetail [$reviseKey] ['price'] == $price)
  7145. unset ( $reviseDetail [$reviseKey] );
  7146. $revisePrice = 0;
  7147. foreach ( $reviseDetail as $key => $value ) {
  7148. $revisePrice += $value ['price'];
  7149. }
  7150. $reviseDetailString = json_encode ( $reviseDetail );
  7151. $receipt->reviseDetail = $reviseDetailString;
  7152. $receipt->sum = $receiptDetail ['sum'] - $price;
  7153. $receipt->revisePrice = $revisePrice;
  7154. $receipt->update ( array (
  7155. 'where' => 'rid=' . $rid
  7156. ) );
  7157. return '/receiptburEdi/' . $rid;
  7158. } else
  7159. die ( 'illegal request2' );
  7160. }
  7161. function updateApprovalReceipt() {
  7162. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7163. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  7164. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7165. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  7166. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  7167. if (! empty ( $rid )) {
  7168. Doo::loadModel ( "verify" );
  7169. $verify = new verify ();
  7170. Doo::loadModel ( "receiptDetail" );
  7171. $receiptDetailObj = new receiptDetail ();
  7172. Doo::loadModel ( "itemStatistics" );
  7173. Doo::loadModel ( "statistics" );
  7174. $statistics = new statistics ();
  7175. $itemStatistics = new itemStatistics ();
  7176. Doo::loadModel ( "receipt" );
  7177. $receipt = new receipt ();
  7178. $receiptDetail = $receipt->getOne ( array (
  7179. 'where' => 'rid=' . $rid . ' and status=2 ',
  7180. 'asArray' => true
  7181. ) );
  7182. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  7183. $nsflag = true;
  7184. foreach ( $nslist as $value ) {
  7185. if ($value == $this->staff ['0'] ['sid']) {
  7186. $nsflag = false;
  7187. break;
  7188. }
  7189. }
  7190. if (empty ( $receiptDetail ) || $nsflag)
  7191. return "/approval";
  7192. $verifyDetail = $verify->getOne ( array (
  7193. 'where' => ' vid =' . $receiptDetail ['verify'],
  7194. 'asArray' => true
  7195. ) );
  7196. $verifyString = $verifyDetail ['staff'];
  7197. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  7198. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  7199. if (empty ( $opinion )) {
  7200. if ($status == 3)
  7201. $opinion = "终止";
  7202. else
  7203. $opinion = "同意支付";
  7204. }
  7205. $nowStaff = 0;
  7206. $nowStaffList = array ();
  7207. if (empty ( $verifyStaff )) {
  7208. // 还需加入是否已经进入角色审批
  7209. if ($verifyDetail [0] [1] == 'ROLE') {
  7210. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  7211. foreach ( $vStaffString as $key => $value ) {
  7212. $staffK = explode ( "_", $value );
  7213. if ($staffK [0] != $this->staff [0] ['sid'])
  7214. array_push ( $nowStaffList, $staffK [0] );
  7215. }
  7216. // print_r($verifyDetail);
  7217. // die;
  7218. if (! empty ( $nowStaffList )) {
  7219. $nowStaff = implode ( ',', $nowStaffList );
  7220. $verifyStaff = array (
  7221. $this->staff [0] ['sid'] . "_R" => array (
  7222. 'date' => date ( 'Y-m-d' ),
  7223. 'opinion' => $opinion,
  7224. 'status' => $status,
  7225. 'nextStaff' => $verifyDetail [0] [0],
  7226. 'ROLE' => 1
  7227. )
  7228. );
  7229. } else {
  7230. $nowStaff = $verifyDetail [1] [0];
  7231. $verifyStaff = array (
  7232. $this->staff [0] ['sid'] . "_R" => array (
  7233. 'date' => date ( 'Y-m-d' ),
  7234. 'opinion' => $opinion,
  7235. 'status' => $status,
  7236. 'nextStaff' => $verifyDetail [1] [0]
  7237. )
  7238. );
  7239. }
  7240. } else {
  7241. if ($verifyDetail [1] [1] == 'ROLE') {
  7242. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  7243. // echo "dd";
  7244. foreach ( $vStaffString as $key => $value ) {
  7245. $staffK = explode ( "_", $value );
  7246. array_push ( $nowStaffList, $staffK [0] );
  7247. }
  7248. $nowStaff = implode ( ',', $nowStaffList );
  7249. $verifyStaff = array (
  7250. $this->staff [0] ['sid'] => array (
  7251. 'date' => date ( 'Y-m-d' ),
  7252. 'opinion' => $opinion,
  7253. 'status' => $status,
  7254. 'nextStaff' => $verifyDetail [1] [0],
  7255. 'ROLE' => 1
  7256. )
  7257. );
  7258. } else {
  7259. $nowStaff = $verifyDetail [1] [0];
  7260. $verifyStaff = array (
  7261. $this->staff [0] ['sid'] => array (
  7262. 'date' => date ( 'Y-m-d' ),
  7263. 'opinion' => $opinion,
  7264. 'status' => $status,
  7265. 'nextStaff' => $verifyDetail [1] [0]
  7266. )
  7267. );
  7268. }
  7269. }
  7270. if ($status == 3)
  7271. $verifyStaff = array (
  7272. 'final' => $status,
  7273. $this->staff [0] ['sid'] => array (
  7274. 'date' => date ( 'Y-m-d' ),
  7275. 'opinion' => $opinion,
  7276. 'status' => $status
  7277. )
  7278. );
  7279. $vStaffString = json_encode ( $verifyStaff );
  7280. $receipt->nowStaff = $nowStaff;
  7281. $receipt->verifyStaff = $vStaffString;
  7282. } else {
  7283. $VS = end ( $verifyStaff );
  7284. // 非角色审批
  7285. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  7286. $nextStaff = 0;
  7287. $roleSTF = false;
  7288. foreach ( $verifyDetail as $key => $value ) {
  7289. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  7290. if (isset ( $verifyDetail [$key + 1] )) {
  7291. $nextStaff = $verifyDetail [$key + 1] [0];
  7292. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  7293. $roleSTF = true;
  7294. }
  7295. break;
  7296. }
  7297. }
  7298. if (! $roleSTF) {
  7299. $nowStaff = $nextStaff;
  7300. $verifyStaff [$this->staff [0] ['sid']] = array (
  7301. 'date' => date ( 'Y-m-d' ),
  7302. 'opinion' => $opinion,
  7303. 'status' => $status,
  7304. 'nextStaff' => $nextStaff
  7305. );
  7306. } else {
  7307. // 获取角色下的所有用户ID
  7308. $nowStaffList = array ();
  7309. foreach ( $verifyDetail as $vfk ) {
  7310. if ($vfk [1] == 'ROLE') {
  7311. $vStaffString = json_decode ( $vfk [3] );
  7312. foreach ( $vStaffString as $key => $value ) {
  7313. $staffK = explode ( "_", $value );
  7314. array_push ( $nowStaffList, $staffK [0] );
  7315. }
  7316. }
  7317. }
  7318. $nowStaff = implode ( ',', $nowStaffList );
  7319. $verifyStaff [$this->staff [0] ['sid']] = array (
  7320. 'date' => date ( 'Y-m-d' ),
  7321. 'opinion' => $opinion,
  7322. 'status' => $status,
  7323. 'nextStaff' => $nextStaff,
  7324. 'ROLE' => 0
  7325. );
  7326. }
  7327. if ($status == 3) {
  7328. $verifyStaff ['final'] = $status;
  7329. $verifyStaff [$this->staff [0] ['sid']] = array (
  7330. 'date' => date ( 'Y-m-d' ),
  7331. 'opinion' => $opinion,
  7332. 'status' => $status
  7333. );
  7334. }
  7335. $vStaffString = json_encode ( $verifyStaff );
  7336. $receipt->nowStaff = $nowStaff;
  7337. $receipt->verifyStaff = $vStaffString;
  7338. }
  7339. // 角色审批
  7340. if (isset ( $VS ['ROLE'] )) {
  7341. // 找出角色人 当前审批角色组
  7342. $verifyJSStaff = array ();
  7343. $nowStaffList2 = array ();
  7344. foreach ( $verifyDetail as $key => $value ) {
  7345. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  7346. $verifyJSStaff = json_decode ( $value [3] );
  7347. foreach ( $verifyJSStaff as $m ) {
  7348. $staffK = explode ( "_", $m );
  7349. array_push ( $nowStaffList2, $staffK [0] );
  7350. }
  7351. // print_r($nowStaffList2);
  7352. }
  7353. }
  7354. $RoleVerifyStaff = array ();
  7355. foreach ( $verifyStaff as $key => $value ) {
  7356. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  7357. foreach ( $nowStaffList2 as $m ) {
  7358. if ($key == $m . "_R")
  7359. $RoleVerifyStaff [$key] = $value;
  7360. }
  7361. }
  7362. }
  7363. // print_r($verifyStaff);
  7364. // print_r($nowStaffList2);
  7365. // print_r($RoleVerifyStaff);
  7366. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  7367. // print_r($verifyJSStaff);
  7368. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  7369. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  7370. // 下一个审批人ID
  7371. $nextStaff = 0;
  7372. $falg = false;
  7373. foreach ( $verifyDetail as $key => $value ) {
  7374. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  7375. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  7376. $falg = true;
  7377. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  7378. $nowStaffList = array ();
  7379. foreach ( $vStaffString as $v ) {
  7380. $staffK = explode ( "_", $v );
  7381. array_push ( $nowStaffList, $staffK [0] );
  7382. }
  7383. $nowStaff = implode ( ',', $nowStaffList );
  7384. $nextStaff = $verifyDetail [$key + 1] [0];
  7385. } elseif (isset ( $verifyDetail [$key + 1] )) {
  7386. $nextStaff = $verifyDetail [$key + 1] [0];
  7387. $nowStaff = $nextStaff;
  7388. } else
  7389. $nowStaff = '';
  7390. break;
  7391. }
  7392. }
  7393. if ($falg)
  7394. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7395. 'date' => date ( 'Y-m-d' ),
  7396. 'opinion' => $opinion,
  7397. 'status' => $status,
  7398. 'nextStaff' => $nextStaff,
  7399. 'ROLE' => 1
  7400. );
  7401. else
  7402. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7403. 'date' => date ( 'Y-m-d' ),
  7404. 'opinion' => $opinion,
  7405. 'status' => $status,
  7406. 'nextStaff' => $nextStaff
  7407. );
  7408. // print_r($verifyStaff);
  7409. // echo $nowStaff;die;
  7410. } else { // 进入下一个角色或者审批人
  7411. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  7412. //
  7413. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  7414. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7415. 'date' => date ( 'Y-m-d' ),
  7416. 'opinion' => $opinion,
  7417. 'status' => $status,
  7418. 'nextStaff' => $VS ['nextStaff'],
  7419. 'ROLE' => 1
  7420. );
  7421. // print_r($verifyStaff);
  7422. // die;
  7423. }
  7424. if ($status == 3) {
  7425. $verifyStaff ['final'] = $status;
  7426. $verifyStaff [$this->staff [0] ['sid']] = array (
  7427. 'date' => date ( 'Y-m-d' ),
  7428. 'opinion' => $opinion,
  7429. 'status' => $status
  7430. );
  7431. }
  7432. $vStaffString = json_encode ( $verifyStaff );
  7433. $receipt->verifyStaff = $vStaffString;
  7434. $receipt->nowStaff = $nowStaff;
  7435. // die;
  7436. // }
  7437. // print_r($verifyStaff);
  7438. // die;
  7439. }
  7440. // print_r($verifyStaff);die;
  7441. }
  7442. // print_r($verifyDetail);
  7443. $roleKey = 0;
  7444. $roleId = 0;
  7445. $verifyDetailCopy = array ();
  7446. foreach ( $verifyDetail as $k => $v ) {
  7447. if ($v [1] == 'ROLE') {
  7448. $roleId = $v [0];
  7449. $roleVerify = json_decode ( $v [3], true );
  7450. $roleKey = $k;
  7451. $roleArray = array ();
  7452. foreach ( $roleVerify as $o => $p ) {
  7453. $staffID = explode ( '_', $p );
  7454. $exp = array (
  7455. 0 => $staffID [0],
  7456. 1 => $staffID [1]
  7457. );
  7458. array_push ( $roleArray, $exp );
  7459. }
  7460. $verifyDetailCopy [$v [0]] = $roleArray;
  7461. }
  7462. }
  7463. // print_r($verifyDetail);
  7464. foreach ( $verifyDetailCopy as $k => $v ) {
  7465. foreach ( $verifyDetail as $m => $n ) {
  7466. if ($n [0] == $k) {
  7467. array_splice ( $verifyDetail, $m, 1, $v );
  7468. }
  7469. }
  7470. }
  7471. // die;
  7472. // if (!empty($roleArray))
  7473. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  7474. // echo $roleId;
  7475. // print_r($verifyStaff);
  7476. // print_r($verifyDetail);
  7477. // die;
  7478. Doo::loadModel ( "receiptLog" );
  7479. $receiptLog = new receiptLog ();
  7480. // 审批日志
  7481. if (! isset ( $verifyStaff ['final'] )) {
  7482. if (! empty ( $roleId )) {
  7483. Doo::loadModel ( "role" );
  7484. $role = new role ();
  7485. $roleInfo = $role->getOne ( array (
  7486. 'where' => 'rid=' . $roleId,
  7487. 'asArray' => true
  7488. ) );
  7489. $receiptLog->rolename = $roleInfo ['name'];
  7490. }
  7491. $receiptLog->username = $this->staff [0] ['username'];
  7492. $receiptLog->uid = $this->staff [0] ['sid'];
  7493. $receiptLog->date = date ( "Y-m-d" );
  7494. $receiptLog->opinion = $opinion;
  7495. $receiptLog->img = $this->staff [0] ['avatar'];
  7496. $receiptLog->status = 1;
  7497. $receiptLog->rid = $rid;
  7498. $receiptLog->insert ();
  7499. }
  7500. if (isset ( $verifyStaff ['final'] )) { // rDetail
  7501. $receipt->verifyBreakup = $verifyString;
  7502. $receipt->status = 3;
  7503. $receiptDetailObj->status = 3;
  7504. $receiptDetailObj->update ( array (
  7505. 'where' => 'rid=' . $rid
  7506. ) );
  7507. if (! empty ( $roleId )) {
  7508. Doo::loadModel ( "role" );
  7509. $role = new role ();
  7510. $roleInfo = $role->getOne ( array (
  7511. 'where' => 'rid=' . $roleId,
  7512. 'asArray' => true
  7513. ) );
  7514. $receiptLog->rolename = $roleInfo ['name'];
  7515. }
  7516. $receiptLog->username = $this->staff [0] ['username'];
  7517. $receiptLog->uid = $this->staff [0] ['sid'];
  7518. $receiptLog->date = date ( "Y-m-d" );
  7519. $receiptLog->opinion = $opinion;
  7520. $receiptLog->img = $this->staff [0] ['avatar'];
  7521. $receiptLog->status = 3;
  7522. $receiptLog->rid = $rid;
  7523. $receiptLog->insert ();
  7524. // 微信企业号通知
  7525. $this->setWXMsg ( $rid, 3 );
  7526. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  7527. $receipt->status = 1;
  7528. $reviseSum = 0;
  7529. $receipt->verifyBreakup = $verifyString;
  7530. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  7531. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7532. foreach ( $reviseDetail as $key => $value ) {
  7533. $receiptDetailObj = new receiptDetail ();
  7534. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7535. $receiptDetailObj->item = $value ['description'];
  7536. $receiptDetailObj->itemCategory = "报销金额调整";
  7537. $receiptDetailObj->price = $value ['price'];
  7538. $receiptDetailObj->date = $receiptDetail ['date'];
  7539. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  7540. $receiptDetailObj->rid = $rid;
  7541. $receiptDetailObj->status = 1;
  7542. $receiptDetailObj->insert ();
  7543. $reviseSum += $value ['price'];
  7544. }
  7545. $itemStatistics = new itemStatistics ();
  7546. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7547. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7548. $itemStatistics->price = $reviseSum;
  7549. $itemStatistics->itemCategory = "报销金额调整";
  7550. $itemStatistics->date = $receiptDetail ['date'];
  7551. $itemStatistics->insert ();
  7552. }
  7553. $receiptDetailObj = new receiptDetail ();
  7554. $receiptDetailObj->status = 1;
  7555. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  7556. $receiptDetailObj->update ( array (
  7557. 'where' => 'rid=' . $rid
  7558. ) );
  7559. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7560. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7561. $stat = $statistics->getOne ( array (
  7562. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  7563. 'asArray' => true
  7564. ) );
  7565. if (empty ( $stat )) {
  7566. $statistics->date = $receiptDetail ['date'];
  7567. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7568. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7569. $statistics->agPrice = $receiptDetail ['sum'];
  7570. $statistics->rePrice = $reviseSum;
  7571. $statistics->insert ();
  7572. } else {
  7573. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  7574. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  7575. $statistics->update ( array (
  7576. 'where' => 'sid=' . $stat ['sid']
  7577. ) );
  7578. }
  7579. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7580. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7581. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  7582. foreach ( $accountItem ['cSum'] as $key => $value ) {
  7583. if ($key == "agencySum") {
  7584. $iStatistics = $itemStatistics->getOne ( array (
  7585. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  7586. 'asArray' => true
  7587. ) );
  7588. if (empty ( $iStatistics )) {
  7589. $itemStatistics->cid = $receiptDetail ['cid'];
  7590. ;
  7591. $itemStatistics->staff = $receiptDetail ['staff'];
  7592. $itemStatistics->price = $value;
  7593. $itemStatistics->itemCategory = $this->AGENCY;
  7594. $itemStatistics->date = $receiptDetail ['date'];
  7595. $itemStatistics->insert ();
  7596. } else {
  7597. if (! empty ( $value )) {
  7598. $itemStatistics->price = $value + $iStatistics ['price'];
  7599. $itemStatistics->update ( array (
  7600. 'where' => 'sid=' . $iStatistics ['sid']
  7601. ) );
  7602. }
  7603. }
  7604. } elseif ($key == "travelSum") {
  7605. $iStatistics = $itemStatistics->getOne ( array (
  7606. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  7607. 'asArray' => true
  7608. ) );
  7609. if (empty ( $iStatistics )) {
  7610. $itemStatistics->cid = $receiptDetail ['cid'];
  7611. $itemStatistics->staff = $receiptDetail ['staff'];
  7612. $itemStatistics->price = $value;
  7613. $itemStatistics->itemCategory = $this->TRAVEL;
  7614. $itemStatistics->date = $receiptDetail ['date'];
  7615. $itemStatistics->insert ();
  7616. } else {
  7617. if (! empty ( $value )) {
  7618. $itemStatistics->price = $value + $iStatistics ['price'];
  7619. $itemStatistics->update ( array (
  7620. 'where' => 'sid=' . $iStatistics ['sid']
  7621. ) );
  7622. }
  7623. }
  7624. } elseif ($key == "trainSum") {
  7625. $iStatistics = $itemStatistics->getOne ( array (
  7626. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  7627. 'asArray' => true
  7628. ) );
  7629. if (empty ( $iStatistics )) {
  7630. $itemStatistics->cid = $receiptDetail ['cid'];
  7631. $itemStatistics->staff = $receiptDetail ['staff'];
  7632. $itemStatistics->price = $value;
  7633. $itemStatistics->itemCategory = $this->TRAIN;
  7634. $itemStatistics->date = $receiptDetail ['date'];
  7635. $itemStatistics->insert ();
  7636. } else {
  7637. if (! empty ( $value )) {
  7638. $itemStatistics->price = $value + $iStatistics ['price'];
  7639. $itemStatistics->update ( array (
  7640. 'where' => 'sid=' . $iStatistics ['sid']
  7641. ) );
  7642. }
  7643. }
  7644. } elseif ($key == "otherSum") {
  7645. $iStatistics = $itemStatistics->getOne ( array (
  7646. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  7647. 'asArray' => true
  7648. ) );
  7649. if (empty ( $iStatistics )) {
  7650. $itemStatistics->cid = $receiptDetail ['cid'];
  7651. $itemStatistics->staff = $receiptDetail ['staff'];
  7652. $itemStatistics->price = $value;
  7653. $itemStatistics->itemCategory = $this->OTHER;
  7654. $itemStatistics->date = $receiptDetail ['date'];
  7655. $itemStatistics->insert ();
  7656. } else {
  7657. if (! empty ( $value )) {
  7658. $itemStatistics->price = $value + $iStatistics ['price'];
  7659. $itemStatistics->update ( array (
  7660. 'where' => 'sid=' . $iStatistics ['sid']
  7661. ) );
  7662. }
  7663. }
  7664. }
  7665. }
  7666. $receipt->pastDate = date ( "Y-m-d" );
  7667. // 微信企业号通知
  7668. $this->setWXMsg ( $rid, 1 );
  7669. }
  7670. $receipt->amount = $amount;
  7671. $receipt->update ( array (
  7672. 'where' => ' rid = ' . $rid
  7673. ) );
  7674. // 进入下一条审批费用新加需求
  7675. $vidList = array ();
  7676. $verifyDetail = $verify->find ( array (
  7677. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  7678. 'asArray' => true
  7679. ) );
  7680. foreach ( $verifyDetail as $key => $value ) {
  7681. array_push ( $vidList, $value ['vid'] );
  7682. }
  7683. $vid = implode ( ",", $vidList );
  7684. if (empty ( $verifyDetail ))
  7685. $vid = 0;
  7686. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  7687. $receipt = new receipt ();
  7688. $rd = $receipt->getOne ( array (
  7689. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  7690. 'asc' => 'rid',
  7691. 'asArray' => true
  7692. ) );
  7693. if (empty ( $rd )) {
  7694. return '/approvalExpenses/pendApproval';
  7695. }
  7696. if ($rd ['Rtype'] == 1) {
  7697. if ($rd ['isBK'] == 1) {
  7698. return '/receiptburEdi/' . $rd ['rid'];
  7699. } else {
  7700. return '/expensesEdi/' . $rd ['rid'];
  7701. }
  7702. } elseif ($rd ['Rtype'] == 2) {
  7703. return '/remitApproval/' . $rd ['rid'];
  7704. } else {
  7705. return '/receiptburEdi/' . $rd ['rid'];
  7706. }
  7707. // return "/approvalExpenses/pendApproval";
  7708. }
  7709. }
  7710. function expensesRetreats() {
  7711. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7712. if (! empty ( $rid )) {
  7713. // 操作记录
  7714. Doo::loadModel ( "receipt" );
  7715. $receipt = new receipt ();
  7716. Doo::loadModel ( "receiptLog" );
  7717. $receiptLog = new receiptLog ();
  7718. Doo::loadModel ( "verify" );
  7719. $verify = new verify ();
  7720. $receiptInfo = $receipt->getOne ( array (
  7721. 'where' => 'rid=' . $rid,
  7722. 'asArray' => true
  7723. ) );
  7724. $vr = $verify->getOne ( array (
  7725. 'where' => 'vid=' . $receiptInfo ['verify'],
  7726. 'asArray' => true
  7727. ) );
  7728. $jd = json_decode ( $vr ['staff'] );
  7729. $roleId = 0;
  7730. foreach ( $jd as $key => $value ) {
  7731. if ($value [1] == 'ROLE') {
  7732. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7733. if ($pos !== false) {
  7734. $roleId = $value [0];
  7735. }
  7736. }
  7737. }
  7738. // 审批日志
  7739. // echo $roleId;die;
  7740. if (! empty ( $roleId )) {
  7741. Doo::loadModel ( "role" );
  7742. $role = new role ();
  7743. $roleInfo = $role->getOne ( array (
  7744. 'where' => 'rid=' . $roleId,
  7745. 'asArray' => true
  7746. ) );
  7747. $receiptLog->rolename = $roleInfo ['name'];
  7748. }
  7749. $receiptLog->username = $this->staff [0] ['username'];
  7750. $receiptLog->uid = $this->staff [0] ['sid'];
  7751. $receiptLog->date = date ( "Y-m-d" );
  7752. $receiptLog->opinion = '撤回';
  7753. $receiptLog->img = $this->staff [0] ['avatar'];
  7754. $receiptLog->status = 4;
  7755. $receiptLog->rid = $rid;
  7756. $receiptLog->insert ();
  7757. $receipt->status = 4;
  7758. $receipt->update ( array (
  7759. 'where' => 'rid=' . $rid
  7760. ) );
  7761. // 微信企业号通知
  7762. $this->setWXMsg ( $rid, 2 );
  7763. }
  7764. // echo "ddd";
  7765. return '/approvalExpenses/pendApproval';
  7766. }
  7767. function updateCheReceipt() {
  7768. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7769. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7770. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  7771. if (! empty ( $rid )) {
  7772. // 操作记录
  7773. Doo::loadModel ( "receipt" );
  7774. $receipt = new receipt ();
  7775. Doo::loadModel ( "receiptLog" );
  7776. $receiptLog = new receiptLog ();
  7777. Doo::loadModel ( "verify" );
  7778. $verify = new verify ();
  7779. $receiptInfo = $receipt->getOne ( array (
  7780. 'where' => 'rid=' . $rid . ' and status=2',
  7781. 'asArray' => true
  7782. ) );
  7783. if (empty ( $receiptInfo )) {
  7784. echo json_encode ( array (
  7785. 'status' => 2
  7786. ) );
  7787. die ();
  7788. }
  7789. $vr = $verify->getOne ( array (
  7790. 'where' => 'vid=' . $receiptInfo ['verify'],
  7791. 'asArray' => true
  7792. ) );
  7793. $jd = json_decode ( $vr ['staff'] );
  7794. $roleId = 0;
  7795. foreach ( $jd as $key => $value ) {
  7796. if ($value [1] == 'ROLE') {
  7797. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7798. if ($pos !== false) {
  7799. $roleId = $value [0];
  7800. }
  7801. }
  7802. }
  7803. // 审批日志
  7804. // echo $roleId;die;
  7805. if (! empty ( $roleId )) {
  7806. Doo::loadModel ( "role" );
  7807. $role = new role ();
  7808. $roleInfo = $role->getOne ( array (
  7809. 'where' => 'rid=' . $roleId,
  7810. 'asArray' => true
  7811. ) );
  7812. $receiptLog->rolename = $roleInfo ['name'];
  7813. }
  7814. $receiptLog->username = $this->staff [0] ['username'];
  7815. $receiptLog->uid = $this->staff [0] ['sid'];
  7816. $receiptLog->date = date ( "Y-m-d" );
  7817. $receiptLog->opinion = $opinion;
  7818. $receiptLog->img = $this->staff [0] ['avatar'];
  7819. $receiptLog->status = 4;
  7820. $receiptLog->rid = $rid;
  7821. $receiptLog->insert ();
  7822. $receipt->status = 4;
  7823. $receipt->update ( array (
  7824. 'where' => 'rid=' . $rid
  7825. ) );
  7826. // 微信企业号通知
  7827. $this->setWXMsg ( $rid, 2 );
  7828. echo json_encode ( array (
  7829. 'status' => 1
  7830. ) );
  7831. // Header("HTTP/1.1 303 See Other");
  7832. // Header("Location: /approvalExpenses/pendApproval");
  7833. die ();
  7834. }
  7835. echo json_encode ( array (
  7836. 'status' => 2
  7837. ) );
  7838. die ();
  7839. // echo "ddd";
  7840. // return '/saeaBorad';
  7841. }
  7842. function revisePrice() {
  7843. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  7844. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  7845. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7846. // echo $price;die;
  7847. if (! empty ( $rid )) {
  7848. Doo::loadModel ( "receipt" );
  7849. $receipt = new receipt ();
  7850. $receiptDetail = $receipt->getOne ( array (
  7851. 'where' => 'rid=' . $rid . ' and status=2 ',
  7852. 'asArray' => true
  7853. ) );
  7854. if (empty ( $receiptDetail ))
  7855. die ( 'illegal request' );
  7856. $reviseDetail = array ();
  7857. if (empty ( $receiptDetail ['reviseDetail'] )) {
  7858. array_push ( $reviseDetail, array (
  7859. 'sid' => $this->staff [0] ['sid'],
  7860. 'name' => $this->staff [0] ['username'],
  7861. 'description' => $description,
  7862. 'price' => $price
  7863. ) );
  7864. $reviseDetailString = json_encode ( $reviseDetail );
  7865. $receipt->reviseDetail = $reviseDetailString;
  7866. $receipt->revisePrice = $price;
  7867. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7868. } else {
  7869. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7870. array_push ( $reviseDetail, array (
  7871. 'sid' => $this->staff [0] ['sid'],
  7872. 'name' => $this->staff [0] ['username'],
  7873. 'description' => $description,
  7874. 'price' => $price
  7875. ) );
  7876. $reviseDetailString = json_encode ( $reviseDetail );
  7877. $receipt->reviseDetail = $reviseDetailString;
  7878. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  7879. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7880. }
  7881. $receipt->update ( array (
  7882. 'where' => 'rid=' . $rid
  7883. ) );
  7884. if ($receiptDetail ['Rtype'] == 1) {
  7885. if ($receiptDetail ['isBK'] == 1) {
  7886. return '/receiptburEdi/' . $receiptDetail ['rid'];
  7887. }
  7888. } elseif ($receiptDetail ['Rtype'] == 2) {
  7889. } else {
  7890. return '/receiptburEdi/' . $receiptDetail ['rid'];
  7891. }
  7892. }
  7893. die ( 'illegal request' );
  7894. }
  7895. function personalCollect() {
  7896. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7897. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  7898. $this->showCache ( $path );
  7899. Doo::loadModel ( "receiptDetail" );
  7900. Doo::loadModel ( "itemStatistics" );
  7901. Doo::loadModel ( 'statistics' );
  7902. $statistics = new statistics ();
  7903. $itemStatistics = new itemStatistics ();
  7904. $receiptDetail = new receiptDetail ();
  7905. $receiptCollectList = $receiptDetail->find ( array (
  7906. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7907. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7908. 'groupby' => 'itemCategory,Month(date)',
  7909. 'asArray' => true
  7910. ) );
  7911. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  7912. 'where' => 'staff=' . $this->staff [0] ['sid'],
  7913. 'asArray' => true
  7914. ) );
  7915. // create collect html
  7916. $collectArray = array (
  7917. '日常相关费用' => array (),
  7918. '差旅相关费用' => array (),
  7919. '培训班费用' => array (),
  7920. '其他' => array ()
  7921. );
  7922. $adjustment = array ();
  7923. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  7924. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7925. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  7926. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7927. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  7928. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7929. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  7930. array_push ( $collectArray ['其他'], $collectHtml );
  7931. $data ['collectArray'] = $collectArray;
  7932. // statistics html
  7933. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7934. if (empty ( $stList ))
  7935. $stList = array (
  7936. 'rePrice' => 0,
  7937. 'agPrice' => 0
  7938. );
  7939. $data ['stList'] = array (
  7940. 'rePrice' => $stList ['rePrice'],
  7941. 'agPrice' => $stList ['agPrice'],
  7942. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7943. );
  7944. // Adjustment price html
  7945. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7946. array_push ( $adjustment, $collectHtml );
  7947. $data ['adjustment'] = $adjustment;
  7948. // total price html
  7949. $collectHtml = "";
  7950. $total = 0;
  7951. for($i = 1; $i <= 12; $i ++) {
  7952. $sumPrice = 0;
  7953. foreach ( $receiptCollectList as $key => $value ) {
  7954. if ($value ['month'] == $i) {
  7955. $sumPrice += $value ['price'];
  7956. }
  7957. }
  7958. if ($sumPrice == 0)
  7959. $collectHtml .= '<td class="taR">-</td>';
  7960. else
  7961. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7962. $total += $sumPrice;
  7963. }
  7964. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7965. $data ['totalPrice'] = $collectHtml;
  7966. $dateHtml = "";
  7967. $now = date ( "Y" );
  7968. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  7969. if ($YEARD <= $now) {
  7970. $dateHtml .= '<option ';
  7971. if ($year == $YEARD) {
  7972. $dateHtml .= 'selected ';
  7973. }
  7974. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  7975. }
  7976. }
  7977. $data ['dateHtml'] = $dateHtml;
  7978. $data ['year'] = $year;
  7979. $data ['totalYear'] = $total;
  7980. $data ['memu'] = "receipt";
  7981. $data ['staff'] = $this->staff;
  7982. $data ['receiptMemu'] = 'personalCollect';
  7983. $data ['verifyId'] = $this->verifyId;
  7984. $data ['executeId'] = $this->executeId;
  7985. // year staff status 2,4
  7986. if ($year < date ( "Y" )) {
  7987. Doo::loadModel ( 'receipt' );
  7988. $receipt = new receipt ();
  7989. $receiptList = $receipt->find ( array (
  7990. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7991. 'asArray' => true
  7992. ) );
  7993. if (empty ( $receiptList )) {
  7994. ob_start ();
  7995. $this->render ( "/admin/saea_slist_collect", $data );
  7996. $this->cacheFile ( $path );
  7997. die ();
  7998. }
  7999. }
  8000. $this->render ( "/admin/saea_slist_collect", $data );
  8001. }
  8002. function personalCollectDetail() {
  8003. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8004. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  8005. $this->showCache ( $path );
  8006. Doo::loadModel ( "receiptDetail" );
  8007. Doo::loadModel ( "itemStatistics" );
  8008. Doo::loadModel ( 'statistics' );
  8009. Doo::loadModel ( 'accountItem' );
  8010. $accountItem = new accountItem ();
  8011. $statistics = new statistics ();
  8012. $itemStatistics = new itemStatistics ();
  8013. $receiptDetail = new receiptDetail ();
  8014. $receiptCollectList = $receiptDetail->find ( array (
  8015. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  8016. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  8017. 'groupby' => 'item,Month(date)',
  8018. 'asArray' => true
  8019. ) );
  8020. $accountList = $accountItem->find ( array (
  8021. 'asArray' => true
  8022. ) );
  8023. // create CollectDetail HTML
  8024. $collectHtml = array ();
  8025. foreach ( $accountList as $key => $value ) {
  8026. $html = "";
  8027. $asum = 0;
  8028. for($i = 1; $i <= 12; $i ++) {
  8029. $falg = true;
  8030. foreach ( $receiptCollectList as $v ) {
  8031. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  8032. $asum += $v ['price'];
  8033. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8034. $falg = false;
  8035. break;
  8036. }
  8037. }
  8038. if ($falg)
  8039. $html .= '<td class="taR">-</td>';
  8040. }
  8041. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8042. $collectHtml [$value ['category']] [$value ['name']] = $html;
  8043. }
  8044. $data ['collectHtml'] = $collectHtml;
  8045. // create Adjustment price html
  8046. $receiptCollectList = $receiptDetail->find ( array (
  8047. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  8048. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  8049. 'groupby' => 'itemCategory,Month(date)',
  8050. 'asArray' => true
  8051. ) );
  8052. $adjustment = array ();
  8053. $collectArray = array (
  8054. '日常相关费用' => array (),
  8055. '差旅相关费用' => array (),
  8056. '培训班费用' => array (),
  8057. '其他' => array ()
  8058. );
  8059. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  8060. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  8061. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  8062. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  8063. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  8064. array_push ( $collectArray ['培训班费用'], $collectHtml );
  8065. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  8066. array_push ( $collectArray ['其他'], $collectHtml );
  8067. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  8068. array_push ( $adjustment, $collectHtml );
  8069. // total price html
  8070. $collectHtml = "";
  8071. $total = 0;
  8072. for($i = 1; $i <= 12; $i ++) {
  8073. $sumPrice = 0;
  8074. foreach ( $receiptCollectList as $key => $value ) {
  8075. if ($value ['month'] == $i) {
  8076. $sumPrice += $value ['price'];
  8077. }
  8078. }
  8079. if ($sumPrice == 0)
  8080. $collectHtml .= '<td class="taR">-</td>';
  8081. else
  8082. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8083. $total += $sumPrice;
  8084. }
  8085. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8086. // statistics html
  8087. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  8088. if (empty ( $stList ))
  8089. $stList = array (
  8090. 'rePrice' => 0,
  8091. 'agPrice' => 0
  8092. );
  8093. $data ['stList'] = array (
  8094. 'rePrice' => $stList ['rePrice'],
  8095. 'agPrice' => $stList ['agPrice'],
  8096. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8097. );
  8098. $data ['collectArray'] = $collectArray;
  8099. $data ['adjustment'] = $adjustment;
  8100. $data ['totalPrice'] = $collectHtml;
  8101. $data ['totalYear'] = $total;
  8102. $data ['year'] = $year;
  8103. $dateHtml = "";
  8104. $now = date ( "Y" );
  8105. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  8106. if ($YEARD <= $now) {
  8107. $dateHtml .= '<option ';
  8108. if ($year == $YEARD) {
  8109. $dateHtml .= 'selected ';
  8110. }
  8111. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  8112. }
  8113. }
  8114. $data ['dateHtml'] = $dateHtml;
  8115. $data ['memu'] = "receipt";
  8116. $data ['staff'] = $this->staff;
  8117. $data ['receiptMemu'] = 'personalCollect';
  8118. $data ['verifyId'] = $this->verifyId;
  8119. $data ['executeId'] = $this->executeId;
  8120. // year staff status 2,4
  8121. if ($year < date ( "Y" )) {
  8122. Doo::loadModel ( 'receipt' );
  8123. $receipt = new receipt ();
  8124. $receiptList = $receipt->find ( array (
  8125. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  8126. 'asArray' => true
  8127. ) );
  8128. if (empty ( $receiptList )) {
  8129. ob_start ();
  8130. $this->render ( "/admin/saeaCollectArticles", $data );
  8131. $this->cacheFile ( $path );
  8132. die ();
  8133. }
  8134. }
  8135. $this->render ( "/admin/saeaCollectArticles", $data );
  8136. }
  8137. function companyCategoryCollect() {
  8138. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8139. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  8140. $this->showCache ( $path );
  8141. Doo::loadModel ( 'L_category' );
  8142. Doo::loadModel ( 'itemStatistics' );
  8143. Doo::loadModel ( 'statistics' );
  8144. $statistics = new statistics ();
  8145. $Lcategory = new L_category ();
  8146. $itemStatistics = new itemStatistics ();
  8147. Doo::loadModel ( "receiptAuthorityManage" );
  8148. $receiptAuthorityManage = new receiptAuthorityManage ();
  8149. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  8150. $cidList = array ();
  8151. foreach ( $imcStaff as $key => $value ) {
  8152. array_push ( $cidList, $value ['cid'] );
  8153. }
  8154. $cidString = implode ( ',', $cidList );
  8155. $LcategoryList = $Lcategory->find ( array (
  8156. 'where' => ' cid in (' . $cidString . ')',
  8157. 'asArray' => true
  8158. ) ); // 'staff='.$this->staff[0]['sid']." and
  8159. $itemStatisticsList = $itemStatistics->find ( array (
  8160. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8161. 'where' => " Year(date)=" . $year,
  8162. 'groupby' => 'cid,Month(date)',
  8163. 'asArray' => true
  8164. ) );
  8165. // ceatre companyCollectHtml
  8166. foreach ( $LcategoryList as $value ) {
  8167. $html = "";
  8168. $asum = 0;
  8169. for($i = 1; $i <= 12; $i ++) {
  8170. $falg = true;
  8171. foreach ( $itemStatisticsList as $v ) {
  8172. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  8173. $asum += $v ['price'];
  8174. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8175. $falg = false;
  8176. break;
  8177. }
  8178. }
  8179. if ($falg)
  8180. $html .= '<td class="taR">-</td>';
  8181. }
  8182. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8183. $collectHtml [$value ['title']] = array (
  8184. 'html' => $html,
  8185. 'cid' => $value ['cid']
  8186. );
  8187. }
  8188. $data ['companyHtml'] = $collectHtml;
  8189. // total price html
  8190. $collectHtml = "";
  8191. $total = 0;
  8192. for($i = 1; $i <= 12; $i ++) {
  8193. $sumPrice = 0;
  8194. foreach ( $itemStatisticsList as $key => $value ) {
  8195. if ($value ['month'] == $i) {
  8196. $sumPrice += $value ['price'];
  8197. }
  8198. }
  8199. if ($sumPrice == 0)
  8200. $collectHtml .= '<td class="taR">-</td>';
  8201. else
  8202. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8203. $total += $sumPrice;
  8204. }
  8205. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8206. $data ['companyTotalHtml'] = $collectHtml;
  8207. $data ['total'] = $total;
  8208. // statistics html
  8209. // echo $cidString;
  8210. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  8211. if (empty ( $stList ))
  8212. $stList = array (
  8213. 'rePrice' => 0,
  8214. 'agPrice' => 0
  8215. );
  8216. $data ['stList'] = array (
  8217. 'rePrice' => $stList ['rePrice'],
  8218. 'agPrice' => $stList ['agPrice'],
  8219. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8220. );
  8221. $data ['year'] = $year;
  8222. $data ['memu'] = "receipt";
  8223. $data ['staff'] = $this->staff;
  8224. $data ['receiptMemu'] = 'companyCategoryCollect';
  8225. $data ['verifyId'] = $this->verifyId;
  8226. $data ['executeId'] = $this->executeId;
  8227. $dateHtml = "";
  8228. $now = date ( "Y" );
  8229. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  8230. if ($YEARD <= $now) {
  8231. $dateHtml .= '<option ';
  8232. if ($year == $YEARD) {
  8233. $dateHtml .= 'selected ';
  8234. }
  8235. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  8236. }
  8237. }
  8238. $data ['dateHtml'] = $dateHtml;
  8239. // year staff status 2,4
  8240. if ($year < date ( "Y" )) {
  8241. Doo::loadModel ( 'receipt' );
  8242. $receipt = new receipt ();
  8243. $receiptList = $receipt->find ( array (
  8244. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  8245. 'asArray' => true
  8246. ) );
  8247. if (empty ( $receiptList )) {
  8248. ob_start ();
  8249. $this->render ( "/admin/saeaCompanyCollect", $data );
  8250. $this->cacheFile ( $path );
  8251. die ();
  8252. }
  8253. }
  8254. $this->render ( "/admin/saeaCompanyCollect", $data );
  8255. }
  8256. function categoryCollectDetail() {
  8257. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8258. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  8259. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  8260. $this->showCache ( $path );
  8261. Doo::loadModel ( 'statistics' );
  8262. $statistics = new statistics ();
  8263. Doo::loadModel ( "receiptDetail" );
  8264. $receiptDetail = new receiptDetail ();
  8265. Doo::loadModel ( 'L_category' );
  8266. $Lcategory = new L_category ();
  8267. Doo::loadModel ( 'accountItem' );
  8268. $accountItem = new accountItem ();
  8269. Doo::loadModel ( "receiptAuthorityManage" );
  8270. $receiptAuthorityManage = new receiptAuthorityManage ();
  8271. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  8272. $cidList = array ();
  8273. foreach ( $imcStaff as $key => $value ) {
  8274. array_push ( $cidList, $value ['cid'] );
  8275. }
  8276. $cidString = implode ( ',', $cidList );
  8277. $LcategoryList = $Lcategory->find ( array (
  8278. 'where' => 'cid in (' . $cidString . ')',
  8279. 'asArray' => true
  8280. ) );
  8281. if ($cid == 0) {
  8282. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  8283. if ($cid == 0)
  8284. $cid = $LcategoryList [0] ['cid'];
  8285. }
  8286. $data ['LcategoryList'] = $LcategoryList;
  8287. $receiptCollectList = $receiptDetail->find ( array (
  8288. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8289. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  8290. 'groupby' => 'item,Month(pastDate)',
  8291. 'asArray' => true
  8292. ) );
  8293. $accountList = $accountItem->find ( array (
  8294. 'asArray' => true
  8295. ) );
  8296. // create CollectDetail HTML
  8297. $collectHtml = array ();
  8298. foreach ( $accountList as $key => $value ) {
  8299. $html = "";
  8300. $asum = 0;
  8301. for($i = 1; $i <= 12; $i ++) {
  8302. $falg = true;
  8303. foreach ( $receiptCollectList as $v ) {
  8304. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  8305. $asum += $v ['price'];
  8306. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8307. $falg = false;
  8308. break;
  8309. }
  8310. }
  8311. if ($falg)
  8312. $html .= '<td class="taR">-</td>';
  8313. }
  8314. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8315. $collectHtml [$value ['category']] [$value ['name']] = $html;
  8316. }
  8317. $data ['collectHtml'] = $collectHtml;
  8318. // create Adjustment price html
  8319. $receiptCollectList = $receiptDetail->find ( array (
  8320. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  8321. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  8322. 'groupby' => 'itemCategory,Month(pastDate)',
  8323. 'asArray' => true
  8324. ) );
  8325. $adjustment = array ();
  8326. $collectArray = array (
  8327. '日常相关费用' => array (),
  8328. '差旅相关费用' => array (),
  8329. '培训班费用' => array (),
  8330. '其他' => array ()
  8331. );
  8332. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  8333. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  8334. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  8335. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  8336. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  8337. array_push ( $collectArray ['培训班费用'], $collectHtml );
  8338. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  8339. array_push ( $collectArray ['其他'], $collectHtml );
  8340. $data ['collectArray'] = $collectArray;
  8341. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  8342. array_push ( $adjustment, $collectHtml );
  8343. $data ['adjustment'] = $adjustment;
  8344. // total price html
  8345. $collectHtml = "";
  8346. $total = 0;
  8347. for($i = 1; $i <= 12; $i ++) {
  8348. $sumPrice = 0;
  8349. foreach ( $receiptCollectList as $key => $value ) {
  8350. if ($value ['month'] == $i) {
  8351. $sumPrice += $value ['price'];
  8352. }
  8353. }
  8354. if ($sumPrice == 0)
  8355. $collectHtml .= '<td class="taR">-</td>';
  8356. else
  8357. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8358. $total += $sumPrice;
  8359. }
  8360. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8361. // statistics html
  8362. $stList = $statistics->statisticsByCid ( $year, $cid );
  8363. if (empty ( $stList ))
  8364. $stList = array (
  8365. 'rePrice' => 0,
  8366. 'agPrice' => 0
  8367. );
  8368. $data ['stList'] = array (
  8369. 'rePrice' => $stList ['rePrice'],
  8370. 'agPrice' => $stList ['agPrice'],
  8371. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8372. );
  8373. $data ['totalYear'] = $total;
  8374. $data ['year'] = $year;
  8375. $data ['cid'] = $cid;
  8376. $data ['memu'] = "receipt";
  8377. $data ['staff'] = $this->staff;
  8378. $data ['receiptMemu'] = 'companyCategoryCollect';
  8379. $data ['verifyId'] = $this->verifyId;
  8380. $data ['executeId'] = $this->executeId;
  8381. // year staff status 2,4
  8382. if ($year < date ( "Y" )) {
  8383. Doo::loadModel ( 'receipt' );
  8384. $receipt = new receipt ();
  8385. $receiptList = $receipt->find ( array (
  8386. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  8387. 'asArray' => true
  8388. ) );
  8389. if (empty ( $receiptList )) {
  8390. ob_start ();
  8391. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  8392. $this->cacheFile ( $path );
  8393. die ();
  8394. }
  8395. }
  8396. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  8397. }
  8398. function staffCollect() {
  8399. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8400. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  8401. // $this->showCache($path);
  8402. Doo::loadModel ( 'statistics' );
  8403. $statistics = new statistics ();
  8404. Doo::loadModel ( "receiptDetail" );
  8405. $receiptDetail = new receiptDetail ();
  8406. Doo::loadModel ( 'L_category' );
  8407. $Lcategory = new L_category ();
  8408. Doo::loadModel ( 'accountItem' );
  8409. $accountItem = new accountItem ();
  8410. Doo::loadModel ( 'staff' );
  8411. $staff = new staff ();
  8412. Doo::loadModel ( 'itemStatistics' );
  8413. $itemStatistics = new itemStatistics ();
  8414. Doo::loadModel ( "receiptAuthorityManage" );
  8415. $receiptAuthorityManage = new receiptAuthorityManage ();
  8416. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  8417. $cidList = array ();
  8418. foreach ( $imcStaff as $key => $value ) {
  8419. array_push ( $cidList, $value ['cid'] );
  8420. }
  8421. $cidString = implode ( ',', $cidList );
  8422. // statistics html
  8423. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  8424. if (empty ( $stList ))
  8425. $stList = array (
  8426. 'rePrice' => 0,
  8427. 'agPrice' => 0
  8428. );
  8429. $data ['stList'] = array (
  8430. 'rePrice' => $stList ['rePrice'],
  8431. 'agPrice' => $stList ['agPrice'],
  8432. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8433. );
  8434. // ---
  8435. $staffList = $staff->find ( array (
  8436. 'where' => 'username !="admin"',
  8437. 'asArray' => true
  8438. ) );
  8439. $LcategoryList = $Lcategory->find ( array (
  8440. 'asArray' => true
  8441. ) ); // 'staff='.$this->staff[0]['sid']." and
  8442. $itemStatisticsList = $itemStatistics->find ( array (
  8443. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8444. 'where' => " Year(date)=" . $year . ' and cid in (' . $cidString . ')',
  8445. 'groupby' => 'staff,Month(date)',
  8446. 'asArray' => true
  8447. ) );
  8448. $categoryList = $staff->find ( array (
  8449. 'select' => 'COUNT(*) as count,cid,category',
  8450. 'where' => 'username !="admin" and cid in (' . $cidString . ')',
  8451. 'groupby' => 'cid',
  8452. 'asArray' => true
  8453. ) );
  8454. // print_r($itemStatisticsList);die;
  8455. // ceatre companyCollectHtml
  8456. foreach ( $categoryList as $vlu ) {
  8457. $count = $vlu ['count'] + 1;
  8458. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  8459. $m1 = 0;
  8460. $m2 = 0;
  8461. $m3 = 0;
  8462. $m4 = 0;
  8463. $m5 = 0;
  8464. $m6 = 0;
  8465. $m7 = 0;
  8466. $m8 = 0;
  8467. $m9 = 0;
  8468. $m10 = 0;
  8469. $m11 = 0;
  8470. $m12 = 0;
  8471. $m13 = 0;
  8472. foreach ( $staffList as $value ) {
  8473. if ($vlu ['cid'] == $value ['cid']) {
  8474. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  8475. $asum = 0;
  8476. for($i = 1; $i <= 12; $i ++) {
  8477. $falg = true;
  8478. foreach ( $itemStatisticsList as $v ) {
  8479. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  8480. if ($v ['month'] == 1)
  8481. $m1 += $v ['price'];
  8482. if ($v ['month'] == 2)
  8483. $m2 += $v ['price'];
  8484. if ($v ['month'] == 3)
  8485. $m3 += $v ['price'];
  8486. if ($v ['month'] == 4)
  8487. $m4 += $v ['price'];
  8488. if ($v ['month'] == 5)
  8489. $m5 += $v ['price'];
  8490. if ($v ['month'] == 6)
  8491. $m6 += $v ['price'];
  8492. if ($v ['month'] == 7)
  8493. $m7 += $v ['price'];
  8494. if ($v ['month'] == 8)
  8495. $m8 += $v ['price'];
  8496. if ($v ['month'] == 9)
  8497. $m9 += $v ['price'];
  8498. if ($v ['month'] == 10)
  8499. $m10 += $v ['price'];
  8500. if ($v ['month'] == 11)
  8501. $m11 += $v ['price'];
  8502. if ($v ['month'] == 12)
  8503. $m12 += $v ['price'];
  8504. $asum += $v ['price'];
  8505. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8506. $falg = false;
  8507. break;
  8508. }
  8509. }
  8510. if ($falg)
  8511. $html .= '<td class="taR">-</td>';
  8512. }
  8513. $m13 += $asum;
  8514. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8515. $collectHtml [$value ['username'] . '_' . $value ['sid']] = array (
  8516. 'html' => $html,
  8517. 'sid' => $value ['sid']
  8518. );
  8519. $html = "";
  8520. }
  8521. }
  8522. $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>
  8523. <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>
  8524. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  8525. $collectHtml [$vlu ['cid']] = array (
  8526. 'html' => $hl,
  8527. 'sid' => ''
  8528. );
  8529. }
  8530. $data ['companyHtml'] = $collectHtml;
  8531. // total price html
  8532. $collectHtml = "";
  8533. $total = 0;
  8534. for($i = 1; $i <= 12; $i ++) {
  8535. $sumPrice = 0;
  8536. foreach ( $itemStatisticsList as $key => $value ) {
  8537. if ($value ['month'] == $i) {
  8538. $sumPrice += $value ['price'];
  8539. }
  8540. }
  8541. if ($sumPrice == 0)
  8542. $collectHtml .= '<td class="taR">-</td>';
  8543. else
  8544. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8545. $total += $sumPrice;
  8546. }
  8547. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8548. $data ['companyTotalHtml'] = $collectHtml;
  8549. $data ['total'] = $total;
  8550. $data ['year'] = $year;
  8551. $data ['memu'] = "receipt";
  8552. $data ['staff'] = $this->staff;
  8553. $data ['receiptMemu'] = 'companyCategoryCollect';
  8554. $data ['verifyId'] = $this->verifyId;
  8555. $data ['executeId'] = $this->executeId;
  8556. if ($year <= date ( "Y" )) {
  8557. Doo::loadModel ( 'receipt' );
  8558. $receipt = new receipt ();
  8559. $receiptList = $receipt->find ( array (
  8560. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  8561. 'asArray' => true
  8562. ) );
  8563. if (empty ( $receiptList )) { // generated files
  8564. ob_start ();
  8565. $this->render ( "/admin/saeaStaffCollectB", $data );
  8566. $this->cacheFile ( $path );
  8567. die ();
  8568. }
  8569. }
  8570. $this->render ( "/admin/saeaStaffCollectB", $data );
  8571. }
  8572. function staffCollectBak() {
  8573. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8574. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  8575. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  8576. $this->showCache ( $path );
  8577. Doo::loadModel ( 'statistics' );
  8578. $statistics = new statistics ();
  8579. Doo::loadModel ( "receiptDetail" );
  8580. $receiptDetail = new receiptDetail ();
  8581. Doo::loadModel ( 'L_category' );
  8582. $Lcategory = new L_category ();
  8583. Doo::loadModel ( 'accountItem' );
  8584. $accountItem = new accountItem ();
  8585. Doo::loadModel ( 'staff' );
  8586. $staff = new staff ();
  8587. Doo::loadModel ( 'itemStatistics' );
  8588. $itemStatistics = new itemStatistics ();
  8589. $itemStatisticsList = $itemStatistics->find ( array (
  8590. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8591. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8592. 'groupby' => 'staff,itemCategory,Month(date)',
  8593. 'asArray' => true
  8594. ) );
  8595. $itemCategoryList = $itemStatistics->find ( array (
  8596. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8597. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8598. 'groupby' => 'cid,itemCategory,Month(date)',
  8599. 'asArray' => true
  8600. ) );
  8601. $LcategoryList = $Lcategory->find ( array (
  8602. 'asArray' => true
  8603. ) );
  8604. $staffList = $staff->find ( array (
  8605. 'asArray' => true
  8606. ) );
  8607. $htmlArray = array ();
  8608. foreach ( $LcategoryList as $value ) {
  8609. $htmlArray [$value ['title']] = array ();
  8610. foreach ( $staffList as $v ) {
  8611. if ($value ['cid'] == $v ['cid']) {
  8612. $html = "";
  8613. $falg = true;
  8614. $staffSumPrice = 0;
  8615. foreach ( $itemStatisticsList as $a ) {
  8616. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  8617. if (empty ( $a ['price'] )) {
  8618. $html .= '<td class="taR">-</td>';
  8619. $falg = false;
  8620. break;
  8621. } else {
  8622. $staffSumPrice += $a ['price'];
  8623. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8624. $falg = false;
  8625. break;
  8626. }
  8627. }
  8628. }
  8629. if ($falg) {
  8630. $html .= '<td class="taR">-</td>';
  8631. $falg = true;
  8632. }
  8633. $falg = true;
  8634. foreach ( $itemStatisticsList as $a ) {
  8635. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  8636. if (empty ( $a ['price'] )) {
  8637. $html .= '<td class="taR">-</td>';
  8638. $falg = false;
  8639. break;
  8640. } else {
  8641. $staffSumPrice += $a ['price'];
  8642. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8643. $falg = false;
  8644. break;
  8645. }
  8646. }
  8647. }
  8648. if ($falg) {
  8649. $html .= '<td class="taR">-</td>';
  8650. $falg = true;
  8651. }
  8652. $falg = true;
  8653. foreach ( $itemStatisticsList as $a ) {
  8654. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  8655. if (empty ( $a ['price'] )) {
  8656. $html .= '<td class="taR">-</td>';
  8657. $falg = false;
  8658. break;
  8659. } else {
  8660. $staffSumPrice += $a ['price'];
  8661. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8662. $falg = false;
  8663. break;
  8664. }
  8665. }
  8666. }
  8667. if ($falg) {
  8668. $html .= '<td class="taR">-</td>';
  8669. $falg = true;
  8670. }
  8671. $falg = true;
  8672. foreach ( $itemStatisticsList as $a ) {
  8673. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  8674. if (! empty ( $a ['price'] )) {
  8675. $staffSumPrice += $a ['price'];
  8676. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8677. $falg = false;
  8678. break;
  8679. } else {
  8680. $html .= '<td class="taR">-</td>';
  8681. $falg = false;
  8682. break;
  8683. }
  8684. }
  8685. }
  8686. if ($falg) {
  8687. $html .= '<td class="taR">-</td>';
  8688. $falg = true;
  8689. }
  8690. $falg = true;
  8691. foreach ( $itemStatisticsList as $a ) {
  8692. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  8693. if (! empty ( $a ['price'] )) {
  8694. $staffSumPrice += $a ['price'];
  8695. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8696. $falg = false;
  8697. break;
  8698. } else {
  8699. $html .= '<td class="taR">-</td>';
  8700. $falg = false;
  8701. break;
  8702. }
  8703. }
  8704. }
  8705. if ($falg) {
  8706. $html .= '<td class="taR">-</td>';
  8707. $falg = true;
  8708. }
  8709. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  8710. $htmlArray [$value ['title']] [$v ['username']] = $html;
  8711. }
  8712. }
  8713. /* -- --- */
  8714. // 合计费用
  8715. $cateHtml = "";
  8716. $catePrice = 0;
  8717. $cateFalg = true;
  8718. foreach ( $itemCategoryList as $l ) {
  8719. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  8720. if (empty ( $l ['price'] )) {
  8721. $cateHtml .= '<td class="colGreen taR">-</td>';
  8722. $cateFalg = false;
  8723. break;
  8724. } else {
  8725. $catePrice += $l ['price'];
  8726. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8727. $cateFalg = false;
  8728. break;
  8729. }
  8730. }
  8731. }
  8732. if ($cateFalg) {
  8733. $cateHtml .= '<td class="colGreen taR">-</td>';
  8734. $cateFalg = true;
  8735. }
  8736. $cateFalg = true;
  8737. foreach ( $itemCategoryList as $l ) {
  8738. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  8739. if (empty ( $l ['price'] )) {
  8740. $cateHtml .= '<td class="colGreen taR">-</td>';
  8741. $cateFalg = false;
  8742. break;
  8743. } else {
  8744. $catePrice += $l ['price'];
  8745. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8746. $cateFalg = false;
  8747. break;
  8748. }
  8749. }
  8750. }
  8751. if ($cateFalg) {
  8752. $cateHtml .= '<td class="colGreen taR">-</td>';
  8753. $cateFalg = true;
  8754. }
  8755. $cateFalg = true;
  8756. foreach ( $itemCategoryList as $l ) {
  8757. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  8758. if (empty ( $l ['price'] )) {
  8759. $cateHtml .= '<td class="colGreen taR">-</td>';
  8760. $cateFalg = false;
  8761. break;
  8762. } else {
  8763. $catePrice += $l ['price'];
  8764. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8765. $cateFalg = false;
  8766. break;
  8767. }
  8768. }
  8769. }
  8770. if ($cateFalg) {
  8771. $cateHtml .= '<td class="colGreen taR">-</td>';
  8772. $cateFalg = true;
  8773. }
  8774. $cateFalg = true;
  8775. foreach ( $itemCategoryList as $l ) {
  8776. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  8777. if (empty ( $l ['price'] )) {
  8778. $cateHtml .= '<td class="colGreen taR">-</td>';
  8779. $cateFalg = false;
  8780. break;
  8781. } else {
  8782. $catePrice += $l ['price'];
  8783. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8784. $cateFalg = false;
  8785. break;
  8786. }
  8787. }
  8788. }
  8789. if ($cateFalg) {
  8790. $cateHtml .= '<td class="colGreen taR">-</td>';
  8791. $cateFalg = true;
  8792. }
  8793. $cateFalg = true;
  8794. foreach ( $itemCategoryList as $l ) {
  8795. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  8796. if (empty ( $l ['price'] )) {
  8797. $cateHtml .= '<td class="colGreen taR">-</td>';
  8798. $cateFalg = false;
  8799. break;
  8800. } else {
  8801. $catePrice += $l ['price'];
  8802. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8803. $cateFalg = false;
  8804. break;
  8805. }
  8806. }
  8807. }
  8808. if ($cateFalg) {
  8809. $cateHtml .= '<td class="colGreen taR">-</td>';
  8810. $cateFalg = true;
  8811. }
  8812. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  8813. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  8814. /* -- --- */
  8815. }
  8816. // print_r($htmlArray);die;
  8817. $data ['htmlArray'] = $htmlArray;
  8818. // statistics html
  8819. $stList = $statistics->getOne ( array (
  8820. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8821. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8822. 'groupby' => 'Month(date)',
  8823. 'asArray' => true
  8824. ) );
  8825. if (empty ( $stList ))
  8826. $stList = array (
  8827. 'rePrice' => 0,
  8828. 'agPrice' => 0
  8829. );
  8830. $data ['stList'] = array (
  8831. 'rePrice' => $stList ['rePrice'],
  8832. 'agPrice' => $stList ['agPrice'],
  8833. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8834. );
  8835. $monthHtml = "";
  8836. for($i = 1; $i <= 12; $i ++) {
  8837. if ($i == $month)
  8838. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8839. else
  8840. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8841. }
  8842. $data ['monthHtml'] = $monthHtml;
  8843. $data ['year'] = $year;
  8844. $data ['month'] = $month;
  8845. $data ['memu'] = "receipt";
  8846. $data ['staff'] = $this->staff;
  8847. $data ['receiptMemu'] = 'companyCategoryCollect';
  8848. $data ['verifyId'] = $this->verifyId;
  8849. $data ['executeId'] = $this->executeId;
  8850. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  8851. Doo::loadModel ( 'receipt' );
  8852. $receipt = new receipt ();
  8853. $receiptList = $receipt->find ( array (
  8854. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  8855. 'asArray' => true
  8856. ) );
  8857. if (empty ( $receiptList )) { // generated files
  8858. ob_start ();
  8859. $this->render ( "/admin/saeaStaffCollect", $data );
  8860. $this->cacheFile ( $path );
  8861. die ();
  8862. }
  8863. }
  8864. $this->render ( "/admin/saeaStaffCollect", $data );
  8865. }
  8866. /**
  8867. * 日常收支
  8868. */
  8869. function payments() {
  8870. //include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  8871. Doo::loadModel ( "execute" );
  8872. $execute = new execute ();
  8873. if(!$execute->isPaymentsShow($this->staff [0] ['sid'])){
  8874. die ( 'illegal request' );
  8875. }
  8876. Doo::loadModel ( "accountBook" );
  8877. $accountBook = new accountBook ();
  8878. Doo::loadModel ( "accountBookStatistics" );
  8879. $accountBookStatistics = new accountBookStatistics ();
  8880. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  8881. $list = $accountBook->getAccountBookByLimit ( 10 );
  8882. $data ['date'] = date ( "Y-m-d" );
  8883. $data ['statisticsList'] = $statisticsList;
  8884. $data ['list'] = $list;
  8885. $data ['memu'] = "receipt";
  8886. $data ['staff'] = $this->staff;
  8887. $data ['receiptMemu'] = 'payments';
  8888. $data ['verifyId'] = $this->verifyId;
  8889. $data ['executeId'] = $this->executeId;
  8890. $this->render ( "/expenses/payments", $data );
  8891. }
  8892. function paymentsIncomeDo() {
  8893. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  8894. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  8895. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  8896. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  8897. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  8898. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  8899. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  8900. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  8901. Doo::loadClass ( 'XDeode' );
  8902. $XDeode = new XDeode ( 5 );
  8903. Doo::loadModel ( "accountBook" );
  8904. Doo::loadModel ( "accountBookStatistics" );
  8905. Doo::loadModel ( 'wasteBook' );
  8906. // 记录流水时银行的转换
  8907. $accountBank = '';
  8908. if ($receivedBank == '纵横广发') {
  8909. $accountBank = 'CGBDeposit';
  8910. } elseif ($receivedBank == '纵横工行') {
  8911. $accountBank = 'ICBCDeposit';
  8912. } elseif ($receivedBank == '华润银行') {
  8913. $accountBank = 'HUADeposit';
  8914. } elseif ($receivedBank == '个人广发') {
  8915. $accountBank = 'PersonalDeposit';
  8916. }
  8917. if (empty ( $accountBank ))
  8918. die ( 'illegal request' );
  8919. // 收入为理财时特殊处理
  8920. if ($accountType == 7 || $accountType == 9) {
  8921. if ($receivedBank == '个人广发') {
  8922. die ( '个人广发 illegal request' );
  8923. }
  8924. // 添加一条收入
  8925. $accountBook = new accountBook ();
  8926. $accountBook->accountType = 10;
  8927. $accountBook->accountMsg = $accountMsg;
  8928. $accountBook->receivedPrice = $receivedPrice;
  8929. $accountBook->receivedMsg = $receivedMsg;
  8930. $accountBook->receivedBank = $receivedBank;
  8931. $accountBook->receivedDate = $receivedDate;
  8932. $accountBook->remarks = $remarks;
  8933. $accountBook->expensesType = 1;
  8934. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  8935. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  8936. $accountBook->inputStaff = $this->staff [0] ['sid'];
  8937. $inComeId = $accountBook->insert ();
  8938. // 收支汇总-添加一条收入日常汇总
  8939. $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  8940. $accountBookStatistics = new accountBookStatistics ();
  8941. $item = array (
  8942. 'date' => date ( "Y-m-d" ),
  8943. 'accountType' => $abDetail ['accountType'],
  8944. 'accountMsg' => $abDetail ['accountMsg'],
  8945. 'aid' => $abDetail ['aid'],
  8946. 'inComePrice' => $abDetail ['receivedPrice'],
  8947. 'expensesType' => $abDetail ['expensesType']
  8948. );
  8949. $accountBookStatistics->setAccountBookStatistics ( $item );
  8950. // 添加收入流水
  8951. $wasteBook = new wasteBook ();
  8952. $itemWaste = array (
  8953. 'accountPriceShow' => $receivedPrice,
  8954. 'accountPrice' => $receivedPrice,
  8955. 'expensesType' => 1,
  8956. 'accountType' => 6, // 流水类型
  8957. 'dataID' => $inComeId,
  8958. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  8959. 'accountBank' => $accountBank,
  8960. 'category' => $this->staff [0] ['category'],
  8961. 'cid' => $this->staff [0] ['cid'],
  8962. 'name' => $this->staff [0] ['username'],
  8963. 'sid' => $this->staff [0] ['sid'],
  8964. 'inputDate' => date ( "Y-m-d H:i:s" )
  8965. );
  8966. $wasteBook->setAccountBookStatistics ( $itemWaste );
  8967. // 添加一条理财支出
  8968. $accountBank = 'CGBDeposit';
  8969. $expenditureBank = '纵横广发';
  8970. $dailyExpenditureType = 4;
  8971. if ($accountType == 9) {
  8972. $accountBank = 'ICBCDeposit';
  8973. $expenditureBank = '纵横工行';
  8974. $dailyExpenditureType = 6;
  8975. }
  8976. $accountBook = new accountBook ();
  8977. $accountBook->expensesType = 2;
  8978. $accountBook->expenditureType = $dailyExpenditureType;
  8979. $accountBook->expenditureMsg = $accountMsg;
  8980. $accountBook->expenditurePrice = $receivedPrice;
  8981. $accountBook->expenditureBank = $expenditureBank;
  8982. $accountBook->expenditureDate = $receivedDate;
  8983. $accountBook->remarks = $remarks;
  8984. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  8985. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  8986. $accountBook->inputStaff = $this->staff [0] ['sid'];
  8987. $id = $accountBook->insert ();
  8988. // 收支汇总-添加一条理财支出汇总
  8989. $abDetail = $accountBook->getAccountBookByAid ( $id );
  8990. $accountBookStatistics = new accountBookStatistics ();
  8991. $item = array (
  8992. 'date' => date ( "Y-m-d" ),
  8993. 'accountType' => $abDetail ['accountType'],
  8994. 'accountMsg' => $abDetail ['accountMsg'],
  8995. 'aid' => $abDetail ['aid'],
  8996. 'financingPrice' => - $receivedPrice,
  8997. 'expensesType' => 3
  8998. );
  8999. $accountBookStatistics->setAccountBookStatistics ( $item );
  9000. // 添加一条支出理财流水
  9001. $accountTypeWaste = 5;
  9002. if ($accountMsg == '公司固定') {
  9003. $accountTypeWaste = 9;
  9004. } elseif ($accountMsg == '公司活期') {
  9005. $accountTypeWaste = 10;
  9006. } elseif ($accountMsg == '个人(GR)') {
  9007. $accountBank = 'PersonalDeposit';
  9008. }
  9009. $itemWaste = array (
  9010. 'expensesType' => 2,
  9011. 'accountType' => $accountTypeWaste,
  9012. 'accountPriceShow' => $receivedPrice,
  9013. 'accountPrice' => - $receivedPrice,
  9014. 'dataID' => $id,
  9015. 'dailyExpenditureType' => $dailyExpenditureType,
  9016. 'accountBank' => $accountBank,
  9017. 'category' => $this->staff [0] ['category'],
  9018. 'cid' => $this->staff [0] ['cid'],
  9019. 'name' => $this->staff [0] ['username'],
  9020. 'sid' => $this->staff [0] ['sid'],
  9021. 'inputDate' => date ( "Y-m-d H:i:s" )
  9022. )
  9023. ;
  9024. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9025. }elseif($accountType == 1){
  9026. if ($receivedBank == '个人广发')
  9027. die ( 'illegal request' );
  9028. // 添加一条收入
  9029. $accountBook = new accountBook ();
  9030. $accountBook->accountType = $accountType;
  9031. $accountBook->accountMsg = $accountMsg;
  9032. $accountBook->receivedPrice = $receivedPrice;
  9033. $accountBook->receivedMsg = $receivedMsg;
  9034. $accountBook->receivedBank = $receivedBank;
  9035. $accountBook->receivedDate = $receivedDate;
  9036. $accountBook->remarks = $remarks;
  9037. $accountBook->expensesType = 1;
  9038. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9039. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9040. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9041. $id = $accountBook->insert ();
  9042. $abDetail = $accountBook->getAccountBookByAid ( $id );
  9043. // 收支汇总-添加一条收入日常汇总
  9044. $accountBookStatistics = new accountBookStatistics ();
  9045. $item = array (
  9046. 'date' => date ( "Y-m-d" ),
  9047. 'accountType' => $abDetail ['accountType'],
  9048. 'accountMsg' => $abDetail ['accountMsg'],
  9049. 'aid' => $abDetail ['aid'],
  9050. 'expensesType' => $abDetail ['expensesType']
  9051. );
  9052. if ($abDetail ['accountType'] == 8) {
  9053. $item += array (
  9054. 'inComePrice' => $abDetail ['receivedPrice']
  9055. );
  9056. } else {
  9057. $item += array (
  9058. 'inComePrice' => $abDetail ['receivedPrice']
  9059. );
  9060. }
  9061. $accountBookStatistics->setAccountBookStatistics ( $item );
  9062. //流水存储方向
  9063. $itemWaste = array (
  9064. 'accountType' => 6, // 流水类型
  9065. );
  9066. // if($accountMsg=='银行存款'||$accountMsg=='固定理财收益'){
  9067. // }else
  9068. if($accountMsg=='活期理财收益'){
  9069. $itemWaste = array (
  9070. 'accountType' => 10, // 流水类型
  9071. );
  9072. }
  9073. // 添加收入流水
  9074. $wasteBook = new wasteBook ();
  9075. $itemWaste += array (
  9076. 'accountPrice' => $receivedPrice,
  9077. 'accountPriceShow' => $receivedPrice,
  9078. 'expensesType' => 1,
  9079. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  9080. 'dataID' => $id,
  9081. 'accountBank' => $accountBank,
  9082. 'category' => $this->staff [0] ['category'],
  9083. 'cid' => $this->staff [0] ['cid'],
  9084. 'name' => $this->staff [0] ['username'],
  9085. 'sid' => $this->staff [0] ['sid'],
  9086. 'inputDate' => date ( "Y-m-d H:i:s" )
  9087. );
  9088. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9089. } else { // 普通日常收入处理
  9090. // 添加一条收入
  9091. $accountBook = new accountBook ();
  9092. $accountBook->accountType = $accountType;
  9093. $accountBook->accountMsg = $accountMsg;
  9094. $accountBook->receivedPrice = $receivedPrice;
  9095. $accountBook->receivedMsg = $receivedMsg;
  9096. $accountBook->receivedBank = $receivedBank;
  9097. $accountBook->receivedDate = $receivedDate;
  9098. $accountBook->remarks = $remarks;
  9099. $accountBook->expensesType = 1;
  9100. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9101. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9102. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9103. $id = $accountBook->insert ();
  9104. $abDetail = $accountBook->getAccountBookByAid ( $id );
  9105. // 收支汇总-添加一条收入日常汇总
  9106. $accountBookStatistics = new accountBookStatistics ();
  9107. $item = array (
  9108. 'date' => date ( "Y-m-d" ),
  9109. 'accountType' => $abDetail ['accountType'],
  9110. 'accountMsg' => $abDetail ['accountMsg'],
  9111. 'aid' => $abDetail ['aid'],
  9112. 'expensesType' => $abDetail ['expensesType']
  9113. );
  9114. if ($abDetail ['accountType'] == 8) {
  9115. $item += array (
  9116. 'inComePrice' => $abDetail ['receivedPrice']
  9117. );
  9118. } else {
  9119. $item += array (
  9120. 'inComePrice' => $abDetail ['receivedPrice']
  9121. );
  9122. }
  9123. $accountBookStatistics->setAccountBookStatistics ( $item );
  9124. // 添加收入流水
  9125. $itemWaste = array (
  9126. 'accountPrice' => $receivedPrice
  9127. );
  9128. if ($receivedBank == '个人广发') {
  9129. $itemWaste = array (
  9130. 'accountPrice' => - $receivedPrice
  9131. );
  9132. }
  9133. $wasteBook = new wasteBook ();
  9134. $itemWaste += array (
  9135. 'accountPriceShow' => $receivedPrice,
  9136. 'expensesType' => 1,
  9137. 'accountType' => 6, // 流水类型
  9138. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  9139. 'dataID' => $id,
  9140. 'accountBank' => $accountBank,
  9141. 'category' => $this->staff [0] ['category'],
  9142. 'cid' => $this->staff [0] ['cid'],
  9143. 'name' => $this->staff [0] ['username'],
  9144. 'sid' => $this->staff [0] ['sid'],
  9145. 'inputDate' => date ( "Y-m-d H:i:s" )
  9146. );
  9147. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9148. }
  9149. }
  9150. return '/payments';
  9151. }
  9152. /**
  9153. * 添加收入
  9154. * @return string
  9155. */
  9156. function paymentsIncomeDo_() {
  9157. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  9158. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  9159. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  9160. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  9161. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  9162. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  9163. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  9164. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  9165. Doo::loadClass ( 'XDeode' );
  9166. $XDeode = new XDeode ( 5 );
  9167. Doo::loadModel ( "accountBook" );
  9168. $accountBook = new accountBook ();
  9169. $accountBank = '';
  9170. $accountTypeWaste = 6;
  9171. if ($receivedBank == '纵横广发') {
  9172. $accountBank = 'CGBDeposit';
  9173. } elseif ($receivedBank == '纵横工行') {
  9174. $accountBank = 'ICBCDeposit';
  9175. } elseif ($receivedBank == '华润银行') {
  9176. $accountBank = 'HUADeposit';
  9177. } elseif ($receivedBank == '个人广发') {
  9178. $accountBank = 'PersonalDeposit';
  9179. }
  9180. if (empty ( $accountBank ))
  9181. die ( 'illegal request' );
  9182. $dailyIncomeType = '';
  9183. $itemWaste = array (
  9184. 'accountPrice' => $receivedPrice,
  9185. 'expensesType' => 1
  9186. );
  9187. if ($receivedBank == '个人广发') {
  9188. $itemWaste = array (
  9189. 'accountPrice' => - $receivedPrice,
  9190. 'expensesType' => 1
  9191. );
  9192. }
  9193. if ($accountType == 4) {
  9194. $dailyIncomeType = 4;
  9195. } elseif ($accountType == 1) {
  9196. $dailyIncomeType = 1;
  9197. } elseif ($accountType == 2) {
  9198. $dailyIncomeType = 2;
  9199. } elseif ($accountType == 3) {
  9200. $dailyIncomeType = 3;
  9201. } elseif ($accountType == 5) {
  9202. $dailyIncomeType = 5;
  9203. } elseif ($accountType == 6) {
  9204. $dailyIncomeType = 6;
  9205. } elseif ($accountType == 7 || $accountType == 9) {
  9206. $dailyIncomeType = 7;
  9207. if ($accountMsg == '公司固定') {
  9208. $accountTypeWaste = 9;
  9209. } elseif ($accountMsg == '公司活期') {
  9210. $accountTypeWaste = 10;
  9211. } elseif ($accountMsg == '个人(GR)') {
  9212. $accountBank = 'PersonalDeposit';
  9213. }
  9214. $itemWaste = array (
  9215. 'accountPrice' => - $receivedPrice,
  9216. 'expensesType' => 2
  9217. );
  9218. } elseif ($accountType == 8) {
  9219. $dailyIncomeType = 8;
  9220. }
  9221. if (empty ( $dailyIncomeType ))
  9222. die ( 'illegal request' );
  9223. $accountBook->accountType = $accountType;
  9224. $accountBook->accountMsg = $accountMsg;
  9225. $accountBook->receivedPrice = $receivedPrice;
  9226. $accountBook->receivedMsg = $receivedMsg;
  9227. $accountBook->receivedBank = $receivedBank;
  9228. $accountBook->receivedDate = $receivedDate;
  9229. $accountBook->remarks = $remarks;
  9230. $accountBook->expensesType = 1;
  9231. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9232. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9233. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9234. $id = $accountBook->insert ();
  9235. //
  9236. $abDetail = $accountBook->getAccountBookByAid ( $id );
  9237. // 收支汇总
  9238. Doo::loadModel ( "accountBookStatistics" );
  9239. $accountBookStatistics = new accountBookStatistics ();
  9240. $item = array (
  9241. 'date' => date ( "Y-m-d" ),
  9242. 'accountType' => $abDetail ['accountType'],
  9243. 'accountMsg' => $abDetail ['accountMsg'],
  9244. 'aid' => $abDetail ['aid']
  9245. );
  9246. if ($abDetail ['expensesType'] == 1) {
  9247. if ($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) {
  9248. $item += array (
  9249. 'financingPrice' => - $receivedPrice,
  9250. 'expensesType' => 3
  9251. );
  9252. } else if ($abDetail ['accountType'] == 8) {
  9253. $item += array (
  9254. 'inComePrice' => - $abDetail ['receivedPrice'],
  9255. 'expensesType' => $abDetail ['expensesType']
  9256. );
  9257. } else {
  9258. $item += array (
  9259. 'inComePrice' => $abDetail ['receivedPrice'],
  9260. 'expensesType' => $abDetail ['expensesType']
  9261. );
  9262. }
  9263. }
  9264. $accountBookStatistics->setAccountBookStatistics ( $item );
  9265. // 为理财时需添加一条日常支出
  9266. if ($accountType == 7 || $accountType == 9) {
  9267. }
  9268. // 公司流水记录
  9269. Doo::loadModel ( 'wasteBook' );
  9270. $wasteBook = new wasteBook ();
  9271. // 银行
  9272. // if (empty($abDetail)){
  9273. $itemWaste += array (
  9274. 'accountPriceShow' => $receivedPrice,
  9275. 'dataID' => $id,
  9276. 'accountType' => $accountTypeWaste,
  9277. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  9278. 'accountBank' => $accountBank,
  9279. 'category' => $this->staff [0] ['category'],
  9280. 'cid' => $this->staff [0] ['cid'],
  9281. 'name' => $this->staff [0] ['username'],
  9282. 'sid' => $this->staff [0] ['sid'],
  9283. 'inputDate' => date ( "Y-m-d H:i:s" )
  9284. );
  9285. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9286. // }
  9287. // 类型为理财7或者9 要添加一笔理财支出
  9288. if ($accountType == 7 || $accountType == 9) {
  9289. $accountBank = 'CGBDeposit';
  9290. $expenditureBank = '纵横广发';
  9291. $dailyExpenditureType = 4;
  9292. if ($accountType == 9) {
  9293. $accountBank = 'ICBCDeposit';
  9294. $expenditureBank = '纵横工行';
  9295. $dailyExpenditureType = 6;
  9296. }
  9297. // 添加一条支出
  9298. $accountBook = new accountBook ();
  9299. $accountBook->expenditureType = $dailyExpenditureType;
  9300. $accountBook->expenditureMsg = $accountMsg;
  9301. $accountBook->expenditurePrice = $receivedPrice;
  9302. $accountBook->expenditureBank = $expenditureBank;
  9303. $accountBook->expenditureDate = $receivedDate;
  9304. $accountBook->remarks = $remarks;
  9305. $accountBook->expensesType = 2;
  9306. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9307. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9308. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9309. $id = $accountBook->insert ();
  9310. // 添加一条收入流水
  9311. $itemWaste = array (
  9312. 'accountPriceShow' => $receivedPrice,
  9313. 'accountPrice' => $receivedPrice,
  9314. 'dataID' => $id,
  9315. 'expensesType' => 2,
  9316. 'accountType' => $accountTypeWaste,
  9317. 'dailyExpenditureType' => $dailyExpenditureType,
  9318. 'accountBank' => $accountBank,
  9319. 'category' => $this->staff [0] ['category'],
  9320. 'cid' => $this->staff [0] ['cid'],
  9321. 'name' => $this->staff [0] ['username'],
  9322. 'sid' => $this->staff [0] ['sid'],
  9323. 'inputDate' => date ( "Y-m-d H:i:s" )
  9324. )
  9325. ;
  9326. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9327. }
  9328. }
  9329. return '/payments';
  9330. }
  9331. function paymentsExpenditureDo() {
  9332. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  9333. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  9334. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  9335. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  9336. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  9337. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  9338. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  9339. // 理财支出特殊处理
  9340. Doo::loadModel ( "accountBook" );
  9341. Doo::loadModel ( "accountBookStatistics" );
  9342. Doo::loadModel ( 'wasteBook' );
  9343. $accountBank = '';
  9344. if ($expenditureBank == '纵横广发') {
  9345. $accountBank = 'CGBDeposit';
  9346. } elseif ($expenditureBank == '纵横工行') {
  9347. $accountBank = 'ICBCDeposit';
  9348. } elseif ($expenditureBank == '华润银行') {
  9349. $accountBank = 'HUADeposit';
  9350. } elseif ($expenditureBank == '个人广发') {
  9351. $accountBank = 'PersonalDeposit';
  9352. }
  9353. if (empty ( $accountBank ))
  9354. die ( 'illegal request' );
  9355. if ($expenditureType == 4 || $expenditureType == 6) {
  9356. if ($expenditureBank == '个人广发') {
  9357. die ( '个人广发 illegal request' );
  9358. }
  9359. // 添加一笔日常支出
  9360. $accountBook = new accountBook ();
  9361. $accountBook->expensesType = 2;
  9362. $accountBook->expenditureType = 7;
  9363. $accountBook->expenditureMsg = $expenditureMsg;
  9364. $accountBook->expenditurePrice = $expenditurePrice;
  9365. $accountBook->expenditureBank = $expenditureBank;
  9366. $accountBook->expenditureDate = $expenditureDate;
  9367. $accountBook->remarks = $remarks;
  9368. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9369. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9370. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9371. $expenditureId = $accountBook->insert ();
  9372. // 添加日常支出汇总
  9373. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  9374. $accountBookStatistics = new accountBookStatistics ();
  9375. $item = array (
  9376. 'date' => date ( "Y-m-d" ),
  9377. 'expenditureType' => $abDetail ['expenditureType'],
  9378. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  9379. 'aid' => $abDetail ['aid'],
  9380. 'payPrice' => $abDetail ['expenditurePrice'],
  9381. 'expensesType' => $abDetail ['expensesType']
  9382. );
  9383. $accountBookStatistics->setAccountBookStatistics ( $item );
  9384. // 公司日常支出流水
  9385. $wasteBook = new wasteBook ();
  9386. $itemWaste = array (
  9387. 'accountPrice' => - $expenditurePrice
  9388. );
  9389. if ($expenditureBank == '个人广发') {
  9390. $itemWaste = array (
  9391. 'accountPrice' => $expenditurePrice
  9392. );
  9393. }
  9394. $itemWaste += array (
  9395. 'expensesType' => 2,
  9396. 'accountType' => 5,
  9397. 'dailyExpenditureType' => $expenditureType,
  9398. 'accountPriceShow' => $expenditurePrice,
  9399. 'accountPrice' => - $expenditurePrice,
  9400. 'dataID' => $expenditureId,
  9401. 'accountBank' => $accountBank,
  9402. 'category' => $this->staff [0] ['category'],
  9403. 'cid' => $this->staff [0] ['cid'],
  9404. 'name' => $this->staff [0] ['username'],
  9405. 'sid' => $this->staff [0] ['sid'],
  9406. 'inputDate' => date ( "Y-m-d H:i:s" )
  9407. );
  9408. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9409. // 添加一笔理财收入
  9410. $accountBank = 'CGBDeposit';
  9411. $dailyIncomeType = 7;
  9412. $receivedBank = '纵横广发';
  9413. if ($expenditureType == 6) {
  9414. $accountBank = 'ICBCDeposit';
  9415. $receivedBank = '纵横工行';
  9416. $dailyIncomeType = 9;
  9417. }
  9418. $accountBook = new accountBook ();
  9419. $accountBook->expensesType = 1;
  9420. $accountBook->accountType = $dailyIncomeType;
  9421. $accountBook->accountMsg = $expenditureMsg;
  9422. $accountBook->receivedPrice = $expenditurePrice;
  9423. $accountBook->receivedBank = $receivedBank;
  9424. $accountBook->receivedDate = $expenditureDate;
  9425. $accountBook->remarks = $remarks;
  9426. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9427. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9428. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9429. $id = $accountBook->insert ();
  9430. // 添加日常理财收入汇总
  9431. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  9432. $accountBookStatistics = new accountBookStatistics ();
  9433. $item = array (
  9434. 'date' => date ( "Y-m-d" ),
  9435. 'expenditureType' => $abDetail ['expenditureType'],
  9436. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  9437. 'aid' => $abDetail ['aid'],
  9438. 'financingPrice' => $expenditurePrice,
  9439. 'expensesType' => 3
  9440. );
  9441. $accountBookStatistics->setAccountBookStatistics ( $item );
  9442. // 添加一笔收入流水
  9443. if ($expenditureMsg == '公司固定') {
  9444. $accountTypeWaste = 9;
  9445. } elseif ($expenditureMsg == '公司活期') {
  9446. $accountTypeWaste = 10;
  9447. } elseif ($expenditureMsg == '个人(GR)') {
  9448. $accountBank = 'PersonalDeposit';
  9449. }
  9450. $itemWaste = array (
  9451. 'expensesType' => 1,
  9452. 'accountType' => $accountTypeWaste,
  9453. 'accountPriceShow' => $expenditurePrice,
  9454. 'accountPrice' => $expenditurePrice,
  9455. 'dataID' => $id,
  9456. 'dailyIncomeType' => $dailyIncomeType,
  9457. 'accountBank' => $accountBank,
  9458. 'category' => $this->staff [0] ['category'],
  9459. 'cid' => $this->staff [0] ['cid'],
  9460. 'name' => $this->staff [0] ['username'],
  9461. 'sid' => $this->staff [0] ['sid'],
  9462. 'inputDate' => date ( "Y-m-d H:i:s" )
  9463. );
  9464. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9465. } else {
  9466. // 添加一笔日常支出
  9467. $accountBook = new accountBook ();
  9468. $accountBook->expensesType = 2;
  9469. $accountBook->expenditureType = $expenditureType;
  9470. $accountBook->expenditureMsg = $expenditureMsg;
  9471. $accountBook->expenditurePrice = $expenditurePrice;
  9472. $accountBook->expenditureBank = $expenditureBank;
  9473. $accountBook->expenditureDate = $expenditureDate;
  9474. $accountBook->remarks = $remarks;
  9475. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9476. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9477. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9478. $id = $accountBook->insert ();
  9479. // 添加日常支出汇总
  9480. $abDetail = $accountBook->getAccountBookByAid ( $id );
  9481. $accountBookStatistics = new accountBookStatistics ();
  9482. $item = array (
  9483. 'date' => date ( "Y-m-d" ),
  9484. 'expenditureType' => $abDetail ['expenditureType'],
  9485. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  9486. 'aid' => $abDetail ['aid'],
  9487. 'expensesType' => $abDetail ['expensesType']
  9488. );
  9489. if ($expenditureType == 5) {
  9490. $item += array (
  9491. 'payPrice' => - $abDetail ['expenditurePrice']
  9492. );
  9493. } else {
  9494. $item += array (
  9495. 'payPrice' => $abDetail ['expenditurePrice']
  9496. );
  9497. }
  9498. $accountBookStatistics->setAccountBookStatistics ( $item );
  9499. // 公司日常支出流水
  9500. $wasteBook = new wasteBook ();
  9501. $itemWaste = array (
  9502. 'accountPrice' => - $expenditurePrice
  9503. );
  9504. if ($expenditureBank == '个人广发') {
  9505. $itemWaste = array (
  9506. 'accountPrice' => $expenditurePrice
  9507. );
  9508. }
  9509. $itemWaste += array (
  9510. 'expensesType' => 2,
  9511. 'accountType' => 5,
  9512. 'accountPriceShow' => $expenditurePrice,
  9513. 'dataID' => $id,
  9514. 'dailyExpenditureType' => $expenditureType,
  9515. 'accountBank' => $accountBank,
  9516. 'category' => $this->staff [0] ['category'],
  9517. 'cid' => $this->staff [0] ['cid'],
  9518. 'name' => $this->staff [0] ['username'],
  9519. 'sid' => $this->staff [0] ['sid'],
  9520. 'inputDate' => date ( "Y-m-d H:i:s" )
  9521. );
  9522. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9523. }
  9524. }
  9525. return '/payments';
  9526. }
  9527. /**
  9528. * 添加支出
  9529. */
  9530. function paymentsExpenditureDo_() {
  9531. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  9532. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  9533. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  9534. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  9535. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  9536. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  9537. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  9538. $dailyExpenditureType = '';
  9539. $accountTypeWaste = 5;
  9540. $accountBank = '';
  9541. if ($expenditureBank == '纵横广发') {
  9542. $accountBank = 'CGBDeposit';
  9543. } elseif ($expenditureBank == '纵横工行') {
  9544. $accountBank = 'ICBCDeposit';
  9545. } elseif ($expenditureBank == '华润银行') {
  9546. $accountBank = 'HUADeposit';
  9547. } elseif ($expenditureBank == '个人广发') {
  9548. $accountBank = 'PersonalDeposit';
  9549. }
  9550. if (empty ( $accountBank ))
  9551. die ( 'illegal request' );
  9552. $itemWaste = array (
  9553. 'accountPrice' => - $expenditurePrice
  9554. );
  9555. if ($expenditureBank == '个人广发') {
  9556. $itemWaste = array (
  9557. 'accountPrice' => $expenditurePrice
  9558. );
  9559. }
  9560. if ($expenditureType == 4 || $expenditureType == 6) {
  9561. $dailyExpenditureType = 4;
  9562. if ($expenditureMsg == '公司固定') {
  9563. $accountTypeWaste = 9;
  9564. } elseif ($expenditureMsg == '公司活期') {
  9565. $accountTypeWaste = 10;
  9566. } elseif ($expenditureMsg == '个人(GR)') {
  9567. $accountBank = 'PersonalDeposit';
  9568. }
  9569. $itemWaste = array (
  9570. 'accountPrice' => $expenditurePrice
  9571. );
  9572. } elseif ($expenditureType == 1) {
  9573. $dailyExpenditureType = 1;
  9574. } elseif ($expenditureType == 2) {
  9575. $dailyExpenditureType = 2;
  9576. } elseif ($expenditureType == 3) {
  9577. $dailyExpenditureType = 3;
  9578. } elseif ($expenditureType == 5) {
  9579. $dailyExpenditureType = 5;
  9580. }
  9581. if (empty ( $dailyExpenditureType ))
  9582. die ( 'illegal request' );
  9583. Doo::loadModel ( "accountBook" );
  9584. $accountBook = new accountBook ();
  9585. $accountBook->expenditureType = $expenditureType;
  9586. $accountBook->expenditureMsg = $expenditureMsg;
  9587. $accountBook->expenditurePrice = $expenditurePrice;
  9588. $accountBook->expenditureBank = $expenditureBank;
  9589. $accountBook->expenditureDate = $expenditureDate;
  9590. $accountBook->remarks = $remarks;
  9591. $accountBook->expensesType = 2;
  9592. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9593. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9594. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9595. $id = $accountBook->insert ();
  9596. //
  9597. $abDetail = $accountBook->getAccountBookByAid ( $id );
  9598. Doo::loadModel ( "accountBookStatistics" );
  9599. $accountBookStatistics = new accountBookStatistics ();
  9600. $item = array (
  9601. 'date' => date ( "Y-m-d" ),
  9602. 'expenditureType' => $abDetail ['expenditureType'],
  9603. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  9604. 'aid' => $abDetail ['aid']
  9605. );
  9606. if ($abDetail ['expensesType'] == 2) {
  9607. if ($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) {
  9608. $item += array (
  9609. 'financingPrice' => $expenditurePrice,
  9610. 'expensesType' => 3
  9611. );
  9612. } elseif ($abDetail ['expenditureType'] == 5) {
  9613. $item += array (
  9614. 'payPrice' => $abDetail ['expenditurePrice'],
  9615. 'expensesType' => $abDetail ['expensesType']
  9616. );
  9617. } else {
  9618. $item += array (
  9619. 'payPrice' => $abDetail ['expenditurePrice'],
  9620. 'expensesType' => $abDetail ['expensesType']
  9621. );
  9622. }
  9623. }
  9624. $accountBookStatistics->setAccountBookStatistics ( $item );
  9625. // 公司流水记录
  9626. Doo::loadModel ( 'wasteBook' );
  9627. $wasteBook = new wasteBook ();
  9628. $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountTypeWaste, $id );
  9629. // 银行
  9630. if (empty ( $abDetail )) {
  9631. $itemWaste += array (
  9632. 'accountPriceShow' => $expenditurePrice,
  9633. 'dataID' => $id,
  9634. 'expensesType' => 2,
  9635. 'accountType' => $accountTypeWaste,
  9636. 'dailyExpenditureType' => $expenditureType,
  9637. 'accountBank' => $accountBank,
  9638. 'category' => $this->staff [0] ['category'],
  9639. 'cid' => $this->staff [0] ['cid'],
  9640. 'name' => $this->staff [0] ['username'],
  9641. 'sid' => $this->staff [0] ['sid'],
  9642. 'inputDate' => date ( "Y-m-d H:i:s" )
  9643. );
  9644. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9645. }
  9646. // 支出类型为4或者6 需要添加一笔收入和收入流水
  9647. if ($expenditureType == 4 || $expenditureType == 6) {
  9648. $accountBank = 'CGBDeposit';
  9649. $dailyIncomeType = 7;
  9650. $receivedBank = '纵横广发';
  9651. if ($expenditureType == 6) {
  9652. $accountBank = 'ICBCDeposit';
  9653. $receivedBank = '纵横工行';
  9654. $dailyIncomeType = 9;
  9655. }
  9656. // 添加一笔收入
  9657. $accountBook = new accountBook ();
  9658. $accountBook->accountType = $dailyIncomeType;
  9659. $accountBook->accountMsg = $expenditureMsg;
  9660. $accountBook->receivedPrice = $expenditurePrice;
  9661. $accountBook->receivedBank = $receivedBank;
  9662. $accountBook->receivedDate = $expenditureDate;
  9663. $accountBook->remarks = $remarks;
  9664. $accountBook->expensesType = 1;
  9665. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9666. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9667. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9668. $id = $accountBook->insert ();
  9669. // 添加一笔收入流水
  9670. $itemWaste = array (
  9671. 'accountPriceShow' => $expenditurePrice,
  9672. 'accountPrice' => - $expenditurePrice,
  9673. 'dataID' => $id,
  9674. 'expensesType' => 1,
  9675. 'accountType' => $accountTypeWaste,
  9676. 'dailyIncomeType' => $dailyIncomeType,
  9677. 'accountBank' => $accountBank,
  9678. 'category' => $this->staff [0] ['category'],
  9679. 'cid' => $this->staff [0] ['cid'],
  9680. 'name' => $this->staff [0] ['username'],
  9681. 'sid' => $this->staff [0] ['sid'],
  9682. 'inputDate' => date ( "Y-m-d H:i:s" )
  9683. );
  9684. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9685. }
  9686. }
  9687. return '/payments';
  9688. }
  9689. /**
  9690. * 所有收支
  9691. */
  9692. function paymentsAchieve() {
  9693. $page_size = 12;
  9694. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  9695. $expensesType = isset ( $this->params ['expensesType'] ) ? $this->params ['expensesType'] : 'ALL';
  9696. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  9697. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  9698. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  9699. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  9700. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  9701. $submitType = $this->get_args ( 'submitType' ) ? $this->get_args ( 'submitType' ) : "";
  9702. Doo::loadModel ( "accountBookStatistics" );
  9703. $accountBookStatistics = new accountBookStatistics ();
  9704. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  9705. $data ['statisticsList'] = $statisticsList;
  9706. Doo::loadModel ( "accountBook" );
  9707. $accountBook = new accountBook ();
  9708. $con = '';
  9709. if ($expensesType == 'INCOME')
  9710. $con = ' and expensesType=1 ';
  9711. elseif ($expensesType == 'PAY')
  9712. $con = ' and expensesType=2 ';
  9713. $dateArr = explode ( ':', $date );
  9714. $D1 = $dateString = '';
  9715. $D2 = '';
  9716. if (! empty ( $date )) {
  9717. $D1 = $dateArr [0];
  9718. if (isset ( $dateArr [1] ))
  9719. $D2 = $dateArr [1];
  9720. else
  9721. $D2 = '';
  9722. $dateString = $D1 . " : " . $D2;
  9723. }
  9724. if (! empty ( $D1 ) && ! empty ( $D2 ))
  9725. $con .= ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  9726. elseif (! empty ( $D1 ) && empty ( $D2 ))
  9727. $con .= ' and inputDate like "%' . $D1 . '%" ';
  9728. if (! empty ( $price ))
  9729. $con .= ' and (receivedPrice=' . $price . ' or expenditurePrice=' . $price . ')';
  9730. if ($submitType == 1) {
  9731. if ($accountType != '') {
  9732. $expenditureType = '';
  9733. $con .= ' and accountType=' . $accountType;
  9734. if (! empty ( $accountMsg ))
  9735. $con .= ' and (accountType=' . $accountType . ' and accountMsg like "%' . $accountMsg . '%")';
  9736. }
  9737. } elseif ($submitType == 2) {
  9738. if ($expenditureType != '') {
  9739. $accountType = $accountMsg = '';
  9740. $con .= ' and expenditureType=' . $expenditureType;
  9741. }
  9742. } else {
  9743. $accountType = $accountMsg = $expenditureType = '';
  9744. }
  9745. $sql = "" . $con;
  9746. $action = "paymentsAchieve";
  9747. $get = '/' . $expensesType; // "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  9748. $pageinfo = $this->get_page ( "CLD_accountBook", $sql, $page, $page_size, $action, $get, "" );
  9749. $limit = $pageinfo ['lower'] . ',' . $page_size;
  9750. $list = $accountBook->getAccountBookBySql ( $limit, $sql, 'desc' );
  9751. $data ['expenditureType'] = $expenditureType;
  9752. $data ['accountMsg'] = $accountMsg;
  9753. $data ['accountType'] = $accountType;
  9754. $data ['inputDate'] = $date;
  9755. $data ['price'] = $price;
  9756. $data ['expensesType'] = $expensesType;
  9757. $data ['page'] = $pageinfo;
  9758. $data ['list'] = $list;
  9759. $data ['memu'] = "receipt";
  9760. $data ['staff'] = $this->staff;
  9761. $data ['receiptMemu'] = 'payments';
  9762. $data ['verifyId'] = $this->verifyId;
  9763. $data ['executeId'] = $this->executeId;
  9764. $this->render ( "/expenses/paymentsAchieve", $data );
  9765. }
  9766. function paymentsIncomeUpdateDo() {
  9767. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  9768. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  9769. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  9770. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  9771. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  9772. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  9773. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  9774. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  9775. if (! empty ( $aidKey ) && ! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  9776. Doo::loadClass ( 'XDeode' );
  9777. $XDeode = new XDeode ( 5 );
  9778. $aid = $XDeode->decode ( $aidKey );
  9779. Doo::loadModel ( "accountBook" );
  9780. $accountBook = new accountBook ();
  9781. //
  9782. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  9783. $price = $receivedPrice - $abDetail [inComePrice];
  9784. Doo::loadModel ( "accountBookStatistics" );
  9785. $accountBookStatistics = new accountBookStatistics ();
  9786. if ($abDetail ['accountType'] == 7) {
  9787. $item += array (
  9788. 'date' => date ( "Y-m-d" ),
  9789. 'financingPrice' => - $price,
  9790. 'expensesType' => 3,
  9791. 'aid' => $abDetail ['aid']
  9792. );
  9793. } elseif ($abDetail ['accountType'] == 8) {
  9794. $item += array (
  9795. 'date' => date ( "Y-m-d" ),
  9796. 'expensesType' => $abDetail ['expensesType'],
  9797. 'inComePrice' => - $price,
  9798. 'aid' => $abDetail ['aid']
  9799. );
  9800. } else {
  9801. $item = array (
  9802. 'date' => date ( "Y-m-d" ),
  9803. 'expensesType' => $abDetail ['expensesType'],
  9804. 'inComePrice' => $price,
  9805. 'aid' => $abDetail ['aid']
  9806. );
  9807. }
  9808. $accountBookStatistics->setAccountBookStatistics ( $item );
  9809. $accountBook->accountType = $accountType;
  9810. $accountBook->accountMsg = $accountMsg;
  9811. $accountBook->receivedPrice = $receivedPrice;
  9812. $accountBook->receivedMsg = $receivedMsg;
  9813. $accountBook->receivedBank = $receivedBank;
  9814. $accountBook->receivedDate = $receivedDate;
  9815. $accountBook->remarks = $remarks;
  9816. $accountBook->aid = $aid;
  9817. $accountBook->update ();
  9818. }
  9819. return '/paymentsAchieve';
  9820. }
  9821. function paymentsExpenditureEdiDo() {
  9822. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  9823. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  9824. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  9825. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  9826. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  9827. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  9828. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  9829. if (! empty ( $aidKey ) && ! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  9830. Doo::loadClass ( 'XDeode' );
  9831. $XDeode = new XDeode ( 5 );
  9832. $aid = $XDeode->decode ( $aidKey );
  9833. Doo::loadModel ( "accountBook" );
  9834. $accountBook = new accountBook ();
  9835. // 汇总信息
  9836. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  9837. $price = $expenditurePrice - $abDetail [expenditurePrice];
  9838. Doo::loadModel ( "accountBookStatistics" );
  9839. $accountBookStatistics = new accountBookStatistics ();
  9840. if ($abDetail ['expenditureType'] == 4) {
  9841. $item += array (
  9842. 'date' => date ( "Y-m-d" ),
  9843. 'financingPrice' => $price,
  9844. 'expensesType' => 3,
  9845. 'aid' => $abDetail ['aid']
  9846. );
  9847. } elseif ($abDetail ['expenditureType'] == 5) {
  9848. $item += array (
  9849. 'date' => date ( "Y-m-d" ),
  9850. 'expensesType' => $abDetail ['expensesType'],
  9851. 'payPrice' => $price,
  9852. 'aid' => $abDetail ['aid']
  9853. );
  9854. } else {
  9855. $item = array (
  9856. 'date' => date ( "Y-m-d" ),
  9857. 'expensesType' => $abDetail ['expensesType'],
  9858. 'payPrice' => $price,
  9859. 'aid' => $abDetail ['aid']
  9860. );
  9861. }
  9862. $accountBookStatistics->setAccountBookStatistics ( $item );
  9863. //
  9864. $accountBook->expenditureType = $expenditureType;
  9865. $accountBook->expenditureMsg = $expenditureMsg;
  9866. $accountBook->expenditurePrice = $expenditurePrice;
  9867. $accountBook->expenditureBank = $expenditureBank;
  9868. $accountBook->remarks = $remarks;
  9869. $accountBook->expenditureDate = $expenditureDate;
  9870. $accountBook->aid = $aid;
  9871. $id = $accountBook->update ();
  9872. }
  9873. return '/paymentsAchieve';
  9874. }
  9875. function paymentsDelDo() {
  9876. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  9877. if (! empty ( $aidKey )) {
  9878. Doo::loadClass ( 'XDeode' );
  9879. $XDeode = new XDeode ( 5 );
  9880. $aid = $XDeode->decode ( $aidKey );
  9881. Doo::loadModel ( "accountBook" );
  9882. $accountBook = new accountBook ();
  9883. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  9884. if(empty($abDetail))
  9885. die ( 'illegal request' );
  9886. // 删除收支
  9887. Doo::loadModel ( "accountBookStatistics" );
  9888. $accountBookStatistics = new accountBookStatistics ();
  9889. $item = array (
  9890. 'date' => date ( "Y-m-d" ),
  9891. 'aid' => $abDetail ['aid']
  9892. );
  9893. $accountType='';
  9894. if ($abDetail ['expensesType'] == 1) {
  9895. $accountType=6;
  9896. if ($abDetail ['accountType'] != 7) {
  9897. $item += array (
  9898. 'expensesType' => $abDetail ['expensesType'],
  9899. 'inComePrice' => - $abDetail ['receivedPrice']
  9900. );
  9901. } else {
  9902. $item += array (
  9903. 'financingPrice' => $abDetail ['receivedPrice'],
  9904. 'expensesType' => 3
  9905. );
  9906. }
  9907. } elseif ($abDetail ['expensesType'] == 2) {
  9908. $accountType=5;
  9909. if ($abDetail ['accountType'] != 7) {
  9910. $item += array (
  9911. 'expensesType' => $abDetail ['expensesType'],
  9912. 'payPrice' => - $abDetail ['expenditurePrice']
  9913. );
  9914. } else {
  9915. $item += array (
  9916. 'financingPrice' => - $abDetail ['expenditurePrice'],
  9917. 'expensesType' => 3
  9918. );
  9919. }
  9920. }
  9921. if (($abDetail ['expenditureType'] == 4||$abDetail ['expenditureType'] == 6)&&$abDetail ['expensesType'] == 2) {
  9922. if ($abDetail ['expenditureMsg']=='公司固定')
  9923. $accountType=9;
  9924. elseif($abDetail ['expenditureMsg']=='公司活期')
  9925. $accountType=10;
  9926. }
  9927. if (($abDetail ['accountType'] == 7||$abDetail ['accountType'] == 9)&&$abDetail ['expensesType'] == 1) {
  9928. if ($abDetail ['accountMsg']=='公司固定')
  9929. $accountType=9;
  9930. elseif($abDetail ['accountMsg']=='公司活期')
  9931. $accountType=10;
  9932. }
  9933. if($abDetail['accountMsg']=='活期理财收益'){
  9934. $accountType=10;
  9935. }
  9936. $accountBookStatistics->setAccountBookStatistics ( $item );
  9937. $accountBook->delete ( array (
  9938. 'where' => 'aid=' . $aid,
  9939. 'limit' => 1
  9940. ) );
  9941. //删除收入流水
  9942. if(!empty($accountType)){
  9943. Doo::loadModel ( 'wasteBook' );
  9944. $wasteBook = new wasteBook ();
  9945. $wasteBook->delete ( array (
  9946. 'where' => 'dataID=' . $aid . ' and accountType='.$accountType,
  9947. 'limit' => 1
  9948. ) );
  9949. }
  9950. }
  9951. return '/paymentsAchieve';
  9952. }
  9953. function paymentsCollect() {
  9954. Doo::loadModel ( "execute" );
  9955. $execute = new execute ();
  9956. if(!$execute->isPaymentsShow($this->staff [0] ['sid'])){
  9957. die ( 'illegal request' );
  9958. }
  9959. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9960. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  9961. Doo::loadModel ( "accountBookStatistics" );
  9962. $accountBookStatistics = new accountBookStatistics ();
  9963. Doo::loadClass ( 'receipt.func' );
  9964. $statisticsIncome = $accountBookStatistics->getStatisticsByCollect ( $year );
  9965. $html = _getPaymentsCollectByYearHtml ( $statisticsIncome );
  9966. $data ['html'] = $html ['html'];
  9967. $data ['inSum'] = $html ['sum'];
  9968. $statisticsPay = $accountBookStatistics->getStatisticsByCollect ( $year, 2 );
  9969. $html = _getPaymentsCollectPayByYearHtml ( $statisticsPay );
  9970. $data ['payHtml'] = $html ['html'];
  9971. $data ['paySum'] = $html ['sum'];
  9972. // 余额统计
  9973. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1 );
  9974. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2 );
  9975. include './protected/config/wasteBook.conf.php';
  9976. Doo::loadModel ( 'wasteBook' );
  9977. $wasteBook = new wasteBook ();
  9978. $inComePay = $wasteBook->getWasteBookByStatistics ( 1, $year );
  9979. $pay = $wasteBook->getWasteBookByStatistics ( 2, $year );
  9980. // 获得年份之前所有金额
  9981. $detail = $wasteBook->getWasteBookByStatisticsYear ( $year );
  9982. // print_r($detail);
  9983. // $waste['total'];
  9984. $lastBalanceHtml = '<tr><th colspan="2">截至上月余额</th>';
  9985. $inComeHtml = '<tr><th colspan="2">收入</th>';
  9986. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  9987. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  9988. $inSum = $paySum = $showInSum = $showPaySum = $balanceSum = 0;
  9989. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  9990. $limitMonth = date ( 'm' ); // 限制显示月份参数
  9991. if (date ( 'Y' ) > $year) {
  9992. $limitMonth = 12;
  9993. }
  9994. for($i = 1; $i <= 12; $i ++) {
  9995. $inComeA = $payB = 0;
  9996. $falg = true;
  9997. foreach ( $inComePay as $key => $value ) {
  9998. if ($value ['month'] == $i) {
  9999. $falg = false;
  10000. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  10001. $inSum += $value ['accountPrice'];
  10002. $showInSum += $value ['accountPriceShow'];
  10003. $inComeA = $value ['accountPrice'];
  10004. break;
  10005. }
  10006. }
  10007. if ($falg)
  10008. $inComeHtml .= '<td class="taR">-</td>';
  10009. $payFalg = true;
  10010. foreach ( $pay as $key => $value ) {
  10011. if ($value ['month'] == $i) {
  10012. $payFalg = false;
  10013. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  10014. $paySum += $value ['accountPrice'];
  10015. $showPaySum += $value ['accountPriceShow'];
  10016. $payB = $value ['accountPrice'];
  10017. break;
  10018. }
  10019. }
  10020. if ($payFalg)
  10021. $payHtml .= '<td class="taR">-</td>';
  10022. if (empty ( $balanceC ) || $limitMonth < $i)
  10023. $lastBalanceHtml .= '<td class="taR">-</td>';
  10024. else
  10025. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  10026. $balanceC = $balanceC + $inComeA + $payB;
  10027. $balanceSum += $balanceC;
  10028. if (empty ( $balanceC ) || $limitMonth < $i)
  10029. $BalanceHtml .= '<td class="taR">-</td>';
  10030. else
  10031. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  10032. // 余额统计
  10033. }
  10034. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  10035. $data ['inComeHtml'] = $inComeHtml;
  10036. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  10037. $data ['payBalanceHtml'] = $payHtml;
  10038. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  10039. $data ['BalanceHtml'] = $BalanceHtml;
  10040. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  10041. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  10042. $mothHtml = "";
  10043. for($i = 1; $i <= 12; $i ++) {
  10044. if ($moth == $i)
  10045. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  10046. else
  10047. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  10048. }
  10049. $data ['mothHtml'] = $mothHtml;
  10050. $dateHtml = "";
  10051. $now = date ( "Y" );
  10052. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  10053. if ($YEARD <= $now) {
  10054. $dateHtml .= '<option ';
  10055. if ($year == $YEARD) {
  10056. $dateHtml .= 'selected ';
  10057. }
  10058. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  10059. }
  10060. }
  10061. $data ['dateHtml'] = $dateHtml;
  10062. $data ['year'] = $year;
  10063. $data ['memu'] = "receipt";
  10064. $data ['staff'] = $this->staff;
  10065. $data ['receiptMemu'] = 'paymentsCollect';
  10066. $data ['verifyId'] = $this->verifyId;
  10067. $data ['executeId'] = $this->executeId;
  10068. $this->render ( "/expenses/paymentsCollect", $data );
  10069. }
  10070. function paymentsCollectDay() {
  10071. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10072. $moth = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : '';
  10073. if (empty ( $moth ))
  10074. return 'paymentsCollect';
  10075. Doo::loadModel ( "accountBookStatistics" );
  10076. $accountBookStatistics = new accountBookStatistics ();
  10077. $i = 2;
  10078. $y = 2013;
  10079. $day = date ( "t", strtotime ( "$year-$moth" ) );
  10080. Doo::loadClass ( 'receipt.func' );
  10081. $statisticsIncome = $accountBookStatistics->getStatisticsByCollectDay ( $year, 1, $moth );
  10082. $html = _getPaymentsCollectByDayHtml ( $statisticsIncome, $day );
  10083. $data ['html'] = $html ['html'];
  10084. $data ['inSum'] = $html ['sum'];
  10085. $statisticsPay = $accountBookStatistics->getStatisticsByCollectDay ( $year, 2, $moth );
  10086. $html = _getPaymentsCollectPayByDayHtml ( $statisticsPay, $day );
  10087. $data ['payHtml'] = $html ['html'];
  10088. $data ['paySum'] = $html ['sum'];
  10089. $mothHtml = "";
  10090. for($i = 1; $i <= 12; $i ++) {
  10091. if ($moth == $i)
  10092. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  10093. else
  10094. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  10095. }
  10096. $data ['mothHtml'] = $mothHtml;
  10097. $data ['year'] = $year;
  10098. // 余额
  10099. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1, $moth );
  10100. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2, $moth );
  10101. include './protected/config/wasteBook.conf.php';
  10102. Doo::loadModel ( 'wasteBook' );
  10103. $wasteBook = new wasteBook ();
  10104. $inComePay = $wasteBook->getStatisticsByDay ( 1, $year, $moth );
  10105. $pay = $wasteBook->getStatisticsByDay ( 2, $year, $moth );
  10106. // 获得年份之前所有金额
  10107. $detail = $wasteBook->getWasteBookByStatisticsDay ( $year, $moth );
  10108. $lastBalanceHtml = '<tr><th colspan="2">截至上日余额</th>';
  10109. $inComeHtml = '<tr><th colspan="2">收入</th>';
  10110. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  10111. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  10112. $dayHtml = '<tr><th class="taC" colspan="2">余额</th>';
  10113. $inSum = $paySum = $showPaySum = $showInSum = $balanceSum = 0;
  10114. // $balanceC = 0;
  10115. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  10116. $limitDay = date ( 'd' );
  10117. $monthLK = ( int ) date ( 'm' );
  10118. if (date ( 'Y' ) > $year) {
  10119. $limitDay = cal_days_in_month ( CAL_GREGORIAN, date ( 'm' ), date ( 'Y' ) );
  10120. } elseif (date ( 'Y' ) <= $year && $monthLK < $moth) {
  10121. $limitDay = 0;
  10122. }
  10123. for($i = 1; $i <= $day; $i ++) {
  10124. $dayHtml .= '<td class="taC">' . $i . '日</td>';
  10125. $inComeA = $payB = 0;
  10126. $falg = true;
  10127. foreach ( $inComePay as $key => $value ) {
  10128. if ($value ['day'] == $i) {
  10129. $falg = false;
  10130. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  10131. $inSum += $value ['accountPrice'];
  10132. $showInSum += $value ['accountPriceShow'];
  10133. $inComeA = $value ['accountPrice'];
  10134. break;
  10135. }
  10136. }
  10137. if ($falg)
  10138. $inComeHtml .= '<td class="taR">-</td>';
  10139. $payFalg = true;
  10140. foreach ( $pay as $key => $value ) {
  10141. if ($value ['day'] == $i) {
  10142. $payFalg = false;
  10143. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  10144. $paySum += $value ['accountPrice'];
  10145. $showPaySum += $value ['accountPriceShow'];
  10146. $payB = $value ['accountPrice'];
  10147. break;
  10148. }
  10149. }
  10150. if ($payFalg)
  10151. $payHtml .= '<td class="taR">-</td>';
  10152. if (empty ( $balanceC ) || $limitDay < $i)
  10153. $lastBalanceHtml .= '<td class="taR">-</td>';
  10154. else
  10155. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  10156. $balanceC = $balanceC + $inComeA + $payB;
  10157. $balanceSum += $balanceC;
  10158. if (empty ( $balanceC ) || $limitDay < $i)
  10159. $BalanceHtml .= '<td class="taR">-</td>';
  10160. else
  10161. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  10162. }
  10163. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  10164. $data ['inComeHtml'] = $inComeHtml;
  10165. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  10166. $data ['payBalanceHtml'] = $payHtml;
  10167. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  10168. $data ['BalanceHtml'] = $BalanceHtml;
  10169. $dayHtml .= '<td class="taR ">总计</td></tr>';
  10170. $data ['dayHtml'] = $dayHtml;
  10171. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  10172. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  10173. $dateHtml = "";
  10174. $now = date ( "Y" );
  10175. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  10176. if ($YEARD <= $now) {
  10177. $dateHtml .= '<option ';
  10178. if ($year == $YEARD) {
  10179. $dateHtml .= 'selected ';
  10180. }
  10181. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  10182. }
  10183. }
  10184. $data ['dateHtml'] = $dateHtml;
  10185. $data ['memu'] = "receipt";
  10186. $data ['staff'] = $this->staff;
  10187. $data ['receiptMemu'] = 'paymentsCollect';
  10188. $data ['verifyId'] = $this->verifyId;
  10189. $data ['executeId'] = $this->executeId;
  10190. $this->render ( "/expenses/paymentsCollectDay", $data );
  10191. }
  10192. function ajaxGetPaymentsByAid() {
  10193. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  10194. Doo::loadModel ( "accountBook" );
  10195. $accountBook = new accountBook ();
  10196. $detail = $accountBook->getAccountBookByAid ( $serial );
  10197. echo json_encode ( array (
  10198. 'status' => 1,
  10199. 'detail' => $detail
  10200. ) );
  10201. }
  10202. // 公司流水
  10203. function wasteBook() {
  10204. Doo::loadModel ( "execute" );
  10205. $execute = new execute ();
  10206. if(!$execute->isPaymentsShow($this->staff [0] ['sid'])){
  10207. die ( 'illegal request' );
  10208. }
  10209. include './protected/config/wasteBook.conf.php';
  10210. Doo::loadModel ( 'wasteBook' );
  10211. $wasteBook = new wasteBook ();
  10212. $inComeStatistics = $wasteBook->getWasteBookStatisticsByIncome ();
  10213. $waste = $this->getWasteBookStatistics ( $waste, $inComeStatistics );
  10214. $total = $waste ['bank'] ['CGBDeposit'] + $waste ['bank'] ['ICBCDeposit'] + $waste ['bank'] ['HUADeposit'] + $waste ['bank'] ['PersonalDeposit'] + $waste ['financial'] ['current'] ['CGBDeposit'] + $waste ['financial'] ['current'] ['ICBCDeposit'] + $waste ['financial'] ['fixed'] ['CGBDeposit'] + $waste ['financial'] ['fixed'] ['ICBCDeposit'];
  10215. // print_r($waste);
  10216. $data ['waste'] = $waste;
  10217. $data ['total'] = $total;
  10218. // 月流水数据结构
  10219. $monthStatistics = array ();
  10220. $incomeMothStatistics = array ();
  10221. $expenditureMothStatistics = array ();
  10222. for($i = 1; $i <= 12; $i ++) {
  10223. $month = date ( 'Y' ) . '-' . $i;
  10224. if ($i < 10)
  10225. $month = date ( 'Y' ) . '-0' . $i;
  10226. array_push ( $monthStatistics, $month );
  10227. }
  10228. foreach ( $monthStatistics as $value ) {
  10229. $falg = true;
  10230. foreach ( $inComeStatistics ['incomeReport'] as $k => $v ) {
  10231. if ($value == $v ['inputDate']) {
  10232. array_push ( $incomeMothStatistics, $v ['accountPrice'] );
  10233. $falg = false;
  10234. }
  10235. }
  10236. if ($falg) {
  10237. array_push ( $incomeMothStatistics, '' );
  10238. }
  10239. $falgEx = true;
  10240. foreach ( $inComeStatistics ['expenditureReport'] as $k => $v ) {
  10241. if ($value == $v ['inputDate']) {
  10242. array_push ( $expenditureMothStatistics, $v ['accountPrice'] );
  10243. $falg = false;
  10244. }
  10245. }
  10246. if ($falgEx) {
  10247. array_push ( $expenditureMothStatistics, '' );
  10248. }
  10249. }
  10250. $data ['monthStatistics'] = json_encode ( $monthStatistics );
  10251. $data ['incomeMothStatistics'] = json_encode ( $incomeMothStatistics );
  10252. $data ['expenditureMothStatistics'] = json_encode ( $expenditureMothStatistics );
  10253. $expenditureList = $wasteBook->getAccountBookByExpensesType ( 4, 2 );
  10254. $incomeList = $wasteBook->getAccountBookByExpensesType ( 4, 1 );
  10255. // print_r($incomeList);
  10256. $data ['expenditureList'] = $expenditureList;
  10257. $data ['incomeList'] = $incomeList;
  10258. $data ['memu'] = "receipt";
  10259. $data ['staff'] = $this->staff;
  10260. $data ['receiptMemu'] = 'wasteBook';
  10261. $data ['verifyId'] = $this->verifyId;
  10262. $data ['executeId'] = $this->executeId;
  10263. $this->render ( "/expenses/wasteBook", $data );
  10264. }
  10265. function wasteBookIncome() {
  10266. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  10267. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  10268. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  10269. $dailyIncomeType = $this->get_args ( 'dailyIncomeType' ) ? $this->get_args ( 'dailyIncomeType' ) : "ALL";
  10270. $data ['dailyIncomeType'] = $dailyIncomeType;
  10271. Doo::loadModel ( 'wasteBook' );
  10272. $wasteBook = new wasteBook ();
  10273. Doo::loadModel ( 'L_category' );
  10274. $L_category = new L_category ();
  10275. Doo::loadClass ( 'XDeode' );
  10276. $XDeode = new XDeode ( 5 );
  10277. // echo $XDeode->encode(1).'<br>';
  10278. // echo $XDeode->encode(2).'<br>';
  10279. // echo $XDeode->encode(3).'<br>';
  10280. // echo $XDeode->encode(4).'<br>';
  10281. // echo $XDeode->encode(5).'<br>';
  10282. // echo $XDeode->encode(6).'<br>';
  10283. // echo $XDeode->encode(7).'<br>';
  10284. // echo $XDeode->encode(8).'<br>';
  10285. // echo $XDeode->encode(9).'<br>';
  10286. // echo $XDeode->encode(10).'<br>';
  10287. $dateArr = explode ( ':', $date );
  10288. $D1 = '';
  10289. $D2 = '';
  10290. $con = '';
  10291. if (! empty ( $date )) {
  10292. $D1 = $dateArr [0];
  10293. $D2 = $dateArr [1];
  10294. }
  10295. if (! empty ( $D1 ) && ! empty ( $D2 ))
  10296. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  10297. elseif (! empty ( $D1 ) && empty ( $D2 ))
  10298. $con = ' and inputDate = "' . $D1 . '"';
  10299. if ($cid != 'ALL') {
  10300. $cid = $XDeode->decode ( $cid );
  10301. $con .= ' and cid = "' . $cid . '"';
  10302. }
  10303. if ($accountType != 'ALL') {
  10304. if ($accountType == 'INVOICE') {
  10305. $con .= ' and (accountType = 7 or accountType = 8)';
  10306. } elseif ($accountType == 'PAYMENTS') {
  10307. $con .= ' and (accountType = 6 or accountType = 9 or accountType = 10)';
  10308. if($dailyIncomeType!='ALL'){
  10309. $dailyIncomeType = $XDeode->decode ( $dailyIncomeType );
  10310. $con .= ' and dailyIncomeType = '.$dailyIncomeType;
  10311. }
  10312. }
  10313. }
  10314. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 1, $con );
  10315. $sum = 0;
  10316. foreach ( $incomeList as $key => $value ) {
  10317. $sum += $value ['accountPrice'];
  10318. }
  10319. //print_r($incomeList);
  10320. // 获得办事和部门
  10321. $categoryList = $L_category->getCategory ();
  10322. $data ['accountType'] = $accountType;
  10323. $data ['cid'] = $cid;
  10324. $data ['categoryList'] = $categoryList;
  10325. $data ['sum'] = $sum;
  10326. $data ['incomeList'] = $incomeList;
  10327. $data ['inputDate'] = $date;
  10328. $data ['memu'] = "receipt";
  10329. $data ['staff'] = $this->staff;
  10330. $data ['receiptMemu'] = 'wasteBook';
  10331. $data ['verifyId'] = $this->verifyId;
  10332. $data ['executeId'] = $this->executeId;
  10333. $this->render ( "/expenses/wasteBookIncome", $data );
  10334. }
  10335. /**
  10336. * 所有支出
  10337. */
  10338. function wasteBookExpenditure() {
  10339. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  10340. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  10341. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  10342. $dailyExpenditureType = $this->get_args ( 'dailyExpenditureType' ) ? $this->get_args ( 'dailyExpenditureType' ) : "ALL";
  10343. $data ['dailyExpenditureType'] = $dailyExpenditureType;
  10344. $receiptType = $this->get_args ( 'receiptType' ) ? $this->get_args ( 'receiptType' ) : "ALL";
  10345. $data ['receiptType'] = $receiptType;
  10346. Doo::loadModel ( 'wasteBook' );
  10347. $wasteBook = new wasteBook ();
  10348. Doo::loadModel ( 'L_category' );
  10349. $L_category = new L_category ();
  10350. Doo::loadClass ( 'XDeode' );
  10351. $XDeode = new XDeode ( 5 );
  10352. $dateArr = explode ( ':', $date );
  10353. $D1 = '';
  10354. $D2 = '';
  10355. $con = '';
  10356. if (! empty ( $date )) {
  10357. $D1 = $dateArr [0];
  10358. $D2 = $dateArr [1];
  10359. }
  10360. if (! empty ( $D1 ) && ! empty ( $D2 ))
  10361. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  10362. elseif (! empty ( $D1 ) && empty ( $D2 ))
  10363. $con = ' and inputDate = "' . $D1 . '"';
  10364. if ($cid != 'ALL') {
  10365. $cid = $XDeode->decode ( $cid );
  10366. $con .= ' and cid = "' . $cid . '"';
  10367. }
  10368. if ($accountType != 'ALL') {
  10369. if ($accountType == 'INVOICE') {
  10370. $con .= ' and accountType = 11';
  10371. } elseif ($accountType == 'PAYMENTS') {
  10372. $con .= ' and (accountType = 5 or accountType = 9 or accountType = 10)';
  10373. if($dailyExpenditureType!='ALL'){
  10374. $dailyExpenditureType = $XDeode->decode ( $dailyExpenditureType );
  10375. $con .= ' and dailyExpenditureType = '.$dailyExpenditureType;
  10376. }
  10377. }elseif($accountType == 'RECEIPT'){
  10378. if ($receiptType=='ALL'){
  10379. $con .= ' and (accountType = 1 or accountType = 2 or accountType = 3 or accountType = 4)';
  10380. }else{
  10381. $receiptType = $XDeode->decode ( $receiptType );
  10382. echo $receiptType;
  10383. if ($receiptType==1){
  10384. $con .= ' and (accountType = 1 or accountType=2)';
  10385. }else{
  10386. $con .= ' and accountType = '.$receiptType;
  10387. }
  10388. }
  10389. }
  10390. }
  10391. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 2, $con );
  10392. $sum = 0;
  10393. foreach ( $incomeList as $key => $value ) {
  10394. $sum += $value ['accountPriceShow'];
  10395. }
  10396. // print_r($incomeList);
  10397. // 获得办事和部门
  10398. $categoryList = $L_category->getCategory ();
  10399. $data ['accountType'] = $accountType;
  10400. $data ['cid'] = $cid;
  10401. $data ['categoryList'] = $categoryList;
  10402. $data ['sum'] = $sum;
  10403. $data ['incomeList'] = $incomeList;
  10404. $data ['inputDate'] = $date;
  10405. $data ['memu'] = "receipt";
  10406. $data ['staff'] = $this->staff;
  10407. $data ['receiptMemu'] = 'wasteBook';
  10408. $data ['verifyId'] = $this->verifyId;
  10409. $data ['executeId'] = $this->executeId;
  10410. $this->render ( "/expenses/wasteBookExpenditure", $data );
  10411. }
  10412. function ajaxGetWasteinvoiceReceivables() {
  10413. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  10414. Doo::loadClass ( 'XDeode' );
  10415. $XDeode = new XDeode ( 5 );
  10416. $irid = $XDeode->decode ( $serial );
  10417. Doo::loadModel ( 'invoiceReceivables' );
  10418. $invoiceReceivables = new invoiceReceivables ();
  10419. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  10420. echo json_encode ( array (
  10421. 'status' => 1,
  10422. 'detail' => $detail
  10423. ) );
  10424. }
  10425. function ajaxGetWasteInvoice() {
  10426. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  10427. Doo::loadModel ( 'invoice' );
  10428. $invoice = new invoice ();
  10429. Doo::loadModel ( 'invoiceReceivables' );
  10430. $invoiceReceivables = new invoiceReceivables ();
  10431. $detail = $invoice->getInvoiceByIid ( $serial );
  10432. $detailReceivables = $invoiceReceivables->getInvoiceReceivablesByIrid ( $detail ['irid'] );
  10433. $detail ['receivablesBank'] = $detailReceivables ['receivablesBank'];
  10434. echo json_encode ( array (
  10435. 'status' => 1,
  10436. 'detail' => $detail
  10437. ) );
  10438. }
  10439. /**
  10440. */
  10441. function ajaxGetWasteReceipt() {
  10442. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  10443. Doo::loadModel ( 'receipt' );
  10444. $receipt = new receipt ();
  10445. Doo::loadClass ( 'XDeode' );
  10446. $XDeode = new XDeode ( 5 );
  10447. $rid = $XDeode->decode ( $serial );
  10448. // 获得个数据
  10449. $detail = $receipt->getReceiptByRid ( $rid );
  10450. // 初始化
  10451. $detail ['reviseDetail'] = array ();
  10452. if (! empty ( $value ['reviseDetail'] ))
  10453. $detail ['reviseDetail'] = json_decode ( $detail ['reviseDetail'], true );
  10454. $detail ['accountItem'] = json_decode ( $detail ['accountItem'], true );
  10455. $detail ['loanItem'] = json_decode ( $detail ['loanItem'], true );
  10456. $detail ['loanSumCN'] = $this->num_to_rmb ( $detail ['loanSum'] );
  10457. $detail ['sumCN'] = $this->num_to_rmb ( $detail ['sum'] );
  10458. // 获得费用html
  10459. $html = $this->getWasteReceiptHtml ( $detail );
  10460. // 获得费用审批人数据
  10461. $detail = $this->getReceiptApproverHtml ( $detail );
  10462. // 审批执行
  10463. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  10464. <th class="taC" width="90">审批人</th>
  10465. <th class="taC">审批意见</th></tr>';
  10466. foreach ( $detail ['verifyList'] as $key => $value ) {
  10467. $html .= '<tr>
  10468. <td>' . $value [1] . '</td>
  10469. <td>' . $value ['opinion'] . '</td>
  10470. </tr>
  10471. ';
  10472. }
  10473. $html .= ' </tbody></table>';
  10474. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  10475. <th class="taC" width="90">执行人</th>
  10476. <th class="taC">执行意见</th></tr>';
  10477. foreach ( $detail ['executeCopy'] as $key => $value ) {
  10478. $html .= '<tr>
  10479. <td>' . $value [1] . '</td>
  10480. <td>' . $value ['opinion'] . '</td>
  10481. </tr>
  10482. ';
  10483. }
  10484. $html .= ' </tbody></table>';
  10485. $html .= '<table class="table table-bordered table-condensed">
  10486. <tr class="warning">
  10487. <td class="taR"><b>汇款金额</b></td>
  10488. <td width="140" class="taR"><b style="font-size: 24px">¥' . $detail ['amount'] . '</b></td>
  10489. </tr>
  10490. </table>';
  10491. // print_r($detail['verifyList']);
  10492. // header ( 'Content-Type:text/html;charset=utf-8' );
  10493. // echo $html;
  10494. echo json_encode ( array (
  10495. 'status' => 1,
  10496. 'html' => $html,
  10497. 'detail' => $detail
  10498. ) );
  10499. }
  10500. function getReceiptApproverHtml($detail = array()) {
  10501. Doo::loadModel ( 'loanReceipt' );
  10502. $loanReceipt = new loanReceipt ();
  10503. Doo::loadModel ( 'verify' );
  10504. $verify = new verify ();
  10505. Doo::loadModel ( 'staff' );
  10506. $staff = new staff ();
  10507. if (empty ( $detail ))
  10508. return array ();
  10509. $loanList = $loanReceipt->getOne ( array (
  10510. 'where' => 'rid=' . $detail ['loanRid'],
  10511. 'desc' => 'rid',
  10512. 'asArray' => true
  10513. ) );
  10514. if ($detail ['status'] == 3 || $detail ['status'] == 1 || $detail ['status'] == 8 || $detail ['status'] == 9) {
  10515. if ($detail ['status'] == 8 && $detail ['Rtype'] == 1)
  10516. $verifyList ['staff'] = $loanList ['verifyBreakup'];
  10517. else
  10518. $verifyList ['staff'] = $detail ['verifyBreakup'];
  10519. } else
  10520. $verifyList = $verify->getOne ( array (
  10521. 'where' => 'vid=' . $detail ['verify'],
  10522. 'asArray' => true
  10523. ) );
  10524. $verifyList = json_decode ( $verifyList ['staff'], true );
  10525. Doo::loadModel ( 'role' );
  10526. $role = new role ();
  10527. $roleId = 0;
  10528. $flag = true;
  10529. $roleKey = 0;
  10530. $endStaffArray = array ();
  10531. $roleArrayCopy = array ();
  10532. foreach ( $verifyList as $k => $v ) {
  10533. // init verifyStaff
  10534. if ($v [1] == 'ROLE') {
  10535. if (! empty ( $verifyStaff )) {
  10536. $endStaffArray = end ( $verifyStaff );
  10537. }
  10538. $roleVerify = json_decode ( $v [3], true );
  10539. $roleKey = $k;
  10540. $roleArray = array ();
  10541. $rolename = $role->getOne ( array (
  10542. 'where' => 'rid=' . $v [0],
  10543. 'asArray' => true
  10544. ) );
  10545. foreach ( $roleVerify as $o => $p ) {
  10546. $staffID = explode ( '_', $p );
  10547. $staffInfo = $staff->getOne ( array (
  10548. 'where' => 'sid=' . $staffID [0],
  10549. 'asArray' => true
  10550. ) );
  10551. // print_r($staffID);
  10552. $exp = array (
  10553. 0 => $staffInfo ['sid'],
  10554. 1 => $staffID [1],
  10555. 2 => $staffInfo ['avatar'],
  10556. 'date' => '',
  10557. 'date' => '',
  10558. 'opinion' => '',
  10559. 'status' => '',
  10560. 'rolename' => $rolename ['name']
  10561. );
  10562. array_push ( $roleArray, $exp );
  10563. }
  10564. $roleArrayCopy [$v [0]] = $roleArray;
  10565. // $verifyList[$k]['roleArray']=$roleArray;
  10566. }
  10567. $verifyList [$k] ['date'] = "";
  10568. $verifyList [$k] ['opinion'] = "";
  10569. $verifyList [$k] ['status'] = "";
  10570. if (empty ( $verifyStaff )) {
  10571. $verifyList [$k] ['date'] = "";
  10572. $verifyList [$k] ['opinion'] = "";
  10573. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  10574. $verifyList [$k] ['status'] = 4;
  10575. $flag = false;
  10576. }
  10577. } else {
  10578. foreach ( $verifyStaff as $m => $u ) {
  10579. if ($v [0] == $m) {
  10580. $verifyList [$k] ['date'] = $u ['date'];
  10581. $verifyList [$k] ['opinion'] = $u ['opinion'];
  10582. $verifyList [$k] ['status'] = $u ['status'];
  10583. $flag = false;
  10584. break;
  10585. }
  10586. }
  10587. $endStaffArray = end ( $verifyStaff );
  10588. }
  10589. }
  10590. $rolename ['name'] = '';
  10591. if (! empty ( $roleId )) {
  10592. Doo::loadModel ( 'role' );
  10593. $role = new role ();
  10594. $rolename = $role->getOne ( array (
  10595. 'where' => 'rid=' . $roleId,
  10596. 'asArray' => true
  10597. ) );
  10598. }
  10599. if (! empty ( $verifyStaff ))
  10600. $endStaffArray = end ( $verifyStaff );
  10601. $KOP = false;
  10602. foreach ( $roleArrayCopy as $P => $A ) {
  10603. foreach ( $A as $MKI => $AVL ) {
  10604. if (! empty ( $verifyStaff )) {
  10605. // &&$rolename['rid']==$endStaffArray['nextStaff']
  10606. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  10607. $button = 4;
  10608. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  10609. }
  10610. foreach ( $verifyStaff as $m => $u ) {
  10611. $AVLFK = $AVL [0] . '_R';
  10612. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  10613. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  10614. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  10615. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  10616. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  10617. break;
  10618. }
  10619. }
  10620. } else {
  10621. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  10622. $button = 4;
  10623. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  10624. }
  10625. }
  10626. // $roleArray[$MKI]['rolename']=$rolename['name'];
  10627. $KOP = true;
  10628. }
  10629. }
  10630. foreach ( $roleArrayCopy as $k => $v ) {
  10631. foreach ( $verifyList as $m => $n ) {
  10632. if ($n [0] == $k) {
  10633. array_splice ( $verifyList, $m, 1, $v );
  10634. }
  10635. }
  10636. }
  10637. // 费用执行人相关数据
  10638. $executeCopy = json_decode ( $detail ['executeCopy'], true );
  10639. $executeStaff = json_decode ( $detail ['executeStaff'], true );
  10640. foreach ( $executeCopy as $k => $v ) {
  10641. $executeCopy [$k] ['date'] = '';
  10642. $executeCopy [$k] ['opinion'] = '';
  10643. $executeCopy [$k] ['status'] = '';
  10644. if (! empty ( $executeStaff ))
  10645. foreach ( $executeStaff as $m => $u ) {
  10646. if ($v [0] == $m) {
  10647. $executeCopy [$k] ['date'] = $u ['date'];
  10648. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  10649. $executeCopy [$k] ['status'] = $u ['status'];
  10650. break;
  10651. }
  10652. }
  10653. }
  10654. $detail ['executeCopy'] = $executeCopy;
  10655. $detail ['verifyList'] = $verifyList;
  10656. return $detail;
  10657. }
  10658. function getWasteReceiptHtml($detail = array()) {
  10659. if (empty ( $detail ))
  10660. return '';
  10661. $html = '';
  10662. if ($detail ['Rtype'] == 0) { // 报销单
  10663. $html .= '
  10664. <table class="table table-bordered table-condensed">
  10665. <tbody>
  10666. <tr>
  10667. <th colspan="2" class="taC">日常相关费用</th>
  10668. </tr>';
  10669. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  10670. $html .= '
  10671. <tr>
  10672. <th>' . $value ['name'] . '</th>
  10673. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10674. </tr>';
  10675. }
  10676. $html .= '
  10677. <tr>
  10678. <th class="taR">合计</th>
  10679. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  10680. </tr>';
  10681. $html .= '<tr>
  10682. <th colspan="2" class="taC">差旅相关费用</th>
  10683. </tr>';
  10684. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  10685. $html .= '
  10686. <tr>
  10687. <th>' . $value ['name'] . '</th>
  10688. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10689. </tr>';
  10690. }
  10691. $html .= '
  10692. <tr>
  10693. <th class="taR">合计</th>
  10694. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  10695. </tr>';
  10696. $html .= '<tr>
  10697. <th colspan="2" class="taC">培训班费用</th>
  10698. </tr>';
  10699. foreach ( $detail ['accountItem'] ['培训班费用'] as $key => $value ) {
  10700. $html .= '
  10701. <tr>
  10702. <th>' . $value ['name'] . '</th>
  10703. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10704. </tr>';
  10705. }
  10706. $html .= '
  10707. <tr>
  10708. <th class="taR">合计</th>
  10709. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['trainSum'] . '</td>
  10710. </tr>';
  10711. $html .= '<tr>
  10712. <th colspan="2" class="taC">其他</th>
  10713. </tr>';
  10714. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  10715. $html .= '
  10716. <tr>
  10717. <th>' . $value ['name'] . '</th>
  10718. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10719. </tr>';
  10720. }
  10721. $html .= '
  10722. <tr>
  10723. <th class="taR">合计</th>
  10724. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  10725. </tr>';
  10726. $html .= '<tr>
  10727. <th colspan="2" class="taC">报销金额调整</th>
  10728. </tr>';
  10729. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  10730. $html .= '
  10731. <tr>
  10732. <th>' . $value ['name'] . '</th>
  10733. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10734. </tr>';
  10735. }
  10736. $html .= '
  10737. <tr>
  10738. <th class="taR">合计</th>
  10739. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  10740. </tr>';
  10741. $html .= '
  10742. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  10743. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  10744. <tr><th class="taC" colspan="2">报销说明</th></tr>
  10745. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  10746. <tr class="warning">
  10747. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  10748. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  10749. </tr>
  10750. </tbody>
  10751. </table>';
  10752. } elseif ($detail ['Rtype'] == 2) {
  10753. $html .= '
  10754. <table class="table table-bordered table-condensed">
  10755. <tbody>
  10756. <tr>
  10757. <th colspan="2" class="taC">办事处相关费用</th>
  10758. </tr>';
  10759. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  10760. $html .= '
  10761. <tr>
  10762. <th>' . $value ['name'] . '</th>
  10763. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10764. </tr>';
  10765. }
  10766. $html .= '
  10767. <tr>
  10768. <th class="taR">合计</th>
  10769. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  10770. </tr>';
  10771. $html .= '
  10772. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  10773. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  10774. <tr><th class="taC" colspan="2">报销说明</th></tr>
  10775. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  10776. <tr class="warning">
  10777. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  10778. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  10779. </tr>
  10780. </tbody>
  10781. </table>';
  10782. } elseif ($detail ['Rtype'] == 1) {
  10783. if ($detail ['loanRid'] != 0 && ! empty ( $detail ['accountItem'] )) {
  10784. $html .= '<table class="table table-bordered table-condensed">
  10785. <tbody>
  10786. <tr>
  10787. <th colspan="2" class="taC">日常相关费用</th>
  10788. </tr>';
  10789. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  10790. $html .= '
  10791. <tr>
  10792. <th>' . $value ['name'] . '</th>
  10793. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10794. </tr>';
  10795. }
  10796. $html .= '
  10797. <tr>
  10798. <th class="taR">合计</th>
  10799. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  10800. </tr>';
  10801. $html .= '<tr>
  10802. <th colspan="2" class="taC">差旅相关费用</th>
  10803. </tr>';
  10804. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  10805. $html .= '
  10806. <tr>
  10807. <th>' . $value ['name'] . '</th>
  10808. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10809. </tr>';
  10810. }
  10811. $html .= '
  10812. <tr>
  10813. <th class="taR">合计</th>
  10814. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  10815. </tr>';
  10816. $html .= '<tr>
  10817. <th colspan="2" class="taC">培训班费用</th>
  10818. </tr>';
  10819. foreach ( $detail ['accountItem'] ['培训班费用'] as $key => $value ) {
  10820. $html .= '
  10821. <tr>
  10822. <th>' . $value ['name'] . '</th>
  10823. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10824. </tr>';
  10825. }
  10826. $html .= '
  10827. <tr>
  10828. <th class="taR">合计</th>
  10829. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['trainSum'] . '</td>
  10830. </tr>';
  10831. $html .= '<tr>
  10832. <th colspan="2" class="taC">其他</th>
  10833. </tr>';
  10834. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  10835. $html .= '
  10836. <tr>
  10837. <th>' . $value ['name'] . '</th>
  10838. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10839. </tr>';
  10840. }
  10841. $html .= '
  10842. <tr>
  10843. <th class="taR">合计</th>
  10844. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  10845. </tr>';
  10846. $html .= '<tr>
  10847. <th colspan="2" class="taC">报销金额调整</th>
  10848. </tr>';
  10849. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  10850. $html .= '
  10851. <tr>
  10852. <th>' . $value ['name'] . '</th>
  10853. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10854. </tr>';
  10855. }
  10856. $html .= '
  10857. <tr>
  10858. <th class="taR">合计</th>
  10859. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  10860. </tr>';
  10861. $html .= '
  10862. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  10863. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  10864. <tr><th class="taC" colspan="2">报销说明</th></tr>
  10865. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  10866. <tr class="warning">
  10867. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  10868. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  10869. </tr>
  10870. </tbody>
  10871. </table>';
  10872. }
  10873. Doo::loadModel ( 'loanReceipt' );
  10874. $loanReceipt = new loanReceipt ();
  10875. $loanList = $loanReceipt->getOne ( array (
  10876. 'where' => 'rid=' . $detail ['loanRid'],
  10877. 'desc' => 'rid',
  10878. 'asArray' => true
  10879. ) );
  10880. // print_r($loanList);
  10881. $html .= '<table class="table table-bordered table-condensed">
  10882. <tbody>
  10883. <tr>
  10884. <th colspan="2" class="taC">借款费用</th>
  10885. </tr>';
  10886. foreach ( $detail ['loanItem'] ['借款费用'] as $key => $value ) {
  10887. $html .= '<tr>
  10888. <th>' . $value ['name'] . '</th>
  10889. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10890. </tr>';
  10891. }
  10892. $html .= '<tr>
  10893. <th class="taC" colspan="2">产生费用所在办事处</th>
  10894. </tr>
  10895. <tr>
  10896. <th style="text-align: center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th>
  10897. </tr>
  10898. <tr>
  10899. <th class="taC" colspan="2">费用说明</th>
  10900. </tr>
  10901. <tr>
  10902. <td colspan="2">' . $loanList ['explanation'] . '</td>
  10903. </tr>
  10904. <tr class="warning">
  10905. <td class="taR"><b>(' . $loanList ['receiptOrder'] . ')本次费用合计</b></td>
  10906. <td class="taR"><b style="font-size: 24px">¥' . $detail ['loanSum'] . '</b><br>' . $detail ['loanSumCN'] . '</td>
  10907. </tr>
  10908. </tbody>
  10909. </table>
  10910. ';
  10911. }
  10912. return $html;
  10913. }
  10914. /**
  10915. * 计算流水
  10916. */
  10917. function getWasteBookStatistics($waste = array(), $inComeStatistics) {
  10918. $bakWaste ['bank'] = array (
  10919. 'CGBDeposit' => 0,
  10920. 'ICBCDeposit' => 0,
  10921. 'HUADeposit' => 0,
  10922. 'PersonalDeposit' => 0
  10923. );
  10924. $bakWaste ['financial'] = array (
  10925. 'current' => array (
  10926. 'CGBDeposit' => 0,
  10927. 'ICBCDeposit' => 0
  10928. ),
  10929. 'fixed' => array (
  10930. 'CGBDeposit' => 0,
  10931. 'ICBCDeposit' => 0
  10932. )
  10933. )
  10934. ;
  10935. // 存款
  10936. foreach ( $waste ['bank'] as $key => $value ) {
  10937. // 收入
  10938. foreach ( $inComeStatistics ['incomeStatistics'] as $k => $v ) {
  10939. // 广发
  10940. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  10941. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  10942. }
  10943. // 工商
  10944. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  10945. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  10946. }
  10947. // 华润
  10948. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  10949. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  10950. }
  10951. // 个人
  10952. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  10953. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  10954. }
  10955. }
  10956. }
  10957. foreach ( $waste ['bank'] as $key => $value ) {
  10958. // 支出
  10959. foreach ( $inComeStatistics ['expenditureStatistics'] as $k => $v ) {
  10960. // 广发
  10961. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  10962. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  10963. }
  10964. // 工商
  10965. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  10966. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  10967. }
  10968. // 华润
  10969. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  10970. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  10971. }
  10972. // 个人
  10973. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  10974. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  10975. }
  10976. }
  10977. }
  10978. // 活期
  10979. foreach ( $waste ['financial'] ['current'] as $key => $value ) {
  10980. foreach ( $inComeStatistics ['currentStatistics'] as $k => $v ) {
  10981. // 广发
  10982. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  10983. $waste ['financial'] ['current'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  10984. }
  10985. // 工商
  10986. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  10987. $waste ['financial'] ['current'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  10988. }
  10989. // 个人
  10990. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  10991. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  10992. }
  10993. }
  10994. }
  10995. // print_r($inComeStatistics ['fixedStatistics']);
  10996. // 固期
  10997. foreach ( $waste ['financial'] ['fixed'] as $key => $value ) {
  10998. foreach ( $inComeStatistics ['fixedStatistics'] as $k => $v ) {
  10999. // 广发
  11000. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  11001. $waste ['financial'] ['fixed'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  11002. }
  11003. // 工商
  11004. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  11005. $waste ['financial'] ['fixed'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  11006. }
  11007. // 个人
  11008. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  11009. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  11010. }
  11011. }
  11012. }
  11013. return $waste;
  11014. }
  11015. function lyt() {
  11016. Doo::loadModel ( "receiptDetail" );
  11017. $receiptDetail = new receiptDetail ();
  11018. $receiptCollectList = $receiptDetail->find ( array (
  11019. 'where' => 'status=1 ',
  11020. 'asArray' => true
  11021. ) );
  11022. foreach ( $receiptCollectList as $key => $value ) {
  11023. $receiptDetail = new receiptDetail ();
  11024. $receiptDetail->pastDate = $value ['date'];
  11025. $receiptDetail->update ( array (
  11026. 'where' => "rdid= '" . $value ['rdid'] . "'"
  11027. ) );
  11028. }
  11029. }
  11030. function staffCollectMonthDetail() {
  11031. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  11032. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  11033. if (! $year)
  11034. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  11035. if (! $month)
  11036. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  11037. Doo::loadModel ( 'staff' );
  11038. $staff = new staff ();
  11039. Doo::loadModel ( "receiptDetail" );
  11040. $receiptDetail = new receiptDetail ();
  11041. Doo::loadModel ( 'accountItem' );
  11042. $accountItem = new accountItem ();
  11043. Doo::loadModel ( 'statistics' );
  11044. $statistics = new statistics ();
  11045. Doo::loadModel ( 'L_category' );
  11046. $lCategory = new L_category ();
  11047. Doo::loadModel ( "receiptAuthorityManage" );
  11048. $receiptAuthorityManage = new receiptAuthorityManage ();
  11049. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  11050. $cidList = array ();
  11051. foreach ( $imcStaff as $key => $value ) {
  11052. array_push ( $cidList, $value ['cid'] );
  11053. }
  11054. $cidString = implode ( ',', $cidList );
  11055. $staffList = $staff->find ( array (
  11056. 'where' => 'username!="admin" and cid in (' . $cidString . ')',
  11057. 'asArray' => true
  11058. ) );
  11059. $categoryList = $staff->find ( array (
  11060. 'select' => 'COUNT(*) as count,cid,category',
  11061. 'where' => 'username !="admin" and cid in (' . $cidString . ')',
  11062. 'groupby' => 'cid',
  11063. 'asArray' => true
  11064. ) );
  11065. $list = array ();
  11066. foreach ( $categoryList as $vlu ) {
  11067. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  11068. $r1 = 0;
  11069. $r2 = 0;
  11070. $r3 = 0;
  11071. $r4 = 0;
  11072. $r5 = 0;
  11073. $r6 = 0;
  11074. $r7 = 0;
  11075. $r8 = 0;
  11076. $r9 = 0;
  11077. $r10 = 0;
  11078. $r11 = 0;
  11079. $r12 = 0;
  11080. $r13 = 0;
  11081. $r14 = 0;
  11082. $r15 = 0;
  11083. $r16 = 0;
  11084. $r17 = 0;
  11085. $r18 = 0;
  11086. $c1 = 0;
  11087. $c2 = 0;
  11088. $c3 = 0;
  11089. $c4 = 0;
  11090. $c5 = 0;
  11091. $c6 = 0;
  11092. $p1 = 0;
  11093. $p2 = 0;
  11094. $p3 = 0;
  11095. $p4 = 0;
  11096. $p5 = 0;
  11097. $p6 = 0;
  11098. $p7 = 0;
  11099. $p8 = 0;
  11100. $p9 = 0;
  11101. $p10 = 0;
  11102. $p11 = 0;
  11103. $t1 = 0;
  11104. $t2 = 0;
  11105. $t3 = 0;
  11106. $t4 = 0;
  11107. $t5 = 0;
  11108. $s1 = 0;
  11109. $m1 = 0;
  11110. foreach ( $staffList as $value ) {
  11111. if ($vlu ['cid'] == $value ['cid']) {
  11112. // pastDate
  11113. $receiptCollectList = $receiptDetail->find ( array (
  11114. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  11115. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  11116. 'groupby' => 'item,Month(pastDate),itemCategory',
  11117. 'asArray' => true
  11118. ) );
  11119. // if ($value['sid']==42){
  11120. // print_r($receiptCollectList);die;
  11121. // }
  11122. if (! empty ( $receiptCollectList )) {
  11123. $receiptL = array (
  11124. '日常相关费用' => array (),
  11125. '差旅相关费用' => array (),
  11126. '培训班费用' => array (),
  11127. '其他' => array ()
  11128. );
  11129. $html = "";
  11130. $psum = 0;
  11131. $item = array (
  11132. '市内交通费',
  11133. '市内出租费',
  11134. '办事处房租',
  11135. '电话费',
  11136. '水费',
  11137. '电费',
  11138. '办公费用',
  11139. '邮寄费',
  11140. '其他费用',
  11141. '车辆费用',
  11142. '广告费',
  11143. '团队建设费',
  11144. '物业管理费',
  11145. '宽带费',
  11146. '人员薪酬',
  11147. '公积金',
  11148. '社保'
  11149. );
  11150. foreach ( $item as $va ) {
  11151. $falg = true;
  11152. foreach ( $receiptCollectList as $v ) {
  11153. if ($v ['itemCategory'] == '日常相关费用') {
  11154. if ($v ['item'] == $va) {
  11155. if ($va == '市内交通费')
  11156. $r1 += $v ['price'];
  11157. if ($va == '市内出租费')
  11158. $r2 += $v ['price'];
  11159. if ($va == '办事处房租')
  11160. $r3 += $v ['price'];
  11161. if ($va == '电话费')
  11162. $r4 += $v ['price'];
  11163. if ($va == '水费')
  11164. $r5 += $v ['price'];
  11165. if ($va == '电费')
  11166. $r6 += $v ['price'];
  11167. if ($va == '办公费用')
  11168. $r7 += $v ['price'];
  11169. if ($va == '邮寄费')
  11170. $r8 += $v ['price'];
  11171. if ($va == '其他费用')
  11172. $r9 += $v ['price'];
  11173. if ($va == '车辆费用')
  11174. $r10 += $v ['price'];
  11175. if ($va == '广告费')
  11176. $r11 += $v ['price'];
  11177. if ($va == '团队建设费')
  11178. $r13 += $v ['price'];
  11179. if ($va == '物业管理费')
  11180. $r14 += $v ['price'];
  11181. if ($va == '宽带费')
  11182. $r15 += $v ['price'];
  11183. if ($va == '公积金')
  11184. $r16 += $v ['price'];
  11185. if ($va == '社保')
  11186. $r17 += $v ['price'];
  11187. if ($va == '人员薪酬')
  11188. $r18 += $v ['price'];
  11189. $psum += $v ['price'];
  11190. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11191. $falg = false;
  11192. break;
  11193. }
  11194. }
  11195. }
  11196. if ($falg)
  11197. $html .= '<td class="taR">-</td>';
  11198. }
  11199. $r12 += $psum;
  11200. if (! empty ( $psum ))
  11201. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  11202. else
  11203. $psum = '<td class="colGreen taR">-</td>';
  11204. $receiptL ['日常相关费用'] = $psum . $html;
  11205. /* ----------------------------------- */
  11206. $html = "";
  11207. $psum = 0;
  11208. $item = array (
  11209. '往来交通费',
  11210. '市内交通费',
  11211. '出差住宿费',
  11212. '出差补助',
  11213. '其他费用'
  11214. );
  11215. foreach ( $item as $va ) {
  11216. $falg = true;
  11217. foreach ( $receiptCollectList as $v ) {
  11218. if ($v ['itemCategory'] == '差旅相关费用') {
  11219. if ($v ['item'] == $va) {
  11220. if ($va == '往来交通费')
  11221. $c1 += $v ['price'];
  11222. if ($va == '市内交通费')
  11223. $c2 += $v ['price'];
  11224. if ($va == '出差住宿费')
  11225. $c3 += $v ['price'];
  11226. if ($va == '出差补助')
  11227. $c4 += $v ['price'];
  11228. if ($va == '其他费用')
  11229. $c5 += $v ['price'];
  11230. $psum += $v ['price'];
  11231. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11232. $falg = false;
  11233. break;
  11234. }
  11235. }
  11236. }
  11237. if ($falg)
  11238. $html .= '<td class="taR">-</td>';
  11239. }
  11240. $c6 += $psum;
  11241. if (! empty ( $psum ))
  11242. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  11243. else
  11244. $psum = '<td class="colGreen taR">-</td>';
  11245. $receiptL ['差旅相关费用'] = $psum . $html;
  11246. /* ------------------------------------- */
  11247. $html = "";
  11248. $psum = 0;
  11249. $item = array (
  11250. '场租费',
  11251. '薪酬',
  11252. '住宿费',
  11253. '交通费',
  11254. '餐饮费',
  11255. '办公费',
  11256. '公关费',
  11257. '其他',
  11258. '电话费',
  11259. '邮寄费'
  11260. );
  11261. foreach ( $item as $va ) {
  11262. $falg = true;
  11263. foreach ( $receiptCollectList as $v ) {
  11264. if ($v ['itemCategory'] == '培训班费用') {
  11265. if ($v ['item'] == $va) {
  11266. if ($va == '场租费')
  11267. $p1 += $v ['price'];
  11268. if ($va == '薪酬')
  11269. $p2 += $v ['price'];
  11270. if ($va == '住宿费')
  11271. $p3 += $v ['price'];
  11272. if ($va == '交通费')
  11273. $p4 += $v ['price'];
  11274. if ($va == '餐饮费')
  11275. $p5 += $v ['price'];
  11276. if ($va == '办公费')
  11277. $p6 += $v ['price'];
  11278. if ($va == '公关费')
  11279. $p7 += $v ['price'];
  11280. if ($va == '其他')
  11281. $p8 += $v ['price'];
  11282. if ($va == '电话费')
  11283. $p9 += $v ['price'];
  11284. if ($va == '邮寄费')
  11285. $p10 += $v ['price'];
  11286. $psum += $v ['price'];
  11287. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11288. $falg = false;
  11289. break;
  11290. }
  11291. }
  11292. }
  11293. if ($falg)
  11294. $html .= '<td class="taR">-</td>';
  11295. }
  11296. $p11 += $psum;
  11297. if (! empty ( $psum ))
  11298. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  11299. else
  11300. $psum = '<td class="colGreen taR">-</td>';
  11301. $receiptL ['培训班费用'] = $psum . $html;
  11302. /* ------------------------------------- */
  11303. $html = "";
  11304. $psum = 0;
  11305. $item = array (
  11306. '公关费',
  11307. '广告费',
  11308. '借款',
  11309. '可自加费用'
  11310. );
  11311. foreach ( $item as $va ) {
  11312. $falg = true;
  11313. foreach ( $receiptCollectList as $v ) {
  11314. if ($v ['itemCategory'] == '其他') {
  11315. // if ($value['sid']==42){
  11316. //
  11317. // echo var_dump($v['item']);
  11318. // echo var_dump($va);
  11319. // echo var_dump($v['item']==" ".$va);
  11320. // echo $v['item']."==".$va."/<br/>";
  11321. // //print_r( $receiptCollectList);//echo $va;
  11322. // }
  11323. if (trim ( $v ['item'] ) == $va) {
  11324. if ($va == '公关费')
  11325. $t1 += $v ['price'];
  11326. if ($va == '广告费') {
  11327. $t2 += $v ['price'];
  11328. }
  11329. if ($va == '借款')
  11330. $t3 += $v ['price'];
  11331. if ($va == '可自加费用')
  11332. $t4 += $v ['price'];
  11333. $psum += $v ['price'];
  11334. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11335. $falg = false;
  11336. break;
  11337. }
  11338. }
  11339. }
  11340. if ($falg)
  11341. $html .= '<td class="taR">-</td>';
  11342. }
  11343. $t5 += $psum;
  11344. if (! empty ( $psum ))
  11345. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  11346. else
  11347. $psum = '<td class="colGreen taR">-</td>';
  11348. $receiptL ['其他'] = $psum . $html;
  11349. /* ------------------------------------- */
  11350. $html = "";
  11351. $psum = 0;
  11352. foreach ( $receiptCollectList as $v ) {
  11353. if ($v ['itemCategory'] == '报销金额调整') {
  11354. if (! empty ( $v ['price'] )) {
  11355. $psum += $v ['price'];
  11356. }
  11357. }
  11358. }
  11359. $s1 += $psum;
  11360. if (! empty ( $psum ))
  11361. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  11362. else
  11363. $psum = '<td class="taR colOrange">-</td>';
  11364. $receiptL ['报销金额调整'] = $psum . $html;
  11365. } else {
  11366. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  11367. <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>
  11368. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  11369. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  11370. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  11371. $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>
  11372. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  11373. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  11374. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  11375. }
  11376. $monthStaffPrice = $receiptDetail->find ( array (
  11377. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  11378. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  11379. 'groupby' => 'Month(pastDate)',
  11380. 'asArray' => true
  11381. ) );
  11382. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  11383. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  11384. $m1 += $monthStaffPrice [0] ['price'];
  11385. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  11386. } else
  11387. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  11388. $receiptL ['usernameEn'] = urlencode ( $value ['username'] );
  11389. $list [$value ['username']] = $receiptL;
  11390. }
  11391. }
  11392. $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>
  11393. <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>
  11394. <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>';
  11395. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  11396. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  11397. $receiptL ['培训班费用'] = '<td class="colGreen taR">' . $p11 . '</td><td class="taR">' . $p1 . '</td><td class="taR">' . $p2 . '</td><td class="taR">' . $p3 . '</td><td class="taR">' . $p4 . '</td>
  11398. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td><td class="taR">' . $p9 . '</td><td class="taR">' . $p10 . '</td>';
  11399. $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>';
  11400. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  11401. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  11402. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  11403. }
  11404. $data ['list'] = $list;
  11405. // print_r($list);
  11406. $receiptCollectList = $receiptDetail->find ( array (
  11407. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  11408. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  11409. 'groupby' => 'item,Month(pastDate),itemCategory',
  11410. 'asArray' => true
  11411. ) );
  11412. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  11413. // statistics html
  11414. $stList = $statistics->getOne ( array (
  11415. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  11416. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  11417. 'groupby' => 'Month(date)',
  11418. 'asArray' => true
  11419. ) );
  11420. if (empty ( $stList ))
  11421. $stList = array (
  11422. 'rePrice' => 0,
  11423. 'agPrice' => 0
  11424. );
  11425. $data ['stList'] = array (
  11426. 'rePrice' => $stList ['rePrice'],
  11427. 'agPrice' => $stList ['agPrice'],
  11428. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  11429. );
  11430. $monthHtml = "";
  11431. for($i = 1; $i <= 12; $i ++) {
  11432. if ($i == $month)
  11433. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  11434. else
  11435. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  11436. }
  11437. $data ['monthHtml'] = $monthHtml;
  11438. $data ['year'] = $year;
  11439. $data ['month'] = $month;
  11440. $data ['memu'] = "receipt";
  11441. $data ['staff'] = $this->staff;
  11442. $data ['receiptMemu'] = 'companyCategoryCollect';
  11443. $data ['verifyId'] = $this->verifyId;
  11444. $data ['executeId'] = $this->executeId;
  11445. $this->render ( "/admin/staffCollectMonthDetail", $data );
  11446. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  11447. }
  11448. function staffCollectMonthDetail2() {
  11449. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  11450. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  11451. if (! $year)
  11452. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  11453. if (! $month)
  11454. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  11455. Doo::loadModel ( 'staff' );
  11456. $staff = new staff ();
  11457. Doo::loadModel ( "receiptDetail" );
  11458. $receiptDetail = new receiptDetail ();
  11459. Doo::loadModel ( 'accountItem' );
  11460. $accountItem = new accountItem ();
  11461. Doo::loadModel ( 'statistics' );
  11462. $statistics = new statistics ();
  11463. Doo::loadModel ( 'L_category' );
  11464. $lCategory = new L_category ();
  11465. $staffList = $staff->find ( array (
  11466. 'where' => 'username!="admin"',
  11467. 'asArray' => true
  11468. ) );
  11469. $categoryList = $staff->find ( array (
  11470. 'select' => 'COUNT(*) as count,cid,category',
  11471. 'where' => 'username !="admin"',
  11472. 'groupby' => 'cid',
  11473. 'asArray' => true
  11474. ) );
  11475. $list = array ();
  11476. foreach ( $categoryList as $vlu ) {
  11477. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  11478. $r1 = 0;
  11479. $r2 = 0;
  11480. $r3 = 0;
  11481. $r4 = 0;
  11482. $r5 = 0;
  11483. $r6 = 0;
  11484. $r7 = 0;
  11485. $r8 = 0;
  11486. $r9 = 0;
  11487. $r10 = 0;
  11488. $r11 = 0;
  11489. $r12 = 0;
  11490. $r13 = 0;
  11491. $r14 = 0;
  11492. $r15 = 0;
  11493. $c1 = 0;
  11494. $c2 = 0;
  11495. $c3 = 0;
  11496. $c4 = 0;
  11497. $c5 = 0;
  11498. $c6 = 0;
  11499. $p1 = 0;
  11500. $p2 = 0;
  11501. $p3 = 0;
  11502. $p4 = 0;
  11503. $p5 = 0;
  11504. $p6 = 0;
  11505. $p7 = 0;
  11506. $p8 = 0;
  11507. $p9 = 0;
  11508. $t1 = 0;
  11509. $t2 = 0;
  11510. $t3 = 0;
  11511. $t4 = 0;
  11512. $t5 = 0;
  11513. $s1 = 0;
  11514. $m1 = 0;
  11515. foreach ( $staffList as $value ) {
  11516. if ($vlu ['cid'] == $value ['cid']) {
  11517. $receiptCollectList = $receiptDetail->find ( array (
  11518. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  11519. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  11520. 'groupby' => 'item,Month(date),itemCategory',
  11521. 'asArray' => true
  11522. ) );
  11523. if (! empty ( $receiptCollectList )) {
  11524. $receiptL = array (
  11525. '日常相关费用' => array (),
  11526. '差旅相关费用' => array (),
  11527. '培训班费用' => array (),
  11528. '其他' => array ()
  11529. );
  11530. $html = "";
  11531. $psum = 0;
  11532. $item = array (
  11533. '市内交通费',
  11534. '市内出租费',
  11535. '办事处房租',
  11536. '电话费',
  11537. '水费',
  11538. '电费',
  11539. '办公费用',
  11540. '邮寄费',
  11541. '其他费用',
  11542. '车辆费用',
  11543. '广告费',
  11544. '团队建设费',
  11545. '物业管理费',
  11546. '宽带费'
  11547. );
  11548. foreach ( $item as $va ) {
  11549. $falg = true;
  11550. foreach ( $receiptCollectList as $v ) {
  11551. if ($v ['itemCategory'] == '日常相关费用') {
  11552. if ($v ['item'] == $va) {
  11553. if ($va == '市内交通费')
  11554. $r1 += $v ['price'];
  11555. if ($va == '市内出租费')
  11556. $r2 += $v ['price'];
  11557. if ($va == '办事处房租')
  11558. $r3 += $v ['price'];
  11559. if ($va == '电话费')
  11560. $r4 += $v ['price'];
  11561. if ($va == '水费')
  11562. $r5 += $v ['price'];
  11563. if ($va == '电费')
  11564. $r6 += $v ['price'];
  11565. if ($va == '办公费用')
  11566. $r7 += $v ['price'];
  11567. if ($va == '邮寄费')
  11568. $r8 += $v ['price'];
  11569. if ($va == '其他费用')
  11570. $r9 += $v ['price'];
  11571. if ($va == '车辆费用')
  11572. $r10 += $v ['price'];
  11573. if ($va == '广告费')
  11574. $r11 += $v ['price'];
  11575. if ($va == '团队建设费')
  11576. $r13 += $v ['price'];
  11577. if ($va == '物业管理费')
  11578. $r14 += $v ['price'];
  11579. if ($va == '宽带费')
  11580. $r15 += $v ['price'];
  11581. $psum += $v ['price'];
  11582. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11583. $falg = false;
  11584. break;
  11585. }
  11586. }
  11587. }
  11588. if ($falg)
  11589. $html .= '<td class="taR">-</td>';
  11590. }
  11591. $r12 += $psum;
  11592. if (! empty ( $psum ))
  11593. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  11594. else
  11595. $psum = '<td class="colGreen taR">-</td>';
  11596. $receiptL ['日常相关费用'] = $psum . $html;
  11597. /* ----------------------------------- */
  11598. $html = "";
  11599. $psum = 0;
  11600. $item = array (
  11601. '往来交通费',
  11602. '市内交通费',
  11603. '出差住宿费',
  11604. '出差补助',
  11605. '其他费用'
  11606. );
  11607. foreach ( $item as $va ) {
  11608. $falg = true;
  11609. foreach ( $receiptCollectList as $v ) {
  11610. if ($v ['itemCategory'] == '差旅相关费用') {
  11611. if ($v ['item'] == $va) {
  11612. if ($va == '往来交通费')
  11613. $c1 += $v ['price'];
  11614. if ($va == '市内交通费')
  11615. $c2 += $v ['price'];
  11616. if ($va == '出差住宿费')
  11617. $c3 += $v ['price'];
  11618. if ($va == '出差补助')
  11619. $c4 += $v ['price'];
  11620. if ($va == '其他费用')
  11621. $c5 += $v ['price'];
  11622. $psum += $v ['price'];
  11623. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11624. $falg = false;
  11625. break;
  11626. }
  11627. }
  11628. }
  11629. if ($falg)
  11630. $html .= '<td class="taR">-</td>';
  11631. }
  11632. $c6 += $psum;
  11633. if (! empty ( $psum ))
  11634. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  11635. else
  11636. $psum = '<td class="colGreen taR">-</td>';
  11637. $receiptL ['差旅相关费用'] = $psum . $html;
  11638. /* ------------------------------------- */
  11639. $html = "";
  11640. $psum = 0;
  11641. $item = array (
  11642. '场租费',
  11643. '薪酬',
  11644. '住宿费',
  11645. '交通费',
  11646. '餐饮费',
  11647. '办公费',
  11648. '公关费',
  11649. '其他'
  11650. );
  11651. foreach ( $item as $va ) {
  11652. $falg = true;
  11653. foreach ( $receiptCollectList as $v ) {
  11654. if ($v ['itemCategory'] == '培训班费用') {
  11655. if ($v ['item'] == $va) {
  11656. if ($va == '场租费')
  11657. $p1 += $v ['price'];
  11658. if ($va == '薪酬')
  11659. $p2 += $v ['price'];
  11660. if ($va == '住宿费')
  11661. $p3 += $v ['price'];
  11662. if ($va == '交通费')
  11663. $p4 += $v ['price'];
  11664. if ($va == '餐饮费')
  11665. $p5 += $v ['price'];
  11666. if ($va == '办公费')
  11667. $p6 += $v ['price'];
  11668. if ($va == '公关费')
  11669. $p7 += $v ['price'];
  11670. if ($va == '其他')
  11671. $p8 += $v ['price'];
  11672. $psum += $v ['price'];
  11673. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11674. $falg = false;
  11675. break;
  11676. }
  11677. }
  11678. }
  11679. if ($falg)
  11680. $html .= '<td class="taR">-</td>';
  11681. }
  11682. $p9 += $psum;
  11683. if (! empty ( $psum ))
  11684. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  11685. else
  11686. $psum = '<td class="colGreen taR">-</td>';
  11687. $receiptL ['培训班费用'] = $psum . $html;
  11688. /* ------------------------------------- */
  11689. $html = "";
  11690. $psum = 0;
  11691. $item = array (
  11692. '公关费',
  11693. '广告费',
  11694. '借款',
  11695. '可自加费用'
  11696. );
  11697. foreach ( $item as $va ) {
  11698. $falg = true;
  11699. foreach ( $receiptCollectList as $v ) {
  11700. if ($v ['itemCategory'] == '其他') {
  11701. if ($v ['item'] == $va) {
  11702. if ($va == '公关费')
  11703. $t1 += $v ['price'];
  11704. if ($va == '广告费')
  11705. $t2 += $v ['price'];
  11706. if ($va == '借款')
  11707. $t3 += $v ['price'];
  11708. if ($va == '可自加费用')
  11709. $t4 += $v ['price'];
  11710. $psum += $v ['price'];
  11711. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11712. $falg = false;
  11713. break;
  11714. }
  11715. }
  11716. }
  11717. if ($falg)
  11718. $html .= '<td class="taR">-</td>';
  11719. }
  11720. $t5 += $psum;
  11721. if (! empty ( $psum ))
  11722. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  11723. else
  11724. $psum = '<td class="colGreen taR">-</td>';
  11725. $receiptL ['其他'] = $psum . $html;
  11726. /* ------------------------------------- */
  11727. $html = "";
  11728. $psum = 0;
  11729. foreach ( $receiptCollectList as $v ) {
  11730. if ($v ['itemCategory'] == '报销金额调整') {
  11731. if (! empty ( $v ['price'] )) {
  11732. $psum += $v ['price'];
  11733. }
  11734. }
  11735. }
  11736. $s1 += $psum;
  11737. if (! empty ( $psum ))
  11738. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  11739. else
  11740. $psum = '<td class="taR colOrange">-</td>';
  11741. $receiptL ['报销金额调整'] = $psum . $html;
  11742. } else {
  11743. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  11744. <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>';
  11745. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  11746. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  11747. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  11748. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  11749. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  11750. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  11751. }
  11752. $monthStaffPrice = $receiptDetail->find ( array (
  11753. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  11754. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  11755. 'asArray' => true
  11756. ) );
  11757. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  11758. $m1 += $monthStaffPrice [0] ['price'];
  11759. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  11760. } else
  11761. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  11762. $list [$value ['username']] = $receiptL;
  11763. }
  11764. }
  11765. $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>
  11766. <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>
  11767. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  11768. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  11769. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  11770. $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>
  11771. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  11772. $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>';
  11773. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  11774. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  11775. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  11776. }
  11777. $data ['list'] = $list;
  11778. $receiptCollectList = $receiptDetail->find ( array (
  11779. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  11780. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  11781. 'groupby' => 'item,Month(date),itemCategory',
  11782. 'asArray' => true
  11783. ) );
  11784. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  11785. // statistics html
  11786. $stList = $statistics->getOne ( array (
  11787. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  11788. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  11789. 'groupby' => 'Month(date)',
  11790. 'asArray' => true
  11791. ) );
  11792. if (empty ( $stList ))
  11793. $stList = array (
  11794. 'rePrice' => 0,
  11795. 'agPrice' => 0
  11796. );
  11797. $data ['stList'] = array (
  11798. 'rePrice' => $stList ['rePrice'],
  11799. 'agPrice' => $stList ['agPrice'],
  11800. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  11801. );
  11802. $monthHtml = "";
  11803. for($i = 1; $i <= 12; $i ++) {
  11804. if ($i == $month)
  11805. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  11806. else
  11807. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  11808. }
  11809. $data ['monthHtml'] = $monthHtml;
  11810. $data ['year'] = $year;
  11811. $data ['month'] = $month;
  11812. $data ['memu'] = "receipt";
  11813. $data ['staff'] = $this->staff;
  11814. $data ['receiptMemu'] = 'companyCategoryCollect';
  11815. $data ['verifyId'] = $this->verifyId;
  11816. $data ['executeId'] = $this->executeId;
  11817. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  11818. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  11819. }
  11820. /**
  11821. * 用户报销单列表
  11822. */
  11823. function receiptStatisticsStaffDetail() {
  11824. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  11825. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  11826. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  11827. Doo::loadModel ( "receipt" );
  11828. $receipt = new receipt ();
  11829. Doo::loadModel ( "receiptDetail" );
  11830. $receiptDetail = new receiptDetail ();
  11831. Doo::loadModel ( 'staff' );
  11832. $staff = new staff ();
  11833. Doo::loadModel ( 'accountItem' );
  11834. $accountItem = new accountItem ();
  11835. Doo::loadModel ( 'statistics' );
  11836. $statistics = new statistics ();
  11837. if (! empty ( $username )) {
  11838. $username = addslashes ( urldecode ( $username ) );
  11839. $staffDetail = $staff->getStaffByName ( $username );
  11840. if (empty ( $staffDetail ))
  11841. die ( 'illegal request' );
  11842. $list = $receipt->getReceiptBySid ( $staffDetail ['sid'], $year, $month );
  11843. $itemList = $accountItem->getAccountItem ();
  11844. $itemHtml = '';
  11845. $categoryHtml = '';
  11846. $itemKeyList = array_keys ( $itemList );
  11847. $revisePrice = 0;
  11848. // 报销单内容详情
  11849. foreach ( $list as $key => $value ) {
  11850. $accountItemList = json_decode ( $value ['accountItem'], true );
  11851. $list [$key] ['accountItemList'] = $accountItemList;
  11852. $receiptItemHtml = '';
  11853. foreach ( $itemKeyList as $v ) {
  11854. if ($v == '日常相关费用')
  11855. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['agencySum'] . '</td>';
  11856. elseif ($v == '差旅相关费用')
  11857. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['travelSum'] . '</td>';
  11858. elseif ($v == '培训班费用')
  11859. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['trainSum'] . '</td>';
  11860. elseif ($v == '其他')
  11861. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['otherSum'] . '</td>';
  11862. foreach ( $itemList [$v] as $ke => $va ) {
  11863. $falg = true;
  11864. if (! empty ( $accountItemList [$v] )) {
  11865. foreach ( $accountItemList [$v] as $ve ) {
  11866. if ($va ['name'] == $ve ['name']) {
  11867. $receiptItemHtml .= '<td class="taR">' . $ve ['price'] . '</td>';
  11868. $falg = false;
  11869. break;
  11870. }
  11871. }
  11872. }
  11873. if ($falg)
  11874. $receiptItemHtml .= '<td class="taR"></td>';
  11875. }
  11876. }
  11877. // 金额调整和费用查看
  11878. $revisePrice += $value ['revisePrice'];
  11879. $receiptItemHtml .= '<td class="taR">' . $value ['revisePrice'] . '</td>';
  11880. $receiptItemHtml .= '<td class="taR"><a href="#detail" data-toggle="modal" onclick=showExplanation("' . $value ['explanation'] . '")>查看</a></td>';
  11881. $list [$key] ['receiptItemHtml'] = $receiptItemHtml;
  11882. }
  11883. // 报销单合计
  11884. $receiptTotalList = $receiptDetail->getReceiptTotalItem ( $staffDetail ['sid'], $year, $month );
  11885. $rtl = $receiptDetail->getReceiptTotalItemCategory ( $staffDetail ['sid'], $year, $month );
  11886. $receiptTotalHtml = '';
  11887. // 报销单项目抬头
  11888. foreach ( $itemKeyList as $value ) {
  11889. $count = count ( $itemList [$value] ) + 1;
  11890. $itemHtml .= '<th class="taC" colspan="' . $count . '">' . $value . '</th>';
  11891. $categoryHtml .= '<th class="taC">合计</th>';
  11892. foreach ( $rtl as $rtlValue ) {
  11893. if ($rtlValue ['itemCategory'] == $value) {
  11894. $receiptTotalHtml .= '<th>' . $rtlValue ['price'] . '</th>';
  11895. break;
  11896. }
  11897. }
  11898. foreach ( $itemList [$value] as $k => $v ) {
  11899. $categoryHtml .= '<th class="taC">' . $v ['name'] . '</th>';
  11900. // 合计
  11901. $falg = true;
  11902. foreach ( $receiptTotalList as $ve ) {
  11903. if ($ve ['itemCategory'] == $value && $ve ['item'] == $v ['name']) {
  11904. $receiptTotalHtml .= '<th >' . $ve ['price'] . '</th>';
  11905. $falg = false;
  11906. break;
  11907. }
  11908. }
  11909. if ($falg)
  11910. $receiptTotalHtml .= '<th></th>';
  11911. }
  11912. }
  11913. $receiptTotalHtml .= '<th>' . $revisePrice . '</th>';
  11914. $stList = $statistics->getStatisticsBySid ( $staffDetail ['sid'], $year, $month );
  11915. if (empty ( $stList ))
  11916. $stList = array (
  11917. 'rePrice' => 0,
  11918. 'agPrice' => 0
  11919. );
  11920. $data ['stList'] = array (
  11921. 'rePrice' => $stList ['rePrice'],
  11922. 'agPrice' => $stList ['agPrice'],
  11923. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  11924. );
  11925. $monthHtml = "";
  11926. for($i = 1; $i <= 12; $i ++) {
  11927. if ($i == $month)
  11928. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  11929. else
  11930. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  11931. }
  11932. $data ['username'] = urlencode ( $username );
  11933. $data ['usernameEN'] = $username;
  11934. $data ['monthHtml'] = $monthHtml;
  11935. $data ['receiptTotalHtml'] = $receiptTotalHtml;
  11936. $data ['list'] = $list;
  11937. $data ['categoryHtml'] = $categoryHtml;
  11938. $data ['itemHtml'] = $itemHtml;
  11939. $data ['itemList'] = $itemList;
  11940. $data ['year'] = $year;
  11941. $data ['month'] = $month;
  11942. $data ['memu'] = "receipt";
  11943. $data ['staff'] = $this->staff;
  11944. $data ['receiptMemu'] = 'companyCategoryCollect';
  11945. $data ['verifyId'] = $this->verifyId;
  11946. $data ['executeId'] = $this->executeId;
  11947. $this->render ( "/admin/receiptStatisticsStaffDetail", $data );
  11948. }
  11949. die ( 'illegal request' );
  11950. }
  11951. function companyMonthCollectDetail() {
  11952. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  11953. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  11954. if (! $year)
  11955. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  11956. if (! $month)
  11957. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  11958. Doo::loadModel ( 'staff' );
  11959. $staff = new staff ();
  11960. Doo::loadModel ( "receiptDetail" );
  11961. $receiptDetail = new receiptDetail ();
  11962. Doo::loadModel ( 'accountItem' );
  11963. $accountItem = new accountItem ();
  11964. Doo::loadModel ( 'statistics' );
  11965. $statistics = new statistics ();
  11966. Doo::loadModel ( 'L_category' );
  11967. $lCategory = new L_category ();
  11968. $staffList = $staff->find ( array (
  11969. 'where' => 'username!="admin"',
  11970. 'asArray' => true
  11971. ) );
  11972. $categoryList = $lCategory->find ( array (
  11973. 'asArray' => true
  11974. ) );
  11975. $list = array ();
  11976. foreach ( $categoryList as $value ) {
  11977. $receiptCollectList = $receiptDetail->find ( array (
  11978. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  11979. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  11980. 'groupby' => 'item,Month(pastDate),itemCategory',
  11981. 'asArray' => true
  11982. ) );
  11983. if (! empty ( $receiptCollectList )) {
  11984. $receiptL = array (
  11985. '日常相关费用' => array (),
  11986. '差旅相关费用' => array (),
  11987. '培训班费用' => array (),
  11988. '其他' => array ()
  11989. );
  11990. $html = "";
  11991. $psum = 0;
  11992. $item = array (
  11993. '市内交通费',
  11994. '市内出租费',
  11995. '办事处房租',
  11996. '电话费',
  11997. '水费',
  11998. '电费',
  11999. '办公费用',
  12000. '邮寄费',
  12001. '其他费用',
  12002. '车辆费用',
  12003. '广告费',
  12004. '团队建设费'
  12005. );
  12006. foreach ( $item as $va ) {
  12007. $falg = true;
  12008. foreach ( $receiptCollectList as $v ) {
  12009. if ($v ['itemCategory'] == '日常相关费用') {
  12010. if ($v ['item'] == $va) {
  12011. $psum += $v ['price'];
  12012. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12013. $falg = false;
  12014. break;
  12015. }
  12016. }
  12017. }
  12018. if ($falg)
  12019. $html .= '<td class="taR">-</td>';
  12020. }
  12021. if (! empty ( $psum ))
  12022. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  12023. else
  12024. $psum = '<td class="colGreen taR">-</td>';
  12025. $receiptL ['日常相关费用'] = $psum . $html;
  12026. /* ----------------------------------- */
  12027. $html = "";
  12028. $psum = 0;
  12029. $item = array (
  12030. '往来交通费',
  12031. '市内交通费',
  12032. '出差住宿费',
  12033. '出差补助',
  12034. '其他费用'
  12035. );
  12036. foreach ( $item as $va ) {
  12037. $falg = true;
  12038. foreach ( $receiptCollectList as $v ) {
  12039. if ($v ['itemCategory'] == '差旅相关费用') {
  12040. if ($v ['item'] == $va) {
  12041. $psum += $v ['price'];
  12042. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12043. $falg = false;
  12044. break;
  12045. }
  12046. }
  12047. }
  12048. if ($falg)
  12049. $html .= '<td class="taR">-</td>';
  12050. }
  12051. if (! empty ( $psum ))
  12052. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  12053. else
  12054. $psum = '<td class="colGreen taR">-</td>';
  12055. $receiptL ['差旅相关费用'] = $psum . $html;
  12056. /* ------------------------------------- */
  12057. $html = "";
  12058. $psum = 0;
  12059. $item = array (
  12060. '场租费',
  12061. '薪酬',
  12062. '住宿费',
  12063. '交通费',
  12064. '餐饮费',
  12065. '办公费',
  12066. '公关费',
  12067. '其他'
  12068. );
  12069. foreach ( $item as $va ) {
  12070. $falg = true;
  12071. foreach ( $receiptCollectList as $v ) {
  12072. if ($v ['itemCategory'] == '培训班费用') {
  12073. if ($v ['item'] == $va) {
  12074. $psum += $v ['price'];
  12075. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12076. $falg = false;
  12077. break;
  12078. }
  12079. }
  12080. }
  12081. if ($falg)
  12082. $html .= '<td class="taR">-</td>';
  12083. }
  12084. if (! empty ( $psum ))
  12085. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  12086. else
  12087. $psum = '<td class="colGreen taR">-</td>';
  12088. $receiptL ['培训班费用'] = $psum . $html;
  12089. /* ------------------------------------- */
  12090. $html = "";
  12091. $psum = 0;
  12092. $item = array (
  12093. '公关费',
  12094. '广告费',
  12095. '借款',
  12096. '可自加费用'
  12097. );
  12098. foreach ( $item as $va ) {
  12099. $falg = true;
  12100. foreach ( $receiptCollectList as $v ) {
  12101. if ($v ['itemCategory'] == '其他') {
  12102. if ($v ['item'] == $va) {
  12103. $psum += $v ['price'];
  12104. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12105. $falg = false;
  12106. break;
  12107. }
  12108. }
  12109. }
  12110. if ($falg)
  12111. $html .= '<td class="taR">-</td>';
  12112. }
  12113. if (! empty ( $psum ))
  12114. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  12115. else
  12116. $psum = '<td class="colGreen taR">-</td>';
  12117. $receiptL ['其他'] = $psum . $html;
  12118. /* ------------------------------------- */
  12119. $html = "";
  12120. $psum = 0;
  12121. foreach ( $receiptCollectList as $v ) {
  12122. if ($v ['itemCategory'] == '报销金额调整') {
  12123. if (! empty ( $v ['price'] ))
  12124. $psum += $v ['price'];
  12125. }
  12126. }
  12127. if (! empty ( $psum ))
  12128. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  12129. else
  12130. $psum = '<td class="taR colOrange">-</td>';
  12131. $receiptL ['报销金额调整'] = $psum . $html;
  12132. } else {
  12133. $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>
  12134. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12135. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  12136. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12137. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  12138. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12139. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12140. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  12141. }
  12142. $monthStaffPrice = $receiptDetail->find ( array (
  12143. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12144. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12145. 'asArray' => true
  12146. ) );
  12147. if (! empty ( $monthStaffPrice [0] ['price'] ))
  12148. $receiptL ['monthStaffPrice'] = '<td><b>' . $monthStaffPrice [0] ['price'] . '</b></td>';
  12149. else
  12150. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  12151. $list [$value ['title']] = $receiptL;
  12152. }
  12153. $data ['list'] = $list;
  12154. $receiptCollectList = $receiptDetail->find ( array (
  12155. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12156. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12157. 'groupby' => 'item,Month(pastDate),itemCategory',
  12158. 'asArray' => true
  12159. ) );
  12160. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  12161. // print_r($data['monthPriceHtml']);
  12162. // foreach ($data['monthPriceHtml'] as $value){
  12163. // echo $value;
  12164. // }
  12165. // die;
  12166. // statistics html
  12167. $stList = $statistics->getOne ( array (
  12168. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  12169. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  12170. 'groupby' => 'Month(date)',
  12171. 'asArray' => true
  12172. ) );
  12173. if (empty ( $stList ))
  12174. $stList = array (
  12175. 'rePrice' => 0,
  12176. 'agPrice' => 0
  12177. );
  12178. $data ['stList'] = array (
  12179. 'rePrice' => $stList ['rePrice'],
  12180. 'agPrice' => $stList ['agPrice'],
  12181. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  12182. );
  12183. $monthHtml = "";
  12184. for($i = 1; $i <= 12; $i ++) {
  12185. if ($i == $month)
  12186. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  12187. else
  12188. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  12189. }
  12190. $data ['monthHtml'] = $monthHtml;
  12191. $data ['year'] = $year;
  12192. $data ['month'] = $month;
  12193. $data ['memu'] = "receipt";
  12194. $data ['staff'] = $this->staff;
  12195. $data ['receiptMemu'] = 'companyCategoryCollect';
  12196. $data ['verifyId'] = $this->verifyId;
  12197. $data ['executeId'] = $this->executeId;
  12198. $this->render ( "/admin/companyMonthCollectDetail", $data );
  12199. }
  12200. function staffCollectDetail() {
  12201. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  12202. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  12203. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  12204. if (! $staffname) {
  12205. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  12206. $staffname = urldecode ( $staffname );
  12207. }
  12208. Doo::loadModel ( 'staff' );
  12209. $staff = new staff ();
  12210. Doo::loadModel ( "receiptDetail" );
  12211. $receiptDetail = new receiptDetail ();
  12212. Doo::loadModel ( 'accountItem' );
  12213. $accountItem = new accountItem ();
  12214. Doo::loadModel ( 'statistics' );
  12215. $statistics = new statistics ();
  12216. Doo::loadModel ( 'L_category' );
  12217. $lCategory = new L_category ();
  12218. Doo::loadModel ( "receiptAuthorityManage" );
  12219. $receiptAuthorityManage = new receiptAuthorityManage ();
  12220. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  12221. $cidList = array ();
  12222. foreach ( $imcStaff as $key => $value ) {
  12223. array_push ( $cidList, $value ['cid'] );
  12224. }
  12225. $cidString = implode ( ',', $cidList );
  12226. $staffList = $staff->find ( array (
  12227. 'where' => ' cid in (' . $cidString . ')',
  12228. 'asArray' => true
  12229. ) );
  12230. $stHtml = '';
  12231. $stTitle = "";
  12232. $staffId = 0;
  12233. $cid = 0;
  12234. $ocid = 0;
  12235. foreach ( $staffList as $value ) {
  12236. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  12237. $stTitle = $value ['category'] . '-' . $value ['username'];
  12238. $staffId = $value ['sid'];
  12239. $cid = $value ['cid'];
  12240. $ocid = $value ['cid'];
  12241. if (! empty ( $value ['othercid'] ))
  12242. $cid = $value ['cid'] . ',' . $value ['othercid'];
  12243. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  12244. } elseif ($value ['username'] != 'admin')
  12245. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  12246. }
  12247. $data ['lCategoryHtml'] = $lCategory->find ( array (
  12248. 'where' => 'cid in(' . $cid . ')',
  12249. 'asArray' => true
  12250. ) );
  12251. if (empty ( $pcid ))
  12252. $pcid = $ocid;
  12253. $data ['ocid'] = $pcid;
  12254. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  12255. $this->showCache ( $path );
  12256. //
  12257. $receiptCollectList = $receiptDetail->find ( array (
  12258. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12259. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  12260. 'groupby' => 'item,Month(pastDate),itemCategory',
  12261. 'asArray' => true
  12262. ) );
  12263. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  12264. // print_r($receiptCollectList);
  12265. $accountList = $accountItem->find ( array (
  12266. 'asArray' => true
  12267. ) );
  12268. // create CollectDetail HTML
  12269. $collectHtml = array ();
  12270. foreach ( $accountList as $key => $value ) {
  12271. $html = "";
  12272. $asum = 0;
  12273. for($i = 1; $i <= 12; $i ++) {
  12274. $falg = true;
  12275. foreach ( $receiptCollectList as $v ) {
  12276. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  12277. if ($v ['item'] == '可自加费用') {
  12278. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  12279. }
  12280. $asum += $v ['price'];
  12281. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12282. $falg = false;
  12283. break;
  12284. }
  12285. }
  12286. if ($falg)
  12287. $html .= '<td class="taR">-</td>';
  12288. }
  12289. $html .= '<td class="taR colGreen"><b>' . $asum . '</b></td>';
  12290. $collectHtml [$value ['category']] [$value ['name']] = $html;
  12291. }
  12292. $data ['collectHtml'] = $collectHtml;
  12293. // print_r($collectHtml);
  12294. // create Adjustment price html
  12295. $receiptCollectList = $receiptDetail->find ( array (
  12296. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  12297. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  12298. 'groupby' => 'itemCategory,Month(pastDate)',
  12299. 'asArray' => true
  12300. ) );
  12301. $adjustment = array ();
  12302. $collectArray = array (
  12303. '日常相关费用' => array (),
  12304. '差旅相关费用' => array (),
  12305. '培训班费用' => array (),
  12306. '其他' => array ()
  12307. );
  12308. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  12309. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  12310. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  12311. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  12312. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  12313. array_push ( $collectArray ['培训班费用'], $collectHtml );
  12314. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  12315. array_push ( $collectArray ['其他'], $collectHtml );
  12316. $data ['collectArray'] = $collectArray;
  12317. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  12318. array_push ( $adjustment, $collectHtml );
  12319. $data ['adjustment'] = $adjustment;
  12320. // total price html
  12321. $collectHtml = "";
  12322. $total = 0;
  12323. for($i = 1; $i <= 12; $i ++) {
  12324. $sumPrice = 0;
  12325. foreach ( $receiptCollectList as $key => $value ) {
  12326. if ($value ['month'] == $i) {
  12327. $sumPrice += $value ['price'];
  12328. }
  12329. }
  12330. if ($sumPrice == 0)
  12331. $collectHtml .= '<td class="taR">-</td>';
  12332. else
  12333. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  12334. $total += $sumPrice;
  12335. }
  12336. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  12337. // statistics html
  12338. $stList = $statistics->statisticsByYear ( $year, $staffId );
  12339. if (empty ( $stList ))
  12340. $stList = array (
  12341. 'rePrice' => 0,
  12342. 'agPrice' => 0
  12343. );
  12344. $data ['stList'] = array (
  12345. 'rePrice' => $stList ['rePrice'],
  12346. 'agPrice' => $stList ['agPrice'],
  12347. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  12348. );
  12349. $data ['totalPrice'] = $collectHtml;
  12350. $data ['totalYear'] = $total;
  12351. $data ['stHtml'] = $stHtml;
  12352. $data ['year'] = $year;
  12353. $data ['stTitle'] = $stTitle;
  12354. $data ['staffname'] = urlencode ( $staffname );
  12355. $data ['memu'] = "receipt";
  12356. $data ['staff'] = $this->staff;
  12357. $data ['receiptMemu'] = 'companyCategoryCollect';
  12358. $data ['verifyId'] = $this->verifyId;
  12359. $data ['executeId'] = $this->executeId;
  12360. if ($year < date ( "Y" )) {
  12361. Doo::loadModel ( 'receipt' );
  12362. $receipt = new receipt ();
  12363. $receiptList = $receipt->find ( array (
  12364. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  12365. 'asArray' => true
  12366. ) );
  12367. if (empty ( $receiptList )) { // generated files
  12368. ob_start ();
  12369. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  12370. $this->cacheFile ( $path );
  12371. die ();
  12372. }
  12373. }
  12374. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  12375. }
  12376. function BUGFLAG() {
  12377. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  12378. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  12379. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12380. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  12381. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  12382. if (empty ( $status ))
  12383. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  12384. $page_size = 12;
  12385. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  12386. $vidList = array ();
  12387. $button = 0;
  12388. Doo::loadModel ( 'verify' );
  12389. $verify = new verify ();
  12390. Doo::loadModel ( 'receipt' );
  12391. $receipt = new receipt ();
  12392. Doo::loadModel ( 'staff' );
  12393. $staff = new staff ();
  12394. Doo::loadModel ( 'L_category' );
  12395. $Lcategory = new L_category ();
  12396. $dateCondition = " and Year(date) =" . $year;
  12397. if (! empty ( $month ))
  12398. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  12399. $categoryList = $Lcategory->find ( array (
  12400. 'asArray' => true
  12401. ) );
  12402. $staffList = $staff->find ( array (
  12403. 'where' => 'cid=' . $cid,
  12404. 'asArray' => true
  12405. ) );
  12406. $cateCondition = "";
  12407. $staffCondition = "";
  12408. $approvalCondition = "";
  12409. if (! empty ( $cid ))
  12410. $cateCondition = ' and cid=' . $cid;
  12411. if (! empty ( $sid )) {
  12412. $staffCondition = ' and staff=' . $sid;
  12413. $cateCondition = "";
  12414. }
  12415. $approvalCondition = " and status=" . $status;
  12416. if ($status == 2) {
  12417. // 查找角色审批人
  12418. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  12419. }
  12420. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  12421. $approvalCondition = ' and status=2 ';
  12422. }
  12423. if ($status == 1) {
  12424. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  12425. }
  12426. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  12427. $pageinfo ['page'] = array (
  12428. 'previous' => ''
  12429. );
  12430. if ($status == 0) {
  12431. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  12432. $receiptList = $receipt->find ( array (
  12433. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  12434. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  12435. 'desc' => 'rid',
  12436. 'asArray' => true
  12437. ) );
  12438. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  12439. } else
  12440. $receiptList = $receipt->find ( array (
  12441. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  12442. 'desc' => 'rid',
  12443. 'asArray' => true
  12444. ) );
  12445. $rLRes = $receipt->find ( array (
  12446. '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,
  12447. 'desc' => 'rid',
  12448. 'asArray' => true
  12449. ) );
  12450. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  12451. // print_r($pageinfo);
  12452. $Locate = 0;
  12453. foreach ( $receiptList as $key => $value ) {
  12454. $receiptList [$key] ['Locate'] = $Locate;
  12455. $Locate ++;
  12456. $receiptList [$key] ['reviseDetail'] = array ();
  12457. if (! empty ( $value ['reviseDetail'] ))
  12458. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  12459. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  12460. $categoryDetil = $Lcategory->getOne ( array (
  12461. 'where' => 'cid=' . $value ['cid'],
  12462. 'asArray' => true
  12463. ) );
  12464. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  12465. $verifyList = $verify->getOne ( array (
  12466. 'where' => 'vid=' . $value ['verify'],
  12467. 'asArray' => true
  12468. ) );
  12469. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  12470. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  12471. foreach ( $verifyList as $k => $v ) {
  12472. // init verifyStaff
  12473. $verifyList [$k] ['date'] = "";
  12474. $verifyList [$k] ['opinion'] = "";
  12475. $verifyList [$k] ['status'] = "";
  12476. if (empty ( $verifyStaff )) {
  12477. $verifyList [$k] ['date'] = "";
  12478. $verifyList [$k] ['opinion'] = "";
  12479. if ($v [0] == $this->staff [0] ['sid']) {
  12480. $verifyList [$k] ['status'] = 4;
  12481. $button = 4;
  12482. }
  12483. } else {
  12484. $flag = true;
  12485. foreach ( $verifyStaff as $m => $u ) {
  12486. if ($v [0] == $m) {
  12487. $verifyList [$k] ['date'] = $u ['date'];
  12488. $verifyList [$k] ['opinion'] = $u ['opinion'];
  12489. $verifyList [$k] ['status'] = $u ['status'];
  12490. $flag = false;
  12491. break;
  12492. }
  12493. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  12494. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  12495. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  12496. }
  12497. if ($flag) { // 检测可编辑
  12498. if ($v [0] == $this->staff [0] ['sid']) {
  12499. $verifyList [$k] ['status'] = 4;
  12500. $button = 4;
  12501. }
  12502. }
  12503. }
  12504. }
  12505. $receiptList [$key] ['verifyList'] = $verifyList;
  12506. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  12507. 'where' => 'sid=' . $value ['staff'],
  12508. 'asArray' => true
  12509. ) );
  12510. $receiptList [$key] ['button'] = $button;
  12511. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  12512. }
  12513. // print_r($receiptList);die;
  12514. // $data['verifyDetail']=$verifyDetail;
  12515. $mothHtml = "";
  12516. for($i = 1; $i <= 12; $i ++) {
  12517. if ($month == $i)
  12518. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  12519. else
  12520. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  12521. }
  12522. $data ['mothHtml'] = $mothHtml;
  12523. $data ['page'] = $pageinfo;
  12524. $data ['receiptList'] = $receiptList;
  12525. $data ['receiptApprovalCount'] = count ( $rLRes );
  12526. $data ['status'] = $status;
  12527. $data ['year'] = $year;
  12528. $data ['categoryList'] = $categoryList;
  12529. $data ['staffList'] = $staffList;
  12530. $data ['cid'] = $cid;
  12531. $data ['sid'] = $sid;
  12532. // print_r($receiptList);
  12533. $data ['memu'] = "receipt";
  12534. $data ['staff'] = $this->staff;
  12535. $data ['receiptMemu'] = 'approvalExpenses';
  12536. $data ['verifyId'] = $this->verifyId;
  12537. $data ['executeId'] = $this->executeId;
  12538. $this->render ( "/admin/FALG", $data );
  12539. }
  12540. function ajaxGetReceiptOrder() {
  12541. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  12542. if (! empty ( $receiptOrder )) {
  12543. Doo::loadModel ( 'receipt' );
  12544. $receipt = new receipt ();
  12545. Doo::loadModel ( 'staff' );
  12546. $staff = new staff ();
  12547. $receiptInfo = $receipt->getOne ( array (
  12548. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  12549. 'asArray' => true
  12550. ) );
  12551. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  12552. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  12553. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  12554. </tbody></table><table class="table table table-bordered"><tbody>';
  12555. foreach ( $verifyStaff as $key => $value ) {
  12556. $staffInfo = $staff->getOne ( array (
  12557. 'select' => 'username',
  12558. 'where' => ' sid="' . $key . '"',
  12559. 'asArray' => true
  12560. ) );
  12561. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  12562. }
  12563. $html .= '</tbody></table></div></div>';
  12564. echo json_encode ( array (
  12565. 'status' => 1,
  12566. 'receiptHtml' => $html
  12567. ) );
  12568. die ();
  12569. }
  12570. echo json_encode ( array (
  12571. 'status' => 2,
  12572. 'receiptHtml' => ''
  12573. ) );
  12574. die ();
  12575. }
  12576. function _getMonthCollectDetail($receiptCollectList) {
  12577. if (! empty ( $receiptCollectList )) {
  12578. $receiptL = array (
  12579. '日常相关费用' => array (),
  12580. '差旅相关费用' => array (),
  12581. '培训班费用' => array (),
  12582. '其他' => array ()
  12583. );
  12584. $html = "";
  12585. $psum = 0;
  12586. $item = array (
  12587. '市内交通费',
  12588. '市内出租费',
  12589. '办事处房租',
  12590. '电话费',
  12591. '水费',
  12592. '电费',
  12593. '办公费用',
  12594. '邮寄费',
  12595. '其他费用',
  12596. '车辆费用',
  12597. '广告费',
  12598. '团队建设费',
  12599. '物业管理费',
  12600. '宽带费',
  12601. '人员薪酬',
  12602. '公积金',
  12603. '社保'
  12604. );
  12605. foreach ( $item as $value ) {
  12606. $falg = true;
  12607. foreach ( $receiptCollectList as $v ) {
  12608. if ($v ['itemCategory'] == '日常相关费用') {
  12609. if ($v ['item'] == $value) {
  12610. $psum += $v ['price'];
  12611. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12612. $falg = false;
  12613. break;
  12614. }
  12615. }
  12616. }
  12617. if ($falg)
  12618. $html .= '<td class="taR">-</td>';
  12619. }
  12620. if (! empty ( $psum ))
  12621. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  12622. else
  12623. $psum = '<td class="colGreen taR">-</td>';
  12624. $receiptL ['日常相关费用'] = $psum . $html;
  12625. /* ----------------------------------- */
  12626. $html = "";
  12627. $psum = 0;
  12628. $item = array (
  12629. '往来交通费',
  12630. '市内交通费',
  12631. '出差住宿费',
  12632. '出差补助',
  12633. '其他费用'
  12634. );
  12635. foreach ( $item as $value ) {
  12636. $falg = true;
  12637. foreach ( $receiptCollectList as $v ) {
  12638. if ($v ['itemCategory'] == '差旅相关费用') {
  12639. if ($v ['item'] == $value) {
  12640. $psum += $v ['price'];
  12641. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12642. $falg = false;
  12643. break;
  12644. }
  12645. }
  12646. }
  12647. if ($falg)
  12648. $html .= '<td class="taR">-</td>';
  12649. }
  12650. if (! empty ( $psum ))
  12651. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  12652. else
  12653. $psum = '<td class="colGreen taR">-</td>';
  12654. $receiptL ['差旅相关费用'] = $psum . $html;
  12655. /* ------------------------------------- */
  12656. $html = "";
  12657. $psum = 0;
  12658. $item = array (
  12659. '场租费',
  12660. '薪酬',
  12661. '住宿费',
  12662. '交通费',
  12663. '餐饮费',
  12664. '办公费',
  12665. '公关费',
  12666. '其他',
  12667. '电话费',
  12668. '邮寄费'
  12669. );
  12670. foreach ( $item as $value ) {
  12671. $falg = true;
  12672. foreach ( $receiptCollectList as $v ) {
  12673. if ($v ['itemCategory'] == '培训班费用') {
  12674. if ($v ['item'] == $value) {
  12675. $psum += $v ['price'];
  12676. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12677. $falg = false;
  12678. break;
  12679. }
  12680. }
  12681. }
  12682. if ($falg)
  12683. $html .= '<td class="taR">-</td>';
  12684. }
  12685. if (! empty ( $psum ))
  12686. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  12687. else
  12688. $psum = '<td class="colGreen taR">-</td>';
  12689. $receiptL ['培训班费用'] = $psum . $html;
  12690. /* ------------------------------------- */
  12691. $html = "";
  12692. $psum = 0;
  12693. $item = array (
  12694. '公关费',
  12695. '广告费',
  12696. '借款',
  12697. '可自加费用'
  12698. );
  12699. foreach ( $item as $value ) {
  12700. $falg = true;
  12701. foreach ( $receiptCollectList as $v ) {
  12702. if ($v ['itemCategory'] == '其他') {
  12703. if ($v ['item'] == $value) {
  12704. $psum += $v ['price'];
  12705. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12706. $falg = false;
  12707. break;
  12708. }
  12709. }
  12710. }
  12711. if ($falg)
  12712. $html .= '<td class="taR">-</td>';
  12713. }
  12714. if (! empty ( $psum ))
  12715. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  12716. else
  12717. $psum = '<td class="colGreen taR">-</td>';
  12718. $receiptL ['其他'] = $psum . $html;
  12719. /* ------------------------------------- */
  12720. $html = "";
  12721. $psum = 0;
  12722. foreach ( $receiptCollectList as $v ) {
  12723. if ($v ['itemCategory'] == '报销金额调整') {
  12724. if (! empty ( $v ['price'] ))
  12725. $psum += $v ['price'];
  12726. }
  12727. }
  12728. if (! empty ( $psum ))
  12729. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  12730. else
  12731. $psum = '<td class="taR colOrange">-</td>';
  12732. $receiptL ['报销金额调整'] = $psum . $html;
  12733. } else {
  12734. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td>
  12735. <td class="taR">-</td>
  12736. <td class="taR">-</td>
  12737. <td class="taR">-</td>
  12738. <td class="taR">-</td>
  12739. <td class="taR">-</td>
  12740. <td class="taR">-</td>
  12741. <td class="taR">-</td>
  12742. <td class="taR">-</td>
  12743. <td class="taR">-</td>
  12744. <td class="taR">-</td>
  12745. <td class="taR">-</td>
  12746. <td class="taR">-</td>';
  12747. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  12748. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12749. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td>
  12750. <td class="taR">-</td>
  12751. <td class="taR">-</td>
  12752. <td class="taR">-</td>
  12753. <td class="taR">-</td>
  12754. <td class="taR">-</td>
  12755. <td class="taR">-</td>
  12756. <td class="taR">-</td>
  12757. <td class="taR">-</td>';
  12758. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12759. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  12760. }
  12761. return $receiptL;
  12762. }
  12763. function eMail() {
  12764. Doo::loadModel ( 'staff' );
  12765. $staff = new staff ();
  12766. Doo::loadModel ( 'receipt' );
  12767. $receipt = new receipt ();
  12768. Doo::loadModel ( 'L_category' );
  12769. $Lcategory = new L_category ();
  12770. Doo::loadModel ( "verify" );
  12771. $verify = new verify ();
  12772. $staffList = $staff->find ( array (
  12773. 'asArray' => true
  12774. ) );
  12775. foreach ( $staffList as $key => $value ) {
  12776. if ($value ['username'] != 'admin') {
  12777. // 提交人
  12778. $receiptList = $receipt->find ( array (
  12779. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  12780. 'asArray' => true
  12781. ) );
  12782. if (! empty ( $receiptList )) {
  12783. $html = '<br><div><style></style>
  12784. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  12785. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  12786. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  12787. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  12788. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  12789. <tbody><tr>
  12790. <td style="padding: 0 40px;" align="left">
  12791. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  12792. </td></tr><tr>
  12793. <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>
  12794. </tr>
  12795. </tbody> </table></td> </tr> <tr><td>
  12796. <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">
  12797. <tbody> <tr><td>
  12798. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  12799. 以下报销单完成了审批,等着收款吧:</p>
  12800. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  12801. foreach ( $receiptList as $k => $v ) {
  12802. $category = $Lcategory->getOne ( array (
  12803. 'where' => 'cid=' . $v ['cid'],
  12804. 'asArray' => true
  12805. ) );
  12806. $html .= '
  12807. <tr>
  12808. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  12809. <td align="left">
  12810. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  12811. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  12812. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  12813. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  12814. </tr>';
  12815. }
  12816. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  12817. <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>
  12818. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  12819. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  12820. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  12821. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  12822. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  12823. $receipt = new receipt ();
  12824. $receipt->notice = 1;
  12825. $receipt->update ( array (
  12826. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  12827. ) );
  12828. }
  12829. }
  12830. // 审批人
  12831. $verifyList = $verify->find ( array (
  12832. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  12833. 'asArray' => true
  12834. ) );
  12835. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  12836. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  12837. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  12838. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  12839. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  12840. <tbody><tr><td style="padding: 0 40px;" align="left">
  12841. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  12842. </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>
  12843. </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">
  12844. <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>
  12845. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  12846. foreach ( $verifyList as $k => $v ) {
  12847. $receiptList = $receipt->find ( array (
  12848. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  12849. 'asArray' => true
  12850. ) );
  12851. foreach ( $receiptList as $r => $l ) {
  12852. $category = $Lcategory->getOne ( array (
  12853. 'where' => 'cid=' . $l ['cid'],
  12854. 'asArray' => true
  12855. ) );
  12856. $staffDetile = $staff->getOne ( array (
  12857. 'where' => 'sid=' . $l ['staff'],
  12858. 'asArray' => true
  12859. ) );
  12860. $html .= '
  12861. <tr>
  12862. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  12863. <td align="left">
  12864. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  12865. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  12866. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  12867. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  12868. </tr>';
  12869. }
  12870. }
  12871. $html .= '
  12872. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  12873. <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>
  12874. </tr></tbody></table></td></tr></tbody></table></div><br>';
  12875. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  12876. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  12877. // $receipt=new receipt();
  12878. // $receipt->notice=1;
  12879. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  12880. }
  12881. }
  12882. }
  12883. }
  12884. function setWXMsg($rid, $type) {
  12885. Doo::loadModel ( "receipt" );
  12886. $receipt = new receipt ();
  12887. $receiptDetail = $receipt->getOne ( array (
  12888. 'where' => 'rid=' . $rid,
  12889. 'asArray' => true
  12890. ) );
  12891. if (! empty ( $receiptDetail )) {
  12892. Doo::loadModel ( 'staff' );
  12893. $staff = new staff ();
  12894. $staffmsg = $staff->getOne ( array (
  12895. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  12896. 'asArray' => TRUE
  12897. ) );
  12898. if (! empty ( $staffmsg ['wxid'] )) {
  12899. require_once (SITE_PATH . '/protected/class/client.php');
  12900. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  12901. $user = $staffmsg ['wxid'];
  12902. $receiptName = '';
  12903. $msg = '';
  12904. switch ($receiptDetail ['Rtype']) {
  12905. case 0 :
  12906. $receiptName = '报销';
  12907. break;
  12908. case 1 :
  12909. $receiptName = '借款';
  12910. break;
  12911. case 2 :
  12912. $receiptName = '对公汇款';
  12913. break;
  12914. }
  12915. switch ($type) {
  12916. case 1 :
  12917. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  12918. break;
  12919. case 2 :
  12920. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  12921. break;
  12922. case 3 :
  12923. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  12924. break;
  12925. }
  12926. // $result = $client->SendMsg ( $user, $msg, 'text' );
  12927. }
  12928. }
  12929. }
  12930. // Email发送函数
  12931. function SMail($toemail, $subject, $contents) {
  12932. Doo::loadClass ( 'class.phpmailer' );
  12933. $mail = new PHPMailer ();
  12934. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  12935. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  12936. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  12937. $mail->Password = "cDO1GjtY1seH"; // 密码
  12938. $mail->CharSet = "UTF8";
  12939. $mail->SMTPAuth = true;
  12940. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  12941. $mail->Mailer = "smtp";
  12942. $mail->Port = 25;
  12943. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  12944. $mail->MsgHTML ( $contents );
  12945. $mail->AddAddress ( $toemail );
  12946. $mail->CharSet = "UTF-8";
  12947. return $mail->Send ();
  12948. }
  12949. function swfupload() {
  12950. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  12951. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  12952. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  12953. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  12954. header ( "HTTP/1.1 500 Internal Server Error" );
  12955. echo "POST exceeded maximum allowed size.";
  12956. exit ( 0 );
  12957. }
  12958. // Settings
  12959. $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)
  12960. $upload_name = "Filedata";
  12961. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  12962. $extension_whitelist = array (
  12963. "doc",
  12964. "txt",
  12965. "jpg",
  12966. "gif",
  12967. "png"
  12968. ); // Allowed file extensions
  12969. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  12970. // Other variables
  12971. $MAX_FILENAME_LENGTH = 260;
  12972. $file_name = "";
  12973. $file_extension = "";
  12974. $uploadErrors = array (
  12975. 0 => "文件上传成功",
  12976. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  12977. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  12978. 3 => "上传的文件仅为部分文件",
  12979. 4 => "没有文件上传",
  12980. 6 => "缺少临时文件夹"
  12981. );
  12982. $nk = time ();
  12983. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  12984. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  12985. echo "文件无法保存.";
  12986. exit ( 0 );
  12987. }
  12988. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  12989. echo json_encode ( array (
  12990. 'filename' => $file_name,
  12991. 'id' => $nk
  12992. ) );
  12993. exit ( 0 );
  12994. }
  12995. function _GetFileEXT($filename) {
  12996. $pics = explode ( '.', $filename );
  12997. $num = count ( $pics );
  12998. return $pics [$num - 1];
  12999. }
  13000. /**
  13001. * 获取get或者POST值
  13002. * @param string $name 属性名称
  13003. * @return fixed 值
  13004. */
  13005. function get_args($name) {
  13006. if (isset ( $_GET [$name] )) {
  13007. if (is_array ( $_GET [$name] ))
  13008. return $_GET [$name];
  13009. else
  13010. return addslashes ( $_GET [$name] );
  13011. } elseif (isset ( $_POST [$name] )) {
  13012. if (is_array ( $_POST [$name] ))
  13013. return $_POST [$name];
  13014. else
  13015. return addslashes ( $_POST [$name] );
  13016. } else
  13017. return false;
  13018. }
  13019. function num_to_rmb($num) {
  13020. $c1 = "零壹贰叁肆伍陆柒捌玖";
  13021. $c2 = "分角元拾佰仟万拾佰仟亿";
  13022. // 精确到分后面就不要了,所以只留两个小数位
  13023. $num = round ( $num, 2 );
  13024. // 将数字转化为整数
  13025. $num = $num * 100;
  13026. if (strlen ( $num ) > 10) {
  13027. return "金额太大,请检查";
  13028. }
  13029. $i = 0;
  13030. $c = "";
  13031. while ( 1 ) {
  13032. if ($i == 0) {
  13033. // 获取最后一位数字
  13034. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  13035. } else {
  13036. $n = $num % 10;
  13037. }
  13038. // 每次将最后一位数字转化为中文
  13039. $p1 = substr ( $c1, 3 * $n, 3 );
  13040. $p2 = substr ( $c2, 3 * $i, 3 );
  13041. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  13042. $c = $p1 . $p2 . $c;
  13043. } else {
  13044. $c = $p1 . $c;
  13045. }
  13046. $i = $i + 1;
  13047. // 去掉数字最后一位了
  13048. $num = $num / 10;
  13049. // echo $num.'</br>';
  13050. $num = ( int ) $num;
  13051. // $num =floor($num);
  13052. // $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  13053. // echo $num.'</br>';
  13054. // 结束循环
  13055. if ($num == 0) {
  13056. break;
  13057. }
  13058. }
  13059. // echo $c.'</br>';
  13060. $j = 0;
  13061. $slen = strlen ( $c );
  13062. while ( $j < $slen ) {
  13063. // utf8一个汉字相当3个字符
  13064. $m = substr ( $c, $j, 6 );
  13065. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  13066. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  13067. $left = substr ( $c, 0, $j );
  13068. $right = substr ( $c, $j + 3 );
  13069. $c = $left . $right;
  13070. $j = $j - 3;
  13071. $slen = $slen - 3;
  13072. }
  13073. $j = $j + 3;
  13074. }
  13075. // 这个是为了去掉类似23.0中最后一个“零”字
  13076. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  13077. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  13078. }
  13079. // 将处理的汉字加上“整”
  13080. if (empty ( $c )) {
  13081. return "零元整";
  13082. } else {
  13083. return $c . "整";
  13084. }
  13085. }
  13086. /**
  13087. * 获得分页数据
  13088. * @param unknown_type $table
  13089. * @param unknown_type $condition
  13090. * @param unknown_type $on_page
  13091. * @param unknown_type $page_size
  13092. */
  13093. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  13094. $page_c = "";
  13095. $page ['previous'] = $this->get_previous ( $on_page );
  13096. $page ['on_page'] = $on_page;
  13097. $total_count = $this->get_table_count ( $table, $condition );
  13098. $total = intval ( $total_count / $page_size );
  13099. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  13100. $page ['total_data'] = $total_count;
  13101. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  13102. $i = 1;
  13103. $page_max = 1;
  13104. $page_width = 3;
  13105. if ($on_page >= $page_width) {
  13106. $page_max = intval ( $on_page / $page_width ) + 1;
  13107. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  13108. }
  13109. for(; $i <= $page ['total_page']; $i ++) {
  13110. if ($i == $on_page)
  13111. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  13112. else
  13113. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  13114. if ($i == ($page_width * $page_max))
  13115. break;
  13116. }
  13117. $page ['page'] = $page_c;
  13118. $page ['lower'] = (-- $on_page) * $page_size;
  13119. return $page;
  13120. }
  13121. /**
  13122. * 获取总页数
  13123. * @param unknown_type $table
  13124. * @param unknown_type $condition
  13125. */
  13126. public function get_table_count($table = "", $condition = "") {
  13127. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  13128. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  13129. // echo $sql;die;
  13130. $query = Doo::db ()->query ( $sql );
  13131. $result = $query->fetch ();
  13132. return $result ['count'];
  13133. }
  13134. /**
  13135. * 获取上一页
  13136. * @param unknown_type $on_page
  13137. */
  13138. function get_previous($on_page = 1) {
  13139. return $on_page != 0 ? $on_page - 1 : $on_page;
  13140. }
  13141. }
  13142. ?>