ReceiptController.php 374 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class ReceiptController extends DooController {
  6. public $staff;
  7. public $verifyId;
  8. public $executeId;
  9. // public static $NEW2 = 0;
  10. public $AGENCY = "日常相关费用";
  11. public $TRAVEL = "差旅相关费用";
  12. public $TRAIN = "培训班费用";
  13. public $OTHER = "其他";
  14. private $MYREVEIPTCACHEPATH = "protected/cache/myReceipt/";
  15. private $PERSONALCOLLECTCACHEPATH = "protected/cache/personalCollect/";
  16. private $CATEGORYCOLLECTPATH = "protected/cache/categoryCollect/";
  17. private $STAFFCOLLECTPATH = "protected/cache/staffCollect/";
  18. private function showCache($path) {
  19. if (file_exists ( $path )) {
  20. echo "<!DOCTYPE html>";
  21. include $path;
  22. die ();
  23. }
  24. }
  25. private function cacheFile($path) {
  26. $content = ob_get_contents ();
  27. $fp = fopen ( $path, "w" );
  28. fwrite ( $fp, $content );
  29. fclose ( $fp );
  30. }
  31. // private function getExeCount(){
  32. // Doo::loadModel('receipt');
  33. // $receipt=new receipt();
  34. // $receiptList=$receipt->find(array('where'=>'(executeCopy like \'%["'.$this->staff[0]['sid'].'%\' and executeStaff NOT LIKE \'%'.$this->staff[0]['sid'].'%\' ) and (status=1 or status=6)','desc'=>'rid','asArray'=>true));
  35. // return count($receiptList);
  36. // }
  37. // private function getReceiptCount(){
  38. // $status=2;
  39. // $year=date('Y');
  40. // Doo::loadModel('receipt');
  41. // $receipt=new receipt();
  42. // $dateCondition=" and Year(date) =".$year;
  43. // $approvalCondition=' and (nowStaff like "%,'.$this->staff[0]['sid'].'%" or nowStaff like "%'.$this->staff[0]['sid'].',%" or nowStaff='.$this->staff[0]['sid'].' ) ';
  44. // $receiptList=$receipt->find(array('where'=>' status='.$status.$dateCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  45. // return count($receiptList);
  46. // }
  47. private function collectHtml($receiptCollectList = array(), $itemCategory = "日常相关费用", $classType = "b") {
  48. $collectHtml = "";
  49. $sumPrice = 0.00;
  50. for($i = 1; $i <= 12; $i ++) {
  51. $falg = true;
  52. foreach ( $receiptCollectList as $key => $value ) {
  53. if ($value ['itemCategory'] == $itemCategory && $value ['month'] == $i) {
  54. $sumPrice += $value ['price'];
  55. if ($classType == "b") {
  56. $collectHtml .= '<td class="colGreen taR">¥' . $value ['price'] . '</td>';
  57. $falg = false;
  58. break;
  59. } else {
  60. $collectHtml .= '<td class="taR">¥' . $value ['price'] . '</td>';
  61. $falg = false;
  62. break;
  63. }
  64. }
  65. }
  66. if ($falg)
  67. $collectHtml .= '<td class="taR">-</td>';
  68. }
  69. $collectHtml .= '<td class="taR colGreen">¥' . $sumPrice . '</td>';
  70. return $collectHtml;
  71. }
  72. function __construct() {
  73. if (isset ( $_COOKIE ["staff"] )) {
  74. if (! empty ( $_COOKIE ["staff"] )) {
  75. Doo::loadModel ( 'staff' );
  76. Doo::loadModel ( 'verify' );
  77. $verify = new verify ();
  78. $staff = new staff ();
  79. Doo::loadModel ( "execute" );
  80. $execute = new execute ();
  81. $verifyList = $verify->find ( array (
  82. 'select' => 'staff',
  83. 'asArray' => true
  84. ) );
  85. $list = array ();
  86. // 判断角色的审批权限
  87. foreach ( $verifyList as $key => $value ) {
  88. $ver = json_decode ( $value ['staff'] );
  89. foreach ( $ver as $k => $v ) {
  90. if ($v [1] == 'ROLE') {
  91. $roleList = json_decode ( $v [3] );
  92. foreach ( $roleList as $t => $g ) {
  93. $gList = explode ( "_", $g );
  94. array_push ( $list, $gList [0] );
  95. // print_r($list);
  96. }
  97. } else
  98. array_push ( $list, $v [0] );
  99. }
  100. }
  101. // 判断执行人的审批权限
  102. $executeList = $execute->find ( array (
  103. 'select' => 'staff',
  104. 'asArray' => true
  105. ) );
  106. $list2 = array ();
  107. foreach ( $executeList as $key => $value ) {
  108. $ver = json_decode ( $value ['staff'] );
  109. foreach ( $ver as $k => $v ) {
  110. array_push ( $list2, $v [0] );
  111. }
  112. }
  113. $eidList = file_get_contents ( "protected/config/execute/execute.ini" );
  114. $eidList = array_filter ( explode ( ",", $eidList ) );
  115. $this->executeId = array_merge ( $list2, $eidList );
  116. $this->verifyId = $list;
  117. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  118. return "/";
  119. }
  120. }
  121. Doo::loadCore ( 'uri/DooUriRouter' );
  122. $router = new DooUriRouter ();
  123. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  124. if ($routeRs ['1'] != "login") {
  125. header ( 'Content-Type:text/html;charset=utf-8' );
  126. @header ( "Location: /login" );
  127. }
  128. }
  129. function saeaBorad() {
  130. Doo::loadModel ( 'receipt' );
  131. Doo::loadModel ( 'verify' );
  132. $verify = new verify ();
  133. $receipt = new receipt ();
  134. Doo::loadModel ( 'L_category' );
  135. $lCategory = new L_category ();
  136. Doo::loadModel ( "role" );
  137. $role = new role ();
  138. Doo::loadModel ( "receiptLog" );
  139. $receiptLog = new receiptLog ();
  140. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  141. $receiptDetail = $receipt->find ( array (
  142. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  143. 'desc' => 'rid',
  144. 'asArray' => true
  145. ) );
  146. foreach ( $receiptDetail as $key => $value ) {
  147. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  148. $veList = $verify->getOne ( array (
  149. 'where' => 'vid=' . $value ['verify'],
  150. 'asArray' => true
  151. ) );
  152. $v = json_decode ( $veList ['staff'] );
  153. array_push ( $v [0], $veList ['description'] );
  154. foreach ( $v as $n => $m ) {
  155. if ($m ['1'] == 'ROLE') {
  156. $roleInfo = $role->getOne ( array (
  157. 'where' => 'rid=' . $m [0],
  158. 'asArray' => true
  159. ) );
  160. $v [$n] [1] = $roleInfo ['name'];
  161. }
  162. }
  163. $receiptDetail [$key] ['staff'] = $v;
  164. $category = $lCategory->getOne ( array (
  165. 'where' => 'cid=' . $value ['cid'],
  166. 'asArray' => true
  167. ) );
  168. $receiptDetail [$key] ['category'] = $category ['title'];
  169. }
  170. // print_r($receiptLogList);
  171. $data ['receiptLogList'] = $receiptLogList;
  172. $data ['receiptDetail'] = $receiptDetail;
  173. $data ['memu'] = "receipt";
  174. $data ['staff'] = $this->staff;
  175. $data ['receiptMemu'] = 'saeaBorad';
  176. $data ['verifyId'] = $this->verifyId;
  177. $data ['executeId'] = $this->executeId;
  178. $this->render ( "/admin/saeaBorad", $data );
  179. }
  180. function remitAdd() {
  181. Doo::loadModel ( 'accountItem' );
  182. Doo::loadModel ( 'verify' );
  183. Doo::loadModel ( 'receipt' );
  184. Doo::loadModel ( 'L_category' );
  185. $lCategory = new L_category ();
  186. $receipt = new receipt ();
  187. $verify = new verify ();
  188. $accountItem = new accountItem ();
  189. Doo::loadModel ( "role" );
  190. $role = new role ();
  191. $acItem = $accountItem->find ( array (
  192. 'asArray' => true
  193. ) );
  194. $veList = $verify->find ( array (
  195. 'asArray' => true
  196. ) );
  197. foreach ( $veList as $key => $value ) {
  198. $v = json_decode ( $value ['staff'] );
  199. $list = array ();
  200. foreach ( $v as $n => $m ) {
  201. if ($m ['1'] == 'ROLE') {
  202. $roleInfo = $role->getOne ( array (
  203. 'where' => 'rid=' . $m [0],
  204. 'asArray' => true
  205. ) );
  206. $v [$n] [1] = $roleInfo ['name'];
  207. array_push ( $list, $roleInfo ['name'] );
  208. } else {
  209. array_push ( $list, $v [$n] [1] );
  210. }
  211. }
  212. $veList [$key] ['staff'] = implode ( '>', $list );
  213. }
  214. $data ['category'] = $lCategory->find ( array (
  215. 'asArray' => true
  216. ) );
  217. $data ['veList'] = $veList;
  218. $data ['acItem'] = $acItem;
  219. $data ['memu'] = "receipt";
  220. $data ['staff'] = $this->staff;
  221. $data ['receiptMemu'] = 'saeaBorad';
  222. $data ['verifyId'] = $this->verifyId;
  223. $data ['executeId'] = $this->executeId;
  224. $this->render ( "/admin/remitAdd", $data );
  225. }
  226. function remitAddDo() {
  227. $agency = $this->get_args ( 'agency' );
  228. $travel = $this->get_args ( 'travel' );
  229. $train = $this->get_args ( 'train' );
  230. $other = $this->get_args ( 'other' );
  231. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  232. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  233. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  234. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  235. // print_r($agency);die;
  236. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  237. Doo::loadModel ( 'receipt' );
  238. Doo::loadModel ( 'receiptDetail' );
  239. Doo::loadModel ( 'accountItem' );
  240. $accountItem = new accountItem ();
  241. $receipt = new receipt ();
  242. Doo::loadModel ( 'enclosur' );
  243. Doo::loadModel ( 'execute' );
  244. $execute = new execute ();
  245. $executeDetail = $execute->getOne ( array (
  246. 'where' => 'mold="对公汇款执行人"',
  247. 'asArray' => true
  248. ) );
  249. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  250. $aItem = $accountItem->find ( array (
  251. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  252. 'asArray' => true
  253. ) );
  254. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  255. $ag = $tr = $ta = $ot = 0;
  256. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  257. foreach ( $aItem as $key => $value ) {
  258. if ($value ['category'] == $this->AGENCY) {
  259. if (isset ( $agency [$ag] )) {
  260. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  261. array_push ( $accountJson [$this->AGENCY], array (
  262. 'aid' => $value ['aid'],
  263. 'name' => $value ['name'],
  264. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  265. ) );
  266. $sum += $agency [$ag];
  267. $agencySum += $agency [$ag];
  268. }
  269. }
  270. $ag ++;
  271. }
  272. }
  273. $accountJson ['cSum'] = array (
  274. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  275. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  276. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  277. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  278. );
  279. // 报销单
  280. $receipt->accountItem = json_encode ( $accountJson );
  281. $receipt->staff = $this->staff [0] ['sid'];
  282. $receipt->sum = number_format ( $sum, 2, '.', '' );
  283. $receipt->date = date ( "Y-m-d" );
  284. $receipt->cid = $cid;
  285. $receipt->status = 5;
  286. $receipt->Rtype = 2;
  287. // 修改审批流程加入角色
  288. $receipt->verify = $verify;
  289. $receipt->executeCopy = $executeDetail ['staff'];
  290. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  291. $receipt->explanation = $explanation;
  292. $rid = $receipt->insert ();
  293. // 附件
  294. if (! empty ( $enclosurName )) {
  295. $enclosurArray = explode ( '-', $enclosurName );
  296. foreach ( $enclosurArray as $value ) {
  297. $enclosur = new enclosur ();
  298. $enclosur->name = $value;
  299. $enclosur->rid = $rid;
  300. $enclosur->insert ();
  301. }
  302. // print_r($enclosurArray);die;
  303. }
  304. // 报销详情
  305. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  306. $receiptDetail = new receiptDetail ();
  307. $receiptDetail->staff = $this->staff [0] ['sid'];
  308. $receiptDetail->item = $value ['name'];
  309. $receiptDetail->itemCategory = $this->AGENCY;
  310. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  311. $receiptDetail->date = date ( "Y-m-d" );
  312. $receiptDetail->cid = $cid;
  313. $receiptDetail->rid = $rid;
  314. $receiptDetail->status = 4;
  315. $receiptDetail->insert ();
  316. }
  317. }
  318. return "/saeaBorad";
  319. }
  320. function remitEdit() {
  321. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  322. // echo $rid;
  323. Doo::loadModel ( 'accountItem' );
  324. Doo::loadModel ( 'verify' );
  325. Doo::loadModel ( 'receipt' );
  326. $receipt = new receipt ();
  327. $verify = new verify ();
  328. $accountItem = new accountItem ();
  329. Doo::loadModel ( 'L_category' );
  330. $lCategory = new L_category ();
  331. Doo::loadModel ( "role" );
  332. $role = new role ();
  333. $receiptDetail = $receipt->getOne ( array (
  334. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  335. 'asArray' => true
  336. ) );
  337. if (empty ( $receiptDetail ))
  338. return "/saeaCreate";
  339. $acItem = $accountItem->find ( array (
  340. 'asArray' => true
  341. ) );
  342. $veList = $verify->find ( array (
  343. 'asArray' => true
  344. ) );
  345. foreach ( $veList as $key => $value ) {
  346. $v = json_decode ( $value ['staff'] );
  347. $list = array ();
  348. foreach ( $v as $n => $m ) {
  349. if ($m ['1'] == 'ROLE') {
  350. $roleInfo = $role->getOne ( array (
  351. 'where' => 'rid=' . $m [0],
  352. 'asArray' => true
  353. ) );
  354. $v [$n] [1] = $roleInfo ['name'];
  355. array_push ( $list, $roleInfo ['name'] );
  356. } else {
  357. array_push ( $list, $v [$n] [1] );
  358. }
  359. }
  360. $veList [$key] ['staff'] = implode ( '>', $list );
  361. }
  362. // 配置编辑信息
  363. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  364. foreach ( $acItem as $key => $value ) {
  365. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  366. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  367. $acItem [$key] ['price'] = $v ['price'];
  368. }
  369. }
  370. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  371. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  372. $acItem [$key] ['price'] = $v ['price'];
  373. }
  374. }
  375. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  376. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  377. $acItem [$key] ['price'] = $v ['price'];
  378. }
  379. }
  380. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  381. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  382. $acItem [$key] ['price'] = $v ['price'];
  383. }
  384. }
  385. }
  386. $data ['category'] = $lCategory->find ( array (
  387. 'asArray' => true
  388. ) );
  389. $data ['cSum'] = $accountItemList ['cSum'];
  390. $data ['sum'] = $receiptDetail ['sum'];
  391. $data ['receiptDetail'] = $receiptDetail;
  392. $data ['veList'] = $veList;
  393. $data ['acItem'] = $acItem;
  394. $data ['memu'] = "receipt";
  395. $data ['staff'] = $this->staff;
  396. $data ['receiptMemu'] = 'saeaBorad';
  397. $data ['verify'] = $receiptDetail ['verify'];
  398. $data ['verifyId'] = $this->verifyId;
  399. $data ['executeId'] = $this->executeId;
  400. $data ['rid'] = $rid;
  401. $this->render ( "/admin/remitEdit", $data );
  402. }
  403. function remitEdiDo() {
  404. $agency = $this->get_args ( 'agency' );
  405. $travel = $this->get_args ( 'travel' );
  406. $train = $this->get_args ( 'train' );
  407. $other = $this->get_args ( 'other' );
  408. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  409. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  410. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  411. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  412. if (! empty ( $explanation )) {
  413. Doo::loadModel ( 'receipt' );
  414. Doo::loadModel ( 'receiptDetail' );
  415. Doo::loadModel ( 'accountItem' );
  416. $accountItem = new accountItem ();
  417. $receipt = new receipt ();
  418. Doo::loadModel ( 'execute' );
  419. $execute = new execute ();
  420. $executeDetail = $execute->getOne ( array (
  421. 'where' => 'mold="对公汇款执行人"',
  422. 'asArray' => true
  423. ) );
  424. $receiptDetail = $receipt->getOne ( array (
  425. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  426. 'asArray' => true
  427. ) );
  428. if (empty ( $receiptDetail ))
  429. return "/saeaBorad";
  430. $aItem = $accountItem->find ( array (
  431. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  432. 'asArray' => true
  433. ) );
  434. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  435. $ag = $tr = $ta = $ot = 0;
  436. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  437. foreach ( $aItem as $key => $value ) {
  438. if ($value ['category'] == $this->AGENCY) {
  439. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  440. array_push ( $accountJson [$this->AGENCY], array (
  441. 'aid' => $value ['aid'],
  442. 'name' => $value ['name'],
  443. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  444. ) );
  445. $sum += $agency [$ag];
  446. $agencySum += $agency [$ag];
  447. }
  448. $ag ++;
  449. }
  450. }
  451. $accountJson ['cSum'] = array (
  452. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  453. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  454. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  455. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  456. );
  457. // 报销单
  458. $rid = $receipt->rid = $receiptDetail ['rid'];
  459. $receipt->accountItem = json_encode ( $accountJson );
  460. $receipt->staff = $this->staff [0] ['sid'];
  461. $receipt->sum = number_format ( $sum, 2, '.', '' );
  462. $receipt->date = date ( "Y-m-d" );
  463. $receipt->cid = $cid;
  464. if ($receiptDetail ['Rtype'] == 1)
  465. $receipt->status = 7;
  466. else
  467. $receipt->status = 5;
  468. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  469. $receipt->verify = $verify;
  470. $receipt->executeCopy = $executeDetail ['staff'];
  471. $receipt->explanation = $explanation;
  472. $receipt->update ();
  473. $receiptDetail = new receiptDetail ();
  474. $receiptDetail->delete ( array (
  475. 'where' => 'rid=' . $rid
  476. ) );
  477. // 报销详情
  478. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  479. $receiptDetail = new receiptDetail ();
  480. $receiptDetail->staff = $this->staff [0] ['sid'];
  481. $receiptDetail->item = $value ['name'];
  482. $receiptDetail->itemCategory = $this->AGENCY;
  483. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  484. $receiptDetail->date = date ( "Y-m-d" );
  485. $receiptDetail->cid = $cid;
  486. $receiptDetail->rid = $rid;
  487. $receiptDetail->status = 4;
  488. $receiptDetail->insert ();
  489. }
  490. // return "/referReceipt/".$rid;
  491. }
  492. return "/saeaBorad";
  493. }
  494. function remitApproval() {
  495. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  496. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  497. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  498. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  499. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  500. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  501. if (empty ( $status ))
  502. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  503. $vidList = array ();
  504. $button = 0;
  505. Doo::loadModel ( 'verify' );
  506. Doo::loadModel ( 'receipt' );
  507. Doo::loadModel ( 'staff' );
  508. $staff = new staff ();
  509. $receipt = new receipt ();
  510. $verify = new verify ();
  511. Doo::loadModel ( 'L_category' );
  512. $Lcategory = new L_category ();
  513. Doo::loadModel ( 'enclosur' );
  514. $enclosur = new enclosur ();
  515. // user verify ID
  516. $verifyDetail = $verify->find ( array (
  517. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  518. 'asArray' => true
  519. ) );
  520. foreach ( $verifyDetail as $key => $value ) {
  521. array_push ( $vidList, $value ['vid'] );
  522. }
  523. $vid = implode ( ",", $vidList );
  524. if (empty ( $verifyDetail ))
  525. $vid = 0;
  526. $categoryList = $Lcategory->find ( array (
  527. 'asArray' => true
  528. ) );
  529. $staffList = $staff->find ( array (
  530. 'where' => 'cid=' . $cid,
  531. 'asArray' => true
  532. ) );
  533. $ap = "";
  534. if ($status == 4) {
  535. $ap = 4;
  536. $status = 2;
  537. }
  538. // get Receipt By verifyID status 2
  539. $receiptList = $receipt->find ( array (
  540. 'where' => 'rid =' . $rid.' and status=2',
  541. 'desc' => 'rid',
  542. 'asArray' => true
  543. ) );
  544. if(empty($receiptList)){
  545. die('illegal request');
  546. }
  547. $Locate = 0;
  548. $roleId = 0;
  549. if ($ap == 4)
  550. $status = 4;
  551. foreach ( $receiptList as $key => $value ) {
  552. $receiptList [$key] ['Locate'] = $Locate;
  553. $Locate ++;
  554. $receiptList [$key] ['reviseDetail'] = array ();
  555. if (! empty ( $value ['reviseDetail'] ))
  556. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  557. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  558. $categoryDetil = $Lcategory->getOne ( array (
  559. 'where' => 'cid=' . $value ['cid'],
  560. 'asArray' => true
  561. ) );
  562. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  563. // 检测编辑状态
  564. $verifyList = $verify->getOne ( array (
  565. 'where' => 'vid=' . $value ['verify'],
  566. 'asArray' => true
  567. ) );
  568. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  569. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  570. Doo::loadModel ( 'role' );
  571. $role = new role ();
  572. // print_r($verifyList);
  573. $flag = true;
  574. $roleKey = 0;
  575. $endStaffArray = array ();
  576. $roleArrayCopy = array ();
  577. foreach ( $verifyList as $k => $v ) {
  578. // init verifyStaff
  579. if ($v [1] == 'ROLE') {
  580. if (! empty ( $verifyStaff )) {
  581. $endStaffArray = end ( $verifyStaff );
  582. if ($v [0] == $endStaffArray ['nextStaff']) {
  583. $roleId = $v [0];
  584. }
  585. }
  586. $roleVerify = json_decode ( $v [3], true );
  587. $roleKey = $k;
  588. $roleArray = array ();
  589. $rolename = $role->getOne ( array (
  590. 'where' => 'rid=' . $v [0],
  591. 'asArray' => true
  592. ) );
  593. foreach ( $roleVerify as $o => $p ) {
  594. $staffID = explode ( '_', $p );
  595. $staffInfo = $staff->getOne ( array (
  596. 'where' => 'sid=' . $staffID [0],
  597. 'asArray' => true
  598. ) );
  599. // print_r($staffID);
  600. $exp = array (
  601. 0 => $staffInfo ['sid'],
  602. 1 => $staffID [1],
  603. 2 => $staffInfo ['avatar'],
  604. 'date' => '',
  605. 'date' => '',
  606. 'opinion' => '',
  607. 'status' => '',
  608. 'rolename' => $rolename ['name']
  609. );
  610. array_push ( $roleArray, $exp );
  611. }
  612. $roleArrayCopy [$v [0]] = $roleArray;
  613. // $verifyList[$k]['roleArray']=$roleArray;
  614. }
  615. // print_r($roleArray);
  616. $verifyList [$k] ['date'] = "";
  617. $verifyList [$k] ['opinion'] = "";
  618. $verifyList [$k] ['status'] = "";
  619. if (empty ( $verifyStaff )) {
  620. $verifyList [$k] ['date'] = "";
  621. $verifyList [$k] ['opinion'] = "";
  622. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  623. $verifyList [$k] ['status'] = 4;
  624. $button = 4;
  625. $flag = false;
  626. }
  627. } else {
  628. foreach ( $verifyStaff as $m => $u ) {
  629. if ($v [0] == $m) {
  630. $verifyList [$k] ['date'] = $u ['date'];
  631. $verifyList [$k] ['opinion'] = $u ['opinion'];
  632. $verifyList [$k] ['status'] = $u ['status'];
  633. $flag = false;
  634. break;
  635. }
  636. }
  637. $endStaffArray = end ( $verifyStaff );
  638. if (isset ( $endStaffArray ['ROLE'] )) {
  639. } else {
  640. $endKey = key ( $verifyStaff );
  641. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  642. $button = 4;
  643. $verifyList [$k] ['status'] = 4;
  644. }
  645. }
  646. }
  647. }
  648. $rolename ['name'] = '';
  649. if (! empty ( $roleId )) {
  650. Doo::loadModel ( 'role' );
  651. $role = new role ();
  652. $rolename = $role->getOne ( array (
  653. 'where' => 'rid=' . $roleId,
  654. 'asArray' => true
  655. ) );
  656. }
  657. if (! empty ( $verifyStaff ))
  658. $endStaffArray = end ( $verifyStaff );
  659. $KOP = false;
  660. foreach ( $roleArrayCopy as $P => $A ) {
  661. foreach ( $A as $MKI => $AVL ) {
  662. if (! empty ( $verifyStaff )) {
  663. // &&$rolename['rid']==$endStaffArray['nextStaff']
  664. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  665. $button = 4;
  666. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  667. }
  668. foreach ( $verifyStaff as $m => $u ) {
  669. $AVLFK = $AVL [0] . '_R';
  670. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  671. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  672. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  673. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  674. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  675. break;
  676. }
  677. }
  678. } else {
  679. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  680. $button = 4;
  681. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  682. }
  683. }
  684. // $roleArray[$MKI]['rolename']=$rolename['name'];
  685. $KOP = true;
  686. }
  687. }
  688. foreach ( $roleArrayCopy as $k => $v ) {
  689. foreach ( $verifyList as $m => $n ) {
  690. if ($n [0] == $k) {
  691. array_splice ( $verifyList, $m, 1, $v );
  692. }
  693. }
  694. }
  695. $receiptList [$key] ['verifyList'] = $verifyList;
  696. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  697. 'where' => 'sid=' . $value ['staff'],
  698. 'asArray' => true
  699. ) );
  700. $receiptList [$key] ['button'] = $button;
  701. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  702. }
  703. $mothHtml = "";
  704. for($i = 1; $i <= 12; $i ++) {
  705. if ($month == $i)
  706. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  707. else
  708. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  709. }
  710. // 获取审批日志
  711. Doo::loadModel ( 'receiptLog' );
  712. $receiptLog = new receiptLog ();
  713. $rlList = array ();
  714. $rlInfo = $receiptLog->getOne ( array (
  715. 'where' => 'rid=' . $rid . ' and status=4',
  716. 'asArray' => true
  717. ) );
  718. $tijdate = $receiptLog->getOne ( array (
  719. 'where' => 'rid=' . $rid . ' and status=2',
  720. 'asc' => 'rlid',
  721. 'asArray' => true
  722. ) );
  723. if (! empty ( $rlInfo )) {
  724. $rlList = $receiptLog->find ( array (
  725. 'where' => 'rid=' . $rid,
  726. 'asc' => 'rlid',
  727. 'asArray' => true
  728. ) );
  729. }
  730. $receiptList [0] ['rlList'] = $rlList;
  731. $enclosurList = $enclosur->find ( array (
  732. 'where' => 'rid=' . $rid,
  733. 'asArray' => true
  734. ) );
  735. $enclosurHtml = '';
  736. foreach ( $enclosurList as $value ) {
  737. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  738. }
  739. // print_r($receiptList);
  740. $data ['enclosurHtml'] = $enclosurHtml;
  741. $data ['rolename'] = $rolename ['name'];
  742. $data ['datetij'] = $tijdate ['date'];
  743. $data ['mothHtml'] = $mothHtml;
  744. $data ['rid'] = $rid;
  745. $data ['receiptList'] = $receiptList;
  746. $data ['receiptApprovalCount'] = count ( $receiptList );
  747. $data ['status'] = $status;
  748. $data ['year'] = $year;
  749. $data ['categoryList'] = $categoryList;
  750. $data ['staffList'] = $staffList;
  751. $data ['cid'] = $cid;
  752. $data ['sid'] = $sid;
  753. $data ['ap'] = $ap;
  754. $data ['memu'] = "receipt";
  755. $data ['staff'] = $this->staff;
  756. $data ['receiptMemu'] = 'approvalExpenses';
  757. $data ['verifyId'] = $this->verifyId;
  758. $data ['executeId'] = $this->executeId;
  759. $this->render ( "/admin/remitApproval", $data );
  760. }
  761. function saeaLoanAdd() {
  762. Doo::loadModel ( 'verify' );
  763. $verify = new verify ();
  764. Doo::loadModel ( "role" );
  765. $role = new role ();
  766. Doo::loadModel ( 'L_category' );
  767. $lCategory = new L_category ();
  768. $veList = $verify->find ( array (
  769. 'asArray' => true
  770. ) );
  771. foreach ( $veList as $key => $value ) {
  772. $v = json_decode ( $value ['staff'] );
  773. $list = array ();
  774. foreach ( $v as $n => $m ) {
  775. if ($m ['1'] == 'ROLE') {
  776. $roleInfo = $role->getOne ( array (
  777. 'where' => 'rid=' . $m [0],
  778. 'asArray' => true
  779. ) );
  780. $v [$n] [1] = $roleInfo ['name'];
  781. array_push ( $list, $roleInfo ['name'] );
  782. } else {
  783. array_push ( $list, $v [$n] [1] );
  784. }
  785. }
  786. $veList [$key] ['staff'] = implode ( '>', $list );
  787. }
  788. $data ['category'] = $lCategory->find ( array (
  789. 'asArray' => true
  790. ) );
  791. $data ['veList'] = $veList;
  792. $data ['memu'] = "receipt";
  793. $data ['staff'] = $this->staff;
  794. $data ['receiptMemu'] = 'saeaBorad';
  795. $data ['verifyId'] = $this->verifyId;
  796. $data ['executeId'] = $this->executeId;
  797. $this->render ( "/admin/saeaLoanAdd", $data );
  798. }
  799. function saeaLoanAddDo() {
  800. $agency = $this->get_args ( 'agency' );
  801. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  802. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  803. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  804. // die;
  805. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  806. Doo::loadModel ( 'receipt' );
  807. Doo::loadModel ( 'receiptDetail' );
  808. Doo::loadModel ( 'accountItem' );
  809. $accountItem = new accountItem ();
  810. $receipt = new receipt ();
  811. Doo::loadModel ( 'loanReceipt' );
  812. $loanReceipt = new loanReceipt ();
  813. Doo::loadModel ( 'execute' );
  814. $execute = new execute ();
  815. Doo::loadModel ( 'enclosur' );
  816. $executeDetail = $execute->getOne ( array (
  817. 'where' => 'mold="借款执行人"',
  818. 'asArray' => true
  819. ) );
  820. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  821. // if(!empty($receiptDetail))
  822. // return "/referReceipt/".$receiptDetail['rid'];
  823. $aItem = $accountItem->find ( array (
  824. 'asArray' => true
  825. ) );
  826. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  827. $ag = $tr = $ta = $ot = 0;
  828. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  829. array_push ( $accountJson ['借款费用'], array (
  830. 'aid' => 0,
  831. 'name' => '申请金额',
  832. 'price' => number_format ( $agency, 2, '.', '' )
  833. ) );
  834. $sum += $agency;
  835. $agencySum += $agency;
  836. $accountJson ['cSum'] = array (
  837. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  838. 'agencySum' => number_format ( 0, 2, '.', '' ),
  839. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  840. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  841. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  842. );
  843. // 借款数据备份
  844. $loanReceipt->loanItem = json_encode ( $accountJson );
  845. $loanReceipt->staff = $this->staff [0] ['sid'];
  846. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  847. $loanReceipt->date = date ( "Y-m-d" );
  848. $loanReceipt->cid = $cid;
  849. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  850. $loanReceipt->status = 5;
  851. $loanReceipt->Rtype = 1;
  852. $loanReceipt->verify = $verify;
  853. $receipt->receiptOrder = $receipt->receiptOrder;
  854. $loanReceipt->explanation = $explanation;
  855. $loanRid = $loanReceipt->insert ();
  856. // 报销单
  857. $receipt->loanItem = json_encode ( $accountJson );
  858. $receipt->staff = $this->staff [0] ['sid'];
  859. $receipt->sum = number_format ( $sum, 2, '.', '' );
  860. $receipt->date = date ( "Y-m-d" );
  861. $receipt->cid = $cid;
  862. // 特殊状态
  863. $receipt->status = 5;
  864. $receipt->Rtype = 1;
  865. $receipt->loanRid = $loanRid;
  866. // 修改审批流程加入角色
  867. $receipt->verify = $verify;
  868. $receipt->executeCopy = $executeDetail ['staff'];
  869. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  870. $receipt->explanation = $explanation;
  871. $rid = $receipt->insert ();
  872. // 执行数据备份
  873. // $executeCopy->rid=$rid;
  874. // $executeCopy->staff=$executeDetail['staff'];
  875. // $executeCopy->eid=$executeDetail['eid'];
  876. // $ecid=$executeCopy->insert();
  877. }
  878. return "/saeaBorad";
  879. }
  880. function saeaLoanEdi() {
  881. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  882. Doo::loadModel ( 'verify' );
  883. $verify = new verify ();
  884. Doo::loadModel ( "role" );
  885. $role = new role ();
  886. Doo::loadModel ( 'L_category' );
  887. $lCategory = new L_category ();
  888. Doo::loadModel ( 'receipt' );
  889. $receipt = new receipt ();
  890. $receiptInfo = $receipt->getOne ( array (
  891. 'where' => 'rid=' . $rid,
  892. 'asArray' => true
  893. ) );
  894. $veList = $verify->find ( array (
  895. 'asArray' => true
  896. ) );
  897. foreach ( $veList as $key => $value ) {
  898. $v = json_decode ( $value ['staff'] );
  899. $list = array ();
  900. foreach ( $v as $n => $m ) {
  901. if ($m ['1'] == 'ROLE') {
  902. $roleInfo = $role->getOne ( array (
  903. 'where' => 'rid=' . $m [0],
  904. 'asArray' => true
  905. ) );
  906. $v [$n] [1] = $roleInfo ['name'];
  907. array_push ( $list, $roleInfo ['name'] );
  908. } else {
  909. array_push ( $list, $v [$n] [1] );
  910. }
  911. }
  912. $veList [$key] ['staff'] = implode ( '>', $list );
  913. }
  914. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  915. $data ['receiptInfo'] = $receiptInfo;
  916. $data ['category'] = $lCategory->find ( array (
  917. 'asArray' => true
  918. ) );
  919. $data ['veList'] = $veList;
  920. $data ['memu'] = "receipt";
  921. $data ['staff'] = $this->staff;
  922. $data ['receiptMemu'] = 'saeaBorad';
  923. $data ['verifyId'] = $this->verifyId;
  924. $data ['executeId'] = $this->executeId;
  925. $this->render ( "/admin/saeaLoanEdi", $data );
  926. }
  927. function saeaLoanEdiDo() {
  928. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  929. $agency = $this->get_args ( 'agency' );
  930. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  931. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  932. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  933. // die;
  934. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )) {
  935. Doo::loadModel ( 'receipt' );
  936. Doo::loadModel ( 'receiptDetail' );
  937. Doo::loadModel ( 'accountItem' );
  938. $accountItem = new accountItem ();
  939. $receipt = new receipt ();
  940. Doo::loadModel ( 'loanReceipt' );
  941. $loanReceipt = new loanReceipt ();
  942. Doo::loadModel ( 'enclosur' );
  943. Doo::loadModel ( 'execute' );
  944. $execute = new execute ();
  945. $executeDetail = $execute->getOne ( array (
  946. 'where' => 'mold="借款执行人"',
  947. 'asArray' => true
  948. ) );
  949. $receiptDetail = $receipt->getOne ( array (
  950. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  951. 'asArray' => true
  952. ) );
  953. if (empty ( $receiptDetail ))
  954. die ( '参数错误' );
  955. $aItem = $accountItem->find ( array (
  956. 'asArray' => true
  957. ) );
  958. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  959. $ag = $tr = $ta = $ot = 0;
  960. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  961. array_push ( $accountJson ['借款费用'], array (
  962. 'aid' => 0,
  963. 'name' => '申请金额',
  964. 'price' => number_format ( $agency, 2, '.', '' )
  965. ) );
  966. $sum += $agency;
  967. $agencySum += $agency;
  968. $accountJson ['cSum'] = array (
  969. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  970. 'agencySum' => number_format ( 0, 2, '.', '' ),
  971. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  972. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  973. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  974. );
  975. // 报销单
  976. $receipt->loanItem = json_encode ( $accountJson );
  977. $receipt->sum = number_format ( $sum, 2, '.', '' );
  978. $receipt->cid = $cid;
  979. // 特殊状态
  980. // 修改审批流程加入角色
  981. if ($receiptDetail ['status'] != 4)
  982. $receipt->verify = $verify;
  983. $receipt->explanation = $explanation;
  984. $receipt->update ( array (
  985. 'where' => 'rid=' . $rid
  986. ) );
  987. // 借款数据更新
  988. $loanReceipt->loanItem = json_encode ( $accountJson );
  989. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  990. $loanReceipt->cid = $cid;
  991. if ($receiptDetail ['status'] != 4)
  992. $loanReceipt->verify = $verify;
  993. $loanReceipt->explanation = $explanation;
  994. $receipt->executeCopy = $executeDetail ['staff'];
  995. $loanReceipt->update ( array (
  996. 'where' => 'rid=' . $receiptDetail ['loanRid']
  997. ) );
  998. }
  999. return "/saeaBorad";
  1000. }
  1001. function saeaLoanReceiptAdd() {
  1002. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1003. Doo::loadModel ( 'receipt' );
  1004. $receipt = new receipt ();
  1005. Doo::loadModel ( 'loanReceipt' );
  1006. $loanReceipt = new loanReceipt ();
  1007. Doo::loadModel ( 'L_category' );
  1008. $Lcategory = new L_category ();
  1009. Doo::loadModel ( 'verify' );
  1010. Doo::loadModel ( 'statistics' );
  1011. $statistics = new statistics ();
  1012. $verify = new verify ();
  1013. Doo::loadModel ( 'staff' );
  1014. $staff = new staff ();
  1015. $receiptDe = $receipt->getOne ( array (
  1016. 'where' => 'rid=' . $rid,
  1017. 'desc' => 'rid',
  1018. 'asArray' => true
  1019. ) );
  1020. $receiptList = $loanReceipt->find ( array (
  1021. 'where' => 'rid=' . $receiptDe ['loanRid'],
  1022. 'desc' => 'rid',
  1023. 'asArray' => true
  1024. ) );
  1025. $Locate = 0;
  1026. $roleId = 0;
  1027. $button = 0;
  1028. foreach ( $receiptList as $key => $value ) {
  1029. $receiptList [$key] ['Locate'] = $Locate;
  1030. $Locate ++;
  1031. $receiptList [$key] ['reviseDetail'] = array ();
  1032. if (! empty ( $value ['reviseDetail'] ))
  1033. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1034. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1035. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1036. $categoryDetil = $Lcategory->getOne ( array (
  1037. 'where' => 'cid=' . $value ['cid'],
  1038. 'asArray' => true
  1039. ) );
  1040. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1041. // 检测编辑状态
  1042. $verifyList = $verify->getOne ( array (
  1043. 'where' => 'vid=' . $value ['verify'],
  1044. 'asArray' => true
  1045. ) );
  1046. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1047. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1048. Doo::loadModel ( 'role' );
  1049. $role = new role ();
  1050. $flag = true;
  1051. $roleKey = 0;
  1052. $endStaffArray = array ();
  1053. $roleArrayCopy = array ();
  1054. foreach ( $verifyList as $k => $v ) {
  1055. // init verifyStaff
  1056. if ($v [1] == 'ROLE') {
  1057. if (! empty ( $verifyStaff )) {
  1058. $endStaffArray = end ( $verifyStaff );
  1059. // if ($v[0]==$endStaffArray['nextStaff']){
  1060. // $roleId=$v[0];
  1061. // }
  1062. }
  1063. $roleVerify = json_decode ( $v [3], true );
  1064. $roleKey = $k;
  1065. $roleArray = array ();
  1066. $rolename = $role->getOne ( array (
  1067. 'where' => 'rid=' . $v [0],
  1068. 'asArray' => true
  1069. ) );
  1070. foreach ( $roleVerify as $o => $p ) {
  1071. $staffID = explode ( '_', $p );
  1072. $staffInfo = $staff->getOne ( array (
  1073. 'where' => 'sid=' . $staffID [0],
  1074. 'asArray' => true
  1075. ) );
  1076. // print_r($staffID);
  1077. $exp = array (
  1078. 0 => $staffInfo ['sid'],
  1079. 1 => $staffID [1],
  1080. 2 => $staffInfo ['avatar'],
  1081. 'date' => '',
  1082. 'date' => '',
  1083. 'opinion' => '',
  1084. 'status' => '',
  1085. 'rolename' => $rolename ['name']
  1086. );
  1087. array_push ( $roleArray, $exp );
  1088. }
  1089. $roleArrayCopy [$v [0]] = $roleArray;
  1090. // $verifyList[$k]['roleArray']=$roleArray;
  1091. }
  1092. $verifyList [$k] ['date'] = "";
  1093. $verifyList [$k] ['opinion'] = "";
  1094. $verifyList [$k] ['status'] = "";
  1095. if (empty ( $verifyStaff )) {
  1096. $verifyList [$k] ['date'] = "";
  1097. $verifyList [$k] ['opinion'] = "";
  1098. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1099. $verifyList [$k] ['status'] = 4;
  1100. $flag = false;
  1101. }
  1102. } else {
  1103. foreach ( $verifyStaff as $m => $u ) {
  1104. if ($v [0] == $m) {
  1105. $verifyList [$k] ['date'] = $u ['date'];
  1106. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1107. $verifyList [$k] ['status'] = $u ['status'];
  1108. $flag = false;
  1109. break;
  1110. }
  1111. }
  1112. $endStaffArray = end ( $verifyStaff );
  1113. if (isset ( $endStaffArray ['ROLE'] )) {
  1114. } else {
  1115. // $endKey=key($verifyStaff);
  1116. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1117. // $button=4;
  1118. // $verifyList[$k]['status']=4;
  1119. // }
  1120. }
  1121. }
  1122. }
  1123. $rolename ['name'] = '';
  1124. if (! empty ( $roleId )) {
  1125. Doo::loadModel ( 'role' );
  1126. $role = new role ();
  1127. $rolename = $role->getOne ( array (
  1128. 'where' => 'rid=' . $roleId,
  1129. 'asArray' => true
  1130. ) );
  1131. }
  1132. if (! empty ( $verifyStaff ))
  1133. $endStaffArray = end ( $verifyStaff );
  1134. $KOP = false;
  1135. foreach ( $roleArrayCopy as $P => $A ) {
  1136. foreach ( $A as $MKI => $AVL ) {
  1137. if (! empty ( $verifyStaff )) {
  1138. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1139. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1140. $button = 4;
  1141. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1142. }
  1143. foreach ( $verifyStaff as $m => $u ) {
  1144. $AVLFK = $AVL [0] . '_R';
  1145. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1146. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1147. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1148. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1149. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1150. break;
  1151. }
  1152. }
  1153. } else {
  1154. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1155. $button = 4;
  1156. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1157. }
  1158. }
  1159. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1160. $KOP = true;
  1161. }
  1162. }
  1163. foreach ( $roleArrayCopy as $k => $v ) {
  1164. foreach ( $verifyList as $m => $n ) {
  1165. if ($n [0] == $k) {
  1166. array_splice ( $verifyList, $m, 1, $v );
  1167. }
  1168. }
  1169. }
  1170. $receiptList [$key] ['verifyList'] = $verifyList;
  1171. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1172. 'where' => 'sid=' . $value ['staff'],
  1173. 'asArray' => true
  1174. ) );
  1175. $receiptList [$key] ['button'] = $button;
  1176. //
  1177. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1178. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1179. }
  1180. $data ['receiptList'] = $receiptList;
  1181. Doo::loadModel ( 'L_category' );
  1182. $lCategory = new L_category ();
  1183. Doo::loadModel ( 'accountItem' );
  1184. $accountItem = new accountItem ();
  1185. $acItem = $accountItem->find ( array (
  1186. 'asArray' => true
  1187. ) );
  1188. $veList = $verify->find ( array (
  1189. 'asArray' => true
  1190. ) );
  1191. foreach ( $veList as $key => $value ) {
  1192. $v = json_decode ( $value ['staff'] );
  1193. $list = array ();
  1194. foreach ( $v as $n => $m ) {
  1195. if ($m ['1'] == 'ROLE') {
  1196. $roleInfo = $role->getOne ( array (
  1197. 'where' => 'rid=' . $m [0],
  1198. 'asArray' => true
  1199. ) );
  1200. $v [$n] [1] = $roleInfo ['name'];
  1201. array_push ( $list, $roleInfo ['name'] );
  1202. } else {
  1203. array_push ( $list, $v [$n] [1] );
  1204. }
  1205. }
  1206. $veList [$key] ['staff'] = implode ( '>', $list );
  1207. }
  1208. $data ['rid'] = $rid;
  1209. $data ['category'] = $lCategory->find ( array (
  1210. 'asArray' => true
  1211. ) );
  1212. $data ['veList'] = $veList;
  1213. $data ['acItem'] = $acItem;
  1214. $data ['memu'] = "receipt";
  1215. $data ['staff'] = $this->staff;
  1216. $data ['receiptMemu'] = 'saeaBorad';
  1217. $data ['verifyId'] = $this->verifyId;
  1218. $data ['executeId'] = $this->executeId;
  1219. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1220. }
  1221. function saeaLoanReceiptAddDo() {
  1222. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1223. $agency = $this->get_args ( 'agency' );
  1224. $travel = $this->get_args ( 'travel' );
  1225. $train = $this->get_args ( 'train' );
  1226. $other = $this->get_args ( 'other' );
  1227. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1228. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1229. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1230. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1231. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )) {
  1232. Doo::loadModel ( 'receipt' );
  1233. Doo::loadModel ( 'receiptDetail' );
  1234. Doo::loadModel ( 'accountItem' );
  1235. $accountItem = new accountItem ();
  1236. $receipt = new receipt ();
  1237. Doo::loadModel ( 'enclosur' );
  1238. Doo::loadModel ( 'execute' );
  1239. $execute = new execute ();
  1240. $executeDetail = $execute->getOne ( array (
  1241. 'where' => 'mold="借款费用执行人"',
  1242. 'asArray' => true
  1243. ) );
  1244. $receiptDet = $receipt->getOne ( array (
  1245. 'where' => 'rid=' . $rid,
  1246. 'asArray' => true
  1247. ) );
  1248. // if(!empty($receiptDetail))
  1249. // return "/referReceipt/".$receiptDetail['rid'];
  1250. $aItem = $accountItem->find ( array (
  1251. 'asArray' => true
  1252. ) );
  1253. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1254. $ag = $tr = $ta = $ot = 0;
  1255. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1256. foreach ( $aItem as $key => $value ) {
  1257. if ($value ['category'] == $this->AGENCY) {
  1258. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1259. array_push ( $accountJson [$this->AGENCY], array (
  1260. 'aid' => $value ['aid'],
  1261. 'name' => $value ['name'],
  1262. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1263. ) );
  1264. $sum += $agency [$ag];
  1265. $agencySum += $agency [$ag];
  1266. }
  1267. $ag ++;
  1268. }
  1269. if ($value ['category'] == $this->TRAVEL) {
  1270. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1271. array_push ( $accountJson [$this->TRAVEL], array (
  1272. 'aid' => $value ['aid'],
  1273. 'name' => $value ['name'],
  1274. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1275. ) );
  1276. $sum += $travel [$tr];
  1277. $travelSum += $travel [$tr];
  1278. }
  1279. $tr ++;
  1280. }
  1281. if ($value ['category'] == $this->TRAIN) {
  1282. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1283. array_push ( $accountJson [$this->TRAIN], array (
  1284. 'aid' => $value ['aid'],
  1285. 'name' => $value ['name'],
  1286. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1287. ) );
  1288. $sum += $train [$ta];
  1289. $trainSum += $train [$ta];
  1290. }
  1291. $ta ++;
  1292. }
  1293. if ($value ['category'] == $this->OTHER) {
  1294. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1295. array_push ( $accountJson [$this->OTHER], array (
  1296. 'aid' => $value ['aid'],
  1297. 'name' => $value ['name'],
  1298. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1299. ) );
  1300. $sum += $other [$ot];
  1301. $otherSum += $other [$ot];
  1302. }
  1303. $ot ++;
  1304. }
  1305. }
  1306. $accountJson ['cSum'] = array (
  1307. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1308. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1309. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1310. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1311. );
  1312. // 报销单
  1313. $receipt->accountItem = json_encode ( $accountJson );
  1314. $receipt->staff = $this->staff [0] ['sid'];
  1315. $receipt->loanSum = $receiptDet ['sum'];
  1316. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1317. $receipt->date = date ( "Y-m-d" );
  1318. $receipt->pastDate = '';
  1319. $receipt->cid = $cid;
  1320. $receipt->status = 7;
  1321. // 修改审批流程加入角色
  1322. $receipt->verify = $verify;
  1323. $receipt->verifyStaff = '';
  1324. $receipt->executeStaff = '';
  1325. $receipt->executeCopy = $executeDetail ['staff'];
  1326. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  1327. $receipt->explanation = $explanation;
  1328. $receipt->update ( array (
  1329. 'where' => 'rid=' . $rid
  1330. ) );
  1331. // 附件
  1332. if (! empty ( $enclosurName )) {
  1333. $enclosurArray = explode ( '-', $enclosurName );
  1334. foreach ( $enclosurArray as $value ) {
  1335. $enclosur = new enclosur ();
  1336. $enclosur->name = $value;
  1337. $enclosur->rid = $rid;
  1338. $enclosur->insert ();
  1339. }
  1340. // print_r($enclosurArray);die;
  1341. }
  1342. // 报销详情
  1343. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1344. $receiptDetail = new receiptDetail ();
  1345. $receiptDetail->staff = $this->staff [0] ['sid'];
  1346. $receiptDetail->item = $value ['name'];
  1347. $receiptDetail->itemCategory = $this->AGENCY;
  1348. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1349. $receiptDetail->date = date ( "Y-m-d" );
  1350. $receiptDetail->cid = $cid;
  1351. $receiptDetail->rid = $rid;
  1352. $receiptDetail->status = 4;
  1353. $receiptDetail->insert ();
  1354. }
  1355. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1356. $receiptDetail = new receiptDetail ();
  1357. $receiptDetail->staff = $this->staff [0] ['sid'];
  1358. $receiptDetail->item = $value ['name'];
  1359. $receiptDetail->itemCategory = $this->TRAVEL;
  1360. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1361. $receiptDetail->date = date ( "Y-m-d" );
  1362. $receiptDetail->cid = $cid;
  1363. $receiptDetail->rid = $rid;
  1364. $receiptDetail->status = 4;
  1365. $receiptDetail->insert ();
  1366. }
  1367. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1368. $receiptDetail = new receiptDetail ();
  1369. $receiptDetail->staff = $this->staff [0] ['sid'];
  1370. $receiptDetail->item = $value ['name'];
  1371. $receiptDetail->itemCategory = $this->TRAIN;
  1372. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1373. $receiptDetail->date = date ( "Y-m-d" );
  1374. $receiptDetail->cid = $cid;
  1375. $receiptDetail->rid = $rid;
  1376. $receiptDetail->status = 4;
  1377. $receiptDetail->insert ();
  1378. }
  1379. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1380. $receiptDetail = new receiptDetail ();
  1381. $receiptDetail->staff = $this->staff [0] ['sid'];
  1382. $receiptDetail->item = $value ['name'];
  1383. $receiptDetail->itemCategory = $this->OTHER;
  1384. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1385. $receiptDetail->date = date ( "Y-m-d" );
  1386. $receiptDetail->cid = $cid;
  1387. $receiptDetail->rid = $rid;
  1388. $receiptDetail->status = 4;
  1389. $receiptDetail->insert ();
  1390. }
  1391. return "/saeaBorad";
  1392. }
  1393. return "/saeaLoanReceiptAdd/" . $rid;
  1394. }
  1395. function saeaLoanReceiptEdi() {
  1396. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1397. // echo $rid;
  1398. Doo::loadModel ( 'accountItem' );
  1399. Doo::loadModel ( 'verify' );
  1400. Doo::loadModel ( 'receipt' );
  1401. $receipt = new receipt ();
  1402. $verify = new verify ();
  1403. $accountItem = new accountItem ();
  1404. Doo::loadModel ( 'L_category' );
  1405. $Lcategory = new L_category ();
  1406. Doo::loadModel ( "role" );
  1407. $role = new role ();
  1408. Doo::loadModel ( 'loanReceipt' );
  1409. $loanReceipt = new loanReceipt ();
  1410. Doo::loadModel ( 'staff' );
  1411. $staff = new staff ();
  1412. $receiptDetail = $receipt->getOne ( array (
  1413. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  1414. 'asArray' => true
  1415. ) );
  1416. if (empty ( $receiptDetail ))
  1417. return "/saeaBorad";
  1418. $receiptList = $loanReceipt->find ( array (
  1419. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1420. 'desc' => 'rid',
  1421. 'asArray' => true
  1422. ) );
  1423. $Locate = 0;
  1424. $roleId = 0;
  1425. $button = 0;
  1426. foreach ( $receiptList as $key => $value ) {
  1427. $receiptList [$key] ['Locate'] = $Locate;
  1428. $Locate ++;
  1429. $receiptList [$key] ['reviseDetail'] = array ();
  1430. if (! empty ( $value ['reviseDetail'] ))
  1431. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1432. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1433. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1434. $categoryDetil = $Lcategory->getOne ( array (
  1435. 'where' => 'cid=' . $value ['cid'],
  1436. 'asArray' => true
  1437. ) );
  1438. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1439. // 检测编辑状态
  1440. $verifyList = $verify->getOne ( array (
  1441. 'where' => 'vid=' . $value ['verify'],
  1442. 'asArray' => true
  1443. ) );
  1444. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1445. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1446. Doo::loadModel ( 'role' );
  1447. $role = new role ();
  1448. $flag = true;
  1449. $roleKey = 0;
  1450. $endStaffArray = array ();
  1451. $roleArrayCopy = array ();
  1452. foreach ( $verifyList as $k => $v ) {
  1453. // init verifyStaff
  1454. if ($v [1] == 'ROLE') {
  1455. if (! empty ( $verifyStaff )) {
  1456. $endStaffArray = end ( $verifyStaff );
  1457. // if ($v[0]==$endStaffArray['nextStaff']){
  1458. // $roleId=$v[0];
  1459. // }
  1460. }
  1461. $roleVerify = json_decode ( $v [3], true );
  1462. $roleKey = $k;
  1463. $roleArray = array ();
  1464. $rolename = $role->getOne ( array (
  1465. 'where' => 'rid=' . $v [0],
  1466. 'asArray' => true
  1467. ) );
  1468. foreach ( $roleVerify as $o => $p ) {
  1469. $staffID = explode ( '_', $p );
  1470. $staffInfo = $staff->getOne ( array (
  1471. 'where' => 'sid=' . $staffID [0],
  1472. 'asArray' => true
  1473. ) );
  1474. // print_r($staffID);
  1475. $exp = array (
  1476. 0 => $staffInfo ['sid'],
  1477. 1 => $staffID [1],
  1478. 2 => $staffInfo ['avatar'],
  1479. 'date' => '',
  1480. 'date' => '',
  1481. 'opinion' => '',
  1482. 'status' => '',
  1483. 'rolename' => $rolename ['name']
  1484. );
  1485. array_push ( $roleArray, $exp );
  1486. }
  1487. $roleArrayCopy [$v [0]] = $roleArray;
  1488. // $verifyList[$k]['roleArray']=$roleArray;
  1489. }
  1490. $verifyList [$k] ['date'] = "";
  1491. $verifyList [$k] ['opinion'] = "";
  1492. $verifyList [$k] ['status'] = "";
  1493. if (empty ( $verifyStaff )) {
  1494. $verifyList [$k] ['date'] = "";
  1495. $verifyList [$k] ['opinion'] = "";
  1496. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1497. $verifyList [$k] ['status'] = 4;
  1498. $flag = false;
  1499. }
  1500. } else {
  1501. foreach ( $verifyStaff as $m => $u ) {
  1502. if ($v [0] == $m) {
  1503. $verifyList [$k] ['date'] = $u ['date'];
  1504. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1505. $verifyList [$k] ['status'] = $u ['status'];
  1506. $flag = false;
  1507. break;
  1508. }
  1509. }
  1510. $endStaffArray = end ( $verifyStaff );
  1511. if (isset ( $endStaffArray ['ROLE'] )) {
  1512. } else {
  1513. // $endKey=key($verifyStaff);
  1514. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1515. // $button=4;
  1516. // $verifyList[$k]['status']=4;
  1517. // }
  1518. }
  1519. }
  1520. }
  1521. $rolename ['name'] = '';
  1522. if (! empty ( $roleId )) {
  1523. Doo::loadModel ( 'role' );
  1524. $role = new role ();
  1525. $rolename = $role->getOne ( array (
  1526. 'where' => 'rid=' . $roleId,
  1527. 'asArray' => true
  1528. ) );
  1529. }
  1530. if (! empty ( $verifyStaff ))
  1531. $endStaffArray = end ( $verifyStaff );
  1532. $KOP = false;
  1533. foreach ( $roleArrayCopy as $P => $A ) {
  1534. foreach ( $A as $MKI => $AVL ) {
  1535. if (! empty ( $verifyStaff )) {
  1536. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1537. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1538. $button = 4;
  1539. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1540. }
  1541. foreach ( $verifyStaff as $m => $u ) {
  1542. $AVLFK = $AVL [0] . '_R';
  1543. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1544. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1545. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1546. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1547. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1548. break;
  1549. }
  1550. }
  1551. } else {
  1552. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1553. $button = 4;
  1554. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1555. }
  1556. }
  1557. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1558. $KOP = true;
  1559. }
  1560. }
  1561. foreach ( $roleArrayCopy as $k => $v ) {
  1562. foreach ( $verifyList as $m => $n ) {
  1563. if ($n [0] == $k) {
  1564. array_splice ( $verifyList, $m, 1, $v );
  1565. }
  1566. }
  1567. }
  1568. $receiptList [$key] ['verifyList'] = $verifyList;
  1569. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1570. 'where' => 'sid=' . $value ['staff'],
  1571. 'asArray' => true
  1572. ) );
  1573. $receiptList [$key] ['button'] = $button;
  1574. //
  1575. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1576. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1577. }
  1578. $data ['receiptList'] = $receiptList;
  1579. $acItem = $accountItem->find ( array (
  1580. 'asArray' => true
  1581. ) );
  1582. $veList = $verify->find ( array (
  1583. 'asArray' => true
  1584. ) );
  1585. foreach ( $veList as $key => $value ) {
  1586. $v = json_decode ( $value ['staff'] );
  1587. $list = array ();
  1588. foreach ( $v as $n => $m ) {
  1589. if ($m ['1'] == 'ROLE') {
  1590. $roleInfo = $role->getOne ( array (
  1591. 'where' => 'rid=' . $m [0],
  1592. 'asArray' => true
  1593. ) );
  1594. $v [$n] [1] = $roleInfo ['name'];
  1595. array_push ( $list, $roleInfo ['name'] );
  1596. } else {
  1597. array_push ( $list, $v [$n] [1] );
  1598. }
  1599. }
  1600. $veList [$key] ['staff'] = implode ( '>', $list );
  1601. }
  1602. // 配置编辑信息
  1603. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1604. foreach ( $acItem as $key => $value ) {
  1605. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1606. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1607. $acItem [$key] ['price'] = $v ['price'];
  1608. }
  1609. }
  1610. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1611. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1612. $acItem [$key] ['price'] = $v ['price'];
  1613. }
  1614. }
  1615. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1616. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1617. $acItem [$key] ['price'] = $v ['price'];
  1618. }
  1619. }
  1620. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1621. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1622. $acItem [$key] ['price'] = $v ['price'];
  1623. }
  1624. }
  1625. }
  1626. $data ['category'] = $Lcategory->find ( array (
  1627. 'asArray' => true
  1628. ) );
  1629. $data ['cSum'] = $accountItemList ['cSum'];
  1630. $data ['sum'] = $receiptDetail ['sum'];
  1631. $data ['receiptDetail'] = $receiptDetail;
  1632. $data ['veList'] = $veList;
  1633. $data ['acItem'] = $acItem;
  1634. $data ['memu'] = "receipt";
  1635. $data ['staff'] = $this->staff;
  1636. $data ['receiptMemu'] = 'saeaBorad';
  1637. $data ['verify'] = $receiptDetail ['verify'];
  1638. $data ['verifyId'] = $this->verifyId;
  1639. $data ['executeId'] = $this->executeId;
  1640. $data ['rid'] = $rid;
  1641. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  1642. }
  1643. function confirmation() {
  1644. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1645. Doo::loadModel ( 'receipt' );
  1646. Doo::loadModel ( 'receiptDetail' );
  1647. $receipt = new receipt ();
  1648. $receiptDetail = new receiptDetail ();
  1649. Doo::loadModel ( 'statistics' );
  1650. Doo::loadModel ( 'itemStatistics' );
  1651. $statistics = new statistics ();
  1652. $itemStatistics = new itemStatistics ();
  1653. Doo::loadModel ( "verify" );
  1654. $verify = new verify ();
  1655. $receiptDetailList = $receipt->getOne ( array (
  1656. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  1657. 'asArray' => true
  1658. ) );
  1659. if (empty ( $receiptDetailList ))
  1660. return "/saeaBorad";
  1661. $verifyDetail = $verify->getOne ( array (
  1662. 'where' => ' vid =' . $receiptDetailList ['verify'],
  1663. 'asArray' => true
  1664. ) );
  1665. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  1666. if (empty ( $receiptDetailList ['nowStaff'] )) {
  1667. $nowStaff = "";
  1668. $nowStaffList = array ();
  1669. if ($verifyDetail [0] [1] == 'ROLE') {
  1670. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  1671. foreach ( $vStaffString as $key => $value ) {
  1672. $staffK = explode ( "_", $value );
  1673. array_push ( $nowStaffList, $staffK [0] );
  1674. }
  1675. $nowStaff = implode ( ',', $nowStaffList );
  1676. } else {
  1677. $nowStaff = $verifyDetail [0] [0];
  1678. }
  1679. $receipt->nowStaff = $nowStaff;
  1680. }
  1681. // echo $nowStaff;
  1682. // print_r($verifyDetail);die;
  1683. $receipt->rid = $receiptDetailList ['rid'];
  1684. $receipt->status = 2;
  1685. $receipt->update ();
  1686. // 操作日志
  1687. Doo::loadModel ( "receiptLog" );
  1688. $receiptLog = new receiptLog ();
  1689. $verify = new verify ();
  1690. $receiptInfo = $receipt->getOne ( array (
  1691. 'where' => 'rid=' . $rid,
  1692. 'asArray' => true
  1693. ) );
  1694. $vr = $verify->getOne ( array (
  1695. 'where' => 'vid=' . $receiptInfo ['verify'],
  1696. 'asArray' => true
  1697. ) );
  1698. $jd = json_decode ( $vr ['staff'] );
  1699. $roleId = 0;
  1700. foreach ( $jd as $key => $value ) {
  1701. if ($value [1] == 'ROLE') {
  1702. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  1703. if ($pos !== false) {
  1704. $roleId = $value [0];
  1705. }
  1706. }
  1707. }
  1708. // 审批日志
  1709. // echo $roleId;die;
  1710. if (! empty ( $roleId )) {
  1711. Doo::loadModel ( "role" );
  1712. $role = new role ();
  1713. $roleInfo = $role->getOne ( array (
  1714. 'where' => 'rid=' . $roleId,
  1715. 'asArray' => true
  1716. ) );
  1717. $receiptLog->rolename = $roleInfo ['name'];
  1718. }
  1719. $receiptLog->username = $this->staff [0] ['username'];
  1720. $receiptLog->uid = $this->staff [0] ['sid'];
  1721. $receiptLog->date = date ( "Y-m-d" );
  1722. $receiptLog->opinion = '提交审批';
  1723. $receiptLog->img = $this->staff [0] ['avatar'];
  1724. $receiptLog->status = 2;
  1725. $receiptLog->rid = $rid;
  1726. $receiptLog->insert ();
  1727. return "/expenses";
  1728. }
  1729. function expenses() {
  1730. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  1731. if (empty ( $item ))
  1732. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  1733. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1734. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  1735. Doo::loadModel ( 'receipt' );
  1736. $receipt = new receipt ();
  1737. Doo::loadModel ( 'L_category' );
  1738. $Lcategory = new L_category ();
  1739. Doo::loadModel ( 'verify' );
  1740. Doo::loadModel ( 'statistics' );
  1741. $statistics = new statistics ();
  1742. $verify = new verify ();
  1743. Doo::loadModel ( 'staff' );
  1744. $staff = new staff ();
  1745. $condition = "";
  1746. if ($item == "expenses")
  1747. $condition = " and Rtype=1 ";
  1748. elseif ($item == "receipts")
  1749. $condition = " and Rtype=0 ";
  1750. elseif ($item == "remits")
  1751. $condition = " and Rtype=2 ";
  1752. $dateCondition = " and Year(date) =" . $year;
  1753. if (! empty ( $moth )) {
  1754. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  1755. $stList = $statistics->getOne ( array (
  1756. 'select' => 'rePrice ,agPrice',
  1757. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  1758. 'asArray' => true
  1759. ) );
  1760. } else
  1761. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  1762. if (empty ( $stList ))
  1763. $stList = array (
  1764. 'rePrice' => 0,
  1765. 'agPrice' => 0
  1766. );
  1767. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  1768. if (! isset ( $noPassSum ['sum'] ))
  1769. $noPassSum ['sum'] = 0;
  1770. $data ['stList'] = array (
  1771. 'rePrice' => $stList ['rePrice'],
  1772. 'agPrice' => $stList ['agPrice'],
  1773. 'skPrice' => ($noPassSum ['sum'])
  1774. );
  1775. $receiptList = $receipt->find ( array (
  1776. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  1777. 'desc' => 'rid',
  1778. 'asArray' => true
  1779. ) );
  1780. $Locate = 0;
  1781. $roleId = 0;
  1782. $button = 0;
  1783. foreach ( $receiptList as $key => $value ) {
  1784. $receiptList [$key] ['Locate'] = $Locate;
  1785. $Locate ++;
  1786. $receiptList [$key] ['reviseDetail'] = array ();
  1787. if (! empty ( $value ['reviseDetail'] ))
  1788. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1789. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1790. $categoryDetil = $Lcategory->getOne ( array (
  1791. 'where' => 'cid=' . $value ['cid'],
  1792. 'asArray' => true
  1793. ) );
  1794. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1795. // 检测编辑状态
  1796. $verifyList = $verify->getOne ( array (
  1797. 'where' => 'vid=' . $value ['verify'],
  1798. 'asArray' => true
  1799. ) );
  1800. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1801. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1802. Doo::loadModel ( 'role' );
  1803. $role = new role ();
  1804. $flag = true;
  1805. $roleKey = 0;
  1806. $endStaffArray = array ();
  1807. $roleArrayCopy = array ();
  1808. foreach ( $verifyList as $k => $v ) {
  1809. // init verifyStaff
  1810. if ($v [1] == 'ROLE') {
  1811. if (! empty ( $verifyStaff )) {
  1812. $endStaffArray = end ( $verifyStaff );
  1813. // if ($v[0]==$endStaffArray['nextStaff']){
  1814. // $roleId=$v[0];
  1815. // }
  1816. }
  1817. $roleVerify = json_decode ( $v [3], true );
  1818. $roleKey = $k;
  1819. $roleArray = array ();
  1820. $rolename = $role->getOne ( array (
  1821. 'where' => 'rid=' . $v [0],
  1822. 'asArray' => true
  1823. ) );
  1824. foreach ( $roleVerify as $o => $p ) {
  1825. $staffID = explode ( '_', $p );
  1826. $staffInfo = $staff->getOne ( array (
  1827. 'where' => 'sid=' . $staffID [0],
  1828. 'asArray' => true
  1829. ) );
  1830. // print_r($staffID);
  1831. $exp = array (
  1832. 0 => $staffInfo ['sid'],
  1833. 1 => $staffID [1],
  1834. 2 => $staffInfo ['avatar'],
  1835. 'date' => '',
  1836. 'date' => '',
  1837. 'opinion' => '',
  1838. 'status' => '',
  1839. 'rolename' => $rolename ['name']
  1840. );
  1841. array_push ( $roleArray, $exp );
  1842. }
  1843. $roleArrayCopy [$v [0]] = $roleArray;
  1844. // $verifyList[$k]['roleArray']=$roleArray;
  1845. }
  1846. $verifyList [$k] ['date'] = "";
  1847. $verifyList [$k] ['opinion'] = "";
  1848. $verifyList [$k] ['status'] = "";
  1849. if (empty ( $verifyStaff )) {
  1850. $verifyList [$k] ['date'] = "";
  1851. $verifyList [$k] ['opinion'] = "";
  1852. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1853. $verifyList [$k] ['status'] = 4;
  1854. $flag = false;
  1855. }
  1856. } else {
  1857. foreach ( $verifyStaff as $m => $u ) {
  1858. if ($v [0] == $m) {
  1859. $verifyList [$k] ['date'] = $u ['date'];
  1860. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1861. $verifyList [$k] ['status'] = $u ['status'];
  1862. $flag = false;
  1863. break;
  1864. }
  1865. }
  1866. $endStaffArray = end ( $verifyStaff );
  1867. if (isset ( $endStaffArray ['ROLE'] )) {
  1868. } else {
  1869. // $endKey=key($verifyStaff);
  1870. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1871. // $button=4;
  1872. // $verifyList[$k]['status']=4;
  1873. // }
  1874. }
  1875. }
  1876. }
  1877. $rolename ['name'] = '';
  1878. if (! empty ( $roleId )) {
  1879. Doo::loadModel ( 'role' );
  1880. $role = new role ();
  1881. $rolename = $role->getOne ( array (
  1882. 'where' => 'rid=' . $roleId,
  1883. 'asArray' => true
  1884. ) );
  1885. }
  1886. if (! empty ( $verifyStaff ))
  1887. $endStaffArray = end ( $verifyStaff );
  1888. $KOP = false;
  1889. foreach ( $roleArrayCopy as $P => $A ) {
  1890. foreach ( $A as $MKI => $AVL ) {
  1891. if (! empty ( $verifyStaff )) {
  1892. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1893. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1894. $button = 4;
  1895. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1896. }
  1897. foreach ( $verifyStaff as $m => $u ) {
  1898. $AVLFK = $AVL [0] . '_R';
  1899. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1900. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1901. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1902. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1903. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1904. break;
  1905. }
  1906. }
  1907. } else {
  1908. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1909. $button = 4;
  1910. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1911. }
  1912. }
  1913. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1914. $KOP = true;
  1915. }
  1916. }
  1917. foreach ( $roleArrayCopy as $k => $v ) {
  1918. foreach ( $verifyList as $m => $n ) {
  1919. if ($n [0] == $k) {
  1920. array_splice ( $verifyList, $m, 1, $v );
  1921. }
  1922. }
  1923. }
  1924. $receiptList [$key] ['verifyList'] = $verifyList;
  1925. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1926. 'where' => 'sid=' . $value ['staff'],
  1927. 'asArray' => true
  1928. ) );
  1929. $receiptList [$key] ['button'] = $button;
  1930. }
  1931. // print_r($receiptList);die;
  1932. $mothHtml = "";
  1933. for($i = 1; $i <= 12; $i ++) {
  1934. if ($moth == $i)
  1935. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  1936. else
  1937. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  1938. }
  1939. $data ['mothHtml'] = $mothHtml;
  1940. $data ['receiptList'] = $receiptList;
  1941. $data ['memu'] = "receipt";
  1942. $data ['staff'] = $this->staff;
  1943. $data ['receiptMemu'] = 'expenses';
  1944. $data ['verifyId'] = $this->verifyId;
  1945. $data ['executeId'] = $this->executeId;
  1946. $data ['item'] = $item;
  1947. $data ['year'] = $year;
  1948. $this->render ( "/admin/expenses", $data );
  1949. }
  1950. function expensesCollect() {
  1951. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1952. Doo::loadModel ( 'receipt' );
  1953. $receipt = new receipt ();
  1954. Doo::loadModel ( 'L_category' );
  1955. $Lcategory = new L_category ();
  1956. Doo::loadModel ( 'verify' );
  1957. Doo::loadModel ( 'statistics' );
  1958. $statistics = new statistics ();
  1959. $verify = new verify ();
  1960. Doo::loadModel ( 'staff' );
  1961. $staff = new staff ();
  1962. Doo::loadModel ( 'loanReceipt' );
  1963. $loanReceipt = new loanReceipt ();
  1964. $receiptList = $receipt->find ( array (
  1965. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  1966. 'desc' => 'rid',
  1967. 'asArray' => true
  1968. ) );
  1969. $loanList = $loanReceipt->find ( array (
  1970. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  1971. 'desc' => 'rid',
  1972. 'asArray' => true
  1973. ) );
  1974. /*
  1975. * $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;
  1976. */
  1977. $Locate = 0;
  1978. $roleId = 0;
  1979. $button = 0;
  1980. foreach ( $receiptList as $key => $value ) {
  1981. $receiptList [$key] ['Locate'] = $Locate;
  1982. $Locate ++;
  1983. $receiptList [$key] ['reviseDetail'] = array ();
  1984. if (! empty ( $value ['reviseDetail'] ))
  1985. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1986. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1987. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1988. $categoryDetil = $Lcategory->getOne ( array (
  1989. 'where' => 'cid=' . $value ['cid'],
  1990. 'asArray' => true
  1991. ) );
  1992. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1993. // 检测编辑状态
  1994. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  1995. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  1996. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  1997. else
  1998. $verifyList ['staff'] = $value ['verifyBreakup'];
  1999. } else
  2000. $verifyList = $verify->getOne ( array (
  2001. 'where' => 'vid=' . $value ['verify'],
  2002. 'asArray' => true
  2003. ) );
  2004. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2005. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2006. Doo::loadModel ( 'role' );
  2007. $role = new role ();
  2008. $flag = true;
  2009. $roleKey = 0;
  2010. $endStaffArray = array ();
  2011. $roleArrayCopy = array ();
  2012. foreach ( $verifyList as $k => $v ) {
  2013. // init verifyStaff
  2014. if ($v [1] == 'ROLE') {
  2015. if (! empty ( $verifyStaff )) {
  2016. $endStaffArray = end ( $verifyStaff );
  2017. // if ($v[0]==$endStaffArray['nextStaff']){
  2018. // $roleId=$v[0];
  2019. // }
  2020. }
  2021. $roleVerify = json_decode ( $v [3], true );
  2022. $roleKey = $k;
  2023. $roleArray = array ();
  2024. $rolename = $role->getOne ( array (
  2025. 'where' => 'rid=' . $v [0],
  2026. 'asArray' => true
  2027. ) );
  2028. foreach ( $roleVerify as $o => $p ) {
  2029. $staffID = explode ( '_', $p );
  2030. $staffInfo = $staff->getOne ( array (
  2031. 'where' => 'sid=' . $staffID [0],
  2032. 'asArray' => true
  2033. ) );
  2034. // print_r($staffID);
  2035. $exp = array (
  2036. 0 => $staffInfo ['sid'],
  2037. 1 => $staffID [1],
  2038. 2 => $staffInfo ['avatar'],
  2039. 'date' => '',
  2040. 'date' => '',
  2041. 'opinion' => '',
  2042. 'status' => '',
  2043. 'rolename' => $rolename ['name']
  2044. );
  2045. array_push ( $roleArray, $exp );
  2046. }
  2047. $roleArrayCopy [$v [0]] = $roleArray;
  2048. // $verifyList[$k]['roleArray']=$roleArray;
  2049. }
  2050. $verifyList [$k] ['date'] = "";
  2051. $verifyList [$k] ['opinion'] = "";
  2052. $verifyList [$k] ['status'] = "";
  2053. if (empty ( $verifyStaff )) {
  2054. $verifyList [$k] ['date'] = "";
  2055. $verifyList [$k] ['opinion'] = "";
  2056. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2057. $verifyList [$k] ['status'] = 4;
  2058. $flag = false;
  2059. }
  2060. } else {
  2061. foreach ( $verifyStaff as $m => $u ) {
  2062. if ($v [0] == $m) {
  2063. $verifyList [$k] ['date'] = $u ['date'];
  2064. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2065. $verifyList [$k] ['status'] = $u ['status'];
  2066. $flag = false;
  2067. break;
  2068. }
  2069. }
  2070. $endStaffArray = end ( $verifyStaff );
  2071. if (isset ( $endStaffArray ['ROLE'] )) {
  2072. } else {
  2073. // $endKey=key($verifyStaff);
  2074. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2075. // $button=4;
  2076. // $verifyList[$k]['status']=4;
  2077. // }
  2078. }
  2079. }
  2080. }
  2081. $rolename ['name'] = '';
  2082. if (! empty ( $roleId )) {
  2083. Doo::loadModel ( 'role' );
  2084. $role = new role ();
  2085. $rolename = $role->getOne ( array (
  2086. 'where' => 'rid=' . $roleId,
  2087. 'asArray' => true
  2088. ) );
  2089. }
  2090. if (! empty ( $verifyStaff ))
  2091. $endStaffArray = end ( $verifyStaff );
  2092. $KOP = false;
  2093. foreach ( $roleArrayCopy as $P => $A ) {
  2094. foreach ( $A as $MKI => $AVL ) {
  2095. if (! empty ( $verifyStaff )) {
  2096. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2097. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2098. $button = 4;
  2099. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2100. }
  2101. foreach ( $verifyStaff as $m => $u ) {
  2102. $AVLFK = $AVL [0] . '_R';
  2103. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2104. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2105. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2106. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2107. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2108. break;
  2109. }
  2110. }
  2111. } else {
  2112. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2113. $button = 4;
  2114. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2115. }
  2116. }
  2117. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2118. $KOP = true;
  2119. }
  2120. }
  2121. foreach ( $roleArrayCopy as $k => $v ) {
  2122. foreach ( $verifyList as $m => $n ) {
  2123. if ($n [0] == $k) {
  2124. array_splice ( $verifyList, $m, 1, $v );
  2125. }
  2126. }
  2127. }
  2128. // 费用执行人相关数据
  2129. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2130. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2131. foreach ( $executeCopy as $k => $v ) {
  2132. $executeCopy [$k] ['date'] = '';
  2133. $executeCopy [$k] ['opinion'] = '';
  2134. $executeCopy [$k] ['status'] = '';
  2135. if (! empty ( $executeStaff ))
  2136. foreach ( $executeStaff as $m => $u ) {
  2137. if ($v [0] == $m) {
  2138. $executeCopy [$k] ['date'] = $u ['date'];
  2139. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2140. $executeCopy [$k] ['status'] = $u ['status'];
  2141. break;
  2142. }
  2143. }
  2144. }
  2145. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2146. $receiptList [$key] ['verifyList'] = $verifyList;
  2147. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2148. 'where' => 'sid=' . $value ['staff'],
  2149. 'asArray' => true
  2150. ) );
  2151. $receiptList [$key] ['button'] = $button;
  2152. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2153. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2154. $relust = $value ['sum'] - $value ['loanSum'];
  2155. $receiptList [$key] ['relust'] = $relust;
  2156. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2157. }
  2158. Doo::loadModel ( 'enclosur' );
  2159. $enclosur = new enclosur ();
  2160. $enclosurList = $enclosur->find ( array (
  2161. 'where' => 'rid=' . $rid,
  2162. 'asArray' => true
  2163. ) );
  2164. $enclosurHtml = '';
  2165. foreach ( $enclosurList as $value ) {
  2166. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2167. }
  2168. $data ['enclosurHtml'] = $enclosurHtml;
  2169. // print_r($receiptList);
  2170. $data ['receiptList'] = $receiptList;
  2171. $data ['memu'] = "receipt";
  2172. $data ['staff'] = $this->staff;
  2173. $data ['receiptMemu'] = 'expenses';
  2174. $data ['verifyId'] = $this->verifyId;
  2175. $data ['executeId'] = $this->executeId;
  2176. $this->render ( "/admin/expensesCollect", $data );
  2177. }
  2178. function approvalExpenses() {
  2179. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  2180. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2181. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2182. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2183. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2184. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  2185. //echo $rdate;
  2186. if (empty ( $status ))
  2187. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  2188. $page_size = 12;
  2189. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2190. $vidList = array ();
  2191. $button = 0;
  2192. Doo::loadModel ( 'verify' );
  2193. $verify = new verify ();
  2194. Doo::loadModel ( 'receipt' );
  2195. $receipt = new receipt ();
  2196. Doo::loadModel ( 'staff' );
  2197. $staff = new staff ();
  2198. Doo::loadModel ( 'L_category' );
  2199. $Lcategory = new L_category ();
  2200. // user verify ID
  2201. $verifyDetail = $verify->find ( array (
  2202. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  2203. 'asArray' => true
  2204. ) );
  2205. foreach ( $verifyDetail as $key => $value ) {
  2206. array_push ( $vidList, $value ['vid'] );
  2207. }
  2208. $vid = implode ( ",", $vidList );
  2209. if (empty ( $verifyDetail ))
  2210. $vid = 0;
  2211. // if ($status==0)
  2212. // $dateCondition="";
  2213. // else
  2214. $dateCondition = " and Year(date) =" . $year;
  2215. /*
  2216. if (! empty ( $month ))
  2217. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  2218. if($status == 'done'){
  2219. $dateCondition = " and Year(pastDate) =" . $year;
  2220. if (! empty ( $month ))
  2221. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  2222. }
  2223. */
  2224. //date ( 'Y-m' )
  2225. if(!empty($rdate)&&$status == 'done')
  2226. $dateCondition=" and date_format(pastDate,'%Y-%m')='".$rdate."' ";
  2227. elseif (!empty($rdate))
  2228. $dateCondition=" and date_format(date,'%Y-%m')='".$rdate."' ";
  2229. $categoryList = $Lcategory->find ( array (
  2230. 'asArray' => true
  2231. ) );
  2232. $staffList = $staff->find ( array (
  2233. 'where' => 'cid=' . $cid,
  2234. 'asArray' => true
  2235. ) );
  2236. $cateCondition = "";
  2237. $staffCondition = "";
  2238. $approvalCondition = "";
  2239. if (! empty ( $cid )){
  2240. $cateCondition = ' and cid=' . $cid;
  2241. }
  2242. if (! empty ( $sid )) {
  2243. $staffCondition = ' and cid=' . $cid.' and staff=' . $sid;
  2244. $cateCondition = "";
  2245. }
  2246. $get="?year=".$year."&month=".$month."&cid=".$cid."&sid=".$sid;
  2247. if ($status == 'pendApproval') {
  2248. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  2249. }
  2250. if ($status == 'ongoing') {
  2251. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  2252. }
  2253. if ($status == 'done') {
  2254. $approvalCondition = ' and (status=8 or status=9 ) ';
  2255. }
  2256. if ($status == 'termination') {
  2257. $approvalCondition = " and status=3";
  2258. }
  2259. // $approvalCondition = " and status=" . $status;
  2260. // if ($status == 2) {
  2261. // // 查找角色审批人
  2262. // }
  2263. // if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  2264. // $approvalCondition = ' and status=2 ';
  2265. // }
  2266. // if ($status == 1) {
  2267. // $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  2268. // }
  2269. // if ($status == 8) {
  2270. // $approvalCondition = ' and (status=' . $status . ' or status=9 ) ';
  2271. // }
  2272. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  2273. $pageinfo ['page'] = array (
  2274. 'previous' => ''
  2275. );
  2276. // if ($status == 0) {
  2277. // $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  2278. // $receiptList = $receipt->find ( array (
  2279. // 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ')',
  2280. // 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2281. // 'desc' => 'rid',
  2282. // 'asArray' => true
  2283. // ) );
  2284. // //echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2285. // } else
  2286. if ($status == 'done' || $status == 'termination') {
  2287. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/".$status, $get, "" );
  2288. $receiptList = $receipt->find ( array (
  2289. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
  2290. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2291. 'desc' => 'rid',
  2292. 'asArray' => true
  2293. ) );
  2294. } else
  2295. $receiptList = $receipt->find ( array (
  2296. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
  2297. 'desc' => 'rid',
  2298. 'asArray' => true
  2299. ) );
  2300. $rLRes = $receipt->find ( array (
  2301. '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,
  2302. 'desc' => 'rid',
  2303. 'asArray' => true
  2304. ) );
  2305. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2306. // print_r($pageinfo);
  2307. $Locate = 0;
  2308. $reportList=$reportCateList=array();
  2309. foreach ( $receiptList as $key => $value ) {
  2310. $receiptList [$key] ['Locate'] = $Locate;
  2311. $Locate ++;
  2312. $receiptList [$key] ['reviseDetail'] = array ();
  2313. if (! empty ( $value ['reviseDetail'] ))
  2314. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2315. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2316. $categoryDetil = $Lcategory->getOne ( array (
  2317. 'where' => 'cid=' . $value ['cid'],
  2318. 'asArray' => true
  2319. ) );
  2320. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2321. $verifyList = $verify->getOne ( array (
  2322. 'where' => 'vid=' . $value ['verify'],
  2323. 'asArray' => true
  2324. ) );
  2325. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2326. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2327. foreach ( $verifyList as $k => $v ) {
  2328. // init verifyStaff
  2329. $verifyList [$k] ['date'] = "";
  2330. $verifyList [$k] ['opinion'] = "";
  2331. $verifyList [$k] ['status'] = "";
  2332. if (empty ( $verifyStaff )) {
  2333. $verifyList [$k] ['date'] = "";
  2334. $verifyList [$k] ['opinion'] = "";
  2335. if ($v [0] == $this->staff [0] ['sid']) {
  2336. $verifyList [$k] ['status'] = 4;
  2337. $button = 4;
  2338. }
  2339. } else {
  2340. $flag = true;
  2341. foreach ( $verifyStaff as $m => $u ) {
  2342. if ($v [0] == $m) {
  2343. $verifyList [$k] ['date'] = $u ['date'];
  2344. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2345. $verifyList [$k] ['status'] = $u ['status'];
  2346. $flag = false;
  2347. break;
  2348. }
  2349. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  2350. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  2351. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  2352. }
  2353. if ($flag) { // 检测可编辑
  2354. if ($v [0] == $this->staff [0] ['sid']) {
  2355. $verifyList [$k] ['status'] = 4;
  2356. $button = 4;
  2357. }
  2358. }
  2359. }
  2360. }
  2361. $receiptList [$key] ['verifyList'] = $verifyList;
  2362. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2363. 'where' => 'sid=' . $value ['staff'],
  2364. 'asArray' => true
  2365. ) );
  2366. array_push($reportList, $receiptList [$key] ['staffDetail']['sid'].'-'.$receiptList [$key] ['staffDetail']['username'].'-'.$receiptList [$key] ['staffDetail']['category']);
  2367. array_push($reportCateList, $receiptList [$key] ['staffDetail']['cid'].'-'.$receiptList [$key] ['staffDetail']['category']);
  2368. $receiptList [$key] ['button'] = $button;
  2369. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  2370. }
  2371. $reportList=array_unique($reportList);
  2372. $reportHtml='';
  2373. foreach ($reportList as $key=>$value){
  2374. $v=explode("-", $value);
  2375. $reportHtml.='<option node-all=\'true\' node-cate=\''.$v[2].'\' value="'.$v[1].'">'.$v[1].'</option>';
  2376. }
  2377. //print_r($reportList)
  2378. $data['reportHtml']=$reportHtml;
  2379. $reportCateList=array_unique($reportCateList);
  2380. $reportCateHtml='';
  2381. foreach ($reportCateList as $key=>$value){
  2382. $v=explode("-", $value);
  2383. $reportCateHtml.='<option value="'.$v[1].'">'.$v[1].'</option>';
  2384. }
  2385. //$reportHtml.='<option value="ALL">'.$value[''].'</option>';
  2386. $data['reportCateHtml']=$reportCateHtml;
  2387. // print_r($receiptList);die;
  2388. // $data['verifyDetail']=$verifyDetail;
  2389. $mothHtml = "";
  2390. for($i = 1; $i <= 12; $i ++) {
  2391. if ($month == $i)
  2392. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2393. else
  2394. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2395. }
  2396. $data ['mothHtml'] = $mothHtml;
  2397. $data ['page'] = $pageinfo;
  2398. $data ['receiptList'] = $receiptList;
  2399. $data ['receiptApprovalCount'] = count ( $rLRes );
  2400. $data ['status'] = $status;
  2401. $data ['year'] = $year;
  2402. $data ['categoryList'] = $categoryList;
  2403. $data ['staffList'] = $staffList;
  2404. $data ['cid'] = $cid;
  2405. $data ['sid'] = $sid;
  2406. // print_r($receiptList);
  2407. $data ['memu'] = "receipt";
  2408. $data ['staff'] = $this->staff;
  2409. $data ['receiptMemu'] = 'approvalExpenses';
  2410. $data ['verifyId'] = $this->verifyId;
  2411. $data ['executeId'] = $this->executeId;
  2412. $this->render ( "/admin/approvalExpenses", $data );
  2413. }
  2414. function expensesDoc() {
  2415. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2416. Doo::loadModel ( 'receipt' );
  2417. $receipt = new receipt ();
  2418. Doo::loadModel ( 'L_category' );
  2419. $Lcategory = new L_category ();
  2420. Doo::loadModel ( 'verify' );
  2421. Doo::loadModel ( 'statistics' );
  2422. $statistics = new statistics ();
  2423. $verify = new verify ();
  2424. Doo::loadModel ( 'staff' );
  2425. $staff = new staff ();
  2426. Doo::loadModel ( 'loanReceipt' );
  2427. $loanReceipt = new loanReceipt ();
  2428. $receiptList = $receipt->find ( array (
  2429. 'where' => ' rid=' . $rid,
  2430. 'desc' => 'rid',
  2431. 'asArray' => true
  2432. ) );
  2433. $loanList = array ();
  2434. if (! empty ( $receiptList ))
  2435. $loanList = $loanReceipt->find ( array (
  2436. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2437. 'desc' => 'rid',
  2438. 'asArray' => true
  2439. ) );
  2440. $Locate = 0;
  2441. $roleId = 0;
  2442. $button = 0;
  2443. foreach ( $loanList as $key => $value ) {
  2444. $loanList [$key] ['Locate'] = $Locate;
  2445. $Locate ++;
  2446. $loanList [$key] ['reviseDetail'] = array ();
  2447. if (! empty ( $value ['reviseDetail'] ))
  2448. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2449. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2450. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2451. $categoryDetil = $Lcategory->getOne ( array (
  2452. 'where' => 'cid=' . $value ['cid'],
  2453. 'asArray' => true
  2454. ) );
  2455. $loanList [$key] ['category'] = $categoryDetil ['title'];
  2456. // 检测编辑状态
  2457. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  2458. $verifyList ['staff'] = $value ['verifyBreakup'];
  2459. else
  2460. $verifyList = $verify->getOne ( array (
  2461. 'where' => 'vid=' . $value ['verify'],
  2462. 'asArray' => true
  2463. ) );
  2464. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2465. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2466. Doo::loadModel ( 'role' );
  2467. $role = new role ();
  2468. $flag = true;
  2469. $roleKey = 0;
  2470. $endStaffArray = array ();
  2471. $roleArrayCopy = array ();
  2472. foreach ( $verifyList as $k => $v ) {
  2473. // init verifyStaff
  2474. if ($v [1] == 'ROLE') {
  2475. if (! empty ( $verifyStaff )) {
  2476. $endStaffArray = end ( $verifyStaff );
  2477. // if ($v[0]==$endStaffArray['nextStaff']){
  2478. // $roleId=$v[0];
  2479. // }
  2480. }
  2481. $roleVerify = json_decode ( $v [3], true );
  2482. $roleKey = $k;
  2483. $roleArray = array ();
  2484. $rolename = $role->getOne ( array (
  2485. 'where' => 'rid=' . $v [0],
  2486. 'asArray' => true
  2487. ) );
  2488. foreach ( $roleVerify as $o => $p ) {
  2489. $staffID = explode ( '_', $p );
  2490. $staffInfo = $staff->getOne ( array (
  2491. 'where' => 'sid=' . $staffID [0],
  2492. 'asArray' => true
  2493. ) );
  2494. // print_r($staffID);
  2495. $exp = array (
  2496. 0 => $staffInfo ['sid'],
  2497. 1 => $staffID [1],
  2498. 2 => $staffInfo ['avatar'],
  2499. 'date' => '',
  2500. 'date' => '',
  2501. 'opinion' => '',
  2502. 'status' => '',
  2503. 'rolename' => $rolename ['name']
  2504. );
  2505. array_push ( $roleArray, $exp );
  2506. }
  2507. $roleArrayCopy [$v [0]] = $roleArray;
  2508. // $verifyList[$k]['roleArray']=$roleArray;
  2509. }
  2510. $verifyList [$k] ['date'] = "";
  2511. $verifyList [$k] ['opinion'] = "";
  2512. $verifyList [$k] ['status'] = "";
  2513. if (empty ( $verifyStaff )) {
  2514. $verifyList [$k] ['date'] = "";
  2515. $verifyList [$k] ['opinion'] = "";
  2516. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2517. $verifyList [$k] ['status'] = 4;
  2518. $flag = false;
  2519. }
  2520. } else {
  2521. foreach ( $verifyStaff as $m => $u ) {
  2522. if ($v [0] == $m) {
  2523. $verifyList [$k] ['date'] = $u ['date'];
  2524. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2525. $verifyList [$k] ['status'] = $u ['status'];
  2526. $flag = false;
  2527. break;
  2528. }
  2529. }
  2530. $endStaffArray = end ( $verifyStaff );
  2531. if (isset ( $endStaffArray ['ROLE'] )) {
  2532. } else {
  2533. // $endKey=key($verifyStaff);
  2534. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2535. // $button=4;
  2536. // $verifyList[$k]['status']=4;
  2537. // }
  2538. }
  2539. }
  2540. }
  2541. $rolename ['name'] = '';
  2542. if (! empty ( $roleId )) {
  2543. Doo::loadModel ( 'role' );
  2544. $role = new role ();
  2545. $rolename = $role->getOne ( array (
  2546. 'where' => 'rid=' . $roleId,
  2547. 'asArray' => true
  2548. ) );
  2549. }
  2550. if (! empty ( $verifyStaff ))
  2551. $endStaffArray = end ( $verifyStaff );
  2552. $KOP = false;
  2553. foreach ( $roleArrayCopy as $P => $A ) {
  2554. foreach ( $A as $MKI => $AVL ) {
  2555. if (! empty ( $verifyStaff )) {
  2556. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2557. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2558. $button = 4;
  2559. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2560. }
  2561. foreach ( $verifyStaff as $m => $u ) {
  2562. $AVLFK = $AVL [0] . '_R';
  2563. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2564. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2565. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2566. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2567. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2568. break;
  2569. }
  2570. }
  2571. } else {
  2572. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2573. $button = 4;
  2574. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2575. }
  2576. }
  2577. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2578. $KOP = true;
  2579. }
  2580. }
  2581. foreach ( $roleArrayCopy as $k => $v ) {
  2582. foreach ( $verifyList as $m => $n ) {
  2583. if ($n [0] == $k) {
  2584. array_splice ( $verifyList, $m, 1, $v );
  2585. }
  2586. }
  2587. }
  2588. $loanList [$key] ['verifyList'] = $verifyList;
  2589. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  2590. 'where' => 'sid=' . $value ['staff'],
  2591. 'asArray' => true
  2592. ) );
  2593. $loanList [$key] ['button'] = $button;
  2594. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  2595. }
  2596. $data ['loanList'] = $loanList;
  2597. // print_r($loanList);
  2598. $Locate = 0;
  2599. $roleId = 0;
  2600. $button = 0;
  2601. foreach ( $receiptList as $key => $value ) {
  2602. $receiptList [$key] ['Locate'] = $Locate;
  2603. $Locate ++;
  2604. $receiptList [$key] ['reviseDetail'] = array ();
  2605. if (! empty ( $value ['reviseDetail'] ))
  2606. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2607. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2608. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2609. $categoryDetil = $Lcategory->getOne ( array (
  2610. 'where' => 'cid=' . $value ['cid'],
  2611. 'asArray' => true
  2612. ) );
  2613. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2614. // 检测编辑状态
  2615. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  2616. $verifyList ['staff'] = $value ['verifyBreakup'];
  2617. } else
  2618. $verifyList = $verify->getOne ( array (
  2619. 'where' => 'vid=' . $value ['verify'],
  2620. 'asArray' => true
  2621. ) );
  2622. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2623. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2624. Doo::loadModel ( 'role' );
  2625. $role = new role ();
  2626. if ($verifyList == NULL)
  2627. $verifyList = array ();
  2628. $flag = true;
  2629. $roleKey = 0;
  2630. $endStaffArray = array ();
  2631. $roleArrayCopy = array ();
  2632. foreach ( $verifyList as $k => $v ) {
  2633. // init verifyStaff
  2634. if ($v [1] == 'ROLE') {
  2635. if (! empty ( $verifyStaff )) {
  2636. $endStaffArray = end ( $verifyStaff );
  2637. // if ($v[0]==$endStaffArray['nextStaff']){
  2638. // $roleId=$v[0];
  2639. // }
  2640. }
  2641. $roleVerify = json_decode ( $v [3], true );
  2642. $roleKey = $k;
  2643. $roleArray = array ();
  2644. $rolename = $role->getOne ( array (
  2645. 'where' => 'rid=' . $v [0],
  2646. 'asArray' => true
  2647. ) );
  2648. foreach ( $roleVerify as $o => $p ) {
  2649. $staffID = explode ( '_', $p );
  2650. $staffInfo = $staff->getOne ( array (
  2651. 'where' => 'sid=' . $staffID [0],
  2652. 'asArray' => true
  2653. ) );
  2654. // print_r($staffID);
  2655. $exp = array (
  2656. 0 => $staffInfo ['sid'],
  2657. 1 => $staffID [1],
  2658. 2 => $staffInfo ['avatar'],
  2659. 'date' => '',
  2660. 'date' => '',
  2661. 'opinion' => '',
  2662. 'status' => '',
  2663. 'rolename' => $rolename ['name']
  2664. );
  2665. array_push ( $roleArray, $exp );
  2666. }
  2667. $roleArrayCopy [$v [0]] = $roleArray;
  2668. // $verifyList[$k]['roleArray']=$roleArray;
  2669. }
  2670. $verifyList [$k] ['date'] = "";
  2671. $verifyList [$k] ['opinion'] = "";
  2672. $verifyList [$k] ['status'] = "";
  2673. if (empty ( $verifyStaff )) {
  2674. $verifyList [$k] ['date'] = "";
  2675. $verifyList [$k] ['opinion'] = "";
  2676. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2677. $verifyList [$k] ['status'] = 4;
  2678. $flag = false;
  2679. }
  2680. } else {
  2681. foreach ( $verifyStaff as $m => $u ) {
  2682. if ($v [0] == $m) {
  2683. $verifyList [$k] ['date'] = $u ['date'];
  2684. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2685. $verifyList [$k] ['status'] = $u ['status'];
  2686. $flag = false;
  2687. break;
  2688. }
  2689. }
  2690. $endStaffArray = end ( $verifyStaff );
  2691. if (isset ( $endStaffArray ['ROLE'] )) {
  2692. } else {
  2693. // $endKey=key($verifyStaff);
  2694. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2695. // $button=4;
  2696. // $verifyList[$k]['status']=4;
  2697. // }
  2698. }
  2699. }
  2700. }
  2701. $rolename ['name'] = '';
  2702. if (! empty ( $roleId )) {
  2703. Doo::loadModel ( 'role' );
  2704. $role = new role ();
  2705. $rolename = $role->getOne ( array (
  2706. 'where' => 'rid=' . $roleId,
  2707. 'asArray' => true
  2708. ) );
  2709. }
  2710. if (! empty ( $verifyStaff ))
  2711. $endStaffArray = end ( $verifyStaff );
  2712. $KOP = false;
  2713. foreach ( $roleArrayCopy as $P => $A ) {
  2714. foreach ( $A as $MKI => $AVL ) {
  2715. if (! empty ( $verifyStaff )) {
  2716. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2717. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2718. $button = 4;
  2719. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2720. }
  2721. foreach ( $verifyStaff as $m => $u ) {
  2722. $AVLFK = $AVL [0] . '_R';
  2723. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2724. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2725. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2726. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2727. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2728. break;
  2729. }
  2730. }
  2731. } else {
  2732. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2733. $button = 4;
  2734. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2735. }
  2736. }
  2737. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2738. $KOP = true;
  2739. }
  2740. }
  2741. foreach ( $roleArrayCopy as $k => $v ) {
  2742. foreach ( $verifyList as $m => $n ) {
  2743. if ($n [0] == $k) {
  2744. array_splice ( $verifyList, $m, 1, $v );
  2745. }
  2746. }
  2747. }
  2748. // 费用执行人相关数据
  2749. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2750. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2751. foreach ( $executeCopy as $k => $v ) {
  2752. $executeCopy [$k] ['date'] = '';
  2753. $executeCopy [$k] ['opinion'] = '';
  2754. $executeCopy [$k] ['status'] = '';
  2755. if (! empty ( $executeStaff ))
  2756. foreach ( $executeStaff as $m => $u ) {
  2757. if ($v [0] == $m) {
  2758. $executeCopy [$k] ['date'] = $u ['date'];
  2759. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2760. $executeCopy [$k] ['status'] = $u ['status'];
  2761. break;
  2762. }
  2763. }
  2764. }
  2765. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2766. $receiptList [$key] ['verifyList'] = $verifyList;
  2767. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2768. 'where' => 'sid=' . $value ['staff'],
  2769. 'asArray' => true
  2770. ) );
  2771. $receiptList [$key] ['button'] = $button;
  2772. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2773. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2774. $relust = $value ['sum'] - $value ['loanSum'];
  2775. $receiptList [$key] ['relust'] = $relust;
  2776. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2777. }
  2778. // print_r($receiptList);
  2779. // 获取审批日志
  2780. Doo::loadModel ( 'receiptLog' );
  2781. $receiptLog = new receiptLog ();
  2782. $rlList = array ();
  2783. $rlInfo = $receiptLog->getOne ( array (
  2784. 'where' => 'rid=' . $rid . ' and status=4',
  2785. 'asArray' => true
  2786. ) );
  2787. $tijdate = $receiptLog->getOne ( array (
  2788. 'where' => 'rid=' . $rid . ' and status=2',
  2789. 'asc' => 'rlid',
  2790. 'asArray' => true
  2791. ) );
  2792. if (! empty ( $rlInfo )) {
  2793. $rlList = $receiptLog->find ( array (
  2794. 'where' => 'rid=' . $rid,
  2795. 'asc' => 'rlid',
  2796. 'asArray' => true
  2797. ) );
  2798. }
  2799. Doo::loadModel ( 'enclosur' );
  2800. $enclosur = new enclosur ();
  2801. $enclosurList = $enclosur->find ( array (
  2802. 'where' => 'rid=' . $rid,
  2803. 'asArray' => true
  2804. ) );
  2805. $enclosurHtml = '';
  2806. foreach ( $enclosurList as $value ) {
  2807. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2808. }
  2809. $data ['enclosurHtml'] = $enclosurHtml;
  2810. $receiptList [0] ['rlList'] = $rlList;
  2811. $data ['receiptList'] = $receiptList;
  2812. $data ['memu'] = "receipt";
  2813. $data ['staff'] = $this->staff;
  2814. $data ['receiptMemu'] = 'approvalExpenses';
  2815. $data ['verifyId'] = $this->verifyId;
  2816. $data ['executeId'] = $this->executeId;
  2817. $this->render ( "/admin/expensesDoc", $data );
  2818. }
  2819. function expensesEdi() {
  2820. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2821. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  2822. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2823. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2824. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2825. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2826. if (empty ( $status ))
  2827. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  2828. $vidList = array ();
  2829. $button = 0;
  2830. Doo::loadModel ( 'verify' );
  2831. Doo::loadModel ( 'receipt' );
  2832. Doo::loadModel ( 'staff' );
  2833. $staff = new staff ();
  2834. $receipt = new receipt ();
  2835. $verify = new verify ();
  2836. Doo::loadModel ( 'L_category' );
  2837. $Lcategory = new L_category ();
  2838. Doo::loadModel ( 'enclosur' );
  2839. $enclosur = new enclosur ();
  2840. // user verify ID
  2841. $verifyDetail = $verify->find ( array (
  2842. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  2843. 'asArray' => true
  2844. ) );
  2845. foreach ( $verifyDetail as $key => $value ) {
  2846. array_push ( $vidList, $value ['vid'] );
  2847. }
  2848. $vid = implode ( ",", $vidList );
  2849. if (empty ( $verifyDetail ))
  2850. $vid = 0;
  2851. $categoryList = $Lcategory->find ( array (
  2852. 'asArray' => true
  2853. ) );
  2854. $staffList = $staff->find ( array (
  2855. 'where' => 'cid=' . $cid,
  2856. 'asArray' => true
  2857. ) );
  2858. $ap = "";
  2859. if ($status == 4) {
  2860. $ap = 4;
  2861. $status = 2;
  2862. }
  2863. // get Receipt By verifyID status 2
  2864. $receiptList = $receipt->find ( array (
  2865. 'where' => 'rid =' . $rid.' and status=2',
  2866. 'desc' => 'rid',
  2867. 'asArray' => true
  2868. ) );
  2869. if (empty($receiptList)){
  2870. die ( 'illegal request' );
  2871. }
  2872. $Locate = 0;
  2873. $roleId = 0;
  2874. if ($ap == 4)
  2875. $status = 4;
  2876. foreach ( $receiptList as $key => $value ) {
  2877. $receiptList [$key] ['Locate'] = $Locate;
  2878. $Locate ++;
  2879. $receiptList [$key] ['reviseDetail'] = array ();
  2880. if (! empty ( $value ['reviseDetail'] ))
  2881. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2882. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2883. $categoryDetil = $Lcategory->getOne ( array (
  2884. 'where' => 'cid=' . $value ['cid'],
  2885. 'asArray' => true
  2886. ) );
  2887. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2888. // 检测编辑状态
  2889. $verifyList = $verify->getOne ( array (
  2890. 'where' => 'vid=' . $value ['verify'],
  2891. 'asArray' => true
  2892. ) );
  2893. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2894. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2895. Doo::loadModel ( 'role' );
  2896. $role = new role ();
  2897. // print_r($verifyList);
  2898. $flag = true;
  2899. $roleKey = 0;
  2900. $endStaffArray = array ();
  2901. $roleArrayCopy = array ();
  2902. foreach ( $verifyList as $k => $v ) {
  2903. // init verifyStaff
  2904. if ($v [1] == 'ROLE') {
  2905. if (! empty ( $verifyStaff )) {
  2906. $endStaffArray = end ( $verifyStaff );
  2907. if ($v [0] == $endStaffArray ['nextStaff']) {
  2908. $roleId = $v [0];
  2909. }
  2910. }
  2911. $roleVerify = json_decode ( $v [3], true );
  2912. $roleKey = $k;
  2913. $roleArray = array ();
  2914. $rolename = $role->getOne ( array (
  2915. 'where' => 'rid=' . $v [0],
  2916. 'asArray' => true
  2917. ) );
  2918. foreach ( $roleVerify as $o => $p ) {
  2919. $staffID = explode ( '_', $p );
  2920. $staffInfo = $staff->getOne ( array (
  2921. 'where' => 'sid=' . $staffID [0],
  2922. 'asArray' => true
  2923. ) );
  2924. // print_r($staffID);
  2925. $exp = array (
  2926. 0 => $staffInfo ['sid'],
  2927. 1 => $staffID [1],
  2928. 2 => $staffInfo ['avatar'],
  2929. 'date' => '',
  2930. 'date' => '',
  2931. 'opinion' => '',
  2932. 'status' => '',
  2933. 'rolename' => $rolename ['name']
  2934. );
  2935. array_push ( $roleArray, $exp );
  2936. }
  2937. $roleArrayCopy [$v [0]] = $roleArray;
  2938. // $verifyList[$k]['roleArray']=$roleArray;
  2939. }
  2940. // print_r($roleArray);
  2941. $verifyList [$k] ['date'] = "";
  2942. $verifyList [$k] ['opinion'] = "";
  2943. $verifyList [$k] ['status'] = "";
  2944. if (empty ( $verifyStaff )) {
  2945. $verifyList [$k] ['date'] = "";
  2946. $verifyList [$k] ['opinion'] = "";
  2947. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2948. $verifyList [$k] ['status'] = 4;
  2949. $button = 4;
  2950. $flag = false;
  2951. }
  2952. } else {
  2953. foreach ( $verifyStaff as $m => $u ) {
  2954. if ($v [0] == $m) {
  2955. $verifyList [$k] ['date'] = $u ['date'];
  2956. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2957. $verifyList [$k] ['status'] = $u ['status'];
  2958. $flag = false;
  2959. break;
  2960. }
  2961. }
  2962. $endStaffArray = end ( $verifyStaff );
  2963. if (isset ( $endStaffArray ['ROLE'] )) {
  2964. } else {
  2965. $endKey = key ( $verifyStaff );
  2966. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  2967. $button = 4;
  2968. $verifyList [$k] ['status'] = 4;
  2969. }
  2970. }
  2971. }
  2972. }
  2973. $rolename ['name'] = '';
  2974. if (! empty ( $roleId )) {
  2975. Doo::loadModel ( 'role' );
  2976. $role = new role ();
  2977. $rolename = $role->getOne ( array (
  2978. 'where' => 'rid=' . $roleId,
  2979. 'asArray' => true
  2980. ) );
  2981. }
  2982. if (! empty ( $verifyStaff ))
  2983. $endStaffArray = end ( $verifyStaff );
  2984. $KOP = false;
  2985. foreach ( $roleArrayCopy as $P => $A ) {
  2986. foreach ( $A as $MKI => $AVL ) {
  2987. if (! empty ( $verifyStaff )) {
  2988. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2989. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2990. $button = 4;
  2991. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2992. }
  2993. foreach ( $verifyStaff as $m => $u ) {
  2994. $AVLFK = $AVL [0] . '_R';
  2995. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2996. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2997. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2998. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2999. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3000. break;
  3001. }
  3002. }
  3003. } else {
  3004. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3005. $button = 4;
  3006. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3007. }
  3008. }
  3009. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3010. $KOP = true;
  3011. }
  3012. }
  3013. // print_r($roleArrayCopy);
  3014. // echo $roleKey;
  3015. foreach ( $roleArrayCopy as $k => $v ) {
  3016. foreach ( $verifyList as $m => $n ) {
  3017. if ($n [0] == $k) {
  3018. array_splice ( $verifyList, $m, 1, $v );
  3019. }
  3020. }
  3021. }
  3022. $receiptList [$key] ['verifyList'] = $verifyList;
  3023. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3024. 'where' => 'sid=' . $value ['staff'],
  3025. 'asArray' => true
  3026. ) );
  3027. $receiptList [$key] ['button'] = $button;
  3028. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  3029. }
  3030. // $data['verifyDetail']=$verifyDetail;
  3031. $mothHtml = "";
  3032. for($i = 1; $i <= 12; $i ++) {
  3033. if ($month == $i)
  3034. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3035. else
  3036. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3037. }
  3038. // 获取审批日志
  3039. Doo::loadModel ( 'receiptLog' );
  3040. $receiptLog = new receiptLog ();
  3041. $rlList = array ();
  3042. $rlInfo = $receiptLog->getOne ( array (
  3043. 'where' => 'rid=' . $rid . ' and status=4',
  3044. 'asArray' => true
  3045. ) );
  3046. $tijdate = $receiptLog->getOne ( array (
  3047. 'where' => 'rid=' . $rid . ' and status=2',
  3048. 'asc' => 'rlid',
  3049. 'asArray' => true
  3050. ) );
  3051. if (! empty ( $rlInfo )) {
  3052. $rlList = $receiptLog->find ( array (
  3053. 'where' => 'rid=' . $rid,
  3054. 'asc' => 'rlid',
  3055. 'asArray' => true
  3056. ) );
  3057. }
  3058. $receiptList [0] ['rlList'] = $rlList;
  3059. $enclosurList = $enclosur->find ( array (
  3060. 'where' => 'rid=' . $rid,
  3061. 'asArray' => true
  3062. ) );
  3063. $enclosurHtml = '';
  3064. foreach ( $enclosurList as $value ) {
  3065. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3066. }
  3067. // print_r($receiptList);
  3068. $data ['rid'] = $rid;
  3069. $data ['enclosurHtml'] = $enclosurHtml;
  3070. $data ['rolename'] = $rolename ['name'];
  3071. $data ['datetij'] = $tijdate ['date'];
  3072. $data ['mothHtml'] = $mothHtml;
  3073. $data ['receiptList'] = $receiptList;
  3074. $data ['receiptApprovalCount'] = count ( $receiptList );
  3075. $data ['status'] = $status;
  3076. $data ['year'] = $year;
  3077. $data ['categoryList'] = $categoryList;
  3078. $data ['staffList'] = $staffList;
  3079. $data ['cid'] = $cid;
  3080. $data ['sid'] = $sid;
  3081. $data ['ap'] = $ap;
  3082. $data ['memu'] = "receipt";
  3083. $data ['staff'] = $this->staff;
  3084. $data ['receiptMemu'] = 'approvalExpenses';
  3085. $data ['verifyId'] = $this->verifyId;
  3086. $data ['executeId'] = $this->executeId;
  3087. $this->render ( "/admin/expensesEdi", $data );
  3088. }
  3089. function expensesDefray() {
  3090. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3091. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3092. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3093. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  3094. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  3095. if (! empty ( $rid )) {
  3096. Doo::loadModel ( "verify" );
  3097. $verify = new verify ();
  3098. Doo::loadModel ( "receiptDetail" );
  3099. $receiptDetailObj = new receiptDetail ();
  3100. Doo::loadModel ( "itemStatistics" );
  3101. Doo::loadModel ( "statistics" );
  3102. $statistics = new statistics ();
  3103. $itemStatistics = new itemStatistics ();
  3104. Doo::loadModel ( "receipt" );
  3105. $receipt = new receipt ();
  3106. Doo::loadModel ( "loanReceipt" );
  3107. $loanReceipt = new loanReceipt ();
  3108. $receiptDetail = $receipt->getOne ( array (
  3109. 'where' => 'rid=' . $rid . ' and status=2 ',
  3110. 'asArray' => true
  3111. ) );
  3112. if (empty ( $receiptDetail ))
  3113. return "/approval";
  3114. $verifyDetail = $verify->getOne ( array (
  3115. 'where' => ' vid =' . $receiptDetail ['verify'],
  3116. 'asArray' => true
  3117. ) );
  3118. $verifyString = $verifyDetail ['staff'];
  3119. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3120. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  3121. if (empty ( $opinion )) {
  3122. if ($status == 3)
  3123. $opinion = "终止";
  3124. else
  3125. $opinion = "同意支付";
  3126. }
  3127. $nowStaff = 0;
  3128. $nowStaffList = array ();
  3129. if (empty ( $verifyStaff )) {
  3130. // 还需加入是否已经进入角色审批
  3131. if ($verifyDetail [0] [1] == 'ROLE') {
  3132. // print_r($verifyDetail);echo "ddd";
  3133. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3134. foreach ( $vStaffString as $key => $value ) {
  3135. $staffK = explode ( "_", $value );
  3136. if ($staffK [0] != $this->staff [0] ['sid'])
  3137. array_push ( $nowStaffList, $staffK [0] );
  3138. }
  3139. // print_r($verifyDetail);
  3140. // die;
  3141. if (! empty ( $nowStaffList )) {
  3142. $nowStaff = implode ( ',', $nowStaffList );
  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 [0] [0],
  3149. 'ROLE' => 1
  3150. )
  3151. );
  3152. } else {
  3153. $nowStaff = $verifyDetail [1] [0];
  3154. $verifyStaff = array (
  3155. $this->staff [0] ['sid'] . "_R" => array (
  3156. 'date' => date ( 'Y-m-d' ),
  3157. 'opinion' => $opinion,
  3158. 'status' => $status,
  3159. 'nextStaff' => $verifyDetail [1] [0]
  3160. )
  3161. );
  3162. }
  3163. } else {
  3164. if ($verifyDetail [1] [1] == 'ROLE') {
  3165. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  3166. // echo "dd";
  3167. foreach ( $vStaffString as $key => $value ) {
  3168. $staffK = explode ( "_", $value );
  3169. array_push ( $nowStaffList, $staffK [0] );
  3170. }
  3171. $nowStaff = implode ( ',', $nowStaffList );
  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. 'ROLE' => 1
  3179. )
  3180. );
  3181. } else {
  3182. $nowStaff = $verifyDetail [1] [0];
  3183. $verifyStaff = array (
  3184. $this->staff [0] ['sid'] => array (
  3185. 'date' => date ( 'Y-m-d' ),
  3186. 'opinion' => $opinion,
  3187. 'status' => $status,
  3188. 'nextStaff' => $verifyDetail [1] [0]
  3189. )
  3190. );
  3191. }
  3192. }
  3193. if ($status == 3)
  3194. $verifyStaff = array (
  3195. 'final' => $status,
  3196. $this->staff [0] ['sid'] => array (
  3197. 'date' => date ( 'Y-m-d' ),
  3198. 'opinion' => $opinion,
  3199. 'status' => $status
  3200. )
  3201. );
  3202. $vStaffString = json_encode ( $verifyStaff );
  3203. $receipt->nowStaff = $nowStaff;
  3204. $receipt->verifyStaff = $vStaffString;
  3205. $loanReceipt->nowStaff = $nowStaff;
  3206. $loanReceipt->verifyStaff = $vStaffString;
  3207. } else {
  3208. $VS = end ( $verifyStaff );
  3209. // 非角色审批
  3210. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  3211. $nextStaff = 0;
  3212. $roleSTF = false;
  3213. foreach ( $verifyDetail as $key => $value ) {
  3214. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  3215. if (isset ( $verifyDetail [$key + 1] )) {
  3216. $nextStaff = $verifyDetail [$key + 1] [0];
  3217. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  3218. $roleSTF = true;
  3219. }
  3220. break;
  3221. }
  3222. }
  3223. if (! $roleSTF) {
  3224. $nowStaff = $nextStaff;
  3225. $verifyStaff [$this->staff [0] ['sid']] = array (
  3226. 'date' => date ( 'Y-m-d' ),
  3227. 'opinion' => $opinion,
  3228. 'status' => $status,
  3229. 'nextStaff' => $nextStaff
  3230. );
  3231. } else {
  3232. // 获取角色下的所有用户ID
  3233. $nowStaffList = array ();
  3234. foreach ( $verifyDetail as $vfk ) {
  3235. if ($vfk [1] == 'ROLE') {
  3236. $vStaffString = json_decode ( $vfk [3] );
  3237. foreach ( $vStaffString as $key => $value ) {
  3238. $staffK = explode ( "_", $value );
  3239. array_push ( $nowStaffList, $staffK [0] );
  3240. }
  3241. }
  3242. }
  3243. $nowStaff = implode ( ',', $nowStaffList );
  3244. $verifyStaff [$this->staff [0] ['sid']] = array (
  3245. 'date' => date ( 'Y-m-d' ),
  3246. 'opinion' => $opinion,
  3247. 'status' => $status,
  3248. 'nextStaff' => $nextStaff,
  3249. 'ROLE' => 0
  3250. );
  3251. }
  3252. if ($status == 3) {
  3253. $verifyStaff ['final'] = $status;
  3254. $verifyStaff [$this->staff [0] ['sid']] = array (
  3255. 'date' => date ( 'Y-m-d' ),
  3256. 'opinion' => $opinion,
  3257. 'status' => $status
  3258. );
  3259. }
  3260. $vStaffString = json_encode ( $verifyStaff );
  3261. $receipt->nowStaff = $nowStaff;
  3262. $receipt->verifyStaff = $vStaffString;
  3263. $loanReceipt->nowStaff = $nowStaff;
  3264. $loanReceipt->verifyStaff = $vStaffString;
  3265. }
  3266. // 角色审批
  3267. if (isset ( $VS ['ROLE'] )) {
  3268. // 找出角色人 当前审批角色组
  3269. $verifyJSStaff = array ();
  3270. $nowStaffList2 = array ();
  3271. foreach ( $verifyDetail as $key => $value ) {
  3272. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  3273. $verifyJSStaff = json_decode ( $value [3] );
  3274. foreach ( $verifyJSStaff as $m ) {
  3275. $staffK = explode ( "_", $m );
  3276. array_push ( $nowStaffList2, $staffK [0] );
  3277. }
  3278. // print_r($nowStaffList2);
  3279. }
  3280. }
  3281. $RoleVerifyStaff = array ();
  3282. foreach ( $verifyStaff as $key => $value ) {
  3283. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  3284. foreach ( $nowStaffList2 as $m ) {
  3285. if ($key == $m . "_R")
  3286. $RoleVerifyStaff [$key] = $value;
  3287. }
  3288. }
  3289. }
  3290. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  3291. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  3292. // 下一个审批人ID
  3293. $nextStaff = 0;
  3294. $falg = false;
  3295. foreach ( $verifyDetail as $key => $value ) {
  3296. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  3297. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  3298. $falg = true;
  3299. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  3300. $nowStaffList = array ();
  3301. foreach ( $vStaffString as $v ) {
  3302. $staffK = explode ( "_", $v );
  3303. array_push ( $nowStaffList, $staffK [0] );
  3304. }
  3305. $nowStaff = implode ( ',', $nowStaffList );
  3306. $nextStaff = $verifyDetail [$key + 1] [0];
  3307. } elseif (isset ( $verifyDetail [$key + 1] )) {
  3308. $nextStaff = $verifyDetail [$key + 1] [0];
  3309. $nowStaff = $nextStaff;
  3310. } else
  3311. $nowStaff = '';
  3312. break;
  3313. }
  3314. }
  3315. if ($falg)
  3316. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3317. 'date' => date ( 'Y-m-d' ),
  3318. 'opinion' => $opinion,
  3319. 'status' => $status,
  3320. 'nextStaff' => $nextStaff,
  3321. 'ROLE' => 1
  3322. );
  3323. else
  3324. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3325. 'date' => date ( 'Y-m-d' ),
  3326. 'opinion' => $opinion,
  3327. 'status' => $status,
  3328. 'nextStaff' => $nextStaff
  3329. );
  3330. // print_r($verifyStaff);
  3331. // echo $nowStaff;die;
  3332. } else { // 进入下一个角色或者审批人
  3333. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  3334. //
  3335. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  3336. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3337. 'date' => date ( 'Y-m-d' ),
  3338. 'opinion' => $opinion,
  3339. 'status' => $status,
  3340. 'nextStaff' => $VS ['nextStaff'],
  3341. 'ROLE' => 1
  3342. );
  3343. // print_r($verifyStaff);
  3344. // die;
  3345. }
  3346. if ($status == 3) {
  3347. $verifyStaff ['final'] = $status;
  3348. $verifyStaff [$this->staff [0] ['sid']] = array (
  3349. 'date' => date ( 'Y-m-d' ),
  3350. 'opinion' => $opinion,
  3351. 'status' => $status
  3352. );
  3353. }
  3354. $vStaffString = json_encode ( $verifyStaff );
  3355. $receipt->verifyStaff = $vStaffString;
  3356. $receipt->nowStaff = $nowStaff;
  3357. $loanReceipt->nowStaff = $nowStaff;
  3358. $loanReceipt->verifyStaff = $vStaffString;
  3359. // die;
  3360. // }
  3361. // print_r($verifyStaff);
  3362. // die;
  3363. }
  3364. // print_r($verifyStaff);die;
  3365. }
  3366. // print_r($verifyDetail);
  3367. $roleKey = 0;
  3368. $roleId = 0;
  3369. $verifyDetailCopy = array ();
  3370. foreach ( $verifyDetail as $k => $v ) {
  3371. if ($v [1] == 'ROLE') {
  3372. $roleId = $v [0];
  3373. $roleVerify = json_decode ( $v [3], true );
  3374. $roleKey = $k;
  3375. $roleArray = array ();
  3376. foreach ( $roleVerify as $o => $p ) {
  3377. $staffID = explode ( '_', $p );
  3378. $exp = array (
  3379. 0 => $staffID [0],
  3380. 1 => $staffID [1]
  3381. );
  3382. array_push ( $roleArray, $exp );
  3383. }
  3384. $verifyDetailCopy [$v [0]] = $roleArray;
  3385. }
  3386. }
  3387. // print_r($verifyDetail);
  3388. foreach ( $verifyDetailCopy as $k => $v ) {
  3389. foreach ( $verifyDetail as $m => $n ) {
  3390. if ($n [0] == $k) {
  3391. array_splice ( $verifyDetail, $m, 1, $v );
  3392. }
  3393. }
  3394. }
  3395. // 审批日志
  3396. if (! isset ( $verifyStaff ['final'] )) {
  3397. Doo::loadModel ( "receiptLog" );
  3398. $receiptLog = new receiptLog ();
  3399. if (! empty ( $roleId )) {
  3400. Doo::loadModel ( "role" );
  3401. $role = new role ();
  3402. $roleInfo = $role->getOne ( array (
  3403. 'where' => 'rid=' . $roleId,
  3404. 'asArray' => true
  3405. ) );
  3406. $receiptLog->rolename = $roleInfo ['name'];
  3407. }
  3408. $receiptLog->username = $this->staff [0] ['username'];
  3409. $receiptLog->uid = $this->staff [0] ['sid'];
  3410. $receiptLog->date = date ( "Y-m-d" );
  3411. $receiptLog->opinion = $opinion;
  3412. $receiptLog->img = $this->staff [0] ['avatar'];
  3413. $receiptLog->status = 1;
  3414. $receiptLog->rid = $rid;
  3415. $receiptLog->insert ();
  3416. }
  3417. if (isset ( $verifyStaff ['final'] )) { // rDetail
  3418. $receipt->status = 3;
  3419. $receipt->verifyBreakup = $verifyString;
  3420. $receiptDetailObj->status = 3;
  3421. $receiptDetailObj->update ( array (
  3422. 'where' => 'rid=' . $rid
  3423. ) );
  3424. // 微信企业号通知
  3425. $this->setWXMsg ( $rid, 3 );
  3426. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  3427. $receipt->status = 6;
  3428. $receipt->pastDate = date ( "Y-m-d" );
  3429. $receipt->isBK = 1;
  3430. $loanReceipt->verifyBreakup = $verifyString;
  3431. $loanReceipt->status = 1;
  3432. $loanReceipt->pastDate = date ( "Y-m-d" );
  3433. $loanReceipt->update ( array (
  3434. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  3435. ) );
  3436. // 微信企业号通知
  3437. $this->setWXMsg ( $rid, 1 );
  3438. }
  3439. $receipt->amount = $amount;
  3440. $receipt->update ( array (
  3441. 'where' => ' rid = ' . $rid
  3442. ) );
  3443. return "/approvalExpenses/pendApproval";
  3444. }
  3445. }
  3446. function ajaxExamineExe() {
  3447. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3448. Doo::loadModel ( 'receipt' );
  3449. $receipt = new receipt ();
  3450. Doo::loadClass ( 'XDeode' );
  3451. $XDeode = new XDeode ( 5 );
  3452. if (! empty ( $rid )) {
  3453. $rLRes = $receipt->find ( array (
  3454. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  3455. 'asArray' => true
  3456. ) );
  3457. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  3458. echo json_encode ( array (
  3459. 'status' => 1,
  3460. 'receipt' => $rLRes [0]
  3461. ) );
  3462. die ();
  3463. }
  3464. echo json_encode ( array (
  3465. 'status' => 0,
  3466. 'receipt' => array ()
  3467. ) );
  3468. die ();
  3469. }
  3470. function implement() {
  3471. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3472. Doo::loadClass ( 'XDeode' );
  3473. $XDeode = new XDeode ( 5 );
  3474. Doo::loadModel ( 'receipt' );
  3475. $receipt = new receipt ();
  3476. Doo::loadModel ( 'L_category' );
  3477. $Lcategory = new L_category ();
  3478. Doo::loadModel ( 'verify' );
  3479. $verify = new verify ();
  3480. Doo::loadModel ( 'staff' );
  3481. $staff = new staff ();
  3482. Doo::loadModel ( "execute" );
  3483. $execute = new execute ();
  3484. $rid = $XDeode->decode ( $rid );
  3485. $receiptList = $receipt->find ( array (
  3486. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  3487. 'desc' => 'rid',
  3488. 'asArray' => true
  3489. ) );
  3490. Doo::loadModel ( 'loanReceipt' );
  3491. $loanReceipt = new loanReceipt ();
  3492. // print_r($receiptList);
  3493. $loanList = array ();
  3494. if (! isset ( $receiptList ))
  3495. $loanList = $loanReceipt->find ( array (
  3496. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3497. 'desc' => 'rid',
  3498. 'asArray' => true
  3499. ) );
  3500. $Locate = 0;
  3501. $roleId = 0;
  3502. $button = 0;
  3503. foreach ( $loanList as $key => $value ) {
  3504. $loanList [$key] ['Locate'] = $Locate;
  3505. $Locate ++;
  3506. $loanList [$key] ['reviseDetail'] = array ();
  3507. if (! empty ( $value ['reviseDetail'] ))
  3508. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3509. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3510. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3511. $categoryDetil = $Lcategory->getOne ( array (
  3512. 'where' => 'cid=' . $value ['cid'],
  3513. 'asArray' => true
  3514. ) );
  3515. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3516. // 检测编辑状态
  3517. $verifyList = $verify->getOne ( array (
  3518. 'where' => 'vid=' . $value ['verify'],
  3519. 'asArray' => true
  3520. ) );
  3521. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3522. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3523. Doo::loadModel ( 'role' );
  3524. $role = new role ();
  3525. $flag = true;
  3526. $roleKey = 0;
  3527. $endStaffArray = array ();
  3528. $roleArrayCopy = array ();
  3529. foreach ( $verifyList as $k => $v ) {
  3530. // init verifyStaff
  3531. if ($v [1] == 'ROLE') {
  3532. if (! empty ( $verifyStaff )) {
  3533. $endStaffArray = end ( $verifyStaff );
  3534. // if ($v[0]==$endStaffArray['nextStaff']){
  3535. // $roleId=$v[0];
  3536. // }
  3537. }
  3538. $roleVerify = json_decode ( $v [3], true );
  3539. $roleKey = $k;
  3540. $roleArray = array ();
  3541. $rolename = $role->getOne ( array (
  3542. 'where' => 'rid=' . $v [0],
  3543. 'asArray' => true
  3544. ) );
  3545. foreach ( $roleVerify as $o => $p ) {
  3546. $staffID = explode ( '_', $p );
  3547. $staffInfo = $staff->getOne ( array (
  3548. 'where' => 'sid=' . $staffID [0],
  3549. 'asArray' => true
  3550. ) );
  3551. // print_r($staffID);
  3552. $exp = array (
  3553. 0 => $staffInfo ['sid'],
  3554. 1 => $staffID [1],
  3555. 2 => $staffInfo ['avatar'],
  3556. 'date' => '',
  3557. 'date' => '',
  3558. 'opinion' => '',
  3559. 'status' => '',
  3560. 'rolename' => $rolename ['name']
  3561. );
  3562. array_push ( $roleArray, $exp );
  3563. }
  3564. $roleArrayCopy [$v [0]] = $roleArray;
  3565. // $verifyList[$k]['roleArray']=$roleArray;
  3566. }
  3567. $verifyList [$k] ['date'] = "";
  3568. $verifyList [$k] ['opinion'] = "";
  3569. $verifyList [$k] ['status'] = "";
  3570. if (empty ( $verifyStaff )) {
  3571. $verifyList [$k] ['date'] = "";
  3572. $verifyList [$k] ['opinion'] = "";
  3573. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3574. $verifyList [$k] ['status'] = 4;
  3575. $flag = false;
  3576. }
  3577. } else {
  3578. foreach ( $verifyStaff as $m => $u ) {
  3579. if ($v [0] == $m) {
  3580. $verifyList [$k] ['date'] = $u ['date'];
  3581. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3582. $verifyList [$k] ['status'] = $u ['status'];
  3583. $flag = false;
  3584. break;
  3585. }
  3586. }
  3587. $endStaffArray = end ( $verifyStaff );
  3588. if (isset ( $endStaffArray ['ROLE'] )) {
  3589. } else {
  3590. // $endKey=key($verifyStaff);
  3591. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3592. // $button=4;
  3593. // $verifyList[$k]['status']=4;
  3594. // }
  3595. }
  3596. }
  3597. }
  3598. $rolename ['name'] = '';
  3599. if (! empty ( $roleId )) {
  3600. Doo::loadModel ( 'role' );
  3601. $role = new role ();
  3602. $rolename = $role->getOne ( array (
  3603. 'where' => 'rid=' . $roleId,
  3604. 'asArray' => true
  3605. ) );
  3606. }
  3607. if (! empty ( $verifyStaff ))
  3608. $endStaffArray = end ( $verifyStaff );
  3609. $KOP = false;
  3610. foreach ( $roleArrayCopy as $P => $A ) {
  3611. foreach ( $A as $MKI => $AVL ) {
  3612. if (! empty ( $verifyStaff )) {
  3613. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3614. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3615. $button = 4;
  3616. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3617. }
  3618. foreach ( $verifyStaff as $m => $u ) {
  3619. $AVLFK = $AVL [0] . '_R';
  3620. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3621. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3622. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3623. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3624. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3625. break;
  3626. }
  3627. }
  3628. } else {
  3629. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3630. $button = 4;
  3631. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3632. }
  3633. }
  3634. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3635. $KOP = true;
  3636. }
  3637. }
  3638. foreach ( $roleArrayCopy as $k => $v ) {
  3639. foreach ( $verifyList as $m => $n ) {
  3640. if ($n [0] == $k) {
  3641. array_splice ( $verifyList, $m, 1, $v );
  3642. }
  3643. }
  3644. }
  3645. $loanList [$key] ['verifyList'] = $verifyList;
  3646. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3647. 'where' => 'sid=' . $value ['staff'],
  3648. 'asArray' => true
  3649. ) );
  3650. }
  3651. $data ['loanList'] = $loanList;
  3652. $Locate = 0;
  3653. $roleId = 0;
  3654. $button = 0;
  3655. foreach ( $receiptList as $key => $value ) {
  3656. $button2 = 0;
  3657. $receiptList [$key] ['Locate'] = $Locate;
  3658. $Locate ++;
  3659. $receiptList [$key] ['reviseDetail'] = array ();
  3660. if (! empty ( $value ['reviseDetail'] ))
  3661. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3662. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3663. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3664. $categoryDetil = $Lcategory->getOne ( array (
  3665. 'where' => 'cid=' . $value ['cid'],
  3666. 'asArray' => true
  3667. ) );
  3668. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3669. $executeList = json_decode ( $value ['executeCopy'], true );
  3670. $executeStaff = array ();
  3671. if (! empty ( $value ['executeStaff'] ))
  3672. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3673. if (isset ( $executeList )) {
  3674. foreach ( $executeList as $op => $lo ) {
  3675. $executeList [$op] ['date'] = "";
  3676. $executeList [$op] ['opinion'] = "";
  3677. $executeList [$op] ['status'] = "";
  3678. foreach ( $executeStaff as $m => $u ) {
  3679. if ($lo [0] == $m) {
  3680. $executeList [$op] ['date'] = $u ['date'];
  3681. $executeList [$op] ['opinion'] = $u ['opinion'];
  3682. $executeList [$op] ['status'] = $u ['status'];
  3683. break;
  3684. }
  3685. }
  3686. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  3687. $button2 = 1;
  3688. $executeList [$op] ['status'] = 4;
  3689. }
  3690. }
  3691. }
  3692. // 检测编辑状态
  3693. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3694. $verifyList ['staff'] = $value ['verifyBreakup'];
  3695. } else
  3696. $verifyList = $verify->getOne ( array (
  3697. 'where' => 'vid=' . $value ['verify'],
  3698. 'asArray' => true
  3699. ) );
  3700. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3701. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3702. Doo::loadModel ( 'role' );
  3703. $role = new role ();
  3704. if ($verifyList == NULL)
  3705. $verifyList = array ();
  3706. $flag = true;
  3707. $roleKey = 0;
  3708. $endStaffArray = array ();
  3709. $roleArrayCopy = array ();
  3710. foreach ( $verifyList as $k => $v ) {
  3711. // init verifyStaff
  3712. if ($v [1] == 'ROLE') {
  3713. if (! empty ( $verifyStaff )) {
  3714. $endStaffArray = end ( $verifyStaff );
  3715. // if ($v[0]==$endStaffArray['nextStaff']){
  3716. // $roleId=$v[0];
  3717. // }
  3718. }
  3719. $roleVerify = json_decode ( $v [3], true );
  3720. $roleKey = $k;
  3721. $roleArray = array ();
  3722. $rolename = $role->getOne ( array (
  3723. 'where' => 'rid=' . $v [0],
  3724. 'asArray' => true
  3725. ) );
  3726. foreach ( $roleVerify as $o => $p ) {
  3727. $staffID = explode ( '_', $p );
  3728. $staffInfo = $staff->getOne ( array (
  3729. 'where' => 'sid=' . $staffID [0],
  3730. 'asArray' => true
  3731. ) );
  3732. // print_r($staffID);
  3733. $exp = array (
  3734. 0 => $staffInfo ['sid'],
  3735. 1 => $staffID [1],
  3736. 2 => $staffInfo ['avatar'],
  3737. 'date' => '',
  3738. 'date' => '',
  3739. 'opinion' => '',
  3740. 'status' => '',
  3741. 'rolename' => $rolename ['name']
  3742. );
  3743. array_push ( $roleArray, $exp );
  3744. }
  3745. $roleArrayCopy [$v [0]] = $roleArray;
  3746. // $verifyList[$k]['roleArray']=$roleArray;
  3747. }
  3748. $verifyList [$k] ['date'] = "";
  3749. $verifyList [$k] ['opinion'] = "";
  3750. $verifyList [$k] ['status'] = "";
  3751. if (empty ( $verifyStaff )) {
  3752. $verifyList [$k] ['date'] = "";
  3753. $verifyList [$k] ['opinion'] = "";
  3754. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3755. $verifyList [$k] ['status'] = 4;
  3756. $flag = false;
  3757. }
  3758. } else {
  3759. foreach ( $verifyStaff as $m => $u ) {
  3760. if ($v [0] == $m) {
  3761. $verifyList [$k] ['date'] = $u ['date'];
  3762. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3763. $verifyList [$k] ['status'] = $u ['status'];
  3764. $flag = false;
  3765. break;
  3766. }
  3767. }
  3768. $endStaffArray = end ( $verifyStaff );
  3769. if (isset ( $endStaffArray ['ROLE'] )) {
  3770. } else {
  3771. // $endKey=key($verifyStaff);
  3772. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3773. // $button=4;
  3774. // $verifyList[$k]['status']=4;
  3775. // }
  3776. }
  3777. }
  3778. }
  3779. $rolename ['name'] = '';
  3780. if (! empty ( $roleId )) {
  3781. Doo::loadModel ( 'role' );
  3782. $role = new role ();
  3783. $rolename = $role->getOne ( array (
  3784. 'where' => 'rid=' . $roleId,
  3785. 'asArray' => true
  3786. ) );
  3787. }
  3788. if (! empty ( $verifyStaff ))
  3789. $endStaffArray = end ( $verifyStaff );
  3790. $KOP = false;
  3791. foreach ( $roleArrayCopy as $P => $A ) {
  3792. foreach ( $A as $MKI => $AVL ) {
  3793. if (! empty ( $verifyStaff )) {
  3794. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3795. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3796. $button = 4;
  3797. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3798. }
  3799. foreach ( $verifyStaff as $m => $u ) {
  3800. $AVLFK = $AVL [0] . '_R';
  3801. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3802. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3803. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3804. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3805. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3806. break;
  3807. }
  3808. }
  3809. } else {
  3810. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3811. $button = 4;
  3812. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3813. }
  3814. }
  3815. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3816. $KOP = true;
  3817. }
  3818. }
  3819. foreach ( $roleArrayCopy as $k => $v ) {
  3820. foreach ( $verifyList as $m => $n ) {
  3821. if ($n [0] == $k) {
  3822. array_splice ( $verifyList, $m, 1, $v );
  3823. }
  3824. }
  3825. }
  3826. $receiptList [$key] ['verifyList'] = $verifyList;
  3827. $receiptList [$key] ['executeList'] = $executeList;
  3828. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3829. 'where' => 'sid=' . $value ['staff'],
  3830. 'asArray' => true
  3831. ) );
  3832. $receiptList [$key] ['button2'] = $button2;
  3833. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3834. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3835. $relust = $value ['sum'] - $value ['loanSum'];
  3836. $receiptList [$key] ['relust'] = $relust;
  3837. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  3838. }
  3839. // print_r($receiptList[$key]['executeList']);
  3840. $data ['receiptList'] = $receiptList;
  3841. $data ['memu'] = "receipt";
  3842. $data ['staff'] = $this->staff;
  3843. $data ['receiptMemu'] = 'implement';
  3844. $data ['verifyId'] = $this->verifyId;
  3845. $data ['executeId'] = $this->executeId;
  3846. $this->render ( "/admin/implement", $data );
  3847. }
  3848. function implementDo() {
  3849. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3850. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3851. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  3852. if (! empty ( $rid ) && $amount != '') {
  3853. Doo::loadModel ( 'receipt' );
  3854. $receipt = new receipt ();
  3855. Doo::loadClass ( 'XDeode' );
  3856. $XDeode = new XDeode ( 5 );
  3857. $rinfo = $receipt->getOne ( array (
  3858. 'where' => 'rid=' . $rid,
  3859. 'asArray' => true
  3860. ) );
  3861. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  3862. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  3863. if (empty ( $executeStaff )) {
  3864. $executeStaff = array (
  3865. $this->staff [0] ['sid'] => array (
  3866. 'date' => date ( 'Y-m-d' ),
  3867. 'opinion' => $implementOpinions,
  3868. 'status' => 1
  3869. )
  3870. );
  3871. } else {
  3872. $executeStaff [$this->staff [0] ['sid']] = array (
  3873. 'date' => date ( 'Y-m-d' ),
  3874. 'opinion' => $implementOpinions,
  3875. 'status' => 1
  3876. );
  3877. }
  3878. if (count ( $executeStaff ) == count ( $executeCopy )) {
  3879. $receipt->executeStaff = json_encode ( $executeStaff );
  3880. $receipt->status = 8;
  3881. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  3882. $receipt->status = 9;
  3883. if($rinfo ['status']==6){
  3884. $receipt->loanDate=date ( "Y-m-d" );
  3885. }
  3886. $receipt->executeDate = date ( "Y-m-d" );
  3887. } else {
  3888. $receipt->executeStaff = json_encode ( $executeStaff );
  3889. }
  3890. $receipt->amount = $amount;
  3891. $receipt->update ( array (
  3892. 'where' => 'rid=' . $rid
  3893. ) );
  3894. }
  3895. $ridKey = $XDeode->encode ( $rid );
  3896. return "/hisImplement";
  3897. //return "/implement/" . $ridKey . ".html";
  3898. }
  3899. function receiptburEdi() {
  3900. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3901. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  3902. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  3903. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  3904. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3905. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  3906. if (empty ( $status ))
  3907. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  3908. $vidList = array ();
  3909. $button = 0;
  3910. Doo::loadModel ( 'verify' );
  3911. Doo::loadModel ( 'receipt' );
  3912. Doo::loadModel ( 'staff' );
  3913. $staff = new staff ();
  3914. $receipt = new receipt ();
  3915. $verify = new verify ();
  3916. Doo::loadModel ( 'L_category' );
  3917. $Lcategory = new L_category ();
  3918. Doo::loadModel ( 'enclosur' );
  3919. $enclosur = new enclosur ();
  3920. Doo::loadModel ( 'loanReceipt' );
  3921. $loanReceipt = new loanReceipt ();
  3922. // user verify ID
  3923. $verifyDetail = $verify->find ( array (
  3924. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  3925. 'asArray' => true
  3926. ) );
  3927. foreach ( $verifyDetail as $key => $value ) {
  3928. array_push ( $vidList, $value ['vid'] );
  3929. }
  3930. $vid = implode ( ",", $vidList );
  3931. if (empty ( $verifyDetail ))
  3932. $vid = 0;
  3933. $categoryList = $Lcategory->find ( array (
  3934. 'asArray' => true
  3935. ) );
  3936. $staffList = $staff->find ( array (
  3937. 'where' => 'cid=' . $cid,
  3938. 'asArray' => true
  3939. ) );
  3940. $ap = "";
  3941. if ($status == 4) {
  3942. $ap = 4;
  3943. $status = 2;
  3944. }
  3945. // get Receipt By verifyID status 2
  3946. $receiptList = $receipt->find ( array (
  3947. 'where' => 'rid =' . $rid.' and status=2',
  3948. 'desc' => 'rid',
  3949. 'asArray' => true
  3950. ) );
  3951. if(empty($receiptList)){
  3952. die ( 'illegal request' );
  3953. }
  3954. $loanList = $loanReceipt->find ( array (
  3955. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3956. 'desc' => 'rid',
  3957. 'asArray' => true
  3958. ) );
  3959. $Locate = 0;
  3960. $roleId = 0;
  3961. $button = 0;
  3962. foreach ( $loanList as $key => $value ) {
  3963. $loanList [$key] ['Locate'] = $Locate;
  3964. $Locate ++;
  3965. $loanList [$key] ['reviseDetail'] = array ();
  3966. if (! empty ( $value ['reviseDetail'] ))
  3967. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3968. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3969. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3970. $categoryDetil = $Lcategory->getOne ( array (
  3971. 'where' => 'cid=' . $value ['cid'],
  3972. 'asArray' => true
  3973. ) );
  3974. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3975. // 检测编辑状态
  3976. $verifyList = $verify->getOne ( array (
  3977. 'where' => 'vid=' . $value ['verify'],
  3978. 'asArray' => true
  3979. ) );
  3980. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3981. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3982. Doo::loadModel ( 'role' );
  3983. $role = new role ();
  3984. $flag = true;
  3985. $roleKey = 0;
  3986. $endStaffArray = array ();
  3987. $roleArrayCopy = array ();
  3988. foreach ( $verifyList as $k => $v ) {
  3989. // init verifyStaff
  3990. if ($v [1] == 'ROLE') {
  3991. if (! empty ( $verifyStaff )) {
  3992. $endStaffArray = end ( $verifyStaff );
  3993. }
  3994. $roleVerify = json_decode ( $v [3], true );
  3995. $roleKey = $k;
  3996. $roleArray = array ();
  3997. $rolename = $role->getOne ( array (
  3998. 'where' => 'rid=' . $v [0],
  3999. 'asArray' => true
  4000. ) );
  4001. foreach ( $roleVerify as $o => $p ) {
  4002. $staffID = explode ( '_', $p );
  4003. $staffInfo = $staff->getOne ( array (
  4004. 'where' => 'sid=' . $staffID [0],
  4005. 'asArray' => true
  4006. ) );
  4007. // print_r($staffID);
  4008. $exp = array (
  4009. 0 => $staffInfo ['sid'],
  4010. 1 => $staffID [1],
  4011. 2 => $staffInfo ['avatar'],
  4012. 'date' => '',
  4013. 'date' => '',
  4014. 'opinion' => '',
  4015. 'status' => '',
  4016. 'rolename' => $rolename ['name']
  4017. );
  4018. array_push ( $roleArray, $exp );
  4019. }
  4020. $roleArrayCopy [$v [0]] = $roleArray;
  4021. // $verifyList[$k]['roleArray']=$roleArray;
  4022. }
  4023. $verifyList [$k] ['date'] = "";
  4024. $verifyList [$k] ['opinion'] = "";
  4025. $verifyList [$k] ['status'] = "";
  4026. if (empty ( $verifyStaff )) {
  4027. $verifyList [$k] ['date'] = "";
  4028. $verifyList [$k] ['opinion'] = "";
  4029. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4030. $verifyList [$k] ['status'] = 4;
  4031. $flag = false;
  4032. }
  4033. } else {
  4034. foreach ( $verifyStaff as $m => $u ) {
  4035. if ($v [0] == $m) {
  4036. $verifyList [$k] ['date'] = $u ['date'];
  4037. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4038. $verifyList [$k] ['status'] = $u ['status'];
  4039. $flag = false;
  4040. break;
  4041. }
  4042. }
  4043. $endStaffArray = end ( $verifyStaff );
  4044. if (isset ( $endStaffArray ['ROLE'] )) {
  4045. } else {
  4046. }
  4047. }
  4048. }
  4049. $rolename ['name'] = '';
  4050. if (! empty ( $roleId )) {
  4051. Doo::loadModel ( 'role' );
  4052. $role = new role ();
  4053. $rolename = $role->getOne ( array (
  4054. 'where' => 'rid=' . $roleId,
  4055. 'asArray' => true
  4056. ) );
  4057. }
  4058. if (! empty ( $verifyStaff ))
  4059. $endStaffArray = end ( $verifyStaff );
  4060. $KOP = false;
  4061. foreach ( $roleArrayCopy as $P => $A ) {
  4062. foreach ( $A as $MKI => $AVL ) {
  4063. if (! empty ( $verifyStaff )) {
  4064. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4065. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4066. $button = 4;
  4067. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4068. }
  4069. foreach ( $verifyStaff as $m => $u ) {
  4070. $AVLFK = $AVL [0] . '_R';
  4071. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4072. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4073. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4074. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4075. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4076. break;
  4077. }
  4078. }
  4079. } else {
  4080. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4081. $button = 4;
  4082. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4083. }
  4084. }
  4085. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4086. $KOP = true;
  4087. }
  4088. }
  4089. foreach ( $roleArrayCopy as $k => $v ) {
  4090. foreach ( $verifyList as $m => $n ) {
  4091. if ($n [0] == $k) {
  4092. array_splice ( $verifyList, $m, 1, $v );
  4093. }
  4094. }
  4095. }
  4096. $loanList [$key] ['verifyList'] = $verifyList;
  4097. }
  4098. $htmlLoan = '';
  4099. if (isset ( $loanList [0] )) {
  4100. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  4101. if ($value ['status'] == 1)
  4102. $htmlLoan .= '<li class="done" >';
  4103. elseif ($value ['status'] == 3)
  4104. $htmlLoan .= '<li class="undone" >';
  4105. $htmlLoan .= '<div class="avtra"><img src="' . $value [2] . '_2.jpg"></div>';
  4106. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  4107. if (isset ( $value ['rolename'] ))
  4108. $htmlLoan .= $value ['rolename'];
  4109. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  4110. }
  4111. $data ['loanDate'] = $loanList [0] ['date'];
  4112. }
  4113. $data ['htmlLoan'] = $htmlLoan;
  4114. // print_r($loanList);
  4115. $Locate = 0;
  4116. $roleId = 0;
  4117. $button = 0;
  4118. if ($ap == 4)
  4119. $status = 4;
  4120. foreach ( $receiptList as $key => $value ) {
  4121. $receiptList [$key] ['Locate'] = $Locate;
  4122. $Locate ++;
  4123. $receiptList [$key] ['reviseDetail'] = array ();
  4124. if (! empty ( $value ['reviseDetail'] ))
  4125. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4126. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4127. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4128. $categoryDetil = $Lcategory->getOne ( array (
  4129. 'where' => 'cid=' . $value ['cid'],
  4130. 'asArray' => true
  4131. ) );
  4132. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4133. // 检测编辑状态
  4134. $verifyList = $verify->getOne ( array (
  4135. 'where' => 'vid=' . $value ['verify'],
  4136. 'asArray' => true
  4137. ) );
  4138. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4139. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4140. Doo::loadModel ( 'role' );
  4141. $role = new role ();
  4142. // print_r($verifyList);
  4143. $flag = true;
  4144. $roleKey = 0;
  4145. $endStaffArray = array ();
  4146. $roleArrayCopy = array ();
  4147. foreach ( $verifyList as $k => $v ) {
  4148. // init verifyStaff
  4149. if ($v [1] == 'ROLE') {
  4150. if (! empty ( $verifyStaff )) {
  4151. $endStaffArray = end ( $verifyStaff );
  4152. if ($v [0] == $endStaffArray ['nextStaff']) {
  4153. $roleId = $v [0];
  4154. }
  4155. }
  4156. $roleVerify = json_decode ( $v [3], true );
  4157. $roleKey = $k;
  4158. $roleArray = array ();
  4159. $rolename = $role->getOne ( array (
  4160. 'where' => 'rid=' . $v [0],
  4161. 'asArray' => true
  4162. ) );
  4163. foreach ( $roleVerify as $o => $p ) {
  4164. $staffID = explode ( '_', $p );
  4165. $staffInfo = $staff->getOne ( array (
  4166. 'where' => 'sid=' . $staffID [0],
  4167. 'asArray' => true
  4168. ) );
  4169. // print_r($staffID);
  4170. $exp = array (
  4171. 0 => $staffInfo ['sid'],
  4172. 1 => $staffID [1],
  4173. 2 => $staffInfo ['avatar'],
  4174. 'date' => '',
  4175. 'date' => '',
  4176. 'opinion' => '',
  4177. 'status' => '',
  4178. 'rolename' => $rolename ['name']
  4179. );
  4180. array_push ( $roleArray, $exp );
  4181. }
  4182. $roleArrayCopy [$v [0]] = $roleArray;
  4183. // $verifyList[$k]['roleArray']=$roleArray;
  4184. }
  4185. // print_r($roleArray);
  4186. $verifyList [$k] ['date'] = "";
  4187. $verifyList [$k] ['opinion'] = "";
  4188. $verifyList [$k] ['status'] = "";
  4189. if (empty ( $verifyStaff )) {
  4190. $verifyList [$k] ['date'] = "";
  4191. $verifyList [$k] ['opinion'] = "";
  4192. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4193. $verifyList [$k] ['status'] = 4;
  4194. $button = 4;
  4195. $flag = false;
  4196. }
  4197. } else {
  4198. foreach ( $verifyStaff as $m => $u ) {
  4199. if ($v [0] == $m) {
  4200. $verifyList [$k] ['date'] = $u ['date'];
  4201. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4202. $verifyList [$k] ['status'] = $u ['status'];
  4203. $flag = false;
  4204. break;
  4205. }
  4206. }
  4207. $endStaffArray = end ( $verifyStaff );
  4208. if (isset ( $endStaffArray ['ROLE'] )) {
  4209. } else {
  4210. $endKey = key ( $verifyStaff );
  4211. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4212. $button = 4;
  4213. $verifyList [$k] ['status'] = 4;
  4214. }
  4215. }
  4216. }
  4217. }
  4218. $rolename ['name'] = '';
  4219. if (! empty ( $roleId )) {
  4220. Doo::loadModel ( 'role' );
  4221. $role = new role ();
  4222. $rolename = $role->getOne ( array (
  4223. 'where' => 'rid=' . $roleId,
  4224. 'asArray' => true
  4225. ) );
  4226. }
  4227. if (! empty ( $verifyStaff ))
  4228. $endStaffArray = end ( $verifyStaff );
  4229. $KOP = false;
  4230. foreach ( $roleArrayCopy as $P => $A ) {
  4231. foreach ( $A as $MKI => $AVL ) {
  4232. if (! empty ( $verifyStaff )) {
  4233. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4234. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4235. $button = 4;
  4236. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4237. }
  4238. foreach ( $verifyStaff as $m => $u ) {
  4239. $AVLFK = $AVL [0] . '_R';
  4240. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4241. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4242. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4243. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4244. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4245. break;
  4246. }
  4247. }
  4248. } else {
  4249. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4250. $button = 4;
  4251. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4252. }
  4253. }
  4254. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4255. $KOP = true;
  4256. }
  4257. }
  4258. foreach ( $roleArrayCopy as $k => $v ) {
  4259. foreach ( $verifyList as $m => $n ) {
  4260. if ($n [0] == $k) {
  4261. array_splice ( $verifyList, $m, 1, $v );
  4262. }
  4263. }
  4264. }
  4265. // print_r($verifyList);
  4266. $receiptList [$key] ['verifyList'] = $verifyList;
  4267. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4268. 'where' => 'sid=' . $value ['staff'],
  4269. 'asArray' => true
  4270. ) );
  4271. $receiptList [$key] ['button'] = $button;
  4272. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4273. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4274. $relust = $value ['sum'] - $value ['loanSum'];
  4275. $receiptList [$key] ['relust'] = $relust;
  4276. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4277. }
  4278. // print_r($receiptList);die;
  4279. // $data['verifyDetail']=$verifyDetail;
  4280. $mothHtml = "";
  4281. for($i = 1; $i <= 12; $i ++) {
  4282. if ($month == $i)
  4283. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4284. else
  4285. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4286. }
  4287. // 获取审批日志
  4288. Doo::loadModel ( 'receiptLog' );
  4289. $receiptLog = new receiptLog ();
  4290. $rlList = array ();
  4291. $rlInfo = $receiptLog->getOne ( array (
  4292. 'where' => 'rid=' . $rid . ' and status=4',
  4293. 'asArray' => true
  4294. ) );
  4295. $tijdate = $receiptLog->getOne ( array (
  4296. 'where' => 'rid=' . $rid . ' and status=2',
  4297. 'asc' => 'rlid',
  4298. 'asArray' => true
  4299. ) );
  4300. if (! empty ( $rlInfo )) {
  4301. $rlList = $receiptLog->find ( array (
  4302. 'where' => 'rid=' . $rid,
  4303. 'asc' => 'rlid',
  4304. 'asArray' => true
  4305. ) );
  4306. }
  4307. // echo $rid;
  4308. // print_r($receiptList);
  4309. $receiptList [0] ['rlList'] = $rlList;
  4310. // print_r($receiptList);
  4311. $enclosurList = $enclosur->find ( array (
  4312. 'where' => 'rid=' . $rid,
  4313. 'asArray' => true
  4314. ) );
  4315. $enclosurHtml = '';
  4316. foreach ( $enclosurList as $value ) {
  4317. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4318. }
  4319. $data ['enclosurHtml'] = $enclosurHtml;
  4320. $data ['rolename'] = $rolename ['name'];
  4321. // $data['datetij']=$tijdate['date'];
  4322. $data ['mothHtml'] = $mothHtml;
  4323. // print_r($receiptList);
  4324. $data ['rid'] = $rid;
  4325. $data ['tijdate'] = $tijdate ['date'];
  4326. $data ['receiptList'] = $receiptList;
  4327. $data ['receiptApprovalCount'] = count ( $receiptList );
  4328. $data ['status'] = $status;
  4329. $data ['year'] = $year;
  4330. $data ['categoryList'] = $categoryList;
  4331. $data ['staffList'] = $staffList;
  4332. $data ['cid'] = $cid;
  4333. $data ['sid'] = $sid;
  4334. $data ['ap'] = $ap;
  4335. $data ['memu'] = "receipt";
  4336. $data ['staff'] = $this->staff;
  4337. $data ['receiptMemu'] = 'approvalExpenses';
  4338. $data ['verifyId'] = $this->verifyId;
  4339. $data ['executeId'] = $this->executeId;
  4340. $this->render ( "/admin/receiptburEdi", $data );
  4341. }
  4342. function hisImplement() {
  4343. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4344. if (empty ( $item ))
  4345. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "pendImplement";
  4346. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  4347. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4348. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  4349. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  4350. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  4351. Doo::loadModel ( 'receipt' );
  4352. $receipt = new receipt ();
  4353. Doo::loadModel ( 'L_category' );
  4354. $Lcategory = new L_category ();
  4355. Doo::loadModel ( 'verify' );
  4356. Doo::loadModel ( 'statistics' );
  4357. $statistics = new statistics ();
  4358. $verify = new verify ();
  4359. Doo::loadModel ( 'staff' );
  4360. $staff = new staff ();
  4361. Doo::loadClass ( 'XDeode' );
  4362. $XDeode = new XDeode ( 5 );
  4363. $condition = "";
  4364. if ($item == "expenses")
  4365. $condition = " and Rtype=1 ";
  4366. elseif ($item == "receipts")
  4367. $condition = " and Rtype=0 ";
  4368. elseif ($item == "remits")
  4369. $condition = " and Rtype=2 ";
  4370. elseif($item =="pendImplement"){
  4371. $condition = ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  4372. }
  4373. //'and (executeCopy like "%["' . $this->staff [0] ['sid'] . '"%" and executeStaff not like "%{"' . $this->staff [0] ['sid'] . '"%" )';
  4374. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  4375. $sopString = "";
  4376. if (empty($rdate))
  4377. $dateCondition = " and Year(date) =" . $year;
  4378. else
  4379. $dateCondition=" and date_format(date,'%Y-%m-%d')='".$rdate."' ";
  4380. if ($item == 'teipts') {
  4381. $statusCon = '(status=1 or status=6 )';
  4382. $dateCondition=" and date_format(pastDate,'%Y-%m-%d')='".$rdate."' ";
  4383. } elseif ($item == 'alerpts') {
  4384. $statusCon = '(status=8 or status=9 )';
  4385. if (empty($rdate))
  4386. $dateCondition = " and Year(date) =" . $year;
  4387. else
  4388. $dateCondition=" and date_format(executeDate,'%Y-%m-%d')='".$rdate."' ";
  4389. }
  4390. /*
  4391. if ($item == 'teipts') {
  4392. $statusCon = '(status=1 or status=6 )';
  4393. $dateCondition = " and Year(pastDate) =" . $year;
  4394. if ($moth != 'MONTH')
  4395. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth;
  4396. if ($day != 'DAY')
  4397. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth . " and day(pastDate)=" . $day;
  4398. } elseif ($item == 'alerpts') {
  4399. $statusCon = '(status=8 or status=9 )';
  4400. $dateCondition = " and Year(executeDate) =" . $year;
  4401. if ($moth != 'MONTH')
  4402. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  4403. if ($day != 'DAY')
  4404. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  4405. }
  4406. */
  4407. if ($sop != 'SOP')
  4408. $sopString = " and staff=" . $sop;
  4409. // $noPassSum=$receipt->receiptByYear($year,$this->staff[0]['sid']); and (status=1 or status=6)
  4410. $receiptList = $receipt->find ( array (
  4411. 'where' => $statusCon . $condition . $dateCondition . $sopString,
  4412. 'desc' => 'rid',
  4413. 'asArray' => true
  4414. ) );
  4415. // 员工筛选
  4416. $receiptList2 = $receipt->find ( array (
  4417. 'where' => $statusCon . $condition . $dateCondition,
  4418. 'desc' => 'rid',
  4419. 'asArray' => true
  4420. ) );
  4421. $sopStaff = array ();
  4422. foreach ( $receiptList2 as $key => $value ) {
  4423. $staffDetail = $staff->getOne ( array (
  4424. 'where' => 'sid=' . $value ['staff'],
  4425. 'asArray' => true
  4426. ) );
  4427. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  4428. }
  4429. $Locate = 0;
  4430. $roleId = 0;
  4431. $button = 0;
  4432. foreach ( $receiptList as $key => $value ) {
  4433. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4434. $receiptList [$key] ['Texe'] = 'false';
  4435. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  4436. $receiptList [$key] ['Texe'] = 'true';
  4437. }
  4438. $receiptList [$key] ['TRexe'] = 'true';
  4439. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  4440. $receiptList [$key] ['TRexe'] = 'false';
  4441. }
  4442. $receiptList [$key] ['Locate'] = $Locate;
  4443. $Locate ++;
  4444. $receiptList [$key] ['reviseDetail'] = array ();
  4445. if (! empty ( $value ['reviseDetail'] ))
  4446. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4447. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4448. $categoryDetil = $Lcategory->getOne ( array (
  4449. 'where' => 'cid=' . $value ['cid'],
  4450. 'asArray' => true
  4451. ) );
  4452. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4453. // 检测编辑状态
  4454. $verifyList = $verify->getOne ( array (
  4455. 'where' => 'vid=' . $value ['verify'],
  4456. 'asArray' => true
  4457. ) );
  4458. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4459. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4460. Doo::loadModel ( 'role' );
  4461. $role = new role ();
  4462. $flag = true;
  4463. $roleKey = 0;
  4464. $endStaffArray = array ();
  4465. $roleArrayCopy = array ();
  4466. foreach ( $verifyList as $k => $v ) {
  4467. // init verifyStaff
  4468. if ($v [1] == 'ROLE') {
  4469. if (! empty ( $verifyStaff )) {
  4470. $endStaffArray = end ( $verifyStaff );
  4471. }
  4472. $roleVerify = json_decode ( $v [3], true );
  4473. $roleKey = $k;
  4474. $roleArray = array ();
  4475. $rolename = $role->getOne ( array (
  4476. 'where' => 'rid=' . $v [0],
  4477. 'asArray' => true
  4478. ) );
  4479. foreach ( $roleVerify as $o => $p ) {
  4480. $staffID = explode ( '_', $p );
  4481. $staffInfo = $staff->getOne ( array (
  4482. 'where' => 'sid=' . $staffID [0],
  4483. 'asArray' => true
  4484. ) );
  4485. $exp = array (
  4486. 0 => $staffInfo ['sid'],
  4487. 1 => $staffID [1],
  4488. 2 => $staffInfo ['avatar'],
  4489. 'date' => '',
  4490. 'date' => '',
  4491. 'opinion' => '',
  4492. 'status' => '',
  4493. 'rolename' => $rolename ['name']
  4494. );
  4495. array_push ( $roleArray, $exp );
  4496. }
  4497. $roleArrayCopy [$v [0]] = $roleArray;
  4498. }
  4499. $verifyList [$k] ['date'] = "";
  4500. $verifyList [$k] ['opinion'] = "";
  4501. $verifyList [$k] ['status'] = "";
  4502. if (empty ( $verifyStaff )) {
  4503. $verifyList [$k] ['date'] = "";
  4504. $verifyList [$k] ['opinion'] = "";
  4505. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4506. $verifyList [$k] ['status'] = 4;
  4507. $flag = false;
  4508. }
  4509. } else {
  4510. foreach ( $verifyStaff as $m => $u ) {
  4511. if ($v [0] == $m) {
  4512. $verifyList [$k] ['date'] = $u ['date'];
  4513. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4514. $verifyList [$k] ['status'] = $u ['status'];
  4515. $flag = false;
  4516. break;
  4517. }
  4518. }
  4519. $endStaffArray = end ( $verifyStaff );
  4520. }
  4521. }
  4522. $rolename ['name'] = '';
  4523. if (! empty ( $roleId )) {
  4524. Doo::loadModel ( 'role' );
  4525. $role = new role ();
  4526. $rolename = $role->getOne ( array (
  4527. 'where' => 'rid=' . $roleId,
  4528. 'asArray' => true
  4529. ) );
  4530. }
  4531. if (! empty ( $verifyStaff ))
  4532. $endStaffArray = end ( $verifyStaff );
  4533. $KOP = false;
  4534. foreach ( $roleArrayCopy as $P => $A ) {
  4535. foreach ( $A as $MKI => $AVL ) {
  4536. if (! empty ( $verifyStaff )) {
  4537. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4538. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4539. $button = 4;
  4540. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4541. }
  4542. foreach ( $verifyStaff as $m => $u ) {
  4543. $AVLFK = $AVL [0] . '_R';
  4544. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4545. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4546. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4547. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4548. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4549. break;
  4550. }
  4551. }
  4552. } else {
  4553. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4554. $button = 4;
  4555. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4556. }
  4557. }
  4558. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4559. $KOP = true;
  4560. }
  4561. }
  4562. foreach ( $roleArrayCopy as $k => $v ) {
  4563. foreach ( $verifyList as $m => $n ) {
  4564. if ($n [0] == $k) {
  4565. array_splice ( $verifyList, $m, 1, $v );
  4566. }
  4567. }
  4568. }
  4569. $receiptList [$key] ['verifyList'] = $verifyList;
  4570. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4571. 'where' => 'sid=' . $value ['staff'],
  4572. 'asArray' => true
  4573. ) );
  4574. $receiptList [$key] ['button'] = $button;
  4575. }
  4576. // print_r($receiptList);
  4577. $mothHtml = "";
  4578. for($i = 1; $i <= 12; $i ++) {
  4579. if ($moth == $i)
  4580. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4581. else
  4582. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4583. }
  4584. $dayHtml = "";
  4585. if ($day != "DAY" || $moth != "MONTH") {
  4586. for($i = 1; $i <= 31; $i ++) {
  4587. if ($day == $i)
  4588. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  4589. else
  4590. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  4591. }
  4592. }
  4593. $sopHtml = "";
  4594. foreach ( $sopStaff as $key => $value ) {
  4595. if ($sop == $key)
  4596. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4597. else
  4598. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4599. }
  4600. $data['rdate']=$rdate;
  4601. $data ['sopHtml'] = $sopHtml;
  4602. $data ['dayHtml'] = $dayHtml;
  4603. $data ['mothHtml'] = $mothHtml;
  4604. $data ['receiptList'] = $receiptList;
  4605. $data ['memu'] = "receipt";
  4606. $data ['staff'] = $this->staff;
  4607. $data ['receiptMemu'] = 'implement';
  4608. $data ['verifyId'] = $this->verifyId;
  4609. $data ['executeId'] = $this->executeId;
  4610. $data ['item'] = $item;
  4611. $data ['year'] = $year;
  4612. $data ['moth'] = $moth;
  4613. $data ['day'] = $day;
  4614. $data ['sop'] = $sop;
  4615. $this->render ( "/admin/hisImplement", $data );
  4616. }
  4617. function ajaxExamine() {
  4618. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4619. Doo::loadModel ( 'receipt' );
  4620. $receipt = new receipt ();
  4621. if (! empty ( $rid )) {
  4622. $rLRes = $receipt->find ( array (
  4623. '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,
  4624. 'asArray' => true
  4625. ) );
  4626. echo json_encode ( array (
  4627. 'status' => 1,
  4628. 'receipt' => $rLRes [0]
  4629. ) );
  4630. die ();
  4631. }
  4632. echo json_encode ( array (
  4633. 'status' => 0,
  4634. 'receipt' => array ()
  4635. ) );
  4636. die ();
  4637. }
  4638. /*
  4639. * 废弃
  4640. */
  4641. function myReceipt() {
  4642. // all approval past withdraw
  4643. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4644. if (empty ( $item ))
  4645. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4646. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4647. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  4648. Doo::loadModel ( 'receipt' );
  4649. $receipt = new receipt ();
  4650. // pre-loaded
  4651. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4652. // have cache
  4653. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  4654. if (! empty ( $moth )) // yearPage
  4655. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  4656. $this->showCache ( $path );
  4657. }
  4658. Doo::loadModel ( 'L_category' );
  4659. $Lcategory = new L_category ();
  4660. Doo::loadModel ( 'verify' );
  4661. Doo::loadModel ( 'statistics' );
  4662. $statistics = new statistics ();
  4663. $verify = new verify ();
  4664. Doo::loadModel ( 'staff' );
  4665. $staff = new staff ();
  4666. $condition = " and status!=0 ";
  4667. if ($item == "approval")
  4668. $condition = " and status=2 ";
  4669. elseif ($item == "withdraw")
  4670. $condition = " and status=3 ";
  4671. elseif ($item == "past")
  4672. $condition = " and status=1 ";
  4673. elseif ($item == "whdw")
  4674. $condition = " and status=4 ";
  4675. $dateCondition = " and Year(date) =" . $year;
  4676. if (! empty ( $moth )) {
  4677. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  4678. $stList = $statistics->getOne ( array (
  4679. 'select' => 'rePrice ,agPrice',
  4680. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  4681. 'asArray' => true
  4682. ) );
  4683. } else
  4684. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  4685. if (empty ( $stList ))
  4686. $stList = array (
  4687. 'rePrice' => 0,
  4688. 'agPrice' => 0
  4689. );
  4690. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  4691. $data ['stList'] = array (
  4692. 'rePrice' => $stList ['rePrice'],
  4693. 'agPrice' => $stList ['agPrice'],
  4694. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  4695. );
  4696. $receiptList = $receipt->find ( array (
  4697. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  4698. 'desc' => 'rid',
  4699. 'asArray' => true
  4700. ) );
  4701. $Locate = 0;
  4702. $roleId = 0;
  4703. $button = 0;
  4704. foreach ( $receiptList as $key => $value ) {
  4705. $receiptList [$key] ['Locate'] = $Locate;
  4706. $Locate ++;
  4707. $receiptList [$key] ['reviseDetail'] = array ();
  4708. if (! empty ( $value ['reviseDetail'] ))
  4709. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4710. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4711. $categoryDetil = $Lcategory->getOne ( array (
  4712. 'where' => 'cid=' . $value ['cid'],
  4713. 'asArray' => true
  4714. ) );
  4715. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4716. // 检测编辑状态
  4717. $verifyList = $verify->getOne ( array (
  4718. 'where' => 'vid=' . $value ['verify'],
  4719. 'asArray' => true
  4720. ) );
  4721. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4722. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4723. Doo::loadModel ( 'role' );
  4724. $role = new role ();
  4725. $flag = true;
  4726. $roleKey = 0;
  4727. $endStaffArray = array ();
  4728. $roleArrayCopy = array ();
  4729. foreach ( $verifyList as $k => $v ) {
  4730. // init verifyStaff
  4731. if ($v [1] == 'ROLE') {
  4732. if (! empty ( $verifyStaff )) {
  4733. $endStaffArray = end ( $verifyStaff );
  4734. // if ($v[0]==$endStaffArray['nextStaff']){
  4735. // $roleId=$v[0];
  4736. // }
  4737. }
  4738. $roleVerify = json_decode ( $v [3], true );
  4739. $roleKey = $k;
  4740. $roleArray = array ();
  4741. $rolename = $role->getOne ( array (
  4742. 'where' => 'rid=' . $v [0],
  4743. 'asArray' => true
  4744. ) );
  4745. foreach ( $roleVerify as $o => $p ) {
  4746. $staffID = explode ( '_', $p );
  4747. $staffInfo = $staff->getOne ( array (
  4748. 'where' => 'sid=' . $staffID [0],
  4749. 'asArray' => true
  4750. ) );
  4751. // print_r($staffID);
  4752. $exp = array (
  4753. 0 => $staffInfo ['sid'],
  4754. 1 => $staffID [1],
  4755. 2 => $staffInfo ['avatar'],
  4756. 'date' => '',
  4757. 'date' => '',
  4758. 'opinion' => '',
  4759. 'status' => '',
  4760. 'rolename' => $rolename ['name']
  4761. );
  4762. array_push ( $roleArray, $exp );
  4763. }
  4764. $roleArrayCopy [$v [0]] = $roleArray;
  4765. // $verifyList[$k]['roleArray']=$roleArray;
  4766. }
  4767. $verifyList [$k] ['date'] = "";
  4768. $verifyList [$k] ['opinion'] = "";
  4769. $verifyList [$k] ['status'] = "";
  4770. if (empty ( $verifyStaff )) {
  4771. $verifyList [$k] ['date'] = "";
  4772. $verifyList [$k] ['opinion'] = "";
  4773. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4774. $verifyList [$k] ['status'] = 4;
  4775. $flag = false;
  4776. }
  4777. } else {
  4778. foreach ( $verifyStaff as $m => $u ) {
  4779. if ($v [0] == $m) {
  4780. $verifyList [$k] ['date'] = $u ['date'];
  4781. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4782. $verifyList [$k] ['status'] = $u ['status'];
  4783. $flag = false;
  4784. break;
  4785. }
  4786. }
  4787. $endStaffArray = end ( $verifyStaff );
  4788. if (isset ( $endStaffArray ['ROLE'] )) {
  4789. } else {
  4790. // $endKey=key($verifyStaff);
  4791. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4792. // $button=4;
  4793. // $verifyList[$k]['status']=4;
  4794. // }
  4795. }
  4796. }
  4797. }
  4798. $rolename ['name'] = '';
  4799. if (! empty ( $roleId )) {
  4800. Doo::loadModel ( 'role' );
  4801. $role = new role ();
  4802. $rolename = $role->getOne ( array (
  4803. 'where' => 'rid=' . $roleId,
  4804. 'asArray' => true
  4805. ) );
  4806. }
  4807. if (! empty ( $verifyStaff ))
  4808. $endStaffArray = end ( $verifyStaff );
  4809. $KOP = false;
  4810. foreach ( $roleArrayCopy as $P => $A ) {
  4811. foreach ( $A as $MKI => $AVL ) {
  4812. if (! empty ( $verifyStaff )) {
  4813. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4814. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4815. $button = 4;
  4816. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4817. }
  4818. foreach ( $verifyStaff as $m => $u ) {
  4819. $AVLFK = $AVL [0] . '_R';
  4820. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4821. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4822. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4823. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4824. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4825. break;
  4826. }
  4827. }
  4828. } else {
  4829. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4830. $button = 4;
  4831. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4832. }
  4833. }
  4834. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4835. $KOP = true;
  4836. }
  4837. }
  4838. foreach ( $roleArrayCopy as $k => $v ) {
  4839. foreach ( $verifyList as $m => $n ) {
  4840. if ($n [0] == $k) {
  4841. array_splice ( $verifyList, $m, 1, $v );
  4842. }
  4843. }
  4844. }
  4845. $receiptList [$key] ['verifyList'] = $verifyList;
  4846. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4847. 'where' => 'sid=' . $value ['staff'],
  4848. 'asArray' => true
  4849. ) );
  4850. $receiptList [$key] ['button'] = $button;
  4851. }
  4852. // print_r($receiptList);die;
  4853. $mothHtml = "";
  4854. for($i = 1; $i <= 12; $i ++) {
  4855. if ($moth == $i)
  4856. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4857. else
  4858. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4859. }
  4860. $data ['mothHtml'] = $mothHtml;
  4861. $data ['receiptList'] = $receiptList;
  4862. $data ['memu'] = "receipt";
  4863. $data ['staff'] = $this->staff;
  4864. $data ['receiptMemu'] = 'receipt';
  4865. $data ['verifyId'] = $this->verifyId;
  4866. $data ['executeId'] = $this->executeId;
  4867. $data ['item'] = $item;
  4868. $data ['year'] = $year;
  4869. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4870. // sufficient condition to generate cache
  4871. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  4872. $receiptList = $receipt->find ( array (
  4873. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  4874. 'asArray' => true
  4875. ) );
  4876. if (empty ( $receiptList )) { // generated files
  4877. ob_start ();
  4878. $this->render ( "/admin/saea_myList", $data );
  4879. $this->cacheFile ( $path );
  4880. die ();
  4881. // $content = ob_get_contents();
  4882. // $fp = fopen($path, "w");
  4883. // fwrite($fp, $content);
  4884. // fclose($fp);
  4885. }
  4886. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  4887. $receiptList = $receipt->find ( array (
  4888. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  4889. 'asArray' => true
  4890. ) );
  4891. if (empty ( $receiptList )) { // generated files
  4892. ob_start ();
  4893. $this->render ( "/admin/saea_myList", $data );
  4894. $this->cacheFile ( $path );
  4895. die ();
  4896. }
  4897. }
  4898. }
  4899. $this->render ( "/admin/saea_myList", $data );
  4900. }
  4901. function saeaCreate() {
  4902. Doo::loadModel ( 'accountItem' );
  4903. Doo::loadModel ( 'verify' );
  4904. Doo::loadModel ( 'receipt' );
  4905. Doo::loadModel ( 'L_category' );
  4906. $lCategory = new L_category ();
  4907. $receipt = new receipt ();
  4908. $verify = new verify ();
  4909. $accountItem = new accountItem ();
  4910. Doo::loadModel ( "role" );
  4911. $role = new role ();
  4912. $acItem = $accountItem->find ( array (
  4913. 'asArray' => true
  4914. ) );
  4915. $veList = $verify->find ( array (
  4916. 'asArray' => true
  4917. ) );
  4918. foreach ( $veList as $key => $value ) {
  4919. $v = json_decode ( $value ['staff'] );
  4920. $list = array ();
  4921. foreach ( $v as $n => $m ) {
  4922. if ($m ['1'] == 'ROLE') {
  4923. $roleInfo = $role->getOne ( array (
  4924. 'where' => 'rid=' . $m [0],
  4925. 'asArray' => true
  4926. ) );
  4927. $v [$n] [1] = $roleInfo ['name'];
  4928. array_push ( $list, $roleInfo ['name'] );
  4929. } else {
  4930. array_push ( $list, $v [$n] [1] );
  4931. }
  4932. }
  4933. $veList [$key] ['staff'] = implode ( '>', $list );
  4934. }
  4935. $data ['category'] = $lCategory->find ( array (
  4936. 'asArray' => true
  4937. ) );
  4938. $data ['veList'] = $veList;
  4939. $data ['acItem'] = $acItem;
  4940. $data ['memu'] = "receipt";
  4941. $data ['staff'] = $this->staff;
  4942. $data ['receiptMemu'] = 'saeaBorad';
  4943. $data ['verifyId'] = $this->verifyId;
  4944. $data ['executeId'] = $this->executeId;
  4945. $this->render ( "/admin/saea_create", $data );
  4946. }
  4947. function addReceipt() {
  4948. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  4949. $agency = $this->get_args ( 'agency' );
  4950. $travel = $this->get_args ( 'travel' );
  4951. $train = $this->get_args ( 'train' );
  4952. $other = $this->get_args ( 'other' );
  4953. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  4954. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  4955. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  4956. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  4957. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  4958. Doo::loadModel ( 'receipt' );
  4959. Doo::loadModel ( 'receiptDetail' );
  4960. Doo::loadModel ( 'accountItem' );
  4961. $accountItem = new accountItem ();
  4962. $receipt = new receipt ();
  4963. Doo::loadModel ( 'enclosur' );
  4964. Doo::loadModel ( 'execute' );
  4965. $execute = new execute ();
  4966. $executeDetail = $execute->getOne ( array (
  4967. 'where' => 'mold="报销单执行人"',
  4968. 'asArray' => true
  4969. ) );
  4970. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  4971. // if(!empty($receiptDetail))
  4972. // return "/referReceipt/".$receiptDetail['rid'];
  4973. $aItem = $accountItem->find ( array (
  4974. 'asArray' => true
  4975. ) );
  4976. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  4977. $ag = $tr = $ta = $ot = 0;
  4978. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  4979. foreach ( $aItem as $key => $value ) {
  4980. if ($value ['category'] == $this->AGENCY) {
  4981. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  4982. array_push ( $accountJson [$this->AGENCY], array (
  4983. 'aid' => $value ['aid'],
  4984. 'name' => $value ['name'],
  4985. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  4986. ) );
  4987. $sum += $agency [$ag];
  4988. $agencySum += $agency [$ag];
  4989. }
  4990. $ag ++;
  4991. }
  4992. if ($value ['category'] == $this->TRAVEL) {
  4993. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  4994. array_push ( $accountJson [$this->TRAVEL], array (
  4995. 'aid' => $value ['aid'],
  4996. 'name' => $value ['name'],
  4997. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  4998. ) );
  4999. $sum += $travel [$tr];
  5000. $travelSum += $travel [$tr];
  5001. }
  5002. $tr ++;
  5003. }
  5004. if ($value ['category'] == $this->TRAIN) {
  5005. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5006. array_push ( $accountJson [$this->TRAIN], array (
  5007. 'aid' => $value ['aid'],
  5008. 'name' => $value ['name'],
  5009. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5010. ) );
  5011. $sum += $train [$ta];
  5012. $trainSum += $train [$ta];
  5013. }
  5014. $ta ++;
  5015. }
  5016. if ($value ['category'] == $this->OTHER) {
  5017. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5018. array_push ( $accountJson [$this->OTHER], array (
  5019. 'aid' => $value ['aid'],
  5020. 'name' => $value ['name'],
  5021. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5022. ) );
  5023. $sum += $other [$ot];
  5024. $otherSum += $other [$ot];
  5025. }
  5026. $ot ++;
  5027. }
  5028. }
  5029. $accountJson ['cSum'] = array (
  5030. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5031. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5032. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5033. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5034. );
  5035. // 报销单
  5036. $receipt->accountItem = json_encode ( $accountJson );
  5037. $receipt->staff = $this->staff [0] ['sid'];
  5038. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5039. $receipt->date = date ( "Y-m-d" );
  5040. $receipt->cid = $cid;
  5041. $receipt->status = 5;
  5042. // 修改审批流程加入角色
  5043. $receipt->verify = $verify;
  5044. $receipt->executeCopy = $executeDetail ['staff'];
  5045. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  5046. $receipt->explanation = $explanation;
  5047. $rid = $receipt->insert ();
  5048. // 附件
  5049. if (! empty ( $enclosurName )) {
  5050. $enclosurArray = explode ( '-', $enclosurName );
  5051. foreach ( $enclosurArray as $value ) {
  5052. $enclosur = new enclosur ();
  5053. $enclosur->name = $value;
  5054. $enclosur->rid = $rid;
  5055. $enclosur->insert ();
  5056. }
  5057. // print_r($enclosurArray);die;
  5058. }
  5059. // 报销详情
  5060. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5061. $receiptDetail = new receiptDetail ();
  5062. $receiptDetail->staff = $this->staff [0] ['sid'];
  5063. $receiptDetail->item = $value ['name'];
  5064. $receiptDetail->itemCategory = $this->AGENCY;
  5065. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5066. $receiptDetail->date = date ( "Y-m-d" );
  5067. $receiptDetail->cid = $cid;
  5068. $receiptDetail->rid = $rid;
  5069. $receiptDetail->status = 4;
  5070. $receiptDetail->insert ();
  5071. }
  5072. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5073. $receiptDetail = new receiptDetail ();
  5074. $receiptDetail->staff = $this->staff [0] ['sid'];
  5075. $receiptDetail->item = $value ['name'];
  5076. $receiptDetail->itemCategory = $this->TRAVEL;
  5077. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5078. $receiptDetail->date = date ( "Y-m-d" );
  5079. $receiptDetail->cid = $cid;
  5080. $receiptDetail->rid = $rid;
  5081. $receiptDetail->status = 4;
  5082. $receiptDetail->insert ();
  5083. }
  5084. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5085. $receiptDetail = new receiptDetail ();
  5086. $receiptDetail->staff = $this->staff [0] ['sid'];
  5087. $receiptDetail->item = $value ['name'];
  5088. $receiptDetail->itemCategory = $this->TRAIN;
  5089. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5090. $receiptDetail->date = date ( "Y-m-d" );
  5091. $receiptDetail->cid = $cid;
  5092. $receiptDetail->rid = $rid;
  5093. $receiptDetail->status = 4;
  5094. $receiptDetail->insert ();
  5095. }
  5096. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5097. $receiptDetail = new receiptDetail ();
  5098. $receiptDetail->staff = $this->staff [0] ['sid'];
  5099. $receiptDetail->item = $value ['name'];
  5100. $receiptDetail->itemCategory = $this->OTHER;
  5101. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5102. $receiptDetail->date = date ( "Y-m-d" );
  5103. $receiptDetail->cid = $cid;
  5104. $receiptDetail->rid = $rid;
  5105. $receiptDetail->status = 4;
  5106. $receiptDetail->insert ();
  5107. }
  5108. // return "/referReceipt/".$rid;
  5109. }
  5110. return "/saeaBorad";
  5111. }
  5112. function referReceipt() {
  5113. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  5114. Doo::loadModel ( 'receipt' );
  5115. Doo::loadModel ( 'verify' );
  5116. $verify = new verify ();
  5117. $receipt = new receipt ();
  5118. Doo::loadModel ( 'L_category' );
  5119. $lCategory = new L_category ();
  5120. Doo::loadModel ( "role" );
  5121. $role = new role ();
  5122. $receiptDetail = $receipt->find ( array (
  5123. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  5124. 'asArray' => true
  5125. ) );
  5126. if (empty ( $receiptDetail ))
  5127. return "/addReceipt";
  5128. foreach ( $receiptDetail as $key => $value ) {
  5129. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5130. $veList = $verify->getOne ( array (
  5131. 'where' => 'vid=' . $value ['verify'],
  5132. 'asArray' => true
  5133. ) );
  5134. $v = json_decode ( $veList ['staff'] );
  5135. array_push ( $v [0], $veList ['description'] );
  5136. foreach ( $v as $n => $m ) {
  5137. if ($m ['1'] == 'ROLE') {
  5138. $roleInfo = $role->getOne ( array (
  5139. 'where' => 'rid=' . $m [0],
  5140. 'asArray' => true
  5141. ) );
  5142. $v [$n] [1] = $roleInfo ['name'];
  5143. }
  5144. }
  5145. $receiptDetail [$key] ['staff'] = $v;
  5146. $category = $lCategory->getOne ( array (
  5147. 'where' => 'cid=' . $value ['cid'],
  5148. 'asArray' => true
  5149. ) );
  5150. $receiptDetail [$key] ['category'] = $category ['title'];
  5151. }
  5152. // print_r($receiptDetail);
  5153. $data ['receiptDetail'] = $receiptDetail;
  5154. $data ['memu'] = "receipt";
  5155. $data ['staff'] = $this->staff;
  5156. $data ['receiptMemu'] = 'saeaCreate';
  5157. $data ['verifyId'] = $this->verifyId;
  5158. $data ['executeId'] = $this->executeId;
  5159. $this->render ( "/admin/saea_confirm", $data );
  5160. }
  5161. function editReceipt() {
  5162. // edit status 4
  5163. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5164. // echo $rid;
  5165. Doo::loadModel ( 'accountItem' );
  5166. Doo::loadModel ( 'verify' );
  5167. Doo::loadModel ( 'receipt' );
  5168. $receipt = new receipt ();
  5169. $verify = new verify ();
  5170. $accountItem = new accountItem ();
  5171. Doo::loadModel ( 'L_category' );
  5172. $lCategory = new L_category ();
  5173. Doo::loadModel ( "role" );
  5174. $role = new role ();
  5175. $receiptDetail = $receipt->getOne ( array (
  5176. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  5177. 'asArray' => true
  5178. ) );
  5179. if (empty ( $receiptDetail ))
  5180. return "/saeaCreate";
  5181. $acItem = $accountItem->find ( array (
  5182. 'asArray' => true
  5183. ) );
  5184. $veList = $verify->find ( array (
  5185. 'asArray' => true
  5186. ) );
  5187. foreach ( $veList as $key => $value ) {
  5188. $v = json_decode ( $value ['staff'] );
  5189. $list = array ();
  5190. foreach ( $v as $n => $m ) {
  5191. if ($m ['1'] == 'ROLE') {
  5192. $roleInfo = $role->getOne ( array (
  5193. 'where' => 'rid=' . $m [0],
  5194. 'asArray' => true
  5195. ) );
  5196. $v [$n] [1] = $roleInfo ['name'];
  5197. array_push ( $list, $roleInfo ['name'] );
  5198. } else {
  5199. array_push ( $list, $v [$n] [1] );
  5200. }
  5201. }
  5202. $veList [$key] ['staff'] = implode ( '>', $list );
  5203. }
  5204. // 配置编辑信息
  5205. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  5206. foreach ( $acItem as $key => $value ) {
  5207. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  5208. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  5209. $acItem [$key] ['price'] = $v ['price'];
  5210. }
  5211. }
  5212. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  5213. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  5214. $acItem [$key] ['price'] = $v ['price'];
  5215. }
  5216. }
  5217. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  5218. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  5219. $acItem [$key] ['price'] = $v ['price'];
  5220. }
  5221. }
  5222. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  5223. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  5224. $acItem [$key] ['price'] = $v ['price'];
  5225. }
  5226. }
  5227. }
  5228. $data ['category'] = $lCategory->find ( array (
  5229. 'asArray' => true
  5230. ) );
  5231. $data ['cSum'] = $accountItemList ['cSum'];
  5232. $data ['sum'] = $receiptDetail ['sum'];
  5233. $data ['receiptDetail'] = $receiptDetail;
  5234. $data ['veList'] = $veList;
  5235. $data ['acItem'] = $acItem;
  5236. $data ['memu'] = "receipt";
  5237. $data ['staff'] = $this->staff;
  5238. $data ['receiptMemu'] = 'saeaBorad';
  5239. $data ['verify'] = $receiptDetail ['verify'];
  5240. $data ['verifyId'] = $this->verifyId;
  5241. $data ['executeId'] = $this->executeId;
  5242. $data ['rid'] = $rid;
  5243. $this->render ( "/admin/saea_edit", $data );
  5244. }
  5245. function updateReceipt() {
  5246. $agency = $this->get_args ( 'agency' );
  5247. $travel = $this->get_args ( 'travel' );
  5248. $train = $this->get_args ( 'train' );
  5249. $other = $this->get_args ( 'other' );
  5250. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5251. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5252. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5253. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5254. if (! empty ( $explanation )) {
  5255. Doo::loadModel ( 'receipt' );
  5256. Doo::loadModel ( 'receiptDetail' );
  5257. Doo::loadModel ( 'accountItem' );
  5258. $accountItem = new accountItem ();
  5259. $receipt = new receipt ();
  5260. Doo::loadModel ( 'execute' );
  5261. $execute = new execute ();
  5262. $receiptDetail = $receipt->getOne ( array (
  5263. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  5264. 'asArray' => true
  5265. ) );
  5266. if (empty ( $receiptDetail ))
  5267. return "/saeaBorad";
  5268. if ($receiptDetail ['Rtype'] == 1)
  5269. $executeDetail = $execute->getOne ( array (
  5270. 'where' => 'mold="借款费用执行人"',
  5271. 'asArray' => true
  5272. ) );
  5273. else
  5274. $executeDetail = $execute->getOne ( array (
  5275. 'where' => 'mold="报销单执行人"',
  5276. 'asArray' => true
  5277. ) );
  5278. $aItem = $accountItem->find ( array (
  5279. 'asArray' => true
  5280. ) );
  5281. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5282. $ag = $tr = $ta = $ot = 0;
  5283. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5284. foreach ( $aItem as $key => $value ) {
  5285. if ($value ['category'] == $this->AGENCY) {
  5286. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5287. array_push ( $accountJson [$this->AGENCY], array (
  5288. 'aid' => $value ['aid'],
  5289. 'name' => $value ['name'],
  5290. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5291. ) );
  5292. $sum += $agency [$ag];
  5293. $agencySum += $agency [$ag];
  5294. }
  5295. $ag ++;
  5296. }
  5297. if ($value ['category'] == $this->TRAVEL) {
  5298. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5299. array_push ( $accountJson [$this->TRAVEL], array (
  5300. 'aid' => $value ['aid'],
  5301. 'name' => $value ['name'],
  5302. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5303. ) );
  5304. $sum += $travel [$tr];
  5305. $travelSum += $travel [$tr];
  5306. }
  5307. $tr ++;
  5308. }
  5309. if ($value ['category'] == $this->TRAIN) {
  5310. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5311. array_push ( $accountJson [$this->TRAIN], array (
  5312. 'aid' => $value ['aid'],
  5313. 'name' => $value ['name'],
  5314. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5315. ) );
  5316. $sum += $train [$ta];
  5317. $trainSum += $train [$ta];
  5318. }
  5319. $ta ++;
  5320. }
  5321. if ($value ['category'] == $this->OTHER) {
  5322. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5323. array_push ( $accountJson [$this->OTHER], array (
  5324. 'aid' => $value ['aid'],
  5325. 'name' => $value ['name'],
  5326. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5327. ) );
  5328. $sum += $other [$ot];
  5329. $otherSum += $other [$ot];
  5330. }
  5331. $ot ++;
  5332. }
  5333. }
  5334. $accountJson ['cSum'] = array (
  5335. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5336. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5337. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5338. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5339. );
  5340. // 报销单
  5341. $rid = $receipt->rid = $receiptDetail ['rid'];
  5342. $receipt->accountItem = json_encode ( $accountJson );
  5343. $receipt->staff = $this->staff [0] ['sid'];
  5344. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5345. $receipt->date = date ( "Y-m-d" );
  5346. $receipt->cid = $cid;
  5347. if (($receiptDetail ['status'] != 4)) {
  5348. if ($receiptDetail ['Rtype'] == 1)
  5349. $receipt->status = 7;
  5350. else
  5351. $receipt->status = 5;
  5352. }
  5353. if ($receiptDetail != 4 && ! empty ( $verify ))
  5354. $receipt->verify = $verify;
  5355. $receipt->executeCopy = $executeDetail ['staff'];
  5356. $receipt->explanation = $explanation;
  5357. $receipt->update ();
  5358. $receiptDetail = new receiptDetail ();
  5359. $receiptDetail->delete ( array (
  5360. 'where' => 'rid=' . $rid
  5361. ) );
  5362. // 报销详情
  5363. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5364. $receiptDetail = new receiptDetail ();
  5365. $receiptDetail->staff = $this->staff [0] ['sid'];
  5366. $receiptDetail->item = $value ['name'];
  5367. $receiptDetail->itemCategory = $this->AGENCY;
  5368. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5369. $receiptDetail->date = date ( "Y-m-d" );
  5370. $receiptDetail->cid = $cid;
  5371. $receiptDetail->rid = $rid;
  5372. $receiptDetail->status = 4;
  5373. $receiptDetail->insert ();
  5374. }
  5375. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5376. $receiptDetail = new receiptDetail ();
  5377. $receiptDetail->staff = $this->staff [0] ['sid'];
  5378. $receiptDetail->item = $value ['name'];
  5379. $receiptDetail->itemCategory = $this->TRAVEL;
  5380. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5381. $receiptDetail->date = date ( "Y-m-d" );
  5382. $receiptDetail->cid = $cid;
  5383. $receiptDetail->rid = $rid;
  5384. $receiptDetail->status = 4;
  5385. $receiptDetail->insert ();
  5386. }
  5387. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5388. $receiptDetail = new receiptDetail ();
  5389. $receiptDetail->staff = $this->staff [0] ['sid'];
  5390. $receiptDetail->item = $value ['name'];
  5391. $receiptDetail->itemCategory = $this->TRAIN;
  5392. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5393. $receiptDetail->date = date ( "Y-m-d" );
  5394. $receiptDetail->cid = $cid;
  5395. $receiptDetail->rid = $rid;
  5396. $receiptDetail->status = 4;
  5397. $receiptDetail->insert ();
  5398. }
  5399. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5400. $receiptDetail = new receiptDetail ();
  5401. $receiptDetail->staff = $this->staff [0] ['sid'];
  5402. $receiptDetail->item = $value ['name'];
  5403. $receiptDetail->itemCategory = $this->OTHER;
  5404. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5405. $receiptDetail->date = date ( "Y-m-d" );
  5406. $receiptDetail->cid = $cid;
  5407. $receiptDetail->rid = $rid;
  5408. $receiptDetail->status = 4;
  5409. $receiptDetail->insert ();
  5410. }
  5411. // return "/referReceipt/".$rid;
  5412. }
  5413. return "/saeaBorad";
  5414. }
  5415. function approvedReceipt() {
  5416. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5417. Doo::loadModel ( 'receipt' );
  5418. Doo::loadModel ( 'receiptDetail' );
  5419. $receipt = new receipt ();
  5420. $receiptDetail = new receiptDetail ();
  5421. Doo::loadModel ( 'statistics' );
  5422. Doo::loadModel ( 'itemStatistics' );
  5423. $statistics = new statistics ();
  5424. $itemStatistics = new itemStatistics ();
  5425. Doo::loadModel ( "verify" );
  5426. $verify = new verify ();
  5427. // 审批状态的判定
  5428. $receiptDetailList = $receipt->getOne ( array (
  5429. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  5430. 'asArray' => true
  5431. ) );
  5432. if (empty ( $receiptDetailList ))
  5433. return "/saeaBorad";
  5434. $verifyDetail = $verify->getOne ( array (
  5435. 'where' => ' vid =' . $receiptDetailList ['verify'],
  5436. 'asArray' => true
  5437. ) );
  5438. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5439. if (empty ( $receiptDetailList ['nowStaff'] )) {
  5440. $nowStaff = "";
  5441. $nowStaffList = array ();
  5442. if ($verifyDetail [0] [1] == 'ROLE') {
  5443. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5444. foreach ( $vStaffString as $key => $value ) {
  5445. $staffK = explode ( "_", $value );
  5446. array_push ( $nowStaffList, $staffK [0] );
  5447. }
  5448. $nowStaff = implode ( ',', $nowStaffList );
  5449. } else {
  5450. $nowStaff = $verifyDetail [0] [0];
  5451. }
  5452. $receipt->nowStaff = $nowStaff;
  5453. }
  5454. // echo $nowStaff;
  5455. // print_r($verifyDetail);die;
  5456. $receipt->rid = $receiptDetailList ['rid'];
  5457. $receipt->date = date ( "Y-m-d" );
  5458. $receipt->status = 2;
  5459. $receipt->update ();
  5460. $receiptDetail->status = 2;
  5461. $receiptDetail->update ( array (
  5462. 'where' => 'rid=' . $receiptDetailList ['rid']
  5463. ) );
  5464. Doo::loadModel ( "receiptLog" );
  5465. $receiptLog = new receiptLog ();
  5466. Doo::loadModel ( "verify" );
  5467. $verify = new verify ();
  5468. $receiptInfo = $receipt->getOne ( array (
  5469. 'where' => 'rid=' . $rid,
  5470. 'asArray' => true
  5471. ) );
  5472. $vr = $verify->getOne ( array (
  5473. 'where' => 'vid=' . $receiptInfo ['verify'],
  5474. 'asArray' => true
  5475. ) );
  5476. $jd = json_decode ( $vr ['staff'] );
  5477. $roleId = 0;
  5478. foreach ( $jd as $key => $value ) {
  5479. if ($value [1] == 'ROLE') {
  5480. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  5481. if ($pos !== false) {
  5482. $roleId = $value [0];
  5483. }
  5484. }
  5485. }
  5486. // 审批日志
  5487. // echo $roleId;die;
  5488. if (! empty ( $roleId )) {
  5489. Doo::loadModel ( "role" );
  5490. $role = new role ();
  5491. $roleInfo = $role->getOne ( array (
  5492. 'where' => 'rid=' . $roleId,
  5493. 'asArray' => true
  5494. ) );
  5495. $receiptLog->rolename = $roleInfo ['name'];
  5496. }
  5497. $receiptLog->username = $this->staff [0] ['username'];
  5498. $receiptLog->uid = $this->staff [0] ['sid'];
  5499. $receiptLog->date = date ( "Y-m-d" );
  5500. $receiptLog->opinion = '提交审批';
  5501. $receiptLog->img = $this->staff [0] ['avatar'];
  5502. $receiptLog->status = 2;
  5503. $receiptLog->rid = $rid;
  5504. $receiptLog->insert ();
  5505. // statistics item
  5506. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  5507. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  5508. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  5509. // print_r($accountItem['cSum']['agencySum']);die;
  5510. // foreach ($accountItem['cSum'] as $key=>$value){
  5511. // if($key=="agencySum"){
  5512. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->AGENCY.'"'.$dateCondition,'asArray'=>true));
  5513. // if(empty($iStatistics)){
  5514. // $itemStatistics->cid=$this->staff[0]['cid'];
  5515. // $itemStatistics->staff=$this->staff[0]['sid'];
  5516. // $itemStatistics->price=$value;
  5517. // $itemStatistics->itemCategory=$this->AGENCY;
  5518. // $itemStatistics->date=date("Y-m-d");
  5519. // $itemStatistics->insert();
  5520. // }else{
  5521. // if (!empty($value)){
  5522. // $itemStatistics->price=$value+$iStatistics['price'];
  5523. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5524. // }
  5525. // }
  5526. // }elseif($key=="travelSum"){
  5527. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->TRAVEL.'"'.$dateCondition,'asArray'=>true));
  5528. // if(empty($iStatistics)){
  5529. // $itemStatistics->cid=$this->staff[0]['cid'];
  5530. // $itemStatistics->staff=$this->staff[0]['sid'];
  5531. // $itemStatistics->price=$value;
  5532. // $itemStatistics->itemCategory=$this->TRAVEL;
  5533. // $itemStatistics->date=date("Y-m-d");
  5534. // $itemStatistics->insert();
  5535. // }else{
  5536. // if (!empty($value)){
  5537. // $itemStatistics->price=$value+$iStatistics['price'];
  5538. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5539. // }
  5540. // }
  5541. // }elseif($key=="trainSum"){
  5542. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->TRAIN.'"'.$dateCondition,'asArray'=>true));
  5543. // if(empty($iStatistics)){
  5544. // $itemStatistics->cid=$this->staff[0]['cid'];
  5545. // $itemStatistics->staff=$this->staff[0]['sid'];
  5546. // $itemStatistics->price=$value;
  5547. // $itemStatistics->itemCategory=$this->TRAIN;
  5548. // $itemStatistics->date=date("Y-m-d");
  5549. // $itemStatistics->insert();
  5550. // }else{
  5551. // if (!empty($value)){
  5552. // $itemStatistics->price=$value+$iStatistics['price'];
  5553. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5554. // }
  5555. // }
  5556. // }elseif($key=="otherSum"){
  5557. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->OTHER.'"'.$dateCondition,'asArray'=>true));
  5558. // if(empty($iStatistics)){
  5559. // $itemStatistics->cid=$this->staff[0]['cid'];
  5560. // $itemStatistics->staff=$this->staff[0]['sid'];
  5561. // $itemStatistics->price=$value;
  5562. // $itemStatistics->itemCategory=$this->OTHER;
  5563. // $itemStatistics->date=date("Y-m-d");
  5564. // $itemStatistics->insert();
  5565. // }else{
  5566. // if (!empty($value)){
  5567. // $itemStatistics->price=$value+$iStatistics['price'];
  5568. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5569. // }
  5570. // }
  5571. // }
  5572. // }
  5573. $stat = $statistics->getOne ( array (
  5574. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5575. 'asArray' => true
  5576. ) );
  5577. if (empty ( $stat )) {
  5578. $statistics->date = date ( "Y-m-d" );
  5579. $statistics->cid = $this->staff [0] ['cid'];
  5580. $statistics->staff = $this->staff [0] ['sid'];
  5581. $statistics->agPrice = 0;
  5582. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5583. $statistics->insert ();
  5584. } else {
  5585. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5586. $statistics->update ( array (
  5587. 'where' => 'sid=' . $stat ['sid']
  5588. ) );
  5589. }
  5590. return "/expenses";
  5591. }
  5592. function approval() {
  5593. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5594. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5595. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5596. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5597. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5598. if (empty ( $status ))
  5599. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5600. $vidList = array ();
  5601. $button = 0;
  5602. Doo::loadModel ( 'verify' );
  5603. $verify = new verify ();
  5604. Doo::loadModel ( 'receipt' );
  5605. $receipt = new receipt ();
  5606. Doo::loadModel ( 'staff' );
  5607. $staff = new staff ();
  5608. Doo::loadModel ( 'L_category' );
  5609. $Lcategory = new L_category ();
  5610. // user verify ID
  5611. $verifyDetail = $verify->find ( array (
  5612. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5613. 'asArray' => true
  5614. ) );
  5615. foreach ( $verifyDetail as $key => $value ) {
  5616. array_push ( $vidList, $value ['vid'] );
  5617. }
  5618. $vid = implode ( ",", $vidList );
  5619. if (empty ( $verifyDetail ))
  5620. $vid = 0;
  5621. /*
  5622. */
  5623. $dateCondition = " and Year(date) =" . $year;
  5624. if (! empty ( $month ))
  5625. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  5626. $categoryList = $Lcategory->find ( array (
  5627. 'asArray' => true
  5628. ) );
  5629. $staffList = $staff->find ( array (
  5630. 'where' => 'cid=' . $cid,
  5631. 'asArray' => true
  5632. ) );
  5633. $cateCondition = "";
  5634. $staffCondition = "";
  5635. $approvalCondition = "";
  5636. if (! empty ( $cid ))
  5637. $cateCondition = ' and cid=' . $cid;
  5638. if (! empty ( $sid )) {
  5639. $staffCondition = ' and staff=' . $sid;
  5640. $cateCondition = "";
  5641. }
  5642. // elseif($status==1){
  5643. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  5644. // }
  5645. if ($status == 2) {
  5646. // 查找角色审批人
  5647. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  5648. }
  5649. $ap = "";
  5650. if ($status == 4) {
  5651. $ap = 4;
  5652. $status = 2;
  5653. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  5654. }
  5655. if ($status == 5) {
  5656. $status = 4;
  5657. $ap = 5;
  5658. }
  5659. // echo $vid;
  5660. // get Receipt By verifyID status 2 .$approvalCondition
  5661. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  5662. $receiptList = $receipt->find ( array (
  5663. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  5664. 'desc' => 'rid',
  5665. 'asArray' => true
  5666. ) );
  5667. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  5668. $Locate = 0;
  5669. if ($ap == 4)
  5670. $status = 4;
  5671. elseif ($ap == 5)
  5672. $status = 5;
  5673. foreach ( $receiptList as $key => $value ) {
  5674. $receiptList [$key] ['Locate'] = $Locate;
  5675. $Locate ++;
  5676. $receiptList [$key] ['reviseDetail'] = array ();
  5677. if (! empty ( $value ['reviseDetail'] ))
  5678. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5679. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5680. $categoryDetil = $Lcategory->getOne ( array (
  5681. 'where' => 'cid=' . $value ['cid'],
  5682. 'asArray' => true
  5683. ) );
  5684. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5685. $verifyList = $verify->getOne ( array (
  5686. 'where' => 'vid=' . $value ['verify'],
  5687. 'asArray' => true
  5688. ) );
  5689. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5690. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5691. foreach ( $verifyList as $k => $v ) {
  5692. // init verifyStaff
  5693. $verifyList [$k] ['date'] = "";
  5694. $verifyList [$k] ['opinion'] = "";
  5695. $verifyList [$k] ['status'] = "";
  5696. if (empty ( $verifyStaff )) {
  5697. $verifyList [$k] ['date'] = "";
  5698. $verifyList [$k] ['opinion'] = "";
  5699. if ($v [0] == $this->staff [0] ['sid']) {
  5700. $verifyList [$k] ['status'] = 4;
  5701. $button = 4;
  5702. }
  5703. } else {
  5704. $flag = true;
  5705. foreach ( $verifyStaff as $m => $u ) {
  5706. if ($v [0] == $m) {
  5707. $verifyList [$k] ['date'] = $u ['date'];
  5708. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5709. $verifyList [$k] ['status'] = $u ['status'];
  5710. $flag = false;
  5711. break;
  5712. }
  5713. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  5714. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  5715. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  5716. }
  5717. if ($flag) { // 检测可编辑
  5718. if ($v [0] == $this->staff [0] ['sid']) {
  5719. $verifyList [$k] ['status'] = 4;
  5720. $button = 4;
  5721. }
  5722. }
  5723. }
  5724. }
  5725. $receiptList [$key] ['verifyList'] = $verifyList;
  5726. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5727. 'where' => 'sid=' . $value ['staff'],
  5728. 'asArray' => true
  5729. ) );
  5730. $receiptList [$key] ['button'] = $button;
  5731. }
  5732. // print_r($receiptList);die;
  5733. // $data['verifyDetail']=$verifyDetail;
  5734. $mothHtml = "";
  5735. for($i = 1; $i <= 12; $i ++) {
  5736. if ($month == $i)
  5737. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5738. else
  5739. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5740. }
  5741. $data ['mothHtml'] = $mothHtml;
  5742. $data ['receiptList'] = $receiptList;
  5743. $data ['receiptApprovalCount'] = count ( $receiptList );
  5744. $data ['status'] = $status;
  5745. $data ['year'] = $year;
  5746. $data ['categoryList'] = $categoryList;
  5747. $data ['staffList'] = $staffList;
  5748. $data ['cid'] = $cid;
  5749. $data ['sid'] = $sid;
  5750. $data ['ap'] = $ap;
  5751. $data ['memu'] = "receipt";
  5752. $data ['staff'] = $this->staff;
  5753. $data ['receiptMemu'] = 'approval';
  5754. $data ['verifyId'] = $this->verifyId;
  5755. $data ['executeId'] = $this->executeId;
  5756. $this->render ( "/admin/saea_reportList", $data );
  5757. }
  5758. function approvalDetails() {
  5759. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5760. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5761. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5762. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5763. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5764. Doo::loadModel ( 'verify' );
  5765. $verify = new verify ();
  5766. Doo::loadModel ( 'receipt' );
  5767. $receipt = new receipt ();
  5768. Doo::loadModel ( 'staff' );
  5769. $staff = new staff ();
  5770. Doo::loadModel ( 'L_category' );
  5771. $Lcategory = new L_category ();
  5772. Doo::loadModel ( 'enclosur' );
  5773. $enclosur = new enclosur ();
  5774. $vidList = array ();
  5775. $verifyDetail = $verify->find ( array (
  5776. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5777. 'asArray' => true
  5778. ) );
  5779. foreach ( $verifyDetail as $key => $value ) {
  5780. array_push ( $vidList, $value ['vid'] );
  5781. }
  5782. $vid = implode ( ",", $vidList );
  5783. if (empty ( $verifyDetail ))
  5784. $vid = 0;
  5785. $categoryList = $Lcategory->find ( array (
  5786. 'asArray' => true
  5787. ) );
  5788. $staffList = $staff->find ( array (
  5789. 'where' => 'cid=' . $cid,
  5790. 'asArray' => true
  5791. ) );
  5792. $ap = 0;
  5793. $receiptList = $receipt->find ( array (
  5794. 'where' => 'rid =' . $rid,
  5795. 'desc' => 'rid',
  5796. 'asArray' => true
  5797. ) );
  5798. $Locate = 0;
  5799. $roleId = 0;
  5800. $button = 0;
  5801. foreach ( $receiptList as $key => $value ) {
  5802. $receiptList [$key] ['Locate'] = $Locate;
  5803. $Locate ++;
  5804. $receiptList [$key] ['reviseDetail'] = array ();
  5805. if (! empty ( $value ['reviseDetail'] ))
  5806. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5807. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5808. $categoryDetil = $Lcategory->getOne ( array (
  5809. 'where' => 'cid=' . $value ['cid'],
  5810. 'asArray' => true
  5811. ) );
  5812. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5813. // 检测编辑状态
  5814. $verifyList = $verify->getOne ( array (
  5815. 'where' => 'vid=' . $value ['verify'],
  5816. 'asArray' => true
  5817. ) );
  5818. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5819. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5820. Doo::loadModel ( 'role' );
  5821. $role = new role ();
  5822. // print_r($verifyList);
  5823. $flag = true;
  5824. $roleKey = 0;
  5825. $endStaffArray = array ();
  5826. $roleArrayCopy = array ();
  5827. foreach ( $verifyList as $k => $v ) {
  5828. // init verifyStaff
  5829. if ($v [1] == 'ROLE') {
  5830. if (! empty ( $verifyStaff )) {
  5831. $endStaffArray = end ( $verifyStaff );
  5832. if ($v [0] == $endStaffArray ['nextStaff']) {
  5833. $roleId = $v [0];
  5834. }
  5835. }
  5836. $roleVerify = json_decode ( $v [3], true );
  5837. $roleKey = $k;
  5838. $roleArray = array ();
  5839. $rolename = $role->getOne ( array (
  5840. 'where' => 'rid=' . $v [0],
  5841. 'asArray' => true
  5842. ) );
  5843. foreach ( $roleVerify as $o => $p ) {
  5844. $staffID = explode ( '_', $p );
  5845. $staffInfo = $staff->getOne ( array (
  5846. 'where' => 'sid=' . $staffID [0],
  5847. 'asArray' => true
  5848. ) );
  5849. // print_r($staffID);
  5850. $exp = array (
  5851. 0 => $staffInfo ['sid'],
  5852. 1 => $staffID [1],
  5853. 2 => $staffInfo ['avatar'],
  5854. 'date' => '',
  5855. 'date' => '',
  5856. 'opinion' => '',
  5857. 'status' => '',
  5858. 'rolename' => $rolename ['name']
  5859. );
  5860. array_push ( $roleArray, $exp );
  5861. }
  5862. $roleArrayCopy [$v [0]] = $roleArray;
  5863. // $verifyList[$k]['roleArray']=$roleArray;
  5864. }
  5865. // print_r($roleArray);
  5866. $verifyList [$k] ['date'] = "";
  5867. $verifyList [$k] ['opinion'] = "";
  5868. $verifyList [$k] ['status'] = "";
  5869. if (empty ( $verifyStaff )) {
  5870. $verifyList [$k] ['date'] = "";
  5871. $verifyList [$k] ['opinion'] = "";
  5872. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5873. $verifyList [$k] ['status'] = 4;
  5874. $button = 4;
  5875. $flag = false;
  5876. }
  5877. } else {
  5878. foreach ( $verifyStaff as $m => $u ) {
  5879. if ($v [0] == $m) {
  5880. $verifyList [$k] ['date'] = $u ['date'];
  5881. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5882. $verifyList [$k] ['status'] = $u ['status'];
  5883. $flag = false;
  5884. break;
  5885. }
  5886. }
  5887. $endStaffArray = end ( $verifyStaff );
  5888. if (isset ( $endStaffArray ['ROLE'] )) {
  5889. } else {
  5890. $endKey = key ( $verifyStaff );
  5891. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5892. $button = 4;
  5893. $verifyList [$k] ['status'] = 4;
  5894. }
  5895. }
  5896. }
  5897. }
  5898. $rolename ['name'] = '';
  5899. if (! empty ( $roleId )) {
  5900. Doo::loadModel ( 'role' );
  5901. $role = new role ();
  5902. $rolename = $role->getOne ( array (
  5903. 'where' => 'rid=' . $roleId,
  5904. 'asArray' => true
  5905. ) );
  5906. }
  5907. if (! empty ( $verifyStaff ))
  5908. $endStaffArray = end ( $verifyStaff );
  5909. $KOP = false;
  5910. foreach ( $roleArrayCopy as $P => $A ) {
  5911. foreach ( $A as $MKI => $AVL ) {
  5912. if (! empty ( $verifyStaff )) {
  5913. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5914. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5915. $button = 4;
  5916. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5917. }
  5918. foreach ( $verifyStaff as $m => $u ) {
  5919. $AVLFK = $AVL [0] . '_R';
  5920. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5921. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5922. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5923. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5924. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5925. break;
  5926. }
  5927. }
  5928. } else {
  5929. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5930. $button = 4;
  5931. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5932. }
  5933. }
  5934. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5935. $KOP = true;
  5936. }
  5937. }
  5938. foreach ( $roleArrayCopy as $k => $v ) {
  5939. foreach ( $verifyList as $m => $n ) {
  5940. if ($n [0] == $k) {
  5941. array_splice ( $verifyList, $m, 1, $v );
  5942. }
  5943. }
  5944. }
  5945. $receiptList [$key] ['verifyList'] = $verifyList;
  5946. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5947. 'where' => 'sid=' . $value ['staff'],
  5948. 'asArray' => true
  5949. ) );
  5950. $receiptList [$key] ['button'] = $button;
  5951. }
  5952. $mothHtml = "";
  5953. for($i = 1; $i <= 12; $i ++) {
  5954. if ($month == $i)
  5955. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5956. else
  5957. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5958. }
  5959. // 获取审批日志
  5960. Doo::loadModel ( 'receiptLog' );
  5961. $receiptLog = new receiptLog ();
  5962. $rlList = array ();
  5963. $rlInfo = $receiptLog->getOne ( array (
  5964. 'where' => 'rid=' . $rid . ' and status=4',
  5965. 'asArray' => true
  5966. ) );
  5967. $tijdate = $receiptLog->getOne ( array (
  5968. 'where' => 'rid=' . $rid . ' and status=2',
  5969. 'asc' => 'rlid',
  5970. 'asArray' => true
  5971. ) );
  5972. if (! empty ( $rlInfo )) {
  5973. $rlList = $receiptLog->find ( array (
  5974. 'where' => 'rid=' . $rid,
  5975. 'asc' => 'rlid',
  5976. 'asArray' => true
  5977. ) );
  5978. }
  5979. $receiptList [0] ['rlList'] = $rlList;
  5980. $enclosurList = $enclosur->find ( array (
  5981. 'where' => 'rid=' . $rid,
  5982. 'asArray' => true
  5983. ) );
  5984. $enclosurHtml = '';
  5985. foreach ( $enclosurList as $value ) {
  5986. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5987. }
  5988. $data ['enclosurHtml'] = $enclosurHtml;
  5989. $data ['rolename'] = $rolename ['name'];
  5990. $data ['datetij'] = $tijdate ['date'];
  5991. $data ['mothHtml'] = $mothHtml;
  5992. $data ['receiptList'] = $receiptList;
  5993. $data ['receiptApprovalCount'] = count ( $receiptList );
  5994. $data ['year'] = $year;
  5995. $data ['categoryList'] = $categoryList;
  5996. $data ['staffList'] = $staffList;
  5997. $data ['cid'] = $cid;
  5998. $data ['sid'] = $sid;
  5999. $data ['status'] = 0;
  6000. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  6001. $ap = 4;
  6002. } else
  6003. $data ['status'] = $receiptList [0] ['status'];
  6004. if ($receiptList [0] ['status'] == 4) {
  6005. $data ['status'] = 5;
  6006. $ap = 0;
  6007. }
  6008. $data ['ap'] = $ap;
  6009. $data ['memu'] = "receipt";
  6010. $data ['staff'] = $this->staff;
  6011. $data ['receiptMemu'] = 'approval';
  6012. $data ['verifyId'] = $this->verifyId;
  6013. $data ['executeId'] = $this->executeId;
  6014. $this->render ( "/admin/saeaReportListReport", $data );
  6015. }
  6016. function approvalEdi() {
  6017. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6018. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  6019. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6020. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6021. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6022. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6023. if (empty ( $status ))
  6024. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  6025. $vidList = array ();
  6026. $button = 0;
  6027. Doo::loadModel ( 'verify' );
  6028. Doo::loadModel ( 'receipt' );
  6029. Doo::loadModel ( 'staff' );
  6030. $staff = new staff ();
  6031. $receipt = new receipt ();
  6032. $verify = new verify ();
  6033. Doo::loadModel ( 'L_category' );
  6034. $Lcategory = new L_category ();
  6035. Doo::loadModel ( 'enclosur' );
  6036. $enclosur = new enclosur ();
  6037. // user verify ID
  6038. $verifyDetail = $verify->find ( array (
  6039. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6040. 'asArray' => true
  6041. ) );
  6042. foreach ( $verifyDetail as $key => $value ) {
  6043. array_push ( $vidList, $value ['vid'] );
  6044. }
  6045. $vid = implode ( ",", $vidList );
  6046. if (empty ( $verifyDetail ))
  6047. $vid = 0;
  6048. $categoryList = $Lcategory->find ( array (
  6049. 'asArray' => true
  6050. ) );
  6051. $staffList = $staff->find ( array (
  6052. 'where' => 'cid=' . $cid,
  6053. 'asArray' => true
  6054. ) );
  6055. $ap = "";
  6056. if ($status == 4) {
  6057. $ap = 4;
  6058. $status = 2;
  6059. }
  6060. // get Receipt By verifyID status 2
  6061. $receiptList = $receipt->find ( array (
  6062. 'where' => 'rid =' . $rid,
  6063. 'desc' => 'rid',
  6064. 'asArray' => true
  6065. ) );
  6066. $Locate = 0;
  6067. $roleId = 0;
  6068. if ($ap == 4)
  6069. $status = 4;
  6070. foreach ( $receiptList as $key => $value ) {
  6071. $receiptList [$key] ['Locate'] = $Locate;
  6072. $Locate ++;
  6073. $receiptList [$key] ['reviseDetail'] = array ();
  6074. if (! empty ( $value ['reviseDetail'] ))
  6075. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6076. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6077. $categoryDetil = $Lcategory->getOne ( array (
  6078. 'where' => 'cid=' . $value ['cid'],
  6079. 'asArray' => true
  6080. ) );
  6081. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6082. // 检测编辑状态
  6083. $verifyList = $verify->getOne ( array (
  6084. 'where' => 'vid=' . $value ['verify'],
  6085. 'asArray' => true
  6086. ) );
  6087. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6088. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6089. // print_r($verifyList);
  6090. //
  6091. // if (empty($verifyStaff)){
  6092. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6093. // $verifyList[0]['status']=4;$button=4;
  6094. // }
  6095. //
  6096. // }else{
  6097. //
  6098. // }
  6099. // die;
  6100. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  6101. // echo array_search("green",$a);
  6102. //
  6103. Doo::loadModel ( 'role' );
  6104. $role = new role ();
  6105. // print_r($verifyList);
  6106. $flag = true;
  6107. $roleKey = 0;
  6108. $endStaffArray = array ();
  6109. $roleArrayCopy = array ();
  6110. foreach ( $verifyList as $k => $v ) {
  6111. // init verifyStaff
  6112. if ($v [1] == 'ROLE') {
  6113. if (! empty ( $verifyStaff )) {
  6114. $endStaffArray = end ( $verifyStaff );
  6115. if ($v [0] == $endStaffArray ['nextStaff']) {
  6116. $roleId = $v [0];
  6117. }
  6118. }
  6119. $roleVerify = json_decode ( $v [3], true );
  6120. $roleKey = $k;
  6121. $roleArray = array ();
  6122. $rolename = $role->getOne ( array (
  6123. 'where' => 'rid=' . $v [0],
  6124. 'asArray' => true
  6125. ) );
  6126. foreach ( $roleVerify as $o => $p ) {
  6127. $staffID = explode ( '_', $p );
  6128. $staffInfo = $staff->getOne ( array (
  6129. 'where' => 'sid=' . $staffID [0],
  6130. 'asArray' => true
  6131. ) );
  6132. // print_r($staffID);
  6133. $exp = array (
  6134. 0 => $staffInfo ['sid'],
  6135. 1 => $staffID [1],
  6136. 2 => $staffInfo ['avatar'],
  6137. 'date' => '',
  6138. 'date' => '',
  6139. 'opinion' => '',
  6140. 'status' => '',
  6141. 'rolename' => $rolename ['name']
  6142. );
  6143. array_push ( $roleArray, $exp );
  6144. }
  6145. $roleArrayCopy [$v [0]] = $roleArray;
  6146. // $verifyList[$k]['roleArray']=$roleArray;
  6147. }
  6148. // print_r($roleArray);
  6149. $verifyList [$k] ['date'] = "";
  6150. $verifyList [$k] ['opinion'] = "";
  6151. $verifyList [$k] ['status'] = "";
  6152. if (empty ( $verifyStaff )) {
  6153. $verifyList [$k] ['date'] = "";
  6154. $verifyList [$k] ['opinion'] = "";
  6155. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6156. $verifyList [$k] ['status'] = 4;
  6157. $button = 4;
  6158. $flag = false;
  6159. }
  6160. } else {
  6161. foreach ( $verifyStaff as $m => $u ) {
  6162. if ($v [0] == $m) {
  6163. $verifyList [$k] ['date'] = $u ['date'];
  6164. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6165. $verifyList [$k] ['status'] = $u ['status'];
  6166. $flag = false;
  6167. break;
  6168. }
  6169. }
  6170. $endStaffArray = end ( $verifyStaff );
  6171. if (isset ( $endStaffArray ['ROLE'] )) {
  6172. } else {
  6173. $endKey = key ( $verifyStaff );
  6174. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6175. $button = 4;
  6176. $verifyList [$k] ['status'] = 4;
  6177. }
  6178. }
  6179. // print_r($endStaffArray);die;
  6180. // if (empty($verifyStaff)){
  6181. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6182. // $verifyList[$k]['status']=4;$button=4;
  6183. // }
  6184. //
  6185. // }else{
  6186. //
  6187. // }
  6188. // if($flag){//检测可编辑
  6189. // if($v[0]==$this->staff[0]['sid']){
  6190. // $verifyList[$k]['status']=4;$button=4;
  6191. // }
  6192. // }
  6193. }
  6194. }
  6195. $rolename ['name'] = '';
  6196. if (! empty ( $roleId )) {
  6197. Doo::loadModel ( 'role' );
  6198. $role = new role ();
  6199. $rolename = $role->getOne ( array (
  6200. 'where' => 'rid=' . $roleId,
  6201. 'asArray' => true
  6202. ) );
  6203. }
  6204. if (! empty ( $verifyStaff ))
  6205. $endStaffArray = end ( $verifyStaff );
  6206. $KOP = false;
  6207. foreach ( $roleArrayCopy as $P => $A ) {
  6208. foreach ( $A as $MKI => $AVL ) {
  6209. if (! empty ( $verifyStaff )) {
  6210. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6211. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6212. $button = 4;
  6213. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6214. }
  6215. foreach ( $verifyStaff as $m => $u ) {
  6216. $AVLFK = $AVL [0] . '_R';
  6217. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6218. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6219. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6220. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6221. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6222. break;
  6223. }
  6224. }
  6225. } else {
  6226. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6227. $button = 4;
  6228. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6229. }
  6230. }
  6231. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6232. $KOP = true;
  6233. }
  6234. }
  6235. // print_r($roleArrayCopy);
  6236. // echo $roleKey;
  6237. foreach ( $roleArrayCopy as $k => $v ) {
  6238. foreach ( $verifyList as $m => $n ) {
  6239. if ($n [0] == $k) {
  6240. array_splice ( $verifyList, $m, 1, $v );
  6241. }
  6242. }
  6243. }
  6244. // if ($KOP)
  6245. // array_splice($verifyList,$roleKey,1,$roleArray);
  6246. // print_r($verifyList);
  6247. $receiptList [$key] ['verifyList'] = $verifyList;
  6248. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6249. 'where' => 'sid=' . $value ['staff'],
  6250. 'asArray' => true
  6251. ) );
  6252. $receiptList [$key] ['button'] = $button;
  6253. }
  6254. // $data['verifyDetail']=$verifyDetail;
  6255. $mothHtml = "";
  6256. for($i = 1; $i <= 12; $i ++) {
  6257. if ($month == $i)
  6258. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6259. else
  6260. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6261. }
  6262. // 获取审批日志
  6263. Doo::loadModel ( 'receiptLog' );
  6264. $receiptLog = new receiptLog ();
  6265. $rlList = array ();
  6266. $rlInfo = $receiptLog->getOne ( array (
  6267. 'where' => 'rid=' . $rid . ' and status=4',
  6268. 'asArray' => true
  6269. ) );
  6270. $tijdate = $receiptLog->getOne ( array (
  6271. 'where' => 'rid=' . $rid . ' and status=2',
  6272. 'asc' => 'rlid',
  6273. 'asArray' => true
  6274. ) );
  6275. if (! empty ( $rlInfo )) {
  6276. $rlList = $receiptLog->find ( array (
  6277. 'where' => 'rid=' . $rid,
  6278. 'asc' => 'rlid',
  6279. 'asArray' => true
  6280. ) );
  6281. }
  6282. $receiptList [0] ['rlList'] = $rlList;
  6283. $enclosurList = $enclosur->find ( array (
  6284. 'where' => 'rid=' . $rid,
  6285. 'asArray' => true
  6286. ) );
  6287. $enclosurHtml = '';
  6288. foreach ( $enclosurList as $value ) {
  6289. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6290. }
  6291. $data ['enclosurHtml'] = $enclosurHtml;
  6292. $data ['rolename'] = $rolename ['name'];
  6293. $data ['datetij'] = $tijdate ['date'];
  6294. $data ['mothHtml'] = $mothHtml;
  6295. $data ['receiptList'] = $receiptList;
  6296. $data ['receiptApprovalCount'] = count ( $receiptList );
  6297. $data ['status'] = $status;
  6298. $data ['year'] = $year;
  6299. $data ['categoryList'] = $categoryList;
  6300. $data ['staffList'] = $staffList;
  6301. $data ['cid'] = $cid;
  6302. $data ['sid'] = $sid;
  6303. $data ['ap'] = $ap;
  6304. $data ['memu'] = "receipt";
  6305. $data ['staff'] = $this->staff;
  6306. $data ['receiptMemu'] = 'approval';
  6307. $data ['verifyId'] = $this->verifyId;
  6308. $data ['executeId'] = $this->executeId;
  6309. $this->render ( "/admin/saeaReportListReport", $data );
  6310. }
  6311. function remittanceHky() {
  6312. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6313. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  6314. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6315. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  6316. $page_size = 15;
  6317. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  6318. Doo::loadModel ( 'receipt' );
  6319. $receipt = new receipt ();
  6320. Doo::loadModel ( 'staff' );
  6321. $staff = new staff ();
  6322. $dateCondition = " and Year(executeDate) =" . $year;
  6323. if ($moth != 'MONTH')
  6324. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  6325. if ($day != 'DAY' && $moth != 'MONTH')
  6326. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  6327. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  6328. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  6329. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  6330. $limit = $pageinfo ['lower'] . ',' . $page_size;
  6331. $dayList = $receipt->find ( array (
  6332. 'select' => 'executeDate,sum(amount) as amount',
  6333. 'where' => $sql,
  6334. 'desc' => 'executeDate',
  6335. 'groupby' => 'executeDate',
  6336. 'limit' => $limit,
  6337. 'asArray' => true
  6338. ) );
  6339. // print_r($dayList);
  6340. foreach ( $dayList as $key => $value ) {
  6341. $remitString = "";
  6342. $receiptList = $receipt->find ( array (
  6343. 'select' => 'rid,executeDate,amount,staff,cid',
  6344. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  6345. 'desc' => 'executeDate',
  6346. 'asArray' => true
  6347. ) );
  6348. foreach ( $receiptList as $k => $v ) {
  6349. $sinfo = $staff->getOne ( array (
  6350. 'select' => 'username,category',
  6351. 'where' => ' sid=' . $v ['staff'],
  6352. 'asArray' => true
  6353. ) );
  6354. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  6355. }
  6356. $dayList [$key] ['staff'] = $remitString;
  6357. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  6358. }
  6359. // print_r($dayList);
  6360. $mothHtml = "";
  6361. for($i = 1; $i <= 12; $i ++) {
  6362. if ($moth == $i)
  6363. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6364. else
  6365. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6366. }
  6367. $dayHtml = "";
  6368. if ($day != "DAY" || $moth != "MONTH") {
  6369. for($i = 1; $i <= 31; $i ++) {
  6370. if ($day == $i)
  6371. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6372. else
  6373. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6374. }
  6375. }
  6376. $data ['page'] = $pageinfo;
  6377. $data ['year'] = $year;
  6378. $data ['moth'] = $moth;
  6379. $data ['day'] = $day;
  6380. $data ['get'] = $get;
  6381. $data ['dayHtml'] = $dayHtml;
  6382. $data ['mothHtml'] = $mothHtml;
  6383. $data ['receiptList'] = $dayList;
  6384. $data ['memu'] = "receipt";
  6385. $data ['staff'] = $this->staff;
  6386. $data ['receiptMemu'] = 'remittanceHky';
  6387. $data ['verifyId'] = $this->verifyId;
  6388. $data ['executeId'] = $this->executeId;
  6389. $this->render ( "/admin/remittanceHky", $data );
  6390. }
  6391. function remittancep() {
  6392. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  6393. Doo::loadModel ( 'receipt' );
  6394. $receipt = new receipt ();
  6395. Doo::loadModel ( 'staff' );
  6396. $staff = new staff ();
  6397. Doo::loadClass ( 'XDeode' );
  6398. $XDeode = new XDeode ( 5 );
  6399. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  6400. $rplist = $receipt->find ( array (
  6401. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6402. 'asArray' => true
  6403. ) );
  6404. $dayList = $receipt->find ( array (
  6405. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6406. 'desc' => 'executeDate',
  6407. 'groupby' => 'staff',
  6408. 'asArray' => true
  6409. ) );
  6410. $html = '';
  6411. foreach ( $dayList as $key => $value ) {
  6412. $sinfo = $staff->getOne ( array (
  6413. 'select' => 'username,category',
  6414. 'where' => ' sid=' . $value ['staff'],
  6415. 'asArray' => true
  6416. ) );
  6417. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  6418. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  6419. $au = 0;
  6420. foreach ( $rplist as $k => $v ) {
  6421. if ($value ['staff'] == $v ['staff']) {
  6422. $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>';
  6423. $au += $v ['amount'];
  6424. }
  6425. }
  6426. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  6427. }
  6428. $data ['html'] = $html;
  6429. $data ['memu'] = "receipt";
  6430. $data ['staff'] = $this->staff;
  6431. $data ['receiptMemu'] = 'remittanceHky';
  6432. $data ['verifyId'] = $this->verifyId;
  6433. $data ['executeId'] = $this->executeId;
  6434. $this->render ( "/admin/remittancep", $data );
  6435. }
  6436. function ajaxGetReceiptDetails() {
  6437. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  6438. Doo::loadClass ( 'XDeode' );
  6439. $XDeode = new XDeode ( 5 );
  6440. $rid = $XDeode->decode ( $rid );
  6441. if (empty ( $rid )) {
  6442. echo json_encode ( array (
  6443. 'status' => 2,
  6444. 'msg' => 'illegal request'
  6445. ) );
  6446. die ();
  6447. }
  6448. Doo::loadModel ( 'receipt' );
  6449. $receipt = new receipt ();
  6450. Doo::loadModel ( 'staff' );
  6451. $staff = new staff ();
  6452. $rinfo = $receipt->getOne ( array (
  6453. 'where' => 'rid= ' . $rid,
  6454. 'asArray' => true
  6455. ) );
  6456. $sinfo = $staff->getOne ( array (
  6457. 'select' => 'username,category',
  6458. 'where' => ' sid=' . $rinfo ['staff'],
  6459. 'asArray' => true
  6460. ) );
  6461. $rinfo ['reviseDetail'] = array ();
  6462. if (! empty ( $rinfo ['reviseDetail'] ))
  6463. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  6464. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  6465. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  6466. $rinfo ['category'] = $sinfo ['category'];
  6467. $verifyStaff = array ();
  6468. if (! empty ( $rinfo ['verifyStaff'] ))
  6469. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  6470. $relust = $rinfo ['sum'] - $rinfo ['loanSum'];
  6471. $rinfo ['relust'] = $relust;
  6472. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  6473. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  6474. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  6475. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  6476. // 费用执行人相关数据
  6477. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6478. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6479. foreach ( $executeCopy as $k => $v ) {
  6480. $executeCopy [$k] ['date'] = '';
  6481. $executeCopy [$k] ['opinion'] = '';
  6482. $executeCopy [$k] ['status'] = '';
  6483. if (! empty ( $executeStaff ))
  6484. foreach ( $executeStaff as $m => $u ) {
  6485. if ($v [0] == $m) {
  6486. $executeCopy [$k] ['date'] = $u ['date'];
  6487. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  6488. $executeCopy [$k] ['status'] = $u ['status'];
  6489. break;
  6490. }
  6491. }
  6492. }
  6493. $rinfo ['executeCopy'] = $executeCopy;
  6494. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  6495. if ($rinfo ['Rtype'] == 1) { // 借款费用
  6496. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6497. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  6498. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  6499. $html .= '<tr><th>' . $value ['name'] . '</th>
  6500. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6501. }
  6502. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6503. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6504. <tr><th class="taC" colspan="2">费用说明</th>
  6505. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6506. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6507. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  6508. </tbody></table>';
  6509. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  6510. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6511. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6512. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6513. $html .= '<tr><th>' . $value ['name'] . '</th>
  6514. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6515. }
  6516. $html .= '<tr><th class="taR">合计</th>
  6517. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6518. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6519. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6520. $html .= '<tr><th>' . $value ['name'] . '</th>
  6521. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6522. }
  6523. $html .= '<tr><th class="taR">合计</th>
  6524. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6525. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6526. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6527. $html .= '<tr><th>' . $value ['name'] . '</th>
  6528. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6529. }
  6530. $html .= '<tr><th class="taR">合计</th>
  6531. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6532. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6533. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6534. $html .= '<tr><th>' . $value ['name'] . '</th>
  6535. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6536. }
  6537. $html .= '<tr><th class="taR">合计</th>
  6538. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6539. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6540. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6541. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6542. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6543. }
  6544. $html .= '<tr><th class="taR">合计</th>
  6545. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6546. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6547. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6548. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6549. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6550. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6551. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6552. <tr';
  6553. if ($rinfo ['relust'] >= 0) {
  6554. $html .= 'class="success"';
  6555. } else {
  6556. $html .= 'class="error"';
  6557. }
  6558. $html .= '><td class="taR"><b>借款结余</b></td>
  6559. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  6560. </tbody></table>
  6561. ';
  6562. }
  6563. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  6564. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6565. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  6566. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6567. $html .= '<tr><th>' . $value ['name'] . '</th>
  6568. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6569. }
  6570. $html .= '<tr><th class="taR">合计</th>
  6571. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6572. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6573. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6574. <tr><th class="taC" colspan="2">费用说明</th>
  6575. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6576. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6577. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6578. </tbody></table>';
  6579. } else {
  6580. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6581. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6582. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6583. $html .= '<tr><th>' . $value ['name'] . '</th>
  6584. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6585. }
  6586. $html .= '<tr><th class="taR">合计</th>
  6587. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6588. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6589. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6590. $html .= '<tr><th>' . $value ['name'] . '</th>
  6591. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6592. }
  6593. $html .= '<tr><th class="taR">合计</th>
  6594. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6595. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6596. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6597. $html .= '<tr><th>' . $value ['name'] . '</th>
  6598. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6599. }
  6600. $html .= '<tr><th class="taR">合计</th>
  6601. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6602. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6603. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6604. $html .= '<tr><th>' . $value ['name'] . '</th>
  6605. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6606. }
  6607. $html .= '<tr><th class="taR">合计</th>
  6608. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6609. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6610. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6611. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6612. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6613. }
  6614. $html .= '<tr><th class="taR">合计</th>
  6615. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6616. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6617. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6618. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6619. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6620. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6621. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  6622. $html .= '</tbody></table>';
  6623. /*
  6624. * <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>
  6625. * <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>
  6626. * <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>
  6627. * <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>
  6628. * <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>
  6629. * <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>
  6630. * </tbody> </table>
  6631. */
  6632. }
  6633. // print_r($verifyStaff);die;
  6634. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  6635. foreach ( $verifyStaff as $key => $value ) {
  6636. $key = trim ( strtr ( $key, '_R', ' ' ) );
  6637. $sinfo = $staff->getOne ( array (
  6638. 'select' => 'username',
  6639. 'where' => ' sid=' . $key,
  6640. 'asArray' => true
  6641. ) );
  6642. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6643. }
  6644. $html .= '</tbody></table>';
  6645. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  6646. foreach ( $rinfo ['executeCopy'] as $value ) {
  6647. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6648. }
  6649. $html .= '</tbody></table>';
  6650. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  6651. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  6652. </tr></table>';
  6653. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  6654. echo json_encode ( array (
  6655. 'status' => 1,
  6656. 'html' => $html
  6657. ) );
  6658. die ();
  6659. }
  6660. function remittance() {
  6661. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6662. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6663. Doo::loadModel ( 'receipt' );
  6664. $receipt = new receipt ();
  6665. Doo::loadModel ( 'staff' );
  6666. $staff = new staff ();
  6667. $dateCondition = " and Year(pastDate) =" . $year;
  6668. if (! empty ( $month ))
  6669. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  6670. // get Receipt By verifyID status 1
  6671. $receiptList = $receipt->find ( array (
  6672. 'select' => 'sum(sum) as sum,staff,pastDate',
  6673. 'where' => ' status=1' . $dateCondition,
  6674. 'desc' => 'pastDate',
  6675. 'groupby' => 'staff,pastDate',
  6676. 'asArray' => true
  6677. ) );
  6678. $dateList = $receipt->find ( array (
  6679. 'select' => 'pastDate,verifyStaff',
  6680. 'where' => ' status=1' . $dateCondition,
  6681. 'desc' => 'pastDate',
  6682. 'groupby' => 'pastDate',
  6683. 'asArray' => true
  6684. ) );
  6685. $dataList = array ();
  6686. foreach ( $dateList as $d => $a ) {
  6687. $dataList [$a ['pastDate']] = array ();
  6688. $daySum = 0;
  6689. foreach ( $receiptList as $key => $value ) {
  6690. if ($a ['pastDate'] == $value ['pastDate']) {
  6691. $oderList = $receipt->find ( array (
  6692. 'select' => 'receiptOrder',
  6693. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  6694. 'asArray' => true
  6695. ) );
  6696. $list = array ();
  6697. $html = "";
  6698. foreach ( $oderList as $v ) {
  6699. array_push ( $list, $v ['receiptOrder'] );
  6700. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  6701. }
  6702. $receiptList [$key] ['receiptOrder'] = $html;
  6703. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  6704. $sinfo = $staff->getOne ( array (
  6705. 'select' => 'username ',
  6706. 'where' => ' sid=' . $value ['staff'],
  6707. 'asArray' => true
  6708. ) );
  6709. $receiptList [$key] ['username'] = $sinfo ['username'];
  6710. $daySum += $value ['sum'];
  6711. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  6712. }
  6713. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  6714. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  6715. }
  6716. }
  6717. // print_r($dataList);
  6718. $data ['dataList'] = $dataList;
  6719. $mothHtml = "";
  6720. for($i = 1; $i <= 12; $i ++) {
  6721. if ($month == $i)
  6722. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6723. else
  6724. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6725. }
  6726. $data ['year'] = $year;
  6727. $data ['mothHtml'] = $mothHtml;
  6728. $data ['memu'] = "receipt";
  6729. $data ['staff'] = $this->staff;
  6730. $data ['receiptMemu'] = 'approval';
  6731. $data ['verifyId'] = $this->verifyId;
  6732. $data ['executeId'] = $this->executeId;
  6733. $this->render ( "/admin/saeaReportListPay", $data );
  6734. }
  6735. function revocationAdjustment() {
  6736. $sid = isset ( $this->params ['sid'] ) && is_numeric ( $this->params ['sid'] ) ? $this->params ['sid'] : 0;
  6737. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  6738. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6739. // echo $price;die;
  6740. if ((! empty ( $sid )) && ($price != - 99999) && (! empty ( $rid ))) {
  6741. Doo::loadModel ( 'receipt' );
  6742. $receipt = new receipt ();
  6743. $receiptDetail = $receipt->getOne ( array (
  6744. 'where' => 'rid=' . $rid,
  6745. 'asArray' => true
  6746. ) );
  6747. if (empty ( $receiptDetail ['reviseDetail'] ))
  6748. return "/approval";
  6749. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  6750. $RD = array ();
  6751. foreach ( $reviseDetail as $key => $value ) {
  6752. if ($value ['price'] == $price && $value ['sid'] == $sid)
  6753. continue;
  6754. array_push ( $RD, $value );
  6755. }
  6756. $reviseDetailString = json_encode ( $RD );
  6757. $receipt->reviseDetail = $reviseDetailString;
  6758. $receipt->sum = $receiptDetail ['sum'] - $price;
  6759. $receipt->revisePrice = $receiptDetail ['revisePrice'] - $price;
  6760. $receipt->update ( array (
  6761. 'where' => 'rid=' . $rid
  6762. ) );
  6763. }
  6764. // approvalEdi/37
  6765. return "/approvalEdi/" . $rid;
  6766. }
  6767. function updateApprovalReceipt() {
  6768. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6769. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  6770. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6771. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  6772. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  6773. if (! empty ( $rid )) {
  6774. Doo::loadModel ( "verify" );
  6775. $verify = new verify ();
  6776. Doo::loadModel ( "receiptDetail" );
  6777. $receiptDetailObj = new receiptDetail ();
  6778. Doo::loadModel ( "itemStatistics" );
  6779. Doo::loadModel ( "statistics" );
  6780. $statistics = new statistics ();
  6781. $itemStatistics = new itemStatistics ();
  6782. Doo::loadModel ( "receipt" );
  6783. $receipt = new receipt ();
  6784. $receiptDetail = $receipt->getOne ( array (
  6785. 'where' => 'rid=' . $rid . ' and status=2 ',
  6786. 'asArray' => true
  6787. ) );
  6788. if (empty ( $receiptDetail ))
  6789. return "/approval";
  6790. $verifyDetail = $verify->getOne ( array (
  6791. 'where' => ' vid =' . $receiptDetail ['verify'],
  6792. 'asArray' => true
  6793. ) );
  6794. $verifyString = $verifyDetail ['staff'];
  6795. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  6796. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  6797. if (empty ( $opinion )) {
  6798. if ($status == 3)
  6799. $opinion = "终止";
  6800. else
  6801. $opinion = "同意支付";
  6802. }
  6803. $nowStaff = 0;
  6804. $nowStaffList = array ();
  6805. if (empty ( $verifyStaff )) {
  6806. // 还需加入是否已经进入角色审批
  6807. if ($verifyDetail [0] [1] == 'ROLE') {
  6808. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  6809. foreach ( $vStaffString as $key => $value ) {
  6810. $staffK = explode ( "_", $value );
  6811. if ($staffK [0] != $this->staff [0] ['sid'])
  6812. array_push ( $nowStaffList, $staffK [0] );
  6813. }
  6814. // print_r($verifyDetail);
  6815. // die;
  6816. if (! empty ( $nowStaffList )) {
  6817. $nowStaff = implode ( ',', $nowStaffList );
  6818. $verifyStaff = array (
  6819. $this->staff [0] ['sid'] . "_R" => array (
  6820. 'date' => date ( 'Y-m-d' ),
  6821. 'opinion' => $opinion,
  6822. 'status' => $status,
  6823. 'nextStaff' => $verifyDetail [0] [0],
  6824. 'ROLE' => 1
  6825. )
  6826. );
  6827. } else {
  6828. $nowStaff = $verifyDetail [1] [0];
  6829. $verifyStaff = array (
  6830. $this->staff [0] ['sid'] . "_R" => array (
  6831. 'date' => date ( 'Y-m-d' ),
  6832. 'opinion' => $opinion,
  6833. 'status' => $status,
  6834. 'nextStaff' => $verifyDetail [1] [0]
  6835. )
  6836. );
  6837. }
  6838. } else {
  6839. if ($verifyDetail [1] [1] == 'ROLE') {
  6840. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  6841. // echo "dd";
  6842. foreach ( $vStaffString as $key => $value ) {
  6843. $staffK = explode ( "_", $value );
  6844. array_push ( $nowStaffList, $staffK [0] );
  6845. }
  6846. $nowStaff = implode ( ',', $nowStaffList );
  6847. $verifyStaff = array (
  6848. $this->staff [0] ['sid'] => array (
  6849. 'date' => date ( 'Y-m-d' ),
  6850. 'opinion' => $opinion,
  6851. 'status' => $status,
  6852. 'nextStaff' => $verifyDetail [1] [0],
  6853. 'ROLE' => 1
  6854. )
  6855. );
  6856. } else {
  6857. $nowStaff = $verifyDetail [1] [0];
  6858. $verifyStaff = array (
  6859. $this->staff [0] ['sid'] => array (
  6860. 'date' => date ( 'Y-m-d' ),
  6861. 'opinion' => $opinion,
  6862. 'status' => $status,
  6863. 'nextStaff' => $verifyDetail [1] [0]
  6864. )
  6865. );
  6866. }
  6867. }
  6868. if ($status == 3)
  6869. $verifyStaff = array (
  6870. 'final' => $status,
  6871. $this->staff [0] ['sid'] => array (
  6872. 'date' => date ( 'Y-m-d' ),
  6873. 'opinion' => $opinion,
  6874. 'status' => $status
  6875. )
  6876. );
  6877. $vStaffString = json_encode ( $verifyStaff );
  6878. $receipt->nowStaff = $nowStaff;
  6879. $receipt->verifyStaff = $vStaffString;
  6880. } else {
  6881. $VS = end ( $verifyStaff );
  6882. // 非角色审批
  6883. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  6884. $nextStaff = 0;
  6885. $roleSTF = false;
  6886. foreach ( $verifyDetail as $key => $value ) {
  6887. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  6888. if (isset ( $verifyDetail [$key + 1] )) {
  6889. $nextStaff = $verifyDetail [$key + 1] [0];
  6890. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  6891. $roleSTF = true;
  6892. }
  6893. break;
  6894. }
  6895. }
  6896. if (! $roleSTF) {
  6897. $nowStaff = $nextStaff;
  6898. $verifyStaff [$this->staff [0] ['sid']] = array (
  6899. 'date' => date ( 'Y-m-d' ),
  6900. 'opinion' => $opinion,
  6901. 'status' => $status,
  6902. 'nextStaff' => $nextStaff
  6903. );
  6904. } else {
  6905. // 获取角色下的所有用户ID
  6906. $nowStaffList = array ();
  6907. foreach ( $verifyDetail as $vfk ) {
  6908. if ($vfk [1] == 'ROLE') {
  6909. $vStaffString = json_decode ( $vfk [3] );
  6910. foreach ( $vStaffString as $key => $value ) {
  6911. $staffK = explode ( "_", $value );
  6912. array_push ( $nowStaffList, $staffK [0] );
  6913. }
  6914. }
  6915. }
  6916. $nowStaff = implode ( ',', $nowStaffList );
  6917. $verifyStaff [$this->staff [0] ['sid']] = array (
  6918. 'date' => date ( 'Y-m-d' ),
  6919. 'opinion' => $opinion,
  6920. 'status' => $status,
  6921. 'nextStaff' => $nextStaff,
  6922. 'ROLE' => 0
  6923. );
  6924. }
  6925. if ($status == 3) {
  6926. $verifyStaff ['final'] = $status;
  6927. $verifyStaff [$this->staff [0] ['sid']] = array (
  6928. 'date' => date ( 'Y-m-d' ),
  6929. 'opinion' => $opinion,
  6930. 'status' => $status
  6931. );
  6932. }
  6933. $vStaffString = json_encode ( $verifyStaff );
  6934. $receipt->nowStaff = $nowStaff;
  6935. $receipt->verifyStaff = $vStaffString;
  6936. }
  6937. // 角色审批
  6938. if (isset ( $VS ['ROLE'] )) {
  6939. // 找出角色人 当前审批角色组
  6940. $verifyJSStaff = array ();
  6941. $nowStaffList2 = array ();
  6942. foreach ( $verifyDetail as $key => $value ) {
  6943. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  6944. $verifyJSStaff = json_decode ( $value [3] );
  6945. foreach ( $verifyJSStaff as $m ) {
  6946. $staffK = explode ( "_", $m );
  6947. array_push ( $nowStaffList2, $staffK [0] );
  6948. }
  6949. // print_r($nowStaffList2);
  6950. }
  6951. }
  6952. $RoleVerifyStaff = array ();
  6953. foreach ( $verifyStaff as $key => $value ) {
  6954. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  6955. foreach ( $nowStaffList2 as $m ) {
  6956. if ($key == $m . "_R")
  6957. $RoleVerifyStaff [$key] = $value;
  6958. }
  6959. }
  6960. }
  6961. // print_r($verifyStaff);
  6962. // print_r($nowStaffList2);
  6963. // print_r($RoleVerifyStaff);
  6964. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  6965. // print_r($verifyJSStaff);
  6966. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  6967. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  6968. // 下一个审批人ID
  6969. $nextStaff = 0;
  6970. $falg = false;
  6971. foreach ( $verifyDetail as $key => $value ) {
  6972. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  6973. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  6974. $falg = true;
  6975. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  6976. $nowStaffList = array ();
  6977. foreach ( $vStaffString as $v ) {
  6978. $staffK = explode ( "_", $v );
  6979. array_push ( $nowStaffList, $staffK [0] );
  6980. }
  6981. $nowStaff = implode ( ',', $nowStaffList );
  6982. $nextStaff = $verifyDetail [$key + 1] [0];
  6983. } elseif (isset ( $verifyDetail [$key + 1] )) {
  6984. $nextStaff = $verifyDetail [$key + 1] [0];
  6985. $nowStaff = $nextStaff;
  6986. } else
  6987. $nowStaff = '';
  6988. break;
  6989. }
  6990. }
  6991. if ($falg)
  6992. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6993. 'date' => date ( 'Y-m-d' ),
  6994. 'opinion' => $opinion,
  6995. 'status' => $status,
  6996. 'nextStaff' => $nextStaff,
  6997. 'ROLE' => 1
  6998. );
  6999. else
  7000. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7001. 'date' => date ( 'Y-m-d' ),
  7002. 'opinion' => $opinion,
  7003. 'status' => $status,
  7004. 'nextStaff' => $nextStaff
  7005. );
  7006. // print_r($verifyStaff);
  7007. // echo $nowStaff;die;
  7008. } else { // 进入下一个角色或者审批人
  7009. /*
  7010. *
  7011. */
  7012. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  7013. //
  7014. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  7015. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7016. 'date' => date ( 'Y-m-d' ),
  7017. 'opinion' => $opinion,
  7018. 'status' => $status,
  7019. 'nextStaff' => $VS ['nextStaff'],
  7020. 'ROLE' => 1
  7021. );
  7022. // print_r($verifyStaff);
  7023. // die;
  7024. }
  7025. if ($status == 3) {
  7026. $verifyStaff ['final'] = $status;
  7027. $verifyStaff [$this->staff [0] ['sid']] = array (
  7028. 'date' => date ( 'Y-m-d' ),
  7029. 'opinion' => $opinion,
  7030. 'status' => $status
  7031. );
  7032. }
  7033. $vStaffString = json_encode ( $verifyStaff );
  7034. $receipt->verifyStaff = $vStaffString;
  7035. $receipt->nowStaff = $nowStaff;
  7036. // die;
  7037. // }
  7038. // print_r($verifyStaff);
  7039. // die;
  7040. }
  7041. // print_r($verifyStaff);die;
  7042. }
  7043. // print_r($verifyDetail);
  7044. $roleKey = 0;
  7045. $roleId = 0;
  7046. $verifyDetailCopy = array ();
  7047. foreach ( $verifyDetail as $k => $v ) {
  7048. if ($v [1] == 'ROLE') {
  7049. $roleId = $v [0];
  7050. $roleVerify = json_decode ( $v [3], true );
  7051. $roleKey = $k;
  7052. $roleArray = array ();
  7053. foreach ( $roleVerify as $o => $p ) {
  7054. $staffID = explode ( '_', $p );
  7055. $exp = array (
  7056. 0 => $staffID [0],
  7057. 1 => $staffID [1]
  7058. );
  7059. array_push ( $roleArray, $exp );
  7060. }
  7061. $verifyDetailCopy [$v [0]] = $roleArray;
  7062. }
  7063. }
  7064. // print_r($verifyDetail);
  7065. foreach ( $verifyDetailCopy as $k => $v ) {
  7066. foreach ( $verifyDetail as $m => $n ) {
  7067. if ($n [0] == $k) {
  7068. array_splice ( $verifyDetail, $m, 1, $v );
  7069. }
  7070. }
  7071. }
  7072. // die;
  7073. // if (!empty($roleArray))
  7074. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  7075. // echo $roleId;
  7076. // print_r($verifyStaff);
  7077. // print_r($verifyDetail);
  7078. // die;
  7079. Doo::loadModel ( "receiptLog" );
  7080. $receiptLog = new receiptLog ();
  7081. // 审批日志
  7082. if (! isset ( $verifyStaff ['final'] )) {
  7083. if (! empty ( $roleId )) {
  7084. Doo::loadModel ( "role" );
  7085. $role = new role ();
  7086. $roleInfo = $role->getOne ( array (
  7087. 'where' => 'rid=' . $roleId,
  7088. 'asArray' => true
  7089. ) );
  7090. $receiptLog->rolename = $roleInfo ['name'];
  7091. }
  7092. $receiptLog->username = $this->staff [0] ['username'];
  7093. $receiptLog->uid = $this->staff [0] ['sid'];
  7094. $receiptLog->date = date ( "Y-m-d" );
  7095. $receiptLog->opinion = $opinion;
  7096. $receiptLog->img = $this->staff [0] ['avatar'];
  7097. $receiptLog->status = 1;
  7098. $receiptLog->rid = $rid;
  7099. $receiptLog->insert ();
  7100. }
  7101. if (isset ( $verifyStaff ['final'] )) { // rDetail
  7102. $receipt->verifyBreakup = $verifyString;
  7103. $receipt->status = 3;
  7104. $receiptDetailObj->status = 3;
  7105. $receiptDetailObj->update ( array (
  7106. 'where' => 'rid=' . $rid
  7107. ) );
  7108. if (! empty ( $roleId )) {
  7109. Doo::loadModel ( "role" );
  7110. $role = new role ();
  7111. $roleInfo = $role->getOne ( array (
  7112. 'where' => 'rid=' . $roleId,
  7113. 'asArray' => true
  7114. ) );
  7115. $receiptLog->rolename = $roleInfo ['name'];
  7116. }
  7117. $receiptLog->username = $this->staff [0] ['username'];
  7118. $receiptLog->uid = $this->staff [0] ['sid'];
  7119. $receiptLog->date = date ( "Y-m-d" );
  7120. $receiptLog->opinion = $opinion;
  7121. $receiptLog->img = $this->staff [0] ['avatar'];
  7122. $receiptLog->status = 3;
  7123. $receiptLog->rid = $rid;
  7124. $receiptLog->insert ();
  7125. // 微信企业号通知
  7126. $this->setWXMsg ( $rid, 3 );
  7127. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  7128. $receipt->status = 1;
  7129. $reviseSum = 0;
  7130. $receipt->verifyBreakup = $verifyString;
  7131. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  7132. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7133. foreach ( $reviseDetail as $key => $value ) {
  7134. $receiptDetailObj = new receiptDetail ();
  7135. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7136. $receiptDetailObj->item = $value ['description'];
  7137. $receiptDetailObj->itemCategory = "报销金额调整";
  7138. $receiptDetailObj->price = $value ['price'];
  7139. $receiptDetailObj->date = $receiptDetail ['date'];
  7140. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  7141. $receiptDetailObj->rid = $rid;
  7142. $receiptDetailObj->status = 1;
  7143. $receiptDetailObj->insert ();
  7144. $reviseSum += $value ['price'];
  7145. }
  7146. $itemStatistics = new itemStatistics ();
  7147. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7148. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7149. $itemStatistics->price = $reviseSum;
  7150. $itemStatistics->itemCategory = "报销金额调整";
  7151. $itemStatistics->date = $receiptDetail ['date'];
  7152. $itemStatistics->insert ();
  7153. }
  7154. $receiptDetailObj = new receiptDetail ();
  7155. $receiptDetailObj->status = 1;
  7156. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  7157. $receiptDetailObj->update ( array (
  7158. 'where' => 'rid=' . $rid
  7159. ) );
  7160. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7161. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7162. $stat = $statistics->getOne ( array (
  7163. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  7164. 'asArray' => true
  7165. ) );
  7166. if (empty ( $stat )) {
  7167. $statistics->date = $receiptDetail ['date'];
  7168. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7169. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7170. $statistics->agPrice = $receiptDetail ['sum'];
  7171. $statistics->rePrice = $reviseSum;
  7172. $statistics->insert ();
  7173. } else {
  7174. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  7175. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  7176. $statistics->update ( array (
  7177. 'where' => 'sid=' . $stat ['sid']
  7178. ) );
  7179. }
  7180. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7181. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7182. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  7183. foreach ( $accountItem ['cSum'] as $key => $value ) {
  7184. if ($key == "agencySum") {
  7185. $iStatistics = $itemStatistics->getOne ( array (
  7186. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  7187. 'asArray' => true
  7188. ) );
  7189. if (empty ( $iStatistics )) {
  7190. $itemStatistics->cid = $receiptDetail ['cid'];
  7191. ;
  7192. $itemStatistics->staff = $receiptDetail ['staff'];
  7193. $itemStatistics->price = $value;
  7194. $itemStatistics->itemCategory = $this->AGENCY;
  7195. $itemStatistics->date = $receiptDetail ['date'];
  7196. $itemStatistics->insert ();
  7197. } else {
  7198. if (! empty ( $value )) {
  7199. $itemStatistics->price = $value + $iStatistics ['price'];
  7200. $itemStatistics->update ( array (
  7201. 'where' => 'sid=' . $iStatistics ['sid']
  7202. ) );
  7203. }
  7204. }
  7205. } elseif ($key == "travelSum") {
  7206. $iStatistics = $itemStatistics->getOne ( array (
  7207. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  7208. 'asArray' => true
  7209. ) );
  7210. if (empty ( $iStatistics )) {
  7211. $itemStatistics->cid = $receiptDetail ['cid'];
  7212. $itemStatistics->staff = $receiptDetail ['staff'];
  7213. $itemStatistics->price = $value;
  7214. $itemStatistics->itemCategory = $this->TRAVEL;
  7215. $itemStatistics->date = $receiptDetail ['date'];
  7216. $itemStatistics->insert ();
  7217. } else {
  7218. if (! empty ( $value )) {
  7219. $itemStatistics->price = $value + $iStatistics ['price'];
  7220. $itemStatistics->update ( array (
  7221. 'where' => 'sid=' . $iStatistics ['sid']
  7222. ) );
  7223. }
  7224. }
  7225. } elseif ($key == "trainSum") {
  7226. $iStatistics = $itemStatistics->getOne ( array (
  7227. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  7228. 'asArray' => true
  7229. ) );
  7230. if (empty ( $iStatistics )) {
  7231. $itemStatistics->cid = $receiptDetail ['cid'];
  7232. $itemStatistics->staff = $receiptDetail ['staff'];
  7233. $itemStatistics->price = $value;
  7234. $itemStatistics->itemCategory = $this->TRAIN;
  7235. $itemStatistics->date = $receiptDetail ['date'];
  7236. $itemStatistics->insert ();
  7237. } else {
  7238. if (! empty ( $value )) {
  7239. $itemStatistics->price = $value + $iStatistics ['price'];
  7240. $itemStatistics->update ( array (
  7241. 'where' => 'sid=' . $iStatistics ['sid']
  7242. ) );
  7243. }
  7244. }
  7245. } elseif ($key == "otherSum") {
  7246. $iStatistics = $itemStatistics->getOne ( array (
  7247. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  7248. 'asArray' => true
  7249. ) );
  7250. if (empty ( $iStatistics )) {
  7251. $itemStatistics->cid = $receiptDetail ['cid'];
  7252. $itemStatistics->staff = $receiptDetail ['staff'];
  7253. $itemStatistics->price = $value;
  7254. $itemStatistics->itemCategory = $this->OTHER;
  7255. $itemStatistics->date = $receiptDetail ['date'];
  7256. $itemStatistics->insert ();
  7257. } else {
  7258. if (! empty ( $value )) {
  7259. $itemStatistics->price = $value + $iStatistics ['price'];
  7260. $itemStatistics->update ( array (
  7261. 'where' => 'sid=' . $iStatistics ['sid']
  7262. ) );
  7263. }
  7264. }
  7265. }
  7266. }
  7267. $receipt->pastDate = date ( "Y-m-d" );
  7268. // 微信企业号通知
  7269. $this->setWXMsg ( $rid, 1 );
  7270. }
  7271. $receipt->amount = $amount;
  7272. $receipt->update ( array (
  7273. 'where' => ' rid = ' . $rid
  7274. ) );
  7275. return "/approvalExpenses/pendApproval";
  7276. }
  7277. }
  7278. function expensesRetreats() {
  7279. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7280. if (! empty ( $rid )) {
  7281. // 操作记录
  7282. Doo::loadModel ( "receipt" );
  7283. $receipt = new receipt ();
  7284. Doo::loadModel ( "receiptLog" );
  7285. $receiptLog = new receiptLog ();
  7286. Doo::loadModel ( "verify" );
  7287. $verify = new verify ();
  7288. $receiptInfo = $receipt->getOne ( array (
  7289. 'where' => 'rid=' . $rid,
  7290. 'asArray' => true
  7291. ) );
  7292. $vr = $verify->getOne ( array (
  7293. 'where' => 'vid=' . $receiptInfo ['verify'],
  7294. 'asArray' => true
  7295. ) );
  7296. $jd = json_decode ( $vr ['staff'] );
  7297. $roleId = 0;
  7298. foreach ( $jd as $key => $value ) {
  7299. if ($value [1] == 'ROLE') {
  7300. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7301. if ($pos !== false) {
  7302. $roleId = $value [0];
  7303. }
  7304. }
  7305. }
  7306. // 审批日志
  7307. // echo $roleId;die;
  7308. if (! empty ( $roleId )) {
  7309. Doo::loadModel ( "role" );
  7310. $role = new role ();
  7311. $roleInfo = $role->getOne ( array (
  7312. 'where' => 'rid=' . $roleId,
  7313. 'asArray' => true
  7314. ) );
  7315. $receiptLog->rolename = $roleInfo ['name'];
  7316. }
  7317. $receiptLog->username = $this->staff [0] ['username'];
  7318. $receiptLog->uid = $this->staff [0] ['sid'];
  7319. $receiptLog->date = date ( "Y-m-d" );
  7320. $receiptLog->opinion = '撤回';
  7321. $receiptLog->img = $this->staff [0] ['avatar'];
  7322. $receiptLog->status = 4;
  7323. $receiptLog->rid = $rid;
  7324. $receiptLog->insert ();
  7325. $receipt->status = 4;
  7326. $receipt->update ( array (
  7327. 'where' => 'rid=' . $rid
  7328. ) );
  7329. // 微信企业号通知
  7330. $this->setWXMsg ( $rid, 2 );
  7331. }
  7332. // echo "ddd";
  7333. return '/approvalExpenses/pendApproval';
  7334. }
  7335. function updateCheReceipt() {
  7336. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7337. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7338. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  7339. if (! empty ( $rid )) {
  7340. // 操作记录
  7341. Doo::loadModel ( "receipt" );
  7342. $receipt = new receipt ();
  7343. Doo::loadModel ( "receiptLog" );
  7344. $receiptLog = new receiptLog ();
  7345. Doo::loadModel ( "verify" );
  7346. $verify = new verify ();
  7347. $receiptInfo = $receipt->getOne ( array (
  7348. 'where' => 'rid=' . $rid.' and status=2',
  7349. 'asArray' => true
  7350. ) );
  7351. if(empty($receiptInfo)){
  7352. echo json_encode ( array (
  7353. 'status' => 2
  7354. ) );
  7355. die ();
  7356. }
  7357. $vr = $verify->getOne ( array (
  7358. 'where' => 'vid=' . $receiptInfo ['verify'],
  7359. 'asArray' => true
  7360. ) );
  7361. $jd = json_decode ( $vr ['staff'] );
  7362. $roleId = 0;
  7363. foreach ( $jd as $key => $value ) {
  7364. if ($value [1] == 'ROLE') {
  7365. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7366. if ($pos !== false) {
  7367. $roleId = $value [0];
  7368. }
  7369. }
  7370. }
  7371. // 审批日志
  7372. // echo $roleId;die;
  7373. if (! empty ( $roleId )) {
  7374. Doo::loadModel ( "role" );
  7375. $role = new role ();
  7376. $roleInfo = $role->getOne ( array (
  7377. 'where' => 'rid=' . $roleId,
  7378. 'asArray' => true
  7379. ) );
  7380. $receiptLog->rolename = $roleInfo ['name'];
  7381. }
  7382. $receiptLog->username = $this->staff [0] ['username'];
  7383. $receiptLog->uid = $this->staff [0] ['sid'];
  7384. $receiptLog->date = date ( "Y-m-d" );
  7385. $receiptLog->opinion = $opinion;
  7386. $receiptLog->img = $this->staff [0] ['avatar'];
  7387. $receiptLog->status = 4;
  7388. $receiptLog->rid = $rid;
  7389. $receiptLog->insert ();
  7390. $receipt->status = 4;
  7391. $receipt->update ( array (
  7392. 'where' => 'rid=' . $rid
  7393. ) );
  7394. // 微信企业号通知
  7395. $this->setWXMsg ( $rid, 2 );
  7396. echo json_encode ( array (
  7397. 'status' => 1
  7398. ) );
  7399. //Header("HTTP/1.1 303 See Other");
  7400. //Header("Location: /approvalExpenses/pendApproval");
  7401. die;
  7402. }
  7403. echo json_encode ( array (
  7404. 'status' => 2
  7405. ) );
  7406. die ();
  7407. // echo "ddd";
  7408. // return '/saeaBorad';
  7409. }
  7410. function revisePrice() {
  7411. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  7412. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  7413. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7414. // echo $price;die;
  7415. if (! empty ( $rid )) {
  7416. Doo::loadModel ( "receipt" );
  7417. $receipt = new receipt ();
  7418. $receiptDetail = $receipt->getOne ( array (
  7419. 'where' => 'rid=' . $rid . ' and status=2 ',
  7420. 'asArray' => true
  7421. ) );
  7422. if (empty ( $receiptDetail ))
  7423. return "/approval";
  7424. $reviseDetail = array ();
  7425. if (empty ( $receiptDetail ['reviseDetail'] )) {
  7426. array_push ( $reviseDetail, array (
  7427. 'sid' => $this->staff [0] ['sid'],
  7428. 'name' => $this->staff [0] ['username'],
  7429. 'description' => $description,
  7430. 'price' => $price
  7431. ) );
  7432. $reviseDetailString = json_encode ( $reviseDetail );
  7433. $receipt->reviseDetail = $reviseDetailString;
  7434. $receipt->revisePrice = $price;
  7435. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7436. } else {
  7437. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7438. array_push ( $reviseDetail, array (
  7439. 'sid' => $this->staff [0] ['sid'],
  7440. 'name' => $this->staff [0] ['username'],
  7441. 'description' => $description,
  7442. 'price' => $price
  7443. ) );
  7444. $reviseDetailString = json_encode ( $reviseDetail );
  7445. $receipt->reviseDetail = $reviseDetailString;
  7446. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  7447. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7448. }
  7449. $receipt->update ( array (
  7450. 'where' => 'rid=' . $rid
  7451. ) );
  7452. }
  7453. return '/approvalEdi/' . $rid;
  7454. }
  7455. function personalCollect() {
  7456. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7457. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  7458. $this->showCache ( $path );
  7459. Doo::loadModel ( "receiptDetail" );
  7460. Doo::loadModel ( "itemStatistics" );
  7461. Doo::loadModel ( 'statistics' );
  7462. $statistics = new statistics ();
  7463. $itemStatistics = new itemStatistics ();
  7464. $receiptDetail = new receiptDetail ();
  7465. $receiptCollectList = $receiptDetail->find ( array (
  7466. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7467. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7468. 'groupby' => 'itemCategory,Month(date)',
  7469. 'asArray' => true
  7470. ) );
  7471. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  7472. 'where' => 'staff=' . $this->staff [0] ['sid'],
  7473. 'asArray' => true
  7474. ) );
  7475. // create collect html
  7476. $collectArray = array (
  7477. '日常相关费用' => array (),
  7478. '差旅相关费用' => array (),
  7479. '培训班费用' => array (),
  7480. '其他' => array ()
  7481. );
  7482. $adjustment = array ();
  7483. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  7484. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7485. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  7486. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7487. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  7488. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7489. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  7490. array_push ( $collectArray ['其他'], $collectHtml );
  7491. $data ['collectArray'] = $collectArray;
  7492. // statistics html
  7493. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7494. if (empty ( $stList ))
  7495. $stList = array (
  7496. 'rePrice' => 0,
  7497. 'agPrice' => 0
  7498. );
  7499. $data ['stList'] = array (
  7500. 'rePrice' => $stList ['rePrice'],
  7501. 'agPrice' => $stList ['agPrice'],
  7502. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7503. );
  7504. // Adjustment price html
  7505. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7506. array_push ( $adjustment, $collectHtml );
  7507. $data ['adjustment'] = $adjustment;
  7508. // total price html
  7509. $collectHtml = "";
  7510. $total = 0;
  7511. for($i = 1; $i <= 12; $i ++) {
  7512. $sumPrice = 0;
  7513. foreach ( $receiptCollectList as $key => $value ) {
  7514. if ($value ['month'] == $i) {
  7515. $sumPrice += $value ['price'];
  7516. }
  7517. }
  7518. if ($sumPrice == 0)
  7519. $collectHtml .= '<td class="taR">-</td>';
  7520. else
  7521. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7522. $total += $sumPrice;
  7523. }
  7524. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7525. $data ['totalPrice'] = $collectHtml;
  7526. $data ['year'] = $year;
  7527. $data ['totalYear'] = $total;
  7528. $data ['memu'] = "receipt";
  7529. $data ['staff'] = $this->staff;
  7530. $data ['receiptMemu'] = 'personalCollect';
  7531. $data ['verifyId'] = $this->verifyId;
  7532. $data ['executeId'] = $this->executeId;
  7533. // year staff status 2,4
  7534. if ($year < date ( "Y" )) {
  7535. Doo::loadModel ( 'receipt' );
  7536. $receipt = new receipt ();
  7537. $receiptList = $receipt->find ( array (
  7538. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7539. 'asArray' => true
  7540. ) );
  7541. if (empty ( $receiptList )) {
  7542. ob_start ();
  7543. $this->render ( "/admin/saea_slist_collect", $data );
  7544. $this->cacheFile ( $path );
  7545. die ();
  7546. }
  7547. }
  7548. $this->render ( "/admin/saea_slist_collect", $data );
  7549. }
  7550. function personalCollectDetail() {
  7551. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7552. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  7553. $this->showCache ( $path );
  7554. Doo::loadModel ( "receiptDetail" );
  7555. Doo::loadModel ( "itemStatistics" );
  7556. Doo::loadModel ( 'statistics' );
  7557. Doo::loadModel ( 'accountItem' );
  7558. $accountItem = new accountItem ();
  7559. $statistics = new statistics ();
  7560. $itemStatistics = new itemStatistics ();
  7561. $receiptDetail = new receiptDetail ();
  7562. $receiptCollectList = $receiptDetail->find ( array (
  7563. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  7564. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7565. 'groupby' => 'item,Month(date)',
  7566. 'asArray' => true
  7567. ) );
  7568. $accountList = $accountItem->find ( array (
  7569. 'asArray' => true
  7570. ) );
  7571. // create CollectDetail HTML
  7572. $collectHtml = array ();
  7573. foreach ( $accountList as $key => $value ) {
  7574. $html = "";
  7575. $asum = 0;
  7576. for($i = 1; $i <= 12; $i ++) {
  7577. $falg = true;
  7578. foreach ( $receiptCollectList as $v ) {
  7579. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7580. $asum += $v ['price'];
  7581. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7582. $falg = false;
  7583. break;
  7584. }
  7585. }
  7586. if ($falg)
  7587. $html .= '<td class="taR">-</td>';
  7588. }
  7589. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7590. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7591. }
  7592. $data ['collectHtml'] = $collectHtml;
  7593. // create Adjustment price html
  7594. $receiptCollectList = $receiptDetail->find ( array (
  7595. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7596. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7597. 'groupby' => 'itemCategory,Month(date)',
  7598. 'asArray' => true
  7599. ) );
  7600. $adjustment = array ();
  7601. $collectArray = array (
  7602. '日常相关费用' => array (),
  7603. '差旅相关费用' => array (),
  7604. '培训班费用' => array (),
  7605. '其他' => array ()
  7606. );
  7607. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7608. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7609. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7610. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7611. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7612. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7613. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7614. array_push ( $collectArray ['其他'], $collectHtml );
  7615. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7616. array_push ( $adjustment, $collectHtml );
  7617. // total price html
  7618. $collectHtml = "";
  7619. $total = 0;
  7620. for($i = 1; $i <= 12; $i ++) {
  7621. $sumPrice = 0;
  7622. foreach ( $receiptCollectList as $key => $value ) {
  7623. if ($value ['month'] == $i) {
  7624. $sumPrice += $value ['price'];
  7625. }
  7626. }
  7627. if ($sumPrice == 0)
  7628. $collectHtml .= '<td class="taR">-</td>';
  7629. else
  7630. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7631. $total += $sumPrice;
  7632. }
  7633. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7634. // statistics html
  7635. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7636. if (empty ( $stList ))
  7637. $stList = array (
  7638. 'rePrice' => 0,
  7639. 'agPrice' => 0
  7640. );
  7641. $data ['stList'] = array (
  7642. 'rePrice' => $stList ['rePrice'],
  7643. 'agPrice' => $stList ['agPrice'],
  7644. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7645. );
  7646. $data ['collectArray'] = $collectArray;
  7647. $data ['adjustment'] = $adjustment;
  7648. $data ['totalPrice'] = $collectHtml;
  7649. $data ['totalYear'] = $total;
  7650. $data ['year'] = $year;
  7651. $data ['memu'] = "receipt";
  7652. $data ['staff'] = $this->staff;
  7653. $data ['receiptMemu'] = 'personalCollect';
  7654. $data ['verifyId'] = $this->verifyId;
  7655. $data ['executeId'] = $this->executeId;
  7656. // year staff status 2,4
  7657. if ($year < date ( "Y" )) {
  7658. Doo::loadModel ( 'receipt' );
  7659. $receipt = new receipt ();
  7660. $receiptList = $receipt->find ( array (
  7661. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7662. 'asArray' => true
  7663. ) );
  7664. if (empty ( $receiptList )) {
  7665. ob_start ();
  7666. $this->render ( "/admin/saeaCollectArticles", $data );
  7667. $this->cacheFile ( $path );
  7668. die ();
  7669. }
  7670. }
  7671. $this->render ( "/admin/saeaCollectArticles", $data );
  7672. }
  7673. function companyCategoryCollect() {
  7674. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7675. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  7676. $this->showCache ( $path );
  7677. Doo::loadModel ( 'L_category' );
  7678. Doo::loadModel ( 'itemStatistics' );
  7679. Doo::loadModel ( 'statistics' );
  7680. $statistics = new statistics ();
  7681. $Lcategory = new L_category ();
  7682. $itemStatistics = new itemStatistics ();
  7683. $LcategoryList = $Lcategory->find ( array (
  7684. 'asArray' => true
  7685. ) ); // 'staff='.$this->staff[0]['sid']." and
  7686. $itemStatisticsList = $itemStatistics->find ( array (
  7687. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7688. 'where' => " Year(date)=" . $year,
  7689. 'groupby' => 'cid,Month(date)',
  7690. 'asArray' => true
  7691. ) );
  7692. // ceatre companyCollectHtml
  7693. foreach ( $LcategoryList as $value ) {
  7694. $html = "";
  7695. $asum = 0;
  7696. for($i = 1; $i <= 12; $i ++) {
  7697. $falg = true;
  7698. foreach ( $itemStatisticsList as $v ) {
  7699. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  7700. $asum += $v ['price'];
  7701. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7702. $falg = false;
  7703. break;
  7704. }
  7705. }
  7706. if ($falg)
  7707. $html .= '<td class="taR">-</td>';
  7708. }
  7709. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7710. $collectHtml [$value ['title']] = array (
  7711. 'html' => $html,
  7712. 'cid' => $value ['cid']
  7713. );
  7714. }
  7715. $data ['companyHtml'] = $collectHtml;
  7716. // total price html
  7717. $collectHtml = "";
  7718. $total = 0;
  7719. for($i = 1; $i <= 12; $i ++) {
  7720. $sumPrice = 0;
  7721. foreach ( $itemStatisticsList as $key => $value ) {
  7722. if ($value ['month'] == $i) {
  7723. $sumPrice += $value ['price'];
  7724. }
  7725. }
  7726. if ($sumPrice == 0)
  7727. $collectHtml .= '<td class="taR">-</td>';
  7728. else
  7729. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7730. $total += $sumPrice;
  7731. }
  7732. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7733. $data ['companyTotalHtml'] = $collectHtml;
  7734. $data ['total'] = $total;
  7735. // statistics html
  7736. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7737. if (empty ( $stList ))
  7738. $stList = array (
  7739. 'rePrice' => 0,
  7740. 'agPrice' => 0
  7741. );
  7742. $data ['stList'] = array (
  7743. 'rePrice' => $stList ['rePrice'],
  7744. 'agPrice' => $stList ['agPrice'],
  7745. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7746. );
  7747. $data ['year'] = $year;
  7748. $data ['memu'] = "receipt";
  7749. $data ['staff'] = $this->staff;
  7750. $data ['receiptMemu'] = 'companyCategoryCollect';
  7751. $data ['verifyId'] = $this->verifyId;
  7752. $data ['executeId'] = $this->executeId;
  7753. // year staff status 2,4
  7754. if ($year < date ( "Y" )) {
  7755. Doo::loadModel ( 'receipt' );
  7756. $receipt = new receipt ();
  7757. $receiptList = $receipt->find ( array (
  7758. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  7759. 'asArray' => true
  7760. ) );
  7761. if (empty ( $receiptList )) {
  7762. ob_start ();
  7763. $this->render ( "/admin/saeaCompanyCollect", $data );
  7764. $this->cacheFile ( $path );
  7765. die ();
  7766. }
  7767. }
  7768. $this->render ( "/admin/saeaCompanyCollect", $data );
  7769. }
  7770. function categoryCollectDetail() {
  7771. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7772. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  7773. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  7774. $this->showCache ( $path );
  7775. Doo::loadModel ( 'statistics' );
  7776. $statistics = new statistics ();
  7777. Doo::loadModel ( "receiptDetail" );
  7778. $receiptDetail = new receiptDetail ();
  7779. Doo::loadModel ( 'L_category' );
  7780. $Lcategory = new L_category ();
  7781. Doo::loadModel ( 'accountItem' );
  7782. $accountItem = new accountItem ();
  7783. $LcategoryList = $Lcategory->find ( array (
  7784. 'asArray' => true
  7785. ) );
  7786. if ($cid == 0) {
  7787. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7788. if ($cid == 0)
  7789. $cid = $LcategoryList [0] ['cid'];
  7790. }
  7791. $data ['LcategoryList'] = $LcategoryList;
  7792. $receiptCollectList = $receiptDetail->find ( array (
  7793. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  7794. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7795. 'groupby' => 'item,Month(pastDate)',
  7796. 'asArray' => true
  7797. ) );
  7798. $accountList = $accountItem->find ( array (
  7799. 'asArray' => true
  7800. ) );
  7801. // create CollectDetail HTML
  7802. $collectHtml = array ();
  7803. foreach ( $accountList as $key => $value ) {
  7804. $html = "";
  7805. $asum = 0;
  7806. for($i = 1; $i <= 12; $i ++) {
  7807. $falg = true;
  7808. foreach ( $receiptCollectList as $v ) {
  7809. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7810. $asum += $v ['price'];
  7811. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7812. $falg = false;
  7813. break;
  7814. }
  7815. }
  7816. if ($falg)
  7817. $html .= '<td class="taR">-</td>';
  7818. }
  7819. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7820. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7821. }
  7822. $data ['collectHtml'] = $collectHtml;
  7823. // create Adjustment price html
  7824. $receiptCollectList = $receiptDetail->find ( array (
  7825. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  7826. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7827. 'groupby' => 'itemCategory,Month(pastDate)',
  7828. 'asArray' => true
  7829. ) );
  7830. $adjustment = array ();
  7831. $collectArray = array (
  7832. '日常相关费用' => array (),
  7833. '差旅相关费用' => array (),
  7834. '培训班费用' => array (),
  7835. '其他' => array ()
  7836. );
  7837. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7838. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7839. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7840. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7841. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7842. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7843. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7844. array_push ( $collectArray ['其他'], $collectHtml );
  7845. $data ['collectArray'] = $collectArray;
  7846. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7847. array_push ( $adjustment, $collectHtml );
  7848. $data ['adjustment'] = $adjustment;
  7849. // total price html
  7850. $collectHtml = "";
  7851. $total = 0;
  7852. for($i = 1; $i <= 12; $i ++) {
  7853. $sumPrice = 0;
  7854. foreach ( $receiptCollectList as $key => $value ) {
  7855. if ($value ['month'] == $i) {
  7856. $sumPrice += $value ['price'];
  7857. }
  7858. }
  7859. if ($sumPrice == 0)
  7860. $collectHtml .= '<td class="taR">-</td>';
  7861. else
  7862. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7863. $total += $sumPrice;
  7864. }
  7865. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7866. // statistics html
  7867. $stList = $statistics->statisticsByCid ( $year, $cid );
  7868. if (empty ( $stList ))
  7869. $stList = array (
  7870. 'rePrice' => 0,
  7871. 'agPrice' => 0
  7872. );
  7873. $data ['stList'] = array (
  7874. 'rePrice' => $stList ['rePrice'],
  7875. 'agPrice' => $stList ['agPrice'],
  7876. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7877. );
  7878. $data ['totalYear'] = $total;
  7879. $data ['year'] = $year;
  7880. $data ['cid'] = $cid;
  7881. $data ['memu'] = "receipt";
  7882. $data ['staff'] = $this->staff;
  7883. $data ['receiptMemu'] = 'companyCategoryCollect';
  7884. $data ['verifyId'] = $this->verifyId;
  7885. $data ['executeId'] = $this->executeId;
  7886. // year staff status 2,4
  7887. if ($year < date ( "Y" )) {
  7888. Doo::loadModel ( 'receipt' );
  7889. $receipt = new receipt ();
  7890. $receiptList = $receipt->find ( array (
  7891. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  7892. 'asArray' => true
  7893. ) );
  7894. if (empty ( $receiptList )) {
  7895. ob_start ();
  7896. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7897. $this->cacheFile ( $path );
  7898. die ();
  7899. }
  7900. }
  7901. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7902. }
  7903. function staffCollect() {
  7904. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7905. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  7906. // $this->showCache($path);
  7907. Doo::loadModel ( 'statistics' );
  7908. $statistics = new statistics ();
  7909. Doo::loadModel ( "receiptDetail" );
  7910. $receiptDetail = new receiptDetail ();
  7911. Doo::loadModel ( 'L_category' );
  7912. $Lcategory = new L_category ();
  7913. Doo::loadModel ( 'accountItem' );
  7914. $accountItem = new accountItem ();
  7915. Doo::loadModel ( 'staff' );
  7916. $staff = new staff ();
  7917. Doo::loadModel ( 'itemStatistics' );
  7918. $itemStatistics = new itemStatistics ();
  7919. /*
  7920. * $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']));
  7921. */
  7922. // statistics html
  7923. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7924. if (empty ( $stList ))
  7925. $stList = array (
  7926. 'rePrice' => 0,
  7927. 'agPrice' => 0
  7928. );
  7929. $data ['stList'] = array (
  7930. 'rePrice' => $stList ['rePrice'],
  7931. 'agPrice' => $stList ['agPrice'],
  7932. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7933. );
  7934. // ---
  7935. $staffList = $staff->find ( array (
  7936. 'where' => 'username !="admin"',
  7937. 'asArray' => true
  7938. ) );
  7939. $LcategoryList = $Lcategory->find ( array (
  7940. 'asArray' => true
  7941. ) ); // 'staff='.$this->staff[0]['sid']." and
  7942. $itemStatisticsList = $itemStatistics->find ( array (
  7943. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7944. 'where' => " Year(date)=" . $year,
  7945. 'groupby' => 'staff,Month(date)',
  7946. 'asArray' => true
  7947. ) );
  7948. $categoryList = $staff->find ( array (
  7949. 'select' => 'COUNT(*) as count,cid,category',
  7950. 'where' => 'username !="admin"',
  7951. 'groupby' => 'cid',
  7952. 'asArray' => true
  7953. ) );
  7954. // print_r($itemStatisticsList);die;
  7955. // ceatre companyCollectHtml
  7956. foreach ( $categoryList as $vlu ) {
  7957. $count = $vlu ['count'] + 1;
  7958. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  7959. $m1 = 0;
  7960. $m2 = 0;
  7961. $m3 = 0;
  7962. $m4 = 0;
  7963. $m5 = 0;
  7964. $m6 = 0;
  7965. $m7 = 0;
  7966. $m8 = 0;
  7967. $m9 = 0;
  7968. $m10 = 0;
  7969. $m11 = 0;
  7970. $m12 = 0;
  7971. $m13 = 0;
  7972. foreach ( $staffList as $value ) {
  7973. if ($vlu ['cid'] == $value ['cid']) {
  7974. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  7975. $asum = 0;
  7976. for($i = 1; $i <= 12; $i ++) {
  7977. $falg = true;
  7978. foreach ( $itemStatisticsList as $v ) {
  7979. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  7980. if ($v ['month'] == 1)
  7981. $m1 += $v ['price'];
  7982. if ($v ['month'] == 2)
  7983. $m2 += $v ['price'];
  7984. if ($v ['month'] == 3)
  7985. $m3 += $v ['price'];
  7986. if ($v ['month'] == 4)
  7987. $m4 += $v ['price'];
  7988. if ($v ['month'] == 5)
  7989. $m5 += $v ['price'];
  7990. if ($v ['month'] == 6)
  7991. $m6 += $v ['price'];
  7992. if ($v ['month'] == 7)
  7993. $m7 += $v ['price'];
  7994. if ($v ['month'] == 8)
  7995. $m8 += $v ['price'];
  7996. if ($v ['month'] == 9)
  7997. $m9 += $v ['price'];
  7998. if ($v ['month'] == 10)
  7999. $m10 += $v ['price'];
  8000. if ($v ['month'] == 11)
  8001. $m11 += $v ['price'];
  8002. if ($v ['month'] == 12)
  8003. $m12 += $v ['price'];
  8004. $asum += $v ['price'];
  8005. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8006. $falg = false;
  8007. break;
  8008. }
  8009. }
  8010. if ($falg)
  8011. $html .= '<td class="taR">-</td>';
  8012. }
  8013. $m13 += $asum;
  8014. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8015. $collectHtml [$value ['username']] = array (
  8016. 'html' => $html,
  8017. 'sid' => $value ['sid']
  8018. );
  8019. $html = "";
  8020. }
  8021. }
  8022. $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>
  8023. <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>
  8024. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  8025. $collectHtml [$vlu ['cid']] = array (
  8026. 'html' => $hl,
  8027. 'sid' => ''
  8028. );
  8029. }
  8030. $data ['companyHtml'] = $collectHtml;
  8031. // total price html
  8032. $collectHtml = "";
  8033. $total = 0;
  8034. for($i = 1; $i <= 12; $i ++) {
  8035. $sumPrice = 0;
  8036. foreach ( $itemStatisticsList as $key => $value ) {
  8037. if ($value ['month'] == $i) {
  8038. $sumPrice += $value ['price'];
  8039. }
  8040. }
  8041. if ($sumPrice == 0)
  8042. $collectHtml .= '<td class="taR">-</td>';
  8043. else
  8044. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8045. $total += $sumPrice;
  8046. }
  8047. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8048. $data ['companyTotalHtml'] = $collectHtml;
  8049. $data ['total'] = $total;
  8050. $data ['year'] = $year;
  8051. $data ['memu'] = "receipt";
  8052. $data ['staff'] = $this->staff;
  8053. $data ['receiptMemu'] = 'companyCategoryCollect';
  8054. $data ['verifyId'] = $this->verifyId;
  8055. $data ['executeId'] = $this->executeId;
  8056. if ($year <= date ( "Y" )) {
  8057. Doo::loadModel ( 'receipt' );
  8058. $receipt = new receipt ();
  8059. $receiptList = $receipt->find ( array (
  8060. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  8061. 'asArray' => true
  8062. ) );
  8063. if (empty ( $receiptList )) { // generated files
  8064. ob_start ();
  8065. $this->render ( "/admin/saeaStaffCollectB", $data );
  8066. $this->cacheFile ( $path );
  8067. die ();
  8068. }
  8069. }
  8070. $this->render ( "/admin/saeaStaffCollectB", $data );
  8071. }
  8072. function staffCollectBak() {
  8073. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8074. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  8075. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  8076. $this->showCache ( $path );
  8077. Doo::loadModel ( 'statistics' );
  8078. $statistics = new statistics ();
  8079. Doo::loadModel ( "receiptDetail" );
  8080. $receiptDetail = new receiptDetail ();
  8081. Doo::loadModel ( 'L_category' );
  8082. $Lcategory = new L_category ();
  8083. Doo::loadModel ( 'accountItem' );
  8084. $accountItem = new accountItem ();
  8085. Doo::loadModel ( 'staff' );
  8086. $staff = new staff ();
  8087. Doo::loadModel ( 'itemStatistics' );
  8088. $itemStatistics = new itemStatistics ();
  8089. $itemStatisticsList = $itemStatistics->find ( array (
  8090. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8091. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8092. 'groupby' => 'staff,itemCategory,Month(date)',
  8093. 'asArray' => true
  8094. ) );
  8095. $itemCategoryList = $itemStatistics->find ( array (
  8096. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8097. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8098. 'groupby' => 'cid,itemCategory,Month(date)',
  8099. 'asArray' => true
  8100. ) );
  8101. $LcategoryList = $Lcategory->find ( array (
  8102. 'asArray' => true
  8103. ) );
  8104. $staffList = $staff->find ( array (
  8105. 'asArray' => true
  8106. ) );
  8107. $htmlArray = array ();
  8108. foreach ( $LcategoryList as $value ) {
  8109. $htmlArray [$value ['title']] = array ();
  8110. foreach ( $staffList as $v ) {
  8111. if ($value ['cid'] == $v ['cid']) {
  8112. $html = "";
  8113. $falg = true;
  8114. $staffSumPrice = 0;
  8115. foreach ( $itemStatisticsList as $a ) {
  8116. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  8117. if (empty ( $a ['price'] )) {
  8118. $html .= '<td class="taR">-</td>';
  8119. $falg = false;
  8120. break;
  8121. } else {
  8122. $staffSumPrice += $a ['price'];
  8123. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8124. $falg = false;
  8125. break;
  8126. }
  8127. }
  8128. }
  8129. if ($falg) {
  8130. $html .= '<td class="taR">-</td>';
  8131. $falg = true;
  8132. }
  8133. $falg = true;
  8134. foreach ( $itemStatisticsList as $a ) {
  8135. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  8136. if (empty ( $a ['price'] )) {
  8137. $html .= '<td class="taR">-</td>';
  8138. $falg = false;
  8139. break;
  8140. } else {
  8141. $staffSumPrice += $a ['price'];
  8142. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8143. $falg = false;
  8144. break;
  8145. }
  8146. }
  8147. }
  8148. if ($falg) {
  8149. $html .= '<td class="taR">-</td>';
  8150. $falg = true;
  8151. }
  8152. $falg = true;
  8153. foreach ( $itemStatisticsList as $a ) {
  8154. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  8155. if (empty ( $a ['price'] )) {
  8156. $html .= '<td class="taR">-</td>';
  8157. $falg = false;
  8158. break;
  8159. } else {
  8160. $staffSumPrice += $a ['price'];
  8161. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8162. $falg = false;
  8163. break;
  8164. }
  8165. }
  8166. }
  8167. if ($falg) {
  8168. $html .= '<td class="taR">-</td>';
  8169. $falg = true;
  8170. }
  8171. $falg = true;
  8172. foreach ( $itemStatisticsList as $a ) {
  8173. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  8174. if (! empty ( $a ['price'] )) {
  8175. $staffSumPrice += $a ['price'];
  8176. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8177. $falg = false;
  8178. break;
  8179. } else {
  8180. $html .= '<td class="taR">-</td>';
  8181. $falg = false;
  8182. break;
  8183. }
  8184. }
  8185. }
  8186. if ($falg) {
  8187. $html .= '<td class="taR">-</td>';
  8188. $falg = true;
  8189. }
  8190. $falg = true;
  8191. foreach ( $itemStatisticsList as $a ) {
  8192. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  8193. if (! empty ( $a ['price'] )) {
  8194. $staffSumPrice += $a ['price'];
  8195. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8196. $falg = false;
  8197. break;
  8198. } else {
  8199. $html .= '<td class="taR">-</td>';
  8200. $falg = false;
  8201. break;
  8202. }
  8203. }
  8204. }
  8205. if ($falg) {
  8206. $html .= '<td class="taR">-</td>';
  8207. $falg = true;
  8208. }
  8209. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  8210. $htmlArray [$value ['title']] [$v ['username']] = $html;
  8211. }
  8212. }
  8213. /* -- --- */
  8214. // 合计费用
  8215. $cateHtml = "";
  8216. $catePrice = 0;
  8217. $cateFalg = true;
  8218. foreach ( $itemCategoryList as $l ) {
  8219. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  8220. if (empty ( $l ['price'] )) {
  8221. $cateHtml .= '<td class="colGreen taR">-</td>';
  8222. $cateFalg = false;
  8223. break;
  8224. } else {
  8225. $catePrice += $l ['price'];
  8226. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8227. $cateFalg = false;
  8228. break;
  8229. }
  8230. }
  8231. }
  8232. if ($cateFalg) {
  8233. $cateHtml .= '<td class="colGreen taR">-</td>';
  8234. $cateFalg = true;
  8235. }
  8236. $cateFalg = true;
  8237. foreach ( $itemCategoryList as $l ) {
  8238. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  8239. if (empty ( $l ['price'] )) {
  8240. $cateHtml .= '<td class="colGreen taR">-</td>';
  8241. $cateFalg = false;
  8242. break;
  8243. } else {
  8244. $catePrice += $l ['price'];
  8245. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8246. $cateFalg = false;
  8247. break;
  8248. }
  8249. }
  8250. }
  8251. if ($cateFalg) {
  8252. $cateHtml .= '<td class="colGreen taR">-</td>';
  8253. $cateFalg = true;
  8254. }
  8255. $cateFalg = true;
  8256. foreach ( $itemCategoryList as $l ) {
  8257. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  8258. if (empty ( $l ['price'] )) {
  8259. $cateHtml .= '<td class="colGreen taR">-</td>';
  8260. $cateFalg = false;
  8261. break;
  8262. } else {
  8263. $catePrice += $l ['price'];
  8264. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8265. $cateFalg = false;
  8266. break;
  8267. }
  8268. }
  8269. }
  8270. if ($cateFalg) {
  8271. $cateHtml .= '<td class="colGreen taR">-</td>';
  8272. $cateFalg = true;
  8273. }
  8274. $cateFalg = true;
  8275. foreach ( $itemCategoryList as $l ) {
  8276. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  8277. if (empty ( $l ['price'] )) {
  8278. $cateHtml .= '<td class="colGreen taR">-</td>';
  8279. $cateFalg = false;
  8280. break;
  8281. } else {
  8282. $catePrice += $l ['price'];
  8283. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8284. $cateFalg = false;
  8285. break;
  8286. }
  8287. }
  8288. }
  8289. if ($cateFalg) {
  8290. $cateHtml .= '<td class="colGreen taR">-</td>';
  8291. $cateFalg = true;
  8292. }
  8293. $cateFalg = true;
  8294. foreach ( $itemCategoryList as $l ) {
  8295. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  8296. if (empty ( $l ['price'] )) {
  8297. $cateHtml .= '<td class="colGreen taR">-</td>';
  8298. $cateFalg = false;
  8299. break;
  8300. } else {
  8301. $catePrice += $l ['price'];
  8302. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8303. $cateFalg = false;
  8304. break;
  8305. }
  8306. }
  8307. }
  8308. if ($cateFalg) {
  8309. $cateHtml .= '<td class="colGreen taR">-</td>';
  8310. $cateFalg = true;
  8311. }
  8312. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  8313. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  8314. /* -- --- */
  8315. }
  8316. // print_r($htmlArray);die;
  8317. $data ['htmlArray'] = $htmlArray;
  8318. // statistics html
  8319. $stList = $statistics->getOne ( array (
  8320. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8321. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8322. 'groupby' => 'Month(date)',
  8323. 'asArray' => true
  8324. ) );
  8325. if (empty ( $stList ))
  8326. $stList = array (
  8327. 'rePrice' => 0,
  8328. 'agPrice' => 0
  8329. );
  8330. $data ['stList'] = array (
  8331. 'rePrice' => $stList ['rePrice'],
  8332. 'agPrice' => $stList ['agPrice'],
  8333. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8334. );
  8335. $monthHtml = "";
  8336. for($i = 1; $i <= 12; $i ++) {
  8337. if ($i == $month)
  8338. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8339. else
  8340. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8341. }
  8342. $data ['monthHtml'] = $monthHtml;
  8343. $data ['year'] = $year;
  8344. $data ['month'] = $month;
  8345. $data ['memu'] = "receipt";
  8346. $data ['staff'] = $this->staff;
  8347. $data ['receiptMemu'] = 'companyCategoryCollect';
  8348. $data ['verifyId'] = $this->verifyId;
  8349. $data ['executeId'] = $this->executeId;
  8350. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  8351. Doo::loadModel ( 'receipt' );
  8352. $receipt = new receipt ();
  8353. $receiptList = $receipt->find ( array (
  8354. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  8355. 'asArray' => true
  8356. ) );
  8357. if (empty ( $receiptList )) { // generated files
  8358. ob_start ();
  8359. $this->render ( "/admin/saeaStaffCollect", $data );
  8360. $this->cacheFile ( $path );
  8361. die ();
  8362. }
  8363. }
  8364. $this->render ( "/admin/saeaStaffCollect", $data );
  8365. }
  8366. function lyt() {
  8367. Doo::loadModel ( "receiptDetail" );
  8368. $receiptDetail = new receiptDetail ();
  8369. $receiptCollectList = $receiptDetail->find ( array (
  8370. 'where' => 'status=1 ',
  8371. 'asArray' => true
  8372. ) );
  8373. foreach ( $receiptCollectList as $key => $value ) {
  8374. $receiptDetail = new receiptDetail ();
  8375. $receiptDetail->pastDate = $value ['date'];
  8376. $receiptDetail->update ( array (
  8377. 'where' => "rdid= '" . $value ['rdid'] . "'"
  8378. ) );
  8379. }
  8380. }
  8381. function staffCollectMonthDetail() {
  8382. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8383. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8384. if (! $year)
  8385. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8386. if (! $month)
  8387. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8388. Doo::loadModel ( 'staff' );
  8389. $staff = new staff ();
  8390. Doo::loadModel ( "receiptDetail" );
  8391. $receiptDetail = new receiptDetail ();
  8392. Doo::loadModel ( 'accountItem' );
  8393. $accountItem = new accountItem ();
  8394. Doo::loadModel ( 'statistics' );
  8395. $statistics = new statistics ();
  8396. Doo::loadModel ( 'L_category' );
  8397. $lCategory = new L_category ();
  8398. $staffList = $staff->find ( array (
  8399. 'where' => 'username!="admin"',
  8400. 'asArray' => true
  8401. ) );
  8402. $categoryList = $staff->find ( array (
  8403. 'select' => 'COUNT(*) as count,cid,category',
  8404. 'where' => 'username !="admin"',
  8405. 'groupby' => 'cid',
  8406. 'asArray' => true
  8407. ) );
  8408. $list = array ();
  8409. foreach ( $categoryList as $vlu ) {
  8410. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8411. $r1 = 0;
  8412. $r2 = 0;
  8413. $r3 = 0;
  8414. $r4 = 0;
  8415. $r5 = 0;
  8416. $r6 = 0;
  8417. $r7 = 0;
  8418. $r8 = 0;
  8419. $r9 = 0;
  8420. $r10 = 0;
  8421. $r11 = 0;
  8422. $r12 = 0;
  8423. $r13 = 0;
  8424. $r14 = 0;
  8425. $r15 = 0;
  8426. $c1 = 0;
  8427. $c2 = 0;
  8428. $c3 = 0;
  8429. $c4 = 0;
  8430. $c5 = 0;
  8431. $c6 = 0;
  8432. $p1 = 0;
  8433. $p2 = 0;
  8434. $p3 = 0;
  8435. $p4 = 0;
  8436. $p5 = 0;
  8437. $p6 = 0;
  8438. $p7 = 0;
  8439. $p8 = 0;
  8440. $p9 = 0;
  8441. $t1 = 0;
  8442. $t2 = 0;
  8443. $t3 = 0;
  8444. $t4 = 0;
  8445. $t5 = 0;
  8446. $s1 = 0;
  8447. $m1 = 0;
  8448. foreach ( $staffList as $value ) {
  8449. if ($vlu ['cid'] == $value ['cid']) {
  8450. // pastDate
  8451. $receiptCollectList = $receiptDetail->find ( array (
  8452. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8453. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8454. 'groupby' => 'item,Month(pastDate),itemCategory',
  8455. 'asArray' => true
  8456. ) );
  8457. // if ($value['sid']==42){
  8458. // print_r($receiptCollectList);die;
  8459. // }
  8460. if (! empty ( $receiptCollectList )) {
  8461. $receiptL = array (
  8462. '日常相关费用' => array (),
  8463. '差旅相关费用' => array (),
  8464. '培训班费用' => array (),
  8465. '其他' => array ()
  8466. );
  8467. $html = "";
  8468. $psum = 0;
  8469. $item = array (
  8470. '市内交通费',
  8471. '市内出租费',
  8472. '办事处房租',
  8473. '电话费',
  8474. '水费',
  8475. '电费',
  8476. '办公费用',
  8477. '邮寄费',
  8478. '其他费用',
  8479. '车辆费用',
  8480. '广告费',
  8481. '团队建设费',
  8482. '物业管理费',
  8483. '宽带费'
  8484. );
  8485. foreach ( $item as $va ) {
  8486. $falg = true;
  8487. foreach ( $receiptCollectList as $v ) {
  8488. if ($v ['itemCategory'] == '日常相关费用') {
  8489. if ($v ['item'] == $va) {
  8490. if ($va == '市内交通费')
  8491. $r1 += $v ['price'];
  8492. if ($va == '市内出租费')
  8493. $r2 += $v ['price'];
  8494. if ($va == '办事处房租')
  8495. $r3 += $v ['price'];
  8496. if ($va == '电话费')
  8497. $r4 += $v ['price'];
  8498. if ($va == '水费')
  8499. $r5 += $v ['price'];
  8500. if ($va == '电费')
  8501. $r6 += $v ['price'];
  8502. if ($va == '办公费用')
  8503. $r7 += $v ['price'];
  8504. if ($va == '邮寄费')
  8505. $r8 += $v ['price'];
  8506. if ($va == '其他费用')
  8507. $r9 += $v ['price'];
  8508. if ($va == '车辆费用')
  8509. $r10 += $v ['price'];
  8510. if ($va == '广告费')
  8511. $r11 += $v ['price'];
  8512. if ($va == '团队建设费')
  8513. $r13 += $v ['price'];
  8514. if ($va == '物业管理费')
  8515. $r14 += $v ['price'];
  8516. if ($va == '宽带费')
  8517. $r15 += $v ['price'];
  8518. $psum += $v ['price'];
  8519. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8520. $falg = false;
  8521. break;
  8522. }
  8523. }
  8524. }
  8525. if ($falg)
  8526. $html .= '<td class="taR">-</td>';
  8527. }
  8528. $r12 += $psum;
  8529. if (! empty ( $psum ))
  8530. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8531. else
  8532. $psum = '<td class="colGreen taR">-</td>';
  8533. $receiptL ['日常相关费用'] = $psum . $html;
  8534. /* ----------------------------------- */
  8535. $html = "";
  8536. $psum = 0;
  8537. $item = array (
  8538. '往来交通费',
  8539. '市内交通费',
  8540. '出差住宿费',
  8541. '出差补助',
  8542. '其他费用'
  8543. );
  8544. foreach ( $item as $va ) {
  8545. $falg = true;
  8546. foreach ( $receiptCollectList as $v ) {
  8547. if ($v ['itemCategory'] == '差旅相关费用') {
  8548. if ($v ['item'] == $va) {
  8549. if ($va == '往来交通费')
  8550. $c1 += $v ['price'];
  8551. if ($va == '市内交通费')
  8552. $c2 += $v ['price'];
  8553. if ($va == '出差住宿费')
  8554. $c3 += $v ['price'];
  8555. if ($va == '出差补助')
  8556. $c4 += $v ['price'];
  8557. if ($va == '其他费用')
  8558. $c5 += $v ['price'];
  8559. $psum += $v ['price'];
  8560. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8561. $falg = false;
  8562. break;
  8563. }
  8564. }
  8565. }
  8566. if ($falg)
  8567. $html .= '<td class="taR">-</td>';
  8568. }
  8569. $c6 += $psum;
  8570. if (! empty ( $psum ))
  8571. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8572. else
  8573. $psum = '<td class="colGreen taR">-</td>';
  8574. $receiptL ['差旅相关费用'] = $psum . $html;
  8575. /* ------------------------------------- */
  8576. $html = "";
  8577. $psum = 0;
  8578. $item = array (
  8579. '场租费',
  8580. '薪酬',
  8581. '住宿费',
  8582. '交通费',
  8583. '餐饮费',
  8584. '办公费',
  8585. '公关费',
  8586. '其他'
  8587. );
  8588. foreach ( $item as $va ) {
  8589. $falg = true;
  8590. foreach ( $receiptCollectList as $v ) {
  8591. if ($v ['itemCategory'] == '培训班费用') {
  8592. if ($v ['item'] == $va) {
  8593. if ($va == '场租费')
  8594. $p1 += $v ['price'];
  8595. if ($va == '薪酬')
  8596. $p2 += $v ['price'];
  8597. if ($va == '住宿费')
  8598. $p3 += $v ['price'];
  8599. if ($va == '交通费')
  8600. $p4 += $v ['price'];
  8601. if ($va == '餐饮费')
  8602. $p5 += $v ['price'];
  8603. if ($va == '办公费')
  8604. $p6 += $v ['price'];
  8605. if ($va == '公关费')
  8606. $p7 += $v ['price'];
  8607. if ($va == '其他')
  8608. $p8 += $v ['price'];
  8609. $psum += $v ['price'];
  8610. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8611. $falg = false;
  8612. break;
  8613. }
  8614. }
  8615. }
  8616. if ($falg)
  8617. $html .= '<td class="taR">-</td>';
  8618. }
  8619. $p9 += $psum;
  8620. if (! empty ( $psum ))
  8621. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8622. else
  8623. $psum = '<td class="colGreen taR">-</td>';
  8624. $receiptL ['培训班费用'] = $psum . $html;
  8625. /* ------------------------------------- */
  8626. $html = "";
  8627. $psum = 0;
  8628. $item = array (
  8629. '公关费',
  8630. '广告费',
  8631. '借款',
  8632. '可自加费用'
  8633. );
  8634. foreach ( $item as $va ) {
  8635. $falg = true;
  8636. foreach ( $receiptCollectList as $v ) {
  8637. if ($v ['itemCategory'] == '其他') {
  8638. // if ($value['sid']==42){
  8639. //
  8640. // echo var_dump($v['item']);
  8641. // echo var_dump($va);
  8642. // echo var_dump($v['item']==" ".$va);
  8643. // echo $v['item']."==".$va."/<br/>";
  8644. // //print_r( $receiptCollectList);//echo $va;
  8645. // }
  8646. if (trim ( $v ['item'] ) == $va) {
  8647. if ($va == '公关费')
  8648. $t1 += $v ['price'];
  8649. if ($va == '广告费') {
  8650. $t2 += $v ['price'];
  8651. }
  8652. if ($va == '借款')
  8653. $t3 += $v ['price'];
  8654. if ($va == '可自加费用')
  8655. $t4 += $v ['price'];
  8656. $psum += $v ['price'];
  8657. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8658. $falg = false;
  8659. break;
  8660. }
  8661. }
  8662. }
  8663. if ($falg)
  8664. $html .= '<td class="taR">-</td>';
  8665. }
  8666. $t5 += $psum;
  8667. if (! empty ( $psum ))
  8668. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8669. else
  8670. $psum = '<td class="colGreen taR">-</td>';
  8671. $receiptL ['其他'] = $psum . $html;
  8672. /* ------------------------------------- */
  8673. $html = "";
  8674. $psum = 0;
  8675. foreach ( $receiptCollectList as $v ) {
  8676. if ($v ['itemCategory'] == '报销金额调整') {
  8677. if (! empty ( $v ['price'] )) {
  8678. $psum += $v ['price'];
  8679. }
  8680. }
  8681. }
  8682. $s1 += $psum;
  8683. if (! empty ( $psum ))
  8684. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8685. else
  8686. $psum = '<td class="taR colOrange">-</td>';
  8687. $receiptL ['报销金额调整'] = $psum . $html;
  8688. } else {
  8689. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8690. <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>
  8691. <td class="taR">-</td><td class="taR">-</td>';
  8692. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  8693. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8694. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8695. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8696. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8697. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  8698. }
  8699. $monthStaffPrice = $receiptDetail->find ( array (
  8700. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8701. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8702. 'groupby' => 'Month(pastDate)',
  8703. 'asArray' => true
  8704. ) );
  8705. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  8706. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  8707. $m1 += $monthStaffPrice [0] ['price'];
  8708. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  8709. } else
  8710. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  8711. $list [$value ['username']] = $receiptL;
  8712. }
  8713. }
  8714. $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>
  8715. <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>
  8716. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  8717. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  8718. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  8719. $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>
  8720. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  8721. $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>';
  8722. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  8723. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  8724. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  8725. }
  8726. $data ['list'] = $list;
  8727. $receiptCollectList = $receiptDetail->find ( array (
  8728. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8729. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8730. 'groupby' => 'item,Month(pastDate),itemCategory',
  8731. 'asArray' => true
  8732. ) );
  8733. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  8734. // statistics html
  8735. $stList = $statistics->getOne ( array (
  8736. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8737. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8738. 'groupby' => 'Month(date)',
  8739. 'asArray' => true
  8740. ) );
  8741. if (empty ( $stList ))
  8742. $stList = array (
  8743. 'rePrice' => 0,
  8744. 'agPrice' => 0
  8745. );
  8746. $data ['stList'] = array (
  8747. 'rePrice' => $stList ['rePrice'],
  8748. 'agPrice' => $stList ['agPrice'],
  8749. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8750. );
  8751. $monthHtml = "";
  8752. for($i = 1; $i <= 12; $i ++) {
  8753. if ($i == $month)
  8754. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8755. else
  8756. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8757. }
  8758. $data ['monthHtml'] = $monthHtml;
  8759. $data ['year'] = $year;
  8760. $data ['month'] = $month;
  8761. $data ['memu'] = "receipt";
  8762. $data ['staff'] = $this->staff;
  8763. $data ['receiptMemu'] = 'companyCategoryCollect';
  8764. $data ['verifyId'] = $this->verifyId;
  8765. $data ['executeId'] = $this->executeId;
  8766. $this->render ( "/admin/staffCollectMonthDetail", $data );
  8767. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  8768. }
  8769. function staffCollectMonthDetail2() {
  8770. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8771. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8772. if (! $year)
  8773. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8774. if (! $month)
  8775. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8776. Doo::loadModel ( 'staff' );
  8777. $staff = new staff ();
  8778. Doo::loadModel ( "receiptDetail" );
  8779. $receiptDetail = new receiptDetail ();
  8780. Doo::loadModel ( 'accountItem' );
  8781. $accountItem = new accountItem ();
  8782. Doo::loadModel ( 'statistics' );
  8783. $statistics = new statistics ();
  8784. Doo::loadModel ( 'L_category' );
  8785. $lCategory = new L_category ();
  8786. $staffList = $staff->find ( array (
  8787. 'where' => 'username!="admin"',
  8788. 'asArray' => true
  8789. ) );
  8790. $categoryList = $staff->find ( array (
  8791. 'select' => 'COUNT(*) as count,cid,category',
  8792. 'where' => 'username !="admin"',
  8793. 'groupby' => 'cid',
  8794. 'asArray' => true
  8795. ) );
  8796. $list = array ();
  8797. foreach ( $categoryList as $vlu ) {
  8798. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8799. $r1 = 0;
  8800. $r2 = 0;
  8801. $r3 = 0;
  8802. $r4 = 0;
  8803. $r5 = 0;
  8804. $r6 = 0;
  8805. $r7 = 0;
  8806. $r8 = 0;
  8807. $r9 = 0;
  8808. $r10 = 0;
  8809. $r11 = 0;
  8810. $r12 = 0;
  8811. $r13 = 0;
  8812. $r14 = 0;
  8813. $r15 = 0;
  8814. $c1 = 0;
  8815. $c2 = 0;
  8816. $c3 = 0;
  8817. $c4 = 0;
  8818. $c5 = 0;
  8819. $c6 = 0;
  8820. $p1 = 0;
  8821. $p2 = 0;
  8822. $p3 = 0;
  8823. $p4 = 0;
  8824. $p5 = 0;
  8825. $p6 = 0;
  8826. $p7 = 0;
  8827. $p8 = 0;
  8828. $p9 = 0;
  8829. $t1 = 0;
  8830. $t2 = 0;
  8831. $t3 = 0;
  8832. $t4 = 0;
  8833. $t5 = 0;
  8834. $s1 = 0;
  8835. $m1 = 0;
  8836. foreach ( $staffList as $value ) {
  8837. if ($vlu ['cid'] == $value ['cid']) {
  8838. $receiptCollectList = $receiptDetail->find ( array (
  8839. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  8840. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  8841. 'groupby' => 'item,Month(date),itemCategory',
  8842. 'asArray' => true
  8843. ) );
  8844. if (! empty ( $receiptCollectList )) {
  8845. $receiptL = array (
  8846. '日常相关费用' => array (),
  8847. '差旅相关费用' => array (),
  8848. '培训班费用' => array (),
  8849. '其他' => array ()
  8850. );
  8851. $html = "";
  8852. $psum = 0;
  8853. $item = array (
  8854. '市内交通费',
  8855. '市内出租费',
  8856. '办事处房租',
  8857. '电话费',
  8858. '水费',
  8859. '电费',
  8860. '办公费用',
  8861. '邮寄费',
  8862. '其他费用',
  8863. '车辆费用',
  8864. '广告费',
  8865. '团队建设费',
  8866. '物业管理费',
  8867. '宽带费'
  8868. );
  8869. foreach ( $item as $va ) {
  8870. $falg = true;
  8871. foreach ( $receiptCollectList as $v ) {
  8872. if ($v ['itemCategory'] == '日常相关费用') {
  8873. if ($v ['item'] == $va) {
  8874. if ($va == '市内交通费')
  8875. $r1 += $v ['price'];
  8876. if ($va == '市内出租费')
  8877. $r2 += $v ['price'];
  8878. if ($va == '办事处房租')
  8879. $r3 += $v ['price'];
  8880. if ($va == '电话费')
  8881. $r4 += $v ['price'];
  8882. if ($va == '水费')
  8883. $r5 += $v ['price'];
  8884. if ($va == '电费')
  8885. $r6 += $v ['price'];
  8886. if ($va == '办公费用')
  8887. $r7 += $v ['price'];
  8888. if ($va == '邮寄费')
  8889. $r8 += $v ['price'];
  8890. if ($va == '其他费用')
  8891. $r9 += $v ['price'];
  8892. if ($va == '车辆费用')
  8893. $r10 += $v ['price'];
  8894. if ($va == '广告费')
  8895. $r11 += $v ['price'];
  8896. if ($va == '团队建设费')
  8897. $r13 += $v ['price'];
  8898. if ($va == '物业管理费')
  8899. $r14 += $v ['price'];
  8900. if ($va == '宽带费')
  8901. $r15 += $v ['price'];
  8902. $psum += $v ['price'];
  8903. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8904. $falg = false;
  8905. break;
  8906. }
  8907. }
  8908. }
  8909. if ($falg)
  8910. $html .= '<td class="taR">-</td>';
  8911. }
  8912. $r12 += $psum;
  8913. if (! empty ( $psum ))
  8914. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8915. else
  8916. $psum = '<td class="colGreen taR">-</td>';
  8917. $receiptL ['日常相关费用'] = $psum . $html;
  8918. /* ----------------------------------- */
  8919. $html = "";
  8920. $psum = 0;
  8921. $item = array (
  8922. '往来交通费',
  8923. '市内交通费',
  8924. '出差住宿费',
  8925. '出差补助',
  8926. '其他费用'
  8927. );
  8928. foreach ( $item as $va ) {
  8929. $falg = true;
  8930. foreach ( $receiptCollectList as $v ) {
  8931. if ($v ['itemCategory'] == '差旅相关费用') {
  8932. if ($v ['item'] == $va) {
  8933. if ($va == '往来交通费')
  8934. $c1 += $v ['price'];
  8935. if ($va == '市内交通费')
  8936. $c2 += $v ['price'];
  8937. if ($va == '出差住宿费')
  8938. $c3 += $v ['price'];
  8939. if ($va == '出差补助')
  8940. $c4 += $v ['price'];
  8941. if ($va == '其他费用')
  8942. $c5 += $v ['price'];
  8943. $psum += $v ['price'];
  8944. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8945. $falg = false;
  8946. break;
  8947. }
  8948. }
  8949. }
  8950. if ($falg)
  8951. $html .= '<td class="taR">-</td>';
  8952. }
  8953. $c6 += $psum;
  8954. if (! empty ( $psum ))
  8955. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8956. else
  8957. $psum = '<td class="colGreen taR">-</td>';
  8958. $receiptL ['差旅相关费用'] = $psum . $html;
  8959. /* ------------------------------------- */
  8960. $html = "";
  8961. $psum = 0;
  8962. $item = array (
  8963. '场租费',
  8964. '薪酬',
  8965. '住宿费',
  8966. '交通费',
  8967. '餐饮费',
  8968. '办公费',
  8969. '公关费',
  8970. '其他'
  8971. );
  8972. foreach ( $item as $va ) {
  8973. $falg = true;
  8974. foreach ( $receiptCollectList as $v ) {
  8975. if ($v ['itemCategory'] == '培训班费用') {
  8976. if ($v ['item'] == $va) {
  8977. if ($va == '场租费')
  8978. $p1 += $v ['price'];
  8979. if ($va == '薪酬')
  8980. $p2 += $v ['price'];
  8981. if ($va == '住宿费')
  8982. $p3 += $v ['price'];
  8983. if ($va == '交通费')
  8984. $p4 += $v ['price'];
  8985. if ($va == '餐饮费')
  8986. $p5 += $v ['price'];
  8987. if ($va == '办公费')
  8988. $p6 += $v ['price'];
  8989. if ($va == '公关费')
  8990. $p7 += $v ['price'];
  8991. if ($va == '其他')
  8992. $p8 += $v ['price'];
  8993. $psum += $v ['price'];
  8994. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8995. $falg = false;
  8996. break;
  8997. }
  8998. }
  8999. }
  9000. if ($falg)
  9001. $html .= '<td class="taR">-</td>';
  9002. }
  9003. $p9 += $psum;
  9004. if (! empty ( $psum ))
  9005. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9006. else
  9007. $psum = '<td class="colGreen taR">-</td>';
  9008. $receiptL ['培训班费用'] = $psum . $html;
  9009. /* ------------------------------------- */
  9010. $html = "";
  9011. $psum = 0;
  9012. $item = array (
  9013. '公关费',
  9014. '广告费',
  9015. '借款',
  9016. '可自加费用'
  9017. );
  9018. foreach ( $item as $va ) {
  9019. $falg = true;
  9020. foreach ( $receiptCollectList as $v ) {
  9021. if ($v ['itemCategory'] == '其他') {
  9022. if ($v ['item'] == $va) {
  9023. if ($va == '公关费')
  9024. $t1 += $v ['price'];
  9025. if ($va == '广告费')
  9026. $t2 += $v ['price'];
  9027. if ($va == '借款')
  9028. $t3 += $v ['price'];
  9029. if ($va == '可自加费用')
  9030. $t4 += $v ['price'];
  9031. $psum += $v ['price'];
  9032. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9033. $falg = false;
  9034. break;
  9035. }
  9036. }
  9037. }
  9038. if ($falg)
  9039. $html .= '<td class="taR">-</td>';
  9040. }
  9041. $t5 += $psum;
  9042. if (! empty ( $psum ))
  9043. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9044. else
  9045. $psum = '<td class="colGreen taR">-</td>';
  9046. $receiptL ['其他'] = $psum . $html;
  9047. /* ------------------------------------- */
  9048. $html = "";
  9049. $psum = 0;
  9050. foreach ( $receiptCollectList as $v ) {
  9051. if ($v ['itemCategory'] == '报销金额调整') {
  9052. if (! empty ( $v ['price'] )) {
  9053. $psum += $v ['price'];
  9054. }
  9055. }
  9056. }
  9057. $s1 += $psum;
  9058. if (! empty ( $psum ))
  9059. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9060. else
  9061. $psum = '<td class="taR colOrange">-</td>';
  9062. $receiptL ['报销金额调整'] = $psum . $html;
  9063. } else {
  9064. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9065. <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>';
  9066. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9067. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9068. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9069. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9070. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9071. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9072. }
  9073. $monthStaffPrice = $receiptDetail->find ( array (
  9074. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9075. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9076. 'asArray' => true
  9077. ) );
  9078. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  9079. $m1 += $monthStaffPrice [0] ['price'];
  9080. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9081. } else
  9082. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9083. $list [$value ['username']] = $receiptL;
  9084. }
  9085. }
  9086. $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>
  9087. <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>
  9088. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  9089. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  9090. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  9091. $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>
  9092. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  9093. $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>';
  9094. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  9095. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  9096. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  9097. }
  9098. $data ['list'] = $list;
  9099. $receiptCollectList = $receiptDetail->find ( array (
  9100. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9101. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9102. 'groupby' => 'item,Month(date),itemCategory',
  9103. 'asArray' => true
  9104. ) );
  9105. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9106. // statistics html
  9107. $stList = $statistics->getOne ( array (
  9108. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9109. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9110. 'groupby' => 'Month(date)',
  9111. 'asArray' => true
  9112. ) );
  9113. if (empty ( $stList ))
  9114. $stList = array (
  9115. 'rePrice' => 0,
  9116. 'agPrice' => 0
  9117. );
  9118. $data ['stList'] = array (
  9119. 'rePrice' => $stList ['rePrice'],
  9120. 'agPrice' => $stList ['agPrice'],
  9121. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9122. );
  9123. $monthHtml = "";
  9124. for($i = 1; $i <= 12; $i ++) {
  9125. if ($i == $month)
  9126. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9127. else
  9128. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9129. }
  9130. $data ['monthHtml'] = $monthHtml;
  9131. $data ['year'] = $year;
  9132. $data ['month'] = $month;
  9133. $data ['memu'] = "receipt";
  9134. $data ['staff'] = $this->staff;
  9135. $data ['receiptMemu'] = 'companyCategoryCollect';
  9136. $data ['verifyId'] = $this->verifyId;
  9137. $data ['executeId'] = $this->executeId;
  9138. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  9139. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9140. }
  9141. function companyMonthCollectDetail() {
  9142. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9143. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9144. if (! $year)
  9145. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9146. if (! $month)
  9147. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9148. Doo::loadModel ( 'staff' );
  9149. $staff = new staff ();
  9150. Doo::loadModel ( "receiptDetail" );
  9151. $receiptDetail = new receiptDetail ();
  9152. Doo::loadModel ( 'accountItem' );
  9153. $accountItem = new accountItem ();
  9154. Doo::loadModel ( 'statistics' );
  9155. $statistics = new statistics ();
  9156. Doo::loadModel ( 'L_category' );
  9157. $lCategory = new L_category ();
  9158. $staffList = $staff->find ( array (
  9159. 'where' => 'username!="admin"',
  9160. 'asArray' => true
  9161. ) );
  9162. $categoryList = $lCategory->find ( array (
  9163. 'asArray' => true
  9164. ) );
  9165. $list = array ();
  9166. foreach ( $categoryList as $value ) {
  9167. $receiptCollectList = $receiptDetail->find ( array (
  9168. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9169. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9170. 'groupby' => 'item,Month(pastDate),itemCategory',
  9171. 'asArray' => true
  9172. ) );
  9173. if (! empty ( $receiptCollectList )) {
  9174. $receiptL = array (
  9175. '日常相关费用' => array (),
  9176. '差旅相关费用' => array (),
  9177. '培训班费用' => array (),
  9178. '其他' => array ()
  9179. );
  9180. $html = "";
  9181. $psum = 0;
  9182. $item = array (
  9183. '市内交通费',
  9184. '市内出租费',
  9185. '办事处房租',
  9186. '电话费',
  9187. '水费',
  9188. '电费',
  9189. '办公费用',
  9190. '邮寄费',
  9191. '其他费用',
  9192. '车辆费用',
  9193. '广告费',
  9194. '团队建设费'
  9195. );
  9196. foreach ( $item as $va ) {
  9197. $falg = true;
  9198. foreach ( $receiptCollectList as $v ) {
  9199. if ($v ['itemCategory'] == '日常相关费用') {
  9200. if ($v ['item'] == $va) {
  9201. $psum += $v ['price'];
  9202. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9203. $falg = false;
  9204. break;
  9205. }
  9206. }
  9207. }
  9208. if ($falg)
  9209. $html .= '<td class="taR">-</td>';
  9210. }
  9211. if (! empty ( $psum ))
  9212. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9213. else
  9214. $psum = '<td class="colGreen taR">-</td>';
  9215. $receiptL ['日常相关费用'] = $psum . $html;
  9216. /* ----------------------------------- */
  9217. $html = "";
  9218. $psum = 0;
  9219. $item = array (
  9220. '往来交通费',
  9221. '市内交通费',
  9222. '出差住宿费',
  9223. '出差补助',
  9224. '其他费用'
  9225. );
  9226. foreach ( $item as $va ) {
  9227. $falg = true;
  9228. foreach ( $receiptCollectList as $v ) {
  9229. if ($v ['itemCategory'] == '差旅相关费用') {
  9230. if ($v ['item'] == $va) {
  9231. $psum += $v ['price'];
  9232. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9233. $falg = false;
  9234. break;
  9235. }
  9236. }
  9237. }
  9238. if ($falg)
  9239. $html .= '<td class="taR">-</td>';
  9240. }
  9241. if (! empty ( $psum ))
  9242. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9243. else
  9244. $psum = '<td class="colGreen taR">-</td>';
  9245. $receiptL ['差旅相关费用'] = $psum . $html;
  9246. /* ------------------------------------- */
  9247. $html = "";
  9248. $psum = 0;
  9249. $item = array (
  9250. '场租费',
  9251. '薪酬',
  9252. '住宿费',
  9253. '交通费',
  9254. '餐饮费',
  9255. '办公费',
  9256. '公关费',
  9257. '其他'
  9258. );
  9259. foreach ( $item as $va ) {
  9260. $falg = true;
  9261. foreach ( $receiptCollectList as $v ) {
  9262. if ($v ['itemCategory'] == '培训班费用') {
  9263. if ($v ['item'] == $va) {
  9264. $psum += $v ['price'];
  9265. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9266. $falg = false;
  9267. break;
  9268. }
  9269. }
  9270. }
  9271. if ($falg)
  9272. $html .= '<td class="taR">-</td>';
  9273. }
  9274. if (! empty ( $psum ))
  9275. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9276. else
  9277. $psum = '<td class="colGreen taR">-</td>';
  9278. $receiptL ['培训班费用'] = $psum . $html;
  9279. /* ------------------------------------- */
  9280. $html = "";
  9281. $psum = 0;
  9282. $item = array (
  9283. '公关费',
  9284. '广告费',
  9285. '借款',
  9286. '可自加费用'
  9287. );
  9288. foreach ( $item as $va ) {
  9289. $falg = true;
  9290. foreach ( $receiptCollectList as $v ) {
  9291. if ($v ['itemCategory'] == '其他') {
  9292. if ($v ['item'] == $va) {
  9293. $psum += $v ['price'];
  9294. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9295. $falg = false;
  9296. break;
  9297. }
  9298. }
  9299. }
  9300. if ($falg)
  9301. $html .= '<td class="taR">-</td>';
  9302. }
  9303. if (! empty ( $psum ))
  9304. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9305. else
  9306. $psum = '<td class="colGreen taR">-</td>';
  9307. $receiptL ['其他'] = $psum . $html;
  9308. /* ------------------------------------- */
  9309. $html = "";
  9310. $psum = 0;
  9311. foreach ( $receiptCollectList as $v ) {
  9312. if ($v ['itemCategory'] == '报销金额调整') {
  9313. if (! empty ( $v ['price'] ))
  9314. $psum += $v ['price'];
  9315. }
  9316. }
  9317. if (! empty ( $psum ))
  9318. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9319. else
  9320. $psum = '<td class="taR colOrange">-</td>';
  9321. $receiptL ['报销金额调整'] = $psum . $html;
  9322. } else {
  9323. $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>
  9324. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9325. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9326. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9327. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9328. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9329. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9330. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9331. }
  9332. $monthStaffPrice = $receiptDetail->find ( array (
  9333. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9334. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9335. 'asArray' => true
  9336. ) );
  9337. if (! empty ( $monthStaffPrice [0] ['price'] ))
  9338. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9339. else
  9340. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9341. $list [$value ['title']] = $receiptL;
  9342. }
  9343. $data ['list'] = $list;
  9344. $receiptCollectList = $receiptDetail->find ( array (
  9345. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9346. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9347. 'groupby' => 'item,Month(pastDate),itemCategory',
  9348. 'asArray' => true
  9349. ) );
  9350. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9351. // print_r($data['monthPriceHtml']);
  9352. // foreach ($data['monthPriceHtml'] as $value){
  9353. // echo $value;
  9354. // }
  9355. // die;
  9356. // statistics html
  9357. $stList = $statistics->getOne ( array (
  9358. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9359. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9360. 'groupby' => 'Month(date)',
  9361. 'asArray' => true
  9362. ) );
  9363. if (empty ( $stList ))
  9364. $stList = array (
  9365. 'rePrice' => 0,
  9366. 'agPrice' => 0
  9367. );
  9368. $data ['stList'] = array (
  9369. 'rePrice' => $stList ['rePrice'],
  9370. 'agPrice' => $stList ['agPrice'],
  9371. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9372. );
  9373. $monthHtml = "";
  9374. for($i = 1; $i <= 12; $i ++) {
  9375. if ($i == $month)
  9376. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9377. else
  9378. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9379. }
  9380. $data ['monthHtml'] = $monthHtml;
  9381. $data ['year'] = $year;
  9382. $data ['month'] = $month;
  9383. $data ['memu'] = "receipt";
  9384. $data ['staff'] = $this->staff;
  9385. $data ['receiptMemu'] = 'companyCategoryCollect';
  9386. $data ['verifyId'] = $this->verifyId;
  9387. $data ['executeId'] = $this->executeId;
  9388. $this->render ( "/admin/companyMonthCollectDetail", $data );
  9389. }
  9390. function staffCollectDetail() {
  9391. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9392. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  9393. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  9394. if (! $staffname) {
  9395. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  9396. $staffname = urldecode ( $staffname );
  9397. }
  9398. Doo::loadModel ( 'staff' );
  9399. $staff = new staff ();
  9400. Doo::loadModel ( "receiptDetail" );
  9401. $receiptDetail = new receiptDetail ();
  9402. Doo::loadModel ( 'accountItem' );
  9403. $accountItem = new accountItem ();
  9404. Doo::loadModel ( 'statistics' );
  9405. $statistics = new statistics ();
  9406. Doo::loadModel ( 'L_category' );
  9407. $lCategory = new L_category ();
  9408. $staffList = $staff->find ( array (
  9409. 'asArray' => true
  9410. ) );
  9411. $stHtml = '';
  9412. $stTitle = "";
  9413. $staffId = 0;
  9414. $cid = 0;
  9415. $ocid = 0;
  9416. foreach ( $staffList as $value ) {
  9417. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  9418. $stTitle = $value ['category'] . '-' . $value ['username'];
  9419. $staffId = $value ['sid'];
  9420. $cid = $value ['cid'];
  9421. $ocid = $value ['cid'];
  9422. if (! empty ( $value ['othercid'] ))
  9423. $cid = $value ['cid'] . ',' . $value ['othercid'];
  9424. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9425. } elseif ($value ['username'] != 'admin')
  9426. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9427. }
  9428. $data ['lCategoryHtml'] = $lCategory->find ( array (
  9429. 'where' => 'cid in(' . $cid . ')',
  9430. 'asArray' => true
  9431. ) );
  9432. if (empty ( $pcid ))
  9433. $pcid = $ocid;
  9434. $data ['ocid'] = $pcid;
  9435. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  9436. $this->showCache ( $path );
  9437. //
  9438. $receiptCollectList = $receiptDetail->find ( array (
  9439. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9440. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9441. 'groupby' => 'item,Month(pastDate),itemCategory',
  9442. 'asArray' => true
  9443. ) );
  9444. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  9445. // print_r($receiptCollectList);
  9446. $accountList = $accountItem->find ( array (
  9447. 'asArray' => true
  9448. ) );
  9449. // create CollectDetail HTML
  9450. $collectHtml = array ();
  9451. foreach ( $accountList as $key => $value ) {
  9452. $html = "";
  9453. $asum = 0;
  9454. for($i = 1; $i <= 12; $i ++) {
  9455. $falg = true;
  9456. foreach ( $receiptCollectList as $v ) {
  9457. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9458. if ($v ['item'] == '可自加费用') {
  9459. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  9460. }
  9461. $asum += $v ['price'];
  9462. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9463. $falg = false;
  9464. break;
  9465. }
  9466. }
  9467. if ($falg)
  9468. $html .= '<td class="taR">-</td>';
  9469. }
  9470. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9471. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9472. }
  9473. $data ['collectHtml'] = $collectHtml;
  9474. // print_r($collectHtml);
  9475. // create Adjustment price html
  9476. $receiptCollectList = $receiptDetail->find ( array (
  9477. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9478. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9479. 'groupby' => 'itemCategory,Month(pastDate)',
  9480. 'asArray' => true
  9481. ) );
  9482. $adjustment = array ();
  9483. $collectArray = array (
  9484. '日常相关费用' => array (),
  9485. '差旅相关费用' => array (),
  9486. '培训班费用' => array (),
  9487. '其他' => array ()
  9488. );
  9489. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9490. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9491. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9492. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9493. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9494. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9495. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9496. array_push ( $collectArray ['其他'], $collectHtml );
  9497. $data ['collectArray'] = $collectArray;
  9498. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9499. array_push ( $adjustment, $collectHtml );
  9500. $data ['adjustment'] = $adjustment;
  9501. // total price html
  9502. $collectHtml = "";
  9503. $total = 0;
  9504. for($i = 1; $i <= 12; $i ++) {
  9505. $sumPrice = 0;
  9506. foreach ( $receiptCollectList as $key => $value ) {
  9507. if ($value ['month'] == $i) {
  9508. $sumPrice += $value ['price'];
  9509. }
  9510. }
  9511. if ($sumPrice == 0)
  9512. $collectHtml .= '<td class="taR">-</td>';
  9513. else
  9514. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9515. $total += $sumPrice;
  9516. }
  9517. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9518. // statistics html
  9519. $stList = $statistics->statisticsByYear ( $year, $staffId );
  9520. if (empty ( $stList ))
  9521. $stList = array (
  9522. 'rePrice' => 0,
  9523. 'agPrice' => 0
  9524. );
  9525. $data ['stList'] = array (
  9526. 'rePrice' => $stList ['rePrice'],
  9527. 'agPrice' => $stList ['agPrice'],
  9528. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9529. );
  9530. $data ['totalPrice'] = $collectHtml;
  9531. $data ['totalYear'] = $total;
  9532. $data ['stHtml'] = $stHtml;
  9533. $data ['year'] = $year;
  9534. $data ['stTitle'] = $stTitle;
  9535. $data ['memu'] = "receipt";
  9536. $data ['staff'] = $this->staff;
  9537. $data ['receiptMemu'] = 'companyCategoryCollect';
  9538. $data ['verifyId'] = $this->verifyId;
  9539. $data ['executeId'] = $this->executeId;
  9540. if ($year < date ( "Y" )) {
  9541. Doo::loadModel ( 'receipt' );
  9542. $receipt = new receipt ();
  9543. $receiptList = $receipt->find ( array (
  9544. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  9545. 'asArray' => true
  9546. ) );
  9547. if (empty ( $receiptList )) { // generated files
  9548. ob_start ();
  9549. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9550. $this->cacheFile ( $path );
  9551. die ();
  9552. }
  9553. }
  9554. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9555. }
  9556. function BUGFLAG() {
  9557. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  9558. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  9559. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9560. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9561. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  9562. if (empty ( $status ))
  9563. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  9564. $page_size = 12;
  9565. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  9566. $vidList = array ();
  9567. $button = 0;
  9568. Doo::loadModel ( 'verify' );
  9569. $verify = new verify ();
  9570. Doo::loadModel ( 'receipt' );
  9571. $receipt = new receipt ();
  9572. Doo::loadModel ( 'staff' );
  9573. $staff = new staff ();
  9574. Doo::loadModel ( 'L_category' );
  9575. $Lcategory = new L_category ();
  9576. $dateCondition = " and Year(date) =" . $year;
  9577. if (! empty ( $month ))
  9578. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  9579. $categoryList = $Lcategory->find ( array (
  9580. 'asArray' => true
  9581. ) );
  9582. $staffList = $staff->find ( array (
  9583. 'where' => 'cid=' . $cid,
  9584. 'asArray' => true
  9585. ) );
  9586. $cateCondition = "";
  9587. $staffCondition = "";
  9588. $approvalCondition = "";
  9589. if (! empty ( $cid ))
  9590. $cateCondition = ' and cid=' . $cid;
  9591. if (! empty ( $sid )) {
  9592. $staffCondition = ' and staff=' . $sid;
  9593. $cateCondition = "";
  9594. }
  9595. $approvalCondition = " and status=" . $status;
  9596. if ($status == 2) {
  9597. // 查找角色审批人
  9598. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9599. }
  9600. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  9601. $approvalCondition = ' and status=2 ';
  9602. }
  9603. if ($status == 1) {
  9604. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  9605. }
  9606. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  9607. $pageinfo ['page'] = array (
  9608. 'previous' => ''
  9609. );
  9610. if ($status == 0) {
  9611. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  9612. $receiptList = $receipt->find ( array (
  9613. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  9614. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  9615. 'desc' => 'rid',
  9616. 'asArray' => true
  9617. ) );
  9618. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9619. } else
  9620. $receiptList = $receipt->find ( array (
  9621. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  9622. 'desc' => 'rid',
  9623. 'asArray' => true
  9624. ) );
  9625. $rLRes = $receipt->find ( array (
  9626. '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,
  9627. 'desc' => 'rid',
  9628. 'asArray' => true
  9629. ) );
  9630. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9631. // print_r($pageinfo);
  9632. $Locate = 0;
  9633. foreach ( $receiptList as $key => $value ) {
  9634. $receiptList [$key] ['Locate'] = $Locate;
  9635. $Locate ++;
  9636. $receiptList [$key] ['reviseDetail'] = array ();
  9637. if (! empty ( $value ['reviseDetail'] ))
  9638. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  9639. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  9640. $categoryDetil = $Lcategory->getOne ( array (
  9641. 'where' => 'cid=' . $value ['cid'],
  9642. 'asArray' => true
  9643. ) );
  9644. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  9645. $verifyList = $verify->getOne ( array (
  9646. 'where' => 'vid=' . $value ['verify'],
  9647. 'asArray' => true
  9648. ) );
  9649. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  9650. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  9651. foreach ( $verifyList as $k => $v ) {
  9652. // init verifyStaff
  9653. $verifyList [$k] ['date'] = "";
  9654. $verifyList [$k] ['opinion'] = "";
  9655. $verifyList [$k] ['status'] = "";
  9656. if (empty ( $verifyStaff )) {
  9657. $verifyList [$k] ['date'] = "";
  9658. $verifyList [$k] ['opinion'] = "";
  9659. if ($v [0] == $this->staff [0] ['sid']) {
  9660. $verifyList [$k] ['status'] = 4;
  9661. $button = 4;
  9662. }
  9663. } else {
  9664. $flag = true;
  9665. foreach ( $verifyStaff as $m => $u ) {
  9666. if ($v [0] == $m) {
  9667. $verifyList [$k] ['date'] = $u ['date'];
  9668. $verifyList [$k] ['opinion'] = $u ['opinion'];
  9669. $verifyList [$k] ['status'] = $u ['status'];
  9670. $flag = false;
  9671. break;
  9672. }
  9673. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  9674. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  9675. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  9676. }
  9677. if ($flag) { // 检测可编辑
  9678. if ($v [0] == $this->staff [0] ['sid']) {
  9679. $verifyList [$k] ['status'] = 4;
  9680. $button = 4;
  9681. }
  9682. }
  9683. }
  9684. }
  9685. $receiptList [$key] ['verifyList'] = $verifyList;
  9686. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  9687. 'where' => 'sid=' . $value ['staff'],
  9688. 'asArray' => true
  9689. ) );
  9690. $receiptList [$key] ['button'] = $button;
  9691. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  9692. }
  9693. // print_r($receiptList);die;
  9694. // $data['verifyDetail']=$verifyDetail;
  9695. $mothHtml = "";
  9696. for($i = 1; $i <= 12; $i ++) {
  9697. if ($month == $i)
  9698. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  9699. else
  9700. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  9701. }
  9702. $data ['mothHtml'] = $mothHtml;
  9703. $data ['page'] = $pageinfo;
  9704. $data ['receiptList'] = $receiptList;
  9705. $data ['receiptApprovalCount'] = count ( $rLRes );
  9706. $data ['status'] = $status;
  9707. $data ['year'] = $year;
  9708. $data ['categoryList'] = $categoryList;
  9709. $data ['staffList'] = $staffList;
  9710. $data ['cid'] = $cid;
  9711. $data ['sid'] = $sid;
  9712. // print_r($receiptList);
  9713. $data ['memu'] = "receipt";
  9714. $data ['staff'] = $this->staff;
  9715. $data ['receiptMemu'] = 'approvalExpenses';
  9716. $data ['verifyId'] = $this->verifyId;
  9717. $data ['executeId'] = $this->executeId;
  9718. $this->render ( "/admin/FALG", $data );
  9719. }
  9720. function ajaxGetReceiptOrder() {
  9721. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  9722. if (! empty ( $receiptOrder )) {
  9723. Doo::loadModel ( 'receipt' );
  9724. $receipt = new receipt ();
  9725. Doo::loadModel ( 'staff' );
  9726. $staff = new staff ();
  9727. $receiptInfo = $receipt->getOne ( array (
  9728. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  9729. 'asArray' => true
  9730. ) );
  9731. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  9732. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  9733. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  9734. </tbody></table><table class="table table table-bordered"><tbody>';
  9735. foreach ( $verifyStaff as $key => $value ) {
  9736. $staffInfo = $staff->getOne ( array (
  9737. 'select' => 'username',
  9738. 'where' => ' sid="' . $key . '"',
  9739. 'asArray' => true
  9740. ) );
  9741. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  9742. }
  9743. $html .= '</tbody></table></div></div>';
  9744. echo json_encode ( array (
  9745. 'status' => 1,
  9746. 'receiptHtml' => $html
  9747. ) );
  9748. die ();
  9749. }
  9750. echo json_encode ( array (
  9751. 'status' => 2,
  9752. 'receiptHtml' => ''
  9753. ) );
  9754. die ();
  9755. }
  9756. function _getMonthCollectDetail($receiptCollectList) {
  9757. if (! empty ( $receiptCollectList )) {
  9758. $receiptL = array (
  9759. '日常相关费用' => array (),
  9760. '差旅相关费用' => array (),
  9761. '培训班费用' => array (),
  9762. '其他' => array ()
  9763. );
  9764. $html = "";
  9765. $psum = 0;
  9766. $item = array (
  9767. '市内交通费',
  9768. '市内出租费',
  9769. '办事处房租',
  9770. '电话费',
  9771. '水费',
  9772. '电费',
  9773. '办公费用',
  9774. '邮寄费',
  9775. '其他费用',
  9776. '车辆费用',
  9777. '广告费',
  9778. '团队建设费',
  9779. '物业管理费',
  9780. '宽带费'
  9781. );
  9782. foreach ( $item as $value ) {
  9783. $falg = true;
  9784. foreach ( $receiptCollectList as $v ) {
  9785. if ($v ['itemCategory'] == '日常相关费用') {
  9786. if ($v ['item'] == $value) {
  9787. $psum += $v ['price'];
  9788. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9789. $falg = false;
  9790. break;
  9791. }
  9792. }
  9793. }
  9794. if ($falg)
  9795. $html .= '<td class="taR">-</td>';
  9796. }
  9797. if (! empty ( $psum ))
  9798. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9799. else
  9800. $psum = '<td class="colGreen taR">-</td>';
  9801. $receiptL ['日常相关费用'] = $psum . $html;
  9802. /* ----------------------------------- */
  9803. $html = "";
  9804. $psum = 0;
  9805. $item = array (
  9806. '往来交通费',
  9807. '市内交通费',
  9808. '出差住宿费',
  9809. '出差补助',
  9810. '其他费用'
  9811. );
  9812. foreach ( $item as $value ) {
  9813. $falg = true;
  9814. foreach ( $receiptCollectList as $v ) {
  9815. if ($v ['itemCategory'] == '差旅相关费用') {
  9816. if ($v ['item'] == $value) {
  9817. $psum += $v ['price'];
  9818. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9819. $falg = false;
  9820. break;
  9821. }
  9822. }
  9823. }
  9824. if ($falg)
  9825. $html .= '<td class="taR">-</td>';
  9826. }
  9827. if (! empty ( $psum ))
  9828. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9829. else
  9830. $psum = '<td class="colGreen taR">-</td>';
  9831. $receiptL ['差旅相关费用'] = $psum . $html;
  9832. /* ------------------------------------- */
  9833. $html = "";
  9834. $psum = 0;
  9835. $item = array (
  9836. '场租费',
  9837. '薪酬',
  9838. '住宿费',
  9839. '交通费',
  9840. '餐饮费',
  9841. '办公费',
  9842. '公关费',
  9843. '其他'
  9844. );
  9845. foreach ( $item as $value ) {
  9846. $falg = true;
  9847. foreach ( $receiptCollectList as $v ) {
  9848. if ($v ['itemCategory'] == '培训班费用') {
  9849. if ($v ['item'] == $value) {
  9850. $psum += $v ['price'];
  9851. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9852. $falg = false;
  9853. break;
  9854. }
  9855. }
  9856. }
  9857. if ($falg)
  9858. $html .= '<td class="taR">-</td>';
  9859. }
  9860. if (! empty ( $psum ))
  9861. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9862. else
  9863. $psum = '<td class="colGreen taR">-</td>';
  9864. $receiptL ['培训班费用'] = $psum . $html;
  9865. /* ------------------------------------- */
  9866. $html = "";
  9867. $psum = 0;
  9868. $item = array (
  9869. '公关费',
  9870. '广告费',
  9871. '借款',
  9872. '可自加费用'
  9873. );
  9874. foreach ( $item as $value ) {
  9875. $falg = true;
  9876. foreach ( $receiptCollectList as $v ) {
  9877. if ($v ['itemCategory'] == '其他') {
  9878. if ($v ['item'] == $value) {
  9879. $psum += $v ['price'];
  9880. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9881. $falg = false;
  9882. break;
  9883. }
  9884. }
  9885. }
  9886. if ($falg)
  9887. $html .= '<td class="taR">-</td>';
  9888. }
  9889. if (! empty ( $psum ))
  9890. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9891. else
  9892. $psum = '<td class="colGreen taR">-</td>';
  9893. $receiptL ['其他'] = $psum . $html;
  9894. /* ------------------------------------- */
  9895. $html = "";
  9896. $psum = 0;
  9897. foreach ( $receiptCollectList as $v ) {
  9898. if ($v ['itemCategory'] == '报销金额调整') {
  9899. if (! empty ( $v ['price'] ))
  9900. $psum += $v ['price'];
  9901. }
  9902. }
  9903. if (! empty ( $psum ))
  9904. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9905. else
  9906. $psum = '<td class="taR colOrange">-</td>';
  9907. $receiptL ['报销金额调整'] = $psum . $html;
  9908. } else {
  9909. $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>
  9910. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9911. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9912. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9913. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9914. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9915. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9916. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9917. }
  9918. return $receiptL;
  9919. }
  9920. function eMail() {
  9921. Doo::loadModel ( 'staff' );
  9922. $staff = new staff ();
  9923. Doo::loadModel ( 'receipt' );
  9924. $receipt = new receipt ();
  9925. Doo::loadModel ( 'L_category' );
  9926. $Lcategory = new L_category ();
  9927. Doo::loadModel ( "verify" );
  9928. $verify = new verify ();
  9929. $staffList = $staff->find ( array (
  9930. 'asArray' => true
  9931. ) );
  9932. foreach ( $staffList as $key => $value ) {
  9933. if ($value ['username'] != 'admin') {
  9934. // 提交人
  9935. $receiptList = $receipt->find ( array (
  9936. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  9937. 'asArray' => true
  9938. ) );
  9939. if (! empty ( $receiptList )) {
  9940. $html = '<br><div><style></style>
  9941. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  9942. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  9943. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9944. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  9945. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9946. <tbody><tr>
  9947. <td style="padding: 0 40px;" align="left">
  9948. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9949. </td></tr><tr>
  9950. <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>
  9951. </tr>
  9952. </tbody> </table></td> </tr> <tr><td>
  9953. <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">
  9954. <tbody> <tr><td>
  9955. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  9956. 以下报销单完成了审批,等着收款吧:</p>
  9957. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  9958. foreach ( $receiptList as $k => $v ) {
  9959. $category = $Lcategory->getOne ( array (
  9960. 'where' => 'cid=' . $v ['cid'],
  9961. 'asArray' => true
  9962. ) );
  9963. $html .= '
  9964. <tr>
  9965. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  9966. <td align="left">
  9967. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  9968. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  9969. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  9970. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  9971. </tr>';
  9972. }
  9973. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  9974. <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>
  9975. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  9976. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  9977. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  9978. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9979. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9980. $receipt = new receipt ();
  9981. $receipt->notice = 1;
  9982. $receipt->update ( array (
  9983. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  9984. ) );
  9985. }
  9986. }
  9987. // 审批人
  9988. $verifyList = $verify->find ( array (
  9989. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  9990. 'asArray' => true
  9991. ) );
  9992. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  9993. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  9994. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9995. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  9996. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9997. <tbody><tr><td style="padding: 0 40px;" align="left">
  9998. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9999. </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>
  10000. </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">
  10001. <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>
  10002. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  10003. foreach ( $verifyList as $k => $v ) {
  10004. $receiptList = $receipt->find ( array (
  10005. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  10006. 'asArray' => true
  10007. ) );
  10008. foreach ( $receiptList as $r => $l ) {
  10009. $category = $Lcategory->getOne ( array (
  10010. 'where' => 'cid=' . $l ['cid'],
  10011. 'asArray' => true
  10012. ) );
  10013. $staffDetile = $staff->getOne ( array (
  10014. 'where' => 'sid=' . $l ['staff'],
  10015. 'asArray' => true
  10016. ) );
  10017. $html .= '
  10018. <tr>
  10019. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  10020. <td align="left">
  10021. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  10022. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  10023. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  10024. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  10025. </tr>';
  10026. }
  10027. }
  10028. $html .= '
  10029. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  10030. <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>
  10031. </tr></tbody></table></td></tr></tbody></table></div><br>';
  10032. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  10033. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  10034. // $receipt=new receipt();
  10035. // $receipt->notice=1;
  10036. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  10037. }
  10038. }
  10039. }
  10040. }
  10041. function setWXMsg($rid, $type) {
  10042. Doo::loadModel ( "receipt" );
  10043. $receipt = new receipt ();
  10044. $receiptDetail = $receipt->getOne ( array (
  10045. 'where' => 'rid=' . $rid,
  10046. 'asArray' => true
  10047. ) );
  10048. if (! empty ( $receiptDetail )) {
  10049. Doo::loadModel ( 'staff' );
  10050. $staff = new staff ();
  10051. $staffmsg = $staff->getOne ( array (
  10052. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  10053. 'asArray' => TRUE
  10054. ) );
  10055. if (! empty ( $staffmsg ['wxid'] )) {
  10056. require_once (SITE_PATH . '/protected/class/client.php');
  10057. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  10058. $user = $staffmsg ['wxid'];
  10059. $receiptName = '';
  10060. $msg = '';
  10061. switch ($receiptDetail ['Rtype']) {
  10062. case 0 :
  10063. $receiptName = '报销';
  10064. break;
  10065. case 1 :
  10066. $receiptName = '借款';
  10067. break;
  10068. case 2 :
  10069. $receiptName = '对公汇款';
  10070. break;
  10071. }
  10072. switch ($type) {
  10073. case 1 :
  10074. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  10075. break;
  10076. case 2 :
  10077. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  10078. break;
  10079. case 3 :
  10080. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  10081. break;
  10082. }
  10083. $result = $client->SendMsg ( $user, $msg, 'text' );
  10084. }
  10085. }
  10086. }
  10087. // Email发送函数
  10088. function SMail($toemail, $subject, $contents) {
  10089. Doo::loadClass ( 'class.phpmailer' );
  10090. $mail = new PHPMailer ();
  10091. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  10092. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  10093. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  10094. $mail->Password = "cDO1GjtY1seH"; // 密码
  10095. $mail->CharSet = "UTF8";
  10096. $mail->SMTPAuth = true;
  10097. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  10098. $mail->Mailer = "smtp";
  10099. $mail->Port = 25;
  10100. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  10101. $mail->MsgHTML ( $contents );
  10102. $mail->AddAddress ( $toemail );
  10103. $mail->CharSet = "UTF-8";
  10104. return $mail->Send ();
  10105. }
  10106. function swfupload() {
  10107. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  10108. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  10109. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  10110. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  10111. header ( "HTTP/1.1 500 Internal Server Error" );
  10112. echo "POST exceeded maximum allowed size.";
  10113. exit ( 0 );
  10114. }
  10115. // Settings
  10116. $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)
  10117. $upload_name = "Filedata";
  10118. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  10119. $extension_whitelist = array (
  10120. "doc",
  10121. "txt",
  10122. "jpg",
  10123. "gif",
  10124. "png"
  10125. ); // Allowed file extensions
  10126. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  10127. // Other variables
  10128. $MAX_FILENAME_LENGTH = 260;
  10129. $file_name = "";
  10130. $file_extension = "";
  10131. $uploadErrors = array (
  10132. 0 => "文件上传成功",
  10133. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  10134. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  10135. 3 => "上传的文件仅为部分文件",
  10136. 4 => "没有文件上传",
  10137. 6 => "缺少临时文件夹"
  10138. );
  10139. $nk = time ();
  10140. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  10141. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  10142. echo "文件无法保存.";
  10143. exit ( 0 );
  10144. }
  10145. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  10146. echo json_encode ( array (
  10147. 'filename' => $file_name,
  10148. 'id' => $nk
  10149. ) );
  10150. exit ( 0 );
  10151. }
  10152. function _GetFileEXT($filename) {
  10153. $pics = explode ( '.', $filename );
  10154. $num = count ( $pics );
  10155. return $pics [$num - 1];
  10156. }
  10157. /**
  10158. * 获取get或者POST值
  10159. * @param string $name 属性名称
  10160. * @return fixed 值
  10161. */
  10162. function get_args($name) {
  10163. if (isset ( $_GET [$name] )) {
  10164. if (is_array ( $_GET [$name] ))
  10165. return $_GET [$name];
  10166. else
  10167. return addslashes ( $_GET [$name] );
  10168. } elseif (isset ( $_POST [$name] )) {
  10169. if (is_array ( $_POST [$name] ))
  10170. return $_POST [$name];
  10171. else
  10172. return addslashes ( $_POST [$name] );
  10173. } else
  10174. return false;
  10175. }
  10176. function num_to_rmb($num) {
  10177. $c1 = "零壹贰叁肆伍陆柒捌玖";
  10178. $c2 = "分角元拾佰仟万拾佰仟亿";
  10179. // 精确到分后面就不要了,所以只留两个小数位
  10180. $num = round ( $num, 2 );
  10181. // 将数字转化为整数
  10182. $num = $num * 100;
  10183. if (strlen ( $num ) > 10) {
  10184. return "金额太大,请检查";
  10185. }
  10186. $i = 0;
  10187. $c = "";
  10188. while ( 1 ) {
  10189. if ($i == 0) {
  10190. // 获取最后一位数字
  10191. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  10192. } else {
  10193. $n = $num % 10;
  10194. }
  10195. // 每次将最后一位数字转化为中文
  10196. $p1 = substr ( $c1, 3 * $n, 3 );
  10197. $p2 = substr ( $c2, 3 * $i, 3 );
  10198. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  10199. $c = $p1 . $p2 . $c;
  10200. } else {
  10201. $c = $p1 . $c;
  10202. }
  10203. $i = $i + 1;
  10204. // 去掉数字最后一位了
  10205. $num = $num / 10;
  10206. $num = ( int ) $num;
  10207. // 结束循环
  10208. if ($num == 0) {
  10209. break;
  10210. }
  10211. }
  10212. $j = 0;
  10213. $slen = strlen ( $c );
  10214. while ( $j < $slen ) {
  10215. // utf8一个汉字相当3个字符
  10216. $m = substr ( $c, $j, 6 );
  10217. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  10218. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  10219. $left = substr ( $c, 0, $j );
  10220. $right = substr ( $c, $j + 3 );
  10221. $c = $left . $right;
  10222. $j = $j - 3;
  10223. $slen = $slen - 3;
  10224. }
  10225. $j = $j + 3;
  10226. }
  10227. // 这个是为了去掉类似23.0中最后一个“零”字
  10228. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  10229. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  10230. }
  10231. // 将处理的汉字加上“整”
  10232. if (empty ( $c )) {
  10233. return "零元整";
  10234. } else {
  10235. return $c . "整";
  10236. }
  10237. }
  10238. /**
  10239. * 获得分页数据
  10240. * @param unknown_type $table
  10241. * @param unknown_type $condition
  10242. * @param unknown_type $on_page
  10243. * @param unknown_type $page_size
  10244. */
  10245. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  10246. $page_c = "";
  10247. $page ['previous'] = $this->get_previous ( $on_page );
  10248. $page ['on_page'] = $on_page;
  10249. $total_count = $this->get_table_count ( $table, $condition );
  10250. $total = intval ( $total_count / $page_size );
  10251. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  10252. $page ['total_data'] = $total_count;
  10253. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  10254. $i = 1;
  10255. $page_max = 1;
  10256. $page_width = 3;
  10257. if ($on_page >= $page_width) {
  10258. $page_max = intval ( $on_page / $page_width ) + 1;
  10259. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  10260. }
  10261. for(; $i <= $page ['total_page']; $i ++) {
  10262. if ($i == $on_page)
  10263. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  10264. else
  10265. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  10266. if ($i == ($page_width * $page_max))
  10267. break;
  10268. }
  10269. $page ['page'] = $page_c;
  10270. $page ['lower'] = (-- $on_page) * $page_size;
  10271. return $page;
  10272. }
  10273. /**
  10274. * 获取总页数
  10275. * @param unknown_type $table
  10276. * @param unknown_type $condition
  10277. */
  10278. public function get_table_count($table = "", $condition = "") {
  10279. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10280. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10281. // echo $sql;die;
  10282. $query = Doo::db ()->query ( $sql );
  10283. $result = $query->fetch ();
  10284. return $result ['count'];
  10285. }
  10286. /**
  10287. * 获取上一页
  10288. * @param unknown_type $on_page
  10289. */
  10290. function get_previous($on_page = 1) {
  10291. return $on_page != 0 ? $on_page - 1 : $on_page;
  10292. }
  10293. }
  10294. ?>