ReceiptController.php 374 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621
  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' ) : '';
  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 = " ";
  2193. // if (! empty ( $month ))
  2194. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  2195. if ($status == 'done'|| $status == 'termination') {
  2196. if (!empty($year)){
  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') { // $dateCondition .
  2265. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  2266. $receiptList = $receipt->find ( array ( // $dateCondition.
  2267. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  2268. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2269. 'desc' => 'rid',
  2270. 'asArray' => true
  2271. ) );
  2272. } else {
  2273. $receiptList = $receipt->find ( array ( // $dateCondition
  2274. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
  2275. 'desc' => 'rid',
  2276. 'asArray' => true
  2277. ) );
  2278. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  2279. }
  2280. $rLRes = $receipt->find ( array (
  2281. 'where' => 'status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )' . $cateCondition . $staffCondition . ' and verify in (' . $vid . ')',
  2282. 'desc' => 'rid',
  2283. 'asArray' => true
  2284. ) );
  2285. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  2286. // print_r($receiptList);
  2287. $Locate = 0;
  2288. $reportList = $reportCateList = array ();
  2289. foreach ( $receiptList as $key => $value ) {
  2290. $receiptList [$key] ['Locate'] = $Locate;
  2291. $Locate ++;
  2292. $receiptList [$key] ['reviseDetail'] = array ();
  2293. if (! empty ( $value ['reviseDetail'] ))
  2294. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2295. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2296. $categoryDetil = $Lcategory->getOne ( array (
  2297. 'where' => 'cid=' . $value ['cid'],
  2298. 'asArray' => true
  2299. ) );
  2300. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2301. $verifyList = $verify->getOne ( array (
  2302. 'where' => 'vid=' . $value ['verify'],
  2303. 'asArray' => true
  2304. ) );
  2305. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2306. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2307. foreach ( $verifyList as $k => $v ) {
  2308. // init verifyStaff
  2309. $verifyList [$k] ['date'] = "";
  2310. $verifyList [$k] ['opinion'] = "";
  2311. $verifyList [$k] ['status'] = "";
  2312. if (empty ( $verifyStaff )) {
  2313. $verifyList [$k] ['date'] = "";
  2314. $verifyList [$k] ['opinion'] = "";
  2315. if ($v [0] == $this->staff [0] ['sid']) {
  2316. $verifyList [$k] ['status'] = 4;
  2317. $button = 4;
  2318. }
  2319. } else {
  2320. $flag = true;
  2321. foreach ( $verifyStaff as $m => $u ) {
  2322. if ($v [0] == $m) {
  2323. $verifyList [$k] ['date'] = $u ['date'];
  2324. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2325. $verifyList [$k] ['status'] = $u ['status'];
  2326. $flag = false;
  2327. break;
  2328. }
  2329. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  2330. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  2331. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  2332. }
  2333. if ($flag) { // 检测可编辑
  2334. if ($v [0] == $this->staff [0] ['sid']) {
  2335. $verifyList [$k] ['status'] = 4;
  2336. $button = 4;
  2337. }
  2338. }
  2339. }
  2340. }
  2341. $receiptList [$key] ['verifyList'] = $verifyList;
  2342. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2343. 'where' => 'sid=' . $value ['staff'],
  2344. 'asArray' => true
  2345. ) );
  2346. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  2347. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  2348. $receiptList [$key] ['button'] = $button;
  2349. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  2350. }
  2351. $reportList = array_unique ( $reportList );
  2352. $reportHtml = '';
  2353. foreach ( $reportList as $key => $value ) {
  2354. $v = explode ( "-", $value );
  2355. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  2356. }
  2357. // print_r($reportList)
  2358. $data ['reportHtml'] = $reportHtml;
  2359. $reportCateList = array_unique ( $reportCateList );
  2360. $reportCateHtml = '';
  2361. foreach ( $reportCateList as $key => $value ) {
  2362. $v = explode ( "-", $value );
  2363. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  2364. }
  2365. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  2366. $data ['reportCateHtml'] = $reportCateHtml;
  2367. // print_r($receiptList);die;
  2368. // $data['verifyDetail']=$verifyDetail;
  2369. $mothHtml = "";
  2370. for($i = 1; $i <= 12; $i ++) {
  2371. if ($month == $i)
  2372. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2373. else
  2374. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2375. }
  2376. $data ['mothHtml'] = $mothHtml;
  2377. $data ['page'] = $pageinfo;
  2378. $data ['receiptList'] = $receiptList;
  2379. $data ['receiptApprovalCount'] = count ( $rLRes );
  2380. $data ['status'] = $status;
  2381. $data ['year'] = $year;
  2382. $data ['categoryList'] = $categoryList;
  2383. $data ['staffList'] = $staffList;
  2384. $data ['cid'] = $cid;
  2385. $data ['sid'] = $sid;
  2386. // print_r($receiptList);
  2387. $data ['memu'] = "receipt";
  2388. $data ['staff'] = $this->staff;
  2389. $data ['receiptMemu'] = 'approvalExpenses';
  2390. $data ['verifyId'] = $this->verifyId;
  2391. $data ['executeId'] = $this->executeId;
  2392. $this->render ( "/admin/approvalExpenses", $data );
  2393. }
  2394. function expensesDoc() {
  2395. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2396. Doo::loadModel ( 'receipt' );
  2397. $receipt = new receipt ();
  2398. Doo::loadModel ( 'L_category' );
  2399. $Lcategory = new L_category ();
  2400. Doo::loadModel ( 'verify' );
  2401. Doo::loadModel ( 'statistics' );
  2402. $statistics = new statistics ();
  2403. $verify = new verify ();
  2404. Doo::loadModel ( 'staff' );
  2405. $staff = new staff ();
  2406. Doo::loadModel ( 'loanReceipt' );
  2407. $loanReceipt = new loanReceipt ();
  2408. $receiptList = $receipt->find ( array (
  2409. 'where' => ' rid=' . $rid,
  2410. 'desc' => 'rid',
  2411. 'asArray' => true
  2412. ) );
  2413. $loanList = array ();
  2414. if (! empty ( $receiptList ))
  2415. $loanList = $loanReceipt->find ( array (
  2416. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2417. 'desc' => 'rid',
  2418. 'asArray' => true
  2419. ) );
  2420. $Locate = 0;
  2421. $roleId = 0;
  2422. $button = 0;
  2423. foreach ( $loanList as $key => $value ) {
  2424. $loanList [$key] ['Locate'] = $Locate;
  2425. $Locate ++;
  2426. $loanList [$key] ['reviseDetail'] = array ();
  2427. if (! empty ( $value ['reviseDetail'] ))
  2428. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2429. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2430. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2431. $categoryDetil = $Lcategory->getOne ( array (
  2432. 'where' => 'cid=' . $value ['cid'],
  2433. 'asArray' => true
  2434. ) );
  2435. $loanList [$key] ['category'] = $categoryDetil ['title'];
  2436. // 检测编辑状态
  2437. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  2438. $verifyList ['staff'] = $value ['verifyBreakup'];
  2439. else
  2440. $verifyList = $verify->getOne ( array (
  2441. 'where' => 'vid=' . $value ['verify'],
  2442. 'asArray' => true
  2443. ) );
  2444. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2445. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2446. Doo::loadModel ( 'role' );
  2447. $role = new role ();
  2448. $flag = true;
  2449. $roleKey = 0;
  2450. $endStaffArray = array ();
  2451. $roleArrayCopy = array ();
  2452. foreach ( $verifyList as $k => $v ) {
  2453. // init verifyStaff
  2454. if ($v [1] == 'ROLE') {
  2455. if (! empty ( $verifyStaff )) {
  2456. $endStaffArray = end ( $verifyStaff );
  2457. // if ($v[0]==$endStaffArray['nextStaff']){
  2458. // $roleId=$v[0];
  2459. // }
  2460. }
  2461. $roleVerify = json_decode ( $v [3], true );
  2462. $roleKey = $k;
  2463. $roleArray = array ();
  2464. $rolename = $role->getOne ( array (
  2465. 'where' => 'rid=' . $v [0],
  2466. 'asArray' => true
  2467. ) );
  2468. foreach ( $roleVerify as $o => $p ) {
  2469. $staffID = explode ( '_', $p );
  2470. $staffInfo = $staff->getOne ( array (
  2471. 'where' => 'sid=' . $staffID [0],
  2472. 'asArray' => true
  2473. ) );
  2474. // print_r($staffID);
  2475. $exp = array (
  2476. 0 => $staffInfo ['sid'],
  2477. 1 => $staffID [1],
  2478. 2 => $staffInfo ['avatar'],
  2479. 'date' => '',
  2480. 'date' => '',
  2481. 'opinion' => '',
  2482. 'status' => '',
  2483. 'rolename' => $rolename ['name']
  2484. );
  2485. array_push ( $roleArray, $exp );
  2486. }
  2487. $roleArrayCopy [$v [0]] = $roleArray;
  2488. // $verifyList[$k]['roleArray']=$roleArray;
  2489. }
  2490. $verifyList [$k] ['date'] = "";
  2491. $verifyList [$k] ['opinion'] = "";
  2492. $verifyList [$k] ['status'] = "";
  2493. if (empty ( $verifyStaff )) {
  2494. $verifyList [$k] ['date'] = "";
  2495. $verifyList [$k] ['opinion'] = "";
  2496. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2497. $verifyList [$k] ['status'] = 4;
  2498. $flag = false;
  2499. }
  2500. } else {
  2501. foreach ( $verifyStaff as $m => $u ) {
  2502. if ($v [0] == $m) {
  2503. $verifyList [$k] ['date'] = $u ['date'];
  2504. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2505. $verifyList [$k] ['status'] = $u ['status'];
  2506. $flag = false;
  2507. break;
  2508. }
  2509. }
  2510. $endStaffArray = end ( $verifyStaff );
  2511. if (isset ( $endStaffArray ['ROLE'] )) {
  2512. } else {
  2513. // $endKey=key($verifyStaff);
  2514. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2515. // $button=4;
  2516. // $verifyList[$k]['status']=4;
  2517. // }
  2518. }
  2519. }
  2520. }
  2521. $rolename ['name'] = '';
  2522. if (! empty ( $roleId )) {
  2523. Doo::loadModel ( 'role' );
  2524. $role = new role ();
  2525. $rolename = $role->getOne ( array (
  2526. 'where' => 'rid=' . $roleId,
  2527. 'asArray' => true
  2528. ) );
  2529. }
  2530. if (! empty ( $verifyStaff ))
  2531. $endStaffArray = end ( $verifyStaff );
  2532. $KOP = false;
  2533. foreach ( $roleArrayCopy as $P => $A ) {
  2534. foreach ( $A as $MKI => $AVL ) {
  2535. if (! empty ( $verifyStaff )) {
  2536. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2537. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2538. $button = 4;
  2539. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2540. }
  2541. foreach ( $verifyStaff as $m => $u ) {
  2542. $AVLFK = $AVL [0] . '_R';
  2543. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2544. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2545. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2546. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2547. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2548. break;
  2549. }
  2550. }
  2551. } else {
  2552. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2553. $button = 4;
  2554. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2555. }
  2556. }
  2557. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2558. $KOP = true;
  2559. }
  2560. }
  2561. foreach ( $roleArrayCopy as $k => $v ) {
  2562. foreach ( $verifyList as $m => $n ) {
  2563. if ($n [0] == $k) {
  2564. array_splice ( $verifyList, $m, 1, $v );
  2565. }
  2566. }
  2567. }
  2568. $loanList [$key] ['verifyList'] = $verifyList;
  2569. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  2570. 'where' => 'sid=' . $value ['staff'],
  2571. 'asArray' => true
  2572. ) );
  2573. $loanList [$key] ['button'] = $button;
  2574. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  2575. }
  2576. $data ['loanList'] = $loanList;
  2577. // print_r($loanList);
  2578. $Locate = 0;
  2579. $roleId = 0;
  2580. $button = 0;
  2581. foreach ( $receiptList as $key => $value ) {
  2582. $receiptList [$key] ['Locate'] = $Locate;
  2583. $Locate ++;
  2584. $receiptList [$key] ['reviseDetail'] = array ();
  2585. if (! empty ( $value ['reviseDetail'] ))
  2586. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2587. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2588. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2589. $categoryDetil = $Lcategory->getOne ( array (
  2590. 'where' => 'cid=' . $value ['cid'],
  2591. 'asArray' => true
  2592. ) );
  2593. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2594. // 检测编辑状态
  2595. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  2596. $verifyList ['staff'] = $value ['verifyBreakup'];
  2597. } else
  2598. $verifyList = $verify->getOne ( array (
  2599. 'where' => 'vid=' . $value ['verify'],
  2600. 'asArray' => true
  2601. ) );
  2602. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2603. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2604. Doo::loadModel ( 'role' );
  2605. $role = new role ();
  2606. if ($verifyList == NULL)
  2607. $verifyList = array ();
  2608. $flag = true;
  2609. $roleKey = 0;
  2610. $endStaffArray = array ();
  2611. $roleArrayCopy = array ();
  2612. foreach ( $verifyList as $k => $v ) {
  2613. // init verifyStaff
  2614. if ($v [1] == 'ROLE') {
  2615. if (! empty ( $verifyStaff )) {
  2616. $endStaffArray = end ( $verifyStaff );
  2617. // if ($v[0]==$endStaffArray['nextStaff']){
  2618. // $roleId=$v[0];
  2619. // }
  2620. }
  2621. $roleVerify = json_decode ( $v [3], true );
  2622. $roleKey = $k;
  2623. $roleArray = array ();
  2624. $rolename = $role->getOne ( array (
  2625. 'where' => 'rid=' . $v [0],
  2626. 'asArray' => true
  2627. ) );
  2628. foreach ( $roleVerify as $o => $p ) {
  2629. $staffID = explode ( '_', $p );
  2630. $staffInfo = $staff->getOne ( array (
  2631. 'where' => 'sid=' . $staffID [0],
  2632. 'asArray' => true
  2633. ) );
  2634. // print_r($staffID);
  2635. $exp = array (
  2636. 0 => $staffInfo ['sid'],
  2637. 1 => $staffID [1],
  2638. 2 => $staffInfo ['avatar'],
  2639. 'date' => '',
  2640. 'date' => '',
  2641. 'opinion' => '',
  2642. 'status' => '',
  2643. 'rolename' => $rolename ['name']
  2644. );
  2645. array_push ( $roleArray, $exp );
  2646. }
  2647. $roleArrayCopy [$v [0]] = $roleArray;
  2648. // $verifyList[$k]['roleArray']=$roleArray;
  2649. }
  2650. $verifyList [$k] ['date'] = "";
  2651. $verifyList [$k] ['opinion'] = "";
  2652. $verifyList [$k] ['status'] = "";
  2653. if (empty ( $verifyStaff )) {
  2654. $verifyList [$k] ['date'] = "";
  2655. $verifyList [$k] ['opinion'] = "";
  2656. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2657. $verifyList [$k] ['status'] = 4;
  2658. $flag = false;
  2659. }
  2660. } else {
  2661. foreach ( $verifyStaff as $m => $u ) {
  2662. if ($v [0] == $m) {
  2663. $verifyList [$k] ['date'] = $u ['date'];
  2664. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2665. $verifyList [$k] ['status'] = $u ['status'];
  2666. $flag = false;
  2667. break;
  2668. }
  2669. }
  2670. $endStaffArray = end ( $verifyStaff );
  2671. if (isset ( $endStaffArray ['ROLE'] )) {
  2672. } else {
  2673. // $endKey=key($verifyStaff);
  2674. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2675. // $button=4;
  2676. // $verifyList[$k]['status']=4;
  2677. // }
  2678. }
  2679. }
  2680. }
  2681. $rolename ['name'] = '';
  2682. if (! empty ( $roleId )) {
  2683. Doo::loadModel ( 'role' );
  2684. $role = new role ();
  2685. $rolename = $role->getOne ( array (
  2686. 'where' => 'rid=' . $roleId,
  2687. 'asArray' => true
  2688. ) );
  2689. }
  2690. if (! empty ( $verifyStaff ))
  2691. $endStaffArray = end ( $verifyStaff );
  2692. $KOP = false;
  2693. foreach ( $roleArrayCopy as $P => $A ) {
  2694. foreach ( $A as $MKI => $AVL ) {
  2695. if (! empty ( $verifyStaff )) {
  2696. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2697. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2698. $button = 4;
  2699. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2700. }
  2701. foreach ( $verifyStaff as $m => $u ) {
  2702. $AVLFK = $AVL [0] . '_R';
  2703. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2704. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2705. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2706. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2707. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2708. break;
  2709. }
  2710. }
  2711. } else {
  2712. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2713. $button = 4;
  2714. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2715. }
  2716. }
  2717. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2718. $KOP = true;
  2719. }
  2720. }
  2721. foreach ( $roleArrayCopy as $k => $v ) {
  2722. foreach ( $verifyList as $m => $n ) {
  2723. if ($n [0] == $k) {
  2724. array_splice ( $verifyList, $m, 1, $v );
  2725. }
  2726. }
  2727. }
  2728. // 费用执行人相关数据
  2729. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2730. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2731. foreach ( $executeCopy as $k => $v ) {
  2732. $executeCopy [$k] ['date'] = '';
  2733. $executeCopy [$k] ['opinion'] = '';
  2734. $executeCopy [$k] ['status'] = '';
  2735. if (! empty ( $executeStaff ))
  2736. foreach ( $executeStaff as $m => $u ) {
  2737. if ($v [0] == $m) {
  2738. $executeCopy [$k] ['date'] = $u ['date'];
  2739. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2740. $executeCopy [$k] ['status'] = $u ['status'];
  2741. break;
  2742. }
  2743. }
  2744. }
  2745. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2746. $receiptList [$key] ['verifyList'] = $verifyList;
  2747. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2748. 'where' => 'sid=' . $value ['staff'],
  2749. 'asArray' => true
  2750. ) );
  2751. $receiptList [$key] ['button'] = $button;
  2752. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2753. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2754. $relust = $value ['sum'] - $value ['loanSum'];
  2755. $receiptList [$key] ['relust'] = $relust;
  2756. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2757. }
  2758. // print_r($receiptList);
  2759. // 获取审批日志
  2760. Doo::loadModel ( 'receiptLog' );
  2761. $receiptLog = new receiptLog ();
  2762. $rlList = array ();
  2763. $rlInfo = $receiptLog->getOne ( array (
  2764. 'where' => 'rid=' . $rid . ' and status=4',
  2765. 'asArray' => true
  2766. ) );
  2767. $tijdate = $receiptLog->getOne ( array (
  2768. 'where' => 'rid=' . $rid . ' and status=2',
  2769. 'asc' => 'rlid',
  2770. 'asArray' => true
  2771. ) );
  2772. if (! empty ( $rlInfo )) {
  2773. $rlList = $receiptLog->find ( array (
  2774. 'where' => 'rid=' . $rid,
  2775. 'asc' => 'rlid',
  2776. 'asArray' => true
  2777. ) );
  2778. }
  2779. Doo::loadModel ( 'enclosur' );
  2780. $enclosur = new enclosur ();
  2781. $enclosurList = $enclosur->find ( array (
  2782. 'where' => 'rid=' . $rid,
  2783. 'asArray' => true
  2784. ) );
  2785. $enclosurHtml = '';
  2786. foreach ( $enclosurList as $value ) {
  2787. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2788. }
  2789. $data ['enclosurHtml'] = $enclosurHtml;
  2790. $receiptList [0] ['rlList'] = $rlList;
  2791. $data ['receiptList'] = $receiptList;
  2792. $data ['memu'] = "receipt";
  2793. $data ['staff'] = $this->staff;
  2794. $data ['receiptMemu'] = 'approvalExpenses';
  2795. $data ['verifyId'] = $this->verifyId;
  2796. $data ['executeId'] = $this->executeId;
  2797. $this->render ( "/admin/expensesDoc", $data );
  2798. }
  2799. function expensesEdi() {
  2800. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2801. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  2802. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2803. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2804. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2805. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2806. if (empty ( $status ))
  2807. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  2808. $vidList = array ();
  2809. $button = 0;
  2810. Doo::loadModel ( 'verify' );
  2811. Doo::loadModel ( 'receipt' );
  2812. Doo::loadModel ( 'staff' );
  2813. $staff = new staff ();
  2814. $receipt = new receipt ();
  2815. $verify = new verify ();
  2816. Doo::loadModel ( 'L_category' );
  2817. $Lcategory = new L_category ();
  2818. Doo::loadModel ( 'enclosur' );
  2819. $enclosur = new enclosur ();
  2820. // user verify ID
  2821. $verifyDetail = $verify->find ( array (
  2822. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  2823. 'asArray' => true
  2824. ) );
  2825. foreach ( $verifyDetail as $key => $value ) {
  2826. array_push ( $vidList, $value ['vid'] );
  2827. }
  2828. $vid = implode ( ",", $vidList );
  2829. if (empty ( $verifyDetail ))
  2830. $vid = 0;
  2831. $categoryList = $Lcategory->find ( array (
  2832. 'asArray' => true
  2833. ) );
  2834. $staffList = $staff->find ( array (
  2835. 'where' => 'cid=' . $cid,
  2836. 'asArray' => true
  2837. ) );
  2838. $ap = "";
  2839. if ($status == 4) {
  2840. $ap = 4;
  2841. $status = 2;
  2842. }
  2843. // get Receipt By verifyID status 2
  2844. $receiptList = $receipt->find ( array (
  2845. 'where' => 'rid =' . $rid . ' and status=2',
  2846. 'desc' => 'rid',
  2847. 'asArray' => true
  2848. ) );
  2849. if (empty ( $receiptList )) {
  2850. die ( 'illegal request' );
  2851. }
  2852. $Locate = 0;
  2853. $roleId = 0;
  2854. if ($ap == 4)
  2855. $status = 4;
  2856. foreach ( $receiptList as $key => $value ) {
  2857. $receiptList [$key] ['Locate'] = $Locate;
  2858. $Locate ++;
  2859. $receiptList [$key] ['reviseDetail'] = array ();
  2860. if (! empty ( $value ['reviseDetail'] ))
  2861. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2862. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2863. $categoryDetil = $Lcategory->getOne ( array (
  2864. 'where' => 'cid=' . $value ['cid'],
  2865. 'asArray' => true
  2866. ) );
  2867. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2868. // 检测编辑状态
  2869. $verifyList = $verify->getOne ( array (
  2870. 'where' => 'vid=' . $value ['verify'],
  2871. 'asArray' => true
  2872. ) );
  2873. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2874. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2875. Doo::loadModel ( 'role' );
  2876. $role = new role ();
  2877. // print_r($verifyList);
  2878. $flag = true;
  2879. $roleKey = 0;
  2880. $endStaffArray = array ();
  2881. $roleArrayCopy = array ();
  2882. foreach ( $verifyList as $k => $v ) {
  2883. // init verifyStaff
  2884. if ($v [1] == 'ROLE') {
  2885. if (! empty ( $verifyStaff )) {
  2886. $endStaffArray = end ( $verifyStaff );
  2887. if ($v [0] == $endStaffArray ['nextStaff']) {
  2888. $roleId = $v [0];
  2889. }
  2890. }
  2891. $roleVerify = json_decode ( $v [3], true );
  2892. $roleKey = $k;
  2893. $roleArray = array ();
  2894. $rolename = $role->getOne ( array (
  2895. 'where' => 'rid=' . $v [0],
  2896. 'asArray' => true
  2897. ) );
  2898. foreach ( $roleVerify as $o => $p ) {
  2899. $staffID = explode ( '_', $p );
  2900. $staffInfo = $staff->getOne ( array (
  2901. 'where' => 'sid=' . $staffID [0],
  2902. 'asArray' => true
  2903. ) );
  2904. // print_r($staffID);
  2905. $exp = array (
  2906. 0 => $staffInfo ['sid'],
  2907. 1 => $staffID [1],
  2908. 2 => $staffInfo ['avatar'],
  2909. 'date' => '',
  2910. 'date' => '',
  2911. 'opinion' => '',
  2912. 'status' => '',
  2913. 'rolename' => $rolename ['name']
  2914. );
  2915. array_push ( $roleArray, $exp );
  2916. }
  2917. $roleArrayCopy [$v [0]] = $roleArray;
  2918. // $verifyList[$k]['roleArray']=$roleArray;
  2919. }
  2920. // print_r($roleArray);
  2921. $verifyList [$k] ['date'] = "";
  2922. $verifyList [$k] ['opinion'] = "";
  2923. $verifyList [$k] ['status'] = "";
  2924. if (empty ( $verifyStaff )) {
  2925. $verifyList [$k] ['date'] = "";
  2926. $verifyList [$k] ['opinion'] = "";
  2927. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2928. $verifyList [$k] ['status'] = 4;
  2929. $button = 4;
  2930. $flag = false;
  2931. }
  2932. } else {
  2933. foreach ( $verifyStaff as $m => $u ) {
  2934. if ($v [0] == $m) {
  2935. $verifyList [$k] ['date'] = $u ['date'];
  2936. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2937. $verifyList [$k] ['status'] = $u ['status'];
  2938. $flag = false;
  2939. break;
  2940. }
  2941. }
  2942. $endStaffArray = end ( $verifyStaff );
  2943. if (isset ( $endStaffArray ['ROLE'] )) {
  2944. } else {
  2945. $endKey = key ( $verifyStaff );
  2946. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  2947. $button = 4;
  2948. $verifyList [$k] ['status'] = 4;
  2949. }
  2950. }
  2951. }
  2952. }
  2953. $rolename ['name'] = '';
  2954. if (! empty ( $roleId )) {
  2955. Doo::loadModel ( 'role' );
  2956. $role = new role ();
  2957. $rolename = $role->getOne ( array (
  2958. 'where' => 'rid=' . $roleId,
  2959. 'asArray' => true
  2960. ) );
  2961. }
  2962. if (! empty ( $verifyStaff ))
  2963. $endStaffArray = end ( $verifyStaff );
  2964. $KOP = false;
  2965. foreach ( $roleArrayCopy as $P => $A ) {
  2966. foreach ( $A as $MKI => $AVL ) {
  2967. if (! empty ( $verifyStaff )) {
  2968. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2969. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2970. $button = 4;
  2971. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2972. }
  2973. foreach ( $verifyStaff as $m => $u ) {
  2974. $AVLFK = $AVL [0] . '_R';
  2975. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2976. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2977. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2978. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2979. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2980. break;
  2981. }
  2982. }
  2983. } else {
  2984. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2985. $button = 4;
  2986. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2987. }
  2988. }
  2989. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2990. $KOP = true;
  2991. }
  2992. }
  2993. // print_r($roleArrayCopy);
  2994. // echo $roleKey;
  2995. foreach ( $roleArrayCopy as $k => $v ) {
  2996. foreach ( $verifyList as $m => $n ) {
  2997. if ($n [0] == $k) {
  2998. array_splice ( $verifyList, $m, 1, $v );
  2999. }
  3000. }
  3001. }
  3002. $receiptList [$key] ['verifyList'] = $verifyList;
  3003. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3004. 'where' => 'sid=' . $value ['staff'],
  3005. 'asArray' => true
  3006. ) );
  3007. $receiptList [$key] ['button'] = $button;
  3008. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  3009. }
  3010. // $data['verifyDetail']=$verifyDetail;
  3011. $mothHtml = "";
  3012. for($i = 1; $i <= 12; $i ++) {
  3013. if ($month == $i)
  3014. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3015. else
  3016. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3017. }
  3018. // 获取审批日志
  3019. Doo::loadModel ( 'receiptLog' );
  3020. $receiptLog = new receiptLog ();
  3021. $rlList = array ();
  3022. $rlInfo = $receiptLog->getOne ( array (
  3023. 'where' => 'rid=' . $rid . ' and status=4',
  3024. 'asArray' => true
  3025. ) );
  3026. $tijdate = $receiptLog->getOne ( array (
  3027. 'where' => 'rid=' . $rid . ' and status=2',
  3028. 'asc' => 'rlid',
  3029. 'asArray' => true
  3030. ) );
  3031. if (! empty ( $rlInfo )) {
  3032. $rlList = $receiptLog->find ( array (
  3033. 'where' => 'rid=' . $rid,
  3034. 'asc' => 'rlid',
  3035. 'asArray' => true
  3036. ) );
  3037. }
  3038. $receiptList [0] ['rlList'] = $rlList;
  3039. $enclosurList = $enclosur->find ( array (
  3040. 'where' => 'rid=' . $rid,
  3041. 'asArray' => true
  3042. ) );
  3043. $enclosurHtml = '';
  3044. foreach ( $enclosurList as $value ) {
  3045. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3046. }
  3047. // print_r($receiptList);
  3048. $data ['rid'] = $rid;
  3049. $data ['enclosurHtml'] = $enclosurHtml;
  3050. $data ['rolename'] = $rolename ['name'];
  3051. $data ['datetij'] = $tijdate ['date'];
  3052. $data ['mothHtml'] = $mothHtml;
  3053. $data ['receiptList'] = $receiptList;
  3054. $data ['receiptApprovalCount'] = count ( $receiptList );
  3055. $data ['status'] = $status;
  3056. $data ['year'] = $year;
  3057. $data ['categoryList'] = $categoryList;
  3058. $data ['staffList'] = $staffList;
  3059. $data ['cid'] = $cid;
  3060. $data ['sid'] = $sid;
  3061. $data ['ap'] = $ap;
  3062. $data ['memu'] = "receipt";
  3063. $data ['staff'] = $this->staff;
  3064. $data ['receiptMemu'] = 'approvalExpenses';
  3065. $data ['verifyId'] = $this->verifyId;
  3066. $data ['executeId'] = $this->executeId;
  3067. $this->render ( "/admin/expensesEdi", $data );
  3068. }
  3069. function expensesDefray() {
  3070. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3071. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3072. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3073. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  3074. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  3075. if (! empty ( $rid )) {
  3076. Doo::loadModel ( "verify" );
  3077. $verify = new verify ();
  3078. Doo::loadModel ( "receiptDetail" );
  3079. $receiptDetailObj = new receiptDetail ();
  3080. Doo::loadModel ( "itemStatistics" );
  3081. Doo::loadModel ( "statistics" );
  3082. $statistics = new statistics ();
  3083. $itemStatistics = new itemStatistics ();
  3084. Doo::loadModel ( "receipt" );
  3085. $receipt = new receipt ();
  3086. Doo::loadModel ( "loanReceipt" );
  3087. $loanReceipt = new loanReceipt ();
  3088. $receiptDetail = $receipt->getOne ( array (
  3089. 'where' => 'rid=' . $rid . ' and status=2 ',
  3090. 'asArray' => true
  3091. ) );
  3092. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  3093. $nsflag = true;
  3094. foreach ( $nslist as $value ) {
  3095. if ($value == $this->staff ['0'] ['sid']) {
  3096. $nsflag = false;
  3097. break;
  3098. }
  3099. }
  3100. // print_r($nslist);die;
  3101. if (empty ( $receiptDetail ) || $nsflag)
  3102. return "/approvalExpenses/pendApproval";
  3103. $verifyDetail = $verify->getOne ( array (
  3104. 'where' => ' vid =' . $receiptDetail ['verify'],
  3105. 'asArray' => true
  3106. ) );
  3107. $verifyString = $verifyDetail ['staff'];
  3108. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3109. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  3110. if (empty ( $opinion )) {
  3111. if ($status == 3)
  3112. $opinion = "终止";
  3113. else
  3114. $opinion = "同意支付";
  3115. }
  3116. $nowStaff = 0;
  3117. $nowStaffList = array ();
  3118. if (empty ( $verifyStaff )) {
  3119. // 还需加入是否已经进入角色审批
  3120. if ($verifyDetail [0] [1] == 'ROLE') {
  3121. // print_r($verifyDetail);echo "ddd";
  3122. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3123. foreach ( $vStaffString as $key => $value ) {
  3124. $staffK = explode ( "_", $value );
  3125. if ($staffK [0] != $this->staff [0] ['sid'])
  3126. array_push ( $nowStaffList, $staffK [0] );
  3127. }
  3128. // print_r($verifyDetail);
  3129. // die;
  3130. if (! empty ( $nowStaffList )) {
  3131. $nowStaff = implode ( ',', $nowStaffList );
  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 [0] [0],
  3138. 'ROLE' => 1
  3139. )
  3140. );
  3141. } else {
  3142. $nowStaff = $verifyDetail [1] [0];
  3143. $verifyStaff = array (
  3144. $this->staff [0] ['sid'] . "_R" => array (
  3145. 'date' => date ( 'Y-m-d' ),
  3146. 'opinion' => $opinion,
  3147. 'status' => $status,
  3148. 'nextStaff' => $verifyDetail [1] [0]
  3149. )
  3150. );
  3151. }
  3152. } else {
  3153. if ($verifyDetail [1] [1] == 'ROLE') {
  3154. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  3155. // echo "dd";
  3156. foreach ( $vStaffString as $key => $value ) {
  3157. $staffK = explode ( "_", $value );
  3158. array_push ( $nowStaffList, $staffK [0] );
  3159. }
  3160. $nowStaff = implode ( ',', $nowStaffList );
  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. 'ROLE' => 1
  3168. )
  3169. );
  3170. } else {
  3171. $nowStaff = $verifyDetail [1] [0];
  3172. $verifyStaff = array (
  3173. $this->staff [0] ['sid'] => array (
  3174. 'date' => date ( 'Y-m-d' ),
  3175. 'opinion' => $opinion,
  3176. 'status' => $status,
  3177. 'nextStaff' => $verifyDetail [1] [0]
  3178. )
  3179. );
  3180. }
  3181. }
  3182. if ($status == 3)
  3183. $verifyStaff = array (
  3184. 'final' => $status,
  3185. $this->staff [0] ['sid'] => array (
  3186. 'date' => date ( 'Y-m-d' ),
  3187. 'opinion' => $opinion,
  3188. 'status' => $status
  3189. )
  3190. );
  3191. $vStaffString = json_encode ( $verifyStaff );
  3192. $receipt->nowStaff = $nowStaff;
  3193. $receipt->verifyStaff = $vStaffString;
  3194. $loanReceipt->nowStaff = $nowStaff;
  3195. $loanReceipt->verifyStaff = $vStaffString;
  3196. } else {
  3197. $VS = end ( $verifyStaff );
  3198. // 非角色审批
  3199. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  3200. $nextStaff = 0;
  3201. $roleSTF = false;
  3202. foreach ( $verifyDetail as $key => $value ) {
  3203. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  3204. if (isset ( $verifyDetail [$key + 1] )) {
  3205. $nextStaff = $verifyDetail [$key + 1] [0];
  3206. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  3207. $roleSTF = true;
  3208. }
  3209. break;
  3210. }
  3211. }
  3212. if (! $roleSTF) {
  3213. $nowStaff = $nextStaff;
  3214. $verifyStaff [$this->staff [0] ['sid']] = array (
  3215. 'date' => date ( 'Y-m-d' ),
  3216. 'opinion' => $opinion,
  3217. 'status' => $status,
  3218. 'nextStaff' => $nextStaff
  3219. );
  3220. } else {
  3221. // 获取角色下的所有用户ID
  3222. $nowStaffList = array ();
  3223. foreach ( $verifyDetail as $vfk ) {
  3224. if ($vfk [1] == 'ROLE') {
  3225. $vStaffString = json_decode ( $vfk [3] );
  3226. foreach ( $vStaffString as $key => $value ) {
  3227. $staffK = explode ( "_", $value );
  3228. array_push ( $nowStaffList, $staffK [0] );
  3229. }
  3230. }
  3231. }
  3232. $nowStaff = implode ( ',', $nowStaffList );
  3233. $verifyStaff [$this->staff [0] ['sid']] = array (
  3234. 'date' => date ( 'Y-m-d' ),
  3235. 'opinion' => $opinion,
  3236. 'status' => $status,
  3237. 'nextStaff' => $nextStaff,
  3238. 'ROLE' => 0
  3239. );
  3240. }
  3241. if ($status == 3) {
  3242. $verifyStaff ['final'] = $status;
  3243. $verifyStaff [$this->staff [0] ['sid']] = array (
  3244. 'date' => date ( 'Y-m-d' ),
  3245. 'opinion' => $opinion,
  3246. 'status' => $status
  3247. );
  3248. }
  3249. $vStaffString = json_encode ( $verifyStaff );
  3250. $receipt->nowStaff = $nowStaff;
  3251. $receipt->verifyStaff = $vStaffString;
  3252. $loanReceipt->nowStaff = $nowStaff;
  3253. $loanReceipt->verifyStaff = $vStaffString;
  3254. }
  3255. // 角色审批
  3256. if (isset ( $VS ['ROLE'] )) {
  3257. // 找出角色人 当前审批角色组
  3258. $verifyJSStaff = array ();
  3259. $nowStaffList2 = array ();
  3260. foreach ( $verifyDetail as $key => $value ) {
  3261. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  3262. $verifyJSStaff = json_decode ( $value [3] );
  3263. foreach ( $verifyJSStaff as $m ) {
  3264. $staffK = explode ( "_", $m );
  3265. array_push ( $nowStaffList2, $staffK [0] );
  3266. }
  3267. // print_r($nowStaffList2);
  3268. }
  3269. }
  3270. $RoleVerifyStaff = array ();
  3271. foreach ( $verifyStaff as $key => $value ) {
  3272. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  3273. foreach ( $nowStaffList2 as $m ) {
  3274. if ($key == $m . "_R")
  3275. $RoleVerifyStaff [$key] = $value;
  3276. }
  3277. }
  3278. }
  3279. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  3280. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  3281. // 下一个审批人ID
  3282. $nextStaff = 0;
  3283. $falg = false;
  3284. foreach ( $verifyDetail as $key => $value ) {
  3285. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  3286. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  3287. $falg = true;
  3288. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  3289. $nowStaffList = array ();
  3290. foreach ( $vStaffString as $v ) {
  3291. $staffK = explode ( "_", $v );
  3292. array_push ( $nowStaffList, $staffK [0] );
  3293. }
  3294. $nowStaff = implode ( ',', $nowStaffList );
  3295. $nextStaff = $verifyDetail [$key + 1] [0];
  3296. } elseif (isset ( $verifyDetail [$key + 1] )) {
  3297. $nextStaff = $verifyDetail [$key + 1] [0];
  3298. $nowStaff = $nextStaff;
  3299. } else
  3300. $nowStaff = '';
  3301. break;
  3302. }
  3303. }
  3304. if ($falg)
  3305. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3306. 'date' => date ( 'Y-m-d' ),
  3307. 'opinion' => $opinion,
  3308. 'status' => $status,
  3309. 'nextStaff' => $nextStaff,
  3310. 'ROLE' => 1
  3311. );
  3312. else
  3313. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3314. 'date' => date ( 'Y-m-d' ),
  3315. 'opinion' => $opinion,
  3316. 'status' => $status,
  3317. 'nextStaff' => $nextStaff
  3318. );
  3319. // print_r($verifyStaff);
  3320. // echo $nowStaff;die;
  3321. } else { // 进入下一个角色或者审批人
  3322. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  3323. //
  3324. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  3325. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3326. 'date' => date ( 'Y-m-d' ),
  3327. 'opinion' => $opinion,
  3328. 'status' => $status,
  3329. 'nextStaff' => $VS ['nextStaff'],
  3330. 'ROLE' => 1
  3331. );
  3332. // print_r($verifyStaff);
  3333. // die;
  3334. }
  3335. if ($status == 3) {
  3336. $verifyStaff ['final'] = $status;
  3337. $verifyStaff [$this->staff [0] ['sid']] = array (
  3338. 'date' => date ( 'Y-m-d' ),
  3339. 'opinion' => $opinion,
  3340. 'status' => $status
  3341. );
  3342. }
  3343. $vStaffString = json_encode ( $verifyStaff );
  3344. $receipt->verifyStaff = $vStaffString;
  3345. $receipt->nowStaff = $nowStaff;
  3346. $loanReceipt->nowStaff = $nowStaff;
  3347. $loanReceipt->verifyStaff = $vStaffString;
  3348. // die;
  3349. // }
  3350. // print_r($verifyStaff);
  3351. // die;
  3352. }
  3353. // print_r($verifyStaff);die;
  3354. }
  3355. // print_r($verifyDetail);
  3356. $roleKey = 0;
  3357. $roleId = 0;
  3358. $verifyDetailCopy = array ();
  3359. foreach ( $verifyDetail as $k => $v ) {
  3360. if ($v [1] == 'ROLE') {
  3361. $roleId = $v [0];
  3362. $roleVerify = json_decode ( $v [3], true );
  3363. $roleKey = $k;
  3364. $roleArray = array ();
  3365. foreach ( $roleVerify as $o => $p ) {
  3366. $staffID = explode ( '_', $p );
  3367. $exp = array (
  3368. 0 => $staffID [0],
  3369. 1 => $staffID [1]
  3370. );
  3371. array_push ( $roleArray, $exp );
  3372. }
  3373. $verifyDetailCopy [$v [0]] = $roleArray;
  3374. }
  3375. }
  3376. // print_r($verifyDetail);
  3377. foreach ( $verifyDetailCopy as $k => $v ) {
  3378. foreach ( $verifyDetail as $m => $n ) {
  3379. if ($n [0] == $k) {
  3380. array_splice ( $verifyDetail, $m, 1, $v );
  3381. }
  3382. }
  3383. }
  3384. // 审批日志
  3385. if (! isset ( $verifyStaff ['final'] )) {
  3386. Doo::loadModel ( "receiptLog" );
  3387. $receiptLog = new receiptLog ();
  3388. if (! empty ( $roleId )) {
  3389. Doo::loadModel ( "role" );
  3390. $role = new role ();
  3391. $roleInfo = $role->getOne ( array (
  3392. 'where' => 'rid=' . $roleId,
  3393. 'asArray' => true
  3394. ) );
  3395. $receiptLog->rolename = $roleInfo ['name'];
  3396. }
  3397. $receiptLog->username = $this->staff [0] ['username'];
  3398. $receiptLog->uid = $this->staff [0] ['sid'];
  3399. $receiptLog->date = date ( "Y-m-d" );
  3400. $receiptLog->opinion = $opinion;
  3401. $receiptLog->img = $this->staff [0] ['avatar'];
  3402. $receiptLog->status = 1;
  3403. $receiptLog->rid = $rid;
  3404. $receiptLog->insert ();
  3405. }
  3406. if (isset ( $verifyStaff ['final'] )) { // rDetail
  3407. $receipt->status = 3;
  3408. $receipt->verifyBreakup = $verifyString;
  3409. $receiptDetailObj->status = 3;
  3410. $receiptDetailObj->update ( array (
  3411. 'where' => 'rid=' . $rid
  3412. ) );
  3413. // 微信企业号通知
  3414. $this->setWXMsg ( $rid, 3 );
  3415. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  3416. $receipt->status = 6;
  3417. $receipt->pastDate = date ( "Y-m-d" );
  3418. $receipt->isBK = 1;
  3419. $loanReceipt->verifyBreakup = $verifyString;
  3420. $loanReceipt->status = 1;
  3421. $loanReceipt->pastDate = date ( "Y-m-d" );
  3422. $loanReceipt->amount = $receiptDetail ['amount'];
  3423. $loanReceipt->update ( array (
  3424. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  3425. ) );
  3426. // 微信企业号通知
  3427. $this->setWXMsg ( $rid, 1 );
  3428. }
  3429. $receipt->amount = $amount;
  3430. $receipt->update ( array (
  3431. 'where' => ' rid = ' . $rid
  3432. ) );
  3433. // 进入下一条审批费用新加需求
  3434. $vidList = array ();
  3435. $verifyDetail = $verify->find ( array (
  3436. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  3437. 'asArray' => true
  3438. ) );
  3439. foreach ( $verifyDetail as $key => $value ) {
  3440. array_push ( $vidList, $value ['vid'] );
  3441. }
  3442. $vid = implode ( ",", $vidList );
  3443. if (empty ( $verifyDetail ))
  3444. $vid = 0;
  3445. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  3446. $receipt = new receipt ();
  3447. $rd = $receipt->getOne ( array (
  3448. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  3449. 'asc' => 'rid',
  3450. 'asArray' => true
  3451. ) );
  3452. if (empty ( $rd )) {
  3453. return '/approvalExpenses/pendApproval';
  3454. }
  3455. if ($rd ['Rtype'] == 1) {
  3456. if ($rd ['isBK'] == 1) {
  3457. return '/receiptburEdi/' . $rd ['rid'];
  3458. } else {
  3459. return '/expensesEdi/' . $rd ['rid'];
  3460. }
  3461. } elseif ($rd ['Rtype'] == 2) {
  3462. return '/remitApproval/' . $rd ['rid'];
  3463. } else {
  3464. return '/receiptburEdi/' . $rd ['rid'];
  3465. }
  3466. // return "/approvalExpenses/pendApproval";
  3467. }
  3468. }
  3469. function ajaxExamineExe() {
  3470. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3471. Doo::loadModel ( 'receipt' );
  3472. $receipt = new receipt ();
  3473. Doo::loadClass ( 'XDeode' );
  3474. $XDeode = new XDeode ( 5 );
  3475. if (! empty ( $rid )) {
  3476. $rLRes = $receipt->find ( array (
  3477. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  3478. 'asArray' => true
  3479. ) );
  3480. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  3481. echo json_encode ( array (
  3482. 'status' => 1,
  3483. 'receipt' => $rLRes [0]
  3484. ) );
  3485. die ();
  3486. }
  3487. echo json_encode ( array (
  3488. 'status' => 0,
  3489. 'receipt' => array ()
  3490. ) );
  3491. die ();
  3492. }
  3493. function implement() {
  3494. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3495. Doo::loadClass ( 'XDeode' );
  3496. $XDeode = new XDeode ( 5 );
  3497. Doo::loadModel ( 'receipt' );
  3498. $receipt = new receipt ();
  3499. Doo::loadModel ( 'L_category' );
  3500. $Lcategory = new L_category ();
  3501. Doo::loadModel ( 'verify' );
  3502. $verify = new verify ();
  3503. Doo::loadModel ( 'staff' );
  3504. $staff = new staff ();
  3505. Doo::loadModel ( "execute" );
  3506. $execute = new execute ();
  3507. $rid = $XDeode->decode ( $rid );
  3508. $receiptList = $receipt->find ( array (
  3509. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  3510. 'desc' => 'rid',
  3511. 'asArray' => true
  3512. ) );
  3513. Doo::loadModel ( 'loanReceipt' );
  3514. $loanReceipt = new loanReceipt ();
  3515. // print_r($receiptList);
  3516. $loanList = array ();
  3517. if (! isset ( $receiptList ))
  3518. $loanList = $loanReceipt->find ( array (
  3519. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3520. 'desc' => 'rid',
  3521. 'asArray' => true
  3522. ) );
  3523. $Locate = 0;
  3524. $roleId = 0;
  3525. $button = 0;
  3526. foreach ( $loanList as $key => $value ) {
  3527. $loanList [$key] ['Locate'] = $Locate;
  3528. $Locate ++;
  3529. $loanList [$key] ['reviseDetail'] = array ();
  3530. if (! empty ( $value ['reviseDetail'] ))
  3531. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3532. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3533. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3534. $categoryDetil = $Lcategory->getOne ( array (
  3535. 'where' => 'cid=' . $value ['cid'],
  3536. 'asArray' => true
  3537. ) );
  3538. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3539. // 检测编辑状态
  3540. $verifyList = $verify->getOne ( array (
  3541. 'where' => 'vid=' . $value ['verify'],
  3542. 'asArray' => true
  3543. ) );
  3544. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3545. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3546. Doo::loadModel ( 'role' );
  3547. $role = new role ();
  3548. $flag = true;
  3549. $roleKey = 0;
  3550. $endStaffArray = array ();
  3551. $roleArrayCopy = array ();
  3552. foreach ( $verifyList as $k => $v ) {
  3553. // init verifyStaff
  3554. if ($v [1] == 'ROLE') {
  3555. if (! empty ( $verifyStaff )) {
  3556. $endStaffArray = end ( $verifyStaff );
  3557. // if ($v[0]==$endStaffArray['nextStaff']){
  3558. // $roleId=$v[0];
  3559. // }
  3560. }
  3561. $roleVerify = json_decode ( $v [3], true );
  3562. $roleKey = $k;
  3563. $roleArray = array ();
  3564. $rolename = $role->getOne ( array (
  3565. 'where' => 'rid=' . $v [0],
  3566. 'asArray' => true
  3567. ) );
  3568. foreach ( $roleVerify as $o => $p ) {
  3569. $staffID = explode ( '_', $p );
  3570. $staffInfo = $staff->getOne ( array (
  3571. 'where' => 'sid=' . $staffID [0],
  3572. 'asArray' => true
  3573. ) );
  3574. // print_r($staffID);
  3575. $exp = array (
  3576. 0 => $staffInfo ['sid'],
  3577. 1 => $staffID [1],
  3578. 2 => $staffInfo ['avatar'],
  3579. 'date' => '',
  3580. 'date' => '',
  3581. 'opinion' => '',
  3582. 'status' => '',
  3583. 'rolename' => $rolename ['name']
  3584. );
  3585. array_push ( $roleArray, $exp );
  3586. }
  3587. $roleArrayCopy [$v [0]] = $roleArray;
  3588. // $verifyList[$k]['roleArray']=$roleArray;
  3589. }
  3590. $verifyList [$k] ['date'] = "";
  3591. $verifyList [$k] ['opinion'] = "";
  3592. $verifyList [$k] ['status'] = "";
  3593. if (empty ( $verifyStaff )) {
  3594. $verifyList [$k] ['date'] = "";
  3595. $verifyList [$k] ['opinion'] = "";
  3596. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3597. $verifyList [$k] ['status'] = 4;
  3598. $flag = false;
  3599. }
  3600. } else {
  3601. foreach ( $verifyStaff as $m => $u ) {
  3602. if ($v [0] == $m) {
  3603. $verifyList [$k] ['date'] = $u ['date'];
  3604. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3605. $verifyList [$k] ['status'] = $u ['status'];
  3606. $flag = false;
  3607. break;
  3608. }
  3609. }
  3610. $endStaffArray = end ( $verifyStaff );
  3611. if (isset ( $endStaffArray ['ROLE'] )) {
  3612. } else {
  3613. // $endKey=key($verifyStaff);
  3614. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3615. // $button=4;
  3616. // $verifyList[$k]['status']=4;
  3617. // }
  3618. }
  3619. }
  3620. }
  3621. $rolename ['name'] = '';
  3622. if (! empty ( $roleId )) {
  3623. Doo::loadModel ( 'role' );
  3624. $role = new role ();
  3625. $rolename = $role->getOne ( array (
  3626. 'where' => 'rid=' . $roleId,
  3627. 'asArray' => true
  3628. ) );
  3629. }
  3630. if (! empty ( $verifyStaff ))
  3631. $endStaffArray = end ( $verifyStaff );
  3632. $KOP = false;
  3633. foreach ( $roleArrayCopy as $P => $A ) {
  3634. foreach ( $A as $MKI => $AVL ) {
  3635. if (! empty ( $verifyStaff )) {
  3636. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3637. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3638. $button = 4;
  3639. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3640. }
  3641. foreach ( $verifyStaff as $m => $u ) {
  3642. $AVLFK = $AVL [0] . '_R';
  3643. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3644. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3645. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3646. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3647. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3648. break;
  3649. }
  3650. }
  3651. } else {
  3652. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3653. $button = 4;
  3654. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3655. }
  3656. }
  3657. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3658. $KOP = true;
  3659. }
  3660. }
  3661. foreach ( $roleArrayCopy as $k => $v ) {
  3662. foreach ( $verifyList as $m => $n ) {
  3663. if ($n [0] == $k) {
  3664. array_splice ( $verifyList, $m, 1, $v );
  3665. }
  3666. }
  3667. }
  3668. $loanList [$key] ['verifyList'] = $verifyList;
  3669. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3670. 'where' => 'sid=' . $value ['staff'],
  3671. 'asArray' => true
  3672. ) );
  3673. }
  3674. $data ['loanList'] = $loanList;
  3675. $Locate = 0;
  3676. $roleId = 0;
  3677. $button = 0;
  3678. foreach ( $receiptList as $key => $value ) {
  3679. $button2 = 0;
  3680. $receiptList [$key] ['Locate'] = $Locate;
  3681. $Locate ++;
  3682. $receiptList [$key] ['reviseDetail'] = array ();
  3683. if (! empty ( $value ['reviseDetail'] ))
  3684. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3685. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3686. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3687. $categoryDetil = $Lcategory->getOne ( array (
  3688. 'where' => 'cid=' . $value ['cid'],
  3689. 'asArray' => true
  3690. ) );
  3691. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3692. $executeList = json_decode ( $value ['executeCopy'], true );
  3693. $executeStaff = array ();
  3694. if (! empty ( $value ['executeStaff'] ))
  3695. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3696. if (isset ( $executeList )) {
  3697. foreach ( $executeList as $op => $lo ) {
  3698. $executeList [$op] ['date'] = "";
  3699. $executeList [$op] ['opinion'] = "";
  3700. $executeList [$op] ['status'] = "";
  3701. foreach ( $executeStaff as $m => $u ) {
  3702. if ($lo [0] == $m) {
  3703. $executeList [$op] ['date'] = $u ['date'];
  3704. $executeList [$op] ['opinion'] = $u ['opinion'];
  3705. $executeList [$op] ['status'] = $u ['status'];
  3706. break;
  3707. }
  3708. }
  3709. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  3710. $button2 = 1;
  3711. $executeList [$op] ['status'] = 4;
  3712. }
  3713. }
  3714. }
  3715. // 检测编辑状态
  3716. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3717. $verifyList ['staff'] = $value ['verifyBreakup'];
  3718. } else
  3719. $verifyList = $verify->getOne ( array (
  3720. 'where' => 'vid=' . $value ['verify'],
  3721. 'asArray' => true
  3722. ) );
  3723. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3724. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3725. Doo::loadModel ( 'role' );
  3726. $role = new role ();
  3727. if ($verifyList == NULL)
  3728. $verifyList = array ();
  3729. $flag = true;
  3730. $roleKey = 0;
  3731. $endStaffArray = array ();
  3732. $roleArrayCopy = array ();
  3733. foreach ( $verifyList as $k => $v ) {
  3734. // init verifyStaff
  3735. if ($v [1] == 'ROLE') {
  3736. if (! empty ( $verifyStaff )) {
  3737. $endStaffArray = end ( $verifyStaff );
  3738. // if ($v[0]==$endStaffArray['nextStaff']){
  3739. // $roleId=$v[0];
  3740. // }
  3741. }
  3742. $roleVerify = json_decode ( $v [3], true );
  3743. $roleKey = $k;
  3744. $roleArray = array ();
  3745. $rolename = $role->getOne ( array (
  3746. 'where' => 'rid=' . $v [0],
  3747. 'asArray' => true
  3748. ) );
  3749. foreach ( $roleVerify as $o => $p ) {
  3750. $staffID = explode ( '_', $p );
  3751. $staffInfo = $staff->getOne ( array (
  3752. 'where' => 'sid=' . $staffID [0],
  3753. 'asArray' => true
  3754. ) );
  3755. // print_r($staffID);
  3756. $exp = array (
  3757. 0 => $staffInfo ['sid'],
  3758. 1 => $staffID [1],
  3759. 2 => $staffInfo ['avatar'],
  3760. 'date' => '',
  3761. 'date' => '',
  3762. 'opinion' => '',
  3763. 'status' => '',
  3764. 'rolename' => $rolename ['name']
  3765. );
  3766. array_push ( $roleArray, $exp );
  3767. }
  3768. $roleArrayCopy [$v [0]] = $roleArray;
  3769. // $verifyList[$k]['roleArray']=$roleArray;
  3770. }
  3771. $verifyList [$k] ['date'] = "";
  3772. $verifyList [$k] ['opinion'] = "";
  3773. $verifyList [$k] ['status'] = "";
  3774. if (empty ( $verifyStaff )) {
  3775. $verifyList [$k] ['date'] = "";
  3776. $verifyList [$k] ['opinion'] = "";
  3777. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3778. $verifyList [$k] ['status'] = 4;
  3779. $flag = false;
  3780. }
  3781. } else {
  3782. foreach ( $verifyStaff as $m => $u ) {
  3783. if ($v [0] == $m) {
  3784. $verifyList [$k] ['date'] = $u ['date'];
  3785. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3786. $verifyList [$k] ['status'] = $u ['status'];
  3787. $flag = false;
  3788. break;
  3789. }
  3790. }
  3791. $endStaffArray = end ( $verifyStaff );
  3792. if (isset ( $endStaffArray ['ROLE'] )) {
  3793. } else {
  3794. // $endKey=key($verifyStaff);
  3795. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3796. // $button=4;
  3797. // $verifyList[$k]['status']=4;
  3798. // }
  3799. }
  3800. }
  3801. }
  3802. $rolename ['name'] = '';
  3803. if (! empty ( $roleId )) {
  3804. Doo::loadModel ( 'role' );
  3805. $role = new role ();
  3806. $rolename = $role->getOne ( array (
  3807. 'where' => 'rid=' . $roleId,
  3808. 'asArray' => true
  3809. ) );
  3810. }
  3811. if (! empty ( $verifyStaff ))
  3812. $endStaffArray = end ( $verifyStaff );
  3813. $KOP = false;
  3814. foreach ( $roleArrayCopy as $P => $A ) {
  3815. foreach ( $A as $MKI => $AVL ) {
  3816. if (! empty ( $verifyStaff )) {
  3817. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3818. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3819. $button = 4;
  3820. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3821. }
  3822. foreach ( $verifyStaff as $m => $u ) {
  3823. $AVLFK = $AVL [0] . '_R';
  3824. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3825. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3826. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3827. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3828. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3829. break;
  3830. }
  3831. }
  3832. } else {
  3833. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3834. $button = 4;
  3835. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3836. }
  3837. }
  3838. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3839. $KOP = true;
  3840. }
  3841. }
  3842. foreach ( $roleArrayCopy as $k => $v ) {
  3843. foreach ( $verifyList as $m => $n ) {
  3844. if ($n [0] == $k) {
  3845. array_splice ( $verifyList, $m, 1, $v );
  3846. }
  3847. }
  3848. }
  3849. $receiptList [$key] ['verifyList'] = $verifyList;
  3850. $receiptList [$key] ['executeList'] = $executeList;
  3851. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3852. 'where' => 'sid=' . $value ['staff'],
  3853. 'asArray' => true
  3854. ) );
  3855. $receiptList [$key] ['button2'] = $button2;
  3856. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3857. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3858. $relust = $value ['sum'] - $value ['loanSum'];
  3859. $receiptList [$key] ['relust'] = $relust;
  3860. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  3861. }
  3862. // print_r($receiptList[$key]['executeList']);
  3863. $data ['receiptList'] = $receiptList;
  3864. $data ['memu'] = "receipt";
  3865. $data ['staff'] = $this->staff;
  3866. $data ['receiptMemu'] = 'implement';
  3867. $data ['verifyId'] = $this->verifyId;
  3868. $data ['executeId'] = $this->executeId;
  3869. $this->render ( "/admin/implement", $data );
  3870. }
  3871. function implementDo() {
  3872. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3873. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3874. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  3875. if (! empty ( $rid ) && $amount != '') {
  3876. Doo::loadModel ( 'receipt' );
  3877. $receipt = new receipt ();
  3878. Doo::loadClass ( 'XDeode' );
  3879. $XDeode = new XDeode ( 5 );
  3880. $rinfo = $receipt->getOne ( array (
  3881. 'where' => 'rid=' . $rid,
  3882. 'asArray' => true
  3883. ) );
  3884. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  3885. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  3886. if (empty ( $executeStaff )) {
  3887. $executeStaff = array (
  3888. $this->staff [0] ['sid'] => array (
  3889. 'date' => date ( 'Y-m-d' ),
  3890. 'opinion' => $implementOpinions,
  3891. 'status' => 1
  3892. )
  3893. );
  3894. } else {
  3895. $executeStaff [$this->staff [0] ['sid']] = array (
  3896. 'date' => date ( 'Y-m-d' ),
  3897. 'opinion' => $implementOpinions,
  3898. 'status' => 1
  3899. );
  3900. }
  3901. if (count ( $executeStaff ) == count ( $executeCopy )) {
  3902. $receipt->executeStaff = json_encode ( $executeStaff );
  3903. $receipt->status = 8;
  3904. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  3905. $receipt->status = 9;
  3906. if ($rinfo ['status'] == 6) {
  3907. $receipt->loanDate = date ( "Y-m-d" );
  3908. }
  3909. $receipt->executeDate = date ( "Y-m-d" );
  3910. } else {
  3911. $receipt->executeStaff = json_encode ( $executeStaff );
  3912. }
  3913. $receipt->amount = $amount;
  3914. $receipt->update ( array (
  3915. 'where' => 'rid=' . $rid
  3916. ) );
  3917. }
  3918. $ridKey = $XDeode->encode ( $rid );
  3919. return "/hisImplement";
  3920. // return "/implement/" . $ridKey . ".html";
  3921. }
  3922. function receiptburEdi() {
  3923. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3924. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  3925. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  3926. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  3927. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3928. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  3929. if (empty ( $status ))
  3930. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  3931. $vidList = array ();
  3932. $button = 0;
  3933. Doo::loadModel ( 'verify' );
  3934. Doo::loadModel ( 'receipt' );
  3935. Doo::loadModel ( 'staff' );
  3936. $staff = new staff ();
  3937. $receipt = new receipt ();
  3938. $verify = new verify ();
  3939. Doo::loadModel ( 'L_category' );
  3940. $Lcategory = new L_category ();
  3941. Doo::loadModel ( 'enclosur' );
  3942. $enclosur = new enclosur ();
  3943. Doo::loadModel ( 'loanReceipt' );
  3944. $loanReceipt = new loanReceipt ();
  3945. // user verify ID
  3946. $verifyDetail = $verify->find ( array (
  3947. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  3948. 'asArray' => true
  3949. ) );
  3950. foreach ( $verifyDetail as $key => $value ) {
  3951. array_push ( $vidList, $value ['vid'] );
  3952. }
  3953. $vid = implode ( ",", $vidList );
  3954. if (empty ( $verifyDetail ))
  3955. $vid = 0;
  3956. $categoryList = $Lcategory->find ( array (
  3957. 'asArray' => true
  3958. ) );
  3959. $staffList = $staff->find ( array (
  3960. 'where' => 'cid=' . $cid,
  3961. 'asArray' => true
  3962. ) );
  3963. $ap = "";
  3964. if ($status == 4) {
  3965. $ap = 4;
  3966. $status = 2;
  3967. }
  3968. // get Receipt By verifyID status 2
  3969. $receiptList = $receipt->find ( array (
  3970. 'where' => 'rid =' . $rid . ' and status=2',
  3971. 'desc' => 'rid',
  3972. 'asArray' => true
  3973. ) );
  3974. if (empty ( $receiptList )) {
  3975. die ( 'illegal request' );
  3976. }
  3977. $loanList = $loanReceipt->find ( array (
  3978. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3979. 'desc' => 'rid',
  3980. 'asArray' => true
  3981. ) );
  3982. $Locate = 0;
  3983. $roleId = 0;
  3984. $button = 0;
  3985. foreach ( $loanList as $key => $value ) {
  3986. $loanList [$key] ['Locate'] = $Locate;
  3987. $Locate ++;
  3988. $loanList [$key] ['reviseDetail'] = array ();
  3989. if (! empty ( $value ['reviseDetail'] ))
  3990. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3991. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3992. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3993. $categoryDetil = $Lcategory->getOne ( array (
  3994. 'where' => 'cid=' . $value ['cid'],
  3995. 'asArray' => true
  3996. ) );
  3997. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3998. // 检测编辑状态
  3999. $verifyList = $verify->getOne ( array (
  4000. 'where' => 'vid=' . $value ['verify'],
  4001. 'asArray' => true
  4002. ) );
  4003. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4004. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4005. Doo::loadModel ( 'role' );
  4006. $role = new role ();
  4007. $flag = true;
  4008. $roleKey = 0;
  4009. $endStaffArray = array ();
  4010. $roleArrayCopy = array ();
  4011. foreach ( $verifyList as $k => $v ) {
  4012. // init verifyStaff
  4013. if ($v [1] == 'ROLE') {
  4014. if (! empty ( $verifyStaff )) {
  4015. $endStaffArray = end ( $verifyStaff );
  4016. }
  4017. $roleVerify = json_decode ( $v [3], true );
  4018. $roleKey = $k;
  4019. $roleArray = array ();
  4020. $rolename = $role->getOne ( array (
  4021. 'where' => 'rid=' . $v [0],
  4022. 'asArray' => true
  4023. ) );
  4024. foreach ( $roleVerify as $o => $p ) {
  4025. $staffID = explode ( '_', $p );
  4026. $staffInfo = $staff->getOne ( array (
  4027. 'where' => 'sid=' . $staffID [0],
  4028. 'asArray' => true
  4029. ) );
  4030. // print_r($staffID);
  4031. $exp = array (
  4032. 0 => $staffInfo ['sid'],
  4033. 1 => $staffID [1],
  4034. 2 => $staffInfo ['avatar'],
  4035. 'date' => '',
  4036. 'date' => '',
  4037. 'opinion' => '',
  4038. 'status' => '',
  4039. 'rolename' => $rolename ['name']
  4040. );
  4041. array_push ( $roleArray, $exp );
  4042. }
  4043. $roleArrayCopy [$v [0]] = $roleArray;
  4044. // $verifyList[$k]['roleArray']=$roleArray;
  4045. }
  4046. $verifyList [$k] ['date'] = "";
  4047. $verifyList [$k] ['opinion'] = "";
  4048. $verifyList [$k] ['status'] = "";
  4049. if (empty ( $verifyStaff )) {
  4050. $verifyList [$k] ['date'] = "";
  4051. $verifyList [$k] ['opinion'] = "";
  4052. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4053. $verifyList [$k] ['status'] = 4;
  4054. $flag = false;
  4055. }
  4056. } else {
  4057. foreach ( $verifyStaff as $m => $u ) {
  4058. if ($v [0] == $m) {
  4059. $verifyList [$k] ['date'] = $u ['date'];
  4060. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4061. $verifyList [$k] ['status'] = $u ['status'];
  4062. $flag = false;
  4063. break;
  4064. }
  4065. }
  4066. $endStaffArray = end ( $verifyStaff );
  4067. if (isset ( $endStaffArray ['ROLE'] )) {
  4068. } else {
  4069. }
  4070. }
  4071. }
  4072. $rolename ['name'] = '';
  4073. if (! empty ( $roleId )) {
  4074. Doo::loadModel ( 'role' );
  4075. $role = new role ();
  4076. $rolename = $role->getOne ( array (
  4077. 'where' => 'rid=' . $roleId,
  4078. 'asArray' => true
  4079. ) );
  4080. }
  4081. if (! empty ( $verifyStaff ))
  4082. $endStaffArray = end ( $verifyStaff );
  4083. $KOP = false;
  4084. foreach ( $roleArrayCopy as $P => $A ) {
  4085. foreach ( $A as $MKI => $AVL ) {
  4086. if (! empty ( $verifyStaff )) {
  4087. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4088. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4089. $button = 4;
  4090. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4091. }
  4092. foreach ( $verifyStaff as $m => $u ) {
  4093. $AVLFK = $AVL [0] . '_R';
  4094. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4095. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4096. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4097. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4098. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4099. break;
  4100. }
  4101. }
  4102. } else {
  4103. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4104. $button = 4;
  4105. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4106. }
  4107. }
  4108. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4109. $KOP = true;
  4110. }
  4111. }
  4112. foreach ( $roleArrayCopy as $k => $v ) {
  4113. foreach ( $verifyList as $m => $n ) {
  4114. if ($n [0] == $k) {
  4115. array_splice ( $verifyList, $m, 1, $v );
  4116. }
  4117. }
  4118. }
  4119. $loanList [$key] ['verifyList'] = $verifyList;
  4120. }
  4121. $htmlLoan = '';
  4122. if (isset ( $loanList [0] )) {
  4123. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  4124. if ($value ['status'] == 1)
  4125. $htmlLoan .= '<li class="done" >';
  4126. elseif ($value ['status'] == 3)
  4127. $htmlLoan .= '<li class="undone" >';
  4128. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  4129. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  4130. if (isset ( $value ['rolename'] ))
  4131. $htmlLoan .= $value ['rolename'];
  4132. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  4133. }
  4134. $data ['loanDate'] = $loanList [0] ['date'];
  4135. }
  4136. $data ['htmlLoan'] = $htmlLoan;
  4137. $data ['loanReceiptDate'] = $loanList [0] ['date'];
  4138. // $data ['LoanReceipt']=$loanList[0];
  4139. // print_r($loanList);
  4140. $Locate = 0;
  4141. $roleId = 0;
  4142. $button = 0;
  4143. if ($ap == 4)
  4144. $status = 4;
  4145. foreach ( $receiptList as $key => $value ) {
  4146. $receiptList [$key] ['Locate'] = $Locate;
  4147. $Locate ++;
  4148. $receiptList [$key] ['reviseDetail'] = array ();
  4149. if (! empty ( $value ['reviseDetail'] ))
  4150. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4151. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4152. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4153. $categoryDetil = $Lcategory->getOne ( array (
  4154. 'where' => 'cid=' . $value ['cid'],
  4155. 'asArray' => true
  4156. ) );
  4157. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4158. // 检测编辑状态
  4159. $verifyList = $verify->getOne ( array (
  4160. 'where' => 'vid=' . $value ['verify'],
  4161. 'asArray' => true
  4162. ) );
  4163. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4164. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4165. Doo::loadModel ( 'role' );
  4166. $role = new role ();
  4167. // print_r($verifyList);
  4168. $flag = true;
  4169. $roleKey = 0;
  4170. $endStaffArray = array ();
  4171. $roleArrayCopy = array ();
  4172. foreach ( $verifyList as $k => $v ) {
  4173. // init verifyStaff
  4174. if ($v [1] == 'ROLE') {
  4175. if (! empty ( $verifyStaff )) {
  4176. $endStaffArray = end ( $verifyStaff );
  4177. if ($v [0] == $endStaffArray ['nextStaff']) {
  4178. $roleId = $v [0];
  4179. }
  4180. }
  4181. $roleVerify = json_decode ( $v [3], true );
  4182. $roleKey = $k;
  4183. $roleArray = array ();
  4184. $rolename = $role->getOne ( array (
  4185. 'where' => 'rid=' . $v [0],
  4186. 'asArray' => true
  4187. ) );
  4188. foreach ( $roleVerify as $o => $p ) {
  4189. $staffID = explode ( '_', $p );
  4190. $staffInfo = $staff->getOne ( array (
  4191. 'where' => 'sid=' . $staffID [0],
  4192. 'asArray' => true
  4193. ) );
  4194. // print_r($staffID);
  4195. $exp = array (
  4196. 0 => $staffInfo ['sid'],
  4197. 1 => $staffID [1],
  4198. 2 => $staffInfo ['avatar'],
  4199. 'date' => '',
  4200. 'date' => '',
  4201. 'opinion' => '',
  4202. 'status' => '',
  4203. 'rolename' => $rolename ['name']
  4204. );
  4205. array_push ( $roleArray, $exp );
  4206. }
  4207. $roleArrayCopy [$v [0]] = $roleArray;
  4208. // $verifyList[$k]['roleArray']=$roleArray;
  4209. }
  4210. // print_r($roleArray);
  4211. $verifyList [$k] ['date'] = "";
  4212. $verifyList [$k] ['opinion'] = "";
  4213. $verifyList [$k] ['status'] = "";
  4214. if (empty ( $verifyStaff )) {
  4215. $verifyList [$k] ['date'] = "";
  4216. $verifyList [$k] ['opinion'] = "";
  4217. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4218. $verifyList [$k] ['status'] = 4;
  4219. $button = 4;
  4220. $flag = false;
  4221. }
  4222. } else {
  4223. foreach ( $verifyStaff as $m => $u ) {
  4224. if ($v [0] == $m) {
  4225. $verifyList [$k] ['date'] = $u ['date'];
  4226. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4227. $verifyList [$k] ['status'] = $u ['status'];
  4228. $flag = false;
  4229. break;
  4230. }
  4231. }
  4232. $endStaffArray = end ( $verifyStaff );
  4233. if (isset ( $endStaffArray ['ROLE'] )) {
  4234. } else {
  4235. $endKey = key ( $verifyStaff );
  4236. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4237. $button = 4;
  4238. $verifyList [$k] ['status'] = 4;
  4239. }
  4240. }
  4241. }
  4242. }
  4243. $rolename ['name'] = '';
  4244. if (! empty ( $roleId )) {
  4245. Doo::loadModel ( 'role' );
  4246. $role = new role ();
  4247. $rolename = $role->getOne ( array (
  4248. 'where' => 'rid=' . $roleId,
  4249. 'asArray' => true
  4250. ) );
  4251. }
  4252. if (! empty ( $verifyStaff ))
  4253. $endStaffArray = end ( $verifyStaff );
  4254. $KOP = false;
  4255. foreach ( $roleArrayCopy as $P => $A ) {
  4256. foreach ( $A as $MKI => $AVL ) {
  4257. if (! empty ( $verifyStaff )) {
  4258. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4259. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4260. $button = 4;
  4261. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4262. }
  4263. foreach ( $verifyStaff as $m => $u ) {
  4264. $AVLFK = $AVL [0] . '_R';
  4265. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4266. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4267. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4268. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4269. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4270. break;
  4271. }
  4272. }
  4273. } else {
  4274. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4275. $button = 4;
  4276. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4277. }
  4278. }
  4279. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4280. $KOP = true;
  4281. }
  4282. }
  4283. foreach ( $roleArrayCopy as $k => $v ) {
  4284. foreach ( $verifyList as $m => $n ) {
  4285. if ($n [0] == $k) {
  4286. array_splice ( $verifyList, $m, 1, $v );
  4287. }
  4288. }
  4289. }
  4290. // print_r($verifyList);
  4291. $receiptList [$key] ['verifyList'] = $verifyList;
  4292. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4293. 'where' => 'sid=' . $value ['staff'],
  4294. 'asArray' => true
  4295. ) );
  4296. $receiptList [$key] ['button'] = $button;
  4297. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4298. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4299. $relust = $value ['sum'] - $value ['loanSum'];
  4300. $receiptList [$key] ['relust'] = $relust;
  4301. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4302. }
  4303. // print_r($receiptList);die;
  4304. // $data['verifyDetail']=$verifyDetail;
  4305. $mothHtml = "";
  4306. for($i = 1; $i <= 12; $i ++) {
  4307. if ($month == $i)
  4308. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4309. else
  4310. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4311. }
  4312. // 获取审批日志
  4313. Doo::loadModel ( 'receiptLog' );
  4314. $receiptLog = new receiptLog ();
  4315. $rlList = array ();
  4316. $rlInfo = $receiptLog->getOne ( array (
  4317. 'where' => 'rid=' . $rid . ' and status=4',
  4318. 'asArray' => true
  4319. ) );
  4320. $tijdate = $receiptLog->getOne ( array (
  4321. 'where' => 'rid=' . $rid . ' and status=2',
  4322. 'asc' => 'rlid',
  4323. 'asArray' => true
  4324. ) );
  4325. if (! empty ( $rlInfo )) {
  4326. $rlList = $receiptLog->find ( array (
  4327. 'where' => 'rid=' . $rid,
  4328. 'asc' => 'rlid',
  4329. 'asArray' => true
  4330. ) );
  4331. }
  4332. // echo $rid;
  4333. // print_r($receiptList);
  4334. $receiptList [0] ['rlList'] = $rlList;
  4335. // print_r($receiptList);
  4336. $enclosurList = $enclosur->find ( array (
  4337. 'where' => 'rid=' . $rid,
  4338. 'asArray' => true
  4339. ) );
  4340. $enclosurHtml = '';
  4341. foreach ( $enclosurList as $value ) {
  4342. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4343. }
  4344. $data ['enclosurHtml'] = $enclosurHtml;
  4345. $data ['rolename'] = $rolename ['name'];
  4346. $data ['mothHtml'] = $mothHtml;
  4347. // print_r($receiptList);
  4348. $data ['rid'] = $rid;
  4349. $data ['tijdate'] = $tijdate ['date'];
  4350. $data ['receiptList'] = $receiptList;
  4351. $data ['receiptApprovalCount'] = count ( $receiptList );
  4352. $data ['status'] = $status;
  4353. $data ['year'] = $year;
  4354. $data ['categoryList'] = $categoryList;
  4355. $data ['staffList'] = $staffList;
  4356. $data ['cid'] = $cid;
  4357. $data ['sid'] = $sid;
  4358. $data ['ap'] = $ap;
  4359. $data ['memu'] = "receipt";
  4360. $data ['staff'] = $this->staff;
  4361. $data ['receiptMemu'] = 'approvalExpenses';
  4362. $data ['verifyId'] = $this->verifyId;
  4363. $data ['executeId'] = $this->executeId;
  4364. $this->render ( "/admin/receiptburEdi", $data );
  4365. }
  4366. function hisImplement() {
  4367. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4368. if (empty ( $item ))
  4369. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "pendImplement";
  4370. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  4371. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4372. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  4373. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  4374. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  4375. Doo::loadModel ( 'receipt' );
  4376. $receipt = new receipt ();
  4377. Doo::loadModel ( 'L_category' );
  4378. $Lcategory = new L_category ();
  4379. Doo::loadModel ( 'verify' );
  4380. Doo::loadModel ( 'statistics' );
  4381. $statistics = new statistics ();
  4382. $verify = new verify ();
  4383. Doo::loadModel ( 'staff' );
  4384. $staff = new staff ();
  4385. Doo::loadClass ( 'XDeode' );
  4386. $XDeode = new XDeode ( 5 );
  4387. $condition = "";
  4388. if ($item == "expenses")
  4389. $condition = " and Rtype=1 ";
  4390. elseif ($item == "receipts")
  4391. $condition = " and Rtype=0 ";
  4392. elseif ($item == "remits")
  4393. $condition = " and Rtype=2 ";
  4394. elseif ($item == "pendImplement") {
  4395. $condition = ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  4396. }
  4397. // 'and (executeCopy like "%["' . $this->staff [0] ['sid'] . '"%" and executeStaff not like "%{"' . $this->staff [0] ['sid'] . '"%" )';
  4398. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  4399. $sopString = "";
  4400. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  4401. if (empty ( $rdate ))
  4402. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  4403. else
  4404. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  4405. if ($item == 'teipts') {
  4406. $statusCon = '(status=1 or status=6 )';
  4407. $dateCondition = " and date_format(pastDate,'%Y-%m-%d')='" . $rdate . "' ";
  4408. } elseif ($item == 'alerpts') {
  4409. $statusCon = '(status=8 or status=9 )';
  4410. if (empty ( $rdate ))
  4411. $dateCondition = " and Year(date) =" . $year;
  4412. else
  4413. $dateCondition = " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  4414. }
  4415. /*
  4416. * if ($item == 'teipts') { $statusCon = '(status=1 or status=6 )'; $dateCondition = " and Year(pastDate) =" . $year; if ($moth != 'MONTH') $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth; if ($day != 'DAY') $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth . " and day(pastDate)=" . $day; } elseif ($item == 'alerpts') { $statusCon = '(status=8 or status=9 )'; $dateCondition = " and Year(executeDate) =" . $year; if ($moth != 'MONTH') $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth; if ($day != 'DAY') $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day; }
  4417. */
  4418. if ($sop != 'SOP')
  4419. $sopString = " and staff=" . $sop;
  4420. // $noPassSum=$receipt->receiptByYear($year,$this->staff[0]['sid']); and (status=1 or status=6)
  4421. $receiptList = $receipt->find ( array (
  4422. 'where' => $statusCon . $condition . $dateCondition . $sopString,
  4423. 'desc' => 'rid',
  4424. 'asArray' => true
  4425. ) );
  4426. // 员工筛选
  4427. $receiptList2 = $receipt->find ( array (
  4428. 'where' => $statusCon . $condition . $dateCondition,
  4429. 'desc' => 'rid',
  4430. 'asArray' => true
  4431. ) );
  4432. $sopStaff = array ();
  4433. foreach ( $receiptList2 as $key => $value ) {
  4434. $staffDetail = $staff->getOne ( array (
  4435. 'where' => 'sid=' . $value ['staff'],
  4436. 'asArray' => true
  4437. ) );
  4438. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  4439. }
  4440. $Locate = 0;
  4441. $roleId = 0;
  4442. $button = 0;
  4443. foreach ( $receiptList as $key => $value ) {
  4444. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4445. $receiptList [$key] ['Texe'] = 'false';
  4446. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  4447. $receiptList [$key] ['Texe'] = 'true';
  4448. }
  4449. $receiptList [$key] ['TRexe'] = 'true';
  4450. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  4451. $receiptList [$key] ['TRexe'] = 'false';
  4452. }
  4453. $receiptList [$key] ['Locate'] = $Locate;
  4454. $Locate ++;
  4455. $receiptList [$key] ['reviseDetail'] = array ();
  4456. if (! empty ( $value ['reviseDetail'] ))
  4457. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4458. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4459. $categoryDetil = $Lcategory->getOne ( array (
  4460. 'where' => 'cid=' . $value ['cid'],
  4461. 'asArray' => true
  4462. ) );
  4463. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4464. // 检测编辑状态
  4465. $verifyList = $verify->getOne ( array (
  4466. 'where' => 'vid=' . $value ['verify'],
  4467. 'asArray' => true
  4468. ) );
  4469. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4470. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4471. Doo::loadModel ( 'role' );
  4472. $role = new role ();
  4473. $flag = true;
  4474. $roleKey = 0;
  4475. $endStaffArray = array ();
  4476. $roleArrayCopy = array ();
  4477. foreach ( $verifyList as $k => $v ) {
  4478. // init verifyStaff
  4479. if ($v [1] == 'ROLE') {
  4480. if (! empty ( $verifyStaff )) {
  4481. $endStaffArray = end ( $verifyStaff );
  4482. }
  4483. $roleVerify = json_decode ( $v [3], true );
  4484. $roleKey = $k;
  4485. $roleArray = array ();
  4486. $rolename = $role->getOne ( array (
  4487. 'where' => 'rid=' . $v [0],
  4488. 'asArray' => true
  4489. ) );
  4490. foreach ( $roleVerify as $o => $p ) {
  4491. $staffID = explode ( '_', $p );
  4492. $staffInfo = $staff->getOne ( array (
  4493. 'where' => 'sid=' . $staffID [0],
  4494. 'asArray' => true
  4495. ) );
  4496. $exp = array (
  4497. 0 => $staffInfo ['sid'],
  4498. 1 => $staffID [1],
  4499. 2 => $staffInfo ['avatar'],
  4500. 'date' => '',
  4501. 'date' => '',
  4502. 'opinion' => '',
  4503. 'status' => '',
  4504. 'rolename' => $rolename ['name']
  4505. );
  4506. array_push ( $roleArray, $exp );
  4507. }
  4508. $roleArrayCopy [$v [0]] = $roleArray;
  4509. }
  4510. $verifyList [$k] ['date'] = "";
  4511. $verifyList [$k] ['opinion'] = "";
  4512. $verifyList [$k] ['status'] = "";
  4513. if (empty ( $verifyStaff )) {
  4514. $verifyList [$k] ['date'] = "";
  4515. $verifyList [$k] ['opinion'] = "";
  4516. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4517. $verifyList [$k] ['status'] = 4;
  4518. $flag = false;
  4519. }
  4520. } else {
  4521. foreach ( $verifyStaff as $m => $u ) {
  4522. if ($v [0] == $m) {
  4523. $verifyList [$k] ['date'] = $u ['date'];
  4524. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4525. $verifyList [$k] ['status'] = $u ['status'];
  4526. $flag = false;
  4527. break;
  4528. }
  4529. }
  4530. $endStaffArray = end ( $verifyStaff );
  4531. }
  4532. }
  4533. $rolename ['name'] = '';
  4534. if (! empty ( $roleId )) {
  4535. Doo::loadModel ( 'role' );
  4536. $role = new role ();
  4537. $rolename = $role->getOne ( array (
  4538. 'where' => 'rid=' . $roleId,
  4539. 'asArray' => true
  4540. ) );
  4541. }
  4542. if (! empty ( $verifyStaff ))
  4543. $endStaffArray = end ( $verifyStaff );
  4544. $KOP = false;
  4545. foreach ( $roleArrayCopy as $P => $A ) {
  4546. foreach ( $A as $MKI => $AVL ) {
  4547. if (! empty ( $verifyStaff )) {
  4548. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4549. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4550. $button = 4;
  4551. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4552. }
  4553. foreach ( $verifyStaff as $m => $u ) {
  4554. $AVLFK = $AVL [0] . '_R';
  4555. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4556. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4557. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4558. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4559. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4560. break;
  4561. }
  4562. }
  4563. } else {
  4564. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4565. $button = 4;
  4566. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4567. }
  4568. }
  4569. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4570. $KOP = true;
  4571. }
  4572. }
  4573. foreach ( $roleArrayCopy as $k => $v ) {
  4574. foreach ( $verifyList as $m => $n ) {
  4575. if ($n [0] == $k) {
  4576. array_splice ( $verifyList, $m, 1, $v );
  4577. }
  4578. }
  4579. }
  4580. $receiptList [$key] ['verifyList'] = $verifyList;
  4581. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4582. 'where' => 'sid=' . $value ['staff'],
  4583. 'asArray' => true
  4584. ) );
  4585. $receiptList [$key] ['button'] = $button;
  4586. }
  4587. // print_r($receiptList);
  4588. $mothHtml = "";
  4589. for($i = 1; $i <= 12; $i ++) {
  4590. if ($moth == $i)
  4591. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4592. else
  4593. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4594. }
  4595. $dayHtml = "";
  4596. if ($day != "DAY" || $moth != "MONTH") {
  4597. for($i = 1; $i <= 31; $i ++) {
  4598. if ($day == $i)
  4599. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  4600. else
  4601. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  4602. }
  4603. }
  4604. $sopHtml = "";
  4605. foreach ( $sopStaff as $key => $value ) {
  4606. if ($sop == $key)
  4607. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4608. else
  4609. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4610. }
  4611. $data ['rdate'] = $rdate;
  4612. $data ['sopHtml'] = $sopHtml;
  4613. $data ['dayHtml'] = $dayHtml;
  4614. $data ['mothHtml'] = $mothHtml;
  4615. $data ['receiptList'] = $receiptList;
  4616. $data ['memu'] = "receipt";
  4617. $data ['staff'] = $this->staff;
  4618. $data ['receiptMemu'] = 'implement';
  4619. $data ['verifyId'] = $this->verifyId;
  4620. $data ['executeId'] = $this->executeId;
  4621. $data ['item'] = $item;
  4622. $data ['year'] = $year;
  4623. $data ['moth'] = $moth;
  4624. $data ['day'] = $day;
  4625. $data ['sop'] = $sop;
  4626. $this->render ( "/admin/hisImplement", $data );
  4627. }
  4628. function ajaxExamine() {
  4629. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4630. Doo::loadModel ( 'receipt' );
  4631. $receipt = new receipt ();
  4632. if (! empty ( $rid )) {
  4633. $rLRes = $receipt->find ( array (
  4634. '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,
  4635. 'asArray' => true
  4636. ) );
  4637. echo json_encode ( array (
  4638. 'status' => 1,
  4639. 'receipt' => $rLRes [0]
  4640. ) );
  4641. die ();
  4642. }
  4643. echo json_encode ( array (
  4644. 'status' => 0,
  4645. 'receipt' => array ()
  4646. ) );
  4647. die ();
  4648. }
  4649. /*
  4650. * 废弃
  4651. */
  4652. function myReceipt() {
  4653. // all approval past withdraw
  4654. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4655. if (empty ( $item ))
  4656. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4657. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4658. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  4659. Doo::loadModel ( 'receipt' );
  4660. $receipt = new receipt ();
  4661. // pre-loaded
  4662. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4663. // have cache
  4664. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  4665. if (! empty ( $moth )) // yearPage
  4666. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  4667. $this->showCache ( $path );
  4668. }
  4669. Doo::loadModel ( 'L_category' );
  4670. $Lcategory = new L_category ();
  4671. Doo::loadModel ( 'verify' );
  4672. Doo::loadModel ( 'statistics' );
  4673. $statistics = new statistics ();
  4674. $verify = new verify ();
  4675. Doo::loadModel ( 'staff' );
  4676. $staff = new staff ();
  4677. $condition = " and status!=0 ";
  4678. if ($item == "approval")
  4679. $condition = " and status=2 ";
  4680. elseif ($item == "withdraw")
  4681. $condition = " and status=3 ";
  4682. elseif ($item == "past")
  4683. $condition = " and status=1 ";
  4684. elseif ($item == "whdw")
  4685. $condition = " and status=4 ";
  4686. $dateCondition = " and Year(date) =" . $year;
  4687. if (! empty ( $moth )) {
  4688. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  4689. $stList = $statistics->getOne ( array (
  4690. 'select' => 'rePrice ,agPrice',
  4691. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  4692. 'asArray' => true
  4693. ) );
  4694. } else
  4695. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  4696. if (empty ( $stList ))
  4697. $stList = array (
  4698. 'rePrice' => 0,
  4699. 'agPrice' => 0
  4700. );
  4701. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  4702. $data ['stList'] = array (
  4703. 'rePrice' => $stList ['rePrice'],
  4704. 'agPrice' => $stList ['agPrice'],
  4705. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  4706. );
  4707. $receiptList = $receipt->find ( array (
  4708. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  4709. 'desc' => 'rid',
  4710. 'asArray' => true
  4711. ) );
  4712. $Locate = 0;
  4713. $roleId = 0;
  4714. $button = 0;
  4715. foreach ( $receiptList as $key => $value ) {
  4716. $receiptList [$key] ['Locate'] = $Locate;
  4717. $Locate ++;
  4718. $receiptList [$key] ['reviseDetail'] = array ();
  4719. if (! empty ( $value ['reviseDetail'] ))
  4720. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4721. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4722. $categoryDetil = $Lcategory->getOne ( array (
  4723. 'where' => 'cid=' . $value ['cid'],
  4724. 'asArray' => true
  4725. ) );
  4726. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4727. // 检测编辑状态
  4728. $verifyList = $verify->getOne ( array (
  4729. 'where' => 'vid=' . $value ['verify'],
  4730. 'asArray' => true
  4731. ) );
  4732. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4733. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4734. Doo::loadModel ( 'role' );
  4735. $role = new role ();
  4736. $flag = true;
  4737. $roleKey = 0;
  4738. $endStaffArray = array ();
  4739. $roleArrayCopy = array ();
  4740. foreach ( $verifyList as $k => $v ) {
  4741. // init verifyStaff
  4742. if ($v [1] == 'ROLE') {
  4743. if (! empty ( $verifyStaff )) {
  4744. $endStaffArray = end ( $verifyStaff );
  4745. // if ($v[0]==$endStaffArray['nextStaff']){
  4746. // $roleId=$v[0];
  4747. // }
  4748. }
  4749. $roleVerify = json_decode ( $v [3], true );
  4750. $roleKey = $k;
  4751. $roleArray = array ();
  4752. $rolename = $role->getOne ( array (
  4753. 'where' => 'rid=' . $v [0],
  4754. 'asArray' => true
  4755. ) );
  4756. foreach ( $roleVerify as $o => $p ) {
  4757. $staffID = explode ( '_', $p );
  4758. $staffInfo = $staff->getOne ( array (
  4759. 'where' => 'sid=' . $staffID [0],
  4760. 'asArray' => true
  4761. ) );
  4762. // print_r($staffID);
  4763. $exp = array (
  4764. 0 => $staffInfo ['sid'],
  4765. 1 => $staffID [1],
  4766. 2 => $staffInfo ['avatar'],
  4767. 'date' => '',
  4768. 'date' => '',
  4769. 'opinion' => '',
  4770. 'status' => '',
  4771. 'rolename' => $rolename ['name']
  4772. );
  4773. array_push ( $roleArray, $exp );
  4774. }
  4775. $roleArrayCopy [$v [0]] = $roleArray;
  4776. // $verifyList[$k]['roleArray']=$roleArray;
  4777. }
  4778. $verifyList [$k] ['date'] = "";
  4779. $verifyList [$k] ['opinion'] = "";
  4780. $verifyList [$k] ['status'] = "";
  4781. if (empty ( $verifyStaff )) {
  4782. $verifyList [$k] ['date'] = "";
  4783. $verifyList [$k] ['opinion'] = "";
  4784. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4785. $verifyList [$k] ['status'] = 4;
  4786. $flag = false;
  4787. }
  4788. } else {
  4789. foreach ( $verifyStaff as $m => $u ) {
  4790. if ($v [0] == $m) {
  4791. $verifyList [$k] ['date'] = $u ['date'];
  4792. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4793. $verifyList [$k] ['status'] = $u ['status'];
  4794. $flag = false;
  4795. break;
  4796. }
  4797. }
  4798. $endStaffArray = end ( $verifyStaff );
  4799. if (isset ( $endStaffArray ['ROLE'] )) {
  4800. } else {
  4801. // $endKey=key($verifyStaff);
  4802. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4803. // $button=4;
  4804. // $verifyList[$k]['status']=4;
  4805. // }
  4806. }
  4807. }
  4808. }
  4809. $rolename ['name'] = '';
  4810. if (! empty ( $roleId )) {
  4811. Doo::loadModel ( 'role' );
  4812. $role = new role ();
  4813. $rolename = $role->getOne ( array (
  4814. 'where' => 'rid=' . $roleId,
  4815. 'asArray' => true
  4816. ) );
  4817. }
  4818. if (! empty ( $verifyStaff ))
  4819. $endStaffArray = end ( $verifyStaff );
  4820. $KOP = false;
  4821. foreach ( $roleArrayCopy as $P => $A ) {
  4822. foreach ( $A as $MKI => $AVL ) {
  4823. if (! empty ( $verifyStaff )) {
  4824. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4825. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4826. $button = 4;
  4827. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4828. }
  4829. foreach ( $verifyStaff as $m => $u ) {
  4830. $AVLFK = $AVL [0] . '_R';
  4831. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4832. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4833. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4834. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4835. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4836. break;
  4837. }
  4838. }
  4839. } else {
  4840. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4841. $button = 4;
  4842. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4843. }
  4844. }
  4845. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4846. $KOP = true;
  4847. }
  4848. }
  4849. foreach ( $roleArrayCopy as $k => $v ) {
  4850. foreach ( $verifyList as $m => $n ) {
  4851. if ($n [0] == $k) {
  4852. array_splice ( $verifyList, $m, 1, $v );
  4853. }
  4854. }
  4855. }
  4856. $receiptList [$key] ['verifyList'] = $verifyList;
  4857. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4858. 'where' => 'sid=' . $value ['staff'],
  4859. 'asArray' => true
  4860. ) );
  4861. $receiptList [$key] ['button'] = $button;
  4862. }
  4863. // print_r($receiptList);die;
  4864. $mothHtml = "";
  4865. for($i = 1; $i <= 12; $i ++) {
  4866. if ($moth == $i)
  4867. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4868. else
  4869. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4870. }
  4871. $data ['mothHtml'] = $mothHtml;
  4872. $data ['receiptList'] = $receiptList;
  4873. $data ['memu'] = "receipt";
  4874. $data ['staff'] = $this->staff;
  4875. $data ['receiptMemu'] = 'receipt';
  4876. $data ['verifyId'] = $this->verifyId;
  4877. $data ['executeId'] = $this->executeId;
  4878. $data ['item'] = $item;
  4879. $data ['year'] = $year;
  4880. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4881. // sufficient condition to generate cache
  4882. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  4883. $receiptList = $receipt->find ( array (
  4884. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  4885. 'asArray' => true
  4886. ) );
  4887. if (empty ( $receiptList )) { // generated files
  4888. ob_start ();
  4889. $this->render ( "/admin/saea_myList", $data );
  4890. $this->cacheFile ( $path );
  4891. die ();
  4892. // $content = ob_get_contents();
  4893. // $fp = fopen($path, "w");
  4894. // fwrite($fp, $content);
  4895. // fclose($fp);
  4896. }
  4897. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  4898. $receiptList = $receipt->find ( array (
  4899. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  4900. 'asArray' => true
  4901. ) );
  4902. if (empty ( $receiptList )) { // generated files
  4903. ob_start ();
  4904. $this->render ( "/admin/saea_myList", $data );
  4905. $this->cacheFile ( $path );
  4906. die ();
  4907. }
  4908. }
  4909. }
  4910. $this->render ( "/admin/saea_myList", $data );
  4911. }
  4912. function saeaCreate() {
  4913. Doo::loadModel ( 'accountItem' );
  4914. Doo::loadModel ( 'verify' );
  4915. Doo::loadModel ( 'receipt' );
  4916. Doo::loadModel ( 'L_category' );
  4917. $lCategory = new L_category ();
  4918. $receipt = new receipt ();
  4919. $verify = new verify ();
  4920. $accountItem = new accountItem ();
  4921. Doo::loadModel ( "role" );
  4922. $role = new role ();
  4923. $acItem = $accountItem->find ( array (
  4924. 'asArray' => true
  4925. ) );
  4926. $veList = $verify->find ( array (
  4927. 'asArray' => true
  4928. ) );
  4929. foreach ( $veList as $key => $value ) {
  4930. $v = json_decode ( $value ['staff'] );
  4931. $list = array ();
  4932. foreach ( $v as $n => $m ) {
  4933. if ($m ['1'] == 'ROLE') {
  4934. $roleInfo = $role->getOne ( array (
  4935. 'where' => 'rid=' . $m [0],
  4936. 'asArray' => true
  4937. ) );
  4938. $v [$n] [1] = $roleInfo ['name'];
  4939. array_push ( $list, $roleInfo ['name'] );
  4940. } else {
  4941. array_push ( $list, $v [$n] [1] );
  4942. }
  4943. }
  4944. $veList [$key] ['staff'] = implode ( '>', $list );
  4945. }
  4946. $data ['category'] = $lCategory->find ( array (
  4947. 'asArray' => true
  4948. ) );
  4949. $data ['veList'] = $veList;
  4950. $data ['acItem'] = $acItem;
  4951. $data ['memu'] = "receipt";
  4952. $data ['staff'] = $this->staff;
  4953. $data ['receiptMemu'] = 'saeaBorad';
  4954. $data ['verifyId'] = $this->verifyId;
  4955. $data ['executeId'] = $this->executeId;
  4956. $this->render ( "/admin/saea_create", $data );
  4957. }
  4958. function addReceipt() {
  4959. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  4960. $agency = $this->get_args ( 'agency' );
  4961. $travel = $this->get_args ( 'travel' );
  4962. $train = $this->get_args ( 'train' );
  4963. $other = $this->get_args ( 'other' );
  4964. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  4965. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  4966. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  4967. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  4968. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  4969. Doo::loadModel ( 'receipt' );
  4970. Doo::loadModel ( 'receiptDetail' );
  4971. Doo::loadModel ( 'accountItem' );
  4972. $accountItem = new accountItem ();
  4973. $receipt = new receipt ();
  4974. Doo::loadModel ( 'enclosur' );
  4975. Doo::loadModel ( 'execute' );
  4976. $execute = new execute ();
  4977. $executeDetail = $execute->getOne ( array (
  4978. 'where' => 'mold="报销单执行人"',
  4979. 'asArray' => true
  4980. ) );
  4981. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  4982. // if(!empty($receiptDetail))
  4983. // return "/referReceipt/".$receiptDetail['rid'];
  4984. $aItem = $accountItem->find ( array (
  4985. 'asArray' => true
  4986. ) );
  4987. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  4988. $ag = $tr = $ta = $ot = 0;
  4989. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  4990. foreach ( $aItem as $key => $value ) {
  4991. if ($value ['category'] == $this->AGENCY) {
  4992. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  4993. array_push ( $accountJson [$this->AGENCY], array (
  4994. 'aid' => $value ['aid'],
  4995. 'name' => $value ['name'],
  4996. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  4997. ) );
  4998. $sum += $agency [$ag];
  4999. $agencySum += $agency [$ag];
  5000. }
  5001. $ag ++;
  5002. }
  5003. if ($value ['category'] == $this->TRAVEL) {
  5004. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5005. array_push ( $accountJson [$this->TRAVEL], array (
  5006. 'aid' => $value ['aid'],
  5007. 'name' => $value ['name'],
  5008. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5009. ) );
  5010. $sum += $travel [$tr];
  5011. $travelSum += $travel [$tr];
  5012. }
  5013. $tr ++;
  5014. }
  5015. if ($value ['category'] == $this->TRAIN) {
  5016. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5017. array_push ( $accountJson [$this->TRAIN], array (
  5018. 'aid' => $value ['aid'],
  5019. 'name' => $value ['name'],
  5020. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5021. ) );
  5022. $sum += $train [$ta];
  5023. $trainSum += $train [$ta];
  5024. }
  5025. $ta ++;
  5026. }
  5027. if ($value ['category'] == $this->OTHER) {
  5028. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5029. array_push ( $accountJson [$this->OTHER], array (
  5030. 'aid' => $value ['aid'],
  5031. 'name' => $value ['name'],
  5032. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5033. ) );
  5034. $sum += $other [$ot];
  5035. $otherSum += $other [$ot];
  5036. }
  5037. $ot ++;
  5038. }
  5039. }
  5040. $accountJson ['cSum'] = array (
  5041. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5042. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5043. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5044. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5045. );
  5046. // 报销单
  5047. $receipt->accountItem = json_encode ( $accountJson );
  5048. $receipt->staff = $this->staff [0] ['sid'];
  5049. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5050. $receipt->date = date ( "Y-m-d" );
  5051. $receipt->cid = $cid;
  5052. $receipt->status = 5;
  5053. // 修改审批流程加入角色
  5054. $receipt->verify = $verify;
  5055. $receipt->executeCopy = $executeDetail ['staff'];
  5056. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  5057. $receipt->explanation = $explanation;
  5058. $rid = $receipt->insert ();
  5059. // 附件
  5060. if (! empty ( $enclosurName )) {
  5061. $enclosurArray = explode ( '-', $enclosurName );
  5062. foreach ( $enclosurArray as $value ) {
  5063. $enclosur = new enclosur ();
  5064. $enclosur->name = $value;
  5065. $enclosur->rid = $rid;
  5066. $enclosur->insert ();
  5067. }
  5068. // print_r($enclosurArray);die;
  5069. }
  5070. // 报销详情
  5071. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5072. $receiptDetail = new receiptDetail ();
  5073. $receiptDetail->staff = $this->staff [0] ['sid'];
  5074. $receiptDetail->item = $value ['name'];
  5075. $receiptDetail->itemCategory = $this->AGENCY;
  5076. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5077. $receiptDetail->date = date ( "Y-m-d" );
  5078. $receiptDetail->cid = $cid;
  5079. $receiptDetail->rid = $rid;
  5080. $receiptDetail->status = 4;
  5081. $receiptDetail->insert ();
  5082. }
  5083. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5084. $receiptDetail = new receiptDetail ();
  5085. $receiptDetail->staff = $this->staff [0] ['sid'];
  5086. $receiptDetail->item = $value ['name'];
  5087. $receiptDetail->itemCategory = $this->TRAVEL;
  5088. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5089. $receiptDetail->date = date ( "Y-m-d" );
  5090. $receiptDetail->cid = $cid;
  5091. $receiptDetail->rid = $rid;
  5092. $receiptDetail->status = 4;
  5093. $receiptDetail->insert ();
  5094. }
  5095. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5096. $receiptDetail = new receiptDetail ();
  5097. $receiptDetail->staff = $this->staff [0] ['sid'];
  5098. $receiptDetail->item = $value ['name'];
  5099. $receiptDetail->itemCategory = $this->TRAIN;
  5100. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5101. $receiptDetail->date = date ( "Y-m-d" );
  5102. $receiptDetail->cid = $cid;
  5103. $receiptDetail->rid = $rid;
  5104. $receiptDetail->status = 4;
  5105. $receiptDetail->insert ();
  5106. }
  5107. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5108. $receiptDetail = new receiptDetail ();
  5109. $receiptDetail->staff = $this->staff [0] ['sid'];
  5110. $receiptDetail->item = $value ['name'];
  5111. $receiptDetail->itemCategory = $this->OTHER;
  5112. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5113. $receiptDetail->date = date ( "Y-m-d" );
  5114. $receiptDetail->cid = $cid;
  5115. $receiptDetail->rid = $rid;
  5116. $receiptDetail->status = 4;
  5117. $receiptDetail->insert ();
  5118. }
  5119. return "/saeaBorad";
  5120. } else
  5121. die ( 'illegal request' );
  5122. }
  5123. function referReceipt() {
  5124. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  5125. Doo::loadModel ( 'receipt' );
  5126. Doo::loadModel ( 'verify' );
  5127. $verify = new verify ();
  5128. $receipt = new receipt ();
  5129. Doo::loadModel ( 'L_category' );
  5130. $lCategory = new L_category ();
  5131. Doo::loadModel ( "role" );
  5132. $role = new role ();
  5133. $receiptDetail = $receipt->find ( array (
  5134. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  5135. 'asArray' => true
  5136. ) );
  5137. if (empty ( $receiptDetail ))
  5138. return "/addReceipt";
  5139. foreach ( $receiptDetail as $key => $value ) {
  5140. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5141. $veList = $verify->getOne ( array (
  5142. 'where' => 'vid=' . $value ['verify'],
  5143. 'asArray' => true
  5144. ) );
  5145. $v = json_decode ( $veList ['staff'] );
  5146. array_push ( $v [0], $veList ['description'] );
  5147. foreach ( $v as $n => $m ) {
  5148. if ($m ['1'] == 'ROLE') {
  5149. $roleInfo = $role->getOne ( array (
  5150. 'where' => 'rid=' . $m [0],
  5151. 'asArray' => true
  5152. ) );
  5153. $v [$n] [1] = $roleInfo ['name'];
  5154. }
  5155. }
  5156. $receiptDetail [$key] ['staff'] = $v;
  5157. $category = $lCategory->getOne ( array (
  5158. 'where' => 'cid=' . $value ['cid'],
  5159. 'asArray' => true
  5160. ) );
  5161. $receiptDetail [$key] ['category'] = $category ['title'];
  5162. }
  5163. // print_r($receiptDetail);
  5164. $data ['receiptDetail'] = $receiptDetail;
  5165. $data ['memu'] = "receipt";
  5166. $data ['staff'] = $this->staff;
  5167. $data ['receiptMemu'] = 'saeaCreate';
  5168. $data ['verifyId'] = $this->verifyId;
  5169. $data ['executeId'] = $this->executeId;
  5170. $this->render ( "/admin/saea_confirm", $data );
  5171. }
  5172. function editReceipt() {
  5173. // edit status 4
  5174. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5175. // echo $rid;
  5176. Doo::loadModel ( 'accountItem' );
  5177. Doo::loadModel ( 'verify' );
  5178. Doo::loadModel ( 'receipt' );
  5179. $receipt = new receipt ();
  5180. $verify = new verify ();
  5181. $accountItem = new accountItem ();
  5182. Doo::loadModel ( 'L_category' );
  5183. $lCategory = new L_category ();
  5184. Doo::loadModel ( "role" );
  5185. $role = new role ();
  5186. $receiptDetail = $receipt->getOne ( array (
  5187. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  5188. 'asArray' => true
  5189. ) );
  5190. if (empty ( $receiptDetail ))
  5191. return "/saeaCreate";
  5192. $acItem = $accountItem->find ( array (
  5193. 'asArray' => true
  5194. ) );
  5195. $veList = $verify->find ( array (
  5196. 'asArray' => true
  5197. ) );
  5198. foreach ( $veList as $key => $value ) {
  5199. $v = json_decode ( $value ['staff'] );
  5200. $list = array ();
  5201. foreach ( $v as $n => $m ) {
  5202. if ($m ['1'] == 'ROLE') {
  5203. $roleInfo = $role->getOne ( array (
  5204. 'where' => 'rid=' . $m [0],
  5205. 'asArray' => true
  5206. ) );
  5207. $v [$n] [1] = $roleInfo ['name'];
  5208. array_push ( $list, $roleInfo ['name'] );
  5209. } else {
  5210. array_push ( $list, $v [$n] [1] );
  5211. }
  5212. }
  5213. $veList [$key] ['staff'] = implode ( '>', $list );
  5214. }
  5215. // 配置编辑信息
  5216. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  5217. foreach ( $acItem as $key => $value ) {
  5218. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  5219. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  5220. $acItem [$key] ['price'] = $v ['price'];
  5221. }
  5222. }
  5223. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  5224. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  5225. $acItem [$key] ['price'] = $v ['price'];
  5226. }
  5227. }
  5228. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  5229. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  5230. $acItem [$key] ['price'] = $v ['price'];
  5231. }
  5232. }
  5233. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  5234. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  5235. $acItem [$key] ['price'] = $v ['price'];
  5236. }
  5237. }
  5238. }
  5239. $data ['category'] = $lCategory->find ( array (
  5240. 'asArray' => true
  5241. ) );
  5242. $data ['cSum'] = $accountItemList ['cSum'];
  5243. $data ['sum'] = $receiptDetail ['sum'];
  5244. $data ['receiptDetail'] = $receiptDetail;
  5245. $data ['veList'] = $veList;
  5246. $data ['acItem'] = $acItem;
  5247. $data ['memu'] = "receipt";
  5248. $data ['staff'] = $this->staff;
  5249. $data ['receiptMemu'] = 'saeaBorad';
  5250. $data ['verify'] = $receiptDetail ['verify'];
  5251. $data ['verifyId'] = $this->verifyId;
  5252. $data ['executeId'] = $this->executeId;
  5253. $data ['rid'] = $rid;
  5254. $this->render ( "/admin/saea_edit", $data );
  5255. }
  5256. function updateReceipt() {
  5257. $agency = $this->get_args ( 'agency' );
  5258. $travel = $this->get_args ( 'travel' );
  5259. $train = $this->get_args ( 'train' );
  5260. $other = $this->get_args ( 'other' );
  5261. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5262. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5263. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5264. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5265. if (! empty ( $explanation )) {
  5266. Doo::loadModel ( 'receipt' );
  5267. Doo::loadModel ( 'receiptDetail' );
  5268. Doo::loadModel ( 'accountItem' );
  5269. $accountItem = new accountItem ();
  5270. $receipt = new receipt ();
  5271. Doo::loadModel ( 'execute' );
  5272. $execute = new execute ();
  5273. $receiptDetail = $receipt->getOne ( array (
  5274. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  5275. 'asArray' => true
  5276. ) );
  5277. if (empty ( $receiptDetail ))
  5278. return "/saeaBorad";
  5279. if ($receiptDetail ['Rtype'] == 1)
  5280. $executeDetail = $execute->getOne ( array (
  5281. 'where' => 'mold="借款费用执行人"',
  5282. 'asArray' => true
  5283. ) );
  5284. else
  5285. $executeDetail = $execute->getOne ( array (
  5286. 'where' => 'mold="报销单执行人"',
  5287. 'asArray' => true
  5288. ) );
  5289. $aItem = $accountItem->find ( array (
  5290. 'asArray' => true
  5291. ) );
  5292. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5293. $ag = $tr = $ta = $ot = 0;
  5294. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5295. foreach ( $aItem as $key => $value ) {
  5296. if ($value ['category'] == $this->AGENCY) {
  5297. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5298. array_push ( $accountJson [$this->AGENCY], array (
  5299. 'aid' => $value ['aid'],
  5300. 'name' => $value ['name'],
  5301. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5302. ) );
  5303. $sum += $agency [$ag];
  5304. $agencySum += $agency [$ag];
  5305. }
  5306. $ag ++;
  5307. }
  5308. if ($value ['category'] == $this->TRAVEL) {
  5309. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5310. array_push ( $accountJson [$this->TRAVEL], array (
  5311. 'aid' => $value ['aid'],
  5312. 'name' => $value ['name'],
  5313. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5314. ) );
  5315. $sum += $travel [$tr];
  5316. $travelSum += $travel [$tr];
  5317. }
  5318. $tr ++;
  5319. }
  5320. if ($value ['category'] == $this->TRAIN) {
  5321. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5322. array_push ( $accountJson [$this->TRAIN], array (
  5323. 'aid' => $value ['aid'],
  5324. 'name' => $value ['name'],
  5325. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5326. ) );
  5327. $sum += $train [$ta];
  5328. $trainSum += $train [$ta];
  5329. }
  5330. $ta ++;
  5331. }
  5332. if ($value ['category'] == $this->OTHER) {
  5333. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5334. array_push ( $accountJson [$this->OTHER], array (
  5335. 'aid' => $value ['aid'],
  5336. 'name' => $value ['name'],
  5337. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5338. ) );
  5339. $sum += $other [$ot];
  5340. $otherSum += $other [$ot];
  5341. }
  5342. $ot ++;
  5343. }
  5344. }
  5345. $accountJson ['cSum'] = array (
  5346. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5347. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5348. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5349. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5350. );
  5351. // 报销单
  5352. $rid = $receipt->rid = $receiptDetail ['rid'];
  5353. $receipt->accountItem = json_encode ( $accountJson );
  5354. $receipt->staff = $this->staff [0] ['sid'];
  5355. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5356. $receipt->date = date ( "Y-m-d" );
  5357. $receipt->cid = $cid;
  5358. if (($receiptDetail ['status'] != 4)) {
  5359. if ($receiptDetail ['Rtype'] == 1)
  5360. $receipt->status = 7;
  5361. else
  5362. $receipt->status = 5;
  5363. }
  5364. if ($receiptDetail != 4 && ! empty ( $verify ))
  5365. $receipt->verify = $verify;
  5366. $receipt->executeCopy = $executeDetail ['staff'];
  5367. $receipt->explanation = $explanation;
  5368. $receipt->update ();
  5369. $receiptDetail = new receiptDetail ();
  5370. $receiptDetail->delete ( array (
  5371. 'where' => 'rid=' . $rid
  5372. ) );
  5373. // 报销详情
  5374. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5375. $receiptDetail = new receiptDetail ();
  5376. $receiptDetail->staff = $this->staff [0] ['sid'];
  5377. $receiptDetail->item = $value ['name'];
  5378. $receiptDetail->itemCategory = $this->AGENCY;
  5379. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5380. $receiptDetail->date = date ( "Y-m-d" );
  5381. $receiptDetail->cid = $cid;
  5382. $receiptDetail->rid = $rid;
  5383. $receiptDetail->status = 4;
  5384. $receiptDetail->insert ();
  5385. }
  5386. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5387. $receiptDetail = new receiptDetail ();
  5388. $receiptDetail->staff = $this->staff [0] ['sid'];
  5389. $receiptDetail->item = $value ['name'];
  5390. $receiptDetail->itemCategory = $this->TRAVEL;
  5391. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5392. $receiptDetail->date = date ( "Y-m-d" );
  5393. $receiptDetail->cid = $cid;
  5394. $receiptDetail->rid = $rid;
  5395. $receiptDetail->status = 4;
  5396. $receiptDetail->insert ();
  5397. }
  5398. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5399. $receiptDetail = new receiptDetail ();
  5400. $receiptDetail->staff = $this->staff [0] ['sid'];
  5401. $receiptDetail->item = $value ['name'];
  5402. $receiptDetail->itemCategory = $this->TRAIN;
  5403. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5404. $receiptDetail->date = date ( "Y-m-d" );
  5405. $receiptDetail->cid = $cid;
  5406. $receiptDetail->rid = $rid;
  5407. $receiptDetail->status = 4;
  5408. $receiptDetail->insert ();
  5409. }
  5410. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5411. $receiptDetail = new receiptDetail ();
  5412. $receiptDetail->staff = $this->staff [0] ['sid'];
  5413. $receiptDetail->item = $value ['name'];
  5414. $receiptDetail->itemCategory = $this->OTHER;
  5415. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5416. $receiptDetail->date = date ( "Y-m-d" );
  5417. $receiptDetail->cid = $cid;
  5418. $receiptDetail->rid = $rid;
  5419. $receiptDetail->status = 4;
  5420. $receiptDetail->insert ();
  5421. }
  5422. // return "/referReceipt/".$rid;
  5423. }
  5424. return "/saeaBorad";
  5425. }
  5426. function approvedReceipt() {
  5427. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5428. Doo::loadModel ( 'receipt' );
  5429. Doo::loadModel ( 'receiptDetail' );
  5430. $receipt = new receipt ();
  5431. $receiptDetail = new receiptDetail ();
  5432. Doo::loadModel ( 'statistics' );
  5433. Doo::loadModel ( 'itemStatistics' );
  5434. $statistics = new statistics ();
  5435. $itemStatistics = new itemStatistics ();
  5436. Doo::loadModel ( "verify" );
  5437. $verify = new verify ();
  5438. // 审批状态的判定
  5439. $receiptDetailList = $receipt->getOne ( array (
  5440. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  5441. 'asArray' => true
  5442. ) );
  5443. if (empty ( $receiptDetailList ))
  5444. return "/saeaBorad";
  5445. $verifyDetail = $verify->getOne ( array (
  5446. 'where' => ' vid =' . $receiptDetailList ['verify'],
  5447. 'asArray' => true
  5448. ) );
  5449. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5450. if (empty ( $receiptDetailList ['nowStaff'] )) {
  5451. $nowStaff = "";
  5452. $nowStaffList = array ();
  5453. if ($verifyDetail [0] [1] == 'ROLE') {
  5454. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5455. foreach ( $vStaffString as $key => $value ) {
  5456. $staffK = explode ( "_", $value );
  5457. array_push ( $nowStaffList, $staffK [0] );
  5458. }
  5459. $nowStaff = implode ( ',', $nowStaffList );
  5460. } else {
  5461. $nowStaff = $verifyDetail [0] [0];
  5462. }
  5463. $receipt->nowStaff = $nowStaff;
  5464. }
  5465. // echo $nowStaff;
  5466. // print_r($verifyDetail);die;
  5467. $receipt->rid = $receiptDetailList ['rid'];
  5468. $receipt->date = date ( "Y-m-d" );
  5469. $receipt->status = 2;
  5470. $receipt->update ();
  5471. $receiptDetail->status = 2;
  5472. $receiptDetail->update ( array (
  5473. 'where' => 'rid=' . $receiptDetailList ['rid']
  5474. ) );
  5475. Doo::loadModel ( "receiptLog" );
  5476. $receiptLog = new receiptLog ();
  5477. Doo::loadModel ( "verify" );
  5478. $verify = new verify ();
  5479. $receiptInfo = $receipt->getOne ( array (
  5480. 'where' => 'rid=' . $rid,
  5481. 'asArray' => true
  5482. ) );
  5483. $vr = $verify->getOne ( array (
  5484. 'where' => 'vid=' . $receiptInfo ['verify'],
  5485. 'asArray' => true
  5486. ) );
  5487. $jd = json_decode ( $vr ['staff'] );
  5488. $roleId = 0;
  5489. foreach ( $jd as $key => $value ) {
  5490. if ($value [1] == 'ROLE') {
  5491. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  5492. if ($pos !== false) {
  5493. $roleId = $value [0];
  5494. }
  5495. }
  5496. }
  5497. // 审批日志
  5498. // echo $roleId;die;
  5499. if (! empty ( $roleId )) {
  5500. Doo::loadModel ( "role" );
  5501. $role = new role ();
  5502. $roleInfo = $role->getOne ( array (
  5503. 'where' => 'rid=' . $roleId,
  5504. 'asArray' => true
  5505. ) );
  5506. $receiptLog->rolename = $roleInfo ['name'];
  5507. }
  5508. $receiptLog->username = $this->staff [0] ['username'];
  5509. $receiptLog->uid = $this->staff [0] ['sid'];
  5510. $receiptLog->date = date ( "Y-m-d" );
  5511. $receiptLog->opinion = '提交审批';
  5512. $receiptLog->img = $this->staff [0] ['avatar'];
  5513. $receiptLog->status = 2;
  5514. $receiptLog->rid = $rid;
  5515. $receiptLog->insert ();
  5516. // statistics item
  5517. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  5518. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  5519. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  5520. $stat = $statistics->getOne ( array (
  5521. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5522. 'asArray' => true
  5523. ) );
  5524. if (empty ( $stat )) {
  5525. $statistics->date = date ( "Y-m-d" );
  5526. $statistics->cid = $this->staff [0] ['cid'];
  5527. $statistics->staff = $this->staff [0] ['sid'];
  5528. $statistics->agPrice = 0;
  5529. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5530. $statistics->insert ();
  5531. } else {
  5532. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5533. $statistics->update ( array (
  5534. 'where' => 'sid=' . $stat ['sid']
  5535. ) );
  5536. }
  5537. return "/expenses";
  5538. }
  5539. function approval() {
  5540. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5541. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5542. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5543. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5544. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5545. if (empty ( $status ))
  5546. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5547. $vidList = array ();
  5548. $button = 0;
  5549. Doo::loadModel ( 'verify' );
  5550. $verify = new verify ();
  5551. Doo::loadModel ( 'receipt' );
  5552. $receipt = new receipt ();
  5553. Doo::loadModel ( 'staff' );
  5554. $staff = new staff ();
  5555. Doo::loadModel ( 'L_category' );
  5556. $Lcategory = new L_category ();
  5557. // user verify ID
  5558. $verifyDetail = $verify->find ( array (
  5559. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5560. 'asArray' => true
  5561. ) );
  5562. foreach ( $verifyDetail as $key => $value ) {
  5563. array_push ( $vidList, $value ['vid'] );
  5564. }
  5565. $vid = implode ( ",", $vidList );
  5566. if (empty ( $verifyDetail ))
  5567. $vid = 0;
  5568. /*
  5569. */
  5570. $dateCondition = " and Year(date) =" . $year;
  5571. if (! empty ( $month ))
  5572. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  5573. $categoryList = $Lcategory->find ( array (
  5574. 'asArray' => true
  5575. ) );
  5576. $staffList = $staff->find ( array (
  5577. 'where' => 'cid=' . $cid,
  5578. 'asArray' => true
  5579. ) );
  5580. $cateCondition = "";
  5581. $staffCondition = "";
  5582. $approvalCondition = "";
  5583. if (! empty ( $cid ))
  5584. $cateCondition = ' and cid=' . $cid;
  5585. if (! empty ( $sid )) {
  5586. $staffCondition = ' and staff=' . $sid;
  5587. $cateCondition = "";
  5588. }
  5589. // elseif($status==1){
  5590. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  5591. // }
  5592. if ($status == 2) {
  5593. // 查找角色审批人
  5594. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  5595. }
  5596. $ap = "";
  5597. if ($status == 4) {
  5598. $ap = 4;
  5599. $status = 2;
  5600. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  5601. }
  5602. if ($status == 5) {
  5603. $status = 4;
  5604. $ap = 5;
  5605. }
  5606. // echo $vid;
  5607. // get Receipt By verifyID status 2 .$approvalCondition
  5608. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  5609. $receiptList = $receipt->find ( array (
  5610. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  5611. 'desc' => 'rid',
  5612. 'asArray' => true
  5613. ) );
  5614. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  5615. $Locate = 0;
  5616. if ($ap == 4)
  5617. $status = 4;
  5618. elseif ($ap == 5)
  5619. $status = 5;
  5620. foreach ( $receiptList as $key => $value ) {
  5621. $receiptList [$key] ['Locate'] = $Locate;
  5622. $Locate ++;
  5623. $receiptList [$key] ['reviseDetail'] = array ();
  5624. if (! empty ( $value ['reviseDetail'] ))
  5625. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5626. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5627. $categoryDetil = $Lcategory->getOne ( array (
  5628. 'where' => 'cid=' . $value ['cid'],
  5629. 'asArray' => true
  5630. ) );
  5631. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5632. $verifyList = $verify->getOne ( array (
  5633. 'where' => 'vid=' . $value ['verify'],
  5634. 'asArray' => true
  5635. ) );
  5636. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5637. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5638. foreach ( $verifyList as $k => $v ) {
  5639. // init verifyStaff
  5640. $verifyList [$k] ['date'] = "";
  5641. $verifyList [$k] ['opinion'] = "";
  5642. $verifyList [$k] ['status'] = "";
  5643. if (empty ( $verifyStaff )) {
  5644. $verifyList [$k] ['date'] = "";
  5645. $verifyList [$k] ['opinion'] = "";
  5646. if ($v [0] == $this->staff [0] ['sid']) {
  5647. $verifyList [$k] ['status'] = 4;
  5648. $button = 4;
  5649. }
  5650. } else {
  5651. $flag = true;
  5652. foreach ( $verifyStaff as $m => $u ) {
  5653. if ($v [0] == $m) {
  5654. $verifyList [$k] ['date'] = $u ['date'];
  5655. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5656. $verifyList [$k] ['status'] = $u ['status'];
  5657. $flag = false;
  5658. break;
  5659. }
  5660. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  5661. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  5662. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  5663. }
  5664. if ($flag) { // 检测可编辑
  5665. if ($v [0] == $this->staff [0] ['sid']) {
  5666. $verifyList [$k] ['status'] = 4;
  5667. $button = 4;
  5668. }
  5669. }
  5670. }
  5671. }
  5672. $receiptList [$key] ['verifyList'] = $verifyList;
  5673. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5674. 'where' => 'sid=' . $value ['staff'],
  5675. 'asArray' => true
  5676. ) );
  5677. $receiptList [$key] ['button'] = $button;
  5678. }
  5679. // print_r($receiptList);die;
  5680. // $data['verifyDetail']=$verifyDetail;
  5681. $mothHtml = "";
  5682. for($i = 1; $i <= 12; $i ++) {
  5683. if ($month == $i)
  5684. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5685. else
  5686. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5687. }
  5688. $data ['mothHtml'] = $mothHtml;
  5689. $data ['receiptList'] = $receiptList;
  5690. $data ['receiptApprovalCount'] = count ( $receiptList );
  5691. $data ['status'] = $status;
  5692. $data ['year'] = $year;
  5693. $data ['categoryList'] = $categoryList;
  5694. $data ['staffList'] = $staffList;
  5695. $data ['cid'] = $cid;
  5696. $data ['sid'] = $sid;
  5697. $data ['ap'] = $ap;
  5698. $data ['memu'] = "receipt";
  5699. $data ['staff'] = $this->staff;
  5700. $data ['receiptMemu'] = 'approval';
  5701. $data ['verifyId'] = $this->verifyId;
  5702. $data ['executeId'] = $this->executeId;
  5703. $this->render ( "/admin/saea_reportList", $data );
  5704. }
  5705. function approvalDetails() {
  5706. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5707. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5708. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5709. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5710. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5711. Doo::loadModel ( 'verify' );
  5712. $verify = new verify ();
  5713. Doo::loadModel ( 'receipt' );
  5714. $receipt = new receipt ();
  5715. Doo::loadModel ( 'staff' );
  5716. $staff = new staff ();
  5717. Doo::loadModel ( 'L_category' );
  5718. $Lcategory = new L_category ();
  5719. Doo::loadModel ( 'enclosur' );
  5720. $enclosur = new enclosur ();
  5721. $vidList = array ();
  5722. $verifyDetail = $verify->find ( array (
  5723. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5724. 'asArray' => true
  5725. ) );
  5726. foreach ( $verifyDetail as $key => $value ) {
  5727. array_push ( $vidList, $value ['vid'] );
  5728. }
  5729. $vid = implode ( ",", $vidList );
  5730. if (empty ( $verifyDetail ))
  5731. $vid = 0;
  5732. $categoryList = $Lcategory->find ( array (
  5733. 'asArray' => true
  5734. ) );
  5735. $staffList = $staff->find ( array (
  5736. 'where' => 'cid=' . $cid,
  5737. 'asArray' => true
  5738. ) );
  5739. $ap = 0;
  5740. $receiptList = $receipt->find ( array (
  5741. 'where' => 'rid =' . $rid,
  5742. 'desc' => 'rid',
  5743. 'asArray' => true
  5744. ) );
  5745. $Locate = 0;
  5746. $roleId = 0;
  5747. $button = 0;
  5748. foreach ( $receiptList as $key => $value ) {
  5749. $receiptList [$key] ['Locate'] = $Locate;
  5750. $Locate ++;
  5751. $receiptList [$key] ['reviseDetail'] = array ();
  5752. if (! empty ( $value ['reviseDetail'] ))
  5753. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5754. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5755. $categoryDetil = $Lcategory->getOne ( array (
  5756. 'where' => 'cid=' . $value ['cid'],
  5757. 'asArray' => true
  5758. ) );
  5759. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5760. // 检测编辑状态
  5761. $verifyList = $verify->getOne ( array (
  5762. 'where' => 'vid=' . $value ['verify'],
  5763. 'asArray' => true
  5764. ) );
  5765. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5766. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5767. Doo::loadModel ( 'role' );
  5768. $role = new role ();
  5769. // print_r($verifyList);
  5770. $flag = true;
  5771. $roleKey = 0;
  5772. $endStaffArray = array ();
  5773. $roleArrayCopy = array ();
  5774. foreach ( $verifyList as $k => $v ) {
  5775. // init verifyStaff
  5776. if ($v [1] == 'ROLE') {
  5777. if (! empty ( $verifyStaff )) {
  5778. $endStaffArray = end ( $verifyStaff );
  5779. if ($v [0] == $endStaffArray ['nextStaff']) {
  5780. $roleId = $v [0];
  5781. }
  5782. }
  5783. $roleVerify = json_decode ( $v [3], true );
  5784. $roleKey = $k;
  5785. $roleArray = array ();
  5786. $rolename = $role->getOne ( array (
  5787. 'where' => 'rid=' . $v [0],
  5788. 'asArray' => true
  5789. ) );
  5790. foreach ( $roleVerify as $o => $p ) {
  5791. $staffID = explode ( '_', $p );
  5792. $staffInfo = $staff->getOne ( array (
  5793. 'where' => 'sid=' . $staffID [0],
  5794. 'asArray' => true
  5795. ) );
  5796. // print_r($staffID);
  5797. $exp = array (
  5798. 0 => $staffInfo ['sid'],
  5799. 1 => $staffID [1],
  5800. 2 => $staffInfo ['avatar'],
  5801. 'date' => '',
  5802. 'date' => '',
  5803. 'opinion' => '',
  5804. 'status' => '',
  5805. 'rolename' => $rolename ['name']
  5806. );
  5807. array_push ( $roleArray, $exp );
  5808. }
  5809. $roleArrayCopy [$v [0]] = $roleArray;
  5810. // $verifyList[$k]['roleArray']=$roleArray;
  5811. }
  5812. // print_r($roleArray);
  5813. $verifyList [$k] ['date'] = "";
  5814. $verifyList [$k] ['opinion'] = "";
  5815. $verifyList [$k] ['status'] = "";
  5816. if (empty ( $verifyStaff )) {
  5817. $verifyList [$k] ['date'] = "";
  5818. $verifyList [$k] ['opinion'] = "";
  5819. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5820. $verifyList [$k] ['status'] = 4;
  5821. $button = 4;
  5822. $flag = false;
  5823. }
  5824. } else {
  5825. foreach ( $verifyStaff as $m => $u ) {
  5826. if ($v [0] == $m) {
  5827. $verifyList [$k] ['date'] = $u ['date'];
  5828. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5829. $verifyList [$k] ['status'] = $u ['status'];
  5830. $flag = false;
  5831. break;
  5832. }
  5833. }
  5834. $endStaffArray = end ( $verifyStaff );
  5835. if (isset ( $endStaffArray ['ROLE'] )) {
  5836. } else {
  5837. $endKey = key ( $verifyStaff );
  5838. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5839. $button = 4;
  5840. $verifyList [$k] ['status'] = 4;
  5841. }
  5842. }
  5843. }
  5844. }
  5845. $rolename ['name'] = '';
  5846. if (! empty ( $roleId )) {
  5847. Doo::loadModel ( 'role' );
  5848. $role = new role ();
  5849. $rolename = $role->getOne ( array (
  5850. 'where' => 'rid=' . $roleId,
  5851. 'asArray' => true
  5852. ) );
  5853. }
  5854. if (! empty ( $verifyStaff ))
  5855. $endStaffArray = end ( $verifyStaff );
  5856. $KOP = false;
  5857. foreach ( $roleArrayCopy as $P => $A ) {
  5858. foreach ( $A as $MKI => $AVL ) {
  5859. if (! empty ( $verifyStaff )) {
  5860. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5861. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5862. $button = 4;
  5863. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5864. }
  5865. foreach ( $verifyStaff as $m => $u ) {
  5866. $AVLFK = $AVL [0] . '_R';
  5867. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5868. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5869. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5870. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5871. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5872. break;
  5873. }
  5874. }
  5875. } else {
  5876. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5877. $button = 4;
  5878. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5879. }
  5880. }
  5881. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5882. $KOP = true;
  5883. }
  5884. }
  5885. foreach ( $roleArrayCopy as $k => $v ) {
  5886. foreach ( $verifyList as $m => $n ) {
  5887. if ($n [0] == $k) {
  5888. array_splice ( $verifyList, $m, 1, $v );
  5889. }
  5890. }
  5891. }
  5892. $receiptList [$key] ['verifyList'] = $verifyList;
  5893. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5894. 'where' => 'sid=' . $value ['staff'],
  5895. 'asArray' => true
  5896. ) );
  5897. $receiptList [$key] ['button'] = $button;
  5898. }
  5899. $mothHtml = "";
  5900. for($i = 1; $i <= 12; $i ++) {
  5901. if ($month == $i)
  5902. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5903. else
  5904. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5905. }
  5906. // 获取审批日志
  5907. Doo::loadModel ( 'receiptLog' );
  5908. $receiptLog = new receiptLog ();
  5909. $rlList = array ();
  5910. $rlInfo = $receiptLog->getOne ( array (
  5911. 'where' => 'rid=' . $rid . ' and status=4',
  5912. 'asArray' => true
  5913. ) );
  5914. $tijdate = $receiptLog->getOne ( array (
  5915. 'where' => 'rid=' . $rid . ' and status=2',
  5916. 'asc' => 'rlid',
  5917. 'asArray' => true
  5918. ) );
  5919. if (! empty ( $rlInfo )) {
  5920. $rlList = $receiptLog->find ( array (
  5921. 'where' => 'rid=' . $rid,
  5922. 'asc' => 'rlid',
  5923. 'asArray' => true
  5924. ) );
  5925. }
  5926. $receiptList [0] ['rlList'] = $rlList;
  5927. $enclosurList = $enclosur->find ( array (
  5928. 'where' => 'rid=' . $rid,
  5929. 'asArray' => true
  5930. ) );
  5931. $enclosurHtml = '';
  5932. foreach ( $enclosurList as $value ) {
  5933. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5934. }
  5935. $data ['enclosurHtml'] = $enclosurHtml;
  5936. $data ['rolename'] = $rolename ['name'];
  5937. $data ['datetij'] = $tijdate ['date'];
  5938. $data ['mothHtml'] = $mothHtml;
  5939. $data ['receiptList'] = $receiptList;
  5940. $data ['receiptApprovalCount'] = count ( $receiptList );
  5941. $data ['year'] = $year;
  5942. $data ['categoryList'] = $categoryList;
  5943. $data ['staffList'] = $staffList;
  5944. $data ['cid'] = $cid;
  5945. $data ['sid'] = $sid;
  5946. $data ['status'] = 0;
  5947. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  5948. $ap = 4;
  5949. } else
  5950. $data ['status'] = $receiptList [0] ['status'];
  5951. if ($receiptList [0] ['status'] == 4) {
  5952. $data ['status'] = 5;
  5953. $ap = 0;
  5954. }
  5955. $data ['ap'] = $ap;
  5956. $data ['memu'] = "receipt";
  5957. $data ['staff'] = $this->staff;
  5958. $data ['receiptMemu'] = 'approval';
  5959. $data ['verifyId'] = $this->verifyId;
  5960. $data ['executeId'] = $this->executeId;
  5961. $this->render ( "/admin/saeaReportListReport", $data );
  5962. }
  5963. function approvalEdi() {
  5964. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5965. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5966. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5967. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5968. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5969. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5970. if (empty ( $status ))
  5971. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5972. $vidList = array ();
  5973. $button = 0;
  5974. Doo::loadModel ( 'verify' );
  5975. Doo::loadModel ( 'receipt' );
  5976. Doo::loadModel ( 'staff' );
  5977. $staff = new staff ();
  5978. $receipt = new receipt ();
  5979. $verify = new verify ();
  5980. Doo::loadModel ( 'L_category' );
  5981. $Lcategory = new L_category ();
  5982. Doo::loadModel ( 'enclosur' );
  5983. $enclosur = new enclosur ();
  5984. // user verify ID
  5985. $verifyDetail = $verify->find ( array (
  5986. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5987. 'asArray' => true
  5988. ) );
  5989. foreach ( $verifyDetail as $key => $value ) {
  5990. array_push ( $vidList, $value ['vid'] );
  5991. }
  5992. $vid = implode ( ",", $vidList );
  5993. if (empty ( $verifyDetail ))
  5994. $vid = 0;
  5995. $categoryList = $Lcategory->find ( array (
  5996. 'asArray' => true
  5997. ) );
  5998. $staffList = $staff->find ( array (
  5999. 'where' => 'cid=' . $cid,
  6000. 'asArray' => true
  6001. ) );
  6002. $ap = "";
  6003. if ($status == 4) {
  6004. $ap = 4;
  6005. $status = 2;
  6006. }
  6007. // get Receipt By verifyID status 2
  6008. $receiptList = $receipt->find ( array (
  6009. 'where' => 'rid =' . $rid,
  6010. 'desc' => 'rid',
  6011. 'asArray' => true
  6012. ) );
  6013. $Locate = 0;
  6014. $roleId = 0;
  6015. if ($ap == 4)
  6016. $status = 4;
  6017. foreach ( $receiptList as $key => $value ) {
  6018. $receiptList [$key] ['Locate'] = $Locate;
  6019. $Locate ++;
  6020. $receiptList [$key] ['reviseDetail'] = array ();
  6021. if (! empty ( $value ['reviseDetail'] ))
  6022. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6023. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6024. $categoryDetil = $Lcategory->getOne ( array (
  6025. 'where' => 'cid=' . $value ['cid'],
  6026. 'asArray' => true
  6027. ) );
  6028. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6029. // 检测编辑状态
  6030. $verifyList = $verify->getOne ( array (
  6031. 'where' => 'vid=' . $value ['verify'],
  6032. 'asArray' => true
  6033. ) );
  6034. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6035. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6036. // print_r($verifyList);
  6037. //
  6038. // if (empty($verifyStaff)){
  6039. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6040. // $verifyList[0]['status']=4;$button=4;
  6041. // }
  6042. //
  6043. // }else{
  6044. //
  6045. // }
  6046. // die;
  6047. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  6048. // echo array_search("green",$a);
  6049. //
  6050. Doo::loadModel ( 'role' );
  6051. $role = new role ();
  6052. // print_r($verifyList);
  6053. $flag = true;
  6054. $roleKey = 0;
  6055. $endStaffArray = array ();
  6056. $roleArrayCopy = array ();
  6057. foreach ( $verifyList as $k => $v ) {
  6058. // init verifyStaff
  6059. if ($v [1] == 'ROLE') {
  6060. if (! empty ( $verifyStaff )) {
  6061. $endStaffArray = end ( $verifyStaff );
  6062. if ($v [0] == $endStaffArray ['nextStaff']) {
  6063. $roleId = $v [0];
  6064. }
  6065. }
  6066. $roleVerify = json_decode ( $v [3], true );
  6067. $roleKey = $k;
  6068. $roleArray = array ();
  6069. $rolename = $role->getOne ( array (
  6070. 'where' => 'rid=' . $v [0],
  6071. 'asArray' => true
  6072. ) );
  6073. foreach ( $roleVerify as $o => $p ) {
  6074. $staffID = explode ( '_', $p );
  6075. $staffInfo = $staff->getOne ( array (
  6076. 'where' => 'sid=' . $staffID [0],
  6077. 'asArray' => true
  6078. ) );
  6079. // print_r($staffID);
  6080. $exp = array (
  6081. 0 => $staffInfo ['sid'],
  6082. 1 => $staffID [1],
  6083. 2 => $staffInfo ['avatar'],
  6084. 'date' => '',
  6085. 'date' => '',
  6086. 'opinion' => '',
  6087. 'status' => '',
  6088. 'rolename' => $rolename ['name']
  6089. );
  6090. array_push ( $roleArray, $exp );
  6091. }
  6092. $roleArrayCopy [$v [0]] = $roleArray;
  6093. // $verifyList[$k]['roleArray']=$roleArray;
  6094. }
  6095. // print_r($roleArray);
  6096. $verifyList [$k] ['date'] = "";
  6097. $verifyList [$k] ['opinion'] = "";
  6098. $verifyList [$k] ['status'] = "";
  6099. if (empty ( $verifyStaff )) {
  6100. $verifyList [$k] ['date'] = "";
  6101. $verifyList [$k] ['opinion'] = "";
  6102. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6103. $verifyList [$k] ['status'] = 4;
  6104. $button = 4;
  6105. $flag = false;
  6106. }
  6107. } else {
  6108. foreach ( $verifyStaff as $m => $u ) {
  6109. if ($v [0] == $m) {
  6110. $verifyList [$k] ['date'] = $u ['date'];
  6111. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6112. $verifyList [$k] ['status'] = $u ['status'];
  6113. $flag = false;
  6114. break;
  6115. }
  6116. }
  6117. $endStaffArray = end ( $verifyStaff );
  6118. if (isset ( $endStaffArray ['ROLE'] )) {
  6119. } else {
  6120. $endKey = key ( $verifyStaff );
  6121. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6122. $button = 4;
  6123. $verifyList [$k] ['status'] = 4;
  6124. }
  6125. }
  6126. // print_r($endStaffArray);die;
  6127. // if (empty($verifyStaff)){
  6128. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6129. // $verifyList[$k]['status']=4;$button=4;
  6130. // }
  6131. //
  6132. // }else{
  6133. //
  6134. // }
  6135. // if($flag){//检测可编辑
  6136. // if($v[0]==$this->staff[0]['sid']){
  6137. // $verifyList[$k]['status']=4;$button=4;
  6138. // }
  6139. // }
  6140. }
  6141. }
  6142. $rolename ['name'] = '';
  6143. if (! empty ( $roleId )) {
  6144. Doo::loadModel ( 'role' );
  6145. $role = new role ();
  6146. $rolename = $role->getOne ( array (
  6147. 'where' => 'rid=' . $roleId,
  6148. 'asArray' => true
  6149. ) );
  6150. }
  6151. if (! empty ( $verifyStaff ))
  6152. $endStaffArray = end ( $verifyStaff );
  6153. $KOP = false;
  6154. foreach ( $roleArrayCopy as $P => $A ) {
  6155. foreach ( $A as $MKI => $AVL ) {
  6156. if (! empty ( $verifyStaff )) {
  6157. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6158. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6159. $button = 4;
  6160. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6161. }
  6162. foreach ( $verifyStaff as $m => $u ) {
  6163. $AVLFK = $AVL [0] . '_R';
  6164. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6165. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6166. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6167. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6168. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6169. break;
  6170. }
  6171. }
  6172. } else {
  6173. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6174. $button = 4;
  6175. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6176. }
  6177. }
  6178. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6179. $KOP = true;
  6180. }
  6181. }
  6182. // print_r($roleArrayCopy);
  6183. // echo $roleKey;
  6184. foreach ( $roleArrayCopy as $k => $v ) {
  6185. foreach ( $verifyList as $m => $n ) {
  6186. if ($n [0] == $k) {
  6187. array_splice ( $verifyList, $m, 1, $v );
  6188. }
  6189. }
  6190. }
  6191. // if ($KOP)
  6192. // array_splice($verifyList,$roleKey,1,$roleArray);
  6193. // print_r($verifyList);
  6194. $receiptList [$key] ['verifyList'] = $verifyList;
  6195. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6196. 'where' => 'sid=' . $value ['staff'],
  6197. 'asArray' => true
  6198. ) );
  6199. $receiptList [$key] ['button'] = $button;
  6200. }
  6201. // $data['verifyDetail']=$verifyDetail;
  6202. $mothHtml = "";
  6203. for($i = 1; $i <= 12; $i ++) {
  6204. if ($month == $i)
  6205. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6206. else
  6207. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6208. }
  6209. // 获取审批日志
  6210. Doo::loadModel ( 'receiptLog' );
  6211. $receiptLog = new receiptLog ();
  6212. $rlList = array ();
  6213. $rlInfo = $receiptLog->getOne ( array (
  6214. 'where' => 'rid=' . $rid . ' and status=4',
  6215. 'asArray' => true
  6216. ) );
  6217. $tijdate = $receiptLog->getOne ( array (
  6218. 'where' => 'rid=' . $rid . ' and status=2',
  6219. 'asc' => 'rlid',
  6220. 'asArray' => true
  6221. ) );
  6222. if (! empty ( $rlInfo )) {
  6223. $rlList = $receiptLog->find ( array (
  6224. 'where' => 'rid=' . $rid,
  6225. 'asc' => 'rlid',
  6226. 'asArray' => true
  6227. ) );
  6228. }
  6229. $receiptList [0] ['rlList'] = $rlList;
  6230. $enclosurList = $enclosur->find ( array (
  6231. 'where' => 'rid=' . $rid,
  6232. 'asArray' => true
  6233. ) );
  6234. $enclosurHtml = '';
  6235. foreach ( $enclosurList as $value ) {
  6236. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6237. }
  6238. $data ['enclosurHtml'] = $enclosurHtml;
  6239. $data ['rolename'] = $rolename ['name'];
  6240. $data ['datetij'] = $tijdate ['date'];
  6241. $data ['mothHtml'] = $mothHtml;
  6242. $data ['receiptList'] = $receiptList;
  6243. $data ['receiptApprovalCount'] = count ( $receiptList );
  6244. $data ['status'] = $status;
  6245. $data ['year'] = $year;
  6246. $data ['categoryList'] = $categoryList;
  6247. $data ['staffList'] = $staffList;
  6248. $data ['cid'] = $cid;
  6249. $data ['sid'] = $sid;
  6250. $data ['ap'] = $ap;
  6251. $data ['memu'] = "receipt";
  6252. $data ['staff'] = $this->staff;
  6253. $data ['receiptMemu'] = 'approval';
  6254. $data ['verifyId'] = $this->verifyId;
  6255. $data ['executeId'] = $this->executeId;
  6256. $this->render ( "/admin/saeaReportListReport", $data );
  6257. }
  6258. function remittanceHky() {
  6259. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6260. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  6261. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6262. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  6263. $page_size = 15;
  6264. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  6265. Doo::loadModel ( 'receipt' );
  6266. $receipt = new receipt ();
  6267. Doo::loadModel ( 'staff' );
  6268. $staff = new staff ();
  6269. $dateCondition = " and Year(executeDate) =" . $year;
  6270. if ($moth != 'MONTH')
  6271. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  6272. if ($day != 'DAY' && $moth != 'MONTH')
  6273. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  6274. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  6275. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  6276. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  6277. $limit = $pageinfo ['lower'] . ',' . $page_size;
  6278. $dayList = $receipt->find ( array (
  6279. 'select' => 'executeDate,sum(amount) as amount',
  6280. 'where' => $sql,
  6281. 'desc' => 'executeDate',
  6282. 'groupby' => 'executeDate',
  6283. 'limit' => $limit,
  6284. 'asArray' => true
  6285. ) );
  6286. // print_r($dayList);
  6287. foreach ( $dayList as $key => $value ) {
  6288. $remitString = "";
  6289. $receiptList = $receipt->find ( array (
  6290. 'select' => 'rid,executeDate,amount,staff,cid',
  6291. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  6292. 'desc' => 'executeDate',
  6293. 'asArray' => true
  6294. ) );
  6295. foreach ( $receiptList as $k => $v ) {
  6296. $sinfo = $staff->getOne ( array (
  6297. 'select' => 'username,category',
  6298. 'where' => ' sid=' . $v ['staff'],
  6299. 'asArray' => true
  6300. ) );
  6301. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  6302. }
  6303. $dayList [$key] ['staff'] = $remitString;
  6304. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  6305. }
  6306. // print_r($dayList);
  6307. $mothHtml = "";
  6308. for($i = 1; $i <= 12; $i ++) {
  6309. if ($moth == $i)
  6310. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6311. else
  6312. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6313. }
  6314. $dayHtml = "";
  6315. if ($day != "DAY" || $moth != "MONTH") {
  6316. for($i = 1; $i <= 31; $i ++) {
  6317. if ($day == $i)
  6318. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6319. else
  6320. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6321. }
  6322. }
  6323. $data ['page'] = $pageinfo;
  6324. $data ['year'] = $year;
  6325. $data ['moth'] = $moth;
  6326. $data ['day'] = $day;
  6327. $data ['get'] = $get;
  6328. $data ['dayHtml'] = $dayHtml;
  6329. $data ['mothHtml'] = $mothHtml;
  6330. $data ['receiptList'] = $dayList;
  6331. $data ['memu'] = "receipt";
  6332. $data ['staff'] = $this->staff;
  6333. $data ['receiptMemu'] = 'remittanceHky';
  6334. $data ['verifyId'] = $this->verifyId;
  6335. $data ['executeId'] = $this->executeId;
  6336. $this->render ( "/admin/remittanceHky", $data );
  6337. }
  6338. function remittancep() {
  6339. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  6340. Doo::loadModel ( 'receipt' );
  6341. $receipt = new receipt ();
  6342. Doo::loadModel ( 'staff' );
  6343. $staff = new staff ();
  6344. Doo::loadClass ( 'XDeode' );
  6345. $XDeode = new XDeode ( 5 );
  6346. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  6347. $rplist = $receipt->find ( array (
  6348. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6349. 'asArray' => true
  6350. ) );
  6351. $dayList = $receipt->find ( array (
  6352. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6353. 'desc' => 'executeDate',
  6354. 'groupby' => 'staff',
  6355. 'asArray' => true
  6356. ) );
  6357. $html = '';
  6358. foreach ( $dayList as $key => $value ) {
  6359. $sinfo = $staff->getOne ( array (
  6360. 'select' => 'username,category',
  6361. 'where' => ' sid=' . $value ['staff'],
  6362. 'asArray' => true
  6363. ) );
  6364. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  6365. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  6366. $au = 0;
  6367. foreach ( $rplist as $k => $v ) {
  6368. if ($value ['staff'] == $v ['staff']) {
  6369. $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>';
  6370. $au += $v ['amount'];
  6371. }
  6372. }
  6373. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  6374. }
  6375. $data ['html'] = $html;
  6376. $data ['memu'] = "receipt";
  6377. $data ['staff'] = $this->staff;
  6378. $data ['receiptMemu'] = 'remittanceHky';
  6379. $data ['verifyId'] = $this->verifyId;
  6380. $data ['executeId'] = $this->executeId;
  6381. $this->render ( "/admin/remittancep", $data );
  6382. }
  6383. function ajaxGetReceiptDetails() {
  6384. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  6385. Doo::loadClass ( 'XDeode' );
  6386. $XDeode = new XDeode ( 5 );
  6387. $rid = $XDeode->decode ( $rid );
  6388. if (empty ( $rid )) {
  6389. echo json_encode ( array (
  6390. 'status' => 2,
  6391. 'msg' => 'illegal request'
  6392. ) );
  6393. die ();
  6394. }
  6395. Doo::loadModel ( 'receipt' );
  6396. $receipt = new receipt ();
  6397. Doo::loadModel ( 'staff' );
  6398. $staff = new staff ();
  6399. $rinfo = $receipt->getOne ( array (
  6400. 'where' => 'rid= ' . $rid,
  6401. 'asArray' => true
  6402. ) );
  6403. $sinfo = $staff->getOne ( array (
  6404. 'select' => 'username,category',
  6405. 'where' => ' sid=' . $rinfo ['staff'],
  6406. 'asArray' => true
  6407. ) );
  6408. $rinfo ['reviseDetail'] = array ();
  6409. if (! empty ( $rinfo ['reviseDetail'] ))
  6410. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  6411. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  6412. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  6413. $rinfo ['category'] = $sinfo ['category'];
  6414. $verifyStaff = array ();
  6415. if (! empty ( $rinfo ['verifyStaff'] ))
  6416. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  6417. $relust = $rinfo ['sum'] - $rinfo ['loanSum'];
  6418. $rinfo ['relust'] = $relust;
  6419. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  6420. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  6421. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  6422. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  6423. // 费用执行人相关数据
  6424. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6425. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6426. foreach ( $executeCopy as $k => $v ) {
  6427. $executeCopy [$k] ['date'] = '';
  6428. $executeCopy [$k] ['opinion'] = '';
  6429. $executeCopy [$k] ['status'] = '';
  6430. if (! empty ( $executeStaff ))
  6431. foreach ( $executeStaff as $m => $u ) {
  6432. if ($v [0] == $m) {
  6433. $executeCopy [$k] ['date'] = $u ['date'];
  6434. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  6435. $executeCopy [$k] ['status'] = $u ['status'];
  6436. break;
  6437. }
  6438. }
  6439. }
  6440. $rinfo ['executeCopy'] = $executeCopy;
  6441. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  6442. if ($rinfo ['Rtype'] == 1) { // 借款费用
  6443. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6444. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  6445. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  6446. $html .= '<tr><th>' . $value ['name'] . '</th>
  6447. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6448. }
  6449. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6450. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6451. <tr><th class="taC" colspan="2">费用说明</th>
  6452. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6453. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6454. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  6455. </tbody></table>';
  6456. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  6457. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6458. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6459. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6460. $html .= '<tr><th>' . $value ['name'] . '</th>
  6461. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6462. }
  6463. $html .= '<tr><th class="taR">合计</th>
  6464. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6465. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6466. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6467. $html .= '<tr><th>' . $value ['name'] . '</th>
  6468. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6469. }
  6470. $html .= '<tr><th class="taR">合计</th>
  6471. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6472. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6473. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6474. $html .= '<tr><th>' . $value ['name'] . '</th>
  6475. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6476. }
  6477. $html .= '<tr><th class="taR">合计</th>
  6478. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6479. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6480. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6481. $html .= '<tr><th>' . $value ['name'] . '</th>
  6482. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6483. }
  6484. $html .= '<tr><th class="taR">合计</th>
  6485. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6486. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6487. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6488. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6489. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6490. }
  6491. $html .= '<tr><th class="taR">合计</th>
  6492. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6493. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6494. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6495. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6496. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6497. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6498. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6499. <tr';
  6500. if ($rinfo ['relust'] >= 0) {
  6501. $html .= 'class="success"';
  6502. } else {
  6503. $html .= 'class="error"';
  6504. }
  6505. $html .= '><td class="taR"><b>借款结余</b></td>
  6506. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  6507. </tbody></table>
  6508. ';
  6509. }
  6510. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  6511. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6512. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  6513. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6514. $html .= '<tr><th>' . $value ['name'] . '</th>
  6515. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6516. }
  6517. $html .= '<tr><th class="taR">合计</th>
  6518. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6519. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6520. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6521. <tr><th class="taC" colspan="2">费用说明</th>
  6522. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6523. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6524. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6525. </tbody></table>';
  6526. } else {
  6527. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6528. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6529. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6530. $html .= '<tr><th>' . $value ['name'] . '</th>
  6531. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6532. }
  6533. $html .= '<tr><th class="taR">合计</th>
  6534. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6535. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6536. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6537. $html .= '<tr><th>' . $value ['name'] . '</th>
  6538. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6539. }
  6540. $html .= '<tr><th class="taR">合计</th>
  6541. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6542. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6543. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6544. $html .= '<tr><th>' . $value ['name'] . '</th>
  6545. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6546. }
  6547. $html .= '<tr><th class="taR">合计</th>
  6548. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6549. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6550. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6551. $html .= '<tr><th>' . $value ['name'] . '</th>
  6552. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6553. }
  6554. $html .= '<tr><th class="taR">合计</th>
  6555. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6556. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6557. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6558. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6559. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6560. }
  6561. $html .= '<tr><th class="taR">合计</th>
  6562. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6563. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6564. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6565. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6566. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6567. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6568. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  6569. $html .= '</tbody></table>';
  6570. /*
  6571. * <table class="table table-bordered table-condensed table-hover"> <tbody> <tr><th colspan="2" class="taC">日常相关费用</th></tr> <!-- loop receiptList' value.accountItem.日常相关费用 --> <tr><th>{{receiptList' value' value.name}}</th><td width="140" class="taR">¥{{receiptList' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptList' value.accountItem.cSum.agencySum}}</td></tr> <tr><th colspan="2" class="taC">差旅相关费用</th></tr> <!-- loop receiptDetail' value.accountItem.差旅相关费用 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.travelSum}}</td></tr> <tr><th colspan="2" class="taC">培训班费用</th></tr> <!-- loop receiptDetail' value.accountItem.培训班费用 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.trainSum}}</td></tr> <tr><th colspan="2" class="taC">其他</th></tr> <!-- loop receiptDetail' value.accountItem.其他 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.otherSum}}</td></tr> <tr><th colspan="2" class="taC">报销金额调整</th></tr> <!-- loop receiptList' value.reviseDetail --> <tr><th><span class="interval">|</span>{{receiptList' value' value.name}}:{{receiptList' value' value.description}}</th><td class="taR">¥{{receiptList' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colOrange taR">¥{{receiptList' value.revisePrice}}</td></tr> <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr> <tr><th style="text-align:center" colspan="2">{{receiptDetail' value.category}}</th></tr> <tr><th class="taC" colspan="2">报销说明</th></tr> <tr><td colspan="2">{{receiptDetail' value.explanation}}</td></tr> <tr class="warning"><td class="taR"><b>({{receiptDetail' value.receiptOrder}})本次报销费用合计</b></td> <td class="colGreed taR"><b style="font-size:24px">¥{{receiptDetail' value.sum}}</b><br>{{receiptDetail' value.sumCN}}</td></tr> </tbody> </table>
  6572. */
  6573. }
  6574. // print_r($verifyStaff);die;
  6575. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  6576. foreach ( $verifyStaff as $key => $value ) {
  6577. $key = trim ( strtr ( $key, '_R', ' ' ) );
  6578. $sinfo = $staff->getOne ( array (
  6579. 'select' => 'username',
  6580. 'where' => ' sid=' . $key,
  6581. 'asArray' => true
  6582. ) );
  6583. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6584. }
  6585. $html .= '</tbody></table>';
  6586. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  6587. foreach ( $rinfo ['executeCopy'] as $value ) {
  6588. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6589. }
  6590. $html .= '</tbody></table>';
  6591. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  6592. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  6593. </tr></table>';
  6594. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  6595. echo json_encode ( array (
  6596. 'status' => 1,
  6597. 'html' => $html
  6598. ) );
  6599. die ();
  6600. }
  6601. function remittance() {
  6602. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6603. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6604. Doo::loadModel ( 'receipt' );
  6605. $receipt = new receipt ();
  6606. Doo::loadModel ( 'staff' );
  6607. $staff = new staff ();
  6608. $dateCondition = " and Year(pastDate) =" . $year;
  6609. if (! empty ( $month ))
  6610. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  6611. // get Receipt By verifyID status 1
  6612. $receiptList = $receipt->find ( array (
  6613. 'select' => 'sum(sum) as sum,staff,pastDate',
  6614. 'where' => ' status=1' . $dateCondition,
  6615. 'desc' => 'pastDate',
  6616. 'groupby' => 'staff,pastDate',
  6617. 'asArray' => true
  6618. ) );
  6619. $dateList = $receipt->find ( array (
  6620. 'select' => 'pastDate,verifyStaff',
  6621. 'where' => ' status=1' . $dateCondition,
  6622. 'desc' => 'pastDate',
  6623. 'groupby' => 'pastDate',
  6624. 'asArray' => true
  6625. ) );
  6626. $dataList = array ();
  6627. foreach ( $dateList as $d => $a ) {
  6628. $dataList [$a ['pastDate']] = array ();
  6629. $daySum = 0;
  6630. foreach ( $receiptList as $key => $value ) {
  6631. if ($a ['pastDate'] == $value ['pastDate']) {
  6632. $oderList = $receipt->find ( array (
  6633. 'select' => 'receiptOrder',
  6634. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  6635. 'asArray' => true
  6636. ) );
  6637. $list = array ();
  6638. $html = "";
  6639. foreach ( $oderList as $v ) {
  6640. array_push ( $list, $v ['receiptOrder'] );
  6641. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  6642. }
  6643. $receiptList [$key] ['receiptOrder'] = $html;
  6644. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  6645. $sinfo = $staff->getOne ( array (
  6646. 'select' => 'username ',
  6647. 'where' => ' sid=' . $value ['staff'],
  6648. 'asArray' => true
  6649. ) );
  6650. $receiptList [$key] ['username'] = $sinfo ['username'];
  6651. $daySum += $value ['sum'];
  6652. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  6653. }
  6654. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  6655. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  6656. }
  6657. }
  6658. // print_r($dataList);
  6659. $data ['dataList'] = $dataList;
  6660. $mothHtml = "";
  6661. for($i = 1; $i <= 12; $i ++) {
  6662. if ($month == $i)
  6663. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6664. else
  6665. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6666. }
  6667. $data ['year'] = $year;
  6668. $data ['mothHtml'] = $mothHtml;
  6669. $data ['memu'] = "receipt";
  6670. $data ['staff'] = $this->staff;
  6671. $data ['receiptMemu'] = 'approval';
  6672. $data ['verifyId'] = $this->verifyId;
  6673. $data ['executeId'] = $this->executeId;
  6674. $this->render ( "/admin/saeaReportListPay", $data );
  6675. }
  6676. function revocationAdjustment() {
  6677. $sid = isset ( $this->params ['sid'] ) && is_numeric ( $this->params ['sid'] ) ? $this->params ['sid'] : 0;
  6678. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  6679. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6680. // echo $price;die;
  6681. if ((! empty ( $sid )) && ($price != - 99999) && (! empty ( $rid ))) {
  6682. Doo::loadModel ( 'receipt' );
  6683. $receipt = new receipt ();
  6684. $receiptDetail = $receipt->getOne ( array (
  6685. 'where' => 'rid=' . $rid,
  6686. 'asArray' => true
  6687. ) );
  6688. if (empty ( $receiptDetail ['reviseDetail'] ))
  6689. return "/approval";
  6690. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  6691. $RD = array ();
  6692. foreach ( $reviseDetail as $key => $value ) {
  6693. if ($value ['price'] == $price && $value ['sid'] == $sid)
  6694. continue;
  6695. array_push ( $RD, $value );
  6696. }
  6697. $reviseDetailString = json_encode ( $RD );
  6698. $receipt->reviseDetail = $reviseDetailString;
  6699. $receipt->sum = $receiptDetail ['sum'] - $price;
  6700. $receipt->revisePrice = $receiptDetail ['revisePrice'] - $price;
  6701. $receipt->update ( array (
  6702. 'where' => 'rid=' . $rid
  6703. ) );
  6704. }
  6705. // approvalEdi/37
  6706. return "/approvalEdi/" . $rid;
  6707. }
  6708. function updateApprovalReceipt() {
  6709. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6710. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  6711. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6712. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  6713. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  6714. if (! empty ( $rid )) {
  6715. Doo::loadModel ( "verify" );
  6716. $verify = new verify ();
  6717. Doo::loadModel ( "receiptDetail" );
  6718. $receiptDetailObj = new receiptDetail ();
  6719. Doo::loadModel ( "itemStatistics" );
  6720. Doo::loadModel ( "statistics" );
  6721. $statistics = new statistics ();
  6722. $itemStatistics = new itemStatistics ();
  6723. Doo::loadModel ( "receipt" );
  6724. $receipt = new receipt ();
  6725. $receiptDetail = $receipt->getOne ( array (
  6726. 'where' => 'rid=' . $rid . ' and status=2 ',
  6727. 'asArray' => true
  6728. ) );
  6729. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  6730. $nsflag = true;
  6731. foreach ( $nslist as $value ) {
  6732. if ($value == $this->staff ['0'] ['sid']) {
  6733. $nsflag = false;
  6734. break;
  6735. }
  6736. }
  6737. if (empty ( $receiptDetail ) || $nsflag)
  6738. return "/approval";
  6739. $verifyDetail = $verify->getOne ( array (
  6740. 'where' => ' vid =' . $receiptDetail ['verify'],
  6741. 'asArray' => true
  6742. ) );
  6743. $verifyString = $verifyDetail ['staff'];
  6744. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  6745. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  6746. if (empty ( $opinion )) {
  6747. if ($status == 3)
  6748. $opinion = "终止";
  6749. else
  6750. $opinion = "同意支付";
  6751. }
  6752. $nowStaff = 0;
  6753. $nowStaffList = array ();
  6754. if (empty ( $verifyStaff )) {
  6755. // 还需加入是否已经进入角色审批
  6756. if ($verifyDetail [0] [1] == 'ROLE') {
  6757. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  6758. foreach ( $vStaffString as $key => $value ) {
  6759. $staffK = explode ( "_", $value );
  6760. if ($staffK [0] != $this->staff [0] ['sid'])
  6761. array_push ( $nowStaffList, $staffK [0] );
  6762. }
  6763. // print_r($verifyDetail);
  6764. // die;
  6765. if (! empty ( $nowStaffList )) {
  6766. $nowStaff = implode ( ',', $nowStaffList );
  6767. $verifyStaff = array (
  6768. $this->staff [0] ['sid'] . "_R" => array (
  6769. 'date' => date ( 'Y-m-d' ),
  6770. 'opinion' => $opinion,
  6771. 'status' => $status,
  6772. 'nextStaff' => $verifyDetail [0] [0],
  6773. 'ROLE' => 1
  6774. )
  6775. );
  6776. } else {
  6777. $nowStaff = $verifyDetail [1] [0];
  6778. $verifyStaff = array (
  6779. $this->staff [0] ['sid'] . "_R" => array (
  6780. 'date' => date ( 'Y-m-d' ),
  6781. 'opinion' => $opinion,
  6782. 'status' => $status,
  6783. 'nextStaff' => $verifyDetail [1] [0]
  6784. )
  6785. );
  6786. }
  6787. } else {
  6788. if ($verifyDetail [1] [1] == 'ROLE') {
  6789. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  6790. // echo "dd";
  6791. foreach ( $vStaffString as $key => $value ) {
  6792. $staffK = explode ( "_", $value );
  6793. array_push ( $nowStaffList, $staffK [0] );
  6794. }
  6795. $nowStaff = implode ( ',', $nowStaffList );
  6796. $verifyStaff = array (
  6797. $this->staff [0] ['sid'] => array (
  6798. 'date' => date ( 'Y-m-d' ),
  6799. 'opinion' => $opinion,
  6800. 'status' => $status,
  6801. 'nextStaff' => $verifyDetail [1] [0],
  6802. 'ROLE' => 1
  6803. )
  6804. );
  6805. } else {
  6806. $nowStaff = $verifyDetail [1] [0];
  6807. $verifyStaff = array (
  6808. $this->staff [0] ['sid'] => array (
  6809. 'date' => date ( 'Y-m-d' ),
  6810. 'opinion' => $opinion,
  6811. 'status' => $status,
  6812. 'nextStaff' => $verifyDetail [1] [0]
  6813. )
  6814. );
  6815. }
  6816. }
  6817. if ($status == 3)
  6818. $verifyStaff = array (
  6819. 'final' => $status,
  6820. $this->staff [0] ['sid'] => array (
  6821. 'date' => date ( 'Y-m-d' ),
  6822. 'opinion' => $opinion,
  6823. 'status' => $status
  6824. )
  6825. );
  6826. $vStaffString = json_encode ( $verifyStaff );
  6827. $receipt->nowStaff = $nowStaff;
  6828. $receipt->verifyStaff = $vStaffString;
  6829. } else {
  6830. $VS = end ( $verifyStaff );
  6831. // 非角色审批
  6832. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  6833. $nextStaff = 0;
  6834. $roleSTF = false;
  6835. foreach ( $verifyDetail as $key => $value ) {
  6836. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  6837. if (isset ( $verifyDetail [$key + 1] )) {
  6838. $nextStaff = $verifyDetail [$key + 1] [0];
  6839. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  6840. $roleSTF = true;
  6841. }
  6842. break;
  6843. }
  6844. }
  6845. if (! $roleSTF) {
  6846. $nowStaff = $nextStaff;
  6847. $verifyStaff [$this->staff [0] ['sid']] = array (
  6848. 'date' => date ( 'Y-m-d' ),
  6849. 'opinion' => $opinion,
  6850. 'status' => $status,
  6851. 'nextStaff' => $nextStaff
  6852. );
  6853. } else {
  6854. // 获取角色下的所有用户ID
  6855. $nowStaffList = array ();
  6856. foreach ( $verifyDetail as $vfk ) {
  6857. if ($vfk [1] == 'ROLE') {
  6858. $vStaffString = json_decode ( $vfk [3] );
  6859. foreach ( $vStaffString as $key => $value ) {
  6860. $staffK = explode ( "_", $value );
  6861. array_push ( $nowStaffList, $staffK [0] );
  6862. }
  6863. }
  6864. }
  6865. $nowStaff = implode ( ',', $nowStaffList );
  6866. $verifyStaff [$this->staff [0] ['sid']] = array (
  6867. 'date' => date ( 'Y-m-d' ),
  6868. 'opinion' => $opinion,
  6869. 'status' => $status,
  6870. 'nextStaff' => $nextStaff,
  6871. 'ROLE' => 0
  6872. );
  6873. }
  6874. if ($status == 3) {
  6875. $verifyStaff ['final'] = $status;
  6876. $verifyStaff [$this->staff [0] ['sid']] = array (
  6877. 'date' => date ( 'Y-m-d' ),
  6878. 'opinion' => $opinion,
  6879. 'status' => $status
  6880. );
  6881. }
  6882. $vStaffString = json_encode ( $verifyStaff );
  6883. $receipt->nowStaff = $nowStaff;
  6884. $receipt->verifyStaff = $vStaffString;
  6885. }
  6886. // 角色审批
  6887. if (isset ( $VS ['ROLE'] )) {
  6888. // 找出角色人 当前审批角色组
  6889. $verifyJSStaff = array ();
  6890. $nowStaffList2 = array ();
  6891. foreach ( $verifyDetail as $key => $value ) {
  6892. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  6893. $verifyJSStaff = json_decode ( $value [3] );
  6894. foreach ( $verifyJSStaff as $m ) {
  6895. $staffK = explode ( "_", $m );
  6896. array_push ( $nowStaffList2, $staffK [0] );
  6897. }
  6898. // print_r($nowStaffList2);
  6899. }
  6900. }
  6901. $RoleVerifyStaff = array ();
  6902. foreach ( $verifyStaff as $key => $value ) {
  6903. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  6904. foreach ( $nowStaffList2 as $m ) {
  6905. if ($key == $m . "_R")
  6906. $RoleVerifyStaff [$key] = $value;
  6907. }
  6908. }
  6909. }
  6910. // print_r($verifyStaff);
  6911. // print_r($nowStaffList2);
  6912. // print_r($RoleVerifyStaff);
  6913. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  6914. // print_r($verifyJSStaff);
  6915. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  6916. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  6917. // 下一个审批人ID
  6918. $nextStaff = 0;
  6919. $falg = false;
  6920. foreach ( $verifyDetail as $key => $value ) {
  6921. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  6922. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  6923. $falg = true;
  6924. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  6925. $nowStaffList = array ();
  6926. foreach ( $vStaffString as $v ) {
  6927. $staffK = explode ( "_", $v );
  6928. array_push ( $nowStaffList, $staffK [0] );
  6929. }
  6930. $nowStaff = implode ( ',', $nowStaffList );
  6931. $nextStaff = $verifyDetail [$key + 1] [0];
  6932. } elseif (isset ( $verifyDetail [$key + 1] )) {
  6933. $nextStaff = $verifyDetail [$key + 1] [0];
  6934. $nowStaff = $nextStaff;
  6935. } else
  6936. $nowStaff = '';
  6937. break;
  6938. }
  6939. }
  6940. if ($falg)
  6941. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6942. 'date' => date ( 'Y-m-d' ),
  6943. 'opinion' => $opinion,
  6944. 'status' => $status,
  6945. 'nextStaff' => $nextStaff,
  6946. 'ROLE' => 1
  6947. );
  6948. else
  6949. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6950. 'date' => date ( 'Y-m-d' ),
  6951. 'opinion' => $opinion,
  6952. 'status' => $status,
  6953. 'nextStaff' => $nextStaff
  6954. );
  6955. // print_r($verifyStaff);
  6956. // echo $nowStaff;die;
  6957. } else { // 进入下一个角色或者审批人
  6958. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  6959. //
  6960. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  6961. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6962. 'date' => date ( 'Y-m-d' ),
  6963. 'opinion' => $opinion,
  6964. 'status' => $status,
  6965. 'nextStaff' => $VS ['nextStaff'],
  6966. 'ROLE' => 1
  6967. );
  6968. // print_r($verifyStaff);
  6969. // die;
  6970. }
  6971. if ($status == 3) {
  6972. $verifyStaff ['final'] = $status;
  6973. $verifyStaff [$this->staff [0] ['sid']] = array (
  6974. 'date' => date ( 'Y-m-d' ),
  6975. 'opinion' => $opinion,
  6976. 'status' => $status
  6977. );
  6978. }
  6979. $vStaffString = json_encode ( $verifyStaff );
  6980. $receipt->verifyStaff = $vStaffString;
  6981. $receipt->nowStaff = $nowStaff;
  6982. // die;
  6983. // }
  6984. // print_r($verifyStaff);
  6985. // die;
  6986. }
  6987. // print_r($verifyStaff);die;
  6988. }
  6989. // print_r($verifyDetail);
  6990. $roleKey = 0;
  6991. $roleId = 0;
  6992. $verifyDetailCopy = array ();
  6993. foreach ( $verifyDetail as $k => $v ) {
  6994. if ($v [1] == 'ROLE') {
  6995. $roleId = $v [0];
  6996. $roleVerify = json_decode ( $v [3], true );
  6997. $roleKey = $k;
  6998. $roleArray = array ();
  6999. foreach ( $roleVerify as $o => $p ) {
  7000. $staffID = explode ( '_', $p );
  7001. $exp = array (
  7002. 0 => $staffID [0],
  7003. 1 => $staffID [1]
  7004. );
  7005. array_push ( $roleArray, $exp );
  7006. }
  7007. $verifyDetailCopy [$v [0]] = $roleArray;
  7008. }
  7009. }
  7010. // print_r($verifyDetail);
  7011. foreach ( $verifyDetailCopy as $k => $v ) {
  7012. foreach ( $verifyDetail as $m => $n ) {
  7013. if ($n [0] == $k) {
  7014. array_splice ( $verifyDetail, $m, 1, $v );
  7015. }
  7016. }
  7017. }
  7018. // die;
  7019. // if (!empty($roleArray))
  7020. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  7021. // echo $roleId;
  7022. // print_r($verifyStaff);
  7023. // print_r($verifyDetail);
  7024. // die;
  7025. Doo::loadModel ( "receiptLog" );
  7026. $receiptLog = new receiptLog ();
  7027. // 审批日志
  7028. if (! isset ( $verifyStaff ['final'] )) {
  7029. if (! empty ( $roleId )) {
  7030. Doo::loadModel ( "role" );
  7031. $role = new role ();
  7032. $roleInfo = $role->getOne ( array (
  7033. 'where' => 'rid=' . $roleId,
  7034. 'asArray' => true
  7035. ) );
  7036. $receiptLog->rolename = $roleInfo ['name'];
  7037. }
  7038. $receiptLog->username = $this->staff [0] ['username'];
  7039. $receiptLog->uid = $this->staff [0] ['sid'];
  7040. $receiptLog->date = date ( "Y-m-d" );
  7041. $receiptLog->opinion = $opinion;
  7042. $receiptLog->img = $this->staff [0] ['avatar'];
  7043. $receiptLog->status = 1;
  7044. $receiptLog->rid = $rid;
  7045. $receiptLog->insert ();
  7046. }
  7047. if (isset ( $verifyStaff ['final'] )) { // rDetail
  7048. $receipt->verifyBreakup = $verifyString;
  7049. $receipt->status = 3;
  7050. $receiptDetailObj->status = 3;
  7051. $receiptDetailObj->update ( array (
  7052. 'where' => 'rid=' . $rid
  7053. ) );
  7054. if (! empty ( $roleId )) {
  7055. Doo::loadModel ( "role" );
  7056. $role = new role ();
  7057. $roleInfo = $role->getOne ( array (
  7058. 'where' => 'rid=' . $roleId,
  7059. 'asArray' => true
  7060. ) );
  7061. $receiptLog->rolename = $roleInfo ['name'];
  7062. }
  7063. $receiptLog->username = $this->staff [0] ['username'];
  7064. $receiptLog->uid = $this->staff [0] ['sid'];
  7065. $receiptLog->date = date ( "Y-m-d" );
  7066. $receiptLog->opinion = $opinion;
  7067. $receiptLog->img = $this->staff [0] ['avatar'];
  7068. $receiptLog->status = 3;
  7069. $receiptLog->rid = $rid;
  7070. $receiptLog->insert ();
  7071. // 微信企业号通知
  7072. $this->setWXMsg ( $rid, 3 );
  7073. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  7074. $receipt->status = 1;
  7075. $reviseSum = 0;
  7076. $receipt->verifyBreakup = $verifyString;
  7077. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  7078. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7079. foreach ( $reviseDetail as $key => $value ) {
  7080. $receiptDetailObj = new receiptDetail ();
  7081. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7082. $receiptDetailObj->item = $value ['description'];
  7083. $receiptDetailObj->itemCategory = "报销金额调整";
  7084. $receiptDetailObj->price = $value ['price'];
  7085. $receiptDetailObj->date = $receiptDetail ['date'];
  7086. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  7087. $receiptDetailObj->rid = $rid;
  7088. $receiptDetailObj->status = 1;
  7089. $receiptDetailObj->insert ();
  7090. $reviseSum += $value ['price'];
  7091. }
  7092. $itemStatistics = new itemStatistics ();
  7093. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7094. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7095. $itemStatistics->price = $reviseSum;
  7096. $itemStatistics->itemCategory = "报销金额调整";
  7097. $itemStatistics->date = $receiptDetail ['date'];
  7098. $itemStatistics->insert ();
  7099. }
  7100. $receiptDetailObj = new receiptDetail ();
  7101. $receiptDetailObj->status = 1;
  7102. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  7103. $receiptDetailObj->update ( array (
  7104. 'where' => 'rid=' . $rid
  7105. ) );
  7106. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7107. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7108. $stat = $statistics->getOne ( array (
  7109. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  7110. 'asArray' => true
  7111. ) );
  7112. if (empty ( $stat )) {
  7113. $statistics->date = $receiptDetail ['date'];
  7114. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7115. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7116. $statistics->agPrice = $receiptDetail ['sum'];
  7117. $statistics->rePrice = $reviseSum;
  7118. $statistics->insert ();
  7119. } else {
  7120. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  7121. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  7122. $statistics->update ( array (
  7123. 'where' => 'sid=' . $stat ['sid']
  7124. ) );
  7125. }
  7126. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7127. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7128. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  7129. foreach ( $accountItem ['cSum'] as $key => $value ) {
  7130. if ($key == "agencySum") {
  7131. $iStatistics = $itemStatistics->getOne ( array (
  7132. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  7133. 'asArray' => true
  7134. ) );
  7135. if (empty ( $iStatistics )) {
  7136. $itemStatistics->cid = $receiptDetail ['cid'];
  7137. ;
  7138. $itemStatistics->staff = $receiptDetail ['staff'];
  7139. $itemStatistics->price = $value;
  7140. $itemStatistics->itemCategory = $this->AGENCY;
  7141. $itemStatistics->date = $receiptDetail ['date'];
  7142. $itemStatistics->insert ();
  7143. } else {
  7144. if (! empty ( $value )) {
  7145. $itemStatistics->price = $value + $iStatistics ['price'];
  7146. $itemStatistics->update ( array (
  7147. 'where' => 'sid=' . $iStatistics ['sid']
  7148. ) );
  7149. }
  7150. }
  7151. } elseif ($key == "travelSum") {
  7152. $iStatistics = $itemStatistics->getOne ( array (
  7153. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  7154. 'asArray' => true
  7155. ) );
  7156. if (empty ( $iStatistics )) {
  7157. $itemStatistics->cid = $receiptDetail ['cid'];
  7158. $itemStatistics->staff = $receiptDetail ['staff'];
  7159. $itemStatistics->price = $value;
  7160. $itemStatistics->itemCategory = $this->TRAVEL;
  7161. $itemStatistics->date = $receiptDetail ['date'];
  7162. $itemStatistics->insert ();
  7163. } else {
  7164. if (! empty ( $value )) {
  7165. $itemStatistics->price = $value + $iStatistics ['price'];
  7166. $itemStatistics->update ( array (
  7167. 'where' => 'sid=' . $iStatistics ['sid']
  7168. ) );
  7169. }
  7170. }
  7171. } elseif ($key == "trainSum") {
  7172. $iStatistics = $itemStatistics->getOne ( array (
  7173. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  7174. 'asArray' => true
  7175. ) );
  7176. if (empty ( $iStatistics )) {
  7177. $itemStatistics->cid = $receiptDetail ['cid'];
  7178. $itemStatistics->staff = $receiptDetail ['staff'];
  7179. $itemStatistics->price = $value;
  7180. $itemStatistics->itemCategory = $this->TRAIN;
  7181. $itemStatistics->date = $receiptDetail ['date'];
  7182. $itemStatistics->insert ();
  7183. } else {
  7184. if (! empty ( $value )) {
  7185. $itemStatistics->price = $value + $iStatistics ['price'];
  7186. $itemStatistics->update ( array (
  7187. 'where' => 'sid=' . $iStatistics ['sid']
  7188. ) );
  7189. }
  7190. }
  7191. } elseif ($key == "otherSum") {
  7192. $iStatistics = $itemStatistics->getOne ( array (
  7193. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  7194. 'asArray' => true
  7195. ) );
  7196. if (empty ( $iStatistics )) {
  7197. $itemStatistics->cid = $receiptDetail ['cid'];
  7198. $itemStatistics->staff = $receiptDetail ['staff'];
  7199. $itemStatistics->price = $value;
  7200. $itemStatistics->itemCategory = $this->OTHER;
  7201. $itemStatistics->date = $receiptDetail ['date'];
  7202. $itemStatistics->insert ();
  7203. } else {
  7204. if (! empty ( $value )) {
  7205. $itemStatistics->price = $value + $iStatistics ['price'];
  7206. $itemStatistics->update ( array (
  7207. 'where' => 'sid=' . $iStatistics ['sid']
  7208. ) );
  7209. }
  7210. }
  7211. }
  7212. }
  7213. $receipt->pastDate = date ( "Y-m-d" );
  7214. // 微信企业号通知
  7215. $this->setWXMsg ( $rid, 1 );
  7216. }
  7217. $receipt->amount = $amount;
  7218. $receipt->update ( array (
  7219. 'where' => ' rid = ' . $rid
  7220. ) );
  7221. // 进入下一条审批费用新加需求
  7222. $vidList = array ();
  7223. $verifyDetail = $verify->find ( array (
  7224. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  7225. 'asArray' => true
  7226. ) );
  7227. foreach ( $verifyDetail as $key => $value ) {
  7228. array_push ( $vidList, $value ['vid'] );
  7229. }
  7230. $vid = implode ( ",", $vidList );
  7231. if (empty ( $verifyDetail ))
  7232. $vid = 0;
  7233. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  7234. $receipt = new receipt ();
  7235. $rd = $receipt->getOne ( array (
  7236. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  7237. 'asc' => 'rid',
  7238. 'asArray' => true
  7239. ) );
  7240. if (empty ( $rd )) {
  7241. return '/approvalExpenses/pendApproval';
  7242. }
  7243. if ($rd ['Rtype'] == 1) {
  7244. if ($rd ['isBK'] == 1) {
  7245. return '/receiptburEdi/' . $rd ['rid'];
  7246. } else {
  7247. return '/expensesEdi/' . $rd ['rid'];
  7248. }
  7249. } elseif ($rd ['Rtype'] == 2) {
  7250. return '/remitApproval/' . $rd ['rid'];
  7251. } else {
  7252. return '/receiptburEdi/' . $rd ['rid'];
  7253. }
  7254. // return "/approvalExpenses/pendApproval";
  7255. }
  7256. }
  7257. function expensesRetreats() {
  7258. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7259. if (! empty ( $rid )) {
  7260. // 操作记录
  7261. Doo::loadModel ( "receipt" );
  7262. $receipt = new receipt ();
  7263. Doo::loadModel ( "receiptLog" );
  7264. $receiptLog = new receiptLog ();
  7265. Doo::loadModel ( "verify" );
  7266. $verify = new verify ();
  7267. $receiptInfo = $receipt->getOne ( array (
  7268. 'where' => 'rid=' . $rid,
  7269. 'asArray' => true
  7270. ) );
  7271. $vr = $verify->getOne ( array (
  7272. 'where' => 'vid=' . $receiptInfo ['verify'],
  7273. 'asArray' => true
  7274. ) );
  7275. $jd = json_decode ( $vr ['staff'] );
  7276. $roleId = 0;
  7277. foreach ( $jd as $key => $value ) {
  7278. if ($value [1] == 'ROLE') {
  7279. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7280. if ($pos !== false) {
  7281. $roleId = $value [0];
  7282. }
  7283. }
  7284. }
  7285. // 审批日志
  7286. // echo $roleId;die;
  7287. if (! empty ( $roleId )) {
  7288. Doo::loadModel ( "role" );
  7289. $role = new role ();
  7290. $roleInfo = $role->getOne ( array (
  7291. 'where' => 'rid=' . $roleId,
  7292. 'asArray' => true
  7293. ) );
  7294. $receiptLog->rolename = $roleInfo ['name'];
  7295. }
  7296. $receiptLog->username = $this->staff [0] ['username'];
  7297. $receiptLog->uid = $this->staff [0] ['sid'];
  7298. $receiptLog->date = date ( "Y-m-d" );
  7299. $receiptLog->opinion = '撤回';
  7300. $receiptLog->img = $this->staff [0] ['avatar'];
  7301. $receiptLog->status = 4;
  7302. $receiptLog->rid = $rid;
  7303. $receiptLog->insert ();
  7304. $receipt->status = 4;
  7305. $receipt->update ( array (
  7306. 'where' => 'rid=' . $rid
  7307. ) );
  7308. // 微信企业号通知
  7309. $this->setWXMsg ( $rid, 2 );
  7310. }
  7311. // echo "ddd";
  7312. return '/approvalExpenses/pendApproval';
  7313. }
  7314. function updateCheReceipt() {
  7315. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7316. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7317. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  7318. if (! empty ( $rid )) {
  7319. // 操作记录
  7320. Doo::loadModel ( "receipt" );
  7321. $receipt = new receipt ();
  7322. Doo::loadModel ( "receiptLog" );
  7323. $receiptLog = new receiptLog ();
  7324. Doo::loadModel ( "verify" );
  7325. $verify = new verify ();
  7326. $receiptInfo = $receipt->getOne ( array (
  7327. 'where' => 'rid=' . $rid . ' and status=2',
  7328. 'asArray' => true
  7329. ) );
  7330. if (empty ( $receiptInfo )) {
  7331. echo json_encode ( array (
  7332. 'status' => 2
  7333. ) );
  7334. die ();
  7335. }
  7336. $vr = $verify->getOne ( array (
  7337. 'where' => 'vid=' . $receiptInfo ['verify'],
  7338. 'asArray' => true
  7339. ) );
  7340. $jd = json_decode ( $vr ['staff'] );
  7341. $roleId = 0;
  7342. foreach ( $jd as $key => $value ) {
  7343. if ($value [1] == 'ROLE') {
  7344. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7345. if ($pos !== false) {
  7346. $roleId = $value [0];
  7347. }
  7348. }
  7349. }
  7350. // 审批日志
  7351. // echo $roleId;die;
  7352. if (! empty ( $roleId )) {
  7353. Doo::loadModel ( "role" );
  7354. $role = new role ();
  7355. $roleInfo = $role->getOne ( array (
  7356. 'where' => 'rid=' . $roleId,
  7357. 'asArray' => true
  7358. ) );
  7359. $receiptLog->rolename = $roleInfo ['name'];
  7360. }
  7361. $receiptLog->username = $this->staff [0] ['username'];
  7362. $receiptLog->uid = $this->staff [0] ['sid'];
  7363. $receiptLog->date = date ( "Y-m-d" );
  7364. $receiptLog->opinion = $opinion;
  7365. $receiptLog->img = $this->staff [0] ['avatar'];
  7366. $receiptLog->status = 4;
  7367. $receiptLog->rid = $rid;
  7368. $receiptLog->insert ();
  7369. $receipt->status = 4;
  7370. $receipt->update ( array (
  7371. 'where' => 'rid=' . $rid
  7372. ) );
  7373. // 微信企业号通知
  7374. $this->setWXMsg ( $rid, 2 );
  7375. echo json_encode ( array (
  7376. 'status' => 1
  7377. ) );
  7378. // Header("HTTP/1.1 303 See Other");
  7379. // Header("Location: /approvalExpenses/pendApproval");
  7380. die ();
  7381. }
  7382. echo json_encode ( array (
  7383. 'status' => 2
  7384. ) );
  7385. die ();
  7386. // echo "ddd";
  7387. // return '/saeaBorad';
  7388. }
  7389. function revisePrice() {
  7390. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  7391. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  7392. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7393. // echo $price;die;
  7394. if (! empty ( $rid )) {
  7395. Doo::loadModel ( "receipt" );
  7396. $receipt = new receipt ();
  7397. $receiptDetail = $receipt->getOne ( array (
  7398. 'where' => 'rid=' . $rid . ' and status=2 ',
  7399. 'asArray' => true
  7400. ) );
  7401. if (empty ( $receiptDetail ))
  7402. return "/approval";
  7403. $reviseDetail = array ();
  7404. if (empty ( $receiptDetail ['reviseDetail'] )) {
  7405. array_push ( $reviseDetail, array (
  7406. 'sid' => $this->staff [0] ['sid'],
  7407. 'name' => $this->staff [0] ['username'],
  7408. 'description' => $description,
  7409. 'price' => $price
  7410. ) );
  7411. $reviseDetailString = json_encode ( $reviseDetail );
  7412. $receipt->reviseDetail = $reviseDetailString;
  7413. $receipt->revisePrice = $price;
  7414. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7415. } else {
  7416. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7417. array_push ( $reviseDetail, array (
  7418. 'sid' => $this->staff [0] ['sid'],
  7419. 'name' => $this->staff [0] ['username'],
  7420. 'description' => $description,
  7421. 'price' => $price
  7422. ) );
  7423. $reviseDetailString = json_encode ( $reviseDetail );
  7424. $receipt->reviseDetail = $reviseDetailString;
  7425. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  7426. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7427. }
  7428. $receipt->update ( array (
  7429. 'where' => 'rid=' . $rid
  7430. ) );
  7431. }
  7432. return '/approvalEdi/' . $rid;
  7433. }
  7434. function personalCollect() {
  7435. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7436. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  7437. $this->showCache ( $path );
  7438. Doo::loadModel ( "receiptDetail" );
  7439. Doo::loadModel ( "itemStatistics" );
  7440. Doo::loadModel ( 'statistics' );
  7441. $statistics = new statistics ();
  7442. $itemStatistics = new itemStatistics ();
  7443. $receiptDetail = new receiptDetail ();
  7444. $receiptCollectList = $receiptDetail->find ( array (
  7445. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7446. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7447. 'groupby' => 'itemCategory,Month(date)',
  7448. 'asArray' => true
  7449. ) );
  7450. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  7451. 'where' => 'staff=' . $this->staff [0] ['sid'],
  7452. 'asArray' => true
  7453. ) );
  7454. // create collect html
  7455. $collectArray = array (
  7456. '日常相关费用' => array (),
  7457. '差旅相关费用' => array (),
  7458. '培训班费用' => array (),
  7459. '其他' => array ()
  7460. );
  7461. $adjustment = array ();
  7462. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  7463. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7464. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  7465. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7466. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  7467. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7468. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  7469. array_push ( $collectArray ['其他'], $collectHtml );
  7470. $data ['collectArray'] = $collectArray;
  7471. // statistics html
  7472. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7473. if (empty ( $stList ))
  7474. $stList = array (
  7475. 'rePrice' => 0,
  7476. 'agPrice' => 0
  7477. );
  7478. $data ['stList'] = array (
  7479. 'rePrice' => $stList ['rePrice'],
  7480. 'agPrice' => $stList ['agPrice'],
  7481. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7482. );
  7483. // Adjustment price html
  7484. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7485. array_push ( $adjustment, $collectHtml );
  7486. $data ['adjustment'] = $adjustment;
  7487. // total price html
  7488. $collectHtml = "";
  7489. $total = 0;
  7490. for($i = 1; $i <= 12; $i ++) {
  7491. $sumPrice = 0;
  7492. foreach ( $receiptCollectList as $key => $value ) {
  7493. if ($value ['month'] == $i) {
  7494. $sumPrice += $value ['price'];
  7495. }
  7496. }
  7497. if ($sumPrice == 0)
  7498. $collectHtml .= '<td class="taR">-</td>';
  7499. else
  7500. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7501. $total += $sumPrice;
  7502. }
  7503. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7504. $data ['totalPrice'] = $collectHtml;
  7505. $data ['year'] = $year;
  7506. $data ['totalYear'] = $total;
  7507. $data ['memu'] = "receipt";
  7508. $data ['staff'] = $this->staff;
  7509. $data ['receiptMemu'] = 'personalCollect';
  7510. $data ['verifyId'] = $this->verifyId;
  7511. $data ['executeId'] = $this->executeId;
  7512. // year staff status 2,4
  7513. if ($year < date ( "Y" )) {
  7514. Doo::loadModel ( 'receipt' );
  7515. $receipt = new receipt ();
  7516. $receiptList = $receipt->find ( array (
  7517. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7518. 'asArray' => true
  7519. ) );
  7520. if (empty ( $receiptList )) {
  7521. ob_start ();
  7522. $this->render ( "/admin/saea_slist_collect", $data );
  7523. $this->cacheFile ( $path );
  7524. die ();
  7525. }
  7526. }
  7527. $this->render ( "/admin/saea_slist_collect", $data );
  7528. }
  7529. function personalCollectDetail() {
  7530. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7531. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  7532. $this->showCache ( $path );
  7533. Doo::loadModel ( "receiptDetail" );
  7534. Doo::loadModel ( "itemStatistics" );
  7535. Doo::loadModel ( 'statistics' );
  7536. Doo::loadModel ( 'accountItem' );
  7537. $accountItem = new accountItem ();
  7538. $statistics = new statistics ();
  7539. $itemStatistics = new itemStatistics ();
  7540. $receiptDetail = new receiptDetail ();
  7541. $receiptCollectList = $receiptDetail->find ( array (
  7542. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  7543. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7544. 'groupby' => 'item,Month(date)',
  7545. 'asArray' => true
  7546. ) );
  7547. $accountList = $accountItem->find ( array (
  7548. 'asArray' => true
  7549. ) );
  7550. // create CollectDetail HTML
  7551. $collectHtml = array ();
  7552. foreach ( $accountList as $key => $value ) {
  7553. $html = "";
  7554. $asum = 0;
  7555. for($i = 1; $i <= 12; $i ++) {
  7556. $falg = true;
  7557. foreach ( $receiptCollectList as $v ) {
  7558. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7559. $asum += $v ['price'];
  7560. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7561. $falg = false;
  7562. break;
  7563. }
  7564. }
  7565. if ($falg)
  7566. $html .= '<td class="taR">-</td>';
  7567. }
  7568. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7569. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7570. }
  7571. $data ['collectHtml'] = $collectHtml;
  7572. // create Adjustment price html
  7573. $receiptCollectList = $receiptDetail->find ( array (
  7574. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7575. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7576. 'groupby' => 'itemCategory,Month(date)',
  7577. 'asArray' => true
  7578. ) );
  7579. $adjustment = array ();
  7580. $collectArray = array (
  7581. '日常相关费用' => array (),
  7582. '差旅相关费用' => array (),
  7583. '培训班费用' => array (),
  7584. '其他' => array ()
  7585. );
  7586. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7587. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7588. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7589. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7590. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7591. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7592. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7593. array_push ( $collectArray ['其他'], $collectHtml );
  7594. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7595. array_push ( $adjustment, $collectHtml );
  7596. // total price html
  7597. $collectHtml = "";
  7598. $total = 0;
  7599. for($i = 1; $i <= 12; $i ++) {
  7600. $sumPrice = 0;
  7601. foreach ( $receiptCollectList as $key => $value ) {
  7602. if ($value ['month'] == $i) {
  7603. $sumPrice += $value ['price'];
  7604. }
  7605. }
  7606. if ($sumPrice == 0)
  7607. $collectHtml .= '<td class="taR">-</td>';
  7608. else
  7609. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7610. $total += $sumPrice;
  7611. }
  7612. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7613. // statistics html
  7614. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7615. if (empty ( $stList ))
  7616. $stList = array (
  7617. 'rePrice' => 0,
  7618. 'agPrice' => 0
  7619. );
  7620. $data ['stList'] = array (
  7621. 'rePrice' => $stList ['rePrice'],
  7622. 'agPrice' => $stList ['agPrice'],
  7623. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7624. );
  7625. $data ['collectArray'] = $collectArray;
  7626. $data ['adjustment'] = $adjustment;
  7627. $data ['totalPrice'] = $collectHtml;
  7628. $data ['totalYear'] = $total;
  7629. $data ['year'] = $year;
  7630. $data ['memu'] = "receipt";
  7631. $data ['staff'] = $this->staff;
  7632. $data ['receiptMemu'] = 'personalCollect';
  7633. $data ['verifyId'] = $this->verifyId;
  7634. $data ['executeId'] = $this->executeId;
  7635. // year staff status 2,4
  7636. if ($year < date ( "Y" )) {
  7637. Doo::loadModel ( 'receipt' );
  7638. $receipt = new receipt ();
  7639. $receiptList = $receipt->find ( array (
  7640. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7641. 'asArray' => true
  7642. ) );
  7643. if (empty ( $receiptList )) {
  7644. ob_start ();
  7645. $this->render ( "/admin/saeaCollectArticles", $data );
  7646. $this->cacheFile ( $path );
  7647. die ();
  7648. }
  7649. }
  7650. $this->render ( "/admin/saeaCollectArticles", $data );
  7651. }
  7652. function companyCategoryCollect() {
  7653. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7654. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  7655. $this->showCache ( $path );
  7656. Doo::loadModel ( 'L_category' );
  7657. Doo::loadModel ( 'itemStatistics' );
  7658. Doo::loadModel ( 'statistics' );
  7659. $statistics = new statistics ();
  7660. $Lcategory = new L_category ();
  7661. $itemStatistics = new itemStatistics ();
  7662. $LcategoryList = $Lcategory->find ( array (
  7663. 'asArray' => true
  7664. ) ); // 'staff='.$this->staff[0]['sid']." and
  7665. $itemStatisticsList = $itemStatistics->find ( array (
  7666. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7667. 'where' => " Year(date)=" . $year,
  7668. 'groupby' => 'cid,Month(date)',
  7669. 'asArray' => true
  7670. ) );
  7671. // ceatre companyCollectHtml
  7672. foreach ( $LcategoryList as $value ) {
  7673. $html = "";
  7674. $asum = 0;
  7675. for($i = 1; $i <= 12; $i ++) {
  7676. $falg = true;
  7677. foreach ( $itemStatisticsList as $v ) {
  7678. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  7679. $asum += $v ['price'];
  7680. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7681. $falg = false;
  7682. break;
  7683. }
  7684. }
  7685. if ($falg)
  7686. $html .= '<td class="taR">-</td>';
  7687. }
  7688. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7689. $collectHtml [$value ['title']] = array (
  7690. 'html' => $html,
  7691. 'cid' => $value ['cid']
  7692. );
  7693. }
  7694. $data ['companyHtml'] = $collectHtml;
  7695. // total price html
  7696. $collectHtml = "";
  7697. $total = 0;
  7698. for($i = 1; $i <= 12; $i ++) {
  7699. $sumPrice = 0;
  7700. foreach ( $itemStatisticsList as $key => $value ) {
  7701. if ($value ['month'] == $i) {
  7702. $sumPrice += $value ['price'];
  7703. }
  7704. }
  7705. if ($sumPrice == 0)
  7706. $collectHtml .= '<td class="taR">-</td>';
  7707. else
  7708. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7709. $total += $sumPrice;
  7710. }
  7711. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7712. $data ['companyTotalHtml'] = $collectHtml;
  7713. $data ['total'] = $total;
  7714. // statistics html
  7715. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7716. if (empty ( $stList ))
  7717. $stList = array (
  7718. 'rePrice' => 0,
  7719. 'agPrice' => 0
  7720. );
  7721. $data ['stList'] = array (
  7722. 'rePrice' => $stList ['rePrice'],
  7723. 'agPrice' => $stList ['agPrice'],
  7724. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7725. );
  7726. $data ['year'] = $year;
  7727. $data ['memu'] = "receipt";
  7728. $data ['staff'] = $this->staff;
  7729. $data ['receiptMemu'] = 'companyCategoryCollect';
  7730. $data ['verifyId'] = $this->verifyId;
  7731. $data ['executeId'] = $this->executeId;
  7732. // year staff status 2,4
  7733. if ($year < date ( "Y" )) {
  7734. Doo::loadModel ( 'receipt' );
  7735. $receipt = new receipt ();
  7736. $receiptList = $receipt->find ( array (
  7737. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  7738. 'asArray' => true
  7739. ) );
  7740. if (empty ( $receiptList )) {
  7741. ob_start ();
  7742. $this->render ( "/admin/saeaCompanyCollect", $data );
  7743. $this->cacheFile ( $path );
  7744. die ();
  7745. }
  7746. }
  7747. $this->render ( "/admin/saeaCompanyCollect", $data );
  7748. }
  7749. function categoryCollectDetail() {
  7750. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7751. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  7752. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  7753. $this->showCache ( $path );
  7754. Doo::loadModel ( 'statistics' );
  7755. $statistics = new statistics ();
  7756. Doo::loadModel ( "receiptDetail" );
  7757. $receiptDetail = new receiptDetail ();
  7758. Doo::loadModel ( 'L_category' );
  7759. $Lcategory = new L_category ();
  7760. Doo::loadModel ( 'accountItem' );
  7761. $accountItem = new accountItem ();
  7762. $LcategoryList = $Lcategory->find ( array (
  7763. 'asArray' => true
  7764. ) );
  7765. if ($cid == 0) {
  7766. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7767. if ($cid == 0)
  7768. $cid = $LcategoryList [0] ['cid'];
  7769. }
  7770. $data ['LcategoryList'] = $LcategoryList;
  7771. $receiptCollectList = $receiptDetail->find ( array (
  7772. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  7773. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7774. 'groupby' => 'item,Month(pastDate)',
  7775. 'asArray' => true
  7776. ) );
  7777. $accountList = $accountItem->find ( array (
  7778. 'asArray' => true
  7779. ) );
  7780. // create CollectDetail HTML
  7781. $collectHtml = array ();
  7782. foreach ( $accountList as $key => $value ) {
  7783. $html = "";
  7784. $asum = 0;
  7785. for($i = 1; $i <= 12; $i ++) {
  7786. $falg = true;
  7787. foreach ( $receiptCollectList as $v ) {
  7788. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7789. $asum += $v ['price'];
  7790. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7791. $falg = false;
  7792. break;
  7793. }
  7794. }
  7795. if ($falg)
  7796. $html .= '<td class="taR">-</td>';
  7797. }
  7798. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7799. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7800. }
  7801. $data ['collectHtml'] = $collectHtml;
  7802. // create Adjustment price html
  7803. $receiptCollectList = $receiptDetail->find ( array (
  7804. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  7805. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7806. 'groupby' => 'itemCategory,Month(pastDate)',
  7807. 'asArray' => true
  7808. ) );
  7809. $adjustment = array ();
  7810. $collectArray = array (
  7811. '日常相关费用' => array (),
  7812. '差旅相关费用' => array (),
  7813. '培训班费用' => array (),
  7814. '其他' => array ()
  7815. );
  7816. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7817. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7818. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7819. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7820. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7821. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7822. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7823. array_push ( $collectArray ['其他'], $collectHtml );
  7824. $data ['collectArray'] = $collectArray;
  7825. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7826. array_push ( $adjustment, $collectHtml );
  7827. $data ['adjustment'] = $adjustment;
  7828. // total price html
  7829. $collectHtml = "";
  7830. $total = 0;
  7831. for($i = 1; $i <= 12; $i ++) {
  7832. $sumPrice = 0;
  7833. foreach ( $receiptCollectList as $key => $value ) {
  7834. if ($value ['month'] == $i) {
  7835. $sumPrice += $value ['price'];
  7836. }
  7837. }
  7838. if ($sumPrice == 0)
  7839. $collectHtml .= '<td class="taR">-</td>';
  7840. else
  7841. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7842. $total += $sumPrice;
  7843. }
  7844. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7845. // statistics html
  7846. $stList = $statistics->statisticsByCid ( $year, $cid );
  7847. if (empty ( $stList ))
  7848. $stList = array (
  7849. 'rePrice' => 0,
  7850. 'agPrice' => 0
  7851. );
  7852. $data ['stList'] = array (
  7853. 'rePrice' => $stList ['rePrice'],
  7854. 'agPrice' => $stList ['agPrice'],
  7855. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7856. );
  7857. $data ['totalYear'] = $total;
  7858. $data ['year'] = $year;
  7859. $data ['cid'] = $cid;
  7860. $data ['memu'] = "receipt";
  7861. $data ['staff'] = $this->staff;
  7862. $data ['receiptMemu'] = 'companyCategoryCollect';
  7863. $data ['verifyId'] = $this->verifyId;
  7864. $data ['executeId'] = $this->executeId;
  7865. // year staff status 2,4
  7866. if ($year < date ( "Y" )) {
  7867. Doo::loadModel ( 'receipt' );
  7868. $receipt = new receipt ();
  7869. $receiptList = $receipt->find ( array (
  7870. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  7871. 'asArray' => true
  7872. ) );
  7873. if (empty ( $receiptList )) {
  7874. ob_start ();
  7875. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7876. $this->cacheFile ( $path );
  7877. die ();
  7878. }
  7879. }
  7880. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7881. }
  7882. function staffCollect() {
  7883. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7884. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  7885. // $this->showCache($path);
  7886. Doo::loadModel ( 'statistics' );
  7887. $statistics = new statistics ();
  7888. Doo::loadModel ( "receiptDetail" );
  7889. $receiptDetail = new receiptDetail ();
  7890. Doo::loadModel ( 'L_category' );
  7891. $Lcategory = new L_category ();
  7892. Doo::loadModel ( 'accountItem' );
  7893. $accountItem = new accountItem ();
  7894. Doo::loadModel ( 'staff' );
  7895. $staff = new staff ();
  7896. Doo::loadModel ( 'itemStatistics' );
  7897. $itemStatistics = new itemStatistics ();
  7898. /*
  7899. * $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']));
  7900. */
  7901. // statistics html
  7902. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7903. if (empty ( $stList ))
  7904. $stList = array (
  7905. 'rePrice' => 0,
  7906. 'agPrice' => 0
  7907. );
  7908. $data ['stList'] = array (
  7909. 'rePrice' => $stList ['rePrice'],
  7910. 'agPrice' => $stList ['agPrice'],
  7911. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7912. );
  7913. // ---
  7914. $staffList = $staff->find ( array (
  7915. 'where' => 'username !="admin"',
  7916. 'asArray' => true
  7917. ) );
  7918. $LcategoryList = $Lcategory->find ( array (
  7919. 'asArray' => true
  7920. ) ); // 'staff='.$this->staff[0]['sid']." and
  7921. $itemStatisticsList = $itemStatistics->find ( array (
  7922. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7923. 'where' => " Year(date)=" . $year,
  7924. 'groupby' => 'staff,Month(date)',
  7925. 'asArray' => true
  7926. ) );
  7927. $categoryList = $staff->find ( array (
  7928. 'select' => 'COUNT(*) as count,cid,category',
  7929. 'where' => 'username !="admin"',
  7930. 'groupby' => 'cid',
  7931. 'asArray' => true
  7932. ) );
  7933. // print_r($itemStatisticsList);die;
  7934. // ceatre companyCollectHtml
  7935. foreach ( $categoryList as $vlu ) {
  7936. $count = $vlu ['count'] + 1;
  7937. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  7938. $m1 = 0;
  7939. $m2 = 0;
  7940. $m3 = 0;
  7941. $m4 = 0;
  7942. $m5 = 0;
  7943. $m6 = 0;
  7944. $m7 = 0;
  7945. $m8 = 0;
  7946. $m9 = 0;
  7947. $m10 = 0;
  7948. $m11 = 0;
  7949. $m12 = 0;
  7950. $m13 = 0;
  7951. foreach ( $staffList as $value ) {
  7952. if ($vlu ['cid'] == $value ['cid']) {
  7953. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  7954. $asum = 0;
  7955. for($i = 1; $i <= 12; $i ++) {
  7956. $falg = true;
  7957. foreach ( $itemStatisticsList as $v ) {
  7958. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  7959. if ($v ['month'] == 1)
  7960. $m1 += $v ['price'];
  7961. if ($v ['month'] == 2)
  7962. $m2 += $v ['price'];
  7963. if ($v ['month'] == 3)
  7964. $m3 += $v ['price'];
  7965. if ($v ['month'] == 4)
  7966. $m4 += $v ['price'];
  7967. if ($v ['month'] == 5)
  7968. $m5 += $v ['price'];
  7969. if ($v ['month'] == 6)
  7970. $m6 += $v ['price'];
  7971. if ($v ['month'] == 7)
  7972. $m7 += $v ['price'];
  7973. if ($v ['month'] == 8)
  7974. $m8 += $v ['price'];
  7975. if ($v ['month'] == 9)
  7976. $m9 += $v ['price'];
  7977. if ($v ['month'] == 10)
  7978. $m10 += $v ['price'];
  7979. if ($v ['month'] == 11)
  7980. $m11 += $v ['price'];
  7981. if ($v ['month'] == 12)
  7982. $m12 += $v ['price'];
  7983. $asum += $v ['price'];
  7984. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7985. $falg = false;
  7986. break;
  7987. }
  7988. }
  7989. if ($falg)
  7990. $html .= '<td class="taR">-</td>';
  7991. }
  7992. $m13 += $asum;
  7993. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7994. $collectHtml [$value ['username'].'_'.$value['sid']] = array (
  7995. 'html' => $html,
  7996. 'sid' => $value ['sid']
  7997. );
  7998. $html = "";
  7999. }
  8000. }
  8001. $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>
  8002. <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>
  8003. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  8004. $collectHtml [$vlu ['cid']] = array (
  8005. 'html' => $hl,
  8006. 'sid' => ''
  8007. );
  8008. }
  8009. $data ['companyHtml'] = $collectHtml;
  8010. // total price html
  8011. $collectHtml = "";
  8012. $total = 0;
  8013. for($i = 1; $i <= 12; $i ++) {
  8014. $sumPrice = 0;
  8015. foreach ( $itemStatisticsList as $key => $value ) {
  8016. if ($value ['month'] == $i) {
  8017. $sumPrice += $value ['price'];
  8018. }
  8019. }
  8020. if ($sumPrice == 0)
  8021. $collectHtml .= '<td class="taR">-</td>';
  8022. else
  8023. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8024. $total += $sumPrice;
  8025. }
  8026. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8027. $data ['companyTotalHtml'] = $collectHtml;
  8028. $data ['total'] = $total;
  8029. $data ['year'] = $year;
  8030. $data ['memu'] = "receipt";
  8031. $data ['staff'] = $this->staff;
  8032. $data ['receiptMemu'] = 'companyCategoryCollect';
  8033. $data ['verifyId'] = $this->verifyId;
  8034. $data ['executeId'] = $this->executeId;
  8035. if ($year <= date ( "Y" )) {
  8036. Doo::loadModel ( 'receipt' );
  8037. $receipt = new receipt ();
  8038. $receiptList = $receipt->find ( array (
  8039. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  8040. 'asArray' => true
  8041. ) );
  8042. if (empty ( $receiptList )) { // generated files
  8043. ob_start ();
  8044. $this->render ( "/admin/saeaStaffCollectB", $data );
  8045. $this->cacheFile ( $path );
  8046. die ();
  8047. }
  8048. }
  8049. $this->render ( "/admin/saeaStaffCollectB", $data );
  8050. }
  8051. function staffCollectBak() {
  8052. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8053. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  8054. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  8055. $this->showCache ( $path );
  8056. Doo::loadModel ( 'statistics' );
  8057. $statistics = new statistics ();
  8058. Doo::loadModel ( "receiptDetail" );
  8059. $receiptDetail = new receiptDetail ();
  8060. Doo::loadModel ( 'L_category' );
  8061. $Lcategory = new L_category ();
  8062. Doo::loadModel ( 'accountItem' );
  8063. $accountItem = new accountItem ();
  8064. Doo::loadModel ( 'staff' );
  8065. $staff = new staff ();
  8066. Doo::loadModel ( 'itemStatistics' );
  8067. $itemStatistics = new itemStatistics ();
  8068. $itemStatisticsList = $itemStatistics->find ( array (
  8069. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8070. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8071. 'groupby' => 'staff,itemCategory,Month(date)',
  8072. 'asArray' => true
  8073. ) );
  8074. $itemCategoryList = $itemStatistics->find ( array (
  8075. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8076. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8077. 'groupby' => 'cid,itemCategory,Month(date)',
  8078. 'asArray' => true
  8079. ) );
  8080. $LcategoryList = $Lcategory->find ( array (
  8081. 'asArray' => true
  8082. ) );
  8083. $staffList = $staff->find ( array (
  8084. 'asArray' => true
  8085. ) );
  8086. $htmlArray = array ();
  8087. foreach ( $LcategoryList as $value ) {
  8088. $htmlArray [$value ['title']] = array ();
  8089. foreach ( $staffList as $v ) {
  8090. if ($value ['cid'] == $v ['cid']) {
  8091. $html = "";
  8092. $falg = true;
  8093. $staffSumPrice = 0;
  8094. foreach ( $itemStatisticsList as $a ) {
  8095. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  8096. if (empty ( $a ['price'] )) {
  8097. $html .= '<td class="taR">-</td>';
  8098. $falg = false;
  8099. break;
  8100. } else {
  8101. $staffSumPrice += $a ['price'];
  8102. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8103. $falg = false;
  8104. break;
  8105. }
  8106. }
  8107. }
  8108. if ($falg) {
  8109. $html .= '<td class="taR">-</td>';
  8110. $falg = true;
  8111. }
  8112. $falg = true;
  8113. foreach ( $itemStatisticsList as $a ) {
  8114. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  8115. if (empty ( $a ['price'] )) {
  8116. $html .= '<td class="taR">-</td>';
  8117. $falg = false;
  8118. break;
  8119. } else {
  8120. $staffSumPrice += $a ['price'];
  8121. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8122. $falg = false;
  8123. break;
  8124. }
  8125. }
  8126. }
  8127. if ($falg) {
  8128. $html .= '<td class="taR">-</td>';
  8129. $falg = true;
  8130. }
  8131. $falg = true;
  8132. foreach ( $itemStatisticsList as $a ) {
  8133. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  8134. if (empty ( $a ['price'] )) {
  8135. $html .= '<td class="taR">-</td>';
  8136. $falg = false;
  8137. break;
  8138. } else {
  8139. $staffSumPrice += $a ['price'];
  8140. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8141. $falg = false;
  8142. break;
  8143. }
  8144. }
  8145. }
  8146. if ($falg) {
  8147. $html .= '<td class="taR">-</td>';
  8148. $falg = true;
  8149. }
  8150. $falg = true;
  8151. foreach ( $itemStatisticsList as $a ) {
  8152. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  8153. if (! empty ( $a ['price'] )) {
  8154. $staffSumPrice += $a ['price'];
  8155. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8156. $falg = false;
  8157. break;
  8158. } else {
  8159. $html .= '<td class="taR">-</td>';
  8160. $falg = false;
  8161. break;
  8162. }
  8163. }
  8164. }
  8165. if ($falg) {
  8166. $html .= '<td class="taR">-</td>';
  8167. $falg = true;
  8168. }
  8169. $falg = true;
  8170. foreach ( $itemStatisticsList as $a ) {
  8171. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  8172. if (! empty ( $a ['price'] )) {
  8173. $staffSumPrice += $a ['price'];
  8174. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8175. $falg = false;
  8176. break;
  8177. } else {
  8178. $html .= '<td class="taR">-</td>';
  8179. $falg = false;
  8180. break;
  8181. }
  8182. }
  8183. }
  8184. if ($falg) {
  8185. $html .= '<td class="taR">-</td>';
  8186. $falg = true;
  8187. }
  8188. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  8189. $htmlArray [$value ['title']] [$v ['username']] = $html;
  8190. }
  8191. }
  8192. /* -- --- */
  8193. // 合计费用
  8194. $cateHtml = "";
  8195. $catePrice = 0;
  8196. $cateFalg = true;
  8197. foreach ( $itemCategoryList as $l ) {
  8198. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  8199. if (empty ( $l ['price'] )) {
  8200. $cateHtml .= '<td class="colGreen taR">-</td>';
  8201. $cateFalg = false;
  8202. break;
  8203. } else {
  8204. $catePrice += $l ['price'];
  8205. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8206. $cateFalg = false;
  8207. break;
  8208. }
  8209. }
  8210. }
  8211. if ($cateFalg) {
  8212. $cateHtml .= '<td class="colGreen taR">-</td>';
  8213. $cateFalg = true;
  8214. }
  8215. $cateFalg = true;
  8216. foreach ( $itemCategoryList as $l ) {
  8217. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  8218. if (empty ( $l ['price'] )) {
  8219. $cateHtml .= '<td class="colGreen taR">-</td>';
  8220. $cateFalg = false;
  8221. break;
  8222. } else {
  8223. $catePrice += $l ['price'];
  8224. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8225. $cateFalg = false;
  8226. break;
  8227. }
  8228. }
  8229. }
  8230. if ($cateFalg) {
  8231. $cateHtml .= '<td class="colGreen taR">-</td>';
  8232. $cateFalg = true;
  8233. }
  8234. $cateFalg = true;
  8235. foreach ( $itemCategoryList as $l ) {
  8236. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  8237. if (empty ( $l ['price'] )) {
  8238. $cateHtml .= '<td class="colGreen taR">-</td>';
  8239. $cateFalg = false;
  8240. break;
  8241. } else {
  8242. $catePrice += $l ['price'];
  8243. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8244. $cateFalg = false;
  8245. break;
  8246. }
  8247. }
  8248. }
  8249. if ($cateFalg) {
  8250. $cateHtml .= '<td class="colGreen taR">-</td>';
  8251. $cateFalg = true;
  8252. }
  8253. $cateFalg = true;
  8254. foreach ( $itemCategoryList as $l ) {
  8255. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  8256. if (empty ( $l ['price'] )) {
  8257. $cateHtml .= '<td class="colGreen taR">-</td>';
  8258. $cateFalg = false;
  8259. break;
  8260. } else {
  8261. $catePrice += $l ['price'];
  8262. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8263. $cateFalg = false;
  8264. break;
  8265. }
  8266. }
  8267. }
  8268. if ($cateFalg) {
  8269. $cateHtml .= '<td class="colGreen taR">-</td>';
  8270. $cateFalg = true;
  8271. }
  8272. $cateFalg = true;
  8273. foreach ( $itemCategoryList as $l ) {
  8274. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  8275. if (empty ( $l ['price'] )) {
  8276. $cateHtml .= '<td class="colGreen taR">-</td>';
  8277. $cateFalg = false;
  8278. break;
  8279. } else {
  8280. $catePrice += $l ['price'];
  8281. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8282. $cateFalg = false;
  8283. break;
  8284. }
  8285. }
  8286. }
  8287. if ($cateFalg) {
  8288. $cateHtml .= '<td class="colGreen taR">-</td>';
  8289. $cateFalg = true;
  8290. }
  8291. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  8292. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  8293. /* -- --- */
  8294. }
  8295. // print_r($htmlArray);die;
  8296. $data ['htmlArray'] = $htmlArray;
  8297. // statistics html
  8298. $stList = $statistics->getOne ( array (
  8299. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8300. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8301. 'groupby' => 'Month(date)',
  8302. 'asArray' => true
  8303. ) );
  8304. if (empty ( $stList ))
  8305. $stList = array (
  8306. 'rePrice' => 0,
  8307. 'agPrice' => 0
  8308. );
  8309. $data ['stList'] = array (
  8310. 'rePrice' => $stList ['rePrice'],
  8311. 'agPrice' => $stList ['agPrice'],
  8312. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8313. );
  8314. $monthHtml = "";
  8315. for($i = 1; $i <= 12; $i ++) {
  8316. if ($i == $month)
  8317. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8318. else
  8319. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8320. }
  8321. $data ['monthHtml'] = $monthHtml;
  8322. $data ['year'] = $year;
  8323. $data ['month'] = $month;
  8324. $data ['memu'] = "receipt";
  8325. $data ['staff'] = $this->staff;
  8326. $data ['receiptMemu'] = 'companyCategoryCollect';
  8327. $data ['verifyId'] = $this->verifyId;
  8328. $data ['executeId'] = $this->executeId;
  8329. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  8330. Doo::loadModel ( 'receipt' );
  8331. $receipt = new receipt ();
  8332. $receiptList = $receipt->find ( array (
  8333. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  8334. 'asArray' => true
  8335. ) );
  8336. if (empty ( $receiptList )) { // generated files
  8337. ob_start ();
  8338. $this->render ( "/admin/saeaStaffCollect", $data );
  8339. $this->cacheFile ( $path );
  8340. die ();
  8341. }
  8342. }
  8343. $this->render ( "/admin/saeaStaffCollect", $data );
  8344. }
  8345. function lyt() {
  8346. Doo::loadModel ( "receiptDetail" );
  8347. $receiptDetail = new receiptDetail ();
  8348. $receiptCollectList = $receiptDetail->find ( array (
  8349. 'where' => 'status=1 ',
  8350. 'asArray' => true
  8351. ) );
  8352. foreach ( $receiptCollectList as $key => $value ) {
  8353. $receiptDetail = new receiptDetail ();
  8354. $receiptDetail->pastDate = $value ['date'];
  8355. $receiptDetail->update ( array (
  8356. 'where' => "rdid= '" . $value ['rdid'] . "'"
  8357. ) );
  8358. }
  8359. }
  8360. function staffCollectMonthDetail() {
  8361. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8362. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8363. if (! $year)
  8364. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8365. if (! $month)
  8366. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8367. Doo::loadModel ( 'staff' );
  8368. $staff = new staff ();
  8369. Doo::loadModel ( "receiptDetail" );
  8370. $receiptDetail = new receiptDetail ();
  8371. Doo::loadModel ( 'accountItem' );
  8372. $accountItem = new accountItem ();
  8373. Doo::loadModel ( 'statistics' );
  8374. $statistics = new statistics ();
  8375. Doo::loadModel ( 'L_category' );
  8376. $lCategory = new L_category ();
  8377. $staffList = $staff->find ( array (
  8378. 'where' => 'username!="admin"',
  8379. 'asArray' => true
  8380. ) );
  8381. $categoryList = $staff->find ( array (
  8382. 'select' => 'COUNT(*) as count,cid,category',
  8383. 'where' => 'username !="admin"',
  8384. 'groupby' => 'cid',
  8385. 'asArray' => true
  8386. ) );
  8387. $list = array ();
  8388. foreach ( $categoryList as $vlu ) {
  8389. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8390. $r1 = 0;
  8391. $r2 = 0;
  8392. $r3 = 0;
  8393. $r4 = 0;
  8394. $r5 = 0;
  8395. $r6 = 0;
  8396. $r7 = 0;
  8397. $r8 = 0;
  8398. $r9 = 0;
  8399. $r10 = 0;
  8400. $r11 = 0;
  8401. $r12 = 0;
  8402. $r13 = 0;
  8403. $r14 = 0;
  8404. $r15 = 0;
  8405. $r16 = 0;
  8406. $r17 = 0;
  8407. $r18 = 0;
  8408. $c1 = 0;
  8409. $c2 = 0;
  8410. $c3 = 0;
  8411. $c4 = 0;
  8412. $c5 = 0;
  8413. $c6 = 0;
  8414. $p1 = 0;
  8415. $p2 = 0;
  8416. $p3 = 0;
  8417. $p4 = 0;
  8418. $p5 = 0;
  8419. $p6 = 0;
  8420. $p7 = 0;
  8421. $p8 = 0;
  8422. $p9 = 0;
  8423. $t1 = 0;
  8424. $t2 = 0;
  8425. $t3 = 0;
  8426. $t4 = 0;
  8427. $t5 = 0;
  8428. $s1 = 0;
  8429. $m1 = 0;
  8430. foreach ( $staffList as $value ) {
  8431. if ($vlu ['cid'] == $value ['cid']) {
  8432. // pastDate
  8433. $receiptCollectList = $receiptDetail->find ( array (
  8434. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8435. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8436. 'groupby' => 'item,Month(pastDate),itemCategory',
  8437. 'asArray' => true
  8438. ) );
  8439. // if ($value['sid']==42){
  8440. // print_r($receiptCollectList);die;
  8441. // }
  8442. if (! empty ( $receiptCollectList )) {
  8443. $receiptL = array (
  8444. '日常相关费用' => array (),
  8445. '差旅相关费用' => array (),
  8446. '培训班费用' => array (),
  8447. '其他' => array ()
  8448. );
  8449. $html = "";
  8450. $psum = 0;
  8451. $item = array (
  8452. '市内交通费',
  8453. '市内出租费',
  8454. '办事处房租',
  8455. '电话费',
  8456. '水费',
  8457. '电费',
  8458. '办公费用',
  8459. '邮寄费',
  8460. '其他费用',
  8461. '车辆费用',
  8462. '广告费',
  8463. '团队建设费',
  8464. '物业管理费',
  8465. '宽带费',
  8466. '人员薪酬',
  8467. '公积金',
  8468. '社保'
  8469. );
  8470. foreach ( $item as $va ) {
  8471. $falg = true;
  8472. foreach ( $receiptCollectList as $v ) {
  8473. if ($v ['itemCategory'] == '日常相关费用') {
  8474. if ($v ['item'] == $va) {
  8475. if ($va == '市内交通费')
  8476. $r1 += $v ['price'];
  8477. if ($va == '市内出租费')
  8478. $r2 += $v ['price'];
  8479. if ($va == '办事处房租')
  8480. $r3 += $v ['price'];
  8481. if ($va == '电话费')
  8482. $r4 += $v ['price'];
  8483. if ($va == '水费')
  8484. $r5 += $v ['price'];
  8485. if ($va == '电费')
  8486. $r6 += $v ['price'];
  8487. if ($va == '办公费用')
  8488. $r7 += $v ['price'];
  8489. if ($va == '邮寄费')
  8490. $r8 += $v ['price'];
  8491. if ($va == '其他费用')
  8492. $r9 += $v ['price'];
  8493. if ($va == '车辆费用')
  8494. $r10 += $v ['price'];
  8495. if ($va == '广告费')
  8496. $r11 += $v ['price'];
  8497. if ($va == '团队建设费')
  8498. $r13 += $v ['price'];
  8499. if ($va == '物业管理费')
  8500. $r14 += $v ['price'];
  8501. if ($va == '宽带费')
  8502. $r15 += $v ['price'];
  8503. if ($va == '公积金')
  8504. $r16 += $v ['price'];
  8505. if ($va == '社保')
  8506. $r17 += $v ['price'];
  8507. if ($va == '人员薪酬')
  8508. $r18 += $v ['price'];
  8509. $psum += $v ['price'];
  8510. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8511. $falg = false;
  8512. break;
  8513. }
  8514. }
  8515. }
  8516. if ($falg)
  8517. $html .= '<td class="taR">-</td>';
  8518. }
  8519. $r12 += $psum;
  8520. if (! empty ( $psum ))
  8521. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8522. else
  8523. $psum = '<td class="colGreen taR">-</td>';
  8524. $receiptL ['日常相关费用'] = $psum . $html;
  8525. /* ----------------------------------- */
  8526. $html = "";
  8527. $psum = 0;
  8528. $item = array (
  8529. '往来交通费',
  8530. '市内交通费',
  8531. '出差住宿费',
  8532. '出差补助',
  8533. '其他费用'
  8534. );
  8535. foreach ( $item as $va ) {
  8536. $falg = true;
  8537. foreach ( $receiptCollectList as $v ) {
  8538. if ($v ['itemCategory'] == '差旅相关费用') {
  8539. if ($v ['item'] == $va) {
  8540. if ($va == '往来交通费')
  8541. $c1 += $v ['price'];
  8542. if ($va == '市内交通费')
  8543. $c2 += $v ['price'];
  8544. if ($va == '出差住宿费')
  8545. $c3 += $v ['price'];
  8546. if ($va == '出差补助')
  8547. $c4 += $v ['price'];
  8548. if ($va == '其他费用')
  8549. $c5 += $v ['price'];
  8550. $psum += $v ['price'];
  8551. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8552. $falg = false;
  8553. break;
  8554. }
  8555. }
  8556. }
  8557. if ($falg)
  8558. $html .= '<td class="taR">-</td>';
  8559. }
  8560. $c6 += $psum;
  8561. if (! empty ( $psum ))
  8562. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8563. else
  8564. $psum = '<td class="colGreen taR">-</td>';
  8565. $receiptL ['差旅相关费用'] = $psum . $html;
  8566. /* ------------------------------------- */
  8567. $html = "";
  8568. $psum = 0;
  8569. $item = array (
  8570. '场租费',
  8571. '薪酬',
  8572. '住宿费',
  8573. '交通费',
  8574. '餐饮费',
  8575. '办公费',
  8576. '公关费',
  8577. '其他'
  8578. );
  8579. foreach ( $item as $va ) {
  8580. $falg = true;
  8581. foreach ( $receiptCollectList as $v ) {
  8582. if ($v ['itemCategory'] == '培训班费用') {
  8583. if ($v ['item'] == $va) {
  8584. if ($va == '场租费')
  8585. $p1 += $v ['price'];
  8586. if ($va == '薪酬')
  8587. $p2 += $v ['price'];
  8588. if ($va == '住宿费')
  8589. $p3 += $v ['price'];
  8590. if ($va == '交通费')
  8591. $p4 += $v ['price'];
  8592. if ($va == '餐饮费')
  8593. $p5 += $v ['price'];
  8594. if ($va == '办公费')
  8595. $p6 += $v ['price'];
  8596. if ($va == '公关费')
  8597. $p7 += $v ['price'];
  8598. if ($va == '其他')
  8599. $p8 += $v ['price'];
  8600. $psum += $v ['price'];
  8601. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8602. $falg = false;
  8603. break;
  8604. }
  8605. }
  8606. }
  8607. if ($falg)
  8608. $html .= '<td class="taR">-</td>';
  8609. }
  8610. $p9 += $psum;
  8611. if (! empty ( $psum ))
  8612. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8613. else
  8614. $psum = '<td class="colGreen taR">-</td>';
  8615. $receiptL ['培训班费用'] = $psum . $html;
  8616. /* ------------------------------------- */
  8617. $html = "";
  8618. $psum = 0;
  8619. $item = array (
  8620. '公关费',
  8621. '广告费',
  8622. '借款',
  8623. '可自加费用'
  8624. );
  8625. foreach ( $item as $va ) {
  8626. $falg = true;
  8627. foreach ( $receiptCollectList as $v ) {
  8628. if ($v ['itemCategory'] == '其他') {
  8629. // if ($value['sid']==42){
  8630. //
  8631. // echo var_dump($v['item']);
  8632. // echo var_dump($va);
  8633. // echo var_dump($v['item']==" ".$va);
  8634. // echo $v['item']."==".$va."/<br/>";
  8635. // //print_r( $receiptCollectList);//echo $va;
  8636. // }
  8637. if (trim ( $v ['item'] ) == $va) {
  8638. if ($va == '公关费')
  8639. $t1 += $v ['price'];
  8640. if ($va == '广告费') {
  8641. $t2 += $v ['price'];
  8642. }
  8643. if ($va == '借款')
  8644. $t3 += $v ['price'];
  8645. if ($va == '可自加费用')
  8646. $t4 += $v ['price'];
  8647. $psum += $v ['price'];
  8648. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8649. $falg = false;
  8650. break;
  8651. }
  8652. }
  8653. }
  8654. if ($falg)
  8655. $html .= '<td class="taR">-</td>';
  8656. }
  8657. $t5 += $psum;
  8658. if (! empty ( $psum ))
  8659. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8660. else
  8661. $psum = '<td class="colGreen taR">-</td>';
  8662. $receiptL ['其他'] = $psum . $html;
  8663. /* ------------------------------------- */
  8664. $html = "";
  8665. $psum = 0;
  8666. foreach ( $receiptCollectList as $v ) {
  8667. if ($v ['itemCategory'] == '报销金额调整') {
  8668. if (! empty ( $v ['price'] )) {
  8669. $psum += $v ['price'];
  8670. }
  8671. }
  8672. }
  8673. $s1 += $psum;
  8674. if (! empty ( $psum ))
  8675. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8676. else
  8677. $psum = '<td class="taR colOrange">-</td>';
  8678. $receiptL ['报销金额调整'] = $psum . $html;
  8679. } else {
  8680. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8681. <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>
  8682. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8683. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  8684. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8685. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8686. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8687. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8688. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  8689. }
  8690. $monthStaffPrice = $receiptDetail->find ( array (
  8691. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8692. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8693. 'groupby' => 'Month(pastDate)',
  8694. 'asArray' => true
  8695. ) );
  8696. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  8697. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  8698. $m1 += $monthStaffPrice [0] ['price'];
  8699. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  8700. } else
  8701. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  8702. $list [$value ['username']] = $receiptL;
  8703. }
  8704. }
  8705. $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>
  8706. <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>
  8707. <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>';
  8708. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  8709. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  8710. $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>
  8711. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  8712. $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>';
  8713. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  8714. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  8715. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  8716. }
  8717. $data ['list'] = $list;
  8718. $receiptCollectList = $receiptDetail->find ( array (
  8719. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8720. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8721. 'groupby' => 'item,Month(pastDate),itemCategory',
  8722. 'asArray' => true
  8723. ) );
  8724. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  8725. // statistics html
  8726. $stList = $statistics->getOne ( array (
  8727. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8728. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8729. 'groupby' => 'Month(date)',
  8730. 'asArray' => true
  8731. ) );
  8732. if (empty ( $stList ))
  8733. $stList = array (
  8734. 'rePrice' => 0,
  8735. 'agPrice' => 0
  8736. );
  8737. $data ['stList'] = array (
  8738. 'rePrice' => $stList ['rePrice'],
  8739. 'agPrice' => $stList ['agPrice'],
  8740. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8741. );
  8742. $monthHtml = "";
  8743. for($i = 1; $i <= 12; $i ++) {
  8744. if ($i == $month)
  8745. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8746. else
  8747. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8748. }
  8749. $data ['monthHtml'] = $monthHtml;
  8750. $data ['year'] = $year;
  8751. $data ['month'] = $month;
  8752. $data ['memu'] = "receipt";
  8753. $data ['staff'] = $this->staff;
  8754. $data ['receiptMemu'] = 'companyCategoryCollect';
  8755. $data ['verifyId'] = $this->verifyId;
  8756. $data ['executeId'] = $this->executeId;
  8757. $this->render ( "/admin/staffCollectMonthDetail", $data );
  8758. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  8759. }
  8760. function staffCollectMonthDetail2() {
  8761. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8762. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8763. if (! $year)
  8764. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8765. if (! $month)
  8766. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8767. Doo::loadModel ( 'staff' );
  8768. $staff = new staff ();
  8769. Doo::loadModel ( "receiptDetail" );
  8770. $receiptDetail = new receiptDetail ();
  8771. Doo::loadModel ( 'accountItem' );
  8772. $accountItem = new accountItem ();
  8773. Doo::loadModel ( 'statistics' );
  8774. $statistics = new statistics ();
  8775. Doo::loadModel ( 'L_category' );
  8776. $lCategory = new L_category ();
  8777. $staffList = $staff->find ( array (
  8778. 'where' => 'username!="admin"',
  8779. 'asArray' => true
  8780. ) );
  8781. $categoryList = $staff->find ( array (
  8782. 'select' => 'COUNT(*) as count,cid,category',
  8783. 'where' => 'username !="admin"',
  8784. 'groupby' => 'cid',
  8785. 'asArray' => true
  8786. ) );
  8787. $list = array ();
  8788. foreach ( $categoryList as $vlu ) {
  8789. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8790. $r1 = 0;
  8791. $r2 = 0;
  8792. $r3 = 0;
  8793. $r4 = 0;
  8794. $r5 = 0;
  8795. $r6 = 0;
  8796. $r7 = 0;
  8797. $r8 = 0;
  8798. $r9 = 0;
  8799. $r10 = 0;
  8800. $r11 = 0;
  8801. $r12 = 0;
  8802. $r13 = 0;
  8803. $r14 = 0;
  8804. $r15 = 0;
  8805. $c1 = 0;
  8806. $c2 = 0;
  8807. $c3 = 0;
  8808. $c4 = 0;
  8809. $c5 = 0;
  8810. $c6 = 0;
  8811. $p1 = 0;
  8812. $p2 = 0;
  8813. $p3 = 0;
  8814. $p4 = 0;
  8815. $p5 = 0;
  8816. $p6 = 0;
  8817. $p7 = 0;
  8818. $p8 = 0;
  8819. $p9 = 0;
  8820. $t1 = 0;
  8821. $t2 = 0;
  8822. $t3 = 0;
  8823. $t4 = 0;
  8824. $t5 = 0;
  8825. $s1 = 0;
  8826. $m1 = 0;
  8827. foreach ( $staffList as $value ) {
  8828. if ($vlu ['cid'] == $value ['cid']) {
  8829. $receiptCollectList = $receiptDetail->find ( array (
  8830. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  8831. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  8832. 'groupby' => 'item,Month(date),itemCategory',
  8833. 'asArray' => true
  8834. ) );
  8835. if (! empty ( $receiptCollectList )) {
  8836. $receiptL = array (
  8837. '日常相关费用' => array (),
  8838. '差旅相关费用' => array (),
  8839. '培训班费用' => array (),
  8840. '其他' => array ()
  8841. );
  8842. $html = "";
  8843. $psum = 0;
  8844. $item = array (
  8845. '市内交通费',
  8846. '市内出租费',
  8847. '办事处房租',
  8848. '电话费',
  8849. '水费',
  8850. '电费',
  8851. '办公费用',
  8852. '邮寄费',
  8853. '其他费用',
  8854. '车辆费用',
  8855. '广告费',
  8856. '团队建设费',
  8857. '物业管理费',
  8858. '宽带费'
  8859. );
  8860. foreach ( $item as $va ) {
  8861. $falg = true;
  8862. foreach ( $receiptCollectList as $v ) {
  8863. if ($v ['itemCategory'] == '日常相关费用') {
  8864. if ($v ['item'] == $va) {
  8865. if ($va == '市内交通费')
  8866. $r1 += $v ['price'];
  8867. if ($va == '市内出租费')
  8868. $r2 += $v ['price'];
  8869. if ($va == '办事处房租')
  8870. $r3 += $v ['price'];
  8871. if ($va == '电话费')
  8872. $r4 += $v ['price'];
  8873. if ($va == '水费')
  8874. $r5 += $v ['price'];
  8875. if ($va == '电费')
  8876. $r6 += $v ['price'];
  8877. if ($va == '办公费用')
  8878. $r7 += $v ['price'];
  8879. if ($va == '邮寄费')
  8880. $r8 += $v ['price'];
  8881. if ($va == '其他费用')
  8882. $r9 += $v ['price'];
  8883. if ($va == '车辆费用')
  8884. $r10 += $v ['price'];
  8885. if ($va == '广告费')
  8886. $r11 += $v ['price'];
  8887. if ($va == '团队建设费')
  8888. $r13 += $v ['price'];
  8889. if ($va == '物业管理费')
  8890. $r14 += $v ['price'];
  8891. if ($va == '宽带费')
  8892. $r15 += $v ['price'];
  8893. $psum += $v ['price'];
  8894. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8895. $falg = false;
  8896. break;
  8897. }
  8898. }
  8899. }
  8900. if ($falg)
  8901. $html .= '<td class="taR">-</td>';
  8902. }
  8903. $r12 += $psum;
  8904. if (! empty ( $psum ))
  8905. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8906. else
  8907. $psum = '<td class="colGreen taR">-</td>';
  8908. $receiptL ['日常相关费用'] = $psum . $html;
  8909. /* ----------------------------------- */
  8910. $html = "";
  8911. $psum = 0;
  8912. $item = array (
  8913. '往来交通费',
  8914. '市内交通费',
  8915. '出差住宿费',
  8916. '出差补助',
  8917. '其他费用'
  8918. );
  8919. foreach ( $item as $va ) {
  8920. $falg = true;
  8921. foreach ( $receiptCollectList as $v ) {
  8922. if ($v ['itemCategory'] == '差旅相关费用') {
  8923. if ($v ['item'] == $va) {
  8924. if ($va == '往来交通费')
  8925. $c1 += $v ['price'];
  8926. if ($va == '市内交通费')
  8927. $c2 += $v ['price'];
  8928. if ($va == '出差住宿费')
  8929. $c3 += $v ['price'];
  8930. if ($va == '出差补助')
  8931. $c4 += $v ['price'];
  8932. if ($va == '其他费用')
  8933. $c5 += $v ['price'];
  8934. $psum += $v ['price'];
  8935. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8936. $falg = false;
  8937. break;
  8938. }
  8939. }
  8940. }
  8941. if ($falg)
  8942. $html .= '<td class="taR">-</td>';
  8943. }
  8944. $c6 += $psum;
  8945. if (! empty ( $psum ))
  8946. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8947. else
  8948. $psum = '<td class="colGreen taR">-</td>';
  8949. $receiptL ['差旅相关费用'] = $psum . $html;
  8950. /* ------------------------------------- */
  8951. $html = "";
  8952. $psum = 0;
  8953. $item = array (
  8954. '场租费',
  8955. '薪酬',
  8956. '住宿费',
  8957. '交通费',
  8958. '餐饮费',
  8959. '办公费',
  8960. '公关费',
  8961. '其他'
  8962. );
  8963. foreach ( $item as $va ) {
  8964. $falg = true;
  8965. foreach ( $receiptCollectList as $v ) {
  8966. if ($v ['itemCategory'] == '培训班费用') {
  8967. if ($v ['item'] == $va) {
  8968. if ($va == '场租费')
  8969. $p1 += $v ['price'];
  8970. if ($va == '薪酬')
  8971. $p2 += $v ['price'];
  8972. if ($va == '住宿费')
  8973. $p3 += $v ['price'];
  8974. if ($va == '交通费')
  8975. $p4 += $v ['price'];
  8976. if ($va == '餐饮费')
  8977. $p5 += $v ['price'];
  8978. if ($va == '办公费')
  8979. $p6 += $v ['price'];
  8980. if ($va == '公关费')
  8981. $p7 += $v ['price'];
  8982. if ($va == '其他')
  8983. $p8 += $v ['price'];
  8984. $psum += $v ['price'];
  8985. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8986. $falg = false;
  8987. break;
  8988. }
  8989. }
  8990. }
  8991. if ($falg)
  8992. $html .= '<td class="taR">-</td>';
  8993. }
  8994. $p9 += $psum;
  8995. if (! empty ( $psum ))
  8996. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8997. else
  8998. $psum = '<td class="colGreen taR">-</td>';
  8999. $receiptL ['培训班费用'] = $psum . $html;
  9000. /* ------------------------------------- */
  9001. $html = "";
  9002. $psum = 0;
  9003. $item = array (
  9004. '公关费',
  9005. '广告费',
  9006. '借款',
  9007. '可自加费用'
  9008. );
  9009. foreach ( $item as $va ) {
  9010. $falg = true;
  9011. foreach ( $receiptCollectList as $v ) {
  9012. if ($v ['itemCategory'] == '其他') {
  9013. if ($v ['item'] == $va) {
  9014. if ($va == '公关费')
  9015. $t1 += $v ['price'];
  9016. if ($va == '广告费')
  9017. $t2 += $v ['price'];
  9018. if ($va == '借款')
  9019. $t3 += $v ['price'];
  9020. if ($va == '可自加费用')
  9021. $t4 += $v ['price'];
  9022. $psum += $v ['price'];
  9023. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9024. $falg = false;
  9025. break;
  9026. }
  9027. }
  9028. }
  9029. if ($falg)
  9030. $html .= '<td class="taR">-</td>';
  9031. }
  9032. $t5 += $psum;
  9033. if (! empty ( $psum ))
  9034. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9035. else
  9036. $psum = '<td class="colGreen taR">-</td>';
  9037. $receiptL ['其他'] = $psum . $html;
  9038. /* ------------------------------------- */
  9039. $html = "";
  9040. $psum = 0;
  9041. foreach ( $receiptCollectList as $v ) {
  9042. if ($v ['itemCategory'] == '报销金额调整') {
  9043. if (! empty ( $v ['price'] )) {
  9044. $psum += $v ['price'];
  9045. }
  9046. }
  9047. }
  9048. $s1 += $psum;
  9049. if (! empty ( $psum ))
  9050. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9051. else
  9052. $psum = '<td class="taR colOrange">-</td>';
  9053. $receiptL ['报销金额调整'] = $psum . $html;
  9054. } else {
  9055. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9056. <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>';
  9057. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9058. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9059. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9060. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9061. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9062. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9063. }
  9064. $monthStaffPrice = $receiptDetail->find ( array (
  9065. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9066. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9067. 'asArray' => true
  9068. ) );
  9069. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  9070. $m1 += $monthStaffPrice [0] ['price'];
  9071. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9072. } else
  9073. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9074. $list [$value ['username']] = $receiptL;
  9075. }
  9076. }
  9077. $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>
  9078. <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>
  9079. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  9080. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  9081. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  9082. $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>
  9083. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  9084. $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>';
  9085. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  9086. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  9087. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  9088. }
  9089. $data ['list'] = $list;
  9090. $receiptCollectList = $receiptDetail->find ( array (
  9091. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9092. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9093. 'groupby' => 'item,Month(date),itemCategory',
  9094. 'asArray' => true
  9095. ) );
  9096. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9097. // statistics html
  9098. $stList = $statistics->getOne ( array (
  9099. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9100. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9101. 'groupby' => 'Month(date)',
  9102. 'asArray' => true
  9103. ) );
  9104. if (empty ( $stList ))
  9105. $stList = array (
  9106. 'rePrice' => 0,
  9107. 'agPrice' => 0
  9108. );
  9109. $data ['stList'] = array (
  9110. 'rePrice' => $stList ['rePrice'],
  9111. 'agPrice' => $stList ['agPrice'],
  9112. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9113. );
  9114. $monthHtml = "";
  9115. for($i = 1; $i <= 12; $i ++) {
  9116. if ($i == $month)
  9117. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9118. else
  9119. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9120. }
  9121. $data ['monthHtml'] = $monthHtml;
  9122. $data ['year'] = $year;
  9123. $data ['month'] = $month;
  9124. $data ['memu'] = "receipt";
  9125. $data ['staff'] = $this->staff;
  9126. $data ['receiptMemu'] = 'companyCategoryCollect';
  9127. $data ['verifyId'] = $this->verifyId;
  9128. $data ['executeId'] = $this->executeId;
  9129. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  9130. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9131. }
  9132. function companyMonthCollectDetail() {
  9133. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9134. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9135. if (! $year)
  9136. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9137. if (! $month)
  9138. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9139. Doo::loadModel ( 'staff' );
  9140. $staff = new staff ();
  9141. Doo::loadModel ( "receiptDetail" );
  9142. $receiptDetail = new receiptDetail ();
  9143. Doo::loadModel ( 'accountItem' );
  9144. $accountItem = new accountItem ();
  9145. Doo::loadModel ( 'statistics' );
  9146. $statistics = new statistics ();
  9147. Doo::loadModel ( 'L_category' );
  9148. $lCategory = new L_category ();
  9149. $staffList = $staff->find ( array (
  9150. 'where' => 'username!="admin"',
  9151. 'asArray' => true
  9152. ) );
  9153. $categoryList = $lCategory->find ( array (
  9154. 'asArray' => true
  9155. ) );
  9156. $list = array ();
  9157. foreach ( $categoryList as $value ) {
  9158. $receiptCollectList = $receiptDetail->find ( array (
  9159. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9160. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9161. 'groupby' => 'item,Month(pastDate),itemCategory',
  9162. 'asArray' => true
  9163. ) );
  9164. if (! empty ( $receiptCollectList )) {
  9165. $receiptL = array (
  9166. '日常相关费用' => array (),
  9167. '差旅相关费用' => array (),
  9168. '培训班费用' => array (),
  9169. '其他' => array ()
  9170. );
  9171. $html = "";
  9172. $psum = 0;
  9173. $item = array (
  9174. '市内交通费',
  9175. '市内出租费',
  9176. '办事处房租',
  9177. '电话费',
  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. );
  9217. foreach ( $item as $va ) {
  9218. $falg = true;
  9219. foreach ( $receiptCollectList as $v ) {
  9220. if ($v ['itemCategory'] == '差旅相关费用') {
  9221. if ($v ['item'] == $va) {
  9222. $psum += $v ['price'];
  9223. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9224. $falg = false;
  9225. break;
  9226. }
  9227. }
  9228. }
  9229. if ($falg)
  9230. $html .= '<td class="taR">-</td>';
  9231. }
  9232. if (! empty ( $psum ))
  9233. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9234. else
  9235. $psum = '<td class="colGreen taR">-</td>';
  9236. $receiptL ['差旅相关费用'] = $psum . $html;
  9237. /* ------------------------------------- */
  9238. $html = "";
  9239. $psum = 0;
  9240. $item = array (
  9241. '场租费',
  9242. '薪酬',
  9243. '住宿费',
  9244. '交通费',
  9245. '餐饮费',
  9246. '办公费',
  9247. '公关费',
  9248. '其他'
  9249. );
  9250. foreach ( $item as $va ) {
  9251. $falg = true;
  9252. foreach ( $receiptCollectList as $v ) {
  9253. if ($v ['itemCategory'] == '培训班费用') {
  9254. if ($v ['item'] == $va) {
  9255. $psum += $v ['price'];
  9256. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9257. $falg = false;
  9258. break;
  9259. }
  9260. }
  9261. }
  9262. if ($falg)
  9263. $html .= '<td class="taR">-</td>';
  9264. }
  9265. if (! empty ( $psum ))
  9266. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9267. else
  9268. $psum = '<td class="colGreen taR">-</td>';
  9269. $receiptL ['培训班费用'] = $psum . $html;
  9270. /* ------------------------------------- */
  9271. $html = "";
  9272. $psum = 0;
  9273. $item = array (
  9274. '公关费',
  9275. '广告费',
  9276. '借款',
  9277. '可自加费用'
  9278. );
  9279. foreach ( $item as $va ) {
  9280. $falg = true;
  9281. foreach ( $receiptCollectList as $v ) {
  9282. if ($v ['itemCategory'] == '其他') {
  9283. if ($v ['item'] == $va) {
  9284. $psum += $v ['price'];
  9285. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9286. $falg = false;
  9287. break;
  9288. }
  9289. }
  9290. }
  9291. if ($falg)
  9292. $html .= '<td class="taR">-</td>';
  9293. }
  9294. if (! empty ( $psum ))
  9295. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9296. else
  9297. $psum = '<td class="colGreen taR">-</td>';
  9298. $receiptL ['其他'] = $psum . $html;
  9299. /* ------------------------------------- */
  9300. $html = "";
  9301. $psum = 0;
  9302. foreach ( $receiptCollectList as $v ) {
  9303. if ($v ['itemCategory'] == '报销金额调整') {
  9304. if (! empty ( $v ['price'] ))
  9305. $psum += $v ['price'];
  9306. }
  9307. }
  9308. if (! empty ( $psum ))
  9309. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9310. else
  9311. $psum = '<td class="taR colOrange">-</td>';
  9312. $receiptL ['报销金额调整'] = $psum . $html;
  9313. } else {
  9314. $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>
  9315. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9316. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9317. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9318. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9319. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9320. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9321. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9322. }
  9323. $monthStaffPrice = $receiptDetail->find ( array (
  9324. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9325. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9326. 'asArray' => true
  9327. ) );
  9328. if (! empty ( $monthStaffPrice [0] ['price'] ))
  9329. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9330. else
  9331. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9332. $list [$value ['title']] = $receiptL;
  9333. }
  9334. $data ['list'] = $list;
  9335. $receiptCollectList = $receiptDetail->find ( array (
  9336. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9337. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9338. 'groupby' => 'item,Month(pastDate),itemCategory',
  9339. 'asArray' => true
  9340. ) );
  9341. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9342. // print_r($data['monthPriceHtml']);
  9343. // foreach ($data['monthPriceHtml'] as $value){
  9344. // echo $value;
  9345. // }
  9346. // die;
  9347. // statistics html
  9348. $stList = $statistics->getOne ( array (
  9349. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9350. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9351. 'groupby' => 'Month(date)',
  9352. 'asArray' => true
  9353. ) );
  9354. if (empty ( $stList ))
  9355. $stList = array (
  9356. 'rePrice' => 0,
  9357. 'agPrice' => 0
  9358. );
  9359. $data ['stList'] = array (
  9360. 'rePrice' => $stList ['rePrice'],
  9361. 'agPrice' => $stList ['agPrice'],
  9362. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9363. );
  9364. $monthHtml = "";
  9365. for($i = 1; $i <= 12; $i ++) {
  9366. if ($i == $month)
  9367. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9368. else
  9369. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9370. }
  9371. $data ['monthHtml'] = $monthHtml;
  9372. $data ['year'] = $year;
  9373. $data ['month'] = $month;
  9374. $data ['memu'] = "receipt";
  9375. $data ['staff'] = $this->staff;
  9376. $data ['receiptMemu'] = 'companyCategoryCollect';
  9377. $data ['verifyId'] = $this->verifyId;
  9378. $data ['executeId'] = $this->executeId;
  9379. $this->render ( "/admin/companyMonthCollectDetail", $data );
  9380. }
  9381. function staffCollectDetail() {
  9382. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9383. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  9384. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  9385. if (! $staffname) {
  9386. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  9387. $staffname = urldecode ( $staffname );
  9388. }
  9389. Doo::loadModel ( 'staff' );
  9390. $staff = new staff ();
  9391. Doo::loadModel ( "receiptDetail" );
  9392. $receiptDetail = new receiptDetail ();
  9393. Doo::loadModel ( 'accountItem' );
  9394. $accountItem = new accountItem ();
  9395. Doo::loadModel ( 'statistics' );
  9396. $statistics = new statistics ();
  9397. Doo::loadModel ( 'L_category' );
  9398. $lCategory = new L_category ();
  9399. $staffList = $staff->find ( array (
  9400. 'asArray' => true
  9401. ) );
  9402. $stHtml = '';
  9403. $stTitle = "";
  9404. $staffId = 0;
  9405. $cid = 0;
  9406. $ocid = 0;
  9407. foreach ( $staffList as $value ) {
  9408. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  9409. $stTitle = $value ['category'] . '-' . $value ['username'];
  9410. $staffId = $value ['sid'];
  9411. $cid = $value ['cid'];
  9412. $ocid = $value ['cid'];
  9413. if (! empty ( $value ['othercid'] ))
  9414. $cid = $value ['cid'] . ',' . $value ['othercid'];
  9415. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9416. } elseif ($value ['username'] != 'admin')
  9417. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9418. }
  9419. $data ['lCategoryHtml'] = $lCategory->find ( array (
  9420. 'where' => 'cid in(' . $cid . ')',
  9421. 'asArray' => true
  9422. ) );
  9423. if (empty ( $pcid ))
  9424. $pcid = $ocid;
  9425. $data ['ocid'] = $pcid;
  9426. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  9427. $this->showCache ( $path );
  9428. //
  9429. $receiptCollectList = $receiptDetail->find ( array (
  9430. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9431. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9432. 'groupby' => 'item,Month(pastDate),itemCategory',
  9433. 'asArray' => true
  9434. ) );
  9435. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  9436. // print_r($receiptCollectList);
  9437. $accountList = $accountItem->find ( array (
  9438. 'asArray' => true
  9439. ) );
  9440. // create CollectDetail HTML
  9441. $collectHtml = array ();
  9442. foreach ( $accountList as $key => $value ) {
  9443. $html = "";
  9444. $asum = 0;
  9445. for($i = 1; $i <= 12; $i ++) {
  9446. $falg = true;
  9447. foreach ( $receiptCollectList as $v ) {
  9448. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9449. if ($v ['item'] == '可自加费用') {
  9450. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  9451. }
  9452. $asum += $v ['price'];
  9453. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9454. $falg = false;
  9455. break;
  9456. }
  9457. }
  9458. if ($falg)
  9459. $html .= '<td class="taR">-</td>';
  9460. }
  9461. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9462. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9463. }
  9464. $data ['collectHtml'] = $collectHtml;
  9465. // print_r($collectHtml);
  9466. // create Adjustment price html
  9467. $receiptCollectList = $receiptDetail->find ( array (
  9468. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9469. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9470. 'groupby' => 'itemCategory,Month(pastDate)',
  9471. 'asArray' => true
  9472. ) );
  9473. $adjustment = array ();
  9474. $collectArray = array (
  9475. '日常相关费用' => array (),
  9476. '差旅相关费用' => array (),
  9477. '培训班费用' => array (),
  9478. '其他' => array ()
  9479. );
  9480. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9481. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9482. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9483. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9484. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9485. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9486. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9487. array_push ( $collectArray ['其他'], $collectHtml );
  9488. $data ['collectArray'] = $collectArray;
  9489. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9490. array_push ( $adjustment, $collectHtml );
  9491. $data ['adjustment'] = $adjustment;
  9492. // total price html
  9493. $collectHtml = "";
  9494. $total = 0;
  9495. for($i = 1; $i <= 12; $i ++) {
  9496. $sumPrice = 0;
  9497. foreach ( $receiptCollectList as $key => $value ) {
  9498. if ($value ['month'] == $i) {
  9499. $sumPrice += $value ['price'];
  9500. }
  9501. }
  9502. if ($sumPrice == 0)
  9503. $collectHtml .= '<td class="taR">-</td>';
  9504. else
  9505. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9506. $total += $sumPrice;
  9507. }
  9508. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9509. // statistics html
  9510. $stList = $statistics->statisticsByYear ( $year, $staffId );
  9511. if (empty ( $stList ))
  9512. $stList = array (
  9513. 'rePrice' => 0,
  9514. 'agPrice' => 0
  9515. );
  9516. $data ['stList'] = array (
  9517. 'rePrice' => $stList ['rePrice'],
  9518. 'agPrice' => $stList ['agPrice'],
  9519. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9520. );
  9521. $data ['totalPrice'] = $collectHtml;
  9522. $data ['totalYear'] = $total;
  9523. $data ['stHtml'] = $stHtml;
  9524. $data ['year'] = $year;
  9525. $data ['stTitle'] = $stTitle;
  9526. $data ['memu'] = "receipt";
  9527. $data ['staff'] = $this->staff;
  9528. $data ['receiptMemu'] = 'companyCategoryCollect';
  9529. $data ['verifyId'] = $this->verifyId;
  9530. $data ['executeId'] = $this->executeId;
  9531. if ($year < date ( "Y" )) {
  9532. Doo::loadModel ( 'receipt' );
  9533. $receipt = new receipt ();
  9534. $receiptList = $receipt->find ( array (
  9535. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  9536. 'asArray' => true
  9537. ) );
  9538. if (empty ( $receiptList )) { // generated files
  9539. ob_start ();
  9540. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9541. $this->cacheFile ( $path );
  9542. die ();
  9543. }
  9544. }
  9545. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9546. }
  9547. function BUGFLAG() {
  9548. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  9549. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  9550. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9551. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9552. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  9553. if (empty ( $status ))
  9554. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  9555. $page_size = 12;
  9556. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  9557. $vidList = array ();
  9558. $button = 0;
  9559. Doo::loadModel ( 'verify' );
  9560. $verify = new verify ();
  9561. Doo::loadModel ( 'receipt' );
  9562. $receipt = new receipt ();
  9563. Doo::loadModel ( 'staff' );
  9564. $staff = new staff ();
  9565. Doo::loadModel ( 'L_category' );
  9566. $Lcategory = new L_category ();
  9567. $dateCondition = " and Year(date) =" . $year;
  9568. if (! empty ( $month ))
  9569. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  9570. $categoryList = $Lcategory->find ( array (
  9571. 'asArray' => true
  9572. ) );
  9573. $staffList = $staff->find ( array (
  9574. 'where' => 'cid=' . $cid,
  9575. 'asArray' => true
  9576. ) );
  9577. $cateCondition = "";
  9578. $staffCondition = "";
  9579. $approvalCondition = "";
  9580. if (! empty ( $cid ))
  9581. $cateCondition = ' and cid=' . $cid;
  9582. if (! empty ( $sid )) {
  9583. $staffCondition = ' and staff=' . $sid;
  9584. $cateCondition = "";
  9585. }
  9586. $approvalCondition = " and status=" . $status;
  9587. if ($status == 2) {
  9588. // 查找角色审批人
  9589. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9590. }
  9591. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  9592. $approvalCondition = ' and status=2 ';
  9593. }
  9594. if ($status == 1) {
  9595. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  9596. }
  9597. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  9598. $pageinfo ['page'] = array (
  9599. 'previous' => ''
  9600. );
  9601. if ($status == 0) {
  9602. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  9603. $receiptList = $receipt->find ( array (
  9604. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  9605. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  9606. 'desc' => 'rid',
  9607. 'asArray' => true
  9608. ) );
  9609. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9610. } else
  9611. $receiptList = $receipt->find ( array (
  9612. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  9613. 'desc' => 'rid',
  9614. 'asArray' => true
  9615. ) );
  9616. $rLRes = $receipt->find ( array (
  9617. '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,
  9618. 'desc' => 'rid',
  9619. 'asArray' => true
  9620. ) );
  9621. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9622. // print_r($pageinfo);
  9623. $Locate = 0;
  9624. foreach ( $receiptList as $key => $value ) {
  9625. $receiptList [$key] ['Locate'] = $Locate;
  9626. $Locate ++;
  9627. $receiptList [$key] ['reviseDetail'] = array ();
  9628. if (! empty ( $value ['reviseDetail'] ))
  9629. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  9630. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  9631. $categoryDetil = $Lcategory->getOne ( array (
  9632. 'where' => 'cid=' . $value ['cid'],
  9633. 'asArray' => true
  9634. ) );
  9635. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  9636. $verifyList = $verify->getOne ( array (
  9637. 'where' => 'vid=' . $value ['verify'],
  9638. 'asArray' => true
  9639. ) );
  9640. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  9641. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  9642. foreach ( $verifyList as $k => $v ) {
  9643. // init verifyStaff
  9644. $verifyList [$k] ['date'] = "";
  9645. $verifyList [$k] ['opinion'] = "";
  9646. $verifyList [$k] ['status'] = "";
  9647. if (empty ( $verifyStaff )) {
  9648. $verifyList [$k] ['date'] = "";
  9649. $verifyList [$k] ['opinion'] = "";
  9650. if ($v [0] == $this->staff [0] ['sid']) {
  9651. $verifyList [$k] ['status'] = 4;
  9652. $button = 4;
  9653. }
  9654. } else {
  9655. $flag = true;
  9656. foreach ( $verifyStaff as $m => $u ) {
  9657. if ($v [0] == $m) {
  9658. $verifyList [$k] ['date'] = $u ['date'];
  9659. $verifyList [$k] ['opinion'] = $u ['opinion'];
  9660. $verifyList [$k] ['status'] = $u ['status'];
  9661. $flag = false;
  9662. break;
  9663. }
  9664. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  9665. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  9666. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  9667. }
  9668. if ($flag) { // 检测可编辑
  9669. if ($v [0] == $this->staff [0] ['sid']) {
  9670. $verifyList [$k] ['status'] = 4;
  9671. $button = 4;
  9672. }
  9673. }
  9674. }
  9675. }
  9676. $receiptList [$key] ['verifyList'] = $verifyList;
  9677. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  9678. 'where' => 'sid=' . $value ['staff'],
  9679. 'asArray' => true
  9680. ) );
  9681. $receiptList [$key] ['button'] = $button;
  9682. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  9683. }
  9684. // print_r($receiptList);die;
  9685. // $data['verifyDetail']=$verifyDetail;
  9686. $mothHtml = "";
  9687. for($i = 1; $i <= 12; $i ++) {
  9688. if ($month == $i)
  9689. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  9690. else
  9691. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  9692. }
  9693. $data ['mothHtml'] = $mothHtml;
  9694. $data ['page'] = $pageinfo;
  9695. $data ['receiptList'] = $receiptList;
  9696. $data ['receiptApprovalCount'] = count ( $rLRes );
  9697. $data ['status'] = $status;
  9698. $data ['year'] = $year;
  9699. $data ['categoryList'] = $categoryList;
  9700. $data ['staffList'] = $staffList;
  9701. $data ['cid'] = $cid;
  9702. $data ['sid'] = $sid;
  9703. // print_r($receiptList);
  9704. $data ['memu'] = "receipt";
  9705. $data ['staff'] = $this->staff;
  9706. $data ['receiptMemu'] = 'approvalExpenses';
  9707. $data ['verifyId'] = $this->verifyId;
  9708. $data ['executeId'] = $this->executeId;
  9709. $this->render ( "/admin/FALG", $data );
  9710. }
  9711. function ajaxGetReceiptOrder() {
  9712. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  9713. if (! empty ( $receiptOrder )) {
  9714. Doo::loadModel ( 'receipt' );
  9715. $receipt = new receipt ();
  9716. Doo::loadModel ( 'staff' );
  9717. $staff = new staff ();
  9718. $receiptInfo = $receipt->getOne ( array (
  9719. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  9720. 'asArray' => true
  9721. ) );
  9722. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  9723. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  9724. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  9725. </tbody></table><table class="table table table-bordered"><tbody>';
  9726. foreach ( $verifyStaff as $key => $value ) {
  9727. $staffInfo = $staff->getOne ( array (
  9728. 'select' => 'username',
  9729. 'where' => ' sid="' . $key . '"',
  9730. 'asArray' => true
  9731. ) );
  9732. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  9733. }
  9734. $html .= '</tbody></table></div></div>';
  9735. echo json_encode ( array (
  9736. 'status' => 1,
  9737. 'receiptHtml' => $html
  9738. ) );
  9739. die ();
  9740. }
  9741. echo json_encode ( array (
  9742. 'status' => 2,
  9743. 'receiptHtml' => ''
  9744. ) );
  9745. die ();
  9746. }
  9747. function _getMonthCollectDetail($receiptCollectList) {
  9748. if (! empty ( $receiptCollectList )) {
  9749. $receiptL = array (
  9750. '日常相关费用' => array (),
  9751. '差旅相关费用' => array (),
  9752. '培训班费用' => array (),
  9753. '其他' => array ()
  9754. );
  9755. $html = "";
  9756. $psum = 0;
  9757. $item = array (
  9758. '市内交通费',
  9759. '市内出租费',
  9760. '办事处房租',
  9761. '电话费',
  9762. '水费',
  9763. '电费',
  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. );
  9803. foreach ( $item as $value ) {
  9804. $falg = true;
  9805. foreach ( $receiptCollectList as $v ) {
  9806. if ($v ['itemCategory'] == '差旅相关费用') {
  9807. if ($v ['item'] == $value) {
  9808. $psum += $v ['price'];
  9809. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9810. $falg = false;
  9811. break;
  9812. }
  9813. }
  9814. }
  9815. if ($falg)
  9816. $html .= '<td class="taR">-</td>';
  9817. }
  9818. if (! empty ( $psum ))
  9819. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9820. else
  9821. $psum = '<td class="colGreen taR">-</td>';
  9822. $receiptL ['差旅相关费用'] = $psum . $html;
  9823. /* ------------------------------------- */
  9824. $html = "";
  9825. $psum = 0;
  9826. $item = array (
  9827. '场租费',
  9828. '薪酬',
  9829. '住宿费',
  9830. '交通费',
  9831. '餐饮费',
  9832. '办公费',
  9833. '公关费',
  9834. '其他'
  9835. );
  9836. foreach ( $item as $value ) {
  9837. $falg = true;
  9838. foreach ( $receiptCollectList as $v ) {
  9839. if ($v ['itemCategory'] == '培训班费用') {
  9840. if ($v ['item'] == $value) {
  9841. $psum += $v ['price'];
  9842. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9843. $falg = false;
  9844. break;
  9845. }
  9846. }
  9847. }
  9848. if ($falg)
  9849. $html .= '<td class="taR">-</td>';
  9850. }
  9851. if (! empty ( $psum ))
  9852. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9853. else
  9854. $psum = '<td class="colGreen taR">-</td>';
  9855. $receiptL ['培训班费用'] = $psum . $html;
  9856. /* ------------------------------------- */
  9857. $html = "";
  9858. $psum = 0;
  9859. $item = array (
  9860. '公关费',
  9861. '广告费',
  9862. '借款',
  9863. '可自加费用'
  9864. );
  9865. foreach ( $item as $value ) {
  9866. $falg = true;
  9867. foreach ( $receiptCollectList as $v ) {
  9868. if ($v ['itemCategory'] == '其他') {
  9869. if ($v ['item'] == $value) {
  9870. $psum += $v ['price'];
  9871. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9872. $falg = false;
  9873. break;
  9874. }
  9875. }
  9876. }
  9877. if ($falg)
  9878. $html .= '<td class="taR">-</td>';
  9879. }
  9880. if (! empty ( $psum ))
  9881. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9882. else
  9883. $psum = '<td class="colGreen taR">-</td>';
  9884. $receiptL ['其他'] = $psum . $html;
  9885. /* ------------------------------------- */
  9886. $html = "";
  9887. $psum = 0;
  9888. foreach ( $receiptCollectList as $v ) {
  9889. if ($v ['itemCategory'] == '报销金额调整') {
  9890. if (! empty ( $v ['price'] ))
  9891. $psum += $v ['price'];
  9892. }
  9893. }
  9894. if (! empty ( $psum ))
  9895. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9896. else
  9897. $psum = '<td class="taR colOrange">-</td>';
  9898. $receiptL ['报销金额调整'] = $psum . $html;
  9899. } else {
  9900. $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>
  9901. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9902. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9903. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9904. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9905. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9906. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9907. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9908. }
  9909. return $receiptL;
  9910. }
  9911. function eMail() {
  9912. Doo::loadModel ( 'staff' );
  9913. $staff = new staff ();
  9914. Doo::loadModel ( 'receipt' );
  9915. $receipt = new receipt ();
  9916. Doo::loadModel ( 'L_category' );
  9917. $Lcategory = new L_category ();
  9918. Doo::loadModel ( "verify" );
  9919. $verify = new verify ();
  9920. $staffList = $staff->find ( array (
  9921. 'asArray' => true
  9922. ) );
  9923. foreach ( $staffList as $key => $value ) {
  9924. if ($value ['username'] != 'admin') {
  9925. // 提交人
  9926. $receiptList = $receipt->find ( array (
  9927. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  9928. 'asArray' => true
  9929. ) );
  9930. if (! empty ( $receiptList )) {
  9931. $html = '<br><div><style></style>
  9932. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  9933. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  9934. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9935. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  9936. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9937. <tbody><tr>
  9938. <td style="padding: 0 40px;" align="left">
  9939. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9940. </td></tr><tr>
  9941. <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>
  9942. </tr>
  9943. </tbody> </table></td> </tr> <tr><td>
  9944. <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">
  9945. <tbody> <tr><td>
  9946. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  9947. 以下报销单完成了审批,等着收款吧:</p>
  9948. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  9949. foreach ( $receiptList as $k => $v ) {
  9950. $category = $Lcategory->getOne ( array (
  9951. 'where' => 'cid=' . $v ['cid'],
  9952. 'asArray' => true
  9953. ) );
  9954. $html .= '
  9955. <tr>
  9956. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  9957. <td align="left">
  9958. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  9959. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  9960. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  9961. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  9962. </tr>';
  9963. }
  9964. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  9965. <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>
  9966. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  9967. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  9968. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  9969. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9970. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9971. $receipt = new receipt ();
  9972. $receipt->notice = 1;
  9973. $receipt->update ( array (
  9974. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  9975. ) );
  9976. }
  9977. }
  9978. // 审批人
  9979. $verifyList = $verify->find ( array (
  9980. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  9981. 'asArray' => true
  9982. ) );
  9983. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  9984. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  9985. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9986. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  9987. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9988. <tbody><tr><td style="padding: 0 40px;" align="left">
  9989. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9990. </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>
  9991. </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">
  9992. <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>
  9993. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  9994. foreach ( $verifyList as $k => $v ) {
  9995. $receiptList = $receipt->find ( array (
  9996. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  9997. 'asArray' => true
  9998. ) );
  9999. foreach ( $receiptList as $r => $l ) {
  10000. $category = $Lcategory->getOne ( array (
  10001. 'where' => 'cid=' . $l ['cid'],
  10002. 'asArray' => true
  10003. ) );
  10004. $staffDetile = $staff->getOne ( array (
  10005. 'where' => 'sid=' . $l ['staff'],
  10006. 'asArray' => true
  10007. ) );
  10008. $html .= '
  10009. <tr>
  10010. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  10011. <td align="left">
  10012. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  10013. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  10014. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  10015. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  10016. </tr>';
  10017. }
  10018. }
  10019. $html .= '
  10020. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  10021. <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>
  10022. </tr></tbody></table></td></tr></tbody></table></div><br>';
  10023. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  10024. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  10025. // $receipt=new receipt();
  10026. // $receipt->notice=1;
  10027. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  10028. }
  10029. }
  10030. }
  10031. }
  10032. function setWXMsg($rid, $type) {
  10033. Doo::loadModel ( "receipt" );
  10034. $receipt = new receipt ();
  10035. $receiptDetail = $receipt->getOne ( array (
  10036. 'where' => 'rid=' . $rid,
  10037. 'asArray' => true
  10038. ) );
  10039. if (! empty ( $receiptDetail )) {
  10040. Doo::loadModel ( 'staff' );
  10041. $staff = new staff ();
  10042. $staffmsg = $staff->getOne ( array (
  10043. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  10044. 'asArray' => TRUE
  10045. ) );
  10046. if (! empty ( $staffmsg ['wxid'] )) {
  10047. require_once (SITE_PATH . '/protected/class/client.php');
  10048. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  10049. $user = $staffmsg ['wxid'];
  10050. $receiptName = '';
  10051. $msg = '';
  10052. switch ($receiptDetail ['Rtype']) {
  10053. case 0 :
  10054. $receiptName = '报销';
  10055. break;
  10056. case 1 :
  10057. $receiptName = '借款';
  10058. break;
  10059. case 2 :
  10060. $receiptName = '对公汇款';
  10061. break;
  10062. }
  10063. switch ($type) {
  10064. case 1 :
  10065. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  10066. break;
  10067. case 2 :
  10068. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  10069. break;
  10070. case 3 :
  10071. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  10072. break;
  10073. }
  10074. $result = $client->SendMsg ( $user, $msg, 'text' );
  10075. }
  10076. }
  10077. }
  10078. // Email发送函数
  10079. function SMail($toemail, $subject, $contents) {
  10080. Doo::loadClass ( 'class.phpmailer' );
  10081. $mail = new PHPMailer ();
  10082. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  10083. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  10084. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  10085. $mail->Password = "cDO1GjtY1seH"; // 密码
  10086. $mail->CharSet = "UTF8";
  10087. $mail->SMTPAuth = true;
  10088. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  10089. $mail->Mailer = "smtp";
  10090. $mail->Port = 25;
  10091. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  10092. $mail->MsgHTML ( $contents );
  10093. $mail->AddAddress ( $toemail );
  10094. $mail->CharSet = "UTF-8";
  10095. return $mail->Send ();
  10096. }
  10097. function swfupload() {
  10098. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  10099. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  10100. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  10101. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  10102. header ( "HTTP/1.1 500 Internal Server Error" );
  10103. echo "POST exceeded maximum allowed size.";
  10104. exit ( 0 );
  10105. }
  10106. // Settings
  10107. $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)
  10108. $upload_name = "Filedata";
  10109. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  10110. $extension_whitelist = array (
  10111. "doc",
  10112. "txt",
  10113. "jpg",
  10114. "gif",
  10115. "png"
  10116. ); // Allowed file extensions
  10117. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  10118. // Other variables
  10119. $MAX_FILENAME_LENGTH = 260;
  10120. $file_name = "";
  10121. $file_extension = "";
  10122. $uploadErrors = array (
  10123. 0 => "文件上传成功",
  10124. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  10125. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  10126. 3 => "上传的文件仅为部分文件",
  10127. 4 => "没有文件上传",
  10128. 6 => "缺少临时文件夹"
  10129. );
  10130. $nk = time ();
  10131. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  10132. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  10133. echo "文件无法保存.";
  10134. exit ( 0 );
  10135. }
  10136. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  10137. echo json_encode ( array (
  10138. 'filename' => $file_name,
  10139. 'id' => $nk
  10140. ) );
  10141. exit ( 0 );
  10142. }
  10143. function _GetFileEXT($filename) {
  10144. $pics = explode ( '.', $filename );
  10145. $num = count ( $pics );
  10146. return $pics [$num - 1];
  10147. }
  10148. /**
  10149. * 获取get或者POST值
  10150. * @param string $name 属性名称
  10151. * @return fixed 值
  10152. */
  10153. function get_args($name) {
  10154. if (isset ( $_GET [$name] )) {
  10155. if (is_array ( $_GET [$name] ))
  10156. return $_GET [$name];
  10157. else
  10158. return addslashes ( $_GET [$name] );
  10159. } elseif (isset ( $_POST [$name] )) {
  10160. if (is_array ( $_POST [$name] ))
  10161. return $_POST [$name];
  10162. else
  10163. return addslashes ( $_POST [$name] );
  10164. } else
  10165. return false;
  10166. }
  10167. function num_to_rmb($num) {
  10168. $c1 = "零壹贰叁肆伍陆柒捌玖";
  10169. $c2 = "分角元拾佰仟万拾佰仟亿";
  10170. // 精确到分后面就不要了,所以只留两个小数位
  10171. $num = round ( $num, 2 );
  10172. // 将数字转化为整数
  10173. $num = $num * 100;
  10174. if (strlen ( $num ) > 10) {
  10175. return "金额太大,请检查";
  10176. }
  10177. $i = 0;
  10178. $c = "";
  10179. while ( 1 ) {
  10180. if ($i == 0) {
  10181. // 获取最后一位数字
  10182. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  10183. } else {
  10184. $n = $num % 10;
  10185. }
  10186. // 每次将最后一位数字转化为中文
  10187. $p1 = substr ( $c1, 3 * $n, 3 );
  10188. $p2 = substr ( $c2, 3 * $i, 3 );
  10189. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  10190. $c = $p1 . $p2 . $c;
  10191. } else {
  10192. $c = $p1 . $c;
  10193. }
  10194. $i = $i + 1;
  10195. // 去掉数字最后一位了
  10196. $num = $num / 10;
  10197. $num = ( int ) $num;
  10198. // 结束循环
  10199. if ($num == 0) {
  10200. break;
  10201. }
  10202. }
  10203. $j = 0;
  10204. $slen = strlen ( $c );
  10205. while ( $j < $slen ) {
  10206. // utf8一个汉字相当3个字符
  10207. $m = substr ( $c, $j, 6 );
  10208. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  10209. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  10210. $left = substr ( $c, 0, $j );
  10211. $right = substr ( $c, $j + 3 );
  10212. $c = $left . $right;
  10213. $j = $j - 3;
  10214. $slen = $slen - 3;
  10215. }
  10216. $j = $j + 3;
  10217. }
  10218. // 这个是为了去掉类似23.0中最后一个“零”字
  10219. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  10220. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  10221. }
  10222. // 将处理的汉字加上“整”
  10223. if (empty ( $c )) {
  10224. return "零元整";
  10225. } else {
  10226. return $c . "整";
  10227. }
  10228. }
  10229. /**
  10230. * 获得分页数据
  10231. * @param unknown_type $table
  10232. * @param unknown_type $condition
  10233. * @param unknown_type $on_page
  10234. * @param unknown_type $page_size
  10235. */
  10236. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  10237. $page_c = "";
  10238. $page ['previous'] = $this->get_previous ( $on_page );
  10239. $page ['on_page'] = $on_page;
  10240. $total_count = $this->get_table_count ( $table, $condition );
  10241. $total = intval ( $total_count / $page_size );
  10242. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  10243. $page ['total_data'] = $total_count;
  10244. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  10245. $i = 1;
  10246. $page_max = 1;
  10247. $page_width = 3;
  10248. if ($on_page >= $page_width) {
  10249. $page_max = intval ( $on_page / $page_width ) + 1;
  10250. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  10251. }
  10252. for(; $i <= $page ['total_page']; $i ++) {
  10253. if ($i == $on_page)
  10254. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  10255. else
  10256. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  10257. if ($i == ($page_width * $page_max))
  10258. break;
  10259. }
  10260. $page ['page'] = $page_c;
  10261. $page ['lower'] = (-- $on_page) * $page_size;
  10262. return $page;
  10263. }
  10264. /**
  10265. * 获取总页数
  10266. * @param unknown_type $table
  10267. * @param unknown_type $condition
  10268. */
  10269. public function get_table_count($table = "", $condition = "") {
  10270. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10271. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10272. // echo $sql;die;
  10273. $query = Doo::db ()->query ( $sql );
  10274. $result = $query->fetch ();
  10275. return $result ['count'];
  10276. }
  10277. /**
  10278. * 获取上一页
  10279. * @param unknown_type $on_page
  10280. */
  10281. function get_previous($on_page = 1) {
  10282. return $on_page != 0 ? $on_page - 1 : $on_page;
  10283. }
  10284. }
  10285. ?>