ReceiptController.php 368 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class ReceiptController extends DooController {
  6. public $staff;
  7. public $verifyId;
  8. public $executeId;
  9. // public static $NEW2 = 0;
  10. public $AGENCY = "日常相关费用";
  11. public $TRAVEL = "差旅相关费用";
  12. public $TRAIN = "培训班费用";
  13. public $OTHER = "其他";
  14. private $MYREVEIPTCACHEPATH = "protected/cache/myReceipt/";
  15. private $PERSONALCOLLECTCACHEPATH = "protected/cache/personalCollect/";
  16. private $CATEGORYCOLLECTPATH = "protected/cache/categoryCollect/";
  17. private $STAFFCOLLECTPATH = "protected/cache/staffCollect/";
  18. private function showCache($path) {
  19. if (file_exists ( $path )) {
  20. echo "<!DOCTYPE html>";
  21. include $path;
  22. die ();
  23. }
  24. }
  25. private function cacheFile($path) {
  26. $content = ob_get_contents ();
  27. $fp = fopen ( $path, "w" );
  28. fwrite ( $fp, $content );
  29. fclose ( $fp );
  30. }
  31. // private function getExeCount(){
  32. // Doo::loadModel('receipt');
  33. // $receipt=new receipt();
  34. // $receiptList=$receipt->find(array('where'=>'(executeCopy like \'%["'.$this->staff[0]['sid'].'%\' and executeStaff NOT LIKE \'%'.$this->staff[0]['sid'].'%\' ) and (status=1 or status=6)','desc'=>'rid','asArray'=>true));
  35. // return count($receiptList);
  36. // }
  37. // private function getReceiptCount(){
  38. // $status=2;
  39. // $year=date('Y');
  40. // Doo::loadModel('receipt');
  41. // $receipt=new receipt();
  42. // $dateCondition=" and Year(date) =".$year;
  43. // $approvalCondition=' and (nowStaff like "%,'.$this->staff[0]['sid'].'%" or nowStaff like "%'.$this->staff[0]['sid'].',%" or nowStaff='.$this->staff[0]['sid'].' ) ';
  44. // $receiptList=$receipt->find(array('where'=>' status='.$status.$dateCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  45. // return count($receiptList);
  46. // }
  47. private function collectHtml($receiptCollectList = array(), $itemCategory = "日常相关费用", $classType = "b") {
  48. $collectHtml = "";
  49. $sumPrice = 0.00;
  50. for($i = 1; $i <= 12; $i ++) {
  51. $falg = true;
  52. foreach ( $receiptCollectList as $key => $value ) {
  53. if ($value ['itemCategory'] == $itemCategory && $value ['month'] == $i) {
  54. $sumPrice += $value ['price'];
  55. if ($classType == "b") {
  56. $collectHtml .= '<td class="colGreen taR">¥' . $value ['price'] . '</td>';
  57. $falg = false;
  58. break;
  59. } else {
  60. $collectHtml .= '<td class="taR">¥' . $value ['price'] . '</td>';
  61. $falg = false;
  62. break;
  63. }
  64. }
  65. }
  66. if ($falg)
  67. $collectHtml .= '<td class="taR">-</td>';
  68. }
  69. $collectHtml .= '<td class="taR colGreen">¥' . $sumPrice . '</td>';
  70. return $collectHtml;
  71. }
  72. function __construct() {
  73. if (isset ( $_COOKIE ["staff"] )) {
  74. if (! empty ( $_COOKIE ["staff"] )) {
  75. Doo::loadModel ( 'staff' );
  76. Doo::loadModel ( 'verify' );
  77. $verify = new verify ();
  78. $staff = new staff ();
  79. Doo::loadModel ( "execute" );
  80. $execute = new execute ();
  81. $verifyList = $verify->find ( array (
  82. 'select' => 'staff',
  83. 'asArray' => true
  84. ) );
  85. $list = array ();
  86. // 判断角色的审批权限
  87. foreach ( $verifyList as $key => $value ) {
  88. $ver = json_decode ( $value ['staff'] );
  89. foreach ( $ver as $k => $v ) {
  90. if ($v [1] == 'ROLE') {
  91. $roleList = json_decode ( $v [3] );
  92. foreach ( $roleList as $t => $g ) {
  93. $gList = explode ( "_", $g );
  94. array_push ( $list, $gList [0] );
  95. // print_r($list);
  96. }
  97. } else
  98. array_push ( $list, $v [0] );
  99. }
  100. }
  101. // 判断执行人的审批权限
  102. $executeList = $execute->find ( array (
  103. 'select' => 'staff',
  104. 'asArray' => true
  105. ) );
  106. $list2 = array ();
  107. foreach ( $executeList as $key => $value ) {
  108. $ver = json_decode ( $value ['staff'] );
  109. foreach ( $ver as $k => $v ) {
  110. array_push ( $list2, $v [0] );
  111. }
  112. }
  113. $eidList = file_get_contents ( "protected/config/execute/execute.ini" );
  114. $eidList = array_filter ( explode ( ",", $eidList ) );
  115. $this->executeId = array_merge ( $list2, $eidList );
  116. $this->verifyId = $list;
  117. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  118. return "/";
  119. }
  120. }
  121. Doo::loadCore ( 'uri/DooUriRouter' );
  122. $router = new DooUriRouter ();
  123. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  124. if ($routeRs ['1'] != "login") {
  125. header ( 'Content-Type:text/html;charset=utf-8' );
  126. @header ( "Location: /login" );
  127. }
  128. }
  129. function saeaBorad() {
  130. Doo::loadModel ( 'receipt' );
  131. Doo::loadModel ( 'verify' );
  132. $verify = new verify ();
  133. $receipt = new receipt ();
  134. Doo::loadModel ( 'L_category' );
  135. $lCategory = new L_category ();
  136. Doo::loadModel ( "role" );
  137. $role = new role ();
  138. Doo::loadModel ( "receiptLog" );
  139. $receiptLog = new receiptLog ();
  140. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  141. $receiptDetail = $receipt->find ( array (
  142. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  143. 'desc' => 'rid',
  144. 'asArray' => true
  145. ) );
  146. foreach ( $receiptDetail as $key => $value ) {
  147. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  148. $veList = $verify->getOne ( array (
  149. 'where' => 'vid=' . $value ['verify'],
  150. 'asArray' => true
  151. ) );
  152. $v = json_decode ( $veList ['staff'] );
  153. array_push ( $v [0], $veList ['description'] );
  154. foreach ( $v as $n => $m ) {
  155. if ($m ['1'] == 'ROLE') {
  156. $roleInfo = $role->getOne ( array (
  157. 'where' => 'rid=' . $m [0],
  158. 'asArray' => true
  159. ) );
  160. $v [$n] [1] = $roleInfo ['name'];
  161. }
  162. }
  163. $receiptDetail [$key] ['staff'] = $v;
  164. $category = $lCategory->getOne ( array (
  165. 'where' => 'cid=' . $value ['cid'],
  166. 'asArray' => true
  167. ) );
  168. $receiptDetail [$key] ['category'] = $category ['title'];
  169. }
  170. // print_r($receiptLogList);
  171. $data ['receiptLogList'] = $receiptLogList;
  172. $data ['receiptDetail'] = $receiptDetail;
  173. $data ['memu'] = "receipt";
  174. $data ['staff'] = $this->staff;
  175. $data ['receiptMemu'] = 'saeaBorad';
  176. $data ['verifyId'] = $this->verifyId;
  177. $data ['executeId'] = $this->executeId;
  178. $this->render ( "/admin/saeaBorad", $data );
  179. }
  180. function remitAdd() {
  181. Doo::loadModel ( 'accountItem' );
  182. Doo::loadModel ( 'verify' );
  183. Doo::loadModel ( 'receipt' );
  184. Doo::loadModel ( 'L_category' );
  185. $lCategory = new L_category ();
  186. $receipt = new receipt ();
  187. $verify = new verify ();
  188. $accountItem = new accountItem ();
  189. Doo::loadModel ( "role" );
  190. $role = new role ();
  191. $acItem = $accountItem->find ( array (
  192. 'asArray' => true
  193. ) );
  194. $veList = $verify->find ( array (
  195. 'asArray' => true
  196. ) );
  197. foreach ( $veList as $key => $value ) {
  198. $v = json_decode ( $value ['staff'] );
  199. $list = array ();
  200. foreach ( $v as $n => $m ) {
  201. if ($m ['1'] == 'ROLE') {
  202. $roleInfo = $role->getOne ( array (
  203. 'where' => 'rid=' . $m [0],
  204. 'asArray' => true
  205. ) );
  206. $v [$n] [1] = $roleInfo ['name'];
  207. array_push ( $list, $roleInfo ['name'] );
  208. } else {
  209. array_push ( $list, $v [$n] [1] );
  210. }
  211. }
  212. $veList [$key] ['staff'] = implode ( '>', $list );
  213. }
  214. $data ['category'] = $lCategory->find ( array (
  215. 'asArray' => true
  216. ) );
  217. $data ['veList'] = $veList;
  218. $data ['acItem'] = $acItem;
  219. $data ['memu'] = "receipt";
  220. $data ['staff'] = $this->staff;
  221. $data ['receiptMemu'] = 'saeaBorad';
  222. $data ['verifyId'] = $this->verifyId;
  223. $data ['executeId'] = $this->executeId;
  224. $this->render ( "/admin/remitAdd", $data );
  225. }
  226. function remitAddDo() {
  227. $agency = $this->get_args ( 'agency' );
  228. $travel = $this->get_args ( 'travel' );
  229. $train = $this->get_args ( 'train' );
  230. $other = $this->get_args ( 'other' );
  231. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  232. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  233. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  234. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  235. // print_r($agency);die;
  236. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  237. Doo::loadModel ( 'receipt' );
  238. Doo::loadModel ( 'receiptDetail' );
  239. Doo::loadModel ( 'accountItem' );
  240. $accountItem = new accountItem ();
  241. $receipt = new receipt ();
  242. Doo::loadModel ( 'enclosur' );
  243. Doo::loadModel ( 'execute' );
  244. $execute = new execute ();
  245. $executeDetail = $execute->getOne ( array (
  246. 'where' => 'mold="对公汇款执行人"',
  247. 'asArray' => true
  248. ) );
  249. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  250. $aItem = $accountItem->find ( array (
  251. 'where' => 'name like "办公费用" or name like "其他费用"',
  252. 'asArray' => true
  253. ) );
  254. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  255. $ag = $tr = $ta = $ot = 0;
  256. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  257. foreach ( $aItem as $key => $value ) {
  258. if ($value ['category'] == $this->AGENCY) {
  259. if (isset ( $agency [$ag] )) {
  260. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  261. array_push ( $accountJson [$this->AGENCY], array (
  262. 'aid' => $value ['aid'],
  263. 'name' => $value ['name'],
  264. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  265. ) );
  266. $sum += $agency [$ag];
  267. $agencySum += $agency [$ag];
  268. }
  269. }
  270. $ag ++;
  271. }
  272. }
  273. $accountJson ['cSum'] = array (
  274. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  275. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  276. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  277. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  278. );
  279. // 报销单
  280. $receipt->accountItem = json_encode ( $accountJson );
  281. $receipt->staff = $this->staff [0] ['sid'];
  282. $receipt->sum = number_format ( $sum, 2, '.', '' );
  283. $receipt->date = date ( "Y-m-d" );
  284. $receipt->cid = $cid;
  285. $receipt->status = 5;
  286. $receipt->Rtype = 2;
  287. // 修改审批流程加入角色
  288. $receipt->verify = $verify;
  289. $receipt->executeCopy = $executeDetail ['staff'];
  290. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  291. $receipt->explanation = $explanation;
  292. $rid = $receipt->insert ();
  293. // 附件
  294. if (! empty ( $enclosurName )) {
  295. $enclosurArray = explode ( '-', $enclosurName );
  296. foreach ( $enclosurArray as $value ) {
  297. $enclosur = new enclosur ();
  298. $enclosur->name = $value;
  299. $enclosur->rid = $rid;
  300. $enclosur->insert ();
  301. }
  302. // print_r($enclosurArray);die;
  303. }
  304. // 报销详情
  305. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  306. $receiptDetail = new receiptDetail ();
  307. $receiptDetail->staff = $this->staff [0] ['sid'];
  308. $receiptDetail->item = $value ['name'];
  309. $receiptDetail->itemCategory = $this->AGENCY;
  310. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  311. $receiptDetail->date = date ( "Y-m-d" );
  312. $receiptDetail->cid = $cid;
  313. $receiptDetail->rid = $rid;
  314. $receiptDetail->status = 4;
  315. $receiptDetail->insert ();
  316. }
  317. }
  318. return "/saeaBorad";
  319. }
  320. function remitEdit() {
  321. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  322. // echo $rid;
  323. Doo::loadModel ( 'accountItem' );
  324. Doo::loadModel ( 'verify' );
  325. Doo::loadModel ( 'receipt' );
  326. $receipt = new receipt ();
  327. $verify = new verify ();
  328. $accountItem = new accountItem ();
  329. Doo::loadModel ( 'L_category' );
  330. $lCategory = new L_category ();
  331. Doo::loadModel ( "role" );
  332. $role = new role ();
  333. $receiptDetail = $receipt->getOne ( array (
  334. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  335. 'asArray' => true
  336. ) );
  337. if (empty ( $receiptDetail ))
  338. return "/saeaCreate";
  339. $acItem = $accountItem->find ( array (
  340. 'asArray' => true
  341. ) );
  342. $veList = $verify->find ( array (
  343. 'asArray' => true
  344. ) );
  345. foreach ( $veList as $key => $value ) {
  346. $v = json_decode ( $value ['staff'] );
  347. $list = array ();
  348. foreach ( $v as $n => $m ) {
  349. if ($m ['1'] == 'ROLE') {
  350. $roleInfo = $role->getOne ( array (
  351. 'where' => 'rid=' . $m [0],
  352. 'asArray' => true
  353. ) );
  354. $v [$n] [1] = $roleInfo ['name'];
  355. array_push ( $list, $roleInfo ['name'] );
  356. } else {
  357. array_push ( $list, $v [$n] [1] );
  358. }
  359. }
  360. $veList [$key] ['staff'] = implode ( '>', $list );
  361. }
  362. // 配置编辑信息
  363. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  364. foreach ( $acItem as $key => $value ) {
  365. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  366. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  367. $acItem [$key] ['price'] = $v ['price'];
  368. }
  369. }
  370. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  371. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  372. $acItem [$key] ['price'] = $v ['price'];
  373. }
  374. }
  375. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  376. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  377. $acItem [$key] ['price'] = $v ['price'];
  378. }
  379. }
  380. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  381. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  382. $acItem [$key] ['price'] = $v ['price'];
  383. }
  384. }
  385. }
  386. $data ['category'] = $lCategory->find ( array (
  387. 'asArray' => true
  388. ) );
  389. $data ['cSum'] = $accountItemList ['cSum'];
  390. $data ['sum'] = $receiptDetail ['sum'];
  391. $data ['receiptDetail'] = $receiptDetail;
  392. $data ['veList'] = $veList;
  393. $data ['acItem'] = $acItem;
  394. $data ['memu'] = "receipt";
  395. $data ['staff'] = $this->staff;
  396. $data ['receiptMemu'] = 'saeaBorad';
  397. $data ['verify'] = $receiptDetail ['verify'];
  398. $data ['verifyId'] = $this->verifyId;
  399. $data ['executeId'] = $this->executeId;
  400. $data ['rid'] = $rid;
  401. $this->render ( "/admin/remitEdit", $data );
  402. }
  403. function remitEdiDo() {
  404. $agency = $this->get_args ( 'agency' );
  405. $travel = $this->get_args ( 'travel' );
  406. $train = $this->get_args ( 'train' );
  407. $other = $this->get_args ( 'other' );
  408. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  409. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  410. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  411. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  412. if (! empty ( $explanation )) {
  413. Doo::loadModel ( 'receipt' );
  414. Doo::loadModel ( 'receiptDetail' );
  415. Doo::loadModel ( 'accountItem' );
  416. $accountItem = new accountItem ();
  417. $receipt = new receipt ();
  418. Doo::loadModel ( 'execute' );
  419. $execute = new execute ();
  420. $executeDetail = $execute->getOne ( array (
  421. 'where' => 'mold="对公汇款执行人"',
  422. 'asArray' => true
  423. ) );
  424. $receiptDetail = $receipt->getOne ( array (
  425. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  426. 'asArray' => true
  427. ) );
  428. if (empty ( $receiptDetail ))
  429. return "/saeaBorad";
  430. $aItem = $accountItem->find ( array (
  431. 'where' => 'name like "办公费用" or name like "其他费用"',
  432. 'asArray' => true
  433. ) );
  434. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  435. $ag = $tr = $ta = $ot = 0;
  436. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  437. foreach ( $aItem as $key => $value ) {
  438. if ($value ['category'] == $this->AGENCY) {
  439. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  440. array_push ( $accountJson [$this->AGENCY], array (
  441. 'aid' => $value ['aid'],
  442. 'name' => $value ['name'],
  443. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  444. ) );
  445. $sum += $agency [$ag];
  446. $agencySum += $agency [$ag];
  447. }
  448. $ag ++;
  449. }
  450. }
  451. $accountJson ['cSum'] = array (
  452. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  453. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  454. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  455. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  456. );
  457. // 报销单
  458. $rid = $receipt->rid = $receiptDetail ['rid'];
  459. $receipt->accountItem = json_encode ( $accountJson );
  460. $receipt->staff = $this->staff [0] ['sid'];
  461. $receipt->sum = number_format ( $sum, 2, '.', '' );
  462. $receipt->date = date ( "Y-m-d" );
  463. $receipt->cid = $cid;
  464. if ($receiptDetail ['Rtype'] == 1)
  465. $receipt->status = 7;
  466. else
  467. $receipt->status = 5;
  468. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  469. $receipt->verify = $verify;
  470. $receipt->executeCopy = $executeDetail ['staff'];
  471. $receipt->explanation = $explanation;
  472. $receipt->update ();
  473. $receiptDetail = new receiptDetail ();
  474. $receiptDetail->delete ( array (
  475. 'where' => 'rid=' . $rid
  476. ) );
  477. // 报销详情
  478. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  479. $receiptDetail = new receiptDetail ();
  480. $receiptDetail->staff = $this->staff [0] ['sid'];
  481. $receiptDetail->item = $value ['name'];
  482. $receiptDetail->itemCategory = $this->AGENCY;
  483. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  484. $receiptDetail->date = date ( "Y-m-d" );
  485. $receiptDetail->cid = $cid;
  486. $receiptDetail->rid = $rid;
  487. $receiptDetail->status = 4;
  488. $receiptDetail->insert ();
  489. }
  490. // return "/referReceipt/".$rid;
  491. }
  492. return "/saeaBorad";
  493. }
  494. function remitApproval() {
  495. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  496. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  497. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  498. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  499. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  500. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  501. if (empty ( $status ))
  502. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  503. $vidList = array ();
  504. $button = 0;
  505. Doo::loadModel ( 'verify' );
  506. Doo::loadModel ( 'receipt' );
  507. Doo::loadModel ( 'staff' );
  508. $staff = new staff ();
  509. $receipt = new receipt ();
  510. $verify = new verify ();
  511. Doo::loadModel ( 'L_category' );
  512. $Lcategory = new L_category ();
  513. Doo::loadModel ( 'enclosur' );
  514. $enclosur = new enclosur ();
  515. // user verify ID
  516. $verifyDetail = $verify->find ( array (
  517. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  518. 'asArray' => true
  519. ) );
  520. foreach ( $verifyDetail as $key => $value ) {
  521. array_push ( $vidList, $value ['vid'] );
  522. }
  523. $vid = implode ( ",", $vidList );
  524. if (empty ( $verifyDetail ))
  525. $vid = 0;
  526. $categoryList = $Lcategory->find ( array (
  527. 'asArray' => true
  528. ) );
  529. $staffList = $staff->find ( array (
  530. 'where' => 'cid=' . $cid,
  531. 'asArray' => true
  532. ) );
  533. $ap = "";
  534. if ($status == 4) {
  535. $ap = 4;
  536. $status = 2;
  537. }
  538. // get Receipt By verifyID status 2
  539. $receiptList = $receipt->find ( array (
  540. 'where' => 'rid =' . $rid,
  541. 'desc' => 'rid',
  542. 'asArray' => true
  543. ) );
  544. $Locate = 0;
  545. $roleId = 0;
  546. if ($ap == 4)
  547. $status = 4;
  548. foreach ( $receiptList as $key => $value ) {
  549. $receiptList [$key] ['Locate'] = $Locate;
  550. $Locate ++;
  551. $receiptList [$key] ['reviseDetail'] = array ();
  552. if (! empty ( $value ['reviseDetail'] ))
  553. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  554. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  555. $categoryDetil = $Lcategory->getOne ( array (
  556. 'where' => 'cid=' . $value ['cid'],
  557. 'asArray' => true
  558. ) );
  559. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  560. // 检测编辑状态
  561. $verifyList = $verify->getOne ( array (
  562. 'where' => 'vid=' . $value ['verify'],
  563. 'asArray' => true
  564. ) );
  565. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  566. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  567. Doo::loadModel ( 'role' );
  568. $role = new role ();
  569. // print_r($verifyList);
  570. $flag = true;
  571. $roleKey = 0;
  572. $endStaffArray = array ();
  573. $roleArrayCopy = array ();
  574. foreach ( $verifyList as $k => $v ) {
  575. // init verifyStaff
  576. if ($v [1] == 'ROLE') {
  577. if (! empty ( $verifyStaff )) {
  578. $endStaffArray = end ( $verifyStaff );
  579. if ($v [0] == $endStaffArray ['nextStaff']) {
  580. $roleId = $v [0];
  581. }
  582. }
  583. $roleVerify = json_decode ( $v [3], true );
  584. $roleKey = $k;
  585. $roleArray = array ();
  586. $rolename = $role->getOne ( array (
  587. 'where' => 'rid=' . $v [0],
  588. 'asArray' => true
  589. ) );
  590. foreach ( $roleVerify as $o => $p ) {
  591. $staffID = explode ( '_', $p );
  592. $staffInfo = $staff->getOne ( array (
  593. 'where' => 'sid=' . $staffID [0],
  594. 'asArray' => true
  595. ) );
  596. // print_r($staffID);
  597. $exp = array (
  598. 0 => $staffInfo ['sid'],
  599. 1 => $staffID [1],
  600. 2 => $staffInfo ['avatar'],
  601. 'date' => '',
  602. 'date' => '',
  603. 'opinion' => '',
  604. 'status' => '',
  605. 'rolename' => $rolename ['name']
  606. );
  607. array_push ( $roleArray, $exp );
  608. }
  609. $roleArrayCopy [$v [0]] = $roleArray;
  610. // $verifyList[$k]['roleArray']=$roleArray;
  611. }
  612. // print_r($roleArray);
  613. $verifyList [$k] ['date'] = "";
  614. $verifyList [$k] ['opinion'] = "";
  615. $verifyList [$k] ['status'] = "";
  616. if (empty ( $verifyStaff )) {
  617. $verifyList [$k] ['date'] = "";
  618. $verifyList [$k] ['opinion'] = "";
  619. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  620. $verifyList [$k] ['status'] = 4;
  621. $button = 4;
  622. $flag = false;
  623. }
  624. } else {
  625. foreach ( $verifyStaff as $m => $u ) {
  626. if ($v [0] == $m) {
  627. $verifyList [$k] ['date'] = $u ['date'];
  628. $verifyList [$k] ['opinion'] = $u ['opinion'];
  629. $verifyList [$k] ['status'] = $u ['status'];
  630. $flag = false;
  631. break;
  632. }
  633. }
  634. $endStaffArray = end ( $verifyStaff );
  635. if (isset ( $endStaffArray ['ROLE'] )) {
  636. } else {
  637. $endKey = key ( $verifyStaff );
  638. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  639. $button = 4;
  640. $verifyList [$k] ['status'] = 4;
  641. }
  642. }
  643. }
  644. }
  645. $rolename ['name'] = '';
  646. if (! empty ( $roleId )) {
  647. Doo::loadModel ( 'role' );
  648. $role = new role ();
  649. $rolename = $role->getOne ( array (
  650. 'where' => 'rid=' . $roleId,
  651. 'asArray' => true
  652. ) );
  653. }
  654. if (! empty ( $verifyStaff ))
  655. $endStaffArray = end ( $verifyStaff );
  656. $KOP = false;
  657. foreach ( $roleArrayCopy as $P => $A ) {
  658. foreach ( $A as $MKI => $AVL ) {
  659. if (! empty ( $verifyStaff )) {
  660. // &&$rolename['rid']==$endStaffArray['nextStaff']
  661. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  662. $button = 4;
  663. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  664. }
  665. foreach ( $verifyStaff as $m => $u ) {
  666. $AVLFK = $AVL [0] . '_R';
  667. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  668. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  669. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  670. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  671. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  672. break;
  673. }
  674. }
  675. } else {
  676. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  677. $button = 4;
  678. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  679. }
  680. }
  681. // $roleArray[$MKI]['rolename']=$rolename['name'];
  682. $KOP = true;
  683. }
  684. }
  685. foreach ( $roleArrayCopy as $k => $v ) {
  686. foreach ( $verifyList as $m => $n ) {
  687. if ($n [0] == $k) {
  688. array_splice ( $verifyList, $m, 1, $v );
  689. }
  690. }
  691. }
  692. $receiptList [$key] ['verifyList'] = $verifyList;
  693. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  694. 'where' => 'sid=' . $value ['staff'],
  695. 'asArray' => true
  696. ) );
  697. $receiptList [$key] ['button'] = $button;
  698. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  699. }
  700. $mothHtml = "";
  701. for($i = 1; $i <= 12; $i ++) {
  702. if ($month == $i)
  703. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  704. else
  705. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  706. }
  707. // 获取审批日志
  708. Doo::loadModel ( 'receiptLog' );
  709. $receiptLog = new receiptLog ();
  710. $rlList = array ();
  711. $rlInfo = $receiptLog->getOne ( array (
  712. 'where' => 'rid=' . $rid . ' and status=4',
  713. 'asArray' => true
  714. ) );
  715. $tijdate = $receiptLog->getOne ( array (
  716. 'where' => 'rid=' . $rid . ' and status=2',
  717. 'asc' => 'rlid',
  718. 'asArray' => true
  719. ) );
  720. if (! empty ( $rlInfo )) {
  721. $rlList = $receiptLog->find ( array (
  722. 'where' => 'rid=' . $rid,
  723. 'asc' => 'rlid',
  724. 'asArray' => true
  725. ) );
  726. }
  727. $receiptList [0] ['rlList'] = $rlList;
  728. $enclosurList = $enclosur->find ( array (
  729. 'where' => 'rid=' . $rid,
  730. 'asArray' => true
  731. ) );
  732. $enclosurHtml = '';
  733. foreach ( $enclosurList as $value ) {
  734. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  735. }
  736. // print_r($receiptList);
  737. $data ['enclosurHtml'] = $enclosurHtml;
  738. $data ['rolename'] = $rolename ['name'];
  739. $data ['datetij'] = $tijdate ['date'];
  740. $data ['mothHtml'] = $mothHtml;
  741. $data ['rid'] = $rid;
  742. $data ['receiptList'] = $receiptList;
  743. $data ['receiptApprovalCount'] = count ( $receiptList );
  744. $data ['status'] = $status;
  745. $data ['year'] = $year;
  746. $data ['categoryList'] = $categoryList;
  747. $data ['staffList'] = $staffList;
  748. $data ['cid'] = $cid;
  749. $data ['sid'] = $sid;
  750. $data ['ap'] = $ap;
  751. $data ['memu'] = "receipt";
  752. $data ['staff'] = $this->staff;
  753. $data ['receiptMemu'] = 'approvalExpenses';
  754. $data ['verifyId'] = $this->verifyId;
  755. $data ['executeId'] = $this->executeId;
  756. $this->render ( "/admin/remitApproval", $data );
  757. }
  758. function saeaLoanAdd() {
  759. Doo::loadModel ( 'verify' );
  760. $verify = new verify ();
  761. Doo::loadModel ( "role" );
  762. $role = new role ();
  763. Doo::loadModel ( 'L_category' );
  764. $lCategory = new L_category ();
  765. $veList = $verify->find ( array (
  766. 'asArray' => true
  767. ) );
  768. foreach ( $veList as $key => $value ) {
  769. $v = json_decode ( $value ['staff'] );
  770. $list = array ();
  771. foreach ( $v as $n => $m ) {
  772. if ($m ['1'] == 'ROLE') {
  773. $roleInfo = $role->getOne ( array (
  774. 'where' => 'rid=' . $m [0],
  775. 'asArray' => true
  776. ) );
  777. $v [$n] [1] = $roleInfo ['name'];
  778. array_push ( $list, $roleInfo ['name'] );
  779. } else {
  780. array_push ( $list, $v [$n] [1] );
  781. }
  782. }
  783. $veList [$key] ['staff'] = implode ( '>', $list );
  784. }
  785. $data ['category'] = $lCategory->find ( array (
  786. 'asArray' => true
  787. ) );
  788. $data ['veList'] = $veList;
  789. $data ['memu'] = "receipt";
  790. $data ['staff'] = $this->staff;
  791. $data ['receiptMemu'] = 'saeaBorad';
  792. $data ['verifyId'] = $this->verifyId;
  793. $data ['executeId'] = $this->executeId;
  794. $this->render ( "/admin/saeaLoanAdd", $data );
  795. }
  796. function saeaLoanAddDo() {
  797. $agency = $this->get_args ( 'agency' );
  798. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  799. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  800. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  801. // die;
  802. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  803. Doo::loadModel ( 'receipt' );
  804. Doo::loadModel ( 'receiptDetail' );
  805. Doo::loadModel ( 'accountItem' );
  806. $accountItem = new accountItem ();
  807. $receipt = new receipt ();
  808. Doo::loadModel ( 'loanReceipt' );
  809. $loanReceipt = new loanReceipt ();
  810. Doo::loadModel ( 'execute' );
  811. $execute = new execute ();
  812. Doo::loadModel ( 'enclosur' );
  813. $executeDetail = $execute->getOne ( array (
  814. 'where' => 'mold="借款执行人"',
  815. 'asArray' => true
  816. ) );
  817. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  818. // if(!empty($receiptDetail))
  819. // return "/referReceipt/".$receiptDetail['rid'];
  820. $aItem = $accountItem->find ( array (
  821. 'asArray' => true
  822. ) );
  823. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  824. $ag = $tr = $ta = $ot = 0;
  825. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  826. array_push ( $accountJson ['借款费用'], array (
  827. 'aid' => 0,
  828. 'name' => '申请金额',
  829. 'price' => number_format ( $agency, 2, '.', '' )
  830. ) );
  831. $sum += $agency;
  832. $agencySum += $agency;
  833. $accountJson ['cSum'] = array (
  834. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  835. 'agencySum' => number_format ( 0, 2, '.', '' ),
  836. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  837. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  838. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  839. );
  840. // 借款数据备份
  841. $loanReceipt->loanItem = json_encode ( $accountJson );
  842. $loanReceipt->staff = $this->staff [0] ['sid'];
  843. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  844. $loanReceipt->date = date ( "Y-m-d" );
  845. $loanReceipt->cid = $cid;
  846. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  847. $loanReceipt->status = 5;
  848. $loanReceipt->Rtype = 1;
  849. $loanReceipt->verify = $verify;
  850. $receipt->receiptOrder = $receipt->receiptOrder;
  851. $loanReceipt->explanation = $explanation;
  852. $loanRid = $loanReceipt->insert ();
  853. // 报销单
  854. $receipt->loanItem = json_encode ( $accountJson );
  855. $receipt->staff = $this->staff [0] ['sid'];
  856. $receipt->sum = number_format ( $sum, 2, '.', '' );
  857. $receipt->date = date ( "Y-m-d" );
  858. $receipt->cid = $cid;
  859. // 特殊状态
  860. $receipt->status = 5;
  861. $receipt->Rtype = 1;
  862. $receipt->loanRid = $loanRid;
  863. // 修改审批流程加入角色
  864. $receipt->verify = $verify;
  865. $receipt->executeCopy = $executeDetail ['staff'];
  866. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  867. $receipt->explanation = $explanation;
  868. $rid = $receipt->insert ();
  869. // 执行数据备份
  870. // $executeCopy->rid=$rid;
  871. // $executeCopy->staff=$executeDetail['staff'];
  872. // $executeCopy->eid=$executeDetail['eid'];
  873. // $ecid=$executeCopy->insert();
  874. }
  875. return "/saeaBorad";
  876. }
  877. function saeaLoanEdi() {
  878. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  879. Doo::loadModel ( 'verify' );
  880. $verify = new verify ();
  881. Doo::loadModel ( "role" );
  882. $role = new role ();
  883. Doo::loadModel ( 'L_category' );
  884. $lCategory = new L_category ();
  885. Doo::loadModel ( 'receipt' );
  886. $receipt = new receipt ();
  887. $receiptInfo = $receipt->getOne ( array (
  888. 'where' => 'rid=' . $rid,
  889. 'asArray' => true
  890. ) );
  891. $veList = $verify->find ( array (
  892. 'asArray' => true
  893. ) );
  894. foreach ( $veList as $key => $value ) {
  895. $v = json_decode ( $value ['staff'] );
  896. $list = array ();
  897. foreach ( $v as $n => $m ) {
  898. if ($m ['1'] == 'ROLE') {
  899. $roleInfo = $role->getOne ( array (
  900. 'where' => 'rid=' . $m [0],
  901. 'asArray' => true
  902. ) );
  903. $v [$n] [1] = $roleInfo ['name'];
  904. array_push ( $list, $roleInfo ['name'] );
  905. } else {
  906. array_push ( $list, $v [$n] [1] );
  907. }
  908. }
  909. $veList [$key] ['staff'] = implode ( '>', $list );
  910. }
  911. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  912. $data ['receiptInfo'] = $receiptInfo;
  913. $data ['category'] = $lCategory->find ( array (
  914. 'asArray' => true
  915. ) );
  916. $data ['veList'] = $veList;
  917. $data ['memu'] = "receipt";
  918. $data ['staff'] = $this->staff;
  919. $data ['receiptMemu'] = 'saeaBorad';
  920. $data ['verifyId'] = $this->verifyId;
  921. $data ['executeId'] = $this->executeId;
  922. $this->render ( "/admin/saeaLoanEdi", $data );
  923. }
  924. function saeaLoanEdiDo() {
  925. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  926. $agency = $this->get_args ( 'agency' );
  927. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  928. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  929. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  930. // die;
  931. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )) {
  932. Doo::loadModel ( 'receipt' );
  933. Doo::loadModel ( 'receiptDetail' );
  934. Doo::loadModel ( 'accountItem' );
  935. $accountItem = new accountItem ();
  936. $receipt = new receipt ();
  937. Doo::loadModel ( 'loanReceipt' );
  938. $loanReceipt = new loanReceipt ();
  939. Doo::loadModel ( 'enclosur' );
  940. Doo::loadModel ( 'execute' );
  941. $execute = new execute ();
  942. $executeDetail = $execute->getOne ( array (
  943. 'where' => 'mold="借款执行人"',
  944. 'asArray' => true
  945. ) );
  946. $receiptDetail = $receipt->getOne ( array (
  947. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  948. 'asArray' => true
  949. ) );
  950. if (empty ( $receiptDetail ))
  951. die ( '参数错误' );
  952. $aItem = $accountItem->find ( array (
  953. 'asArray' => true
  954. ) );
  955. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  956. $ag = $tr = $ta = $ot = 0;
  957. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  958. array_push ( $accountJson ['借款费用'], array (
  959. 'aid' => 0,
  960. 'name' => '申请金额',
  961. 'price' => number_format ( $agency, 2, '.', '' )
  962. ) );
  963. $sum += $agency;
  964. $agencySum += $agency;
  965. $accountJson ['cSum'] = array (
  966. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  967. 'agencySum' => number_format ( 0, 2, '.', '' ),
  968. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  969. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  970. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  971. );
  972. // 报销单
  973. $receipt->loanItem = json_encode ( $accountJson );
  974. $receipt->sum = number_format ( $sum, 2, '.', '' );
  975. $receipt->cid = $cid;
  976. // 特殊状态
  977. // 修改审批流程加入角色
  978. if ($receiptDetail ['status'] != 4)
  979. $receipt->verify = $verify;
  980. $receipt->explanation = $explanation;
  981. $receipt->update ( array (
  982. 'where' => 'rid=' . $rid
  983. ) );
  984. // 借款数据更新
  985. $loanReceipt->loanItem = json_encode ( $accountJson );
  986. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  987. $loanReceipt->cid = $cid;
  988. if ($receiptDetail ['status'] != 4)
  989. $loanReceipt->verify = $verify;
  990. $loanReceipt->explanation = $explanation;
  991. $receipt->executeCopy = $executeDetail ['staff'];
  992. $loanReceipt->update ( array (
  993. 'where' => 'rid=' . $receiptDetail ['loanRid']
  994. ) );
  995. }
  996. return "/saeaBorad";
  997. }
  998. function saeaLoanReceiptAdd() {
  999. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1000. Doo::loadModel ( 'receipt' );
  1001. $receipt = new receipt ();
  1002. Doo::loadModel ( 'loanReceipt' );
  1003. $loanReceipt = new loanReceipt ();
  1004. Doo::loadModel ( 'L_category' );
  1005. $Lcategory = new L_category ();
  1006. Doo::loadModel ( 'verify' );
  1007. Doo::loadModel ( 'statistics' );
  1008. $statistics = new statistics ();
  1009. $verify = new verify ();
  1010. Doo::loadModel ( 'staff' );
  1011. $staff = new staff ();
  1012. $receiptDe = $receipt->getOne ( array (
  1013. 'where' => 'rid=' . $rid,
  1014. 'desc' => 'rid',
  1015. 'asArray' => true
  1016. ) );
  1017. $receiptList = $loanReceipt->find ( array (
  1018. 'where' => 'rid=' . $receiptDe ['loanRid'],
  1019. 'desc' => 'rid',
  1020. 'asArray' => true
  1021. ) );
  1022. $Locate = 0;
  1023. $roleId = 0;
  1024. $button = 0;
  1025. foreach ( $receiptList as $key => $value ) {
  1026. $receiptList [$key] ['Locate'] = $Locate;
  1027. $Locate ++;
  1028. $receiptList [$key] ['reviseDetail'] = array ();
  1029. if (! empty ( $value ['reviseDetail'] ))
  1030. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1031. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1032. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1033. $categoryDetil = $Lcategory->getOne ( array (
  1034. 'where' => 'cid=' . $value ['cid'],
  1035. 'asArray' => true
  1036. ) );
  1037. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1038. // 检测编辑状态
  1039. $verifyList = $verify->getOne ( array (
  1040. 'where' => 'vid=' . $value ['verify'],
  1041. 'asArray' => true
  1042. ) );
  1043. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1044. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1045. Doo::loadModel ( 'role' );
  1046. $role = new role ();
  1047. $flag = true;
  1048. $roleKey = 0;
  1049. $endStaffArray = array ();
  1050. $roleArrayCopy = array ();
  1051. foreach ( $verifyList as $k => $v ) {
  1052. // init verifyStaff
  1053. if ($v [1] == 'ROLE') {
  1054. if (! empty ( $verifyStaff )) {
  1055. $endStaffArray = end ( $verifyStaff );
  1056. // if ($v[0]==$endStaffArray['nextStaff']){
  1057. // $roleId=$v[0];
  1058. // }
  1059. }
  1060. $roleVerify = json_decode ( $v [3], true );
  1061. $roleKey = $k;
  1062. $roleArray = array ();
  1063. $rolename = $role->getOne ( array (
  1064. 'where' => 'rid=' . $v [0],
  1065. 'asArray' => true
  1066. ) );
  1067. foreach ( $roleVerify as $o => $p ) {
  1068. $staffID = explode ( '_', $p );
  1069. $staffInfo = $staff->getOne ( array (
  1070. 'where' => 'sid=' . $staffID [0],
  1071. 'asArray' => true
  1072. ) );
  1073. // print_r($staffID);
  1074. $exp = array (
  1075. 0 => $staffInfo ['sid'],
  1076. 1 => $staffID [1],
  1077. 2 => $staffInfo ['avatar'],
  1078. 'date' => '',
  1079. 'date' => '',
  1080. 'opinion' => '',
  1081. 'status' => '',
  1082. 'rolename' => $rolename ['name']
  1083. );
  1084. array_push ( $roleArray, $exp );
  1085. }
  1086. $roleArrayCopy [$v [0]] = $roleArray;
  1087. // $verifyList[$k]['roleArray']=$roleArray;
  1088. }
  1089. $verifyList [$k] ['date'] = "";
  1090. $verifyList [$k] ['opinion'] = "";
  1091. $verifyList [$k] ['status'] = "";
  1092. if (empty ( $verifyStaff )) {
  1093. $verifyList [$k] ['date'] = "";
  1094. $verifyList [$k] ['opinion'] = "";
  1095. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1096. $verifyList [$k] ['status'] = 4;
  1097. $flag = false;
  1098. }
  1099. } else {
  1100. foreach ( $verifyStaff as $m => $u ) {
  1101. if ($v [0] == $m) {
  1102. $verifyList [$k] ['date'] = $u ['date'];
  1103. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1104. $verifyList [$k] ['status'] = $u ['status'];
  1105. $flag = false;
  1106. break;
  1107. }
  1108. }
  1109. $endStaffArray = end ( $verifyStaff );
  1110. if (isset ( $endStaffArray ['ROLE'] )) {
  1111. } else {
  1112. // $endKey=key($verifyStaff);
  1113. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1114. // $button=4;
  1115. // $verifyList[$k]['status']=4;
  1116. // }
  1117. }
  1118. }
  1119. }
  1120. $rolename ['name'] = '';
  1121. if (! empty ( $roleId )) {
  1122. Doo::loadModel ( 'role' );
  1123. $role = new role ();
  1124. $rolename = $role->getOne ( array (
  1125. 'where' => 'rid=' . $roleId,
  1126. 'asArray' => true
  1127. ) );
  1128. }
  1129. if (! empty ( $verifyStaff ))
  1130. $endStaffArray = end ( $verifyStaff );
  1131. $KOP = false;
  1132. foreach ( $roleArrayCopy as $P => $A ) {
  1133. foreach ( $A as $MKI => $AVL ) {
  1134. if (! empty ( $verifyStaff )) {
  1135. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1136. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1137. $button = 4;
  1138. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1139. }
  1140. foreach ( $verifyStaff as $m => $u ) {
  1141. $AVLFK = $AVL [0] . '_R';
  1142. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1143. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1144. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1145. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1146. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1147. break;
  1148. }
  1149. }
  1150. } else {
  1151. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1152. $button = 4;
  1153. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1154. }
  1155. }
  1156. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1157. $KOP = true;
  1158. }
  1159. }
  1160. foreach ( $roleArrayCopy as $k => $v ) {
  1161. foreach ( $verifyList as $m => $n ) {
  1162. if ($n [0] == $k) {
  1163. array_splice ( $verifyList, $m, 1, $v );
  1164. }
  1165. }
  1166. }
  1167. $receiptList [$key] ['verifyList'] = $verifyList;
  1168. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1169. 'where' => 'sid=' . $value ['staff'],
  1170. 'asArray' => true
  1171. ) );
  1172. $receiptList [$key] ['button'] = $button;
  1173. //
  1174. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1175. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1176. }
  1177. $data ['receiptList'] = $receiptList;
  1178. Doo::loadModel ( 'L_category' );
  1179. $lCategory = new L_category ();
  1180. Doo::loadModel ( 'accountItem' );
  1181. $accountItem = new accountItem ();
  1182. $acItem = $accountItem->find ( array (
  1183. 'asArray' => true
  1184. ) );
  1185. $veList = $verify->find ( array (
  1186. 'asArray' => true
  1187. ) );
  1188. foreach ( $veList as $key => $value ) {
  1189. $v = json_decode ( $value ['staff'] );
  1190. $list = array ();
  1191. foreach ( $v as $n => $m ) {
  1192. if ($m ['1'] == 'ROLE') {
  1193. $roleInfo = $role->getOne ( array (
  1194. 'where' => 'rid=' . $m [0],
  1195. 'asArray' => true
  1196. ) );
  1197. $v [$n] [1] = $roleInfo ['name'];
  1198. array_push ( $list, $roleInfo ['name'] );
  1199. } else {
  1200. array_push ( $list, $v [$n] [1] );
  1201. }
  1202. }
  1203. $veList [$key] ['staff'] = implode ( '>', $list );
  1204. }
  1205. $data ['rid'] = $rid;
  1206. $data ['category'] = $lCategory->find ( array (
  1207. 'asArray' => true
  1208. ) );
  1209. $data ['veList'] = $veList;
  1210. $data ['acItem'] = $acItem;
  1211. $data ['memu'] = "receipt";
  1212. $data ['staff'] = $this->staff;
  1213. $data ['receiptMemu'] = 'saeaBorad';
  1214. $data ['verifyId'] = $this->verifyId;
  1215. $data ['executeId'] = $this->executeId;
  1216. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1217. }
  1218. function saeaLoanReceiptAddDo() {
  1219. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1220. $agency = $this->get_args ( 'agency' );
  1221. $travel = $this->get_args ( 'travel' );
  1222. $train = $this->get_args ( 'train' );
  1223. $other = $this->get_args ( 'other' );
  1224. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1225. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1226. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1227. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1228. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )) {
  1229. Doo::loadModel ( 'receipt' );
  1230. Doo::loadModel ( 'receiptDetail' );
  1231. Doo::loadModel ( 'accountItem' );
  1232. $accountItem = new accountItem ();
  1233. $receipt = new receipt ();
  1234. Doo::loadModel ( 'enclosur' );
  1235. Doo::loadModel ( 'execute' );
  1236. $execute = new execute ();
  1237. $executeDetail = $execute->getOne ( array (
  1238. 'where' => 'mold="借款费用执行人"',
  1239. 'asArray' => true
  1240. ) );
  1241. $receiptDet = $receipt->getOne ( array (
  1242. 'where' => 'rid=' . $rid,
  1243. 'asArray' => true
  1244. ) );
  1245. // if(!empty($receiptDetail))
  1246. // return "/referReceipt/".$receiptDetail['rid'];
  1247. $aItem = $accountItem->find ( array (
  1248. 'asArray' => true
  1249. ) );
  1250. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1251. $ag = $tr = $ta = $ot = 0;
  1252. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1253. foreach ( $aItem as $key => $value ) {
  1254. if ($value ['category'] == $this->AGENCY) {
  1255. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1256. array_push ( $accountJson [$this->AGENCY], array (
  1257. 'aid' => $value ['aid'],
  1258. 'name' => $value ['name'],
  1259. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1260. ) );
  1261. $sum += $agency [$ag];
  1262. $agencySum += $agency [$ag];
  1263. }
  1264. $ag ++;
  1265. }
  1266. if ($value ['category'] == $this->TRAVEL) {
  1267. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1268. array_push ( $accountJson [$this->TRAVEL], array (
  1269. 'aid' => $value ['aid'],
  1270. 'name' => $value ['name'],
  1271. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1272. ) );
  1273. $sum += $travel [$tr];
  1274. $travelSum += $travel [$tr];
  1275. }
  1276. $tr ++;
  1277. }
  1278. if ($value ['category'] == $this->TRAIN) {
  1279. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1280. array_push ( $accountJson [$this->TRAIN], array (
  1281. 'aid' => $value ['aid'],
  1282. 'name' => $value ['name'],
  1283. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1284. ) );
  1285. $sum += $train [$ta];
  1286. $trainSum += $train [$ta];
  1287. }
  1288. $ta ++;
  1289. }
  1290. if ($value ['category'] == $this->OTHER) {
  1291. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1292. array_push ( $accountJson [$this->OTHER], array (
  1293. 'aid' => $value ['aid'],
  1294. 'name' => $value ['name'],
  1295. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1296. ) );
  1297. $sum += $other [$ot];
  1298. $otherSum += $other [$ot];
  1299. }
  1300. $ot ++;
  1301. }
  1302. }
  1303. $accountJson ['cSum'] = array (
  1304. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1305. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1306. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1307. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1308. );
  1309. // 报销单
  1310. $receipt->accountItem = json_encode ( $accountJson );
  1311. $receipt->staff = $this->staff [0] ['sid'];
  1312. $receipt->loanSum = $receiptDet ['sum'];
  1313. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1314. $receipt->date = date ( "Y-m-d" );
  1315. $receipt->pastDate = '';
  1316. $receipt->cid = $cid;
  1317. $receipt->status = 7;
  1318. // 修改审批流程加入角色
  1319. $receipt->verify = $verify;
  1320. $receipt->verifyStaff = '';
  1321. $receipt->executeStaff = '';
  1322. $receipt->executeCopy = $executeDetail ['staff'];
  1323. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  1324. $receipt->explanation = $explanation;
  1325. $receipt->update ( array (
  1326. 'where' => 'rid=' . $rid
  1327. ) );
  1328. // 附件
  1329. if (! empty ( $enclosurName )) {
  1330. $enclosurArray = explode ( '-', $enclosurName );
  1331. foreach ( $enclosurArray as $value ) {
  1332. $enclosur = new enclosur ();
  1333. $enclosur->name = $value;
  1334. $enclosur->rid = $rid;
  1335. $enclosur->insert ();
  1336. }
  1337. // print_r($enclosurArray);die;
  1338. }
  1339. // 报销详情
  1340. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1341. $receiptDetail = new receiptDetail ();
  1342. $receiptDetail->staff = $this->staff [0] ['sid'];
  1343. $receiptDetail->item = $value ['name'];
  1344. $receiptDetail->itemCategory = $this->AGENCY;
  1345. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1346. $receiptDetail->date = date ( "Y-m-d" );
  1347. $receiptDetail->cid = $cid;
  1348. $receiptDetail->rid = $rid;
  1349. $receiptDetail->status = 4;
  1350. $receiptDetail->insert ();
  1351. }
  1352. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1353. $receiptDetail = new receiptDetail ();
  1354. $receiptDetail->staff = $this->staff [0] ['sid'];
  1355. $receiptDetail->item = $value ['name'];
  1356. $receiptDetail->itemCategory = $this->TRAVEL;
  1357. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1358. $receiptDetail->date = date ( "Y-m-d" );
  1359. $receiptDetail->cid = $cid;
  1360. $receiptDetail->rid = $rid;
  1361. $receiptDetail->status = 4;
  1362. $receiptDetail->insert ();
  1363. }
  1364. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1365. $receiptDetail = new receiptDetail ();
  1366. $receiptDetail->staff = $this->staff [0] ['sid'];
  1367. $receiptDetail->item = $value ['name'];
  1368. $receiptDetail->itemCategory = $this->TRAIN;
  1369. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1370. $receiptDetail->date = date ( "Y-m-d" );
  1371. $receiptDetail->cid = $cid;
  1372. $receiptDetail->rid = $rid;
  1373. $receiptDetail->status = 4;
  1374. $receiptDetail->insert ();
  1375. }
  1376. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1377. $receiptDetail = new receiptDetail ();
  1378. $receiptDetail->staff = $this->staff [0] ['sid'];
  1379. $receiptDetail->item = $value ['name'];
  1380. $receiptDetail->itemCategory = $this->OTHER;
  1381. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1382. $receiptDetail->date = date ( "Y-m-d" );
  1383. $receiptDetail->cid = $cid;
  1384. $receiptDetail->rid = $rid;
  1385. $receiptDetail->status = 4;
  1386. $receiptDetail->insert ();
  1387. }
  1388. return "/saeaBorad";
  1389. }
  1390. return "/saeaLoanReceiptAdd/" . $rid;
  1391. }
  1392. function saeaLoanReceiptEdi() {
  1393. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1394. // echo $rid;
  1395. Doo::loadModel ( 'accountItem' );
  1396. Doo::loadModel ( 'verify' );
  1397. Doo::loadModel ( 'receipt' );
  1398. $receipt = new receipt ();
  1399. $verify = new verify ();
  1400. $accountItem = new accountItem ();
  1401. Doo::loadModel ( 'L_category' );
  1402. $Lcategory = new L_category ();
  1403. Doo::loadModel ( "role" );
  1404. $role = new role ();
  1405. Doo::loadModel ( 'loanReceipt' );
  1406. $loanReceipt = new loanReceipt ();
  1407. Doo::loadModel ( 'staff' );
  1408. $staff = new staff ();
  1409. $receiptDetail = $receipt->getOne ( array (
  1410. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  1411. 'asArray' => true
  1412. ) );
  1413. if (empty ( $receiptDetail ))
  1414. return "/saeaBorad";
  1415. $receiptList = $loanReceipt->find ( array (
  1416. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1417. 'desc' => 'rid',
  1418. 'asArray' => true
  1419. ) );
  1420. $Locate = 0;
  1421. $roleId = 0;
  1422. $button = 0;
  1423. foreach ( $receiptList as $key => $value ) {
  1424. $receiptList [$key] ['Locate'] = $Locate;
  1425. $Locate ++;
  1426. $receiptList [$key] ['reviseDetail'] = array ();
  1427. if (! empty ( $value ['reviseDetail'] ))
  1428. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1429. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1430. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1431. $categoryDetil = $Lcategory->getOne ( array (
  1432. 'where' => 'cid=' . $value ['cid'],
  1433. 'asArray' => true
  1434. ) );
  1435. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1436. // 检测编辑状态
  1437. $verifyList = $verify->getOne ( array (
  1438. 'where' => 'vid=' . $value ['verify'],
  1439. 'asArray' => true
  1440. ) );
  1441. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1442. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1443. Doo::loadModel ( 'role' );
  1444. $role = new role ();
  1445. $flag = true;
  1446. $roleKey = 0;
  1447. $endStaffArray = array ();
  1448. $roleArrayCopy = array ();
  1449. foreach ( $verifyList as $k => $v ) {
  1450. // init verifyStaff
  1451. if ($v [1] == 'ROLE') {
  1452. if (! empty ( $verifyStaff )) {
  1453. $endStaffArray = end ( $verifyStaff );
  1454. // if ($v[0]==$endStaffArray['nextStaff']){
  1455. // $roleId=$v[0];
  1456. // }
  1457. }
  1458. $roleVerify = json_decode ( $v [3], true );
  1459. $roleKey = $k;
  1460. $roleArray = array ();
  1461. $rolename = $role->getOne ( array (
  1462. 'where' => 'rid=' . $v [0],
  1463. 'asArray' => true
  1464. ) );
  1465. foreach ( $roleVerify as $o => $p ) {
  1466. $staffID = explode ( '_', $p );
  1467. $staffInfo = $staff->getOne ( array (
  1468. 'where' => 'sid=' . $staffID [0],
  1469. 'asArray' => true
  1470. ) );
  1471. // print_r($staffID);
  1472. $exp = array (
  1473. 0 => $staffInfo ['sid'],
  1474. 1 => $staffID [1],
  1475. 2 => $staffInfo ['avatar'],
  1476. 'date' => '',
  1477. 'date' => '',
  1478. 'opinion' => '',
  1479. 'status' => '',
  1480. 'rolename' => $rolename ['name']
  1481. );
  1482. array_push ( $roleArray, $exp );
  1483. }
  1484. $roleArrayCopy [$v [0]] = $roleArray;
  1485. // $verifyList[$k]['roleArray']=$roleArray;
  1486. }
  1487. $verifyList [$k] ['date'] = "";
  1488. $verifyList [$k] ['opinion'] = "";
  1489. $verifyList [$k] ['status'] = "";
  1490. if (empty ( $verifyStaff )) {
  1491. $verifyList [$k] ['date'] = "";
  1492. $verifyList [$k] ['opinion'] = "";
  1493. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1494. $verifyList [$k] ['status'] = 4;
  1495. $flag = false;
  1496. }
  1497. } else {
  1498. foreach ( $verifyStaff as $m => $u ) {
  1499. if ($v [0] == $m) {
  1500. $verifyList [$k] ['date'] = $u ['date'];
  1501. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1502. $verifyList [$k] ['status'] = $u ['status'];
  1503. $flag = false;
  1504. break;
  1505. }
  1506. }
  1507. $endStaffArray = end ( $verifyStaff );
  1508. if (isset ( $endStaffArray ['ROLE'] )) {
  1509. } else {
  1510. // $endKey=key($verifyStaff);
  1511. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1512. // $button=4;
  1513. // $verifyList[$k]['status']=4;
  1514. // }
  1515. }
  1516. }
  1517. }
  1518. $rolename ['name'] = '';
  1519. if (! empty ( $roleId )) {
  1520. Doo::loadModel ( 'role' );
  1521. $role = new role ();
  1522. $rolename = $role->getOne ( array (
  1523. 'where' => 'rid=' . $roleId,
  1524. 'asArray' => true
  1525. ) );
  1526. }
  1527. if (! empty ( $verifyStaff ))
  1528. $endStaffArray = end ( $verifyStaff );
  1529. $KOP = false;
  1530. foreach ( $roleArrayCopy as $P => $A ) {
  1531. foreach ( $A as $MKI => $AVL ) {
  1532. if (! empty ( $verifyStaff )) {
  1533. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1534. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1535. $button = 4;
  1536. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1537. }
  1538. foreach ( $verifyStaff as $m => $u ) {
  1539. $AVLFK = $AVL [0] . '_R';
  1540. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1541. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1542. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1543. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1544. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1545. break;
  1546. }
  1547. }
  1548. } else {
  1549. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1550. $button = 4;
  1551. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1552. }
  1553. }
  1554. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1555. $KOP = true;
  1556. }
  1557. }
  1558. foreach ( $roleArrayCopy as $k => $v ) {
  1559. foreach ( $verifyList as $m => $n ) {
  1560. if ($n [0] == $k) {
  1561. array_splice ( $verifyList, $m, 1, $v );
  1562. }
  1563. }
  1564. }
  1565. $receiptList [$key] ['verifyList'] = $verifyList;
  1566. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1567. 'where' => 'sid=' . $value ['staff'],
  1568. 'asArray' => true
  1569. ) );
  1570. $receiptList [$key] ['button'] = $button;
  1571. //
  1572. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1573. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1574. }
  1575. $data ['receiptList'] = $receiptList;
  1576. $acItem = $accountItem->find ( array (
  1577. 'asArray' => true
  1578. ) );
  1579. $veList = $verify->find ( array (
  1580. 'asArray' => true
  1581. ) );
  1582. foreach ( $veList as $key => $value ) {
  1583. $v = json_decode ( $value ['staff'] );
  1584. $list = array ();
  1585. foreach ( $v as $n => $m ) {
  1586. if ($m ['1'] == 'ROLE') {
  1587. $roleInfo = $role->getOne ( array (
  1588. 'where' => 'rid=' . $m [0],
  1589. 'asArray' => true
  1590. ) );
  1591. $v [$n] [1] = $roleInfo ['name'];
  1592. array_push ( $list, $roleInfo ['name'] );
  1593. } else {
  1594. array_push ( $list, $v [$n] [1] );
  1595. }
  1596. }
  1597. $veList [$key] ['staff'] = implode ( '>', $list );
  1598. }
  1599. // 配置编辑信息
  1600. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1601. foreach ( $acItem as $key => $value ) {
  1602. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1603. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1604. $acItem [$key] ['price'] = $v ['price'];
  1605. }
  1606. }
  1607. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1608. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1609. $acItem [$key] ['price'] = $v ['price'];
  1610. }
  1611. }
  1612. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1613. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1614. $acItem [$key] ['price'] = $v ['price'];
  1615. }
  1616. }
  1617. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1618. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1619. $acItem [$key] ['price'] = $v ['price'];
  1620. }
  1621. }
  1622. }
  1623. $data ['category'] = $Lcategory->find ( array (
  1624. 'asArray' => true
  1625. ) );
  1626. $data ['cSum'] = $accountItemList ['cSum'];
  1627. $data ['sum'] = $receiptDetail ['sum'];
  1628. $data ['receiptDetail'] = $receiptDetail;
  1629. $data ['veList'] = $veList;
  1630. $data ['acItem'] = $acItem;
  1631. $data ['memu'] = "receipt";
  1632. $data ['staff'] = $this->staff;
  1633. $data ['receiptMemu'] = 'saeaBorad';
  1634. $data ['verify'] = $receiptDetail ['verify'];
  1635. $data ['verifyId'] = $this->verifyId;
  1636. $data ['executeId'] = $this->executeId;
  1637. $data ['rid'] = $rid;
  1638. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  1639. }
  1640. function confirmation() {
  1641. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1642. Doo::loadModel ( 'receipt' );
  1643. Doo::loadModel ( 'receiptDetail' );
  1644. $receipt = new receipt ();
  1645. $receiptDetail = new receiptDetail ();
  1646. Doo::loadModel ( 'statistics' );
  1647. Doo::loadModel ( 'itemStatistics' );
  1648. $statistics = new statistics ();
  1649. $itemStatistics = new itemStatistics ();
  1650. Doo::loadModel ( "verify" );
  1651. $verify = new verify ();
  1652. $receiptDetailList = $receipt->getOne ( array (
  1653. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  1654. 'asArray' => true
  1655. ) );
  1656. if (empty ( $receiptDetailList ))
  1657. return "/saeaBorad";
  1658. $verifyDetail = $verify->getOne ( array (
  1659. 'where' => ' vid =' . $receiptDetailList ['verify'],
  1660. 'asArray' => true
  1661. ) );
  1662. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  1663. if (empty ( $receiptDetailList ['nowStaff'] )) {
  1664. $nowStaff = "";
  1665. $nowStaffList = array ();
  1666. if ($verifyDetail [0] [1] == 'ROLE') {
  1667. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  1668. foreach ( $vStaffString as $key => $value ) {
  1669. $staffK = explode ( "_", $value );
  1670. array_push ( $nowStaffList, $staffK [0] );
  1671. }
  1672. $nowStaff = implode ( ',', $nowStaffList );
  1673. } else {
  1674. $nowStaff = $verifyDetail [0] [0];
  1675. }
  1676. $receipt->nowStaff = $nowStaff;
  1677. }
  1678. // echo $nowStaff;
  1679. // print_r($verifyDetail);die;
  1680. $receipt->rid = $receiptDetailList ['rid'];
  1681. $receipt->status = 2;
  1682. $receipt->update ();
  1683. // 操作日志
  1684. Doo::loadModel ( "receiptLog" );
  1685. $receiptLog = new receiptLog ();
  1686. $verify = new verify ();
  1687. $receiptInfo = $receipt->getOne ( array (
  1688. 'where' => 'rid=' . $rid,
  1689. 'asArray' => true
  1690. ) );
  1691. $vr = $verify->getOne ( array (
  1692. 'where' => 'vid=' . $receiptInfo ['verify'],
  1693. 'asArray' => true
  1694. ) );
  1695. $jd = json_decode ( $vr ['staff'] );
  1696. $roleId = 0;
  1697. foreach ( $jd as $key => $value ) {
  1698. if ($value [1] == 'ROLE') {
  1699. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  1700. if ($pos !== false) {
  1701. $roleId = $value [0];
  1702. }
  1703. }
  1704. }
  1705. // 审批日志
  1706. // echo $roleId;die;
  1707. if (! empty ( $roleId )) {
  1708. Doo::loadModel ( "role" );
  1709. $role = new role ();
  1710. $roleInfo = $role->getOne ( array (
  1711. 'where' => 'rid=' . $roleId,
  1712. 'asArray' => true
  1713. ) );
  1714. $receiptLog->rolename = $roleInfo ['name'];
  1715. }
  1716. $receiptLog->username = $this->staff [0] ['username'];
  1717. $receiptLog->uid = $this->staff [0] ['sid'];
  1718. $receiptLog->date = date ( "Y-m-d" );
  1719. $receiptLog->opinion = '提交审批';
  1720. $receiptLog->img = $this->staff [0] ['avatar'];
  1721. $receiptLog->status = 2;
  1722. $receiptLog->rid = $rid;
  1723. $receiptLog->insert ();
  1724. return "/expenses";
  1725. }
  1726. function expenses() {
  1727. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  1728. if (empty ( $item ))
  1729. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  1730. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1731. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  1732. Doo::loadModel ( 'receipt' );
  1733. $receipt = new receipt ();
  1734. Doo::loadModel ( 'L_category' );
  1735. $Lcategory = new L_category ();
  1736. Doo::loadModel ( 'verify' );
  1737. Doo::loadModel ( 'statistics' );
  1738. $statistics = new statistics ();
  1739. $verify = new verify ();
  1740. Doo::loadModel ( 'staff' );
  1741. $staff = new staff ();
  1742. $condition = "";
  1743. if ($item == "expenses")
  1744. $condition = " and Rtype=1 ";
  1745. elseif ($item == "receipts")
  1746. $condition = " and Rtype=0 ";
  1747. elseif ($item == "remits")
  1748. $condition = " and Rtype=2 ";
  1749. $dateCondition = " and Year(date) =" . $year;
  1750. if (! empty ( $moth )) {
  1751. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  1752. $stList = $statistics->getOne ( array (
  1753. 'select' => 'rePrice ,agPrice',
  1754. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  1755. 'asArray' => true
  1756. ) );
  1757. } else
  1758. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  1759. if (empty ( $stList ))
  1760. $stList = array (
  1761. 'rePrice' => 0,
  1762. 'agPrice' => 0
  1763. );
  1764. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  1765. if (! isset ( $noPassSum ['sum'] ))
  1766. $noPassSum ['sum'] = 0;
  1767. $data ['stList'] = array (
  1768. 'rePrice' => $stList ['rePrice'],
  1769. 'agPrice' => $stList ['agPrice'],
  1770. 'skPrice' => ($noPassSum ['sum'])
  1771. );
  1772. $receiptList = $receipt->find ( array (
  1773. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  1774. 'desc' => 'rid',
  1775. 'asArray' => true
  1776. ) );
  1777. $Locate = 0;
  1778. $roleId = 0;
  1779. $button = 0;
  1780. foreach ( $receiptList as $key => $value ) {
  1781. $receiptList [$key] ['Locate'] = $Locate;
  1782. $Locate ++;
  1783. $receiptList [$key] ['reviseDetail'] = array ();
  1784. if (! empty ( $value ['reviseDetail'] ))
  1785. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1786. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1787. $categoryDetil = $Lcategory->getOne ( array (
  1788. 'where' => 'cid=' . $value ['cid'],
  1789. 'asArray' => true
  1790. ) );
  1791. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1792. // 检测编辑状态
  1793. $verifyList = $verify->getOne ( array (
  1794. 'where' => 'vid=' . $value ['verify'],
  1795. 'asArray' => true
  1796. ) );
  1797. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1798. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1799. Doo::loadModel ( 'role' );
  1800. $role = new role ();
  1801. $flag = true;
  1802. $roleKey = 0;
  1803. $endStaffArray = array ();
  1804. $roleArrayCopy = array ();
  1805. foreach ( $verifyList as $k => $v ) {
  1806. // init verifyStaff
  1807. if ($v [1] == 'ROLE') {
  1808. if (! empty ( $verifyStaff )) {
  1809. $endStaffArray = end ( $verifyStaff );
  1810. // if ($v[0]==$endStaffArray['nextStaff']){
  1811. // $roleId=$v[0];
  1812. // }
  1813. }
  1814. $roleVerify = json_decode ( $v [3], true );
  1815. $roleKey = $k;
  1816. $roleArray = array ();
  1817. $rolename = $role->getOne ( array (
  1818. 'where' => 'rid=' . $v [0],
  1819. 'asArray' => true
  1820. ) );
  1821. foreach ( $roleVerify as $o => $p ) {
  1822. $staffID = explode ( '_', $p );
  1823. $staffInfo = $staff->getOne ( array (
  1824. 'where' => 'sid=' . $staffID [0],
  1825. 'asArray' => true
  1826. ) );
  1827. // print_r($staffID);
  1828. $exp = array (
  1829. 0 => $staffInfo ['sid'],
  1830. 1 => $staffID [1],
  1831. 2 => $staffInfo ['avatar'],
  1832. 'date' => '',
  1833. 'date' => '',
  1834. 'opinion' => '',
  1835. 'status' => '',
  1836. 'rolename' => $rolename ['name']
  1837. );
  1838. array_push ( $roleArray, $exp );
  1839. }
  1840. $roleArrayCopy [$v [0]] = $roleArray;
  1841. // $verifyList[$k]['roleArray']=$roleArray;
  1842. }
  1843. $verifyList [$k] ['date'] = "";
  1844. $verifyList [$k] ['opinion'] = "";
  1845. $verifyList [$k] ['status'] = "";
  1846. if (empty ( $verifyStaff )) {
  1847. $verifyList [$k] ['date'] = "";
  1848. $verifyList [$k] ['opinion'] = "";
  1849. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1850. $verifyList [$k] ['status'] = 4;
  1851. $flag = false;
  1852. }
  1853. } else {
  1854. foreach ( $verifyStaff as $m => $u ) {
  1855. if ($v [0] == $m) {
  1856. $verifyList [$k] ['date'] = $u ['date'];
  1857. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1858. $verifyList [$k] ['status'] = $u ['status'];
  1859. $flag = false;
  1860. break;
  1861. }
  1862. }
  1863. $endStaffArray = end ( $verifyStaff );
  1864. if (isset ( $endStaffArray ['ROLE'] )) {
  1865. } else {
  1866. // $endKey=key($verifyStaff);
  1867. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1868. // $button=4;
  1869. // $verifyList[$k]['status']=4;
  1870. // }
  1871. }
  1872. }
  1873. }
  1874. $rolename ['name'] = '';
  1875. if (! empty ( $roleId )) {
  1876. Doo::loadModel ( 'role' );
  1877. $role = new role ();
  1878. $rolename = $role->getOne ( array (
  1879. 'where' => 'rid=' . $roleId,
  1880. 'asArray' => true
  1881. ) );
  1882. }
  1883. if (! empty ( $verifyStaff ))
  1884. $endStaffArray = end ( $verifyStaff );
  1885. $KOP = false;
  1886. foreach ( $roleArrayCopy as $P => $A ) {
  1887. foreach ( $A as $MKI => $AVL ) {
  1888. if (! empty ( $verifyStaff )) {
  1889. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1890. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1891. $button = 4;
  1892. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1893. }
  1894. foreach ( $verifyStaff as $m => $u ) {
  1895. $AVLFK = $AVL [0] . '_R';
  1896. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1897. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1898. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1899. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1900. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1901. break;
  1902. }
  1903. }
  1904. } else {
  1905. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1906. $button = 4;
  1907. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1908. }
  1909. }
  1910. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1911. $KOP = true;
  1912. }
  1913. }
  1914. foreach ( $roleArrayCopy as $k => $v ) {
  1915. foreach ( $verifyList as $m => $n ) {
  1916. if ($n [0] == $k) {
  1917. array_splice ( $verifyList, $m, 1, $v );
  1918. }
  1919. }
  1920. }
  1921. $receiptList [$key] ['verifyList'] = $verifyList;
  1922. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1923. 'where' => 'sid=' . $value ['staff'],
  1924. 'asArray' => true
  1925. ) );
  1926. $receiptList [$key] ['button'] = $button;
  1927. }
  1928. // print_r($receiptList);die;
  1929. $mothHtml = "";
  1930. for($i = 1; $i <= 12; $i ++) {
  1931. if ($moth == $i)
  1932. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  1933. else
  1934. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  1935. }
  1936. $data ['mothHtml'] = $mothHtml;
  1937. $data ['receiptList'] = $receiptList;
  1938. $data ['memu'] = "receipt";
  1939. $data ['staff'] = $this->staff;
  1940. $data ['receiptMemu'] = 'expenses';
  1941. $data ['verifyId'] = $this->verifyId;
  1942. $data ['executeId'] = $this->executeId;
  1943. $data ['item'] = $item;
  1944. $data ['year'] = $year;
  1945. $this->render ( "/admin/expenses", $data );
  1946. }
  1947. function expensesCollect() {
  1948. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1949. Doo::loadModel ( 'receipt' );
  1950. $receipt = new receipt ();
  1951. Doo::loadModel ( 'L_category' );
  1952. $Lcategory = new L_category ();
  1953. Doo::loadModel ( 'verify' );
  1954. Doo::loadModel ( 'statistics' );
  1955. $statistics = new statistics ();
  1956. $verify = new verify ();
  1957. Doo::loadModel ( 'staff' );
  1958. $staff = new staff ();
  1959. Doo::loadModel ( 'loanReceipt' );
  1960. $loanReceipt = new loanReceipt ();
  1961. $receiptList = $receipt->find ( array (
  1962. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  1963. 'desc' => 'rid',
  1964. 'asArray' => true
  1965. ) );
  1966. $loanList = $loanReceipt->find ( array (
  1967. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  1968. 'desc' => 'rid',
  1969. 'asArray' => true
  1970. ) );
  1971. /*
  1972. * $Locate=0;$roleId=0;$button=0; foreach ($loanList as $key=>$value){ $loanList[$key]['Locate']=$Locate;$Locate++; $loanList[$key]['reviseDetail']=array(); if (!empty($value['reviseDetail'])) $loanList[$key]['reviseDetail']=json_decode($value['reviseDetail'],true); $loanList[$key]['accountItem']=json_decode($value['accountItem'],true); $loanList[$key]['loanItem']=json_decode($value['loanItem'],true); $categoryDetil=$Lcategory->getOne(array('where'=>'cid='.$value['cid'],'asArray'=>true)); $loanList[$key]['category']=$categoryDetil['title']; //检测编辑状态 if ($value['status']==3||$value['status']==1||$value['status']==8||$value['status']==9) $verifyList['staff']=$value['verifyBreakup']; else $verifyList=$verify->getOne(array('where'=>'vid='.$value['verify'],'asArray'=>true)); $verifyList=json_decode($verifyList['staff'],true);//status opinion $verifyStaff=json_decode($value['verifyStaff'],true); Doo::loadModel('role'); $role=new role(); $flag=true;$roleKey=0;$endStaffArray=array();$roleArrayCopy=array(); foreach ($verifyList as $k=>$v){ //init verifyStaff if ($v[1]=='ROLE'){ if (!empty($verifyStaff)){ $endStaffArray=end($verifyStaff); // if ($v[0]==$endStaffArray['nextStaff']){ // $roleId=$v[0]; // } } $roleVerify=json_decode($v[3],true); $roleKey=$k;$roleArray=array(); $rolename=$role->getOne(array('where'=>'rid='.$v[0],'asArray'=>true)); foreach ($roleVerify as $o=>$p){ $staffID=explode ('_',$p); $staffInfo=$staff->getOne(array('where'=>'sid='.$staffID[0],'asArray'=>true)); //print_r($staffID); $exp=array(0=>$staffInfo['sid'],1=>$staffID[1],2=>$staffInfo['avatar'],'date'=>'','date'=>'','opinion'=>'','status'=>'','rolename'=>$rolename['name']); array_push($roleArray, $exp); } $roleArrayCopy[$v[0]]=$roleArray; //$verifyList[$k]['roleArray']=$roleArray; } $verifyList[$k]['date']=""; $verifyList[$k]['opinion']=""; $verifyList[$k]['status']=""; if (empty($verifyStaff)){ $verifyList[$k]['date']=""; $verifyList[$k]['opinion']=""; if (($verifyList[0][0]==$this->staff[0]['sid'])&&$flag){ $verifyList[$k]['status']=4; $flag=false; } }else{ foreach ($verifyStaff as $m=>$u){ if ($v[0]==$m){ $verifyList[$k]['date']=$u['date']; $verifyList[$k]['opinion']=$u['opinion']; $verifyList[$k]['status']=$u['status']; $flag=false; break; } } $endStaffArray=end($verifyStaff); if (isset($endStaffArray['ROLE'])){ }else{ // $endKey=key($verifyStaff); // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){ // $button=4; // $verifyList[$k]['status']=4; // } } } } $rolename['name']=''; if (!empty($roleId)){ Doo::loadModel('role'); $role=new role(); $rolename=$role->getOne(array('where'=>'rid='.$roleId,'asArray'=>true)); } if (!empty($verifyStaff)) $endStaffArray=end($verifyStaff); $KOP=false; foreach ($roleArrayCopy as $P=>$A){ foreach ( $A as $MKI=>$AVL){ if (!empty($verifyStaff)){ //&&$rolename['rid']==$endStaffArray['nextStaff'] if ($this->staff[0]['sid']==$AVL[0]&&isset($endStaffArray['ROLE'])&&$rolename['rid']==$endStaffArray['nextStaff']){ $button=4; $roleArrayCopy[$P][$MKI]['status']=4; } foreach ($verifyStaff as $m=>$u){ $AVLFK=$AVL[0].'_R'; //echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>'; if (strcmp($AVLFK,$m)==0){//&&isset($u['ROLE'])&&$u['ROLE']==1 $roleArrayCopy[$P][$MKI]['date']=$u['date']; $roleArrayCopy[$P][$MKI]['opinion']=$u['opinion']; $roleArrayCopy[$P][$MKI]['status']=$u['status']; break; } } }else{ if ($this->staff[0]['sid']==$AVL[0]&&$verifyList[0][1]=='ROLE'){ $button=4; $roleArrayCopy[$P][$MKI]['status']=4; } } //$roleArray[$MKI]['rolename']=$rolename['name']; $KOP=true; } } foreach ($roleArrayCopy as $k=>$v){ foreach ($verifyList as $m=>$n){ if ($n[0]==$k){ array_splice($verifyList,$m,1,$v); } } } $loanList[$key]['verifyList']=$verifyList; $loanList[$key]['staffDetail']=$staff->getOne(array('where'=>'sid='.$value['staff'],'asArray'=>true)); $loanList[$key]['button']=$button; //$loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']); } $data['loanList']=$loanList;
  1973. */
  1974. $Locate = 0;
  1975. $roleId = 0;
  1976. $button = 0;
  1977. foreach ( $receiptList as $key => $value ) {
  1978. $receiptList [$key] ['Locate'] = $Locate;
  1979. $Locate ++;
  1980. $receiptList [$key] ['reviseDetail'] = array ();
  1981. if (! empty ( $value ['reviseDetail'] ))
  1982. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1983. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1984. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1985. $categoryDetil = $Lcategory->getOne ( array (
  1986. 'where' => 'cid=' . $value ['cid'],
  1987. 'asArray' => true
  1988. ) );
  1989. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1990. // 检测编辑状态
  1991. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  1992. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  1993. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  1994. else
  1995. $verifyList ['staff'] = $value ['verifyBreakup'];
  1996. } else
  1997. $verifyList = $verify->getOne ( array (
  1998. 'where' => 'vid=' . $value ['verify'],
  1999. 'asArray' => true
  2000. ) );
  2001. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2002. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2003. Doo::loadModel ( 'role' );
  2004. $role = new role ();
  2005. $flag = true;
  2006. $roleKey = 0;
  2007. $endStaffArray = array ();
  2008. $roleArrayCopy = array ();
  2009. foreach ( $verifyList as $k => $v ) {
  2010. // init verifyStaff
  2011. if ($v [1] == 'ROLE') {
  2012. if (! empty ( $verifyStaff )) {
  2013. $endStaffArray = end ( $verifyStaff );
  2014. // if ($v[0]==$endStaffArray['nextStaff']){
  2015. // $roleId=$v[0];
  2016. // }
  2017. }
  2018. $roleVerify = json_decode ( $v [3], true );
  2019. $roleKey = $k;
  2020. $roleArray = array ();
  2021. $rolename = $role->getOne ( array (
  2022. 'where' => 'rid=' . $v [0],
  2023. 'asArray' => true
  2024. ) );
  2025. foreach ( $roleVerify as $o => $p ) {
  2026. $staffID = explode ( '_', $p );
  2027. $staffInfo = $staff->getOne ( array (
  2028. 'where' => 'sid=' . $staffID [0],
  2029. 'asArray' => true
  2030. ) );
  2031. // print_r($staffID);
  2032. $exp = array (
  2033. 0 => $staffInfo ['sid'],
  2034. 1 => $staffID [1],
  2035. 2 => $staffInfo ['avatar'],
  2036. 'date' => '',
  2037. 'date' => '',
  2038. 'opinion' => '',
  2039. 'status' => '',
  2040. 'rolename' => $rolename ['name']
  2041. );
  2042. array_push ( $roleArray, $exp );
  2043. }
  2044. $roleArrayCopy [$v [0]] = $roleArray;
  2045. // $verifyList[$k]['roleArray']=$roleArray;
  2046. }
  2047. $verifyList [$k] ['date'] = "";
  2048. $verifyList [$k] ['opinion'] = "";
  2049. $verifyList [$k] ['status'] = "";
  2050. if (empty ( $verifyStaff )) {
  2051. $verifyList [$k] ['date'] = "";
  2052. $verifyList [$k] ['opinion'] = "";
  2053. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2054. $verifyList [$k] ['status'] = 4;
  2055. $flag = false;
  2056. }
  2057. } else {
  2058. foreach ( $verifyStaff as $m => $u ) {
  2059. if ($v [0] == $m) {
  2060. $verifyList [$k] ['date'] = $u ['date'];
  2061. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2062. $verifyList [$k] ['status'] = $u ['status'];
  2063. $flag = false;
  2064. break;
  2065. }
  2066. }
  2067. $endStaffArray = end ( $verifyStaff );
  2068. if (isset ( $endStaffArray ['ROLE'] )) {
  2069. } else {
  2070. // $endKey=key($verifyStaff);
  2071. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2072. // $button=4;
  2073. // $verifyList[$k]['status']=4;
  2074. // }
  2075. }
  2076. }
  2077. }
  2078. $rolename ['name'] = '';
  2079. if (! empty ( $roleId )) {
  2080. Doo::loadModel ( 'role' );
  2081. $role = new role ();
  2082. $rolename = $role->getOne ( array (
  2083. 'where' => 'rid=' . $roleId,
  2084. 'asArray' => true
  2085. ) );
  2086. }
  2087. if (! empty ( $verifyStaff ))
  2088. $endStaffArray = end ( $verifyStaff );
  2089. $KOP = false;
  2090. foreach ( $roleArrayCopy as $P => $A ) {
  2091. foreach ( $A as $MKI => $AVL ) {
  2092. if (! empty ( $verifyStaff )) {
  2093. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2094. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2095. $button = 4;
  2096. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2097. }
  2098. foreach ( $verifyStaff as $m => $u ) {
  2099. $AVLFK = $AVL [0] . '_R';
  2100. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2101. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2102. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2103. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2104. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2105. break;
  2106. }
  2107. }
  2108. } else {
  2109. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2110. $button = 4;
  2111. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2112. }
  2113. }
  2114. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2115. $KOP = true;
  2116. }
  2117. }
  2118. foreach ( $roleArrayCopy as $k => $v ) {
  2119. foreach ( $verifyList as $m => $n ) {
  2120. if ($n [0] == $k) {
  2121. array_splice ( $verifyList, $m, 1, $v );
  2122. }
  2123. }
  2124. }
  2125. // 费用执行人相关数据
  2126. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2127. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2128. foreach ( $executeCopy as $k => $v ) {
  2129. $executeCopy [$k] ['date'] = '';
  2130. $executeCopy [$k] ['opinion'] = '';
  2131. $executeCopy [$k] ['status'] = '';
  2132. if (! empty ( $executeStaff ))
  2133. foreach ( $executeStaff as $m => $u ) {
  2134. if ($v [0] == $m) {
  2135. $executeCopy [$k] ['date'] = $u ['date'];
  2136. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2137. $executeCopy [$k] ['status'] = $u ['status'];
  2138. break;
  2139. }
  2140. }
  2141. }
  2142. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2143. $receiptList [$key] ['verifyList'] = $verifyList;
  2144. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2145. 'where' => 'sid=' . $value ['staff'],
  2146. 'asArray' => true
  2147. ) );
  2148. $receiptList [$key] ['button'] = $button;
  2149. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2150. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2151. $relust = $value ['sum'] - $value ['loanSum'];
  2152. $receiptList [$key] ['relust'] = $relust;
  2153. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  2154. }
  2155. // print_r($receiptList);
  2156. $data ['receiptList'] = $receiptList;
  2157. $data ['memu'] = "receipt";
  2158. $data ['staff'] = $this->staff;
  2159. $data ['receiptMemu'] = 'expenses';
  2160. $data ['verifyId'] = $this->verifyId;
  2161. $data ['executeId'] = $this->executeId;
  2162. $this->render ( "/admin/expensesCollect", $data );
  2163. }
  2164. function approvalExpenses() {
  2165. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  2166. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2167. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2168. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2169. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2170. if (empty ( $status ))
  2171. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  2172. $page_size = 12;
  2173. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2174. $vidList = array ();
  2175. $button = 0;
  2176. Doo::loadModel ( 'verify' );
  2177. $verify = new verify ();
  2178. Doo::loadModel ( 'receipt' );
  2179. $receipt = new receipt ();
  2180. Doo::loadModel ( 'staff' );
  2181. $staff = new staff ();
  2182. Doo::loadModel ( 'L_category' );
  2183. $Lcategory = new L_category ();
  2184. // user verify ID
  2185. $verifyDetail = $verify->find ( array (
  2186. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  2187. 'asArray' => true
  2188. ) );
  2189. foreach ( $verifyDetail as $key => $value ) {
  2190. array_push ( $vidList, $value ['vid'] );
  2191. }
  2192. $vid = implode ( ",", $vidList );
  2193. if (empty ( $verifyDetail ))
  2194. $vid = 0;
  2195. // if ($status==0)
  2196. // $dateCondition="";
  2197. // else
  2198. $dateCondition = " and Year(date) =" . $year;
  2199. if (! empty ( $month ))
  2200. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  2201. $categoryList = $Lcategory->find ( array (
  2202. 'asArray' => true
  2203. ) );
  2204. $staffList = $staff->find ( array (
  2205. 'where' => 'cid=' . $cid,
  2206. 'asArray' => true
  2207. ) );
  2208. $cateCondition = "";
  2209. $staffCondition = "";
  2210. $approvalCondition = "";
  2211. if (! empty ( $cid ))
  2212. $cateCondition = ' and cid=' . $cid;
  2213. if (! empty ( $sid )) {
  2214. $staffCondition = ' and staff=' . $sid;
  2215. $cateCondition = "";
  2216. }
  2217. $approvalCondition = " and status=" . $status;
  2218. if ($status == 2) {
  2219. // 查找角色审批人
  2220. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  2221. }
  2222. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  2223. $approvalCondition = ' and status=2 ';
  2224. }
  2225. if ($status == 1) {
  2226. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  2227. }
  2228. if ($status == 8) {
  2229. $approvalCondition = ' and (status=' . $status . ' or status=9) ';
  2230. }
  2231. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  2232. $pageinfo ['page'] = array (
  2233. 'previous' => ''
  2234. );
  2235. if ($status == 0) {
  2236. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  2237. $receiptList = $receipt->find ( array (
  2238. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ')',
  2239. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2240. 'desc' => 'rid',
  2241. 'asArray' => true
  2242. ) );
  2243. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2244. } else
  2245. $receiptList = $receipt->find ( array (
  2246. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
  2247. 'desc' => 'rid',
  2248. 'asArray' => true
  2249. ) );
  2250. $rLRes = $receipt->find ( array (
  2251. '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,
  2252. 'desc' => 'rid',
  2253. 'asArray' => true
  2254. ) );
  2255. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2256. // print_r($pageinfo);
  2257. $Locate = 0;
  2258. foreach ( $receiptList as $key => $value ) {
  2259. $receiptList [$key] ['Locate'] = $Locate;
  2260. $Locate ++;
  2261. $receiptList [$key] ['reviseDetail'] = array ();
  2262. if (! empty ( $value ['reviseDetail'] ))
  2263. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2264. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2265. $categoryDetil = $Lcategory->getOne ( array (
  2266. 'where' => 'cid=' . $value ['cid'],
  2267. 'asArray' => true
  2268. ) );
  2269. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2270. $verifyList = $verify->getOne ( array (
  2271. 'where' => 'vid=' . $value ['verify'],
  2272. 'asArray' => true
  2273. ) );
  2274. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2275. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2276. foreach ( $verifyList as $k => $v ) {
  2277. // init verifyStaff
  2278. $verifyList [$k] ['date'] = "";
  2279. $verifyList [$k] ['opinion'] = "";
  2280. $verifyList [$k] ['status'] = "";
  2281. if (empty ( $verifyStaff )) {
  2282. $verifyList [$k] ['date'] = "";
  2283. $verifyList [$k] ['opinion'] = "";
  2284. if ($v [0] == $this->staff [0] ['sid']) {
  2285. $verifyList [$k] ['status'] = 4;
  2286. $button = 4;
  2287. }
  2288. } else {
  2289. $flag = true;
  2290. foreach ( $verifyStaff as $m => $u ) {
  2291. if ($v [0] == $m) {
  2292. $verifyList [$k] ['date'] = $u ['date'];
  2293. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2294. $verifyList [$k] ['status'] = $u ['status'];
  2295. $flag = false;
  2296. break;
  2297. }
  2298. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  2299. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  2300. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  2301. }
  2302. if ($flag) { // 检测可编辑
  2303. if ($v [0] == $this->staff [0] ['sid']) {
  2304. $verifyList [$k] ['status'] = 4;
  2305. $button = 4;
  2306. }
  2307. }
  2308. }
  2309. }
  2310. $receiptList [$key] ['verifyList'] = $verifyList;
  2311. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2312. 'where' => 'sid=' . $value ['staff'],
  2313. 'asArray' => true
  2314. ) );
  2315. $receiptList [$key] ['button'] = $button;
  2316. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  2317. }
  2318. // print_r($receiptList);die;
  2319. // $data['verifyDetail']=$verifyDetail;
  2320. $mothHtml = "";
  2321. for($i = 1; $i <= 12; $i ++) {
  2322. if ($month == $i)
  2323. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2324. else
  2325. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2326. }
  2327. $data ['mothHtml'] = $mothHtml;
  2328. $data ['page'] = $pageinfo;
  2329. $data ['receiptList'] = $receiptList;
  2330. $data ['receiptApprovalCount'] = count ( $rLRes );
  2331. $data ['status'] = $status;
  2332. $data ['year'] = $year;
  2333. $data ['categoryList'] = $categoryList;
  2334. $data ['staffList'] = $staffList;
  2335. $data ['cid'] = $cid;
  2336. $data ['sid'] = $sid;
  2337. // print_r($receiptList);
  2338. $data ['memu'] = "receipt";
  2339. $data ['staff'] = $this->staff;
  2340. $data ['receiptMemu'] = 'approvalExpenses';
  2341. $data ['verifyId'] = $this->verifyId;
  2342. $data ['executeId'] = $this->executeId;
  2343. $this->render ( "/admin/approvalExpenses", $data );
  2344. }
  2345. function expensesDoc() {
  2346. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2347. Doo::loadModel ( 'receipt' );
  2348. $receipt = new receipt ();
  2349. Doo::loadModel ( 'L_category' );
  2350. $Lcategory = new L_category ();
  2351. Doo::loadModel ( 'verify' );
  2352. Doo::loadModel ( 'statistics' );
  2353. $statistics = new statistics ();
  2354. $verify = new verify ();
  2355. Doo::loadModel ( 'staff' );
  2356. $staff = new staff ();
  2357. Doo::loadModel ( 'loanReceipt' );
  2358. $loanReceipt = new loanReceipt ();
  2359. $receiptList = $receipt->find ( array (
  2360. 'where' => ' rid=' . $rid,
  2361. 'desc' => 'rid',
  2362. 'asArray' => true
  2363. ) );
  2364. $loanList = array ();
  2365. if (! empty ( $receiptList ))
  2366. $loanList = $loanReceipt->find ( array (
  2367. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2368. 'desc' => 'rid',
  2369. 'asArray' => true
  2370. ) );
  2371. $Locate = 0;
  2372. $roleId = 0;
  2373. $button = 0;
  2374. foreach ( $loanList as $key => $value ) {
  2375. $loanList [$key] ['Locate'] = $Locate;
  2376. $Locate ++;
  2377. $loanList [$key] ['reviseDetail'] = array ();
  2378. if (! empty ( $value ['reviseDetail'] ))
  2379. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2380. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2381. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2382. $categoryDetil = $Lcategory->getOne ( array (
  2383. 'where' => 'cid=' . $value ['cid'],
  2384. 'asArray' => true
  2385. ) );
  2386. $loanList [$key] ['category'] = $categoryDetil ['title'];
  2387. // 检测编辑状态
  2388. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  2389. $verifyList ['staff'] = $value ['verifyBreakup'];
  2390. else
  2391. $verifyList = $verify->getOne ( array (
  2392. 'where' => 'vid=' . $value ['verify'],
  2393. 'asArray' => true
  2394. ) );
  2395. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2396. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2397. Doo::loadModel ( 'role' );
  2398. $role = new role ();
  2399. $flag = true;
  2400. $roleKey = 0;
  2401. $endStaffArray = array ();
  2402. $roleArrayCopy = array ();
  2403. foreach ( $verifyList as $k => $v ) {
  2404. // init verifyStaff
  2405. if ($v [1] == 'ROLE') {
  2406. if (! empty ( $verifyStaff )) {
  2407. $endStaffArray = end ( $verifyStaff );
  2408. // if ($v[0]==$endStaffArray['nextStaff']){
  2409. // $roleId=$v[0];
  2410. // }
  2411. }
  2412. $roleVerify = json_decode ( $v [3], true );
  2413. $roleKey = $k;
  2414. $roleArray = array ();
  2415. $rolename = $role->getOne ( array (
  2416. 'where' => 'rid=' . $v [0],
  2417. 'asArray' => true
  2418. ) );
  2419. foreach ( $roleVerify as $o => $p ) {
  2420. $staffID = explode ( '_', $p );
  2421. $staffInfo = $staff->getOne ( array (
  2422. 'where' => 'sid=' . $staffID [0],
  2423. 'asArray' => true
  2424. ) );
  2425. // print_r($staffID);
  2426. $exp = array (
  2427. 0 => $staffInfo ['sid'],
  2428. 1 => $staffID [1],
  2429. 2 => $staffInfo ['avatar'],
  2430. 'date' => '',
  2431. 'date' => '',
  2432. 'opinion' => '',
  2433. 'status' => '',
  2434. 'rolename' => $rolename ['name']
  2435. );
  2436. array_push ( $roleArray, $exp );
  2437. }
  2438. $roleArrayCopy [$v [0]] = $roleArray;
  2439. // $verifyList[$k]['roleArray']=$roleArray;
  2440. }
  2441. $verifyList [$k] ['date'] = "";
  2442. $verifyList [$k] ['opinion'] = "";
  2443. $verifyList [$k] ['status'] = "";
  2444. if (empty ( $verifyStaff )) {
  2445. $verifyList [$k] ['date'] = "";
  2446. $verifyList [$k] ['opinion'] = "";
  2447. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2448. $verifyList [$k] ['status'] = 4;
  2449. $flag = false;
  2450. }
  2451. } else {
  2452. foreach ( $verifyStaff as $m => $u ) {
  2453. if ($v [0] == $m) {
  2454. $verifyList [$k] ['date'] = $u ['date'];
  2455. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2456. $verifyList [$k] ['status'] = $u ['status'];
  2457. $flag = false;
  2458. break;
  2459. }
  2460. }
  2461. $endStaffArray = end ( $verifyStaff );
  2462. if (isset ( $endStaffArray ['ROLE'] )) {
  2463. } else {
  2464. // $endKey=key($verifyStaff);
  2465. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2466. // $button=4;
  2467. // $verifyList[$k]['status']=4;
  2468. // }
  2469. }
  2470. }
  2471. }
  2472. $rolename ['name'] = '';
  2473. if (! empty ( $roleId )) {
  2474. Doo::loadModel ( 'role' );
  2475. $role = new role ();
  2476. $rolename = $role->getOne ( array (
  2477. 'where' => 'rid=' . $roleId,
  2478. 'asArray' => true
  2479. ) );
  2480. }
  2481. if (! empty ( $verifyStaff ))
  2482. $endStaffArray = end ( $verifyStaff );
  2483. $KOP = false;
  2484. foreach ( $roleArrayCopy as $P => $A ) {
  2485. foreach ( $A as $MKI => $AVL ) {
  2486. if (! empty ( $verifyStaff )) {
  2487. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2488. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2489. $button = 4;
  2490. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2491. }
  2492. foreach ( $verifyStaff as $m => $u ) {
  2493. $AVLFK = $AVL [0] . '_R';
  2494. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2495. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2496. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2497. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2498. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2499. break;
  2500. }
  2501. }
  2502. } else {
  2503. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2504. $button = 4;
  2505. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2506. }
  2507. }
  2508. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2509. $KOP = true;
  2510. }
  2511. }
  2512. foreach ( $roleArrayCopy as $k => $v ) {
  2513. foreach ( $verifyList as $m => $n ) {
  2514. if ($n [0] == $k) {
  2515. array_splice ( $verifyList, $m, 1, $v );
  2516. }
  2517. }
  2518. }
  2519. $loanList [$key] ['verifyList'] = $verifyList;
  2520. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  2521. 'where' => 'sid=' . $value ['staff'],
  2522. 'asArray' => true
  2523. ) );
  2524. $loanList [$key] ['button'] = $button;
  2525. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  2526. }
  2527. $data ['loanList'] = $loanList;
  2528. // print_r($loanList);
  2529. $Locate = 0;
  2530. $roleId = 0;
  2531. $button = 0;
  2532. foreach ( $receiptList as $key => $value ) {
  2533. $receiptList [$key] ['Locate'] = $Locate;
  2534. $Locate ++;
  2535. $receiptList [$key] ['reviseDetail'] = array ();
  2536. if (! empty ( $value ['reviseDetail'] ))
  2537. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2538. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2539. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2540. $categoryDetil = $Lcategory->getOne ( array (
  2541. 'where' => 'cid=' . $value ['cid'],
  2542. 'asArray' => true
  2543. ) );
  2544. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2545. // 检测编辑状态
  2546. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  2547. $verifyList ['staff'] = $value ['verifyBreakup'];
  2548. } else
  2549. $verifyList = $verify->getOne ( array (
  2550. 'where' => 'vid=' . $value ['verify'],
  2551. 'asArray' => true
  2552. ) );
  2553. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2554. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2555. Doo::loadModel ( 'role' );
  2556. $role = new role ();
  2557. if ($verifyList == NULL)
  2558. $verifyList = array ();
  2559. $flag = true;
  2560. $roleKey = 0;
  2561. $endStaffArray = array ();
  2562. $roleArrayCopy = array ();
  2563. foreach ( $verifyList as $k => $v ) {
  2564. // init verifyStaff
  2565. if ($v [1] == 'ROLE') {
  2566. if (! empty ( $verifyStaff )) {
  2567. $endStaffArray = end ( $verifyStaff );
  2568. // if ($v[0]==$endStaffArray['nextStaff']){
  2569. // $roleId=$v[0];
  2570. // }
  2571. }
  2572. $roleVerify = json_decode ( $v [3], true );
  2573. $roleKey = $k;
  2574. $roleArray = array ();
  2575. $rolename = $role->getOne ( array (
  2576. 'where' => 'rid=' . $v [0],
  2577. 'asArray' => true
  2578. ) );
  2579. foreach ( $roleVerify as $o => $p ) {
  2580. $staffID = explode ( '_', $p );
  2581. $staffInfo = $staff->getOne ( array (
  2582. 'where' => 'sid=' . $staffID [0],
  2583. 'asArray' => true
  2584. ) );
  2585. // print_r($staffID);
  2586. $exp = array (
  2587. 0 => $staffInfo ['sid'],
  2588. 1 => $staffID [1],
  2589. 2 => $staffInfo ['avatar'],
  2590. 'date' => '',
  2591. 'date' => '',
  2592. 'opinion' => '',
  2593. 'status' => '',
  2594. 'rolename' => $rolename ['name']
  2595. );
  2596. array_push ( $roleArray, $exp );
  2597. }
  2598. $roleArrayCopy [$v [0]] = $roleArray;
  2599. // $verifyList[$k]['roleArray']=$roleArray;
  2600. }
  2601. $verifyList [$k] ['date'] = "";
  2602. $verifyList [$k] ['opinion'] = "";
  2603. $verifyList [$k] ['status'] = "";
  2604. if (empty ( $verifyStaff )) {
  2605. $verifyList [$k] ['date'] = "";
  2606. $verifyList [$k] ['opinion'] = "";
  2607. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2608. $verifyList [$k] ['status'] = 4;
  2609. $flag = false;
  2610. }
  2611. } else {
  2612. foreach ( $verifyStaff as $m => $u ) {
  2613. if ($v [0] == $m) {
  2614. $verifyList [$k] ['date'] = $u ['date'];
  2615. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2616. $verifyList [$k] ['status'] = $u ['status'];
  2617. $flag = false;
  2618. break;
  2619. }
  2620. }
  2621. $endStaffArray = end ( $verifyStaff );
  2622. if (isset ( $endStaffArray ['ROLE'] )) {
  2623. } else {
  2624. // $endKey=key($verifyStaff);
  2625. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2626. // $button=4;
  2627. // $verifyList[$k]['status']=4;
  2628. // }
  2629. }
  2630. }
  2631. }
  2632. $rolename ['name'] = '';
  2633. if (! empty ( $roleId )) {
  2634. Doo::loadModel ( 'role' );
  2635. $role = new role ();
  2636. $rolename = $role->getOne ( array (
  2637. 'where' => 'rid=' . $roleId,
  2638. 'asArray' => true
  2639. ) );
  2640. }
  2641. if (! empty ( $verifyStaff ))
  2642. $endStaffArray = end ( $verifyStaff );
  2643. $KOP = false;
  2644. foreach ( $roleArrayCopy as $P => $A ) {
  2645. foreach ( $A as $MKI => $AVL ) {
  2646. if (! empty ( $verifyStaff )) {
  2647. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2648. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2649. $button = 4;
  2650. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2651. }
  2652. foreach ( $verifyStaff as $m => $u ) {
  2653. $AVLFK = $AVL [0] . '_R';
  2654. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2655. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2656. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2657. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2658. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2659. break;
  2660. }
  2661. }
  2662. } else {
  2663. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2664. $button = 4;
  2665. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2666. }
  2667. }
  2668. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2669. $KOP = true;
  2670. }
  2671. }
  2672. foreach ( $roleArrayCopy as $k => $v ) {
  2673. foreach ( $verifyList as $m => $n ) {
  2674. if ($n [0] == $k) {
  2675. array_splice ( $verifyList, $m, 1, $v );
  2676. }
  2677. }
  2678. }
  2679. // 费用执行人相关数据
  2680. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2681. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2682. foreach ( $executeCopy as $k => $v ) {
  2683. $executeCopy [$k] ['date'] = '';
  2684. $executeCopy [$k] ['opinion'] = '';
  2685. $executeCopy [$k] ['status'] = '';
  2686. if (! empty ( $executeStaff ))
  2687. foreach ( $executeStaff as $m => $u ) {
  2688. if ($v [0] == $m) {
  2689. $executeCopy [$k] ['date'] = $u ['date'];
  2690. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2691. $executeCopy [$k] ['status'] = $u ['status'];
  2692. break;
  2693. }
  2694. }
  2695. }
  2696. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2697. $receiptList [$key] ['verifyList'] = $verifyList;
  2698. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2699. 'where' => 'sid=' . $value ['staff'],
  2700. 'asArray' => true
  2701. ) );
  2702. $receiptList [$key] ['button'] = $button;
  2703. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2704. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2705. }
  2706. // print_r($receiptList);
  2707. // 获取审批日志
  2708. Doo::loadModel ( 'receiptLog' );
  2709. $receiptLog = new receiptLog ();
  2710. $rlList = array ();
  2711. $rlInfo = $receiptLog->getOne ( array (
  2712. 'where' => 'rid=' . $rid . ' and status=4',
  2713. 'asArray' => true
  2714. ) );
  2715. $tijdate = $receiptLog->getOne ( array (
  2716. 'where' => 'rid=' . $rid . ' and status=2',
  2717. 'asc' => 'rlid',
  2718. 'asArray' => true
  2719. ) );
  2720. if (! empty ( $rlInfo )) {
  2721. $rlList = $receiptLog->find ( array (
  2722. 'where' => 'rid=' . $rid,
  2723. 'asc' => 'rlid',
  2724. 'asArray' => true
  2725. ) );
  2726. }
  2727. $receiptList [0] ['rlList'] = $rlList;
  2728. $data ['receiptList'] = $receiptList;
  2729. $data ['memu'] = "receipt";
  2730. $data ['staff'] = $this->staff;
  2731. $data ['receiptMemu'] = 'approvalExpenses';
  2732. $data ['verifyId'] = $this->verifyId;
  2733. $data ['executeId'] = $this->executeId;
  2734. $this->render ( "/admin/expensesDoc", $data );
  2735. }
  2736. function expensesEdi() {
  2737. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2738. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  2739. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2740. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2741. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2742. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2743. if (empty ( $status ))
  2744. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  2745. $vidList = array ();
  2746. $button = 0;
  2747. Doo::loadModel ( 'verify' );
  2748. Doo::loadModel ( 'receipt' );
  2749. Doo::loadModel ( 'staff' );
  2750. $staff = new staff ();
  2751. $receipt = new receipt ();
  2752. $verify = new verify ();
  2753. Doo::loadModel ( 'L_category' );
  2754. $Lcategory = new L_category ();
  2755. Doo::loadModel ( 'enclosur' );
  2756. $enclosur = new enclosur ();
  2757. // user verify ID
  2758. $verifyDetail = $verify->find ( array (
  2759. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  2760. 'asArray' => true
  2761. ) );
  2762. foreach ( $verifyDetail as $key => $value ) {
  2763. array_push ( $vidList, $value ['vid'] );
  2764. }
  2765. $vid = implode ( ",", $vidList );
  2766. if (empty ( $verifyDetail ))
  2767. $vid = 0;
  2768. $categoryList = $Lcategory->find ( array (
  2769. 'asArray' => true
  2770. ) );
  2771. $staffList = $staff->find ( array (
  2772. 'where' => 'cid=' . $cid,
  2773. 'asArray' => true
  2774. ) );
  2775. $ap = "";
  2776. if ($status == 4) {
  2777. $ap = 4;
  2778. $status = 2;
  2779. }
  2780. // get Receipt By verifyID status 2
  2781. $receiptList = $receipt->find ( array (
  2782. 'where' => 'rid =' . $rid,
  2783. 'desc' => 'rid',
  2784. 'asArray' => true
  2785. ) );
  2786. $Locate = 0;
  2787. $roleId = 0;
  2788. if ($ap == 4)
  2789. $status = 4;
  2790. foreach ( $receiptList as $key => $value ) {
  2791. $receiptList [$key] ['Locate'] = $Locate;
  2792. $Locate ++;
  2793. $receiptList [$key] ['reviseDetail'] = array ();
  2794. if (! empty ( $value ['reviseDetail'] ))
  2795. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2796. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2797. $categoryDetil = $Lcategory->getOne ( array (
  2798. 'where' => 'cid=' . $value ['cid'],
  2799. 'asArray' => true
  2800. ) );
  2801. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2802. // 检测编辑状态
  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. // print_r($verifyList);
  2812. $flag = true;
  2813. $roleKey = 0;
  2814. $endStaffArray = array ();
  2815. $roleArrayCopy = array ();
  2816. foreach ( $verifyList as $k => $v ) {
  2817. // init verifyStaff
  2818. if ($v [1] == 'ROLE') {
  2819. if (! empty ( $verifyStaff )) {
  2820. $endStaffArray = end ( $verifyStaff );
  2821. if ($v [0] == $endStaffArray ['nextStaff']) {
  2822. $roleId = $v [0];
  2823. }
  2824. }
  2825. $roleVerify = json_decode ( $v [3], true );
  2826. $roleKey = $k;
  2827. $roleArray = array ();
  2828. $rolename = $role->getOne ( array (
  2829. 'where' => 'rid=' . $v [0],
  2830. 'asArray' => true
  2831. ) );
  2832. foreach ( $roleVerify as $o => $p ) {
  2833. $staffID = explode ( '_', $p );
  2834. $staffInfo = $staff->getOne ( array (
  2835. 'where' => 'sid=' . $staffID [0],
  2836. 'asArray' => true
  2837. ) );
  2838. // print_r($staffID);
  2839. $exp = array (
  2840. 0 => $staffInfo ['sid'],
  2841. 1 => $staffID [1],
  2842. 2 => $staffInfo ['avatar'],
  2843. 'date' => '',
  2844. 'date' => '',
  2845. 'opinion' => '',
  2846. 'status' => '',
  2847. 'rolename' => $rolename ['name']
  2848. );
  2849. array_push ( $roleArray, $exp );
  2850. }
  2851. $roleArrayCopy [$v [0]] = $roleArray;
  2852. // $verifyList[$k]['roleArray']=$roleArray;
  2853. }
  2854. // print_r($roleArray);
  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. $button = 4;
  2864. $flag = false;
  2865. }
  2866. } else {
  2867. foreach ( $verifyStaff as $m => $u ) {
  2868. if ($v [0] == $m) {
  2869. $verifyList [$k] ['date'] = $u ['date'];
  2870. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2871. $verifyList [$k] ['status'] = $u ['status'];
  2872. $flag = false;
  2873. break;
  2874. }
  2875. }
  2876. $endStaffArray = end ( $verifyStaff );
  2877. if (isset ( $endStaffArray ['ROLE'] )) {
  2878. } else {
  2879. $endKey = key ( $verifyStaff );
  2880. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  2881. $button = 4;
  2882. $verifyList [$k] ['status'] = 4;
  2883. }
  2884. }
  2885. }
  2886. }
  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. // print_r($roleArrayCopy);
  2928. // echo $roleKey;
  2929. foreach ( $roleArrayCopy as $k => $v ) {
  2930. foreach ( $verifyList as $m => $n ) {
  2931. if ($n [0] == $k) {
  2932. array_splice ( $verifyList, $m, 1, $v );
  2933. }
  2934. }
  2935. }
  2936. $receiptList [$key] ['verifyList'] = $verifyList;
  2937. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2938. 'where' => 'sid=' . $value ['staff'],
  2939. 'asArray' => true
  2940. ) );
  2941. $receiptList [$key] ['button'] = $button;
  2942. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  2943. }
  2944. // $data['verifyDetail']=$verifyDetail;
  2945. $mothHtml = "";
  2946. for($i = 1; $i <= 12; $i ++) {
  2947. if ($month == $i)
  2948. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2949. else
  2950. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2951. }
  2952. // 获取审批日志
  2953. Doo::loadModel ( 'receiptLog' );
  2954. $receiptLog = new receiptLog ();
  2955. $rlList = array ();
  2956. $rlInfo = $receiptLog->getOne ( array (
  2957. 'where' => 'rid=' . $rid . ' and status=4',
  2958. 'asArray' => true
  2959. ) );
  2960. $tijdate = $receiptLog->getOne ( array (
  2961. 'where' => 'rid=' . $rid . ' and status=2',
  2962. 'asc' => 'rlid',
  2963. 'asArray' => true
  2964. ) );
  2965. if (! empty ( $rlInfo )) {
  2966. $rlList = $receiptLog->find ( array (
  2967. 'where' => 'rid=' . $rid,
  2968. 'asc' => 'rlid',
  2969. 'asArray' => true
  2970. ) );
  2971. }
  2972. $receiptList [0] ['rlList'] = $rlList;
  2973. $enclosurList = $enclosur->find ( array (
  2974. 'where' => 'rid=' . $rid,
  2975. 'asArray' => true
  2976. ) );
  2977. $enclosurHtml = '';
  2978. foreach ( $enclosurList as $value ) {
  2979. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2980. }
  2981. // print_r($receiptList);
  2982. $data ['rid'] = $rid;
  2983. $data ['enclosurHtml'] = $enclosurHtml;
  2984. $data ['rolename'] = $rolename ['name'];
  2985. $data ['datetij'] = $tijdate ['date'];
  2986. $data ['mothHtml'] = $mothHtml;
  2987. $data ['receiptList'] = $receiptList;
  2988. $data ['receiptApprovalCount'] = count ( $receiptList );
  2989. $data ['status'] = $status;
  2990. $data ['year'] = $year;
  2991. $data ['categoryList'] = $categoryList;
  2992. $data ['staffList'] = $staffList;
  2993. $data ['cid'] = $cid;
  2994. $data ['sid'] = $sid;
  2995. $data ['ap'] = $ap;
  2996. $data ['memu'] = "receipt";
  2997. $data ['staff'] = $this->staff;
  2998. $data ['receiptMemu'] = 'approvalExpenses';
  2999. $data ['verifyId'] = $this->verifyId;
  3000. $data ['executeId'] = $this->executeId;
  3001. $this->render ( "/admin/expensesEdi", $data );
  3002. }
  3003. function expensesDefray() {
  3004. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3005. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3006. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3007. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  3008. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  3009. if (! empty ( $rid )) {
  3010. Doo::loadModel ( "verify" );
  3011. $verify = new verify ();
  3012. Doo::loadModel ( "receiptDetail" );
  3013. $receiptDetailObj = new receiptDetail ();
  3014. Doo::loadModel ( "itemStatistics" );
  3015. Doo::loadModel ( "statistics" );
  3016. $statistics = new statistics ();
  3017. $itemStatistics = new itemStatistics ();
  3018. Doo::loadModel ( "receipt" );
  3019. $receipt = new receipt ();
  3020. Doo::loadModel ( "loanReceipt" );
  3021. $loanReceipt = new loanReceipt ();
  3022. $receiptDetail = $receipt->getOne ( array (
  3023. 'where' => 'rid=' . $rid . ' and status=2 ',
  3024. 'asArray' => true
  3025. ) );
  3026. if (empty ( $receiptDetail ))
  3027. return "/approval";
  3028. $verifyDetail = $verify->getOne ( array (
  3029. 'where' => ' vid =' . $receiptDetail ['verify'],
  3030. 'asArray' => true
  3031. ) );
  3032. $verifyString = $verifyDetail ['staff'];
  3033. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3034. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  3035. if (empty ( $opinion )) {
  3036. if ($status == 3)
  3037. $opinion = "终止";
  3038. else
  3039. $opinion = "同意支付";
  3040. }
  3041. $nowStaff = 0;
  3042. $nowStaffList = array ();
  3043. if (empty ( $verifyStaff )) {
  3044. // 还需加入是否已经进入角色审批
  3045. if ($verifyDetail [0] [1] == 'ROLE') {
  3046. // print_r($verifyDetail);echo "ddd";
  3047. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3048. foreach ( $vStaffString as $key => $value ) {
  3049. $staffK = explode ( "_", $value );
  3050. if ($staffK [0] != $this->staff [0] ['sid'])
  3051. array_push ( $nowStaffList, $staffK [0] );
  3052. }
  3053. // print_r($verifyDetail);
  3054. // die;
  3055. if (! empty ( $nowStaffList )) {
  3056. $nowStaff = implode ( ',', $nowStaffList );
  3057. $verifyStaff = array (
  3058. $this->staff [0] ['sid'] . "_R" => array (
  3059. 'date' => date ( 'Y-m-d' ),
  3060. 'opinion' => $opinion,
  3061. 'status' => $status,
  3062. 'nextStaff' => $verifyDetail [0] [0],
  3063. 'ROLE' => 1
  3064. )
  3065. );
  3066. } else {
  3067. $nowStaff = $verifyDetail [1] [0];
  3068. $verifyStaff = array (
  3069. $this->staff [0] ['sid'] . "_R" => array (
  3070. 'date' => date ( 'Y-m-d' ),
  3071. 'opinion' => $opinion,
  3072. 'status' => $status,
  3073. 'nextStaff' => $verifyDetail [1] [0]
  3074. )
  3075. );
  3076. }
  3077. } else {
  3078. if ($verifyDetail [1] [1] == 'ROLE') {
  3079. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  3080. // echo "dd";
  3081. foreach ( $vStaffString as $key => $value ) {
  3082. $staffK = explode ( "_", $value );
  3083. array_push ( $nowStaffList, $staffK [0] );
  3084. }
  3085. $nowStaff = implode ( ',', $nowStaffList );
  3086. $verifyStaff = array (
  3087. $this->staff [0] ['sid'] => array (
  3088. 'date' => date ( 'Y-m-d' ),
  3089. 'opinion' => $opinion,
  3090. 'status' => $status,
  3091. 'nextStaff' => $verifyDetail [1] [0],
  3092. 'ROLE' => 1
  3093. )
  3094. );
  3095. } else {
  3096. $nowStaff = $verifyDetail [1] [0];
  3097. $verifyStaff = array (
  3098. $this->staff [0] ['sid'] => array (
  3099. 'date' => date ( 'Y-m-d' ),
  3100. 'opinion' => $opinion,
  3101. 'status' => $status,
  3102. 'nextStaff' => $verifyDetail [1] [0]
  3103. )
  3104. );
  3105. }
  3106. }
  3107. if ($status == 3)
  3108. $verifyStaff = array (
  3109. 'final' => $status,
  3110. $this->staff [0] ['sid'] => array (
  3111. 'date' => date ( 'Y-m-d' ),
  3112. 'opinion' => $opinion,
  3113. 'status' => $status
  3114. )
  3115. );
  3116. $vStaffString = json_encode ( $verifyStaff );
  3117. $receipt->nowStaff = $nowStaff;
  3118. $receipt->verifyStaff = $vStaffString;
  3119. $loanReceipt->nowStaff = $nowStaff;
  3120. $loanReceipt->verifyStaff = $vStaffString;
  3121. } else {
  3122. $VS = end ( $verifyStaff );
  3123. // 非角色审批
  3124. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  3125. $nextStaff = 0;
  3126. $roleSTF = false;
  3127. foreach ( $verifyDetail as $key => $value ) {
  3128. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  3129. if (isset ( $verifyDetail [$key + 1] )) {
  3130. $nextStaff = $verifyDetail [$key + 1] [0];
  3131. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  3132. $roleSTF = true;
  3133. }
  3134. break;
  3135. }
  3136. }
  3137. if (! $roleSTF) {
  3138. $nowStaff = $nextStaff;
  3139. $verifyStaff [$this->staff [0] ['sid']] = array (
  3140. 'date' => date ( 'Y-m-d' ),
  3141. 'opinion' => $opinion,
  3142. 'status' => $status,
  3143. 'nextStaff' => $nextStaff
  3144. );
  3145. } else {
  3146. // 获取角色下的所有用户ID
  3147. $nowStaffList = array ();
  3148. foreach ( $verifyDetail as $vfk ) {
  3149. if ($vfk [1] == 'ROLE') {
  3150. $vStaffString = json_decode ( $vfk [3] );
  3151. foreach ( $vStaffString as $key => $value ) {
  3152. $staffK = explode ( "_", $value );
  3153. array_push ( $nowStaffList, $staffK [0] );
  3154. }
  3155. }
  3156. }
  3157. $nowStaff = implode ( ',', $nowStaffList );
  3158. $verifyStaff [$this->staff [0] ['sid']] = array (
  3159. 'date' => date ( 'Y-m-d' ),
  3160. 'opinion' => $opinion,
  3161. 'status' => $status,
  3162. 'nextStaff' => $nextStaff,
  3163. 'ROLE' => 0
  3164. );
  3165. }
  3166. if ($status == 3) {
  3167. $verifyStaff ['final'] = $status;
  3168. $verifyStaff [$this->staff [0] ['sid']] = array (
  3169. 'date' => date ( 'Y-m-d' ),
  3170. 'opinion' => $opinion,
  3171. 'status' => $status
  3172. );
  3173. }
  3174. $vStaffString = json_encode ( $verifyStaff );
  3175. $receipt->nowStaff = $nowStaff;
  3176. $receipt->verifyStaff = $vStaffString;
  3177. $loanReceipt->nowStaff = $nowStaff;
  3178. $loanReceipt->verifyStaff = $vStaffString;
  3179. }
  3180. // 角色审批
  3181. if (isset ( $VS ['ROLE'] )) {
  3182. // 找出角色人 当前审批角色组
  3183. $verifyJSStaff = array ();
  3184. $nowStaffList2 = array ();
  3185. foreach ( $verifyDetail as $key => $value ) {
  3186. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  3187. $verifyJSStaff = json_decode ( $value [3] );
  3188. foreach ( $verifyJSStaff as $m ) {
  3189. $staffK = explode ( "_", $m );
  3190. array_push ( $nowStaffList2, $staffK [0] );
  3191. }
  3192. // print_r($nowStaffList2);
  3193. }
  3194. }
  3195. $RoleVerifyStaff = array ();
  3196. foreach ( $verifyStaff as $key => $value ) {
  3197. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  3198. foreach ( $nowStaffList2 as $m ) {
  3199. if ($key == $m . "_R")
  3200. $RoleVerifyStaff [$key] = $value;
  3201. }
  3202. }
  3203. }
  3204. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  3205. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  3206. // 下一个审批人ID
  3207. $nextStaff = 0;
  3208. $falg = false;
  3209. foreach ( $verifyDetail as $key => $value ) {
  3210. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  3211. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  3212. $falg = true;
  3213. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  3214. $nowStaffList = array ();
  3215. foreach ( $vStaffString as $v ) {
  3216. $staffK = explode ( "_", $v );
  3217. array_push ( $nowStaffList, $staffK [0] );
  3218. }
  3219. $nowStaff = implode ( ',', $nowStaffList );
  3220. $nextStaff = $verifyDetail [$key + 1] [0];
  3221. } elseif (isset ( $verifyDetail [$key + 1] )) {
  3222. $nextStaff = $verifyDetail [$key + 1] [0];
  3223. $nowStaff = $nextStaff;
  3224. } else
  3225. $nowStaff = '';
  3226. break;
  3227. }
  3228. }
  3229. if ($falg)
  3230. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3231. 'date' => date ( 'Y-m-d' ),
  3232. 'opinion' => $opinion,
  3233. 'status' => $status,
  3234. 'nextStaff' => $nextStaff,
  3235. 'ROLE' => 1
  3236. );
  3237. else
  3238. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3239. 'date' => date ( 'Y-m-d' ),
  3240. 'opinion' => $opinion,
  3241. 'status' => $status,
  3242. 'nextStaff' => $nextStaff
  3243. );
  3244. // print_r($verifyStaff);
  3245. // echo $nowStaff;die;
  3246. } else { // 进入下一个角色或者审批人
  3247. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  3248. //
  3249. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  3250. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3251. 'date' => date ( 'Y-m-d' ),
  3252. 'opinion' => $opinion,
  3253. 'status' => $status,
  3254. 'nextStaff' => $VS ['nextStaff'],
  3255. 'ROLE' => 1
  3256. );
  3257. // print_r($verifyStaff);
  3258. // die;
  3259. }
  3260. if ($status == 3) {
  3261. $verifyStaff ['final'] = $status;
  3262. $verifyStaff [$this->staff [0] ['sid']] = array (
  3263. 'date' => date ( 'Y-m-d' ),
  3264. 'opinion' => $opinion,
  3265. 'status' => $status
  3266. );
  3267. }
  3268. $vStaffString = json_encode ( $verifyStaff );
  3269. $receipt->verifyStaff = $vStaffString;
  3270. $receipt->nowStaff = $nowStaff;
  3271. $loanReceipt->nowStaff = $nowStaff;
  3272. $loanReceipt->verifyStaff = $vStaffString;
  3273. // die;
  3274. // }
  3275. // print_r($verifyStaff);
  3276. // die;
  3277. }
  3278. // print_r($verifyStaff);die;
  3279. }
  3280. // print_r($verifyDetail);
  3281. $roleKey = 0;
  3282. $roleId = 0;
  3283. $verifyDetailCopy = array ();
  3284. foreach ( $verifyDetail as $k => $v ) {
  3285. if ($v [1] == 'ROLE') {
  3286. $roleId = $v [0];
  3287. $roleVerify = json_decode ( $v [3], true );
  3288. $roleKey = $k;
  3289. $roleArray = array ();
  3290. foreach ( $roleVerify as $o => $p ) {
  3291. $staffID = explode ( '_', $p );
  3292. $exp = array (
  3293. 0 => $staffID [0],
  3294. 1 => $staffID [1]
  3295. );
  3296. array_push ( $roleArray, $exp );
  3297. }
  3298. $verifyDetailCopy [$v [0]] = $roleArray;
  3299. }
  3300. }
  3301. // print_r($verifyDetail);
  3302. foreach ( $verifyDetailCopy as $k => $v ) {
  3303. foreach ( $verifyDetail as $m => $n ) {
  3304. if ($n [0] == $k) {
  3305. array_splice ( $verifyDetail, $m, 1, $v );
  3306. }
  3307. }
  3308. }
  3309. // 审批日志
  3310. if (! isset ( $verifyStaff ['final'] )) {
  3311. Doo::loadModel ( "receiptLog" );
  3312. $receiptLog = new receiptLog ();
  3313. if (! empty ( $roleId )) {
  3314. Doo::loadModel ( "role" );
  3315. $role = new role ();
  3316. $roleInfo = $role->getOne ( array (
  3317. 'where' => 'rid=' . $roleId,
  3318. 'asArray' => true
  3319. ) );
  3320. $receiptLog->rolename = $roleInfo ['name'];
  3321. }
  3322. $receiptLog->username = $this->staff [0] ['username'];
  3323. $receiptLog->uid = $this->staff [0] ['sid'];
  3324. $receiptLog->date = date ( "Y-m-d" );
  3325. $receiptLog->opinion = $opinion;
  3326. $receiptLog->img = $this->staff [0] ['avatar'];
  3327. $receiptLog->status = 1;
  3328. $receiptLog->rid = $rid;
  3329. $receiptLog->insert ();
  3330. }
  3331. if (isset ( $verifyStaff ['final'] )) { // rDetail
  3332. $receipt->status = 3;
  3333. $receipt->verifyBreakup = $verifyString;
  3334. $receiptDetailObj->status = 3;
  3335. $receiptDetailObj->update ( array (
  3336. 'where' => 'rid=' . $rid
  3337. ) );
  3338. // 微信企业号通知
  3339. $this->setWXMsg ( $rid, 3 );
  3340. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  3341. $receipt->status = 6;
  3342. $receipt->pastDate = date ( "Y-m-d" );
  3343. $receipt->isBK = 1;
  3344. $loanReceipt->verifyBreakup = $verifyString;
  3345. $loanReceipt->status = 1;
  3346. $loanReceipt->pastDate = date ( "Y-m-d" );
  3347. $loanReceipt->update ( array (
  3348. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  3349. ) );
  3350. // 微信企业号通知
  3351. $this->setWXMsg ( $rid, 1 );
  3352. }
  3353. $receipt->amount = $amount;
  3354. $receipt->update ( array (
  3355. 'where' => ' rid = ' . $rid
  3356. ) );
  3357. return "/approvalExpenses/2";
  3358. }
  3359. }
  3360. function ajaxExamineExe() {
  3361. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3362. Doo::loadModel ( 'receipt' );
  3363. $receipt = new receipt ();
  3364. Doo::loadClass ( 'XDeode' );
  3365. $XDeode = new XDeode ( 5 );
  3366. if (! empty ( $rid )) {
  3367. $rLRes = $receipt->find ( array (
  3368. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  3369. 'asArray' => true
  3370. ) );
  3371. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  3372. echo json_encode ( array (
  3373. 'status' => 1,
  3374. 'receipt' => $rLRes [0]
  3375. ) );
  3376. die ();
  3377. }
  3378. echo json_encode ( array (
  3379. 'status' => 0,
  3380. 'receipt' => array ()
  3381. ) );
  3382. die ();
  3383. }
  3384. function implement() {
  3385. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3386. Doo::loadClass ( 'XDeode' );
  3387. $XDeode = new XDeode ( 5 );
  3388. Doo::loadModel ( 'receipt' );
  3389. $receipt = new receipt ();
  3390. Doo::loadModel ( 'L_category' );
  3391. $Lcategory = new L_category ();
  3392. Doo::loadModel ( 'verify' );
  3393. $verify = new verify ();
  3394. Doo::loadModel ( 'staff' );
  3395. $staff = new staff ();
  3396. Doo::loadModel ( "execute" );
  3397. $execute = new execute ();
  3398. $rid = $XDeode->decode ( $rid );
  3399. $receiptList = $receipt->find ( array (
  3400. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  3401. 'desc' => 'rid',
  3402. 'asArray' => true
  3403. ) );
  3404. Doo::loadModel ( 'loanReceipt' );
  3405. $loanReceipt = new loanReceipt ();
  3406. // print_r($receiptList);
  3407. $loanList = array ();
  3408. if (! isset ( $receiptList ))
  3409. $loanList = $loanReceipt->find ( array (
  3410. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3411. 'desc' => 'rid',
  3412. 'asArray' => true
  3413. ) );
  3414. $Locate = 0;
  3415. $roleId = 0;
  3416. $button = 0;
  3417. foreach ( $loanList as $key => $value ) {
  3418. $loanList [$key] ['Locate'] = $Locate;
  3419. $Locate ++;
  3420. $loanList [$key] ['reviseDetail'] = array ();
  3421. if (! empty ( $value ['reviseDetail'] ))
  3422. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3423. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3424. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3425. $categoryDetil = $Lcategory->getOne ( array (
  3426. 'where' => 'cid=' . $value ['cid'],
  3427. 'asArray' => true
  3428. ) );
  3429. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3430. // 检测编辑状态
  3431. $verifyList = $verify->getOne ( array (
  3432. 'where' => 'vid=' . $value ['verify'],
  3433. 'asArray' => true
  3434. ) );
  3435. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3436. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3437. Doo::loadModel ( 'role' );
  3438. $role = new role ();
  3439. $flag = true;
  3440. $roleKey = 0;
  3441. $endStaffArray = array ();
  3442. $roleArrayCopy = array ();
  3443. foreach ( $verifyList as $k => $v ) {
  3444. // init verifyStaff
  3445. if ($v [1] == 'ROLE') {
  3446. if (! empty ( $verifyStaff )) {
  3447. $endStaffArray = end ( $verifyStaff );
  3448. // if ($v[0]==$endStaffArray['nextStaff']){
  3449. // $roleId=$v[0];
  3450. // }
  3451. }
  3452. $roleVerify = json_decode ( $v [3], true );
  3453. $roleKey = $k;
  3454. $roleArray = array ();
  3455. $rolename = $role->getOne ( array (
  3456. 'where' => 'rid=' . $v [0],
  3457. 'asArray' => true
  3458. ) );
  3459. foreach ( $roleVerify as $o => $p ) {
  3460. $staffID = explode ( '_', $p );
  3461. $staffInfo = $staff->getOne ( array (
  3462. 'where' => 'sid=' . $staffID [0],
  3463. 'asArray' => true
  3464. ) );
  3465. // print_r($staffID);
  3466. $exp = array (
  3467. 0 => $staffInfo ['sid'],
  3468. 1 => $staffID [1],
  3469. 2 => $staffInfo ['avatar'],
  3470. 'date' => '',
  3471. 'date' => '',
  3472. 'opinion' => '',
  3473. 'status' => '',
  3474. 'rolename' => $rolename ['name']
  3475. );
  3476. array_push ( $roleArray, $exp );
  3477. }
  3478. $roleArrayCopy [$v [0]] = $roleArray;
  3479. // $verifyList[$k]['roleArray']=$roleArray;
  3480. }
  3481. $verifyList [$k] ['date'] = "";
  3482. $verifyList [$k] ['opinion'] = "";
  3483. $verifyList [$k] ['status'] = "";
  3484. if (empty ( $verifyStaff )) {
  3485. $verifyList [$k] ['date'] = "";
  3486. $verifyList [$k] ['opinion'] = "";
  3487. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3488. $verifyList [$k] ['status'] = 4;
  3489. $flag = false;
  3490. }
  3491. } else {
  3492. foreach ( $verifyStaff as $m => $u ) {
  3493. if ($v [0] == $m) {
  3494. $verifyList [$k] ['date'] = $u ['date'];
  3495. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3496. $verifyList [$k] ['status'] = $u ['status'];
  3497. $flag = false;
  3498. break;
  3499. }
  3500. }
  3501. $endStaffArray = end ( $verifyStaff );
  3502. if (isset ( $endStaffArray ['ROLE'] )) {
  3503. } else {
  3504. // $endKey=key($verifyStaff);
  3505. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3506. // $button=4;
  3507. // $verifyList[$k]['status']=4;
  3508. // }
  3509. }
  3510. }
  3511. }
  3512. $rolename ['name'] = '';
  3513. if (! empty ( $roleId )) {
  3514. Doo::loadModel ( 'role' );
  3515. $role = new role ();
  3516. $rolename = $role->getOne ( array (
  3517. 'where' => 'rid=' . $roleId,
  3518. 'asArray' => true
  3519. ) );
  3520. }
  3521. if (! empty ( $verifyStaff ))
  3522. $endStaffArray = end ( $verifyStaff );
  3523. $KOP = false;
  3524. foreach ( $roleArrayCopy as $P => $A ) {
  3525. foreach ( $A as $MKI => $AVL ) {
  3526. if (! empty ( $verifyStaff )) {
  3527. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3528. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3529. $button = 4;
  3530. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3531. }
  3532. foreach ( $verifyStaff as $m => $u ) {
  3533. $AVLFK = $AVL [0] . '_R';
  3534. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3535. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3536. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3537. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3538. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3539. break;
  3540. }
  3541. }
  3542. } else {
  3543. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3544. $button = 4;
  3545. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3546. }
  3547. }
  3548. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3549. $KOP = true;
  3550. }
  3551. }
  3552. foreach ( $roleArrayCopy as $k => $v ) {
  3553. foreach ( $verifyList as $m => $n ) {
  3554. if ($n [0] == $k) {
  3555. array_splice ( $verifyList, $m, 1, $v );
  3556. }
  3557. }
  3558. }
  3559. $loanList [$key] ['verifyList'] = $verifyList;
  3560. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3561. 'where' => 'sid=' . $value ['staff'],
  3562. 'asArray' => true
  3563. ) );
  3564. }
  3565. $data ['loanList'] = $loanList;
  3566. $Locate = 0;
  3567. $roleId = 0;
  3568. $button = 0;
  3569. foreach ( $receiptList as $key => $value ) {
  3570. $button2 = 0;
  3571. $receiptList [$key] ['Locate'] = $Locate;
  3572. $Locate ++;
  3573. $receiptList [$key] ['reviseDetail'] = array ();
  3574. if (! empty ( $value ['reviseDetail'] ))
  3575. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3576. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3577. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3578. $categoryDetil = $Lcategory->getOne ( array (
  3579. 'where' => 'cid=' . $value ['cid'],
  3580. 'asArray' => true
  3581. ) );
  3582. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3583. $executeList = json_decode ( $value ['executeCopy'], true );
  3584. $executeStaff = array ();
  3585. if (! empty ( $value ['executeStaff'] ))
  3586. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3587. if (isset ( $executeList )) {
  3588. foreach ( $executeList as $op => $lo ) {
  3589. $executeList [$op] ['date'] = "";
  3590. $executeList [$op] ['opinion'] = "";
  3591. $executeList [$op] ['status'] = "";
  3592. foreach ( $executeStaff as $m => $u ) {
  3593. if ($lo [0] == $m) {
  3594. $executeList [$op] ['date'] = $u ['date'];
  3595. $executeList [$op] ['opinion'] = $u ['opinion'];
  3596. $executeList [$op] ['status'] = $u ['status'];
  3597. break;
  3598. }
  3599. }
  3600. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  3601. $button2 = 1;
  3602. $executeList [$op] ['status'] = 4;
  3603. }
  3604. }
  3605. }
  3606. // 检测编辑状态
  3607. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3608. $verifyList ['staff'] = $value ['verifyBreakup'];
  3609. } else
  3610. $verifyList = $verify->getOne ( array (
  3611. 'where' => 'vid=' . $value ['verify'],
  3612. 'asArray' => true
  3613. ) );
  3614. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3615. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3616. Doo::loadModel ( 'role' );
  3617. $role = new role ();
  3618. if ($verifyList == NULL)
  3619. $verifyList = array ();
  3620. $flag = true;
  3621. $roleKey = 0;
  3622. $endStaffArray = array ();
  3623. $roleArrayCopy = array ();
  3624. foreach ( $verifyList as $k => $v ) {
  3625. // init verifyStaff
  3626. if ($v [1] == 'ROLE') {
  3627. if (! empty ( $verifyStaff )) {
  3628. $endStaffArray = end ( $verifyStaff );
  3629. // if ($v[0]==$endStaffArray['nextStaff']){
  3630. // $roleId=$v[0];
  3631. // }
  3632. }
  3633. $roleVerify = json_decode ( $v [3], true );
  3634. $roleKey = $k;
  3635. $roleArray = array ();
  3636. $rolename = $role->getOne ( array (
  3637. 'where' => 'rid=' . $v [0],
  3638. 'asArray' => true
  3639. ) );
  3640. foreach ( $roleVerify as $o => $p ) {
  3641. $staffID = explode ( '_', $p );
  3642. $staffInfo = $staff->getOne ( array (
  3643. 'where' => 'sid=' . $staffID [0],
  3644. 'asArray' => true
  3645. ) );
  3646. // print_r($staffID);
  3647. $exp = array (
  3648. 0 => $staffInfo ['sid'],
  3649. 1 => $staffID [1],
  3650. 2 => $staffInfo ['avatar'],
  3651. 'date' => '',
  3652. 'date' => '',
  3653. 'opinion' => '',
  3654. 'status' => '',
  3655. 'rolename' => $rolename ['name']
  3656. );
  3657. array_push ( $roleArray, $exp );
  3658. }
  3659. $roleArrayCopy [$v [0]] = $roleArray;
  3660. // $verifyList[$k]['roleArray']=$roleArray;
  3661. }
  3662. $verifyList [$k] ['date'] = "";
  3663. $verifyList [$k] ['opinion'] = "";
  3664. $verifyList [$k] ['status'] = "";
  3665. if (empty ( $verifyStaff )) {
  3666. $verifyList [$k] ['date'] = "";
  3667. $verifyList [$k] ['opinion'] = "";
  3668. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3669. $verifyList [$k] ['status'] = 4;
  3670. $flag = false;
  3671. }
  3672. } else {
  3673. foreach ( $verifyStaff as $m => $u ) {
  3674. if ($v [0] == $m) {
  3675. $verifyList [$k] ['date'] = $u ['date'];
  3676. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3677. $verifyList [$k] ['status'] = $u ['status'];
  3678. $flag = false;
  3679. break;
  3680. }
  3681. }
  3682. $endStaffArray = end ( $verifyStaff );
  3683. if (isset ( $endStaffArray ['ROLE'] )) {
  3684. } else {
  3685. // $endKey=key($verifyStaff);
  3686. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3687. // $button=4;
  3688. // $verifyList[$k]['status']=4;
  3689. // }
  3690. }
  3691. }
  3692. }
  3693. $rolename ['name'] = '';
  3694. if (! empty ( $roleId )) {
  3695. Doo::loadModel ( 'role' );
  3696. $role = new role ();
  3697. $rolename = $role->getOne ( array (
  3698. 'where' => 'rid=' . $roleId,
  3699. 'asArray' => true
  3700. ) );
  3701. }
  3702. if (! empty ( $verifyStaff ))
  3703. $endStaffArray = end ( $verifyStaff );
  3704. $KOP = false;
  3705. foreach ( $roleArrayCopy as $P => $A ) {
  3706. foreach ( $A as $MKI => $AVL ) {
  3707. if (! empty ( $verifyStaff )) {
  3708. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3709. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3710. $button = 4;
  3711. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3712. }
  3713. foreach ( $verifyStaff as $m => $u ) {
  3714. $AVLFK = $AVL [0] . '_R';
  3715. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3716. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3717. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3718. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3719. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3720. break;
  3721. }
  3722. }
  3723. } else {
  3724. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3725. $button = 4;
  3726. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3727. }
  3728. }
  3729. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3730. $KOP = true;
  3731. }
  3732. }
  3733. foreach ( $roleArrayCopy as $k => $v ) {
  3734. foreach ( $verifyList as $m => $n ) {
  3735. if ($n [0] == $k) {
  3736. array_splice ( $verifyList, $m, 1, $v );
  3737. }
  3738. }
  3739. }
  3740. $receiptList [$key] ['verifyList'] = $verifyList;
  3741. $receiptList [$key] ['executeList'] = $executeList;
  3742. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3743. 'where' => 'sid=' . $value ['staff'],
  3744. 'asArray' => true
  3745. ) );
  3746. $receiptList [$key] ['button2'] = $button2;
  3747. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3748. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3749. $relust = $value ['sum'] - $value ['loanSum'];
  3750. $receiptList [$key] ['relust'] = $relust;
  3751. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  3752. }
  3753. // print_r($receiptList[$key]['executeList']);
  3754. $data ['receiptList'] = $receiptList;
  3755. $data ['memu'] = "receipt";
  3756. $data ['staff'] = $this->staff;
  3757. $data ['receiptMemu'] = 'implement';
  3758. $data ['verifyId'] = $this->verifyId;
  3759. $data ['executeId'] = $this->executeId;
  3760. $this->render ( "/admin/implement", $data );
  3761. }
  3762. function implementDo() {
  3763. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3764. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3765. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  3766. if (! empty ( $rid ) && ! empty ( $amount )) {
  3767. Doo::loadModel ( 'receipt' );
  3768. $receipt = new receipt ();
  3769. Doo::loadClass ( 'XDeode' );
  3770. $XDeode = new XDeode ( 5 );
  3771. $rinfo = $receipt->getOne ( array (
  3772. 'where' => 'rid=' . $rid,
  3773. 'asArray' => true
  3774. ) );
  3775. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  3776. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  3777. if (empty ( $executeStaff )) {
  3778. $executeStaff = array (
  3779. $this->staff [0] ['sid'] => array (
  3780. 'date' => date ( 'Y-m-d' ),
  3781. 'opinion' => $implementOpinions,
  3782. 'status' => 1
  3783. )
  3784. );
  3785. } else {
  3786. $executeStaff [$this->staff [0] ['sid']] = array (
  3787. 'date' => date ( 'Y-m-d' ),
  3788. 'opinion' => $implementOpinions,
  3789. 'status' => 1
  3790. );
  3791. }
  3792. if (count ( $executeStaff ) == count ( $executeCopy )) {
  3793. $receipt->executeStaff = json_encode ( $executeStaff );
  3794. $receipt->status = 8;
  3795. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  3796. $receipt->status = 9;
  3797. $receipt->executeDate = date ( "Y-m-d" );
  3798. } else {
  3799. $receipt->executeStaff = json_encode ( $executeStaff );
  3800. }
  3801. $receipt->amount = $amount;
  3802. $receipt->update ( array (
  3803. 'where' => 'rid=' . $rid
  3804. ) );
  3805. }
  3806. $ridKey = $XDeode->encode ( $rid );
  3807. return "/implement/" . $ridKey . ".html";
  3808. }
  3809. function receiptburEdi() {
  3810. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3811. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  3812. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  3813. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  3814. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3815. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  3816. if (empty ( $status ))
  3817. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  3818. $vidList = array ();
  3819. $button = 0;
  3820. Doo::loadModel ( 'verify' );
  3821. Doo::loadModel ( 'receipt' );
  3822. Doo::loadModel ( 'staff' );
  3823. $staff = new staff ();
  3824. $receipt = new receipt ();
  3825. $verify = new verify ();
  3826. Doo::loadModel ( 'L_category' );
  3827. $Lcategory = new L_category ();
  3828. Doo::loadModel ( 'enclosur' );
  3829. $enclosur = new enclosur ();
  3830. Doo::loadModel ( 'loanReceipt' );
  3831. $loanReceipt = new loanReceipt ();
  3832. // user verify ID
  3833. $verifyDetail = $verify->find ( array (
  3834. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  3835. 'asArray' => true
  3836. ) );
  3837. foreach ( $verifyDetail as $key => $value ) {
  3838. array_push ( $vidList, $value ['vid'] );
  3839. }
  3840. $vid = implode ( ",", $vidList );
  3841. if (empty ( $verifyDetail ))
  3842. $vid = 0;
  3843. $categoryList = $Lcategory->find ( array (
  3844. 'asArray' => true
  3845. ) );
  3846. $staffList = $staff->find ( array (
  3847. 'where' => 'cid=' . $cid,
  3848. 'asArray' => true
  3849. ) );
  3850. $ap = "";
  3851. if ($status == 4) {
  3852. $ap = 4;
  3853. $status = 2;
  3854. }
  3855. // get Receipt By verifyID status 2
  3856. $receiptList = $receipt->find ( array (
  3857. 'where' => 'rid =' . $rid,
  3858. 'desc' => 'rid',
  3859. 'asArray' => true
  3860. ) );
  3861. $loanList = $loanReceipt->find ( array (
  3862. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3863. 'desc' => 'rid',
  3864. 'asArray' => true
  3865. ) );
  3866. $Locate = 0;
  3867. $roleId = 0;
  3868. $button = 0;
  3869. foreach ( $loanList as $key => $value ) {
  3870. $loanList [$key] ['Locate'] = $Locate;
  3871. $Locate ++;
  3872. $loanList [$key] ['reviseDetail'] = array ();
  3873. if (! empty ( $value ['reviseDetail'] ))
  3874. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3875. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3876. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3877. $categoryDetil = $Lcategory->getOne ( array (
  3878. 'where' => 'cid=' . $value ['cid'],
  3879. 'asArray' => true
  3880. ) );
  3881. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3882. // 检测编辑状态
  3883. $verifyList = $verify->getOne ( array (
  3884. 'where' => 'vid=' . $value ['verify'],
  3885. 'asArray' => true
  3886. ) );
  3887. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3888. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3889. Doo::loadModel ( 'role' );
  3890. $role = new role ();
  3891. $flag = true;
  3892. $roleKey = 0;
  3893. $endStaffArray = array ();
  3894. $roleArrayCopy = array ();
  3895. foreach ( $verifyList as $k => $v ) {
  3896. // init verifyStaff
  3897. if ($v [1] == 'ROLE') {
  3898. if (! empty ( $verifyStaff )) {
  3899. $endStaffArray = end ( $verifyStaff );
  3900. }
  3901. $roleVerify = json_decode ( $v [3], true );
  3902. $roleKey = $k;
  3903. $roleArray = array ();
  3904. $rolename = $role->getOne ( array (
  3905. 'where' => 'rid=' . $v [0],
  3906. 'asArray' => true
  3907. ) );
  3908. foreach ( $roleVerify as $o => $p ) {
  3909. $staffID = explode ( '_', $p );
  3910. $staffInfo = $staff->getOne ( array (
  3911. 'where' => 'sid=' . $staffID [0],
  3912. 'asArray' => true
  3913. ) );
  3914. // print_r($staffID);
  3915. $exp = array (
  3916. 0 => $staffInfo ['sid'],
  3917. 1 => $staffID [1],
  3918. 2 => $staffInfo ['avatar'],
  3919. 'date' => '',
  3920. 'date' => '',
  3921. 'opinion' => '',
  3922. 'status' => '',
  3923. 'rolename' => $rolename ['name']
  3924. );
  3925. array_push ( $roleArray, $exp );
  3926. }
  3927. $roleArrayCopy [$v [0]] = $roleArray;
  3928. // $verifyList[$k]['roleArray']=$roleArray;
  3929. }
  3930. $verifyList [$k] ['date'] = "";
  3931. $verifyList [$k] ['opinion'] = "";
  3932. $verifyList [$k] ['status'] = "";
  3933. if (empty ( $verifyStaff )) {
  3934. $verifyList [$k] ['date'] = "";
  3935. $verifyList [$k] ['opinion'] = "";
  3936. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3937. $verifyList [$k] ['status'] = 4;
  3938. $flag = false;
  3939. }
  3940. } else {
  3941. foreach ( $verifyStaff as $m => $u ) {
  3942. if ($v [0] == $m) {
  3943. $verifyList [$k] ['date'] = $u ['date'];
  3944. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3945. $verifyList [$k] ['status'] = $u ['status'];
  3946. $flag = false;
  3947. break;
  3948. }
  3949. }
  3950. $endStaffArray = end ( $verifyStaff );
  3951. if (isset ( $endStaffArray ['ROLE'] )) {
  3952. } else {
  3953. }
  3954. }
  3955. }
  3956. $rolename ['name'] = '';
  3957. if (! empty ( $roleId )) {
  3958. Doo::loadModel ( 'role' );
  3959. $role = new role ();
  3960. $rolename = $role->getOne ( array (
  3961. 'where' => 'rid=' . $roleId,
  3962. 'asArray' => true
  3963. ) );
  3964. }
  3965. if (! empty ( $verifyStaff ))
  3966. $endStaffArray = end ( $verifyStaff );
  3967. $KOP = false;
  3968. foreach ( $roleArrayCopy as $P => $A ) {
  3969. foreach ( $A as $MKI => $AVL ) {
  3970. if (! empty ( $verifyStaff )) {
  3971. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3972. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3973. $button = 4;
  3974. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3975. }
  3976. foreach ( $verifyStaff as $m => $u ) {
  3977. $AVLFK = $AVL [0] . '_R';
  3978. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3979. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3980. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3981. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3982. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3983. break;
  3984. }
  3985. }
  3986. } else {
  3987. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3988. $button = 4;
  3989. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3990. }
  3991. }
  3992. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3993. $KOP = true;
  3994. }
  3995. }
  3996. foreach ( $roleArrayCopy as $k => $v ) {
  3997. foreach ( $verifyList as $m => $n ) {
  3998. if ($n [0] == $k) {
  3999. array_splice ( $verifyList, $m, 1, $v );
  4000. }
  4001. }
  4002. }
  4003. $loanList [$key] ['verifyList'] = $verifyList;
  4004. }
  4005. $htmlLoan = '';
  4006. if (isset ( $loanList [0] )) {
  4007. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  4008. if ($value ['status'] == 1)
  4009. $htmlLoan .= '<li class="done" >';
  4010. elseif ($value ['status'] == 3)
  4011. $htmlLoan .= '<li class="undone" >';
  4012. $htmlLoan .= '<div class="avtra"><img src="' . $value [2] . '_2.jpg"></div>';
  4013. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  4014. if (isset ( $value ['rolename'] ))
  4015. $htmlLoan .= $value ['rolename'];
  4016. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  4017. }
  4018. $data ['loanDate'] = $loanList [0] ['date'];
  4019. }
  4020. $data ['htmlLoan'] = $htmlLoan;
  4021. // print_r($loanList);
  4022. $Locate = 0;
  4023. $roleId = 0;
  4024. $button = 0;
  4025. if ($ap == 4)
  4026. $status = 4;
  4027. foreach ( $receiptList as $key => $value ) {
  4028. $receiptList [$key] ['Locate'] = $Locate;
  4029. $Locate ++;
  4030. $receiptList [$key] ['reviseDetail'] = array ();
  4031. if (! empty ( $value ['reviseDetail'] ))
  4032. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4033. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4034. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4035. $categoryDetil = $Lcategory->getOne ( array (
  4036. 'where' => 'cid=' . $value ['cid'],
  4037. 'asArray' => true
  4038. ) );
  4039. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4040. // 检测编辑状态
  4041. $verifyList = $verify->getOne ( array (
  4042. 'where' => 'vid=' . $value ['verify'],
  4043. 'asArray' => true
  4044. ) );
  4045. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4046. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4047. Doo::loadModel ( 'role' );
  4048. $role = new role ();
  4049. // print_r($verifyList);
  4050. $flag = true;
  4051. $roleKey = 0;
  4052. $endStaffArray = array ();
  4053. $roleArrayCopy = array ();
  4054. foreach ( $verifyList as $k => $v ) {
  4055. // init verifyStaff
  4056. if ($v [1] == 'ROLE') {
  4057. if (! empty ( $verifyStaff )) {
  4058. $endStaffArray = end ( $verifyStaff );
  4059. if ($v [0] == $endStaffArray ['nextStaff']) {
  4060. $roleId = $v [0];
  4061. }
  4062. }
  4063. $roleVerify = json_decode ( $v [3], true );
  4064. $roleKey = $k;
  4065. $roleArray = array ();
  4066. $rolename = $role->getOne ( array (
  4067. 'where' => 'rid=' . $v [0],
  4068. 'asArray' => true
  4069. ) );
  4070. foreach ( $roleVerify as $o => $p ) {
  4071. $staffID = explode ( '_', $p );
  4072. $staffInfo = $staff->getOne ( array (
  4073. 'where' => 'sid=' . $staffID [0],
  4074. 'asArray' => true
  4075. ) );
  4076. // print_r($staffID);
  4077. $exp = array (
  4078. 0 => $staffInfo ['sid'],
  4079. 1 => $staffID [1],
  4080. 2 => $staffInfo ['avatar'],
  4081. 'date' => '',
  4082. 'date' => '',
  4083. 'opinion' => '',
  4084. 'status' => '',
  4085. 'rolename' => $rolename ['name']
  4086. );
  4087. array_push ( $roleArray, $exp );
  4088. }
  4089. $roleArrayCopy [$v [0]] = $roleArray;
  4090. // $verifyList[$k]['roleArray']=$roleArray;
  4091. }
  4092. // print_r($roleArray);
  4093. $verifyList [$k] ['date'] = "";
  4094. $verifyList [$k] ['opinion'] = "";
  4095. $verifyList [$k] ['status'] = "";
  4096. if (empty ( $verifyStaff )) {
  4097. $verifyList [$k] ['date'] = "";
  4098. $verifyList [$k] ['opinion'] = "";
  4099. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4100. $verifyList [$k] ['status'] = 4;
  4101. $button = 4;
  4102. $flag = false;
  4103. }
  4104. } else {
  4105. foreach ( $verifyStaff as $m => $u ) {
  4106. if ($v [0] == $m) {
  4107. $verifyList [$k] ['date'] = $u ['date'];
  4108. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4109. $verifyList [$k] ['status'] = $u ['status'];
  4110. $flag = false;
  4111. break;
  4112. }
  4113. }
  4114. $endStaffArray = end ( $verifyStaff );
  4115. if (isset ( $endStaffArray ['ROLE'] )) {
  4116. } else {
  4117. $endKey = key ( $verifyStaff );
  4118. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4119. $button = 4;
  4120. $verifyList [$k] ['status'] = 4;
  4121. }
  4122. }
  4123. }
  4124. }
  4125. $rolename ['name'] = '';
  4126. if (! empty ( $roleId )) {
  4127. Doo::loadModel ( 'role' );
  4128. $role = new role ();
  4129. $rolename = $role->getOne ( array (
  4130. 'where' => 'rid=' . $roleId,
  4131. 'asArray' => true
  4132. ) );
  4133. }
  4134. if (! empty ( $verifyStaff ))
  4135. $endStaffArray = end ( $verifyStaff );
  4136. $KOP = false;
  4137. foreach ( $roleArrayCopy as $P => $A ) {
  4138. foreach ( $A as $MKI => $AVL ) {
  4139. if (! empty ( $verifyStaff )) {
  4140. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4141. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4142. $button = 4;
  4143. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4144. }
  4145. foreach ( $verifyStaff as $m => $u ) {
  4146. $AVLFK = $AVL [0] . '_R';
  4147. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4148. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4149. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4150. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4151. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4152. break;
  4153. }
  4154. }
  4155. } else {
  4156. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4157. $button = 4;
  4158. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4159. }
  4160. }
  4161. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4162. $KOP = true;
  4163. }
  4164. }
  4165. foreach ( $roleArrayCopy as $k => $v ) {
  4166. foreach ( $verifyList as $m => $n ) {
  4167. if ($n [0] == $k) {
  4168. array_splice ( $verifyList, $m, 1, $v );
  4169. }
  4170. }
  4171. }
  4172. // print_r($verifyList);
  4173. $receiptList [$key] ['verifyList'] = $verifyList;
  4174. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4175. 'where' => 'sid=' . $value ['staff'],
  4176. 'asArray' => true
  4177. ) );
  4178. $receiptList [$key] ['button'] = $button;
  4179. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4180. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4181. $relust = $value ['sum'] - $value ['loanSum'];
  4182. $receiptList [$key] ['relust'] = $relust;
  4183. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  4184. }
  4185. // print_r($receiptList);die;
  4186. // $data['verifyDetail']=$verifyDetail;
  4187. $mothHtml = "";
  4188. for($i = 1; $i <= 12; $i ++) {
  4189. if ($month == $i)
  4190. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4191. else
  4192. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4193. }
  4194. // 获取审批日志
  4195. Doo::loadModel ( 'receiptLog' );
  4196. $receiptLog = new receiptLog ();
  4197. $rlList = array ();
  4198. $rlInfo = $receiptLog->getOne ( array (
  4199. 'where' => 'rid=' . $rid . ' and status=4',
  4200. 'asArray' => true
  4201. ) );
  4202. $tijdate = $receiptLog->getOne ( array (
  4203. 'where' => 'rid=' . $rid . ' and status=2',
  4204. 'asc' => 'rlid',
  4205. 'asArray' => true
  4206. ) );
  4207. if (! empty ( $rlInfo )) {
  4208. $rlList = $receiptLog->find ( array (
  4209. 'where' => 'rid=' . $rid,
  4210. 'asc' => 'rlid',
  4211. 'asArray' => true
  4212. ) );
  4213. }
  4214. // echo $rid;
  4215. // print_r($receiptList);
  4216. $receiptList [0] ['rlList'] = $rlList;
  4217. $enclosurList = $enclosur->find ( array (
  4218. 'where' => 'rid=' . $rid,
  4219. 'asArray' => true
  4220. ) );
  4221. $enclosurHtml = '';
  4222. foreach ( $enclosurList as $value ) {
  4223. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4224. }
  4225. $data ['enclosurHtml'] = $enclosurHtml;
  4226. $data ['rolename'] = $rolename ['name'];
  4227. // $data['datetij']=$tijdate['date'];
  4228. $data ['mothHtml'] = $mothHtml;
  4229. // print_r($receiptList);
  4230. $data ['rid'] = $rid;
  4231. $data ['tijdate'] = $tijdate ['date'];
  4232. $data ['receiptList'] = $receiptList;
  4233. $data ['receiptApprovalCount'] = count ( $receiptList );
  4234. $data ['status'] = $status;
  4235. $data ['year'] = $year;
  4236. $data ['categoryList'] = $categoryList;
  4237. $data ['staffList'] = $staffList;
  4238. $data ['cid'] = $cid;
  4239. $data ['sid'] = $sid;
  4240. $data ['ap'] = $ap;
  4241. $data ['memu'] = "receipt";
  4242. $data ['staff'] = $this->staff;
  4243. $data ['receiptMemu'] = 'approvalExpenses';
  4244. $data ['verifyId'] = $this->verifyId;
  4245. $data ['executeId'] = $this->executeId;
  4246. $this->render ( "/admin/receiptburEdi", $data );
  4247. }
  4248. function hisImplement() {
  4249. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4250. if (empty ( $item ))
  4251. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4252. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4253. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  4254. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  4255. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  4256. Doo::loadModel ( 'receipt' );
  4257. $receipt = new receipt ();
  4258. Doo::loadModel ( 'L_category' );
  4259. $Lcategory = new L_category ();
  4260. Doo::loadModel ( 'verify' );
  4261. Doo::loadModel ( 'statistics' );
  4262. $statistics = new statistics ();
  4263. $verify = new verify ();
  4264. Doo::loadModel ( 'staff' );
  4265. $staff = new staff ();
  4266. Doo::loadClass ( 'XDeode' );
  4267. $XDeode = new XDeode ( 5 );
  4268. $condition = "";
  4269. if ($item == "expenses")
  4270. $condition = " and Rtype=1 ";
  4271. elseif ($item == "receipts")
  4272. $condition = " and Rtype=0 ";
  4273. elseif ($item == "remits")
  4274. $condition = " and Rtype=2 ";
  4275. $sopString = "";
  4276. $dateCondition = " and Year(date) =" . $year;
  4277. if ($sop != 'SOP')
  4278. $sopString = " and staff=" . $sop;
  4279. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  4280. if ($item == 'teipts') {
  4281. $statusCon = '(status=1 or status=6 )';
  4282. $dateCondition = " and Year(pastDate) =" . $year;
  4283. if ($moth != 'MONTH')
  4284. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth;
  4285. if ($day != 'DAY')
  4286. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth . " and day(pastDate)=" . $day;
  4287. } elseif ($item == 'alerpts') {
  4288. $statusCon = '(status=8 or status=9 )';
  4289. $dateCondition = " and Year(executeDate) =" . $year;
  4290. if ($moth != 'MONTH')
  4291. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  4292. if ($day != 'DAY')
  4293. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  4294. }
  4295. // $noPassSum=$receipt->receiptByYear($year,$this->staff[0]['sid']); and (status=1 or status=6)
  4296. $receiptList = $receipt->find ( array (
  4297. 'where' => $statusCon . $condition . $dateCondition . $sopString,
  4298. 'desc' => 'rid',
  4299. 'asArray' => true
  4300. ) );
  4301. // 员工筛选
  4302. $receiptList2 = $receipt->find ( array (
  4303. 'where' => $statusCon . $condition . $dateCondition,
  4304. 'desc' => 'rid',
  4305. 'asArray' => true
  4306. ) );
  4307. $sopStaff = array ();
  4308. foreach ( $receiptList2 as $key => $value ) {
  4309. $staffDetail = $staff->getOne ( array (
  4310. 'where' => 'sid=' . $value ['staff'],
  4311. 'asArray' => true
  4312. ) );
  4313. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  4314. }
  4315. $Locate = 0;
  4316. $roleId = 0;
  4317. $button = 0;
  4318. foreach ( $receiptList as $key => $value ) {
  4319. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4320. $receiptList [$key] ['Texe'] = 'false';
  4321. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  4322. $receiptList [$key] ['Texe'] = 'true';
  4323. }
  4324. $receiptList [$key] ['TRexe'] = 'true';
  4325. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  4326. $receiptList [$key] ['TRexe'] = 'false';
  4327. }
  4328. $receiptList [$key] ['Locate'] = $Locate;
  4329. $Locate ++;
  4330. $receiptList [$key] ['reviseDetail'] = array ();
  4331. if (! empty ( $value ['reviseDetail'] ))
  4332. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4333. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4334. $categoryDetil = $Lcategory->getOne ( array (
  4335. 'where' => 'cid=' . $value ['cid'],
  4336. 'asArray' => true
  4337. ) );
  4338. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4339. // 检测编辑状态
  4340. $verifyList = $verify->getOne ( array (
  4341. 'where' => 'vid=' . $value ['verify'],
  4342. 'asArray' => true
  4343. ) );
  4344. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4345. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4346. Doo::loadModel ( 'role' );
  4347. $role = new role ();
  4348. $flag = true;
  4349. $roleKey = 0;
  4350. $endStaffArray = array ();
  4351. $roleArrayCopy = array ();
  4352. foreach ( $verifyList as $k => $v ) {
  4353. // init verifyStaff
  4354. if ($v [1] == 'ROLE') {
  4355. if (! empty ( $verifyStaff )) {
  4356. $endStaffArray = end ( $verifyStaff );
  4357. }
  4358. $roleVerify = json_decode ( $v [3], true );
  4359. $roleKey = $k;
  4360. $roleArray = array ();
  4361. $rolename = $role->getOne ( array (
  4362. 'where' => 'rid=' . $v [0],
  4363. 'asArray' => true
  4364. ) );
  4365. foreach ( $roleVerify as $o => $p ) {
  4366. $staffID = explode ( '_', $p );
  4367. $staffInfo = $staff->getOne ( array (
  4368. 'where' => 'sid=' . $staffID [0],
  4369. 'asArray' => true
  4370. ) );
  4371. $exp = array (
  4372. 0 => $staffInfo ['sid'],
  4373. 1 => $staffID [1],
  4374. 2 => $staffInfo ['avatar'],
  4375. 'date' => '',
  4376. 'date' => '',
  4377. 'opinion' => '',
  4378. 'status' => '',
  4379. 'rolename' => $rolename ['name']
  4380. );
  4381. array_push ( $roleArray, $exp );
  4382. }
  4383. $roleArrayCopy [$v [0]] = $roleArray;
  4384. }
  4385. $verifyList [$k] ['date'] = "";
  4386. $verifyList [$k] ['opinion'] = "";
  4387. $verifyList [$k] ['status'] = "";
  4388. if (empty ( $verifyStaff )) {
  4389. $verifyList [$k] ['date'] = "";
  4390. $verifyList [$k] ['opinion'] = "";
  4391. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4392. $verifyList [$k] ['status'] = 4;
  4393. $flag = false;
  4394. }
  4395. } else {
  4396. foreach ( $verifyStaff as $m => $u ) {
  4397. if ($v [0] == $m) {
  4398. $verifyList [$k] ['date'] = $u ['date'];
  4399. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4400. $verifyList [$k] ['status'] = $u ['status'];
  4401. $flag = false;
  4402. break;
  4403. }
  4404. }
  4405. $endStaffArray = end ( $verifyStaff );
  4406. }
  4407. }
  4408. $rolename ['name'] = '';
  4409. if (! empty ( $roleId )) {
  4410. Doo::loadModel ( 'role' );
  4411. $role = new role ();
  4412. $rolename = $role->getOne ( array (
  4413. 'where' => 'rid=' . $roleId,
  4414. 'asArray' => true
  4415. ) );
  4416. }
  4417. if (! empty ( $verifyStaff ))
  4418. $endStaffArray = end ( $verifyStaff );
  4419. $KOP = false;
  4420. foreach ( $roleArrayCopy as $P => $A ) {
  4421. foreach ( $A as $MKI => $AVL ) {
  4422. if (! empty ( $verifyStaff )) {
  4423. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4424. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4425. $button = 4;
  4426. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4427. }
  4428. foreach ( $verifyStaff as $m => $u ) {
  4429. $AVLFK = $AVL [0] . '_R';
  4430. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4431. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4432. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4433. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4434. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4435. break;
  4436. }
  4437. }
  4438. } else {
  4439. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4440. $button = 4;
  4441. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4442. }
  4443. }
  4444. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4445. $KOP = true;
  4446. }
  4447. }
  4448. foreach ( $roleArrayCopy as $k => $v ) {
  4449. foreach ( $verifyList as $m => $n ) {
  4450. if ($n [0] == $k) {
  4451. array_splice ( $verifyList, $m, 1, $v );
  4452. }
  4453. }
  4454. }
  4455. $receiptList [$key] ['verifyList'] = $verifyList;
  4456. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4457. 'where' => 'sid=' . $value ['staff'],
  4458. 'asArray' => true
  4459. ) );
  4460. $receiptList [$key] ['button'] = $button;
  4461. }
  4462. // print_r($receiptList);
  4463. $mothHtml = "";
  4464. for($i = 1; $i <= 12; $i ++) {
  4465. if ($moth == $i)
  4466. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4467. else
  4468. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4469. }
  4470. $dayHtml = "";
  4471. if ($day != "DAY" || $moth != "MONTH") {
  4472. for($i = 1; $i <= 31; $i ++) {
  4473. if ($day == $i)
  4474. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  4475. else
  4476. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  4477. }
  4478. }
  4479. $sopHtml = "";
  4480. foreach ( $sopStaff as $key => $value ) {
  4481. if ($sop == $key)
  4482. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4483. else
  4484. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4485. }
  4486. $data ['sopHtml'] = $sopHtml;
  4487. $data ['dayHtml'] = $dayHtml;
  4488. $data ['mothHtml'] = $mothHtml;
  4489. $data ['receiptList'] = $receiptList;
  4490. $data ['memu'] = "receipt";
  4491. $data ['staff'] = $this->staff;
  4492. $data ['receiptMemu'] = 'implement';
  4493. $data ['verifyId'] = $this->verifyId;
  4494. $data ['executeId'] = $this->executeId;
  4495. $data ['item'] = $item;
  4496. $data ['year'] = $year;
  4497. $data ['moth'] = $moth;
  4498. $data ['day'] = $day;
  4499. $data ['sop'] = $sop;
  4500. $this->render ( "/admin/hisImplement", $data );
  4501. }
  4502. function ajaxExamine() {
  4503. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4504. Doo::loadModel ( 'receipt' );
  4505. $receipt = new receipt ();
  4506. if (! empty ( $rid )) {
  4507. $rLRes = $receipt->find ( array (
  4508. '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,
  4509. 'asArray' => true
  4510. ) );
  4511. echo json_encode ( array (
  4512. 'status' => 1,
  4513. 'receipt' => $rLRes [0]
  4514. ) );
  4515. die ();
  4516. }
  4517. echo json_encode ( array (
  4518. 'status' => 0,
  4519. 'receipt' => array ()
  4520. ) );
  4521. die ();
  4522. }
  4523. /*
  4524. * 废弃
  4525. */
  4526. function myReceipt() {
  4527. // all approval past withdraw
  4528. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4529. if (empty ( $item ))
  4530. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4531. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4532. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  4533. Doo::loadModel ( 'receipt' );
  4534. $receipt = new receipt ();
  4535. // pre-loaded
  4536. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4537. // have cache
  4538. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  4539. if (! empty ( $moth )) // yearPage
  4540. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  4541. $this->showCache ( $path );
  4542. }
  4543. Doo::loadModel ( 'L_category' );
  4544. $Lcategory = new L_category ();
  4545. Doo::loadModel ( 'verify' );
  4546. Doo::loadModel ( 'statistics' );
  4547. $statistics = new statistics ();
  4548. $verify = new verify ();
  4549. Doo::loadModel ( 'staff' );
  4550. $staff = new staff ();
  4551. $condition = " and status!=0 ";
  4552. if ($item == "approval")
  4553. $condition = " and status=2 ";
  4554. elseif ($item == "withdraw")
  4555. $condition = " and status=3 ";
  4556. elseif ($item == "past")
  4557. $condition = " and status=1 ";
  4558. elseif ($item == "whdw")
  4559. $condition = " and status=4 ";
  4560. $dateCondition = " and Year(date) =" . $year;
  4561. if (! empty ( $moth )) {
  4562. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  4563. $stList = $statistics->getOne ( array (
  4564. 'select' => 'rePrice ,agPrice',
  4565. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  4566. 'asArray' => true
  4567. ) );
  4568. } else
  4569. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  4570. if (empty ( $stList ))
  4571. $stList = array (
  4572. 'rePrice' => 0,
  4573. 'agPrice' => 0
  4574. );
  4575. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  4576. $data ['stList'] = array (
  4577. 'rePrice' => $stList ['rePrice'],
  4578. 'agPrice' => $stList ['agPrice'],
  4579. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  4580. );
  4581. $receiptList = $receipt->find ( array (
  4582. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  4583. 'desc' => 'rid',
  4584. 'asArray' => true
  4585. ) );
  4586. $Locate = 0;
  4587. $roleId = 0;
  4588. $button = 0;
  4589. foreach ( $receiptList as $key => $value ) {
  4590. $receiptList [$key] ['Locate'] = $Locate;
  4591. $Locate ++;
  4592. $receiptList [$key] ['reviseDetail'] = array ();
  4593. if (! empty ( $value ['reviseDetail'] ))
  4594. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4595. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4596. $categoryDetil = $Lcategory->getOne ( array (
  4597. 'where' => 'cid=' . $value ['cid'],
  4598. 'asArray' => true
  4599. ) );
  4600. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4601. // 检测编辑状态
  4602. $verifyList = $verify->getOne ( array (
  4603. 'where' => 'vid=' . $value ['verify'],
  4604. 'asArray' => true
  4605. ) );
  4606. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4607. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4608. Doo::loadModel ( 'role' );
  4609. $role = new role ();
  4610. $flag = true;
  4611. $roleKey = 0;
  4612. $endStaffArray = array ();
  4613. $roleArrayCopy = array ();
  4614. foreach ( $verifyList as $k => $v ) {
  4615. // init verifyStaff
  4616. if ($v [1] == 'ROLE') {
  4617. if (! empty ( $verifyStaff )) {
  4618. $endStaffArray = end ( $verifyStaff );
  4619. // if ($v[0]==$endStaffArray['nextStaff']){
  4620. // $roleId=$v[0];
  4621. // }
  4622. }
  4623. $roleVerify = json_decode ( $v [3], true );
  4624. $roleKey = $k;
  4625. $roleArray = array ();
  4626. $rolename = $role->getOne ( array (
  4627. 'where' => 'rid=' . $v [0],
  4628. 'asArray' => true
  4629. ) );
  4630. foreach ( $roleVerify as $o => $p ) {
  4631. $staffID = explode ( '_', $p );
  4632. $staffInfo = $staff->getOne ( array (
  4633. 'where' => 'sid=' . $staffID [0],
  4634. 'asArray' => true
  4635. ) );
  4636. // print_r($staffID);
  4637. $exp = array (
  4638. 0 => $staffInfo ['sid'],
  4639. 1 => $staffID [1],
  4640. 2 => $staffInfo ['avatar'],
  4641. 'date' => '',
  4642. 'date' => '',
  4643. 'opinion' => '',
  4644. 'status' => '',
  4645. 'rolename' => $rolename ['name']
  4646. );
  4647. array_push ( $roleArray, $exp );
  4648. }
  4649. $roleArrayCopy [$v [0]] = $roleArray;
  4650. // $verifyList[$k]['roleArray']=$roleArray;
  4651. }
  4652. $verifyList [$k] ['date'] = "";
  4653. $verifyList [$k] ['opinion'] = "";
  4654. $verifyList [$k] ['status'] = "";
  4655. if (empty ( $verifyStaff )) {
  4656. $verifyList [$k] ['date'] = "";
  4657. $verifyList [$k] ['opinion'] = "";
  4658. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4659. $verifyList [$k] ['status'] = 4;
  4660. $flag = false;
  4661. }
  4662. } else {
  4663. foreach ( $verifyStaff as $m => $u ) {
  4664. if ($v [0] == $m) {
  4665. $verifyList [$k] ['date'] = $u ['date'];
  4666. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4667. $verifyList [$k] ['status'] = $u ['status'];
  4668. $flag = false;
  4669. break;
  4670. }
  4671. }
  4672. $endStaffArray = end ( $verifyStaff );
  4673. if (isset ( $endStaffArray ['ROLE'] )) {
  4674. } else {
  4675. // $endKey=key($verifyStaff);
  4676. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4677. // $button=4;
  4678. // $verifyList[$k]['status']=4;
  4679. // }
  4680. }
  4681. }
  4682. }
  4683. $rolename ['name'] = '';
  4684. if (! empty ( $roleId )) {
  4685. Doo::loadModel ( 'role' );
  4686. $role = new role ();
  4687. $rolename = $role->getOne ( array (
  4688. 'where' => 'rid=' . $roleId,
  4689. 'asArray' => true
  4690. ) );
  4691. }
  4692. if (! empty ( $verifyStaff ))
  4693. $endStaffArray = end ( $verifyStaff );
  4694. $KOP = false;
  4695. foreach ( $roleArrayCopy as $P => $A ) {
  4696. foreach ( $A as $MKI => $AVL ) {
  4697. if (! empty ( $verifyStaff )) {
  4698. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4699. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4700. $button = 4;
  4701. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4702. }
  4703. foreach ( $verifyStaff as $m => $u ) {
  4704. $AVLFK = $AVL [0] . '_R';
  4705. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4706. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4707. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4708. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4709. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4710. break;
  4711. }
  4712. }
  4713. } else {
  4714. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4715. $button = 4;
  4716. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4717. }
  4718. }
  4719. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4720. $KOP = true;
  4721. }
  4722. }
  4723. foreach ( $roleArrayCopy as $k => $v ) {
  4724. foreach ( $verifyList as $m => $n ) {
  4725. if ($n [0] == $k) {
  4726. array_splice ( $verifyList, $m, 1, $v );
  4727. }
  4728. }
  4729. }
  4730. $receiptList [$key] ['verifyList'] = $verifyList;
  4731. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4732. 'where' => 'sid=' . $value ['staff'],
  4733. 'asArray' => true
  4734. ) );
  4735. $receiptList [$key] ['button'] = $button;
  4736. }
  4737. // print_r($receiptList);die;
  4738. $mothHtml = "";
  4739. for($i = 1; $i <= 12; $i ++) {
  4740. if ($moth == $i)
  4741. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4742. else
  4743. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4744. }
  4745. $data ['mothHtml'] = $mothHtml;
  4746. $data ['receiptList'] = $receiptList;
  4747. $data ['memu'] = "receipt";
  4748. $data ['staff'] = $this->staff;
  4749. $data ['receiptMemu'] = 'receipt';
  4750. $data ['verifyId'] = $this->verifyId;
  4751. $data ['executeId'] = $this->executeId;
  4752. $data ['item'] = $item;
  4753. $data ['year'] = $year;
  4754. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4755. // sufficient condition to generate cache
  4756. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  4757. $receiptList = $receipt->find ( array (
  4758. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  4759. 'asArray' => true
  4760. ) );
  4761. if (empty ( $receiptList )) { // generated files
  4762. ob_start ();
  4763. $this->render ( "/admin/saea_myList", $data );
  4764. $this->cacheFile ( $path );
  4765. die ();
  4766. // $content = ob_get_contents();
  4767. // $fp = fopen($path, "w");
  4768. // fwrite($fp, $content);
  4769. // fclose($fp);
  4770. }
  4771. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  4772. $receiptList = $receipt->find ( array (
  4773. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  4774. 'asArray' => true
  4775. ) );
  4776. if (empty ( $receiptList )) { // generated files
  4777. ob_start ();
  4778. $this->render ( "/admin/saea_myList", $data );
  4779. $this->cacheFile ( $path );
  4780. die ();
  4781. }
  4782. }
  4783. }
  4784. $this->render ( "/admin/saea_myList", $data );
  4785. }
  4786. function saeaCreate() {
  4787. Doo::loadModel ( 'accountItem' );
  4788. Doo::loadModel ( 'verify' );
  4789. Doo::loadModel ( 'receipt' );
  4790. Doo::loadModel ( 'L_category' );
  4791. $lCategory = new L_category ();
  4792. $receipt = new receipt ();
  4793. $verify = new verify ();
  4794. $accountItem = new accountItem ();
  4795. Doo::loadModel ( "role" );
  4796. $role = new role ();
  4797. $acItem = $accountItem->find ( array (
  4798. 'asArray' => true
  4799. ) );
  4800. $veList = $verify->find ( array (
  4801. 'asArray' => true
  4802. ) );
  4803. foreach ( $veList as $key => $value ) {
  4804. $v = json_decode ( $value ['staff'] );
  4805. $list = array ();
  4806. foreach ( $v as $n => $m ) {
  4807. if ($m ['1'] == 'ROLE') {
  4808. $roleInfo = $role->getOne ( array (
  4809. 'where' => 'rid=' . $m [0],
  4810. 'asArray' => true
  4811. ) );
  4812. $v [$n] [1] = $roleInfo ['name'];
  4813. array_push ( $list, $roleInfo ['name'] );
  4814. } else {
  4815. array_push ( $list, $v [$n] [1] );
  4816. }
  4817. }
  4818. $veList [$key] ['staff'] = implode ( '>', $list );
  4819. }
  4820. $data ['category'] = $lCategory->find ( array (
  4821. 'asArray' => true
  4822. ) );
  4823. $data ['veList'] = $veList;
  4824. $data ['acItem'] = $acItem;
  4825. $data ['memu'] = "receipt";
  4826. $data ['staff'] = $this->staff;
  4827. $data ['receiptMemu'] = 'saeaBorad';
  4828. $data ['verifyId'] = $this->verifyId;
  4829. $data ['executeId'] = $this->executeId;
  4830. $this->render ( "/admin/saea_create", $data );
  4831. }
  4832. function addReceipt() {
  4833. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  4834. $agency = $this->get_args ( 'agency' );
  4835. $travel = $this->get_args ( 'travel' );
  4836. $train = $this->get_args ( 'train' );
  4837. $other = $this->get_args ( 'other' );
  4838. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  4839. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  4840. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  4841. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  4842. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  4843. Doo::loadModel ( 'receipt' );
  4844. Doo::loadModel ( 'receiptDetail' );
  4845. Doo::loadModel ( 'accountItem' );
  4846. $accountItem = new accountItem ();
  4847. $receipt = new receipt ();
  4848. Doo::loadModel ( 'enclosur' );
  4849. Doo::loadModel ( 'execute' );
  4850. $execute = new execute ();
  4851. $executeDetail = $execute->getOne ( array (
  4852. 'where' => 'mold="报销单执行人"',
  4853. 'asArray' => true
  4854. ) );
  4855. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  4856. // if(!empty($receiptDetail))
  4857. // return "/referReceipt/".$receiptDetail['rid'];
  4858. $aItem = $accountItem->find ( array (
  4859. 'asArray' => true
  4860. ) );
  4861. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  4862. $ag = $tr = $ta = $ot = 0;
  4863. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  4864. foreach ( $aItem as $key => $value ) {
  4865. if ($value ['category'] == $this->AGENCY) {
  4866. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  4867. array_push ( $accountJson [$this->AGENCY], array (
  4868. 'aid' => $value ['aid'],
  4869. 'name' => $value ['name'],
  4870. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  4871. ) );
  4872. $sum += $agency [$ag];
  4873. $agencySum += $agency [$ag];
  4874. }
  4875. $ag ++;
  4876. }
  4877. if ($value ['category'] == $this->TRAVEL) {
  4878. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  4879. array_push ( $accountJson [$this->TRAVEL], array (
  4880. 'aid' => $value ['aid'],
  4881. 'name' => $value ['name'],
  4882. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  4883. ) );
  4884. $sum += $travel [$tr];
  4885. $travelSum += $travel [$tr];
  4886. }
  4887. $tr ++;
  4888. }
  4889. if ($value ['category'] == $this->TRAIN) {
  4890. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  4891. array_push ( $accountJson [$this->TRAIN], array (
  4892. 'aid' => $value ['aid'],
  4893. 'name' => $value ['name'],
  4894. 'price' => number_format ( $train [$ta], 2, '.', '' )
  4895. ) );
  4896. $sum += $train [$ta];
  4897. $trainSum += $train [$ta];
  4898. }
  4899. $ta ++;
  4900. }
  4901. if ($value ['category'] == $this->OTHER) {
  4902. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  4903. array_push ( $accountJson [$this->OTHER], array (
  4904. 'aid' => $value ['aid'],
  4905. 'name' => $value ['name'],
  4906. 'price' => number_format ( $other [$ot], 2, '.', '' )
  4907. ) );
  4908. $sum += $other [$ot];
  4909. $otherSum += $other [$ot];
  4910. }
  4911. $ot ++;
  4912. }
  4913. }
  4914. $accountJson ['cSum'] = array (
  4915. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  4916. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  4917. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  4918. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  4919. );
  4920. // 报销单
  4921. $receipt->accountItem = json_encode ( $accountJson );
  4922. $receipt->staff = $this->staff [0] ['sid'];
  4923. $receipt->sum = number_format ( $sum, 2, '.', '' );
  4924. $receipt->date = date ( "Y-m-d" );
  4925. $receipt->cid = $cid;
  4926. $receipt->status = 5;
  4927. // 修改审批流程加入角色
  4928. $receipt->verify = $verify;
  4929. $receipt->executeCopy = $executeDetail ['staff'];
  4930. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  4931. $receipt->explanation = $explanation;
  4932. $rid = $receipt->insert ();
  4933. // 附件
  4934. if (! empty ( $enclosurName )) {
  4935. $enclosurArray = explode ( '-', $enclosurName );
  4936. foreach ( $enclosurArray as $value ) {
  4937. $enclosur = new enclosur ();
  4938. $enclosur->name = $value;
  4939. $enclosur->rid = $rid;
  4940. $enclosur->insert ();
  4941. }
  4942. // print_r($enclosurArray);die;
  4943. }
  4944. // 报销详情
  4945. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  4946. $receiptDetail = new receiptDetail ();
  4947. $receiptDetail->staff = $this->staff [0] ['sid'];
  4948. $receiptDetail->item = $value ['name'];
  4949. $receiptDetail->itemCategory = $this->AGENCY;
  4950. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  4951. $receiptDetail->date = date ( "Y-m-d" );
  4952. $receiptDetail->cid = $cid;
  4953. $receiptDetail->rid = $rid;
  4954. $receiptDetail->status = 4;
  4955. $receiptDetail->insert ();
  4956. }
  4957. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  4958. $receiptDetail = new receiptDetail ();
  4959. $receiptDetail->staff = $this->staff [0] ['sid'];
  4960. $receiptDetail->item = $value ['name'];
  4961. $receiptDetail->itemCategory = $this->TRAVEL;
  4962. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  4963. $receiptDetail->date = date ( "Y-m-d" );
  4964. $receiptDetail->cid = $cid;
  4965. $receiptDetail->rid = $rid;
  4966. $receiptDetail->status = 4;
  4967. $receiptDetail->insert ();
  4968. }
  4969. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  4970. $receiptDetail = new receiptDetail ();
  4971. $receiptDetail->staff = $this->staff [0] ['sid'];
  4972. $receiptDetail->item = $value ['name'];
  4973. $receiptDetail->itemCategory = $this->TRAIN;
  4974. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  4975. $receiptDetail->date = date ( "Y-m-d" );
  4976. $receiptDetail->cid = $cid;
  4977. $receiptDetail->rid = $rid;
  4978. $receiptDetail->status = 4;
  4979. $receiptDetail->insert ();
  4980. }
  4981. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  4982. $receiptDetail = new receiptDetail ();
  4983. $receiptDetail->staff = $this->staff [0] ['sid'];
  4984. $receiptDetail->item = $value ['name'];
  4985. $receiptDetail->itemCategory = $this->OTHER;
  4986. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  4987. $receiptDetail->date = date ( "Y-m-d" );
  4988. $receiptDetail->cid = $cid;
  4989. $receiptDetail->rid = $rid;
  4990. $receiptDetail->status = 4;
  4991. $receiptDetail->insert ();
  4992. }
  4993. // return "/referReceipt/".$rid;
  4994. }
  4995. return "/saeaBorad";
  4996. }
  4997. function referReceipt() {
  4998. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  4999. Doo::loadModel ( 'receipt' );
  5000. Doo::loadModel ( 'verify' );
  5001. $verify = new verify ();
  5002. $receipt = new receipt ();
  5003. Doo::loadModel ( 'L_category' );
  5004. $lCategory = new L_category ();
  5005. Doo::loadModel ( "role" );
  5006. $role = new role ();
  5007. $receiptDetail = $receipt->find ( array (
  5008. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  5009. 'asArray' => true
  5010. ) );
  5011. if (empty ( $receiptDetail ))
  5012. return "/addReceipt";
  5013. foreach ( $receiptDetail as $key => $value ) {
  5014. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5015. $veList = $verify->getOne ( array (
  5016. 'where' => 'vid=' . $value ['verify'],
  5017. 'asArray' => true
  5018. ) );
  5019. $v = json_decode ( $veList ['staff'] );
  5020. array_push ( $v [0], $veList ['description'] );
  5021. foreach ( $v as $n => $m ) {
  5022. if ($m ['1'] == 'ROLE') {
  5023. $roleInfo = $role->getOne ( array (
  5024. 'where' => 'rid=' . $m [0],
  5025. 'asArray' => true
  5026. ) );
  5027. $v [$n] [1] = $roleInfo ['name'];
  5028. }
  5029. }
  5030. $receiptDetail [$key] ['staff'] = $v;
  5031. $category = $lCategory->getOne ( array (
  5032. 'where' => 'cid=' . $value ['cid'],
  5033. 'asArray' => true
  5034. ) );
  5035. $receiptDetail [$key] ['category'] = $category ['title'];
  5036. }
  5037. // print_r($receiptDetail);
  5038. $data ['receiptDetail'] = $receiptDetail;
  5039. $data ['memu'] = "receipt";
  5040. $data ['staff'] = $this->staff;
  5041. $data ['receiptMemu'] = 'saeaCreate';
  5042. $data ['verifyId'] = $this->verifyId;
  5043. $data ['executeId'] = $this->executeId;
  5044. $this->render ( "/admin/saea_confirm", $data );
  5045. }
  5046. function editReceipt() {
  5047. // edit status 4
  5048. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5049. // echo $rid;
  5050. Doo::loadModel ( 'accountItem' );
  5051. Doo::loadModel ( 'verify' );
  5052. Doo::loadModel ( 'receipt' );
  5053. $receipt = new receipt ();
  5054. $verify = new verify ();
  5055. $accountItem = new accountItem ();
  5056. Doo::loadModel ( 'L_category' );
  5057. $lCategory = new L_category ();
  5058. Doo::loadModel ( "role" );
  5059. $role = new role ();
  5060. $receiptDetail = $receipt->getOne ( array (
  5061. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  5062. 'asArray' => true
  5063. ) );
  5064. if (empty ( $receiptDetail ))
  5065. return "/saeaCreate";
  5066. $acItem = $accountItem->find ( array (
  5067. 'asArray' => true
  5068. ) );
  5069. $veList = $verify->find ( array (
  5070. 'asArray' => true
  5071. ) );
  5072. foreach ( $veList as $key => $value ) {
  5073. $v = json_decode ( $value ['staff'] );
  5074. $list = array ();
  5075. foreach ( $v as $n => $m ) {
  5076. if ($m ['1'] == 'ROLE') {
  5077. $roleInfo = $role->getOne ( array (
  5078. 'where' => 'rid=' . $m [0],
  5079. 'asArray' => true
  5080. ) );
  5081. $v [$n] [1] = $roleInfo ['name'];
  5082. array_push ( $list, $roleInfo ['name'] );
  5083. } else {
  5084. array_push ( $list, $v [$n] [1] );
  5085. }
  5086. }
  5087. $veList [$key] ['staff'] = implode ( '>', $list );
  5088. }
  5089. // 配置编辑信息
  5090. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  5091. foreach ( $acItem as $key => $value ) {
  5092. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  5093. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  5094. $acItem [$key] ['price'] = $v ['price'];
  5095. }
  5096. }
  5097. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  5098. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  5099. $acItem [$key] ['price'] = $v ['price'];
  5100. }
  5101. }
  5102. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  5103. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  5104. $acItem [$key] ['price'] = $v ['price'];
  5105. }
  5106. }
  5107. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  5108. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  5109. $acItem [$key] ['price'] = $v ['price'];
  5110. }
  5111. }
  5112. }
  5113. $data ['category'] = $lCategory->find ( array (
  5114. 'asArray' => true
  5115. ) );
  5116. $data ['cSum'] = $accountItemList ['cSum'];
  5117. $data ['sum'] = $receiptDetail ['sum'];
  5118. $data ['receiptDetail'] = $receiptDetail;
  5119. $data ['veList'] = $veList;
  5120. $data ['acItem'] = $acItem;
  5121. $data ['memu'] = "receipt";
  5122. $data ['staff'] = $this->staff;
  5123. $data ['receiptMemu'] = 'saeaBorad';
  5124. $data ['verify'] = $receiptDetail ['verify'];
  5125. $data ['verifyId'] = $this->verifyId;
  5126. $data ['executeId'] = $this->executeId;
  5127. $data ['rid'] = $rid;
  5128. $this->render ( "/admin/saea_edit", $data );
  5129. }
  5130. function updateReceipt() {
  5131. $agency = $this->get_args ( 'agency' );
  5132. $travel = $this->get_args ( 'travel' );
  5133. $train = $this->get_args ( 'train' );
  5134. $other = $this->get_args ( 'other' );
  5135. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5136. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5137. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5138. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5139. if (! empty ( $explanation )) {
  5140. Doo::loadModel ( 'receipt' );
  5141. Doo::loadModel ( 'receiptDetail' );
  5142. Doo::loadModel ( 'accountItem' );
  5143. $accountItem = new accountItem ();
  5144. $receipt = new receipt ();
  5145. Doo::loadModel ( 'execute' );
  5146. $execute = new execute ();
  5147. $receiptDetail = $receipt->getOne ( array (
  5148. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  5149. 'asArray' => true
  5150. ) );
  5151. if (empty ( $receiptDetail ))
  5152. return "/saeaBorad";
  5153. if ($receiptDetail ['Rtype'] == 1)
  5154. $executeDetail = $execute->getOne ( array (
  5155. 'where' => 'mold="借款费用执行人"',
  5156. 'asArray' => true
  5157. ) );
  5158. else
  5159. $executeDetail = $execute->getOne ( array (
  5160. 'where' => 'mold="报销单执行人"',
  5161. 'asArray' => true
  5162. ) );
  5163. $aItem = $accountItem->find ( array (
  5164. 'asArray' => true
  5165. ) );
  5166. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5167. $ag = $tr = $ta = $ot = 0;
  5168. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5169. foreach ( $aItem as $key => $value ) {
  5170. if ($value ['category'] == $this->AGENCY) {
  5171. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5172. array_push ( $accountJson [$this->AGENCY], array (
  5173. 'aid' => $value ['aid'],
  5174. 'name' => $value ['name'],
  5175. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5176. ) );
  5177. $sum += $agency [$ag];
  5178. $agencySum += $agency [$ag];
  5179. }
  5180. $ag ++;
  5181. }
  5182. if ($value ['category'] == $this->TRAVEL) {
  5183. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5184. array_push ( $accountJson [$this->TRAVEL], array (
  5185. 'aid' => $value ['aid'],
  5186. 'name' => $value ['name'],
  5187. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5188. ) );
  5189. $sum += $travel [$tr];
  5190. $travelSum += $travel [$tr];
  5191. }
  5192. $tr ++;
  5193. }
  5194. if ($value ['category'] == $this->TRAIN) {
  5195. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5196. array_push ( $accountJson [$this->TRAIN], array (
  5197. 'aid' => $value ['aid'],
  5198. 'name' => $value ['name'],
  5199. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5200. ) );
  5201. $sum += $train [$ta];
  5202. $trainSum += $train [$ta];
  5203. }
  5204. $ta ++;
  5205. }
  5206. if ($value ['category'] == $this->OTHER) {
  5207. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5208. array_push ( $accountJson [$this->OTHER], array (
  5209. 'aid' => $value ['aid'],
  5210. 'name' => $value ['name'],
  5211. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5212. ) );
  5213. $sum += $other [$ot];
  5214. $otherSum += $other [$ot];
  5215. }
  5216. $ot ++;
  5217. }
  5218. }
  5219. $accountJson ['cSum'] = array (
  5220. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5221. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5222. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5223. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5224. );
  5225. // 报销单
  5226. $rid = $receipt->rid = $receiptDetail ['rid'];
  5227. $receipt->accountItem = json_encode ( $accountJson );
  5228. $receipt->staff = $this->staff [0] ['sid'];
  5229. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5230. $receipt->date = date ( "Y-m-d" );
  5231. $receipt->cid = $cid;
  5232. if (($receiptDetail ['status'] != 4)) {
  5233. if ($receiptDetail ['Rtype'] == 1)
  5234. $receipt->status = 7;
  5235. else
  5236. $receipt->status = 5;
  5237. }
  5238. if ($receiptDetail != 4 && ! empty ( $verify ))
  5239. $receipt->verify = $verify;
  5240. $receipt->executeCopy = $executeDetail ['staff'];
  5241. $receipt->explanation = $explanation;
  5242. $receipt->update ();
  5243. $receiptDetail = new receiptDetail ();
  5244. $receiptDetail->delete ( array (
  5245. 'where' => 'rid=' . $rid
  5246. ) );
  5247. // 报销详情
  5248. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5249. $receiptDetail = new receiptDetail ();
  5250. $receiptDetail->staff = $this->staff [0] ['sid'];
  5251. $receiptDetail->item = $value ['name'];
  5252. $receiptDetail->itemCategory = $this->AGENCY;
  5253. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5254. $receiptDetail->date = date ( "Y-m-d" );
  5255. $receiptDetail->cid = $cid;
  5256. $receiptDetail->rid = $rid;
  5257. $receiptDetail->status = 4;
  5258. $receiptDetail->insert ();
  5259. }
  5260. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5261. $receiptDetail = new receiptDetail ();
  5262. $receiptDetail->staff = $this->staff [0] ['sid'];
  5263. $receiptDetail->item = $value ['name'];
  5264. $receiptDetail->itemCategory = $this->TRAVEL;
  5265. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5266. $receiptDetail->date = date ( "Y-m-d" );
  5267. $receiptDetail->cid = $cid;
  5268. $receiptDetail->rid = $rid;
  5269. $receiptDetail->status = 4;
  5270. $receiptDetail->insert ();
  5271. }
  5272. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5273. $receiptDetail = new receiptDetail ();
  5274. $receiptDetail->staff = $this->staff [0] ['sid'];
  5275. $receiptDetail->item = $value ['name'];
  5276. $receiptDetail->itemCategory = $this->TRAIN;
  5277. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5278. $receiptDetail->date = date ( "Y-m-d" );
  5279. $receiptDetail->cid = $cid;
  5280. $receiptDetail->rid = $rid;
  5281. $receiptDetail->status = 4;
  5282. $receiptDetail->insert ();
  5283. }
  5284. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5285. $receiptDetail = new receiptDetail ();
  5286. $receiptDetail->staff = $this->staff [0] ['sid'];
  5287. $receiptDetail->item = $value ['name'];
  5288. $receiptDetail->itemCategory = $this->OTHER;
  5289. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5290. $receiptDetail->date = date ( "Y-m-d" );
  5291. $receiptDetail->cid = $cid;
  5292. $receiptDetail->rid = $rid;
  5293. $receiptDetail->status = 4;
  5294. $receiptDetail->insert ();
  5295. }
  5296. // return "/referReceipt/".$rid;
  5297. }
  5298. return "/saeaBorad";
  5299. }
  5300. function approvedReceipt() {
  5301. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5302. Doo::loadModel ( 'receipt' );
  5303. Doo::loadModel ( 'receiptDetail' );
  5304. $receipt = new receipt ();
  5305. $receiptDetail = new receiptDetail ();
  5306. Doo::loadModel ( 'statistics' );
  5307. Doo::loadModel ( 'itemStatistics' );
  5308. $statistics = new statistics ();
  5309. $itemStatistics = new itemStatistics ();
  5310. Doo::loadModel ( "verify" );
  5311. $verify = new verify ();
  5312. // 审批状态的判定
  5313. $receiptDetailList = $receipt->getOne ( array (
  5314. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  5315. 'asArray' => true
  5316. ) );
  5317. if (empty ( $receiptDetailList ))
  5318. return "/saeaBorad";
  5319. $verifyDetail = $verify->getOne ( array (
  5320. 'where' => ' vid =' . $receiptDetailList ['verify'],
  5321. 'asArray' => true
  5322. ) );
  5323. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5324. if (empty ( $receiptDetailList ['nowStaff'] )) {
  5325. $nowStaff = "";
  5326. $nowStaffList = array ();
  5327. if ($verifyDetail [0] [1] == 'ROLE') {
  5328. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5329. foreach ( $vStaffString as $key => $value ) {
  5330. $staffK = explode ( "_", $value );
  5331. array_push ( $nowStaffList, $staffK [0] );
  5332. }
  5333. $nowStaff = implode ( ',', $nowStaffList );
  5334. } else {
  5335. $nowStaff = $verifyDetail [0] [0];
  5336. }
  5337. $receipt->nowStaff = $nowStaff;
  5338. }
  5339. // echo $nowStaff;
  5340. // print_r($verifyDetail);die;
  5341. $receipt->rid = $receiptDetailList ['rid'];
  5342. $receipt->date = date ( "Y-m-d" );
  5343. $receipt->status = 2;
  5344. $receipt->update ();
  5345. $receiptDetail->status = 2;
  5346. $receiptDetail->update ( array (
  5347. 'where' => 'rid=' . $receiptDetailList ['rid']
  5348. ) );
  5349. Doo::loadModel ( "receiptLog" );
  5350. $receiptLog = new receiptLog ();
  5351. Doo::loadModel ( "verify" );
  5352. $verify = new verify ();
  5353. $receiptInfo = $receipt->getOne ( array (
  5354. 'where' => 'rid=' . $rid,
  5355. 'asArray' => true
  5356. ) );
  5357. $vr = $verify->getOne ( array (
  5358. 'where' => 'vid=' . $receiptInfo ['verify'],
  5359. 'asArray' => true
  5360. ) );
  5361. $jd = json_decode ( $vr ['staff'] );
  5362. $roleId = 0;
  5363. foreach ( $jd as $key => $value ) {
  5364. if ($value [1] == 'ROLE') {
  5365. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  5366. if ($pos !== false) {
  5367. $roleId = $value [0];
  5368. }
  5369. }
  5370. }
  5371. // 审批日志
  5372. // echo $roleId;die;
  5373. if (! empty ( $roleId )) {
  5374. Doo::loadModel ( "role" );
  5375. $role = new role ();
  5376. $roleInfo = $role->getOne ( array (
  5377. 'where' => 'rid=' . $roleId,
  5378. 'asArray' => true
  5379. ) );
  5380. $receiptLog->rolename = $roleInfo ['name'];
  5381. }
  5382. $receiptLog->username = $this->staff [0] ['username'];
  5383. $receiptLog->uid = $this->staff [0] ['sid'];
  5384. $receiptLog->date = date ( "Y-m-d" );
  5385. $receiptLog->opinion = '提交审批';
  5386. $receiptLog->img = $this->staff [0] ['avatar'];
  5387. $receiptLog->status = 2;
  5388. $receiptLog->rid = $rid;
  5389. $receiptLog->insert ();
  5390. // statistics item
  5391. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  5392. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  5393. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  5394. // print_r($accountItem['cSum']['agencySum']);die;
  5395. // foreach ($accountItem['cSum'] as $key=>$value){
  5396. // if($key=="agencySum"){
  5397. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->AGENCY.'"'.$dateCondition,'asArray'=>true));
  5398. // if(empty($iStatistics)){
  5399. // $itemStatistics->cid=$this->staff[0]['cid'];
  5400. // $itemStatistics->staff=$this->staff[0]['sid'];
  5401. // $itemStatistics->price=$value;
  5402. // $itemStatistics->itemCategory=$this->AGENCY;
  5403. // $itemStatistics->date=date("Y-m-d");
  5404. // $itemStatistics->insert();
  5405. // }else{
  5406. // if (!empty($value)){
  5407. // $itemStatistics->price=$value+$iStatistics['price'];
  5408. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5409. // }
  5410. // }
  5411. // }elseif($key=="travelSum"){
  5412. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->TRAVEL.'"'.$dateCondition,'asArray'=>true));
  5413. // if(empty($iStatistics)){
  5414. // $itemStatistics->cid=$this->staff[0]['cid'];
  5415. // $itemStatistics->staff=$this->staff[0]['sid'];
  5416. // $itemStatistics->price=$value;
  5417. // $itemStatistics->itemCategory=$this->TRAVEL;
  5418. // $itemStatistics->date=date("Y-m-d");
  5419. // $itemStatistics->insert();
  5420. // }else{
  5421. // if (!empty($value)){
  5422. // $itemStatistics->price=$value+$iStatistics['price'];
  5423. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5424. // }
  5425. // }
  5426. // }elseif($key=="trainSum"){
  5427. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->TRAIN.'"'.$dateCondition,'asArray'=>true));
  5428. // if(empty($iStatistics)){
  5429. // $itemStatistics->cid=$this->staff[0]['cid'];
  5430. // $itemStatistics->staff=$this->staff[0]['sid'];
  5431. // $itemStatistics->price=$value;
  5432. // $itemStatistics->itemCategory=$this->TRAIN;
  5433. // $itemStatistics->date=date("Y-m-d");
  5434. // $itemStatistics->insert();
  5435. // }else{
  5436. // if (!empty($value)){
  5437. // $itemStatistics->price=$value+$iStatistics['price'];
  5438. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5439. // }
  5440. // }
  5441. // }elseif($key=="otherSum"){
  5442. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->OTHER.'"'.$dateCondition,'asArray'=>true));
  5443. // if(empty($iStatistics)){
  5444. // $itemStatistics->cid=$this->staff[0]['cid'];
  5445. // $itemStatistics->staff=$this->staff[0]['sid'];
  5446. // $itemStatistics->price=$value;
  5447. // $itemStatistics->itemCategory=$this->OTHER;
  5448. // $itemStatistics->date=date("Y-m-d");
  5449. // $itemStatistics->insert();
  5450. // }else{
  5451. // if (!empty($value)){
  5452. // $itemStatistics->price=$value+$iStatistics['price'];
  5453. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5454. // }
  5455. // }
  5456. // }
  5457. // }
  5458. $stat = $statistics->getOne ( array (
  5459. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5460. 'asArray' => true
  5461. ) );
  5462. if (empty ( $stat )) {
  5463. $statistics->date = date ( "Y-m-d" );
  5464. $statistics->cid = $this->staff [0] ['cid'];
  5465. $statistics->staff = $this->staff [0] ['sid'];
  5466. $statistics->agPrice = 0;
  5467. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5468. $statistics->insert ();
  5469. } else {
  5470. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5471. $statistics->update ( array (
  5472. 'where' => 'sid=' . $stat ['sid']
  5473. ) );
  5474. }
  5475. return "/expenses";
  5476. }
  5477. function approval() {
  5478. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5479. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5480. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5481. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5482. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5483. if (empty ( $status ))
  5484. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5485. $vidList = array ();
  5486. $button = 0;
  5487. Doo::loadModel ( 'verify' );
  5488. $verify = new verify ();
  5489. Doo::loadModel ( 'receipt' );
  5490. $receipt = new receipt ();
  5491. Doo::loadModel ( 'staff' );
  5492. $staff = new staff ();
  5493. Doo::loadModel ( 'L_category' );
  5494. $Lcategory = new L_category ();
  5495. // user verify ID
  5496. $verifyDetail = $verify->find ( array (
  5497. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5498. 'asArray' => true
  5499. ) );
  5500. foreach ( $verifyDetail as $key => $value ) {
  5501. array_push ( $vidList, $value ['vid'] );
  5502. }
  5503. $vid = implode ( ",", $vidList );
  5504. if (empty ( $verifyDetail ))
  5505. $vid = 0;
  5506. /*
  5507. */
  5508. $dateCondition = " and Year(date) =" . $year;
  5509. if (! empty ( $month ))
  5510. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  5511. $categoryList = $Lcategory->find ( array (
  5512. 'asArray' => true
  5513. ) );
  5514. $staffList = $staff->find ( array (
  5515. 'where' => 'cid=' . $cid,
  5516. 'asArray' => true
  5517. ) );
  5518. $cateCondition = "";
  5519. $staffCondition = "";
  5520. $approvalCondition = "";
  5521. if (! empty ( $cid ))
  5522. $cateCondition = ' and cid=' . $cid;
  5523. if (! empty ( $sid )) {
  5524. $staffCondition = ' and staff=' . $sid;
  5525. $cateCondition = "";
  5526. }
  5527. // elseif($status==1){
  5528. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  5529. // }
  5530. if ($status == 2) {
  5531. // 查找角色审批人
  5532. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  5533. }
  5534. $ap = "";
  5535. if ($status == 4) {
  5536. $ap = 4;
  5537. $status = 2;
  5538. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  5539. }
  5540. if ($status == 5) {
  5541. $status = 4;
  5542. $ap = 5;
  5543. }
  5544. // echo $vid;
  5545. // get Receipt By verifyID status 2 .$approvalCondition
  5546. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  5547. $receiptList = $receipt->find ( array (
  5548. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  5549. 'desc' => 'rid',
  5550. 'asArray' => true
  5551. ) );
  5552. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  5553. $Locate = 0;
  5554. if ($ap == 4)
  5555. $status = 4;
  5556. elseif ($ap == 5)
  5557. $status = 5;
  5558. foreach ( $receiptList as $key => $value ) {
  5559. $receiptList [$key] ['Locate'] = $Locate;
  5560. $Locate ++;
  5561. $receiptList [$key] ['reviseDetail'] = array ();
  5562. if (! empty ( $value ['reviseDetail'] ))
  5563. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5564. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5565. $categoryDetil = $Lcategory->getOne ( array (
  5566. 'where' => 'cid=' . $value ['cid'],
  5567. 'asArray' => true
  5568. ) );
  5569. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5570. $verifyList = $verify->getOne ( array (
  5571. 'where' => 'vid=' . $value ['verify'],
  5572. 'asArray' => true
  5573. ) );
  5574. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5575. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5576. foreach ( $verifyList as $k => $v ) {
  5577. // init verifyStaff
  5578. $verifyList [$k] ['date'] = "";
  5579. $verifyList [$k] ['opinion'] = "";
  5580. $verifyList [$k] ['status'] = "";
  5581. if (empty ( $verifyStaff )) {
  5582. $verifyList [$k] ['date'] = "";
  5583. $verifyList [$k] ['opinion'] = "";
  5584. if ($v [0] == $this->staff [0] ['sid']) {
  5585. $verifyList [$k] ['status'] = 4;
  5586. $button = 4;
  5587. }
  5588. } else {
  5589. $flag = true;
  5590. foreach ( $verifyStaff as $m => $u ) {
  5591. if ($v [0] == $m) {
  5592. $verifyList [$k] ['date'] = $u ['date'];
  5593. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5594. $verifyList [$k] ['status'] = $u ['status'];
  5595. $flag = false;
  5596. break;
  5597. }
  5598. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  5599. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  5600. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  5601. }
  5602. if ($flag) { // 检测可编辑
  5603. if ($v [0] == $this->staff [0] ['sid']) {
  5604. $verifyList [$k] ['status'] = 4;
  5605. $button = 4;
  5606. }
  5607. }
  5608. }
  5609. }
  5610. $receiptList [$key] ['verifyList'] = $verifyList;
  5611. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5612. 'where' => 'sid=' . $value ['staff'],
  5613. 'asArray' => true
  5614. ) );
  5615. $receiptList [$key] ['button'] = $button;
  5616. }
  5617. // print_r($receiptList);die;
  5618. // $data['verifyDetail']=$verifyDetail;
  5619. $mothHtml = "";
  5620. for($i = 1; $i <= 12; $i ++) {
  5621. if ($month == $i)
  5622. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5623. else
  5624. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5625. }
  5626. $data ['mothHtml'] = $mothHtml;
  5627. $data ['receiptList'] = $receiptList;
  5628. $data ['receiptApprovalCount'] = count ( $receiptList );
  5629. $data ['status'] = $status;
  5630. $data ['year'] = $year;
  5631. $data ['categoryList'] = $categoryList;
  5632. $data ['staffList'] = $staffList;
  5633. $data ['cid'] = $cid;
  5634. $data ['sid'] = $sid;
  5635. $data ['ap'] = $ap;
  5636. $data ['memu'] = "receipt";
  5637. $data ['staff'] = $this->staff;
  5638. $data ['receiptMemu'] = 'approval';
  5639. $data ['verifyId'] = $this->verifyId;
  5640. $data ['executeId'] = $this->executeId;
  5641. $this->render ( "/admin/saea_reportList", $data );
  5642. }
  5643. function approvalDetails() {
  5644. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5645. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5646. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5647. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5648. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5649. Doo::loadModel ( 'verify' );
  5650. $verify = new verify ();
  5651. Doo::loadModel ( 'receipt' );
  5652. $receipt = new receipt ();
  5653. Doo::loadModel ( 'staff' );
  5654. $staff = new staff ();
  5655. Doo::loadModel ( 'L_category' );
  5656. $Lcategory = new L_category ();
  5657. Doo::loadModel ( 'enclosur' );
  5658. $enclosur = new enclosur ();
  5659. $vidList = array ();
  5660. $verifyDetail = $verify->find ( array (
  5661. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5662. 'asArray' => true
  5663. ) );
  5664. foreach ( $verifyDetail as $key => $value ) {
  5665. array_push ( $vidList, $value ['vid'] );
  5666. }
  5667. $vid = implode ( ",", $vidList );
  5668. if (empty ( $verifyDetail ))
  5669. $vid = 0;
  5670. $categoryList = $Lcategory->find ( array (
  5671. 'asArray' => true
  5672. ) );
  5673. $staffList = $staff->find ( array (
  5674. 'where' => 'cid=' . $cid,
  5675. 'asArray' => true
  5676. ) );
  5677. $ap = 0;
  5678. $receiptList = $receipt->find ( array (
  5679. 'where' => 'rid =' . $rid,
  5680. 'desc' => 'rid',
  5681. 'asArray' => true
  5682. ) );
  5683. $Locate = 0;
  5684. $roleId = 0;
  5685. $button = 0;
  5686. foreach ( $receiptList as $key => $value ) {
  5687. $receiptList [$key] ['Locate'] = $Locate;
  5688. $Locate ++;
  5689. $receiptList [$key] ['reviseDetail'] = array ();
  5690. if (! empty ( $value ['reviseDetail'] ))
  5691. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5692. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5693. $categoryDetil = $Lcategory->getOne ( array (
  5694. 'where' => 'cid=' . $value ['cid'],
  5695. 'asArray' => true
  5696. ) );
  5697. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5698. // 检测编辑状态
  5699. $verifyList = $verify->getOne ( array (
  5700. 'where' => 'vid=' . $value ['verify'],
  5701. 'asArray' => true
  5702. ) );
  5703. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5704. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5705. Doo::loadModel ( 'role' );
  5706. $role = new role ();
  5707. // print_r($verifyList);
  5708. $flag = true;
  5709. $roleKey = 0;
  5710. $endStaffArray = array ();
  5711. $roleArrayCopy = array ();
  5712. foreach ( $verifyList as $k => $v ) {
  5713. // init verifyStaff
  5714. if ($v [1] == 'ROLE') {
  5715. if (! empty ( $verifyStaff )) {
  5716. $endStaffArray = end ( $verifyStaff );
  5717. if ($v [0] == $endStaffArray ['nextStaff']) {
  5718. $roleId = $v [0];
  5719. }
  5720. }
  5721. $roleVerify = json_decode ( $v [3], true );
  5722. $roleKey = $k;
  5723. $roleArray = array ();
  5724. $rolename = $role->getOne ( array (
  5725. 'where' => 'rid=' . $v [0],
  5726. 'asArray' => true
  5727. ) );
  5728. foreach ( $roleVerify as $o => $p ) {
  5729. $staffID = explode ( '_', $p );
  5730. $staffInfo = $staff->getOne ( array (
  5731. 'where' => 'sid=' . $staffID [0],
  5732. 'asArray' => true
  5733. ) );
  5734. // print_r($staffID);
  5735. $exp = array (
  5736. 0 => $staffInfo ['sid'],
  5737. 1 => $staffID [1],
  5738. 2 => $staffInfo ['avatar'],
  5739. 'date' => '',
  5740. 'date' => '',
  5741. 'opinion' => '',
  5742. 'status' => '',
  5743. 'rolename' => $rolename ['name']
  5744. );
  5745. array_push ( $roleArray, $exp );
  5746. }
  5747. $roleArrayCopy [$v [0]] = $roleArray;
  5748. // $verifyList[$k]['roleArray']=$roleArray;
  5749. }
  5750. // print_r($roleArray);
  5751. $verifyList [$k] ['date'] = "";
  5752. $verifyList [$k] ['opinion'] = "";
  5753. $verifyList [$k] ['status'] = "";
  5754. if (empty ( $verifyStaff )) {
  5755. $verifyList [$k] ['date'] = "";
  5756. $verifyList [$k] ['opinion'] = "";
  5757. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5758. $verifyList [$k] ['status'] = 4;
  5759. $button = 4;
  5760. $flag = false;
  5761. }
  5762. } else {
  5763. foreach ( $verifyStaff as $m => $u ) {
  5764. if ($v [0] == $m) {
  5765. $verifyList [$k] ['date'] = $u ['date'];
  5766. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5767. $verifyList [$k] ['status'] = $u ['status'];
  5768. $flag = false;
  5769. break;
  5770. }
  5771. }
  5772. $endStaffArray = end ( $verifyStaff );
  5773. if (isset ( $endStaffArray ['ROLE'] )) {
  5774. } else {
  5775. $endKey = key ( $verifyStaff );
  5776. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5777. $button = 4;
  5778. $verifyList [$k] ['status'] = 4;
  5779. }
  5780. }
  5781. }
  5782. }
  5783. $rolename ['name'] = '';
  5784. if (! empty ( $roleId )) {
  5785. Doo::loadModel ( 'role' );
  5786. $role = new role ();
  5787. $rolename = $role->getOne ( array (
  5788. 'where' => 'rid=' . $roleId,
  5789. 'asArray' => true
  5790. ) );
  5791. }
  5792. if (! empty ( $verifyStaff ))
  5793. $endStaffArray = end ( $verifyStaff );
  5794. $KOP = false;
  5795. foreach ( $roleArrayCopy as $P => $A ) {
  5796. foreach ( $A as $MKI => $AVL ) {
  5797. if (! empty ( $verifyStaff )) {
  5798. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5799. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5800. $button = 4;
  5801. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5802. }
  5803. foreach ( $verifyStaff as $m => $u ) {
  5804. $AVLFK = $AVL [0] . '_R';
  5805. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5806. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5807. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5808. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5809. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5810. break;
  5811. }
  5812. }
  5813. } else {
  5814. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5815. $button = 4;
  5816. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5817. }
  5818. }
  5819. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5820. $KOP = true;
  5821. }
  5822. }
  5823. foreach ( $roleArrayCopy as $k => $v ) {
  5824. foreach ( $verifyList as $m => $n ) {
  5825. if ($n [0] == $k) {
  5826. array_splice ( $verifyList, $m, 1, $v );
  5827. }
  5828. }
  5829. }
  5830. $receiptList [$key] ['verifyList'] = $verifyList;
  5831. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5832. 'where' => 'sid=' . $value ['staff'],
  5833. 'asArray' => true
  5834. ) );
  5835. $receiptList [$key] ['button'] = $button;
  5836. }
  5837. $mothHtml = "";
  5838. for($i = 1; $i <= 12; $i ++) {
  5839. if ($month == $i)
  5840. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5841. else
  5842. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5843. }
  5844. // 获取审批日志
  5845. Doo::loadModel ( 'receiptLog' );
  5846. $receiptLog = new receiptLog ();
  5847. $rlList = array ();
  5848. $rlInfo = $receiptLog->getOne ( array (
  5849. 'where' => 'rid=' . $rid . ' and status=4',
  5850. 'asArray' => true
  5851. ) );
  5852. $tijdate = $receiptLog->getOne ( array (
  5853. 'where' => 'rid=' . $rid . ' and status=2',
  5854. 'asc' => 'rlid',
  5855. 'asArray' => true
  5856. ) );
  5857. if (! empty ( $rlInfo )) {
  5858. $rlList = $receiptLog->find ( array (
  5859. 'where' => 'rid=' . $rid,
  5860. 'asc' => 'rlid',
  5861. 'asArray' => true
  5862. ) );
  5863. }
  5864. $receiptList [0] ['rlList'] = $rlList;
  5865. $enclosurList = $enclosur->find ( array (
  5866. 'where' => 'rid=' . $rid,
  5867. 'asArray' => true
  5868. ) );
  5869. $enclosurHtml = '';
  5870. foreach ( $enclosurList as $value ) {
  5871. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5872. }
  5873. $data ['enclosurHtml'] = $enclosurHtml;
  5874. $data ['rolename'] = $rolename ['name'];
  5875. $data ['datetij'] = $tijdate ['date'];
  5876. $data ['mothHtml'] = $mothHtml;
  5877. $data ['receiptList'] = $receiptList;
  5878. $data ['receiptApprovalCount'] = count ( $receiptList );
  5879. $data ['year'] = $year;
  5880. $data ['categoryList'] = $categoryList;
  5881. $data ['staffList'] = $staffList;
  5882. $data ['cid'] = $cid;
  5883. $data ['sid'] = $sid;
  5884. $data ['status'] = 0;
  5885. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  5886. $ap = 4;
  5887. } else
  5888. $data ['status'] = $receiptList [0] ['status'];
  5889. if ($receiptList [0] ['status'] == 4) {
  5890. $data ['status'] = 5;
  5891. $ap = 0;
  5892. }
  5893. $data ['ap'] = $ap;
  5894. $data ['memu'] = "receipt";
  5895. $data ['staff'] = $this->staff;
  5896. $data ['receiptMemu'] = 'approval';
  5897. $data ['verifyId'] = $this->verifyId;
  5898. $data ['executeId'] = $this->executeId;
  5899. $this->render ( "/admin/saeaReportListReport", $data );
  5900. }
  5901. function approvalEdi() {
  5902. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5903. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5904. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5905. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5906. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5907. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5908. if (empty ( $status ))
  5909. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5910. $vidList = array ();
  5911. $button = 0;
  5912. Doo::loadModel ( 'verify' );
  5913. Doo::loadModel ( 'receipt' );
  5914. Doo::loadModel ( 'staff' );
  5915. $staff = new staff ();
  5916. $receipt = new receipt ();
  5917. $verify = new verify ();
  5918. Doo::loadModel ( 'L_category' );
  5919. $Lcategory = new L_category ();
  5920. Doo::loadModel ( 'enclosur' );
  5921. $enclosur = new enclosur ();
  5922. // user verify ID
  5923. $verifyDetail = $verify->find ( array (
  5924. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5925. 'asArray' => true
  5926. ) );
  5927. foreach ( $verifyDetail as $key => $value ) {
  5928. array_push ( $vidList, $value ['vid'] );
  5929. }
  5930. $vid = implode ( ",", $vidList );
  5931. if (empty ( $verifyDetail ))
  5932. $vid = 0;
  5933. $categoryList = $Lcategory->find ( array (
  5934. 'asArray' => true
  5935. ) );
  5936. $staffList = $staff->find ( array (
  5937. 'where' => 'cid=' . $cid,
  5938. 'asArray' => true
  5939. ) );
  5940. $ap = "";
  5941. if ($status == 4) {
  5942. $ap = 4;
  5943. $status = 2;
  5944. }
  5945. // get Receipt By verifyID status 2
  5946. $receiptList = $receipt->find ( array (
  5947. 'where' => 'rid =' . $rid,
  5948. 'desc' => 'rid',
  5949. 'asArray' => true
  5950. ) );
  5951. $Locate = 0;
  5952. $roleId = 0;
  5953. if ($ap == 4)
  5954. $status = 4;
  5955. foreach ( $receiptList as $key => $value ) {
  5956. $receiptList [$key] ['Locate'] = $Locate;
  5957. $Locate ++;
  5958. $receiptList [$key] ['reviseDetail'] = array ();
  5959. if (! empty ( $value ['reviseDetail'] ))
  5960. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5961. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5962. $categoryDetil = $Lcategory->getOne ( array (
  5963. 'where' => 'cid=' . $value ['cid'],
  5964. 'asArray' => true
  5965. ) );
  5966. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5967. // 检测编辑状态
  5968. $verifyList = $verify->getOne ( array (
  5969. 'where' => 'vid=' . $value ['verify'],
  5970. 'asArray' => true
  5971. ) );
  5972. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5973. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5974. // print_r($verifyList);
  5975. //
  5976. // if (empty($verifyStaff)){
  5977. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  5978. // $verifyList[0]['status']=4;$button=4;
  5979. // }
  5980. //
  5981. // }else{
  5982. //
  5983. // }
  5984. // die;
  5985. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  5986. // echo array_search("green",$a);
  5987. //
  5988. Doo::loadModel ( 'role' );
  5989. $role = new role ();
  5990. // print_r($verifyList);
  5991. $flag = true;
  5992. $roleKey = 0;
  5993. $endStaffArray = array ();
  5994. $roleArrayCopy = array ();
  5995. foreach ( $verifyList as $k => $v ) {
  5996. // init verifyStaff
  5997. if ($v [1] == 'ROLE') {
  5998. if (! empty ( $verifyStaff )) {
  5999. $endStaffArray = end ( $verifyStaff );
  6000. if ($v [0] == $endStaffArray ['nextStaff']) {
  6001. $roleId = $v [0];
  6002. }
  6003. }
  6004. $roleVerify = json_decode ( $v [3], true );
  6005. $roleKey = $k;
  6006. $roleArray = array ();
  6007. $rolename = $role->getOne ( array (
  6008. 'where' => 'rid=' . $v [0],
  6009. 'asArray' => true
  6010. ) );
  6011. foreach ( $roleVerify as $o => $p ) {
  6012. $staffID = explode ( '_', $p );
  6013. $staffInfo = $staff->getOne ( array (
  6014. 'where' => 'sid=' . $staffID [0],
  6015. 'asArray' => true
  6016. ) );
  6017. // print_r($staffID);
  6018. $exp = array (
  6019. 0 => $staffInfo ['sid'],
  6020. 1 => $staffID [1],
  6021. 2 => $staffInfo ['avatar'],
  6022. 'date' => '',
  6023. 'date' => '',
  6024. 'opinion' => '',
  6025. 'status' => '',
  6026. 'rolename' => $rolename ['name']
  6027. );
  6028. array_push ( $roleArray, $exp );
  6029. }
  6030. $roleArrayCopy [$v [0]] = $roleArray;
  6031. // $verifyList[$k]['roleArray']=$roleArray;
  6032. }
  6033. // print_r($roleArray);
  6034. $verifyList [$k] ['date'] = "";
  6035. $verifyList [$k] ['opinion'] = "";
  6036. $verifyList [$k] ['status'] = "";
  6037. if (empty ( $verifyStaff )) {
  6038. $verifyList [$k] ['date'] = "";
  6039. $verifyList [$k] ['opinion'] = "";
  6040. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6041. $verifyList [$k] ['status'] = 4;
  6042. $button = 4;
  6043. $flag = false;
  6044. }
  6045. } else {
  6046. foreach ( $verifyStaff as $m => $u ) {
  6047. if ($v [0] == $m) {
  6048. $verifyList [$k] ['date'] = $u ['date'];
  6049. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6050. $verifyList [$k] ['status'] = $u ['status'];
  6051. $flag = false;
  6052. break;
  6053. }
  6054. }
  6055. $endStaffArray = end ( $verifyStaff );
  6056. if (isset ( $endStaffArray ['ROLE'] )) {
  6057. } else {
  6058. $endKey = key ( $verifyStaff );
  6059. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6060. $button = 4;
  6061. $verifyList [$k] ['status'] = 4;
  6062. }
  6063. }
  6064. // print_r($endStaffArray);die;
  6065. // if (empty($verifyStaff)){
  6066. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6067. // $verifyList[$k]['status']=4;$button=4;
  6068. // }
  6069. //
  6070. // }else{
  6071. //
  6072. // }
  6073. // if($flag){//检测可编辑
  6074. // if($v[0]==$this->staff[0]['sid']){
  6075. // $verifyList[$k]['status']=4;$button=4;
  6076. // }
  6077. // }
  6078. }
  6079. }
  6080. $rolename ['name'] = '';
  6081. if (! empty ( $roleId )) {
  6082. Doo::loadModel ( 'role' );
  6083. $role = new role ();
  6084. $rolename = $role->getOne ( array (
  6085. 'where' => 'rid=' . $roleId,
  6086. 'asArray' => true
  6087. ) );
  6088. }
  6089. if (! empty ( $verifyStaff ))
  6090. $endStaffArray = end ( $verifyStaff );
  6091. $KOP = false;
  6092. foreach ( $roleArrayCopy as $P => $A ) {
  6093. foreach ( $A as $MKI => $AVL ) {
  6094. if (! empty ( $verifyStaff )) {
  6095. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6096. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6097. $button = 4;
  6098. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6099. }
  6100. foreach ( $verifyStaff as $m => $u ) {
  6101. $AVLFK = $AVL [0] . '_R';
  6102. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6103. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6104. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6105. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6106. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6107. break;
  6108. }
  6109. }
  6110. } else {
  6111. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6112. $button = 4;
  6113. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6114. }
  6115. }
  6116. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6117. $KOP = true;
  6118. }
  6119. }
  6120. // print_r($roleArrayCopy);
  6121. // echo $roleKey;
  6122. foreach ( $roleArrayCopy as $k => $v ) {
  6123. foreach ( $verifyList as $m => $n ) {
  6124. if ($n [0] == $k) {
  6125. array_splice ( $verifyList, $m, 1, $v );
  6126. }
  6127. }
  6128. }
  6129. // if ($KOP)
  6130. // array_splice($verifyList,$roleKey,1,$roleArray);
  6131. // print_r($verifyList);
  6132. $receiptList [$key] ['verifyList'] = $verifyList;
  6133. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6134. 'where' => 'sid=' . $value ['staff'],
  6135. 'asArray' => true
  6136. ) );
  6137. $receiptList [$key] ['button'] = $button;
  6138. }
  6139. // $data['verifyDetail']=$verifyDetail;
  6140. $mothHtml = "";
  6141. for($i = 1; $i <= 12; $i ++) {
  6142. if ($month == $i)
  6143. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6144. else
  6145. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6146. }
  6147. // 获取审批日志
  6148. Doo::loadModel ( 'receiptLog' );
  6149. $receiptLog = new receiptLog ();
  6150. $rlList = array ();
  6151. $rlInfo = $receiptLog->getOne ( array (
  6152. 'where' => 'rid=' . $rid . ' and status=4',
  6153. 'asArray' => true
  6154. ) );
  6155. $tijdate = $receiptLog->getOne ( array (
  6156. 'where' => 'rid=' . $rid . ' and status=2',
  6157. 'asc' => 'rlid',
  6158. 'asArray' => true
  6159. ) );
  6160. if (! empty ( $rlInfo )) {
  6161. $rlList = $receiptLog->find ( array (
  6162. 'where' => 'rid=' . $rid,
  6163. 'asc' => 'rlid',
  6164. 'asArray' => true
  6165. ) );
  6166. }
  6167. $receiptList [0] ['rlList'] = $rlList;
  6168. $enclosurList = $enclosur->find ( array (
  6169. 'where' => 'rid=' . $rid,
  6170. 'asArray' => true
  6171. ) );
  6172. $enclosurHtml = '';
  6173. foreach ( $enclosurList as $value ) {
  6174. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6175. }
  6176. $data ['enclosurHtml'] = $enclosurHtml;
  6177. $data ['rolename'] = $rolename ['name'];
  6178. $data ['datetij'] = $tijdate ['date'];
  6179. $data ['mothHtml'] = $mothHtml;
  6180. $data ['receiptList'] = $receiptList;
  6181. $data ['receiptApprovalCount'] = count ( $receiptList );
  6182. $data ['status'] = $status;
  6183. $data ['year'] = $year;
  6184. $data ['categoryList'] = $categoryList;
  6185. $data ['staffList'] = $staffList;
  6186. $data ['cid'] = $cid;
  6187. $data ['sid'] = $sid;
  6188. $data ['ap'] = $ap;
  6189. $data ['memu'] = "receipt";
  6190. $data ['staff'] = $this->staff;
  6191. $data ['receiptMemu'] = 'approval';
  6192. $data ['verifyId'] = $this->verifyId;
  6193. $data ['executeId'] = $this->executeId;
  6194. $this->render ( "/admin/saeaReportListReport", $data );
  6195. }
  6196. function remittanceHky() {
  6197. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6198. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  6199. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6200. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  6201. $page_size = 15;
  6202. $get = "?year=".$year."&moth=".$moth."&day=".$day;
  6203. Doo::loadModel ( 'receipt' );
  6204. $receipt = new receipt ();
  6205. Doo::loadModel ( 'staff' );
  6206. $staff = new staff ();
  6207. $dateCondition = " and Year(executeDate) =" . $year;
  6208. if ($moth != 'MONTH')
  6209. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  6210. if ($day != 'DAY'&&$moth != 'MONTH')
  6211. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  6212. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  6213. $table='(SELECT count(*) FROM CLD_receipt WHERE '.$sql.' group by executeDate ) a ';
  6214. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  6215. $limit = $pageinfo ['lower'] . ',' . $page_size;
  6216. $dayList = $receipt->find ( array (
  6217. 'select' => 'executeDate,sum(amount) as amount',
  6218. 'where' => $sql,
  6219. 'desc' => 'executeDate',
  6220. 'groupby' => 'executeDate',
  6221. 'limit' => $limit,
  6222. 'asArray' => true
  6223. ) );
  6224. //print_r($dayList);
  6225. foreach ( $dayList as $key => $value ) {
  6226. $remitString = "";
  6227. $receiptList = $receipt->find ( array (
  6228. 'select' => 'rid,executeDate,amount,staff,cid',
  6229. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'].'"',
  6230. 'desc' => 'executeDate',
  6231. 'asArray' => true
  6232. ) );
  6233. foreach ( $receiptList as $k => $v ) {
  6234. $sinfo = $staff->getOne ( array (
  6235. 'select' => 'username,category',
  6236. 'where' => ' sid=' . $v ['staff'],
  6237. 'asArray' => true
  6238. ) );
  6239. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  6240. }
  6241. $dayList [$key] ['staff'] = $remitString;
  6242. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  6243. }
  6244. //print_r($dayList);
  6245. $mothHtml = "";
  6246. for($i = 1; $i <= 12; $i ++) {
  6247. if ($moth == $i)
  6248. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6249. else
  6250. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6251. }
  6252. $dayHtml = "";
  6253. if ($day != "DAY" || $moth != "MONTH") {
  6254. for($i = 1; $i <= 31; $i ++) {
  6255. if ($day == $i)
  6256. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6257. else
  6258. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6259. }
  6260. }
  6261. $data ['page'] = $pageinfo;
  6262. $data ['year'] = $year;
  6263. $data ['moth'] = $moth;
  6264. $data ['day'] = $day;
  6265. $data ['get'] = $get;
  6266. $data ['dayHtml'] = $dayHtml;
  6267. $data ['mothHtml'] = $mothHtml;
  6268. $data ['receiptList'] = $dayList;
  6269. $data ['memu'] = "receipt";
  6270. $data ['staff'] = $this->staff;
  6271. $data ['receiptMemu'] = 'remittanceHky';
  6272. $data ['verifyId'] = $this->verifyId;
  6273. $data ['executeId'] = $this->executeId;
  6274. $this->render ( "/admin/remittanceHky", $data );
  6275. }
  6276. function remittancep(){
  6277. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  6278. Doo::loadModel ( 'receipt' );
  6279. $receipt = new receipt ();
  6280. Doo::loadModel ( 'staff' );
  6281. $staff = new staff ();
  6282. Doo::loadClass ( 'XDeode' );
  6283. $XDeode = new XDeode ( 5 );
  6284. $dateCondition=' and executeDate="'.date('Y-m-d', $timeStamp).'"';
  6285. $rplist = $receipt->find ( array (
  6286. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6287. 'asArray' => true
  6288. ) );
  6289. $dayList = $receipt->find ( array (
  6290. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6291. 'desc' => 'executeDate',
  6292. 'groupby' => 'staff',
  6293. 'asArray' => true
  6294. ) );
  6295. $html='';
  6296. foreach ( $dayList as $key => $value ) {
  6297. $sinfo = $staff->getOne ( array (
  6298. 'select' => 'username,category',
  6299. 'where' => ' sid=' . $value ['staff'],
  6300. 'asArray' => true
  6301. ) );
  6302. $html.='<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">'.$sinfo['category'].'-'.$sinfo['username'].'</th></tr></thead><tbody>
  6303. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  6304. $au=0;
  6305. foreach ($rplist as $k=>$v){
  6306. if ($value ['staff']==$v['staff']){
  6307. $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>';
  6308. $au+=$v['amount'];
  6309. }
  6310. }
  6311. $html.='<tr><td>合计</td><td class="taR"><b>¥'.$au.'</b></td></tr></tbody></table>';
  6312. }
  6313. $data ['html'] =$html;
  6314. $data ['memu'] = "receipt";
  6315. $data ['staff'] = $this->staff;
  6316. $data ['receiptMemu'] = 'remittanceHky';
  6317. $data ['verifyId'] = $this->verifyId;
  6318. $data ['executeId'] = $this->executeId;
  6319. $this->render ( "/admin/remittancep", $data );
  6320. }
  6321. function ajaxGetReceiptDetails(){
  6322. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  6323. Doo::loadClass ( 'XDeode' );
  6324. $XDeode = new XDeode ( 5 );
  6325. $rid=$XDeode->decode($rid);
  6326. if (empty ( $rid )) {
  6327. echo json_encode ( array (
  6328. 'status' => 2,
  6329. 'msg' => 'illegal request'
  6330. ) );
  6331. die ();
  6332. }
  6333. Doo::loadModel ( 'receipt' );
  6334. $receipt = new receipt ();
  6335. Doo::loadModel ( 'staff' );
  6336. $staff = new staff ();
  6337. $rinfo = $receipt->getOne ( array (
  6338. 'where' => 'rid= ' . $rid,
  6339. 'asArray' => true
  6340. ) );
  6341. $sinfo = $staff->getOne ( array (
  6342. 'select' => 'username,category',
  6343. 'where' => ' sid=' . $rinfo ['staff'],
  6344. 'asArray' => true
  6345. ) );
  6346. $rinfo['reviseDetail'] = array ();
  6347. if (! empty ( $rinfo ['reviseDetail'] ))
  6348. $rinfo['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  6349. $rinfo['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  6350. $rinfo['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  6351. $rinfo['category'] = $sinfo ['category'];
  6352. $verifyStaff=array();
  6353. if (!empty($rinfo ['verifyStaff']))
  6354. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  6355. $relust = $rinfo ['sum'] - $rinfo ['loanSum'];
  6356. $rinfo ['relust'] = $relust;
  6357. $rinfo['relustCN'] = $this->num_to_rmb ( $relust );
  6358. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  6359. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  6360. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  6361. // 费用执行人相关数据
  6362. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6363. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6364. foreach ( $executeCopy as $k => $v ) {
  6365. $executeCopy [$k] ['date'] = '';
  6366. $executeCopy [$k] ['opinion'] = '';
  6367. $executeCopy [$k] ['status'] = '';
  6368. if (! empty ( $executeStaff ))
  6369. foreach ( $executeStaff as $m => $u ) {
  6370. if ($v [0] == $m) {
  6371. $executeCopy [$k] ['date'] = $u ['date'];
  6372. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  6373. $executeCopy [$k] ['status'] = $u ['status'];
  6374. break;
  6375. }
  6376. }
  6377. }
  6378. $rinfo ['executeCopy'] = $executeCopy;
  6379. $html='<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  6380. if ($rinfo['Rtype']==1){//借款费用
  6381. $html.='<table class="table table-bordered table-condensed table-hover"><tbody>
  6382. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  6383. foreach ($rinfo['loanItem']['借款费用'] as $value){
  6384. $html.='<tr><th>'.$value['name'].'</th>
  6385. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6386. }
  6387. $html.='<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6388. <tr><th style="text-align:center" colspan="2">'.$rinfo['category'].'</th></tr>
  6389. <tr><th class="taC" colspan="2">费用说明</th>
  6390. </tr><tr><td colspan="2">'.$rinfo['explanation'].'</td></tr>
  6391. <tr class="warning"><td class="taR"><b>('.$rinfo['receiptOrder'].')本次费用合计</b></td>
  6392. <td class="taR"><b style="font-size:24px">¥'.$rinfo['loanSum'].'</b><br>'.$rinfo['loanSumCN'].'</td></tr>
  6393. </tbody></table>';
  6394. if ($rinfo['loanRid']!=0&&!empty($rinfo['accountItem'])){
  6395. $html.='<table class="table table-bordered table-condensed table-hover"><tbody>';
  6396. $html.='<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6397. foreach ($rinfo['accountItem']['日常相关费用'] as $value){
  6398. $html.='<tr><th>'.$value['name'].'</th>
  6399. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6400. }
  6401. $html.='<tr><th class="taR">合计</th>
  6402. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['agencySum'].'</td></tr>';
  6403. $html.='<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6404. foreach ($rinfo['accountItem']['差旅相关费用'] as $value){
  6405. $html.='<tr><th>'.$value['name'].'</th>
  6406. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6407. }
  6408. $html.='<tr><th class="taR">合计</th>
  6409. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['travelSum'].'</td></tr>';
  6410. $html.='<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6411. foreach ($rinfo['accountItem']['培训班费用'] as $value){
  6412. $html.='<tr><th>'.$value['name'].'</th>
  6413. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6414. }
  6415. $html.='<tr><th class="taR">合计</th>
  6416. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['trainSum'].'</td></tr>';
  6417. $html.='<tr><th colspan="2" class="taC">其他</th></tr>';
  6418. foreach ($rinfo['accountItem']['其他'] as $value){
  6419. $html.='<tr><th>'.$value['name'].'</th>
  6420. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6421. }
  6422. $html.='<tr><th class="taR">合计</th>
  6423. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['otherSum'].'</td></tr>';
  6424. $html.='<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6425. foreach ($rinfo['reviseDetail'] as $value){
  6426. $html.='<tr><th><span class="interval">|</span>'.$value['name'].':'.$value['description'].'</th>
  6427. <td class="taR">¥'.$value['price'].'</td></tr>';
  6428. }
  6429. $html.='<tr><th class="taR">合计</th>
  6430. <td class="colGreen taR">¥'.$rinfo['revisePrice'].'</td></tr>';
  6431. $html.='<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6432. <tr><th style="text-align:center" colspan="2">'.$rinfo['category'].'</th></tr>
  6433. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6434. <tr><td colspan="2">'.$rinfo['explanation'].'</td></tr>
  6435. <tr class="warning"><td class="taR"><b>('.$rinfo['receiptOrder'].')本次报销费用合计</b></td>
  6436. <td class="colGreed taR"><b style="font-size:24px">¥'.$rinfo['sum'].'</b><br>'.$rinfo['sumCN'].'</td></tr>
  6437. <tr';
  6438. if($rinfo['relust']>=0){
  6439. $html.='class="success"';
  6440. }else{
  6441. $html.='class="error"';
  6442. }
  6443. $html.='><td class="taR"><b>借款结余</b></td>
  6444. <td class="taR"><b style="font-size:24px">¥'.$rinfo['relust'].'</b><br>'.$rinfo['relustCN'].'</td></tr>
  6445. </tbody></table>
  6446. ';
  6447. }
  6448. }elseif ($rinfo['Rtype']==2){//对公汇款
  6449. $html.='<table class="table table-bordered table-condensed table-hover"><tbody>
  6450. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  6451. foreach ($rinfo['accountItem']['日常相关费用'] as $value){
  6452. $html.='<tr><th>'.$value['name'].'</th>
  6453. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6454. }
  6455. $html.='<tr><th class="taR">合计</th>
  6456. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['agencySum'].'</td></tr>';
  6457. $html.='<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6458. <tr><th style="text-align:center" colspan="2">'.$rinfo['category'].'</th></tr>
  6459. <tr><th class="taC" colspan="2">费用说明</th>
  6460. </tr><tr><td colspan="2">'.$rinfo['explanation'].'</td></tr>
  6461. <tr class="warning"><td class="taR"><b>('.$rinfo['receiptOrder'].')本次费用合计</b></td>
  6462. <td class="taR"><b style="font-size:24px">¥'.$rinfo['sum'].'</b><br>'.$rinfo['sumCN'].'</td></tr>
  6463. </tbody></table>';
  6464. }else{
  6465. $html.='<table class="table table-bordered table-condensed table-hover"><tbody>';
  6466. $html.='<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6467. foreach ($rinfo['accountItem']['日常相关费用'] as $value){
  6468. $html.='<tr><th>'.$value['name'].'</th>
  6469. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6470. }
  6471. $html.='<tr><th class="taR">合计</th>
  6472. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['agencySum'].'</td></tr>';
  6473. $html.='<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6474. foreach ($rinfo['accountItem']['差旅相关费用'] as $value){
  6475. $html.='<tr><th>'.$value['name'].'</th>
  6476. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6477. }
  6478. $html.='<tr><th class="taR">合计</th>
  6479. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['travelSum'].'</td></tr>';
  6480. $html.='<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6481. foreach ($rinfo['accountItem']['培训班费用'] as $value){
  6482. $html.='<tr><th>'.$value['name'].'</th>
  6483. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6484. }
  6485. $html.='<tr><th class="taR">合计</th>
  6486. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['trainSum'].'</td></tr>';
  6487. $html.='<tr><th colspan="2" class="taC">其他</th></tr>';
  6488. foreach ($rinfo['accountItem']['其他'] as $value){
  6489. $html.='<tr><th>'.$value['name'].'</th>
  6490. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6491. }
  6492. $html.='<tr><th class="taR">合计</th>
  6493. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['otherSum'].'</td></tr>';
  6494. $html.='<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6495. foreach ($rinfo['reviseDetail'] as $value){
  6496. $html.='<tr><th><span class="interval">|</span>'.$value['name'].':'.$value['description'].'</th>
  6497. <td class="taR">¥'.$value['price'].'</td></tr>';
  6498. }
  6499. $html.='<tr><th class="taR">合计</th>
  6500. <td class="colGreen taR">¥'.$rinfo['revisePrice'].'</td></tr>';
  6501. $html.='<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6502. <tr><th style="text-align:center" colspan="2">'.$rinfo['category'].'</th></tr>
  6503. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6504. <tr><td colspan="2">'.$rinfo['explanation'].'</td></tr>
  6505. <tr class="warning"><td class="taR"><b>('.$rinfo['receiptOrder'].')本次报销费用合计</b></td>
  6506. <td class="colGreed taR"><b style="font-size:24px">¥'.$rinfo['sum'].'</b><br>'.$rinfo['sumCN'].'</td></tr>';
  6507. $html.='</tbody></table>';
  6508. /*
  6509. <table class="table table-bordered table-condensed table-hover">
  6510. <tbody>
  6511. <tr><th colspan="2" class="taC">日常相关费用</th></tr>
  6512. <!-- loop receiptList' value.accountItem.日常相关费用 -->
  6513. <tr><th>{{receiptList' value' value.name}}</th><td width="140" class="taR">¥{{receiptList' value' value.price}}</td></tr>
  6514. <!-- endloop -->
  6515. <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptList' value.accountItem.cSum.agencySum}}</td></tr>
  6516. <tr><th colspan="2" class="taC">差旅相关费用</th></tr>
  6517. <!-- loop receiptDetail' value.accountItem.差旅相关费用 -->
  6518. <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr>
  6519. <!-- endloop -->
  6520. <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.travelSum}}</td></tr>
  6521. <tr><th colspan="2" class="taC">培训班费用</th></tr>
  6522. <!-- loop receiptDetail' value.accountItem.培训班费用 -->
  6523. <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr>
  6524. <!-- endloop -->
  6525. <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.trainSum}}</td></tr>
  6526. <tr><th colspan="2" class="taC">其他</th></tr>
  6527. <!-- loop receiptDetail' value.accountItem.其他 -->
  6528. <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr>
  6529. <!-- endloop -->
  6530. <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.otherSum}}</td></tr>
  6531. <tr><th colspan="2" class="taC">报销金额调整</th></tr>
  6532. <!-- loop receiptList' value.reviseDetail -->
  6533. <tr><th><span class="interval">|</span>{{receiptList' value' value.name}}:{{receiptList' value' value.description}}</th><td class="taR">¥{{receiptList' value' value.price}}</td></tr>
  6534. <!-- endloop -->
  6535. <tr><th class="taR">合计</th><td class="colOrange taR">¥{{receiptList' value.revisePrice}}</td></tr>
  6536. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6537. <tr><th style="text-align:center" colspan="2">{{receiptDetail' value.category}}</th></tr>
  6538. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6539. <tr><td colspan="2">{{receiptDetail' value.explanation}}</td></tr>
  6540. <tr class="warning"><td class="taR"><b>({{receiptDetail' value.receiptOrder}})本次报销费用合计</b></td>
  6541. <td class="colGreed taR"><b style="font-size:24px">¥{{receiptDetail' value.sum}}</b><br>{{receiptDetail' value.sumCN}}</td></tr>
  6542. </tbody>
  6543. </table>
  6544. */
  6545. }
  6546. //print_r($verifyStaff);die;
  6547. $html.='<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  6548. foreach ($verifyStaff as $key=>$value){
  6549. $key=trim(strtr($key,'_R',' '));
  6550. $sinfo = $staff->getOne ( array (
  6551. 'select' => 'username',
  6552. 'where' => ' sid=' . $key,
  6553. 'asArray' => true
  6554. ) );
  6555. $html.='<tr><td>'.$sinfo['username'].'</td><td>'.$value['opinion'].'</td></tr>';
  6556. }
  6557. $html.='</tbody></table>';
  6558. $html.='<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  6559. foreach ($rinfo['executeCopy'] as $value){
  6560. $html.='<tr><td>'.$value[1].'</td><td>'.$value['opinion'].'</td></tr>';
  6561. }
  6562. $html.='</tbody></table>';
  6563. $html.='<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  6564. <td width="140" class="taR"><b style="font-size:24px">¥'.$rinfo['amount'].'</b><br>'.$rinfo['amountCN'].'</td>
  6565. </tr></table>';
  6566. $html.='</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  6567. echo json_encode ( array (
  6568. 'status' => 1,
  6569. 'html' => $html
  6570. ) );
  6571. die;
  6572. }
  6573. function remittance() {
  6574. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6575. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6576. Doo::loadModel ( 'receipt' );
  6577. $receipt = new receipt ();
  6578. Doo::loadModel ( 'staff' );
  6579. $staff = new staff ();
  6580. $dateCondition = " and Year(pastDate) =" . $year;
  6581. if (! empty ( $month ))
  6582. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  6583. // get Receipt By verifyID status 1
  6584. $receiptList = $receipt->find ( array (
  6585. 'select' => 'sum(sum) as sum,staff,pastDate',
  6586. 'where' => ' status=1' . $dateCondition,
  6587. 'desc' => 'pastDate',
  6588. 'groupby' => 'staff,pastDate',
  6589. 'asArray' => true
  6590. ) );
  6591. $dateList = $receipt->find ( array (
  6592. 'select' => 'pastDate,verifyStaff',
  6593. 'where' => ' status=1' . $dateCondition,
  6594. 'desc' => 'pastDate',
  6595. 'groupby' => 'pastDate',
  6596. 'asArray' => true
  6597. ) );
  6598. $dataList = array ();
  6599. foreach ( $dateList as $d => $a ) {
  6600. $dataList [$a ['pastDate']] = array ();
  6601. $daySum = 0;
  6602. foreach ( $receiptList as $key => $value ) {
  6603. if ($a ['pastDate'] == $value ['pastDate']) {
  6604. $oderList = $receipt->find ( array (
  6605. 'select' => 'receiptOrder',
  6606. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  6607. 'asArray' => true
  6608. ) );
  6609. $list = array ();
  6610. $html = "";
  6611. foreach ( $oderList as $v ) {
  6612. array_push ( $list, $v ['receiptOrder'] );
  6613. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  6614. }
  6615. $receiptList [$key] ['receiptOrder'] = $html;
  6616. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  6617. $sinfo = $staff->getOne ( array (
  6618. 'select' => 'username ',
  6619. 'where' => ' sid=' . $value ['staff'],
  6620. 'asArray' => true
  6621. ) );
  6622. $receiptList [$key] ['username'] = $sinfo ['username'];
  6623. $daySum += $value ['sum'];
  6624. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  6625. }
  6626. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  6627. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  6628. }
  6629. }
  6630. // print_r($dataList);
  6631. $data ['dataList'] = $dataList;
  6632. $mothHtml = "";
  6633. for($i = 1; $i <= 12; $i ++) {
  6634. if ($month == $i)
  6635. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6636. else
  6637. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6638. }
  6639. $data ['year'] = $year;
  6640. $data ['mothHtml'] = $mothHtml;
  6641. $data ['memu'] = "receipt";
  6642. $data ['staff'] = $this->staff;
  6643. $data ['receiptMemu'] = 'approval';
  6644. $data ['verifyId'] = $this->verifyId;
  6645. $data ['executeId'] = $this->executeId;
  6646. $this->render ( "/admin/saeaReportListPay", $data );
  6647. }
  6648. function revocationAdjustment() {
  6649. $sid = isset ( $this->params ['sid'] ) && is_numeric ( $this->params ['sid'] ) ? $this->params ['sid'] : 0;
  6650. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  6651. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6652. // echo $price;die;
  6653. if ((! empty ( $sid )) && ($price != - 99999) && (! empty ( $rid ))) {
  6654. Doo::loadModel ( 'receipt' );
  6655. $receipt = new receipt ();
  6656. $receiptDetail = $receipt->getOne ( array (
  6657. 'where' => 'rid=' . $rid,
  6658. 'asArray' => true
  6659. ) );
  6660. if (empty ( $receiptDetail ['reviseDetail'] ))
  6661. return "/approval";
  6662. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  6663. $RD = array ();
  6664. foreach ( $reviseDetail as $key => $value ) {
  6665. if ($value ['price'] == $price && $value ['sid'] == $sid)
  6666. continue;
  6667. array_push ( $RD, $value );
  6668. }
  6669. $reviseDetailString = json_encode ( $RD );
  6670. $receipt->reviseDetail = $reviseDetailString;
  6671. $receipt->sum = $receiptDetail ['sum'] - $price;
  6672. $receipt->revisePrice = $receiptDetail ['revisePrice'] - $price;
  6673. $receipt->update ( array (
  6674. 'where' => 'rid=' . $rid
  6675. ) );
  6676. }
  6677. // approvalEdi/37
  6678. return "/approvalEdi/" . $rid;
  6679. }
  6680. function updateApprovalReceipt() {
  6681. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6682. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  6683. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6684. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  6685. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  6686. if (! empty ( $rid )) {
  6687. Doo::loadModel ( "verify" );
  6688. $verify = new verify ();
  6689. Doo::loadModel ( "receiptDetail" );
  6690. $receiptDetailObj = new receiptDetail ();
  6691. Doo::loadModel ( "itemStatistics" );
  6692. Doo::loadModel ( "statistics" );
  6693. $statistics = new statistics ();
  6694. $itemStatistics = new itemStatistics ();
  6695. Doo::loadModel ( "receipt" );
  6696. $receipt = new receipt ();
  6697. $receiptDetail = $receipt->getOne ( array (
  6698. 'where' => 'rid=' . $rid . ' and status=2 ',
  6699. 'asArray' => true
  6700. ) );
  6701. if (empty ( $receiptDetail ))
  6702. return "/approval";
  6703. $verifyDetail = $verify->getOne ( array (
  6704. 'where' => ' vid =' . $receiptDetail ['verify'],
  6705. 'asArray' => true
  6706. ) );
  6707. $verifyString = $verifyDetail ['staff'];
  6708. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  6709. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  6710. if (empty ( $opinion )) {
  6711. if ($status == 3)
  6712. $opinion = "终止";
  6713. else
  6714. $opinion = "同意支付";
  6715. }
  6716. $nowStaff = 0;
  6717. $nowStaffList = array ();
  6718. if (empty ( $verifyStaff )) {
  6719. // 还需加入是否已经进入角色审批
  6720. if ($verifyDetail [0] [1] == 'ROLE') {
  6721. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  6722. foreach ( $vStaffString as $key => $value ) {
  6723. $staffK = explode ( "_", $value );
  6724. if ($staffK [0] != $this->staff [0] ['sid'])
  6725. array_push ( $nowStaffList, $staffK [0] );
  6726. }
  6727. // print_r($verifyDetail);
  6728. // die;
  6729. if (! empty ( $nowStaffList )) {
  6730. $nowStaff = implode ( ',', $nowStaffList );
  6731. $verifyStaff = array (
  6732. $this->staff [0] ['sid'] . "_R" => array (
  6733. 'date' => date ( 'Y-m-d' ),
  6734. 'opinion' => $opinion,
  6735. 'status' => $status,
  6736. 'nextStaff' => $verifyDetail [0] [0],
  6737. 'ROLE' => 1
  6738. )
  6739. );
  6740. } else {
  6741. $nowStaff = $verifyDetail [1] [0];
  6742. $verifyStaff = array (
  6743. $this->staff [0] ['sid'] . "_R" => array (
  6744. 'date' => date ( 'Y-m-d' ),
  6745. 'opinion' => $opinion,
  6746. 'status' => $status,
  6747. 'nextStaff' => $verifyDetail [1] [0]
  6748. )
  6749. );
  6750. }
  6751. } else {
  6752. if ($verifyDetail [1] [1] == 'ROLE') {
  6753. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  6754. // echo "dd";
  6755. foreach ( $vStaffString as $key => $value ) {
  6756. $staffK = explode ( "_", $value );
  6757. array_push ( $nowStaffList, $staffK [0] );
  6758. }
  6759. $nowStaff = implode ( ',', $nowStaffList );
  6760. $verifyStaff = array (
  6761. $this->staff [0] ['sid'] => array (
  6762. 'date' => date ( 'Y-m-d' ),
  6763. 'opinion' => $opinion,
  6764. 'status' => $status,
  6765. 'nextStaff' => $verifyDetail [1] [0],
  6766. 'ROLE' => 1
  6767. )
  6768. );
  6769. } else {
  6770. $nowStaff = $verifyDetail [1] [0];
  6771. $verifyStaff = array (
  6772. $this->staff [0] ['sid'] => array (
  6773. 'date' => date ( 'Y-m-d' ),
  6774. 'opinion' => $opinion,
  6775. 'status' => $status,
  6776. 'nextStaff' => $verifyDetail [1] [0]
  6777. )
  6778. );
  6779. }
  6780. }
  6781. if ($status == 3)
  6782. $verifyStaff = array (
  6783. 'final' => $status,
  6784. $this->staff [0] ['sid'] => array (
  6785. 'date' => date ( 'Y-m-d' ),
  6786. 'opinion' => $opinion,
  6787. 'status' => $status
  6788. )
  6789. );
  6790. $vStaffString = json_encode ( $verifyStaff );
  6791. $receipt->nowStaff = $nowStaff;
  6792. $receipt->verifyStaff = $vStaffString;
  6793. } else {
  6794. $VS = end ( $verifyStaff );
  6795. // 非角色审批
  6796. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  6797. $nextStaff = 0;
  6798. $roleSTF = false;
  6799. foreach ( $verifyDetail as $key => $value ) {
  6800. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  6801. if (isset ( $verifyDetail [$key + 1] )) {
  6802. $nextStaff = $verifyDetail [$key + 1] [0];
  6803. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  6804. $roleSTF = true;
  6805. }
  6806. break;
  6807. }
  6808. }
  6809. if (! $roleSTF) {
  6810. $nowStaff = $nextStaff;
  6811. $verifyStaff [$this->staff [0] ['sid']] = array (
  6812. 'date' => date ( 'Y-m-d' ),
  6813. 'opinion' => $opinion,
  6814. 'status' => $status,
  6815. 'nextStaff' => $nextStaff
  6816. );
  6817. } else {
  6818. // 获取角色下的所有用户ID
  6819. $nowStaffList = array ();
  6820. foreach ( $verifyDetail as $vfk ) {
  6821. if ($vfk [1] == 'ROLE') {
  6822. $vStaffString = json_decode ( $vfk [3] );
  6823. foreach ( $vStaffString as $key => $value ) {
  6824. $staffK = explode ( "_", $value );
  6825. array_push ( $nowStaffList, $staffK [0] );
  6826. }
  6827. }
  6828. }
  6829. $nowStaff = implode ( ',', $nowStaffList );
  6830. $verifyStaff [$this->staff [0] ['sid']] = array (
  6831. 'date' => date ( 'Y-m-d' ),
  6832. 'opinion' => $opinion,
  6833. 'status' => $status,
  6834. 'nextStaff' => $nextStaff,
  6835. 'ROLE' => 0
  6836. );
  6837. }
  6838. if ($status == 3) {
  6839. $verifyStaff ['final'] = $status;
  6840. $verifyStaff [$this->staff [0] ['sid']] = array (
  6841. 'date' => date ( 'Y-m-d' ),
  6842. 'opinion' => $opinion,
  6843. 'status' => $status
  6844. );
  6845. }
  6846. $vStaffString = json_encode ( $verifyStaff );
  6847. $receipt->nowStaff = $nowStaff;
  6848. $receipt->verifyStaff = $vStaffString;
  6849. }
  6850. // 角色审批
  6851. if (isset ( $VS ['ROLE'] )) {
  6852. // 找出角色人 当前审批角色组
  6853. $verifyJSStaff = array ();
  6854. $nowStaffList2 = array ();
  6855. foreach ( $verifyDetail as $key => $value ) {
  6856. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  6857. $verifyJSStaff = json_decode ( $value [3] );
  6858. foreach ( $verifyJSStaff as $m ) {
  6859. $staffK = explode ( "_", $m );
  6860. array_push ( $nowStaffList2, $staffK [0] );
  6861. }
  6862. // print_r($nowStaffList2);
  6863. }
  6864. }
  6865. $RoleVerifyStaff = array ();
  6866. foreach ( $verifyStaff as $key => $value ) {
  6867. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  6868. foreach ( $nowStaffList2 as $m ) {
  6869. if ($key == $m . "_R")
  6870. $RoleVerifyStaff [$key] = $value;
  6871. }
  6872. }
  6873. }
  6874. // print_r($verifyStaff);
  6875. // print_r($nowStaffList2);
  6876. // print_r($RoleVerifyStaff);
  6877. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  6878. // print_r($verifyJSStaff);
  6879. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  6880. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  6881. // 下一个审批人ID
  6882. $nextStaff = 0;
  6883. $falg = false;
  6884. foreach ( $verifyDetail as $key => $value ) {
  6885. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  6886. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  6887. $falg = true;
  6888. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  6889. $nowStaffList = array ();
  6890. foreach ( $vStaffString as $v ) {
  6891. $staffK = explode ( "_", $v );
  6892. array_push ( $nowStaffList, $staffK [0] );
  6893. }
  6894. $nowStaff = implode ( ',', $nowStaffList );
  6895. $nextStaff = $verifyDetail [$key + 1] [0];
  6896. } elseif (isset ( $verifyDetail [$key + 1] )) {
  6897. $nextStaff = $verifyDetail [$key + 1] [0];
  6898. $nowStaff = $nextStaff;
  6899. } else
  6900. $nowStaff = '';
  6901. break;
  6902. }
  6903. }
  6904. if ($falg)
  6905. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6906. 'date' => date ( 'Y-m-d' ),
  6907. 'opinion' => $opinion,
  6908. 'status' => $status,
  6909. 'nextStaff' => $nextStaff,
  6910. 'ROLE' => 1
  6911. );
  6912. else
  6913. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6914. 'date' => date ( 'Y-m-d' ),
  6915. 'opinion' => $opinion,
  6916. 'status' => $status,
  6917. 'nextStaff' => $nextStaff
  6918. );
  6919. // print_r($verifyStaff);
  6920. // echo $nowStaff;die;
  6921. } else { // 进入下一个角色或者审批人
  6922. /*
  6923. *
  6924. */
  6925. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  6926. //
  6927. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  6928. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6929. 'date' => date ( 'Y-m-d' ),
  6930. 'opinion' => $opinion,
  6931. 'status' => $status,
  6932. 'nextStaff' => $VS ['nextStaff'],
  6933. 'ROLE' => 1
  6934. );
  6935. // print_r($verifyStaff);
  6936. // die;
  6937. }
  6938. if ($status == 3) {
  6939. $verifyStaff ['final'] = $status;
  6940. $verifyStaff [$this->staff [0] ['sid']] = array (
  6941. 'date' => date ( 'Y-m-d' ),
  6942. 'opinion' => $opinion,
  6943. 'status' => $status
  6944. );
  6945. }
  6946. $vStaffString = json_encode ( $verifyStaff );
  6947. $receipt->verifyStaff = $vStaffString;
  6948. $receipt->nowStaff = $nowStaff;
  6949. // die;
  6950. // }
  6951. // print_r($verifyStaff);
  6952. // die;
  6953. }
  6954. // print_r($verifyStaff);die;
  6955. }
  6956. // print_r($verifyDetail);
  6957. $roleKey = 0;
  6958. $roleId = 0;
  6959. $verifyDetailCopy = array ();
  6960. foreach ( $verifyDetail as $k => $v ) {
  6961. if ($v [1] == 'ROLE') {
  6962. $roleId = $v [0];
  6963. $roleVerify = json_decode ( $v [3], true );
  6964. $roleKey = $k;
  6965. $roleArray = array ();
  6966. foreach ( $roleVerify as $o => $p ) {
  6967. $staffID = explode ( '_', $p );
  6968. $exp = array (
  6969. 0 => $staffID [0],
  6970. 1 => $staffID [1]
  6971. );
  6972. array_push ( $roleArray, $exp );
  6973. }
  6974. $verifyDetailCopy [$v [0]] = $roleArray;
  6975. }
  6976. }
  6977. // print_r($verifyDetail);
  6978. foreach ( $verifyDetailCopy as $k => $v ) {
  6979. foreach ( $verifyDetail as $m => $n ) {
  6980. if ($n [0] == $k) {
  6981. array_splice ( $verifyDetail, $m, 1, $v );
  6982. }
  6983. }
  6984. }
  6985. // die;
  6986. // if (!empty($roleArray))
  6987. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  6988. // echo $roleId;
  6989. // print_r($verifyStaff);
  6990. // print_r($verifyDetail);
  6991. // die;
  6992. Doo::loadModel ( "receiptLog" );
  6993. $receiptLog = new receiptLog ();
  6994. // 审批日志
  6995. if (! isset ( $verifyStaff ['final'] )) {
  6996. if (! empty ( $roleId )) {
  6997. Doo::loadModel ( "role" );
  6998. $role = new role ();
  6999. $roleInfo = $role->getOne ( array (
  7000. 'where' => 'rid=' . $roleId,
  7001. 'asArray' => true
  7002. ) );
  7003. $receiptLog->rolename = $roleInfo ['name'];
  7004. }
  7005. $receiptLog->username = $this->staff [0] ['username'];
  7006. $receiptLog->uid = $this->staff [0] ['sid'];
  7007. $receiptLog->date = date ( "Y-m-d" );
  7008. $receiptLog->opinion = $opinion;
  7009. $receiptLog->img = $this->staff [0] ['avatar'];
  7010. $receiptLog->status = 1;
  7011. $receiptLog->rid = $rid;
  7012. $receiptLog->insert ();
  7013. }
  7014. if (isset ( $verifyStaff ['final'] )) { // rDetail
  7015. $receipt->verifyBreakup = $verifyString;
  7016. $receipt->status = 3;
  7017. $receiptDetailObj->status = 3;
  7018. $receiptDetailObj->update ( array (
  7019. 'where' => 'rid=' . $rid
  7020. ) );
  7021. if (! empty ( $roleId )) {
  7022. Doo::loadModel ( "role" );
  7023. $role = new role ();
  7024. $roleInfo = $role->getOne ( array (
  7025. 'where' => 'rid=' . $roleId,
  7026. 'asArray' => true
  7027. ) );
  7028. $receiptLog->rolename = $roleInfo ['name'];
  7029. }
  7030. $receiptLog->username = $this->staff [0] ['username'];
  7031. $receiptLog->uid = $this->staff [0] ['sid'];
  7032. $receiptLog->date = date ( "Y-m-d" );
  7033. $receiptLog->opinion = $opinion;
  7034. $receiptLog->img = $this->staff [0] ['avatar'];
  7035. $receiptLog->status = 3;
  7036. $receiptLog->rid = $rid;
  7037. $receiptLog->insert ();
  7038. // 微信企业号通知
  7039. $this->setWXMsg ( $rid, 3 );
  7040. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  7041. $receipt->status = 1;
  7042. $reviseSum = 0;
  7043. $receipt->verifyBreakup = $verifyString;
  7044. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  7045. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7046. foreach ( $reviseDetail as $key => $value ) {
  7047. $receiptDetailObj = new receiptDetail ();
  7048. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7049. $receiptDetailObj->item = $value ['description'];
  7050. $receiptDetailObj->itemCategory = "报销金额调整";
  7051. $receiptDetailObj->price = $value ['price'];
  7052. $receiptDetailObj->date = $receiptDetail ['date'];
  7053. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  7054. $receiptDetailObj->rid = $rid;
  7055. $receiptDetailObj->status = 1;
  7056. $receiptDetailObj->insert ();
  7057. $reviseSum += $value ['price'];
  7058. }
  7059. $itemStatistics = new itemStatistics ();
  7060. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7061. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7062. $itemStatistics->price = $reviseSum;
  7063. $itemStatistics->itemCategory = "报销金额调整";
  7064. $itemStatistics->date = $receiptDetail ['date'];
  7065. $itemStatistics->insert ();
  7066. }
  7067. $receiptDetailObj = new receiptDetail ();
  7068. $receiptDetailObj->status = 1;
  7069. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  7070. $receiptDetailObj->update ( array (
  7071. 'where' => 'rid=' . $rid
  7072. ) );
  7073. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7074. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7075. $stat = $statistics->getOne ( array (
  7076. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  7077. 'asArray' => true
  7078. ) );
  7079. if (empty ( $stat )) {
  7080. $statistics->date = $receiptDetail ['date'];
  7081. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7082. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7083. $statistics->agPrice = $receiptDetail ['sum'];
  7084. $statistics->rePrice = $reviseSum;
  7085. $statistics->insert ();
  7086. } else {
  7087. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  7088. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  7089. $statistics->update ( array (
  7090. 'where' => 'sid=' . $stat ['sid']
  7091. ) );
  7092. }
  7093. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7094. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7095. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  7096. foreach ( $accountItem ['cSum'] as $key => $value ) {
  7097. if ($key == "agencySum") {
  7098. $iStatistics = $itemStatistics->getOne ( array (
  7099. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  7100. 'asArray' => true
  7101. ) );
  7102. if (empty ( $iStatistics )) {
  7103. $itemStatistics->cid = $receiptDetail ['cid'];
  7104. ;
  7105. $itemStatistics->staff = $receiptDetail ['staff'];
  7106. $itemStatistics->price = $value;
  7107. $itemStatistics->itemCategory = $this->AGENCY;
  7108. $itemStatistics->date = $receiptDetail ['date'];
  7109. $itemStatistics->insert ();
  7110. } else {
  7111. if (! empty ( $value )) {
  7112. $itemStatistics->price = $value + $iStatistics ['price'];
  7113. $itemStatistics->update ( array (
  7114. 'where' => 'sid=' . $iStatistics ['sid']
  7115. ) );
  7116. }
  7117. }
  7118. } elseif ($key == "travelSum") {
  7119. $iStatistics = $itemStatistics->getOne ( array (
  7120. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  7121. 'asArray' => true
  7122. ) );
  7123. if (empty ( $iStatistics )) {
  7124. $itemStatistics->cid = $receiptDetail ['cid'];
  7125. $itemStatistics->staff = $receiptDetail ['staff'];
  7126. $itemStatistics->price = $value;
  7127. $itemStatistics->itemCategory = $this->TRAVEL;
  7128. $itemStatistics->date = $receiptDetail ['date'];
  7129. $itemStatistics->insert ();
  7130. } else {
  7131. if (! empty ( $value )) {
  7132. $itemStatistics->price = $value + $iStatistics ['price'];
  7133. $itemStatistics->update ( array (
  7134. 'where' => 'sid=' . $iStatistics ['sid']
  7135. ) );
  7136. }
  7137. }
  7138. } elseif ($key == "trainSum") {
  7139. $iStatistics = $itemStatistics->getOne ( array (
  7140. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  7141. 'asArray' => true
  7142. ) );
  7143. if (empty ( $iStatistics )) {
  7144. $itemStatistics->cid = $receiptDetail ['cid'];
  7145. $itemStatistics->staff = $receiptDetail ['staff'];
  7146. $itemStatistics->price = $value;
  7147. $itemStatistics->itemCategory = $this->TRAIN;
  7148. $itemStatistics->date = $receiptDetail ['date'];
  7149. $itemStatistics->insert ();
  7150. } else {
  7151. if (! empty ( $value )) {
  7152. $itemStatistics->price = $value + $iStatistics ['price'];
  7153. $itemStatistics->update ( array (
  7154. 'where' => 'sid=' . $iStatistics ['sid']
  7155. ) );
  7156. }
  7157. }
  7158. } elseif ($key == "otherSum") {
  7159. $iStatistics = $itemStatistics->getOne ( array (
  7160. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  7161. 'asArray' => true
  7162. ) );
  7163. if (empty ( $iStatistics )) {
  7164. $itemStatistics->cid = $receiptDetail ['cid'];
  7165. $itemStatistics->staff = $receiptDetail ['staff'];
  7166. $itemStatistics->price = $value;
  7167. $itemStatistics->itemCategory = $this->OTHER;
  7168. $itemStatistics->date = $receiptDetail ['date'];
  7169. $itemStatistics->insert ();
  7170. } else {
  7171. if (! empty ( $value )) {
  7172. $itemStatistics->price = $value + $iStatistics ['price'];
  7173. $itemStatistics->update ( array (
  7174. 'where' => 'sid=' . $iStatistics ['sid']
  7175. ) );
  7176. }
  7177. }
  7178. }
  7179. }
  7180. $receipt->pastDate = date ( "Y-m-d" );
  7181. // 微信企业号通知
  7182. $this->setWXMsg ( $rid, 1 );
  7183. }
  7184. $receipt->amount = $amount;
  7185. $receipt->update ( array (
  7186. 'where' => ' rid = ' . $rid
  7187. ) );
  7188. return "/approvalExpenses/2";
  7189. }
  7190. }
  7191. function expensesRetreats() {
  7192. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7193. if (! empty ( $rid )) {
  7194. // 操作记录
  7195. Doo::loadModel ( "receipt" );
  7196. $receipt = new receipt ();
  7197. Doo::loadModel ( "receiptLog" );
  7198. $receiptLog = new receiptLog ();
  7199. Doo::loadModel ( "verify" );
  7200. $verify = new verify ();
  7201. $receiptInfo = $receipt->getOne ( array (
  7202. 'where' => 'rid=' . $rid,
  7203. 'asArray' => true
  7204. ) );
  7205. $vr = $verify->getOne ( array (
  7206. 'where' => 'vid=' . $receiptInfo ['verify'],
  7207. 'asArray' => true
  7208. ) );
  7209. $jd = json_decode ( $vr ['staff'] );
  7210. $roleId = 0;
  7211. foreach ( $jd as $key => $value ) {
  7212. if ($value [1] == 'ROLE') {
  7213. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7214. if ($pos !== false) {
  7215. $roleId = $value [0];
  7216. }
  7217. }
  7218. }
  7219. // 审批日志
  7220. // echo $roleId;die;
  7221. if (! empty ( $roleId )) {
  7222. Doo::loadModel ( "role" );
  7223. $role = new role ();
  7224. $roleInfo = $role->getOne ( array (
  7225. 'where' => 'rid=' . $roleId,
  7226. 'asArray' => true
  7227. ) );
  7228. $receiptLog->rolename = $roleInfo ['name'];
  7229. }
  7230. $receiptLog->username = $this->staff [0] ['username'];
  7231. $receiptLog->uid = $this->staff [0] ['sid'];
  7232. $receiptLog->date = date ( "Y-m-d" );
  7233. $receiptLog->opinion = '撤回';
  7234. $receiptLog->img = $this->staff [0] ['avatar'];
  7235. $receiptLog->status = 4;
  7236. $receiptLog->rid = $rid;
  7237. $receiptLog->insert ();
  7238. $receipt->status = 4;
  7239. $receipt->update ( array (
  7240. 'where' => 'rid=' . $rid
  7241. ) );
  7242. // 微信企业号通知
  7243. $this->setWXMsg ( $rid, 2 );
  7244. }
  7245. // echo "ddd";
  7246. return '/approvalExpenses';
  7247. }
  7248. function updateCheReceipt() {
  7249. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7250. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7251. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  7252. if (! empty ( $rid )) {
  7253. // 操作记录
  7254. Doo::loadModel ( "receipt" );
  7255. $receipt = new receipt ();
  7256. Doo::loadModel ( "receiptLog" );
  7257. $receiptLog = new receiptLog ();
  7258. Doo::loadModel ( "verify" );
  7259. $verify = new verify ();
  7260. $receiptInfo = $receipt->getOne ( array (
  7261. 'where' => 'rid=' . $rid,
  7262. 'asArray' => true
  7263. ) );
  7264. $vr = $verify->getOne ( array (
  7265. 'where' => 'vid=' . $receiptInfo ['verify'],
  7266. 'asArray' => true
  7267. ) );
  7268. $jd = json_decode ( $vr ['staff'] );
  7269. $roleId = 0;
  7270. foreach ( $jd as $key => $value ) {
  7271. if ($value [1] == 'ROLE') {
  7272. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7273. if ($pos !== false) {
  7274. $roleId = $value [0];
  7275. }
  7276. }
  7277. }
  7278. // 审批日志
  7279. // echo $roleId;die;
  7280. if (! empty ( $roleId )) {
  7281. Doo::loadModel ( "role" );
  7282. $role = new role ();
  7283. $roleInfo = $role->getOne ( array (
  7284. 'where' => 'rid=' . $roleId,
  7285. 'asArray' => true
  7286. ) );
  7287. $receiptLog->rolename = $roleInfo ['name'];
  7288. }
  7289. $receiptLog->username = $this->staff [0] ['username'];
  7290. $receiptLog->uid = $this->staff [0] ['sid'];
  7291. $receiptLog->date = date ( "Y-m-d" );
  7292. $receiptLog->opinion = $opinion;
  7293. $receiptLog->img = $this->staff [0] ['avatar'];
  7294. $receiptLog->status = 4;
  7295. $receiptLog->rid = $rid;
  7296. $receiptLog->insert ();
  7297. $receipt->status = 4;
  7298. $receipt->update ( array (
  7299. 'where' => 'rid=' . $rid
  7300. ) );
  7301. // 微信企业号通知
  7302. $this->setWXMsg ( $rid, 2 );
  7303. echo json_encode ( array (
  7304. 'status' => 1
  7305. ) );
  7306. die ();
  7307. }
  7308. echo json_encode ( array (
  7309. 'status' => 2
  7310. ) );
  7311. die ();
  7312. // echo "ddd";
  7313. // return '/saeaBorad';
  7314. }
  7315. function revisePrice() {
  7316. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  7317. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  7318. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7319. // echo $price;die;
  7320. if (! empty ( $rid )) {
  7321. Doo::loadModel ( "receipt" );
  7322. $receipt = new receipt ();
  7323. $receiptDetail = $receipt->getOne ( array (
  7324. 'where' => 'rid=' . $rid . ' and status=2 ',
  7325. 'asArray' => true
  7326. ) );
  7327. if (empty ( $receiptDetail ))
  7328. return "/approval";
  7329. $reviseDetail = array ();
  7330. if (empty ( $receiptDetail ['reviseDetail'] )) {
  7331. array_push ( $reviseDetail, array (
  7332. 'sid' => $this->staff [0] ['sid'],
  7333. 'name' => $this->staff [0] ['username'],
  7334. 'description' => $description,
  7335. 'price' => $price
  7336. ) );
  7337. $reviseDetailString = json_encode ( $reviseDetail );
  7338. $receipt->reviseDetail = $reviseDetailString;
  7339. $receipt->revisePrice = $price;
  7340. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7341. } else {
  7342. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7343. array_push ( $reviseDetail, array (
  7344. 'sid' => $this->staff [0] ['sid'],
  7345. 'name' => $this->staff [0] ['username'],
  7346. 'description' => $description,
  7347. 'price' => $price
  7348. ) );
  7349. $reviseDetailString = json_encode ( $reviseDetail );
  7350. $receipt->reviseDetail = $reviseDetailString;
  7351. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  7352. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7353. }
  7354. $receipt->update ( array (
  7355. 'where' => 'rid=' . $rid
  7356. ) );
  7357. }
  7358. return '/approvalEdi/' . $rid;
  7359. }
  7360. function personalCollect() {
  7361. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7362. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  7363. $this->showCache ( $path );
  7364. Doo::loadModel ( "receiptDetail" );
  7365. Doo::loadModel ( "itemStatistics" );
  7366. Doo::loadModel ( 'statistics' );
  7367. $statistics = new statistics ();
  7368. $itemStatistics = new itemStatistics ();
  7369. $receiptDetail = new receiptDetail ();
  7370. $receiptCollectList = $receiptDetail->find ( array (
  7371. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7372. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7373. 'groupby' => 'itemCategory,Month(date)',
  7374. 'asArray' => true
  7375. ) );
  7376. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  7377. 'where' => 'staff=' . $this->staff [0] ['sid'],
  7378. 'asArray' => true
  7379. ) );
  7380. // create collect html
  7381. $collectArray = array (
  7382. '日常相关费用' => array (),
  7383. '差旅相关费用' => array (),
  7384. '培训班费用' => array (),
  7385. '其他' => array ()
  7386. );
  7387. $adjustment = array ();
  7388. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  7389. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7390. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  7391. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7392. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  7393. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7394. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  7395. array_push ( $collectArray ['其他'], $collectHtml );
  7396. $data ['collectArray'] = $collectArray;
  7397. // statistics html
  7398. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7399. if (empty ( $stList ))
  7400. $stList = array (
  7401. 'rePrice' => 0,
  7402. 'agPrice' => 0
  7403. );
  7404. $data ['stList'] = array (
  7405. 'rePrice' => $stList ['rePrice'],
  7406. 'agPrice' => $stList ['agPrice'],
  7407. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7408. );
  7409. // Adjustment price html
  7410. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7411. array_push ( $adjustment, $collectHtml );
  7412. $data ['adjustment'] = $adjustment;
  7413. // total price html
  7414. $collectHtml = "";
  7415. $total = 0;
  7416. for($i = 1; $i <= 12; $i ++) {
  7417. $sumPrice = 0;
  7418. foreach ( $receiptCollectList as $key => $value ) {
  7419. if ($value ['month'] == $i) {
  7420. $sumPrice += $value ['price'];
  7421. }
  7422. }
  7423. if ($sumPrice == 0)
  7424. $collectHtml .= '<td class="taR">-</td>';
  7425. else
  7426. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7427. $total += $sumPrice;
  7428. }
  7429. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7430. $data ['totalPrice'] = $collectHtml;
  7431. $data ['year'] = $year;
  7432. $data ['totalYear'] = $total;
  7433. $data ['memu'] = "receipt";
  7434. $data ['staff'] = $this->staff;
  7435. $data ['receiptMemu'] = 'personalCollect';
  7436. $data ['verifyId'] = $this->verifyId;
  7437. $data ['executeId'] = $this->executeId;
  7438. // year staff status 2,4
  7439. if ($year < date ( "Y" )) {
  7440. Doo::loadModel ( 'receipt' );
  7441. $receipt = new receipt ();
  7442. $receiptList = $receipt->find ( array (
  7443. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7444. 'asArray' => true
  7445. ) );
  7446. if (empty ( $receiptList )) {
  7447. ob_start ();
  7448. $this->render ( "/admin/saea_slist_collect", $data );
  7449. $this->cacheFile ( $path );
  7450. die ();
  7451. }
  7452. }
  7453. $this->render ( "/admin/saea_slist_collect", $data );
  7454. }
  7455. function personalCollectDetail() {
  7456. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7457. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  7458. $this->showCache ( $path );
  7459. Doo::loadModel ( "receiptDetail" );
  7460. Doo::loadModel ( "itemStatistics" );
  7461. Doo::loadModel ( 'statistics' );
  7462. Doo::loadModel ( 'accountItem' );
  7463. $accountItem = new accountItem ();
  7464. $statistics = new statistics ();
  7465. $itemStatistics = new itemStatistics ();
  7466. $receiptDetail = new receiptDetail ();
  7467. $receiptCollectList = $receiptDetail->find ( array (
  7468. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  7469. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7470. 'groupby' => 'item,Month(date)',
  7471. 'asArray' => true
  7472. ) );
  7473. $accountList = $accountItem->find ( array (
  7474. 'asArray' => true
  7475. ) );
  7476. // create CollectDetail HTML
  7477. $collectHtml = array ();
  7478. foreach ( $accountList as $key => $value ) {
  7479. $html = "";
  7480. $asum = 0;
  7481. for($i = 1; $i <= 12; $i ++) {
  7482. $falg = true;
  7483. foreach ( $receiptCollectList as $v ) {
  7484. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7485. $asum += $v ['price'];
  7486. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7487. $falg = false;
  7488. break;
  7489. }
  7490. }
  7491. if ($falg)
  7492. $html .= '<td class="taR">-</td>';
  7493. }
  7494. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7495. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7496. }
  7497. $data ['collectHtml'] = $collectHtml;
  7498. // create Adjustment price html
  7499. $receiptCollectList = $receiptDetail->find ( array (
  7500. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7501. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7502. 'groupby' => 'itemCategory,Month(date)',
  7503. 'asArray' => true
  7504. ) );
  7505. $adjustment = array ();
  7506. $collectArray = array (
  7507. '日常相关费用' => array (),
  7508. '差旅相关费用' => array (),
  7509. '培训班费用' => array (),
  7510. '其他' => array ()
  7511. );
  7512. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7513. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7514. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7515. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7516. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7517. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7518. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7519. array_push ( $collectArray ['其他'], $collectHtml );
  7520. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7521. array_push ( $adjustment, $collectHtml );
  7522. // total price html
  7523. $collectHtml = "";
  7524. $total = 0;
  7525. for($i = 1; $i <= 12; $i ++) {
  7526. $sumPrice = 0;
  7527. foreach ( $receiptCollectList as $key => $value ) {
  7528. if ($value ['month'] == $i) {
  7529. $sumPrice += $value ['price'];
  7530. }
  7531. }
  7532. if ($sumPrice == 0)
  7533. $collectHtml .= '<td class="taR">-</td>';
  7534. else
  7535. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7536. $total += $sumPrice;
  7537. }
  7538. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7539. // statistics html
  7540. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7541. if (empty ( $stList ))
  7542. $stList = array (
  7543. 'rePrice' => 0,
  7544. 'agPrice' => 0
  7545. );
  7546. $data ['stList'] = array (
  7547. 'rePrice' => $stList ['rePrice'],
  7548. 'agPrice' => $stList ['agPrice'],
  7549. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7550. );
  7551. $data ['collectArray'] = $collectArray;
  7552. $data ['adjustment'] = $adjustment;
  7553. $data ['totalPrice'] = $collectHtml;
  7554. $data ['totalYear'] = $total;
  7555. $data ['year'] = $year;
  7556. $data ['memu'] = "receipt";
  7557. $data ['staff'] = $this->staff;
  7558. $data ['receiptMemu'] = 'personalCollect';
  7559. $data ['verifyId'] = $this->verifyId;
  7560. $data ['executeId'] = $this->executeId;
  7561. // year staff status 2,4
  7562. if ($year < date ( "Y" )) {
  7563. Doo::loadModel ( 'receipt' );
  7564. $receipt = new receipt ();
  7565. $receiptList = $receipt->find ( array (
  7566. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7567. 'asArray' => true
  7568. ) );
  7569. if (empty ( $receiptList )) {
  7570. ob_start ();
  7571. $this->render ( "/admin/saeaCollectArticles", $data );
  7572. $this->cacheFile ( $path );
  7573. die ();
  7574. }
  7575. }
  7576. $this->render ( "/admin/saeaCollectArticles", $data );
  7577. }
  7578. function companyCategoryCollect() {
  7579. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7580. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  7581. $this->showCache ( $path );
  7582. Doo::loadModel ( 'L_category' );
  7583. Doo::loadModel ( 'itemStatistics' );
  7584. Doo::loadModel ( 'statistics' );
  7585. $statistics = new statistics ();
  7586. $Lcategory = new L_category ();
  7587. $itemStatistics = new itemStatistics ();
  7588. $LcategoryList = $Lcategory->find ( array (
  7589. 'asArray' => true
  7590. ) ); // 'staff='.$this->staff[0]['sid']." and
  7591. $itemStatisticsList = $itemStatistics->find ( array (
  7592. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7593. 'where' => " Year(date)=" . $year,
  7594. 'groupby' => 'cid,Month(date)',
  7595. 'asArray' => true
  7596. ) );
  7597. // ceatre companyCollectHtml
  7598. foreach ( $LcategoryList as $value ) {
  7599. $html = "";
  7600. $asum = 0;
  7601. for($i = 1; $i <= 12; $i ++) {
  7602. $falg = true;
  7603. foreach ( $itemStatisticsList as $v ) {
  7604. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  7605. $asum += $v ['price'];
  7606. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7607. $falg = false;
  7608. break;
  7609. }
  7610. }
  7611. if ($falg)
  7612. $html .= '<td class="taR">-</td>';
  7613. }
  7614. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7615. $collectHtml [$value ['title']] = array (
  7616. 'html' => $html,
  7617. 'cid' => $value ['cid']
  7618. );
  7619. }
  7620. $data ['companyHtml'] = $collectHtml;
  7621. // total price html
  7622. $collectHtml = "";
  7623. $total = 0;
  7624. for($i = 1; $i <= 12; $i ++) {
  7625. $sumPrice = 0;
  7626. foreach ( $itemStatisticsList as $key => $value ) {
  7627. if ($value ['month'] == $i) {
  7628. $sumPrice += $value ['price'];
  7629. }
  7630. }
  7631. if ($sumPrice == 0)
  7632. $collectHtml .= '<td class="taR">-</td>';
  7633. else
  7634. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7635. $total += $sumPrice;
  7636. }
  7637. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7638. $data ['companyTotalHtml'] = $collectHtml;
  7639. $data ['total'] = $total;
  7640. // statistics html
  7641. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7642. if (empty ( $stList ))
  7643. $stList = array (
  7644. 'rePrice' => 0,
  7645. 'agPrice' => 0
  7646. );
  7647. $data ['stList'] = array (
  7648. 'rePrice' => $stList ['rePrice'],
  7649. 'agPrice' => $stList ['agPrice'],
  7650. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7651. );
  7652. $data ['year'] = $year;
  7653. $data ['memu'] = "receipt";
  7654. $data ['staff'] = $this->staff;
  7655. $data ['receiptMemu'] = 'companyCategoryCollect';
  7656. $data ['verifyId'] = $this->verifyId;
  7657. $data ['executeId'] = $this->executeId;
  7658. // year staff status 2,4
  7659. if ($year < date ( "Y" )) {
  7660. Doo::loadModel ( 'receipt' );
  7661. $receipt = new receipt ();
  7662. $receiptList = $receipt->find ( array (
  7663. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  7664. 'asArray' => true
  7665. ) );
  7666. if (empty ( $receiptList )) {
  7667. ob_start ();
  7668. $this->render ( "/admin/saeaCompanyCollect", $data );
  7669. $this->cacheFile ( $path );
  7670. die ();
  7671. }
  7672. }
  7673. $this->render ( "/admin/saeaCompanyCollect", $data );
  7674. }
  7675. function categoryCollectDetail() {
  7676. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7677. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  7678. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  7679. $this->showCache ( $path );
  7680. Doo::loadModel ( 'statistics' );
  7681. $statistics = new statistics ();
  7682. Doo::loadModel ( "receiptDetail" );
  7683. $receiptDetail = new receiptDetail ();
  7684. Doo::loadModel ( 'L_category' );
  7685. $Lcategory = new L_category ();
  7686. Doo::loadModel ( 'accountItem' );
  7687. $accountItem = new accountItem ();
  7688. $LcategoryList = $Lcategory->find ( array (
  7689. 'asArray' => true
  7690. ) );
  7691. if ($cid == 0) {
  7692. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7693. if ($cid == 0)
  7694. $cid = $LcategoryList [0] ['cid'];
  7695. }
  7696. $data ['LcategoryList'] = $LcategoryList;
  7697. $receiptCollectList = $receiptDetail->find ( array (
  7698. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  7699. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7700. 'groupby' => 'item,Month(pastDate)',
  7701. 'asArray' => true
  7702. ) );
  7703. $accountList = $accountItem->find ( array (
  7704. 'asArray' => true
  7705. ) );
  7706. // create CollectDetail HTML
  7707. $collectHtml = array ();
  7708. foreach ( $accountList as $key => $value ) {
  7709. $html = "";
  7710. $asum = 0;
  7711. for($i = 1; $i <= 12; $i ++) {
  7712. $falg = true;
  7713. foreach ( $receiptCollectList as $v ) {
  7714. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7715. $asum += $v ['price'];
  7716. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7717. $falg = false;
  7718. break;
  7719. }
  7720. }
  7721. if ($falg)
  7722. $html .= '<td class="taR">-</td>';
  7723. }
  7724. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7725. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7726. }
  7727. $data ['collectHtml'] = $collectHtml;
  7728. // create Adjustment price html
  7729. $receiptCollectList = $receiptDetail->find ( array (
  7730. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  7731. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7732. 'groupby' => 'itemCategory,Month(pastDate)',
  7733. 'asArray' => true
  7734. ) );
  7735. $adjustment = array ();
  7736. $collectArray = array (
  7737. '日常相关费用' => array (),
  7738. '差旅相关费用' => array (),
  7739. '培训班费用' => array (),
  7740. '其他' => array ()
  7741. );
  7742. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7743. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7744. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7745. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7746. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7747. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7748. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7749. array_push ( $collectArray ['其他'], $collectHtml );
  7750. $data ['collectArray'] = $collectArray;
  7751. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7752. array_push ( $adjustment, $collectHtml );
  7753. $data ['adjustment'] = $adjustment;
  7754. // total price html
  7755. $collectHtml = "";
  7756. $total = 0;
  7757. for($i = 1; $i <= 12; $i ++) {
  7758. $sumPrice = 0;
  7759. foreach ( $receiptCollectList as $key => $value ) {
  7760. if ($value ['month'] == $i) {
  7761. $sumPrice += $value ['price'];
  7762. }
  7763. }
  7764. if ($sumPrice == 0)
  7765. $collectHtml .= '<td class="taR">-</td>';
  7766. else
  7767. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7768. $total += $sumPrice;
  7769. }
  7770. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7771. // statistics html
  7772. $stList = $statistics->statisticsByCid ( $year, $cid );
  7773. if (empty ( $stList ))
  7774. $stList = array (
  7775. 'rePrice' => 0,
  7776. 'agPrice' => 0
  7777. );
  7778. $data ['stList'] = array (
  7779. 'rePrice' => $stList ['rePrice'],
  7780. 'agPrice' => $stList ['agPrice'],
  7781. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7782. );
  7783. $data ['totalYear'] = $total;
  7784. $data ['year'] = $year;
  7785. $data ['cid'] = $cid;
  7786. $data ['memu'] = "receipt";
  7787. $data ['staff'] = $this->staff;
  7788. $data ['receiptMemu'] = 'companyCategoryCollect';
  7789. $data ['verifyId'] = $this->verifyId;
  7790. $data ['executeId'] = $this->executeId;
  7791. // year staff status 2,4
  7792. if ($year < date ( "Y" )) {
  7793. Doo::loadModel ( 'receipt' );
  7794. $receipt = new receipt ();
  7795. $receiptList = $receipt->find ( array (
  7796. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  7797. 'asArray' => true
  7798. ) );
  7799. if (empty ( $receiptList )) {
  7800. ob_start ();
  7801. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7802. $this->cacheFile ( $path );
  7803. die ();
  7804. }
  7805. }
  7806. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7807. }
  7808. function staffCollect() {
  7809. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7810. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  7811. // $this->showCache($path);
  7812. Doo::loadModel ( 'statistics' );
  7813. $statistics = new statistics ();
  7814. Doo::loadModel ( "receiptDetail" );
  7815. $receiptDetail = new receiptDetail ();
  7816. Doo::loadModel ( 'L_category' );
  7817. $Lcategory = new L_category ();
  7818. Doo::loadModel ( 'accountItem' );
  7819. $accountItem = new accountItem ();
  7820. Doo::loadModel ( 'staff' );
  7821. $staff = new staff ();
  7822. Doo::loadModel ( 'itemStatistics' );
  7823. $itemStatistics = new itemStatistics ();
  7824. /*
  7825. * $stList=$statistics->getOne(array('select'=>'sum(rePrice) as rePrice,sum(agPrice) as agPrice', 'where'=>" Year(date)=".$year,'groupby'=>'Month(date)','asArray'=>true)); if(empty($stList)) $stList=array('rePrice'=>0,'agPrice'=>0); $data['stList']=array('rePrice'=>$stList['rePrice'],'agPrice'=>$stList['agPrice'],'skPrice'=>($stList['rePrice']-$stList['agPrice']));
  7826. */
  7827. // statistics html
  7828. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7829. if (empty ( $stList ))
  7830. $stList = array (
  7831. 'rePrice' => 0,
  7832. 'agPrice' => 0
  7833. );
  7834. $data ['stList'] = array (
  7835. 'rePrice' => $stList ['rePrice'],
  7836. 'agPrice' => $stList ['agPrice'],
  7837. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7838. );
  7839. // ---
  7840. $staffList = $staff->find ( array (
  7841. 'where' => 'username !="admin"',
  7842. 'asArray' => true
  7843. ) );
  7844. $LcategoryList = $Lcategory->find ( array (
  7845. 'asArray' => true
  7846. ) ); // 'staff='.$this->staff[0]['sid']." and
  7847. $itemStatisticsList = $itemStatistics->find ( array (
  7848. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7849. 'where' => " Year(date)=" . $year,
  7850. 'groupby' => 'staff,Month(date)',
  7851. 'asArray' => true
  7852. ) );
  7853. $categoryList = $staff->find ( array (
  7854. 'select' => 'COUNT(*) as count,cid,category',
  7855. 'where' => 'username !="admin"',
  7856. 'groupby' => 'cid',
  7857. 'asArray' => true
  7858. ) );
  7859. // print_r($itemStatisticsList);die;
  7860. // ceatre companyCollectHtml
  7861. foreach ( $categoryList as $vlu ) {
  7862. $count = $vlu ['count'] + 1;
  7863. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  7864. $m1 = 0;
  7865. $m2 = 0;
  7866. $m3 = 0;
  7867. $m4 = 0;
  7868. $m5 = 0;
  7869. $m6 = 0;
  7870. $m7 = 0;
  7871. $m8 = 0;
  7872. $m9 = 0;
  7873. $m10 = 0;
  7874. $m11 = 0;
  7875. $m12 = 0;
  7876. $m13 = 0;
  7877. foreach ( $staffList as $value ) {
  7878. if ($vlu ['cid'] == $value ['cid']) {
  7879. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  7880. $asum = 0;
  7881. for($i = 1; $i <= 12; $i ++) {
  7882. $falg = true;
  7883. foreach ( $itemStatisticsList as $v ) {
  7884. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  7885. if ($v ['month'] == 1)
  7886. $m1 += $v ['price'];
  7887. if ($v ['month'] == 2)
  7888. $m2 += $v ['price'];
  7889. if ($v ['month'] == 3)
  7890. $m3 += $v ['price'];
  7891. if ($v ['month'] == 4)
  7892. $m4 += $v ['price'];
  7893. if ($v ['month'] == 5)
  7894. $m5 += $v ['price'];
  7895. if ($v ['month'] == 6)
  7896. $m6 += $v ['price'];
  7897. if ($v ['month'] == 7)
  7898. $m7 += $v ['price'];
  7899. if ($v ['month'] == 8)
  7900. $m8 += $v ['price'];
  7901. if ($v ['month'] == 9)
  7902. $m9 += $v ['price'];
  7903. if ($v ['month'] == 10)
  7904. $m10 += $v ['price'];
  7905. if ($v ['month'] == 11)
  7906. $m11 += $v ['price'];
  7907. if ($v ['month'] == 12)
  7908. $m12 += $v ['price'];
  7909. $asum += $v ['price'];
  7910. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7911. $falg = false;
  7912. break;
  7913. }
  7914. }
  7915. if ($falg)
  7916. $html .= '<td class="taR">-</td>';
  7917. }
  7918. $m13 += $asum;
  7919. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7920. $collectHtml [$value ['username']] = array (
  7921. 'html' => $html,
  7922. 'sid' => $value ['sid']
  7923. );
  7924. $html = "";
  7925. }
  7926. }
  7927. $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>
  7928. <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>
  7929. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  7930. $collectHtml [$vlu ['cid']] = array (
  7931. 'html' => $hl,
  7932. 'sid' => ''
  7933. );
  7934. }
  7935. $data ['companyHtml'] = $collectHtml;
  7936. // total price html
  7937. $collectHtml = "";
  7938. $total = 0;
  7939. for($i = 1; $i <= 12; $i ++) {
  7940. $sumPrice = 0;
  7941. foreach ( $itemStatisticsList as $key => $value ) {
  7942. if ($value ['month'] == $i) {
  7943. $sumPrice += $value ['price'];
  7944. }
  7945. }
  7946. if ($sumPrice == 0)
  7947. $collectHtml .= '<td class="taR">-</td>';
  7948. else
  7949. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7950. $total += $sumPrice;
  7951. }
  7952. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7953. $data ['companyTotalHtml'] = $collectHtml;
  7954. $data ['total'] = $total;
  7955. $data ['year'] = $year;
  7956. $data ['memu'] = "receipt";
  7957. $data ['staff'] = $this->staff;
  7958. $data ['receiptMemu'] = 'companyCategoryCollect';
  7959. $data ['verifyId'] = $this->verifyId;
  7960. $data ['executeId'] = $this->executeId;
  7961. if ($year <= date ( "Y" )) {
  7962. Doo::loadModel ( 'receipt' );
  7963. $receipt = new receipt ();
  7964. $receiptList = $receipt->find ( array (
  7965. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  7966. 'asArray' => true
  7967. ) );
  7968. if (empty ( $receiptList )) { // generated files
  7969. ob_start ();
  7970. $this->render ( "/admin/saeaStaffCollectB", $data );
  7971. $this->cacheFile ( $path );
  7972. die ();
  7973. }
  7974. }
  7975. $this->render ( "/admin/saeaStaffCollectB", $data );
  7976. }
  7977. function staffCollectBak() {
  7978. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7979. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  7980. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  7981. $this->showCache ( $path );
  7982. Doo::loadModel ( 'statistics' );
  7983. $statistics = new statistics ();
  7984. Doo::loadModel ( "receiptDetail" );
  7985. $receiptDetail = new receiptDetail ();
  7986. Doo::loadModel ( 'L_category' );
  7987. $Lcategory = new L_category ();
  7988. Doo::loadModel ( 'accountItem' );
  7989. $accountItem = new accountItem ();
  7990. Doo::loadModel ( 'staff' );
  7991. $staff = new staff ();
  7992. Doo::loadModel ( 'itemStatistics' );
  7993. $itemStatistics = new itemStatistics ();
  7994. $itemStatisticsList = $itemStatistics->find ( array (
  7995. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7996. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  7997. 'groupby' => 'staff,itemCategory,Month(date)',
  7998. 'asArray' => true
  7999. ) );
  8000. $itemCategoryList = $itemStatistics->find ( array (
  8001. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8002. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8003. 'groupby' => 'cid,itemCategory,Month(date)',
  8004. 'asArray' => true
  8005. ) );
  8006. $LcategoryList = $Lcategory->find ( array (
  8007. 'asArray' => true
  8008. ) );
  8009. $staffList = $staff->find ( array (
  8010. 'asArray' => true
  8011. ) );
  8012. $htmlArray = array ();
  8013. foreach ( $LcategoryList as $value ) {
  8014. $htmlArray [$value ['title']] = array ();
  8015. foreach ( $staffList as $v ) {
  8016. if ($value ['cid'] == $v ['cid']) {
  8017. $html = "";
  8018. $falg = true;
  8019. $staffSumPrice = 0;
  8020. foreach ( $itemStatisticsList as $a ) {
  8021. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  8022. if (empty ( $a ['price'] )) {
  8023. $html .= '<td class="taR">-</td>';
  8024. $falg = false;
  8025. break;
  8026. } else {
  8027. $staffSumPrice += $a ['price'];
  8028. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8029. $falg = false;
  8030. break;
  8031. }
  8032. }
  8033. }
  8034. if ($falg) {
  8035. $html .= '<td class="taR">-</td>';
  8036. $falg = true;
  8037. }
  8038. $falg = true;
  8039. foreach ( $itemStatisticsList as $a ) {
  8040. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  8041. if (empty ( $a ['price'] )) {
  8042. $html .= '<td class="taR">-</td>';
  8043. $falg = false;
  8044. break;
  8045. } else {
  8046. $staffSumPrice += $a ['price'];
  8047. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8048. $falg = false;
  8049. break;
  8050. }
  8051. }
  8052. }
  8053. if ($falg) {
  8054. $html .= '<td class="taR">-</td>';
  8055. $falg = true;
  8056. }
  8057. $falg = true;
  8058. foreach ( $itemStatisticsList as $a ) {
  8059. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  8060. if (empty ( $a ['price'] )) {
  8061. $html .= '<td class="taR">-</td>';
  8062. $falg = false;
  8063. break;
  8064. } else {
  8065. $staffSumPrice += $a ['price'];
  8066. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8067. $falg = false;
  8068. break;
  8069. }
  8070. }
  8071. }
  8072. if ($falg) {
  8073. $html .= '<td class="taR">-</td>';
  8074. $falg = true;
  8075. }
  8076. $falg = true;
  8077. foreach ( $itemStatisticsList as $a ) {
  8078. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  8079. if (! empty ( $a ['price'] )) {
  8080. $staffSumPrice += $a ['price'];
  8081. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8082. $falg = false;
  8083. break;
  8084. } else {
  8085. $html .= '<td class="taR">-</td>';
  8086. $falg = false;
  8087. break;
  8088. }
  8089. }
  8090. }
  8091. if ($falg) {
  8092. $html .= '<td class="taR">-</td>';
  8093. $falg = true;
  8094. }
  8095. $falg = true;
  8096. foreach ( $itemStatisticsList as $a ) {
  8097. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  8098. if (! empty ( $a ['price'] )) {
  8099. $staffSumPrice += $a ['price'];
  8100. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8101. $falg = false;
  8102. break;
  8103. } else {
  8104. $html .= '<td class="taR">-</td>';
  8105. $falg = false;
  8106. break;
  8107. }
  8108. }
  8109. }
  8110. if ($falg) {
  8111. $html .= '<td class="taR">-</td>';
  8112. $falg = true;
  8113. }
  8114. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  8115. $htmlArray [$value ['title']] [$v ['username']] = $html;
  8116. }
  8117. }
  8118. /* -- --- */
  8119. // 合计费用
  8120. $cateHtml = "";
  8121. $catePrice = 0;
  8122. $cateFalg = true;
  8123. foreach ( $itemCategoryList as $l ) {
  8124. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  8125. if (empty ( $l ['price'] )) {
  8126. $cateHtml .= '<td class="colGreen taR">-</td>';
  8127. $cateFalg = false;
  8128. break;
  8129. } else {
  8130. $catePrice += $l ['price'];
  8131. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8132. $cateFalg = false;
  8133. break;
  8134. }
  8135. }
  8136. }
  8137. if ($cateFalg) {
  8138. $cateHtml .= '<td class="colGreen taR">-</td>';
  8139. $cateFalg = true;
  8140. }
  8141. $cateFalg = true;
  8142. foreach ( $itemCategoryList as $l ) {
  8143. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  8144. if (empty ( $l ['price'] )) {
  8145. $cateHtml .= '<td class="colGreen taR">-</td>';
  8146. $cateFalg = false;
  8147. break;
  8148. } else {
  8149. $catePrice += $l ['price'];
  8150. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8151. $cateFalg = false;
  8152. break;
  8153. }
  8154. }
  8155. }
  8156. if ($cateFalg) {
  8157. $cateHtml .= '<td class="colGreen taR">-</td>';
  8158. $cateFalg = true;
  8159. }
  8160. $cateFalg = true;
  8161. foreach ( $itemCategoryList as $l ) {
  8162. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  8163. if (empty ( $l ['price'] )) {
  8164. $cateHtml .= '<td class="colGreen taR">-</td>';
  8165. $cateFalg = false;
  8166. break;
  8167. } else {
  8168. $catePrice += $l ['price'];
  8169. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8170. $cateFalg = false;
  8171. break;
  8172. }
  8173. }
  8174. }
  8175. if ($cateFalg) {
  8176. $cateHtml .= '<td class="colGreen taR">-</td>';
  8177. $cateFalg = true;
  8178. }
  8179. $cateFalg = true;
  8180. foreach ( $itemCategoryList as $l ) {
  8181. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  8182. if (empty ( $l ['price'] )) {
  8183. $cateHtml .= '<td class="colGreen taR">-</td>';
  8184. $cateFalg = false;
  8185. break;
  8186. } else {
  8187. $catePrice += $l ['price'];
  8188. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8189. $cateFalg = false;
  8190. break;
  8191. }
  8192. }
  8193. }
  8194. if ($cateFalg) {
  8195. $cateHtml .= '<td class="colGreen taR">-</td>';
  8196. $cateFalg = true;
  8197. }
  8198. $cateFalg = true;
  8199. foreach ( $itemCategoryList as $l ) {
  8200. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  8201. if (empty ( $l ['price'] )) {
  8202. $cateHtml .= '<td class="colGreen taR">-</td>';
  8203. $cateFalg = false;
  8204. break;
  8205. } else {
  8206. $catePrice += $l ['price'];
  8207. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8208. $cateFalg = false;
  8209. break;
  8210. }
  8211. }
  8212. }
  8213. if ($cateFalg) {
  8214. $cateHtml .= '<td class="colGreen taR">-</td>';
  8215. $cateFalg = true;
  8216. }
  8217. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  8218. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  8219. /* -- --- */
  8220. }
  8221. // print_r($htmlArray);die;
  8222. $data ['htmlArray'] = $htmlArray;
  8223. // statistics html
  8224. $stList = $statistics->getOne ( array (
  8225. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8226. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8227. 'groupby' => 'Month(date)',
  8228. 'asArray' => true
  8229. ) );
  8230. if (empty ( $stList ))
  8231. $stList = array (
  8232. 'rePrice' => 0,
  8233. 'agPrice' => 0
  8234. );
  8235. $data ['stList'] = array (
  8236. 'rePrice' => $stList ['rePrice'],
  8237. 'agPrice' => $stList ['agPrice'],
  8238. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8239. );
  8240. $monthHtml = "";
  8241. for($i = 1; $i <= 12; $i ++) {
  8242. if ($i == $month)
  8243. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8244. else
  8245. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8246. }
  8247. $data ['monthHtml'] = $monthHtml;
  8248. $data ['year'] = $year;
  8249. $data ['month'] = $month;
  8250. $data ['memu'] = "receipt";
  8251. $data ['staff'] = $this->staff;
  8252. $data ['receiptMemu'] = 'companyCategoryCollect';
  8253. $data ['verifyId'] = $this->verifyId;
  8254. $data ['executeId'] = $this->executeId;
  8255. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  8256. Doo::loadModel ( 'receipt' );
  8257. $receipt = new receipt ();
  8258. $receiptList = $receipt->find ( array (
  8259. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  8260. 'asArray' => true
  8261. ) );
  8262. if (empty ( $receiptList )) { // generated files
  8263. ob_start ();
  8264. $this->render ( "/admin/saeaStaffCollect", $data );
  8265. $this->cacheFile ( $path );
  8266. die ();
  8267. }
  8268. }
  8269. $this->render ( "/admin/saeaStaffCollect", $data );
  8270. }
  8271. function lyt() {
  8272. Doo::loadModel ( "receiptDetail" );
  8273. $receiptDetail = new receiptDetail ();
  8274. $receiptCollectList = $receiptDetail->find ( array (
  8275. 'where' => 'status=1 ',
  8276. 'asArray' => true
  8277. ) );
  8278. foreach ( $receiptCollectList as $key => $value ) {
  8279. $receiptDetail = new receiptDetail ();
  8280. $receiptDetail->pastDate = $value ['date'];
  8281. $receiptDetail->update ( array (
  8282. 'where' => "rdid= '" . $value ['rdid'] . "'"
  8283. ) );
  8284. }
  8285. }
  8286. function staffCollectMonthDetail() {
  8287. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8288. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8289. if (! $year)
  8290. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8291. if (! $month)
  8292. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8293. Doo::loadModel ( 'staff' );
  8294. $staff = new staff ();
  8295. Doo::loadModel ( "receiptDetail" );
  8296. $receiptDetail = new receiptDetail ();
  8297. Doo::loadModel ( 'accountItem' );
  8298. $accountItem = new accountItem ();
  8299. Doo::loadModel ( 'statistics' );
  8300. $statistics = new statistics ();
  8301. Doo::loadModel ( 'L_category' );
  8302. $lCategory = new L_category ();
  8303. $staffList = $staff->find ( array (
  8304. 'where' => 'username!="admin"',
  8305. 'asArray' => true
  8306. ) );
  8307. $categoryList = $staff->find ( array (
  8308. 'select' => 'COUNT(*) as count,cid,category',
  8309. 'where' => 'username !="admin"',
  8310. 'groupby' => 'cid',
  8311. 'asArray' => true
  8312. ) );
  8313. $list = array ();
  8314. foreach ( $categoryList as $vlu ) {
  8315. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8316. $r1 = 0;
  8317. $r2 = 0;
  8318. $r3 = 0;
  8319. $r4 = 0;
  8320. $r5 = 0;
  8321. $r6 = 0;
  8322. $r7 = 0;
  8323. $r8 = 0;
  8324. $r9 = 0;
  8325. $r10 = 0;
  8326. $r11 = 0;
  8327. $r12 = 0;
  8328. $r13 = 0;
  8329. $r14 = 0;
  8330. $r15 = 0;
  8331. $c1 = 0;
  8332. $c2 = 0;
  8333. $c3 = 0;
  8334. $c4 = 0;
  8335. $c5 = 0;
  8336. $c6 = 0;
  8337. $p1 = 0;
  8338. $p2 = 0;
  8339. $p3 = 0;
  8340. $p4 = 0;
  8341. $p5 = 0;
  8342. $p6 = 0;
  8343. $p7 = 0;
  8344. $p8 = 0;
  8345. $p9 = 0;
  8346. $t1 = 0;
  8347. $t2 = 0;
  8348. $t3 = 0;
  8349. $t4 = 0;
  8350. $t5 = 0;
  8351. $s1 = 0;
  8352. $m1 = 0;
  8353. foreach ( $staffList as $value ) {
  8354. if ($vlu ['cid'] == $value ['cid']) {
  8355. // pastDate
  8356. $receiptCollectList = $receiptDetail->find ( array (
  8357. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8358. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8359. 'groupby' => 'item,Month(pastDate),itemCategory',
  8360. 'asArray' => true
  8361. ) );
  8362. // if ($value['sid']==42){
  8363. // print_r($receiptCollectList);die;
  8364. // }
  8365. if (! empty ( $receiptCollectList )) {
  8366. $receiptL = array (
  8367. '日常相关费用' => array (),
  8368. '差旅相关费用' => array (),
  8369. '培训班费用' => array (),
  8370. '其他' => array ()
  8371. );
  8372. $html = "";
  8373. $psum = 0;
  8374. $item = array (
  8375. '市内交通费',
  8376. '市内出租费',
  8377. '办事处房租',
  8378. '电话费',
  8379. '水费',
  8380. '电费',
  8381. '办公费用',
  8382. '邮寄费',
  8383. '其他费用',
  8384. '车辆费用',
  8385. '广告费',
  8386. '团队建设费',
  8387. '物业管理费',
  8388. '宽带费'
  8389. );
  8390. foreach ( $item as $va ) {
  8391. $falg = true;
  8392. foreach ( $receiptCollectList as $v ) {
  8393. if ($v ['itemCategory'] == '日常相关费用') {
  8394. if ($v ['item'] == $va) {
  8395. if ($va == '市内交通费')
  8396. $r1 += $v ['price'];
  8397. if ($va == '市内出租费')
  8398. $r2 += $v ['price'];
  8399. if ($va == '办事处房租')
  8400. $r3 += $v ['price'];
  8401. if ($va == '电话费')
  8402. $r4 += $v ['price'];
  8403. if ($va == '水费')
  8404. $r5 += $v ['price'];
  8405. if ($va == '电费')
  8406. $r6 += $v ['price'];
  8407. if ($va == '办公费用')
  8408. $r7 += $v ['price'];
  8409. if ($va == '邮寄费')
  8410. $r8 += $v ['price'];
  8411. if ($va == '其他费用')
  8412. $r9 += $v ['price'];
  8413. if ($va == '车辆费用')
  8414. $r10 += $v ['price'];
  8415. if ($va == '广告费')
  8416. $r11 += $v ['price'];
  8417. if ($va == '团队建设费')
  8418. $r13 += $v ['price'];
  8419. if ($va == '物业管理费')
  8420. $r14 += $v ['price'];
  8421. if ($va == '宽带费')
  8422. $r15 += $v ['price'];
  8423. $psum += $v ['price'];
  8424. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8425. $falg = false;
  8426. break;
  8427. }
  8428. }
  8429. }
  8430. if ($falg)
  8431. $html .= '<td class="taR">-</td>';
  8432. }
  8433. $r12 += $psum;
  8434. if (! empty ( $psum ))
  8435. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8436. else
  8437. $psum = '<td class="colGreen taR">-</td>';
  8438. $receiptL ['日常相关费用'] = $psum . $html;
  8439. /* ----------------------------------- */
  8440. $html = "";
  8441. $psum = 0;
  8442. $item = array (
  8443. '往来交通费',
  8444. '市内交通费',
  8445. '出差住宿费',
  8446. '出差补助',
  8447. '其他费用'
  8448. );
  8449. foreach ( $item as $va ) {
  8450. $falg = true;
  8451. foreach ( $receiptCollectList as $v ) {
  8452. if ($v ['itemCategory'] == '差旅相关费用') {
  8453. if ($v ['item'] == $va) {
  8454. if ($va == '往来交通费')
  8455. $c1 += $v ['price'];
  8456. if ($va == '市内交通费')
  8457. $c2 += $v ['price'];
  8458. if ($va == '出差住宿费')
  8459. $c3 += $v ['price'];
  8460. if ($va == '出差补助')
  8461. $c4 += $v ['price'];
  8462. if ($va == '其他费用')
  8463. $c5 += $v ['price'];
  8464. $psum += $v ['price'];
  8465. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8466. $falg = false;
  8467. break;
  8468. }
  8469. }
  8470. }
  8471. if ($falg)
  8472. $html .= '<td class="taR">-</td>';
  8473. }
  8474. $c6 += $psum;
  8475. if (! empty ( $psum ))
  8476. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8477. else
  8478. $psum = '<td class="colGreen taR">-</td>';
  8479. $receiptL ['差旅相关费用'] = $psum . $html;
  8480. /* ------------------------------------- */
  8481. $html = "";
  8482. $psum = 0;
  8483. $item = array (
  8484. '场租费',
  8485. '薪酬',
  8486. '住宿费',
  8487. '交通费',
  8488. '餐饮费',
  8489. '办公费',
  8490. '公关费',
  8491. '其他'
  8492. );
  8493. foreach ( $item as $va ) {
  8494. $falg = true;
  8495. foreach ( $receiptCollectList as $v ) {
  8496. if ($v ['itemCategory'] == '培训班费用') {
  8497. if ($v ['item'] == $va) {
  8498. if ($va == '场租费')
  8499. $p1 += $v ['price'];
  8500. if ($va == '薪酬')
  8501. $p2 += $v ['price'];
  8502. if ($va == '住宿费')
  8503. $p3 += $v ['price'];
  8504. if ($va == '交通费')
  8505. $p4 += $v ['price'];
  8506. if ($va == '餐饮费')
  8507. $p5 += $v ['price'];
  8508. if ($va == '办公费')
  8509. $p6 += $v ['price'];
  8510. if ($va == '公关费')
  8511. $p7 += $v ['price'];
  8512. if ($va == '其他')
  8513. $p8 += $v ['price'];
  8514. $psum += $v ['price'];
  8515. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8516. $falg = false;
  8517. break;
  8518. }
  8519. }
  8520. }
  8521. if ($falg)
  8522. $html .= '<td class="taR">-</td>';
  8523. }
  8524. $p9 += $psum;
  8525. if (! empty ( $psum ))
  8526. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8527. else
  8528. $psum = '<td class="colGreen taR">-</td>';
  8529. $receiptL ['培训班费用'] = $psum . $html;
  8530. /* ------------------------------------- */
  8531. $html = "";
  8532. $psum = 0;
  8533. $item = array (
  8534. '公关费',
  8535. '广告费',
  8536. '借款',
  8537. '可自加费用'
  8538. );
  8539. foreach ( $item as $va ) {
  8540. $falg = true;
  8541. foreach ( $receiptCollectList as $v ) {
  8542. if ($v ['itemCategory'] == '其他') {
  8543. // if ($value['sid']==42){
  8544. //
  8545. // echo var_dump($v['item']);
  8546. // echo var_dump($va);
  8547. // echo var_dump($v['item']==" ".$va);
  8548. // echo $v['item']."==".$va."/<br/>";
  8549. // //print_r( $receiptCollectList);//echo $va;
  8550. // }
  8551. if (trim ( $v ['item'] ) == $va) {
  8552. if ($va == '公关费')
  8553. $t1 += $v ['price'];
  8554. if ($va == '广告费') {
  8555. $t2 += $v ['price'];
  8556. }
  8557. if ($va == '借款')
  8558. $t3 += $v ['price'];
  8559. if ($va == '可自加费用')
  8560. $t4 += $v ['price'];
  8561. $psum += $v ['price'];
  8562. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8563. $falg = false;
  8564. break;
  8565. }
  8566. }
  8567. }
  8568. if ($falg)
  8569. $html .= '<td class="taR">-</td>';
  8570. }
  8571. $t5 += $psum;
  8572. if (! empty ( $psum ))
  8573. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8574. else
  8575. $psum = '<td class="colGreen taR">-</td>';
  8576. $receiptL ['其他'] = $psum . $html;
  8577. /* ------------------------------------- */
  8578. $html = "";
  8579. $psum = 0;
  8580. foreach ( $receiptCollectList as $v ) {
  8581. if ($v ['itemCategory'] == '报销金额调整') {
  8582. if (! empty ( $v ['price'] )) {
  8583. $psum += $v ['price'];
  8584. }
  8585. }
  8586. }
  8587. $s1 += $psum;
  8588. if (! empty ( $psum ))
  8589. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8590. else
  8591. $psum = '<td class="taR colOrange">-</td>';
  8592. $receiptL ['报销金额调整'] = $psum . $html;
  8593. } else {
  8594. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8595. <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>
  8596. <td class="taR">-</td><td class="taR">-</td>';
  8597. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  8598. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8599. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8600. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8601. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8602. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  8603. }
  8604. $monthStaffPrice = $receiptDetail->find ( array (
  8605. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8606. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8607. 'groupby' => 'Month(pastDate)',
  8608. 'asArray' => true
  8609. ) );
  8610. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  8611. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  8612. $m1 += $monthStaffPrice [0] ['price'];
  8613. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  8614. } else
  8615. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  8616. $list [$value ['username']] = $receiptL;
  8617. }
  8618. }
  8619. $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>
  8620. <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>
  8621. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  8622. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  8623. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  8624. $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>
  8625. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  8626. $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>';
  8627. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  8628. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  8629. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  8630. }
  8631. $data ['list'] = $list;
  8632. $receiptCollectList = $receiptDetail->find ( array (
  8633. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8634. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8635. 'groupby' => 'item,Month(pastDate),itemCategory',
  8636. 'asArray' => true
  8637. ) );
  8638. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  8639. // statistics html
  8640. $stList = $statistics->getOne ( array (
  8641. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8642. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8643. 'groupby' => 'Month(date)',
  8644. 'asArray' => true
  8645. ) );
  8646. if (empty ( $stList ))
  8647. $stList = array (
  8648. 'rePrice' => 0,
  8649. 'agPrice' => 0
  8650. );
  8651. $data ['stList'] = array (
  8652. 'rePrice' => $stList ['rePrice'],
  8653. 'agPrice' => $stList ['agPrice'],
  8654. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8655. );
  8656. $monthHtml = "";
  8657. for($i = 1; $i <= 12; $i ++) {
  8658. if ($i == $month)
  8659. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8660. else
  8661. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8662. }
  8663. $data ['monthHtml'] = $monthHtml;
  8664. $data ['year'] = $year;
  8665. $data ['month'] = $month;
  8666. $data ['memu'] = "receipt";
  8667. $data ['staff'] = $this->staff;
  8668. $data ['receiptMemu'] = 'companyCategoryCollect';
  8669. $data ['verifyId'] = $this->verifyId;
  8670. $data ['executeId'] = $this->executeId;
  8671. $this->render ( "/admin/staffCollectMonthDetail", $data );
  8672. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  8673. }
  8674. function staffCollectMonthDetail2() {
  8675. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8676. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8677. if (! $year)
  8678. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8679. if (! $month)
  8680. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8681. Doo::loadModel ( 'staff' );
  8682. $staff = new staff ();
  8683. Doo::loadModel ( "receiptDetail" );
  8684. $receiptDetail = new receiptDetail ();
  8685. Doo::loadModel ( 'accountItem' );
  8686. $accountItem = new accountItem ();
  8687. Doo::loadModel ( 'statistics' );
  8688. $statistics = new statistics ();
  8689. Doo::loadModel ( 'L_category' );
  8690. $lCategory = new L_category ();
  8691. $staffList = $staff->find ( array (
  8692. 'where' => 'username!="admin"',
  8693. 'asArray' => true
  8694. ) );
  8695. $categoryList = $staff->find ( array (
  8696. 'select' => 'COUNT(*) as count,cid,category',
  8697. 'where' => 'username !="admin"',
  8698. 'groupby' => 'cid',
  8699. 'asArray' => true
  8700. ) );
  8701. $list = array ();
  8702. foreach ( $categoryList as $vlu ) {
  8703. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8704. $r1 = 0;
  8705. $r2 = 0;
  8706. $r3 = 0;
  8707. $r4 = 0;
  8708. $r5 = 0;
  8709. $r6 = 0;
  8710. $r7 = 0;
  8711. $r8 = 0;
  8712. $r9 = 0;
  8713. $r10 = 0;
  8714. $r11 = 0;
  8715. $r12 = 0;
  8716. $r13 = 0;
  8717. $r14 = 0;
  8718. $r15 = 0;
  8719. $c1 = 0;
  8720. $c2 = 0;
  8721. $c3 = 0;
  8722. $c4 = 0;
  8723. $c5 = 0;
  8724. $c6 = 0;
  8725. $p1 = 0;
  8726. $p2 = 0;
  8727. $p3 = 0;
  8728. $p4 = 0;
  8729. $p5 = 0;
  8730. $p6 = 0;
  8731. $p7 = 0;
  8732. $p8 = 0;
  8733. $p9 = 0;
  8734. $t1 = 0;
  8735. $t2 = 0;
  8736. $t3 = 0;
  8737. $t4 = 0;
  8738. $t5 = 0;
  8739. $s1 = 0;
  8740. $m1 = 0;
  8741. foreach ( $staffList as $value ) {
  8742. if ($vlu ['cid'] == $value ['cid']) {
  8743. $receiptCollectList = $receiptDetail->find ( array (
  8744. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  8745. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  8746. 'groupby' => 'item,Month(date),itemCategory',
  8747. 'asArray' => true
  8748. ) );
  8749. if (! empty ( $receiptCollectList )) {
  8750. $receiptL = array (
  8751. '日常相关费用' => array (),
  8752. '差旅相关费用' => array (),
  8753. '培训班费用' => array (),
  8754. '其他' => array ()
  8755. );
  8756. $html = "";
  8757. $psum = 0;
  8758. $item = array (
  8759. '市内交通费',
  8760. '市内出租费',
  8761. '办事处房租',
  8762. '电话费',
  8763. '水费',
  8764. '电费',
  8765. '办公费用',
  8766. '邮寄费',
  8767. '其他费用',
  8768. '车辆费用',
  8769. '广告费',
  8770. '团队建设费',
  8771. '物业管理费',
  8772. '宽带费'
  8773. );
  8774. foreach ( $item as $va ) {
  8775. $falg = true;
  8776. foreach ( $receiptCollectList as $v ) {
  8777. if ($v ['itemCategory'] == '日常相关费用') {
  8778. if ($v ['item'] == $va) {
  8779. if ($va == '市内交通费')
  8780. $r1 += $v ['price'];
  8781. if ($va == '市内出租费')
  8782. $r2 += $v ['price'];
  8783. if ($va == '办事处房租')
  8784. $r3 += $v ['price'];
  8785. if ($va == '电话费')
  8786. $r4 += $v ['price'];
  8787. if ($va == '水费')
  8788. $r5 += $v ['price'];
  8789. if ($va == '电费')
  8790. $r6 += $v ['price'];
  8791. if ($va == '办公费用')
  8792. $r7 += $v ['price'];
  8793. if ($va == '邮寄费')
  8794. $r8 += $v ['price'];
  8795. if ($va == '其他费用')
  8796. $r9 += $v ['price'];
  8797. if ($va == '车辆费用')
  8798. $r10 += $v ['price'];
  8799. if ($va == '广告费')
  8800. $r11 += $v ['price'];
  8801. if ($va == '团队建设费')
  8802. $r13 += $v ['price'];
  8803. if ($va == '物业管理费')
  8804. $r14 += $v ['price'];
  8805. if ($va == '宽带费')
  8806. $r15 += $v ['price'];
  8807. $psum += $v ['price'];
  8808. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8809. $falg = false;
  8810. break;
  8811. }
  8812. }
  8813. }
  8814. if ($falg)
  8815. $html .= '<td class="taR">-</td>';
  8816. }
  8817. $r12 += $psum;
  8818. if (! empty ( $psum ))
  8819. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8820. else
  8821. $psum = '<td class="colGreen taR">-</td>';
  8822. $receiptL ['日常相关费用'] = $psum . $html;
  8823. /* ----------------------------------- */
  8824. $html = "";
  8825. $psum = 0;
  8826. $item = array (
  8827. '往来交通费',
  8828. '市内交通费',
  8829. '出差住宿费',
  8830. '出差补助',
  8831. '其他费用'
  8832. );
  8833. foreach ( $item as $va ) {
  8834. $falg = true;
  8835. foreach ( $receiptCollectList as $v ) {
  8836. if ($v ['itemCategory'] == '差旅相关费用') {
  8837. if ($v ['item'] == $va) {
  8838. if ($va == '往来交通费')
  8839. $c1 += $v ['price'];
  8840. if ($va == '市内交通费')
  8841. $c2 += $v ['price'];
  8842. if ($va == '出差住宿费')
  8843. $c3 += $v ['price'];
  8844. if ($va == '出差补助')
  8845. $c4 += $v ['price'];
  8846. if ($va == '其他费用')
  8847. $c5 += $v ['price'];
  8848. $psum += $v ['price'];
  8849. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8850. $falg = false;
  8851. break;
  8852. }
  8853. }
  8854. }
  8855. if ($falg)
  8856. $html .= '<td class="taR">-</td>';
  8857. }
  8858. $c6 += $psum;
  8859. if (! empty ( $psum ))
  8860. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8861. else
  8862. $psum = '<td class="colGreen taR">-</td>';
  8863. $receiptL ['差旅相关费用'] = $psum . $html;
  8864. /* ------------------------------------- */
  8865. $html = "";
  8866. $psum = 0;
  8867. $item = array (
  8868. '场租费',
  8869. '薪酬',
  8870. '住宿费',
  8871. '交通费',
  8872. '餐饮费',
  8873. '办公费',
  8874. '公关费',
  8875. '其他'
  8876. );
  8877. foreach ( $item as $va ) {
  8878. $falg = true;
  8879. foreach ( $receiptCollectList as $v ) {
  8880. if ($v ['itemCategory'] == '培训班费用') {
  8881. if ($v ['item'] == $va) {
  8882. if ($va == '场租费')
  8883. $p1 += $v ['price'];
  8884. if ($va == '薪酬')
  8885. $p2 += $v ['price'];
  8886. if ($va == '住宿费')
  8887. $p3 += $v ['price'];
  8888. if ($va == '交通费')
  8889. $p4 += $v ['price'];
  8890. if ($va == '餐饮费')
  8891. $p5 += $v ['price'];
  8892. if ($va == '办公费')
  8893. $p6 += $v ['price'];
  8894. if ($va == '公关费')
  8895. $p7 += $v ['price'];
  8896. if ($va == '其他')
  8897. $p8 += $v ['price'];
  8898. $psum += $v ['price'];
  8899. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8900. $falg = false;
  8901. break;
  8902. }
  8903. }
  8904. }
  8905. if ($falg)
  8906. $html .= '<td class="taR">-</td>';
  8907. }
  8908. $p9 += $psum;
  8909. if (! empty ( $psum ))
  8910. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8911. else
  8912. $psum = '<td class="colGreen taR">-</td>';
  8913. $receiptL ['培训班费用'] = $psum . $html;
  8914. /* ------------------------------------- */
  8915. $html = "";
  8916. $psum = 0;
  8917. $item = array (
  8918. '公关费',
  8919. '广告费',
  8920. '借款',
  8921. '可自加费用'
  8922. );
  8923. foreach ( $item as $va ) {
  8924. $falg = true;
  8925. foreach ( $receiptCollectList as $v ) {
  8926. if ($v ['itemCategory'] == '其他') {
  8927. if ($v ['item'] == $va) {
  8928. if ($va == '公关费')
  8929. $t1 += $v ['price'];
  8930. if ($va == '广告费')
  8931. $t2 += $v ['price'];
  8932. if ($va == '借款')
  8933. $t3 += $v ['price'];
  8934. if ($va == '可自加费用')
  8935. $t4 += $v ['price'];
  8936. $psum += $v ['price'];
  8937. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8938. $falg = false;
  8939. break;
  8940. }
  8941. }
  8942. }
  8943. if ($falg)
  8944. $html .= '<td class="taR">-</td>';
  8945. }
  8946. $t5 += $psum;
  8947. if (! empty ( $psum ))
  8948. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8949. else
  8950. $psum = '<td class="colGreen taR">-</td>';
  8951. $receiptL ['其他'] = $psum . $html;
  8952. /* ------------------------------------- */
  8953. $html = "";
  8954. $psum = 0;
  8955. foreach ( $receiptCollectList as $v ) {
  8956. if ($v ['itemCategory'] == '报销金额调整') {
  8957. if (! empty ( $v ['price'] )) {
  8958. $psum += $v ['price'];
  8959. }
  8960. }
  8961. }
  8962. $s1 += $psum;
  8963. if (! empty ( $psum ))
  8964. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8965. else
  8966. $psum = '<td class="taR colOrange">-</td>';
  8967. $receiptL ['报销金额调整'] = $psum . $html;
  8968. } else {
  8969. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8970. <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>';
  8971. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  8972. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8973. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8974. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8975. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8976. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  8977. }
  8978. $monthStaffPrice = $receiptDetail->find ( array (
  8979. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  8980. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  8981. 'asArray' => true
  8982. ) );
  8983. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  8984. $m1 += $monthStaffPrice [0] ['price'];
  8985. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  8986. } else
  8987. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  8988. $list [$value ['username']] = $receiptL;
  8989. }
  8990. }
  8991. $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>
  8992. <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>
  8993. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  8994. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  8995. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  8996. $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>
  8997. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  8998. $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>';
  8999. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  9000. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  9001. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  9002. }
  9003. $data ['list'] = $list;
  9004. $receiptCollectList = $receiptDetail->find ( array (
  9005. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9006. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9007. 'groupby' => 'item,Month(date),itemCategory',
  9008. 'asArray' => true
  9009. ) );
  9010. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9011. // statistics html
  9012. $stList = $statistics->getOne ( array (
  9013. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9014. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9015. 'groupby' => 'Month(date)',
  9016. 'asArray' => true
  9017. ) );
  9018. if (empty ( $stList ))
  9019. $stList = array (
  9020. 'rePrice' => 0,
  9021. 'agPrice' => 0
  9022. );
  9023. $data ['stList'] = array (
  9024. 'rePrice' => $stList ['rePrice'],
  9025. 'agPrice' => $stList ['agPrice'],
  9026. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9027. );
  9028. $monthHtml = "";
  9029. for($i = 1; $i <= 12; $i ++) {
  9030. if ($i == $month)
  9031. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9032. else
  9033. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9034. }
  9035. $data ['monthHtml'] = $monthHtml;
  9036. $data ['year'] = $year;
  9037. $data ['month'] = $month;
  9038. $data ['memu'] = "receipt";
  9039. $data ['staff'] = $this->staff;
  9040. $data ['receiptMemu'] = 'companyCategoryCollect';
  9041. $data ['verifyId'] = $this->verifyId;
  9042. $data ['executeId'] = $this->executeId;
  9043. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  9044. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9045. }
  9046. function companyMonthCollectDetail() {
  9047. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9048. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9049. if (! $year)
  9050. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9051. if (! $month)
  9052. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9053. Doo::loadModel ( 'staff' );
  9054. $staff = new staff ();
  9055. Doo::loadModel ( "receiptDetail" );
  9056. $receiptDetail = new receiptDetail ();
  9057. Doo::loadModel ( 'accountItem' );
  9058. $accountItem = new accountItem ();
  9059. Doo::loadModel ( 'statistics' );
  9060. $statistics = new statistics ();
  9061. Doo::loadModel ( 'L_category' );
  9062. $lCategory = new L_category ();
  9063. $staffList = $staff->find ( array (
  9064. 'where' => 'username!="admin"',
  9065. 'asArray' => true
  9066. ) );
  9067. $categoryList = $lCategory->find ( array (
  9068. 'asArray' => true
  9069. ) );
  9070. $list = array ();
  9071. foreach ( $categoryList as $value ) {
  9072. $receiptCollectList = $receiptDetail->find ( array (
  9073. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9074. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9075. 'groupby' => 'item,Month(pastDate),itemCategory',
  9076. 'asArray' => true
  9077. ) );
  9078. if (! empty ( $receiptCollectList )) {
  9079. $receiptL = array (
  9080. '日常相关费用' => array (),
  9081. '差旅相关费用' => array (),
  9082. '培训班费用' => array (),
  9083. '其他' => array ()
  9084. );
  9085. $html = "";
  9086. $psum = 0;
  9087. $item = array (
  9088. '市内交通费',
  9089. '市内出租费',
  9090. '办事处房租',
  9091. '电话费',
  9092. '水费',
  9093. '电费',
  9094. '办公费用',
  9095. '邮寄费',
  9096. '其他费用',
  9097. '车辆费用',
  9098. '广告费',
  9099. '团队建设费'
  9100. );
  9101. foreach ( $item as $va ) {
  9102. $falg = true;
  9103. foreach ( $receiptCollectList as $v ) {
  9104. if ($v ['itemCategory'] == '日常相关费用') {
  9105. if ($v ['item'] == $va) {
  9106. $psum += $v ['price'];
  9107. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9108. $falg = false;
  9109. break;
  9110. }
  9111. }
  9112. }
  9113. if ($falg)
  9114. $html .= '<td class="taR">-</td>';
  9115. }
  9116. if (! empty ( $psum ))
  9117. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9118. else
  9119. $psum = '<td class="colGreen taR">-</td>';
  9120. $receiptL ['日常相关费用'] = $psum . $html;
  9121. /* ----------------------------------- */
  9122. $html = "";
  9123. $psum = 0;
  9124. $item = array (
  9125. '往来交通费',
  9126. '市内交通费',
  9127. '出差住宿费',
  9128. '出差补助',
  9129. '其他费用'
  9130. );
  9131. foreach ( $item as $va ) {
  9132. $falg = true;
  9133. foreach ( $receiptCollectList as $v ) {
  9134. if ($v ['itemCategory'] == '差旅相关费用') {
  9135. if ($v ['item'] == $va) {
  9136. $psum += $v ['price'];
  9137. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9138. $falg = false;
  9139. break;
  9140. }
  9141. }
  9142. }
  9143. if ($falg)
  9144. $html .= '<td class="taR">-</td>';
  9145. }
  9146. if (! empty ( $psum ))
  9147. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9148. else
  9149. $psum = '<td class="colGreen taR">-</td>';
  9150. $receiptL ['差旅相关费用'] = $psum . $html;
  9151. /* ------------------------------------- */
  9152. $html = "";
  9153. $psum = 0;
  9154. $item = array (
  9155. '场租费',
  9156. '薪酬',
  9157. '住宿费',
  9158. '交通费',
  9159. '餐饮费',
  9160. '办公费',
  9161. '公关费',
  9162. '其他'
  9163. );
  9164. foreach ( $item as $va ) {
  9165. $falg = true;
  9166. foreach ( $receiptCollectList as $v ) {
  9167. if ($v ['itemCategory'] == '培训班费用') {
  9168. if ($v ['item'] == $va) {
  9169. $psum += $v ['price'];
  9170. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9171. $falg = false;
  9172. break;
  9173. }
  9174. }
  9175. }
  9176. if ($falg)
  9177. $html .= '<td class="taR">-</td>';
  9178. }
  9179. if (! empty ( $psum ))
  9180. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9181. else
  9182. $psum = '<td class="colGreen taR">-</td>';
  9183. $receiptL ['培训班费用'] = $psum . $html;
  9184. /* ------------------------------------- */
  9185. $html = "";
  9186. $psum = 0;
  9187. $item = array (
  9188. '公关费',
  9189. '广告费',
  9190. '借款',
  9191. '可自加费用'
  9192. );
  9193. foreach ( $item as $va ) {
  9194. $falg = true;
  9195. foreach ( $receiptCollectList as $v ) {
  9196. if ($v ['itemCategory'] == '其他') {
  9197. if ($v ['item'] == $va) {
  9198. $psum += $v ['price'];
  9199. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9200. $falg = false;
  9201. break;
  9202. }
  9203. }
  9204. }
  9205. if ($falg)
  9206. $html .= '<td class="taR">-</td>';
  9207. }
  9208. if (! empty ( $psum ))
  9209. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9210. else
  9211. $psum = '<td class="colGreen taR">-</td>';
  9212. $receiptL ['其他'] = $psum . $html;
  9213. /* ------------------------------------- */
  9214. $html = "";
  9215. $psum = 0;
  9216. foreach ( $receiptCollectList as $v ) {
  9217. if ($v ['itemCategory'] == '报销金额调整') {
  9218. if (! empty ( $v ['price'] ))
  9219. $psum += $v ['price'];
  9220. }
  9221. }
  9222. if (! empty ( $psum ))
  9223. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9224. else
  9225. $psum = '<td class="taR colOrange">-</td>';
  9226. $receiptL ['报销金额调整'] = $psum . $html;
  9227. } else {
  9228. $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>
  9229. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9230. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9231. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9232. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9233. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9234. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9235. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9236. }
  9237. $monthStaffPrice = $receiptDetail->find ( array (
  9238. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9239. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9240. 'asArray' => true
  9241. ) );
  9242. if (! empty ( $monthStaffPrice [0] ['price'] ))
  9243. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9244. else
  9245. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9246. $list [$value ['title']] = $receiptL;
  9247. }
  9248. $data ['list'] = $list;
  9249. $receiptCollectList = $receiptDetail->find ( array (
  9250. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9251. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9252. 'groupby' => 'item,Month(pastDate),itemCategory',
  9253. 'asArray' => true
  9254. ) );
  9255. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9256. // print_r($data['monthPriceHtml']);
  9257. // foreach ($data['monthPriceHtml'] as $value){
  9258. // echo $value;
  9259. // }
  9260. // die;
  9261. // statistics html
  9262. $stList = $statistics->getOne ( array (
  9263. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9264. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9265. 'groupby' => 'Month(date)',
  9266. 'asArray' => true
  9267. ) );
  9268. if (empty ( $stList ))
  9269. $stList = array (
  9270. 'rePrice' => 0,
  9271. 'agPrice' => 0
  9272. );
  9273. $data ['stList'] = array (
  9274. 'rePrice' => $stList ['rePrice'],
  9275. 'agPrice' => $stList ['agPrice'],
  9276. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9277. );
  9278. $monthHtml = "";
  9279. for($i = 1; $i <= 12; $i ++) {
  9280. if ($i == $month)
  9281. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9282. else
  9283. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9284. }
  9285. $data ['monthHtml'] = $monthHtml;
  9286. $data ['year'] = $year;
  9287. $data ['month'] = $month;
  9288. $data ['memu'] = "receipt";
  9289. $data ['staff'] = $this->staff;
  9290. $data ['receiptMemu'] = 'companyCategoryCollect';
  9291. $data ['verifyId'] = $this->verifyId;
  9292. $data ['executeId'] = $this->executeId;
  9293. $this->render ( "/admin/companyMonthCollectDetail", $data );
  9294. }
  9295. function staffCollectDetail() {
  9296. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9297. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  9298. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  9299. if (! $staffname) {
  9300. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  9301. $staffname = urldecode ( $staffname );
  9302. }
  9303. Doo::loadModel ( 'staff' );
  9304. $staff = new staff ();
  9305. Doo::loadModel ( "receiptDetail" );
  9306. $receiptDetail = new receiptDetail ();
  9307. Doo::loadModel ( 'accountItem' );
  9308. $accountItem = new accountItem ();
  9309. Doo::loadModel ( 'statistics' );
  9310. $statistics = new statistics ();
  9311. Doo::loadModel ( 'L_category' );
  9312. $lCategory = new L_category ();
  9313. $staffList = $staff->find ( array (
  9314. 'asArray' => true
  9315. ) );
  9316. $stHtml = '';
  9317. $stTitle = "";
  9318. $staffId = 0;
  9319. $cid = 0;
  9320. $ocid = 0;
  9321. foreach ( $staffList as $value ) {
  9322. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  9323. $stTitle = $value ['category'] . '-' . $value ['username'];
  9324. $staffId = $value ['sid'];
  9325. $cid = $value ['cid'];
  9326. $ocid = $value ['cid'];
  9327. if (! empty ( $value ['othercid'] ))
  9328. $cid = $value ['cid'] . ',' . $value ['othercid'];
  9329. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9330. } elseif ($value ['username'] != 'admin')
  9331. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9332. }
  9333. $data ['lCategoryHtml'] = $lCategory->find ( array (
  9334. 'where' => 'cid in(' . $cid . ')',
  9335. 'asArray' => true
  9336. ) );
  9337. if (empty ( $pcid ))
  9338. $pcid = $ocid;
  9339. $data ['ocid'] = $pcid;
  9340. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  9341. $this->showCache ( $path );
  9342. //
  9343. $receiptCollectList = $receiptDetail->find ( array (
  9344. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9345. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9346. 'groupby' => 'item,Month(pastDate),itemCategory',
  9347. 'asArray' => true
  9348. ) );
  9349. $accountList = $accountItem->find ( array (
  9350. 'asArray' => true
  9351. ) );
  9352. // create CollectDetail HTML
  9353. $collectHtml = array ();
  9354. foreach ( $accountList as $key => $value ) {
  9355. $html = "";
  9356. $asum = 0;
  9357. for($i = 1; $i <= 12; $i ++) {
  9358. $falg = true;
  9359. foreach ( $receiptCollectList as $v ) {
  9360. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9361. $asum += $v ['price'];
  9362. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9363. $falg = false;
  9364. break;
  9365. }
  9366. }
  9367. if ($falg)
  9368. $html .= '<td class="taR">-</td>';
  9369. }
  9370. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9371. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9372. }
  9373. $data ['collectHtml'] = $collectHtml;
  9374. // create Adjustment price html
  9375. $receiptCollectList = $receiptDetail->find ( array (
  9376. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9377. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9378. 'groupby' => 'itemCategory,Month(pastDate)',
  9379. 'asArray' => true
  9380. ) );
  9381. $adjustment = array ();
  9382. $collectArray = array (
  9383. '日常相关费用' => array (),
  9384. '差旅相关费用' => array (),
  9385. '培训班费用' => array (),
  9386. '其他' => array ()
  9387. );
  9388. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9389. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9390. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9391. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9392. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9393. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9394. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9395. array_push ( $collectArray ['其他'], $collectHtml );
  9396. $data ['collectArray'] = $collectArray;
  9397. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9398. array_push ( $adjustment, $collectHtml );
  9399. $data ['adjustment'] = $adjustment;
  9400. // total price html
  9401. $collectHtml = "";
  9402. $total = 0;
  9403. for($i = 1; $i <= 12; $i ++) {
  9404. $sumPrice = 0;
  9405. foreach ( $receiptCollectList as $key => $value ) {
  9406. if ($value ['month'] == $i) {
  9407. $sumPrice += $value ['price'];
  9408. }
  9409. }
  9410. if ($sumPrice == 0)
  9411. $collectHtml .= '<td class="taR">-</td>';
  9412. else
  9413. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9414. $total += $sumPrice;
  9415. }
  9416. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9417. // statistics html
  9418. $stList = $statistics->statisticsByYear ( $year, $staffId );
  9419. if (empty ( $stList ))
  9420. $stList = array (
  9421. 'rePrice' => 0,
  9422. 'agPrice' => 0
  9423. );
  9424. $data ['stList'] = array (
  9425. 'rePrice' => $stList ['rePrice'],
  9426. 'agPrice' => $stList ['agPrice'],
  9427. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9428. );
  9429. $data ['totalPrice'] = $collectHtml;
  9430. $data ['totalYear'] = $total;
  9431. $data ['stHtml'] = $stHtml;
  9432. $data ['year'] = $year;
  9433. $data ['stTitle'] = $stTitle;
  9434. $data ['memu'] = "receipt";
  9435. $data ['staff'] = $this->staff;
  9436. $data ['receiptMemu'] = 'companyCategoryCollect';
  9437. $data ['verifyId'] = $this->verifyId;
  9438. $data ['executeId'] = $this->executeId;
  9439. if ($year < date ( "Y" )) {
  9440. Doo::loadModel ( 'receipt' );
  9441. $receipt = new receipt ();
  9442. $receiptList = $receipt->find ( array (
  9443. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  9444. 'asArray' => true
  9445. ) );
  9446. if (empty ( $receiptList )) { // generated files
  9447. ob_start ();
  9448. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9449. $this->cacheFile ( $path );
  9450. die ();
  9451. }
  9452. }
  9453. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9454. }
  9455. function BUGFLAG() {
  9456. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  9457. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  9458. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9459. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9460. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  9461. if (empty ( $status ))
  9462. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  9463. $page_size = 12;
  9464. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  9465. $vidList = array ();
  9466. $button = 0;
  9467. Doo::loadModel ( 'verify' );
  9468. $verify = new verify ();
  9469. Doo::loadModel ( 'receipt' );
  9470. $receipt = new receipt ();
  9471. Doo::loadModel ( 'staff' );
  9472. $staff = new staff ();
  9473. Doo::loadModel ( 'L_category' );
  9474. $Lcategory = new L_category ();
  9475. $dateCondition = " and Year(date) =" . $year;
  9476. if (! empty ( $month ))
  9477. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  9478. $categoryList = $Lcategory->find ( array (
  9479. 'asArray' => true
  9480. ) );
  9481. $staffList = $staff->find ( array (
  9482. 'where' => 'cid=' . $cid,
  9483. 'asArray' => true
  9484. ) );
  9485. $cateCondition = "";
  9486. $staffCondition = "";
  9487. $approvalCondition = "";
  9488. if (! empty ( $cid ))
  9489. $cateCondition = ' and cid=' . $cid;
  9490. if (! empty ( $sid )) {
  9491. $staffCondition = ' and staff=' . $sid;
  9492. $cateCondition = "";
  9493. }
  9494. $approvalCondition = " and status=" . $status;
  9495. if ($status == 2) {
  9496. // 查找角色审批人
  9497. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9498. }
  9499. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  9500. $approvalCondition = ' and status=2 ';
  9501. }
  9502. if ($status == 1) {
  9503. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  9504. }
  9505. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  9506. $pageinfo ['page'] = array (
  9507. 'previous' => ''
  9508. );
  9509. if ($status == 0) {
  9510. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  9511. $receiptList = $receipt->find ( array (
  9512. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  9513. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  9514. 'desc' => 'rid',
  9515. 'asArray' => true
  9516. ) );
  9517. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9518. } else
  9519. $receiptList = $receipt->find ( array (
  9520. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  9521. 'desc' => 'rid',
  9522. 'asArray' => true
  9523. ) );
  9524. $rLRes = $receipt->find ( array (
  9525. '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,
  9526. 'desc' => 'rid',
  9527. 'asArray' => true
  9528. ) );
  9529. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9530. // print_r($pageinfo);
  9531. $Locate = 0;
  9532. foreach ( $receiptList as $key => $value ) {
  9533. $receiptList [$key] ['Locate'] = $Locate;
  9534. $Locate ++;
  9535. $receiptList [$key] ['reviseDetail'] = array ();
  9536. if (! empty ( $value ['reviseDetail'] ))
  9537. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  9538. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  9539. $categoryDetil = $Lcategory->getOne ( array (
  9540. 'where' => 'cid=' . $value ['cid'],
  9541. 'asArray' => true
  9542. ) );
  9543. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  9544. $verifyList = $verify->getOne ( array (
  9545. 'where' => 'vid=' . $value ['verify'],
  9546. 'asArray' => true
  9547. ) );
  9548. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  9549. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  9550. foreach ( $verifyList as $k => $v ) {
  9551. // init verifyStaff
  9552. $verifyList [$k] ['date'] = "";
  9553. $verifyList [$k] ['opinion'] = "";
  9554. $verifyList [$k] ['status'] = "";
  9555. if (empty ( $verifyStaff )) {
  9556. $verifyList [$k] ['date'] = "";
  9557. $verifyList [$k] ['opinion'] = "";
  9558. if ($v [0] == $this->staff [0] ['sid']) {
  9559. $verifyList [$k] ['status'] = 4;
  9560. $button = 4;
  9561. }
  9562. } else {
  9563. $flag = true;
  9564. foreach ( $verifyStaff as $m => $u ) {
  9565. if ($v [0] == $m) {
  9566. $verifyList [$k] ['date'] = $u ['date'];
  9567. $verifyList [$k] ['opinion'] = $u ['opinion'];
  9568. $verifyList [$k] ['status'] = $u ['status'];
  9569. $flag = false;
  9570. break;
  9571. }
  9572. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  9573. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  9574. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  9575. }
  9576. if ($flag) { // 检测可编辑
  9577. if ($v [0] == $this->staff [0] ['sid']) {
  9578. $verifyList [$k] ['status'] = 4;
  9579. $button = 4;
  9580. }
  9581. }
  9582. }
  9583. }
  9584. $receiptList [$key] ['verifyList'] = $verifyList;
  9585. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  9586. 'where' => 'sid=' . $value ['staff'],
  9587. 'asArray' => true
  9588. ) );
  9589. $receiptList [$key] ['button'] = $button;
  9590. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  9591. }
  9592. // print_r($receiptList);die;
  9593. // $data['verifyDetail']=$verifyDetail;
  9594. $mothHtml = "";
  9595. for($i = 1; $i <= 12; $i ++) {
  9596. if ($month == $i)
  9597. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  9598. else
  9599. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  9600. }
  9601. $data ['mothHtml'] = $mothHtml;
  9602. $data ['page'] = $pageinfo;
  9603. $data ['receiptList'] = $receiptList;
  9604. $data ['receiptApprovalCount'] = count ( $rLRes );
  9605. $data ['status'] = $status;
  9606. $data ['year'] = $year;
  9607. $data ['categoryList'] = $categoryList;
  9608. $data ['staffList'] = $staffList;
  9609. $data ['cid'] = $cid;
  9610. $data ['sid'] = $sid;
  9611. // print_r($receiptList);
  9612. $data ['memu'] = "receipt";
  9613. $data ['staff'] = $this->staff;
  9614. $data ['receiptMemu'] = 'approvalExpenses';
  9615. $data ['verifyId'] = $this->verifyId;
  9616. $data ['executeId'] = $this->executeId;
  9617. $this->render ( "/admin/FALG", $data );
  9618. }
  9619. function ajaxGetReceiptOrder() {
  9620. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  9621. if (! empty ( $receiptOrder )) {
  9622. Doo::loadModel ( 'receipt' );
  9623. $receipt = new receipt ();
  9624. Doo::loadModel ( 'staff' );
  9625. $staff = new staff ();
  9626. $receiptInfo = $receipt->getOne ( array (
  9627. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  9628. 'asArray' => true
  9629. ) );
  9630. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  9631. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  9632. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  9633. </tbody></table><table class="table table table-bordered"><tbody>';
  9634. foreach ( $verifyStaff as $key => $value ) {
  9635. $staffInfo = $staff->getOne ( array (
  9636. 'select' => 'username',
  9637. 'where' => ' sid="' . $key . '"',
  9638. 'asArray' => true
  9639. ) );
  9640. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  9641. }
  9642. $html .= '</tbody></table></div></div>';
  9643. echo json_encode ( array (
  9644. 'status' => 1,
  9645. 'receiptHtml' => $html
  9646. ) );
  9647. die ();
  9648. }
  9649. echo json_encode ( array (
  9650. 'status' => 2,
  9651. 'receiptHtml' => ''
  9652. ) );
  9653. die ();
  9654. }
  9655. function _getMonthCollectDetail($receiptCollectList) {
  9656. if (! empty ( $receiptCollectList )) {
  9657. $receiptL = array (
  9658. '日常相关费用' => array (),
  9659. '差旅相关费用' => array (),
  9660. '培训班费用' => array (),
  9661. '其他' => array ()
  9662. );
  9663. $html = "";
  9664. $psum = 0;
  9665. $item = array (
  9666. '市内交通费',
  9667. '市内出租费',
  9668. '办事处房租',
  9669. '电话费',
  9670. '水费',
  9671. '电费',
  9672. '办公费用',
  9673. '邮寄费',
  9674. '其他费用',
  9675. '车辆费用',
  9676. '广告费',
  9677. '团队建设费',
  9678. '物业管理费',
  9679. '宽带费'
  9680. );
  9681. foreach ( $item as $value ) {
  9682. $falg = true;
  9683. foreach ( $receiptCollectList as $v ) {
  9684. if ($v ['itemCategory'] == '日常相关费用') {
  9685. if ($v ['item'] == $value) {
  9686. $psum += $v ['price'];
  9687. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9688. $falg = false;
  9689. break;
  9690. }
  9691. }
  9692. }
  9693. if ($falg)
  9694. $html .= '<td class="taR">-</td>';
  9695. }
  9696. if (! empty ( $psum ))
  9697. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9698. else
  9699. $psum = '<td class="colGreen taR">-</td>';
  9700. $receiptL ['日常相关费用'] = $psum . $html;
  9701. /* ----------------------------------- */
  9702. $html = "";
  9703. $psum = 0;
  9704. $item = array (
  9705. '往来交通费',
  9706. '市内交通费',
  9707. '出差住宿费',
  9708. '出差补助',
  9709. '其他费用'
  9710. );
  9711. foreach ( $item as $value ) {
  9712. $falg = true;
  9713. foreach ( $receiptCollectList as $v ) {
  9714. if ($v ['itemCategory'] == '差旅相关费用') {
  9715. if ($v ['item'] == $value) {
  9716. $psum += $v ['price'];
  9717. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9718. $falg = false;
  9719. break;
  9720. }
  9721. }
  9722. }
  9723. if ($falg)
  9724. $html .= '<td class="taR">-</td>';
  9725. }
  9726. if (! empty ( $psum ))
  9727. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9728. else
  9729. $psum = '<td class="colGreen taR">-</td>';
  9730. $receiptL ['差旅相关费用'] = $psum . $html;
  9731. /* ------------------------------------- */
  9732. $html = "";
  9733. $psum = 0;
  9734. $item = array (
  9735. '场租费',
  9736. '薪酬',
  9737. '住宿费',
  9738. '交通费',
  9739. '餐饮费',
  9740. '办公费',
  9741. '公关费',
  9742. '其他'
  9743. );
  9744. foreach ( $item as $value ) {
  9745. $falg = true;
  9746. foreach ( $receiptCollectList as $v ) {
  9747. if ($v ['itemCategory'] == '培训班费用') {
  9748. if ($v ['item'] == $value) {
  9749. $psum += $v ['price'];
  9750. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9751. $falg = false;
  9752. break;
  9753. }
  9754. }
  9755. }
  9756. if ($falg)
  9757. $html .= '<td class="taR">-</td>';
  9758. }
  9759. if (! empty ( $psum ))
  9760. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9761. else
  9762. $psum = '<td class="colGreen taR">-</td>';
  9763. $receiptL ['培训班费用'] = $psum . $html;
  9764. /* ------------------------------------- */
  9765. $html = "";
  9766. $psum = 0;
  9767. $item = array (
  9768. '公关费',
  9769. '广告费',
  9770. '借款',
  9771. '可自加费用'
  9772. );
  9773. foreach ( $item as $value ) {
  9774. $falg = true;
  9775. foreach ( $receiptCollectList as $v ) {
  9776. if ($v ['itemCategory'] == '其他') {
  9777. if ($v ['item'] == $value) {
  9778. $psum += $v ['price'];
  9779. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9780. $falg = false;
  9781. break;
  9782. }
  9783. }
  9784. }
  9785. if ($falg)
  9786. $html .= '<td class="taR">-</td>';
  9787. }
  9788. if (! empty ( $psum ))
  9789. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9790. else
  9791. $psum = '<td class="colGreen taR">-</td>';
  9792. $receiptL ['其他'] = $psum . $html;
  9793. /* ------------------------------------- */
  9794. $html = "";
  9795. $psum = 0;
  9796. foreach ( $receiptCollectList as $v ) {
  9797. if ($v ['itemCategory'] == '报销金额调整') {
  9798. if (! empty ( $v ['price'] ))
  9799. $psum += $v ['price'];
  9800. }
  9801. }
  9802. if (! empty ( $psum ))
  9803. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9804. else
  9805. $psum = '<td class="taR colOrange">-</td>';
  9806. $receiptL ['报销金额调整'] = $psum . $html;
  9807. } else {
  9808. $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>
  9809. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9810. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9811. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9812. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9813. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9814. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9815. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9816. }
  9817. return $receiptL;
  9818. }
  9819. function eMail() {
  9820. Doo::loadModel ( 'staff' );
  9821. $staff = new staff ();
  9822. Doo::loadModel ( 'receipt' );
  9823. $receipt = new receipt ();
  9824. Doo::loadModel ( 'L_category' );
  9825. $Lcategory = new L_category ();
  9826. Doo::loadModel ( "verify" );
  9827. $verify = new verify ();
  9828. $staffList = $staff->find ( array (
  9829. 'asArray' => true
  9830. ) );
  9831. foreach ( $staffList as $key => $value ) {
  9832. if ($value ['username'] != 'admin') {
  9833. // 提交人
  9834. $receiptList = $receipt->find ( array (
  9835. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  9836. 'asArray' => true
  9837. ) );
  9838. if (! empty ( $receiptList )) {
  9839. $html = '<br><div><style></style>
  9840. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  9841. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  9842. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9843. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  9844. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9845. <tbody><tr>
  9846. <td style="padding: 0 40px;" align="left">
  9847. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9848. </td></tr><tr>
  9849. <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>
  9850. </tr>
  9851. </tbody> </table></td> </tr> <tr><td>
  9852. <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">
  9853. <tbody> <tr><td>
  9854. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  9855. 以下报销单完成了审批,等着收款吧:</p>
  9856. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  9857. foreach ( $receiptList as $k => $v ) {
  9858. $category = $Lcategory->getOne ( array (
  9859. 'where' => 'cid=' . $v ['cid'],
  9860. 'asArray' => true
  9861. ) );
  9862. $html .= '
  9863. <tr>
  9864. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  9865. <td align="left">
  9866. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  9867. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  9868. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  9869. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  9870. </tr>';
  9871. }
  9872. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  9873. <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>
  9874. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  9875. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  9876. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  9877. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9878. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9879. $receipt = new receipt ();
  9880. $receipt->notice = 1;
  9881. $receipt->update ( array (
  9882. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  9883. ) );
  9884. }
  9885. }
  9886. // 审批人
  9887. $verifyList = $verify->find ( array (
  9888. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  9889. 'asArray' => true
  9890. ) );
  9891. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  9892. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  9893. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9894. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  9895. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9896. <tbody><tr><td style="padding: 0 40px;" align="left">
  9897. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9898. </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>
  9899. </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">
  9900. <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>
  9901. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  9902. foreach ( $verifyList as $k => $v ) {
  9903. $receiptList = $receipt->find ( array (
  9904. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  9905. 'asArray' => true
  9906. ) );
  9907. foreach ( $receiptList as $r => $l ) {
  9908. $category = $Lcategory->getOne ( array (
  9909. 'where' => 'cid=' . $l ['cid'],
  9910. 'asArray' => true
  9911. ) );
  9912. $staffDetile = $staff->getOne ( array (
  9913. 'where' => 'sid=' . $l ['staff'],
  9914. 'asArray' => true
  9915. ) );
  9916. $html .= '
  9917. <tr>
  9918. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  9919. <td align="left">
  9920. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  9921. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  9922. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  9923. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  9924. </tr>';
  9925. }
  9926. }
  9927. $html .= '
  9928. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  9929. <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>
  9930. </tr></tbody></table></td></tr></tbody></table></div><br>';
  9931. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  9932. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  9933. // $receipt=new receipt();
  9934. // $receipt->notice=1;
  9935. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  9936. }
  9937. }
  9938. }
  9939. }
  9940. function setWXMsg($rid, $type) {
  9941. Doo::loadModel ( "receipt" );
  9942. $receipt = new receipt ();
  9943. $receiptDetail = $receipt->getOne ( array (
  9944. 'where' => 'rid=' . $rid,
  9945. 'asArray' => true
  9946. ) );
  9947. if (! empty ( $receiptDetail )) {
  9948. Doo::loadModel ( 'staff' );
  9949. $staff = new staff ();
  9950. $staffmsg = $staff->getStaffBySid ( $receiptDetail ['staff'] );
  9951. if (! empty ( $staffmsg ['wxid'] )) {
  9952. require_once (SITE_PATH . '/protected/class/client.php');
  9953. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  9954. $user = $staffmsg ['wxid'];
  9955. $receiptName = '';
  9956. $msg = '';
  9957. switch ($receiptDetail ['Rtype']) {
  9958. case 0 :
  9959. $receiptName = '报销';
  9960. break;
  9961. case 1 :
  9962. $receiptName = '借款';
  9963. break;
  9964. case 2 :
  9965. $receiptName = '对公汇款';
  9966. break;
  9967. }
  9968. switch ($type) {
  9969. case 1 :
  9970. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  9971. break;
  9972. case 2 :
  9973. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  9974. break;
  9975. case 3 :
  9976. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  9977. break;
  9978. }
  9979. $result = $client->SendMsg ( $user, $msg, 'text' );
  9980. }
  9981. }
  9982. }
  9983. // Email发送函数
  9984. function SMail($toemail, $subject, $contents) {
  9985. Doo::loadClass ( 'class.phpmailer' );
  9986. $mail = new PHPMailer ();
  9987. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  9988. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  9989. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  9990. $mail->Password = "cDO1GjtY1seH"; // 密码
  9991. $mail->CharSet = "UTF8";
  9992. $mail->SMTPAuth = true;
  9993. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  9994. $mail->Mailer = "smtp";
  9995. $mail->Port = 25;
  9996. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  9997. $mail->MsgHTML ( $contents );
  9998. $mail->AddAddress ( $toemail );
  9999. $mail->CharSet = "UTF-8";
  10000. return $mail->Send ();
  10001. }
  10002. function swfupload() {
  10003. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  10004. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  10005. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  10006. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  10007. header ( "HTTP/1.1 500 Internal Server Error" );
  10008. echo "POST exceeded maximum allowed size.";
  10009. exit ( 0 );
  10010. }
  10011. // Settings
  10012. $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)
  10013. $upload_name = "Filedata";
  10014. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  10015. $extension_whitelist = array (
  10016. "doc",
  10017. "txt",
  10018. "jpg",
  10019. "gif",
  10020. "png"
  10021. ); // Allowed file extensions
  10022. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  10023. // Other variables
  10024. $MAX_FILENAME_LENGTH = 260;
  10025. $file_name = "";
  10026. $file_extension = "";
  10027. $uploadErrors = array (
  10028. 0 => "文件上传成功",
  10029. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  10030. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  10031. 3 => "上传的文件仅为部分文件",
  10032. 4 => "没有文件上传",
  10033. 6 => "缺少临时文件夹"
  10034. );
  10035. $nk = time ();
  10036. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  10037. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  10038. echo "文件无法保存.";
  10039. exit ( 0 );
  10040. }
  10041. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  10042. echo json_encode ( array (
  10043. 'filename' => $file_name,
  10044. 'id' => $nk
  10045. ) );
  10046. exit ( 0 );
  10047. }
  10048. function _GetFileEXT($filename) {
  10049. $pics = explode ( '.', $filename );
  10050. $num = count ( $pics );
  10051. return $pics [$num - 1];
  10052. }
  10053. /**
  10054. * 获取get或者POST值
  10055. * @param string $name 属性名称
  10056. * @return fixed 值
  10057. */
  10058. function get_args($name) {
  10059. if (isset ( $_GET [$name] )) {
  10060. if (is_array ( $_GET [$name] ))
  10061. return $_GET [$name];
  10062. else
  10063. return addslashes ( $_GET [$name] );
  10064. } elseif (isset ( $_POST [$name] )) {
  10065. if (is_array ( $_POST [$name] ))
  10066. return $_POST [$name];
  10067. else
  10068. return addslashes ( $_POST [$name] );
  10069. } else
  10070. return false;
  10071. }
  10072. function num_to_rmb($num) {
  10073. $c1 = "零壹贰叁肆伍陆柒捌玖";
  10074. $c2 = "分角元拾佰仟万拾佰仟亿";
  10075. // 精确到分后面就不要了,所以只留两个小数位
  10076. $num = round ( $num, 2 );
  10077. // 将数字转化为整数
  10078. $num = $num * 100;
  10079. if (strlen ( $num ) > 10) {
  10080. return "金额太大,请检查";
  10081. }
  10082. $i = 0;
  10083. $c = "";
  10084. while ( 1 ) {
  10085. if ($i == 0) {
  10086. // 获取最后一位数字
  10087. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  10088. } else {
  10089. $n = $num % 10;
  10090. }
  10091. // 每次将最后一位数字转化为中文
  10092. $p1 = substr ( $c1, 3 * $n, 3 );
  10093. $p2 = substr ( $c2, 3 * $i, 3 );
  10094. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  10095. $c = $p1 . $p2 . $c;
  10096. } else {
  10097. $c = $p1 . $c;
  10098. }
  10099. $i = $i + 1;
  10100. // 去掉数字最后一位了
  10101. $num = $num / 10;
  10102. $num = ( int ) $num;
  10103. // 结束循环
  10104. if ($num == 0) {
  10105. break;
  10106. }
  10107. }
  10108. $j = 0;
  10109. $slen = strlen ( $c );
  10110. while ( $j < $slen ) {
  10111. // utf8一个汉字相当3个字符
  10112. $m = substr ( $c, $j, 6 );
  10113. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  10114. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  10115. $left = substr ( $c, 0, $j );
  10116. $right = substr ( $c, $j + 3 );
  10117. $c = $left . $right;
  10118. $j = $j - 3;
  10119. $slen = $slen - 3;
  10120. }
  10121. $j = $j + 3;
  10122. }
  10123. // 这个是为了去掉类似23.0中最后一个“零”字
  10124. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  10125. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  10126. }
  10127. // 将处理的汉字加上“整”
  10128. if (empty ( $c )) {
  10129. return "零元整";
  10130. } else {
  10131. return $c . "整";
  10132. }
  10133. }
  10134. /**
  10135. * 获得分页数据
  10136. * @param unknown_type $table
  10137. * @param unknown_type $condition
  10138. * @param unknown_type $on_page
  10139. * @param unknown_type $page_size
  10140. */
  10141. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  10142. $page_c = "";
  10143. $page ['previous'] = $this->get_previous ( $on_page );
  10144. $page ['on_page'] = $on_page;
  10145. $total_count = $this->get_table_count ( $table, $condition );
  10146. $total = intval ( $total_count / $page_size );
  10147. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  10148. $page ['total_data'] = $total_count;
  10149. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  10150. $i = 1;
  10151. $page_max = 1;
  10152. $page_width = 3;
  10153. if ($on_page >= $page_width) {
  10154. $page_max = intval ( $on_page / $page_width ) + 1;
  10155. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  10156. }
  10157. for(; $i <= $page ['total_page']; $i ++) {
  10158. if ($i == $on_page)
  10159. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  10160. else
  10161. $page_c .= '<li><a href="/' . $action . '/0/' . $i . $get . '">' . $i . '</a></li>';
  10162. if ($i == ($page_width * $page_max))
  10163. break;
  10164. }
  10165. $page ['page'] = $page_c;
  10166. $page ['lower'] = (-- $on_page) * $page_size;
  10167. return $page;
  10168. }
  10169. /**
  10170. * 获取总页数
  10171. * @param unknown_type $table
  10172. * @param unknown_type $condition
  10173. */
  10174. public function get_table_count($table = "", $condition = "") {
  10175. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10176. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10177. //echo $sql;die;
  10178. $query = Doo::db ()->query ( $sql );
  10179. $result = $query->fetch ();
  10180. return $result ['count'];
  10181. }
  10182. /**
  10183. * 获取上一页
  10184. * @param unknown_type $on_page
  10185. */
  10186. function get_previous($on_page = 1) {
  10187. return $on_page != 0 ? $on_page - 1 : $on_page;
  10188. }
  10189. }
  10190. ?>