ReceiptController.php 370 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class ReceiptController extends DooController {
  6. public $staff;
  7. public $verifyId;
  8. public $executeId;
  9. // public static $NEW2 = 0;
  10. public $AGENCY = "日常相关费用";
  11. public $TRAVEL = "差旅相关费用";
  12. public $TRAIN = "培训班费用";
  13. public $OTHER = "其他";
  14. private $MYREVEIPTCACHEPATH = "protected/cache/myReceipt/";
  15. private $PERSONALCOLLECTCACHEPATH = "protected/cache/personalCollect/";
  16. private $CATEGORYCOLLECTPATH = "protected/cache/categoryCollect/";
  17. private $STAFFCOLLECTPATH = "protected/cache/staffCollect/";
  18. private function showCache($path) {
  19. if (file_exists ( $path )) {
  20. echo "<!DOCTYPE html>";
  21. include $path;
  22. die ();
  23. }
  24. }
  25. private function cacheFile($path) {
  26. $content = ob_get_contents ();
  27. $fp = fopen ( $path, "w" );
  28. fwrite ( $fp, $content );
  29. fclose ( $fp );
  30. }
  31. private function collectHtml($receiptCollectList = array(), $itemCategory = "日常相关费用", $classType = "b") {
  32. $collectHtml = "";
  33. $sumPrice = 0.00;
  34. for($i = 1; $i <= 12; $i ++) {
  35. $falg = true;
  36. foreach ( $receiptCollectList as $key => $value ) {
  37. if ($value ['itemCategory'] == $itemCategory && $value ['month'] == $i) {
  38. $sumPrice += $value ['price'];
  39. if ($classType == "b") {
  40. $collectHtml .= '<td class="colGreen taR">¥' . $value ['price'] . '</td>';
  41. $falg = false;
  42. break;
  43. } else {
  44. $collectHtml .= '<td class="taR">¥' . $value ['price'] . '</td>';
  45. $falg = false;
  46. break;
  47. }
  48. }
  49. }
  50. if ($falg)
  51. $collectHtml .= '<td class="taR">-</td>';
  52. }
  53. $collectHtml .= '<td class="taR colGreen">¥' . $sumPrice . '</td>';
  54. return $collectHtml;
  55. }
  56. function __construct() {
  57. if (isset ( $_COOKIE ["staff"] )) {
  58. if (! empty ( $_COOKIE ["staff"] )) {
  59. Doo::loadModel ( 'staff' );
  60. Doo::loadModel ( 'verify' );
  61. $verify = new verify ();
  62. $staff = new staff ();
  63. Doo::loadModel ( "execute" );
  64. $execute = new execute ();
  65. $verifyList = $verify->find ( array (
  66. 'select' => 'staff',
  67. 'asArray' => true
  68. ) );
  69. $list = array ();
  70. // 判断角色的审批权限
  71. foreach ( $verifyList as $key => $value ) {
  72. $ver = json_decode ( $value ['staff'] );
  73. foreach ( $ver as $k => $v ) {
  74. if ($v [1] == 'ROLE') {
  75. $roleList = json_decode ( $v [3] );
  76. foreach ( $roleList as $t => $g ) {
  77. $gList = explode ( "_", $g );
  78. array_push ( $list, $gList [0] );
  79. // print_r($list);
  80. }
  81. } else
  82. array_push ( $list, $v [0] );
  83. }
  84. }
  85. // 判断执行人的审批权限
  86. $executeList = $execute->find ( array (
  87. 'select' => 'staff',
  88. 'asArray' => true
  89. ) );
  90. $list2 = array ();
  91. foreach ( $executeList as $key => $value ) {
  92. $ver = json_decode ( $value ['staff'] );
  93. foreach ( $ver as $k => $v ) {
  94. array_push ( $list2, $v [0] );
  95. }
  96. }
  97. $eidList = file_get_contents ( "protected/config/execute/execute.ini" );
  98. $eidList = array_filter ( explode ( ",", $eidList ) );
  99. $this->executeId = array_merge ( $list2, $eidList );
  100. $this->verifyId = $list;
  101. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  102. return "/";
  103. }
  104. }
  105. Doo::loadCore ( 'uri/DooUriRouter' );
  106. $router = new DooUriRouter ();
  107. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  108. if ($routeRs ['1'] != "login") {
  109. header ( 'Content-Type:text/html;charset=utf-8' );
  110. @header ( "Location: /login" );
  111. }
  112. }
  113. function saeaBorad() {
  114. Doo::loadModel ( 'receipt' );
  115. Doo::loadModel ( 'verify' );
  116. $verify = new verify ();
  117. $receipt = new receipt ();
  118. Doo::loadModel ( 'L_category' );
  119. $lCategory = new L_category ();
  120. Doo::loadModel ( "role" );
  121. $role = new role ();
  122. Doo::loadModel ( "receiptLog" );
  123. $receiptLog = new receiptLog ();
  124. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  125. $receiptDetail = $receipt->find ( array (
  126. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  127. 'desc' => 'rid',
  128. 'asArray' => true
  129. ) );
  130. foreach ( $receiptDetail as $key => $value ) {
  131. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  132. $veList = $verify->getOne ( array (
  133. 'where' => 'vid=' . $value ['verify'],
  134. 'asArray' => true
  135. ) );
  136. $v = json_decode ( $veList ['staff'] );
  137. array_push ( $v [0], $veList ['description'] );
  138. foreach ( $v as $n => $m ) {
  139. if ($m ['1'] == 'ROLE') {
  140. $roleInfo = $role->getOne ( array (
  141. 'where' => 'rid=' . $m [0],
  142. 'asArray' => true
  143. ) );
  144. $v [$n] [1] = $roleInfo ['name'];
  145. }
  146. }
  147. $receiptDetail [$key] ['staff'] = $v;
  148. $category = $lCategory->getOne ( array (
  149. 'where' => 'cid=' . $value ['cid'],
  150. 'asArray' => true
  151. ) );
  152. $receiptDetail [$key] ['category'] = $category ['title'];
  153. }
  154. // print_r($receiptLogList);
  155. $data ['receiptLogList'] = $receiptLogList;
  156. $data ['receiptDetail'] = $receiptDetail;
  157. $data ['memu'] = "receipt";
  158. $data ['staff'] = $this->staff;
  159. $data ['receiptMemu'] = 'saeaBorad';
  160. $data ['verifyId'] = $this->verifyId;
  161. $data ['executeId'] = $this->executeId;
  162. $this->render ( "/admin/saeaBorad", $data );
  163. }
  164. function remitAdd() {
  165. Doo::loadModel ( 'accountItem' );
  166. Doo::loadModel ( 'verify' );
  167. Doo::loadModel ( 'receipt' );
  168. Doo::loadModel ( 'L_category' );
  169. $lCategory = new L_category ();
  170. $receipt = new receipt ();
  171. $verify = new verify ();
  172. $accountItem = new accountItem ();
  173. Doo::loadModel ( "role" );
  174. $role = new role ();
  175. $acItem = $accountItem->find ( array (
  176. 'asArray' => true
  177. ) );
  178. $veList = $verify->find ( array (
  179. 'asArray' => true
  180. ) );
  181. foreach ( $veList as $key => $value ) {
  182. $v = json_decode ( $value ['staff'] );
  183. $list = array ();
  184. foreach ( $v as $n => $m ) {
  185. if ($m ['1'] == 'ROLE') {
  186. $roleInfo = $role->getOne ( array (
  187. 'where' => 'rid=' . $m [0],
  188. 'asArray' => true
  189. ) );
  190. $v [$n] [1] = $roleInfo ['name'];
  191. array_push ( $list, $roleInfo ['name'] );
  192. } else {
  193. array_push ( $list, $v [$n] [1] );
  194. }
  195. }
  196. $veList [$key] ['staff'] = implode ( '>', $list );
  197. }
  198. $data ['category'] = $lCategory->find ( array (
  199. 'asArray' => true
  200. ) );
  201. $data ['veList'] = $veList;
  202. $data ['acItem'] = $acItem;
  203. $data ['memu'] = "receipt";
  204. $data ['staff'] = $this->staff;
  205. $data ['receiptMemu'] = 'saeaBorad';
  206. $data ['verifyId'] = $this->verifyId;
  207. $data ['executeId'] = $this->executeId;
  208. $this->render ( "/admin/remitAdd", $data );
  209. }
  210. function remitAddDo() {
  211. $agency = $this->get_args ( 'agency' );
  212. $travel = $this->get_args ( 'travel' );
  213. $train = $this->get_args ( 'train' );
  214. $other = $this->get_args ( 'other' );
  215. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  216. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  217. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  218. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  219. // print_r($agency);die;
  220. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  221. Doo::loadModel ( 'receipt' );
  222. Doo::loadModel ( 'receiptDetail' );
  223. Doo::loadModel ( 'accountItem' );
  224. $accountItem = new accountItem ();
  225. $receipt = new receipt ();
  226. Doo::loadModel ( 'enclosur' );
  227. Doo::loadModel ( 'execute' );
  228. $execute = new execute ();
  229. $executeDetail = $execute->getOne ( array (
  230. 'where' => 'mold="对公汇款执行人"',
  231. 'asArray' => true
  232. ) );
  233. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  234. $aItem = $accountItem->find ( array (
  235. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  236. 'asArray' => true
  237. ) );
  238. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  239. $ag = $tr = $ta = $ot = 0;
  240. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  241. foreach ( $aItem as $key => $value ) {
  242. if ($value ['category'] == $this->AGENCY) {
  243. if (isset ( $agency [$ag] )) {
  244. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  245. array_push ( $accountJson [$this->AGENCY], array (
  246. 'aid' => $value ['aid'],
  247. 'name' => $value ['name'],
  248. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  249. ) );
  250. $sum += $agency [$ag];
  251. $agencySum += $agency [$ag];
  252. }
  253. }
  254. $ag ++;
  255. }
  256. }
  257. $accountJson ['cSum'] = array (
  258. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  259. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  260. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  261. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  262. );
  263. // 报销单
  264. $receipt->accountItem = json_encode ( $accountJson );
  265. $receipt->staff = $this->staff [0] ['sid'];
  266. $receipt->sum = number_format ( $sum, 2, '.', '' );
  267. $receipt->date = date ( "Y-m-d" );
  268. $receipt->cid = $cid;
  269. $receipt->status = 5;
  270. $receipt->Rtype = 2;
  271. // 修改审批流程加入角色
  272. $receipt->verify = $verify;
  273. $receipt->executeCopy = $executeDetail ['staff'];
  274. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  275. $receipt->explanation = $explanation;
  276. $rid = $receipt->insert ();
  277. // 附件
  278. if (! empty ( $enclosurName )) {
  279. $enclosurArray = explode ( '-', $enclosurName );
  280. foreach ( $enclosurArray as $value ) {
  281. $enclosur = new enclosur ();
  282. $enclosur->name = $value;
  283. $enclosur->rid = $rid;
  284. $enclosur->insert ();
  285. }
  286. // print_r($enclosurArray);die;
  287. }
  288. // 报销详情
  289. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  290. $receiptDetail = new receiptDetail ();
  291. $receiptDetail->staff = $this->staff [0] ['sid'];
  292. $receiptDetail->item = $value ['name'];
  293. $receiptDetail->itemCategory = $this->AGENCY;
  294. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  295. $receiptDetail->date = date ( "Y-m-d" );
  296. $receiptDetail->cid = $cid;
  297. $receiptDetail->rid = $rid;
  298. $receiptDetail->status = 4;
  299. $receiptDetail->insert ();
  300. }
  301. return "/saeaBorad";
  302. }else
  303. die ( 'illegal request' );
  304. }
  305. function remitEdit() {
  306. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  307. // echo $rid;
  308. Doo::loadModel ( 'accountItem' );
  309. Doo::loadModel ( 'verify' );
  310. Doo::loadModel ( 'receipt' );
  311. $receipt = new receipt ();
  312. $verify = new verify ();
  313. $accountItem = new accountItem ();
  314. Doo::loadModel ( 'L_category' );
  315. $lCategory = new L_category ();
  316. Doo::loadModel ( "role" );
  317. $role = new role ();
  318. $receiptDetail = $receipt->getOne ( array (
  319. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  320. 'asArray' => true
  321. ) );
  322. if (empty ( $receiptDetail ))
  323. return "/saeaCreate";
  324. $acItem = $accountItem->find ( array (
  325. 'asArray' => true
  326. ) );
  327. $veList = $verify->find ( array (
  328. 'asArray' => true
  329. ) );
  330. foreach ( $veList as $key => $value ) {
  331. $v = json_decode ( $value ['staff'] );
  332. $list = array ();
  333. foreach ( $v as $n => $m ) {
  334. if ($m ['1'] == 'ROLE') {
  335. $roleInfo = $role->getOne ( array (
  336. 'where' => 'rid=' . $m [0],
  337. 'asArray' => true
  338. ) );
  339. $v [$n] [1] = $roleInfo ['name'];
  340. array_push ( $list, $roleInfo ['name'] );
  341. } else {
  342. array_push ( $list, $v [$n] [1] );
  343. }
  344. }
  345. $veList [$key] ['staff'] = implode ( '>', $list );
  346. }
  347. // 配置编辑信息
  348. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  349. foreach ( $acItem as $key => $value ) {
  350. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  351. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  352. $acItem [$key] ['price'] = $v ['price'];
  353. }
  354. }
  355. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  356. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  357. $acItem [$key] ['price'] = $v ['price'];
  358. }
  359. }
  360. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  361. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  362. $acItem [$key] ['price'] = $v ['price'];
  363. }
  364. }
  365. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  366. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  367. $acItem [$key] ['price'] = $v ['price'];
  368. }
  369. }
  370. }
  371. $data ['category'] = $lCategory->find ( array (
  372. 'asArray' => true
  373. ) );
  374. $data ['cSum'] = $accountItemList ['cSum'];
  375. $data ['sum'] = $receiptDetail ['sum'];
  376. $data ['receiptDetail'] = $receiptDetail;
  377. $data ['veList'] = $veList;
  378. $data ['acItem'] = $acItem;
  379. $data ['memu'] = "receipt";
  380. $data ['staff'] = $this->staff;
  381. $data ['receiptMemu'] = 'saeaBorad';
  382. $data ['verify'] = $receiptDetail ['verify'];
  383. $data ['verifyId'] = $this->verifyId;
  384. $data ['executeId'] = $this->executeId;
  385. $data ['rid'] = $rid;
  386. $this->render ( "/admin/remitEdit", $data );
  387. }
  388. function remitEdiDo() {
  389. $agency = $this->get_args ( 'agency' );
  390. $travel = $this->get_args ( 'travel' );
  391. $train = $this->get_args ( 'train' );
  392. $other = $this->get_args ( 'other' );
  393. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  394. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  395. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  396. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  397. if (! empty ( $explanation )) {
  398. Doo::loadModel ( 'receipt' );
  399. Doo::loadModel ( 'receiptDetail' );
  400. Doo::loadModel ( 'accountItem' );
  401. $accountItem = new accountItem ();
  402. $receipt = new receipt ();
  403. Doo::loadModel ( 'execute' );
  404. $execute = new execute ();
  405. $executeDetail = $execute->getOne ( array (
  406. 'where' => 'mold="对公汇款执行人"',
  407. 'asArray' => true
  408. ) );
  409. $receiptDetail = $receipt->getOne ( array (
  410. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  411. 'asArray' => true
  412. ) );
  413. if (empty ( $receiptDetail ))
  414. return "/saeaBorad";
  415. $aItem = $accountItem->find ( array (
  416. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  417. 'asArray' => true
  418. ) );
  419. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  420. $ag = $tr = $ta = $ot = 0;
  421. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  422. foreach ( $aItem as $key => $value ) {
  423. if ($value ['category'] == $this->AGENCY) {
  424. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  425. array_push ( $accountJson [$this->AGENCY], array (
  426. 'aid' => $value ['aid'],
  427. 'name' => $value ['name'],
  428. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  429. ) );
  430. $sum += $agency [$ag];
  431. $agencySum += $agency [$ag];
  432. }
  433. $ag ++;
  434. }
  435. }
  436. $accountJson ['cSum'] = array (
  437. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  438. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  439. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  440. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  441. );
  442. // 报销单
  443. $rid = $receipt->rid = $receiptDetail ['rid'];
  444. $receipt->accountItem = json_encode ( $accountJson );
  445. $receipt->staff = $this->staff [0] ['sid'];
  446. $receipt->sum = number_format ( $sum, 2, '.', '' );
  447. $receipt->date = date ( "Y-m-d" );
  448. $receipt->cid = $cid;
  449. if ($receiptDetail ['Rtype'] == 1)
  450. $receipt->status = 7;
  451. else
  452. $receipt->status = 5;
  453. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  454. $receipt->verify = $verify;
  455. $receipt->executeCopy = $executeDetail ['staff'];
  456. $receipt->explanation = $explanation;
  457. $receipt->update ();
  458. $receiptDetail = new receiptDetail ();
  459. $receiptDetail->delete ( array (
  460. 'where' => 'rid=' . $rid
  461. ) );
  462. // 报销详情
  463. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  464. $receiptDetail = new receiptDetail ();
  465. $receiptDetail->staff = $this->staff [0] ['sid'];
  466. $receiptDetail->item = $value ['name'];
  467. $receiptDetail->itemCategory = $this->AGENCY;
  468. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  469. $receiptDetail->date = date ( "Y-m-d" );
  470. $receiptDetail->cid = $cid;
  471. $receiptDetail->rid = $rid;
  472. $receiptDetail->status = 4;
  473. $receiptDetail->insert ();
  474. }
  475. // return "/referReceipt/".$rid;
  476. }
  477. return "/saeaBorad";
  478. }
  479. function remitApproval() {
  480. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  481. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  482. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  483. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  484. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  485. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  486. if (empty ( $status ))
  487. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  488. $vidList = array ();
  489. $button = 0;
  490. Doo::loadModel ( 'verify' );
  491. Doo::loadModel ( 'receipt' );
  492. Doo::loadModel ( 'staff' );
  493. $staff = new staff ();
  494. $receipt = new receipt ();
  495. $verify = new verify ();
  496. Doo::loadModel ( 'L_category' );
  497. $Lcategory = new L_category ();
  498. Doo::loadModel ( 'enclosur' );
  499. $enclosur = new enclosur ();
  500. // user verify ID
  501. $verifyDetail = $verify->find ( array (
  502. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  503. 'asArray' => true
  504. ) );
  505. foreach ( $verifyDetail as $key => $value ) {
  506. array_push ( $vidList, $value ['vid'] );
  507. }
  508. $vid = implode ( ",", $vidList );
  509. if (empty ( $verifyDetail ))
  510. $vid = 0;
  511. $categoryList = $Lcategory->find ( array (
  512. 'asArray' => true
  513. ) );
  514. $staffList = $staff->find ( array (
  515. 'where' => 'cid=' . $cid,
  516. 'asArray' => true
  517. ) );
  518. $ap = "";
  519. if ($status == 4) {
  520. $ap = 4;
  521. $status = 2;
  522. }
  523. // get Receipt By verifyID status 2
  524. $receiptList = $receipt->find ( array (
  525. 'where' => 'rid =' . $rid.' and status=2',
  526. 'desc' => 'rid',
  527. 'asArray' => true
  528. ) );
  529. if(empty($receiptList)){
  530. die('illegal request');
  531. }
  532. $Locate = 0;
  533. $roleId = 0;
  534. if ($ap == 4)
  535. $status = 4;
  536. foreach ( $receiptList as $key => $value ) {
  537. $receiptList [$key] ['Locate'] = $Locate;
  538. $Locate ++;
  539. $receiptList [$key] ['reviseDetail'] = array ();
  540. if (! empty ( $value ['reviseDetail'] ))
  541. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  542. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  543. $categoryDetil = $Lcategory->getOne ( array (
  544. 'where' => 'cid=' . $value ['cid'],
  545. 'asArray' => true
  546. ) );
  547. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  548. // 检测编辑状态
  549. $verifyList = $verify->getOne ( array (
  550. 'where' => 'vid=' . $value ['verify'],
  551. 'asArray' => true
  552. ) );
  553. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  554. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  555. Doo::loadModel ( 'role' );
  556. $role = new role ();
  557. // print_r($verifyList);
  558. $flag = true;
  559. $roleKey = 0;
  560. $endStaffArray = array ();
  561. $roleArrayCopy = array ();
  562. foreach ( $verifyList as $k => $v ) {
  563. // init verifyStaff
  564. if ($v [1] == 'ROLE') {
  565. if (! empty ( $verifyStaff )) {
  566. $endStaffArray = end ( $verifyStaff );
  567. if ($v [0] == $endStaffArray ['nextStaff']) {
  568. $roleId = $v [0];
  569. }
  570. }
  571. $roleVerify = json_decode ( $v [3], true );
  572. $roleKey = $k;
  573. $roleArray = array ();
  574. $rolename = $role->getOne ( array (
  575. 'where' => 'rid=' . $v [0],
  576. 'asArray' => true
  577. ) );
  578. foreach ( $roleVerify as $o => $p ) {
  579. $staffID = explode ( '_', $p );
  580. $staffInfo = $staff->getOne ( array (
  581. 'where' => 'sid=' . $staffID [0],
  582. 'asArray' => true
  583. ) );
  584. // print_r($staffID);
  585. $exp = array (
  586. 0 => $staffInfo ['sid'],
  587. 1 => $staffID [1],
  588. 2 => $staffInfo ['avatar'],
  589. 'date' => '',
  590. 'date' => '',
  591. 'opinion' => '',
  592. 'status' => '',
  593. 'rolename' => $rolename ['name']
  594. );
  595. array_push ( $roleArray, $exp );
  596. }
  597. $roleArrayCopy [$v [0]] = $roleArray;
  598. // $verifyList[$k]['roleArray']=$roleArray;
  599. }
  600. // print_r($roleArray);
  601. $verifyList [$k] ['date'] = "";
  602. $verifyList [$k] ['opinion'] = "";
  603. $verifyList [$k] ['status'] = "";
  604. if (empty ( $verifyStaff )) {
  605. $verifyList [$k] ['date'] = "";
  606. $verifyList [$k] ['opinion'] = "";
  607. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  608. $verifyList [$k] ['status'] = 4;
  609. $button = 4;
  610. $flag = false;
  611. }
  612. } else {
  613. foreach ( $verifyStaff as $m => $u ) {
  614. if ($v [0] == $m) {
  615. $verifyList [$k] ['date'] = $u ['date'];
  616. $verifyList [$k] ['opinion'] = $u ['opinion'];
  617. $verifyList [$k] ['status'] = $u ['status'];
  618. $flag = false;
  619. break;
  620. }
  621. }
  622. $endStaffArray = end ( $verifyStaff );
  623. if (isset ( $endStaffArray ['ROLE'] )) {
  624. } else {
  625. $endKey = key ( $verifyStaff );
  626. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  627. $button = 4;
  628. $verifyList [$k] ['status'] = 4;
  629. }
  630. }
  631. }
  632. }
  633. $rolename ['name'] = '';
  634. if (! empty ( $roleId )) {
  635. Doo::loadModel ( 'role' );
  636. $role = new role ();
  637. $rolename = $role->getOne ( array (
  638. 'where' => 'rid=' . $roleId,
  639. 'asArray' => true
  640. ) );
  641. }
  642. if (! empty ( $verifyStaff ))
  643. $endStaffArray = end ( $verifyStaff );
  644. $KOP = false;
  645. foreach ( $roleArrayCopy as $P => $A ) {
  646. foreach ( $A as $MKI => $AVL ) {
  647. if (! empty ( $verifyStaff )) {
  648. // &&$rolename['rid']==$endStaffArray['nextStaff']
  649. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  650. $button = 4;
  651. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  652. }
  653. foreach ( $verifyStaff as $m => $u ) {
  654. $AVLFK = $AVL [0] . '_R';
  655. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  656. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  657. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  658. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  659. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  660. break;
  661. }
  662. }
  663. } else {
  664. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  665. $button = 4;
  666. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  667. }
  668. }
  669. // $roleArray[$MKI]['rolename']=$rolename['name'];
  670. $KOP = true;
  671. }
  672. }
  673. foreach ( $roleArrayCopy as $k => $v ) {
  674. foreach ( $verifyList as $m => $n ) {
  675. if ($n [0] == $k) {
  676. array_splice ( $verifyList, $m, 1, $v );
  677. }
  678. }
  679. }
  680. $receiptList [$key] ['verifyList'] = $verifyList;
  681. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  682. 'where' => 'sid=' . $value ['staff'],
  683. 'asArray' => true
  684. ) );
  685. $receiptList [$key] ['button'] = $button;
  686. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  687. }
  688. $mothHtml = "";
  689. for($i = 1; $i <= 12; $i ++) {
  690. if ($month == $i)
  691. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  692. else
  693. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  694. }
  695. // 获取审批日志
  696. Doo::loadModel ( 'receiptLog' );
  697. $receiptLog = new receiptLog ();
  698. $rlList = array ();
  699. $rlInfo = $receiptLog->getOne ( array (
  700. 'where' => 'rid=' . $rid . ' and status=4',
  701. 'asArray' => true
  702. ) );
  703. $tijdate = $receiptLog->getOne ( array (
  704. 'where' => 'rid=' . $rid . ' and status=2',
  705. 'asc' => 'rlid',
  706. 'asArray' => true
  707. ) );
  708. if (! empty ( $rlInfo )) {
  709. $rlList = $receiptLog->find ( array (
  710. 'where' => 'rid=' . $rid,
  711. 'asc' => 'rlid',
  712. 'asArray' => true
  713. ) );
  714. }
  715. $receiptList [0] ['rlList'] = $rlList;
  716. $enclosurList = $enclosur->find ( array (
  717. 'where' => 'rid=' . $rid,
  718. 'asArray' => true
  719. ) );
  720. $enclosurHtml = '';
  721. foreach ( $enclosurList as $value ) {
  722. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  723. }
  724. // print_r($receiptList);
  725. $data ['enclosurHtml'] = $enclosurHtml;
  726. $data ['rolename'] = $rolename ['name'];
  727. $data ['datetij'] = $tijdate ['date'];
  728. $data ['mothHtml'] = $mothHtml;
  729. $data ['rid'] = $rid;
  730. $data ['receiptList'] = $receiptList;
  731. $data ['receiptApprovalCount'] = count ( $receiptList );
  732. $data ['status'] = $status;
  733. $data ['year'] = $year;
  734. $data ['categoryList'] = $categoryList;
  735. $data ['staffList'] = $staffList;
  736. $data ['cid'] = $cid;
  737. $data ['sid'] = $sid;
  738. $data ['ap'] = $ap;
  739. $data ['memu'] = "receipt";
  740. $data ['staff'] = $this->staff;
  741. $data ['receiptMemu'] = 'approvalExpenses';
  742. $data ['verifyId'] = $this->verifyId;
  743. $data ['executeId'] = $this->executeId;
  744. $this->render ( "/admin/remitApproval", $data );
  745. }
  746. function saeaLoanAdd() {
  747. Doo::loadModel ( 'verify' );
  748. $verify = new verify ();
  749. Doo::loadModel ( "role" );
  750. $role = new role ();
  751. Doo::loadModel ( 'L_category' );
  752. $lCategory = new L_category ();
  753. $veList = $verify->find ( array (
  754. 'asArray' => true
  755. ) );
  756. foreach ( $veList as $key => $value ) {
  757. $v = json_decode ( $value ['staff'] );
  758. $list = array ();
  759. foreach ( $v as $n => $m ) {
  760. if ($m ['1'] == 'ROLE') {
  761. $roleInfo = $role->getOne ( array (
  762. 'where' => 'rid=' . $m [0],
  763. 'asArray' => true
  764. ) );
  765. $v [$n] [1] = $roleInfo ['name'];
  766. array_push ( $list, $roleInfo ['name'] );
  767. } else {
  768. array_push ( $list, $v [$n] [1] );
  769. }
  770. }
  771. $veList [$key] ['staff'] = implode ( '>', $list );
  772. }
  773. $data ['category'] = $lCategory->find ( array (
  774. 'asArray' => true
  775. ) );
  776. $data ['veList'] = $veList;
  777. $data ['memu'] = "receipt";
  778. $data ['staff'] = $this->staff;
  779. $data ['receiptMemu'] = 'saeaBorad';
  780. $data ['verifyId'] = $this->verifyId;
  781. $data ['executeId'] = $this->executeId;
  782. $this->render ( "/admin/saeaLoanAdd", $data );
  783. }
  784. function saeaLoanAddDo() {
  785. $agency = $this->get_args ( 'agency' );
  786. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  787. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  788. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  789. // die;
  790. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  791. Doo::loadModel ( 'receipt' );
  792. Doo::loadModel ( 'receiptDetail' );
  793. Doo::loadModel ( 'accountItem' );
  794. $accountItem = new accountItem ();
  795. $receipt = new receipt ();
  796. Doo::loadModel ( 'loanReceipt' );
  797. $loanReceipt = new loanReceipt ();
  798. Doo::loadModel ( 'execute' );
  799. $execute = new execute ();
  800. Doo::loadModel ( 'enclosur' );
  801. $executeDetail = $execute->getOne ( array (
  802. 'where' => 'mold="借款执行人"',
  803. 'asArray' => true
  804. ) );
  805. $aItem = $accountItem->find ( array (
  806. 'asArray' => true
  807. ) );
  808. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  809. $ag = $tr = $ta = $ot = 0;
  810. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  811. array_push ( $accountJson ['借款费用'], array (
  812. 'aid' => 0,
  813. 'name' => '申请金额',
  814. 'price' => number_format ( $agency, 2, '.', '' )
  815. ) );
  816. $sum += $agency;
  817. $agencySum += $agency;
  818. $accountJson ['cSum'] = array (
  819. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  820. 'agencySum' => number_format ( 0, 2, '.', '' ),
  821. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  822. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  823. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  824. );
  825. // 借款数据备份
  826. $loanReceipt->loanItem = json_encode ( $accountJson );
  827. $loanReceipt->staff = $this->staff [0] ['sid'];
  828. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  829. $loanReceipt->date = date ( "Y-m-d" );
  830. $loanReceipt->cid = $cid;
  831. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  832. $loanReceipt->status = 5;
  833. $loanReceipt->Rtype = 1;
  834. $loanReceipt->verify = $verify;
  835. $receipt->receiptOrder = $receipt->receiptOrder;
  836. $loanReceipt->explanation = $explanation;
  837. $loanRid = $loanReceipt->insert ();
  838. // 报销单
  839. $receipt->loanItem = json_encode ( $accountJson );
  840. $receipt->staff = $this->staff [0] ['sid'];
  841. $receipt->sum = number_format ( $sum, 2, '.', '' );
  842. $receipt->date = date ( "Y-m-d" );
  843. $receipt->cid = $cid;
  844. // 特殊状态
  845. $receipt->status = 5;
  846. $receipt->Rtype = 1;
  847. $receipt->loanRid = $loanRid;
  848. // 修改审批流程加入角色
  849. $receipt->verify = $verify;
  850. $receipt->executeCopy = $executeDetail ['staff'];
  851. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  852. $receipt->explanation = $explanation;
  853. $rid = $receipt->insert ();
  854. return "/saeaBorad";
  855. }else
  856. die ( 'illegal request' );
  857. }
  858. function saeaLoanEdi() {
  859. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  860. Doo::loadModel ( 'verify' );
  861. $verify = new verify ();
  862. Doo::loadModel ( "role" );
  863. $role = new role ();
  864. Doo::loadModel ( 'L_category' );
  865. $lCategory = new L_category ();
  866. Doo::loadModel ( 'receipt' );
  867. $receipt = new receipt ();
  868. $receiptInfo = $receipt->getOne ( array (
  869. 'where' => 'rid=' . $rid,
  870. 'asArray' => true
  871. ) );
  872. $veList = $verify->find ( array (
  873. 'asArray' => true
  874. ) );
  875. foreach ( $veList as $key => $value ) {
  876. $v = json_decode ( $value ['staff'] );
  877. $list = array ();
  878. foreach ( $v as $n => $m ) {
  879. if ($m ['1'] == 'ROLE') {
  880. $roleInfo = $role->getOne ( array (
  881. 'where' => 'rid=' . $m [0],
  882. 'asArray' => true
  883. ) );
  884. $v [$n] [1] = $roleInfo ['name'];
  885. array_push ( $list, $roleInfo ['name'] );
  886. } else {
  887. array_push ( $list, $v [$n] [1] );
  888. }
  889. }
  890. $veList [$key] ['staff'] = implode ( '>', $list );
  891. }
  892. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  893. $data ['receiptInfo'] = $receiptInfo;
  894. $data ['category'] = $lCategory->find ( array (
  895. 'asArray' => true
  896. ) );
  897. $data ['veList'] = $veList;
  898. $data ['memu'] = "receipt";
  899. $data ['staff'] = $this->staff;
  900. $data ['receiptMemu'] = 'saeaBorad';
  901. $data ['verifyId'] = $this->verifyId;
  902. $data ['executeId'] = $this->executeId;
  903. $this->render ( "/admin/saeaLoanEdi", $data );
  904. }
  905. function saeaLoanEdiDo() {
  906. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  907. $agency = $this->get_args ( 'agency' );
  908. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  909. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  910. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  911. // die;
  912. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )) {
  913. Doo::loadModel ( 'receipt' );
  914. Doo::loadModel ( 'receiptDetail' );
  915. Doo::loadModel ( 'accountItem' );
  916. $accountItem = new accountItem ();
  917. $receipt = new receipt ();
  918. Doo::loadModel ( 'loanReceipt' );
  919. $loanReceipt = new loanReceipt ();
  920. Doo::loadModel ( 'enclosur' );
  921. Doo::loadModel ( 'execute' );
  922. $execute = new execute ();
  923. $executeDetail = $execute->getOne ( array (
  924. 'where' => 'mold="借款执行人"',
  925. 'asArray' => true
  926. ) );
  927. $receiptDetail = $receipt->getOne ( array (
  928. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  929. 'asArray' => true
  930. ) );
  931. if (empty ( $receiptDetail ))
  932. die ( '参数错误' );
  933. $aItem = $accountItem->find ( array (
  934. 'asArray' => true
  935. ) );
  936. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  937. $ag = $tr = $ta = $ot = 0;
  938. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  939. array_push ( $accountJson ['借款费用'], array (
  940. 'aid' => 0,
  941. 'name' => '申请金额',
  942. 'price' => number_format ( $agency, 2, '.', '' )
  943. ) );
  944. $sum += $agency;
  945. $agencySum += $agency;
  946. $accountJson ['cSum'] = array (
  947. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  948. 'agencySum' => number_format ( 0, 2, '.', '' ),
  949. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  950. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  951. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  952. );
  953. // 报销单
  954. $receipt->loanItem = json_encode ( $accountJson );
  955. $receipt->sum = number_format ( $sum, 2, '.', '' );
  956. $receipt->cid = $cid;
  957. // 特殊状态
  958. // 修改审批流程加入角色
  959. if ($receiptDetail ['status'] != 4)
  960. $receipt->verify = $verify;
  961. $receipt->explanation = $explanation;
  962. $receipt->update ( array (
  963. 'where' => 'rid=' . $rid
  964. ) );
  965. // 借款数据更新
  966. $loanReceipt->loanItem = json_encode ( $accountJson );
  967. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  968. $loanReceipt->cid = $cid;
  969. if ($receiptDetail ['status'] != 4)
  970. $loanReceipt->verify = $verify;
  971. $loanReceipt->explanation = $explanation;
  972. $receipt->executeCopy = $executeDetail ['staff'];
  973. $loanReceipt->update ( array (
  974. 'where' => 'rid=' . $receiptDetail ['loanRid']
  975. ) );
  976. }
  977. return "/saeaBorad";
  978. }
  979. function saeaLoanReceiptAdd() {
  980. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  981. Doo::loadModel ( 'receipt' );
  982. $receipt = new receipt ();
  983. Doo::loadModel ( 'loanReceipt' );
  984. $loanReceipt = new loanReceipt ();
  985. Doo::loadModel ( 'L_category' );
  986. $Lcategory = new L_category ();
  987. Doo::loadModel ( 'verify' );
  988. Doo::loadModel ( 'statistics' );
  989. $statistics = new statistics ();
  990. $verify = new verify ();
  991. Doo::loadModel ( 'staff' );
  992. $staff = new staff ();
  993. $receiptDe = $receipt->getOne ( array (
  994. 'where' => 'rid=' . $rid,
  995. 'desc' => 'rid',
  996. 'asArray' => true
  997. ) );
  998. $receiptList = $loanReceipt->find ( array (
  999. 'where' => 'rid=' . $receiptDe ['loanRid'],
  1000. 'desc' => 'rid',
  1001. 'asArray' => true
  1002. ) );
  1003. $Locate = 0;
  1004. $roleId = 0;
  1005. $button = 0;
  1006. foreach ( $receiptList as $key => $value ) {
  1007. $receiptList [$key] ['Locate'] = $Locate;
  1008. $Locate ++;
  1009. $receiptList [$key] ['reviseDetail'] = array ();
  1010. if (! empty ( $value ['reviseDetail'] ))
  1011. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1012. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1013. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1014. $categoryDetil = $Lcategory->getOne ( array (
  1015. 'where' => 'cid=' . $value ['cid'],
  1016. 'asArray' => true
  1017. ) );
  1018. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1019. // 检测编辑状态
  1020. $verifyList = $verify->getOne ( array (
  1021. 'where' => 'vid=' . $value ['verify'],
  1022. 'asArray' => true
  1023. ) );
  1024. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1025. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1026. Doo::loadModel ( 'role' );
  1027. $role = new role ();
  1028. $flag = true;
  1029. $roleKey = 0;
  1030. $endStaffArray = array ();
  1031. $roleArrayCopy = array ();
  1032. foreach ( $verifyList as $k => $v ) {
  1033. // init verifyStaff
  1034. if ($v [1] == 'ROLE') {
  1035. if (! empty ( $verifyStaff )) {
  1036. $endStaffArray = end ( $verifyStaff );
  1037. // if ($v[0]==$endStaffArray['nextStaff']){
  1038. // $roleId=$v[0];
  1039. // }
  1040. }
  1041. $roleVerify = json_decode ( $v [3], true );
  1042. $roleKey = $k;
  1043. $roleArray = array ();
  1044. $rolename = $role->getOne ( array (
  1045. 'where' => 'rid=' . $v [0],
  1046. 'asArray' => true
  1047. ) );
  1048. foreach ( $roleVerify as $o => $p ) {
  1049. $staffID = explode ( '_', $p );
  1050. $staffInfo = $staff->getOne ( array (
  1051. 'where' => 'sid=' . $staffID [0],
  1052. 'asArray' => true
  1053. ) );
  1054. // print_r($staffID);
  1055. $exp = array (
  1056. 0 => $staffInfo ['sid'],
  1057. 1 => $staffID [1],
  1058. 2 => $staffInfo ['avatar'],
  1059. 'date' => '',
  1060. 'date' => '',
  1061. 'opinion' => '',
  1062. 'status' => '',
  1063. 'rolename' => $rolename ['name']
  1064. );
  1065. array_push ( $roleArray, $exp );
  1066. }
  1067. $roleArrayCopy [$v [0]] = $roleArray;
  1068. // $verifyList[$k]['roleArray']=$roleArray;
  1069. }
  1070. $verifyList [$k] ['date'] = "";
  1071. $verifyList [$k] ['opinion'] = "";
  1072. $verifyList [$k] ['status'] = "";
  1073. if (empty ( $verifyStaff )) {
  1074. $verifyList [$k] ['date'] = "";
  1075. $verifyList [$k] ['opinion'] = "";
  1076. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1077. $verifyList [$k] ['status'] = 4;
  1078. $flag = false;
  1079. }
  1080. } else {
  1081. foreach ( $verifyStaff as $m => $u ) {
  1082. if ($v [0] == $m) {
  1083. $verifyList [$k] ['date'] = $u ['date'];
  1084. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1085. $verifyList [$k] ['status'] = $u ['status'];
  1086. $flag = false;
  1087. break;
  1088. }
  1089. }
  1090. $endStaffArray = end ( $verifyStaff );
  1091. if (isset ( $endStaffArray ['ROLE'] )) {
  1092. } else {
  1093. // $endKey=key($verifyStaff);
  1094. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1095. // $button=4;
  1096. // $verifyList[$k]['status']=4;
  1097. // }
  1098. }
  1099. }
  1100. }
  1101. $rolename ['name'] = '';
  1102. if (! empty ( $roleId )) {
  1103. Doo::loadModel ( 'role' );
  1104. $role = new role ();
  1105. $rolename = $role->getOne ( array (
  1106. 'where' => 'rid=' . $roleId,
  1107. 'asArray' => true
  1108. ) );
  1109. }
  1110. if (! empty ( $verifyStaff ))
  1111. $endStaffArray = end ( $verifyStaff );
  1112. $KOP = false;
  1113. foreach ( $roleArrayCopy as $P => $A ) {
  1114. foreach ( $A as $MKI => $AVL ) {
  1115. if (! empty ( $verifyStaff )) {
  1116. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1117. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1118. $button = 4;
  1119. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1120. }
  1121. foreach ( $verifyStaff as $m => $u ) {
  1122. $AVLFK = $AVL [0] . '_R';
  1123. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1124. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1125. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1126. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1127. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1128. break;
  1129. }
  1130. }
  1131. } else {
  1132. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1133. $button = 4;
  1134. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1135. }
  1136. }
  1137. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1138. $KOP = true;
  1139. }
  1140. }
  1141. foreach ( $roleArrayCopy as $k => $v ) {
  1142. foreach ( $verifyList as $m => $n ) {
  1143. if ($n [0] == $k) {
  1144. array_splice ( $verifyList, $m, 1, $v );
  1145. }
  1146. }
  1147. }
  1148. $receiptList [$key] ['verifyList'] = $verifyList;
  1149. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1150. 'where' => 'sid=' . $value ['staff'],
  1151. 'asArray' => true
  1152. ) );
  1153. $receiptList [$key] ['button'] = $button;
  1154. //
  1155. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1156. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1157. }
  1158. $data ['receiptList'] = $receiptList;
  1159. Doo::loadModel ( 'L_category' );
  1160. $lCategory = new L_category ();
  1161. Doo::loadModel ( 'accountItem' );
  1162. $accountItem = new accountItem ();
  1163. $acItem = $accountItem->find ( array (
  1164. 'asArray' => true
  1165. ) );
  1166. $veList = $verify->find ( array (
  1167. 'asArray' => true
  1168. ) );
  1169. foreach ( $veList as $key => $value ) {
  1170. $v = json_decode ( $value ['staff'] );
  1171. $list = array ();
  1172. foreach ( $v as $n => $m ) {
  1173. if ($m ['1'] == 'ROLE') {
  1174. $roleInfo = $role->getOne ( array (
  1175. 'where' => 'rid=' . $m [0],
  1176. 'asArray' => true
  1177. ) );
  1178. $v [$n] [1] = $roleInfo ['name'];
  1179. array_push ( $list, $roleInfo ['name'] );
  1180. } else {
  1181. array_push ( $list, $v [$n] [1] );
  1182. }
  1183. }
  1184. $veList [$key] ['staff'] = implode ( '>', $list );
  1185. }
  1186. $data ['rid'] = $rid;
  1187. $data ['category'] = $lCategory->find ( array (
  1188. 'asArray' => true
  1189. ) );
  1190. $data ['veList'] = $veList;
  1191. $data ['acItem'] = $acItem;
  1192. $data ['memu'] = "receipt";
  1193. $data ['staff'] = $this->staff;
  1194. $data ['receiptMemu'] = 'saeaBorad';
  1195. $data ['verifyId'] = $this->verifyId;
  1196. $data ['executeId'] = $this->executeId;
  1197. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1198. }
  1199. function saeaLoanReceiptAddDo() {
  1200. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1201. $agency = $this->get_args ( 'agency' );
  1202. $travel = $this->get_args ( 'travel' );
  1203. $train = $this->get_args ( 'train' );
  1204. $other = $this->get_args ( 'other' );
  1205. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1206. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1207. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1208. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1209. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )) {
  1210. Doo::loadModel ( 'receipt' );
  1211. Doo::loadModel ( 'receiptDetail' );
  1212. Doo::loadModel ( 'accountItem' );
  1213. $accountItem = new accountItem ();
  1214. $receipt = new receipt ();
  1215. Doo::loadModel ( 'enclosur' );
  1216. Doo::loadModel ( 'execute' );
  1217. $execute = new execute ();
  1218. $executeDetail = $execute->getOne ( array (
  1219. 'where' => 'mold="借款费用执行人"',
  1220. 'asArray' => true
  1221. ) );
  1222. $receiptDet = $receipt->getOne ( array (
  1223. 'where' => 'rid=' . $rid,
  1224. 'asArray' => true
  1225. ) );
  1226. // if(!empty($receiptDetail))
  1227. // return "/referReceipt/".$receiptDetail['rid'];
  1228. $aItem = $accountItem->find ( array (
  1229. 'asArray' => true
  1230. ) );
  1231. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1232. $ag = $tr = $ta = $ot = 0;
  1233. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1234. foreach ( $aItem as $key => $value ) {
  1235. if ($value ['category'] == $this->AGENCY) {
  1236. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1237. array_push ( $accountJson [$this->AGENCY], array (
  1238. 'aid' => $value ['aid'],
  1239. 'name' => $value ['name'],
  1240. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1241. ) );
  1242. $sum += $agency [$ag];
  1243. $agencySum += $agency [$ag];
  1244. }
  1245. $ag ++;
  1246. }
  1247. if ($value ['category'] == $this->TRAVEL) {
  1248. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1249. array_push ( $accountJson [$this->TRAVEL], array (
  1250. 'aid' => $value ['aid'],
  1251. 'name' => $value ['name'],
  1252. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1253. ) );
  1254. $sum += $travel [$tr];
  1255. $travelSum += $travel [$tr];
  1256. }
  1257. $tr ++;
  1258. }
  1259. if ($value ['category'] == $this->TRAIN) {
  1260. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1261. array_push ( $accountJson [$this->TRAIN], array (
  1262. 'aid' => $value ['aid'],
  1263. 'name' => $value ['name'],
  1264. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1265. ) );
  1266. $sum += $train [$ta];
  1267. $trainSum += $train [$ta];
  1268. }
  1269. $ta ++;
  1270. }
  1271. if ($value ['category'] == $this->OTHER) {
  1272. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1273. array_push ( $accountJson [$this->OTHER], array (
  1274. 'aid' => $value ['aid'],
  1275. 'name' => $value ['name'],
  1276. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1277. ) );
  1278. $sum += $other [$ot];
  1279. $otherSum += $other [$ot];
  1280. }
  1281. $ot ++;
  1282. }
  1283. }
  1284. $accountJson ['cSum'] = array (
  1285. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1286. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1287. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1288. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1289. );
  1290. // 报销单
  1291. $receipt->accountItem = json_encode ( $accountJson );
  1292. $receipt->staff = $this->staff [0] ['sid'];
  1293. $receipt->loanSum = $receiptDet ['sum'];
  1294. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1295. $receipt->date = date ( "Y-m-d" );
  1296. $receipt->pastDate = '';
  1297. $receipt->cid = $cid;
  1298. $receipt->status = 7;
  1299. // 修改审批流程加入角色
  1300. $receipt->verify = $verify;
  1301. $receipt->verifyStaff = '';
  1302. $receipt->executeStaff = '';
  1303. $receipt->executeCopy = $executeDetail ['staff'];
  1304. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  1305. $receipt->explanation = $explanation;
  1306. $receipt->update ( array (
  1307. 'where' => 'rid=' . $rid
  1308. ) );
  1309. // 附件
  1310. if (! empty ( $enclosurName )) {
  1311. $enclosurArray = explode ( '-', $enclosurName );
  1312. foreach ( $enclosurArray as $value ) {
  1313. $enclosur = new enclosur ();
  1314. $enclosur->name = $value;
  1315. $enclosur->rid = $rid;
  1316. $enclosur->insert ();
  1317. }
  1318. // print_r($enclosurArray);die;
  1319. }
  1320. // 报销详情
  1321. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1322. $receiptDetail = new receiptDetail ();
  1323. $receiptDetail->staff = $this->staff [0] ['sid'];
  1324. $receiptDetail->item = $value ['name'];
  1325. $receiptDetail->itemCategory = $this->AGENCY;
  1326. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1327. $receiptDetail->date = date ( "Y-m-d" );
  1328. $receiptDetail->cid = $cid;
  1329. $receiptDetail->rid = $rid;
  1330. $receiptDetail->status = 4;
  1331. $receiptDetail->insert ();
  1332. }
  1333. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1334. $receiptDetail = new receiptDetail ();
  1335. $receiptDetail->staff = $this->staff [0] ['sid'];
  1336. $receiptDetail->item = $value ['name'];
  1337. $receiptDetail->itemCategory = $this->TRAVEL;
  1338. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1339. $receiptDetail->date = date ( "Y-m-d" );
  1340. $receiptDetail->cid = $cid;
  1341. $receiptDetail->rid = $rid;
  1342. $receiptDetail->status = 4;
  1343. $receiptDetail->insert ();
  1344. }
  1345. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1346. $receiptDetail = new receiptDetail ();
  1347. $receiptDetail->staff = $this->staff [0] ['sid'];
  1348. $receiptDetail->item = $value ['name'];
  1349. $receiptDetail->itemCategory = $this->TRAIN;
  1350. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1351. $receiptDetail->date = date ( "Y-m-d" );
  1352. $receiptDetail->cid = $cid;
  1353. $receiptDetail->rid = $rid;
  1354. $receiptDetail->status = 4;
  1355. $receiptDetail->insert ();
  1356. }
  1357. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1358. $receiptDetail = new receiptDetail ();
  1359. $receiptDetail->staff = $this->staff [0] ['sid'];
  1360. $receiptDetail->item = $value ['name'];
  1361. $receiptDetail->itemCategory = $this->OTHER;
  1362. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1363. $receiptDetail->date = date ( "Y-m-d" );
  1364. $receiptDetail->cid = $cid;
  1365. $receiptDetail->rid = $rid;
  1366. $receiptDetail->status = 4;
  1367. $receiptDetail->insert ();
  1368. }
  1369. return "/saeaBorad";
  1370. }
  1371. return "/saeaLoanReceiptAdd/" . $rid;
  1372. }
  1373. function saeaLoanReceiptEdi() {
  1374. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1375. // echo $rid;
  1376. Doo::loadModel ( 'accountItem' );
  1377. Doo::loadModel ( 'verify' );
  1378. Doo::loadModel ( 'receipt' );
  1379. $receipt = new receipt ();
  1380. $verify = new verify ();
  1381. $accountItem = new accountItem ();
  1382. Doo::loadModel ( 'L_category' );
  1383. $Lcategory = new L_category ();
  1384. Doo::loadModel ( "role" );
  1385. $role = new role ();
  1386. Doo::loadModel ( 'loanReceipt' );
  1387. $loanReceipt = new loanReceipt ();
  1388. Doo::loadModel ( 'staff' );
  1389. $staff = new staff ();
  1390. $receiptDetail = $receipt->getOne ( array (
  1391. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  1392. 'asArray' => true
  1393. ) );
  1394. if (empty ( $receiptDetail ))
  1395. return "/saeaBorad";
  1396. $receiptList = $loanReceipt->find ( array (
  1397. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1398. 'desc' => 'rid',
  1399. 'asArray' => true
  1400. ) );
  1401. $Locate = 0;
  1402. $roleId = 0;
  1403. $button = 0;
  1404. foreach ( $receiptList as $key => $value ) {
  1405. $receiptList [$key] ['Locate'] = $Locate;
  1406. $Locate ++;
  1407. $receiptList [$key] ['reviseDetail'] = array ();
  1408. if (! empty ( $value ['reviseDetail'] ))
  1409. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1410. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1411. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1412. $categoryDetil = $Lcategory->getOne ( array (
  1413. 'where' => 'cid=' . $value ['cid'],
  1414. 'asArray' => true
  1415. ) );
  1416. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1417. // 检测编辑状态
  1418. $verifyList = $verify->getOne ( array (
  1419. 'where' => 'vid=' . $value ['verify'],
  1420. 'asArray' => true
  1421. ) );
  1422. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1423. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1424. Doo::loadModel ( 'role' );
  1425. $role = new role ();
  1426. $flag = true;
  1427. $roleKey = 0;
  1428. $endStaffArray = array ();
  1429. $roleArrayCopy = array ();
  1430. foreach ( $verifyList as $k => $v ) {
  1431. // init verifyStaff
  1432. if ($v [1] == 'ROLE') {
  1433. if (! empty ( $verifyStaff )) {
  1434. $endStaffArray = end ( $verifyStaff );
  1435. // if ($v[0]==$endStaffArray['nextStaff']){
  1436. // $roleId=$v[0];
  1437. // }
  1438. }
  1439. $roleVerify = json_decode ( $v [3], true );
  1440. $roleKey = $k;
  1441. $roleArray = array ();
  1442. $rolename = $role->getOne ( array (
  1443. 'where' => 'rid=' . $v [0],
  1444. 'asArray' => true
  1445. ) );
  1446. foreach ( $roleVerify as $o => $p ) {
  1447. $staffID = explode ( '_', $p );
  1448. $staffInfo = $staff->getOne ( array (
  1449. 'where' => 'sid=' . $staffID [0],
  1450. 'asArray' => true
  1451. ) );
  1452. // print_r($staffID);
  1453. $exp = array (
  1454. 0 => $staffInfo ['sid'],
  1455. 1 => $staffID [1],
  1456. 2 => $staffInfo ['avatar'],
  1457. 'date' => '',
  1458. 'date' => '',
  1459. 'opinion' => '',
  1460. 'status' => '',
  1461. 'rolename' => $rolename ['name']
  1462. );
  1463. array_push ( $roleArray, $exp );
  1464. }
  1465. $roleArrayCopy [$v [0]] = $roleArray;
  1466. // $verifyList[$k]['roleArray']=$roleArray;
  1467. }
  1468. $verifyList [$k] ['date'] = "";
  1469. $verifyList [$k] ['opinion'] = "";
  1470. $verifyList [$k] ['status'] = "";
  1471. if (empty ( $verifyStaff )) {
  1472. $verifyList [$k] ['date'] = "";
  1473. $verifyList [$k] ['opinion'] = "";
  1474. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1475. $verifyList [$k] ['status'] = 4;
  1476. $flag = false;
  1477. }
  1478. } else {
  1479. foreach ( $verifyStaff as $m => $u ) {
  1480. if ($v [0] == $m) {
  1481. $verifyList [$k] ['date'] = $u ['date'];
  1482. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1483. $verifyList [$k] ['status'] = $u ['status'];
  1484. $flag = false;
  1485. break;
  1486. }
  1487. }
  1488. $endStaffArray = end ( $verifyStaff );
  1489. if (isset ( $endStaffArray ['ROLE'] )) {
  1490. } else {
  1491. // $endKey=key($verifyStaff);
  1492. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1493. // $button=4;
  1494. // $verifyList[$k]['status']=4;
  1495. // }
  1496. }
  1497. }
  1498. }
  1499. $rolename ['name'] = '';
  1500. if (! empty ( $roleId )) {
  1501. Doo::loadModel ( 'role' );
  1502. $role = new role ();
  1503. $rolename = $role->getOne ( array (
  1504. 'where' => 'rid=' . $roleId,
  1505. 'asArray' => true
  1506. ) );
  1507. }
  1508. if (! empty ( $verifyStaff ))
  1509. $endStaffArray = end ( $verifyStaff );
  1510. $KOP = false;
  1511. foreach ( $roleArrayCopy as $P => $A ) {
  1512. foreach ( $A as $MKI => $AVL ) {
  1513. if (! empty ( $verifyStaff )) {
  1514. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1515. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1516. $button = 4;
  1517. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1518. }
  1519. foreach ( $verifyStaff as $m => $u ) {
  1520. $AVLFK = $AVL [0] . '_R';
  1521. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1522. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1523. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1524. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1525. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1526. break;
  1527. }
  1528. }
  1529. } else {
  1530. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1531. $button = 4;
  1532. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1533. }
  1534. }
  1535. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1536. $KOP = true;
  1537. }
  1538. }
  1539. foreach ( $roleArrayCopy as $k => $v ) {
  1540. foreach ( $verifyList as $m => $n ) {
  1541. if ($n [0] == $k) {
  1542. array_splice ( $verifyList, $m, 1, $v );
  1543. }
  1544. }
  1545. }
  1546. $receiptList [$key] ['verifyList'] = $verifyList;
  1547. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1548. 'where' => 'sid=' . $value ['staff'],
  1549. 'asArray' => true
  1550. ) );
  1551. $receiptList [$key] ['button'] = $button;
  1552. //
  1553. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1554. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1555. }
  1556. $data ['receiptList'] = $receiptList;
  1557. $acItem = $accountItem->find ( array (
  1558. 'asArray' => true
  1559. ) );
  1560. $veList = $verify->find ( array (
  1561. 'asArray' => true
  1562. ) );
  1563. foreach ( $veList as $key => $value ) {
  1564. $v = json_decode ( $value ['staff'] );
  1565. $list = array ();
  1566. foreach ( $v as $n => $m ) {
  1567. if ($m ['1'] == 'ROLE') {
  1568. $roleInfo = $role->getOne ( array (
  1569. 'where' => 'rid=' . $m [0],
  1570. 'asArray' => true
  1571. ) );
  1572. $v [$n] [1] = $roleInfo ['name'];
  1573. array_push ( $list, $roleInfo ['name'] );
  1574. } else {
  1575. array_push ( $list, $v [$n] [1] );
  1576. }
  1577. }
  1578. $veList [$key] ['staff'] = implode ( '>', $list );
  1579. }
  1580. // 配置编辑信息
  1581. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1582. foreach ( $acItem as $key => $value ) {
  1583. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1584. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1585. $acItem [$key] ['price'] = $v ['price'];
  1586. }
  1587. }
  1588. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1589. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1590. $acItem [$key] ['price'] = $v ['price'];
  1591. }
  1592. }
  1593. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1594. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1595. $acItem [$key] ['price'] = $v ['price'];
  1596. }
  1597. }
  1598. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1599. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1600. $acItem [$key] ['price'] = $v ['price'];
  1601. }
  1602. }
  1603. }
  1604. $data ['category'] = $Lcategory->find ( array (
  1605. 'asArray' => true
  1606. ) );
  1607. $data ['cSum'] = $accountItemList ['cSum'];
  1608. $data ['sum'] = $receiptDetail ['sum'];
  1609. $data ['receiptDetail'] = $receiptDetail;
  1610. $data ['veList'] = $veList;
  1611. $data ['acItem'] = $acItem;
  1612. $data ['memu'] = "receipt";
  1613. $data ['staff'] = $this->staff;
  1614. $data ['receiptMemu'] = 'saeaBorad';
  1615. $data ['verify'] = $receiptDetail ['verify'];
  1616. $data ['verifyId'] = $this->verifyId;
  1617. $data ['executeId'] = $this->executeId;
  1618. $data ['rid'] = $rid;
  1619. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  1620. }
  1621. function confirmation() {
  1622. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1623. Doo::loadModel ( 'receipt' );
  1624. Doo::loadModel ( 'receiptDetail' );
  1625. $receipt = new receipt ();
  1626. $receiptDetail = new receiptDetail ();
  1627. Doo::loadModel ( 'statistics' );
  1628. Doo::loadModel ( 'itemStatistics' );
  1629. $statistics = new statistics ();
  1630. $itemStatistics = new itemStatistics ();
  1631. Doo::loadModel ( "verify" );
  1632. $verify = new verify ();
  1633. $receiptDetailList = $receipt->getOne ( array (
  1634. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  1635. 'asArray' => true
  1636. ) );
  1637. if (empty ( $receiptDetailList ))
  1638. return "/saeaBorad";
  1639. $verifyDetail = $verify->getOne ( array (
  1640. 'where' => ' vid =' . $receiptDetailList ['verify'],
  1641. 'asArray' => true
  1642. ) );
  1643. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  1644. if (empty ( $receiptDetailList ['nowStaff'] )) {
  1645. $nowStaff = "";
  1646. $nowStaffList = array ();
  1647. if ($verifyDetail [0] [1] == 'ROLE') {
  1648. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  1649. foreach ( $vStaffString as $key => $value ) {
  1650. $staffK = explode ( "_", $value );
  1651. array_push ( $nowStaffList, $staffK [0] );
  1652. }
  1653. $nowStaff = implode ( ',', $nowStaffList );
  1654. } else {
  1655. $nowStaff = $verifyDetail [0] [0];
  1656. }
  1657. $receipt->nowStaff = $nowStaff;
  1658. }
  1659. // echo $nowStaff;
  1660. // print_r($verifyDetail);die;
  1661. $receipt->rid = $receiptDetailList ['rid'];
  1662. $receipt->status = 2;
  1663. $receipt->update ();
  1664. // 操作日志
  1665. Doo::loadModel ( "receiptLog" );
  1666. $receiptLog = new receiptLog ();
  1667. $verify = new verify ();
  1668. $receiptInfo = $receipt->getOne ( array (
  1669. 'where' => 'rid=' . $rid,
  1670. 'asArray' => true
  1671. ) );
  1672. $vr = $verify->getOne ( array (
  1673. 'where' => 'vid=' . $receiptInfo ['verify'],
  1674. 'asArray' => true
  1675. ) );
  1676. $jd = json_decode ( $vr ['staff'] );
  1677. $roleId = 0;
  1678. foreach ( $jd as $key => $value ) {
  1679. if ($value [1] == 'ROLE') {
  1680. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  1681. if ($pos !== false) {
  1682. $roleId = $value [0];
  1683. }
  1684. }
  1685. }
  1686. // 审批日志
  1687. // echo $roleId;die;
  1688. if (! empty ( $roleId )) {
  1689. Doo::loadModel ( "role" );
  1690. $role = new role ();
  1691. $roleInfo = $role->getOne ( array (
  1692. 'where' => 'rid=' . $roleId,
  1693. 'asArray' => true
  1694. ) );
  1695. $receiptLog->rolename = $roleInfo ['name'];
  1696. }
  1697. $receiptLog->username = $this->staff [0] ['username'];
  1698. $receiptLog->uid = $this->staff [0] ['sid'];
  1699. $receiptLog->date = date ( "Y-m-d" );
  1700. $receiptLog->opinion = '提交审批';
  1701. $receiptLog->img = $this->staff [0] ['avatar'];
  1702. $receiptLog->status = 2;
  1703. $receiptLog->rid = $rid;
  1704. $receiptLog->insert ();
  1705. return "/expenses";
  1706. }
  1707. function expenses() {
  1708. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  1709. if (empty ( $item ))
  1710. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  1711. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1712. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  1713. Doo::loadModel ( 'receipt' );
  1714. $receipt = new receipt ();
  1715. Doo::loadModel ( 'L_category' );
  1716. $Lcategory = new L_category ();
  1717. Doo::loadModel ( 'verify' );
  1718. Doo::loadModel ( 'statistics' );
  1719. $statistics = new statistics ();
  1720. $verify = new verify ();
  1721. Doo::loadModel ( 'staff' );
  1722. $staff = new staff ();
  1723. $condition = "";
  1724. if ($item == "expenses")
  1725. $condition = " and Rtype=1 ";
  1726. elseif ($item == "receipts")
  1727. $condition = " and Rtype=0 ";
  1728. elseif ($item == "remits")
  1729. $condition = " and Rtype=2 ";
  1730. $dateCondition = " and Year(date) =" . $year;
  1731. if (! empty ( $moth )) {
  1732. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  1733. $stList = $statistics->getOne ( array (
  1734. 'select' => 'rePrice ,agPrice',
  1735. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  1736. 'asArray' => true
  1737. ) );
  1738. } else
  1739. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  1740. if (empty ( $stList ))
  1741. $stList = array (
  1742. 'rePrice' => 0,
  1743. 'agPrice' => 0
  1744. );
  1745. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  1746. if (! isset ( $noPassSum ['sum'] ))
  1747. $noPassSum ['sum'] = 0;
  1748. $data ['stList'] = array (
  1749. 'rePrice' => $stList ['rePrice'],
  1750. 'agPrice' => $stList ['agPrice'],
  1751. 'skPrice' => ($noPassSum ['sum'])
  1752. );
  1753. $receiptList = $receipt->find ( array (
  1754. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  1755. 'desc' => 'rid',
  1756. 'asArray' => true
  1757. ) );
  1758. $Locate = 0;
  1759. $roleId = 0;
  1760. $button = 0;
  1761. foreach ( $receiptList as $key => $value ) {
  1762. $receiptList [$key] ['Locate'] = $Locate;
  1763. $Locate ++;
  1764. $receiptList [$key] ['reviseDetail'] = array ();
  1765. if (! empty ( $value ['reviseDetail'] ))
  1766. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1767. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1768. $categoryDetil = $Lcategory->getOne ( array (
  1769. 'where' => 'cid=' . $value ['cid'],
  1770. 'asArray' => true
  1771. ) );
  1772. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1773. // 检测编辑状态
  1774. $verifyList = $verify->getOne ( array (
  1775. 'where' => 'vid=' . $value ['verify'],
  1776. 'asArray' => true
  1777. ) );
  1778. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1779. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1780. Doo::loadModel ( 'role' );
  1781. $role = new role ();
  1782. $flag = true;
  1783. $roleKey = 0;
  1784. $endStaffArray = array ();
  1785. $roleArrayCopy = array ();
  1786. foreach ( $verifyList as $k => $v ) {
  1787. // init verifyStaff
  1788. if ($v [1] == 'ROLE') {
  1789. if (! empty ( $verifyStaff )) {
  1790. $endStaffArray = end ( $verifyStaff );
  1791. // if ($v[0]==$endStaffArray['nextStaff']){
  1792. // $roleId=$v[0];
  1793. // }
  1794. }
  1795. $roleVerify = json_decode ( $v [3], true );
  1796. $roleKey = $k;
  1797. $roleArray = array ();
  1798. $rolename = $role->getOne ( array (
  1799. 'where' => 'rid=' . $v [0],
  1800. 'asArray' => true
  1801. ) );
  1802. foreach ( $roleVerify as $o => $p ) {
  1803. $staffID = explode ( '_', $p );
  1804. $staffInfo = $staff->getOne ( array (
  1805. 'where' => 'sid=' . $staffID [0],
  1806. 'asArray' => true
  1807. ) );
  1808. // print_r($staffID);
  1809. $exp = array (
  1810. 0 => $staffInfo ['sid'],
  1811. 1 => $staffID [1],
  1812. 2 => $staffInfo ['avatar'],
  1813. 'date' => '',
  1814. 'date' => '',
  1815. 'opinion' => '',
  1816. 'status' => '',
  1817. 'rolename' => $rolename ['name']
  1818. );
  1819. array_push ( $roleArray, $exp );
  1820. }
  1821. $roleArrayCopy [$v [0]] = $roleArray;
  1822. // $verifyList[$k]['roleArray']=$roleArray;
  1823. }
  1824. $verifyList [$k] ['date'] = "";
  1825. $verifyList [$k] ['opinion'] = "";
  1826. $verifyList [$k] ['status'] = "";
  1827. if (empty ( $verifyStaff )) {
  1828. $verifyList [$k] ['date'] = "";
  1829. $verifyList [$k] ['opinion'] = "";
  1830. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1831. $verifyList [$k] ['status'] = 4;
  1832. $flag = false;
  1833. }
  1834. } else {
  1835. foreach ( $verifyStaff as $m => $u ) {
  1836. if ($v [0] == $m) {
  1837. $verifyList [$k] ['date'] = $u ['date'];
  1838. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1839. $verifyList [$k] ['status'] = $u ['status'];
  1840. $flag = false;
  1841. break;
  1842. }
  1843. }
  1844. $endStaffArray = end ( $verifyStaff );
  1845. if (isset ( $endStaffArray ['ROLE'] )) {
  1846. } else {
  1847. // $endKey=key($verifyStaff);
  1848. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1849. // $button=4;
  1850. // $verifyList[$k]['status']=4;
  1851. // }
  1852. }
  1853. }
  1854. }
  1855. $rolename ['name'] = '';
  1856. if (! empty ( $roleId )) {
  1857. Doo::loadModel ( 'role' );
  1858. $role = new role ();
  1859. $rolename = $role->getOne ( array (
  1860. 'where' => 'rid=' . $roleId,
  1861. 'asArray' => true
  1862. ) );
  1863. }
  1864. if (! empty ( $verifyStaff ))
  1865. $endStaffArray = end ( $verifyStaff );
  1866. $KOP = false;
  1867. foreach ( $roleArrayCopy as $P => $A ) {
  1868. foreach ( $A as $MKI => $AVL ) {
  1869. if (! empty ( $verifyStaff )) {
  1870. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1871. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1872. $button = 4;
  1873. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1874. }
  1875. foreach ( $verifyStaff as $m => $u ) {
  1876. $AVLFK = $AVL [0] . '_R';
  1877. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1878. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1879. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1880. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1881. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1882. break;
  1883. }
  1884. }
  1885. } else {
  1886. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1887. $button = 4;
  1888. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1889. }
  1890. }
  1891. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1892. $KOP = true;
  1893. }
  1894. }
  1895. foreach ( $roleArrayCopy as $k => $v ) {
  1896. foreach ( $verifyList as $m => $n ) {
  1897. if ($n [0] == $k) {
  1898. array_splice ( $verifyList, $m, 1, $v );
  1899. }
  1900. }
  1901. }
  1902. $receiptList [$key] ['verifyList'] = $verifyList;
  1903. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1904. 'where' => 'sid=' . $value ['staff'],
  1905. 'asArray' => true
  1906. ) );
  1907. $receiptList [$key] ['button'] = $button;
  1908. }
  1909. // print_r($receiptList);die;
  1910. $mothHtml = "";
  1911. for($i = 1; $i <= 12; $i ++) {
  1912. if ($moth == $i)
  1913. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  1914. else
  1915. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  1916. }
  1917. $data ['mothHtml'] = $mothHtml;
  1918. $data ['receiptList'] = $receiptList;
  1919. $data ['memu'] = "receipt";
  1920. $data ['staff'] = $this->staff;
  1921. $data ['receiptMemu'] = 'expenses';
  1922. $data ['verifyId'] = $this->verifyId;
  1923. $data ['executeId'] = $this->executeId;
  1924. $data ['item'] = $item;
  1925. $data ['year'] = $year;
  1926. $this->render ( "/admin/expenses", $data );
  1927. }
  1928. function expensesCollect() {
  1929. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1930. Doo::loadModel ( 'receipt' );
  1931. $receipt = new receipt ();
  1932. Doo::loadModel ( 'L_category' );
  1933. $Lcategory = new L_category ();
  1934. Doo::loadModel ( 'verify' );
  1935. Doo::loadModel ( 'statistics' );
  1936. $statistics = new statistics ();
  1937. $verify = new verify ();
  1938. Doo::loadModel ( 'staff' );
  1939. $staff = new staff ();
  1940. Doo::loadModel ( 'loanReceipt' );
  1941. $loanReceipt = new loanReceipt ();
  1942. $receiptList = $receipt->find ( array (
  1943. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  1944. 'desc' => 'rid',
  1945. 'asArray' => true
  1946. ) );
  1947. $loanList = $loanReceipt->find ( array (
  1948. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  1949. 'desc' => 'rid',
  1950. 'asArray' => true
  1951. ) );
  1952. /*
  1953. * $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;
  1954. */
  1955. $Locate = 0;
  1956. $roleId = 0;
  1957. $button = 0;
  1958. foreach ( $receiptList as $key => $value ) {
  1959. $receiptList [$key] ['Locate'] = $Locate;
  1960. $Locate ++;
  1961. $receiptList [$key] ['reviseDetail'] = array ();
  1962. if (! empty ( $value ['reviseDetail'] ))
  1963. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1964. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1965. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1966. $categoryDetil = $Lcategory->getOne ( array (
  1967. 'where' => 'cid=' . $value ['cid'],
  1968. 'asArray' => true
  1969. ) );
  1970. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1971. // 检测编辑状态
  1972. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  1973. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  1974. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  1975. else
  1976. $verifyList ['staff'] = $value ['verifyBreakup'];
  1977. } else
  1978. $verifyList = $verify->getOne ( array (
  1979. 'where' => 'vid=' . $value ['verify'],
  1980. 'asArray' => true
  1981. ) );
  1982. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1983. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1984. Doo::loadModel ( 'role' );
  1985. $role = new role ();
  1986. $flag = true;
  1987. $roleKey = 0;
  1988. $endStaffArray = array ();
  1989. $roleArrayCopy = array ();
  1990. foreach ( $verifyList as $k => $v ) {
  1991. // init verifyStaff
  1992. if ($v [1] == 'ROLE') {
  1993. if (! empty ( $verifyStaff )) {
  1994. $endStaffArray = end ( $verifyStaff );
  1995. // if ($v[0]==$endStaffArray['nextStaff']){
  1996. // $roleId=$v[0];
  1997. // }
  1998. }
  1999. $roleVerify = json_decode ( $v [3], true );
  2000. $roleKey = $k;
  2001. $roleArray = array ();
  2002. $rolename = $role->getOne ( array (
  2003. 'where' => 'rid=' . $v [0],
  2004. 'asArray' => true
  2005. ) );
  2006. foreach ( $roleVerify as $o => $p ) {
  2007. $staffID = explode ( '_', $p );
  2008. $staffInfo = $staff->getOne ( array (
  2009. 'where' => 'sid=' . $staffID [0],
  2010. 'asArray' => true
  2011. ) );
  2012. // print_r($staffID);
  2013. $exp = array (
  2014. 0 => $staffInfo ['sid'],
  2015. 1 => $staffID [1],
  2016. 2 => $staffInfo ['avatar'],
  2017. 'date' => '',
  2018. 'date' => '',
  2019. 'opinion' => '',
  2020. 'status' => '',
  2021. 'rolename' => $rolename ['name']
  2022. );
  2023. array_push ( $roleArray, $exp );
  2024. }
  2025. $roleArrayCopy [$v [0]] = $roleArray;
  2026. // $verifyList[$k]['roleArray']=$roleArray;
  2027. }
  2028. $verifyList [$k] ['date'] = "";
  2029. $verifyList [$k] ['opinion'] = "";
  2030. $verifyList [$k] ['status'] = "";
  2031. if (empty ( $verifyStaff )) {
  2032. $verifyList [$k] ['date'] = "";
  2033. $verifyList [$k] ['opinion'] = "";
  2034. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2035. $verifyList [$k] ['status'] = 4;
  2036. $flag = false;
  2037. }
  2038. } else {
  2039. foreach ( $verifyStaff as $m => $u ) {
  2040. if ($v [0] == $m) {
  2041. $verifyList [$k] ['date'] = $u ['date'];
  2042. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2043. $verifyList [$k] ['status'] = $u ['status'];
  2044. $flag = false;
  2045. break;
  2046. }
  2047. }
  2048. $endStaffArray = end ( $verifyStaff );
  2049. if (isset ( $endStaffArray ['ROLE'] )) {
  2050. } else {
  2051. // $endKey=key($verifyStaff);
  2052. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2053. // $button=4;
  2054. // $verifyList[$k]['status']=4;
  2055. // }
  2056. }
  2057. }
  2058. }
  2059. $rolename ['name'] = '';
  2060. if (! empty ( $roleId )) {
  2061. Doo::loadModel ( 'role' );
  2062. $role = new role ();
  2063. $rolename = $role->getOne ( array (
  2064. 'where' => 'rid=' . $roleId,
  2065. 'asArray' => true
  2066. ) );
  2067. }
  2068. if (! empty ( $verifyStaff ))
  2069. $endStaffArray = end ( $verifyStaff );
  2070. $KOP = false;
  2071. foreach ( $roleArrayCopy as $P => $A ) {
  2072. foreach ( $A as $MKI => $AVL ) {
  2073. if (! empty ( $verifyStaff )) {
  2074. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2075. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2076. $button = 4;
  2077. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2078. }
  2079. foreach ( $verifyStaff as $m => $u ) {
  2080. $AVLFK = $AVL [0] . '_R';
  2081. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2082. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2083. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2084. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2085. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2086. break;
  2087. }
  2088. }
  2089. } else {
  2090. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2091. $button = 4;
  2092. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2093. }
  2094. }
  2095. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2096. $KOP = true;
  2097. }
  2098. }
  2099. foreach ( $roleArrayCopy as $k => $v ) {
  2100. foreach ( $verifyList as $m => $n ) {
  2101. if ($n [0] == $k) {
  2102. array_splice ( $verifyList, $m, 1, $v );
  2103. }
  2104. }
  2105. }
  2106. // 费用执行人相关数据
  2107. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2108. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2109. foreach ( $executeCopy as $k => $v ) {
  2110. $executeCopy [$k] ['date'] = '';
  2111. $executeCopy [$k] ['opinion'] = '';
  2112. $executeCopy [$k] ['status'] = '';
  2113. if (! empty ( $executeStaff ))
  2114. foreach ( $executeStaff as $m => $u ) {
  2115. if ($v [0] == $m) {
  2116. $executeCopy [$k] ['date'] = $u ['date'];
  2117. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2118. $executeCopy [$k] ['status'] = $u ['status'];
  2119. break;
  2120. }
  2121. }
  2122. }
  2123. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2124. $receiptList [$key] ['verifyList'] = $verifyList;
  2125. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2126. 'where' => 'sid=' . $value ['staff'],
  2127. 'asArray' => true
  2128. ) );
  2129. $receiptList [$key] ['button'] = $button;
  2130. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2131. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2132. $relust = $value ['sum'] - $value ['loanSum'];
  2133. $receiptList [$key] ['relust'] = $relust;
  2134. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2135. }
  2136. Doo::loadModel ( 'enclosur' );
  2137. $enclosur = new enclosur ();
  2138. $enclosurList = $enclosur->find ( array (
  2139. 'where' => 'rid=' . $rid,
  2140. 'asArray' => true
  2141. ) );
  2142. $enclosurHtml = '';
  2143. foreach ( $enclosurList as $value ) {
  2144. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2145. }
  2146. $data ['enclosurHtml'] = $enclosurHtml;
  2147. // print_r($receiptList);
  2148. $data ['receiptList'] = $receiptList;
  2149. $data ['memu'] = "receipt";
  2150. $data ['staff'] = $this->staff;
  2151. $data ['receiptMemu'] = 'expenses';
  2152. $data ['verifyId'] = $this->verifyId;
  2153. $data ['executeId'] = $this->executeId;
  2154. $this->render ( "/admin/expensesCollect", $data );
  2155. }
  2156. function approvalExpenses() {
  2157. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  2158. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2159. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2160. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2161. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2162. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  2163. //echo $rdate;
  2164. if (empty ( $status ))
  2165. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  2166. $page_size = 12;
  2167. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2168. $vidList = array ();
  2169. $button = 0;
  2170. Doo::loadModel ( 'verify' );
  2171. $verify = new verify ();
  2172. Doo::loadModel ( 'receipt' );
  2173. $receipt = new receipt ();
  2174. Doo::loadModel ( 'staff' );
  2175. $staff = new staff ();
  2176. Doo::loadModel ( 'L_category' );
  2177. $Lcategory = new L_category ();
  2178. // user verify ID
  2179. $verifyDetail = $verify->find ( array (
  2180. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  2181. 'asArray' => true
  2182. ) );
  2183. foreach ( $verifyDetail as $key => $value ) {
  2184. array_push ( $vidList, $value ['vid'] );
  2185. }
  2186. $vid = implode ( ",", $vidList );
  2187. if (empty ( $verifyDetail ))
  2188. $vid = 0;
  2189. // if ($status==0)
  2190. // $dateCondition="";
  2191. // else
  2192. $dateCondition = " and Year(date) =" . $year;
  2193. /*
  2194. if (! empty ( $month ))
  2195. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  2196. if($status == 'done'){
  2197. $dateCondition = " and Year(pastDate) =" . $year;
  2198. if (! empty ( $month ))
  2199. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  2200. }
  2201. */
  2202. //date ( 'Y-m' )
  2203. if(!empty($rdate)&&$status == 'done')
  2204. $dateCondition=" and date_format(pastDate,'%Y-%m')='".$rdate."' ";
  2205. elseif (!empty($rdate))
  2206. $dateCondition=" and date_format(date,'%Y-%m')='".$rdate."' ";
  2207. $categoryList = $Lcategory->find ( array (
  2208. 'asArray' => true
  2209. ) );
  2210. $staffList = $staff->find ( array (
  2211. 'where' => 'cid=' . $cid,
  2212. 'asArray' => true
  2213. ) );
  2214. $cateCondition = "";
  2215. $staffCondition = "";
  2216. $approvalCondition = "";
  2217. if (! empty ( $cid )){
  2218. $cateCondition = ' and cid=' . $cid;
  2219. }
  2220. if (! empty ( $sid )) {
  2221. $staffCondition = ' and cid=' . $cid.' and staff=' . $sid;
  2222. $cateCondition = "";
  2223. }
  2224. $get="?year=".$year."&month=".$month."&cid=".$cid."&sid=".$sid;
  2225. if ($status == 'pendApproval') {
  2226. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  2227. }
  2228. if ($status == 'ongoing') {
  2229. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  2230. }
  2231. if ($status == 'done') {
  2232. $approvalCondition = ' and (status=8 or status=9 ) ';
  2233. }
  2234. if ($status == 'termination') {
  2235. $approvalCondition = " and status=3";
  2236. }
  2237. // $approvalCondition = " and status=" . $status;
  2238. // if ($status == 2) {
  2239. // // 查找角色审批人
  2240. // }
  2241. // if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  2242. // $approvalCondition = ' and status=2 ';
  2243. // }
  2244. // if ($status == 1) {
  2245. // $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  2246. // }
  2247. // if ($status == 8) {
  2248. // $approvalCondition = ' and (status=' . $status . ' or status=9 ) ';
  2249. // }
  2250. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  2251. $pageinfo ['page'] = array (
  2252. 'previous' => ''
  2253. );
  2254. // if ($status == 0) {
  2255. // $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  2256. // $receiptList = $receipt->find ( array (
  2257. // 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ')',
  2258. // 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2259. // 'desc' => 'rid',
  2260. // 'asArray' => true
  2261. // ) );
  2262. // //echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2263. // } else
  2264. if ($status == 'done' || $status == 'termination') {
  2265. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/".$status, $get, "" );
  2266. $receiptList = $receipt->find ( array (
  2267. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
  2268. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2269. 'desc' => 'rid',
  2270. 'asArray' => true
  2271. ) );
  2272. } else
  2273. $receiptList = $receipt->find ( array (
  2274. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
  2275. 'desc' => 'rid',
  2276. 'asArray' => true
  2277. ) );
  2278. $rLRes = $receipt->find ( array (
  2279. '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,
  2280. 'desc' => 'rid',
  2281. 'asArray' => true
  2282. ) );
  2283. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2284. // print_r($pageinfo);
  2285. $Locate = 0;
  2286. $reportList=$reportCateList=array();
  2287. foreach ( $receiptList as $key => $value ) {
  2288. $receiptList [$key] ['Locate'] = $Locate;
  2289. $Locate ++;
  2290. $receiptList [$key] ['reviseDetail'] = array ();
  2291. if (! empty ( $value ['reviseDetail'] ))
  2292. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2293. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2294. $categoryDetil = $Lcategory->getOne ( array (
  2295. 'where' => 'cid=' . $value ['cid'],
  2296. 'asArray' => true
  2297. ) );
  2298. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2299. $verifyList = $verify->getOne ( array (
  2300. 'where' => 'vid=' . $value ['verify'],
  2301. 'asArray' => true
  2302. ) );
  2303. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2304. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2305. foreach ( $verifyList as $k => $v ) {
  2306. // init verifyStaff
  2307. $verifyList [$k] ['date'] = "";
  2308. $verifyList [$k] ['opinion'] = "";
  2309. $verifyList [$k] ['status'] = "";
  2310. if (empty ( $verifyStaff )) {
  2311. $verifyList [$k] ['date'] = "";
  2312. $verifyList [$k] ['opinion'] = "";
  2313. if ($v [0] == $this->staff [0] ['sid']) {
  2314. $verifyList [$k] ['status'] = 4;
  2315. $button = 4;
  2316. }
  2317. } else {
  2318. $flag = true;
  2319. foreach ( $verifyStaff as $m => $u ) {
  2320. if ($v [0] == $m) {
  2321. $verifyList [$k] ['date'] = $u ['date'];
  2322. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2323. $verifyList [$k] ['status'] = $u ['status'];
  2324. $flag = false;
  2325. break;
  2326. }
  2327. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  2328. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  2329. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  2330. }
  2331. if ($flag) { // 检测可编辑
  2332. if ($v [0] == $this->staff [0] ['sid']) {
  2333. $verifyList [$k] ['status'] = 4;
  2334. $button = 4;
  2335. }
  2336. }
  2337. }
  2338. }
  2339. $receiptList [$key] ['verifyList'] = $verifyList;
  2340. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2341. 'where' => 'sid=' . $value ['staff'],
  2342. 'asArray' => true
  2343. ) );
  2344. array_push($reportList, $receiptList [$key] ['staffDetail']['sid'].'-'.$receiptList [$key] ['staffDetail']['username'].'-'.$receiptList [$key] ['staffDetail']['category']);
  2345. array_push($reportCateList, $receiptList [$key] ['staffDetail']['cid'].'-'.$receiptList [$key] ['staffDetail']['category']);
  2346. $receiptList [$key] ['button'] = $button;
  2347. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  2348. }
  2349. $reportList=array_unique($reportList);
  2350. $reportHtml='';
  2351. foreach ($reportList as $key=>$value){
  2352. $v=explode("-", $value);
  2353. $reportHtml.='<option node-all=\'true\' node-cate=\''.$v[2].'\' value="'.$v[1].'">'.$v[1].'</option>';
  2354. }
  2355. //print_r($reportList)
  2356. $data['reportHtml']=$reportHtml;
  2357. $reportCateList=array_unique($reportCateList);
  2358. $reportCateHtml='';
  2359. foreach ($reportCateList as $key=>$value){
  2360. $v=explode("-", $value);
  2361. $reportCateHtml.='<option value="'.$v[1].'">'.$v[1].'</option>';
  2362. }
  2363. //$reportHtml.='<option value="ALL">'.$value[''].'</option>';
  2364. $data['reportCateHtml']=$reportCateHtml;
  2365. // print_r($receiptList);die;
  2366. // $data['verifyDetail']=$verifyDetail;
  2367. $mothHtml = "";
  2368. for($i = 1; $i <= 12; $i ++) {
  2369. if ($month == $i)
  2370. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2371. else
  2372. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2373. }
  2374. $data ['mothHtml'] = $mothHtml;
  2375. $data ['page'] = $pageinfo;
  2376. $data ['receiptList'] = $receiptList;
  2377. $data ['receiptApprovalCount'] = count ( $rLRes );
  2378. $data ['status'] = $status;
  2379. $data ['year'] = $year;
  2380. $data ['categoryList'] = $categoryList;
  2381. $data ['staffList'] = $staffList;
  2382. $data ['cid'] = $cid;
  2383. $data ['sid'] = $sid;
  2384. // print_r($receiptList);
  2385. $data ['memu'] = "receipt";
  2386. $data ['staff'] = $this->staff;
  2387. $data ['receiptMemu'] = 'approvalExpenses';
  2388. $data ['verifyId'] = $this->verifyId;
  2389. $data ['executeId'] = $this->executeId;
  2390. $this->render ( "/admin/approvalExpenses", $data );
  2391. }
  2392. function expensesDoc() {
  2393. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2394. Doo::loadModel ( 'receipt' );
  2395. $receipt = new receipt ();
  2396. Doo::loadModel ( 'L_category' );
  2397. $Lcategory = new L_category ();
  2398. Doo::loadModel ( 'verify' );
  2399. Doo::loadModel ( 'statistics' );
  2400. $statistics = new statistics ();
  2401. $verify = new verify ();
  2402. Doo::loadModel ( 'staff' );
  2403. $staff = new staff ();
  2404. Doo::loadModel ( 'loanReceipt' );
  2405. $loanReceipt = new loanReceipt ();
  2406. $receiptList = $receipt->find ( array (
  2407. 'where' => ' rid=' . $rid,
  2408. 'desc' => 'rid',
  2409. 'asArray' => true
  2410. ) );
  2411. $loanList = array ();
  2412. if (! empty ( $receiptList ))
  2413. $loanList = $loanReceipt->find ( array (
  2414. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2415. 'desc' => 'rid',
  2416. 'asArray' => true
  2417. ) );
  2418. $Locate = 0;
  2419. $roleId = 0;
  2420. $button = 0;
  2421. foreach ( $loanList as $key => $value ) {
  2422. $loanList [$key] ['Locate'] = $Locate;
  2423. $Locate ++;
  2424. $loanList [$key] ['reviseDetail'] = array ();
  2425. if (! empty ( $value ['reviseDetail'] ))
  2426. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2427. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2428. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2429. $categoryDetil = $Lcategory->getOne ( array (
  2430. 'where' => 'cid=' . $value ['cid'],
  2431. 'asArray' => true
  2432. ) );
  2433. $loanList [$key] ['category'] = $categoryDetil ['title'];
  2434. // 检测编辑状态
  2435. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  2436. $verifyList ['staff'] = $value ['verifyBreakup'];
  2437. else
  2438. $verifyList = $verify->getOne ( array (
  2439. 'where' => 'vid=' . $value ['verify'],
  2440. 'asArray' => true
  2441. ) );
  2442. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2443. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2444. Doo::loadModel ( 'role' );
  2445. $role = new role ();
  2446. $flag = true;
  2447. $roleKey = 0;
  2448. $endStaffArray = array ();
  2449. $roleArrayCopy = array ();
  2450. foreach ( $verifyList as $k => $v ) {
  2451. // init verifyStaff
  2452. if ($v [1] == 'ROLE') {
  2453. if (! empty ( $verifyStaff )) {
  2454. $endStaffArray = end ( $verifyStaff );
  2455. // if ($v[0]==$endStaffArray['nextStaff']){
  2456. // $roleId=$v[0];
  2457. // }
  2458. }
  2459. $roleVerify = json_decode ( $v [3], true );
  2460. $roleKey = $k;
  2461. $roleArray = array ();
  2462. $rolename = $role->getOne ( array (
  2463. 'where' => 'rid=' . $v [0],
  2464. 'asArray' => true
  2465. ) );
  2466. foreach ( $roleVerify as $o => $p ) {
  2467. $staffID = explode ( '_', $p );
  2468. $staffInfo = $staff->getOne ( array (
  2469. 'where' => 'sid=' . $staffID [0],
  2470. 'asArray' => true
  2471. ) );
  2472. // print_r($staffID);
  2473. $exp = array (
  2474. 0 => $staffInfo ['sid'],
  2475. 1 => $staffID [1],
  2476. 2 => $staffInfo ['avatar'],
  2477. 'date' => '',
  2478. 'date' => '',
  2479. 'opinion' => '',
  2480. 'status' => '',
  2481. 'rolename' => $rolename ['name']
  2482. );
  2483. array_push ( $roleArray, $exp );
  2484. }
  2485. $roleArrayCopy [$v [0]] = $roleArray;
  2486. // $verifyList[$k]['roleArray']=$roleArray;
  2487. }
  2488. $verifyList [$k] ['date'] = "";
  2489. $verifyList [$k] ['opinion'] = "";
  2490. $verifyList [$k] ['status'] = "";
  2491. if (empty ( $verifyStaff )) {
  2492. $verifyList [$k] ['date'] = "";
  2493. $verifyList [$k] ['opinion'] = "";
  2494. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2495. $verifyList [$k] ['status'] = 4;
  2496. $flag = false;
  2497. }
  2498. } else {
  2499. foreach ( $verifyStaff as $m => $u ) {
  2500. if ($v [0] == $m) {
  2501. $verifyList [$k] ['date'] = $u ['date'];
  2502. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2503. $verifyList [$k] ['status'] = $u ['status'];
  2504. $flag = false;
  2505. break;
  2506. }
  2507. }
  2508. $endStaffArray = end ( $verifyStaff );
  2509. if (isset ( $endStaffArray ['ROLE'] )) {
  2510. } else {
  2511. // $endKey=key($verifyStaff);
  2512. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2513. // $button=4;
  2514. // $verifyList[$k]['status']=4;
  2515. // }
  2516. }
  2517. }
  2518. }
  2519. $rolename ['name'] = '';
  2520. if (! empty ( $roleId )) {
  2521. Doo::loadModel ( 'role' );
  2522. $role = new role ();
  2523. $rolename = $role->getOne ( array (
  2524. 'where' => 'rid=' . $roleId,
  2525. 'asArray' => true
  2526. ) );
  2527. }
  2528. if (! empty ( $verifyStaff ))
  2529. $endStaffArray = end ( $verifyStaff );
  2530. $KOP = false;
  2531. foreach ( $roleArrayCopy as $P => $A ) {
  2532. foreach ( $A as $MKI => $AVL ) {
  2533. if (! empty ( $verifyStaff )) {
  2534. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2535. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2536. $button = 4;
  2537. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2538. }
  2539. foreach ( $verifyStaff as $m => $u ) {
  2540. $AVLFK = $AVL [0] . '_R';
  2541. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2542. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2543. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2544. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2545. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2546. break;
  2547. }
  2548. }
  2549. } else {
  2550. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2551. $button = 4;
  2552. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2553. }
  2554. }
  2555. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2556. $KOP = true;
  2557. }
  2558. }
  2559. foreach ( $roleArrayCopy as $k => $v ) {
  2560. foreach ( $verifyList as $m => $n ) {
  2561. if ($n [0] == $k) {
  2562. array_splice ( $verifyList, $m, 1, $v );
  2563. }
  2564. }
  2565. }
  2566. $loanList [$key] ['verifyList'] = $verifyList;
  2567. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  2568. 'where' => 'sid=' . $value ['staff'],
  2569. 'asArray' => true
  2570. ) );
  2571. $loanList [$key] ['button'] = $button;
  2572. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  2573. }
  2574. $data ['loanList'] = $loanList;
  2575. // print_r($loanList);
  2576. $Locate = 0;
  2577. $roleId = 0;
  2578. $button = 0;
  2579. foreach ( $receiptList as $key => $value ) {
  2580. $receiptList [$key] ['Locate'] = $Locate;
  2581. $Locate ++;
  2582. $receiptList [$key] ['reviseDetail'] = array ();
  2583. if (! empty ( $value ['reviseDetail'] ))
  2584. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2585. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2586. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2587. $categoryDetil = $Lcategory->getOne ( array (
  2588. 'where' => 'cid=' . $value ['cid'],
  2589. 'asArray' => true
  2590. ) );
  2591. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2592. // 检测编辑状态
  2593. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  2594. $verifyList ['staff'] = $value ['verifyBreakup'];
  2595. } else
  2596. $verifyList = $verify->getOne ( array (
  2597. 'where' => 'vid=' . $value ['verify'],
  2598. 'asArray' => true
  2599. ) );
  2600. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2601. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2602. Doo::loadModel ( 'role' );
  2603. $role = new role ();
  2604. if ($verifyList == NULL)
  2605. $verifyList = array ();
  2606. $flag = true;
  2607. $roleKey = 0;
  2608. $endStaffArray = array ();
  2609. $roleArrayCopy = array ();
  2610. foreach ( $verifyList as $k => $v ) {
  2611. // init verifyStaff
  2612. if ($v [1] == 'ROLE') {
  2613. if (! empty ( $verifyStaff )) {
  2614. $endStaffArray = end ( $verifyStaff );
  2615. // if ($v[0]==$endStaffArray['nextStaff']){
  2616. // $roleId=$v[0];
  2617. // }
  2618. }
  2619. $roleVerify = json_decode ( $v [3], true );
  2620. $roleKey = $k;
  2621. $roleArray = array ();
  2622. $rolename = $role->getOne ( array (
  2623. 'where' => 'rid=' . $v [0],
  2624. 'asArray' => true
  2625. ) );
  2626. foreach ( $roleVerify as $o => $p ) {
  2627. $staffID = explode ( '_', $p );
  2628. $staffInfo = $staff->getOne ( array (
  2629. 'where' => 'sid=' . $staffID [0],
  2630. 'asArray' => true
  2631. ) );
  2632. // print_r($staffID);
  2633. $exp = array (
  2634. 0 => $staffInfo ['sid'],
  2635. 1 => $staffID [1],
  2636. 2 => $staffInfo ['avatar'],
  2637. 'date' => '',
  2638. 'date' => '',
  2639. 'opinion' => '',
  2640. 'status' => '',
  2641. 'rolename' => $rolename ['name']
  2642. );
  2643. array_push ( $roleArray, $exp );
  2644. }
  2645. $roleArrayCopy [$v [0]] = $roleArray;
  2646. // $verifyList[$k]['roleArray']=$roleArray;
  2647. }
  2648. $verifyList [$k] ['date'] = "";
  2649. $verifyList [$k] ['opinion'] = "";
  2650. $verifyList [$k] ['status'] = "";
  2651. if (empty ( $verifyStaff )) {
  2652. $verifyList [$k] ['date'] = "";
  2653. $verifyList [$k] ['opinion'] = "";
  2654. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2655. $verifyList [$k] ['status'] = 4;
  2656. $flag = false;
  2657. }
  2658. } else {
  2659. foreach ( $verifyStaff as $m => $u ) {
  2660. if ($v [0] == $m) {
  2661. $verifyList [$k] ['date'] = $u ['date'];
  2662. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2663. $verifyList [$k] ['status'] = $u ['status'];
  2664. $flag = false;
  2665. break;
  2666. }
  2667. }
  2668. $endStaffArray = end ( $verifyStaff );
  2669. if (isset ( $endStaffArray ['ROLE'] )) {
  2670. } else {
  2671. // $endKey=key($verifyStaff);
  2672. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2673. // $button=4;
  2674. // $verifyList[$k]['status']=4;
  2675. // }
  2676. }
  2677. }
  2678. }
  2679. $rolename ['name'] = '';
  2680. if (! empty ( $roleId )) {
  2681. Doo::loadModel ( 'role' );
  2682. $role = new role ();
  2683. $rolename = $role->getOne ( array (
  2684. 'where' => 'rid=' . $roleId,
  2685. 'asArray' => true
  2686. ) );
  2687. }
  2688. if (! empty ( $verifyStaff ))
  2689. $endStaffArray = end ( $verifyStaff );
  2690. $KOP = false;
  2691. foreach ( $roleArrayCopy as $P => $A ) {
  2692. foreach ( $A as $MKI => $AVL ) {
  2693. if (! empty ( $verifyStaff )) {
  2694. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2695. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2696. $button = 4;
  2697. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2698. }
  2699. foreach ( $verifyStaff as $m => $u ) {
  2700. $AVLFK = $AVL [0] . '_R';
  2701. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2702. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2703. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2704. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2705. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2706. break;
  2707. }
  2708. }
  2709. } else {
  2710. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2711. $button = 4;
  2712. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2713. }
  2714. }
  2715. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2716. $KOP = true;
  2717. }
  2718. }
  2719. foreach ( $roleArrayCopy as $k => $v ) {
  2720. foreach ( $verifyList as $m => $n ) {
  2721. if ($n [0] == $k) {
  2722. array_splice ( $verifyList, $m, 1, $v );
  2723. }
  2724. }
  2725. }
  2726. // 费用执行人相关数据
  2727. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2728. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2729. foreach ( $executeCopy as $k => $v ) {
  2730. $executeCopy [$k] ['date'] = '';
  2731. $executeCopy [$k] ['opinion'] = '';
  2732. $executeCopy [$k] ['status'] = '';
  2733. if (! empty ( $executeStaff ))
  2734. foreach ( $executeStaff as $m => $u ) {
  2735. if ($v [0] == $m) {
  2736. $executeCopy [$k] ['date'] = $u ['date'];
  2737. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2738. $executeCopy [$k] ['status'] = $u ['status'];
  2739. break;
  2740. }
  2741. }
  2742. }
  2743. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2744. $receiptList [$key] ['verifyList'] = $verifyList;
  2745. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2746. 'where' => 'sid=' . $value ['staff'],
  2747. 'asArray' => true
  2748. ) );
  2749. $receiptList [$key] ['button'] = $button;
  2750. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2751. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2752. $relust = $value ['sum'] - $value ['loanSum'];
  2753. $receiptList [$key] ['relust'] = $relust;
  2754. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2755. }
  2756. // print_r($receiptList);
  2757. // 获取审批日志
  2758. Doo::loadModel ( 'receiptLog' );
  2759. $receiptLog = new receiptLog ();
  2760. $rlList = array ();
  2761. $rlInfo = $receiptLog->getOne ( array (
  2762. 'where' => 'rid=' . $rid . ' and status=4',
  2763. 'asArray' => true
  2764. ) );
  2765. $tijdate = $receiptLog->getOne ( array (
  2766. 'where' => 'rid=' . $rid . ' and status=2',
  2767. 'asc' => 'rlid',
  2768. 'asArray' => true
  2769. ) );
  2770. if (! empty ( $rlInfo )) {
  2771. $rlList = $receiptLog->find ( array (
  2772. 'where' => 'rid=' . $rid,
  2773. 'asc' => 'rlid',
  2774. 'asArray' => true
  2775. ) );
  2776. }
  2777. Doo::loadModel ( 'enclosur' );
  2778. $enclosur = new enclosur ();
  2779. $enclosurList = $enclosur->find ( array (
  2780. 'where' => 'rid=' . $rid,
  2781. 'asArray' => true
  2782. ) );
  2783. $enclosurHtml = '';
  2784. foreach ( $enclosurList as $value ) {
  2785. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2786. }
  2787. $data ['enclosurHtml'] = $enclosurHtml;
  2788. $receiptList [0] ['rlList'] = $rlList;
  2789. $data ['receiptList'] = $receiptList;
  2790. $data ['memu'] = "receipt";
  2791. $data ['staff'] = $this->staff;
  2792. $data ['receiptMemu'] = 'approvalExpenses';
  2793. $data ['verifyId'] = $this->verifyId;
  2794. $data ['executeId'] = $this->executeId;
  2795. $this->render ( "/admin/expensesDoc", $data );
  2796. }
  2797. function expensesEdi() {
  2798. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2799. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  2800. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2801. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2802. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2803. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2804. if (empty ( $status ))
  2805. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  2806. $vidList = array ();
  2807. $button = 0;
  2808. Doo::loadModel ( 'verify' );
  2809. Doo::loadModel ( 'receipt' );
  2810. Doo::loadModel ( 'staff' );
  2811. $staff = new staff ();
  2812. $receipt = new receipt ();
  2813. $verify = new verify ();
  2814. Doo::loadModel ( 'L_category' );
  2815. $Lcategory = new L_category ();
  2816. Doo::loadModel ( 'enclosur' );
  2817. $enclosur = new enclosur ();
  2818. // user verify ID
  2819. $verifyDetail = $verify->find ( array (
  2820. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  2821. 'asArray' => true
  2822. ) );
  2823. foreach ( $verifyDetail as $key => $value ) {
  2824. array_push ( $vidList, $value ['vid'] );
  2825. }
  2826. $vid = implode ( ",", $vidList );
  2827. if (empty ( $verifyDetail ))
  2828. $vid = 0;
  2829. $categoryList = $Lcategory->find ( array (
  2830. 'asArray' => true
  2831. ) );
  2832. $staffList = $staff->find ( array (
  2833. 'where' => 'cid=' . $cid,
  2834. 'asArray' => true
  2835. ) );
  2836. $ap = "";
  2837. if ($status == 4) {
  2838. $ap = 4;
  2839. $status = 2;
  2840. }
  2841. // get Receipt By verifyID status 2
  2842. $receiptList = $receipt->find ( array (
  2843. 'where' => 'rid =' . $rid.' and status=2',
  2844. 'desc' => 'rid',
  2845. 'asArray' => true
  2846. ) );
  2847. if (empty($receiptList)){
  2848. die ( 'illegal request' );
  2849. }
  2850. $Locate = 0;
  2851. $roleId = 0;
  2852. if ($ap == 4)
  2853. $status = 4;
  2854. foreach ( $receiptList as $key => $value ) {
  2855. $receiptList [$key] ['Locate'] = $Locate;
  2856. $Locate ++;
  2857. $receiptList [$key] ['reviseDetail'] = array ();
  2858. if (! empty ( $value ['reviseDetail'] ))
  2859. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2860. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2861. $categoryDetil = $Lcategory->getOne ( array (
  2862. 'where' => 'cid=' . $value ['cid'],
  2863. 'asArray' => true
  2864. ) );
  2865. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2866. // 检测编辑状态
  2867. $verifyList = $verify->getOne ( array (
  2868. 'where' => 'vid=' . $value ['verify'],
  2869. 'asArray' => true
  2870. ) );
  2871. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2872. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2873. Doo::loadModel ( 'role' );
  2874. $role = new role ();
  2875. // print_r($verifyList);
  2876. $flag = true;
  2877. $roleKey = 0;
  2878. $endStaffArray = array ();
  2879. $roleArrayCopy = array ();
  2880. foreach ( $verifyList as $k => $v ) {
  2881. // init verifyStaff
  2882. if ($v [1] == 'ROLE') {
  2883. if (! empty ( $verifyStaff )) {
  2884. $endStaffArray = end ( $verifyStaff );
  2885. if ($v [0] == $endStaffArray ['nextStaff']) {
  2886. $roleId = $v [0];
  2887. }
  2888. }
  2889. $roleVerify = json_decode ( $v [3], true );
  2890. $roleKey = $k;
  2891. $roleArray = array ();
  2892. $rolename = $role->getOne ( array (
  2893. 'where' => 'rid=' . $v [0],
  2894. 'asArray' => true
  2895. ) );
  2896. foreach ( $roleVerify as $o => $p ) {
  2897. $staffID = explode ( '_', $p );
  2898. $staffInfo = $staff->getOne ( array (
  2899. 'where' => 'sid=' . $staffID [0],
  2900. 'asArray' => true
  2901. ) );
  2902. // print_r($staffID);
  2903. $exp = array (
  2904. 0 => $staffInfo ['sid'],
  2905. 1 => $staffID [1],
  2906. 2 => $staffInfo ['avatar'],
  2907. 'date' => '',
  2908. 'date' => '',
  2909. 'opinion' => '',
  2910. 'status' => '',
  2911. 'rolename' => $rolename ['name']
  2912. );
  2913. array_push ( $roleArray, $exp );
  2914. }
  2915. $roleArrayCopy [$v [0]] = $roleArray;
  2916. // $verifyList[$k]['roleArray']=$roleArray;
  2917. }
  2918. // print_r($roleArray);
  2919. $verifyList [$k] ['date'] = "";
  2920. $verifyList [$k] ['opinion'] = "";
  2921. $verifyList [$k] ['status'] = "";
  2922. if (empty ( $verifyStaff )) {
  2923. $verifyList [$k] ['date'] = "";
  2924. $verifyList [$k] ['opinion'] = "";
  2925. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2926. $verifyList [$k] ['status'] = 4;
  2927. $button = 4;
  2928. $flag = false;
  2929. }
  2930. } else {
  2931. foreach ( $verifyStaff as $m => $u ) {
  2932. if ($v [0] == $m) {
  2933. $verifyList [$k] ['date'] = $u ['date'];
  2934. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2935. $verifyList [$k] ['status'] = $u ['status'];
  2936. $flag = false;
  2937. break;
  2938. }
  2939. }
  2940. $endStaffArray = end ( $verifyStaff );
  2941. if (isset ( $endStaffArray ['ROLE'] )) {
  2942. } else {
  2943. $endKey = key ( $verifyStaff );
  2944. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  2945. $button = 4;
  2946. $verifyList [$k] ['status'] = 4;
  2947. }
  2948. }
  2949. }
  2950. }
  2951. $rolename ['name'] = '';
  2952. if (! empty ( $roleId )) {
  2953. Doo::loadModel ( 'role' );
  2954. $role = new role ();
  2955. $rolename = $role->getOne ( array (
  2956. 'where' => 'rid=' . $roleId,
  2957. 'asArray' => true
  2958. ) );
  2959. }
  2960. if (! empty ( $verifyStaff ))
  2961. $endStaffArray = end ( $verifyStaff );
  2962. $KOP = false;
  2963. foreach ( $roleArrayCopy as $P => $A ) {
  2964. foreach ( $A as $MKI => $AVL ) {
  2965. if (! empty ( $verifyStaff )) {
  2966. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2967. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2968. $button = 4;
  2969. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2970. }
  2971. foreach ( $verifyStaff as $m => $u ) {
  2972. $AVLFK = $AVL [0] . '_R';
  2973. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2974. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2975. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2976. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2977. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2978. break;
  2979. }
  2980. }
  2981. } else {
  2982. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2983. $button = 4;
  2984. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2985. }
  2986. }
  2987. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2988. $KOP = true;
  2989. }
  2990. }
  2991. // print_r($roleArrayCopy);
  2992. // echo $roleKey;
  2993. foreach ( $roleArrayCopy as $k => $v ) {
  2994. foreach ( $verifyList as $m => $n ) {
  2995. if ($n [0] == $k) {
  2996. array_splice ( $verifyList, $m, 1, $v );
  2997. }
  2998. }
  2999. }
  3000. $receiptList [$key] ['verifyList'] = $verifyList;
  3001. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3002. 'where' => 'sid=' . $value ['staff'],
  3003. 'asArray' => true
  3004. ) );
  3005. $receiptList [$key] ['button'] = $button;
  3006. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  3007. }
  3008. // $data['verifyDetail']=$verifyDetail;
  3009. $mothHtml = "";
  3010. for($i = 1; $i <= 12; $i ++) {
  3011. if ($month == $i)
  3012. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3013. else
  3014. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3015. }
  3016. // 获取审批日志
  3017. Doo::loadModel ( 'receiptLog' );
  3018. $receiptLog = new receiptLog ();
  3019. $rlList = array ();
  3020. $rlInfo = $receiptLog->getOne ( array (
  3021. 'where' => 'rid=' . $rid . ' and status=4',
  3022. 'asArray' => true
  3023. ) );
  3024. $tijdate = $receiptLog->getOne ( array (
  3025. 'where' => 'rid=' . $rid . ' and status=2',
  3026. 'asc' => 'rlid',
  3027. 'asArray' => true
  3028. ) );
  3029. if (! empty ( $rlInfo )) {
  3030. $rlList = $receiptLog->find ( array (
  3031. 'where' => 'rid=' . $rid,
  3032. 'asc' => 'rlid',
  3033. 'asArray' => true
  3034. ) );
  3035. }
  3036. $receiptList [0] ['rlList'] = $rlList;
  3037. $enclosurList = $enclosur->find ( array (
  3038. 'where' => 'rid=' . $rid,
  3039. 'asArray' => true
  3040. ) );
  3041. $enclosurHtml = '';
  3042. foreach ( $enclosurList as $value ) {
  3043. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3044. }
  3045. // print_r($receiptList);
  3046. $data ['rid'] = $rid;
  3047. $data ['enclosurHtml'] = $enclosurHtml;
  3048. $data ['rolename'] = $rolename ['name'];
  3049. $data ['datetij'] = $tijdate ['date'];
  3050. $data ['mothHtml'] = $mothHtml;
  3051. $data ['receiptList'] = $receiptList;
  3052. $data ['receiptApprovalCount'] = count ( $receiptList );
  3053. $data ['status'] = $status;
  3054. $data ['year'] = $year;
  3055. $data ['categoryList'] = $categoryList;
  3056. $data ['staffList'] = $staffList;
  3057. $data ['cid'] = $cid;
  3058. $data ['sid'] = $sid;
  3059. $data ['ap'] = $ap;
  3060. $data ['memu'] = "receipt";
  3061. $data ['staff'] = $this->staff;
  3062. $data ['receiptMemu'] = 'approvalExpenses';
  3063. $data ['verifyId'] = $this->verifyId;
  3064. $data ['executeId'] = $this->executeId;
  3065. $this->render ( "/admin/expensesEdi", $data );
  3066. }
  3067. function expensesDefray() {
  3068. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3069. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3070. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3071. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  3072. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  3073. if (! empty ( $rid )) {
  3074. Doo::loadModel ( "verify" );
  3075. $verify = new verify ();
  3076. Doo::loadModel ( "receiptDetail" );
  3077. $receiptDetailObj = new receiptDetail ();
  3078. Doo::loadModel ( "itemStatistics" );
  3079. Doo::loadModel ( "statistics" );
  3080. $statistics = new statistics ();
  3081. $itemStatistics = new itemStatistics ();
  3082. Doo::loadModel ( "receipt" );
  3083. $receipt = new receipt ();
  3084. Doo::loadModel ( "loanReceipt" );
  3085. $loanReceipt = new loanReceipt ();
  3086. $receiptDetail = $receipt->getOne ( array (
  3087. 'where' => 'rid=' . $rid . ' and status=2 ',
  3088. 'asArray' => true
  3089. ) );
  3090. if (empty ( $receiptDetail )||$receiptDetail['nowStaff']!=$this->staff['0']['sid'])
  3091. return "/approvalExpenses/pendApproval";
  3092. $verifyDetail = $verify->getOne ( array (
  3093. 'where' => ' vid =' . $receiptDetail ['verify'],
  3094. 'asArray' => true
  3095. ) );
  3096. $verifyString = $verifyDetail ['staff'];
  3097. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3098. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  3099. if (empty ( $opinion )) {
  3100. if ($status == 3)
  3101. $opinion = "终止";
  3102. else
  3103. $opinion = "同意支付";
  3104. }
  3105. $nowStaff = 0;
  3106. $nowStaffList = array ();
  3107. if (empty ( $verifyStaff )) {
  3108. // 还需加入是否已经进入角色审批
  3109. if ($verifyDetail [0] [1] == 'ROLE') {
  3110. // print_r($verifyDetail);echo "ddd";
  3111. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3112. foreach ( $vStaffString as $key => $value ) {
  3113. $staffK = explode ( "_", $value );
  3114. if ($staffK [0] != $this->staff [0] ['sid'])
  3115. array_push ( $nowStaffList, $staffK [0] );
  3116. }
  3117. // print_r($verifyDetail);
  3118. // die;
  3119. if (! empty ( $nowStaffList )) {
  3120. $nowStaff = implode ( ',', $nowStaffList );
  3121. $verifyStaff = array (
  3122. $this->staff [0] ['sid'] . "_R" => array (
  3123. 'date' => date ( 'Y-m-d' ),
  3124. 'opinion' => $opinion,
  3125. 'status' => $status,
  3126. 'nextStaff' => $verifyDetail [0] [0],
  3127. 'ROLE' => 1
  3128. )
  3129. );
  3130. } else {
  3131. $nowStaff = $verifyDetail [1] [0];
  3132. $verifyStaff = array (
  3133. $this->staff [0] ['sid'] . "_R" => array (
  3134. 'date' => date ( 'Y-m-d' ),
  3135. 'opinion' => $opinion,
  3136. 'status' => $status,
  3137. 'nextStaff' => $verifyDetail [1] [0]
  3138. )
  3139. );
  3140. }
  3141. } else {
  3142. if ($verifyDetail [1] [1] == 'ROLE') {
  3143. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  3144. // echo "dd";
  3145. foreach ( $vStaffString as $key => $value ) {
  3146. $staffK = explode ( "_", $value );
  3147. array_push ( $nowStaffList, $staffK [0] );
  3148. }
  3149. $nowStaff = implode ( ',', $nowStaffList );
  3150. $verifyStaff = array (
  3151. $this->staff [0] ['sid'] => array (
  3152. 'date' => date ( 'Y-m-d' ),
  3153. 'opinion' => $opinion,
  3154. 'status' => $status,
  3155. 'nextStaff' => $verifyDetail [1] [0],
  3156. 'ROLE' => 1
  3157. )
  3158. );
  3159. } else {
  3160. $nowStaff = $verifyDetail [1] [0];
  3161. $verifyStaff = array (
  3162. $this->staff [0] ['sid'] => array (
  3163. 'date' => date ( 'Y-m-d' ),
  3164. 'opinion' => $opinion,
  3165. 'status' => $status,
  3166. 'nextStaff' => $verifyDetail [1] [0]
  3167. )
  3168. );
  3169. }
  3170. }
  3171. if ($status == 3)
  3172. $verifyStaff = array (
  3173. 'final' => $status,
  3174. $this->staff [0] ['sid'] => array (
  3175. 'date' => date ( 'Y-m-d' ),
  3176. 'opinion' => $opinion,
  3177. 'status' => $status
  3178. )
  3179. );
  3180. $vStaffString = json_encode ( $verifyStaff );
  3181. $receipt->nowStaff = $nowStaff;
  3182. $receipt->verifyStaff = $vStaffString;
  3183. $loanReceipt->nowStaff = $nowStaff;
  3184. $loanReceipt->verifyStaff = $vStaffString;
  3185. } else {
  3186. $VS = end ( $verifyStaff );
  3187. // 非角色审批
  3188. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  3189. $nextStaff = 0;
  3190. $roleSTF = false;
  3191. foreach ( $verifyDetail as $key => $value ) {
  3192. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  3193. if (isset ( $verifyDetail [$key + 1] )) {
  3194. $nextStaff = $verifyDetail [$key + 1] [0];
  3195. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  3196. $roleSTF = true;
  3197. }
  3198. break;
  3199. }
  3200. }
  3201. if (! $roleSTF) {
  3202. $nowStaff = $nextStaff;
  3203. $verifyStaff [$this->staff [0] ['sid']] = array (
  3204. 'date' => date ( 'Y-m-d' ),
  3205. 'opinion' => $opinion,
  3206. 'status' => $status,
  3207. 'nextStaff' => $nextStaff
  3208. );
  3209. } else {
  3210. // 获取角色下的所有用户ID
  3211. $nowStaffList = array ();
  3212. foreach ( $verifyDetail as $vfk ) {
  3213. if ($vfk [1] == 'ROLE') {
  3214. $vStaffString = json_decode ( $vfk [3] );
  3215. foreach ( $vStaffString as $key => $value ) {
  3216. $staffK = explode ( "_", $value );
  3217. array_push ( $nowStaffList, $staffK [0] );
  3218. }
  3219. }
  3220. }
  3221. $nowStaff = implode ( ',', $nowStaffList );
  3222. $verifyStaff [$this->staff [0] ['sid']] = array (
  3223. 'date' => date ( 'Y-m-d' ),
  3224. 'opinion' => $opinion,
  3225. 'status' => $status,
  3226. 'nextStaff' => $nextStaff,
  3227. 'ROLE' => 0
  3228. );
  3229. }
  3230. if ($status == 3) {
  3231. $verifyStaff ['final'] = $status;
  3232. $verifyStaff [$this->staff [0] ['sid']] = array (
  3233. 'date' => date ( 'Y-m-d' ),
  3234. 'opinion' => $opinion,
  3235. 'status' => $status
  3236. );
  3237. }
  3238. $vStaffString = json_encode ( $verifyStaff );
  3239. $receipt->nowStaff = $nowStaff;
  3240. $receipt->verifyStaff = $vStaffString;
  3241. $loanReceipt->nowStaff = $nowStaff;
  3242. $loanReceipt->verifyStaff = $vStaffString;
  3243. }
  3244. // 角色审批
  3245. if (isset ( $VS ['ROLE'] )) {
  3246. // 找出角色人 当前审批角色组
  3247. $verifyJSStaff = array ();
  3248. $nowStaffList2 = array ();
  3249. foreach ( $verifyDetail as $key => $value ) {
  3250. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  3251. $verifyJSStaff = json_decode ( $value [3] );
  3252. foreach ( $verifyJSStaff as $m ) {
  3253. $staffK = explode ( "_", $m );
  3254. array_push ( $nowStaffList2, $staffK [0] );
  3255. }
  3256. // print_r($nowStaffList2);
  3257. }
  3258. }
  3259. $RoleVerifyStaff = array ();
  3260. foreach ( $verifyStaff as $key => $value ) {
  3261. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  3262. foreach ( $nowStaffList2 as $m ) {
  3263. if ($key == $m . "_R")
  3264. $RoleVerifyStaff [$key] = $value;
  3265. }
  3266. }
  3267. }
  3268. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  3269. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  3270. // 下一个审批人ID
  3271. $nextStaff = 0;
  3272. $falg = false;
  3273. foreach ( $verifyDetail as $key => $value ) {
  3274. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  3275. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  3276. $falg = true;
  3277. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  3278. $nowStaffList = array ();
  3279. foreach ( $vStaffString as $v ) {
  3280. $staffK = explode ( "_", $v );
  3281. array_push ( $nowStaffList, $staffK [0] );
  3282. }
  3283. $nowStaff = implode ( ',', $nowStaffList );
  3284. $nextStaff = $verifyDetail [$key + 1] [0];
  3285. } elseif (isset ( $verifyDetail [$key + 1] )) {
  3286. $nextStaff = $verifyDetail [$key + 1] [0];
  3287. $nowStaff = $nextStaff;
  3288. } else
  3289. $nowStaff = '';
  3290. break;
  3291. }
  3292. }
  3293. if ($falg)
  3294. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3295. 'date' => date ( 'Y-m-d' ),
  3296. 'opinion' => $opinion,
  3297. 'status' => $status,
  3298. 'nextStaff' => $nextStaff,
  3299. 'ROLE' => 1
  3300. );
  3301. else
  3302. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3303. 'date' => date ( 'Y-m-d' ),
  3304. 'opinion' => $opinion,
  3305. 'status' => $status,
  3306. 'nextStaff' => $nextStaff
  3307. );
  3308. // print_r($verifyStaff);
  3309. // echo $nowStaff;die;
  3310. } else { // 进入下一个角色或者审批人
  3311. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  3312. //
  3313. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  3314. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3315. 'date' => date ( 'Y-m-d' ),
  3316. 'opinion' => $opinion,
  3317. 'status' => $status,
  3318. 'nextStaff' => $VS ['nextStaff'],
  3319. 'ROLE' => 1
  3320. );
  3321. // print_r($verifyStaff);
  3322. // die;
  3323. }
  3324. if ($status == 3) {
  3325. $verifyStaff ['final'] = $status;
  3326. $verifyStaff [$this->staff [0] ['sid']] = array (
  3327. 'date' => date ( 'Y-m-d' ),
  3328. 'opinion' => $opinion,
  3329. 'status' => $status
  3330. );
  3331. }
  3332. $vStaffString = json_encode ( $verifyStaff );
  3333. $receipt->verifyStaff = $vStaffString;
  3334. $receipt->nowStaff = $nowStaff;
  3335. $loanReceipt->nowStaff = $nowStaff;
  3336. $loanReceipt->verifyStaff = $vStaffString;
  3337. // die;
  3338. // }
  3339. // print_r($verifyStaff);
  3340. // die;
  3341. }
  3342. // print_r($verifyStaff);die;
  3343. }
  3344. // print_r($verifyDetail);
  3345. $roleKey = 0;
  3346. $roleId = 0;
  3347. $verifyDetailCopy = array ();
  3348. foreach ( $verifyDetail as $k => $v ) {
  3349. if ($v [1] == 'ROLE') {
  3350. $roleId = $v [0];
  3351. $roleVerify = json_decode ( $v [3], true );
  3352. $roleKey = $k;
  3353. $roleArray = array ();
  3354. foreach ( $roleVerify as $o => $p ) {
  3355. $staffID = explode ( '_', $p );
  3356. $exp = array (
  3357. 0 => $staffID [0],
  3358. 1 => $staffID [1]
  3359. );
  3360. array_push ( $roleArray, $exp );
  3361. }
  3362. $verifyDetailCopy [$v [0]] = $roleArray;
  3363. }
  3364. }
  3365. // print_r($verifyDetail);
  3366. foreach ( $verifyDetailCopy as $k => $v ) {
  3367. foreach ( $verifyDetail as $m => $n ) {
  3368. if ($n [0] == $k) {
  3369. array_splice ( $verifyDetail, $m, 1, $v );
  3370. }
  3371. }
  3372. }
  3373. // 审批日志
  3374. if (! isset ( $verifyStaff ['final'] )) {
  3375. Doo::loadModel ( "receiptLog" );
  3376. $receiptLog = new receiptLog ();
  3377. if (! empty ( $roleId )) {
  3378. Doo::loadModel ( "role" );
  3379. $role = new role ();
  3380. $roleInfo = $role->getOne ( array (
  3381. 'where' => 'rid=' . $roleId,
  3382. 'asArray' => true
  3383. ) );
  3384. $receiptLog->rolename = $roleInfo ['name'];
  3385. }
  3386. $receiptLog->username = $this->staff [0] ['username'];
  3387. $receiptLog->uid = $this->staff [0] ['sid'];
  3388. $receiptLog->date = date ( "Y-m-d" );
  3389. $receiptLog->opinion = $opinion;
  3390. $receiptLog->img = $this->staff [0] ['avatar'];
  3391. $receiptLog->status = 1;
  3392. $receiptLog->rid = $rid;
  3393. $receiptLog->insert ();
  3394. }
  3395. if (isset ( $verifyStaff ['final'] )) { // rDetail
  3396. $receipt->status = 3;
  3397. $receipt->verifyBreakup = $verifyString;
  3398. $receiptDetailObj->status = 3;
  3399. $receiptDetailObj->update ( array (
  3400. 'where' => 'rid=' . $rid
  3401. ) );
  3402. // 微信企业号通知
  3403. $this->setWXMsg ( $rid, 3 );
  3404. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  3405. $receipt->status = 6;
  3406. $receipt->pastDate = date ( "Y-m-d" );
  3407. $receipt->isBK = 1;
  3408. $loanReceipt->verifyBreakup = $verifyString;
  3409. $loanReceipt->status = 1;
  3410. $loanReceipt->pastDate = date ( "Y-m-d" );
  3411. $loanReceipt->amount = $receiptDetail ['amount'];
  3412. $loanReceipt->update ( array (
  3413. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  3414. ) );
  3415. // 微信企业号通知
  3416. $this->setWXMsg ( $rid, 1 );
  3417. }
  3418. $receipt->amount = $amount;
  3419. $receipt->update ( array (
  3420. 'where' => ' rid = ' . $rid
  3421. ) );
  3422. return "/approvalExpenses/pendApproval";
  3423. }
  3424. }
  3425. function ajaxExamineExe() {
  3426. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3427. Doo::loadModel ( 'receipt' );
  3428. $receipt = new receipt ();
  3429. Doo::loadClass ( 'XDeode' );
  3430. $XDeode = new XDeode ( 5 );
  3431. if (! empty ( $rid )) {
  3432. $rLRes = $receipt->find ( array (
  3433. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  3434. 'asArray' => true
  3435. ) );
  3436. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  3437. echo json_encode ( array (
  3438. 'status' => 1,
  3439. 'receipt' => $rLRes [0]
  3440. ) );
  3441. die ();
  3442. }
  3443. echo json_encode ( array (
  3444. 'status' => 0,
  3445. 'receipt' => array ()
  3446. ) );
  3447. die ();
  3448. }
  3449. function implement() {
  3450. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3451. Doo::loadClass ( 'XDeode' );
  3452. $XDeode = new XDeode ( 5 );
  3453. Doo::loadModel ( 'receipt' );
  3454. $receipt = new receipt ();
  3455. Doo::loadModel ( 'L_category' );
  3456. $Lcategory = new L_category ();
  3457. Doo::loadModel ( 'verify' );
  3458. $verify = new verify ();
  3459. Doo::loadModel ( 'staff' );
  3460. $staff = new staff ();
  3461. Doo::loadModel ( "execute" );
  3462. $execute = new execute ();
  3463. $rid = $XDeode->decode ( $rid );
  3464. $receiptList = $receipt->find ( array (
  3465. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  3466. 'desc' => 'rid',
  3467. 'asArray' => true
  3468. ) );
  3469. Doo::loadModel ( 'loanReceipt' );
  3470. $loanReceipt = new loanReceipt ();
  3471. // print_r($receiptList);
  3472. $loanList = array ();
  3473. if (! isset ( $receiptList ))
  3474. $loanList = $loanReceipt->find ( array (
  3475. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3476. 'desc' => 'rid',
  3477. 'asArray' => true
  3478. ) );
  3479. $Locate = 0;
  3480. $roleId = 0;
  3481. $button = 0;
  3482. foreach ( $loanList as $key => $value ) {
  3483. $loanList [$key] ['Locate'] = $Locate;
  3484. $Locate ++;
  3485. $loanList [$key] ['reviseDetail'] = array ();
  3486. if (! empty ( $value ['reviseDetail'] ))
  3487. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3488. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3489. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3490. $categoryDetil = $Lcategory->getOne ( array (
  3491. 'where' => 'cid=' . $value ['cid'],
  3492. 'asArray' => true
  3493. ) );
  3494. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3495. // 检测编辑状态
  3496. $verifyList = $verify->getOne ( array (
  3497. 'where' => 'vid=' . $value ['verify'],
  3498. 'asArray' => true
  3499. ) );
  3500. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3501. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3502. Doo::loadModel ( 'role' );
  3503. $role = new role ();
  3504. $flag = true;
  3505. $roleKey = 0;
  3506. $endStaffArray = array ();
  3507. $roleArrayCopy = array ();
  3508. foreach ( $verifyList as $k => $v ) {
  3509. // init verifyStaff
  3510. if ($v [1] == 'ROLE') {
  3511. if (! empty ( $verifyStaff )) {
  3512. $endStaffArray = end ( $verifyStaff );
  3513. // if ($v[0]==$endStaffArray['nextStaff']){
  3514. // $roleId=$v[0];
  3515. // }
  3516. }
  3517. $roleVerify = json_decode ( $v [3], true );
  3518. $roleKey = $k;
  3519. $roleArray = array ();
  3520. $rolename = $role->getOne ( array (
  3521. 'where' => 'rid=' . $v [0],
  3522. 'asArray' => true
  3523. ) );
  3524. foreach ( $roleVerify as $o => $p ) {
  3525. $staffID = explode ( '_', $p );
  3526. $staffInfo = $staff->getOne ( array (
  3527. 'where' => 'sid=' . $staffID [0],
  3528. 'asArray' => true
  3529. ) );
  3530. // print_r($staffID);
  3531. $exp = array (
  3532. 0 => $staffInfo ['sid'],
  3533. 1 => $staffID [1],
  3534. 2 => $staffInfo ['avatar'],
  3535. 'date' => '',
  3536. 'date' => '',
  3537. 'opinion' => '',
  3538. 'status' => '',
  3539. 'rolename' => $rolename ['name']
  3540. );
  3541. array_push ( $roleArray, $exp );
  3542. }
  3543. $roleArrayCopy [$v [0]] = $roleArray;
  3544. // $verifyList[$k]['roleArray']=$roleArray;
  3545. }
  3546. $verifyList [$k] ['date'] = "";
  3547. $verifyList [$k] ['opinion'] = "";
  3548. $verifyList [$k] ['status'] = "";
  3549. if (empty ( $verifyStaff )) {
  3550. $verifyList [$k] ['date'] = "";
  3551. $verifyList [$k] ['opinion'] = "";
  3552. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3553. $verifyList [$k] ['status'] = 4;
  3554. $flag = false;
  3555. }
  3556. } else {
  3557. foreach ( $verifyStaff as $m => $u ) {
  3558. if ($v [0] == $m) {
  3559. $verifyList [$k] ['date'] = $u ['date'];
  3560. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3561. $verifyList [$k] ['status'] = $u ['status'];
  3562. $flag = false;
  3563. break;
  3564. }
  3565. }
  3566. $endStaffArray = end ( $verifyStaff );
  3567. if (isset ( $endStaffArray ['ROLE'] )) {
  3568. } else {
  3569. // $endKey=key($verifyStaff);
  3570. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3571. // $button=4;
  3572. // $verifyList[$k]['status']=4;
  3573. // }
  3574. }
  3575. }
  3576. }
  3577. $rolename ['name'] = '';
  3578. if (! empty ( $roleId )) {
  3579. Doo::loadModel ( 'role' );
  3580. $role = new role ();
  3581. $rolename = $role->getOne ( array (
  3582. 'where' => 'rid=' . $roleId,
  3583. 'asArray' => true
  3584. ) );
  3585. }
  3586. if (! empty ( $verifyStaff ))
  3587. $endStaffArray = end ( $verifyStaff );
  3588. $KOP = false;
  3589. foreach ( $roleArrayCopy as $P => $A ) {
  3590. foreach ( $A as $MKI => $AVL ) {
  3591. if (! empty ( $verifyStaff )) {
  3592. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3593. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3594. $button = 4;
  3595. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3596. }
  3597. foreach ( $verifyStaff as $m => $u ) {
  3598. $AVLFK = $AVL [0] . '_R';
  3599. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3600. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3601. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3602. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3603. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3604. break;
  3605. }
  3606. }
  3607. } else {
  3608. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3609. $button = 4;
  3610. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3611. }
  3612. }
  3613. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3614. $KOP = true;
  3615. }
  3616. }
  3617. foreach ( $roleArrayCopy as $k => $v ) {
  3618. foreach ( $verifyList as $m => $n ) {
  3619. if ($n [0] == $k) {
  3620. array_splice ( $verifyList, $m, 1, $v );
  3621. }
  3622. }
  3623. }
  3624. $loanList [$key] ['verifyList'] = $verifyList;
  3625. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3626. 'where' => 'sid=' . $value ['staff'],
  3627. 'asArray' => true
  3628. ) );
  3629. }
  3630. $data ['loanList'] = $loanList;
  3631. $Locate = 0;
  3632. $roleId = 0;
  3633. $button = 0;
  3634. foreach ( $receiptList as $key => $value ) {
  3635. $button2 = 0;
  3636. $receiptList [$key] ['Locate'] = $Locate;
  3637. $Locate ++;
  3638. $receiptList [$key] ['reviseDetail'] = array ();
  3639. if (! empty ( $value ['reviseDetail'] ))
  3640. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3641. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3642. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3643. $categoryDetil = $Lcategory->getOne ( array (
  3644. 'where' => 'cid=' . $value ['cid'],
  3645. 'asArray' => true
  3646. ) );
  3647. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3648. $executeList = json_decode ( $value ['executeCopy'], true );
  3649. $executeStaff = array ();
  3650. if (! empty ( $value ['executeStaff'] ))
  3651. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3652. if (isset ( $executeList )) {
  3653. foreach ( $executeList as $op => $lo ) {
  3654. $executeList [$op] ['date'] = "";
  3655. $executeList [$op] ['opinion'] = "";
  3656. $executeList [$op] ['status'] = "";
  3657. foreach ( $executeStaff as $m => $u ) {
  3658. if ($lo [0] == $m) {
  3659. $executeList [$op] ['date'] = $u ['date'];
  3660. $executeList [$op] ['opinion'] = $u ['opinion'];
  3661. $executeList [$op] ['status'] = $u ['status'];
  3662. break;
  3663. }
  3664. }
  3665. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  3666. $button2 = 1;
  3667. $executeList [$op] ['status'] = 4;
  3668. }
  3669. }
  3670. }
  3671. // 检测编辑状态
  3672. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3673. $verifyList ['staff'] = $value ['verifyBreakup'];
  3674. } else
  3675. $verifyList = $verify->getOne ( array (
  3676. 'where' => 'vid=' . $value ['verify'],
  3677. 'asArray' => true
  3678. ) );
  3679. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3680. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3681. Doo::loadModel ( 'role' );
  3682. $role = new role ();
  3683. if ($verifyList == NULL)
  3684. $verifyList = array ();
  3685. $flag = true;
  3686. $roleKey = 0;
  3687. $endStaffArray = array ();
  3688. $roleArrayCopy = array ();
  3689. foreach ( $verifyList as $k => $v ) {
  3690. // init verifyStaff
  3691. if ($v [1] == 'ROLE') {
  3692. if (! empty ( $verifyStaff )) {
  3693. $endStaffArray = end ( $verifyStaff );
  3694. // if ($v[0]==$endStaffArray['nextStaff']){
  3695. // $roleId=$v[0];
  3696. // }
  3697. }
  3698. $roleVerify = json_decode ( $v [3], true );
  3699. $roleKey = $k;
  3700. $roleArray = array ();
  3701. $rolename = $role->getOne ( array (
  3702. 'where' => 'rid=' . $v [0],
  3703. 'asArray' => true
  3704. ) );
  3705. foreach ( $roleVerify as $o => $p ) {
  3706. $staffID = explode ( '_', $p );
  3707. $staffInfo = $staff->getOne ( array (
  3708. 'where' => 'sid=' . $staffID [0],
  3709. 'asArray' => true
  3710. ) );
  3711. // print_r($staffID);
  3712. $exp = array (
  3713. 0 => $staffInfo ['sid'],
  3714. 1 => $staffID [1],
  3715. 2 => $staffInfo ['avatar'],
  3716. 'date' => '',
  3717. 'date' => '',
  3718. 'opinion' => '',
  3719. 'status' => '',
  3720. 'rolename' => $rolename ['name']
  3721. );
  3722. array_push ( $roleArray, $exp );
  3723. }
  3724. $roleArrayCopy [$v [0]] = $roleArray;
  3725. // $verifyList[$k]['roleArray']=$roleArray;
  3726. }
  3727. $verifyList [$k] ['date'] = "";
  3728. $verifyList [$k] ['opinion'] = "";
  3729. $verifyList [$k] ['status'] = "";
  3730. if (empty ( $verifyStaff )) {
  3731. $verifyList [$k] ['date'] = "";
  3732. $verifyList [$k] ['opinion'] = "";
  3733. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3734. $verifyList [$k] ['status'] = 4;
  3735. $flag = false;
  3736. }
  3737. } else {
  3738. foreach ( $verifyStaff as $m => $u ) {
  3739. if ($v [0] == $m) {
  3740. $verifyList [$k] ['date'] = $u ['date'];
  3741. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3742. $verifyList [$k] ['status'] = $u ['status'];
  3743. $flag = false;
  3744. break;
  3745. }
  3746. }
  3747. $endStaffArray = end ( $verifyStaff );
  3748. if (isset ( $endStaffArray ['ROLE'] )) {
  3749. } else {
  3750. // $endKey=key($verifyStaff);
  3751. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3752. // $button=4;
  3753. // $verifyList[$k]['status']=4;
  3754. // }
  3755. }
  3756. }
  3757. }
  3758. $rolename ['name'] = '';
  3759. if (! empty ( $roleId )) {
  3760. Doo::loadModel ( 'role' );
  3761. $role = new role ();
  3762. $rolename = $role->getOne ( array (
  3763. 'where' => 'rid=' . $roleId,
  3764. 'asArray' => true
  3765. ) );
  3766. }
  3767. if (! empty ( $verifyStaff ))
  3768. $endStaffArray = end ( $verifyStaff );
  3769. $KOP = false;
  3770. foreach ( $roleArrayCopy as $P => $A ) {
  3771. foreach ( $A as $MKI => $AVL ) {
  3772. if (! empty ( $verifyStaff )) {
  3773. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3774. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3775. $button = 4;
  3776. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3777. }
  3778. foreach ( $verifyStaff as $m => $u ) {
  3779. $AVLFK = $AVL [0] . '_R';
  3780. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3781. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3782. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3783. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3784. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3785. break;
  3786. }
  3787. }
  3788. } else {
  3789. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3790. $button = 4;
  3791. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3792. }
  3793. }
  3794. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3795. $KOP = true;
  3796. }
  3797. }
  3798. foreach ( $roleArrayCopy as $k => $v ) {
  3799. foreach ( $verifyList as $m => $n ) {
  3800. if ($n [0] == $k) {
  3801. array_splice ( $verifyList, $m, 1, $v );
  3802. }
  3803. }
  3804. }
  3805. $receiptList [$key] ['verifyList'] = $verifyList;
  3806. $receiptList [$key] ['executeList'] = $executeList;
  3807. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3808. 'where' => 'sid=' . $value ['staff'],
  3809. 'asArray' => true
  3810. ) );
  3811. $receiptList [$key] ['button2'] = $button2;
  3812. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3813. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3814. $relust = $value ['sum'] - $value ['loanSum'];
  3815. $receiptList [$key] ['relust'] = $relust;
  3816. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  3817. }
  3818. // print_r($receiptList[$key]['executeList']);
  3819. $data ['receiptList'] = $receiptList;
  3820. $data ['memu'] = "receipt";
  3821. $data ['staff'] = $this->staff;
  3822. $data ['receiptMemu'] = 'implement';
  3823. $data ['verifyId'] = $this->verifyId;
  3824. $data ['executeId'] = $this->executeId;
  3825. $this->render ( "/admin/implement", $data );
  3826. }
  3827. function implementDo() {
  3828. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3829. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3830. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  3831. if (! empty ( $rid ) && $amount != '') {
  3832. Doo::loadModel ( 'receipt' );
  3833. $receipt = new receipt ();
  3834. Doo::loadClass ( 'XDeode' );
  3835. $XDeode = new XDeode ( 5 );
  3836. $rinfo = $receipt->getOne ( array (
  3837. 'where' => 'rid=' . $rid,
  3838. 'asArray' => true
  3839. ) );
  3840. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  3841. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  3842. if (empty ( $executeStaff )) {
  3843. $executeStaff = array (
  3844. $this->staff [0] ['sid'] => array (
  3845. 'date' => date ( 'Y-m-d' ),
  3846. 'opinion' => $implementOpinions,
  3847. 'status' => 1
  3848. )
  3849. );
  3850. } else {
  3851. $executeStaff [$this->staff [0] ['sid']] = array (
  3852. 'date' => date ( 'Y-m-d' ),
  3853. 'opinion' => $implementOpinions,
  3854. 'status' => 1
  3855. );
  3856. }
  3857. if (count ( $executeStaff ) == count ( $executeCopy )) {
  3858. $receipt->executeStaff = json_encode ( $executeStaff );
  3859. $receipt->status = 8;
  3860. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  3861. $receipt->status = 9;
  3862. if($rinfo ['status']==6){
  3863. $receipt->loanDate=date ( "Y-m-d" );
  3864. }
  3865. $receipt->executeDate = date ( "Y-m-d" );
  3866. } else {
  3867. $receipt->executeStaff = json_encode ( $executeStaff );
  3868. }
  3869. $receipt->amount = $amount;
  3870. $receipt->update ( array (
  3871. 'where' => 'rid=' . $rid
  3872. ) );
  3873. }
  3874. $ridKey = $XDeode->encode ( $rid );
  3875. return "/hisImplement";
  3876. //return "/implement/" . $ridKey . ".html";
  3877. }
  3878. function receiptburEdi() {
  3879. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3880. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  3881. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  3882. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  3883. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3884. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  3885. if (empty ( $status ))
  3886. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  3887. $vidList = array ();
  3888. $button = 0;
  3889. Doo::loadModel ( 'verify' );
  3890. Doo::loadModel ( 'receipt' );
  3891. Doo::loadModel ( 'staff' );
  3892. $staff = new staff ();
  3893. $receipt = new receipt ();
  3894. $verify = new verify ();
  3895. Doo::loadModel ( 'L_category' );
  3896. $Lcategory = new L_category ();
  3897. Doo::loadModel ( 'enclosur' );
  3898. $enclosur = new enclosur ();
  3899. Doo::loadModel ( 'loanReceipt' );
  3900. $loanReceipt = new loanReceipt ();
  3901. // user verify ID
  3902. $verifyDetail = $verify->find ( array (
  3903. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  3904. 'asArray' => true
  3905. ) );
  3906. foreach ( $verifyDetail as $key => $value ) {
  3907. array_push ( $vidList, $value ['vid'] );
  3908. }
  3909. $vid = implode ( ",", $vidList );
  3910. if (empty ( $verifyDetail ))
  3911. $vid = 0;
  3912. $categoryList = $Lcategory->find ( array (
  3913. 'asArray' => true
  3914. ) );
  3915. $staffList = $staff->find ( array (
  3916. 'where' => 'cid=' . $cid,
  3917. 'asArray' => true
  3918. ) );
  3919. $ap = "";
  3920. if ($status == 4) {
  3921. $ap = 4;
  3922. $status = 2;
  3923. }
  3924. // get Receipt By verifyID status 2
  3925. $receiptList = $receipt->find ( array (
  3926. 'where' => 'rid =' . $rid.' and status=2',
  3927. 'desc' => 'rid',
  3928. 'asArray' => true
  3929. ) );
  3930. if(empty($receiptList)){
  3931. die ( 'illegal request' );
  3932. }
  3933. $loanList = $loanReceipt->find ( array (
  3934. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3935. 'desc' => 'rid',
  3936. 'asArray' => true
  3937. ) );
  3938. $Locate = 0;
  3939. $roleId = 0;
  3940. $button = 0;
  3941. foreach ( $loanList as $key => $value ) {
  3942. $loanList [$key] ['Locate'] = $Locate;
  3943. $Locate ++;
  3944. $loanList [$key] ['reviseDetail'] = array ();
  3945. if (! empty ( $value ['reviseDetail'] ))
  3946. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3947. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3948. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3949. $categoryDetil = $Lcategory->getOne ( array (
  3950. 'where' => 'cid=' . $value ['cid'],
  3951. 'asArray' => true
  3952. ) );
  3953. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3954. // 检测编辑状态
  3955. $verifyList = $verify->getOne ( array (
  3956. 'where' => 'vid=' . $value ['verify'],
  3957. 'asArray' => true
  3958. ) );
  3959. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3960. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3961. Doo::loadModel ( 'role' );
  3962. $role = new role ();
  3963. $flag = true;
  3964. $roleKey = 0;
  3965. $endStaffArray = array ();
  3966. $roleArrayCopy = array ();
  3967. foreach ( $verifyList as $k => $v ) {
  3968. // init verifyStaff
  3969. if ($v [1] == 'ROLE') {
  3970. if (! empty ( $verifyStaff )) {
  3971. $endStaffArray = end ( $verifyStaff );
  3972. }
  3973. $roleVerify = json_decode ( $v [3], true );
  3974. $roleKey = $k;
  3975. $roleArray = array ();
  3976. $rolename = $role->getOne ( array (
  3977. 'where' => 'rid=' . $v [0],
  3978. 'asArray' => true
  3979. ) );
  3980. foreach ( $roleVerify as $o => $p ) {
  3981. $staffID = explode ( '_', $p );
  3982. $staffInfo = $staff->getOne ( array (
  3983. 'where' => 'sid=' . $staffID [0],
  3984. 'asArray' => true
  3985. ) );
  3986. // print_r($staffID);
  3987. $exp = array (
  3988. 0 => $staffInfo ['sid'],
  3989. 1 => $staffID [1],
  3990. 2 => $staffInfo ['avatar'],
  3991. 'date' => '',
  3992. 'date' => '',
  3993. 'opinion' => '',
  3994. 'status' => '',
  3995. 'rolename' => $rolename ['name']
  3996. );
  3997. array_push ( $roleArray, $exp );
  3998. }
  3999. $roleArrayCopy [$v [0]] = $roleArray;
  4000. // $verifyList[$k]['roleArray']=$roleArray;
  4001. }
  4002. $verifyList [$k] ['date'] = "";
  4003. $verifyList [$k] ['opinion'] = "";
  4004. $verifyList [$k] ['status'] = "";
  4005. if (empty ( $verifyStaff )) {
  4006. $verifyList [$k] ['date'] = "";
  4007. $verifyList [$k] ['opinion'] = "";
  4008. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4009. $verifyList [$k] ['status'] = 4;
  4010. $flag = false;
  4011. }
  4012. } else {
  4013. foreach ( $verifyStaff as $m => $u ) {
  4014. if ($v [0] == $m) {
  4015. $verifyList [$k] ['date'] = $u ['date'];
  4016. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4017. $verifyList [$k] ['status'] = $u ['status'];
  4018. $flag = false;
  4019. break;
  4020. }
  4021. }
  4022. $endStaffArray = end ( $verifyStaff );
  4023. if (isset ( $endStaffArray ['ROLE'] )) {
  4024. } else {
  4025. }
  4026. }
  4027. }
  4028. $rolename ['name'] = '';
  4029. if (! empty ( $roleId )) {
  4030. Doo::loadModel ( 'role' );
  4031. $role = new role ();
  4032. $rolename = $role->getOne ( array (
  4033. 'where' => 'rid=' . $roleId,
  4034. 'asArray' => true
  4035. ) );
  4036. }
  4037. if (! empty ( $verifyStaff ))
  4038. $endStaffArray = end ( $verifyStaff );
  4039. $KOP = false;
  4040. foreach ( $roleArrayCopy as $P => $A ) {
  4041. foreach ( $A as $MKI => $AVL ) {
  4042. if (! empty ( $verifyStaff )) {
  4043. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4044. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4045. $button = 4;
  4046. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4047. }
  4048. foreach ( $verifyStaff as $m => $u ) {
  4049. $AVLFK = $AVL [0] . '_R';
  4050. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4051. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4052. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4053. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4054. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4055. break;
  4056. }
  4057. }
  4058. } else {
  4059. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4060. $button = 4;
  4061. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4062. }
  4063. }
  4064. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4065. $KOP = true;
  4066. }
  4067. }
  4068. foreach ( $roleArrayCopy as $k => $v ) {
  4069. foreach ( $verifyList as $m => $n ) {
  4070. if ($n [0] == $k) {
  4071. array_splice ( $verifyList, $m, 1, $v );
  4072. }
  4073. }
  4074. }
  4075. $loanList [$key] ['verifyList'] = $verifyList;
  4076. }
  4077. $htmlLoan = '';
  4078. if (isset ( $loanList [0] )) {
  4079. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  4080. if ($value ['status'] == 1)
  4081. $htmlLoan .= '<li class="done" >';
  4082. elseif ($value ['status'] == 3)
  4083. $htmlLoan .= '<li class="undone" >';
  4084. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  4085. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  4086. if (isset ( $value ['rolename'] ))
  4087. $htmlLoan .= $value ['rolename'];
  4088. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  4089. }
  4090. $data ['loanDate'] = $loanList [0] ['date'];
  4091. }
  4092. $data ['htmlLoan'] = $htmlLoan;
  4093. $data['loanReceiptDate']=$loanList [0] ['date'];
  4094. //$data ['LoanReceipt']=$loanList[0];
  4095. // print_r($loanList);
  4096. $Locate = 0;
  4097. $roleId = 0;
  4098. $button = 0;
  4099. if ($ap == 4)
  4100. $status = 4;
  4101. foreach ( $receiptList as $key => $value ) {
  4102. $receiptList [$key] ['Locate'] = $Locate;
  4103. $Locate ++;
  4104. $receiptList [$key] ['reviseDetail'] = array ();
  4105. if (! empty ( $value ['reviseDetail'] ))
  4106. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4107. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4108. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4109. $categoryDetil = $Lcategory->getOne ( array (
  4110. 'where' => 'cid=' . $value ['cid'],
  4111. 'asArray' => true
  4112. ) );
  4113. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4114. // 检测编辑状态
  4115. $verifyList = $verify->getOne ( array (
  4116. 'where' => 'vid=' . $value ['verify'],
  4117. 'asArray' => true
  4118. ) );
  4119. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4120. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4121. Doo::loadModel ( 'role' );
  4122. $role = new role ();
  4123. // print_r($verifyList);
  4124. $flag = true;
  4125. $roleKey = 0;
  4126. $endStaffArray = array ();
  4127. $roleArrayCopy = array ();
  4128. foreach ( $verifyList as $k => $v ) {
  4129. // init verifyStaff
  4130. if ($v [1] == 'ROLE') {
  4131. if (! empty ( $verifyStaff )) {
  4132. $endStaffArray = end ( $verifyStaff );
  4133. if ($v [0] == $endStaffArray ['nextStaff']) {
  4134. $roleId = $v [0];
  4135. }
  4136. }
  4137. $roleVerify = json_decode ( $v [3], true );
  4138. $roleKey = $k;
  4139. $roleArray = array ();
  4140. $rolename = $role->getOne ( array (
  4141. 'where' => 'rid=' . $v [0],
  4142. 'asArray' => true
  4143. ) );
  4144. foreach ( $roleVerify as $o => $p ) {
  4145. $staffID = explode ( '_', $p );
  4146. $staffInfo = $staff->getOne ( array (
  4147. 'where' => 'sid=' . $staffID [0],
  4148. 'asArray' => true
  4149. ) );
  4150. // print_r($staffID);
  4151. $exp = array (
  4152. 0 => $staffInfo ['sid'],
  4153. 1 => $staffID [1],
  4154. 2 => $staffInfo ['avatar'],
  4155. 'date' => '',
  4156. 'date' => '',
  4157. 'opinion' => '',
  4158. 'status' => '',
  4159. 'rolename' => $rolename ['name']
  4160. );
  4161. array_push ( $roleArray, $exp );
  4162. }
  4163. $roleArrayCopy [$v [0]] = $roleArray;
  4164. // $verifyList[$k]['roleArray']=$roleArray;
  4165. }
  4166. // print_r($roleArray);
  4167. $verifyList [$k] ['date'] = "";
  4168. $verifyList [$k] ['opinion'] = "";
  4169. $verifyList [$k] ['status'] = "";
  4170. if (empty ( $verifyStaff )) {
  4171. $verifyList [$k] ['date'] = "";
  4172. $verifyList [$k] ['opinion'] = "";
  4173. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4174. $verifyList [$k] ['status'] = 4;
  4175. $button = 4;
  4176. $flag = false;
  4177. }
  4178. } else {
  4179. foreach ( $verifyStaff as $m => $u ) {
  4180. if ($v [0] == $m) {
  4181. $verifyList [$k] ['date'] = $u ['date'];
  4182. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4183. $verifyList [$k] ['status'] = $u ['status'];
  4184. $flag = false;
  4185. break;
  4186. }
  4187. }
  4188. $endStaffArray = end ( $verifyStaff );
  4189. if (isset ( $endStaffArray ['ROLE'] )) {
  4190. } else {
  4191. $endKey = key ( $verifyStaff );
  4192. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4193. $button = 4;
  4194. $verifyList [$k] ['status'] = 4;
  4195. }
  4196. }
  4197. }
  4198. }
  4199. $rolename ['name'] = '';
  4200. if (! empty ( $roleId )) {
  4201. Doo::loadModel ( 'role' );
  4202. $role = new role ();
  4203. $rolename = $role->getOne ( array (
  4204. 'where' => 'rid=' . $roleId,
  4205. 'asArray' => true
  4206. ) );
  4207. }
  4208. if (! empty ( $verifyStaff ))
  4209. $endStaffArray = end ( $verifyStaff );
  4210. $KOP = false;
  4211. foreach ( $roleArrayCopy as $P => $A ) {
  4212. foreach ( $A as $MKI => $AVL ) {
  4213. if (! empty ( $verifyStaff )) {
  4214. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4215. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4216. $button = 4;
  4217. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4218. }
  4219. foreach ( $verifyStaff as $m => $u ) {
  4220. $AVLFK = $AVL [0] . '_R';
  4221. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4222. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4223. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4224. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4225. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4226. break;
  4227. }
  4228. }
  4229. } else {
  4230. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4231. $button = 4;
  4232. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4233. }
  4234. }
  4235. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4236. $KOP = true;
  4237. }
  4238. }
  4239. foreach ( $roleArrayCopy as $k => $v ) {
  4240. foreach ( $verifyList as $m => $n ) {
  4241. if ($n [0] == $k) {
  4242. array_splice ( $verifyList, $m, 1, $v );
  4243. }
  4244. }
  4245. }
  4246. // print_r($verifyList);
  4247. $receiptList [$key] ['verifyList'] = $verifyList;
  4248. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4249. 'where' => 'sid=' . $value ['staff'],
  4250. 'asArray' => true
  4251. ) );
  4252. $receiptList [$key] ['button'] = $button;
  4253. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4254. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4255. $relust = $value ['sum'] - $value ['loanSum'];
  4256. $receiptList [$key] ['relust'] = $relust;
  4257. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4258. }
  4259. // print_r($receiptList);die;
  4260. // $data['verifyDetail']=$verifyDetail;
  4261. $mothHtml = "";
  4262. for($i = 1; $i <= 12; $i ++) {
  4263. if ($month == $i)
  4264. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4265. else
  4266. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4267. }
  4268. // 获取审批日志
  4269. Doo::loadModel ( 'receiptLog' );
  4270. $receiptLog = new receiptLog ();
  4271. $rlList = array ();
  4272. $rlInfo = $receiptLog->getOne ( array (
  4273. 'where' => 'rid=' . $rid . ' and status=4',
  4274. 'asArray' => true
  4275. ) );
  4276. $tijdate = $receiptLog->getOne ( array (
  4277. 'where' => 'rid=' . $rid . ' and status=2',
  4278. 'asc' => 'rlid',
  4279. 'asArray' => true
  4280. ) );
  4281. if (! empty ( $rlInfo )) {
  4282. $rlList = $receiptLog->find ( array (
  4283. 'where' => 'rid=' . $rid,
  4284. 'asc' => 'rlid',
  4285. 'asArray' => true
  4286. ) );
  4287. }
  4288. // echo $rid;
  4289. // print_r($receiptList);
  4290. $receiptList [0] ['rlList'] = $rlList;
  4291. // print_r($receiptList);
  4292. $enclosurList = $enclosur->find ( array (
  4293. 'where' => 'rid=' . $rid,
  4294. 'asArray' => true
  4295. ) );
  4296. $enclosurHtml = '';
  4297. foreach ( $enclosurList as $value ) {
  4298. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4299. }
  4300. $data ['enclosurHtml'] = $enclosurHtml;
  4301. $data ['rolename'] = $rolename ['name'];
  4302. $data ['mothHtml'] = $mothHtml;
  4303. //print_r($receiptList);
  4304. $data ['rid'] = $rid;
  4305. $data ['tijdate'] = $tijdate ['date'];
  4306. $data ['receiptList'] = $receiptList;
  4307. $data ['receiptApprovalCount'] = count ( $receiptList );
  4308. $data ['status'] = $status;
  4309. $data ['year'] = $year;
  4310. $data ['categoryList'] = $categoryList;
  4311. $data ['staffList'] = $staffList;
  4312. $data ['cid'] = $cid;
  4313. $data ['sid'] = $sid;
  4314. $data ['ap'] = $ap;
  4315. $data ['memu'] = "receipt";
  4316. $data ['staff'] = $this->staff;
  4317. $data ['receiptMemu'] = 'approvalExpenses';
  4318. $data ['verifyId'] = $this->verifyId;
  4319. $data ['executeId'] = $this->executeId;
  4320. $this->render ( "/admin/receiptburEdi", $data );
  4321. }
  4322. function hisImplement() {
  4323. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4324. if (empty ( $item ))
  4325. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "pendImplement";
  4326. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  4327. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4328. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  4329. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  4330. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  4331. Doo::loadModel ( 'receipt' );
  4332. $receipt = new receipt ();
  4333. Doo::loadModel ( 'L_category' );
  4334. $Lcategory = new L_category ();
  4335. Doo::loadModel ( 'verify' );
  4336. Doo::loadModel ( 'statistics' );
  4337. $statistics = new statistics ();
  4338. $verify = new verify ();
  4339. Doo::loadModel ( 'staff' );
  4340. $staff = new staff ();
  4341. Doo::loadClass ( 'XDeode' );
  4342. $XDeode = new XDeode ( 5 );
  4343. $condition = "";
  4344. if ($item == "expenses")
  4345. $condition = " and Rtype=1 ";
  4346. elseif ($item == "receipts")
  4347. $condition = " and Rtype=0 ";
  4348. elseif ($item == "remits")
  4349. $condition = " and Rtype=2 ";
  4350. elseif($item =="pendImplement"){
  4351. $condition = ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  4352. }
  4353. //'and (executeCopy like "%["' . $this->staff [0] ['sid'] . '"%" and executeStaff not like "%{"' . $this->staff [0] ['sid'] . '"%" )';
  4354. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  4355. $sopString = "";
  4356. if (empty($rdate))
  4357. $dateCondition = " and Year(date) =" . $year;
  4358. else
  4359. $dateCondition=" and date_format(date,'%Y-%m-%d')='".$rdate."' ";
  4360. if ($item == 'teipts') {
  4361. $statusCon = '(status=1 or status=6 )';
  4362. $dateCondition=" and date_format(pastDate,'%Y-%m-%d')='".$rdate."' ";
  4363. } elseif ($item == 'alerpts') {
  4364. $statusCon = '(status=8 or status=9 )';
  4365. if (empty($rdate))
  4366. $dateCondition = " and Year(date) =" . $year;
  4367. else
  4368. $dateCondition=" and date_format(executeDate,'%Y-%m-%d')='".$rdate."' ";
  4369. }
  4370. /*
  4371. if ($item == 'teipts') {
  4372. $statusCon = '(status=1 or status=6 )';
  4373. $dateCondition = " and Year(pastDate) =" . $year;
  4374. if ($moth != 'MONTH')
  4375. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth;
  4376. if ($day != 'DAY')
  4377. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth . " and day(pastDate)=" . $day;
  4378. } elseif ($item == 'alerpts') {
  4379. $statusCon = '(status=8 or status=9 )';
  4380. $dateCondition = " and Year(executeDate) =" . $year;
  4381. if ($moth != 'MONTH')
  4382. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  4383. if ($day != 'DAY')
  4384. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  4385. }
  4386. */
  4387. if ($sop != 'SOP')
  4388. $sopString = " and staff=" . $sop;
  4389. // $noPassSum=$receipt->receiptByYear($year,$this->staff[0]['sid']); and (status=1 or status=6)
  4390. $receiptList = $receipt->find ( array (
  4391. 'where' => $statusCon . $condition . $dateCondition . $sopString,
  4392. 'desc' => 'rid',
  4393. 'asArray' => true
  4394. ) );
  4395. // 员工筛选
  4396. $receiptList2 = $receipt->find ( array (
  4397. 'where' => $statusCon . $condition . $dateCondition,
  4398. 'desc' => 'rid',
  4399. 'asArray' => true
  4400. ) );
  4401. $sopStaff = array ();
  4402. foreach ( $receiptList2 as $key => $value ) {
  4403. $staffDetail = $staff->getOne ( array (
  4404. 'where' => 'sid=' . $value ['staff'],
  4405. 'asArray' => true
  4406. ) );
  4407. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  4408. }
  4409. $Locate = 0;
  4410. $roleId = 0;
  4411. $button = 0;
  4412. foreach ( $receiptList as $key => $value ) {
  4413. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4414. $receiptList [$key] ['Texe'] = 'false';
  4415. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  4416. $receiptList [$key] ['Texe'] = 'true';
  4417. }
  4418. $receiptList [$key] ['TRexe'] = 'true';
  4419. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  4420. $receiptList [$key] ['TRexe'] = 'false';
  4421. }
  4422. $receiptList [$key] ['Locate'] = $Locate;
  4423. $Locate ++;
  4424. $receiptList [$key] ['reviseDetail'] = array ();
  4425. if (! empty ( $value ['reviseDetail'] ))
  4426. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4427. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4428. $categoryDetil = $Lcategory->getOne ( array (
  4429. 'where' => 'cid=' . $value ['cid'],
  4430. 'asArray' => true
  4431. ) );
  4432. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4433. // 检测编辑状态
  4434. $verifyList = $verify->getOne ( array (
  4435. 'where' => 'vid=' . $value ['verify'],
  4436. 'asArray' => true
  4437. ) );
  4438. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4439. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4440. Doo::loadModel ( 'role' );
  4441. $role = new role ();
  4442. $flag = true;
  4443. $roleKey = 0;
  4444. $endStaffArray = array ();
  4445. $roleArrayCopy = array ();
  4446. foreach ( $verifyList as $k => $v ) {
  4447. // init verifyStaff
  4448. if ($v [1] == 'ROLE') {
  4449. if (! empty ( $verifyStaff )) {
  4450. $endStaffArray = end ( $verifyStaff );
  4451. }
  4452. $roleVerify = json_decode ( $v [3], true );
  4453. $roleKey = $k;
  4454. $roleArray = array ();
  4455. $rolename = $role->getOne ( array (
  4456. 'where' => 'rid=' . $v [0],
  4457. 'asArray' => true
  4458. ) );
  4459. foreach ( $roleVerify as $o => $p ) {
  4460. $staffID = explode ( '_', $p );
  4461. $staffInfo = $staff->getOne ( array (
  4462. 'where' => 'sid=' . $staffID [0],
  4463. 'asArray' => true
  4464. ) );
  4465. $exp = array (
  4466. 0 => $staffInfo ['sid'],
  4467. 1 => $staffID [1],
  4468. 2 => $staffInfo ['avatar'],
  4469. 'date' => '',
  4470. 'date' => '',
  4471. 'opinion' => '',
  4472. 'status' => '',
  4473. 'rolename' => $rolename ['name']
  4474. );
  4475. array_push ( $roleArray, $exp );
  4476. }
  4477. $roleArrayCopy [$v [0]] = $roleArray;
  4478. }
  4479. $verifyList [$k] ['date'] = "";
  4480. $verifyList [$k] ['opinion'] = "";
  4481. $verifyList [$k] ['status'] = "";
  4482. if (empty ( $verifyStaff )) {
  4483. $verifyList [$k] ['date'] = "";
  4484. $verifyList [$k] ['opinion'] = "";
  4485. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4486. $verifyList [$k] ['status'] = 4;
  4487. $flag = false;
  4488. }
  4489. } else {
  4490. foreach ( $verifyStaff as $m => $u ) {
  4491. if ($v [0] == $m) {
  4492. $verifyList [$k] ['date'] = $u ['date'];
  4493. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4494. $verifyList [$k] ['status'] = $u ['status'];
  4495. $flag = false;
  4496. break;
  4497. }
  4498. }
  4499. $endStaffArray = end ( $verifyStaff );
  4500. }
  4501. }
  4502. $rolename ['name'] = '';
  4503. if (! empty ( $roleId )) {
  4504. Doo::loadModel ( 'role' );
  4505. $role = new role ();
  4506. $rolename = $role->getOne ( array (
  4507. 'where' => 'rid=' . $roleId,
  4508. 'asArray' => true
  4509. ) );
  4510. }
  4511. if (! empty ( $verifyStaff ))
  4512. $endStaffArray = end ( $verifyStaff );
  4513. $KOP = false;
  4514. foreach ( $roleArrayCopy as $P => $A ) {
  4515. foreach ( $A as $MKI => $AVL ) {
  4516. if (! empty ( $verifyStaff )) {
  4517. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4518. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4519. $button = 4;
  4520. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4521. }
  4522. foreach ( $verifyStaff as $m => $u ) {
  4523. $AVLFK = $AVL [0] . '_R';
  4524. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4525. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4526. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4527. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4528. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4529. break;
  4530. }
  4531. }
  4532. } else {
  4533. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4534. $button = 4;
  4535. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4536. }
  4537. }
  4538. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4539. $KOP = true;
  4540. }
  4541. }
  4542. foreach ( $roleArrayCopy as $k => $v ) {
  4543. foreach ( $verifyList as $m => $n ) {
  4544. if ($n [0] == $k) {
  4545. array_splice ( $verifyList, $m, 1, $v );
  4546. }
  4547. }
  4548. }
  4549. $receiptList [$key] ['verifyList'] = $verifyList;
  4550. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4551. 'where' => 'sid=' . $value ['staff'],
  4552. 'asArray' => true
  4553. ) );
  4554. $receiptList [$key] ['button'] = $button;
  4555. }
  4556. // print_r($receiptList);
  4557. $mothHtml = "";
  4558. for($i = 1; $i <= 12; $i ++) {
  4559. if ($moth == $i)
  4560. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4561. else
  4562. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4563. }
  4564. $dayHtml = "";
  4565. if ($day != "DAY" || $moth != "MONTH") {
  4566. for($i = 1; $i <= 31; $i ++) {
  4567. if ($day == $i)
  4568. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  4569. else
  4570. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  4571. }
  4572. }
  4573. $sopHtml = "";
  4574. foreach ( $sopStaff as $key => $value ) {
  4575. if ($sop == $key)
  4576. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4577. else
  4578. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4579. }
  4580. $data['rdate']=$rdate;
  4581. $data ['sopHtml'] = $sopHtml;
  4582. $data ['dayHtml'] = $dayHtml;
  4583. $data ['mothHtml'] = $mothHtml;
  4584. $data ['receiptList'] = $receiptList;
  4585. $data ['memu'] = "receipt";
  4586. $data ['staff'] = $this->staff;
  4587. $data ['receiptMemu'] = 'implement';
  4588. $data ['verifyId'] = $this->verifyId;
  4589. $data ['executeId'] = $this->executeId;
  4590. $data ['item'] = $item;
  4591. $data ['year'] = $year;
  4592. $data ['moth'] = $moth;
  4593. $data ['day'] = $day;
  4594. $data ['sop'] = $sop;
  4595. $this->render ( "/admin/hisImplement", $data );
  4596. }
  4597. function ajaxExamine() {
  4598. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4599. Doo::loadModel ( 'receipt' );
  4600. $receipt = new receipt ();
  4601. if (! empty ( $rid )) {
  4602. $rLRes = $receipt->find ( array (
  4603. '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,
  4604. 'asArray' => true
  4605. ) );
  4606. echo json_encode ( array (
  4607. 'status' => 1,
  4608. 'receipt' => $rLRes [0]
  4609. ) );
  4610. die ();
  4611. }
  4612. echo json_encode ( array (
  4613. 'status' => 0,
  4614. 'receipt' => array ()
  4615. ) );
  4616. die ();
  4617. }
  4618. /*
  4619. * 废弃
  4620. */
  4621. function myReceipt() {
  4622. // all approval past withdraw
  4623. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4624. if (empty ( $item ))
  4625. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4626. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4627. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  4628. Doo::loadModel ( 'receipt' );
  4629. $receipt = new receipt ();
  4630. // pre-loaded
  4631. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4632. // have cache
  4633. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  4634. if (! empty ( $moth )) // yearPage
  4635. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  4636. $this->showCache ( $path );
  4637. }
  4638. Doo::loadModel ( 'L_category' );
  4639. $Lcategory = new L_category ();
  4640. Doo::loadModel ( 'verify' );
  4641. Doo::loadModel ( 'statistics' );
  4642. $statistics = new statistics ();
  4643. $verify = new verify ();
  4644. Doo::loadModel ( 'staff' );
  4645. $staff = new staff ();
  4646. $condition = " and status!=0 ";
  4647. if ($item == "approval")
  4648. $condition = " and status=2 ";
  4649. elseif ($item == "withdraw")
  4650. $condition = " and status=3 ";
  4651. elseif ($item == "past")
  4652. $condition = " and status=1 ";
  4653. elseif ($item == "whdw")
  4654. $condition = " and status=4 ";
  4655. $dateCondition = " and Year(date) =" . $year;
  4656. if (! empty ( $moth )) {
  4657. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  4658. $stList = $statistics->getOne ( array (
  4659. 'select' => 'rePrice ,agPrice',
  4660. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  4661. 'asArray' => true
  4662. ) );
  4663. } else
  4664. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  4665. if (empty ( $stList ))
  4666. $stList = array (
  4667. 'rePrice' => 0,
  4668. 'agPrice' => 0
  4669. );
  4670. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  4671. $data ['stList'] = array (
  4672. 'rePrice' => $stList ['rePrice'],
  4673. 'agPrice' => $stList ['agPrice'],
  4674. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  4675. );
  4676. $receiptList = $receipt->find ( array (
  4677. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  4678. 'desc' => 'rid',
  4679. 'asArray' => true
  4680. ) );
  4681. $Locate = 0;
  4682. $roleId = 0;
  4683. $button = 0;
  4684. foreach ( $receiptList as $key => $value ) {
  4685. $receiptList [$key] ['Locate'] = $Locate;
  4686. $Locate ++;
  4687. $receiptList [$key] ['reviseDetail'] = array ();
  4688. if (! empty ( $value ['reviseDetail'] ))
  4689. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4690. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4691. $categoryDetil = $Lcategory->getOne ( array (
  4692. 'where' => 'cid=' . $value ['cid'],
  4693. 'asArray' => true
  4694. ) );
  4695. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4696. // 检测编辑状态
  4697. $verifyList = $verify->getOne ( array (
  4698. 'where' => 'vid=' . $value ['verify'],
  4699. 'asArray' => true
  4700. ) );
  4701. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4702. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4703. Doo::loadModel ( 'role' );
  4704. $role = new role ();
  4705. $flag = true;
  4706. $roleKey = 0;
  4707. $endStaffArray = array ();
  4708. $roleArrayCopy = array ();
  4709. foreach ( $verifyList as $k => $v ) {
  4710. // init verifyStaff
  4711. if ($v [1] == 'ROLE') {
  4712. if (! empty ( $verifyStaff )) {
  4713. $endStaffArray = end ( $verifyStaff );
  4714. // if ($v[0]==$endStaffArray['nextStaff']){
  4715. // $roleId=$v[0];
  4716. // }
  4717. }
  4718. $roleVerify = json_decode ( $v [3], true );
  4719. $roleKey = $k;
  4720. $roleArray = array ();
  4721. $rolename = $role->getOne ( array (
  4722. 'where' => 'rid=' . $v [0],
  4723. 'asArray' => true
  4724. ) );
  4725. foreach ( $roleVerify as $o => $p ) {
  4726. $staffID = explode ( '_', $p );
  4727. $staffInfo = $staff->getOne ( array (
  4728. 'where' => 'sid=' . $staffID [0],
  4729. 'asArray' => true
  4730. ) );
  4731. // print_r($staffID);
  4732. $exp = array (
  4733. 0 => $staffInfo ['sid'],
  4734. 1 => $staffID [1],
  4735. 2 => $staffInfo ['avatar'],
  4736. 'date' => '',
  4737. 'date' => '',
  4738. 'opinion' => '',
  4739. 'status' => '',
  4740. 'rolename' => $rolename ['name']
  4741. );
  4742. array_push ( $roleArray, $exp );
  4743. }
  4744. $roleArrayCopy [$v [0]] = $roleArray;
  4745. // $verifyList[$k]['roleArray']=$roleArray;
  4746. }
  4747. $verifyList [$k] ['date'] = "";
  4748. $verifyList [$k] ['opinion'] = "";
  4749. $verifyList [$k] ['status'] = "";
  4750. if (empty ( $verifyStaff )) {
  4751. $verifyList [$k] ['date'] = "";
  4752. $verifyList [$k] ['opinion'] = "";
  4753. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4754. $verifyList [$k] ['status'] = 4;
  4755. $flag = false;
  4756. }
  4757. } else {
  4758. foreach ( $verifyStaff as $m => $u ) {
  4759. if ($v [0] == $m) {
  4760. $verifyList [$k] ['date'] = $u ['date'];
  4761. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4762. $verifyList [$k] ['status'] = $u ['status'];
  4763. $flag = false;
  4764. break;
  4765. }
  4766. }
  4767. $endStaffArray = end ( $verifyStaff );
  4768. if (isset ( $endStaffArray ['ROLE'] )) {
  4769. } else {
  4770. // $endKey=key($verifyStaff);
  4771. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4772. // $button=4;
  4773. // $verifyList[$k]['status']=4;
  4774. // }
  4775. }
  4776. }
  4777. }
  4778. $rolename ['name'] = '';
  4779. if (! empty ( $roleId )) {
  4780. Doo::loadModel ( 'role' );
  4781. $role = new role ();
  4782. $rolename = $role->getOne ( array (
  4783. 'where' => 'rid=' . $roleId,
  4784. 'asArray' => true
  4785. ) );
  4786. }
  4787. if (! empty ( $verifyStaff ))
  4788. $endStaffArray = end ( $verifyStaff );
  4789. $KOP = false;
  4790. foreach ( $roleArrayCopy as $P => $A ) {
  4791. foreach ( $A as $MKI => $AVL ) {
  4792. if (! empty ( $verifyStaff )) {
  4793. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4794. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4795. $button = 4;
  4796. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4797. }
  4798. foreach ( $verifyStaff as $m => $u ) {
  4799. $AVLFK = $AVL [0] . '_R';
  4800. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4801. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4802. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4803. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4804. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4805. break;
  4806. }
  4807. }
  4808. } else {
  4809. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4810. $button = 4;
  4811. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4812. }
  4813. }
  4814. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4815. $KOP = true;
  4816. }
  4817. }
  4818. foreach ( $roleArrayCopy as $k => $v ) {
  4819. foreach ( $verifyList as $m => $n ) {
  4820. if ($n [0] == $k) {
  4821. array_splice ( $verifyList, $m, 1, $v );
  4822. }
  4823. }
  4824. }
  4825. $receiptList [$key] ['verifyList'] = $verifyList;
  4826. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4827. 'where' => 'sid=' . $value ['staff'],
  4828. 'asArray' => true
  4829. ) );
  4830. $receiptList [$key] ['button'] = $button;
  4831. }
  4832. // print_r($receiptList);die;
  4833. $mothHtml = "";
  4834. for($i = 1; $i <= 12; $i ++) {
  4835. if ($moth == $i)
  4836. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4837. else
  4838. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4839. }
  4840. $data ['mothHtml'] = $mothHtml;
  4841. $data ['receiptList'] = $receiptList;
  4842. $data ['memu'] = "receipt";
  4843. $data ['staff'] = $this->staff;
  4844. $data ['receiptMemu'] = 'receipt';
  4845. $data ['verifyId'] = $this->verifyId;
  4846. $data ['executeId'] = $this->executeId;
  4847. $data ['item'] = $item;
  4848. $data ['year'] = $year;
  4849. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4850. // sufficient condition to generate cache
  4851. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  4852. $receiptList = $receipt->find ( array (
  4853. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  4854. 'asArray' => true
  4855. ) );
  4856. if (empty ( $receiptList )) { // generated files
  4857. ob_start ();
  4858. $this->render ( "/admin/saea_myList", $data );
  4859. $this->cacheFile ( $path );
  4860. die ();
  4861. // $content = ob_get_contents();
  4862. // $fp = fopen($path, "w");
  4863. // fwrite($fp, $content);
  4864. // fclose($fp);
  4865. }
  4866. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  4867. $receiptList = $receipt->find ( array (
  4868. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  4869. 'asArray' => true
  4870. ) );
  4871. if (empty ( $receiptList )) { // generated files
  4872. ob_start ();
  4873. $this->render ( "/admin/saea_myList", $data );
  4874. $this->cacheFile ( $path );
  4875. die ();
  4876. }
  4877. }
  4878. }
  4879. $this->render ( "/admin/saea_myList", $data );
  4880. }
  4881. function saeaCreate() {
  4882. Doo::loadModel ( 'accountItem' );
  4883. Doo::loadModel ( 'verify' );
  4884. Doo::loadModel ( 'receipt' );
  4885. Doo::loadModel ( 'L_category' );
  4886. $lCategory = new L_category ();
  4887. $receipt = new receipt ();
  4888. $verify = new verify ();
  4889. $accountItem = new accountItem ();
  4890. Doo::loadModel ( "role" );
  4891. $role = new role ();
  4892. $acItem = $accountItem->find ( array (
  4893. 'asArray' => true
  4894. ) );
  4895. $veList = $verify->find ( array (
  4896. 'asArray' => true
  4897. ) );
  4898. foreach ( $veList as $key => $value ) {
  4899. $v = json_decode ( $value ['staff'] );
  4900. $list = array ();
  4901. foreach ( $v as $n => $m ) {
  4902. if ($m ['1'] == 'ROLE') {
  4903. $roleInfo = $role->getOne ( array (
  4904. 'where' => 'rid=' . $m [0],
  4905. 'asArray' => true
  4906. ) );
  4907. $v [$n] [1] = $roleInfo ['name'];
  4908. array_push ( $list, $roleInfo ['name'] );
  4909. } else {
  4910. array_push ( $list, $v [$n] [1] );
  4911. }
  4912. }
  4913. $veList [$key] ['staff'] = implode ( '>', $list );
  4914. }
  4915. $data ['category'] = $lCategory->find ( array (
  4916. 'asArray' => true
  4917. ) );
  4918. $data ['veList'] = $veList;
  4919. $data ['acItem'] = $acItem;
  4920. $data ['memu'] = "receipt";
  4921. $data ['staff'] = $this->staff;
  4922. $data ['receiptMemu'] = 'saeaBorad';
  4923. $data ['verifyId'] = $this->verifyId;
  4924. $data ['executeId'] = $this->executeId;
  4925. $this->render ( "/admin/saea_create", $data );
  4926. }
  4927. function addReceipt() {
  4928. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  4929. $agency = $this->get_args ( 'agency' );
  4930. $travel = $this->get_args ( 'travel' );
  4931. $train = $this->get_args ( 'train' );
  4932. $other = $this->get_args ( 'other' );
  4933. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  4934. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  4935. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  4936. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  4937. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  4938. Doo::loadModel ( 'receipt' );
  4939. Doo::loadModel ( 'receiptDetail' );
  4940. Doo::loadModel ( 'accountItem' );
  4941. $accountItem = new accountItem ();
  4942. $receipt = new receipt ();
  4943. Doo::loadModel ( 'enclosur' );
  4944. Doo::loadModel ( 'execute' );
  4945. $execute = new execute ();
  4946. $executeDetail = $execute->getOne ( array (
  4947. 'where' => 'mold="报销单执行人"',
  4948. 'asArray' => true
  4949. ) );
  4950. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  4951. // if(!empty($receiptDetail))
  4952. // return "/referReceipt/".$receiptDetail['rid'];
  4953. $aItem = $accountItem->find ( array (
  4954. 'asArray' => true
  4955. ) );
  4956. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  4957. $ag = $tr = $ta = $ot = 0;
  4958. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  4959. foreach ( $aItem as $key => $value ) {
  4960. if ($value ['category'] == $this->AGENCY) {
  4961. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  4962. array_push ( $accountJson [$this->AGENCY], array (
  4963. 'aid' => $value ['aid'],
  4964. 'name' => $value ['name'],
  4965. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  4966. ) );
  4967. $sum += $agency [$ag];
  4968. $agencySum += $agency [$ag];
  4969. }
  4970. $ag ++;
  4971. }
  4972. if ($value ['category'] == $this->TRAVEL) {
  4973. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  4974. array_push ( $accountJson [$this->TRAVEL], array (
  4975. 'aid' => $value ['aid'],
  4976. 'name' => $value ['name'],
  4977. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  4978. ) );
  4979. $sum += $travel [$tr];
  4980. $travelSum += $travel [$tr];
  4981. }
  4982. $tr ++;
  4983. }
  4984. if ($value ['category'] == $this->TRAIN) {
  4985. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  4986. array_push ( $accountJson [$this->TRAIN], array (
  4987. 'aid' => $value ['aid'],
  4988. 'name' => $value ['name'],
  4989. 'price' => number_format ( $train [$ta], 2, '.', '' )
  4990. ) );
  4991. $sum += $train [$ta];
  4992. $trainSum += $train [$ta];
  4993. }
  4994. $ta ++;
  4995. }
  4996. if ($value ['category'] == $this->OTHER) {
  4997. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  4998. array_push ( $accountJson [$this->OTHER], array (
  4999. 'aid' => $value ['aid'],
  5000. 'name' => $value ['name'],
  5001. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5002. ) );
  5003. $sum += $other [$ot];
  5004. $otherSum += $other [$ot];
  5005. }
  5006. $ot ++;
  5007. }
  5008. }
  5009. $accountJson ['cSum'] = array (
  5010. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5011. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5012. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5013. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5014. );
  5015. // 报销单
  5016. $receipt->accountItem = json_encode ( $accountJson );
  5017. $receipt->staff = $this->staff [0] ['sid'];
  5018. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5019. $receipt->date = date ( "Y-m-d" );
  5020. $receipt->cid = $cid;
  5021. $receipt->status = 5;
  5022. // 修改审批流程加入角色
  5023. $receipt->verify = $verify;
  5024. $receipt->executeCopy = $executeDetail ['staff'];
  5025. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  5026. $receipt->explanation = $explanation;
  5027. $rid = $receipt->insert ();
  5028. // 附件
  5029. if (! empty ( $enclosurName )) {
  5030. $enclosurArray = explode ( '-', $enclosurName );
  5031. foreach ( $enclosurArray as $value ) {
  5032. $enclosur = new enclosur ();
  5033. $enclosur->name = $value;
  5034. $enclosur->rid = $rid;
  5035. $enclosur->insert ();
  5036. }
  5037. // print_r($enclosurArray);die;
  5038. }
  5039. // 报销详情
  5040. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5041. $receiptDetail = new receiptDetail ();
  5042. $receiptDetail->staff = $this->staff [0] ['sid'];
  5043. $receiptDetail->item = $value ['name'];
  5044. $receiptDetail->itemCategory = $this->AGENCY;
  5045. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5046. $receiptDetail->date = date ( "Y-m-d" );
  5047. $receiptDetail->cid = $cid;
  5048. $receiptDetail->rid = $rid;
  5049. $receiptDetail->status = 4;
  5050. $receiptDetail->insert ();
  5051. }
  5052. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5053. $receiptDetail = new receiptDetail ();
  5054. $receiptDetail->staff = $this->staff [0] ['sid'];
  5055. $receiptDetail->item = $value ['name'];
  5056. $receiptDetail->itemCategory = $this->TRAVEL;
  5057. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5058. $receiptDetail->date = date ( "Y-m-d" );
  5059. $receiptDetail->cid = $cid;
  5060. $receiptDetail->rid = $rid;
  5061. $receiptDetail->status = 4;
  5062. $receiptDetail->insert ();
  5063. }
  5064. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5065. $receiptDetail = new receiptDetail ();
  5066. $receiptDetail->staff = $this->staff [0] ['sid'];
  5067. $receiptDetail->item = $value ['name'];
  5068. $receiptDetail->itemCategory = $this->TRAIN;
  5069. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5070. $receiptDetail->date = date ( "Y-m-d" );
  5071. $receiptDetail->cid = $cid;
  5072. $receiptDetail->rid = $rid;
  5073. $receiptDetail->status = 4;
  5074. $receiptDetail->insert ();
  5075. }
  5076. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5077. $receiptDetail = new receiptDetail ();
  5078. $receiptDetail->staff = $this->staff [0] ['sid'];
  5079. $receiptDetail->item = $value ['name'];
  5080. $receiptDetail->itemCategory = $this->OTHER;
  5081. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5082. $receiptDetail->date = date ( "Y-m-d" );
  5083. $receiptDetail->cid = $cid;
  5084. $receiptDetail->rid = $rid;
  5085. $receiptDetail->status = 4;
  5086. $receiptDetail->insert ();
  5087. }
  5088. return "/saeaBorad";
  5089. }else
  5090. die ( 'illegal request' );
  5091. }
  5092. function referReceipt() {
  5093. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  5094. Doo::loadModel ( 'receipt' );
  5095. Doo::loadModel ( 'verify' );
  5096. $verify = new verify ();
  5097. $receipt = new receipt ();
  5098. Doo::loadModel ( 'L_category' );
  5099. $lCategory = new L_category ();
  5100. Doo::loadModel ( "role" );
  5101. $role = new role ();
  5102. $receiptDetail = $receipt->find ( array (
  5103. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  5104. 'asArray' => true
  5105. ) );
  5106. if (empty ( $receiptDetail ))
  5107. return "/addReceipt";
  5108. foreach ( $receiptDetail as $key => $value ) {
  5109. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5110. $veList = $verify->getOne ( array (
  5111. 'where' => 'vid=' . $value ['verify'],
  5112. 'asArray' => true
  5113. ) );
  5114. $v = json_decode ( $veList ['staff'] );
  5115. array_push ( $v [0], $veList ['description'] );
  5116. foreach ( $v as $n => $m ) {
  5117. if ($m ['1'] == 'ROLE') {
  5118. $roleInfo = $role->getOne ( array (
  5119. 'where' => 'rid=' . $m [0],
  5120. 'asArray' => true
  5121. ) );
  5122. $v [$n] [1] = $roleInfo ['name'];
  5123. }
  5124. }
  5125. $receiptDetail [$key] ['staff'] = $v;
  5126. $category = $lCategory->getOne ( array (
  5127. 'where' => 'cid=' . $value ['cid'],
  5128. 'asArray' => true
  5129. ) );
  5130. $receiptDetail [$key] ['category'] = $category ['title'];
  5131. }
  5132. // print_r($receiptDetail);
  5133. $data ['receiptDetail'] = $receiptDetail;
  5134. $data ['memu'] = "receipt";
  5135. $data ['staff'] = $this->staff;
  5136. $data ['receiptMemu'] = 'saeaCreate';
  5137. $data ['verifyId'] = $this->verifyId;
  5138. $data ['executeId'] = $this->executeId;
  5139. $this->render ( "/admin/saea_confirm", $data );
  5140. }
  5141. function editReceipt() {
  5142. // edit status 4
  5143. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5144. // echo $rid;
  5145. Doo::loadModel ( 'accountItem' );
  5146. Doo::loadModel ( 'verify' );
  5147. Doo::loadModel ( 'receipt' );
  5148. $receipt = new receipt ();
  5149. $verify = new verify ();
  5150. $accountItem = new accountItem ();
  5151. Doo::loadModel ( 'L_category' );
  5152. $lCategory = new L_category ();
  5153. Doo::loadModel ( "role" );
  5154. $role = new role ();
  5155. $receiptDetail = $receipt->getOne ( array (
  5156. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  5157. 'asArray' => true
  5158. ) );
  5159. if (empty ( $receiptDetail ))
  5160. return "/saeaCreate";
  5161. $acItem = $accountItem->find ( array (
  5162. 'asArray' => true
  5163. ) );
  5164. $veList = $verify->find ( array (
  5165. 'asArray' => true
  5166. ) );
  5167. foreach ( $veList as $key => $value ) {
  5168. $v = json_decode ( $value ['staff'] );
  5169. $list = array ();
  5170. foreach ( $v as $n => $m ) {
  5171. if ($m ['1'] == 'ROLE') {
  5172. $roleInfo = $role->getOne ( array (
  5173. 'where' => 'rid=' . $m [0],
  5174. 'asArray' => true
  5175. ) );
  5176. $v [$n] [1] = $roleInfo ['name'];
  5177. array_push ( $list, $roleInfo ['name'] );
  5178. } else {
  5179. array_push ( $list, $v [$n] [1] );
  5180. }
  5181. }
  5182. $veList [$key] ['staff'] = implode ( '>', $list );
  5183. }
  5184. // 配置编辑信息
  5185. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  5186. foreach ( $acItem as $key => $value ) {
  5187. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  5188. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  5189. $acItem [$key] ['price'] = $v ['price'];
  5190. }
  5191. }
  5192. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  5193. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  5194. $acItem [$key] ['price'] = $v ['price'];
  5195. }
  5196. }
  5197. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  5198. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  5199. $acItem [$key] ['price'] = $v ['price'];
  5200. }
  5201. }
  5202. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  5203. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  5204. $acItem [$key] ['price'] = $v ['price'];
  5205. }
  5206. }
  5207. }
  5208. $data ['category'] = $lCategory->find ( array (
  5209. 'asArray' => true
  5210. ) );
  5211. $data ['cSum'] = $accountItemList ['cSum'];
  5212. $data ['sum'] = $receiptDetail ['sum'];
  5213. $data ['receiptDetail'] = $receiptDetail;
  5214. $data ['veList'] = $veList;
  5215. $data ['acItem'] = $acItem;
  5216. $data ['memu'] = "receipt";
  5217. $data ['staff'] = $this->staff;
  5218. $data ['receiptMemu'] = 'saeaBorad';
  5219. $data ['verify'] = $receiptDetail ['verify'];
  5220. $data ['verifyId'] = $this->verifyId;
  5221. $data ['executeId'] = $this->executeId;
  5222. $data ['rid'] = $rid;
  5223. $this->render ( "/admin/saea_edit", $data );
  5224. }
  5225. function updateReceipt() {
  5226. $agency = $this->get_args ( 'agency' );
  5227. $travel = $this->get_args ( 'travel' );
  5228. $train = $this->get_args ( 'train' );
  5229. $other = $this->get_args ( 'other' );
  5230. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5231. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5232. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5233. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5234. if (! empty ( $explanation )) {
  5235. Doo::loadModel ( 'receipt' );
  5236. Doo::loadModel ( 'receiptDetail' );
  5237. Doo::loadModel ( 'accountItem' );
  5238. $accountItem = new accountItem ();
  5239. $receipt = new receipt ();
  5240. Doo::loadModel ( 'execute' );
  5241. $execute = new execute ();
  5242. $receiptDetail = $receipt->getOne ( array (
  5243. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  5244. 'asArray' => true
  5245. ) );
  5246. if (empty ( $receiptDetail ))
  5247. return "/saeaBorad";
  5248. if ($receiptDetail ['Rtype'] == 1)
  5249. $executeDetail = $execute->getOne ( array (
  5250. 'where' => 'mold="借款费用执行人"',
  5251. 'asArray' => true
  5252. ) );
  5253. else
  5254. $executeDetail = $execute->getOne ( array (
  5255. 'where' => 'mold="报销单执行人"',
  5256. 'asArray' => true
  5257. ) );
  5258. $aItem = $accountItem->find ( array (
  5259. 'asArray' => true
  5260. ) );
  5261. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5262. $ag = $tr = $ta = $ot = 0;
  5263. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5264. foreach ( $aItem as $key => $value ) {
  5265. if ($value ['category'] == $this->AGENCY) {
  5266. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5267. array_push ( $accountJson [$this->AGENCY], array (
  5268. 'aid' => $value ['aid'],
  5269. 'name' => $value ['name'],
  5270. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5271. ) );
  5272. $sum += $agency [$ag];
  5273. $agencySum += $agency [$ag];
  5274. }
  5275. $ag ++;
  5276. }
  5277. if ($value ['category'] == $this->TRAVEL) {
  5278. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5279. array_push ( $accountJson [$this->TRAVEL], array (
  5280. 'aid' => $value ['aid'],
  5281. 'name' => $value ['name'],
  5282. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5283. ) );
  5284. $sum += $travel [$tr];
  5285. $travelSum += $travel [$tr];
  5286. }
  5287. $tr ++;
  5288. }
  5289. if ($value ['category'] == $this->TRAIN) {
  5290. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5291. array_push ( $accountJson [$this->TRAIN], array (
  5292. 'aid' => $value ['aid'],
  5293. 'name' => $value ['name'],
  5294. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5295. ) );
  5296. $sum += $train [$ta];
  5297. $trainSum += $train [$ta];
  5298. }
  5299. $ta ++;
  5300. }
  5301. if ($value ['category'] == $this->OTHER) {
  5302. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5303. array_push ( $accountJson [$this->OTHER], array (
  5304. 'aid' => $value ['aid'],
  5305. 'name' => $value ['name'],
  5306. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5307. ) );
  5308. $sum += $other [$ot];
  5309. $otherSum += $other [$ot];
  5310. }
  5311. $ot ++;
  5312. }
  5313. }
  5314. $accountJson ['cSum'] = array (
  5315. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5316. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5317. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5318. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5319. );
  5320. // 报销单
  5321. $rid = $receipt->rid = $receiptDetail ['rid'];
  5322. $receipt->accountItem = json_encode ( $accountJson );
  5323. $receipt->staff = $this->staff [0] ['sid'];
  5324. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5325. $receipt->date = date ( "Y-m-d" );
  5326. $receipt->cid = $cid;
  5327. if (($receiptDetail ['status'] != 4)) {
  5328. if ($receiptDetail ['Rtype'] == 1)
  5329. $receipt->status = 7;
  5330. else
  5331. $receipt->status = 5;
  5332. }
  5333. if ($receiptDetail != 4 && ! empty ( $verify ))
  5334. $receipt->verify = $verify;
  5335. $receipt->executeCopy = $executeDetail ['staff'];
  5336. $receipt->explanation = $explanation;
  5337. $receipt->update ();
  5338. $receiptDetail = new receiptDetail ();
  5339. $receiptDetail->delete ( array (
  5340. 'where' => 'rid=' . $rid
  5341. ) );
  5342. // 报销详情
  5343. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5344. $receiptDetail = new receiptDetail ();
  5345. $receiptDetail->staff = $this->staff [0] ['sid'];
  5346. $receiptDetail->item = $value ['name'];
  5347. $receiptDetail->itemCategory = $this->AGENCY;
  5348. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5349. $receiptDetail->date = date ( "Y-m-d" );
  5350. $receiptDetail->cid = $cid;
  5351. $receiptDetail->rid = $rid;
  5352. $receiptDetail->status = 4;
  5353. $receiptDetail->insert ();
  5354. }
  5355. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5356. $receiptDetail = new receiptDetail ();
  5357. $receiptDetail->staff = $this->staff [0] ['sid'];
  5358. $receiptDetail->item = $value ['name'];
  5359. $receiptDetail->itemCategory = $this->TRAVEL;
  5360. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5361. $receiptDetail->date = date ( "Y-m-d" );
  5362. $receiptDetail->cid = $cid;
  5363. $receiptDetail->rid = $rid;
  5364. $receiptDetail->status = 4;
  5365. $receiptDetail->insert ();
  5366. }
  5367. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5368. $receiptDetail = new receiptDetail ();
  5369. $receiptDetail->staff = $this->staff [0] ['sid'];
  5370. $receiptDetail->item = $value ['name'];
  5371. $receiptDetail->itemCategory = $this->TRAIN;
  5372. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5373. $receiptDetail->date = date ( "Y-m-d" );
  5374. $receiptDetail->cid = $cid;
  5375. $receiptDetail->rid = $rid;
  5376. $receiptDetail->status = 4;
  5377. $receiptDetail->insert ();
  5378. }
  5379. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5380. $receiptDetail = new receiptDetail ();
  5381. $receiptDetail->staff = $this->staff [0] ['sid'];
  5382. $receiptDetail->item = $value ['name'];
  5383. $receiptDetail->itemCategory = $this->OTHER;
  5384. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5385. $receiptDetail->date = date ( "Y-m-d" );
  5386. $receiptDetail->cid = $cid;
  5387. $receiptDetail->rid = $rid;
  5388. $receiptDetail->status = 4;
  5389. $receiptDetail->insert ();
  5390. }
  5391. // return "/referReceipt/".$rid;
  5392. }
  5393. return "/saeaBorad";
  5394. }
  5395. function approvedReceipt() {
  5396. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5397. Doo::loadModel ( 'receipt' );
  5398. Doo::loadModel ( 'receiptDetail' );
  5399. $receipt = new receipt ();
  5400. $receiptDetail = new receiptDetail ();
  5401. Doo::loadModel ( 'statistics' );
  5402. Doo::loadModel ( 'itemStatistics' );
  5403. $statistics = new statistics ();
  5404. $itemStatistics = new itemStatistics ();
  5405. Doo::loadModel ( "verify" );
  5406. $verify = new verify ();
  5407. // 审批状态的判定
  5408. $receiptDetailList = $receipt->getOne ( array (
  5409. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  5410. 'asArray' => true
  5411. ) );
  5412. if (empty ( $receiptDetailList ))
  5413. return "/saeaBorad";
  5414. $verifyDetail = $verify->getOne ( array (
  5415. 'where' => ' vid =' . $receiptDetailList ['verify'],
  5416. 'asArray' => true
  5417. ) );
  5418. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5419. if (empty ( $receiptDetailList ['nowStaff'] )) {
  5420. $nowStaff = "";
  5421. $nowStaffList = array ();
  5422. if ($verifyDetail [0] [1] == 'ROLE') {
  5423. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5424. foreach ( $vStaffString as $key => $value ) {
  5425. $staffK = explode ( "_", $value );
  5426. array_push ( $nowStaffList, $staffK [0] );
  5427. }
  5428. $nowStaff = implode ( ',', $nowStaffList );
  5429. } else {
  5430. $nowStaff = $verifyDetail [0] [0];
  5431. }
  5432. $receipt->nowStaff = $nowStaff;
  5433. }
  5434. // echo $nowStaff;
  5435. // print_r($verifyDetail);die;
  5436. $receipt->rid = $receiptDetailList ['rid'];
  5437. $receipt->date = date ( "Y-m-d" );
  5438. $receipt->status = 2;
  5439. $receipt->update ();
  5440. $receiptDetail->status = 2;
  5441. $receiptDetail->update ( array (
  5442. 'where' => 'rid=' . $receiptDetailList ['rid']
  5443. ) );
  5444. Doo::loadModel ( "receiptLog" );
  5445. $receiptLog = new receiptLog ();
  5446. Doo::loadModel ( "verify" );
  5447. $verify = new verify ();
  5448. $receiptInfo = $receipt->getOne ( array (
  5449. 'where' => 'rid=' . $rid,
  5450. 'asArray' => true
  5451. ) );
  5452. $vr = $verify->getOne ( array (
  5453. 'where' => 'vid=' . $receiptInfo ['verify'],
  5454. 'asArray' => true
  5455. ) );
  5456. $jd = json_decode ( $vr ['staff'] );
  5457. $roleId = 0;
  5458. foreach ( $jd as $key => $value ) {
  5459. if ($value [1] == 'ROLE') {
  5460. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  5461. if ($pos !== false) {
  5462. $roleId = $value [0];
  5463. }
  5464. }
  5465. }
  5466. // 审批日志
  5467. // echo $roleId;die;
  5468. if (! empty ( $roleId )) {
  5469. Doo::loadModel ( "role" );
  5470. $role = new role ();
  5471. $roleInfo = $role->getOne ( array (
  5472. 'where' => 'rid=' . $roleId,
  5473. 'asArray' => true
  5474. ) );
  5475. $receiptLog->rolename = $roleInfo ['name'];
  5476. }
  5477. $receiptLog->username = $this->staff [0] ['username'];
  5478. $receiptLog->uid = $this->staff [0] ['sid'];
  5479. $receiptLog->date = date ( "Y-m-d" );
  5480. $receiptLog->opinion = '提交审批';
  5481. $receiptLog->img = $this->staff [0] ['avatar'];
  5482. $receiptLog->status = 2;
  5483. $receiptLog->rid = $rid;
  5484. $receiptLog->insert ();
  5485. // statistics item
  5486. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  5487. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  5488. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  5489. $stat = $statistics->getOne ( array (
  5490. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5491. 'asArray' => true
  5492. ) );
  5493. if (empty ( $stat )) {
  5494. $statistics->date = date ( "Y-m-d" );
  5495. $statistics->cid = $this->staff [0] ['cid'];
  5496. $statistics->staff = $this->staff [0] ['sid'];
  5497. $statistics->agPrice = 0;
  5498. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5499. $statistics->insert ();
  5500. } else {
  5501. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5502. $statistics->update ( array (
  5503. 'where' => 'sid=' . $stat ['sid']
  5504. ) );
  5505. }
  5506. return "/expenses";
  5507. }
  5508. function approval() {
  5509. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5510. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5511. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5512. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5513. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5514. if (empty ( $status ))
  5515. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5516. $vidList = array ();
  5517. $button = 0;
  5518. Doo::loadModel ( 'verify' );
  5519. $verify = new verify ();
  5520. Doo::loadModel ( 'receipt' );
  5521. $receipt = new receipt ();
  5522. Doo::loadModel ( 'staff' );
  5523. $staff = new staff ();
  5524. Doo::loadModel ( 'L_category' );
  5525. $Lcategory = new L_category ();
  5526. // user verify ID
  5527. $verifyDetail = $verify->find ( array (
  5528. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5529. 'asArray' => true
  5530. ) );
  5531. foreach ( $verifyDetail as $key => $value ) {
  5532. array_push ( $vidList, $value ['vid'] );
  5533. }
  5534. $vid = implode ( ",", $vidList );
  5535. if (empty ( $verifyDetail ))
  5536. $vid = 0;
  5537. /*
  5538. */
  5539. $dateCondition = " and Year(date) =" . $year;
  5540. if (! empty ( $month ))
  5541. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  5542. $categoryList = $Lcategory->find ( array (
  5543. 'asArray' => true
  5544. ) );
  5545. $staffList = $staff->find ( array (
  5546. 'where' => 'cid=' . $cid,
  5547. 'asArray' => true
  5548. ) );
  5549. $cateCondition = "";
  5550. $staffCondition = "";
  5551. $approvalCondition = "";
  5552. if (! empty ( $cid ))
  5553. $cateCondition = ' and cid=' . $cid;
  5554. if (! empty ( $sid )) {
  5555. $staffCondition = ' and staff=' . $sid;
  5556. $cateCondition = "";
  5557. }
  5558. // elseif($status==1){
  5559. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  5560. // }
  5561. if ($status == 2) {
  5562. // 查找角色审批人
  5563. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  5564. }
  5565. $ap = "";
  5566. if ($status == 4) {
  5567. $ap = 4;
  5568. $status = 2;
  5569. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  5570. }
  5571. if ($status == 5) {
  5572. $status = 4;
  5573. $ap = 5;
  5574. }
  5575. // echo $vid;
  5576. // get Receipt By verifyID status 2 .$approvalCondition
  5577. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  5578. $receiptList = $receipt->find ( array (
  5579. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  5580. 'desc' => 'rid',
  5581. 'asArray' => true
  5582. ) );
  5583. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  5584. $Locate = 0;
  5585. if ($ap == 4)
  5586. $status = 4;
  5587. elseif ($ap == 5)
  5588. $status = 5;
  5589. foreach ( $receiptList as $key => $value ) {
  5590. $receiptList [$key] ['Locate'] = $Locate;
  5591. $Locate ++;
  5592. $receiptList [$key] ['reviseDetail'] = array ();
  5593. if (! empty ( $value ['reviseDetail'] ))
  5594. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5595. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5596. $categoryDetil = $Lcategory->getOne ( array (
  5597. 'where' => 'cid=' . $value ['cid'],
  5598. 'asArray' => true
  5599. ) );
  5600. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5601. $verifyList = $verify->getOne ( array (
  5602. 'where' => 'vid=' . $value ['verify'],
  5603. 'asArray' => true
  5604. ) );
  5605. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5606. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5607. foreach ( $verifyList as $k => $v ) {
  5608. // init verifyStaff
  5609. $verifyList [$k] ['date'] = "";
  5610. $verifyList [$k] ['opinion'] = "";
  5611. $verifyList [$k] ['status'] = "";
  5612. if (empty ( $verifyStaff )) {
  5613. $verifyList [$k] ['date'] = "";
  5614. $verifyList [$k] ['opinion'] = "";
  5615. if ($v [0] == $this->staff [0] ['sid']) {
  5616. $verifyList [$k] ['status'] = 4;
  5617. $button = 4;
  5618. }
  5619. } else {
  5620. $flag = true;
  5621. foreach ( $verifyStaff as $m => $u ) {
  5622. if ($v [0] == $m) {
  5623. $verifyList [$k] ['date'] = $u ['date'];
  5624. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5625. $verifyList [$k] ['status'] = $u ['status'];
  5626. $flag = false;
  5627. break;
  5628. }
  5629. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  5630. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  5631. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  5632. }
  5633. if ($flag) { // 检测可编辑
  5634. if ($v [0] == $this->staff [0] ['sid']) {
  5635. $verifyList [$k] ['status'] = 4;
  5636. $button = 4;
  5637. }
  5638. }
  5639. }
  5640. }
  5641. $receiptList [$key] ['verifyList'] = $verifyList;
  5642. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5643. 'where' => 'sid=' . $value ['staff'],
  5644. 'asArray' => true
  5645. ) );
  5646. $receiptList [$key] ['button'] = $button;
  5647. }
  5648. // print_r($receiptList);die;
  5649. // $data['verifyDetail']=$verifyDetail;
  5650. $mothHtml = "";
  5651. for($i = 1; $i <= 12; $i ++) {
  5652. if ($month == $i)
  5653. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5654. else
  5655. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5656. }
  5657. $data ['mothHtml'] = $mothHtml;
  5658. $data ['receiptList'] = $receiptList;
  5659. $data ['receiptApprovalCount'] = count ( $receiptList );
  5660. $data ['status'] = $status;
  5661. $data ['year'] = $year;
  5662. $data ['categoryList'] = $categoryList;
  5663. $data ['staffList'] = $staffList;
  5664. $data ['cid'] = $cid;
  5665. $data ['sid'] = $sid;
  5666. $data ['ap'] = $ap;
  5667. $data ['memu'] = "receipt";
  5668. $data ['staff'] = $this->staff;
  5669. $data ['receiptMemu'] = 'approval';
  5670. $data ['verifyId'] = $this->verifyId;
  5671. $data ['executeId'] = $this->executeId;
  5672. $this->render ( "/admin/saea_reportList", $data );
  5673. }
  5674. function approvalDetails() {
  5675. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5676. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5677. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5678. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5679. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5680. Doo::loadModel ( 'verify' );
  5681. $verify = new verify ();
  5682. Doo::loadModel ( 'receipt' );
  5683. $receipt = new receipt ();
  5684. Doo::loadModel ( 'staff' );
  5685. $staff = new staff ();
  5686. Doo::loadModel ( 'L_category' );
  5687. $Lcategory = new L_category ();
  5688. Doo::loadModel ( 'enclosur' );
  5689. $enclosur = new enclosur ();
  5690. $vidList = array ();
  5691. $verifyDetail = $verify->find ( array (
  5692. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5693. 'asArray' => true
  5694. ) );
  5695. foreach ( $verifyDetail as $key => $value ) {
  5696. array_push ( $vidList, $value ['vid'] );
  5697. }
  5698. $vid = implode ( ",", $vidList );
  5699. if (empty ( $verifyDetail ))
  5700. $vid = 0;
  5701. $categoryList = $Lcategory->find ( array (
  5702. 'asArray' => true
  5703. ) );
  5704. $staffList = $staff->find ( array (
  5705. 'where' => 'cid=' . $cid,
  5706. 'asArray' => true
  5707. ) );
  5708. $ap = 0;
  5709. $receiptList = $receipt->find ( array (
  5710. 'where' => 'rid =' . $rid,
  5711. 'desc' => 'rid',
  5712. 'asArray' => true
  5713. ) );
  5714. $Locate = 0;
  5715. $roleId = 0;
  5716. $button = 0;
  5717. foreach ( $receiptList as $key => $value ) {
  5718. $receiptList [$key] ['Locate'] = $Locate;
  5719. $Locate ++;
  5720. $receiptList [$key] ['reviseDetail'] = array ();
  5721. if (! empty ( $value ['reviseDetail'] ))
  5722. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5723. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5724. $categoryDetil = $Lcategory->getOne ( array (
  5725. 'where' => 'cid=' . $value ['cid'],
  5726. 'asArray' => true
  5727. ) );
  5728. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5729. // 检测编辑状态
  5730. $verifyList = $verify->getOne ( array (
  5731. 'where' => 'vid=' . $value ['verify'],
  5732. 'asArray' => true
  5733. ) );
  5734. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5735. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5736. Doo::loadModel ( 'role' );
  5737. $role = new role ();
  5738. // print_r($verifyList);
  5739. $flag = true;
  5740. $roleKey = 0;
  5741. $endStaffArray = array ();
  5742. $roleArrayCopy = array ();
  5743. foreach ( $verifyList as $k => $v ) {
  5744. // init verifyStaff
  5745. if ($v [1] == 'ROLE') {
  5746. if (! empty ( $verifyStaff )) {
  5747. $endStaffArray = end ( $verifyStaff );
  5748. if ($v [0] == $endStaffArray ['nextStaff']) {
  5749. $roleId = $v [0];
  5750. }
  5751. }
  5752. $roleVerify = json_decode ( $v [3], true );
  5753. $roleKey = $k;
  5754. $roleArray = array ();
  5755. $rolename = $role->getOne ( array (
  5756. 'where' => 'rid=' . $v [0],
  5757. 'asArray' => true
  5758. ) );
  5759. foreach ( $roleVerify as $o => $p ) {
  5760. $staffID = explode ( '_', $p );
  5761. $staffInfo = $staff->getOne ( array (
  5762. 'where' => 'sid=' . $staffID [0],
  5763. 'asArray' => true
  5764. ) );
  5765. // print_r($staffID);
  5766. $exp = array (
  5767. 0 => $staffInfo ['sid'],
  5768. 1 => $staffID [1],
  5769. 2 => $staffInfo ['avatar'],
  5770. 'date' => '',
  5771. 'date' => '',
  5772. 'opinion' => '',
  5773. 'status' => '',
  5774. 'rolename' => $rolename ['name']
  5775. );
  5776. array_push ( $roleArray, $exp );
  5777. }
  5778. $roleArrayCopy [$v [0]] = $roleArray;
  5779. // $verifyList[$k]['roleArray']=$roleArray;
  5780. }
  5781. // print_r($roleArray);
  5782. $verifyList [$k] ['date'] = "";
  5783. $verifyList [$k] ['opinion'] = "";
  5784. $verifyList [$k] ['status'] = "";
  5785. if (empty ( $verifyStaff )) {
  5786. $verifyList [$k] ['date'] = "";
  5787. $verifyList [$k] ['opinion'] = "";
  5788. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5789. $verifyList [$k] ['status'] = 4;
  5790. $button = 4;
  5791. $flag = false;
  5792. }
  5793. } else {
  5794. foreach ( $verifyStaff as $m => $u ) {
  5795. if ($v [0] == $m) {
  5796. $verifyList [$k] ['date'] = $u ['date'];
  5797. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5798. $verifyList [$k] ['status'] = $u ['status'];
  5799. $flag = false;
  5800. break;
  5801. }
  5802. }
  5803. $endStaffArray = end ( $verifyStaff );
  5804. if (isset ( $endStaffArray ['ROLE'] )) {
  5805. } else {
  5806. $endKey = key ( $verifyStaff );
  5807. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5808. $button = 4;
  5809. $verifyList [$k] ['status'] = 4;
  5810. }
  5811. }
  5812. }
  5813. }
  5814. $rolename ['name'] = '';
  5815. if (! empty ( $roleId )) {
  5816. Doo::loadModel ( 'role' );
  5817. $role = new role ();
  5818. $rolename = $role->getOne ( array (
  5819. 'where' => 'rid=' . $roleId,
  5820. 'asArray' => true
  5821. ) );
  5822. }
  5823. if (! empty ( $verifyStaff ))
  5824. $endStaffArray = end ( $verifyStaff );
  5825. $KOP = false;
  5826. foreach ( $roleArrayCopy as $P => $A ) {
  5827. foreach ( $A as $MKI => $AVL ) {
  5828. if (! empty ( $verifyStaff )) {
  5829. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5830. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5831. $button = 4;
  5832. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5833. }
  5834. foreach ( $verifyStaff as $m => $u ) {
  5835. $AVLFK = $AVL [0] . '_R';
  5836. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5837. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5838. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5839. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5840. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5841. break;
  5842. }
  5843. }
  5844. } else {
  5845. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5846. $button = 4;
  5847. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5848. }
  5849. }
  5850. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5851. $KOP = true;
  5852. }
  5853. }
  5854. foreach ( $roleArrayCopy as $k => $v ) {
  5855. foreach ( $verifyList as $m => $n ) {
  5856. if ($n [0] == $k) {
  5857. array_splice ( $verifyList, $m, 1, $v );
  5858. }
  5859. }
  5860. }
  5861. $receiptList [$key] ['verifyList'] = $verifyList;
  5862. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5863. 'where' => 'sid=' . $value ['staff'],
  5864. 'asArray' => true
  5865. ) );
  5866. $receiptList [$key] ['button'] = $button;
  5867. }
  5868. $mothHtml = "";
  5869. for($i = 1; $i <= 12; $i ++) {
  5870. if ($month == $i)
  5871. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5872. else
  5873. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5874. }
  5875. // 获取审批日志
  5876. Doo::loadModel ( 'receiptLog' );
  5877. $receiptLog = new receiptLog ();
  5878. $rlList = array ();
  5879. $rlInfo = $receiptLog->getOne ( array (
  5880. 'where' => 'rid=' . $rid . ' and status=4',
  5881. 'asArray' => true
  5882. ) );
  5883. $tijdate = $receiptLog->getOne ( array (
  5884. 'where' => 'rid=' . $rid . ' and status=2',
  5885. 'asc' => 'rlid',
  5886. 'asArray' => true
  5887. ) );
  5888. if (! empty ( $rlInfo )) {
  5889. $rlList = $receiptLog->find ( array (
  5890. 'where' => 'rid=' . $rid,
  5891. 'asc' => 'rlid',
  5892. 'asArray' => true
  5893. ) );
  5894. }
  5895. $receiptList [0] ['rlList'] = $rlList;
  5896. $enclosurList = $enclosur->find ( array (
  5897. 'where' => 'rid=' . $rid,
  5898. 'asArray' => true
  5899. ) );
  5900. $enclosurHtml = '';
  5901. foreach ( $enclosurList as $value ) {
  5902. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5903. }
  5904. $data ['enclosurHtml'] = $enclosurHtml;
  5905. $data ['rolename'] = $rolename ['name'];
  5906. $data ['datetij'] = $tijdate ['date'];
  5907. $data ['mothHtml'] = $mothHtml;
  5908. $data ['receiptList'] = $receiptList;
  5909. $data ['receiptApprovalCount'] = count ( $receiptList );
  5910. $data ['year'] = $year;
  5911. $data ['categoryList'] = $categoryList;
  5912. $data ['staffList'] = $staffList;
  5913. $data ['cid'] = $cid;
  5914. $data ['sid'] = $sid;
  5915. $data ['status'] = 0;
  5916. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  5917. $ap = 4;
  5918. } else
  5919. $data ['status'] = $receiptList [0] ['status'];
  5920. if ($receiptList [0] ['status'] == 4) {
  5921. $data ['status'] = 5;
  5922. $ap = 0;
  5923. }
  5924. $data ['ap'] = $ap;
  5925. $data ['memu'] = "receipt";
  5926. $data ['staff'] = $this->staff;
  5927. $data ['receiptMemu'] = 'approval';
  5928. $data ['verifyId'] = $this->verifyId;
  5929. $data ['executeId'] = $this->executeId;
  5930. $this->render ( "/admin/saeaReportListReport", $data );
  5931. }
  5932. function approvalEdi() {
  5933. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5934. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5935. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5936. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5937. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5938. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5939. if (empty ( $status ))
  5940. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5941. $vidList = array ();
  5942. $button = 0;
  5943. Doo::loadModel ( 'verify' );
  5944. Doo::loadModel ( 'receipt' );
  5945. Doo::loadModel ( 'staff' );
  5946. $staff = new staff ();
  5947. $receipt = new receipt ();
  5948. $verify = new verify ();
  5949. Doo::loadModel ( 'L_category' );
  5950. $Lcategory = new L_category ();
  5951. Doo::loadModel ( 'enclosur' );
  5952. $enclosur = new enclosur ();
  5953. // user verify ID
  5954. $verifyDetail = $verify->find ( array (
  5955. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5956. 'asArray' => true
  5957. ) );
  5958. foreach ( $verifyDetail as $key => $value ) {
  5959. array_push ( $vidList, $value ['vid'] );
  5960. }
  5961. $vid = implode ( ",", $vidList );
  5962. if (empty ( $verifyDetail ))
  5963. $vid = 0;
  5964. $categoryList = $Lcategory->find ( array (
  5965. 'asArray' => true
  5966. ) );
  5967. $staffList = $staff->find ( array (
  5968. 'where' => 'cid=' . $cid,
  5969. 'asArray' => true
  5970. ) );
  5971. $ap = "";
  5972. if ($status == 4) {
  5973. $ap = 4;
  5974. $status = 2;
  5975. }
  5976. // get Receipt By verifyID status 2
  5977. $receiptList = $receipt->find ( array (
  5978. 'where' => 'rid =' . $rid,
  5979. 'desc' => 'rid',
  5980. 'asArray' => true
  5981. ) );
  5982. $Locate = 0;
  5983. $roleId = 0;
  5984. if ($ap == 4)
  5985. $status = 4;
  5986. foreach ( $receiptList as $key => $value ) {
  5987. $receiptList [$key] ['Locate'] = $Locate;
  5988. $Locate ++;
  5989. $receiptList [$key] ['reviseDetail'] = array ();
  5990. if (! empty ( $value ['reviseDetail'] ))
  5991. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5992. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5993. $categoryDetil = $Lcategory->getOne ( array (
  5994. 'where' => 'cid=' . $value ['cid'],
  5995. 'asArray' => true
  5996. ) );
  5997. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5998. // 检测编辑状态
  5999. $verifyList = $verify->getOne ( array (
  6000. 'where' => 'vid=' . $value ['verify'],
  6001. 'asArray' => true
  6002. ) );
  6003. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6004. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6005. // print_r($verifyList);
  6006. //
  6007. // if (empty($verifyStaff)){
  6008. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6009. // $verifyList[0]['status']=4;$button=4;
  6010. // }
  6011. //
  6012. // }else{
  6013. //
  6014. // }
  6015. // die;
  6016. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  6017. // echo array_search("green",$a);
  6018. //
  6019. Doo::loadModel ( 'role' );
  6020. $role = new role ();
  6021. // print_r($verifyList);
  6022. $flag = true;
  6023. $roleKey = 0;
  6024. $endStaffArray = array ();
  6025. $roleArrayCopy = array ();
  6026. foreach ( $verifyList as $k => $v ) {
  6027. // init verifyStaff
  6028. if ($v [1] == 'ROLE') {
  6029. if (! empty ( $verifyStaff )) {
  6030. $endStaffArray = end ( $verifyStaff );
  6031. if ($v [0] == $endStaffArray ['nextStaff']) {
  6032. $roleId = $v [0];
  6033. }
  6034. }
  6035. $roleVerify = json_decode ( $v [3], true );
  6036. $roleKey = $k;
  6037. $roleArray = array ();
  6038. $rolename = $role->getOne ( array (
  6039. 'where' => 'rid=' . $v [0],
  6040. 'asArray' => true
  6041. ) );
  6042. foreach ( $roleVerify as $o => $p ) {
  6043. $staffID = explode ( '_', $p );
  6044. $staffInfo = $staff->getOne ( array (
  6045. 'where' => 'sid=' . $staffID [0],
  6046. 'asArray' => true
  6047. ) );
  6048. // print_r($staffID);
  6049. $exp = array (
  6050. 0 => $staffInfo ['sid'],
  6051. 1 => $staffID [1],
  6052. 2 => $staffInfo ['avatar'],
  6053. 'date' => '',
  6054. 'date' => '',
  6055. 'opinion' => '',
  6056. 'status' => '',
  6057. 'rolename' => $rolename ['name']
  6058. );
  6059. array_push ( $roleArray, $exp );
  6060. }
  6061. $roleArrayCopy [$v [0]] = $roleArray;
  6062. // $verifyList[$k]['roleArray']=$roleArray;
  6063. }
  6064. // print_r($roleArray);
  6065. $verifyList [$k] ['date'] = "";
  6066. $verifyList [$k] ['opinion'] = "";
  6067. $verifyList [$k] ['status'] = "";
  6068. if (empty ( $verifyStaff )) {
  6069. $verifyList [$k] ['date'] = "";
  6070. $verifyList [$k] ['opinion'] = "";
  6071. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6072. $verifyList [$k] ['status'] = 4;
  6073. $button = 4;
  6074. $flag = false;
  6075. }
  6076. } else {
  6077. foreach ( $verifyStaff as $m => $u ) {
  6078. if ($v [0] == $m) {
  6079. $verifyList [$k] ['date'] = $u ['date'];
  6080. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6081. $verifyList [$k] ['status'] = $u ['status'];
  6082. $flag = false;
  6083. break;
  6084. }
  6085. }
  6086. $endStaffArray = end ( $verifyStaff );
  6087. if (isset ( $endStaffArray ['ROLE'] )) {
  6088. } else {
  6089. $endKey = key ( $verifyStaff );
  6090. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6091. $button = 4;
  6092. $verifyList [$k] ['status'] = 4;
  6093. }
  6094. }
  6095. // print_r($endStaffArray);die;
  6096. // if (empty($verifyStaff)){
  6097. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6098. // $verifyList[$k]['status']=4;$button=4;
  6099. // }
  6100. //
  6101. // }else{
  6102. //
  6103. // }
  6104. // if($flag){//检测可编辑
  6105. // if($v[0]==$this->staff[0]['sid']){
  6106. // $verifyList[$k]['status']=4;$button=4;
  6107. // }
  6108. // }
  6109. }
  6110. }
  6111. $rolename ['name'] = '';
  6112. if (! empty ( $roleId )) {
  6113. Doo::loadModel ( 'role' );
  6114. $role = new role ();
  6115. $rolename = $role->getOne ( array (
  6116. 'where' => 'rid=' . $roleId,
  6117. 'asArray' => true
  6118. ) );
  6119. }
  6120. if (! empty ( $verifyStaff ))
  6121. $endStaffArray = end ( $verifyStaff );
  6122. $KOP = false;
  6123. foreach ( $roleArrayCopy as $P => $A ) {
  6124. foreach ( $A as $MKI => $AVL ) {
  6125. if (! empty ( $verifyStaff )) {
  6126. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6127. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6128. $button = 4;
  6129. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6130. }
  6131. foreach ( $verifyStaff as $m => $u ) {
  6132. $AVLFK = $AVL [0] . '_R';
  6133. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6134. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6135. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6136. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6137. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6138. break;
  6139. }
  6140. }
  6141. } else {
  6142. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6143. $button = 4;
  6144. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6145. }
  6146. }
  6147. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6148. $KOP = true;
  6149. }
  6150. }
  6151. // print_r($roleArrayCopy);
  6152. // echo $roleKey;
  6153. foreach ( $roleArrayCopy as $k => $v ) {
  6154. foreach ( $verifyList as $m => $n ) {
  6155. if ($n [0] == $k) {
  6156. array_splice ( $verifyList, $m, 1, $v );
  6157. }
  6158. }
  6159. }
  6160. // if ($KOP)
  6161. // array_splice($verifyList,$roleKey,1,$roleArray);
  6162. // print_r($verifyList);
  6163. $receiptList [$key] ['verifyList'] = $verifyList;
  6164. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6165. 'where' => 'sid=' . $value ['staff'],
  6166. 'asArray' => true
  6167. ) );
  6168. $receiptList [$key] ['button'] = $button;
  6169. }
  6170. // $data['verifyDetail']=$verifyDetail;
  6171. $mothHtml = "";
  6172. for($i = 1; $i <= 12; $i ++) {
  6173. if ($month == $i)
  6174. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6175. else
  6176. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6177. }
  6178. // 获取审批日志
  6179. Doo::loadModel ( 'receiptLog' );
  6180. $receiptLog = new receiptLog ();
  6181. $rlList = array ();
  6182. $rlInfo = $receiptLog->getOne ( array (
  6183. 'where' => 'rid=' . $rid . ' and status=4',
  6184. 'asArray' => true
  6185. ) );
  6186. $tijdate = $receiptLog->getOne ( array (
  6187. 'where' => 'rid=' . $rid . ' and status=2',
  6188. 'asc' => 'rlid',
  6189. 'asArray' => true
  6190. ) );
  6191. if (! empty ( $rlInfo )) {
  6192. $rlList = $receiptLog->find ( array (
  6193. 'where' => 'rid=' . $rid,
  6194. 'asc' => 'rlid',
  6195. 'asArray' => true
  6196. ) );
  6197. }
  6198. $receiptList [0] ['rlList'] = $rlList;
  6199. $enclosurList = $enclosur->find ( array (
  6200. 'where' => 'rid=' . $rid,
  6201. 'asArray' => true
  6202. ) );
  6203. $enclosurHtml = '';
  6204. foreach ( $enclosurList as $value ) {
  6205. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6206. }
  6207. $data ['enclosurHtml'] = $enclosurHtml;
  6208. $data ['rolename'] = $rolename ['name'];
  6209. $data ['datetij'] = $tijdate ['date'];
  6210. $data ['mothHtml'] = $mothHtml;
  6211. $data ['receiptList'] = $receiptList;
  6212. $data ['receiptApprovalCount'] = count ( $receiptList );
  6213. $data ['status'] = $status;
  6214. $data ['year'] = $year;
  6215. $data ['categoryList'] = $categoryList;
  6216. $data ['staffList'] = $staffList;
  6217. $data ['cid'] = $cid;
  6218. $data ['sid'] = $sid;
  6219. $data ['ap'] = $ap;
  6220. $data ['memu'] = "receipt";
  6221. $data ['staff'] = $this->staff;
  6222. $data ['receiptMemu'] = 'approval';
  6223. $data ['verifyId'] = $this->verifyId;
  6224. $data ['executeId'] = $this->executeId;
  6225. $this->render ( "/admin/saeaReportListReport", $data );
  6226. }
  6227. function remittanceHky() {
  6228. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6229. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  6230. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6231. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  6232. $page_size = 15;
  6233. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  6234. Doo::loadModel ( 'receipt' );
  6235. $receipt = new receipt ();
  6236. Doo::loadModel ( 'staff' );
  6237. $staff = new staff ();
  6238. $dateCondition = " and Year(executeDate) =" . $year;
  6239. if ($moth != 'MONTH')
  6240. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  6241. if ($day != 'DAY' && $moth != 'MONTH')
  6242. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  6243. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  6244. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  6245. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  6246. $limit = $pageinfo ['lower'] . ',' . $page_size;
  6247. $dayList = $receipt->find ( array (
  6248. 'select' => 'executeDate,sum(amount) as amount',
  6249. 'where' => $sql,
  6250. 'desc' => 'executeDate',
  6251. 'groupby' => 'executeDate',
  6252. 'limit' => $limit,
  6253. 'asArray' => true
  6254. ) );
  6255. // print_r($dayList);
  6256. foreach ( $dayList as $key => $value ) {
  6257. $remitString = "";
  6258. $receiptList = $receipt->find ( array (
  6259. 'select' => 'rid,executeDate,amount,staff,cid',
  6260. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  6261. 'desc' => 'executeDate',
  6262. 'asArray' => true
  6263. ) );
  6264. foreach ( $receiptList as $k => $v ) {
  6265. $sinfo = $staff->getOne ( array (
  6266. 'select' => 'username,category',
  6267. 'where' => ' sid=' . $v ['staff'],
  6268. 'asArray' => true
  6269. ) );
  6270. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  6271. }
  6272. $dayList [$key] ['staff'] = $remitString;
  6273. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  6274. }
  6275. // print_r($dayList);
  6276. $mothHtml = "";
  6277. for($i = 1; $i <= 12; $i ++) {
  6278. if ($moth == $i)
  6279. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6280. else
  6281. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6282. }
  6283. $dayHtml = "";
  6284. if ($day != "DAY" || $moth != "MONTH") {
  6285. for($i = 1; $i <= 31; $i ++) {
  6286. if ($day == $i)
  6287. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6288. else
  6289. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6290. }
  6291. }
  6292. $data ['page'] = $pageinfo;
  6293. $data ['year'] = $year;
  6294. $data ['moth'] = $moth;
  6295. $data ['day'] = $day;
  6296. $data ['get'] = $get;
  6297. $data ['dayHtml'] = $dayHtml;
  6298. $data ['mothHtml'] = $mothHtml;
  6299. $data ['receiptList'] = $dayList;
  6300. $data ['memu'] = "receipt";
  6301. $data ['staff'] = $this->staff;
  6302. $data ['receiptMemu'] = 'remittanceHky';
  6303. $data ['verifyId'] = $this->verifyId;
  6304. $data ['executeId'] = $this->executeId;
  6305. $this->render ( "/admin/remittanceHky", $data );
  6306. }
  6307. function remittancep() {
  6308. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  6309. Doo::loadModel ( 'receipt' );
  6310. $receipt = new receipt ();
  6311. Doo::loadModel ( 'staff' );
  6312. $staff = new staff ();
  6313. Doo::loadClass ( 'XDeode' );
  6314. $XDeode = new XDeode ( 5 );
  6315. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  6316. $rplist = $receipt->find ( array (
  6317. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6318. 'asArray' => true
  6319. ) );
  6320. $dayList = $receipt->find ( array (
  6321. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6322. 'desc' => 'executeDate',
  6323. 'groupby' => 'staff',
  6324. 'asArray' => true
  6325. ) );
  6326. $html = '';
  6327. foreach ( $dayList as $key => $value ) {
  6328. $sinfo = $staff->getOne ( array (
  6329. 'select' => 'username,category',
  6330. 'where' => ' sid=' . $value ['staff'],
  6331. 'asArray' => true
  6332. ) );
  6333. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  6334. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  6335. $au = 0;
  6336. foreach ( $rplist as $k => $v ) {
  6337. if ($value ['staff'] == $v ['staff']) {
  6338. $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>';
  6339. $au += $v ['amount'];
  6340. }
  6341. }
  6342. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  6343. }
  6344. $data ['html'] = $html;
  6345. $data ['memu'] = "receipt";
  6346. $data ['staff'] = $this->staff;
  6347. $data ['receiptMemu'] = 'remittanceHky';
  6348. $data ['verifyId'] = $this->verifyId;
  6349. $data ['executeId'] = $this->executeId;
  6350. $this->render ( "/admin/remittancep", $data );
  6351. }
  6352. function ajaxGetReceiptDetails() {
  6353. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  6354. Doo::loadClass ( 'XDeode' );
  6355. $XDeode = new XDeode ( 5 );
  6356. $rid = $XDeode->decode ( $rid );
  6357. if (empty ( $rid )) {
  6358. echo json_encode ( array (
  6359. 'status' => 2,
  6360. 'msg' => 'illegal request'
  6361. ) );
  6362. die ();
  6363. }
  6364. Doo::loadModel ( 'receipt' );
  6365. $receipt = new receipt ();
  6366. Doo::loadModel ( 'staff' );
  6367. $staff = new staff ();
  6368. $rinfo = $receipt->getOne ( array (
  6369. 'where' => 'rid= ' . $rid,
  6370. 'asArray' => true
  6371. ) );
  6372. $sinfo = $staff->getOne ( array (
  6373. 'select' => 'username,category',
  6374. 'where' => ' sid=' . $rinfo ['staff'],
  6375. 'asArray' => true
  6376. ) );
  6377. $rinfo ['reviseDetail'] = array ();
  6378. if (! empty ( $rinfo ['reviseDetail'] ))
  6379. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  6380. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  6381. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  6382. $rinfo ['category'] = $sinfo ['category'];
  6383. $verifyStaff = array ();
  6384. if (! empty ( $rinfo ['verifyStaff'] ))
  6385. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  6386. $relust = $rinfo ['sum'] - $rinfo ['loanSum'];
  6387. $rinfo ['relust'] = $relust;
  6388. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  6389. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  6390. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  6391. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  6392. // 费用执行人相关数据
  6393. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6394. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6395. foreach ( $executeCopy as $k => $v ) {
  6396. $executeCopy [$k] ['date'] = '';
  6397. $executeCopy [$k] ['opinion'] = '';
  6398. $executeCopy [$k] ['status'] = '';
  6399. if (! empty ( $executeStaff ))
  6400. foreach ( $executeStaff as $m => $u ) {
  6401. if ($v [0] == $m) {
  6402. $executeCopy [$k] ['date'] = $u ['date'];
  6403. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  6404. $executeCopy [$k] ['status'] = $u ['status'];
  6405. break;
  6406. }
  6407. }
  6408. }
  6409. $rinfo ['executeCopy'] = $executeCopy;
  6410. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  6411. if ($rinfo ['Rtype'] == 1) { // 借款费用
  6412. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6413. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  6414. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  6415. $html .= '<tr><th>' . $value ['name'] . '</th>
  6416. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6417. }
  6418. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6419. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6420. <tr><th class="taC" colspan="2">费用说明</th>
  6421. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6422. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6423. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  6424. </tbody></table>';
  6425. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  6426. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6427. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6428. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6429. $html .= '<tr><th>' . $value ['name'] . '</th>
  6430. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6431. }
  6432. $html .= '<tr><th class="taR">合计</th>
  6433. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6434. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6435. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6436. $html .= '<tr><th>' . $value ['name'] . '</th>
  6437. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6438. }
  6439. $html .= '<tr><th class="taR">合计</th>
  6440. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6441. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6442. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6443. $html .= '<tr><th>' . $value ['name'] . '</th>
  6444. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6445. }
  6446. $html .= '<tr><th class="taR">合计</th>
  6447. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6448. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6449. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6450. $html .= '<tr><th>' . $value ['name'] . '</th>
  6451. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6452. }
  6453. $html .= '<tr><th class="taR">合计</th>
  6454. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6455. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6456. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6457. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6458. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6459. }
  6460. $html .= '<tr><th class="taR">合计</th>
  6461. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6462. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6463. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6464. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6465. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6466. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6467. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6468. <tr';
  6469. if ($rinfo ['relust'] >= 0) {
  6470. $html .= 'class="success"';
  6471. } else {
  6472. $html .= 'class="error"';
  6473. }
  6474. $html .= '><td class="taR"><b>借款结余</b></td>
  6475. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  6476. </tbody></table>
  6477. ';
  6478. }
  6479. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  6480. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6481. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  6482. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6483. $html .= '<tr><th>' . $value ['name'] . '</th>
  6484. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6485. }
  6486. $html .= '<tr><th class="taR">合计</th>
  6487. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6488. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6489. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6490. <tr><th class="taC" colspan="2">费用说明</th>
  6491. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6492. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6493. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6494. </tbody></table>';
  6495. } else {
  6496. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6497. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6498. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6499. $html .= '<tr><th>' . $value ['name'] . '</th>
  6500. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6501. }
  6502. $html .= '<tr><th class="taR">合计</th>
  6503. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6504. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6505. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6506. $html .= '<tr><th>' . $value ['name'] . '</th>
  6507. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6508. }
  6509. $html .= '<tr><th class="taR">合计</th>
  6510. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6511. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6512. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6513. $html .= '<tr><th>' . $value ['name'] . '</th>
  6514. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6515. }
  6516. $html .= '<tr><th class="taR">合计</th>
  6517. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6518. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6519. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6520. $html .= '<tr><th>' . $value ['name'] . '</th>
  6521. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6522. }
  6523. $html .= '<tr><th class="taR">合计</th>
  6524. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6525. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6526. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6527. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6528. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6529. }
  6530. $html .= '<tr><th class="taR">合计</th>
  6531. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6532. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6533. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6534. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6535. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6536. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6537. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  6538. $html .= '</tbody></table>';
  6539. /*
  6540. * <table class="table table-bordered table-condensed table-hover"> <tbody> <tr><th colspan="2" class="taC">日常相关费用</th></tr> <!-- loop receiptList' value.accountItem.日常相关费用 --> <tr><th>{{receiptList' value' value.name}}</th><td width="140" class="taR">¥{{receiptList' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptList' value.accountItem.cSum.agencySum}}</td></tr>
  6541. * <tr><th colspan="2" class="taC">差旅相关费用</th></tr> <!-- loop receiptDetail' value.accountItem.差旅相关费用 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.travelSum}}</td></tr>
  6542. * <tr><th colspan="2" class="taC">培训班费用</th></tr> <!-- loop receiptDetail' value.accountItem.培训班费用 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.trainSum}}</td></tr>
  6543. * <tr><th colspan="2" class="taC">其他</th></tr> <!-- loop receiptDetail' value.accountItem.其他 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.otherSum}}</td></tr>
  6544. * <tr><th colspan="2" class="taC">报销金额调整</th></tr> <!-- loop receiptList' value.reviseDetail --> <tr><th><span class="interval">|</span>{{receiptList' value' value.name}}:{{receiptList' value' value.description}}</th><td class="taR">¥{{receiptList' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colOrange taR">¥{{receiptList' value.revisePrice}}</td></tr>
  6545. * <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr> <tr><th style="text-align:center" colspan="2">{{receiptDetail' value.category}}</th></tr> <tr><th class="taC" colspan="2">报销说明</th></tr> <tr><td colspan="2">{{receiptDetail' value.explanation}}</td></tr> <tr class="warning"><td class="taR"><b>({{receiptDetail' value.receiptOrder}})本次报销费用合计</b></td> <td class="colGreed taR"><b style="font-size:24px">¥{{receiptDetail' value.sum}}</b><br>{{receiptDetail' value.sumCN}}</td></tr>
  6546. * </tbody> </table>
  6547. */
  6548. }
  6549. // print_r($verifyStaff);die;
  6550. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  6551. foreach ( $verifyStaff as $key => $value ) {
  6552. $key = trim ( strtr ( $key, '_R', ' ' ) );
  6553. $sinfo = $staff->getOne ( array (
  6554. 'select' => 'username',
  6555. 'where' => ' sid=' . $key,
  6556. 'asArray' => true
  6557. ) );
  6558. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6559. }
  6560. $html .= '</tbody></table>';
  6561. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  6562. foreach ( $rinfo ['executeCopy'] as $value ) {
  6563. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6564. }
  6565. $html .= '</tbody></table>';
  6566. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  6567. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  6568. </tr></table>';
  6569. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  6570. echo json_encode ( array (
  6571. 'status' => 1,
  6572. 'html' => $html
  6573. ) );
  6574. die ();
  6575. }
  6576. function remittance() {
  6577. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6578. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6579. Doo::loadModel ( 'receipt' );
  6580. $receipt = new receipt ();
  6581. Doo::loadModel ( 'staff' );
  6582. $staff = new staff ();
  6583. $dateCondition = " and Year(pastDate) =" . $year;
  6584. if (! empty ( $month ))
  6585. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  6586. // get Receipt By verifyID status 1
  6587. $receiptList = $receipt->find ( array (
  6588. 'select' => 'sum(sum) as sum,staff,pastDate',
  6589. 'where' => ' status=1' . $dateCondition,
  6590. 'desc' => 'pastDate',
  6591. 'groupby' => 'staff,pastDate',
  6592. 'asArray' => true
  6593. ) );
  6594. $dateList = $receipt->find ( array (
  6595. 'select' => 'pastDate,verifyStaff',
  6596. 'where' => ' status=1' . $dateCondition,
  6597. 'desc' => 'pastDate',
  6598. 'groupby' => 'pastDate',
  6599. 'asArray' => true
  6600. ) );
  6601. $dataList = array ();
  6602. foreach ( $dateList as $d => $a ) {
  6603. $dataList [$a ['pastDate']] = array ();
  6604. $daySum = 0;
  6605. foreach ( $receiptList as $key => $value ) {
  6606. if ($a ['pastDate'] == $value ['pastDate']) {
  6607. $oderList = $receipt->find ( array (
  6608. 'select' => 'receiptOrder',
  6609. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  6610. 'asArray' => true
  6611. ) );
  6612. $list = array ();
  6613. $html = "";
  6614. foreach ( $oderList as $v ) {
  6615. array_push ( $list, $v ['receiptOrder'] );
  6616. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  6617. }
  6618. $receiptList [$key] ['receiptOrder'] = $html;
  6619. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  6620. $sinfo = $staff->getOne ( array (
  6621. 'select' => 'username ',
  6622. 'where' => ' sid=' . $value ['staff'],
  6623. 'asArray' => true
  6624. ) );
  6625. $receiptList [$key] ['username'] = $sinfo ['username'];
  6626. $daySum += $value ['sum'];
  6627. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  6628. }
  6629. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  6630. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  6631. }
  6632. }
  6633. // print_r($dataList);
  6634. $data ['dataList'] = $dataList;
  6635. $mothHtml = "";
  6636. for($i = 1; $i <= 12; $i ++) {
  6637. if ($month == $i)
  6638. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6639. else
  6640. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6641. }
  6642. $data ['year'] = $year;
  6643. $data ['mothHtml'] = $mothHtml;
  6644. $data ['memu'] = "receipt";
  6645. $data ['staff'] = $this->staff;
  6646. $data ['receiptMemu'] = 'approval';
  6647. $data ['verifyId'] = $this->verifyId;
  6648. $data ['executeId'] = $this->executeId;
  6649. $this->render ( "/admin/saeaReportListPay", $data );
  6650. }
  6651. function revocationAdjustment() {
  6652. $sid = isset ( $this->params ['sid'] ) && is_numeric ( $this->params ['sid'] ) ? $this->params ['sid'] : 0;
  6653. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  6654. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6655. // echo $price;die;
  6656. if ((! empty ( $sid )) && ($price != - 99999) && (! empty ( $rid ))) {
  6657. Doo::loadModel ( 'receipt' );
  6658. $receipt = new receipt ();
  6659. $receiptDetail = $receipt->getOne ( array (
  6660. 'where' => 'rid=' . $rid,
  6661. 'asArray' => true
  6662. ) );
  6663. if (empty ( $receiptDetail ['reviseDetail'] ))
  6664. return "/approval";
  6665. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  6666. $RD = array ();
  6667. foreach ( $reviseDetail as $key => $value ) {
  6668. if ($value ['price'] == $price && $value ['sid'] == $sid)
  6669. continue;
  6670. array_push ( $RD, $value );
  6671. }
  6672. $reviseDetailString = json_encode ( $RD );
  6673. $receipt->reviseDetail = $reviseDetailString;
  6674. $receipt->sum = $receiptDetail ['sum'] - $price;
  6675. $receipt->revisePrice = $receiptDetail ['revisePrice'] - $price;
  6676. $receipt->update ( array (
  6677. 'where' => 'rid=' . $rid
  6678. ) );
  6679. }
  6680. // approvalEdi/37
  6681. return "/approvalEdi/" . $rid;
  6682. }
  6683. function updateApprovalReceipt() {
  6684. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6685. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  6686. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6687. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  6688. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  6689. if (! empty ( $rid )) {
  6690. Doo::loadModel ( "verify" );
  6691. $verify = new verify ();
  6692. Doo::loadModel ( "receiptDetail" );
  6693. $receiptDetailObj = new receiptDetail ();
  6694. Doo::loadModel ( "itemStatistics" );
  6695. Doo::loadModel ( "statistics" );
  6696. $statistics = new statistics ();
  6697. $itemStatistics = new itemStatistics ();
  6698. Doo::loadModel ( "receipt" );
  6699. $receipt = new receipt ();
  6700. $receiptDetail = $receipt->getOne ( array (
  6701. 'where' => 'rid=' . $rid . ' and status=2 ',
  6702. 'asArray' => true
  6703. ) );
  6704. if (empty ( $receiptDetail ))
  6705. return "/approval";
  6706. $verifyDetail = $verify->getOne ( array (
  6707. 'where' => ' vid =' . $receiptDetail ['verify'],
  6708. 'asArray' => true
  6709. ) );
  6710. $verifyString = $verifyDetail ['staff'];
  6711. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  6712. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  6713. if (empty ( $opinion )) {
  6714. if ($status == 3)
  6715. $opinion = "终止";
  6716. else
  6717. $opinion = "同意支付";
  6718. }
  6719. $nowStaff = 0;
  6720. $nowStaffList = array ();
  6721. if (empty ( $verifyStaff )) {
  6722. // 还需加入是否已经进入角色审批
  6723. if ($verifyDetail [0] [1] == 'ROLE') {
  6724. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  6725. foreach ( $vStaffString as $key => $value ) {
  6726. $staffK = explode ( "_", $value );
  6727. if ($staffK [0] != $this->staff [0] ['sid'])
  6728. array_push ( $nowStaffList, $staffK [0] );
  6729. }
  6730. // print_r($verifyDetail);
  6731. // die;
  6732. if (! empty ( $nowStaffList )) {
  6733. $nowStaff = implode ( ',', $nowStaffList );
  6734. $verifyStaff = array (
  6735. $this->staff [0] ['sid'] . "_R" => array (
  6736. 'date' => date ( 'Y-m-d' ),
  6737. 'opinion' => $opinion,
  6738. 'status' => $status,
  6739. 'nextStaff' => $verifyDetail [0] [0],
  6740. 'ROLE' => 1
  6741. )
  6742. );
  6743. } else {
  6744. $nowStaff = $verifyDetail [1] [0];
  6745. $verifyStaff = array (
  6746. $this->staff [0] ['sid'] . "_R" => array (
  6747. 'date' => date ( 'Y-m-d' ),
  6748. 'opinion' => $opinion,
  6749. 'status' => $status,
  6750. 'nextStaff' => $verifyDetail [1] [0]
  6751. )
  6752. );
  6753. }
  6754. } else {
  6755. if ($verifyDetail [1] [1] == 'ROLE') {
  6756. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  6757. // echo "dd";
  6758. foreach ( $vStaffString as $key => $value ) {
  6759. $staffK = explode ( "_", $value );
  6760. array_push ( $nowStaffList, $staffK [0] );
  6761. }
  6762. $nowStaff = implode ( ',', $nowStaffList );
  6763. $verifyStaff = array (
  6764. $this->staff [0] ['sid'] => array (
  6765. 'date' => date ( 'Y-m-d' ),
  6766. 'opinion' => $opinion,
  6767. 'status' => $status,
  6768. 'nextStaff' => $verifyDetail [1] [0],
  6769. 'ROLE' => 1
  6770. )
  6771. );
  6772. } else {
  6773. $nowStaff = $verifyDetail [1] [0];
  6774. $verifyStaff = array (
  6775. $this->staff [0] ['sid'] => array (
  6776. 'date' => date ( 'Y-m-d' ),
  6777. 'opinion' => $opinion,
  6778. 'status' => $status,
  6779. 'nextStaff' => $verifyDetail [1] [0]
  6780. )
  6781. );
  6782. }
  6783. }
  6784. if ($status == 3)
  6785. $verifyStaff = array (
  6786. 'final' => $status,
  6787. $this->staff [0] ['sid'] => array (
  6788. 'date' => date ( 'Y-m-d' ),
  6789. 'opinion' => $opinion,
  6790. 'status' => $status
  6791. )
  6792. );
  6793. $vStaffString = json_encode ( $verifyStaff );
  6794. $receipt->nowStaff = $nowStaff;
  6795. $receipt->verifyStaff = $vStaffString;
  6796. } else {
  6797. $VS = end ( $verifyStaff );
  6798. // 非角色审批
  6799. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  6800. $nextStaff = 0;
  6801. $roleSTF = false;
  6802. foreach ( $verifyDetail as $key => $value ) {
  6803. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  6804. if (isset ( $verifyDetail [$key + 1] )) {
  6805. $nextStaff = $verifyDetail [$key + 1] [0];
  6806. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  6807. $roleSTF = true;
  6808. }
  6809. break;
  6810. }
  6811. }
  6812. if (! $roleSTF) {
  6813. $nowStaff = $nextStaff;
  6814. $verifyStaff [$this->staff [0] ['sid']] = array (
  6815. 'date' => date ( 'Y-m-d' ),
  6816. 'opinion' => $opinion,
  6817. 'status' => $status,
  6818. 'nextStaff' => $nextStaff
  6819. );
  6820. } else {
  6821. // 获取角色下的所有用户ID
  6822. $nowStaffList = array ();
  6823. foreach ( $verifyDetail as $vfk ) {
  6824. if ($vfk [1] == 'ROLE') {
  6825. $vStaffString = json_decode ( $vfk [3] );
  6826. foreach ( $vStaffString as $key => $value ) {
  6827. $staffK = explode ( "_", $value );
  6828. array_push ( $nowStaffList, $staffK [0] );
  6829. }
  6830. }
  6831. }
  6832. $nowStaff = implode ( ',', $nowStaffList );
  6833. $verifyStaff [$this->staff [0] ['sid']] = array (
  6834. 'date' => date ( 'Y-m-d' ),
  6835. 'opinion' => $opinion,
  6836. 'status' => $status,
  6837. 'nextStaff' => $nextStaff,
  6838. 'ROLE' => 0
  6839. );
  6840. }
  6841. if ($status == 3) {
  6842. $verifyStaff ['final'] = $status;
  6843. $verifyStaff [$this->staff [0] ['sid']] = array (
  6844. 'date' => date ( 'Y-m-d' ),
  6845. 'opinion' => $opinion,
  6846. 'status' => $status
  6847. );
  6848. }
  6849. $vStaffString = json_encode ( $verifyStaff );
  6850. $receipt->nowStaff = $nowStaff;
  6851. $receipt->verifyStaff = $vStaffString;
  6852. }
  6853. // 角色审批
  6854. if (isset ( $VS ['ROLE'] )) {
  6855. // 找出角色人 当前审批角色组
  6856. $verifyJSStaff = array ();
  6857. $nowStaffList2 = array ();
  6858. foreach ( $verifyDetail as $key => $value ) {
  6859. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  6860. $verifyJSStaff = json_decode ( $value [3] );
  6861. foreach ( $verifyJSStaff as $m ) {
  6862. $staffK = explode ( "_", $m );
  6863. array_push ( $nowStaffList2, $staffK [0] );
  6864. }
  6865. // print_r($nowStaffList2);
  6866. }
  6867. }
  6868. $RoleVerifyStaff = array ();
  6869. foreach ( $verifyStaff as $key => $value ) {
  6870. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  6871. foreach ( $nowStaffList2 as $m ) {
  6872. if ($key == $m . "_R")
  6873. $RoleVerifyStaff [$key] = $value;
  6874. }
  6875. }
  6876. }
  6877. // print_r($verifyStaff);
  6878. // print_r($nowStaffList2);
  6879. // print_r($RoleVerifyStaff);
  6880. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  6881. // print_r($verifyJSStaff);
  6882. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  6883. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  6884. // 下一个审批人ID
  6885. $nextStaff = 0;
  6886. $falg = false;
  6887. foreach ( $verifyDetail as $key => $value ) {
  6888. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  6889. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  6890. $falg = true;
  6891. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  6892. $nowStaffList = array ();
  6893. foreach ( $vStaffString as $v ) {
  6894. $staffK = explode ( "_", $v );
  6895. array_push ( $nowStaffList, $staffK [0] );
  6896. }
  6897. $nowStaff = implode ( ',', $nowStaffList );
  6898. $nextStaff = $verifyDetail [$key + 1] [0];
  6899. } elseif (isset ( $verifyDetail [$key + 1] )) {
  6900. $nextStaff = $verifyDetail [$key + 1] [0];
  6901. $nowStaff = $nextStaff;
  6902. } else
  6903. $nowStaff = '';
  6904. break;
  6905. }
  6906. }
  6907. if ($falg)
  6908. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6909. 'date' => date ( 'Y-m-d' ),
  6910. 'opinion' => $opinion,
  6911. 'status' => $status,
  6912. 'nextStaff' => $nextStaff,
  6913. 'ROLE' => 1
  6914. );
  6915. else
  6916. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6917. 'date' => date ( 'Y-m-d' ),
  6918. 'opinion' => $opinion,
  6919. 'status' => $status,
  6920. 'nextStaff' => $nextStaff
  6921. );
  6922. // print_r($verifyStaff);
  6923. // echo $nowStaff;die;
  6924. } else { // 进入下一个角色或者审批人
  6925. /*
  6926. *
  6927. */
  6928. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  6929. //
  6930. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  6931. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6932. 'date' => date ( 'Y-m-d' ),
  6933. 'opinion' => $opinion,
  6934. 'status' => $status,
  6935. 'nextStaff' => $VS ['nextStaff'],
  6936. 'ROLE' => 1
  6937. );
  6938. // print_r($verifyStaff);
  6939. // die;
  6940. }
  6941. if ($status == 3) {
  6942. $verifyStaff ['final'] = $status;
  6943. $verifyStaff [$this->staff [0] ['sid']] = array (
  6944. 'date' => date ( 'Y-m-d' ),
  6945. 'opinion' => $opinion,
  6946. 'status' => $status
  6947. );
  6948. }
  6949. $vStaffString = json_encode ( $verifyStaff );
  6950. $receipt->verifyStaff = $vStaffString;
  6951. $receipt->nowStaff = $nowStaff;
  6952. // die;
  6953. // }
  6954. // print_r($verifyStaff);
  6955. // die;
  6956. }
  6957. // print_r($verifyStaff);die;
  6958. }
  6959. // print_r($verifyDetail);
  6960. $roleKey = 0;
  6961. $roleId = 0;
  6962. $verifyDetailCopy = array ();
  6963. foreach ( $verifyDetail as $k => $v ) {
  6964. if ($v [1] == 'ROLE') {
  6965. $roleId = $v [0];
  6966. $roleVerify = json_decode ( $v [3], true );
  6967. $roleKey = $k;
  6968. $roleArray = array ();
  6969. foreach ( $roleVerify as $o => $p ) {
  6970. $staffID = explode ( '_', $p );
  6971. $exp = array (
  6972. 0 => $staffID [0],
  6973. 1 => $staffID [1]
  6974. );
  6975. array_push ( $roleArray, $exp );
  6976. }
  6977. $verifyDetailCopy [$v [0]] = $roleArray;
  6978. }
  6979. }
  6980. // print_r($verifyDetail);
  6981. foreach ( $verifyDetailCopy as $k => $v ) {
  6982. foreach ( $verifyDetail as $m => $n ) {
  6983. if ($n [0] == $k) {
  6984. array_splice ( $verifyDetail, $m, 1, $v );
  6985. }
  6986. }
  6987. }
  6988. // die;
  6989. // if (!empty($roleArray))
  6990. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  6991. // echo $roleId;
  6992. // print_r($verifyStaff);
  6993. // print_r($verifyDetail);
  6994. // die;
  6995. Doo::loadModel ( "receiptLog" );
  6996. $receiptLog = new receiptLog ();
  6997. // 审批日志
  6998. if (! isset ( $verifyStaff ['final'] )) {
  6999. if (! empty ( $roleId )) {
  7000. Doo::loadModel ( "role" );
  7001. $role = new role ();
  7002. $roleInfo = $role->getOne ( array (
  7003. 'where' => 'rid=' . $roleId,
  7004. 'asArray' => true
  7005. ) );
  7006. $receiptLog->rolename = $roleInfo ['name'];
  7007. }
  7008. $receiptLog->username = $this->staff [0] ['username'];
  7009. $receiptLog->uid = $this->staff [0] ['sid'];
  7010. $receiptLog->date = date ( "Y-m-d" );
  7011. $receiptLog->opinion = $opinion;
  7012. $receiptLog->img = $this->staff [0] ['avatar'];
  7013. $receiptLog->status = 1;
  7014. $receiptLog->rid = $rid;
  7015. $receiptLog->insert ();
  7016. }
  7017. if (isset ( $verifyStaff ['final'] )) { // rDetail
  7018. $receipt->verifyBreakup = $verifyString;
  7019. $receipt->status = 3;
  7020. $receiptDetailObj->status = 3;
  7021. $receiptDetailObj->update ( array (
  7022. 'where' => 'rid=' . $rid
  7023. ) );
  7024. if (! empty ( $roleId )) {
  7025. Doo::loadModel ( "role" );
  7026. $role = new role ();
  7027. $roleInfo = $role->getOne ( array (
  7028. 'where' => 'rid=' . $roleId,
  7029. 'asArray' => true
  7030. ) );
  7031. $receiptLog->rolename = $roleInfo ['name'];
  7032. }
  7033. $receiptLog->username = $this->staff [0] ['username'];
  7034. $receiptLog->uid = $this->staff [0] ['sid'];
  7035. $receiptLog->date = date ( "Y-m-d" );
  7036. $receiptLog->opinion = $opinion;
  7037. $receiptLog->img = $this->staff [0] ['avatar'];
  7038. $receiptLog->status = 3;
  7039. $receiptLog->rid = $rid;
  7040. $receiptLog->insert ();
  7041. // 微信企业号通知
  7042. $this->setWXMsg ( $rid, 3 );
  7043. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  7044. $receipt->status = 1;
  7045. $reviseSum = 0;
  7046. $receipt->verifyBreakup = $verifyString;
  7047. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  7048. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7049. foreach ( $reviseDetail as $key => $value ) {
  7050. $receiptDetailObj = new receiptDetail ();
  7051. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7052. $receiptDetailObj->item = $value ['description'];
  7053. $receiptDetailObj->itemCategory = "报销金额调整";
  7054. $receiptDetailObj->price = $value ['price'];
  7055. $receiptDetailObj->date = $receiptDetail ['date'];
  7056. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  7057. $receiptDetailObj->rid = $rid;
  7058. $receiptDetailObj->status = 1;
  7059. $receiptDetailObj->insert ();
  7060. $reviseSum += $value ['price'];
  7061. }
  7062. $itemStatistics = new itemStatistics ();
  7063. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7064. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7065. $itemStatistics->price = $reviseSum;
  7066. $itemStatistics->itemCategory = "报销金额调整";
  7067. $itemStatistics->date = $receiptDetail ['date'];
  7068. $itemStatistics->insert ();
  7069. }
  7070. $receiptDetailObj = new receiptDetail ();
  7071. $receiptDetailObj->status = 1;
  7072. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  7073. $receiptDetailObj->update ( array (
  7074. 'where' => 'rid=' . $rid
  7075. ) );
  7076. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7077. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7078. $stat = $statistics->getOne ( array (
  7079. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  7080. 'asArray' => true
  7081. ) );
  7082. if (empty ( $stat )) {
  7083. $statistics->date = $receiptDetail ['date'];
  7084. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7085. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7086. $statistics->agPrice = $receiptDetail ['sum'];
  7087. $statistics->rePrice = $reviseSum;
  7088. $statistics->insert ();
  7089. } else {
  7090. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  7091. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  7092. $statistics->update ( array (
  7093. 'where' => 'sid=' . $stat ['sid']
  7094. ) );
  7095. }
  7096. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7097. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7098. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  7099. foreach ( $accountItem ['cSum'] as $key => $value ) {
  7100. if ($key == "agencySum") {
  7101. $iStatistics = $itemStatistics->getOne ( array (
  7102. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  7103. 'asArray' => true
  7104. ) );
  7105. if (empty ( $iStatistics )) {
  7106. $itemStatistics->cid = $receiptDetail ['cid'];
  7107. ;
  7108. $itemStatistics->staff = $receiptDetail ['staff'];
  7109. $itemStatistics->price = $value;
  7110. $itemStatistics->itemCategory = $this->AGENCY;
  7111. $itemStatistics->date = $receiptDetail ['date'];
  7112. $itemStatistics->insert ();
  7113. } else {
  7114. if (! empty ( $value )) {
  7115. $itemStatistics->price = $value + $iStatistics ['price'];
  7116. $itemStatistics->update ( array (
  7117. 'where' => 'sid=' . $iStatistics ['sid']
  7118. ) );
  7119. }
  7120. }
  7121. } elseif ($key == "travelSum") {
  7122. $iStatistics = $itemStatistics->getOne ( array (
  7123. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  7124. 'asArray' => true
  7125. ) );
  7126. if (empty ( $iStatistics )) {
  7127. $itemStatistics->cid = $receiptDetail ['cid'];
  7128. $itemStatistics->staff = $receiptDetail ['staff'];
  7129. $itemStatistics->price = $value;
  7130. $itemStatistics->itemCategory = $this->TRAVEL;
  7131. $itemStatistics->date = $receiptDetail ['date'];
  7132. $itemStatistics->insert ();
  7133. } else {
  7134. if (! empty ( $value )) {
  7135. $itemStatistics->price = $value + $iStatistics ['price'];
  7136. $itemStatistics->update ( array (
  7137. 'where' => 'sid=' . $iStatistics ['sid']
  7138. ) );
  7139. }
  7140. }
  7141. } elseif ($key == "trainSum") {
  7142. $iStatistics = $itemStatistics->getOne ( array (
  7143. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  7144. 'asArray' => true
  7145. ) );
  7146. if (empty ( $iStatistics )) {
  7147. $itemStatistics->cid = $receiptDetail ['cid'];
  7148. $itemStatistics->staff = $receiptDetail ['staff'];
  7149. $itemStatistics->price = $value;
  7150. $itemStatistics->itemCategory = $this->TRAIN;
  7151. $itemStatistics->date = $receiptDetail ['date'];
  7152. $itemStatistics->insert ();
  7153. } else {
  7154. if (! empty ( $value )) {
  7155. $itemStatistics->price = $value + $iStatistics ['price'];
  7156. $itemStatistics->update ( array (
  7157. 'where' => 'sid=' . $iStatistics ['sid']
  7158. ) );
  7159. }
  7160. }
  7161. } elseif ($key == "otherSum") {
  7162. $iStatistics = $itemStatistics->getOne ( array (
  7163. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  7164. 'asArray' => true
  7165. ) );
  7166. if (empty ( $iStatistics )) {
  7167. $itemStatistics->cid = $receiptDetail ['cid'];
  7168. $itemStatistics->staff = $receiptDetail ['staff'];
  7169. $itemStatistics->price = $value;
  7170. $itemStatistics->itemCategory = $this->OTHER;
  7171. $itemStatistics->date = $receiptDetail ['date'];
  7172. $itemStatistics->insert ();
  7173. } else {
  7174. if (! empty ( $value )) {
  7175. $itemStatistics->price = $value + $iStatistics ['price'];
  7176. $itemStatistics->update ( array (
  7177. 'where' => 'sid=' . $iStatistics ['sid']
  7178. ) );
  7179. }
  7180. }
  7181. }
  7182. }
  7183. $receipt->pastDate = date ( "Y-m-d" );
  7184. // 微信企业号通知
  7185. $this->setWXMsg ( $rid, 1 );
  7186. }
  7187. $receipt->amount = $amount;
  7188. $receipt->update ( array (
  7189. 'where' => ' rid = ' . $rid
  7190. ) );
  7191. return "/approvalExpenses/pendApproval";
  7192. }
  7193. }
  7194. function expensesRetreats() {
  7195. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7196. if (! empty ( $rid )) {
  7197. // 操作记录
  7198. Doo::loadModel ( "receipt" );
  7199. $receipt = new receipt ();
  7200. Doo::loadModel ( "receiptLog" );
  7201. $receiptLog = new receiptLog ();
  7202. Doo::loadModel ( "verify" );
  7203. $verify = new verify ();
  7204. $receiptInfo = $receipt->getOne ( array (
  7205. 'where' => 'rid=' . $rid,
  7206. 'asArray' => true
  7207. ) );
  7208. $vr = $verify->getOne ( array (
  7209. 'where' => 'vid=' . $receiptInfo ['verify'],
  7210. 'asArray' => true
  7211. ) );
  7212. $jd = json_decode ( $vr ['staff'] );
  7213. $roleId = 0;
  7214. foreach ( $jd as $key => $value ) {
  7215. if ($value [1] == 'ROLE') {
  7216. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7217. if ($pos !== false) {
  7218. $roleId = $value [0];
  7219. }
  7220. }
  7221. }
  7222. // 审批日志
  7223. // echo $roleId;die;
  7224. if (! empty ( $roleId )) {
  7225. Doo::loadModel ( "role" );
  7226. $role = new role ();
  7227. $roleInfo = $role->getOne ( array (
  7228. 'where' => 'rid=' . $roleId,
  7229. 'asArray' => true
  7230. ) );
  7231. $receiptLog->rolename = $roleInfo ['name'];
  7232. }
  7233. $receiptLog->username = $this->staff [0] ['username'];
  7234. $receiptLog->uid = $this->staff [0] ['sid'];
  7235. $receiptLog->date = date ( "Y-m-d" );
  7236. $receiptLog->opinion = '撤回';
  7237. $receiptLog->img = $this->staff [0] ['avatar'];
  7238. $receiptLog->status = 4;
  7239. $receiptLog->rid = $rid;
  7240. $receiptLog->insert ();
  7241. $receipt->status = 4;
  7242. $receipt->update ( array (
  7243. 'where' => 'rid=' . $rid
  7244. ) );
  7245. // 微信企业号通知
  7246. $this->setWXMsg ( $rid, 2 );
  7247. }
  7248. // echo "ddd";
  7249. return '/approvalExpenses/pendApproval';
  7250. }
  7251. function updateCheReceipt() {
  7252. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7253. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7254. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  7255. if (! empty ( $rid )) {
  7256. // 操作记录
  7257. Doo::loadModel ( "receipt" );
  7258. $receipt = new receipt ();
  7259. Doo::loadModel ( "receiptLog" );
  7260. $receiptLog = new receiptLog ();
  7261. Doo::loadModel ( "verify" );
  7262. $verify = new verify ();
  7263. $receiptInfo = $receipt->getOne ( array (
  7264. 'where' => 'rid=' . $rid.' and status=2',
  7265. 'asArray' => true
  7266. ) );
  7267. if(empty($receiptInfo)){
  7268. echo json_encode ( array (
  7269. 'status' => 2
  7270. ) );
  7271. die ();
  7272. }
  7273. $vr = $verify->getOne ( array (
  7274. 'where' => 'vid=' . $receiptInfo ['verify'],
  7275. 'asArray' => true
  7276. ) );
  7277. $jd = json_decode ( $vr ['staff'] );
  7278. $roleId = 0;
  7279. foreach ( $jd as $key => $value ) {
  7280. if ($value [1] == 'ROLE') {
  7281. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7282. if ($pos !== false) {
  7283. $roleId = $value [0];
  7284. }
  7285. }
  7286. }
  7287. // 审批日志
  7288. // echo $roleId;die;
  7289. if (! empty ( $roleId )) {
  7290. Doo::loadModel ( "role" );
  7291. $role = new role ();
  7292. $roleInfo = $role->getOne ( array (
  7293. 'where' => 'rid=' . $roleId,
  7294. 'asArray' => true
  7295. ) );
  7296. $receiptLog->rolename = $roleInfo ['name'];
  7297. }
  7298. $receiptLog->username = $this->staff [0] ['username'];
  7299. $receiptLog->uid = $this->staff [0] ['sid'];
  7300. $receiptLog->date = date ( "Y-m-d" );
  7301. $receiptLog->opinion = $opinion;
  7302. $receiptLog->img = $this->staff [0] ['avatar'];
  7303. $receiptLog->status = 4;
  7304. $receiptLog->rid = $rid;
  7305. $receiptLog->insert ();
  7306. $receipt->status = 4;
  7307. $receipt->update ( array (
  7308. 'where' => 'rid=' . $rid
  7309. ) );
  7310. // 微信企业号通知
  7311. $this->setWXMsg ( $rid, 2 );
  7312. echo json_encode ( array (
  7313. 'status' => 1
  7314. ) );
  7315. //Header("HTTP/1.1 303 See Other");
  7316. //Header("Location: /approvalExpenses/pendApproval");
  7317. die;
  7318. }
  7319. echo json_encode ( array (
  7320. 'status' => 2
  7321. ) );
  7322. die ();
  7323. // echo "ddd";
  7324. // return '/saeaBorad';
  7325. }
  7326. function revisePrice() {
  7327. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  7328. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  7329. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7330. // echo $price;die;
  7331. if (! empty ( $rid )) {
  7332. Doo::loadModel ( "receipt" );
  7333. $receipt = new receipt ();
  7334. $receiptDetail = $receipt->getOne ( array (
  7335. 'where' => 'rid=' . $rid . ' and status=2 ',
  7336. 'asArray' => true
  7337. ) );
  7338. if (empty ( $receiptDetail ))
  7339. return "/approval";
  7340. $reviseDetail = array ();
  7341. if (empty ( $receiptDetail ['reviseDetail'] )) {
  7342. array_push ( $reviseDetail, array (
  7343. 'sid' => $this->staff [0] ['sid'],
  7344. 'name' => $this->staff [0] ['username'],
  7345. 'description' => $description,
  7346. 'price' => $price
  7347. ) );
  7348. $reviseDetailString = json_encode ( $reviseDetail );
  7349. $receipt->reviseDetail = $reviseDetailString;
  7350. $receipt->revisePrice = $price;
  7351. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7352. } else {
  7353. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7354. array_push ( $reviseDetail, array (
  7355. 'sid' => $this->staff [0] ['sid'],
  7356. 'name' => $this->staff [0] ['username'],
  7357. 'description' => $description,
  7358. 'price' => $price
  7359. ) );
  7360. $reviseDetailString = json_encode ( $reviseDetail );
  7361. $receipt->reviseDetail = $reviseDetailString;
  7362. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  7363. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7364. }
  7365. $receipt->update ( array (
  7366. 'where' => 'rid=' . $rid
  7367. ) );
  7368. }
  7369. return '/approvalEdi/' . $rid;
  7370. }
  7371. function personalCollect() {
  7372. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7373. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  7374. $this->showCache ( $path );
  7375. Doo::loadModel ( "receiptDetail" );
  7376. Doo::loadModel ( "itemStatistics" );
  7377. Doo::loadModel ( 'statistics' );
  7378. $statistics = new statistics ();
  7379. $itemStatistics = new itemStatistics ();
  7380. $receiptDetail = new receiptDetail ();
  7381. $receiptCollectList = $receiptDetail->find ( array (
  7382. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7383. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7384. 'groupby' => 'itemCategory,Month(date)',
  7385. 'asArray' => true
  7386. ) );
  7387. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  7388. 'where' => 'staff=' . $this->staff [0] ['sid'],
  7389. 'asArray' => true
  7390. ) );
  7391. // create collect html
  7392. $collectArray = array (
  7393. '日常相关费用' => array (),
  7394. '差旅相关费用' => array (),
  7395. '培训班费用' => array (),
  7396. '其他' => array ()
  7397. );
  7398. $adjustment = array ();
  7399. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  7400. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7401. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  7402. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7403. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  7404. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7405. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  7406. array_push ( $collectArray ['其他'], $collectHtml );
  7407. $data ['collectArray'] = $collectArray;
  7408. // statistics html
  7409. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7410. if (empty ( $stList ))
  7411. $stList = array (
  7412. 'rePrice' => 0,
  7413. 'agPrice' => 0
  7414. );
  7415. $data ['stList'] = array (
  7416. 'rePrice' => $stList ['rePrice'],
  7417. 'agPrice' => $stList ['agPrice'],
  7418. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7419. );
  7420. // Adjustment price html
  7421. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7422. array_push ( $adjustment, $collectHtml );
  7423. $data ['adjustment'] = $adjustment;
  7424. // total price html
  7425. $collectHtml = "";
  7426. $total = 0;
  7427. for($i = 1; $i <= 12; $i ++) {
  7428. $sumPrice = 0;
  7429. foreach ( $receiptCollectList as $key => $value ) {
  7430. if ($value ['month'] == $i) {
  7431. $sumPrice += $value ['price'];
  7432. }
  7433. }
  7434. if ($sumPrice == 0)
  7435. $collectHtml .= '<td class="taR">-</td>';
  7436. else
  7437. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7438. $total += $sumPrice;
  7439. }
  7440. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7441. $data ['totalPrice'] = $collectHtml;
  7442. $data ['year'] = $year;
  7443. $data ['totalYear'] = $total;
  7444. $data ['memu'] = "receipt";
  7445. $data ['staff'] = $this->staff;
  7446. $data ['receiptMemu'] = 'personalCollect';
  7447. $data ['verifyId'] = $this->verifyId;
  7448. $data ['executeId'] = $this->executeId;
  7449. // year staff status 2,4
  7450. if ($year < date ( "Y" )) {
  7451. Doo::loadModel ( 'receipt' );
  7452. $receipt = new receipt ();
  7453. $receiptList = $receipt->find ( array (
  7454. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7455. 'asArray' => true
  7456. ) );
  7457. if (empty ( $receiptList )) {
  7458. ob_start ();
  7459. $this->render ( "/admin/saea_slist_collect", $data );
  7460. $this->cacheFile ( $path );
  7461. die ();
  7462. }
  7463. }
  7464. $this->render ( "/admin/saea_slist_collect", $data );
  7465. }
  7466. function personalCollectDetail() {
  7467. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7468. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  7469. $this->showCache ( $path );
  7470. Doo::loadModel ( "receiptDetail" );
  7471. Doo::loadModel ( "itemStatistics" );
  7472. Doo::loadModel ( 'statistics' );
  7473. Doo::loadModel ( 'accountItem' );
  7474. $accountItem = new accountItem ();
  7475. $statistics = new statistics ();
  7476. $itemStatistics = new itemStatistics ();
  7477. $receiptDetail = new receiptDetail ();
  7478. $receiptCollectList = $receiptDetail->find ( array (
  7479. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  7480. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7481. 'groupby' => 'item,Month(date)',
  7482. 'asArray' => true
  7483. ) );
  7484. $accountList = $accountItem->find ( array (
  7485. 'asArray' => true
  7486. ) );
  7487. // create CollectDetail HTML
  7488. $collectHtml = array ();
  7489. foreach ( $accountList as $key => $value ) {
  7490. $html = "";
  7491. $asum = 0;
  7492. for($i = 1; $i <= 12; $i ++) {
  7493. $falg = true;
  7494. foreach ( $receiptCollectList as $v ) {
  7495. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7496. $asum += $v ['price'];
  7497. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7498. $falg = false;
  7499. break;
  7500. }
  7501. }
  7502. if ($falg)
  7503. $html .= '<td class="taR">-</td>';
  7504. }
  7505. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7506. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7507. }
  7508. $data ['collectHtml'] = $collectHtml;
  7509. // create Adjustment price html
  7510. $receiptCollectList = $receiptDetail->find ( array (
  7511. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7512. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7513. 'groupby' => 'itemCategory,Month(date)',
  7514. 'asArray' => true
  7515. ) );
  7516. $adjustment = array ();
  7517. $collectArray = array (
  7518. '日常相关费用' => array (),
  7519. '差旅相关费用' => array (),
  7520. '培训班费用' => array (),
  7521. '其他' => array ()
  7522. );
  7523. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7524. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7525. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7526. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7527. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7528. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7529. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7530. array_push ( $collectArray ['其他'], $collectHtml );
  7531. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7532. array_push ( $adjustment, $collectHtml );
  7533. // total price html
  7534. $collectHtml = "";
  7535. $total = 0;
  7536. for($i = 1; $i <= 12; $i ++) {
  7537. $sumPrice = 0;
  7538. foreach ( $receiptCollectList as $key => $value ) {
  7539. if ($value ['month'] == $i) {
  7540. $sumPrice += $value ['price'];
  7541. }
  7542. }
  7543. if ($sumPrice == 0)
  7544. $collectHtml .= '<td class="taR">-</td>';
  7545. else
  7546. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7547. $total += $sumPrice;
  7548. }
  7549. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7550. // statistics html
  7551. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7552. if (empty ( $stList ))
  7553. $stList = array (
  7554. 'rePrice' => 0,
  7555. 'agPrice' => 0
  7556. );
  7557. $data ['stList'] = array (
  7558. 'rePrice' => $stList ['rePrice'],
  7559. 'agPrice' => $stList ['agPrice'],
  7560. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7561. );
  7562. $data ['collectArray'] = $collectArray;
  7563. $data ['adjustment'] = $adjustment;
  7564. $data ['totalPrice'] = $collectHtml;
  7565. $data ['totalYear'] = $total;
  7566. $data ['year'] = $year;
  7567. $data ['memu'] = "receipt";
  7568. $data ['staff'] = $this->staff;
  7569. $data ['receiptMemu'] = 'personalCollect';
  7570. $data ['verifyId'] = $this->verifyId;
  7571. $data ['executeId'] = $this->executeId;
  7572. // year staff status 2,4
  7573. if ($year < date ( "Y" )) {
  7574. Doo::loadModel ( 'receipt' );
  7575. $receipt = new receipt ();
  7576. $receiptList = $receipt->find ( array (
  7577. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7578. 'asArray' => true
  7579. ) );
  7580. if (empty ( $receiptList )) {
  7581. ob_start ();
  7582. $this->render ( "/admin/saeaCollectArticles", $data );
  7583. $this->cacheFile ( $path );
  7584. die ();
  7585. }
  7586. }
  7587. $this->render ( "/admin/saeaCollectArticles", $data );
  7588. }
  7589. function companyCategoryCollect() {
  7590. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7591. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  7592. $this->showCache ( $path );
  7593. Doo::loadModel ( 'L_category' );
  7594. Doo::loadModel ( 'itemStatistics' );
  7595. Doo::loadModel ( 'statistics' );
  7596. $statistics = new statistics ();
  7597. $Lcategory = new L_category ();
  7598. $itemStatistics = new itemStatistics ();
  7599. $LcategoryList = $Lcategory->find ( array (
  7600. 'asArray' => true
  7601. ) ); // 'staff='.$this->staff[0]['sid']." and
  7602. $itemStatisticsList = $itemStatistics->find ( array (
  7603. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7604. 'where' => " Year(date)=" . $year,
  7605. 'groupby' => 'cid,Month(date)',
  7606. 'asArray' => true
  7607. ) );
  7608. // ceatre companyCollectHtml
  7609. foreach ( $LcategoryList as $value ) {
  7610. $html = "";
  7611. $asum = 0;
  7612. for($i = 1; $i <= 12; $i ++) {
  7613. $falg = true;
  7614. foreach ( $itemStatisticsList as $v ) {
  7615. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  7616. $asum += $v ['price'];
  7617. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7618. $falg = false;
  7619. break;
  7620. }
  7621. }
  7622. if ($falg)
  7623. $html .= '<td class="taR">-</td>';
  7624. }
  7625. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7626. $collectHtml [$value ['title']] = array (
  7627. 'html' => $html,
  7628. 'cid' => $value ['cid']
  7629. );
  7630. }
  7631. $data ['companyHtml'] = $collectHtml;
  7632. // total price html
  7633. $collectHtml = "";
  7634. $total = 0;
  7635. for($i = 1; $i <= 12; $i ++) {
  7636. $sumPrice = 0;
  7637. foreach ( $itemStatisticsList as $key => $value ) {
  7638. if ($value ['month'] == $i) {
  7639. $sumPrice += $value ['price'];
  7640. }
  7641. }
  7642. if ($sumPrice == 0)
  7643. $collectHtml .= '<td class="taR">-</td>';
  7644. else
  7645. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7646. $total += $sumPrice;
  7647. }
  7648. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7649. $data ['companyTotalHtml'] = $collectHtml;
  7650. $data ['total'] = $total;
  7651. // statistics html
  7652. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7653. if (empty ( $stList ))
  7654. $stList = array (
  7655. 'rePrice' => 0,
  7656. 'agPrice' => 0
  7657. );
  7658. $data ['stList'] = array (
  7659. 'rePrice' => $stList ['rePrice'],
  7660. 'agPrice' => $stList ['agPrice'],
  7661. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7662. );
  7663. $data ['year'] = $year;
  7664. $data ['memu'] = "receipt";
  7665. $data ['staff'] = $this->staff;
  7666. $data ['receiptMemu'] = 'companyCategoryCollect';
  7667. $data ['verifyId'] = $this->verifyId;
  7668. $data ['executeId'] = $this->executeId;
  7669. // year staff status 2,4
  7670. if ($year < date ( "Y" )) {
  7671. Doo::loadModel ( 'receipt' );
  7672. $receipt = new receipt ();
  7673. $receiptList = $receipt->find ( array (
  7674. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  7675. 'asArray' => true
  7676. ) );
  7677. if (empty ( $receiptList )) {
  7678. ob_start ();
  7679. $this->render ( "/admin/saeaCompanyCollect", $data );
  7680. $this->cacheFile ( $path );
  7681. die ();
  7682. }
  7683. }
  7684. $this->render ( "/admin/saeaCompanyCollect", $data );
  7685. }
  7686. function categoryCollectDetail() {
  7687. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7688. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  7689. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  7690. $this->showCache ( $path );
  7691. Doo::loadModel ( 'statistics' );
  7692. $statistics = new statistics ();
  7693. Doo::loadModel ( "receiptDetail" );
  7694. $receiptDetail = new receiptDetail ();
  7695. Doo::loadModel ( 'L_category' );
  7696. $Lcategory = new L_category ();
  7697. Doo::loadModel ( 'accountItem' );
  7698. $accountItem = new accountItem ();
  7699. $LcategoryList = $Lcategory->find ( array (
  7700. 'asArray' => true
  7701. ) );
  7702. if ($cid == 0) {
  7703. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7704. if ($cid == 0)
  7705. $cid = $LcategoryList [0] ['cid'];
  7706. }
  7707. $data ['LcategoryList'] = $LcategoryList;
  7708. $receiptCollectList = $receiptDetail->find ( array (
  7709. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  7710. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7711. 'groupby' => 'item,Month(pastDate)',
  7712. 'asArray' => true
  7713. ) );
  7714. $accountList = $accountItem->find ( array (
  7715. 'asArray' => true
  7716. ) );
  7717. // create CollectDetail HTML
  7718. $collectHtml = array ();
  7719. foreach ( $accountList as $key => $value ) {
  7720. $html = "";
  7721. $asum = 0;
  7722. for($i = 1; $i <= 12; $i ++) {
  7723. $falg = true;
  7724. foreach ( $receiptCollectList as $v ) {
  7725. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7726. $asum += $v ['price'];
  7727. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7728. $falg = false;
  7729. break;
  7730. }
  7731. }
  7732. if ($falg)
  7733. $html .= '<td class="taR">-</td>';
  7734. }
  7735. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7736. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7737. }
  7738. $data ['collectHtml'] = $collectHtml;
  7739. // create Adjustment price html
  7740. $receiptCollectList = $receiptDetail->find ( array (
  7741. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  7742. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7743. 'groupby' => 'itemCategory,Month(pastDate)',
  7744. 'asArray' => true
  7745. ) );
  7746. $adjustment = array ();
  7747. $collectArray = array (
  7748. '日常相关费用' => array (),
  7749. '差旅相关费用' => array (),
  7750. '培训班费用' => array (),
  7751. '其他' => array ()
  7752. );
  7753. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7754. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7755. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7756. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7757. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7758. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7759. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7760. array_push ( $collectArray ['其他'], $collectHtml );
  7761. $data ['collectArray'] = $collectArray;
  7762. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7763. array_push ( $adjustment, $collectHtml );
  7764. $data ['adjustment'] = $adjustment;
  7765. // total price html
  7766. $collectHtml = "";
  7767. $total = 0;
  7768. for($i = 1; $i <= 12; $i ++) {
  7769. $sumPrice = 0;
  7770. foreach ( $receiptCollectList as $key => $value ) {
  7771. if ($value ['month'] == $i) {
  7772. $sumPrice += $value ['price'];
  7773. }
  7774. }
  7775. if ($sumPrice == 0)
  7776. $collectHtml .= '<td class="taR">-</td>';
  7777. else
  7778. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7779. $total += $sumPrice;
  7780. }
  7781. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7782. // statistics html
  7783. $stList = $statistics->statisticsByCid ( $year, $cid );
  7784. if (empty ( $stList ))
  7785. $stList = array (
  7786. 'rePrice' => 0,
  7787. 'agPrice' => 0
  7788. );
  7789. $data ['stList'] = array (
  7790. 'rePrice' => $stList ['rePrice'],
  7791. 'agPrice' => $stList ['agPrice'],
  7792. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7793. );
  7794. $data ['totalYear'] = $total;
  7795. $data ['year'] = $year;
  7796. $data ['cid'] = $cid;
  7797. $data ['memu'] = "receipt";
  7798. $data ['staff'] = $this->staff;
  7799. $data ['receiptMemu'] = 'companyCategoryCollect';
  7800. $data ['verifyId'] = $this->verifyId;
  7801. $data ['executeId'] = $this->executeId;
  7802. // year staff status 2,4
  7803. if ($year < date ( "Y" )) {
  7804. Doo::loadModel ( 'receipt' );
  7805. $receipt = new receipt ();
  7806. $receiptList = $receipt->find ( array (
  7807. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  7808. 'asArray' => true
  7809. ) );
  7810. if (empty ( $receiptList )) {
  7811. ob_start ();
  7812. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7813. $this->cacheFile ( $path );
  7814. die ();
  7815. }
  7816. }
  7817. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7818. }
  7819. function staffCollect() {
  7820. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7821. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  7822. // $this->showCache($path);
  7823. Doo::loadModel ( 'statistics' );
  7824. $statistics = new statistics ();
  7825. Doo::loadModel ( "receiptDetail" );
  7826. $receiptDetail = new receiptDetail ();
  7827. Doo::loadModel ( 'L_category' );
  7828. $Lcategory = new L_category ();
  7829. Doo::loadModel ( 'accountItem' );
  7830. $accountItem = new accountItem ();
  7831. Doo::loadModel ( 'staff' );
  7832. $staff = new staff ();
  7833. Doo::loadModel ( 'itemStatistics' );
  7834. $itemStatistics = new itemStatistics ();
  7835. /*
  7836. * $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']));
  7837. */
  7838. // statistics html
  7839. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7840. if (empty ( $stList ))
  7841. $stList = array (
  7842. 'rePrice' => 0,
  7843. 'agPrice' => 0
  7844. );
  7845. $data ['stList'] = array (
  7846. 'rePrice' => $stList ['rePrice'],
  7847. 'agPrice' => $stList ['agPrice'],
  7848. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7849. );
  7850. // ---
  7851. $staffList = $staff->find ( array (
  7852. 'where' => 'username !="admin"',
  7853. 'asArray' => true
  7854. ) );
  7855. $LcategoryList = $Lcategory->find ( array (
  7856. 'asArray' => true
  7857. ) ); // 'staff='.$this->staff[0]['sid']." and
  7858. $itemStatisticsList = $itemStatistics->find ( array (
  7859. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7860. 'where' => " Year(date)=" . $year,
  7861. 'groupby' => 'staff,Month(date)',
  7862. 'asArray' => true
  7863. ) );
  7864. $categoryList = $staff->find ( array (
  7865. 'select' => 'COUNT(*) as count,cid,category',
  7866. 'where' => 'username !="admin"',
  7867. 'groupby' => 'cid',
  7868. 'asArray' => true
  7869. ) );
  7870. // print_r($itemStatisticsList);die;
  7871. // ceatre companyCollectHtml
  7872. foreach ( $categoryList as $vlu ) {
  7873. $count = $vlu ['count'] + 1;
  7874. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  7875. $m1 = 0;
  7876. $m2 = 0;
  7877. $m3 = 0;
  7878. $m4 = 0;
  7879. $m5 = 0;
  7880. $m6 = 0;
  7881. $m7 = 0;
  7882. $m8 = 0;
  7883. $m9 = 0;
  7884. $m10 = 0;
  7885. $m11 = 0;
  7886. $m12 = 0;
  7887. $m13 = 0;
  7888. foreach ( $staffList as $value ) {
  7889. if ($vlu ['cid'] == $value ['cid']) {
  7890. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  7891. $asum = 0;
  7892. for($i = 1; $i <= 12; $i ++) {
  7893. $falg = true;
  7894. foreach ( $itemStatisticsList as $v ) {
  7895. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  7896. if ($v ['month'] == 1)
  7897. $m1 += $v ['price'];
  7898. if ($v ['month'] == 2)
  7899. $m2 += $v ['price'];
  7900. if ($v ['month'] == 3)
  7901. $m3 += $v ['price'];
  7902. if ($v ['month'] == 4)
  7903. $m4 += $v ['price'];
  7904. if ($v ['month'] == 5)
  7905. $m5 += $v ['price'];
  7906. if ($v ['month'] == 6)
  7907. $m6 += $v ['price'];
  7908. if ($v ['month'] == 7)
  7909. $m7 += $v ['price'];
  7910. if ($v ['month'] == 8)
  7911. $m8 += $v ['price'];
  7912. if ($v ['month'] == 9)
  7913. $m9 += $v ['price'];
  7914. if ($v ['month'] == 10)
  7915. $m10 += $v ['price'];
  7916. if ($v ['month'] == 11)
  7917. $m11 += $v ['price'];
  7918. if ($v ['month'] == 12)
  7919. $m12 += $v ['price'];
  7920. $asum += $v ['price'];
  7921. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7922. $falg = false;
  7923. break;
  7924. }
  7925. }
  7926. if ($falg)
  7927. $html .= '<td class="taR">-</td>';
  7928. }
  7929. $m13 += $asum;
  7930. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7931. $collectHtml [$value ['username']] = array (
  7932. 'html' => $html,
  7933. 'sid' => $value ['sid']
  7934. );
  7935. $html = "";
  7936. }
  7937. }
  7938. $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>
  7939. <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>
  7940. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  7941. $collectHtml [$vlu ['cid']] = array (
  7942. 'html' => $hl,
  7943. 'sid' => ''
  7944. );
  7945. }
  7946. $data ['companyHtml'] = $collectHtml;
  7947. // total price html
  7948. $collectHtml = "";
  7949. $total = 0;
  7950. for($i = 1; $i <= 12; $i ++) {
  7951. $sumPrice = 0;
  7952. foreach ( $itemStatisticsList as $key => $value ) {
  7953. if ($value ['month'] == $i) {
  7954. $sumPrice += $value ['price'];
  7955. }
  7956. }
  7957. if ($sumPrice == 0)
  7958. $collectHtml .= '<td class="taR">-</td>';
  7959. else
  7960. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7961. $total += $sumPrice;
  7962. }
  7963. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7964. $data ['companyTotalHtml'] = $collectHtml;
  7965. $data ['total'] = $total;
  7966. $data ['year'] = $year;
  7967. $data ['memu'] = "receipt";
  7968. $data ['staff'] = $this->staff;
  7969. $data ['receiptMemu'] = 'companyCategoryCollect';
  7970. $data ['verifyId'] = $this->verifyId;
  7971. $data ['executeId'] = $this->executeId;
  7972. if ($year <= date ( "Y" )) {
  7973. Doo::loadModel ( 'receipt' );
  7974. $receipt = new receipt ();
  7975. $receiptList = $receipt->find ( array (
  7976. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  7977. 'asArray' => true
  7978. ) );
  7979. if (empty ( $receiptList )) { // generated files
  7980. ob_start ();
  7981. $this->render ( "/admin/saeaStaffCollectB", $data );
  7982. $this->cacheFile ( $path );
  7983. die ();
  7984. }
  7985. }
  7986. $this->render ( "/admin/saeaStaffCollectB", $data );
  7987. }
  7988. function staffCollectBak() {
  7989. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7990. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  7991. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  7992. $this->showCache ( $path );
  7993. Doo::loadModel ( 'statistics' );
  7994. $statistics = new statistics ();
  7995. Doo::loadModel ( "receiptDetail" );
  7996. $receiptDetail = new receiptDetail ();
  7997. Doo::loadModel ( 'L_category' );
  7998. $Lcategory = new L_category ();
  7999. Doo::loadModel ( 'accountItem' );
  8000. $accountItem = new accountItem ();
  8001. Doo::loadModel ( 'staff' );
  8002. $staff = new staff ();
  8003. Doo::loadModel ( 'itemStatistics' );
  8004. $itemStatistics = new itemStatistics ();
  8005. $itemStatisticsList = $itemStatistics->find ( array (
  8006. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8007. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8008. 'groupby' => 'staff,itemCategory,Month(date)',
  8009. 'asArray' => true
  8010. ) );
  8011. $itemCategoryList = $itemStatistics->find ( array (
  8012. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8013. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8014. 'groupby' => 'cid,itemCategory,Month(date)',
  8015. 'asArray' => true
  8016. ) );
  8017. $LcategoryList = $Lcategory->find ( array (
  8018. 'asArray' => true
  8019. ) );
  8020. $staffList = $staff->find ( array (
  8021. 'asArray' => true
  8022. ) );
  8023. $htmlArray = array ();
  8024. foreach ( $LcategoryList as $value ) {
  8025. $htmlArray [$value ['title']] = array ();
  8026. foreach ( $staffList as $v ) {
  8027. if ($value ['cid'] == $v ['cid']) {
  8028. $html = "";
  8029. $falg = true;
  8030. $staffSumPrice = 0;
  8031. foreach ( $itemStatisticsList as $a ) {
  8032. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  8033. if (empty ( $a ['price'] )) {
  8034. $html .= '<td class="taR">-</td>';
  8035. $falg = false;
  8036. break;
  8037. } else {
  8038. $staffSumPrice += $a ['price'];
  8039. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8040. $falg = false;
  8041. break;
  8042. }
  8043. }
  8044. }
  8045. if ($falg) {
  8046. $html .= '<td class="taR">-</td>';
  8047. $falg = true;
  8048. }
  8049. $falg = true;
  8050. foreach ( $itemStatisticsList as $a ) {
  8051. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  8052. if (empty ( $a ['price'] )) {
  8053. $html .= '<td class="taR">-</td>';
  8054. $falg = false;
  8055. break;
  8056. } else {
  8057. $staffSumPrice += $a ['price'];
  8058. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8059. $falg = false;
  8060. break;
  8061. }
  8062. }
  8063. }
  8064. if ($falg) {
  8065. $html .= '<td class="taR">-</td>';
  8066. $falg = true;
  8067. }
  8068. $falg = true;
  8069. foreach ( $itemStatisticsList as $a ) {
  8070. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  8071. if (empty ( $a ['price'] )) {
  8072. $html .= '<td class="taR">-</td>';
  8073. $falg = false;
  8074. break;
  8075. } else {
  8076. $staffSumPrice += $a ['price'];
  8077. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8078. $falg = false;
  8079. break;
  8080. }
  8081. }
  8082. }
  8083. if ($falg) {
  8084. $html .= '<td class="taR">-</td>';
  8085. $falg = true;
  8086. }
  8087. $falg = true;
  8088. foreach ( $itemStatisticsList as $a ) {
  8089. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  8090. if (! empty ( $a ['price'] )) {
  8091. $staffSumPrice += $a ['price'];
  8092. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8093. $falg = false;
  8094. break;
  8095. } else {
  8096. $html .= '<td class="taR">-</td>';
  8097. $falg = false;
  8098. break;
  8099. }
  8100. }
  8101. }
  8102. if ($falg) {
  8103. $html .= '<td class="taR">-</td>';
  8104. $falg = true;
  8105. }
  8106. $falg = true;
  8107. foreach ( $itemStatisticsList as $a ) {
  8108. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  8109. if (! empty ( $a ['price'] )) {
  8110. $staffSumPrice += $a ['price'];
  8111. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8112. $falg = false;
  8113. break;
  8114. } else {
  8115. $html .= '<td class="taR">-</td>';
  8116. $falg = false;
  8117. break;
  8118. }
  8119. }
  8120. }
  8121. if ($falg) {
  8122. $html .= '<td class="taR">-</td>';
  8123. $falg = true;
  8124. }
  8125. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  8126. $htmlArray [$value ['title']] [$v ['username']] = $html;
  8127. }
  8128. }
  8129. /* -- --- */
  8130. // 合计费用
  8131. $cateHtml = "";
  8132. $catePrice = 0;
  8133. $cateFalg = true;
  8134. foreach ( $itemCategoryList as $l ) {
  8135. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  8136. if (empty ( $l ['price'] )) {
  8137. $cateHtml .= '<td class="colGreen taR">-</td>';
  8138. $cateFalg = false;
  8139. break;
  8140. } else {
  8141. $catePrice += $l ['price'];
  8142. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8143. $cateFalg = false;
  8144. break;
  8145. }
  8146. }
  8147. }
  8148. if ($cateFalg) {
  8149. $cateHtml .= '<td class="colGreen taR">-</td>';
  8150. $cateFalg = true;
  8151. }
  8152. $cateFalg = true;
  8153. foreach ( $itemCategoryList as $l ) {
  8154. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  8155. if (empty ( $l ['price'] )) {
  8156. $cateHtml .= '<td class="colGreen taR">-</td>';
  8157. $cateFalg = false;
  8158. break;
  8159. } else {
  8160. $catePrice += $l ['price'];
  8161. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8162. $cateFalg = false;
  8163. break;
  8164. }
  8165. }
  8166. }
  8167. if ($cateFalg) {
  8168. $cateHtml .= '<td class="colGreen taR">-</td>';
  8169. $cateFalg = true;
  8170. }
  8171. $cateFalg = true;
  8172. foreach ( $itemCategoryList as $l ) {
  8173. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  8174. if (empty ( $l ['price'] )) {
  8175. $cateHtml .= '<td class="colGreen taR">-</td>';
  8176. $cateFalg = false;
  8177. break;
  8178. } else {
  8179. $catePrice += $l ['price'];
  8180. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8181. $cateFalg = false;
  8182. break;
  8183. }
  8184. }
  8185. }
  8186. if ($cateFalg) {
  8187. $cateHtml .= '<td class="colGreen taR">-</td>';
  8188. $cateFalg = true;
  8189. }
  8190. $cateFalg = true;
  8191. foreach ( $itemCategoryList as $l ) {
  8192. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  8193. if (empty ( $l ['price'] )) {
  8194. $cateHtml .= '<td class="colGreen taR">-</td>';
  8195. $cateFalg = false;
  8196. break;
  8197. } else {
  8198. $catePrice += $l ['price'];
  8199. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8200. $cateFalg = false;
  8201. break;
  8202. }
  8203. }
  8204. }
  8205. if ($cateFalg) {
  8206. $cateHtml .= '<td class="colGreen taR">-</td>';
  8207. $cateFalg = true;
  8208. }
  8209. $cateFalg = true;
  8210. foreach ( $itemCategoryList as $l ) {
  8211. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  8212. if (empty ( $l ['price'] )) {
  8213. $cateHtml .= '<td class="colGreen taR">-</td>';
  8214. $cateFalg = false;
  8215. break;
  8216. } else {
  8217. $catePrice += $l ['price'];
  8218. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8219. $cateFalg = false;
  8220. break;
  8221. }
  8222. }
  8223. }
  8224. if ($cateFalg) {
  8225. $cateHtml .= '<td class="colGreen taR">-</td>';
  8226. $cateFalg = true;
  8227. }
  8228. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  8229. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  8230. /* -- --- */
  8231. }
  8232. // print_r($htmlArray);die;
  8233. $data ['htmlArray'] = $htmlArray;
  8234. // statistics html
  8235. $stList = $statistics->getOne ( array (
  8236. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8237. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8238. 'groupby' => 'Month(date)',
  8239. 'asArray' => true
  8240. ) );
  8241. if (empty ( $stList ))
  8242. $stList = array (
  8243. 'rePrice' => 0,
  8244. 'agPrice' => 0
  8245. );
  8246. $data ['stList'] = array (
  8247. 'rePrice' => $stList ['rePrice'],
  8248. 'agPrice' => $stList ['agPrice'],
  8249. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8250. );
  8251. $monthHtml = "";
  8252. for($i = 1; $i <= 12; $i ++) {
  8253. if ($i == $month)
  8254. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8255. else
  8256. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8257. }
  8258. $data ['monthHtml'] = $monthHtml;
  8259. $data ['year'] = $year;
  8260. $data ['month'] = $month;
  8261. $data ['memu'] = "receipt";
  8262. $data ['staff'] = $this->staff;
  8263. $data ['receiptMemu'] = 'companyCategoryCollect';
  8264. $data ['verifyId'] = $this->verifyId;
  8265. $data ['executeId'] = $this->executeId;
  8266. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  8267. Doo::loadModel ( 'receipt' );
  8268. $receipt = new receipt ();
  8269. $receiptList = $receipt->find ( array (
  8270. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  8271. 'asArray' => true
  8272. ) );
  8273. if (empty ( $receiptList )) { // generated files
  8274. ob_start ();
  8275. $this->render ( "/admin/saeaStaffCollect", $data );
  8276. $this->cacheFile ( $path );
  8277. die ();
  8278. }
  8279. }
  8280. $this->render ( "/admin/saeaStaffCollect", $data );
  8281. }
  8282. function lyt() {
  8283. Doo::loadModel ( "receiptDetail" );
  8284. $receiptDetail = new receiptDetail ();
  8285. $receiptCollectList = $receiptDetail->find ( array (
  8286. 'where' => 'status=1 ',
  8287. 'asArray' => true
  8288. ) );
  8289. foreach ( $receiptCollectList as $key => $value ) {
  8290. $receiptDetail = new receiptDetail ();
  8291. $receiptDetail->pastDate = $value ['date'];
  8292. $receiptDetail->update ( array (
  8293. 'where' => "rdid= '" . $value ['rdid'] . "'"
  8294. ) );
  8295. }
  8296. }
  8297. function staffCollectMonthDetail() {
  8298. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8299. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8300. if (! $year)
  8301. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8302. if (! $month)
  8303. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8304. Doo::loadModel ( 'staff' );
  8305. $staff = new staff ();
  8306. Doo::loadModel ( "receiptDetail" );
  8307. $receiptDetail = new receiptDetail ();
  8308. Doo::loadModel ( 'accountItem' );
  8309. $accountItem = new accountItem ();
  8310. Doo::loadModel ( 'statistics' );
  8311. $statistics = new statistics ();
  8312. Doo::loadModel ( 'L_category' );
  8313. $lCategory = new L_category ();
  8314. $staffList = $staff->find ( array (
  8315. 'where' => 'username!="admin"',
  8316. 'asArray' => true
  8317. ) );
  8318. $categoryList = $staff->find ( array (
  8319. 'select' => 'COUNT(*) as count,cid,category',
  8320. 'where' => 'username !="admin"',
  8321. 'groupby' => 'cid',
  8322. 'asArray' => true
  8323. ) );
  8324. $list = array ();
  8325. foreach ( $categoryList as $vlu ) {
  8326. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8327. $r1 = 0;
  8328. $r2 = 0;
  8329. $r3 = 0;
  8330. $r4 = 0;
  8331. $r5 = 0;
  8332. $r6 = 0;
  8333. $r7 = 0;
  8334. $r8 = 0;
  8335. $r9 = 0;
  8336. $r10 = 0;
  8337. $r11 = 0;
  8338. $r12 = 0;
  8339. $r13 = 0;
  8340. $r14 = 0;
  8341. $r15 = 0;
  8342. $r16=0;
  8343. $r17=0;
  8344. $r18=0;
  8345. $c1 = 0;
  8346. $c2 = 0;
  8347. $c3 = 0;
  8348. $c4 = 0;
  8349. $c5 = 0;
  8350. $c6 = 0;
  8351. $p1 = 0;
  8352. $p2 = 0;
  8353. $p3 = 0;
  8354. $p4 = 0;
  8355. $p5 = 0;
  8356. $p6 = 0;
  8357. $p7 = 0;
  8358. $p8 = 0;
  8359. $p9 = 0;
  8360. $t1 = 0;
  8361. $t2 = 0;
  8362. $t3 = 0;
  8363. $t4 = 0;
  8364. $t5 = 0;
  8365. $s1 = 0;
  8366. $m1 = 0;
  8367. foreach ( $staffList as $value ) {
  8368. if ($vlu ['cid'] == $value ['cid']) {
  8369. // pastDate
  8370. $receiptCollectList = $receiptDetail->find ( array (
  8371. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8372. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8373. 'groupby' => 'item,Month(pastDate),itemCategory',
  8374. 'asArray' => true
  8375. ) );
  8376. // if ($value['sid']==42){
  8377. // print_r($receiptCollectList);die;
  8378. // }
  8379. if (! empty ( $receiptCollectList )) {
  8380. $receiptL = array (
  8381. '日常相关费用' => array (),
  8382. '差旅相关费用' => array (),
  8383. '培训班费用' => array (),
  8384. '其他' => array ()
  8385. );
  8386. $html = "";
  8387. $psum = 0;
  8388. $item = array (
  8389. '市内交通费',
  8390. '市内出租费',
  8391. '办事处房租',
  8392. '电话费',
  8393. '水费',
  8394. '电费',
  8395. '办公费用',
  8396. '邮寄费',
  8397. '其他费用',
  8398. '车辆费用',
  8399. '广告费',
  8400. '团队建设费',
  8401. '物业管理费',
  8402. '宽带费',
  8403. '人员薪酬',
  8404. '公积金',
  8405. '社保'
  8406. );
  8407. foreach ( $item as $va ) {
  8408. $falg = true;
  8409. foreach ( $receiptCollectList as $v ) {
  8410. if ($v ['itemCategory'] == '日常相关费用') {
  8411. if ($v ['item'] == $va) {
  8412. if ($va == '市内交通费')
  8413. $r1 += $v ['price'];
  8414. if ($va == '市内出租费')
  8415. $r2 += $v ['price'];
  8416. if ($va == '办事处房租')
  8417. $r3 += $v ['price'];
  8418. if ($va == '电话费')
  8419. $r4 += $v ['price'];
  8420. if ($va == '水费')
  8421. $r5 += $v ['price'];
  8422. if ($va == '电费')
  8423. $r6 += $v ['price'];
  8424. if ($va == '办公费用')
  8425. $r7 += $v ['price'];
  8426. if ($va == '邮寄费')
  8427. $r8 += $v ['price'];
  8428. if ($va == '其他费用')
  8429. $r9 += $v ['price'];
  8430. if ($va == '车辆费用')
  8431. $r10 += $v ['price'];
  8432. if ($va == '广告费')
  8433. $r11 += $v ['price'];
  8434. if ($va == '团队建设费')
  8435. $r13 += $v ['price'];
  8436. if ($va == '物业管理费')
  8437. $r14 += $v ['price'];
  8438. if ($va == '宽带费')
  8439. $r15 += $v ['price'];
  8440. if ($va == '公积金')
  8441. $r16 += $v ['price'];
  8442. if ($va == '社保')
  8443. $r17 += $v ['price'];
  8444. if ($va == '人员薪酬')
  8445. $r18 += $v ['price'];
  8446. $psum += $v ['price'];
  8447. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8448. $falg = false;
  8449. break;
  8450. }
  8451. }
  8452. }
  8453. if ($falg)
  8454. $html .= '<td class="taR">-</td>';
  8455. }
  8456. $r12 += $psum;
  8457. if (! empty ( $psum ))
  8458. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8459. else
  8460. $psum = '<td class="colGreen taR">-</td>';
  8461. $receiptL ['日常相关费用'] = $psum . $html;
  8462. /* ----------------------------------- */
  8463. $html = "";
  8464. $psum = 0;
  8465. $item = array (
  8466. '往来交通费',
  8467. '市内交通费',
  8468. '出差住宿费',
  8469. '出差补助',
  8470. '其他费用'
  8471. );
  8472. foreach ( $item as $va ) {
  8473. $falg = true;
  8474. foreach ( $receiptCollectList as $v ) {
  8475. if ($v ['itemCategory'] == '差旅相关费用') {
  8476. if ($v ['item'] == $va) {
  8477. if ($va == '往来交通费')
  8478. $c1 += $v ['price'];
  8479. if ($va == '市内交通费')
  8480. $c2 += $v ['price'];
  8481. if ($va == '出差住宿费')
  8482. $c3 += $v ['price'];
  8483. if ($va == '出差补助')
  8484. $c4 += $v ['price'];
  8485. if ($va == '其他费用')
  8486. $c5 += $v ['price'];
  8487. $psum += $v ['price'];
  8488. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8489. $falg = false;
  8490. break;
  8491. }
  8492. }
  8493. }
  8494. if ($falg)
  8495. $html .= '<td class="taR">-</td>';
  8496. }
  8497. $c6 += $psum;
  8498. if (! empty ( $psum ))
  8499. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8500. else
  8501. $psum = '<td class="colGreen taR">-</td>';
  8502. $receiptL ['差旅相关费用'] = $psum . $html;
  8503. /* ------------------------------------- */
  8504. $html = "";
  8505. $psum = 0;
  8506. $item = array (
  8507. '场租费',
  8508. '薪酬',
  8509. '住宿费',
  8510. '交通费',
  8511. '餐饮费',
  8512. '办公费',
  8513. '公关费',
  8514. '其他'
  8515. );
  8516. foreach ( $item as $va ) {
  8517. $falg = true;
  8518. foreach ( $receiptCollectList as $v ) {
  8519. if ($v ['itemCategory'] == '培训班费用') {
  8520. if ($v ['item'] == $va) {
  8521. if ($va == '场租费')
  8522. $p1 += $v ['price'];
  8523. if ($va == '薪酬')
  8524. $p2 += $v ['price'];
  8525. if ($va == '住宿费')
  8526. $p3 += $v ['price'];
  8527. if ($va == '交通费')
  8528. $p4 += $v ['price'];
  8529. if ($va == '餐饮费')
  8530. $p5 += $v ['price'];
  8531. if ($va == '办公费')
  8532. $p6 += $v ['price'];
  8533. if ($va == '公关费')
  8534. $p7 += $v ['price'];
  8535. if ($va == '其他')
  8536. $p8 += $v ['price'];
  8537. $psum += $v ['price'];
  8538. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8539. $falg = false;
  8540. break;
  8541. }
  8542. }
  8543. }
  8544. if ($falg)
  8545. $html .= '<td class="taR">-</td>';
  8546. }
  8547. $p9 += $psum;
  8548. if (! empty ( $psum ))
  8549. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8550. else
  8551. $psum = '<td class="colGreen taR">-</td>';
  8552. $receiptL ['培训班费用'] = $psum . $html;
  8553. /* ------------------------------------- */
  8554. $html = "";
  8555. $psum = 0;
  8556. $item = array (
  8557. '公关费',
  8558. '广告费',
  8559. '借款',
  8560. '可自加费用'
  8561. );
  8562. foreach ( $item as $va ) {
  8563. $falg = true;
  8564. foreach ( $receiptCollectList as $v ) {
  8565. if ($v ['itemCategory'] == '其他') {
  8566. // if ($value['sid']==42){
  8567. //
  8568. // echo var_dump($v['item']);
  8569. // echo var_dump($va);
  8570. // echo var_dump($v['item']==" ".$va);
  8571. // echo $v['item']."==".$va."/<br/>";
  8572. // //print_r( $receiptCollectList);//echo $va;
  8573. // }
  8574. if (trim ( $v ['item'] ) == $va) {
  8575. if ($va == '公关费')
  8576. $t1 += $v ['price'];
  8577. if ($va == '广告费') {
  8578. $t2 += $v ['price'];
  8579. }
  8580. if ($va == '借款')
  8581. $t3 += $v ['price'];
  8582. if ($va == '可自加费用')
  8583. $t4 += $v ['price'];
  8584. $psum += $v ['price'];
  8585. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8586. $falg = false;
  8587. break;
  8588. }
  8589. }
  8590. }
  8591. if ($falg)
  8592. $html .= '<td class="taR">-</td>';
  8593. }
  8594. $t5 += $psum;
  8595. if (! empty ( $psum ))
  8596. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8597. else
  8598. $psum = '<td class="colGreen taR">-</td>';
  8599. $receiptL ['其他'] = $psum . $html;
  8600. /* ------------------------------------- */
  8601. $html = "";
  8602. $psum = 0;
  8603. foreach ( $receiptCollectList as $v ) {
  8604. if ($v ['itemCategory'] == '报销金额调整') {
  8605. if (! empty ( $v ['price'] )) {
  8606. $psum += $v ['price'];
  8607. }
  8608. }
  8609. }
  8610. $s1 += $psum;
  8611. if (! empty ( $psum ))
  8612. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8613. else
  8614. $psum = '<td class="taR colOrange">-</td>';
  8615. $receiptL ['报销金额调整'] = $psum . $html;
  8616. } else {
  8617. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8618. <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>
  8619. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8620. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  8621. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8622. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8623. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8624. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8625. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  8626. }
  8627. $monthStaffPrice = $receiptDetail->find ( array (
  8628. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8629. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8630. 'groupby' => 'Month(pastDate)',
  8631. 'asArray' => true
  8632. ) );
  8633. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  8634. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  8635. $m1 += $monthStaffPrice [0] ['price'];
  8636. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  8637. } else
  8638. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  8639. $list [$value ['username']] = $receiptL;
  8640. }
  8641. }
  8642. $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>
  8643. <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>
  8644. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td><td class="taR">' . $r18 . '</td> <td class="taR">' . $r16 . '</td><td class="taR">' . $r17 . '</td>';
  8645. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  8646. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  8647. $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>
  8648. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  8649. $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>';
  8650. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  8651. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  8652. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  8653. }
  8654. $data ['list'] = $list;
  8655. $receiptCollectList = $receiptDetail->find ( array (
  8656. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8657. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8658. 'groupby' => 'item,Month(pastDate),itemCategory',
  8659. 'asArray' => true
  8660. ) );
  8661. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  8662. // statistics html
  8663. $stList = $statistics->getOne ( array (
  8664. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8665. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8666. 'groupby' => 'Month(date)',
  8667. 'asArray' => true
  8668. ) );
  8669. if (empty ( $stList ))
  8670. $stList = array (
  8671. 'rePrice' => 0,
  8672. 'agPrice' => 0
  8673. );
  8674. $data ['stList'] = array (
  8675. 'rePrice' => $stList ['rePrice'],
  8676. 'agPrice' => $stList ['agPrice'],
  8677. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8678. );
  8679. $monthHtml = "";
  8680. for($i = 1; $i <= 12; $i ++) {
  8681. if ($i == $month)
  8682. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8683. else
  8684. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8685. }
  8686. $data ['monthHtml'] = $monthHtml;
  8687. $data ['year'] = $year;
  8688. $data ['month'] = $month;
  8689. $data ['memu'] = "receipt";
  8690. $data ['staff'] = $this->staff;
  8691. $data ['receiptMemu'] = 'companyCategoryCollect';
  8692. $data ['verifyId'] = $this->verifyId;
  8693. $data ['executeId'] = $this->executeId;
  8694. $this->render ( "/admin/staffCollectMonthDetail", $data );
  8695. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  8696. }
  8697. function staffCollectMonthDetail2() {
  8698. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8699. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8700. if (! $year)
  8701. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8702. if (! $month)
  8703. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8704. Doo::loadModel ( 'staff' );
  8705. $staff = new staff ();
  8706. Doo::loadModel ( "receiptDetail" );
  8707. $receiptDetail = new receiptDetail ();
  8708. Doo::loadModel ( 'accountItem' );
  8709. $accountItem = new accountItem ();
  8710. Doo::loadModel ( 'statistics' );
  8711. $statistics = new statistics ();
  8712. Doo::loadModel ( 'L_category' );
  8713. $lCategory = new L_category ();
  8714. $staffList = $staff->find ( array (
  8715. 'where' => 'username!="admin"',
  8716. 'asArray' => true
  8717. ) );
  8718. $categoryList = $staff->find ( array (
  8719. 'select' => 'COUNT(*) as count,cid,category',
  8720. 'where' => 'username !="admin"',
  8721. 'groupby' => 'cid',
  8722. 'asArray' => true
  8723. ) );
  8724. $list = array ();
  8725. foreach ( $categoryList as $vlu ) {
  8726. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8727. $r1 = 0;
  8728. $r2 = 0;
  8729. $r3 = 0;
  8730. $r4 = 0;
  8731. $r5 = 0;
  8732. $r6 = 0;
  8733. $r7 = 0;
  8734. $r8 = 0;
  8735. $r9 = 0;
  8736. $r10 = 0;
  8737. $r11 = 0;
  8738. $r12 = 0;
  8739. $r13 = 0;
  8740. $r14 = 0;
  8741. $r15 = 0;
  8742. $c1 = 0;
  8743. $c2 = 0;
  8744. $c3 = 0;
  8745. $c4 = 0;
  8746. $c5 = 0;
  8747. $c6 = 0;
  8748. $p1 = 0;
  8749. $p2 = 0;
  8750. $p3 = 0;
  8751. $p4 = 0;
  8752. $p5 = 0;
  8753. $p6 = 0;
  8754. $p7 = 0;
  8755. $p8 = 0;
  8756. $p9 = 0;
  8757. $t1 = 0;
  8758. $t2 = 0;
  8759. $t3 = 0;
  8760. $t4 = 0;
  8761. $t5 = 0;
  8762. $s1 = 0;
  8763. $m1 = 0;
  8764. foreach ( $staffList as $value ) {
  8765. if ($vlu ['cid'] == $value ['cid']) {
  8766. $receiptCollectList = $receiptDetail->find ( array (
  8767. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  8768. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  8769. 'groupby' => 'item,Month(date),itemCategory',
  8770. 'asArray' => true
  8771. ) );
  8772. if (! empty ( $receiptCollectList )) {
  8773. $receiptL = array (
  8774. '日常相关费用' => array (),
  8775. '差旅相关费用' => array (),
  8776. '培训班费用' => array (),
  8777. '其他' => array ()
  8778. );
  8779. $html = "";
  8780. $psum = 0;
  8781. $item = array (
  8782. '市内交通费',
  8783. '市内出租费',
  8784. '办事处房租',
  8785. '电话费',
  8786. '水费',
  8787. '电费',
  8788. '办公费用',
  8789. '邮寄费',
  8790. '其他费用',
  8791. '车辆费用',
  8792. '广告费',
  8793. '团队建设费',
  8794. '物业管理费',
  8795. '宽带费'
  8796. );
  8797. foreach ( $item as $va ) {
  8798. $falg = true;
  8799. foreach ( $receiptCollectList as $v ) {
  8800. if ($v ['itemCategory'] == '日常相关费用') {
  8801. if ($v ['item'] == $va) {
  8802. if ($va == '市内交通费')
  8803. $r1 += $v ['price'];
  8804. if ($va == '市内出租费')
  8805. $r2 += $v ['price'];
  8806. if ($va == '办事处房租')
  8807. $r3 += $v ['price'];
  8808. if ($va == '电话费')
  8809. $r4 += $v ['price'];
  8810. if ($va == '水费')
  8811. $r5 += $v ['price'];
  8812. if ($va == '电费')
  8813. $r6 += $v ['price'];
  8814. if ($va == '办公费用')
  8815. $r7 += $v ['price'];
  8816. if ($va == '邮寄费')
  8817. $r8 += $v ['price'];
  8818. if ($va == '其他费用')
  8819. $r9 += $v ['price'];
  8820. if ($va == '车辆费用')
  8821. $r10 += $v ['price'];
  8822. if ($va == '广告费')
  8823. $r11 += $v ['price'];
  8824. if ($va == '团队建设费')
  8825. $r13 += $v ['price'];
  8826. if ($va == '物业管理费')
  8827. $r14 += $v ['price'];
  8828. if ($va == '宽带费')
  8829. $r15 += $v ['price'];
  8830. $psum += $v ['price'];
  8831. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8832. $falg = false;
  8833. break;
  8834. }
  8835. }
  8836. }
  8837. if ($falg)
  8838. $html .= '<td class="taR">-</td>';
  8839. }
  8840. $r12 += $psum;
  8841. if (! empty ( $psum ))
  8842. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8843. else
  8844. $psum = '<td class="colGreen taR">-</td>';
  8845. $receiptL ['日常相关费用'] = $psum . $html;
  8846. /* ----------------------------------- */
  8847. $html = "";
  8848. $psum = 0;
  8849. $item = array (
  8850. '往来交通费',
  8851. '市内交通费',
  8852. '出差住宿费',
  8853. '出差补助',
  8854. '其他费用'
  8855. );
  8856. foreach ( $item as $va ) {
  8857. $falg = true;
  8858. foreach ( $receiptCollectList as $v ) {
  8859. if ($v ['itemCategory'] == '差旅相关费用') {
  8860. if ($v ['item'] == $va) {
  8861. if ($va == '往来交通费')
  8862. $c1 += $v ['price'];
  8863. if ($va == '市内交通费')
  8864. $c2 += $v ['price'];
  8865. if ($va == '出差住宿费')
  8866. $c3 += $v ['price'];
  8867. if ($va == '出差补助')
  8868. $c4 += $v ['price'];
  8869. if ($va == '其他费用')
  8870. $c5 += $v ['price'];
  8871. $psum += $v ['price'];
  8872. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8873. $falg = false;
  8874. break;
  8875. }
  8876. }
  8877. }
  8878. if ($falg)
  8879. $html .= '<td class="taR">-</td>';
  8880. }
  8881. $c6 += $psum;
  8882. if (! empty ( $psum ))
  8883. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8884. else
  8885. $psum = '<td class="colGreen taR">-</td>';
  8886. $receiptL ['差旅相关费用'] = $psum . $html;
  8887. /* ------------------------------------- */
  8888. $html = "";
  8889. $psum = 0;
  8890. $item = array (
  8891. '场租费',
  8892. '薪酬',
  8893. '住宿费',
  8894. '交通费',
  8895. '餐饮费',
  8896. '办公费',
  8897. '公关费',
  8898. '其他'
  8899. );
  8900. foreach ( $item as $va ) {
  8901. $falg = true;
  8902. foreach ( $receiptCollectList as $v ) {
  8903. if ($v ['itemCategory'] == '培训班费用') {
  8904. if ($v ['item'] == $va) {
  8905. if ($va == '场租费')
  8906. $p1 += $v ['price'];
  8907. if ($va == '薪酬')
  8908. $p2 += $v ['price'];
  8909. if ($va == '住宿费')
  8910. $p3 += $v ['price'];
  8911. if ($va == '交通费')
  8912. $p4 += $v ['price'];
  8913. if ($va == '餐饮费')
  8914. $p5 += $v ['price'];
  8915. if ($va == '办公费')
  8916. $p6 += $v ['price'];
  8917. if ($va == '公关费')
  8918. $p7 += $v ['price'];
  8919. if ($va == '其他')
  8920. $p8 += $v ['price'];
  8921. $psum += $v ['price'];
  8922. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8923. $falg = false;
  8924. break;
  8925. }
  8926. }
  8927. }
  8928. if ($falg)
  8929. $html .= '<td class="taR">-</td>';
  8930. }
  8931. $p9 += $psum;
  8932. if (! empty ( $psum ))
  8933. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8934. else
  8935. $psum = '<td class="colGreen taR">-</td>';
  8936. $receiptL ['培训班费用'] = $psum . $html;
  8937. /* ------------------------------------- */
  8938. $html = "";
  8939. $psum = 0;
  8940. $item = array (
  8941. '公关费',
  8942. '广告费',
  8943. '借款',
  8944. '可自加费用'
  8945. );
  8946. foreach ( $item as $va ) {
  8947. $falg = true;
  8948. foreach ( $receiptCollectList as $v ) {
  8949. if ($v ['itemCategory'] == '其他') {
  8950. if ($v ['item'] == $va) {
  8951. if ($va == '公关费')
  8952. $t1 += $v ['price'];
  8953. if ($va == '广告费')
  8954. $t2 += $v ['price'];
  8955. if ($va == '借款')
  8956. $t3 += $v ['price'];
  8957. if ($va == '可自加费用')
  8958. $t4 += $v ['price'];
  8959. $psum += $v ['price'];
  8960. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8961. $falg = false;
  8962. break;
  8963. }
  8964. }
  8965. }
  8966. if ($falg)
  8967. $html .= '<td class="taR">-</td>';
  8968. }
  8969. $t5 += $psum;
  8970. if (! empty ( $psum ))
  8971. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8972. else
  8973. $psum = '<td class="colGreen taR">-</td>';
  8974. $receiptL ['其他'] = $psum . $html;
  8975. /* ------------------------------------- */
  8976. $html = "";
  8977. $psum = 0;
  8978. foreach ( $receiptCollectList as $v ) {
  8979. if ($v ['itemCategory'] == '报销金额调整') {
  8980. if (! empty ( $v ['price'] )) {
  8981. $psum += $v ['price'];
  8982. }
  8983. }
  8984. }
  8985. $s1 += $psum;
  8986. if (! empty ( $psum ))
  8987. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8988. else
  8989. $psum = '<td class="taR colOrange">-</td>';
  8990. $receiptL ['报销金额调整'] = $psum . $html;
  8991. } else {
  8992. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8993. <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>';
  8994. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  8995. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8996. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8997. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8998. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8999. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9000. }
  9001. $monthStaffPrice = $receiptDetail->find ( array (
  9002. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9003. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9004. 'asArray' => true
  9005. ) );
  9006. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  9007. $m1 += $monthStaffPrice [0] ['price'];
  9008. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9009. } else
  9010. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9011. $list [$value ['username']] = $receiptL;
  9012. }
  9013. }
  9014. $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>
  9015. <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>
  9016. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  9017. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  9018. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  9019. $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>
  9020. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  9021. $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>';
  9022. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  9023. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  9024. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  9025. }
  9026. $data ['list'] = $list;
  9027. $receiptCollectList = $receiptDetail->find ( array (
  9028. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9029. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9030. 'groupby' => 'item,Month(date),itemCategory',
  9031. 'asArray' => true
  9032. ) );
  9033. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9034. // statistics html
  9035. $stList = $statistics->getOne ( array (
  9036. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9037. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9038. 'groupby' => 'Month(date)',
  9039. 'asArray' => true
  9040. ) );
  9041. if (empty ( $stList ))
  9042. $stList = array (
  9043. 'rePrice' => 0,
  9044. 'agPrice' => 0
  9045. );
  9046. $data ['stList'] = array (
  9047. 'rePrice' => $stList ['rePrice'],
  9048. 'agPrice' => $stList ['agPrice'],
  9049. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9050. );
  9051. $monthHtml = "";
  9052. for($i = 1; $i <= 12; $i ++) {
  9053. if ($i == $month)
  9054. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9055. else
  9056. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9057. }
  9058. $data ['monthHtml'] = $monthHtml;
  9059. $data ['year'] = $year;
  9060. $data ['month'] = $month;
  9061. $data ['memu'] = "receipt";
  9062. $data ['staff'] = $this->staff;
  9063. $data ['receiptMemu'] = 'companyCategoryCollect';
  9064. $data ['verifyId'] = $this->verifyId;
  9065. $data ['executeId'] = $this->executeId;
  9066. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  9067. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9068. }
  9069. function companyMonthCollectDetail() {
  9070. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9071. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9072. if (! $year)
  9073. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9074. if (! $month)
  9075. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9076. Doo::loadModel ( 'staff' );
  9077. $staff = new staff ();
  9078. Doo::loadModel ( "receiptDetail" );
  9079. $receiptDetail = new receiptDetail ();
  9080. Doo::loadModel ( 'accountItem' );
  9081. $accountItem = new accountItem ();
  9082. Doo::loadModel ( 'statistics' );
  9083. $statistics = new statistics ();
  9084. Doo::loadModel ( 'L_category' );
  9085. $lCategory = new L_category ();
  9086. $staffList = $staff->find ( array (
  9087. 'where' => 'username!="admin"',
  9088. 'asArray' => true
  9089. ) );
  9090. $categoryList = $lCategory->find ( array (
  9091. 'asArray' => true
  9092. ) );
  9093. $list = array ();
  9094. foreach ( $categoryList as $value ) {
  9095. $receiptCollectList = $receiptDetail->find ( array (
  9096. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9097. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9098. 'groupby' => 'item,Month(pastDate),itemCategory',
  9099. 'asArray' => true
  9100. ) );
  9101. if (! empty ( $receiptCollectList )) {
  9102. $receiptL = array (
  9103. '日常相关费用' => array (),
  9104. '差旅相关费用' => array (),
  9105. '培训班费用' => array (),
  9106. '其他' => array ()
  9107. );
  9108. $html = "";
  9109. $psum = 0;
  9110. $item = array (
  9111. '市内交通费',
  9112. '市内出租费',
  9113. '办事处房租',
  9114. '电话费',
  9115. '水费',
  9116. '电费',
  9117. '办公费用',
  9118. '邮寄费',
  9119. '其他费用',
  9120. '车辆费用',
  9121. '广告费',
  9122. '团队建设费'
  9123. );
  9124. foreach ( $item as $va ) {
  9125. $falg = true;
  9126. foreach ( $receiptCollectList as $v ) {
  9127. if ($v ['itemCategory'] == '日常相关费用') {
  9128. if ($v ['item'] == $va) {
  9129. $psum += $v ['price'];
  9130. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9131. $falg = false;
  9132. break;
  9133. }
  9134. }
  9135. }
  9136. if ($falg)
  9137. $html .= '<td class="taR">-</td>';
  9138. }
  9139. if (! empty ( $psum ))
  9140. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9141. else
  9142. $psum = '<td class="colGreen taR">-</td>';
  9143. $receiptL ['日常相关费用'] = $psum . $html;
  9144. /* ----------------------------------- */
  9145. $html = "";
  9146. $psum = 0;
  9147. $item = array (
  9148. '往来交通费',
  9149. '市内交通费',
  9150. '出差住宿费',
  9151. '出差补助',
  9152. '其他费用'
  9153. );
  9154. foreach ( $item as $va ) {
  9155. $falg = true;
  9156. foreach ( $receiptCollectList as $v ) {
  9157. if ($v ['itemCategory'] == '差旅相关费用') {
  9158. if ($v ['item'] == $va) {
  9159. $psum += $v ['price'];
  9160. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9161. $falg = false;
  9162. break;
  9163. }
  9164. }
  9165. }
  9166. if ($falg)
  9167. $html .= '<td class="taR">-</td>';
  9168. }
  9169. if (! empty ( $psum ))
  9170. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9171. else
  9172. $psum = '<td class="colGreen taR">-</td>';
  9173. $receiptL ['差旅相关费用'] = $psum . $html;
  9174. /* ------------------------------------- */
  9175. $html = "";
  9176. $psum = 0;
  9177. $item = array (
  9178. '场租费',
  9179. '薪酬',
  9180. '住宿费',
  9181. '交通费',
  9182. '餐饮费',
  9183. '办公费',
  9184. '公关费',
  9185. '其他'
  9186. );
  9187. foreach ( $item as $va ) {
  9188. $falg = true;
  9189. foreach ( $receiptCollectList as $v ) {
  9190. if ($v ['itemCategory'] == '培训班费用') {
  9191. if ($v ['item'] == $va) {
  9192. $psum += $v ['price'];
  9193. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9194. $falg = false;
  9195. break;
  9196. }
  9197. }
  9198. }
  9199. if ($falg)
  9200. $html .= '<td class="taR">-</td>';
  9201. }
  9202. if (! empty ( $psum ))
  9203. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9204. else
  9205. $psum = '<td class="colGreen taR">-</td>';
  9206. $receiptL ['培训班费用'] = $psum . $html;
  9207. /* ------------------------------------- */
  9208. $html = "";
  9209. $psum = 0;
  9210. $item = array (
  9211. '公关费',
  9212. '广告费',
  9213. '借款',
  9214. '可自加费用'
  9215. );
  9216. foreach ( $item as $va ) {
  9217. $falg = true;
  9218. foreach ( $receiptCollectList as $v ) {
  9219. if ($v ['itemCategory'] == '其他') {
  9220. if ($v ['item'] == $va) {
  9221. $psum += $v ['price'];
  9222. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9223. $falg = false;
  9224. break;
  9225. }
  9226. }
  9227. }
  9228. if ($falg)
  9229. $html .= '<td class="taR">-</td>';
  9230. }
  9231. if (! empty ( $psum ))
  9232. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9233. else
  9234. $psum = '<td class="colGreen taR">-</td>';
  9235. $receiptL ['其他'] = $psum . $html;
  9236. /* ------------------------------------- */
  9237. $html = "";
  9238. $psum = 0;
  9239. foreach ( $receiptCollectList as $v ) {
  9240. if ($v ['itemCategory'] == '报销金额调整') {
  9241. if (! empty ( $v ['price'] ))
  9242. $psum += $v ['price'];
  9243. }
  9244. }
  9245. if (! empty ( $psum ))
  9246. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9247. else
  9248. $psum = '<td class="taR colOrange">-</td>';
  9249. $receiptL ['报销金额调整'] = $psum . $html;
  9250. } else {
  9251. $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>
  9252. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9253. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9254. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9255. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9256. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9257. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9258. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9259. }
  9260. $monthStaffPrice = $receiptDetail->find ( array (
  9261. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9262. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9263. 'asArray' => true
  9264. ) );
  9265. if (! empty ( $monthStaffPrice [0] ['price'] ))
  9266. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9267. else
  9268. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9269. $list [$value ['title']] = $receiptL;
  9270. }
  9271. $data ['list'] = $list;
  9272. $receiptCollectList = $receiptDetail->find ( array (
  9273. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9274. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9275. 'groupby' => 'item,Month(pastDate),itemCategory',
  9276. 'asArray' => true
  9277. ) );
  9278. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9279. // print_r($data['monthPriceHtml']);
  9280. // foreach ($data['monthPriceHtml'] as $value){
  9281. // echo $value;
  9282. // }
  9283. // die;
  9284. // statistics html
  9285. $stList = $statistics->getOne ( array (
  9286. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9287. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9288. 'groupby' => 'Month(date)',
  9289. 'asArray' => true
  9290. ) );
  9291. if (empty ( $stList ))
  9292. $stList = array (
  9293. 'rePrice' => 0,
  9294. 'agPrice' => 0
  9295. );
  9296. $data ['stList'] = array (
  9297. 'rePrice' => $stList ['rePrice'],
  9298. 'agPrice' => $stList ['agPrice'],
  9299. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9300. );
  9301. $monthHtml = "";
  9302. for($i = 1; $i <= 12; $i ++) {
  9303. if ($i == $month)
  9304. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9305. else
  9306. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9307. }
  9308. $data ['monthHtml'] = $monthHtml;
  9309. $data ['year'] = $year;
  9310. $data ['month'] = $month;
  9311. $data ['memu'] = "receipt";
  9312. $data ['staff'] = $this->staff;
  9313. $data ['receiptMemu'] = 'companyCategoryCollect';
  9314. $data ['verifyId'] = $this->verifyId;
  9315. $data ['executeId'] = $this->executeId;
  9316. $this->render ( "/admin/companyMonthCollectDetail", $data );
  9317. }
  9318. function staffCollectDetail() {
  9319. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9320. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  9321. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  9322. if (! $staffname) {
  9323. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  9324. $staffname = urldecode ( $staffname );
  9325. }
  9326. Doo::loadModel ( 'staff' );
  9327. $staff = new staff ();
  9328. Doo::loadModel ( "receiptDetail" );
  9329. $receiptDetail = new receiptDetail ();
  9330. Doo::loadModel ( 'accountItem' );
  9331. $accountItem = new accountItem ();
  9332. Doo::loadModel ( 'statistics' );
  9333. $statistics = new statistics ();
  9334. Doo::loadModel ( 'L_category' );
  9335. $lCategory = new L_category ();
  9336. $staffList = $staff->find ( array (
  9337. 'asArray' => true
  9338. ) );
  9339. $stHtml = '';
  9340. $stTitle = "";
  9341. $staffId = 0;
  9342. $cid = 0;
  9343. $ocid = 0;
  9344. foreach ( $staffList as $value ) {
  9345. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  9346. $stTitle = $value ['category'] . '-' . $value ['username'];
  9347. $staffId = $value ['sid'];
  9348. $cid = $value ['cid'];
  9349. $ocid = $value ['cid'];
  9350. if (! empty ( $value ['othercid'] ))
  9351. $cid = $value ['cid'] . ',' . $value ['othercid'];
  9352. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9353. } elseif ($value ['username'] != 'admin')
  9354. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9355. }
  9356. $data ['lCategoryHtml'] = $lCategory->find ( array (
  9357. 'where' => 'cid in(' . $cid . ')',
  9358. 'asArray' => true
  9359. ) );
  9360. if (empty ( $pcid ))
  9361. $pcid = $ocid;
  9362. $data ['ocid'] = $pcid;
  9363. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  9364. $this->showCache ( $path );
  9365. //
  9366. $receiptCollectList = $receiptDetail->find ( array (
  9367. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9368. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9369. 'groupby' => 'item,Month(pastDate),itemCategory',
  9370. 'asArray' => true
  9371. ) );
  9372. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  9373. // print_r($receiptCollectList);
  9374. $accountList = $accountItem->find ( array (
  9375. 'asArray' => true
  9376. ) );
  9377. // create CollectDetail HTML
  9378. $collectHtml = array ();
  9379. foreach ( $accountList as $key => $value ) {
  9380. $html = "";
  9381. $asum = 0;
  9382. for($i = 1; $i <= 12; $i ++) {
  9383. $falg = true;
  9384. foreach ( $receiptCollectList as $v ) {
  9385. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9386. if ($v ['item'] == '可自加费用') {
  9387. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  9388. }
  9389. $asum += $v ['price'];
  9390. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9391. $falg = false;
  9392. break;
  9393. }
  9394. }
  9395. if ($falg)
  9396. $html .= '<td class="taR">-</td>';
  9397. }
  9398. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9399. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9400. }
  9401. $data ['collectHtml'] = $collectHtml;
  9402. // print_r($collectHtml);
  9403. // create Adjustment price html
  9404. $receiptCollectList = $receiptDetail->find ( array (
  9405. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9406. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9407. 'groupby' => 'itemCategory,Month(pastDate)',
  9408. 'asArray' => true
  9409. ) );
  9410. $adjustment = array ();
  9411. $collectArray = array (
  9412. '日常相关费用' => array (),
  9413. '差旅相关费用' => array (),
  9414. '培训班费用' => array (),
  9415. '其他' => array ()
  9416. );
  9417. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9418. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9419. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9420. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9421. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9422. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9423. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9424. array_push ( $collectArray ['其他'], $collectHtml );
  9425. $data ['collectArray'] = $collectArray;
  9426. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9427. array_push ( $adjustment, $collectHtml );
  9428. $data ['adjustment'] = $adjustment;
  9429. // total price html
  9430. $collectHtml = "";
  9431. $total = 0;
  9432. for($i = 1; $i <= 12; $i ++) {
  9433. $sumPrice = 0;
  9434. foreach ( $receiptCollectList as $key => $value ) {
  9435. if ($value ['month'] == $i) {
  9436. $sumPrice += $value ['price'];
  9437. }
  9438. }
  9439. if ($sumPrice == 0)
  9440. $collectHtml .= '<td class="taR">-</td>';
  9441. else
  9442. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9443. $total += $sumPrice;
  9444. }
  9445. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9446. // statistics html
  9447. $stList = $statistics->statisticsByYear ( $year, $staffId );
  9448. if (empty ( $stList ))
  9449. $stList = array (
  9450. 'rePrice' => 0,
  9451. 'agPrice' => 0
  9452. );
  9453. $data ['stList'] = array (
  9454. 'rePrice' => $stList ['rePrice'],
  9455. 'agPrice' => $stList ['agPrice'],
  9456. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9457. );
  9458. $data ['totalPrice'] = $collectHtml;
  9459. $data ['totalYear'] = $total;
  9460. $data ['stHtml'] = $stHtml;
  9461. $data ['year'] = $year;
  9462. $data ['stTitle'] = $stTitle;
  9463. $data ['memu'] = "receipt";
  9464. $data ['staff'] = $this->staff;
  9465. $data ['receiptMemu'] = 'companyCategoryCollect';
  9466. $data ['verifyId'] = $this->verifyId;
  9467. $data ['executeId'] = $this->executeId;
  9468. if ($year < date ( "Y" )) {
  9469. Doo::loadModel ( 'receipt' );
  9470. $receipt = new receipt ();
  9471. $receiptList = $receipt->find ( array (
  9472. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  9473. 'asArray' => true
  9474. ) );
  9475. if (empty ( $receiptList )) { // generated files
  9476. ob_start ();
  9477. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9478. $this->cacheFile ( $path );
  9479. die ();
  9480. }
  9481. }
  9482. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9483. }
  9484. function BUGFLAG() {
  9485. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  9486. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  9487. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9488. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9489. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  9490. if (empty ( $status ))
  9491. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  9492. $page_size = 12;
  9493. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  9494. $vidList = array ();
  9495. $button = 0;
  9496. Doo::loadModel ( 'verify' );
  9497. $verify = new verify ();
  9498. Doo::loadModel ( 'receipt' );
  9499. $receipt = new receipt ();
  9500. Doo::loadModel ( 'staff' );
  9501. $staff = new staff ();
  9502. Doo::loadModel ( 'L_category' );
  9503. $Lcategory = new L_category ();
  9504. $dateCondition = " and Year(date) =" . $year;
  9505. if (! empty ( $month ))
  9506. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  9507. $categoryList = $Lcategory->find ( array (
  9508. 'asArray' => true
  9509. ) );
  9510. $staffList = $staff->find ( array (
  9511. 'where' => 'cid=' . $cid,
  9512. 'asArray' => true
  9513. ) );
  9514. $cateCondition = "";
  9515. $staffCondition = "";
  9516. $approvalCondition = "";
  9517. if (! empty ( $cid ))
  9518. $cateCondition = ' and cid=' . $cid;
  9519. if (! empty ( $sid )) {
  9520. $staffCondition = ' and staff=' . $sid;
  9521. $cateCondition = "";
  9522. }
  9523. $approvalCondition = " and status=" . $status;
  9524. if ($status == 2) {
  9525. // 查找角色审批人
  9526. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9527. }
  9528. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  9529. $approvalCondition = ' and status=2 ';
  9530. }
  9531. if ($status == 1) {
  9532. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  9533. }
  9534. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  9535. $pageinfo ['page'] = array (
  9536. 'previous' => ''
  9537. );
  9538. if ($status == 0) {
  9539. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  9540. $receiptList = $receipt->find ( array (
  9541. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  9542. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  9543. 'desc' => 'rid',
  9544. 'asArray' => true
  9545. ) );
  9546. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9547. } else
  9548. $receiptList = $receipt->find ( array (
  9549. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  9550. 'desc' => 'rid',
  9551. 'asArray' => true
  9552. ) );
  9553. $rLRes = $receipt->find ( array (
  9554. '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,
  9555. 'desc' => 'rid',
  9556. 'asArray' => true
  9557. ) );
  9558. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9559. // print_r($pageinfo);
  9560. $Locate = 0;
  9561. foreach ( $receiptList as $key => $value ) {
  9562. $receiptList [$key] ['Locate'] = $Locate;
  9563. $Locate ++;
  9564. $receiptList [$key] ['reviseDetail'] = array ();
  9565. if (! empty ( $value ['reviseDetail'] ))
  9566. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  9567. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  9568. $categoryDetil = $Lcategory->getOne ( array (
  9569. 'where' => 'cid=' . $value ['cid'],
  9570. 'asArray' => true
  9571. ) );
  9572. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  9573. $verifyList = $verify->getOne ( array (
  9574. 'where' => 'vid=' . $value ['verify'],
  9575. 'asArray' => true
  9576. ) );
  9577. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  9578. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  9579. foreach ( $verifyList as $k => $v ) {
  9580. // init verifyStaff
  9581. $verifyList [$k] ['date'] = "";
  9582. $verifyList [$k] ['opinion'] = "";
  9583. $verifyList [$k] ['status'] = "";
  9584. if (empty ( $verifyStaff )) {
  9585. $verifyList [$k] ['date'] = "";
  9586. $verifyList [$k] ['opinion'] = "";
  9587. if ($v [0] == $this->staff [0] ['sid']) {
  9588. $verifyList [$k] ['status'] = 4;
  9589. $button = 4;
  9590. }
  9591. } else {
  9592. $flag = true;
  9593. foreach ( $verifyStaff as $m => $u ) {
  9594. if ($v [0] == $m) {
  9595. $verifyList [$k] ['date'] = $u ['date'];
  9596. $verifyList [$k] ['opinion'] = $u ['opinion'];
  9597. $verifyList [$k] ['status'] = $u ['status'];
  9598. $flag = false;
  9599. break;
  9600. }
  9601. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  9602. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  9603. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  9604. }
  9605. if ($flag) { // 检测可编辑
  9606. if ($v [0] == $this->staff [0] ['sid']) {
  9607. $verifyList [$k] ['status'] = 4;
  9608. $button = 4;
  9609. }
  9610. }
  9611. }
  9612. }
  9613. $receiptList [$key] ['verifyList'] = $verifyList;
  9614. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  9615. 'where' => 'sid=' . $value ['staff'],
  9616. 'asArray' => true
  9617. ) );
  9618. $receiptList [$key] ['button'] = $button;
  9619. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  9620. }
  9621. // print_r($receiptList);die;
  9622. // $data['verifyDetail']=$verifyDetail;
  9623. $mothHtml = "";
  9624. for($i = 1; $i <= 12; $i ++) {
  9625. if ($month == $i)
  9626. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  9627. else
  9628. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  9629. }
  9630. $data ['mothHtml'] = $mothHtml;
  9631. $data ['page'] = $pageinfo;
  9632. $data ['receiptList'] = $receiptList;
  9633. $data ['receiptApprovalCount'] = count ( $rLRes );
  9634. $data ['status'] = $status;
  9635. $data ['year'] = $year;
  9636. $data ['categoryList'] = $categoryList;
  9637. $data ['staffList'] = $staffList;
  9638. $data ['cid'] = $cid;
  9639. $data ['sid'] = $sid;
  9640. // print_r($receiptList);
  9641. $data ['memu'] = "receipt";
  9642. $data ['staff'] = $this->staff;
  9643. $data ['receiptMemu'] = 'approvalExpenses';
  9644. $data ['verifyId'] = $this->verifyId;
  9645. $data ['executeId'] = $this->executeId;
  9646. $this->render ( "/admin/FALG", $data );
  9647. }
  9648. function ajaxGetReceiptOrder() {
  9649. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  9650. if (! empty ( $receiptOrder )) {
  9651. Doo::loadModel ( 'receipt' );
  9652. $receipt = new receipt ();
  9653. Doo::loadModel ( 'staff' );
  9654. $staff = new staff ();
  9655. $receiptInfo = $receipt->getOne ( array (
  9656. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  9657. 'asArray' => true
  9658. ) );
  9659. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  9660. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  9661. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  9662. </tbody></table><table class="table table table-bordered"><tbody>';
  9663. foreach ( $verifyStaff as $key => $value ) {
  9664. $staffInfo = $staff->getOne ( array (
  9665. 'select' => 'username',
  9666. 'where' => ' sid="' . $key . '"',
  9667. 'asArray' => true
  9668. ) );
  9669. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  9670. }
  9671. $html .= '</tbody></table></div></div>';
  9672. echo json_encode ( array (
  9673. 'status' => 1,
  9674. 'receiptHtml' => $html
  9675. ) );
  9676. die ();
  9677. }
  9678. echo json_encode ( array (
  9679. 'status' => 2,
  9680. 'receiptHtml' => ''
  9681. ) );
  9682. die ();
  9683. }
  9684. function _getMonthCollectDetail($receiptCollectList) {
  9685. if (! empty ( $receiptCollectList )) {
  9686. $receiptL = array (
  9687. '日常相关费用' => array (),
  9688. '差旅相关费用' => array (),
  9689. '培训班费用' => array (),
  9690. '其他' => array ()
  9691. );
  9692. $html = "";
  9693. $psum = 0;
  9694. $item = array (
  9695. '市内交通费',
  9696. '市内出租费',
  9697. '办事处房租',
  9698. '电话费',
  9699. '水费',
  9700. '电费',
  9701. '办公费用',
  9702. '邮寄费',
  9703. '其他费用',
  9704. '车辆费用',
  9705. '广告费',
  9706. '团队建设费',
  9707. '物业管理费',
  9708. '宽带费'
  9709. );
  9710. foreach ( $item as $value ) {
  9711. $falg = true;
  9712. foreach ( $receiptCollectList as $v ) {
  9713. if ($v ['itemCategory'] == '日常相关费用') {
  9714. if ($v ['item'] == $value) {
  9715. $psum += $v ['price'];
  9716. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9717. $falg = false;
  9718. break;
  9719. }
  9720. }
  9721. }
  9722. if ($falg)
  9723. $html .= '<td class="taR">-</td>';
  9724. }
  9725. if (! empty ( $psum ))
  9726. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9727. else
  9728. $psum = '<td class="colGreen taR">-</td>';
  9729. $receiptL ['日常相关费用'] = $psum . $html;
  9730. /* ----------------------------------- */
  9731. $html = "";
  9732. $psum = 0;
  9733. $item = array (
  9734. '往来交通费',
  9735. '市内交通费',
  9736. '出差住宿费',
  9737. '出差补助',
  9738. '其他费用'
  9739. );
  9740. foreach ( $item as $value ) {
  9741. $falg = true;
  9742. foreach ( $receiptCollectList as $v ) {
  9743. if ($v ['itemCategory'] == '差旅相关费用') {
  9744. if ($v ['item'] == $value) {
  9745. $psum += $v ['price'];
  9746. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9747. $falg = false;
  9748. break;
  9749. }
  9750. }
  9751. }
  9752. if ($falg)
  9753. $html .= '<td class="taR">-</td>';
  9754. }
  9755. if (! empty ( $psum ))
  9756. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9757. else
  9758. $psum = '<td class="colGreen taR">-</td>';
  9759. $receiptL ['差旅相关费用'] = $psum . $html;
  9760. /* ------------------------------------- */
  9761. $html = "";
  9762. $psum = 0;
  9763. $item = array (
  9764. '场租费',
  9765. '薪酬',
  9766. '住宿费',
  9767. '交通费',
  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. $item = array (
  9797. '公关费',
  9798. '广告费',
  9799. '借款',
  9800. '可自加费用'
  9801. );
  9802. foreach ( $item as $value ) {
  9803. $falg = true;
  9804. foreach ( $receiptCollectList as $v ) {
  9805. if ($v ['itemCategory'] == '其他') {
  9806. if ($v ['item'] == $value) {
  9807. $psum += $v ['price'];
  9808. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9809. $falg = false;
  9810. break;
  9811. }
  9812. }
  9813. }
  9814. if ($falg)
  9815. $html .= '<td class="taR">-</td>';
  9816. }
  9817. if (! empty ( $psum ))
  9818. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9819. else
  9820. $psum = '<td class="colGreen taR">-</td>';
  9821. $receiptL ['其他'] = $psum . $html;
  9822. /* ------------------------------------- */
  9823. $html = "";
  9824. $psum = 0;
  9825. foreach ( $receiptCollectList as $v ) {
  9826. if ($v ['itemCategory'] == '报销金额调整') {
  9827. if (! empty ( $v ['price'] ))
  9828. $psum += $v ['price'];
  9829. }
  9830. }
  9831. if (! empty ( $psum ))
  9832. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9833. else
  9834. $psum = '<td class="taR colOrange">-</td>';
  9835. $receiptL ['报销金额调整'] = $psum . $html;
  9836. } else {
  9837. $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>
  9838. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9839. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9840. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9841. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9842. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9843. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9844. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9845. }
  9846. return $receiptL;
  9847. }
  9848. function eMail() {
  9849. Doo::loadModel ( 'staff' );
  9850. $staff = new staff ();
  9851. Doo::loadModel ( 'receipt' );
  9852. $receipt = new receipt ();
  9853. Doo::loadModel ( 'L_category' );
  9854. $Lcategory = new L_category ();
  9855. Doo::loadModel ( "verify" );
  9856. $verify = new verify ();
  9857. $staffList = $staff->find ( array (
  9858. 'asArray' => true
  9859. ) );
  9860. foreach ( $staffList as $key => $value ) {
  9861. if ($value ['username'] != 'admin') {
  9862. // 提交人
  9863. $receiptList = $receipt->find ( array (
  9864. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  9865. 'asArray' => true
  9866. ) );
  9867. if (! empty ( $receiptList )) {
  9868. $html = '<br><div><style></style>
  9869. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  9870. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  9871. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9872. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  9873. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9874. <tbody><tr>
  9875. <td style="padding: 0 40px;" align="left">
  9876. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9877. </td></tr><tr>
  9878. <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>
  9879. </tr>
  9880. </tbody> </table></td> </tr> <tr><td>
  9881. <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">
  9882. <tbody> <tr><td>
  9883. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  9884. 以下报销单完成了审批,等着收款吧:</p>
  9885. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  9886. foreach ( $receiptList as $k => $v ) {
  9887. $category = $Lcategory->getOne ( array (
  9888. 'where' => 'cid=' . $v ['cid'],
  9889. 'asArray' => true
  9890. ) );
  9891. $html .= '
  9892. <tr>
  9893. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  9894. <td align="left">
  9895. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  9896. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  9897. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  9898. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  9899. </tr>';
  9900. }
  9901. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  9902. <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>
  9903. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  9904. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  9905. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  9906. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9907. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9908. $receipt = new receipt ();
  9909. $receipt->notice = 1;
  9910. $receipt->update ( array (
  9911. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  9912. ) );
  9913. }
  9914. }
  9915. // 审批人
  9916. $verifyList = $verify->find ( array (
  9917. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  9918. 'asArray' => true
  9919. ) );
  9920. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  9921. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  9922. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9923. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  9924. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9925. <tbody><tr><td style="padding: 0 40px;" align="left">
  9926. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9927. </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>
  9928. </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">
  9929. <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>
  9930. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  9931. foreach ( $verifyList as $k => $v ) {
  9932. $receiptList = $receipt->find ( array (
  9933. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  9934. 'asArray' => true
  9935. ) );
  9936. foreach ( $receiptList as $r => $l ) {
  9937. $category = $Lcategory->getOne ( array (
  9938. 'where' => 'cid=' . $l ['cid'],
  9939. 'asArray' => true
  9940. ) );
  9941. $staffDetile = $staff->getOne ( array (
  9942. 'where' => 'sid=' . $l ['staff'],
  9943. 'asArray' => true
  9944. ) );
  9945. $html .= '
  9946. <tr>
  9947. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  9948. <td align="left">
  9949. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  9950. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  9951. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  9952. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  9953. </tr>';
  9954. }
  9955. }
  9956. $html .= '
  9957. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  9958. <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>
  9959. </tr></tbody></table></td></tr></tbody></table></div><br>';
  9960. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  9961. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  9962. // $receipt=new receipt();
  9963. // $receipt->notice=1;
  9964. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  9965. }
  9966. }
  9967. }
  9968. }
  9969. function setWXMsg($rid, $type) {
  9970. Doo::loadModel ( "receipt" );
  9971. $receipt = new receipt ();
  9972. $receiptDetail = $receipt->getOne ( array (
  9973. 'where' => 'rid=' . $rid,
  9974. 'asArray' => true
  9975. ) );
  9976. if (! empty ( $receiptDetail )) {
  9977. Doo::loadModel ( 'staff' );
  9978. $staff = new staff ();
  9979. $staffmsg = $staff->getOne ( array (
  9980. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  9981. 'asArray' => TRUE
  9982. ) );
  9983. if (! empty ( $staffmsg ['wxid'] )) {
  9984. require_once (SITE_PATH . '/protected/class/client.php');
  9985. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  9986. $user = $staffmsg ['wxid'];
  9987. $receiptName = '';
  9988. $msg = '';
  9989. switch ($receiptDetail ['Rtype']) {
  9990. case 0 :
  9991. $receiptName = '报销';
  9992. break;
  9993. case 1 :
  9994. $receiptName = '借款';
  9995. break;
  9996. case 2 :
  9997. $receiptName = '对公汇款';
  9998. break;
  9999. }
  10000. switch ($type) {
  10001. case 1 :
  10002. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  10003. break;
  10004. case 2 :
  10005. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  10006. break;
  10007. case 3 :
  10008. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  10009. break;
  10010. }
  10011. $result = $client->SendMsg ( $user, $msg, 'text' );
  10012. }
  10013. }
  10014. }
  10015. // Email发送函数
  10016. function SMail($toemail, $subject, $contents) {
  10017. Doo::loadClass ( 'class.phpmailer' );
  10018. $mail = new PHPMailer ();
  10019. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  10020. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  10021. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  10022. $mail->Password = "cDO1GjtY1seH"; // 密码
  10023. $mail->CharSet = "UTF8";
  10024. $mail->SMTPAuth = true;
  10025. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  10026. $mail->Mailer = "smtp";
  10027. $mail->Port = 25;
  10028. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  10029. $mail->MsgHTML ( $contents );
  10030. $mail->AddAddress ( $toemail );
  10031. $mail->CharSet = "UTF-8";
  10032. return $mail->Send ();
  10033. }
  10034. function swfupload() {
  10035. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  10036. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  10037. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  10038. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  10039. header ( "HTTP/1.1 500 Internal Server Error" );
  10040. echo "POST exceeded maximum allowed size.";
  10041. exit ( 0 );
  10042. }
  10043. // Settings
  10044. $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)
  10045. $upload_name = "Filedata";
  10046. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  10047. $extension_whitelist = array (
  10048. "doc",
  10049. "txt",
  10050. "jpg",
  10051. "gif",
  10052. "png"
  10053. ); // Allowed file extensions
  10054. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  10055. // Other variables
  10056. $MAX_FILENAME_LENGTH = 260;
  10057. $file_name = "";
  10058. $file_extension = "";
  10059. $uploadErrors = array (
  10060. 0 => "文件上传成功",
  10061. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  10062. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  10063. 3 => "上传的文件仅为部分文件",
  10064. 4 => "没有文件上传",
  10065. 6 => "缺少临时文件夹"
  10066. );
  10067. $nk = time ();
  10068. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  10069. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  10070. echo "文件无法保存.";
  10071. exit ( 0 );
  10072. }
  10073. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  10074. echo json_encode ( array (
  10075. 'filename' => $file_name,
  10076. 'id' => $nk
  10077. ) );
  10078. exit ( 0 );
  10079. }
  10080. function _GetFileEXT($filename) {
  10081. $pics = explode ( '.', $filename );
  10082. $num = count ( $pics );
  10083. return $pics [$num - 1];
  10084. }
  10085. /**
  10086. * 获取get或者POST值
  10087. * @param string $name 属性名称
  10088. * @return fixed 值
  10089. */
  10090. function get_args($name) {
  10091. if (isset ( $_GET [$name] )) {
  10092. if (is_array ( $_GET [$name] ))
  10093. return $_GET [$name];
  10094. else
  10095. return addslashes ( $_GET [$name] );
  10096. } elseif (isset ( $_POST [$name] )) {
  10097. if (is_array ( $_POST [$name] ))
  10098. return $_POST [$name];
  10099. else
  10100. return addslashes ( $_POST [$name] );
  10101. } else
  10102. return false;
  10103. }
  10104. function num_to_rmb($num) {
  10105. $c1 = "零壹贰叁肆伍陆柒捌玖";
  10106. $c2 = "分角元拾佰仟万拾佰仟亿";
  10107. // 精确到分后面就不要了,所以只留两个小数位
  10108. $num = round ( $num, 2 );
  10109. // 将数字转化为整数
  10110. $num = $num * 100;
  10111. if (strlen ( $num ) > 10) {
  10112. return "金额太大,请检查";
  10113. }
  10114. $i = 0;
  10115. $c = "";
  10116. while ( 1 ) {
  10117. if ($i == 0) {
  10118. // 获取最后一位数字
  10119. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  10120. } else {
  10121. $n = $num % 10;
  10122. }
  10123. // 每次将最后一位数字转化为中文
  10124. $p1 = substr ( $c1, 3 * $n, 3 );
  10125. $p2 = substr ( $c2, 3 * $i, 3 );
  10126. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  10127. $c = $p1 . $p2 . $c;
  10128. } else {
  10129. $c = $p1 . $c;
  10130. }
  10131. $i = $i + 1;
  10132. // 去掉数字最后一位了
  10133. $num = $num / 10;
  10134. $num = ( int ) $num;
  10135. // 结束循环
  10136. if ($num == 0) {
  10137. break;
  10138. }
  10139. }
  10140. $j = 0;
  10141. $slen = strlen ( $c );
  10142. while ( $j < $slen ) {
  10143. // utf8一个汉字相当3个字符
  10144. $m = substr ( $c, $j, 6 );
  10145. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  10146. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  10147. $left = substr ( $c, 0, $j );
  10148. $right = substr ( $c, $j + 3 );
  10149. $c = $left . $right;
  10150. $j = $j - 3;
  10151. $slen = $slen - 3;
  10152. }
  10153. $j = $j + 3;
  10154. }
  10155. // 这个是为了去掉类似23.0中最后一个“零”字
  10156. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  10157. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  10158. }
  10159. // 将处理的汉字加上“整”
  10160. if (empty ( $c )) {
  10161. return "零元整";
  10162. } else {
  10163. return $c . "整";
  10164. }
  10165. }
  10166. /**
  10167. * 获得分页数据
  10168. * @param unknown_type $table
  10169. * @param unknown_type $condition
  10170. * @param unknown_type $on_page
  10171. * @param unknown_type $page_size
  10172. */
  10173. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  10174. $page_c = "";
  10175. $page ['previous'] = $this->get_previous ( $on_page );
  10176. $page ['on_page'] = $on_page;
  10177. $total_count = $this->get_table_count ( $table, $condition );
  10178. $total = intval ( $total_count / $page_size );
  10179. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  10180. $page ['total_data'] = $total_count;
  10181. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  10182. $i = 1;
  10183. $page_max = 1;
  10184. $page_width = 3;
  10185. if ($on_page >= $page_width) {
  10186. $page_max = intval ( $on_page / $page_width ) + 1;
  10187. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  10188. }
  10189. for(; $i <= $page ['total_page']; $i ++) {
  10190. if ($i == $on_page)
  10191. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  10192. else
  10193. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  10194. if ($i == ($page_width * $page_max))
  10195. break;
  10196. }
  10197. $page ['page'] = $page_c;
  10198. $page ['lower'] = (-- $on_page) * $page_size;
  10199. return $page;
  10200. }
  10201. /**
  10202. * 获取总页数
  10203. * @param unknown_type $table
  10204. * @param unknown_type $condition
  10205. */
  10206. public function get_table_count($table = "", $condition = "") {
  10207. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10208. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10209. // echo $sql;die;
  10210. $query = Doo::db ()->query ( $sql );
  10211. $result = $query->fetch ();
  10212. return $result ['count'];
  10213. }
  10214. /**
  10215. * 获取上一页
  10216. * @param unknown_type $on_page
  10217. */
  10218. function get_previous($on_page = 1) {
  10219. return $on_page != 0 ? $on_page - 1 : $on_page;
  10220. }
  10221. }
  10222. ?>