ReceiptController.php 374 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class ReceiptController extends DooController {
  6. public $staff;
  7. public $verifyId;
  8. public $executeId;
  9. // public static $NEW2 = 0;
  10. public $AGENCY = "日常相关费用";
  11. public $TRAVEL = "差旅相关费用";
  12. public $TRAIN = "培训班费用";
  13. public $OTHER = "其他";
  14. private $MYREVEIPTCACHEPATH = "protected/cache/myReceipt/";
  15. private $PERSONALCOLLECTCACHEPATH = "protected/cache/personalCollect/";
  16. private $CATEGORYCOLLECTPATH = "protected/cache/categoryCollect/";
  17. private $STAFFCOLLECTPATH = "protected/cache/staffCollect/";
  18. private function showCache($path) {
  19. if (file_exists ( $path )) {
  20. echo "<!DOCTYPE html>";
  21. include $path;
  22. die ();
  23. }
  24. }
  25. private function cacheFile($path) {
  26. $content = ob_get_contents ();
  27. $fp = fopen ( $path, "w" );
  28. fwrite ( $fp, $content );
  29. fclose ( $fp );
  30. }
  31. private function collectHtml($receiptCollectList = array(), $itemCategory = "日常相关费用", $classType = "b") {
  32. $collectHtml = "";
  33. $sumPrice = 0.00;
  34. for($i = 1; $i <= 12; $i ++) {
  35. $falg = true;
  36. foreach ( $receiptCollectList as $key => $value ) {
  37. if ($value ['itemCategory'] == $itemCategory && $value ['month'] == $i) {
  38. $sumPrice += $value ['price'];
  39. if ($classType == "b") {
  40. $collectHtml .= '<td class="colGreen taR">¥' . $value ['price'] . '</td>';
  41. $falg = false;
  42. break;
  43. } else {
  44. $collectHtml .= '<td class="taR">¥' . $value ['price'] . '</td>';
  45. $falg = false;
  46. break;
  47. }
  48. }
  49. }
  50. if ($falg)
  51. $collectHtml .= '<td class="taR">-</td>';
  52. }
  53. $collectHtml .= '<td class="taR colGreen">¥' . $sumPrice . '</td>';
  54. return $collectHtml;
  55. }
  56. function __construct() {
  57. if (isset ( $_COOKIE ["staff"] )) {
  58. if (! empty ( $_COOKIE ["staff"] )) {
  59. Doo::loadModel ( 'staff' );
  60. Doo::loadModel ( 'verify' );
  61. $verify = new verify ();
  62. $staff = new staff ();
  63. Doo::loadModel ( "execute" );
  64. $execute = new execute ();
  65. $verifyList = $verify->find ( array (
  66. 'select' => 'staff',
  67. 'asArray' => true
  68. ) );
  69. $list = array ();
  70. // 判断角色的审批权限
  71. foreach ( $verifyList as $key => $value ) {
  72. $ver = json_decode ( $value ['staff'] );
  73. foreach ( $ver as $k => $v ) {
  74. if ($v [1] == 'ROLE') {
  75. $roleList = json_decode ( $v [3] );
  76. foreach ( $roleList as $t => $g ) {
  77. $gList = explode ( "_", $g );
  78. array_push ( $list, $gList [0] );
  79. // print_r($list);
  80. }
  81. } else
  82. array_push ( $list, $v [0] );
  83. }
  84. }
  85. // 判断执行人的审批权限
  86. $executeList = $execute->find ( array (
  87. 'select' => 'staff',
  88. 'asArray' => true
  89. ) );
  90. $list2 = array ();
  91. foreach ( $executeList as $key => $value ) {
  92. $ver = json_decode ( $value ['staff'] );
  93. foreach ( $ver as $k => $v ) {
  94. array_push ( $list2, $v [0] );
  95. }
  96. }
  97. $eidList = file_get_contents ( "protected/config/execute/execute.ini" );
  98. $eidList = array_filter ( explode ( ",", $eidList ) );
  99. $this->executeId = array_merge ( $list2, $eidList );
  100. $this->verifyId = $list;
  101. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  102. return "/";
  103. }
  104. }
  105. Doo::loadCore ( 'uri/DooUriRouter' );
  106. $router = new DooUriRouter ();
  107. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  108. if ($routeRs ['1'] != "login") {
  109. header ( 'Content-Type:text/html;charset=utf-8' );
  110. @header ( "Location: /login" );
  111. }
  112. }
  113. function saeaBorad() {
  114. Doo::loadModel ( 'receipt' );
  115. Doo::loadModel ( 'verify' );
  116. $verify = new verify ();
  117. $receipt = new receipt ();
  118. Doo::loadModel ( 'L_category' );
  119. $lCategory = new L_category ();
  120. Doo::loadModel ( "role" );
  121. $role = new role ();
  122. Doo::loadModel ( "receiptLog" );
  123. $receiptLog = new receiptLog ();
  124. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  125. $receiptDetail = $receipt->find ( array (
  126. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  127. 'desc' => 'rid',
  128. 'asArray' => true
  129. ) );
  130. foreach ( $receiptDetail as $key => $value ) {
  131. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  132. $veList = $verify->getOne ( array (
  133. 'where' => 'vid=' . $value ['verify'],
  134. 'asArray' => true
  135. ) );
  136. $v = json_decode ( $veList ['staff'] );
  137. array_push ( $v [0], $veList ['description'] );
  138. foreach ( $v as $n => $m ) {
  139. if ($m ['1'] == 'ROLE') {
  140. $roleInfo = $role->getOne ( array (
  141. 'where' => 'rid=' . $m [0],
  142. 'asArray' => true
  143. ) );
  144. $v [$n] [1] = $roleInfo ['name'];
  145. }
  146. }
  147. $receiptDetail [$key] ['staff'] = $v;
  148. $category = $lCategory->getOne ( array (
  149. 'where' => 'cid=' . $value ['cid'],
  150. 'asArray' => true
  151. ) );
  152. $receiptDetail [$key] ['category'] = $category ['title'];
  153. }
  154. // print_r($receiptLogList);
  155. $data ['receiptLogList'] = $receiptLogList;
  156. $data ['receiptDetail'] = $receiptDetail;
  157. $data ['memu'] = "receipt";
  158. $data ['staff'] = $this->staff;
  159. $data ['receiptMemu'] = 'saeaBorad';
  160. $data ['verifyId'] = $this->verifyId;
  161. $data ['executeId'] = $this->executeId;
  162. $this->render ( "/admin/saeaBorad", $data );
  163. }
  164. function remitAdd() {
  165. Doo::loadModel ( 'accountItem' );
  166. Doo::loadModel ( 'verify' );
  167. Doo::loadModel ( 'receipt' );
  168. Doo::loadModel ( 'L_category' );
  169. $lCategory = new L_category ();
  170. $receipt = new receipt ();
  171. $verify = new verify ();
  172. $accountItem = new accountItem ();
  173. Doo::loadModel ( "role" );
  174. $role = new role ();
  175. $acItem = $accountItem->find ( array (
  176. 'asArray' => true
  177. ) );
  178. $veList = $verify->find ( array (
  179. 'asArray' => true
  180. ) );
  181. foreach ( $veList as $key => $value ) {
  182. $v = json_decode ( $value ['staff'] );
  183. $list = array ();
  184. foreach ( $v as $n => $m ) {
  185. if ($m ['1'] == 'ROLE') {
  186. $roleInfo = $role->getOne ( array (
  187. 'where' => 'rid=' . $m [0],
  188. 'asArray' => true
  189. ) );
  190. $v [$n] [1] = $roleInfo ['name'];
  191. array_push ( $list, $roleInfo ['name'] );
  192. } else {
  193. array_push ( $list, $v [$n] [1] );
  194. }
  195. }
  196. $veList [$key] ['staff'] = implode ( '>', $list );
  197. }
  198. $data ['category'] = $lCategory->find ( array (
  199. 'asArray' => true
  200. ) );
  201. $data ['veList'] = $veList;
  202. $data ['acItem'] = $acItem;
  203. $data ['memu'] = "receipt";
  204. $data ['staff'] = $this->staff;
  205. $data ['receiptMemu'] = 'saeaBorad';
  206. $data ['verifyId'] = $this->verifyId;
  207. $data ['executeId'] = $this->executeId;
  208. $this->render ( "/admin/remitAdd", $data );
  209. }
  210. function remitAddDo() {
  211. $agency = $this->get_args ( 'agency' );
  212. $travel = $this->get_args ( 'travel' );
  213. $train = $this->get_args ( 'train' );
  214. $other = $this->get_args ( 'other' );
  215. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  216. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  217. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  218. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  219. // print_r($agency);die;
  220. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  221. Doo::loadModel ( 'receipt' );
  222. Doo::loadModel ( 'receiptDetail' );
  223. Doo::loadModel ( 'accountItem' );
  224. $accountItem = new accountItem ();
  225. $receipt = new receipt ();
  226. Doo::loadModel ( 'enclosur' );
  227. Doo::loadModel ( 'execute' );
  228. $execute = new execute ();
  229. $executeDetail = $execute->getOne ( array (
  230. 'where' => 'mold="对公汇款执行人"',
  231. 'asArray' => true
  232. ) );
  233. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  234. $aItem = $accountItem->find ( array (
  235. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  236. 'asArray' => true
  237. ) );
  238. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  239. $ag = $tr = $ta = $ot = 0;
  240. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  241. foreach ( $aItem as $key => $value ) {
  242. if ($value ['category'] == $this->AGENCY) {
  243. if (isset ( $agency [$ag] )) {
  244. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  245. array_push ( $accountJson [$this->AGENCY], array (
  246. 'aid' => $value ['aid'],
  247. 'name' => $value ['name'],
  248. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  249. ) );
  250. $sum += $agency [$ag];
  251. $agencySum += $agency [$ag];
  252. }
  253. }
  254. $ag ++;
  255. }
  256. }
  257. $accountJson ['cSum'] = array (
  258. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  259. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  260. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  261. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  262. );
  263. // 报销单
  264. $receipt->accountItem = json_encode ( $accountJson );
  265. $receipt->staff = $this->staff [0] ['sid'];
  266. $receipt->sum = number_format ( $sum, 2, '.', '' );
  267. $receipt->date = date ( "Y-m-d" );
  268. $receipt->cid = $cid;
  269. $receipt->status = 5;
  270. $receipt->Rtype = 2;
  271. // 修改审批流程加入角色
  272. $receipt->verify = $verify;
  273. $receipt->executeCopy = $executeDetail ['staff'];
  274. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  275. $receipt->explanation = $explanation;
  276. $rid = $receipt->insert ();
  277. // 附件
  278. if (! empty ( $enclosurName )) {
  279. $enclosurArray = explode ( '-', $enclosurName );
  280. foreach ( $enclosurArray as $value ) {
  281. $enclosur = new enclosur ();
  282. $enclosur->name = $value;
  283. $enclosur->rid = $rid;
  284. $enclosur->insert ();
  285. }
  286. // print_r($enclosurArray);die;
  287. }
  288. // 报销详情
  289. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  290. $receiptDetail = new receiptDetail ();
  291. $receiptDetail->staff = $this->staff [0] ['sid'];
  292. $receiptDetail->item = $value ['name'];
  293. $receiptDetail->itemCategory = $this->AGENCY;
  294. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  295. $receiptDetail->date = date ( "Y-m-d" );
  296. $receiptDetail->cid = $cid;
  297. $receiptDetail->rid = $rid;
  298. $receiptDetail->status = 4;
  299. $receiptDetail->insert ();
  300. }
  301. return "/saeaBorad";
  302. } else
  303. die ( 'illegal request' );
  304. }
  305. function remitEdit() {
  306. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  307. // echo $rid;
  308. Doo::loadModel ( 'accountItem' );
  309. Doo::loadModel ( 'verify' );
  310. Doo::loadModel ( 'receipt' );
  311. $receipt = new receipt ();
  312. $verify = new verify ();
  313. $accountItem = new accountItem ();
  314. Doo::loadModel ( 'L_category' );
  315. $lCategory = new L_category ();
  316. Doo::loadModel ( "role" );
  317. $role = new role ();
  318. $receiptDetail = $receipt->getOne ( array (
  319. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  320. 'asArray' => true
  321. ) );
  322. if (empty ( $receiptDetail ))
  323. return "/saeaCreate";
  324. $acItem = $accountItem->find ( array (
  325. 'asArray' => true
  326. ) );
  327. $veList = $verify->find ( array (
  328. 'asArray' => true
  329. ) );
  330. foreach ( $veList as $key => $value ) {
  331. $v = json_decode ( $value ['staff'] );
  332. $list = array ();
  333. foreach ( $v as $n => $m ) {
  334. if ($m ['1'] == 'ROLE') {
  335. $roleInfo = $role->getOne ( array (
  336. 'where' => 'rid=' . $m [0],
  337. 'asArray' => true
  338. ) );
  339. $v [$n] [1] = $roleInfo ['name'];
  340. array_push ( $list, $roleInfo ['name'] );
  341. } else {
  342. array_push ( $list, $v [$n] [1] );
  343. }
  344. }
  345. $veList [$key] ['staff'] = implode ( '>', $list );
  346. }
  347. // 配置编辑信息
  348. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  349. foreach ( $acItem as $key => $value ) {
  350. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  351. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  352. $acItem [$key] ['price'] = $v ['price'];
  353. }
  354. }
  355. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  356. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  357. $acItem [$key] ['price'] = $v ['price'];
  358. }
  359. }
  360. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  361. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  362. $acItem [$key] ['price'] = $v ['price'];
  363. }
  364. }
  365. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  366. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  367. $acItem [$key] ['price'] = $v ['price'];
  368. }
  369. }
  370. }
  371. $data ['category'] = $lCategory->find ( array (
  372. 'asArray' => true
  373. ) );
  374. $data ['cSum'] = $accountItemList ['cSum'];
  375. $data ['sum'] = $receiptDetail ['sum'];
  376. $data ['receiptDetail'] = $receiptDetail;
  377. $data ['veList'] = $veList;
  378. $data ['acItem'] = $acItem;
  379. $data ['memu'] = "receipt";
  380. $data ['staff'] = $this->staff;
  381. $data ['receiptMemu'] = 'saeaBorad';
  382. $data ['verify'] = $receiptDetail ['verify'];
  383. $data ['verifyId'] = $this->verifyId;
  384. $data ['executeId'] = $this->executeId;
  385. $data ['rid'] = $rid;
  386. $this->render ( "/admin/remitEdit", $data );
  387. }
  388. function remitEdiDo() {
  389. $agency = $this->get_args ( 'agency' );
  390. $travel = $this->get_args ( 'travel' );
  391. $train = $this->get_args ( 'train' );
  392. $other = $this->get_args ( 'other' );
  393. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  394. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  395. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  396. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  397. if (! empty ( $explanation )) {
  398. Doo::loadModel ( 'receipt' );
  399. Doo::loadModel ( 'receiptDetail' );
  400. Doo::loadModel ( 'accountItem' );
  401. $accountItem = new accountItem ();
  402. $receipt = new receipt ();
  403. Doo::loadModel ( 'execute' );
  404. $execute = new execute ();
  405. $executeDetail = $execute->getOne ( array (
  406. 'where' => 'mold="对公汇款执行人"',
  407. 'asArray' => true
  408. ) );
  409. $receiptDetail = $receipt->getOne ( array (
  410. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  411. 'asArray' => true
  412. ) );
  413. if (empty ( $receiptDetail ))
  414. return "/saeaBorad";
  415. $aItem = $accountItem->find ( array (
  416. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  417. 'asArray' => true
  418. ) );
  419. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  420. $ag = $tr = $ta = $ot = 0;
  421. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  422. foreach ( $aItem as $key => $value ) {
  423. if ($value ['category'] == $this->AGENCY) {
  424. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  425. array_push ( $accountJson [$this->AGENCY], array (
  426. 'aid' => $value ['aid'],
  427. 'name' => $value ['name'],
  428. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  429. ) );
  430. $sum += $agency [$ag];
  431. $agencySum += $agency [$ag];
  432. }
  433. $ag ++;
  434. }
  435. }
  436. $accountJson ['cSum'] = array (
  437. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  438. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  439. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  440. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  441. );
  442. // 报销单
  443. $rid = $receipt->rid = $receiptDetail ['rid'];
  444. $receipt->accountItem = json_encode ( $accountJson );
  445. $receipt->staff = $this->staff [0] ['sid'];
  446. $receipt->sum = number_format ( $sum, 2, '.', '' );
  447. $receipt->date = date ( "Y-m-d" );
  448. $receipt->cid = $cid;
  449. if ($receiptDetail ['Rtype'] == 1)
  450. $receipt->status = 7;
  451. else
  452. $receipt->status = 5;
  453. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  454. $receipt->verify = $verify;
  455. $receipt->executeCopy = $executeDetail ['staff'];
  456. $receipt->explanation = $explanation;
  457. $receipt->update ();
  458. $receiptDetail = new receiptDetail ();
  459. $receiptDetail->delete ( array (
  460. 'where' => 'rid=' . $rid
  461. ) );
  462. // 报销详情
  463. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  464. $receiptDetail = new receiptDetail ();
  465. $receiptDetail->staff = $this->staff [0] ['sid'];
  466. $receiptDetail->item = $value ['name'];
  467. $receiptDetail->itemCategory = $this->AGENCY;
  468. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  469. $receiptDetail->date = date ( "Y-m-d" );
  470. $receiptDetail->cid = $cid;
  471. $receiptDetail->rid = $rid;
  472. $receiptDetail->status = 4;
  473. $receiptDetail->insert ();
  474. }
  475. // return "/referReceipt/".$rid;
  476. }
  477. return "/saeaBorad";
  478. }
  479. function remitApproval() {
  480. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  481. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  482. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  483. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  484. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  485. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  486. if (empty ( $status ))
  487. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  488. $vidList = array ();
  489. $button = 0;
  490. Doo::loadModel ( 'verify' );
  491. Doo::loadModel ( 'receipt' );
  492. Doo::loadModel ( 'staff' );
  493. $staff = new staff ();
  494. $receipt = new receipt ();
  495. $verify = new verify ();
  496. Doo::loadModel ( 'L_category' );
  497. $Lcategory = new L_category ();
  498. Doo::loadModel ( 'enclosur' );
  499. $enclosur = new enclosur ();
  500. // user verify ID
  501. $verifyDetail = $verify->find ( array (
  502. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  503. 'asArray' => true
  504. ) );
  505. foreach ( $verifyDetail as $key => $value ) {
  506. array_push ( $vidList, $value ['vid'] );
  507. }
  508. $vid = implode ( ",", $vidList );
  509. if (empty ( $verifyDetail ))
  510. $vid = 0;
  511. $categoryList = $Lcategory->find ( array (
  512. 'asArray' => true
  513. ) );
  514. $staffList = $staff->find ( array (
  515. 'where' => 'cid=' . $cid,
  516. 'asArray' => true
  517. ) );
  518. $ap = "";
  519. if ($status == 4) {
  520. $ap = 4;
  521. $status = 2;
  522. }
  523. // get Receipt By verifyID status 2
  524. $receiptList = $receipt->find ( array (
  525. 'where' => 'rid =' . $rid . ' and status=2',
  526. 'desc' => 'rid',
  527. 'asArray' => true
  528. ) );
  529. if (empty ( $receiptList )) {
  530. die ( 'illegal request' );
  531. }
  532. $Locate = 0;
  533. $roleId = 0;
  534. if ($ap == 4)
  535. $status = 4;
  536. foreach ( $receiptList as $key => $value ) {
  537. $receiptList [$key] ['Locate'] = $Locate;
  538. $Locate ++;
  539. $receiptList [$key] ['reviseDetail'] = array ();
  540. if (! empty ( $value ['reviseDetail'] ))
  541. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  542. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  543. $categoryDetil = $Lcategory->getOne ( array (
  544. 'where' => 'cid=' . $value ['cid'],
  545. 'asArray' => true
  546. ) );
  547. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  548. // 检测编辑状态
  549. $verifyList = $verify->getOne ( array (
  550. 'where' => 'vid=' . $value ['verify'],
  551. 'asArray' => true
  552. ) );
  553. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  554. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  555. Doo::loadModel ( 'role' );
  556. $role = new role ();
  557. // print_r($verifyList);
  558. $flag = true;
  559. $roleKey = 0;
  560. $endStaffArray = array ();
  561. $roleArrayCopy = array ();
  562. foreach ( $verifyList as $k => $v ) {
  563. // init verifyStaff
  564. if ($v [1] == 'ROLE') {
  565. if (! empty ( $verifyStaff )) {
  566. $endStaffArray = end ( $verifyStaff );
  567. if ($v [0] == $endStaffArray ['nextStaff']) {
  568. $roleId = $v [0];
  569. }
  570. }
  571. $roleVerify = json_decode ( $v [3], true );
  572. $roleKey = $k;
  573. $roleArray = array ();
  574. $rolename = $role->getOne ( array (
  575. 'where' => 'rid=' . $v [0],
  576. 'asArray' => true
  577. ) );
  578. foreach ( $roleVerify as $o => $p ) {
  579. $staffID = explode ( '_', $p );
  580. $staffInfo = $staff->getOne ( array (
  581. 'where' => 'sid=' . $staffID [0],
  582. 'asArray' => true
  583. ) );
  584. // print_r($staffID);
  585. $exp = array (
  586. 0 => $staffInfo ['sid'],
  587. 1 => $staffID [1],
  588. 2 => $staffInfo ['avatar'],
  589. 'date' => '',
  590. 'date' => '',
  591. 'opinion' => '',
  592. 'status' => '',
  593. 'rolename' => $rolename ['name']
  594. );
  595. array_push ( $roleArray, $exp );
  596. }
  597. $roleArrayCopy [$v [0]] = $roleArray;
  598. // $verifyList[$k]['roleArray']=$roleArray;
  599. }
  600. // print_r($roleArray);
  601. $verifyList [$k] ['date'] = "";
  602. $verifyList [$k] ['opinion'] = "";
  603. $verifyList [$k] ['status'] = "";
  604. if (empty ( $verifyStaff )) {
  605. $verifyList [$k] ['date'] = "";
  606. $verifyList [$k] ['opinion'] = "";
  607. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  608. $verifyList [$k] ['status'] = 4;
  609. $button = 4;
  610. $flag = false;
  611. }
  612. } else {
  613. foreach ( $verifyStaff as $m => $u ) {
  614. if ($v [0] == $m) {
  615. $verifyList [$k] ['date'] = $u ['date'];
  616. $verifyList [$k] ['opinion'] = $u ['opinion'];
  617. $verifyList [$k] ['status'] = $u ['status'];
  618. $flag = false;
  619. break;
  620. }
  621. }
  622. $endStaffArray = end ( $verifyStaff );
  623. if (isset ( $endStaffArray ['ROLE'] )) {
  624. } else {
  625. $endKey = key ( $verifyStaff );
  626. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  627. $button = 4;
  628. $verifyList [$k] ['status'] = 4;
  629. }
  630. }
  631. }
  632. }
  633. $rolename ['name'] = '';
  634. if (! empty ( $roleId )) {
  635. Doo::loadModel ( 'role' );
  636. $role = new role ();
  637. $rolename = $role->getOne ( array (
  638. 'where' => 'rid=' . $roleId,
  639. 'asArray' => true
  640. ) );
  641. }
  642. if (! empty ( $verifyStaff ))
  643. $endStaffArray = end ( $verifyStaff );
  644. $KOP = false;
  645. foreach ( $roleArrayCopy as $P => $A ) {
  646. foreach ( $A as $MKI => $AVL ) {
  647. if (! empty ( $verifyStaff )) {
  648. // &&$rolename['rid']==$endStaffArray['nextStaff']
  649. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  650. $button = 4;
  651. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  652. }
  653. foreach ( $verifyStaff as $m => $u ) {
  654. $AVLFK = $AVL [0] . '_R';
  655. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  656. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  657. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  658. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  659. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  660. break;
  661. }
  662. }
  663. } else {
  664. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  665. $button = 4;
  666. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  667. }
  668. }
  669. // $roleArray[$MKI]['rolename']=$rolename['name'];
  670. $KOP = true;
  671. }
  672. }
  673. foreach ( $roleArrayCopy as $k => $v ) {
  674. foreach ( $verifyList as $m => $n ) {
  675. if ($n [0] == $k) {
  676. array_splice ( $verifyList, $m, 1, $v );
  677. }
  678. }
  679. }
  680. $receiptList [$key] ['verifyList'] = $verifyList;
  681. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  682. 'where' => 'sid=' . $value ['staff'],
  683. 'asArray' => true
  684. ) );
  685. $receiptList [$key] ['button'] = $button;
  686. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  687. }
  688. $mothHtml = "";
  689. for($i = 1; $i <= 12; $i ++) {
  690. if ($month == $i)
  691. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  692. else
  693. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  694. }
  695. // 获取审批日志
  696. Doo::loadModel ( 'receiptLog' );
  697. $receiptLog = new receiptLog ();
  698. $rlList = array ();
  699. $rlInfo = $receiptLog->getOne ( array (
  700. 'where' => 'rid=' . $rid . ' and status=4',
  701. 'asArray' => true
  702. ) );
  703. $tijdate = $receiptLog->getOne ( array (
  704. 'where' => 'rid=' . $rid . ' and status=2',
  705. 'asc' => 'rlid',
  706. 'asArray' => true
  707. ) );
  708. if (! empty ( $rlInfo )) {
  709. $rlList = $receiptLog->find ( array (
  710. 'where' => 'rid=' . $rid,
  711. 'asc' => 'rlid',
  712. 'asArray' => true
  713. ) );
  714. }
  715. $receiptList [0] ['rlList'] = $rlList;
  716. $enclosurList = $enclosur->find ( array (
  717. 'where' => 'rid=' . $rid,
  718. 'asArray' => true
  719. ) );
  720. $enclosurHtml = '';
  721. foreach ( $enclosurList as $value ) {
  722. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  723. }
  724. // print_r($receiptList);
  725. $data ['enclosurHtml'] = $enclosurHtml;
  726. $data ['rolename'] = $rolename ['name'];
  727. $data ['datetij'] = $tijdate ['date'];
  728. $data ['mothHtml'] = $mothHtml;
  729. $data ['rid'] = $rid;
  730. $data ['receiptList'] = $receiptList;
  731. $data ['receiptApprovalCount'] = count ( $receiptList );
  732. $data ['status'] = $status;
  733. $data ['year'] = $year;
  734. $data ['categoryList'] = $categoryList;
  735. $data ['staffList'] = $staffList;
  736. $data ['cid'] = $cid;
  737. $data ['sid'] = $sid;
  738. $data ['ap'] = $ap;
  739. $data ['memu'] = "receipt";
  740. $data ['staff'] = $this->staff;
  741. $data ['receiptMemu'] = 'approvalExpenses';
  742. $data ['verifyId'] = $this->verifyId;
  743. $data ['executeId'] = $this->executeId;
  744. $this->render ( "/admin/remitApproval", $data );
  745. }
  746. function saeaLoanAdd() {
  747. Doo::loadModel ( 'verify' );
  748. $verify = new verify ();
  749. Doo::loadModel ( "role" );
  750. $role = new role ();
  751. Doo::loadModel ( 'L_category' );
  752. $lCategory = new L_category ();
  753. $veList = $verify->find ( array (
  754. 'asArray' => true
  755. ) );
  756. foreach ( $veList as $key => $value ) {
  757. $v = json_decode ( $value ['staff'] );
  758. $list = array ();
  759. foreach ( $v as $n => $m ) {
  760. if ($m ['1'] == 'ROLE') {
  761. $roleInfo = $role->getOne ( array (
  762. 'where' => 'rid=' . $m [0],
  763. 'asArray' => true
  764. ) );
  765. $v [$n] [1] = $roleInfo ['name'];
  766. array_push ( $list, $roleInfo ['name'] );
  767. } else {
  768. array_push ( $list, $v [$n] [1] );
  769. }
  770. }
  771. $veList [$key] ['staff'] = implode ( '>', $list );
  772. }
  773. $data ['category'] = $lCategory->find ( array (
  774. 'asArray' => true
  775. ) );
  776. $data ['veList'] = $veList;
  777. $data ['memu'] = "receipt";
  778. $data ['staff'] = $this->staff;
  779. $data ['receiptMemu'] = 'saeaBorad';
  780. $data ['verifyId'] = $this->verifyId;
  781. $data ['executeId'] = $this->executeId;
  782. $this->render ( "/admin/saeaLoanAdd", $data );
  783. }
  784. function saeaLoanAddDo() {
  785. $agency = $this->get_args ( 'agency' );
  786. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  787. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  788. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  789. // die;
  790. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  791. Doo::loadModel ( 'receipt' );
  792. Doo::loadModel ( 'receiptDetail' );
  793. Doo::loadModel ( 'accountItem' );
  794. $accountItem = new accountItem ();
  795. $receipt = new receipt ();
  796. Doo::loadModel ( 'loanReceipt' );
  797. $loanReceipt = new loanReceipt ();
  798. Doo::loadModel ( 'execute' );
  799. $execute = new execute ();
  800. Doo::loadModel ( 'enclosur' );
  801. $executeDetail = $execute->getOne ( array (
  802. 'where' => 'mold="借款执行人"',
  803. 'asArray' => true
  804. ) );
  805. $aItem = $accountItem->find ( array (
  806. 'asArray' => true
  807. ) );
  808. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  809. $ag = $tr = $ta = $ot = 0;
  810. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  811. array_push ( $accountJson ['借款费用'], array (
  812. 'aid' => 0,
  813. 'name' => '申请金额',
  814. 'price' => number_format ( $agency, 2, '.', '' )
  815. ) );
  816. $sum += $agency;
  817. $agencySum += $agency;
  818. $accountJson ['cSum'] = array (
  819. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  820. 'agencySum' => number_format ( 0, 2, '.', '' ),
  821. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  822. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  823. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  824. );
  825. // 借款数据备份
  826. $loanReceipt->loanItem = json_encode ( $accountJson );
  827. $loanReceipt->staff = $this->staff [0] ['sid'];
  828. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  829. $loanReceipt->date = date ( "Y-m-d" );
  830. $loanReceipt->cid = $cid;
  831. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  832. $loanReceipt->status = 5;
  833. $loanReceipt->Rtype = 1;
  834. $loanReceipt->verify = $verify;
  835. $receipt->receiptOrder = $receipt->receiptOrder;
  836. $loanReceipt->explanation = $explanation;
  837. $loanRid = $loanReceipt->insert ();
  838. // 报销单
  839. $receipt->loanItem = json_encode ( $accountJson );
  840. $receipt->staff = $this->staff [0] ['sid'];
  841. $receipt->sum = number_format ( $sum, 2, '.', '' );
  842. $receipt->date = date ( "Y-m-d" );
  843. $receipt->cid = $cid;
  844. // 特殊状态
  845. $receipt->status = 5;
  846. $receipt->Rtype = 1;
  847. $receipt->loanRid = $loanRid;
  848. // 修改审批流程加入角色
  849. $receipt->verify = $verify;
  850. $receipt->executeCopy = $executeDetail ['staff'];
  851. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  852. $receipt->explanation = $explanation;
  853. $rid = $receipt->insert ();
  854. return "/saeaBorad";
  855. } else
  856. die ( 'illegal request' );
  857. }
  858. function saeaLoanEdi() {
  859. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  860. Doo::loadModel ( 'verify' );
  861. $verify = new verify ();
  862. Doo::loadModel ( "role" );
  863. $role = new role ();
  864. Doo::loadModel ( 'L_category' );
  865. $lCategory = new L_category ();
  866. Doo::loadModel ( 'receipt' );
  867. $receipt = new receipt ();
  868. $receiptInfo = $receipt->getOne ( array (
  869. 'where' => 'rid=' . $rid,
  870. 'asArray' => true
  871. ) );
  872. $veList = $verify->find ( array (
  873. 'asArray' => true
  874. ) );
  875. foreach ( $veList as $key => $value ) {
  876. $v = json_decode ( $value ['staff'] );
  877. $list = array ();
  878. foreach ( $v as $n => $m ) {
  879. if ($m ['1'] == 'ROLE') {
  880. $roleInfo = $role->getOne ( array (
  881. 'where' => 'rid=' . $m [0],
  882. 'asArray' => true
  883. ) );
  884. $v [$n] [1] = $roleInfo ['name'];
  885. array_push ( $list, $roleInfo ['name'] );
  886. } else {
  887. array_push ( $list, $v [$n] [1] );
  888. }
  889. }
  890. $veList [$key] ['staff'] = implode ( '>', $list );
  891. }
  892. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  893. $data ['receiptInfo'] = $receiptInfo;
  894. $data ['category'] = $lCategory->find ( array (
  895. 'asArray' => true
  896. ) );
  897. $data ['veList'] = $veList;
  898. $data ['memu'] = "receipt";
  899. $data ['staff'] = $this->staff;
  900. $data ['receiptMemu'] = 'saeaBorad';
  901. $data ['verifyId'] = $this->verifyId;
  902. $data ['executeId'] = $this->executeId;
  903. $this->render ( "/admin/saeaLoanEdi", $data );
  904. }
  905. function saeaLoanEdiDo() {
  906. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  907. $agency = $this->get_args ( 'agency' );
  908. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  909. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  910. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  911. // die;
  912. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )) {
  913. Doo::loadModel ( 'receipt' );
  914. Doo::loadModel ( 'receiptDetail' );
  915. Doo::loadModel ( 'accountItem' );
  916. $accountItem = new accountItem ();
  917. $receipt = new receipt ();
  918. Doo::loadModel ( 'loanReceipt' );
  919. $loanReceipt = new loanReceipt ();
  920. Doo::loadModel ( 'enclosur' );
  921. Doo::loadModel ( 'execute' );
  922. $execute = new execute ();
  923. $executeDetail = $execute->getOne ( array (
  924. 'where' => 'mold="借款执行人"',
  925. 'asArray' => true
  926. ) );
  927. $receiptDetail = $receipt->getOne ( array (
  928. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  929. 'asArray' => true
  930. ) );
  931. if (empty ( $receiptDetail ))
  932. die ( '参数错误' );
  933. $aItem = $accountItem->find ( array (
  934. 'asArray' => true
  935. ) );
  936. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  937. $ag = $tr = $ta = $ot = 0;
  938. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  939. array_push ( $accountJson ['借款费用'], array (
  940. 'aid' => 0,
  941. 'name' => '申请金额',
  942. 'price' => number_format ( $agency, 2, '.', '' )
  943. ) );
  944. $sum += $agency;
  945. $agencySum += $agency;
  946. $accountJson ['cSum'] = array (
  947. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  948. 'agencySum' => number_format ( 0, 2, '.', '' ),
  949. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  950. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  951. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  952. );
  953. // 报销单
  954. $receipt->loanItem = json_encode ( $accountJson );
  955. $receipt->sum = number_format ( $sum, 2, '.', '' );
  956. $receipt->cid = $cid;
  957. // 特殊状态
  958. // 修改审批流程加入角色
  959. if ($receiptDetail ['status'] != 4)
  960. $receipt->verify = $verify;
  961. $receipt->explanation = $explanation;
  962. $receipt->update ( array (
  963. 'where' => 'rid=' . $rid
  964. ) );
  965. // 借款数据更新
  966. $loanReceipt->loanItem = json_encode ( $accountJson );
  967. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  968. $loanReceipt->cid = $cid;
  969. if ($receiptDetail ['status'] != 4)
  970. $loanReceipt->verify = $verify;
  971. $loanReceipt->explanation = $explanation;
  972. $receipt->executeCopy = $executeDetail ['staff'];
  973. $loanReceipt->update ( array (
  974. 'where' => 'rid=' . $receiptDetail ['loanRid']
  975. ) );
  976. }
  977. return "/saeaBorad";
  978. }
  979. function saeaLoanReceiptAdd() {
  980. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  981. Doo::loadModel ( 'receipt' );
  982. $receipt = new receipt ();
  983. Doo::loadModel ( 'loanReceipt' );
  984. $loanReceipt = new loanReceipt ();
  985. Doo::loadModel ( 'L_category' );
  986. $Lcategory = new L_category ();
  987. Doo::loadModel ( 'verify' );
  988. Doo::loadModel ( 'statistics' );
  989. $statistics = new statistics ();
  990. $verify = new verify ();
  991. Doo::loadModel ( 'staff' );
  992. $staff = new staff ();
  993. $receiptDe = $receipt->getOne ( array (
  994. 'where' => 'rid=' . $rid,
  995. 'desc' => 'rid',
  996. 'asArray' => true
  997. ) );
  998. $receiptList = $loanReceipt->find ( array (
  999. 'where' => 'rid=' . $receiptDe ['loanRid'],
  1000. 'desc' => 'rid',
  1001. 'asArray' => true
  1002. ) );
  1003. $Locate = 0;
  1004. $roleId = 0;
  1005. $button = 0;
  1006. foreach ( $receiptList as $key => $value ) {
  1007. $receiptList [$key] ['Locate'] = $Locate;
  1008. $Locate ++;
  1009. $receiptList [$key] ['reviseDetail'] = array ();
  1010. if (! empty ( $value ['reviseDetail'] ))
  1011. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1012. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1013. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1014. $categoryDetil = $Lcategory->getOne ( array (
  1015. 'where' => 'cid=' . $value ['cid'],
  1016. 'asArray' => true
  1017. ) );
  1018. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1019. // 检测编辑状态
  1020. $verifyList = $verify->getOne ( array (
  1021. 'where' => 'vid=' . $value ['verify'],
  1022. 'asArray' => true
  1023. ) );
  1024. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1025. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1026. Doo::loadModel ( 'role' );
  1027. $role = new role ();
  1028. $flag = true;
  1029. $roleKey = 0;
  1030. $endStaffArray = array ();
  1031. $roleArrayCopy = array ();
  1032. foreach ( $verifyList as $k => $v ) {
  1033. // init verifyStaff
  1034. if ($v [1] == 'ROLE') {
  1035. if (! empty ( $verifyStaff )) {
  1036. $endStaffArray = end ( $verifyStaff );
  1037. // if ($v[0]==$endStaffArray['nextStaff']){
  1038. // $roleId=$v[0];
  1039. // }
  1040. }
  1041. $roleVerify = json_decode ( $v [3], true );
  1042. $roleKey = $k;
  1043. $roleArray = array ();
  1044. $rolename = $role->getOne ( array (
  1045. 'where' => 'rid=' . $v [0],
  1046. 'asArray' => true
  1047. ) );
  1048. foreach ( $roleVerify as $o => $p ) {
  1049. $staffID = explode ( '_', $p );
  1050. $staffInfo = $staff->getOne ( array (
  1051. 'where' => 'sid=' . $staffID [0],
  1052. 'asArray' => true
  1053. ) );
  1054. // print_r($staffID);
  1055. $exp = array (
  1056. 0 => $staffInfo ['sid'],
  1057. 1 => $staffID [1],
  1058. 2 => $staffInfo ['avatar'],
  1059. 'date' => '',
  1060. 'date' => '',
  1061. 'opinion' => '',
  1062. 'status' => '',
  1063. 'rolename' => $rolename ['name']
  1064. );
  1065. array_push ( $roleArray, $exp );
  1066. }
  1067. $roleArrayCopy [$v [0]] = $roleArray;
  1068. // $verifyList[$k]['roleArray']=$roleArray;
  1069. }
  1070. $verifyList [$k] ['date'] = "";
  1071. $verifyList [$k] ['opinion'] = "";
  1072. $verifyList [$k] ['status'] = "";
  1073. if (empty ( $verifyStaff )) {
  1074. $verifyList [$k] ['date'] = "";
  1075. $verifyList [$k] ['opinion'] = "";
  1076. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1077. $verifyList [$k] ['status'] = 4;
  1078. $flag = false;
  1079. }
  1080. } else {
  1081. foreach ( $verifyStaff as $m => $u ) {
  1082. if ($v [0] == $m) {
  1083. $verifyList [$k] ['date'] = $u ['date'];
  1084. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1085. $verifyList [$k] ['status'] = $u ['status'];
  1086. $flag = false;
  1087. break;
  1088. }
  1089. }
  1090. $endStaffArray = end ( $verifyStaff );
  1091. if (isset ( $endStaffArray ['ROLE'] )) {
  1092. } else {
  1093. // $endKey=key($verifyStaff);
  1094. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1095. // $button=4;
  1096. // $verifyList[$k]['status']=4;
  1097. // }
  1098. }
  1099. }
  1100. }
  1101. $rolename ['name'] = '';
  1102. if (! empty ( $roleId )) {
  1103. Doo::loadModel ( 'role' );
  1104. $role = new role ();
  1105. $rolename = $role->getOne ( array (
  1106. 'where' => 'rid=' . $roleId,
  1107. 'asArray' => true
  1108. ) );
  1109. }
  1110. if (! empty ( $verifyStaff ))
  1111. $endStaffArray = end ( $verifyStaff );
  1112. $KOP = false;
  1113. foreach ( $roleArrayCopy as $P => $A ) {
  1114. foreach ( $A as $MKI => $AVL ) {
  1115. if (! empty ( $verifyStaff )) {
  1116. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1117. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1118. $button = 4;
  1119. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1120. }
  1121. foreach ( $verifyStaff as $m => $u ) {
  1122. $AVLFK = $AVL [0] . '_R';
  1123. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1124. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1125. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1126. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1127. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1128. break;
  1129. }
  1130. }
  1131. } else {
  1132. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1133. $button = 4;
  1134. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1135. }
  1136. }
  1137. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1138. $KOP = true;
  1139. }
  1140. }
  1141. foreach ( $roleArrayCopy as $k => $v ) {
  1142. foreach ( $verifyList as $m => $n ) {
  1143. if ($n [0] == $k) {
  1144. array_splice ( $verifyList, $m, 1, $v );
  1145. }
  1146. }
  1147. }
  1148. $receiptList [$key] ['verifyList'] = $verifyList;
  1149. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1150. 'where' => 'sid=' . $value ['staff'],
  1151. 'asArray' => true
  1152. ) );
  1153. $receiptList [$key] ['button'] = $button;
  1154. //
  1155. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1156. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1157. }
  1158. $data ['receiptList'] = $receiptList;
  1159. Doo::loadModel ( 'L_category' );
  1160. $lCategory = new L_category ();
  1161. Doo::loadModel ( 'accountItem' );
  1162. $accountItem = new accountItem ();
  1163. $acItem = $accountItem->find ( array (
  1164. 'asArray' => true
  1165. ) );
  1166. $veList = $verify->find ( array (
  1167. 'asArray' => true
  1168. ) );
  1169. foreach ( $veList as $key => $value ) {
  1170. $v = json_decode ( $value ['staff'] );
  1171. $list = array ();
  1172. foreach ( $v as $n => $m ) {
  1173. if ($m ['1'] == 'ROLE') {
  1174. $roleInfo = $role->getOne ( array (
  1175. 'where' => 'rid=' . $m [0],
  1176. 'asArray' => true
  1177. ) );
  1178. $v [$n] [1] = $roleInfo ['name'];
  1179. array_push ( $list, $roleInfo ['name'] );
  1180. } else {
  1181. array_push ( $list, $v [$n] [1] );
  1182. }
  1183. }
  1184. $veList [$key] ['staff'] = implode ( '>', $list );
  1185. }
  1186. $data ['rid'] = $rid;
  1187. $data ['category'] = $lCategory->find ( array (
  1188. 'asArray' => true
  1189. ) );
  1190. $data ['veList'] = $veList;
  1191. $data ['acItem'] = $acItem;
  1192. $data ['memu'] = "receipt";
  1193. $data ['staff'] = $this->staff;
  1194. $data ['receiptMemu'] = 'saeaBorad';
  1195. $data ['verifyId'] = $this->verifyId;
  1196. $data ['executeId'] = $this->executeId;
  1197. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1198. }
  1199. function saeaLoanReceiptAddDo() {
  1200. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1201. $agency = $this->get_args ( 'agency' );
  1202. $travel = $this->get_args ( 'travel' );
  1203. $train = $this->get_args ( 'train' );
  1204. $other = $this->get_args ( 'other' );
  1205. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1206. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1207. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1208. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1209. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )) {
  1210. Doo::loadModel ( 'receipt' );
  1211. Doo::loadModel ( 'receiptDetail' );
  1212. Doo::loadModel ( 'accountItem' );
  1213. $accountItem = new accountItem ();
  1214. $receipt = new receipt ();
  1215. Doo::loadModel ( 'enclosur' );
  1216. Doo::loadModel ( 'execute' );
  1217. $execute = new execute ();
  1218. $executeDetail = $execute->getOne ( array (
  1219. 'where' => 'mold="借款费用执行人"',
  1220. 'asArray' => true
  1221. ) );
  1222. $receiptDet = $receipt->getOne ( array (
  1223. 'where' => 'rid=' . $rid,
  1224. 'asArray' => true
  1225. ) );
  1226. // if(!empty($receiptDetail))
  1227. // return "/referReceipt/".$receiptDetail['rid'];
  1228. $aItem = $accountItem->find ( array (
  1229. 'asArray' => true
  1230. ) );
  1231. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1232. $ag = $tr = $ta = $ot = 0;
  1233. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1234. foreach ( $aItem as $key => $value ) {
  1235. if ($value ['category'] == $this->AGENCY) {
  1236. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1237. array_push ( $accountJson [$this->AGENCY], array (
  1238. 'aid' => $value ['aid'],
  1239. 'name' => $value ['name'],
  1240. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1241. ) );
  1242. $sum += $agency [$ag];
  1243. $agencySum += $agency [$ag];
  1244. }
  1245. $ag ++;
  1246. }
  1247. if ($value ['category'] == $this->TRAVEL) {
  1248. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1249. array_push ( $accountJson [$this->TRAVEL], array (
  1250. 'aid' => $value ['aid'],
  1251. 'name' => $value ['name'],
  1252. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1253. ) );
  1254. $sum += $travel [$tr];
  1255. $travelSum += $travel [$tr];
  1256. }
  1257. $tr ++;
  1258. }
  1259. if ($value ['category'] == $this->TRAIN) {
  1260. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1261. array_push ( $accountJson [$this->TRAIN], array (
  1262. 'aid' => $value ['aid'],
  1263. 'name' => $value ['name'],
  1264. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1265. ) );
  1266. $sum += $train [$ta];
  1267. $trainSum += $train [$ta];
  1268. }
  1269. $ta ++;
  1270. }
  1271. if ($value ['category'] == $this->OTHER) {
  1272. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1273. array_push ( $accountJson [$this->OTHER], array (
  1274. 'aid' => $value ['aid'],
  1275. 'name' => $value ['name'],
  1276. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1277. ) );
  1278. $sum += $other [$ot];
  1279. $otherSum += $other [$ot];
  1280. }
  1281. $ot ++;
  1282. }
  1283. }
  1284. $accountJson ['cSum'] = array (
  1285. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1286. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1287. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1288. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1289. );
  1290. // 报销单
  1291. $receipt->accountItem = json_encode ( $accountJson );
  1292. $receipt->staff = $this->staff [0] ['sid'];
  1293. $receipt->loanSum = $receiptDet ['sum'];
  1294. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1295. $receipt->date = date ( "Y-m-d" );
  1296. $receipt->pastDate = '';
  1297. $receipt->cid = $cid;
  1298. $receipt->status = 7;
  1299. // 修改审批流程加入角色
  1300. $receipt->verify = $verify;
  1301. $receipt->verifyStaff = '';
  1302. $receipt->executeStaff = '';
  1303. $receipt->executeCopy = $executeDetail ['staff'];
  1304. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  1305. $receipt->explanation = $explanation;
  1306. $receipt->update ( array (
  1307. 'where' => 'rid=' . $rid
  1308. ) );
  1309. // 附件
  1310. if (! empty ( $enclosurName )) {
  1311. $enclosurArray = explode ( '-', $enclosurName );
  1312. foreach ( $enclosurArray as $value ) {
  1313. $enclosur = new enclosur ();
  1314. $enclosur->name = $value;
  1315. $enclosur->rid = $rid;
  1316. $enclosur->insert ();
  1317. }
  1318. // print_r($enclosurArray);die;
  1319. }
  1320. // 报销详情
  1321. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1322. $receiptDetail = new receiptDetail ();
  1323. $receiptDetail->staff = $this->staff [0] ['sid'];
  1324. $receiptDetail->item = $value ['name'];
  1325. $receiptDetail->itemCategory = $this->AGENCY;
  1326. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1327. $receiptDetail->date = date ( "Y-m-d" );
  1328. $receiptDetail->cid = $cid;
  1329. $receiptDetail->rid = $rid;
  1330. $receiptDetail->status = 4;
  1331. $receiptDetail->insert ();
  1332. }
  1333. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1334. $receiptDetail = new receiptDetail ();
  1335. $receiptDetail->staff = $this->staff [0] ['sid'];
  1336. $receiptDetail->item = $value ['name'];
  1337. $receiptDetail->itemCategory = $this->TRAVEL;
  1338. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1339. $receiptDetail->date = date ( "Y-m-d" );
  1340. $receiptDetail->cid = $cid;
  1341. $receiptDetail->rid = $rid;
  1342. $receiptDetail->status = 4;
  1343. $receiptDetail->insert ();
  1344. }
  1345. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1346. $receiptDetail = new receiptDetail ();
  1347. $receiptDetail->staff = $this->staff [0] ['sid'];
  1348. $receiptDetail->item = $value ['name'];
  1349. $receiptDetail->itemCategory = $this->TRAIN;
  1350. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1351. $receiptDetail->date = date ( "Y-m-d" );
  1352. $receiptDetail->cid = $cid;
  1353. $receiptDetail->rid = $rid;
  1354. $receiptDetail->status = 4;
  1355. $receiptDetail->insert ();
  1356. }
  1357. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1358. $receiptDetail = new receiptDetail ();
  1359. $receiptDetail->staff = $this->staff [0] ['sid'];
  1360. $receiptDetail->item = $value ['name'];
  1361. $receiptDetail->itemCategory = $this->OTHER;
  1362. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1363. $receiptDetail->date = date ( "Y-m-d" );
  1364. $receiptDetail->cid = $cid;
  1365. $receiptDetail->rid = $rid;
  1366. $receiptDetail->status = 4;
  1367. $receiptDetail->insert ();
  1368. }
  1369. return "/saeaBorad";
  1370. }
  1371. return "/saeaLoanReceiptAdd/" . $rid;
  1372. }
  1373. function saeaLoanReceiptEdi() {
  1374. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1375. // echo $rid;
  1376. Doo::loadModel ( 'accountItem' );
  1377. Doo::loadModel ( 'verify' );
  1378. Doo::loadModel ( 'receipt' );
  1379. $receipt = new receipt ();
  1380. $verify = new verify ();
  1381. $accountItem = new accountItem ();
  1382. Doo::loadModel ( 'L_category' );
  1383. $Lcategory = new L_category ();
  1384. Doo::loadModel ( "role" );
  1385. $role = new role ();
  1386. Doo::loadModel ( 'loanReceipt' );
  1387. $loanReceipt = new loanReceipt ();
  1388. Doo::loadModel ( 'staff' );
  1389. $staff = new staff ();
  1390. $receiptDetail = $receipt->getOne ( array (
  1391. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  1392. 'asArray' => true
  1393. ) );
  1394. if (empty ( $receiptDetail ))
  1395. return "/saeaBorad";
  1396. $receiptList = $loanReceipt->find ( array (
  1397. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1398. 'desc' => 'rid',
  1399. 'asArray' => true
  1400. ) );
  1401. $Locate = 0;
  1402. $roleId = 0;
  1403. $button = 0;
  1404. foreach ( $receiptList as $key => $value ) {
  1405. $receiptList [$key] ['Locate'] = $Locate;
  1406. $Locate ++;
  1407. $receiptList [$key] ['reviseDetail'] = array ();
  1408. if (! empty ( $value ['reviseDetail'] ))
  1409. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1410. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1411. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1412. $categoryDetil = $Lcategory->getOne ( array (
  1413. 'where' => 'cid=' . $value ['cid'],
  1414. 'asArray' => true
  1415. ) );
  1416. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1417. // 检测编辑状态
  1418. $verifyList = $verify->getOne ( array (
  1419. 'where' => 'vid=' . $value ['verify'],
  1420. 'asArray' => true
  1421. ) );
  1422. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1423. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1424. Doo::loadModel ( 'role' );
  1425. $role = new role ();
  1426. $flag = true;
  1427. $roleKey = 0;
  1428. $endStaffArray = array ();
  1429. $roleArrayCopy = array ();
  1430. foreach ( $verifyList as $k => $v ) {
  1431. // init verifyStaff
  1432. if ($v [1] == 'ROLE') {
  1433. if (! empty ( $verifyStaff )) {
  1434. $endStaffArray = end ( $verifyStaff );
  1435. // if ($v[0]==$endStaffArray['nextStaff']){
  1436. // $roleId=$v[0];
  1437. // }
  1438. }
  1439. $roleVerify = json_decode ( $v [3], true );
  1440. $roleKey = $k;
  1441. $roleArray = array ();
  1442. $rolename = $role->getOne ( array (
  1443. 'where' => 'rid=' . $v [0],
  1444. 'asArray' => true
  1445. ) );
  1446. foreach ( $roleVerify as $o => $p ) {
  1447. $staffID = explode ( '_', $p );
  1448. $staffInfo = $staff->getOne ( array (
  1449. 'where' => 'sid=' . $staffID [0],
  1450. 'asArray' => true
  1451. ) );
  1452. // print_r($staffID);
  1453. $exp = array (
  1454. 0 => $staffInfo ['sid'],
  1455. 1 => $staffID [1],
  1456. 2 => $staffInfo ['avatar'],
  1457. 'date' => '',
  1458. 'date' => '',
  1459. 'opinion' => '',
  1460. 'status' => '',
  1461. 'rolename' => $rolename ['name']
  1462. );
  1463. array_push ( $roleArray, $exp );
  1464. }
  1465. $roleArrayCopy [$v [0]] = $roleArray;
  1466. // $verifyList[$k]['roleArray']=$roleArray;
  1467. }
  1468. $verifyList [$k] ['date'] = "";
  1469. $verifyList [$k] ['opinion'] = "";
  1470. $verifyList [$k] ['status'] = "";
  1471. if (empty ( $verifyStaff )) {
  1472. $verifyList [$k] ['date'] = "";
  1473. $verifyList [$k] ['opinion'] = "";
  1474. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1475. $verifyList [$k] ['status'] = 4;
  1476. $flag = false;
  1477. }
  1478. } else {
  1479. foreach ( $verifyStaff as $m => $u ) {
  1480. if ($v [0] == $m) {
  1481. $verifyList [$k] ['date'] = $u ['date'];
  1482. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1483. $verifyList [$k] ['status'] = $u ['status'];
  1484. $flag = false;
  1485. break;
  1486. }
  1487. }
  1488. $endStaffArray = end ( $verifyStaff );
  1489. if (isset ( $endStaffArray ['ROLE'] )) {
  1490. } else {
  1491. // $endKey=key($verifyStaff);
  1492. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1493. // $button=4;
  1494. // $verifyList[$k]['status']=4;
  1495. // }
  1496. }
  1497. }
  1498. }
  1499. $rolename ['name'] = '';
  1500. if (! empty ( $roleId )) {
  1501. Doo::loadModel ( 'role' );
  1502. $role = new role ();
  1503. $rolename = $role->getOne ( array (
  1504. 'where' => 'rid=' . $roleId,
  1505. 'asArray' => true
  1506. ) );
  1507. }
  1508. if (! empty ( $verifyStaff ))
  1509. $endStaffArray = end ( $verifyStaff );
  1510. $KOP = false;
  1511. foreach ( $roleArrayCopy as $P => $A ) {
  1512. foreach ( $A as $MKI => $AVL ) {
  1513. if (! empty ( $verifyStaff )) {
  1514. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1515. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1516. $button = 4;
  1517. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1518. }
  1519. foreach ( $verifyStaff as $m => $u ) {
  1520. $AVLFK = $AVL [0] . '_R';
  1521. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1522. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1523. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1524. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1525. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1526. break;
  1527. }
  1528. }
  1529. } else {
  1530. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1531. $button = 4;
  1532. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1533. }
  1534. }
  1535. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1536. $KOP = true;
  1537. }
  1538. }
  1539. foreach ( $roleArrayCopy as $k => $v ) {
  1540. foreach ( $verifyList as $m => $n ) {
  1541. if ($n [0] == $k) {
  1542. array_splice ( $verifyList, $m, 1, $v );
  1543. }
  1544. }
  1545. }
  1546. $receiptList [$key] ['verifyList'] = $verifyList;
  1547. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1548. 'where' => 'sid=' . $value ['staff'],
  1549. 'asArray' => true
  1550. ) );
  1551. $receiptList [$key] ['button'] = $button;
  1552. //
  1553. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1554. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1555. }
  1556. $data ['receiptList'] = $receiptList;
  1557. $acItem = $accountItem->find ( array (
  1558. 'asArray' => true
  1559. ) );
  1560. $veList = $verify->find ( array (
  1561. 'asArray' => true
  1562. ) );
  1563. foreach ( $veList as $key => $value ) {
  1564. $v = json_decode ( $value ['staff'] );
  1565. $list = array ();
  1566. foreach ( $v as $n => $m ) {
  1567. if ($m ['1'] == 'ROLE') {
  1568. $roleInfo = $role->getOne ( array (
  1569. 'where' => 'rid=' . $m [0],
  1570. 'asArray' => true
  1571. ) );
  1572. $v [$n] [1] = $roleInfo ['name'];
  1573. array_push ( $list, $roleInfo ['name'] );
  1574. } else {
  1575. array_push ( $list, $v [$n] [1] );
  1576. }
  1577. }
  1578. $veList [$key] ['staff'] = implode ( '>', $list );
  1579. }
  1580. // 配置编辑信息
  1581. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1582. foreach ( $acItem as $key => $value ) {
  1583. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1584. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1585. $acItem [$key] ['price'] = $v ['price'];
  1586. }
  1587. }
  1588. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1589. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1590. $acItem [$key] ['price'] = $v ['price'];
  1591. }
  1592. }
  1593. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1594. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1595. $acItem [$key] ['price'] = $v ['price'];
  1596. }
  1597. }
  1598. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1599. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1600. $acItem [$key] ['price'] = $v ['price'];
  1601. }
  1602. }
  1603. }
  1604. $data ['category'] = $Lcategory->find ( array (
  1605. 'asArray' => true
  1606. ) );
  1607. $data ['cSum'] = $accountItemList ['cSum'];
  1608. $data ['sum'] = $receiptDetail ['sum'];
  1609. $data ['receiptDetail'] = $receiptDetail;
  1610. $data ['veList'] = $veList;
  1611. $data ['acItem'] = $acItem;
  1612. $data ['memu'] = "receipt";
  1613. $data ['staff'] = $this->staff;
  1614. $data ['receiptMemu'] = 'saeaBorad';
  1615. $data ['verify'] = $receiptDetail ['verify'];
  1616. $data ['verifyId'] = $this->verifyId;
  1617. $data ['executeId'] = $this->executeId;
  1618. $data ['rid'] = $rid;
  1619. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  1620. }
  1621. function confirmation() {
  1622. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1623. Doo::loadModel ( 'receipt' );
  1624. Doo::loadModel ( 'receiptDetail' );
  1625. $receipt = new receipt ();
  1626. $receiptDetail = new receiptDetail ();
  1627. Doo::loadModel ( 'statistics' );
  1628. Doo::loadModel ( 'itemStatistics' );
  1629. $statistics = new statistics ();
  1630. $itemStatistics = new itemStatistics ();
  1631. Doo::loadModel ( "verify" );
  1632. $verify = new verify ();
  1633. $receiptDetailList = $receipt->getOne ( array (
  1634. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  1635. 'asArray' => true
  1636. ) );
  1637. if (empty ( $receiptDetailList ))
  1638. return "/saeaBorad";
  1639. $verifyDetail = $verify->getOne ( array (
  1640. 'where' => ' vid =' . $receiptDetailList ['verify'],
  1641. 'asArray' => true
  1642. ) );
  1643. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  1644. if (empty ( $receiptDetailList ['nowStaff'] )) {
  1645. $nowStaff = "";
  1646. $nowStaffList = array ();
  1647. if ($verifyDetail [0] [1] == 'ROLE') {
  1648. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  1649. foreach ( $vStaffString as $key => $value ) {
  1650. $staffK = explode ( "_", $value );
  1651. array_push ( $nowStaffList, $staffK [0] );
  1652. }
  1653. $nowStaff = implode ( ',', $nowStaffList );
  1654. } else {
  1655. $nowStaff = $verifyDetail [0] [0];
  1656. }
  1657. $receipt->nowStaff = $nowStaff;
  1658. }
  1659. // echo $nowStaff;
  1660. // print_r($verifyDetail);die;
  1661. $receipt->rid = $receiptDetailList ['rid'];
  1662. $receipt->status = 2;
  1663. $receipt->update ();
  1664. // 操作日志
  1665. Doo::loadModel ( "receiptLog" );
  1666. $receiptLog = new receiptLog ();
  1667. $verify = new verify ();
  1668. $receiptInfo = $receipt->getOne ( array (
  1669. 'where' => 'rid=' . $rid,
  1670. 'asArray' => true
  1671. ) );
  1672. $vr = $verify->getOne ( array (
  1673. 'where' => 'vid=' . $receiptInfo ['verify'],
  1674. 'asArray' => true
  1675. ) );
  1676. $jd = json_decode ( $vr ['staff'] );
  1677. $roleId = 0;
  1678. foreach ( $jd as $key => $value ) {
  1679. if ($value [1] == 'ROLE') {
  1680. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  1681. if ($pos !== false) {
  1682. $roleId = $value [0];
  1683. }
  1684. }
  1685. }
  1686. // 审批日志
  1687. // echo $roleId;die;
  1688. if (! empty ( $roleId )) {
  1689. Doo::loadModel ( "role" );
  1690. $role = new role ();
  1691. $roleInfo = $role->getOne ( array (
  1692. 'where' => 'rid=' . $roleId,
  1693. 'asArray' => true
  1694. ) );
  1695. $receiptLog->rolename = $roleInfo ['name'];
  1696. }
  1697. $receiptLog->username = $this->staff [0] ['username'];
  1698. $receiptLog->uid = $this->staff [0] ['sid'];
  1699. $receiptLog->date = date ( "Y-m-d" );
  1700. $receiptLog->opinion = '提交审批';
  1701. $receiptLog->img = $this->staff [0] ['avatar'];
  1702. $receiptLog->status = 2;
  1703. $receiptLog->rid = $rid;
  1704. $receiptLog->insert ();
  1705. return "/expenses";
  1706. }
  1707. function expenses() {
  1708. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  1709. if (empty ( $item ))
  1710. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  1711. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1712. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  1713. Doo::loadModel ( 'receipt' );
  1714. $receipt = new receipt ();
  1715. Doo::loadModel ( 'L_category' );
  1716. $Lcategory = new L_category ();
  1717. Doo::loadModel ( 'verify' );
  1718. Doo::loadModel ( 'statistics' );
  1719. $statistics = new statistics ();
  1720. $verify = new verify ();
  1721. Doo::loadModel ( 'staff' );
  1722. $staff = new staff ();
  1723. $condition = "";
  1724. if ($item == "expenses")
  1725. $condition = " and Rtype=1 ";
  1726. elseif ($item == "receipts")
  1727. $condition = " and Rtype=0 ";
  1728. elseif ($item == "remits")
  1729. $condition = " and Rtype=2 ";
  1730. $dateCondition = " and Year(date) =" . $year;
  1731. if (! empty ( $moth )) {
  1732. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  1733. $stList = $statistics->getOne ( array (
  1734. 'select' => 'rePrice ,agPrice',
  1735. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  1736. 'asArray' => true
  1737. ) );
  1738. } else
  1739. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  1740. if (empty ( $stList ))
  1741. $stList = array (
  1742. 'rePrice' => 0,
  1743. 'agPrice' => 0
  1744. );
  1745. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  1746. if (! isset ( $noPassSum ['sum'] ))
  1747. $noPassSum ['sum'] = 0;
  1748. $data ['stList'] = array (
  1749. 'rePrice' => $stList ['rePrice'],
  1750. 'agPrice' => $stList ['agPrice'],
  1751. 'skPrice' => ($noPassSum ['sum'])
  1752. );
  1753. $receiptList = $receipt->find ( array (
  1754. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  1755. 'desc' => 'rid',
  1756. 'asArray' => true
  1757. ) );
  1758. $Locate = 0;
  1759. $roleId = 0;
  1760. $button = 0;
  1761. foreach ( $receiptList as $key => $value ) {
  1762. $receiptList [$key] ['Locate'] = $Locate;
  1763. $Locate ++;
  1764. $receiptList [$key] ['reviseDetail'] = array ();
  1765. if (! empty ( $value ['reviseDetail'] ))
  1766. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1767. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1768. $categoryDetil = $Lcategory->getOne ( array (
  1769. 'where' => 'cid=' . $value ['cid'],
  1770. 'asArray' => true
  1771. ) );
  1772. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1773. // 检测编辑状态
  1774. $verifyList = $verify->getOne ( array (
  1775. 'where' => 'vid=' . $value ['verify'],
  1776. 'asArray' => true
  1777. ) );
  1778. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1779. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1780. Doo::loadModel ( 'role' );
  1781. $role = new role ();
  1782. $flag = true;
  1783. $roleKey = 0;
  1784. $endStaffArray = array ();
  1785. $roleArrayCopy = array ();
  1786. foreach ( $verifyList as $k => $v ) {
  1787. // init verifyStaff
  1788. if ($v [1] == 'ROLE') {
  1789. if (! empty ( $verifyStaff )) {
  1790. $endStaffArray = end ( $verifyStaff );
  1791. // if ($v[0]==$endStaffArray['nextStaff']){
  1792. // $roleId=$v[0];
  1793. // }
  1794. }
  1795. $roleVerify = json_decode ( $v [3], true );
  1796. $roleKey = $k;
  1797. $roleArray = array ();
  1798. $rolename = $role->getOne ( array (
  1799. 'where' => 'rid=' . $v [0],
  1800. 'asArray' => true
  1801. ) );
  1802. foreach ( $roleVerify as $o => $p ) {
  1803. $staffID = explode ( '_', $p );
  1804. $staffInfo = $staff->getOne ( array (
  1805. 'where' => 'sid=' . $staffID [0],
  1806. 'asArray' => true
  1807. ) );
  1808. // print_r($staffID);
  1809. $exp = array (
  1810. 0 => $staffInfo ['sid'],
  1811. 1 => $staffID [1],
  1812. 2 => $staffInfo ['avatar'],
  1813. 'date' => '',
  1814. 'date' => '',
  1815. 'opinion' => '',
  1816. 'status' => '',
  1817. 'rolename' => $rolename ['name']
  1818. );
  1819. array_push ( $roleArray, $exp );
  1820. }
  1821. $roleArrayCopy [$v [0]] = $roleArray;
  1822. // $verifyList[$k]['roleArray']=$roleArray;
  1823. }
  1824. $verifyList [$k] ['date'] = "";
  1825. $verifyList [$k] ['opinion'] = "";
  1826. $verifyList [$k] ['status'] = "";
  1827. if (empty ( $verifyStaff )) {
  1828. $verifyList [$k] ['date'] = "";
  1829. $verifyList [$k] ['opinion'] = "";
  1830. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1831. $verifyList [$k] ['status'] = 4;
  1832. $flag = false;
  1833. }
  1834. } else {
  1835. foreach ( $verifyStaff as $m => $u ) {
  1836. if ($v [0] == $m) {
  1837. $verifyList [$k] ['date'] = $u ['date'];
  1838. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1839. $verifyList [$k] ['status'] = $u ['status'];
  1840. $flag = false;
  1841. break;
  1842. }
  1843. }
  1844. $endStaffArray = end ( $verifyStaff );
  1845. if (isset ( $endStaffArray ['ROLE'] )) {
  1846. } else {
  1847. // $endKey=key($verifyStaff);
  1848. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1849. // $button=4;
  1850. // $verifyList[$k]['status']=4;
  1851. // }
  1852. }
  1853. }
  1854. }
  1855. $rolename ['name'] = '';
  1856. if (! empty ( $roleId )) {
  1857. Doo::loadModel ( 'role' );
  1858. $role = new role ();
  1859. $rolename = $role->getOne ( array (
  1860. 'where' => 'rid=' . $roleId,
  1861. 'asArray' => true
  1862. ) );
  1863. }
  1864. if (! empty ( $verifyStaff ))
  1865. $endStaffArray = end ( $verifyStaff );
  1866. $KOP = false;
  1867. foreach ( $roleArrayCopy as $P => $A ) {
  1868. foreach ( $A as $MKI => $AVL ) {
  1869. if (! empty ( $verifyStaff )) {
  1870. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1871. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1872. $button = 4;
  1873. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1874. }
  1875. foreach ( $verifyStaff as $m => $u ) {
  1876. $AVLFK = $AVL [0] . '_R';
  1877. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1878. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1879. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1880. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1881. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1882. break;
  1883. }
  1884. }
  1885. } else {
  1886. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1887. $button = 4;
  1888. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1889. }
  1890. }
  1891. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1892. $KOP = true;
  1893. }
  1894. }
  1895. foreach ( $roleArrayCopy as $k => $v ) {
  1896. foreach ( $verifyList as $m => $n ) {
  1897. if ($n [0] == $k) {
  1898. array_splice ( $verifyList, $m, 1, $v );
  1899. }
  1900. }
  1901. }
  1902. $receiptList [$key] ['verifyList'] = $verifyList;
  1903. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1904. 'where' => 'sid=' . $value ['staff'],
  1905. 'asArray' => true
  1906. ) );
  1907. $receiptList [$key] ['button'] = $button;
  1908. }
  1909. // print_r($receiptList);die;
  1910. $mothHtml = "";
  1911. for($i = 1; $i <= 12; $i ++) {
  1912. if ($moth == $i)
  1913. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  1914. else
  1915. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  1916. }
  1917. $data ['mothHtml'] = $mothHtml;
  1918. $data ['receiptList'] = $receiptList;
  1919. $data ['memu'] = "receipt";
  1920. $data ['staff'] = $this->staff;
  1921. $data ['receiptMemu'] = 'expenses';
  1922. $data ['verifyId'] = $this->verifyId;
  1923. $data ['executeId'] = $this->executeId;
  1924. $data ['item'] = $item;
  1925. $data ['year'] = $year;
  1926. $this->render ( "/admin/expenses", $data );
  1927. }
  1928. function expensesCollect() {
  1929. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1930. Doo::loadModel ( 'receipt' );
  1931. $receipt = new receipt ();
  1932. Doo::loadModel ( 'L_category' );
  1933. $Lcategory = new L_category ();
  1934. Doo::loadModel ( 'verify' );
  1935. Doo::loadModel ( 'statistics' );
  1936. $statistics = new statistics ();
  1937. $verify = new verify ();
  1938. Doo::loadModel ( 'staff' );
  1939. $staff = new staff ();
  1940. Doo::loadModel ( 'loanReceipt' );
  1941. $loanReceipt = new loanReceipt ();
  1942. $receiptList = $receipt->find ( array (
  1943. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  1944. 'desc' => 'rid',
  1945. 'asArray' => true
  1946. ) );
  1947. $loanList = $loanReceipt->find ( array (
  1948. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  1949. 'desc' => 'rid',
  1950. 'asArray' => true
  1951. ) );
  1952. /*
  1953. * $Locate=0;$roleId=0;$button=0; foreach ($loanList as $key=>$value){ $loanList[$key]['Locate']=$Locate;$Locate++; $loanList[$key]['reviseDetail']=array(); if (!empty($value['reviseDetail'])) $loanList[$key]['reviseDetail']=json_decode($value['reviseDetail'],true); $loanList[$key]['accountItem']=json_decode($value['accountItem'],true); $loanList[$key]['loanItem']=json_decode($value['loanItem'],true); $categoryDetil=$Lcategory->getOne(array('where'=>'cid='.$value['cid'],'asArray'=>true)); $loanList[$key]['category']=$categoryDetil['title']; //检测编辑状态 if ($value['status']==3||$value['status']==1||$value['status']==8||$value['status']==9) $verifyList['staff']=$value['verifyBreakup']; else $verifyList=$verify->getOne(array('where'=>'vid='.$value['verify'],'asArray'=>true)); $verifyList=json_decode($verifyList['staff'],true);//status opinion $verifyStaff=json_decode($value['verifyStaff'],true); Doo::loadModel('role'); $role=new role(); $flag=true;$roleKey=0;$endStaffArray=array();$roleArrayCopy=array(); foreach ($verifyList as $k=>$v){ //init verifyStaff if ($v[1]=='ROLE'){ if (!empty($verifyStaff)){ $endStaffArray=end($verifyStaff); // if ($v[0]==$endStaffArray['nextStaff']){ // $roleId=$v[0]; // } } $roleVerify=json_decode($v[3],true); $roleKey=$k;$roleArray=array(); $rolename=$role->getOne(array('where'=>'rid='.$v[0],'asArray'=>true)); foreach ($roleVerify as $o=>$p){ $staffID=explode ('_',$p); $staffInfo=$staff->getOne(array('where'=>'sid='.$staffID[0],'asArray'=>true)); //print_r($staffID); $exp=array(0=>$staffInfo['sid'],1=>$staffID[1],2=>$staffInfo['avatar'],'date'=>'','date'=>'','opinion'=>'','status'=>'','rolename'=>$rolename['name']); array_push($roleArray, $exp); } $roleArrayCopy[$v[0]]=$roleArray; //$verifyList[$k]['roleArray']=$roleArray; } $verifyList[$k]['date']=""; $verifyList[$k]['opinion']=""; $verifyList[$k]['status']=""; if (empty($verifyStaff)){ $verifyList[$k]['date']=""; $verifyList[$k]['opinion']=""; if (($verifyList[0][0]==$this->staff[0]['sid'])&&$flag){ $verifyList[$k]['status']=4; $flag=false; } }else{ foreach ($verifyStaff as $m=>$u){ if ($v[0]==$m){ $verifyList[$k]['date']=$u['date']; $verifyList[$k]['opinion']=$u['opinion']; $verifyList[$k]['status']=$u['status']; $flag=false; break; } } $endStaffArray=end($verifyStaff); if (isset($endStaffArray['ROLE'])){ }else{ // $endKey=key($verifyStaff); // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){ // $button=4; // $verifyList[$k]['status']=4; // } } } } $rolename['name']=''; if (!empty($roleId)){ Doo::loadModel('role'); $role=new role(); $rolename=$role->getOne(array('where'=>'rid='.$roleId,'asArray'=>true)); } if (!empty($verifyStaff)) $endStaffArray=end($verifyStaff); $KOP=false; foreach ($roleArrayCopy as $P=>$A){ foreach ( $A as $MKI=>$AVL){ if (!empty($verifyStaff)){ //&&$rolename['rid']==$endStaffArray['nextStaff'] if ($this->staff[0]['sid']==$AVL[0]&&isset($endStaffArray['ROLE'])&&$rolename['rid']==$endStaffArray['nextStaff']){ $button=4; $roleArrayCopy[$P][$MKI]['status']=4; } foreach ($verifyStaff as $m=>$u){ $AVLFK=$AVL[0].'_R'; //echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>'; if (strcmp($AVLFK,$m)==0){//&&isset($u['ROLE'])&&$u['ROLE']==1 $roleArrayCopy[$P][$MKI]['date']=$u['date']; $roleArrayCopy[$P][$MKI]['opinion']=$u['opinion']; $roleArrayCopy[$P][$MKI]['status']=$u['status']; break; } } }else{ if ($this->staff[0]['sid']==$AVL[0]&&$verifyList[0][1]=='ROLE'){ $button=4; $roleArrayCopy[$P][$MKI]['status']=4; } } //$roleArray[$MKI]['rolename']=$rolename['name']; $KOP=true; } } foreach ($roleArrayCopy as $k=>$v){ foreach ($verifyList as $m=>$n){ if ($n[0]==$k){ array_splice($verifyList,$m,1,$v); } } } $loanList[$key]['verifyList']=$verifyList; $loanList[$key]['staffDetail']=$staff->getOne(array('where'=>'sid='.$value['staff'],'asArray'=>true)); $loanList[$key]['button']=$button; //$loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']); } $data['loanList']=$loanList;
  1954. */
  1955. $Locate = 0;
  1956. $roleId = 0;
  1957. $button = 0;
  1958. foreach ( $receiptList as $key => $value ) {
  1959. $receiptList [$key] ['Locate'] = $Locate;
  1960. $Locate ++;
  1961. $receiptList [$key] ['reviseDetail'] = array ();
  1962. if (! empty ( $value ['reviseDetail'] ))
  1963. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1964. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1965. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1966. $categoryDetil = $Lcategory->getOne ( array (
  1967. 'where' => 'cid=' . $value ['cid'],
  1968. 'asArray' => true
  1969. ) );
  1970. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1971. // 检测编辑状态
  1972. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  1973. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  1974. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  1975. else
  1976. $verifyList ['staff'] = $value ['verifyBreakup'];
  1977. } else
  1978. $verifyList = $verify->getOne ( array (
  1979. 'where' => 'vid=' . $value ['verify'],
  1980. 'asArray' => true
  1981. ) );
  1982. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1983. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1984. Doo::loadModel ( 'role' );
  1985. $role = new role ();
  1986. $flag = true;
  1987. $roleKey = 0;
  1988. $endStaffArray = array ();
  1989. $roleArrayCopy = array ();
  1990. foreach ( $verifyList as $k => $v ) {
  1991. // init verifyStaff
  1992. if ($v [1] == 'ROLE') {
  1993. if (! empty ( $verifyStaff )) {
  1994. $endStaffArray = end ( $verifyStaff );
  1995. // if ($v[0]==$endStaffArray['nextStaff']){
  1996. // $roleId=$v[0];
  1997. // }
  1998. }
  1999. $roleVerify = json_decode ( $v [3], true );
  2000. $roleKey = $k;
  2001. $roleArray = array ();
  2002. $rolename = $role->getOne ( array (
  2003. 'where' => 'rid=' . $v [0],
  2004. 'asArray' => true
  2005. ) );
  2006. foreach ( $roleVerify as $o => $p ) {
  2007. $staffID = explode ( '_', $p );
  2008. $staffInfo = $staff->getOne ( array (
  2009. 'where' => 'sid=' . $staffID [0],
  2010. 'asArray' => true
  2011. ) );
  2012. // print_r($staffID);
  2013. $exp = array (
  2014. 0 => $staffInfo ['sid'],
  2015. 1 => $staffID [1],
  2016. 2 => $staffInfo ['avatar'],
  2017. 'date' => '',
  2018. 'date' => '',
  2019. 'opinion' => '',
  2020. 'status' => '',
  2021. 'rolename' => $rolename ['name']
  2022. );
  2023. array_push ( $roleArray, $exp );
  2024. }
  2025. $roleArrayCopy [$v [0]] = $roleArray;
  2026. // $verifyList[$k]['roleArray']=$roleArray;
  2027. }
  2028. $verifyList [$k] ['date'] = "";
  2029. $verifyList [$k] ['opinion'] = "";
  2030. $verifyList [$k] ['status'] = "";
  2031. if (empty ( $verifyStaff )) {
  2032. $verifyList [$k] ['date'] = "";
  2033. $verifyList [$k] ['opinion'] = "";
  2034. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2035. $verifyList [$k] ['status'] = 4;
  2036. $flag = false;
  2037. }
  2038. } else {
  2039. foreach ( $verifyStaff as $m => $u ) {
  2040. if ($v [0] == $m) {
  2041. $verifyList [$k] ['date'] = $u ['date'];
  2042. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2043. $verifyList [$k] ['status'] = $u ['status'];
  2044. $flag = false;
  2045. break;
  2046. }
  2047. }
  2048. $endStaffArray = end ( $verifyStaff );
  2049. if (isset ( $endStaffArray ['ROLE'] )) {
  2050. } else {
  2051. // $endKey=key($verifyStaff);
  2052. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2053. // $button=4;
  2054. // $verifyList[$k]['status']=4;
  2055. // }
  2056. }
  2057. }
  2058. }
  2059. $rolename ['name'] = '';
  2060. if (! empty ( $roleId )) {
  2061. Doo::loadModel ( 'role' );
  2062. $role = new role ();
  2063. $rolename = $role->getOne ( array (
  2064. 'where' => 'rid=' . $roleId,
  2065. 'asArray' => true
  2066. ) );
  2067. }
  2068. if (! empty ( $verifyStaff ))
  2069. $endStaffArray = end ( $verifyStaff );
  2070. $KOP = false;
  2071. foreach ( $roleArrayCopy as $P => $A ) {
  2072. foreach ( $A as $MKI => $AVL ) {
  2073. if (! empty ( $verifyStaff )) {
  2074. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2075. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2076. $button = 4;
  2077. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2078. }
  2079. foreach ( $verifyStaff as $m => $u ) {
  2080. $AVLFK = $AVL [0] . '_R';
  2081. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2082. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2083. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2084. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2085. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2086. break;
  2087. }
  2088. }
  2089. } else {
  2090. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2091. $button = 4;
  2092. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2093. }
  2094. }
  2095. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2096. $KOP = true;
  2097. }
  2098. }
  2099. foreach ( $roleArrayCopy as $k => $v ) {
  2100. foreach ( $verifyList as $m => $n ) {
  2101. if ($n [0] == $k) {
  2102. array_splice ( $verifyList, $m, 1, $v );
  2103. }
  2104. }
  2105. }
  2106. // 费用执行人相关数据
  2107. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2108. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2109. foreach ( $executeCopy as $k => $v ) {
  2110. $executeCopy [$k] ['date'] = '';
  2111. $executeCopy [$k] ['opinion'] = '';
  2112. $executeCopy [$k] ['status'] = '';
  2113. if (! empty ( $executeStaff ))
  2114. foreach ( $executeStaff as $m => $u ) {
  2115. if ($v [0] == $m) {
  2116. $executeCopy [$k] ['date'] = $u ['date'];
  2117. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2118. $executeCopy [$k] ['status'] = $u ['status'];
  2119. break;
  2120. }
  2121. }
  2122. }
  2123. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2124. $receiptList [$key] ['verifyList'] = $verifyList;
  2125. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2126. 'where' => 'sid=' . $value ['staff'],
  2127. 'asArray' => true
  2128. ) );
  2129. $receiptList [$key] ['button'] = $button;
  2130. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2131. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2132. $relust = $value ['sum'] - $value ['loanSum'];
  2133. $receiptList [$key] ['relust'] = $relust;
  2134. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2135. }
  2136. Doo::loadModel ( 'enclosur' );
  2137. $enclosur = new enclosur ();
  2138. $enclosurList = $enclosur->find ( array (
  2139. 'where' => 'rid=' . $rid,
  2140. 'asArray' => true
  2141. ) );
  2142. $enclosurHtml = '';
  2143. foreach ( $enclosurList as $value ) {
  2144. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2145. }
  2146. $data ['enclosurHtml'] = $enclosurHtml;
  2147. // print_r($receiptList);
  2148. $data ['receiptList'] = $receiptList;
  2149. $data ['memu'] = "receipt";
  2150. $data ['staff'] = $this->staff;
  2151. $data ['receiptMemu'] = 'expenses';
  2152. $data ['verifyId'] = $this->verifyId;
  2153. $data ['executeId'] = $this->executeId;
  2154. $this->render ( "/admin/expensesCollect", $data );
  2155. }
  2156. function approvalExpenses() {
  2157. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  2158. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2159. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2160. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2161. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2162. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  2163. // echo $rdate;
  2164. if (empty ( $status ))
  2165. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  2166. $page_size = 12;
  2167. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2168. $vidList = array ();
  2169. $button = 0;
  2170. Doo::loadModel ( 'verify' );
  2171. $verify = new verify ();
  2172. Doo::loadModel ( 'receipt' );
  2173. $receipt = new receipt ();
  2174. Doo::loadModel ( 'staff' );
  2175. $staff = new staff ();
  2176. Doo::loadModel ( 'L_category' );
  2177. $Lcategory = new L_category ();
  2178. // user verify ID
  2179. $verifyDetail = $verify->find ( array (
  2180. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  2181. 'asArray' => true
  2182. ) );
  2183. foreach ( $verifyDetail as $key => $value ) {
  2184. array_push ( $vidList, $value ['vid'] );
  2185. }
  2186. $vid = implode ( ",", $vidList );
  2187. if (empty ( $verifyDetail ))
  2188. $vid = 0;
  2189. // if ($status==0)
  2190. // $dateCondition="";
  2191. // else
  2192. $dateCondition = " and Year(date) =" . $year;
  2193. /*
  2194. * if (! empty ( $month )) $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month; if($status == 'done'){ $dateCondition = " and Year(pastDate) =" . $year; if (! empty ( $month )) $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month; }
  2195. */
  2196. // date ( 'Y-m' )
  2197. if (! empty ( $rdate ) && $status == 'done')
  2198. $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  2199. elseif (! empty ( $rdate ))
  2200. $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  2201. $categoryList = $Lcategory->find ( array (
  2202. 'asArray' => true
  2203. ) );
  2204. $staffList = $staff->find ( array (
  2205. 'where' => 'cid=' . $cid,
  2206. 'asArray' => true
  2207. ) );
  2208. $cateCondition = "";
  2209. $staffCondition = "";
  2210. $approvalCondition = "";
  2211. if (! empty ( $cid )) {
  2212. $cateCondition = ' and cid=' . $cid;
  2213. }
  2214. if (! empty ( $sid )) {
  2215. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  2216. $cateCondition = "";
  2217. }
  2218. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  2219. if ($status == 'pendApproval') {
  2220. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  2221. }
  2222. if ($status == 'ongoing') {
  2223. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  2224. }
  2225. if ($status == 'done') {
  2226. $approvalCondition = ' and (status=8 or status=9 ) ';
  2227. }
  2228. if ($status == 'termination') {
  2229. $approvalCondition = " and status=3";
  2230. }
  2231. // $approvalCondition = " and status=" . $status;
  2232. // if ($status == 2) {
  2233. // // 查找角色审批人
  2234. // }
  2235. // if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  2236. // $approvalCondition = ' and status=2 ';
  2237. // }
  2238. // if ($status == 1) {
  2239. // $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  2240. // }
  2241. // if ($status == 8) {
  2242. // $approvalCondition = ' and (status=' . $status . ' or status=9 ) ';
  2243. // }
  2244. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  2245. $pageinfo ['page'] = array (
  2246. 'previous' => ''
  2247. );
  2248. // if ($status == 0) {
  2249. // $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  2250. // $receiptList = $receipt->find ( array (
  2251. // 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ')',
  2252. // 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2253. // 'desc' => 'rid',
  2254. // 'asArray' => true
  2255. // ) );
  2256. // //echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2257. // } else
  2258. if ($status == 'done' || $status == 'termination') {
  2259. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  2260. $receiptList = $receipt->find ( array (
  2261. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
  2262. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2263. 'desc' => 'rid',
  2264. 'asArray' => true
  2265. ) );
  2266. } else
  2267. $receiptList = $receipt->find ( array (
  2268. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
  2269. 'desc' => 'rid',
  2270. 'asArray' => true
  2271. ) );
  2272. $rLRes = $receipt->find ( array (
  2273. '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,
  2274. 'desc' => 'rid',
  2275. 'asArray' => true
  2276. ) );
  2277. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2278. // print_r($pageinfo);
  2279. $Locate = 0;
  2280. $reportList = $reportCateList = array ();
  2281. foreach ( $receiptList as $key => $value ) {
  2282. $receiptList [$key] ['Locate'] = $Locate;
  2283. $Locate ++;
  2284. $receiptList [$key] ['reviseDetail'] = array ();
  2285. if (! empty ( $value ['reviseDetail'] ))
  2286. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2287. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2288. $categoryDetil = $Lcategory->getOne ( array (
  2289. 'where' => 'cid=' . $value ['cid'],
  2290. 'asArray' => true
  2291. ) );
  2292. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2293. $verifyList = $verify->getOne ( array (
  2294. 'where' => 'vid=' . $value ['verify'],
  2295. 'asArray' => true
  2296. ) );
  2297. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2298. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2299. foreach ( $verifyList as $k => $v ) {
  2300. // init verifyStaff
  2301. $verifyList [$k] ['date'] = "";
  2302. $verifyList [$k] ['opinion'] = "";
  2303. $verifyList [$k] ['status'] = "";
  2304. if (empty ( $verifyStaff )) {
  2305. $verifyList [$k] ['date'] = "";
  2306. $verifyList [$k] ['opinion'] = "";
  2307. if ($v [0] == $this->staff [0] ['sid']) {
  2308. $verifyList [$k] ['status'] = 4;
  2309. $button = 4;
  2310. }
  2311. } else {
  2312. $flag = true;
  2313. foreach ( $verifyStaff as $m => $u ) {
  2314. if ($v [0] == $m) {
  2315. $verifyList [$k] ['date'] = $u ['date'];
  2316. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2317. $verifyList [$k] ['status'] = $u ['status'];
  2318. $flag = false;
  2319. break;
  2320. }
  2321. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  2322. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  2323. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  2324. }
  2325. if ($flag) { // 检测可编辑
  2326. if ($v [0] == $this->staff [0] ['sid']) {
  2327. $verifyList [$k] ['status'] = 4;
  2328. $button = 4;
  2329. }
  2330. }
  2331. }
  2332. }
  2333. $receiptList [$key] ['verifyList'] = $verifyList;
  2334. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2335. 'where' => 'sid=' . $value ['staff'],
  2336. 'asArray' => true
  2337. ) );
  2338. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  2339. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  2340. $receiptList [$key] ['button'] = $button;
  2341. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  2342. }
  2343. $reportList = array_unique ( $reportList );
  2344. $reportHtml = '';
  2345. foreach ( $reportList as $key => $value ) {
  2346. $v = explode ( "-", $value );
  2347. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  2348. }
  2349. // print_r($reportList)
  2350. $data ['reportHtml'] = $reportHtml;
  2351. $reportCateList = array_unique ( $reportCateList );
  2352. $reportCateHtml = '';
  2353. foreach ( $reportCateList as $key => $value ) {
  2354. $v = explode ( "-", $value );
  2355. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  2356. }
  2357. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  2358. $data ['reportCateHtml'] = $reportCateHtml;
  2359. // print_r($receiptList);die;
  2360. // $data['verifyDetail']=$verifyDetail;
  2361. $mothHtml = "";
  2362. for($i = 1; $i <= 12; $i ++) {
  2363. if ($month == $i)
  2364. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2365. else
  2366. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2367. }
  2368. $data ['mothHtml'] = $mothHtml;
  2369. $data ['page'] = $pageinfo;
  2370. $data ['receiptList'] = $receiptList;
  2371. $data ['receiptApprovalCount'] = count ( $rLRes );
  2372. $data ['status'] = $status;
  2373. $data ['year'] = $year;
  2374. $data ['categoryList'] = $categoryList;
  2375. $data ['staffList'] = $staffList;
  2376. $data ['cid'] = $cid;
  2377. $data ['sid'] = $sid;
  2378. // print_r($receiptList);
  2379. $data ['memu'] = "receipt";
  2380. $data ['staff'] = $this->staff;
  2381. $data ['receiptMemu'] = 'approvalExpenses';
  2382. $data ['verifyId'] = $this->verifyId;
  2383. $data ['executeId'] = $this->executeId;
  2384. $this->render ( "/admin/approvalExpenses", $data );
  2385. }
  2386. function expensesDoc() {
  2387. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2388. Doo::loadModel ( 'receipt' );
  2389. $receipt = new receipt ();
  2390. Doo::loadModel ( 'L_category' );
  2391. $Lcategory = new L_category ();
  2392. Doo::loadModel ( 'verify' );
  2393. Doo::loadModel ( 'statistics' );
  2394. $statistics = new statistics ();
  2395. $verify = new verify ();
  2396. Doo::loadModel ( 'staff' );
  2397. $staff = new staff ();
  2398. Doo::loadModel ( 'loanReceipt' );
  2399. $loanReceipt = new loanReceipt ();
  2400. $receiptList = $receipt->find ( array (
  2401. 'where' => ' rid=' . $rid,
  2402. 'desc' => 'rid',
  2403. 'asArray' => true
  2404. ) );
  2405. $loanList = array ();
  2406. if (! empty ( $receiptList ))
  2407. $loanList = $loanReceipt->find ( array (
  2408. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2409. 'desc' => 'rid',
  2410. 'asArray' => true
  2411. ) );
  2412. $Locate = 0;
  2413. $roleId = 0;
  2414. $button = 0;
  2415. foreach ( $loanList as $key => $value ) {
  2416. $loanList [$key] ['Locate'] = $Locate;
  2417. $Locate ++;
  2418. $loanList [$key] ['reviseDetail'] = array ();
  2419. if (! empty ( $value ['reviseDetail'] ))
  2420. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2421. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2422. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2423. $categoryDetil = $Lcategory->getOne ( array (
  2424. 'where' => 'cid=' . $value ['cid'],
  2425. 'asArray' => true
  2426. ) );
  2427. $loanList [$key] ['category'] = $categoryDetil ['title'];
  2428. // 检测编辑状态
  2429. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  2430. $verifyList ['staff'] = $value ['verifyBreakup'];
  2431. else
  2432. $verifyList = $verify->getOne ( array (
  2433. 'where' => 'vid=' . $value ['verify'],
  2434. 'asArray' => true
  2435. ) );
  2436. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2437. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2438. Doo::loadModel ( 'role' );
  2439. $role = new role ();
  2440. $flag = true;
  2441. $roleKey = 0;
  2442. $endStaffArray = array ();
  2443. $roleArrayCopy = array ();
  2444. foreach ( $verifyList as $k => $v ) {
  2445. // init verifyStaff
  2446. if ($v [1] == 'ROLE') {
  2447. if (! empty ( $verifyStaff )) {
  2448. $endStaffArray = end ( $verifyStaff );
  2449. // if ($v[0]==$endStaffArray['nextStaff']){
  2450. // $roleId=$v[0];
  2451. // }
  2452. }
  2453. $roleVerify = json_decode ( $v [3], true );
  2454. $roleKey = $k;
  2455. $roleArray = array ();
  2456. $rolename = $role->getOne ( array (
  2457. 'where' => 'rid=' . $v [0],
  2458. 'asArray' => true
  2459. ) );
  2460. foreach ( $roleVerify as $o => $p ) {
  2461. $staffID = explode ( '_', $p );
  2462. $staffInfo = $staff->getOne ( array (
  2463. 'where' => 'sid=' . $staffID [0],
  2464. 'asArray' => true
  2465. ) );
  2466. // print_r($staffID);
  2467. $exp = array (
  2468. 0 => $staffInfo ['sid'],
  2469. 1 => $staffID [1],
  2470. 2 => $staffInfo ['avatar'],
  2471. 'date' => '',
  2472. 'date' => '',
  2473. 'opinion' => '',
  2474. 'status' => '',
  2475. 'rolename' => $rolename ['name']
  2476. );
  2477. array_push ( $roleArray, $exp );
  2478. }
  2479. $roleArrayCopy [$v [0]] = $roleArray;
  2480. // $verifyList[$k]['roleArray']=$roleArray;
  2481. }
  2482. $verifyList [$k] ['date'] = "";
  2483. $verifyList [$k] ['opinion'] = "";
  2484. $verifyList [$k] ['status'] = "";
  2485. if (empty ( $verifyStaff )) {
  2486. $verifyList [$k] ['date'] = "";
  2487. $verifyList [$k] ['opinion'] = "";
  2488. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2489. $verifyList [$k] ['status'] = 4;
  2490. $flag = false;
  2491. }
  2492. } else {
  2493. foreach ( $verifyStaff as $m => $u ) {
  2494. if ($v [0] == $m) {
  2495. $verifyList [$k] ['date'] = $u ['date'];
  2496. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2497. $verifyList [$k] ['status'] = $u ['status'];
  2498. $flag = false;
  2499. break;
  2500. }
  2501. }
  2502. $endStaffArray = end ( $verifyStaff );
  2503. if (isset ( $endStaffArray ['ROLE'] )) {
  2504. } else {
  2505. // $endKey=key($verifyStaff);
  2506. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2507. // $button=4;
  2508. // $verifyList[$k]['status']=4;
  2509. // }
  2510. }
  2511. }
  2512. }
  2513. $rolename ['name'] = '';
  2514. if (! empty ( $roleId )) {
  2515. Doo::loadModel ( 'role' );
  2516. $role = new role ();
  2517. $rolename = $role->getOne ( array (
  2518. 'where' => 'rid=' . $roleId,
  2519. 'asArray' => true
  2520. ) );
  2521. }
  2522. if (! empty ( $verifyStaff ))
  2523. $endStaffArray = end ( $verifyStaff );
  2524. $KOP = false;
  2525. foreach ( $roleArrayCopy as $P => $A ) {
  2526. foreach ( $A as $MKI => $AVL ) {
  2527. if (! empty ( $verifyStaff )) {
  2528. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2529. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2530. $button = 4;
  2531. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2532. }
  2533. foreach ( $verifyStaff as $m => $u ) {
  2534. $AVLFK = $AVL [0] . '_R';
  2535. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2536. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2537. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2538. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2539. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2540. break;
  2541. }
  2542. }
  2543. } else {
  2544. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2545. $button = 4;
  2546. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2547. }
  2548. }
  2549. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2550. $KOP = true;
  2551. }
  2552. }
  2553. foreach ( $roleArrayCopy as $k => $v ) {
  2554. foreach ( $verifyList as $m => $n ) {
  2555. if ($n [0] == $k) {
  2556. array_splice ( $verifyList, $m, 1, $v );
  2557. }
  2558. }
  2559. }
  2560. $loanList [$key] ['verifyList'] = $verifyList;
  2561. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  2562. 'where' => 'sid=' . $value ['staff'],
  2563. 'asArray' => true
  2564. ) );
  2565. $loanList [$key] ['button'] = $button;
  2566. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  2567. }
  2568. $data ['loanList'] = $loanList;
  2569. // print_r($loanList);
  2570. $Locate = 0;
  2571. $roleId = 0;
  2572. $button = 0;
  2573. foreach ( $receiptList as $key => $value ) {
  2574. $receiptList [$key] ['Locate'] = $Locate;
  2575. $Locate ++;
  2576. $receiptList [$key] ['reviseDetail'] = array ();
  2577. if (! empty ( $value ['reviseDetail'] ))
  2578. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2579. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2580. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2581. $categoryDetil = $Lcategory->getOne ( array (
  2582. 'where' => 'cid=' . $value ['cid'],
  2583. 'asArray' => true
  2584. ) );
  2585. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2586. // 检测编辑状态
  2587. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  2588. $verifyList ['staff'] = $value ['verifyBreakup'];
  2589. } else
  2590. $verifyList = $verify->getOne ( array (
  2591. 'where' => 'vid=' . $value ['verify'],
  2592. 'asArray' => true
  2593. ) );
  2594. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2595. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2596. Doo::loadModel ( 'role' );
  2597. $role = new role ();
  2598. if ($verifyList == NULL)
  2599. $verifyList = array ();
  2600. $flag = true;
  2601. $roleKey = 0;
  2602. $endStaffArray = array ();
  2603. $roleArrayCopy = array ();
  2604. foreach ( $verifyList as $k => $v ) {
  2605. // init verifyStaff
  2606. if ($v [1] == 'ROLE') {
  2607. if (! empty ( $verifyStaff )) {
  2608. $endStaffArray = end ( $verifyStaff );
  2609. // if ($v[0]==$endStaffArray['nextStaff']){
  2610. // $roleId=$v[0];
  2611. // }
  2612. }
  2613. $roleVerify = json_decode ( $v [3], true );
  2614. $roleKey = $k;
  2615. $roleArray = array ();
  2616. $rolename = $role->getOne ( array (
  2617. 'where' => 'rid=' . $v [0],
  2618. 'asArray' => true
  2619. ) );
  2620. foreach ( $roleVerify as $o => $p ) {
  2621. $staffID = explode ( '_', $p );
  2622. $staffInfo = $staff->getOne ( array (
  2623. 'where' => 'sid=' . $staffID [0],
  2624. 'asArray' => true
  2625. ) );
  2626. // print_r($staffID);
  2627. $exp = array (
  2628. 0 => $staffInfo ['sid'],
  2629. 1 => $staffID [1],
  2630. 2 => $staffInfo ['avatar'],
  2631. 'date' => '',
  2632. 'date' => '',
  2633. 'opinion' => '',
  2634. 'status' => '',
  2635. 'rolename' => $rolename ['name']
  2636. );
  2637. array_push ( $roleArray, $exp );
  2638. }
  2639. $roleArrayCopy [$v [0]] = $roleArray;
  2640. // $verifyList[$k]['roleArray']=$roleArray;
  2641. }
  2642. $verifyList [$k] ['date'] = "";
  2643. $verifyList [$k] ['opinion'] = "";
  2644. $verifyList [$k] ['status'] = "";
  2645. if (empty ( $verifyStaff )) {
  2646. $verifyList [$k] ['date'] = "";
  2647. $verifyList [$k] ['opinion'] = "";
  2648. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2649. $verifyList [$k] ['status'] = 4;
  2650. $flag = false;
  2651. }
  2652. } else {
  2653. foreach ( $verifyStaff as $m => $u ) {
  2654. if ($v [0] == $m) {
  2655. $verifyList [$k] ['date'] = $u ['date'];
  2656. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2657. $verifyList [$k] ['status'] = $u ['status'];
  2658. $flag = false;
  2659. break;
  2660. }
  2661. }
  2662. $endStaffArray = end ( $verifyStaff );
  2663. if (isset ( $endStaffArray ['ROLE'] )) {
  2664. } else {
  2665. // $endKey=key($verifyStaff);
  2666. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2667. // $button=4;
  2668. // $verifyList[$k]['status']=4;
  2669. // }
  2670. }
  2671. }
  2672. }
  2673. $rolename ['name'] = '';
  2674. if (! empty ( $roleId )) {
  2675. Doo::loadModel ( 'role' );
  2676. $role = new role ();
  2677. $rolename = $role->getOne ( array (
  2678. 'where' => 'rid=' . $roleId,
  2679. 'asArray' => true
  2680. ) );
  2681. }
  2682. if (! empty ( $verifyStaff ))
  2683. $endStaffArray = end ( $verifyStaff );
  2684. $KOP = false;
  2685. foreach ( $roleArrayCopy as $P => $A ) {
  2686. foreach ( $A as $MKI => $AVL ) {
  2687. if (! empty ( $verifyStaff )) {
  2688. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2689. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2690. $button = 4;
  2691. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2692. }
  2693. foreach ( $verifyStaff as $m => $u ) {
  2694. $AVLFK = $AVL [0] . '_R';
  2695. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2696. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2697. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2698. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2699. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2700. break;
  2701. }
  2702. }
  2703. } else {
  2704. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2705. $button = 4;
  2706. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2707. }
  2708. }
  2709. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2710. $KOP = true;
  2711. }
  2712. }
  2713. foreach ( $roleArrayCopy as $k => $v ) {
  2714. foreach ( $verifyList as $m => $n ) {
  2715. if ($n [0] == $k) {
  2716. array_splice ( $verifyList, $m, 1, $v );
  2717. }
  2718. }
  2719. }
  2720. // 费用执行人相关数据
  2721. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2722. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2723. foreach ( $executeCopy as $k => $v ) {
  2724. $executeCopy [$k] ['date'] = '';
  2725. $executeCopy [$k] ['opinion'] = '';
  2726. $executeCopy [$k] ['status'] = '';
  2727. if (! empty ( $executeStaff ))
  2728. foreach ( $executeStaff as $m => $u ) {
  2729. if ($v [0] == $m) {
  2730. $executeCopy [$k] ['date'] = $u ['date'];
  2731. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2732. $executeCopy [$k] ['status'] = $u ['status'];
  2733. break;
  2734. }
  2735. }
  2736. }
  2737. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2738. $receiptList [$key] ['verifyList'] = $verifyList;
  2739. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2740. 'where' => 'sid=' . $value ['staff'],
  2741. 'asArray' => true
  2742. ) );
  2743. $receiptList [$key] ['button'] = $button;
  2744. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2745. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2746. $relust = $value ['sum'] - $value ['loanSum'];
  2747. $receiptList [$key] ['relust'] = $relust;
  2748. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2749. }
  2750. // print_r($receiptList);
  2751. // 获取审批日志
  2752. Doo::loadModel ( 'receiptLog' );
  2753. $receiptLog = new receiptLog ();
  2754. $rlList = array ();
  2755. $rlInfo = $receiptLog->getOne ( array (
  2756. 'where' => 'rid=' . $rid . ' and status=4',
  2757. 'asArray' => true
  2758. ) );
  2759. $tijdate = $receiptLog->getOne ( array (
  2760. 'where' => 'rid=' . $rid . ' and status=2',
  2761. 'asc' => 'rlid',
  2762. 'asArray' => true
  2763. ) );
  2764. if (! empty ( $rlInfo )) {
  2765. $rlList = $receiptLog->find ( array (
  2766. 'where' => 'rid=' . $rid,
  2767. 'asc' => 'rlid',
  2768. 'asArray' => true
  2769. ) );
  2770. }
  2771. Doo::loadModel ( 'enclosur' );
  2772. $enclosur = new enclosur ();
  2773. $enclosurList = $enclosur->find ( array (
  2774. 'where' => 'rid=' . $rid,
  2775. 'asArray' => true
  2776. ) );
  2777. $enclosurHtml = '';
  2778. foreach ( $enclosurList as $value ) {
  2779. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2780. }
  2781. $data ['enclosurHtml'] = $enclosurHtml;
  2782. $receiptList [0] ['rlList'] = $rlList;
  2783. $data ['receiptList'] = $receiptList;
  2784. $data ['memu'] = "receipt";
  2785. $data ['staff'] = $this->staff;
  2786. $data ['receiptMemu'] = 'approvalExpenses';
  2787. $data ['verifyId'] = $this->verifyId;
  2788. $data ['executeId'] = $this->executeId;
  2789. $this->render ( "/admin/expensesDoc", $data );
  2790. }
  2791. function expensesEdi() {
  2792. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2793. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  2794. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2795. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2796. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2797. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2798. if (empty ( $status ))
  2799. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  2800. $vidList = array ();
  2801. $button = 0;
  2802. Doo::loadModel ( 'verify' );
  2803. Doo::loadModel ( 'receipt' );
  2804. Doo::loadModel ( 'staff' );
  2805. $staff = new staff ();
  2806. $receipt = new receipt ();
  2807. $verify = new verify ();
  2808. Doo::loadModel ( 'L_category' );
  2809. $Lcategory = new L_category ();
  2810. Doo::loadModel ( 'enclosur' );
  2811. $enclosur = new enclosur ();
  2812. // user verify ID
  2813. $verifyDetail = $verify->find ( array (
  2814. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  2815. 'asArray' => true
  2816. ) );
  2817. foreach ( $verifyDetail as $key => $value ) {
  2818. array_push ( $vidList, $value ['vid'] );
  2819. }
  2820. $vid = implode ( ",", $vidList );
  2821. if (empty ( $verifyDetail ))
  2822. $vid = 0;
  2823. $categoryList = $Lcategory->find ( array (
  2824. 'asArray' => true
  2825. ) );
  2826. $staffList = $staff->find ( array (
  2827. 'where' => 'cid=' . $cid,
  2828. 'asArray' => true
  2829. ) );
  2830. $ap = "";
  2831. if ($status == 4) {
  2832. $ap = 4;
  2833. $status = 2;
  2834. }
  2835. // get Receipt By verifyID status 2
  2836. $receiptList = $receipt->find ( array (
  2837. 'where' => 'rid =' . $rid . ' and status=2',
  2838. 'desc' => 'rid',
  2839. 'asArray' => true
  2840. ) );
  2841. if (empty ( $receiptList )) {
  2842. die ( 'illegal request' );
  2843. }
  2844. $Locate = 0;
  2845. $roleId = 0;
  2846. if ($ap == 4)
  2847. $status = 4;
  2848. foreach ( $receiptList as $key => $value ) {
  2849. $receiptList [$key] ['Locate'] = $Locate;
  2850. $Locate ++;
  2851. $receiptList [$key] ['reviseDetail'] = array ();
  2852. if (! empty ( $value ['reviseDetail'] ))
  2853. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2854. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2855. $categoryDetil = $Lcategory->getOne ( array (
  2856. 'where' => 'cid=' . $value ['cid'],
  2857. 'asArray' => true
  2858. ) );
  2859. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2860. // 检测编辑状态
  2861. $verifyList = $verify->getOne ( array (
  2862. 'where' => 'vid=' . $value ['verify'],
  2863. 'asArray' => true
  2864. ) );
  2865. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2866. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2867. Doo::loadModel ( 'role' );
  2868. $role = new role ();
  2869. // print_r($verifyList);
  2870. $flag = true;
  2871. $roleKey = 0;
  2872. $endStaffArray = array ();
  2873. $roleArrayCopy = array ();
  2874. foreach ( $verifyList as $k => $v ) {
  2875. // init verifyStaff
  2876. if ($v [1] == 'ROLE') {
  2877. if (! empty ( $verifyStaff )) {
  2878. $endStaffArray = end ( $verifyStaff );
  2879. if ($v [0] == $endStaffArray ['nextStaff']) {
  2880. $roleId = $v [0];
  2881. }
  2882. }
  2883. $roleVerify = json_decode ( $v [3], true );
  2884. $roleKey = $k;
  2885. $roleArray = array ();
  2886. $rolename = $role->getOne ( array (
  2887. 'where' => 'rid=' . $v [0],
  2888. 'asArray' => true
  2889. ) );
  2890. foreach ( $roleVerify as $o => $p ) {
  2891. $staffID = explode ( '_', $p );
  2892. $staffInfo = $staff->getOne ( array (
  2893. 'where' => 'sid=' . $staffID [0],
  2894. 'asArray' => true
  2895. ) );
  2896. // print_r($staffID);
  2897. $exp = array (
  2898. 0 => $staffInfo ['sid'],
  2899. 1 => $staffID [1],
  2900. 2 => $staffInfo ['avatar'],
  2901. 'date' => '',
  2902. 'date' => '',
  2903. 'opinion' => '',
  2904. 'status' => '',
  2905. 'rolename' => $rolename ['name']
  2906. );
  2907. array_push ( $roleArray, $exp );
  2908. }
  2909. $roleArrayCopy [$v [0]] = $roleArray;
  2910. // $verifyList[$k]['roleArray']=$roleArray;
  2911. }
  2912. // print_r($roleArray);
  2913. $verifyList [$k] ['date'] = "";
  2914. $verifyList [$k] ['opinion'] = "";
  2915. $verifyList [$k] ['status'] = "";
  2916. if (empty ( $verifyStaff )) {
  2917. $verifyList [$k] ['date'] = "";
  2918. $verifyList [$k] ['opinion'] = "";
  2919. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2920. $verifyList [$k] ['status'] = 4;
  2921. $button = 4;
  2922. $flag = false;
  2923. }
  2924. } else {
  2925. foreach ( $verifyStaff as $m => $u ) {
  2926. if ($v [0] == $m) {
  2927. $verifyList [$k] ['date'] = $u ['date'];
  2928. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2929. $verifyList [$k] ['status'] = $u ['status'];
  2930. $flag = false;
  2931. break;
  2932. }
  2933. }
  2934. $endStaffArray = end ( $verifyStaff );
  2935. if (isset ( $endStaffArray ['ROLE'] )) {
  2936. } else {
  2937. $endKey = key ( $verifyStaff );
  2938. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  2939. $button = 4;
  2940. $verifyList [$k] ['status'] = 4;
  2941. }
  2942. }
  2943. }
  2944. }
  2945. $rolename ['name'] = '';
  2946. if (! empty ( $roleId )) {
  2947. Doo::loadModel ( 'role' );
  2948. $role = new role ();
  2949. $rolename = $role->getOne ( array (
  2950. 'where' => 'rid=' . $roleId,
  2951. 'asArray' => true
  2952. ) );
  2953. }
  2954. if (! empty ( $verifyStaff ))
  2955. $endStaffArray = end ( $verifyStaff );
  2956. $KOP = false;
  2957. foreach ( $roleArrayCopy as $P => $A ) {
  2958. foreach ( $A as $MKI => $AVL ) {
  2959. if (! empty ( $verifyStaff )) {
  2960. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2961. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2962. $button = 4;
  2963. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2964. }
  2965. foreach ( $verifyStaff as $m => $u ) {
  2966. $AVLFK = $AVL [0] . '_R';
  2967. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2968. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2969. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2970. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2971. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2972. break;
  2973. }
  2974. }
  2975. } else {
  2976. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2977. $button = 4;
  2978. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2979. }
  2980. }
  2981. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2982. $KOP = true;
  2983. }
  2984. }
  2985. // print_r($roleArrayCopy);
  2986. // echo $roleKey;
  2987. foreach ( $roleArrayCopy as $k => $v ) {
  2988. foreach ( $verifyList as $m => $n ) {
  2989. if ($n [0] == $k) {
  2990. array_splice ( $verifyList, $m, 1, $v );
  2991. }
  2992. }
  2993. }
  2994. $receiptList [$key] ['verifyList'] = $verifyList;
  2995. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2996. 'where' => 'sid=' . $value ['staff'],
  2997. 'asArray' => true
  2998. ) );
  2999. $receiptList [$key] ['button'] = $button;
  3000. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  3001. }
  3002. // $data['verifyDetail']=$verifyDetail;
  3003. $mothHtml = "";
  3004. for($i = 1; $i <= 12; $i ++) {
  3005. if ($month == $i)
  3006. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3007. else
  3008. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3009. }
  3010. // 获取审批日志
  3011. Doo::loadModel ( 'receiptLog' );
  3012. $receiptLog = new receiptLog ();
  3013. $rlList = array ();
  3014. $rlInfo = $receiptLog->getOne ( array (
  3015. 'where' => 'rid=' . $rid . ' and status=4',
  3016. 'asArray' => true
  3017. ) );
  3018. $tijdate = $receiptLog->getOne ( array (
  3019. 'where' => 'rid=' . $rid . ' and status=2',
  3020. 'asc' => 'rlid',
  3021. 'asArray' => true
  3022. ) );
  3023. if (! empty ( $rlInfo )) {
  3024. $rlList = $receiptLog->find ( array (
  3025. 'where' => 'rid=' . $rid,
  3026. 'asc' => 'rlid',
  3027. 'asArray' => true
  3028. ) );
  3029. }
  3030. $receiptList [0] ['rlList'] = $rlList;
  3031. $enclosurList = $enclosur->find ( array (
  3032. 'where' => 'rid=' . $rid,
  3033. 'asArray' => true
  3034. ) );
  3035. $enclosurHtml = '';
  3036. foreach ( $enclosurList as $value ) {
  3037. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3038. }
  3039. // print_r($receiptList);
  3040. $data ['rid'] = $rid;
  3041. $data ['enclosurHtml'] = $enclosurHtml;
  3042. $data ['rolename'] = $rolename ['name'];
  3043. $data ['datetij'] = $tijdate ['date'];
  3044. $data ['mothHtml'] = $mothHtml;
  3045. $data ['receiptList'] = $receiptList;
  3046. $data ['receiptApprovalCount'] = count ( $receiptList );
  3047. $data ['status'] = $status;
  3048. $data ['year'] = $year;
  3049. $data ['categoryList'] = $categoryList;
  3050. $data ['staffList'] = $staffList;
  3051. $data ['cid'] = $cid;
  3052. $data ['sid'] = $sid;
  3053. $data ['ap'] = $ap;
  3054. $data ['memu'] = "receipt";
  3055. $data ['staff'] = $this->staff;
  3056. $data ['receiptMemu'] = 'approvalExpenses';
  3057. $data ['verifyId'] = $this->verifyId;
  3058. $data ['executeId'] = $this->executeId;
  3059. $this->render ( "/admin/expensesEdi", $data );
  3060. }
  3061. function expensesDefray() {
  3062. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3063. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3064. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3065. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  3066. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  3067. if (! empty ( $rid )) {
  3068. Doo::loadModel ( "verify" );
  3069. $verify = new verify ();
  3070. Doo::loadModel ( "receiptDetail" );
  3071. $receiptDetailObj = new receiptDetail ();
  3072. Doo::loadModel ( "itemStatistics" );
  3073. Doo::loadModel ( "statistics" );
  3074. $statistics = new statistics ();
  3075. $itemStatistics = new itemStatistics ();
  3076. Doo::loadModel ( "receipt" );
  3077. $receipt = new receipt ();
  3078. Doo::loadModel ( "loanReceipt" );
  3079. $loanReceipt = new loanReceipt ();
  3080. $receiptDetail = $receipt->getOne ( array (
  3081. 'where' => 'rid=' . $rid . ' and status=2 ',
  3082. 'asArray' => true
  3083. ) );
  3084. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  3085. $nsflag = true;
  3086. foreach ( $nslist as $value ) {
  3087. if ($value == $this->staff ['0'] ['sid']) {
  3088. $nsflag = false;
  3089. break;
  3090. }
  3091. }
  3092. // print_r($nslist);die;
  3093. if (empty ( $receiptDetail ) || $nsflag)
  3094. return "/approvalExpenses/pendApproval";
  3095. $verifyDetail = $verify->getOne ( array (
  3096. 'where' => ' vid =' . $receiptDetail ['verify'],
  3097. 'asArray' => true
  3098. ) );
  3099. $verifyString = $verifyDetail ['staff'];
  3100. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3101. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  3102. if (empty ( $opinion )) {
  3103. if ($status == 3)
  3104. $opinion = "终止";
  3105. else
  3106. $opinion = "同意支付";
  3107. }
  3108. $nowStaff = 0;
  3109. $nowStaffList = array ();
  3110. if (empty ( $verifyStaff )) {
  3111. // 还需加入是否已经进入角色审批
  3112. if ($verifyDetail [0] [1] == 'ROLE') {
  3113. // print_r($verifyDetail);echo "ddd";
  3114. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3115. foreach ( $vStaffString as $key => $value ) {
  3116. $staffK = explode ( "_", $value );
  3117. if ($staffK [0] != $this->staff [0] ['sid'])
  3118. array_push ( $nowStaffList, $staffK [0] );
  3119. }
  3120. // print_r($verifyDetail);
  3121. // die;
  3122. if (! empty ( $nowStaffList )) {
  3123. $nowStaff = implode ( ',', $nowStaffList );
  3124. $verifyStaff = array (
  3125. $this->staff [0] ['sid'] . "_R" => array (
  3126. 'date' => date ( 'Y-m-d' ),
  3127. 'opinion' => $opinion,
  3128. 'status' => $status,
  3129. 'nextStaff' => $verifyDetail [0] [0],
  3130. 'ROLE' => 1
  3131. )
  3132. );
  3133. } else {
  3134. $nowStaff = $verifyDetail [1] [0];
  3135. $verifyStaff = array (
  3136. $this->staff [0] ['sid'] . "_R" => array (
  3137. 'date' => date ( 'Y-m-d' ),
  3138. 'opinion' => $opinion,
  3139. 'status' => $status,
  3140. 'nextStaff' => $verifyDetail [1] [0]
  3141. )
  3142. );
  3143. }
  3144. } else {
  3145. if ($verifyDetail [1] [1] == 'ROLE') {
  3146. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  3147. // echo "dd";
  3148. foreach ( $vStaffString as $key => $value ) {
  3149. $staffK = explode ( "_", $value );
  3150. array_push ( $nowStaffList, $staffK [0] );
  3151. }
  3152. $nowStaff = implode ( ',', $nowStaffList );
  3153. $verifyStaff = array (
  3154. $this->staff [0] ['sid'] => array (
  3155. 'date' => date ( 'Y-m-d' ),
  3156. 'opinion' => $opinion,
  3157. 'status' => $status,
  3158. 'nextStaff' => $verifyDetail [1] [0],
  3159. 'ROLE' => 1
  3160. )
  3161. );
  3162. } else {
  3163. $nowStaff = $verifyDetail [1] [0];
  3164. $verifyStaff = array (
  3165. $this->staff [0] ['sid'] => array (
  3166. 'date' => date ( 'Y-m-d' ),
  3167. 'opinion' => $opinion,
  3168. 'status' => $status,
  3169. 'nextStaff' => $verifyDetail [1] [0]
  3170. )
  3171. );
  3172. }
  3173. }
  3174. if ($status == 3)
  3175. $verifyStaff = array (
  3176. 'final' => $status,
  3177. $this->staff [0] ['sid'] => array (
  3178. 'date' => date ( 'Y-m-d' ),
  3179. 'opinion' => $opinion,
  3180. 'status' => $status
  3181. )
  3182. );
  3183. $vStaffString = json_encode ( $verifyStaff );
  3184. $receipt->nowStaff = $nowStaff;
  3185. $receipt->verifyStaff = $vStaffString;
  3186. $loanReceipt->nowStaff = $nowStaff;
  3187. $loanReceipt->verifyStaff = $vStaffString;
  3188. } else {
  3189. $VS = end ( $verifyStaff );
  3190. // 非角色审批
  3191. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  3192. $nextStaff = 0;
  3193. $roleSTF = false;
  3194. foreach ( $verifyDetail as $key => $value ) {
  3195. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  3196. if (isset ( $verifyDetail [$key + 1] )) {
  3197. $nextStaff = $verifyDetail [$key + 1] [0];
  3198. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  3199. $roleSTF = true;
  3200. }
  3201. break;
  3202. }
  3203. }
  3204. if (! $roleSTF) {
  3205. $nowStaff = $nextStaff;
  3206. $verifyStaff [$this->staff [0] ['sid']] = array (
  3207. 'date' => date ( 'Y-m-d' ),
  3208. 'opinion' => $opinion,
  3209. 'status' => $status,
  3210. 'nextStaff' => $nextStaff
  3211. );
  3212. } else {
  3213. // 获取角色下的所有用户ID
  3214. $nowStaffList = array ();
  3215. foreach ( $verifyDetail as $vfk ) {
  3216. if ($vfk [1] == 'ROLE') {
  3217. $vStaffString = json_decode ( $vfk [3] );
  3218. foreach ( $vStaffString as $key => $value ) {
  3219. $staffK = explode ( "_", $value );
  3220. array_push ( $nowStaffList, $staffK [0] );
  3221. }
  3222. }
  3223. }
  3224. $nowStaff = implode ( ',', $nowStaffList );
  3225. $verifyStaff [$this->staff [0] ['sid']] = array (
  3226. 'date' => date ( 'Y-m-d' ),
  3227. 'opinion' => $opinion,
  3228. 'status' => $status,
  3229. 'nextStaff' => $nextStaff,
  3230. 'ROLE' => 0
  3231. );
  3232. }
  3233. if ($status == 3) {
  3234. $verifyStaff ['final'] = $status;
  3235. $verifyStaff [$this->staff [0] ['sid']] = array (
  3236. 'date' => date ( 'Y-m-d' ),
  3237. 'opinion' => $opinion,
  3238. 'status' => $status
  3239. );
  3240. }
  3241. $vStaffString = json_encode ( $verifyStaff );
  3242. $receipt->nowStaff = $nowStaff;
  3243. $receipt->verifyStaff = $vStaffString;
  3244. $loanReceipt->nowStaff = $nowStaff;
  3245. $loanReceipt->verifyStaff = $vStaffString;
  3246. }
  3247. // 角色审批
  3248. if (isset ( $VS ['ROLE'] )) {
  3249. // 找出角色人 当前审批角色组
  3250. $verifyJSStaff = array ();
  3251. $nowStaffList2 = array ();
  3252. foreach ( $verifyDetail as $key => $value ) {
  3253. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  3254. $verifyJSStaff = json_decode ( $value [3] );
  3255. foreach ( $verifyJSStaff as $m ) {
  3256. $staffK = explode ( "_", $m );
  3257. array_push ( $nowStaffList2, $staffK [0] );
  3258. }
  3259. // print_r($nowStaffList2);
  3260. }
  3261. }
  3262. $RoleVerifyStaff = array ();
  3263. foreach ( $verifyStaff as $key => $value ) {
  3264. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  3265. foreach ( $nowStaffList2 as $m ) {
  3266. if ($key == $m . "_R")
  3267. $RoleVerifyStaff [$key] = $value;
  3268. }
  3269. }
  3270. }
  3271. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  3272. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  3273. // 下一个审批人ID
  3274. $nextStaff = 0;
  3275. $falg = false;
  3276. foreach ( $verifyDetail as $key => $value ) {
  3277. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  3278. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  3279. $falg = true;
  3280. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  3281. $nowStaffList = array ();
  3282. foreach ( $vStaffString as $v ) {
  3283. $staffK = explode ( "_", $v );
  3284. array_push ( $nowStaffList, $staffK [0] );
  3285. }
  3286. $nowStaff = implode ( ',', $nowStaffList );
  3287. $nextStaff = $verifyDetail [$key + 1] [0];
  3288. } elseif (isset ( $verifyDetail [$key + 1] )) {
  3289. $nextStaff = $verifyDetail [$key + 1] [0];
  3290. $nowStaff = $nextStaff;
  3291. } else
  3292. $nowStaff = '';
  3293. break;
  3294. }
  3295. }
  3296. if ($falg)
  3297. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3298. 'date' => date ( 'Y-m-d' ),
  3299. 'opinion' => $opinion,
  3300. 'status' => $status,
  3301. 'nextStaff' => $nextStaff,
  3302. 'ROLE' => 1
  3303. );
  3304. else
  3305. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3306. 'date' => date ( 'Y-m-d' ),
  3307. 'opinion' => $opinion,
  3308. 'status' => $status,
  3309. 'nextStaff' => $nextStaff
  3310. );
  3311. // print_r($verifyStaff);
  3312. // echo $nowStaff;die;
  3313. } else { // 进入下一个角色或者审批人
  3314. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  3315. //
  3316. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  3317. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3318. 'date' => date ( 'Y-m-d' ),
  3319. 'opinion' => $opinion,
  3320. 'status' => $status,
  3321. 'nextStaff' => $VS ['nextStaff'],
  3322. 'ROLE' => 1
  3323. );
  3324. // print_r($verifyStaff);
  3325. // die;
  3326. }
  3327. if ($status == 3) {
  3328. $verifyStaff ['final'] = $status;
  3329. $verifyStaff [$this->staff [0] ['sid']] = array (
  3330. 'date' => date ( 'Y-m-d' ),
  3331. 'opinion' => $opinion,
  3332. 'status' => $status
  3333. );
  3334. }
  3335. $vStaffString = json_encode ( $verifyStaff );
  3336. $receipt->verifyStaff = $vStaffString;
  3337. $receipt->nowStaff = $nowStaff;
  3338. $loanReceipt->nowStaff = $nowStaff;
  3339. $loanReceipt->verifyStaff = $vStaffString;
  3340. // die;
  3341. // }
  3342. // print_r($verifyStaff);
  3343. // die;
  3344. }
  3345. // print_r($verifyStaff);die;
  3346. }
  3347. // print_r($verifyDetail);
  3348. $roleKey = 0;
  3349. $roleId = 0;
  3350. $verifyDetailCopy = array ();
  3351. foreach ( $verifyDetail as $k => $v ) {
  3352. if ($v [1] == 'ROLE') {
  3353. $roleId = $v [0];
  3354. $roleVerify = json_decode ( $v [3], true );
  3355. $roleKey = $k;
  3356. $roleArray = array ();
  3357. foreach ( $roleVerify as $o => $p ) {
  3358. $staffID = explode ( '_', $p );
  3359. $exp = array (
  3360. 0 => $staffID [0],
  3361. 1 => $staffID [1]
  3362. );
  3363. array_push ( $roleArray, $exp );
  3364. }
  3365. $verifyDetailCopy [$v [0]] = $roleArray;
  3366. }
  3367. }
  3368. // print_r($verifyDetail);
  3369. foreach ( $verifyDetailCopy as $k => $v ) {
  3370. foreach ( $verifyDetail as $m => $n ) {
  3371. if ($n [0] == $k) {
  3372. array_splice ( $verifyDetail, $m, 1, $v );
  3373. }
  3374. }
  3375. }
  3376. // 审批日志
  3377. if (! isset ( $verifyStaff ['final'] )) {
  3378. Doo::loadModel ( "receiptLog" );
  3379. $receiptLog = new receiptLog ();
  3380. if (! empty ( $roleId )) {
  3381. Doo::loadModel ( "role" );
  3382. $role = new role ();
  3383. $roleInfo = $role->getOne ( array (
  3384. 'where' => 'rid=' . $roleId,
  3385. 'asArray' => true
  3386. ) );
  3387. $receiptLog->rolename = $roleInfo ['name'];
  3388. }
  3389. $receiptLog->username = $this->staff [0] ['username'];
  3390. $receiptLog->uid = $this->staff [0] ['sid'];
  3391. $receiptLog->date = date ( "Y-m-d" );
  3392. $receiptLog->opinion = $opinion;
  3393. $receiptLog->img = $this->staff [0] ['avatar'];
  3394. $receiptLog->status = 1;
  3395. $receiptLog->rid = $rid;
  3396. $receiptLog->insert ();
  3397. }
  3398. if (isset ( $verifyStaff ['final'] )) { // rDetail
  3399. $receipt->status = 3;
  3400. $receipt->verifyBreakup = $verifyString;
  3401. $receiptDetailObj->status = 3;
  3402. $receiptDetailObj->update ( array (
  3403. 'where' => 'rid=' . $rid
  3404. ) );
  3405. // 微信企业号通知
  3406. $this->setWXMsg ( $rid, 3 );
  3407. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  3408. $receipt->status = 6;
  3409. $receipt->pastDate = date ( "Y-m-d" );
  3410. $receipt->isBK = 1;
  3411. $loanReceipt->verifyBreakup = $verifyString;
  3412. $loanReceipt->status = 1;
  3413. $loanReceipt->pastDate = date ( "Y-m-d" );
  3414. $loanReceipt->amount = $receiptDetail ['amount'];
  3415. $loanReceipt->update ( array (
  3416. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  3417. ) );
  3418. // 微信企业号通知
  3419. $this->setWXMsg ( $rid, 1 );
  3420. }
  3421. $receipt->amount = $amount;
  3422. $receipt->update ( array (
  3423. 'where' => ' rid = ' . $rid
  3424. ) );
  3425. // 进入下一条审批费用新加需求
  3426. $vidList = array ();
  3427. $verifyDetail = $verify->find ( array (
  3428. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  3429. 'asArray' => true
  3430. ) );
  3431. foreach ( $verifyDetail as $key => $value ) {
  3432. array_push ( $vidList, $value ['vid'] );
  3433. }
  3434. $vid = implode ( ",", $vidList );
  3435. if (empty ( $verifyDetail ))
  3436. $vid = 0;
  3437. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  3438. $receipt=new receipt();
  3439. $rd = $receipt->getOne ( array (
  3440. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  3441. 'asc' => 'rid',
  3442. 'asArray' => true
  3443. ) );
  3444. if (empty ( $rd )) {
  3445. return '/approvalExpenses/pendApproval';
  3446. }
  3447. if ($rd ['Rtype'] == 1) {
  3448. if ($rd ['isBK'] == 1) {
  3449. return '/receiptburEdi/' . $rd ['rid'];
  3450. } else {
  3451. return '/expensesEdi/' . $rd ['rid'];
  3452. }
  3453. } elseif ($rd ['Rtype'] == 2) {
  3454. return '/remitApproval/' . $rd ['rid'];
  3455. } else {
  3456. return '/receiptburEdi/' . $rd ['rid'];
  3457. }
  3458. // return "/approvalExpenses/pendApproval";
  3459. }
  3460. }
  3461. function ajaxExamineExe() {
  3462. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3463. Doo::loadModel ( 'receipt' );
  3464. $receipt = new receipt ();
  3465. Doo::loadClass ( 'XDeode' );
  3466. $XDeode = new XDeode ( 5 );
  3467. if (! empty ( $rid )) {
  3468. $rLRes = $receipt->find ( array (
  3469. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  3470. 'asArray' => true
  3471. ) );
  3472. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  3473. echo json_encode ( array (
  3474. 'status' => 1,
  3475. 'receipt' => $rLRes [0]
  3476. ) );
  3477. die ();
  3478. }
  3479. echo json_encode ( array (
  3480. 'status' => 0,
  3481. 'receipt' => array ()
  3482. ) );
  3483. die ();
  3484. }
  3485. function implement() {
  3486. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3487. Doo::loadClass ( 'XDeode' );
  3488. $XDeode = new XDeode ( 5 );
  3489. Doo::loadModel ( 'receipt' );
  3490. $receipt = new receipt ();
  3491. Doo::loadModel ( 'L_category' );
  3492. $Lcategory = new L_category ();
  3493. Doo::loadModel ( 'verify' );
  3494. $verify = new verify ();
  3495. Doo::loadModel ( 'staff' );
  3496. $staff = new staff ();
  3497. Doo::loadModel ( "execute" );
  3498. $execute = new execute ();
  3499. $rid = $XDeode->decode ( $rid );
  3500. $receiptList = $receipt->find ( array (
  3501. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  3502. 'desc' => 'rid',
  3503. 'asArray' => true
  3504. ) );
  3505. Doo::loadModel ( 'loanReceipt' );
  3506. $loanReceipt = new loanReceipt ();
  3507. // print_r($receiptList);
  3508. $loanList = array ();
  3509. if (! isset ( $receiptList ))
  3510. $loanList = $loanReceipt->find ( array (
  3511. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3512. 'desc' => 'rid',
  3513. 'asArray' => true
  3514. ) );
  3515. $Locate = 0;
  3516. $roleId = 0;
  3517. $button = 0;
  3518. foreach ( $loanList as $key => $value ) {
  3519. $loanList [$key] ['Locate'] = $Locate;
  3520. $Locate ++;
  3521. $loanList [$key] ['reviseDetail'] = array ();
  3522. if (! empty ( $value ['reviseDetail'] ))
  3523. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3524. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3525. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3526. $categoryDetil = $Lcategory->getOne ( array (
  3527. 'where' => 'cid=' . $value ['cid'],
  3528. 'asArray' => true
  3529. ) );
  3530. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3531. // 检测编辑状态
  3532. $verifyList = $verify->getOne ( array (
  3533. 'where' => 'vid=' . $value ['verify'],
  3534. 'asArray' => true
  3535. ) );
  3536. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3537. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3538. Doo::loadModel ( 'role' );
  3539. $role = new role ();
  3540. $flag = true;
  3541. $roleKey = 0;
  3542. $endStaffArray = array ();
  3543. $roleArrayCopy = array ();
  3544. foreach ( $verifyList as $k => $v ) {
  3545. // init verifyStaff
  3546. if ($v [1] == 'ROLE') {
  3547. if (! empty ( $verifyStaff )) {
  3548. $endStaffArray = end ( $verifyStaff );
  3549. // if ($v[0]==$endStaffArray['nextStaff']){
  3550. // $roleId=$v[0];
  3551. // }
  3552. }
  3553. $roleVerify = json_decode ( $v [3], true );
  3554. $roleKey = $k;
  3555. $roleArray = array ();
  3556. $rolename = $role->getOne ( array (
  3557. 'where' => 'rid=' . $v [0],
  3558. 'asArray' => true
  3559. ) );
  3560. foreach ( $roleVerify as $o => $p ) {
  3561. $staffID = explode ( '_', $p );
  3562. $staffInfo = $staff->getOne ( array (
  3563. 'where' => 'sid=' . $staffID [0],
  3564. 'asArray' => true
  3565. ) );
  3566. // print_r($staffID);
  3567. $exp = array (
  3568. 0 => $staffInfo ['sid'],
  3569. 1 => $staffID [1],
  3570. 2 => $staffInfo ['avatar'],
  3571. 'date' => '',
  3572. 'date' => '',
  3573. 'opinion' => '',
  3574. 'status' => '',
  3575. 'rolename' => $rolename ['name']
  3576. );
  3577. array_push ( $roleArray, $exp );
  3578. }
  3579. $roleArrayCopy [$v [0]] = $roleArray;
  3580. // $verifyList[$k]['roleArray']=$roleArray;
  3581. }
  3582. $verifyList [$k] ['date'] = "";
  3583. $verifyList [$k] ['opinion'] = "";
  3584. $verifyList [$k] ['status'] = "";
  3585. if (empty ( $verifyStaff )) {
  3586. $verifyList [$k] ['date'] = "";
  3587. $verifyList [$k] ['opinion'] = "";
  3588. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3589. $verifyList [$k] ['status'] = 4;
  3590. $flag = false;
  3591. }
  3592. } else {
  3593. foreach ( $verifyStaff as $m => $u ) {
  3594. if ($v [0] == $m) {
  3595. $verifyList [$k] ['date'] = $u ['date'];
  3596. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3597. $verifyList [$k] ['status'] = $u ['status'];
  3598. $flag = false;
  3599. break;
  3600. }
  3601. }
  3602. $endStaffArray = end ( $verifyStaff );
  3603. if (isset ( $endStaffArray ['ROLE'] )) {
  3604. } else {
  3605. // $endKey=key($verifyStaff);
  3606. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3607. // $button=4;
  3608. // $verifyList[$k]['status']=4;
  3609. // }
  3610. }
  3611. }
  3612. }
  3613. $rolename ['name'] = '';
  3614. if (! empty ( $roleId )) {
  3615. Doo::loadModel ( 'role' );
  3616. $role = new role ();
  3617. $rolename = $role->getOne ( array (
  3618. 'where' => 'rid=' . $roleId,
  3619. 'asArray' => true
  3620. ) );
  3621. }
  3622. if (! empty ( $verifyStaff ))
  3623. $endStaffArray = end ( $verifyStaff );
  3624. $KOP = false;
  3625. foreach ( $roleArrayCopy as $P => $A ) {
  3626. foreach ( $A as $MKI => $AVL ) {
  3627. if (! empty ( $verifyStaff )) {
  3628. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3629. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3630. $button = 4;
  3631. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3632. }
  3633. foreach ( $verifyStaff as $m => $u ) {
  3634. $AVLFK = $AVL [0] . '_R';
  3635. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3636. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3637. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3638. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3639. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3640. break;
  3641. }
  3642. }
  3643. } else {
  3644. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3645. $button = 4;
  3646. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3647. }
  3648. }
  3649. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3650. $KOP = true;
  3651. }
  3652. }
  3653. foreach ( $roleArrayCopy as $k => $v ) {
  3654. foreach ( $verifyList as $m => $n ) {
  3655. if ($n [0] == $k) {
  3656. array_splice ( $verifyList, $m, 1, $v );
  3657. }
  3658. }
  3659. }
  3660. $loanList [$key] ['verifyList'] = $verifyList;
  3661. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3662. 'where' => 'sid=' . $value ['staff'],
  3663. 'asArray' => true
  3664. ) );
  3665. }
  3666. $data ['loanList'] = $loanList;
  3667. $Locate = 0;
  3668. $roleId = 0;
  3669. $button = 0;
  3670. foreach ( $receiptList as $key => $value ) {
  3671. $button2 = 0;
  3672. $receiptList [$key] ['Locate'] = $Locate;
  3673. $Locate ++;
  3674. $receiptList [$key] ['reviseDetail'] = array ();
  3675. if (! empty ( $value ['reviseDetail'] ))
  3676. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3677. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3678. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3679. $categoryDetil = $Lcategory->getOne ( array (
  3680. 'where' => 'cid=' . $value ['cid'],
  3681. 'asArray' => true
  3682. ) );
  3683. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3684. $executeList = json_decode ( $value ['executeCopy'], true );
  3685. $executeStaff = array ();
  3686. if (! empty ( $value ['executeStaff'] ))
  3687. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3688. if (isset ( $executeList )) {
  3689. foreach ( $executeList as $op => $lo ) {
  3690. $executeList [$op] ['date'] = "";
  3691. $executeList [$op] ['opinion'] = "";
  3692. $executeList [$op] ['status'] = "";
  3693. foreach ( $executeStaff as $m => $u ) {
  3694. if ($lo [0] == $m) {
  3695. $executeList [$op] ['date'] = $u ['date'];
  3696. $executeList [$op] ['opinion'] = $u ['opinion'];
  3697. $executeList [$op] ['status'] = $u ['status'];
  3698. break;
  3699. }
  3700. }
  3701. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  3702. $button2 = 1;
  3703. $executeList [$op] ['status'] = 4;
  3704. }
  3705. }
  3706. }
  3707. // 检测编辑状态
  3708. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3709. $verifyList ['staff'] = $value ['verifyBreakup'];
  3710. } else
  3711. $verifyList = $verify->getOne ( array (
  3712. 'where' => 'vid=' . $value ['verify'],
  3713. 'asArray' => true
  3714. ) );
  3715. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3716. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3717. Doo::loadModel ( 'role' );
  3718. $role = new role ();
  3719. if ($verifyList == NULL)
  3720. $verifyList = array ();
  3721. $flag = true;
  3722. $roleKey = 0;
  3723. $endStaffArray = array ();
  3724. $roleArrayCopy = array ();
  3725. foreach ( $verifyList as $k => $v ) {
  3726. // init verifyStaff
  3727. if ($v [1] == 'ROLE') {
  3728. if (! empty ( $verifyStaff )) {
  3729. $endStaffArray = end ( $verifyStaff );
  3730. // if ($v[0]==$endStaffArray['nextStaff']){
  3731. // $roleId=$v[0];
  3732. // }
  3733. }
  3734. $roleVerify = json_decode ( $v [3], true );
  3735. $roleKey = $k;
  3736. $roleArray = array ();
  3737. $rolename = $role->getOne ( array (
  3738. 'where' => 'rid=' . $v [0],
  3739. 'asArray' => true
  3740. ) );
  3741. foreach ( $roleVerify as $o => $p ) {
  3742. $staffID = explode ( '_', $p );
  3743. $staffInfo = $staff->getOne ( array (
  3744. 'where' => 'sid=' . $staffID [0],
  3745. 'asArray' => true
  3746. ) );
  3747. // print_r($staffID);
  3748. $exp = array (
  3749. 0 => $staffInfo ['sid'],
  3750. 1 => $staffID [1],
  3751. 2 => $staffInfo ['avatar'],
  3752. 'date' => '',
  3753. 'date' => '',
  3754. 'opinion' => '',
  3755. 'status' => '',
  3756. 'rolename' => $rolename ['name']
  3757. );
  3758. array_push ( $roleArray, $exp );
  3759. }
  3760. $roleArrayCopy [$v [0]] = $roleArray;
  3761. // $verifyList[$k]['roleArray']=$roleArray;
  3762. }
  3763. $verifyList [$k] ['date'] = "";
  3764. $verifyList [$k] ['opinion'] = "";
  3765. $verifyList [$k] ['status'] = "";
  3766. if (empty ( $verifyStaff )) {
  3767. $verifyList [$k] ['date'] = "";
  3768. $verifyList [$k] ['opinion'] = "";
  3769. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3770. $verifyList [$k] ['status'] = 4;
  3771. $flag = false;
  3772. }
  3773. } else {
  3774. foreach ( $verifyStaff as $m => $u ) {
  3775. if ($v [0] == $m) {
  3776. $verifyList [$k] ['date'] = $u ['date'];
  3777. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3778. $verifyList [$k] ['status'] = $u ['status'];
  3779. $flag = false;
  3780. break;
  3781. }
  3782. }
  3783. $endStaffArray = end ( $verifyStaff );
  3784. if (isset ( $endStaffArray ['ROLE'] )) {
  3785. } else {
  3786. // $endKey=key($verifyStaff);
  3787. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3788. // $button=4;
  3789. // $verifyList[$k]['status']=4;
  3790. // }
  3791. }
  3792. }
  3793. }
  3794. $rolename ['name'] = '';
  3795. if (! empty ( $roleId )) {
  3796. Doo::loadModel ( 'role' );
  3797. $role = new role ();
  3798. $rolename = $role->getOne ( array (
  3799. 'where' => 'rid=' . $roleId,
  3800. 'asArray' => true
  3801. ) );
  3802. }
  3803. if (! empty ( $verifyStaff ))
  3804. $endStaffArray = end ( $verifyStaff );
  3805. $KOP = false;
  3806. foreach ( $roleArrayCopy as $P => $A ) {
  3807. foreach ( $A as $MKI => $AVL ) {
  3808. if (! empty ( $verifyStaff )) {
  3809. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3810. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3811. $button = 4;
  3812. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3813. }
  3814. foreach ( $verifyStaff as $m => $u ) {
  3815. $AVLFK = $AVL [0] . '_R';
  3816. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3817. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3818. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3819. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3820. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3821. break;
  3822. }
  3823. }
  3824. } else {
  3825. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3826. $button = 4;
  3827. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3828. }
  3829. }
  3830. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3831. $KOP = true;
  3832. }
  3833. }
  3834. foreach ( $roleArrayCopy as $k => $v ) {
  3835. foreach ( $verifyList as $m => $n ) {
  3836. if ($n [0] == $k) {
  3837. array_splice ( $verifyList, $m, 1, $v );
  3838. }
  3839. }
  3840. }
  3841. $receiptList [$key] ['verifyList'] = $verifyList;
  3842. $receiptList [$key] ['executeList'] = $executeList;
  3843. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3844. 'where' => 'sid=' . $value ['staff'],
  3845. 'asArray' => true
  3846. ) );
  3847. $receiptList [$key] ['button2'] = $button2;
  3848. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3849. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3850. $relust = $value ['sum'] - $value ['loanSum'];
  3851. $receiptList [$key] ['relust'] = $relust;
  3852. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  3853. }
  3854. // print_r($receiptList[$key]['executeList']);
  3855. $data ['receiptList'] = $receiptList;
  3856. $data ['memu'] = "receipt";
  3857. $data ['staff'] = $this->staff;
  3858. $data ['receiptMemu'] = 'implement';
  3859. $data ['verifyId'] = $this->verifyId;
  3860. $data ['executeId'] = $this->executeId;
  3861. $this->render ( "/admin/implement", $data );
  3862. }
  3863. function implementDo() {
  3864. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3865. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3866. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  3867. if (! empty ( $rid ) && $amount != '') {
  3868. Doo::loadModel ( 'receipt' );
  3869. $receipt = new receipt ();
  3870. Doo::loadClass ( 'XDeode' );
  3871. $XDeode = new XDeode ( 5 );
  3872. $rinfo = $receipt->getOne ( array (
  3873. 'where' => 'rid=' . $rid,
  3874. 'asArray' => true
  3875. ) );
  3876. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  3877. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  3878. if (empty ( $executeStaff )) {
  3879. $executeStaff = array (
  3880. $this->staff [0] ['sid'] => array (
  3881. 'date' => date ( 'Y-m-d' ),
  3882. 'opinion' => $implementOpinions,
  3883. 'status' => 1
  3884. )
  3885. );
  3886. } else {
  3887. $executeStaff [$this->staff [0] ['sid']] = array (
  3888. 'date' => date ( 'Y-m-d' ),
  3889. 'opinion' => $implementOpinions,
  3890. 'status' => 1
  3891. );
  3892. }
  3893. if (count ( $executeStaff ) == count ( $executeCopy )) {
  3894. $receipt->executeStaff = json_encode ( $executeStaff );
  3895. $receipt->status = 8;
  3896. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  3897. $receipt->status = 9;
  3898. if ($rinfo ['status'] == 6) {
  3899. $receipt->loanDate = date ( "Y-m-d" );
  3900. }
  3901. $receipt->executeDate = date ( "Y-m-d" );
  3902. } else {
  3903. $receipt->executeStaff = json_encode ( $executeStaff );
  3904. }
  3905. $receipt->amount = $amount;
  3906. $receipt->update ( array (
  3907. 'where' => 'rid=' . $rid
  3908. ) );
  3909. }
  3910. $ridKey = $XDeode->encode ( $rid );
  3911. return "/hisImplement";
  3912. // return "/implement/" . $ridKey . ".html";
  3913. }
  3914. function receiptburEdi() {
  3915. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3916. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  3917. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  3918. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  3919. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3920. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  3921. if (empty ( $status ))
  3922. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  3923. $vidList = array ();
  3924. $button = 0;
  3925. Doo::loadModel ( 'verify' );
  3926. Doo::loadModel ( 'receipt' );
  3927. Doo::loadModel ( 'staff' );
  3928. $staff = new staff ();
  3929. $receipt = new receipt ();
  3930. $verify = new verify ();
  3931. Doo::loadModel ( 'L_category' );
  3932. $Lcategory = new L_category ();
  3933. Doo::loadModel ( 'enclosur' );
  3934. $enclosur = new enclosur ();
  3935. Doo::loadModel ( 'loanReceipt' );
  3936. $loanReceipt = new loanReceipt ();
  3937. // user verify ID
  3938. $verifyDetail = $verify->find ( array (
  3939. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  3940. 'asArray' => true
  3941. ) );
  3942. foreach ( $verifyDetail as $key => $value ) {
  3943. array_push ( $vidList, $value ['vid'] );
  3944. }
  3945. $vid = implode ( ",", $vidList );
  3946. if (empty ( $verifyDetail ))
  3947. $vid = 0;
  3948. $categoryList = $Lcategory->find ( array (
  3949. 'asArray' => true
  3950. ) );
  3951. $staffList = $staff->find ( array (
  3952. 'where' => 'cid=' . $cid,
  3953. 'asArray' => true
  3954. ) );
  3955. $ap = "";
  3956. if ($status == 4) {
  3957. $ap = 4;
  3958. $status = 2;
  3959. }
  3960. // get Receipt By verifyID status 2
  3961. $receiptList = $receipt->find ( array (
  3962. 'where' => 'rid =' . $rid . ' and status=2',
  3963. 'desc' => 'rid',
  3964. 'asArray' => true
  3965. ) );
  3966. if (empty ( $receiptList )) {
  3967. die ( 'illegal request' );
  3968. }
  3969. $loanList = $loanReceipt->find ( array (
  3970. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3971. 'desc' => 'rid',
  3972. 'asArray' => true
  3973. ) );
  3974. $Locate = 0;
  3975. $roleId = 0;
  3976. $button = 0;
  3977. foreach ( $loanList as $key => $value ) {
  3978. $loanList [$key] ['Locate'] = $Locate;
  3979. $Locate ++;
  3980. $loanList [$key] ['reviseDetail'] = array ();
  3981. if (! empty ( $value ['reviseDetail'] ))
  3982. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3983. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3984. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3985. $categoryDetil = $Lcategory->getOne ( array (
  3986. 'where' => 'cid=' . $value ['cid'],
  3987. 'asArray' => true
  3988. ) );
  3989. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3990. // 检测编辑状态
  3991. $verifyList = $verify->getOne ( array (
  3992. 'where' => 'vid=' . $value ['verify'],
  3993. 'asArray' => true
  3994. ) );
  3995. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3996. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3997. Doo::loadModel ( 'role' );
  3998. $role = new role ();
  3999. $flag = true;
  4000. $roleKey = 0;
  4001. $endStaffArray = array ();
  4002. $roleArrayCopy = array ();
  4003. foreach ( $verifyList as $k => $v ) {
  4004. // init verifyStaff
  4005. if ($v [1] == 'ROLE') {
  4006. if (! empty ( $verifyStaff )) {
  4007. $endStaffArray = end ( $verifyStaff );
  4008. }
  4009. $roleVerify = json_decode ( $v [3], true );
  4010. $roleKey = $k;
  4011. $roleArray = array ();
  4012. $rolename = $role->getOne ( array (
  4013. 'where' => 'rid=' . $v [0],
  4014. 'asArray' => true
  4015. ) );
  4016. foreach ( $roleVerify as $o => $p ) {
  4017. $staffID = explode ( '_', $p );
  4018. $staffInfo = $staff->getOne ( array (
  4019. 'where' => 'sid=' . $staffID [0],
  4020. 'asArray' => true
  4021. ) );
  4022. // print_r($staffID);
  4023. $exp = array (
  4024. 0 => $staffInfo ['sid'],
  4025. 1 => $staffID [1],
  4026. 2 => $staffInfo ['avatar'],
  4027. 'date' => '',
  4028. 'date' => '',
  4029. 'opinion' => '',
  4030. 'status' => '',
  4031. 'rolename' => $rolename ['name']
  4032. );
  4033. array_push ( $roleArray, $exp );
  4034. }
  4035. $roleArrayCopy [$v [0]] = $roleArray;
  4036. // $verifyList[$k]['roleArray']=$roleArray;
  4037. }
  4038. $verifyList [$k] ['date'] = "";
  4039. $verifyList [$k] ['opinion'] = "";
  4040. $verifyList [$k] ['status'] = "";
  4041. if (empty ( $verifyStaff )) {
  4042. $verifyList [$k] ['date'] = "";
  4043. $verifyList [$k] ['opinion'] = "";
  4044. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4045. $verifyList [$k] ['status'] = 4;
  4046. $flag = false;
  4047. }
  4048. } else {
  4049. foreach ( $verifyStaff as $m => $u ) {
  4050. if ($v [0] == $m) {
  4051. $verifyList [$k] ['date'] = $u ['date'];
  4052. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4053. $verifyList [$k] ['status'] = $u ['status'];
  4054. $flag = false;
  4055. break;
  4056. }
  4057. }
  4058. $endStaffArray = end ( $verifyStaff );
  4059. if (isset ( $endStaffArray ['ROLE'] )) {
  4060. } else {
  4061. }
  4062. }
  4063. }
  4064. $rolename ['name'] = '';
  4065. if (! empty ( $roleId )) {
  4066. Doo::loadModel ( 'role' );
  4067. $role = new role ();
  4068. $rolename = $role->getOne ( array (
  4069. 'where' => 'rid=' . $roleId,
  4070. 'asArray' => true
  4071. ) );
  4072. }
  4073. if (! empty ( $verifyStaff ))
  4074. $endStaffArray = end ( $verifyStaff );
  4075. $KOP = false;
  4076. foreach ( $roleArrayCopy as $P => $A ) {
  4077. foreach ( $A as $MKI => $AVL ) {
  4078. if (! empty ( $verifyStaff )) {
  4079. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4080. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4081. $button = 4;
  4082. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4083. }
  4084. foreach ( $verifyStaff as $m => $u ) {
  4085. $AVLFK = $AVL [0] . '_R';
  4086. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4087. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4088. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4089. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4090. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4091. break;
  4092. }
  4093. }
  4094. } else {
  4095. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4096. $button = 4;
  4097. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4098. }
  4099. }
  4100. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4101. $KOP = true;
  4102. }
  4103. }
  4104. foreach ( $roleArrayCopy as $k => $v ) {
  4105. foreach ( $verifyList as $m => $n ) {
  4106. if ($n [0] == $k) {
  4107. array_splice ( $verifyList, $m, 1, $v );
  4108. }
  4109. }
  4110. }
  4111. $loanList [$key] ['verifyList'] = $verifyList;
  4112. }
  4113. $htmlLoan = '';
  4114. if (isset ( $loanList [0] )) {
  4115. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  4116. if ($value ['status'] == 1)
  4117. $htmlLoan .= '<li class="done" >';
  4118. elseif ($value ['status'] == 3)
  4119. $htmlLoan .= '<li class="undone" >';
  4120. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  4121. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  4122. if (isset ( $value ['rolename'] ))
  4123. $htmlLoan .= $value ['rolename'];
  4124. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  4125. }
  4126. $data ['loanDate'] = $loanList [0] ['date'];
  4127. }
  4128. $data ['htmlLoan'] = $htmlLoan;
  4129. $data ['loanReceiptDate'] = $loanList [0] ['date'];
  4130. // $data ['LoanReceipt']=$loanList[0];
  4131. // print_r($loanList);
  4132. $Locate = 0;
  4133. $roleId = 0;
  4134. $button = 0;
  4135. if ($ap == 4)
  4136. $status = 4;
  4137. foreach ( $receiptList as $key => $value ) {
  4138. $receiptList [$key] ['Locate'] = $Locate;
  4139. $Locate ++;
  4140. $receiptList [$key] ['reviseDetail'] = array ();
  4141. if (! empty ( $value ['reviseDetail'] ))
  4142. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4143. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4144. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4145. $categoryDetil = $Lcategory->getOne ( array (
  4146. 'where' => 'cid=' . $value ['cid'],
  4147. 'asArray' => true
  4148. ) );
  4149. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4150. // 检测编辑状态
  4151. $verifyList = $verify->getOne ( array (
  4152. 'where' => 'vid=' . $value ['verify'],
  4153. 'asArray' => true
  4154. ) );
  4155. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4156. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4157. Doo::loadModel ( 'role' );
  4158. $role = new role ();
  4159. // print_r($verifyList);
  4160. $flag = true;
  4161. $roleKey = 0;
  4162. $endStaffArray = array ();
  4163. $roleArrayCopy = array ();
  4164. foreach ( $verifyList as $k => $v ) {
  4165. // init verifyStaff
  4166. if ($v [1] == 'ROLE') {
  4167. if (! empty ( $verifyStaff )) {
  4168. $endStaffArray = end ( $verifyStaff );
  4169. if ($v [0] == $endStaffArray ['nextStaff']) {
  4170. $roleId = $v [0];
  4171. }
  4172. }
  4173. $roleVerify = json_decode ( $v [3], true );
  4174. $roleKey = $k;
  4175. $roleArray = array ();
  4176. $rolename = $role->getOne ( array (
  4177. 'where' => 'rid=' . $v [0],
  4178. 'asArray' => true
  4179. ) );
  4180. foreach ( $roleVerify as $o => $p ) {
  4181. $staffID = explode ( '_', $p );
  4182. $staffInfo = $staff->getOne ( array (
  4183. 'where' => 'sid=' . $staffID [0],
  4184. 'asArray' => true
  4185. ) );
  4186. // print_r($staffID);
  4187. $exp = array (
  4188. 0 => $staffInfo ['sid'],
  4189. 1 => $staffID [1],
  4190. 2 => $staffInfo ['avatar'],
  4191. 'date' => '',
  4192. 'date' => '',
  4193. 'opinion' => '',
  4194. 'status' => '',
  4195. 'rolename' => $rolename ['name']
  4196. );
  4197. array_push ( $roleArray, $exp );
  4198. }
  4199. $roleArrayCopy [$v [0]] = $roleArray;
  4200. // $verifyList[$k]['roleArray']=$roleArray;
  4201. }
  4202. // print_r($roleArray);
  4203. $verifyList [$k] ['date'] = "";
  4204. $verifyList [$k] ['opinion'] = "";
  4205. $verifyList [$k] ['status'] = "";
  4206. if (empty ( $verifyStaff )) {
  4207. $verifyList [$k] ['date'] = "";
  4208. $verifyList [$k] ['opinion'] = "";
  4209. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4210. $verifyList [$k] ['status'] = 4;
  4211. $button = 4;
  4212. $flag = false;
  4213. }
  4214. } else {
  4215. foreach ( $verifyStaff as $m => $u ) {
  4216. if ($v [0] == $m) {
  4217. $verifyList [$k] ['date'] = $u ['date'];
  4218. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4219. $verifyList [$k] ['status'] = $u ['status'];
  4220. $flag = false;
  4221. break;
  4222. }
  4223. }
  4224. $endStaffArray = end ( $verifyStaff );
  4225. if (isset ( $endStaffArray ['ROLE'] )) {
  4226. } else {
  4227. $endKey = key ( $verifyStaff );
  4228. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4229. $button = 4;
  4230. $verifyList [$k] ['status'] = 4;
  4231. }
  4232. }
  4233. }
  4234. }
  4235. $rolename ['name'] = '';
  4236. if (! empty ( $roleId )) {
  4237. Doo::loadModel ( 'role' );
  4238. $role = new role ();
  4239. $rolename = $role->getOne ( array (
  4240. 'where' => 'rid=' . $roleId,
  4241. 'asArray' => true
  4242. ) );
  4243. }
  4244. if (! empty ( $verifyStaff ))
  4245. $endStaffArray = end ( $verifyStaff );
  4246. $KOP = false;
  4247. foreach ( $roleArrayCopy as $P => $A ) {
  4248. foreach ( $A as $MKI => $AVL ) {
  4249. if (! empty ( $verifyStaff )) {
  4250. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4251. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4252. $button = 4;
  4253. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4254. }
  4255. foreach ( $verifyStaff as $m => $u ) {
  4256. $AVLFK = $AVL [0] . '_R';
  4257. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4258. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4259. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4260. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4261. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4262. break;
  4263. }
  4264. }
  4265. } else {
  4266. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4267. $button = 4;
  4268. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4269. }
  4270. }
  4271. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4272. $KOP = true;
  4273. }
  4274. }
  4275. foreach ( $roleArrayCopy as $k => $v ) {
  4276. foreach ( $verifyList as $m => $n ) {
  4277. if ($n [0] == $k) {
  4278. array_splice ( $verifyList, $m, 1, $v );
  4279. }
  4280. }
  4281. }
  4282. // print_r($verifyList);
  4283. $receiptList [$key] ['verifyList'] = $verifyList;
  4284. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4285. 'where' => 'sid=' . $value ['staff'],
  4286. 'asArray' => true
  4287. ) );
  4288. $receiptList [$key] ['button'] = $button;
  4289. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4290. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4291. $relust = $value ['sum'] - $value ['loanSum'];
  4292. $receiptList [$key] ['relust'] = $relust;
  4293. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4294. }
  4295. // print_r($receiptList);die;
  4296. // $data['verifyDetail']=$verifyDetail;
  4297. $mothHtml = "";
  4298. for($i = 1; $i <= 12; $i ++) {
  4299. if ($month == $i)
  4300. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4301. else
  4302. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4303. }
  4304. // 获取审批日志
  4305. Doo::loadModel ( 'receiptLog' );
  4306. $receiptLog = new receiptLog ();
  4307. $rlList = array ();
  4308. $rlInfo = $receiptLog->getOne ( array (
  4309. 'where' => 'rid=' . $rid . ' and status=4',
  4310. 'asArray' => true
  4311. ) );
  4312. $tijdate = $receiptLog->getOne ( array (
  4313. 'where' => 'rid=' . $rid . ' and status=2',
  4314. 'asc' => 'rlid',
  4315. 'asArray' => true
  4316. ) );
  4317. if (! empty ( $rlInfo )) {
  4318. $rlList = $receiptLog->find ( array (
  4319. 'where' => 'rid=' . $rid,
  4320. 'asc' => 'rlid',
  4321. 'asArray' => true
  4322. ) );
  4323. }
  4324. // echo $rid;
  4325. // print_r($receiptList);
  4326. $receiptList [0] ['rlList'] = $rlList;
  4327. // print_r($receiptList);
  4328. $enclosurList = $enclosur->find ( array (
  4329. 'where' => 'rid=' . $rid,
  4330. 'asArray' => true
  4331. ) );
  4332. $enclosurHtml = '';
  4333. foreach ( $enclosurList as $value ) {
  4334. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4335. }
  4336. $data ['enclosurHtml'] = $enclosurHtml;
  4337. $data ['rolename'] = $rolename ['name'];
  4338. $data ['mothHtml'] = $mothHtml;
  4339. // print_r($receiptList);
  4340. $data ['rid'] = $rid;
  4341. $data ['tijdate'] = $tijdate ['date'];
  4342. $data ['receiptList'] = $receiptList;
  4343. $data ['receiptApprovalCount'] = count ( $receiptList );
  4344. $data ['status'] = $status;
  4345. $data ['year'] = $year;
  4346. $data ['categoryList'] = $categoryList;
  4347. $data ['staffList'] = $staffList;
  4348. $data ['cid'] = $cid;
  4349. $data ['sid'] = $sid;
  4350. $data ['ap'] = $ap;
  4351. $data ['memu'] = "receipt";
  4352. $data ['staff'] = $this->staff;
  4353. $data ['receiptMemu'] = 'approvalExpenses';
  4354. $data ['verifyId'] = $this->verifyId;
  4355. $data ['executeId'] = $this->executeId;
  4356. $this->render ( "/admin/receiptburEdi", $data );
  4357. }
  4358. function hisImplement() {
  4359. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4360. if (empty ( $item ))
  4361. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "pendImplement";
  4362. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  4363. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4364. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  4365. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  4366. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  4367. Doo::loadModel ( 'receipt' );
  4368. $receipt = new receipt ();
  4369. Doo::loadModel ( 'L_category' );
  4370. $Lcategory = new L_category ();
  4371. Doo::loadModel ( 'verify' );
  4372. Doo::loadModel ( 'statistics' );
  4373. $statistics = new statistics ();
  4374. $verify = new verify ();
  4375. Doo::loadModel ( 'staff' );
  4376. $staff = new staff ();
  4377. Doo::loadClass ( 'XDeode' );
  4378. $XDeode = new XDeode ( 5 );
  4379. $condition = "";
  4380. if ($item == "expenses")
  4381. $condition = " and Rtype=1 ";
  4382. elseif ($item == "receipts")
  4383. $condition = " and Rtype=0 ";
  4384. elseif ($item == "remits")
  4385. $condition = " and Rtype=2 ";
  4386. elseif ($item == "pendImplement") {
  4387. $condition = ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  4388. }
  4389. // 'and (executeCopy like "%["' . $this->staff [0] ['sid'] . '"%" and executeStaff not like "%{"' . $this->staff [0] ['sid'] . '"%" )';
  4390. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  4391. $sopString = "";
  4392. if (empty ( $rdate ))
  4393. $dateCondition = " and Year(date) =" . $year;
  4394. else
  4395. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  4396. if ($item == 'teipts') {
  4397. $statusCon = '(status=1 or status=6 )';
  4398. $dateCondition = " and date_format(pastDate,'%Y-%m-%d')='" . $rdate . "' ";
  4399. } elseif ($item == 'alerpts') {
  4400. $statusCon = '(status=8 or status=9 )';
  4401. if (empty ( $rdate ))
  4402. $dateCondition = " and Year(date) =" . $year;
  4403. else
  4404. $dateCondition = " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  4405. }
  4406. /*
  4407. * if ($item == 'teipts') { $statusCon = '(status=1 or status=6 )'; $dateCondition = " and Year(pastDate) =" . $year; if ($moth != 'MONTH') $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth; if ($day != 'DAY') $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth . " and day(pastDate)=" . $day; } elseif ($item == 'alerpts') { $statusCon = '(status=8 or status=9 )'; $dateCondition = " and Year(executeDate) =" . $year; if ($moth != 'MONTH') $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth; if ($day != 'DAY') $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day; }
  4408. */
  4409. if ($sop != 'SOP')
  4410. $sopString = " and staff=" . $sop;
  4411. // $noPassSum=$receipt->receiptByYear($year,$this->staff[0]['sid']); and (status=1 or status=6)
  4412. $receiptList = $receipt->find ( array (
  4413. 'where' => $statusCon . $condition . $dateCondition . $sopString,
  4414. 'desc' => 'rid',
  4415. 'asArray' => true
  4416. ) );
  4417. // 员工筛选
  4418. $receiptList2 = $receipt->find ( array (
  4419. 'where' => $statusCon . $condition . $dateCondition,
  4420. 'desc' => 'rid',
  4421. 'asArray' => true
  4422. ) );
  4423. $sopStaff = array ();
  4424. foreach ( $receiptList2 as $key => $value ) {
  4425. $staffDetail = $staff->getOne ( array (
  4426. 'where' => 'sid=' . $value ['staff'],
  4427. 'asArray' => true
  4428. ) );
  4429. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  4430. }
  4431. $Locate = 0;
  4432. $roleId = 0;
  4433. $button = 0;
  4434. foreach ( $receiptList as $key => $value ) {
  4435. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4436. $receiptList [$key] ['Texe'] = 'false';
  4437. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  4438. $receiptList [$key] ['Texe'] = 'true';
  4439. }
  4440. $receiptList [$key] ['TRexe'] = 'true';
  4441. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  4442. $receiptList [$key] ['TRexe'] = 'false';
  4443. }
  4444. $receiptList [$key] ['Locate'] = $Locate;
  4445. $Locate ++;
  4446. $receiptList [$key] ['reviseDetail'] = array ();
  4447. if (! empty ( $value ['reviseDetail'] ))
  4448. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4449. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4450. $categoryDetil = $Lcategory->getOne ( array (
  4451. 'where' => 'cid=' . $value ['cid'],
  4452. 'asArray' => true
  4453. ) );
  4454. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4455. // 检测编辑状态
  4456. $verifyList = $verify->getOne ( array (
  4457. 'where' => 'vid=' . $value ['verify'],
  4458. 'asArray' => true
  4459. ) );
  4460. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4461. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4462. Doo::loadModel ( 'role' );
  4463. $role = new role ();
  4464. $flag = true;
  4465. $roleKey = 0;
  4466. $endStaffArray = array ();
  4467. $roleArrayCopy = array ();
  4468. foreach ( $verifyList as $k => $v ) {
  4469. // init verifyStaff
  4470. if ($v [1] == 'ROLE') {
  4471. if (! empty ( $verifyStaff )) {
  4472. $endStaffArray = end ( $verifyStaff );
  4473. }
  4474. $roleVerify = json_decode ( $v [3], true );
  4475. $roleKey = $k;
  4476. $roleArray = array ();
  4477. $rolename = $role->getOne ( array (
  4478. 'where' => 'rid=' . $v [0],
  4479. 'asArray' => true
  4480. ) );
  4481. foreach ( $roleVerify as $o => $p ) {
  4482. $staffID = explode ( '_', $p );
  4483. $staffInfo = $staff->getOne ( array (
  4484. 'where' => 'sid=' . $staffID [0],
  4485. 'asArray' => true
  4486. ) );
  4487. $exp = array (
  4488. 0 => $staffInfo ['sid'],
  4489. 1 => $staffID [1],
  4490. 2 => $staffInfo ['avatar'],
  4491. 'date' => '',
  4492. 'date' => '',
  4493. 'opinion' => '',
  4494. 'status' => '',
  4495. 'rolename' => $rolename ['name']
  4496. );
  4497. array_push ( $roleArray, $exp );
  4498. }
  4499. $roleArrayCopy [$v [0]] = $roleArray;
  4500. }
  4501. $verifyList [$k] ['date'] = "";
  4502. $verifyList [$k] ['opinion'] = "";
  4503. $verifyList [$k] ['status'] = "";
  4504. if (empty ( $verifyStaff )) {
  4505. $verifyList [$k] ['date'] = "";
  4506. $verifyList [$k] ['opinion'] = "";
  4507. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4508. $verifyList [$k] ['status'] = 4;
  4509. $flag = false;
  4510. }
  4511. } else {
  4512. foreach ( $verifyStaff as $m => $u ) {
  4513. if ($v [0] == $m) {
  4514. $verifyList [$k] ['date'] = $u ['date'];
  4515. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4516. $verifyList [$k] ['status'] = $u ['status'];
  4517. $flag = false;
  4518. break;
  4519. }
  4520. }
  4521. $endStaffArray = end ( $verifyStaff );
  4522. }
  4523. }
  4524. $rolename ['name'] = '';
  4525. if (! empty ( $roleId )) {
  4526. Doo::loadModel ( 'role' );
  4527. $role = new role ();
  4528. $rolename = $role->getOne ( array (
  4529. 'where' => 'rid=' . $roleId,
  4530. 'asArray' => true
  4531. ) );
  4532. }
  4533. if (! empty ( $verifyStaff ))
  4534. $endStaffArray = end ( $verifyStaff );
  4535. $KOP = false;
  4536. foreach ( $roleArrayCopy as $P => $A ) {
  4537. foreach ( $A as $MKI => $AVL ) {
  4538. if (! empty ( $verifyStaff )) {
  4539. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4540. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4541. $button = 4;
  4542. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4543. }
  4544. foreach ( $verifyStaff as $m => $u ) {
  4545. $AVLFK = $AVL [0] . '_R';
  4546. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4547. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4548. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4549. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4550. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4551. break;
  4552. }
  4553. }
  4554. } else {
  4555. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4556. $button = 4;
  4557. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4558. }
  4559. }
  4560. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4561. $KOP = true;
  4562. }
  4563. }
  4564. foreach ( $roleArrayCopy as $k => $v ) {
  4565. foreach ( $verifyList as $m => $n ) {
  4566. if ($n [0] == $k) {
  4567. array_splice ( $verifyList, $m, 1, $v );
  4568. }
  4569. }
  4570. }
  4571. $receiptList [$key] ['verifyList'] = $verifyList;
  4572. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4573. 'where' => 'sid=' . $value ['staff'],
  4574. 'asArray' => true
  4575. ) );
  4576. $receiptList [$key] ['button'] = $button;
  4577. }
  4578. // print_r($receiptList);
  4579. $mothHtml = "";
  4580. for($i = 1; $i <= 12; $i ++) {
  4581. if ($moth == $i)
  4582. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4583. else
  4584. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4585. }
  4586. $dayHtml = "";
  4587. if ($day != "DAY" || $moth != "MONTH") {
  4588. for($i = 1; $i <= 31; $i ++) {
  4589. if ($day == $i)
  4590. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  4591. else
  4592. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  4593. }
  4594. }
  4595. $sopHtml = "";
  4596. foreach ( $sopStaff as $key => $value ) {
  4597. if ($sop == $key)
  4598. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4599. else
  4600. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4601. }
  4602. $data ['rdate'] = $rdate;
  4603. $data ['sopHtml'] = $sopHtml;
  4604. $data ['dayHtml'] = $dayHtml;
  4605. $data ['mothHtml'] = $mothHtml;
  4606. $data ['receiptList'] = $receiptList;
  4607. $data ['memu'] = "receipt";
  4608. $data ['staff'] = $this->staff;
  4609. $data ['receiptMemu'] = 'implement';
  4610. $data ['verifyId'] = $this->verifyId;
  4611. $data ['executeId'] = $this->executeId;
  4612. $data ['item'] = $item;
  4613. $data ['year'] = $year;
  4614. $data ['moth'] = $moth;
  4615. $data ['day'] = $day;
  4616. $data ['sop'] = $sop;
  4617. $this->render ( "/admin/hisImplement", $data );
  4618. }
  4619. function ajaxExamine() {
  4620. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4621. Doo::loadModel ( 'receipt' );
  4622. $receipt = new receipt ();
  4623. if (! empty ( $rid )) {
  4624. $rLRes = $receipt->find ( array (
  4625. '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,
  4626. 'asArray' => true
  4627. ) );
  4628. echo json_encode ( array (
  4629. 'status' => 1,
  4630. 'receipt' => $rLRes [0]
  4631. ) );
  4632. die ();
  4633. }
  4634. echo json_encode ( array (
  4635. 'status' => 0,
  4636. 'receipt' => array ()
  4637. ) );
  4638. die ();
  4639. }
  4640. /*
  4641. * 废弃
  4642. */
  4643. function myReceipt() {
  4644. // all approval past withdraw
  4645. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4646. if (empty ( $item ))
  4647. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4648. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4649. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  4650. Doo::loadModel ( 'receipt' );
  4651. $receipt = new receipt ();
  4652. // pre-loaded
  4653. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4654. // have cache
  4655. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  4656. if (! empty ( $moth )) // yearPage
  4657. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  4658. $this->showCache ( $path );
  4659. }
  4660. Doo::loadModel ( 'L_category' );
  4661. $Lcategory = new L_category ();
  4662. Doo::loadModel ( 'verify' );
  4663. Doo::loadModel ( 'statistics' );
  4664. $statistics = new statistics ();
  4665. $verify = new verify ();
  4666. Doo::loadModel ( 'staff' );
  4667. $staff = new staff ();
  4668. $condition = " and status!=0 ";
  4669. if ($item == "approval")
  4670. $condition = " and status=2 ";
  4671. elseif ($item == "withdraw")
  4672. $condition = " and status=3 ";
  4673. elseif ($item == "past")
  4674. $condition = " and status=1 ";
  4675. elseif ($item == "whdw")
  4676. $condition = " and status=4 ";
  4677. $dateCondition = " and Year(date) =" . $year;
  4678. if (! empty ( $moth )) {
  4679. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  4680. $stList = $statistics->getOne ( array (
  4681. 'select' => 'rePrice ,agPrice',
  4682. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  4683. 'asArray' => true
  4684. ) );
  4685. } else
  4686. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  4687. if (empty ( $stList ))
  4688. $stList = array (
  4689. 'rePrice' => 0,
  4690. 'agPrice' => 0
  4691. );
  4692. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  4693. $data ['stList'] = array (
  4694. 'rePrice' => $stList ['rePrice'],
  4695. 'agPrice' => $stList ['agPrice'],
  4696. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  4697. );
  4698. $receiptList = $receipt->find ( array (
  4699. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  4700. 'desc' => 'rid',
  4701. 'asArray' => true
  4702. ) );
  4703. $Locate = 0;
  4704. $roleId = 0;
  4705. $button = 0;
  4706. foreach ( $receiptList as $key => $value ) {
  4707. $receiptList [$key] ['Locate'] = $Locate;
  4708. $Locate ++;
  4709. $receiptList [$key] ['reviseDetail'] = array ();
  4710. if (! empty ( $value ['reviseDetail'] ))
  4711. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4712. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4713. $categoryDetil = $Lcategory->getOne ( array (
  4714. 'where' => 'cid=' . $value ['cid'],
  4715. 'asArray' => true
  4716. ) );
  4717. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4718. // 检测编辑状态
  4719. $verifyList = $verify->getOne ( array (
  4720. 'where' => 'vid=' . $value ['verify'],
  4721. 'asArray' => true
  4722. ) );
  4723. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4724. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4725. Doo::loadModel ( 'role' );
  4726. $role = new role ();
  4727. $flag = true;
  4728. $roleKey = 0;
  4729. $endStaffArray = array ();
  4730. $roleArrayCopy = array ();
  4731. foreach ( $verifyList as $k => $v ) {
  4732. // init verifyStaff
  4733. if ($v [1] == 'ROLE') {
  4734. if (! empty ( $verifyStaff )) {
  4735. $endStaffArray = end ( $verifyStaff );
  4736. // if ($v[0]==$endStaffArray['nextStaff']){
  4737. // $roleId=$v[0];
  4738. // }
  4739. }
  4740. $roleVerify = json_decode ( $v [3], true );
  4741. $roleKey = $k;
  4742. $roleArray = array ();
  4743. $rolename = $role->getOne ( array (
  4744. 'where' => 'rid=' . $v [0],
  4745. 'asArray' => true
  4746. ) );
  4747. foreach ( $roleVerify as $o => $p ) {
  4748. $staffID = explode ( '_', $p );
  4749. $staffInfo = $staff->getOne ( array (
  4750. 'where' => 'sid=' . $staffID [0],
  4751. 'asArray' => true
  4752. ) );
  4753. // print_r($staffID);
  4754. $exp = array (
  4755. 0 => $staffInfo ['sid'],
  4756. 1 => $staffID [1],
  4757. 2 => $staffInfo ['avatar'],
  4758. 'date' => '',
  4759. 'date' => '',
  4760. 'opinion' => '',
  4761. 'status' => '',
  4762. 'rolename' => $rolename ['name']
  4763. );
  4764. array_push ( $roleArray, $exp );
  4765. }
  4766. $roleArrayCopy [$v [0]] = $roleArray;
  4767. // $verifyList[$k]['roleArray']=$roleArray;
  4768. }
  4769. $verifyList [$k] ['date'] = "";
  4770. $verifyList [$k] ['opinion'] = "";
  4771. $verifyList [$k] ['status'] = "";
  4772. if (empty ( $verifyStaff )) {
  4773. $verifyList [$k] ['date'] = "";
  4774. $verifyList [$k] ['opinion'] = "";
  4775. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4776. $verifyList [$k] ['status'] = 4;
  4777. $flag = false;
  4778. }
  4779. } else {
  4780. foreach ( $verifyStaff as $m => $u ) {
  4781. if ($v [0] == $m) {
  4782. $verifyList [$k] ['date'] = $u ['date'];
  4783. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4784. $verifyList [$k] ['status'] = $u ['status'];
  4785. $flag = false;
  4786. break;
  4787. }
  4788. }
  4789. $endStaffArray = end ( $verifyStaff );
  4790. if (isset ( $endStaffArray ['ROLE'] )) {
  4791. } else {
  4792. // $endKey=key($verifyStaff);
  4793. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4794. // $button=4;
  4795. // $verifyList[$k]['status']=4;
  4796. // }
  4797. }
  4798. }
  4799. }
  4800. $rolename ['name'] = '';
  4801. if (! empty ( $roleId )) {
  4802. Doo::loadModel ( 'role' );
  4803. $role = new role ();
  4804. $rolename = $role->getOne ( array (
  4805. 'where' => 'rid=' . $roleId,
  4806. 'asArray' => true
  4807. ) );
  4808. }
  4809. if (! empty ( $verifyStaff ))
  4810. $endStaffArray = end ( $verifyStaff );
  4811. $KOP = false;
  4812. foreach ( $roleArrayCopy as $P => $A ) {
  4813. foreach ( $A as $MKI => $AVL ) {
  4814. if (! empty ( $verifyStaff )) {
  4815. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4816. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4817. $button = 4;
  4818. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4819. }
  4820. foreach ( $verifyStaff as $m => $u ) {
  4821. $AVLFK = $AVL [0] . '_R';
  4822. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4823. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4824. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4825. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4826. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4827. break;
  4828. }
  4829. }
  4830. } else {
  4831. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4832. $button = 4;
  4833. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4834. }
  4835. }
  4836. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4837. $KOP = true;
  4838. }
  4839. }
  4840. foreach ( $roleArrayCopy as $k => $v ) {
  4841. foreach ( $verifyList as $m => $n ) {
  4842. if ($n [0] == $k) {
  4843. array_splice ( $verifyList, $m, 1, $v );
  4844. }
  4845. }
  4846. }
  4847. $receiptList [$key] ['verifyList'] = $verifyList;
  4848. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4849. 'where' => 'sid=' . $value ['staff'],
  4850. 'asArray' => true
  4851. ) );
  4852. $receiptList [$key] ['button'] = $button;
  4853. }
  4854. // print_r($receiptList);die;
  4855. $mothHtml = "";
  4856. for($i = 1; $i <= 12; $i ++) {
  4857. if ($moth == $i)
  4858. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4859. else
  4860. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4861. }
  4862. $data ['mothHtml'] = $mothHtml;
  4863. $data ['receiptList'] = $receiptList;
  4864. $data ['memu'] = "receipt";
  4865. $data ['staff'] = $this->staff;
  4866. $data ['receiptMemu'] = 'receipt';
  4867. $data ['verifyId'] = $this->verifyId;
  4868. $data ['executeId'] = $this->executeId;
  4869. $data ['item'] = $item;
  4870. $data ['year'] = $year;
  4871. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4872. // sufficient condition to generate cache
  4873. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  4874. $receiptList = $receipt->find ( array (
  4875. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  4876. 'asArray' => true
  4877. ) );
  4878. if (empty ( $receiptList )) { // generated files
  4879. ob_start ();
  4880. $this->render ( "/admin/saea_myList", $data );
  4881. $this->cacheFile ( $path );
  4882. die ();
  4883. // $content = ob_get_contents();
  4884. // $fp = fopen($path, "w");
  4885. // fwrite($fp, $content);
  4886. // fclose($fp);
  4887. }
  4888. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  4889. $receiptList = $receipt->find ( array (
  4890. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  4891. 'asArray' => true
  4892. ) );
  4893. if (empty ( $receiptList )) { // generated files
  4894. ob_start ();
  4895. $this->render ( "/admin/saea_myList", $data );
  4896. $this->cacheFile ( $path );
  4897. die ();
  4898. }
  4899. }
  4900. }
  4901. $this->render ( "/admin/saea_myList", $data );
  4902. }
  4903. function saeaCreate() {
  4904. Doo::loadModel ( 'accountItem' );
  4905. Doo::loadModel ( 'verify' );
  4906. Doo::loadModel ( 'receipt' );
  4907. Doo::loadModel ( 'L_category' );
  4908. $lCategory = new L_category ();
  4909. $receipt = new receipt ();
  4910. $verify = new verify ();
  4911. $accountItem = new accountItem ();
  4912. Doo::loadModel ( "role" );
  4913. $role = new role ();
  4914. $acItem = $accountItem->find ( array (
  4915. 'asArray' => true
  4916. ) );
  4917. $veList = $verify->find ( array (
  4918. 'asArray' => true
  4919. ) );
  4920. foreach ( $veList as $key => $value ) {
  4921. $v = json_decode ( $value ['staff'] );
  4922. $list = array ();
  4923. foreach ( $v as $n => $m ) {
  4924. if ($m ['1'] == 'ROLE') {
  4925. $roleInfo = $role->getOne ( array (
  4926. 'where' => 'rid=' . $m [0],
  4927. 'asArray' => true
  4928. ) );
  4929. $v [$n] [1] = $roleInfo ['name'];
  4930. array_push ( $list, $roleInfo ['name'] );
  4931. } else {
  4932. array_push ( $list, $v [$n] [1] );
  4933. }
  4934. }
  4935. $veList [$key] ['staff'] = implode ( '>', $list );
  4936. }
  4937. $data ['category'] = $lCategory->find ( array (
  4938. 'asArray' => true
  4939. ) );
  4940. $data ['veList'] = $veList;
  4941. $data ['acItem'] = $acItem;
  4942. $data ['memu'] = "receipt";
  4943. $data ['staff'] = $this->staff;
  4944. $data ['receiptMemu'] = 'saeaBorad';
  4945. $data ['verifyId'] = $this->verifyId;
  4946. $data ['executeId'] = $this->executeId;
  4947. $this->render ( "/admin/saea_create", $data );
  4948. }
  4949. function addReceipt() {
  4950. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  4951. $agency = $this->get_args ( 'agency' );
  4952. $travel = $this->get_args ( 'travel' );
  4953. $train = $this->get_args ( 'train' );
  4954. $other = $this->get_args ( 'other' );
  4955. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  4956. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  4957. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  4958. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  4959. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  4960. Doo::loadModel ( 'receipt' );
  4961. Doo::loadModel ( 'receiptDetail' );
  4962. Doo::loadModel ( 'accountItem' );
  4963. $accountItem = new accountItem ();
  4964. $receipt = new receipt ();
  4965. Doo::loadModel ( 'enclosur' );
  4966. Doo::loadModel ( 'execute' );
  4967. $execute = new execute ();
  4968. $executeDetail = $execute->getOne ( array (
  4969. 'where' => 'mold="报销单执行人"',
  4970. 'asArray' => true
  4971. ) );
  4972. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  4973. // if(!empty($receiptDetail))
  4974. // return "/referReceipt/".$receiptDetail['rid'];
  4975. $aItem = $accountItem->find ( array (
  4976. 'asArray' => true
  4977. ) );
  4978. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  4979. $ag = $tr = $ta = $ot = 0;
  4980. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  4981. foreach ( $aItem as $key => $value ) {
  4982. if ($value ['category'] == $this->AGENCY) {
  4983. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  4984. array_push ( $accountJson [$this->AGENCY], array (
  4985. 'aid' => $value ['aid'],
  4986. 'name' => $value ['name'],
  4987. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  4988. ) );
  4989. $sum += $agency [$ag];
  4990. $agencySum += $agency [$ag];
  4991. }
  4992. $ag ++;
  4993. }
  4994. if ($value ['category'] == $this->TRAVEL) {
  4995. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  4996. array_push ( $accountJson [$this->TRAVEL], array (
  4997. 'aid' => $value ['aid'],
  4998. 'name' => $value ['name'],
  4999. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5000. ) );
  5001. $sum += $travel [$tr];
  5002. $travelSum += $travel [$tr];
  5003. }
  5004. $tr ++;
  5005. }
  5006. if ($value ['category'] == $this->TRAIN) {
  5007. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5008. array_push ( $accountJson [$this->TRAIN], array (
  5009. 'aid' => $value ['aid'],
  5010. 'name' => $value ['name'],
  5011. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5012. ) );
  5013. $sum += $train [$ta];
  5014. $trainSum += $train [$ta];
  5015. }
  5016. $ta ++;
  5017. }
  5018. if ($value ['category'] == $this->OTHER) {
  5019. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5020. array_push ( $accountJson [$this->OTHER], array (
  5021. 'aid' => $value ['aid'],
  5022. 'name' => $value ['name'],
  5023. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5024. ) );
  5025. $sum += $other [$ot];
  5026. $otherSum += $other [$ot];
  5027. }
  5028. $ot ++;
  5029. }
  5030. }
  5031. $accountJson ['cSum'] = array (
  5032. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5033. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5034. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5035. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5036. );
  5037. // 报销单
  5038. $receipt->accountItem = json_encode ( $accountJson );
  5039. $receipt->staff = $this->staff [0] ['sid'];
  5040. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5041. $receipt->date = date ( "Y-m-d" );
  5042. $receipt->cid = $cid;
  5043. $receipt->status = 5;
  5044. // 修改审批流程加入角色
  5045. $receipt->verify = $verify;
  5046. $receipt->executeCopy = $executeDetail ['staff'];
  5047. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  5048. $receipt->explanation = $explanation;
  5049. $rid = $receipt->insert ();
  5050. // 附件
  5051. if (! empty ( $enclosurName )) {
  5052. $enclosurArray = explode ( '-', $enclosurName );
  5053. foreach ( $enclosurArray as $value ) {
  5054. $enclosur = new enclosur ();
  5055. $enclosur->name = $value;
  5056. $enclosur->rid = $rid;
  5057. $enclosur->insert ();
  5058. }
  5059. // print_r($enclosurArray);die;
  5060. }
  5061. // 报销详情
  5062. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5063. $receiptDetail = new receiptDetail ();
  5064. $receiptDetail->staff = $this->staff [0] ['sid'];
  5065. $receiptDetail->item = $value ['name'];
  5066. $receiptDetail->itemCategory = $this->AGENCY;
  5067. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5068. $receiptDetail->date = date ( "Y-m-d" );
  5069. $receiptDetail->cid = $cid;
  5070. $receiptDetail->rid = $rid;
  5071. $receiptDetail->status = 4;
  5072. $receiptDetail->insert ();
  5073. }
  5074. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5075. $receiptDetail = new receiptDetail ();
  5076. $receiptDetail->staff = $this->staff [0] ['sid'];
  5077. $receiptDetail->item = $value ['name'];
  5078. $receiptDetail->itemCategory = $this->TRAVEL;
  5079. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5080. $receiptDetail->date = date ( "Y-m-d" );
  5081. $receiptDetail->cid = $cid;
  5082. $receiptDetail->rid = $rid;
  5083. $receiptDetail->status = 4;
  5084. $receiptDetail->insert ();
  5085. }
  5086. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5087. $receiptDetail = new receiptDetail ();
  5088. $receiptDetail->staff = $this->staff [0] ['sid'];
  5089. $receiptDetail->item = $value ['name'];
  5090. $receiptDetail->itemCategory = $this->TRAIN;
  5091. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5092. $receiptDetail->date = date ( "Y-m-d" );
  5093. $receiptDetail->cid = $cid;
  5094. $receiptDetail->rid = $rid;
  5095. $receiptDetail->status = 4;
  5096. $receiptDetail->insert ();
  5097. }
  5098. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5099. $receiptDetail = new receiptDetail ();
  5100. $receiptDetail->staff = $this->staff [0] ['sid'];
  5101. $receiptDetail->item = $value ['name'];
  5102. $receiptDetail->itemCategory = $this->OTHER;
  5103. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5104. $receiptDetail->date = date ( "Y-m-d" );
  5105. $receiptDetail->cid = $cid;
  5106. $receiptDetail->rid = $rid;
  5107. $receiptDetail->status = 4;
  5108. $receiptDetail->insert ();
  5109. }
  5110. return "/saeaBorad";
  5111. } else
  5112. die ( 'illegal request' );
  5113. }
  5114. function referReceipt() {
  5115. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  5116. Doo::loadModel ( 'receipt' );
  5117. Doo::loadModel ( 'verify' );
  5118. $verify = new verify ();
  5119. $receipt = new receipt ();
  5120. Doo::loadModel ( 'L_category' );
  5121. $lCategory = new L_category ();
  5122. Doo::loadModel ( "role" );
  5123. $role = new role ();
  5124. $receiptDetail = $receipt->find ( array (
  5125. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  5126. 'asArray' => true
  5127. ) );
  5128. if (empty ( $receiptDetail ))
  5129. return "/addReceipt";
  5130. foreach ( $receiptDetail as $key => $value ) {
  5131. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5132. $veList = $verify->getOne ( array (
  5133. 'where' => 'vid=' . $value ['verify'],
  5134. 'asArray' => true
  5135. ) );
  5136. $v = json_decode ( $veList ['staff'] );
  5137. array_push ( $v [0], $veList ['description'] );
  5138. foreach ( $v as $n => $m ) {
  5139. if ($m ['1'] == 'ROLE') {
  5140. $roleInfo = $role->getOne ( array (
  5141. 'where' => 'rid=' . $m [0],
  5142. 'asArray' => true
  5143. ) );
  5144. $v [$n] [1] = $roleInfo ['name'];
  5145. }
  5146. }
  5147. $receiptDetail [$key] ['staff'] = $v;
  5148. $category = $lCategory->getOne ( array (
  5149. 'where' => 'cid=' . $value ['cid'],
  5150. 'asArray' => true
  5151. ) );
  5152. $receiptDetail [$key] ['category'] = $category ['title'];
  5153. }
  5154. // print_r($receiptDetail);
  5155. $data ['receiptDetail'] = $receiptDetail;
  5156. $data ['memu'] = "receipt";
  5157. $data ['staff'] = $this->staff;
  5158. $data ['receiptMemu'] = 'saeaCreate';
  5159. $data ['verifyId'] = $this->verifyId;
  5160. $data ['executeId'] = $this->executeId;
  5161. $this->render ( "/admin/saea_confirm", $data );
  5162. }
  5163. function editReceipt() {
  5164. // edit status 4
  5165. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5166. // echo $rid;
  5167. Doo::loadModel ( 'accountItem' );
  5168. Doo::loadModel ( 'verify' );
  5169. Doo::loadModel ( 'receipt' );
  5170. $receipt = new receipt ();
  5171. $verify = new verify ();
  5172. $accountItem = new accountItem ();
  5173. Doo::loadModel ( 'L_category' );
  5174. $lCategory = new L_category ();
  5175. Doo::loadModel ( "role" );
  5176. $role = new role ();
  5177. $receiptDetail = $receipt->getOne ( array (
  5178. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  5179. 'asArray' => true
  5180. ) );
  5181. if (empty ( $receiptDetail ))
  5182. return "/saeaCreate";
  5183. $acItem = $accountItem->find ( array (
  5184. 'asArray' => true
  5185. ) );
  5186. $veList = $verify->find ( array (
  5187. 'asArray' => true
  5188. ) );
  5189. foreach ( $veList as $key => $value ) {
  5190. $v = json_decode ( $value ['staff'] );
  5191. $list = array ();
  5192. foreach ( $v as $n => $m ) {
  5193. if ($m ['1'] == 'ROLE') {
  5194. $roleInfo = $role->getOne ( array (
  5195. 'where' => 'rid=' . $m [0],
  5196. 'asArray' => true
  5197. ) );
  5198. $v [$n] [1] = $roleInfo ['name'];
  5199. array_push ( $list, $roleInfo ['name'] );
  5200. } else {
  5201. array_push ( $list, $v [$n] [1] );
  5202. }
  5203. }
  5204. $veList [$key] ['staff'] = implode ( '>', $list );
  5205. }
  5206. // 配置编辑信息
  5207. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  5208. foreach ( $acItem as $key => $value ) {
  5209. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  5210. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  5211. $acItem [$key] ['price'] = $v ['price'];
  5212. }
  5213. }
  5214. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  5215. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  5216. $acItem [$key] ['price'] = $v ['price'];
  5217. }
  5218. }
  5219. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  5220. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  5221. $acItem [$key] ['price'] = $v ['price'];
  5222. }
  5223. }
  5224. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  5225. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  5226. $acItem [$key] ['price'] = $v ['price'];
  5227. }
  5228. }
  5229. }
  5230. $data ['category'] = $lCategory->find ( array (
  5231. 'asArray' => true
  5232. ) );
  5233. $data ['cSum'] = $accountItemList ['cSum'];
  5234. $data ['sum'] = $receiptDetail ['sum'];
  5235. $data ['receiptDetail'] = $receiptDetail;
  5236. $data ['veList'] = $veList;
  5237. $data ['acItem'] = $acItem;
  5238. $data ['memu'] = "receipt";
  5239. $data ['staff'] = $this->staff;
  5240. $data ['receiptMemu'] = 'saeaBorad';
  5241. $data ['verify'] = $receiptDetail ['verify'];
  5242. $data ['verifyId'] = $this->verifyId;
  5243. $data ['executeId'] = $this->executeId;
  5244. $data ['rid'] = $rid;
  5245. $this->render ( "/admin/saea_edit", $data );
  5246. }
  5247. function updateReceipt() {
  5248. $agency = $this->get_args ( 'agency' );
  5249. $travel = $this->get_args ( 'travel' );
  5250. $train = $this->get_args ( 'train' );
  5251. $other = $this->get_args ( 'other' );
  5252. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5253. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5254. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5255. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5256. if (! empty ( $explanation )) {
  5257. Doo::loadModel ( 'receipt' );
  5258. Doo::loadModel ( 'receiptDetail' );
  5259. Doo::loadModel ( 'accountItem' );
  5260. $accountItem = new accountItem ();
  5261. $receipt = new receipt ();
  5262. Doo::loadModel ( 'execute' );
  5263. $execute = new execute ();
  5264. $receiptDetail = $receipt->getOne ( array (
  5265. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  5266. 'asArray' => true
  5267. ) );
  5268. if (empty ( $receiptDetail ))
  5269. return "/saeaBorad";
  5270. if ($receiptDetail ['Rtype'] == 1)
  5271. $executeDetail = $execute->getOne ( array (
  5272. 'where' => 'mold="借款费用执行人"',
  5273. 'asArray' => true
  5274. ) );
  5275. else
  5276. $executeDetail = $execute->getOne ( array (
  5277. 'where' => 'mold="报销单执行人"',
  5278. 'asArray' => true
  5279. ) );
  5280. $aItem = $accountItem->find ( array (
  5281. 'asArray' => true
  5282. ) );
  5283. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5284. $ag = $tr = $ta = $ot = 0;
  5285. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5286. foreach ( $aItem as $key => $value ) {
  5287. if ($value ['category'] == $this->AGENCY) {
  5288. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5289. array_push ( $accountJson [$this->AGENCY], array (
  5290. 'aid' => $value ['aid'],
  5291. 'name' => $value ['name'],
  5292. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5293. ) );
  5294. $sum += $agency [$ag];
  5295. $agencySum += $agency [$ag];
  5296. }
  5297. $ag ++;
  5298. }
  5299. if ($value ['category'] == $this->TRAVEL) {
  5300. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5301. array_push ( $accountJson [$this->TRAVEL], array (
  5302. 'aid' => $value ['aid'],
  5303. 'name' => $value ['name'],
  5304. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5305. ) );
  5306. $sum += $travel [$tr];
  5307. $travelSum += $travel [$tr];
  5308. }
  5309. $tr ++;
  5310. }
  5311. if ($value ['category'] == $this->TRAIN) {
  5312. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5313. array_push ( $accountJson [$this->TRAIN], array (
  5314. 'aid' => $value ['aid'],
  5315. 'name' => $value ['name'],
  5316. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5317. ) );
  5318. $sum += $train [$ta];
  5319. $trainSum += $train [$ta];
  5320. }
  5321. $ta ++;
  5322. }
  5323. if ($value ['category'] == $this->OTHER) {
  5324. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5325. array_push ( $accountJson [$this->OTHER], array (
  5326. 'aid' => $value ['aid'],
  5327. 'name' => $value ['name'],
  5328. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5329. ) );
  5330. $sum += $other [$ot];
  5331. $otherSum += $other [$ot];
  5332. }
  5333. $ot ++;
  5334. }
  5335. }
  5336. $accountJson ['cSum'] = array (
  5337. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5338. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5339. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5340. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5341. );
  5342. // 报销单
  5343. $rid = $receipt->rid = $receiptDetail ['rid'];
  5344. $receipt->accountItem = json_encode ( $accountJson );
  5345. $receipt->staff = $this->staff [0] ['sid'];
  5346. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5347. $receipt->date = date ( "Y-m-d" );
  5348. $receipt->cid = $cid;
  5349. if (($receiptDetail ['status'] != 4)) {
  5350. if ($receiptDetail ['Rtype'] == 1)
  5351. $receipt->status = 7;
  5352. else
  5353. $receipt->status = 5;
  5354. }
  5355. if ($receiptDetail != 4 && ! empty ( $verify ))
  5356. $receipt->verify = $verify;
  5357. $receipt->executeCopy = $executeDetail ['staff'];
  5358. $receipt->explanation = $explanation;
  5359. $receipt->update ();
  5360. $receiptDetail = new receiptDetail ();
  5361. $receiptDetail->delete ( array (
  5362. 'where' => 'rid=' . $rid
  5363. ) );
  5364. // 报销详情
  5365. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5366. $receiptDetail = new receiptDetail ();
  5367. $receiptDetail->staff = $this->staff [0] ['sid'];
  5368. $receiptDetail->item = $value ['name'];
  5369. $receiptDetail->itemCategory = $this->AGENCY;
  5370. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5371. $receiptDetail->date = date ( "Y-m-d" );
  5372. $receiptDetail->cid = $cid;
  5373. $receiptDetail->rid = $rid;
  5374. $receiptDetail->status = 4;
  5375. $receiptDetail->insert ();
  5376. }
  5377. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5378. $receiptDetail = new receiptDetail ();
  5379. $receiptDetail->staff = $this->staff [0] ['sid'];
  5380. $receiptDetail->item = $value ['name'];
  5381. $receiptDetail->itemCategory = $this->TRAVEL;
  5382. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5383. $receiptDetail->date = date ( "Y-m-d" );
  5384. $receiptDetail->cid = $cid;
  5385. $receiptDetail->rid = $rid;
  5386. $receiptDetail->status = 4;
  5387. $receiptDetail->insert ();
  5388. }
  5389. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5390. $receiptDetail = new receiptDetail ();
  5391. $receiptDetail->staff = $this->staff [0] ['sid'];
  5392. $receiptDetail->item = $value ['name'];
  5393. $receiptDetail->itemCategory = $this->TRAIN;
  5394. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5395. $receiptDetail->date = date ( "Y-m-d" );
  5396. $receiptDetail->cid = $cid;
  5397. $receiptDetail->rid = $rid;
  5398. $receiptDetail->status = 4;
  5399. $receiptDetail->insert ();
  5400. }
  5401. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5402. $receiptDetail = new receiptDetail ();
  5403. $receiptDetail->staff = $this->staff [0] ['sid'];
  5404. $receiptDetail->item = $value ['name'];
  5405. $receiptDetail->itemCategory = $this->OTHER;
  5406. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5407. $receiptDetail->date = date ( "Y-m-d" );
  5408. $receiptDetail->cid = $cid;
  5409. $receiptDetail->rid = $rid;
  5410. $receiptDetail->status = 4;
  5411. $receiptDetail->insert ();
  5412. }
  5413. // return "/referReceipt/".$rid;
  5414. }
  5415. return "/saeaBorad";
  5416. }
  5417. function approvedReceipt() {
  5418. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5419. Doo::loadModel ( 'receipt' );
  5420. Doo::loadModel ( 'receiptDetail' );
  5421. $receipt = new receipt ();
  5422. $receiptDetail = new receiptDetail ();
  5423. Doo::loadModel ( 'statistics' );
  5424. Doo::loadModel ( 'itemStatistics' );
  5425. $statistics = new statistics ();
  5426. $itemStatistics = new itemStatistics ();
  5427. Doo::loadModel ( "verify" );
  5428. $verify = new verify ();
  5429. // 审批状态的判定
  5430. $receiptDetailList = $receipt->getOne ( array (
  5431. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  5432. 'asArray' => true
  5433. ) );
  5434. if (empty ( $receiptDetailList ))
  5435. return "/saeaBorad";
  5436. $verifyDetail = $verify->getOne ( array (
  5437. 'where' => ' vid =' . $receiptDetailList ['verify'],
  5438. 'asArray' => true
  5439. ) );
  5440. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5441. if (empty ( $receiptDetailList ['nowStaff'] )) {
  5442. $nowStaff = "";
  5443. $nowStaffList = array ();
  5444. if ($verifyDetail [0] [1] == 'ROLE') {
  5445. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5446. foreach ( $vStaffString as $key => $value ) {
  5447. $staffK = explode ( "_", $value );
  5448. array_push ( $nowStaffList, $staffK [0] );
  5449. }
  5450. $nowStaff = implode ( ',', $nowStaffList );
  5451. } else {
  5452. $nowStaff = $verifyDetail [0] [0];
  5453. }
  5454. $receipt->nowStaff = $nowStaff;
  5455. }
  5456. // echo $nowStaff;
  5457. // print_r($verifyDetail);die;
  5458. $receipt->rid = $receiptDetailList ['rid'];
  5459. $receipt->date = date ( "Y-m-d" );
  5460. $receipt->status = 2;
  5461. $receipt->update ();
  5462. $receiptDetail->status = 2;
  5463. $receiptDetail->update ( array (
  5464. 'where' => 'rid=' . $receiptDetailList ['rid']
  5465. ) );
  5466. Doo::loadModel ( "receiptLog" );
  5467. $receiptLog = new receiptLog ();
  5468. Doo::loadModel ( "verify" );
  5469. $verify = new verify ();
  5470. $receiptInfo = $receipt->getOne ( array (
  5471. 'where' => 'rid=' . $rid,
  5472. 'asArray' => true
  5473. ) );
  5474. $vr = $verify->getOne ( array (
  5475. 'where' => 'vid=' . $receiptInfo ['verify'],
  5476. 'asArray' => true
  5477. ) );
  5478. $jd = json_decode ( $vr ['staff'] );
  5479. $roleId = 0;
  5480. foreach ( $jd as $key => $value ) {
  5481. if ($value [1] == 'ROLE') {
  5482. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  5483. if ($pos !== false) {
  5484. $roleId = $value [0];
  5485. }
  5486. }
  5487. }
  5488. // 审批日志
  5489. // echo $roleId;die;
  5490. if (! empty ( $roleId )) {
  5491. Doo::loadModel ( "role" );
  5492. $role = new role ();
  5493. $roleInfo = $role->getOne ( array (
  5494. 'where' => 'rid=' . $roleId,
  5495. 'asArray' => true
  5496. ) );
  5497. $receiptLog->rolename = $roleInfo ['name'];
  5498. }
  5499. $receiptLog->username = $this->staff [0] ['username'];
  5500. $receiptLog->uid = $this->staff [0] ['sid'];
  5501. $receiptLog->date = date ( "Y-m-d" );
  5502. $receiptLog->opinion = '提交审批';
  5503. $receiptLog->img = $this->staff [0] ['avatar'];
  5504. $receiptLog->status = 2;
  5505. $receiptLog->rid = $rid;
  5506. $receiptLog->insert ();
  5507. // statistics item
  5508. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  5509. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  5510. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  5511. $stat = $statistics->getOne ( array (
  5512. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5513. 'asArray' => true
  5514. ) );
  5515. if (empty ( $stat )) {
  5516. $statistics->date = date ( "Y-m-d" );
  5517. $statistics->cid = $this->staff [0] ['cid'];
  5518. $statistics->staff = $this->staff [0] ['sid'];
  5519. $statistics->agPrice = 0;
  5520. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5521. $statistics->insert ();
  5522. } else {
  5523. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5524. $statistics->update ( array (
  5525. 'where' => 'sid=' . $stat ['sid']
  5526. ) );
  5527. }
  5528. return "/expenses";
  5529. }
  5530. function approval() {
  5531. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5532. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5533. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5534. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5535. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5536. if (empty ( $status ))
  5537. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5538. $vidList = array ();
  5539. $button = 0;
  5540. Doo::loadModel ( 'verify' );
  5541. $verify = new verify ();
  5542. Doo::loadModel ( 'receipt' );
  5543. $receipt = new receipt ();
  5544. Doo::loadModel ( 'staff' );
  5545. $staff = new staff ();
  5546. Doo::loadModel ( 'L_category' );
  5547. $Lcategory = new L_category ();
  5548. // user verify ID
  5549. $verifyDetail = $verify->find ( array (
  5550. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5551. 'asArray' => true
  5552. ) );
  5553. foreach ( $verifyDetail as $key => $value ) {
  5554. array_push ( $vidList, $value ['vid'] );
  5555. }
  5556. $vid = implode ( ",", $vidList );
  5557. if (empty ( $verifyDetail ))
  5558. $vid = 0;
  5559. /*
  5560. */
  5561. $dateCondition = " and Year(date) =" . $year;
  5562. if (! empty ( $month ))
  5563. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  5564. $categoryList = $Lcategory->find ( array (
  5565. 'asArray' => true
  5566. ) );
  5567. $staffList = $staff->find ( array (
  5568. 'where' => 'cid=' . $cid,
  5569. 'asArray' => true
  5570. ) );
  5571. $cateCondition = "";
  5572. $staffCondition = "";
  5573. $approvalCondition = "";
  5574. if (! empty ( $cid ))
  5575. $cateCondition = ' and cid=' . $cid;
  5576. if (! empty ( $sid )) {
  5577. $staffCondition = ' and staff=' . $sid;
  5578. $cateCondition = "";
  5579. }
  5580. // elseif($status==1){
  5581. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  5582. // }
  5583. if ($status == 2) {
  5584. // 查找角色审批人
  5585. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  5586. }
  5587. $ap = "";
  5588. if ($status == 4) {
  5589. $ap = 4;
  5590. $status = 2;
  5591. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  5592. }
  5593. if ($status == 5) {
  5594. $status = 4;
  5595. $ap = 5;
  5596. }
  5597. // echo $vid;
  5598. // get Receipt By verifyID status 2 .$approvalCondition
  5599. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  5600. $receiptList = $receipt->find ( array (
  5601. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  5602. 'desc' => 'rid',
  5603. 'asArray' => true
  5604. ) );
  5605. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  5606. $Locate = 0;
  5607. if ($ap == 4)
  5608. $status = 4;
  5609. elseif ($ap == 5)
  5610. $status = 5;
  5611. foreach ( $receiptList as $key => $value ) {
  5612. $receiptList [$key] ['Locate'] = $Locate;
  5613. $Locate ++;
  5614. $receiptList [$key] ['reviseDetail'] = array ();
  5615. if (! empty ( $value ['reviseDetail'] ))
  5616. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5617. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5618. $categoryDetil = $Lcategory->getOne ( array (
  5619. 'where' => 'cid=' . $value ['cid'],
  5620. 'asArray' => true
  5621. ) );
  5622. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5623. $verifyList = $verify->getOne ( array (
  5624. 'where' => 'vid=' . $value ['verify'],
  5625. 'asArray' => true
  5626. ) );
  5627. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5628. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5629. foreach ( $verifyList as $k => $v ) {
  5630. // init verifyStaff
  5631. $verifyList [$k] ['date'] = "";
  5632. $verifyList [$k] ['opinion'] = "";
  5633. $verifyList [$k] ['status'] = "";
  5634. if (empty ( $verifyStaff )) {
  5635. $verifyList [$k] ['date'] = "";
  5636. $verifyList [$k] ['opinion'] = "";
  5637. if ($v [0] == $this->staff [0] ['sid']) {
  5638. $verifyList [$k] ['status'] = 4;
  5639. $button = 4;
  5640. }
  5641. } else {
  5642. $flag = true;
  5643. foreach ( $verifyStaff as $m => $u ) {
  5644. if ($v [0] == $m) {
  5645. $verifyList [$k] ['date'] = $u ['date'];
  5646. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5647. $verifyList [$k] ['status'] = $u ['status'];
  5648. $flag = false;
  5649. break;
  5650. }
  5651. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  5652. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  5653. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  5654. }
  5655. if ($flag) { // 检测可编辑
  5656. if ($v [0] == $this->staff [0] ['sid']) {
  5657. $verifyList [$k] ['status'] = 4;
  5658. $button = 4;
  5659. }
  5660. }
  5661. }
  5662. }
  5663. $receiptList [$key] ['verifyList'] = $verifyList;
  5664. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5665. 'where' => 'sid=' . $value ['staff'],
  5666. 'asArray' => true
  5667. ) );
  5668. $receiptList [$key] ['button'] = $button;
  5669. }
  5670. // print_r($receiptList);die;
  5671. // $data['verifyDetail']=$verifyDetail;
  5672. $mothHtml = "";
  5673. for($i = 1; $i <= 12; $i ++) {
  5674. if ($month == $i)
  5675. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5676. else
  5677. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5678. }
  5679. $data ['mothHtml'] = $mothHtml;
  5680. $data ['receiptList'] = $receiptList;
  5681. $data ['receiptApprovalCount'] = count ( $receiptList );
  5682. $data ['status'] = $status;
  5683. $data ['year'] = $year;
  5684. $data ['categoryList'] = $categoryList;
  5685. $data ['staffList'] = $staffList;
  5686. $data ['cid'] = $cid;
  5687. $data ['sid'] = $sid;
  5688. $data ['ap'] = $ap;
  5689. $data ['memu'] = "receipt";
  5690. $data ['staff'] = $this->staff;
  5691. $data ['receiptMemu'] = 'approval';
  5692. $data ['verifyId'] = $this->verifyId;
  5693. $data ['executeId'] = $this->executeId;
  5694. $this->render ( "/admin/saea_reportList", $data );
  5695. }
  5696. function approvalDetails() {
  5697. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5698. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5699. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5700. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5701. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5702. Doo::loadModel ( 'verify' );
  5703. $verify = new verify ();
  5704. Doo::loadModel ( 'receipt' );
  5705. $receipt = new receipt ();
  5706. Doo::loadModel ( 'staff' );
  5707. $staff = new staff ();
  5708. Doo::loadModel ( 'L_category' );
  5709. $Lcategory = new L_category ();
  5710. Doo::loadModel ( 'enclosur' );
  5711. $enclosur = new enclosur ();
  5712. $vidList = array ();
  5713. $verifyDetail = $verify->find ( array (
  5714. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5715. 'asArray' => true
  5716. ) );
  5717. foreach ( $verifyDetail as $key => $value ) {
  5718. array_push ( $vidList, $value ['vid'] );
  5719. }
  5720. $vid = implode ( ",", $vidList );
  5721. if (empty ( $verifyDetail ))
  5722. $vid = 0;
  5723. $categoryList = $Lcategory->find ( array (
  5724. 'asArray' => true
  5725. ) );
  5726. $staffList = $staff->find ( array (
  5727. 'where' => 'cid=' . $cid,
  5728. 'asArray' => true
  5729. ) );
  5730. $ap = 0;
  5731. $receiptList = $receipt->find ( array (
  5732. 'where' => 'rid =' . $rid,
  5733. 'desc' => 'rid',
  5734. 'asArray' => true
  5735. ) );
  5736. $Locate = 0;
  5737. $roleId = 0;
  5738. $button = 0;
  5739. foreach ( $receiptList as $key => $value ) {
  5740. $receiptList [$key] ['Locate'] = $Locate;
  5741. $Locate ++;
  5742. $receiptList [$key] ['reviseDetail'] = array ();
  5743. if (! empty ( $value ['reviseDetail'] ))
  5744. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5745. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5746. $categoryDetil = $Lcategory->getOne ( array (
  5747. 'where' => 'cid=' . $value ['cid'],
  5748. 'asArray' => true
  5749. ) );
  5750. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5751. // 检测编辑状态
  5752. $verifyList = $verify->getOne ( array (
  5753. 'where' => 'vid=' . $value ['verify'],
  5754. 'asArray' => true
  5755. ) );
  5756. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5757. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5758. Doo::loadModel ( 'role' );
  5759. $role = new role ();
  5760. // print_r($verifyList);
  5761. $flag = true;
  5762. $roleKey = 0;
  5763. $endStaffArray = array ();
  5764. $roleArrayCopy = array ();
  5765. foreach ( $verifyList as $k => $v ) {
  5766. // init verifyStaff
  5767. if ($v [1] == 'ROLE') {
  5768. if (! empty ( $verifyStaff )) {
  5769. $endStaffArray = end ( $verifyStaff );
  5770. if ($v [0] == $endStaffArray ['nextStaff']) {
  5771. $roleId = $v [0];
  5772. }
  5773. }
  5774. $roleVerify = json_decode ( $v [3], true );
  5775. $roleKey = $k;
  5776. $roleArray = array ();
  5777. $rolename = $role->getOne ( array (
  5778. 'where' => 'rid=' . $v [0],
  5779. 'asArray' => true
  5780. ) );
  5781. foreach ( $roleVerify as $o => $p ) {
  5782. $staffID = explode ( '_', $p );
  5783. $staffInfo = $staff->getOne ( array (
  5784. 'where' => 'sid=' . $staffID [0],
  5785. 'asArray' => true
  5786. ) );
  5787. // print_r($staffID);
  5788. $exp = array (
  5789. 0 => $staffInfo ['sid'],
  5790. 1 => $staffID [1],
  5791. 2 => $staffInfo ['avatar'],
  5792. 'date' => '',
  5793. 'date' => '',
  5794. 'opinion' => '',
  5795. 'status' => '',
  5796. 'rolename' => $rolename ['name']
  5797. );
  5798. array_push ( $roleArray, $exp );
  5799. }
  5800. $roleArrayCopy [$v [0]] = $roleArray;
  5801. // $verifyList[$k]['roleArray']=$roleArray;
  5802. }
  5803. // print_r($roleArray);
  5804. $verifyList [$k] ['date'] = "";
  5805. $verifyList [$k] ['opinion'] = "";
  5806. $verifyList [$k] ['status'] = "";
  5807. if (empty ( $verifyStaff )) {
  5808. $verifyList [$k] ['date'] = "";
  5809. $verifyList [$k] ['opinion'] = "";
  5810. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5811. $verifyList [$k] ['status'] = 4;
  5812. $button = 4;
  5813. $flag = false;
  5814. }
  5815. } else {
  5816. foreach ( $verifyStaff as $m => $u ) {
  5817. if ($v [0] == $m) {
  5818. $verifyList [$k] ['date'] = $u ['date'];
  5819. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5820. $verifyList [$k] ['status'] = $u ['status'];
  5821. $flag = false;
  5822. break;
  5823. }
  5824. }
  5825. $endStaffArray = end ( $verifyStaff );
  5826. if (isset ( $endStaffArray ['ROLE'] )) {
  5827. } else {
  5828. $endKey = key ( $verifyStaff );
  5829. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5830. $button = 4;
  5831. $verifyList [$k] ['status'] = 4;
  5832. }
  5833. }
  5834. }
  5835. }
  5836. $rolename ['name'] = '';
  5837. if (! empty ( $roleId )) {
  5838. Doo::loadModel ( 'role' );
  5839. $role = new role ();
  5840. $rolename = $role->getOne ( array (
  5841. 'where' => 'rid=' . $roleId,
  5842. 'asArray' => true
  5843. ) );
  5844. }
  5845. if (! empty ( $verifyStaff ))
  5846. $endStaffArray = end ( $verifyStaff );
  5847. $KOP = false;
  5848. foreach ( $roleArrayCopy as $P => $A ) {
  5849. foreach ( $A as $MKI => $AVL ) {
  5850. if (! empty ( $verifyStaff )) {
  5851. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5852. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5853. $button = 4;
  5854. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5855. }
  5856. foreach ( $verifyStaff as $m => $u ) {
  5857. $AVLFK = $AVL [0] . '_R';
  5858. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5859. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5860. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5861. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5862. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5863. break;
  5864. }
  5865. }
  5866. } else {
  5867. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5868. $button = 4;
  5869. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5870. }
  5871. }
  5872. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5873. $KOP = true;
  5874. }
  5875. }
  5876. foreach ( $roleArrayCopy as $k => $v ) {
  5877. foreach ( $verifyList as $m => $n ) {
  5878. if ($n [0] == $k) {
  5879. array_splice ( $verifyList, $m, 1, $v );
  5880. }
  5881. }
  5882. }
  5883. $receiptList [$key] ['verifyList'] = $verifyList;
  5884. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5885. 'where' => 'sid=' . $value ['staff'],
  5886. 'asArray' => true
  5887. ) );
  5888. $receiptList [$key] ['button'] = $button;
  5889. }
  5890. $mothHtml = "";
  5891. for($i = 1; $i <= 12; $i ++) {
  5892. if ($month == $i)
  5893. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5894. else
  5895. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5896. }
  5897. // 获取审批日志
  5898. Doo::loadModel ( 'receiptLog' );
  5899. $receiptLog = new receiptLog ();
  5900. $rlList = array ();
  5901. $rlInfo = $receiptLog->getOne ( array (
  5902. 'where' => 'rid=' . $rid . ' and status=4',
  5903. 'asArray' => true
  5904. ) );
  5905. $tijdate = $receiptLog->getOne ( array (
  5906. 'where' => 'rid=' . $rid . ' and status=2',
  5907. 'asc' => 'rlid',
  5908. 'asArray' => true
  5909. ) );
  5910. if (! empty ( $rlInfo )) {
  5911. $rlList = $receiptLog->find ( array (
  5912. 'where' => 'rid=' . $rid,
  5913. 'asc' => 'rlid',
  5914. 'asArray' => true
  5915. ) );
  5916. }
  5917. $receiptList [0] ['rlList'] = $rlList;
  5918. $enclosurList = $enclosur->find ( array (
  5919. 'where' => 'rid=' . $rid,
  5920. 'asArray' => true
  5921. ) );
  5922. $enclosurHtml = '';
  5923. foreach ( $enclosurList as $value ) {
  5924. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5925. }
  5926. $data ['enclosurHtml'] = $enclosurHtml;
  5927. $data ['rolename'] = $rolename ['name'];
  5928. $data ['datetij'] = $tijdate ['date'];
  5929. $data ['mothHtml'] = $mothHtml;
  5930. $data ['receiptList'] = $receiptList;
  5931. $data ['receiptApprovalCount'] = count ( $receiptList );
  5932. $data ['year'] = $year;
  5933. $data ['categoryList'] = $categoryList;
  5934. $data ['staffList'] = $staffList;
  5935. $data ['cid'] = $cid;
  5936. $data ['sid'] = $sid;
  5937. $data ['status'] = 0;
  5938. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  5939. $ap = 4;
  5940. } else
  5941. $data ['status'] = $receiptList [0] ['status'];
  5942. if ($receiptList [0] ['status'] == 4) {
  5943. $data ['status'] = 5;
  5944. $ap = 0;
  5945. }
  5946. $data ['ap'] = $ap;
  5947. $data ['memu'] = "receipt";
  5948. $data ['staff'] = $this->staff;
  5949. $data ['receiptMemu'] = 'approval';
  5950. $data ['verifyId'] = $this->verifyId;
  5951. $data ['executeId'] = $this->executeId;
  5952. $this->render ( "/admin/saeaReportListReport", $data );
  5953. }
  5954. function approvalEdi() {
  5955. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5956. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5957. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5958. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5959. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5960. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5961. if (empty ( $status ))
  5962. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5963. $vidList = array ();
  5964. $button = 0;
  5965. Doo::loadModel ( 'verify' );
  5966. Doo::loadModel ( 'receipt' );
  5967. Doo::loadModel ( 'staff' );
  5968. $staff = new staff ();
  5969. $receipt = new receipt ();
  5970. $verify = new verify ();
  5971. Doo::loadModel ( 'L_category' );
  5972. $Lcategory = new L_category ();
  5973. Doo::loadModel ( 'enclosur' );
  5974. $enclosur = new enclosur ();
  5975. // user verify ID
  5976. $verifyDetail = $verify->find ( array (
  5977. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5978. 'asArray' => true
  5979. ) );
  5980. foreach ( $verifyDetail as $key => $value ) {
  5981. array_push ( $vidList, $value ['vid'] );
  5982. }
  5983. $vid = implode ( ",", $vidList );
  5984. if (empty ( $verifyDetail ))
  5985. $vid = 0;
  5986. $categoryList = $Lcategory->find ( array (
  5987. 'asArray' => true
  5988. ) );
  5989. $staffList = $staff->find ( array (
  5990. 'where' => 'cid=' . $cid,
  5991. 'asArray' => true
  5992. ) );
  5993. $ap = "";
  5994. if ($status == 4) {
  5995. $ap = 4;
  5996. $status = 2;
  5997. }
  5998. // get Receipt By verifyID status 2
  5999. $receiptList = $receipt->find ( array (
  6000. 'where' => 'rid =' . $rid,
  6001. 'desc' => 'rid',
  6002. 'asArray' => true
  6003. ) );
  6004. $Locate = 0;
  6005. $roleId = 0;
  6006. if ($ap == 4)
  6007. $status = 4;
  6008. foreach ( $receiptList as $key => $value ) {
  6009. $receiptList [$key] ['Locate'] = $Locate;
  6010. $Locate ++;
  6011. $receiptList [$key] ['reviseDetail'] = array ();
  6012. if (! empty ( $value ['reviseDetail'] ))
  6013. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6014. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6015. $categoryDetil = $Lcategory->getOne ( array (
  6016. 'where' => 'cid=' . $value ['cid'],
  6017. 'asArray' => true
  6018. ) );
  6019. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6020. // 检测编辑状态
  6021. $verifyList = $verify->getOne ( array (
  6022. 'where' => 'vid=' . $value ['verify'],
  6023. 'asArray' => true
  6024. ) );
  6025. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6026. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6027. // print_r($verifyList);
  6028. //
  6029. // if (empty($verifyStaff)){
  6030. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6031. // $verifyList[0]['status']=4;$button=4;
  6032. // }
  6033. //
  6034. // }else{
  6035. //
  6036. // }
  6037. // die;
  6038. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  6039. // echo array_search("green",$a);
  6040. //
  6041. Doo::loadModel ( 'role' );
  6042. $role = new role ();
  6043. // print_r($verifyList);
  6044. $flag = true;
  6045. $roleKey = 0;
  6046. $endStaffArray = array ();
  6047. $roleArrayCopy = array ();
  6048. foreach ( $verifyList as $k => $v ) {
  6049. // init verifyStaff
  6050. if ($v [1] == 'ROLE') {
  6051. if (! empty ( $verifyStaff )) {
  6052. $endStaffArray = end ( $verifyStaff );
  6053. if ($v [0] == $endStaffArray ['nextStaff']) {
  6054. $roleId = $v [0];
  6055. }
  6056. }
  6057. $roleVerify = json_decode ( $v [3], true );
  6058. $roleKey = $k;
  6059. $roleArray = array ();
  6060. $rolename = $role->getOne ( array (
  6061. 'where' => 'rid=' . $v [0],
  6062. 'asArray' => true
  6063. ) );
  6064. foreach ( $roleVerify as $o => $p ) {
  6065. $staffID = explode ( '_', $p );
  6066. $staffInfo = $staff->getOne ( array (
  6067. 'where' => 'sid=' . $staffID [0],
  6068. 'asArray' => true
  6069. ) );
  6070. // print_r($staffID);
  6071. $exp = array (
  6072. 0 => $staffInfo ['sid'],
  6073. 1 => $staffID [1],
  6074. 2 => $staffInfo ['avatar'],
  6075. 'date' => '',
  6076. 'date' => '',
  6077. 'opinion' => '',
  6078. 'status' => '',
  6079. 'rolename' => $rolename ['name']
  6080. );
  6081. array_push ( $roleArray, $exp );
  6082. }
  6083. $roleArrayCopy [$v [0]] = $roleArray;
  6084. // $verifyList[$k]['roleArray']=$roleArray;
  6085. }
  6086. // print_r($roleArray);
  6087. $verifyList [$k] ['date'] = "";
  6088. $verifyList [$k] ['opinion'] = "";
  6089. $verifyList [$k] ['status'] = "";
  6090. if (empty ( $verifyStaff )) {
  6091. $verifyList [$k] ['date'] = "";
  6092. $verifyList [$k] ['opinion'] = "";
  6093. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6094. $verifyList [$k] ['status'] = 4;
  6095. $button = 4;
  6096. $flag = false;
  6097. }
  6098. } else {
  6099. foreach ( $verifyStaff as $m => $u ) {
  6100. if ($v [0] == $m) {
  6101. $verifyList [$k] ['date'] = $u ['date'];
  6102. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6103. $verifyList [$k] ['status'] = $u ['status'];
  6104. $flag = false;
  6105. break;
  6106. }
  6107. }
  6108. $endStaffArray = end ( $verifyStaff );
  6109. if (isset ( $endStaffArray ['ROLE'] )) {
  6110. } else {
  6111. $endKey = key ( $verifyStaff );
  6112. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6113. $button = 4;
  6114. $verifyList [$k] ['status'] = 4;
  6115. }
  6116. }
  6117. // print_r($endStaffArray);die;
  6118. // if (empty($verifyStaff)){
  6119. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6120. // $verifyList[$k]['status']=4;$button=4;
  6121. // }
  6122. //
  6123. // }else{
  6124. //
  6125. // }
  6126. // if($flag){//检测可编辑
  6127. // if($v[0]==$this->staff[0]['sid']){
  6128. // $verifyList[$k]['status']=4;$button=4;
  6129. // }
  6130. // }
  6131. }
  6132. }
  6133. $rolename ['name'] = '';
  6134. if (! empty ( $roleId )) {
  6135. Doo::loadModel ( 'role' );
  6136. $role = new role ();
  6137. $rolename = $role->getOne ( array (
  6138. 'where' => 'rid=' . $roleId,
  6139. 'asArray' => true
  6140. ) );
  6141. }
  6142. if (! empty ( $verifyStaff ))
  6143. $endStaffArray = end ( $verifyStaff );
  6144. $KOP = false;
  6145. foreach ( $roleArrayCopy as $P => $A ) {
  6146. foreach ( $A as $MKI => $AVL ) {
  6147. if (! empty ( $verifyStaff )) {
  6148. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6149. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6150. $button = 4;
  6151. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6152. }
  6153. foreach ( $verifyStaff as $m => $u ) {
  6154. $AVLFK = $AVL [0] . '_R';
  6155. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6156. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6157. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6158. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6159. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6160. break;
  6161. }
  6162. }
  6163. } else {
  6164. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6165. $button = 4;
  6166. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6167. }
  6168. }
  6169. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6170. $KOP = true;
  6171. }
  6172. }
  6173. // print_r($roleArrayCopy);
  6174. // echo $roleKey;
  6175. foreach ( $roleArrayCopy as $k => $v ) {
  6176. foreach ( $verifyList as $m => $n ) {
  6177. if ($n [0] == $k) {
  6178. array_splice ( $verifyList, $m, 1, $v );
  6179. }
  6180. }
  6181. }
  6182. // if ($KOP)
  6183. // array_splice($verifyList,$roleKey,1,$roleArray);
  6184. // print_r($verifyList);
  6185. $receiptList [$key] ['verifyList'] = $verifyList;
  6186. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6187. 'where' => 'sid=' . $value ['staff'],
  6188. 'asArray' => true
  6189. ) );
  6190. $receiptList [$key] ['button'] = $button;
  6191. }
  6192. // $data['verifyDetail']=$verifyDetail;
  6193. $mothHtml = "";
  6194. for($i = 1; $i <= 12; $i ++) {
  6195. if ($month == $i)
  6196. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6197. else
  6198. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6199. }
  6200. // 获取审批日志
  6201. Doo::loadModel ( 'receiptLog' );
  6202. $receiptLog = new receiptLog ();
  6203. $rlList = array ();
  6204. $rlInfo = $receiptLog->getOne ( array (
  6205. 'where' => 'rid=' . $rid . ' and status=4',
  6206. 'asArray' => true
  6207. ) );
  6208. $tijdate = $receiptLog->getOne ( array (
  6209. 'where' => 'rid=' . $rid . ' and status=2',
  6210. 'asc' => 'rlid',
  6211. 'asArray' => true
  6212. ) );
  6213. if (! empty ( $rlInfo )) {
  6214. $rlList = $receiptLog->find ( array (
  6215. 'where' => 'rid=' . $rid,
  6216. 'asc' => 'rlid',
  6217. 'asArray' => true
  6218. ) );
  6219. }
  6220. $receiptList [0] ['rlList'] = $rlList;
  6221. $enclosurList = $enclosur->find ( array (
  6222. 'where' => 'rid=' . $rid,
  6223. 'asArray' => true
  6224. ) );
  6225. $enclosurHtml = '';
  6226. foreach ( $enclosurList as $value ) {
  6227. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6228. }
  6229. $data ['enclosurHtml'] = $enclosurHtml;
  6230. $data ['rolename'] = $rolename ['name'];
  6231. $data ['datetij'] = $tijdate ['date'];
  6232. $data ['mothHtml'] = $mothHtml;
  6233. $data ['receiptList'] = $receiptList;
  6234. $data ['receiptApprovalCount'] = count ( $receiptList );
  6235. $data ['status'] = $status;
  6236. $data ['year'] = $year;
  6237. $data ['categoryList'] = $categoryList;
  6238. $data ['staffList'] = $staffList;
  6239. $data ['cid'] = $cid;
  6240. $data ['sid'] = $sid;
  6241. $data ['ap'] = $ap;
  6242. $data ['memu'] = "receipt";
  6243. $data ['staff'] = $this->staff;
  6244. $data ['receiptMemu'] = 'approval';
  6245. $data ['verifyId'] = $this->verifyId;
  6246. $data ['executeId'] = $this->executeId;
  6247. $this->render ( "/admin/saeaReportListReport", $data );
  6248. }
  6249. function remittanceHky() {
  6250. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6251. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  6252. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6253. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  6254. $page_size = 15;
  6255. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  6256. Doo::loadModel ( 'receipt' );
  6257. $receipt = new receipt ();
  6258. Doo::loadModel ( 'staff' );
  6259. $staff = new staff ();
  6260. $dateCondition = " and Year(executeDate) =" . $year;
  6261. if ($moth != 'MONTH')
  6262. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  6263. if ($day != 'DAY' && $moth != 'MONTH')
  6264. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  6265. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  6266. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  6267. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  6268. $limit = $pageinfo ['lower'] . ',' . $page_size;
  6269. $dayList = $receipt->find ( array (
  6270. 'select' => 'executeDate,sum(amount) as amount',
  6271. 'where' => $sql,
  6272. 'desc' => 'executeDate',
  6273. 'groupby' => 'executeDate',
  6274. 'limit' => $limit,
  6275. 'asArray' => true
  6276. ) );
  6277. // print_r($dayList);
  6278. foreach ( $dayList as $key => $value ) {
  6279. $remitString = "";
  6280. $receiptList = $receipt->find ( array (
  6281. 'select' => 'rid,executeDate,amount,staff,cid',
  6282. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  6283. 'desc' => 'executeDate',
  6284. 'asArray' => true
  6285. ) );
  6286. foreach ( $receiptList as $k => $v ) {
  6287. $sinfo = $staff->getOne ( array (
  6288. 'select' => 'username,category',
  6289. 'where' => ' sid=' . $v ['staff'],
  6290. 'asArray' => true
  6291. ) );
  6292. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  6293. }
  6294. $dayList [$key] ['staff'] = $remitString;
  6295. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  6296. }
  6297. // print_r($dayList);
  6298. $mothHtml = "";
  6299. for($i = 1; $i <= 12; $i ++) {
  6300. if ($moth == $i)
  6301. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6302. else
  6303. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6304. }
  6305. $dayHtml = "";
  6306. if ($day != "DAY" || $moth != "MONTH") {
  6307. for($i = 1; $i <= 31; $i ++) {
  6308. if ($day == $i)
  6309. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6310. else
  6311. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6312. }
  6313. }
  6314. $data ['page'] = $pageinfo;
  6315. $data ['year'] = $year;
  6316. $data ['moth'] = $moth;
  6317. $data ['day'] = $day;
  6318. $data ['get'] = $get;
  6319. $data ['dayHtml'] = $dayHtml;
  6320. $data ['mothHtml'] = $mothHtml;
  6321. $data ['receiptList'] = $dayList;
  6322. $data ['memu'] = "receipt";
  6323. $data ['staff'] = $this->staff;
  6324. $data ['receiptMemu'] = 'remittanceHky';
  6325. $data ['verifyId'] = $this->verifyId;
  6326. $data ['executeId'] = $this->executeId;
  6327. $this->render ( "/admin/remittanceHky", $data );
  6328. }
  6329. function remittancep() {
  6330. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  6331. Doo::loadModel ( 'receipt' );
  6332. $receipt = new receipt ();
  6333. Doo::loadModel ( 'staff' );
  6334. $staff = new staff ();
  6335. Doo::loadClass ( 'XDeode' );
  6336. $XDeode = new XDeode ( 5 );
  6337. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  6338. $rplist = $receipt->find ( array (
  6339. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6340. 'asArray' => true
  6341. ) );
  6342. $dayList = $receipt->find ( array (
  6343. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6344. 'desc' => 'executeDate',
  6345. 'groupby' => 'staff',
  6346. 'asArray' => true
  6347. ) );
  6348. $html = '';
  6349. foreach ( $dayList as $key => $value ) {
  6350. $sinfo = $staff->getOne ( array (
  6351. 'select' => 'username,category',
  6352. 'where' => ' sid=' . $value ['staff'],
  6353. 'asArray' => true
  6354. ) );
  6355. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  6356. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  6357. $au = 0;
  6358. foreach ( $rplist as $k => $v ) {
  6359. if ($value ['staff'] == $v ['staff']) {
  6360. $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>';
  6361. $au += $v ['amount'];
  6362. }
  6363. }
  6364. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  6365. }
  6366. $data ['html'] = $html;
  6367. $data ['memu'] = "receipt";
  6368. $data ['staff'] = $this->staff;
  6369. $data ['receiptMemu'] = 'remittanceHky';
  6370. $data ['verifyId'] = $this->verifyId;
  6371. $data ['executeId'] = $this->executeId;
  6372. $this->render ( "/admin/remittancep", $data );
  6373. }
  6374. function ajaxGetReceiptDetails() {
  6375. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  6376. Doo::loadClass ( 'XDeode' );
  6377. $XDeode = new XDeode ( 5 );
  6378. $rid = $XDeode->decode ( $rid );
  6379. if (empty ( $rid )) {
  6380. echo json_encode ( array (
  6381. 'status' => 2,
  6382. 'msg' => 'illegal request'
  6383. ) );
  6384. die ();
  6385. }
  6386. Doo::loadModel ( 'receipt' );
  6387. $receipt = new receipt ();
  6388. Doo::loadModel ( 'staff' );
  6389. $staff = new staff ();
  6390. $rinfo = $receipt->getOne ( array (
  6391. 'where' => 'rid= ' . $rid,
  6392. 'asArray' => true
  6393. ) );
  6394. $sinfo = $staff->getOne ( array (
  6395. 'select' => 'username,category',
  6396. 'where' => ' sid=' . $rinfo ['staff'],
  6397. 'asArray' => true
  6398. ) );
  6399. $rinfo ['reviseDetail'] = array ();
  6400. if (! empty ( $rinfo ['reviseDetail'] ))
  6401. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  6402. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  6403. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  6404. $rinfo ['category'] = $sinfo ['category'];
  6405. $verifyStaff = array ();
  6406. if (! empty ( $rinfo ['verifyStaff'] ))
  6407. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  6408. $relust = $rinfo ['sum'] - $rinfo ['loanSum'];
  6409. $rinfo ['relust'] = $relust;
  6410. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  6411. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  6412. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  6413. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  6414. // 费用执行人相关数据
  6415. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6416. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6417. foreach ( $executeCopy as $k => $v ) {
  6418. $executeCopy [$k] ['date'] = '';
  6419. $executeCopy [$k] ['opinion'] = '';
  6420. $executeCopy [$k] ['status'] = '';
  6421. if (! empty ( $executeStaff ))
  6422. foreach ( $executeStaff as $m => $u ) {
  6423. if ($v [0] == $m) {
  6424. $executeCopy [$k] ['date'] = $u ['date'];
  6425. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  6426. $executeCopy [$k] ['status'] = $u ['status'];
  6427. break;
  6428. }
  6429. }
  6430. }
  6431. $rinfo ['executeCopy'] = $executeCopy;
  6432. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  6433. if ($rinfo ['Rtype'] == 1) { // 借款费用
  6434. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6435. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  6436. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  6437. $html .= '<tr><th>' . $value ['name'] . '</th>
  6438. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6439. }
  6440. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6441. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6442. <tr><th class="taC" colspan="2">费用说明</th>
  6443. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6444. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6445. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  6446. </tbody></table>';
  6447. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  6448. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6449. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6450. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6451. $html .= '<tr><th>' . $value ['name'] . '</th>
  6452. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6453. }
  6454. $html .= '<tr><th class="taR">合计</th>
  6455. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6456. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6457. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6458. $html .= '<tr><th>' . $value ['name'] . '</th>
  6459. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6460. }
  6461. $html .= '<tr><th class="taR">合计</th>
  6462. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6463. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6464. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6465. $html .= '<tr><th>' . $value ['name'] . '</th>
  6466. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6467. }
  6468. $html .= '<tr><th class="taR">合计</th>
  6469. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6470. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6471. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6472. $html .= '<tr><th>' . $value ['name'] . '</th>
  6473. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6474. }
  6475. $html .= '<tr><th class="taR">合计</th>
  6476. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6477. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6478. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6479. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6480. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6481. }
  6482. $html .= '<tr><th class="taR">合计</th>
  6483. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6484. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6485. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6486. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6487. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6488. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6489. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6490. <tr';
  6491. if ($rinfo ['relust'] >= 0) {
  6492. $html .= 'class="success"';
  6493. } else {
  6494. $html .= 'class="error"';
  6495. }
  6496. $html .= '><td class="taR"><b>借款结余</b></td>
  6497. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  6498. </tbody></table>
  6499. ';
  6500. }
  6501. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  6502. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6503. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  6504. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6505. $html .= '<tr><th>' . $value ['name'] . '</th>
  6506. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6507. }
  6508. $html .= '<tr><th class="taR">合计</th>
  6509. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6510. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6511. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6512. <tr><th class="taC" colspan="2">费用说明</th>
  6513. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6514. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6515. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6516. </tbody></table>';
  6517. } else {
  6518. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6519. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6520. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6521. $html .= '<tr><th>' . $value ['name'] . '</th>
  6522. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6523. }
  6524. $html .= '<tr><th class="taR">合计</th>
  6525. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6526. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6527. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6528. $html .= '<tr><th>' . $value ['name'] . '</th>
  6529. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6530. }
  6531. $html .= '<tr><th class="taR">合计</th>
  6532. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6533. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6534. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6535. $html .= '<tr><th>' . $value ['name'] . '</th>
  6536. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6537. }
  6538. $html .= '<tr><th class="taR">合计</th>
  6539. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6540. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6541. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6542. $html .= '<tr><th>' . $value ['name'] . '</th>
  6543. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6544. }
  6545. $html .= '<tr><th class="taR">合计</th>
  6546. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6547. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6548. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6549. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6550. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6551. }
  6552. $html .= '<tr><th class="taR">合计</th>
  6553. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6554. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6555. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6556. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6557. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6558. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6559. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  6560. $html .= '</tbody></table>';
  6561. /*
  6562. * <table class="table table-bordered table-condensed table-hover"> <tbody> <tr><th colspan="2" class="taC">日常相关费用</th></tr> <!-- loop receiptList' value.accountItem.日常相关费用 --> <tr><th>{{receiptList' value' value.name}}</th><td width="140" class="taR">¥{{receiptList' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptList' value.accountItem.cSum.agencySum}}</td></tr> <tr><th colspan="2" class="taC">差旅相关费用</th></tr> <!-- loop receiptDetail' value.accountItem.差旅相关费用 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.travelSum}}</td></tr> <tr><th colspan="2" class="taC">培训班费用</th></tr> <!-- loop receiptDetail' value.accountItem.培训班费用 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.trainSum}}</td></tr> <tr><th colspan="2" class="taC">其他</th></tr> <!-- loop receiptDetail' value.accountItem.其他 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.otherSum}}</td></tr> <tr><th colspan="2" class="taC">报销金额调整</th></tr> <!-- loop receiptList' value.reviseDetail --> <tr><th><span class="interval">|</span>{{receiptList' value' value.name}}:{{receiptList' value' value.description}}</th><td class="taR">¥{{receiptList' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colOrange taR">¥{{receiptList' value.revisePrice}}</td></tr> <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr> <tr><th style="text-align:center" colspan="2">{{receiptDetail' value.category}}</th></tr> <tr><th class="taC" colspan="2">报销说明</th></tr> <tr><td colspan="2">{{receiptDetail' value.explanation}}</td></tr> <tr class="warning"><td class="taR"><b>({{receiptDetail' value.receiptOrder}})本次报销费用合计</b></td> <td class="colGreed taR"><b style="font-size:24px">¥{{receiptDetail' value.sum}}</b><br>{{receiptDetail' value.sumCN}}</td></tr> </tbody> </table>
  6563. */
  6564. }
  6565. // print_r($verifyStaff);die;
  6566. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  6567. foreach ( $verifyStaff as $key => $value ) {
  6568. $key = trim ( strtr ( $key, '_R', ' ' ) );
  6569. $sinfo = $staff->getOne ( array (
  6570. 'select' => 'username',
  6571. 'where' => ' sid=' . $key,
  6572. 'asArray' => true
  6573. ) );
  6574. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6575. }
  6576. $html .= '</tbody></table>';
  6577. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  6578. foreach ( $rinfo ['executeCopy'] as $value ) {
  6579. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6580. }
  6581. $html .= '</tbody></table>';
  6582. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  6583. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  6584. </tr></table>';
  6585. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  6586. echo json_encode ( array (
  6587. 'status' => 1,
  6588. 'html' => $html
  6589. ) );
  6590. die ();
  6591. }
  6592. function remittance() {
  6593. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6594. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6595. Doo::loadModel ( 'receipt' );
  6596. $receipt = new receipt ();
  6597. Doo::loadModel ( 'staff' );
  6598. $staff = new staff ();
  6599. $dateCondition = " and Year(pastDate) =" . $year;
  6600. if (! empty ( $month ))
  6601. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  6602. // get Receipt By verifyID status 1
  6603. $receiptList = $receipt->find ( array (
  6604. 'select' => 'sum(sum) as sum,staff,pastDate',
  6605. 'where' => ' status=1' . $dateCondition,
  6606. 'desc' => 'pastDate',
  6607. 'groupby' => 'staff,pastDate',
  6608. 'asArray' => true
  6609. ) );
  6610. $dateList = $receipt->find ( array (
  6611. 'select' => 'pastDate,verifyStaff',
  6612. 'where' => ' status=1' . $dateCondition,
  6613. 'desc' => 'pastDate',
  6614. 'groupby' => 'pastDate',
  6615. 'asArray' => true
  6616. ) );
  6617. $dataList = array ();
  6618. foreach ( $dateList as $d => $a ) {
  6619. $dataList [$a ['pastDate']] = array ();
  6620. $daySum = 0;
  6621. foreach ( $receiptList as $key => $value ) {
  6622. if ($a ['pastDate'] == $value ['pastDate']) {
  6623. $oderList = $receipt->find ( array (
  6624. 'select' => 'receiptOrder',
  6625. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  6626. 'asArray' => true
  6627. ) );
  6628. $list = array ();
  6629. $html = "";
  6630. foreach ( $oderList as $v ) {
  6631. array_push ( $list, $v ['receiptOrder'] );
  6632. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  6633. }
  6634. $receiptList [$key] ['receiptOrder'] = $html;
  6635. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  6636. $sinfo = $staff->getOne ( array (
  6637. 'select' => 'username ',
  6638. 'where' => ' sid=' . $value ['staff'],
  6639. 'asArray' => true
  6640. ) );
  6641. $receiptList [$key] ['username'] = $sinfo ['username'];
  6642. $daySum += $value ['sum'];
  6643. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  6644. }
  6645. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  6646. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  6647. }
  6648. }
  6649. // print_r($dataList);
  6650. $data ['dataList'] = $dataList;
  6651. $mothHtml = "";
  6652. for($i = 1; $i <= 12; $i ++) {
  6653. if ($month == $i)
  6654. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6655. else
  6656. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6657. }
  6658. $data ['year'] = $year;
  6659. $data ['mothHtml'] = $mothHtml;
  6660. $data ['memu'] = "receipt";
  6661. $data ['staff'] = $this->staff;
  6662. $data ['receiptMemu'] = 'approval';
  6663. $data ['verifyId'] = $this->verifyId;
  6664. $data ['executeId'] = $this->executeId;
  6665. $this->render ( "/admin/saeaReportListPay", $data );
  6666. }
  6667. function revocationAdjustment() {
  6668. $sid = isset ( $this->params ['sid'] ) && is_numeric ( $this->params ['sid'] ) ? $this->params ['sid'] : 0;
  6669. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  6670. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6671. // echo $price;die;
  6672. if ((! empty ( $sid )) && ($price != - 99999) && (! empty ( $rid ))) {
  6673. Doo::loadModel ( 'receipt' );
  6674. $receipt = new receipt ();
  6675. $receiptDetail = $receipt->getOne ( array (
  6676. 'where' => 'rid=' . $rid,
  6677. 'asArray' => true
  6678. ) );
  6679. if (empty ( $receiptDetail ['reviseDetail'] ))
  6680. return "/approval";
  6681. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  6682. $RD = array ();
  6683. foreach ( $reviseDetail as $key => $value ) {
  6684. if ($value ['price'] == $price && $value ['sid'] == $sid)
  6685. continue;
  6686. array_push ( $RD, $value );
  6687. }
  6688. $reviseDetailString = json_encode ( $RD );
  6689. $receipt->reviseDetail = $reviseDetailString;
  6690. $receipt->sum = $receiptDetail ['sum'] - $price;
  6691. $receipt->revisePrice = $receiptDetail ['revisePrice'] - $price;
  6692. $receipt->update ( array (
  6693. 'where' => 'rid=' . $rid
  6694. ) );
  6695. }
  6696. // approvalEdi/37
  6697. return "/approvalEdi/" . $rid;
  6698. }
  6699. function updateApprovalReceipt() {
  6700. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6701. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  6702. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6703. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  6704. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  6705. if (! empty ( $rid )) {
  6706. Doo::loadModel ( "verify" );
  6707. $verify = new verify ();
  6708. Doo::loadModel ( "receiptDetail" );
  6709. $receiptDetailObj = new receiptDetail ();
  6710. Doo::loadModel ( "itemStatistics" );
  6711. Doo::loadModel ( "statistics" );
  6712. $statistics = new statistics ();
  6713. $itemStatistics = new itemStatistics ();
  6714. Doo::loadModel ( "receipt" );
  6715. $receipt = new receipt ();
  6716. $receiptDetail = $receipt->getOne ( array (
  6717. 'where' => 'rid=' . $rid . ' and status=2 ',
  6718. 'asArray' => true
  6719. ) );
  6720. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  6721. $nsflag = true;
  6722. foreach ( $nslist as $value ) {
  6723. if ($value == $this->staff ['0'] ['sid']) {
  6724. $nsflag = false;
  6725. break;
  6726. }
  6727. }
  6728. if (empty ( $receiptDetail ) || $nsflag)
  6729. return "/approval";
  6730. $verifyDetail = $verify->getOne ( array (
  6731. 'where' => ' vid =' . $receiptDetail ['verify'],
  6732. 'asArray' => true
  6733. ) );
  6734. $verifyString = $verifyDetail ['staff'];
  6735. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  6736. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  6737. if (empty ( $opinion )) {
  6738. if ($status == 3)
  6739. $opinion = "终止";
  6740. else
  6741. $opinion = "同意支付";
  6742. }
  6743. $nowStaff = 0;
  6744. $nowStaffList = array ();
  6745. if (empty ( $verifyStaff )) {
  6746. // 还需加入是否已经进入角色审批
  6747. if ($verifyDetail [0] [1] == 'ROLE') {
  6748. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  6749. foreach ( $vStaffString as $key => $value ) {
  6750. $staffK = explode ( "_", $value );
  6751. if ($staffK [0] != $this->staff [0] ['sid'])
  6752. array_push ( $nowStaffList, $staffK [0] );
  6753. }
  6754. // print_r($verifyDetail);
  6755. // die;
  6756. if (! empty ( $nowStaffList )) {
  6757. $nowStaff = implode ( ',', $nowStaffList );
  6758. $verifyStaff = array (
  6759. $this->staff [0] ['sid'] . "_R" => array (
  6760. 'date' => date ( 'Y-m-d' ),
  6761. 'opinion' => $opinion,
  6762. 'status' => $status,
  6763. 'nextStaff' => $verifyDetail [0] [0],
  6764. 'ROLE' => 1
  6765. )
  6766. );
  6767. } else {
  6768. $nowStaff = $verifyDetail [1] [0];
  6769. $verifyStaff = array (
  6770. $this->staff [0] ['sid'] . "_R" => array (
  6771. 'date' => date ( 'Y-m-d' ),
  6772. 'opinion' => $opinion,
  6773. 'status' => $status,
  6774. 'nextStaff' => $verifyDetail [1] [0]
  6775. )
  6776. );
  6777. }
  6778. } else {
  6779. if ($verifyDetail [1] [1] == 'ROLE') {
  6780. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  6781. // echo "dd";
  6782. foreach ( $vStaffString as $key => $value ) {
  6783. $staffK = explode ( "_", $value );
  6784. array_push ( $nowStaffList, $staffK [0] );
  6785. }
  6786. $nowStaff = implode ( ',', $nowStaffList );
  6787. $verifyStaff = array (
  6788. $this->staff [0] ['sid'] => array (
  6789. 'date' => date ( 'Y-m-d' ),
  6790. 'opinion' => $opinion,
  6791. 'status' => $status,
  6792. 'nextStaff' => $verifyDetail [1] [0],
  6793. 'ROLE' => 1
  6794. )
  6795. );
  6796. } else {
  6797. $nowStaff = $verifyDetail [1] [0];
  6798. $verifyStaff = array (
  6799. $this->staff [0] ['sid'] => array (
  6800. 'date' => date ( 'Y-m-d' ),
  6801. 'opinion' => $opinion,
  6802. 'status' => $status,
  6803. 'nextStaff' => $verifyDetail [1] [0]
  6804. )
  6805. );
  6806. }
  6807. }
  6808. if ($status == 3)
  6809. $verifyStaff = array (
  6810. 'final' => $status,
  6811. $this->staff [0] ['sid'] => array (
  6812. 'date' => date ( 'Y-m-d' ),
  6813. 'opinion' => $opinion,
  6814. 'status' => $status
  6815. )
  6816. );
  6817. $vStaffString = json_encode ( $verifyStaff );
  6818. $receipt->nowStaff = $nowStaff;
  6819. $receipt->verifyStaff = $vStaffString;
  6820. } else {
  6821. $VS = end ( $verifyStaff );
  6822. // 非角色审批
  6823. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  6824. $nextStaff = 0;
  6825. $roleSTF = false;
  6826. foreach ( $verifyDetail as $key => $value ) {
  6827. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  6828. if (isset ( $verifyDetail [$key + 1] )) {
  6829. $nextStaff = $verifyDetail [$key + 1] [0];
  6830. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  6831. $roleSTF = true;
  6832. }
  6833. break;
  6834. }
  6835. }
  6836. if (! $roleSTF) {
  6837. $nowStaff = $nextStaff;
  6838. $verifyStaff [$this->staff [0] ['sid']] = array (
  6839. 'date' => date ( 'Y-m-d' ),
  6840. 'opinion' => $opinion,
  6841. 'status' => $status,
  6842. 'nextStaff' => $nextStaff
  6843. );
  6844. } else {
  6845. // 获取角色下的所有用户ID
  6846. $nowStaffList = array ();
  6847. foreach ( $verifyDetail as $vfk ) {
  6848. if ($vfk [1] == 'ROLE') {
  6849. $vStaffString = json_decode ( $vfk [3] );
  6850. foreach ( $vStaffString as $key => $value ) {
  6851. $staffK = explode ( "_", $value );
  6852. array_push ( $nowStaffList, $staffK [0] );
  6853. }
  6854. }
  6855. }
  6856. $nowStaff = implode ( ',', $nowStaffList );
  6857. $verifyStaff [$this->staff [0] ['sid']] = array (
  6858. 'date' => date ( 'Y-m-d' ),
  6859. 'opinion' => $opinion,
  6860. 'status' => $status,
  6861. 'nextStaff' => $nextStaff,
  6862. 'ROLE' => 0
  6863. );
  6864. }
  6865. if ($status == 3) {
  6866. $verifyStaff ['final'] = $status;
  6867. $verifyStaff [$this->staff [0] ['sid']] = array (
  6868. 'date' => date ( 'Y-m-d' ),
  6869. 'opinion' => $opinion,
  6870. 'status' => $status
  6871. );
  6872. }
  6873. $vStaffString = json_encode ( $verifyStaff );
  6874. $receipt->nowStaff = $nowStaff;
  6875. $receipt->verifyStaff = $vStaffString;
  6876. }
  6877. // 角色审批
  6878. if (isset ( $VS ['ROLE'] )) {
  6879. // 找出角色人 当前审批角色组
  6880. $verifyJSStaff = array ();
  6881. $nowStaffList2 = array ();
  6882. foreach ( $verifyDetail as $key => $value ) {
  6883. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  6884. $verifyJSStaff = json_decode ( $value [3] );
  6885. foreach ( $verifyJSStaff as $m ) {
  6886. $staffK = explode ( "_", $m );
  6887. array_push ( $nowStaffList2, $staffK [0] );
  6888. }
  6889. // print_r($nowStaffList2);
  6890. }
  6891. }
  6892. $RoleVerifyStaff = array ();
  6893. foreach ( $verifyStaff as $key => $value ) {
  6894. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  6895. foreach ( $nowStaffList2 as $m ) {
  6896. if ($key == $m . "_R")
  6897. $RoleVerifyStaff [$key] = $value;
  6898. }
  6899. }
  6900. }
  6901. // print_r($verifyStaff);
  6902. // print_r($nowStaffList2);
  6903. // print_r($RoleVerifyStaff);
  6904. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  6905. // print_r($verifyJSStaff);
  6906. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  6907. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  6908. // 下一个审批人ID
  6909. $nextStaff = 0;
  6910. $falg = false;
  6911. foreach ( $verifyDetail as $key => $value ) {
  6912. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  6913. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  6914. $falg = true;
  6915. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  6916. $nowStaffList = array ();
  6917. foreach ( $vStaffString as $v ) {
  6918. $staffK = explode ( "_", $v );
  6919. array_push ( $nowStaffList, $staffK [0] );
  6920. }
  6921. $nowStaff = implode ( ',', $nowStaffList );
  6922. $nextStaff = $verifyDetail [$key + 1] [0];
  6923. } elseif (isset ( $verifyDetail [$key + 1] )) {
  6924. $nextStaff = $verifyDetail [$key + 1] [0];
  6925. $nowStaff = $nextStaff;
  6926. } else
  6927. $nowStaff = '';
  6928. break;
  6929. }
  6930. }
  6931. if ($falg)
  6932. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6933. 'date' => date ( 'Y-m-d' ),
  6934. 'opinion' => $opinion,
  6935. 'status' => $status,
  6936. 'nextStaff' => $nextStaff,
  6937. 'ROLE' => 1
  6938. );
  6939. else
  6940. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6941. 'date' => date ( 'Y-m-d' ),
  6942. 'opinion' => $opinion,
  6943. 'status' => $status,
  6944. 'nextStaff' => $nextStaff
  6945. );
  6946. // print_r($verifyStaff);
  6947. // echo $nowStaff;die;
  6948. } else { // 进入下一个角色或者审批人
  6949. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  6950. //
  6951. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  6952. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6953. 'date' => date ( 'Y-m-d' ),
  6954. 'opinion' => $opinion,
  6955. 'status' => $status,
  6956. 'nextStaff' => $VS ['nextStaff'],
  6957. 'ROLE' => 1
  6958. );
  6959. // print_r($verifyStaff);
  6960. // die;
  6961. }
  6962. if ($status == 3) {
  6963. $verifyStaff ['final'] = $status;
  6964. $verifyStaff [$this->staff [0] ['sid']] = array (
  6965. 'date' => date ( 'Y-m-d' ),
  6966. 'opinion' => $opinion,
  6967. 'status' => $status
  6968. );
  6969. }
  6970. $vStaffString = json_encode ( $verifyStaff );
  6971. $receipt->verifyStaff = $vStaffString;
  6972. $receipt->nowStaff = $nowStaff;
  6973. // die;
  6974. // }
  6975. // print_r($verifyStaff);
  6976. // die;
  6977. }
  6978. // print_r($verifyStaff);die;
  6979. }
  6980. // print_r($verifyDetail);
  6981. $roleKey = 0;
  6982. $roleId = 0;
  6983. $verifyDetailCopy = array ();
  6984. foreach ( $verifyDetail as $k => $v ) {
  6985. if ($v [1] == 'ROLE') {
  6986. $roleId = $v [0];
  6987. $roleVerify = json_decode ( $v [3], true );
  6988. $roleKey = $k;
  6989. $roleArray = array ();
  6990. foreach ( $roleVerify as $o => $p ) {
  6991. $staffID = explode ( '_', $p );
  6992. $exp = array (
  6993. 0 => $staffID [0],
  6994. 1 => $staffID [1]
  6995. );
  6996. array_push ( $roleArray, $exp );
  6997. }
  6998. $verifyDetailCopy [$v [0]] = $roleArray;
  6999. }
  7000. }
  7001. // print_r($verifyDetail);
  7002. foreach ( $verifyDetailCopy as $k => $v ) {
  7003. foreach ( $verifyDetail as $m => $n ) {
  7004. if ($n [0] == $k) {
  7005. array_splice ( $verifyDetail, $m, 1, $v );
  7006. }
  7007. }
  7008. }
  7009. // die;
  7010. // if (!empty($roleArray))
  7011. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  7012. // echo $roleId;
  7013. // print_r($verifyStaff);
  7014. // print_r($verifyDetail);
  7015. // die;
  7016. Doo::loadModel ( "receiptLog" );
  7017. $receiptLog = new receiptLog ();
  7018. // 审批日志
  7019. if (! isset ( $verifyStaff ['final'] )) {
  7020. if (! empty ( $roleId )) {
  7021. Doo::loadModel ( "role" );
  7022. $role = new role ();
  7023. $roleInfo = $role->getOne ( array (
  7024. 'where' => 'rid=' . $roleId,
  7025. 'asArray' => true
  7026. ) );
  7027. $receiptLog->rolename = $roleInfo ['name'];
  7028. }
  7029. $receiptLog->username = $this->staff [0] ['username'];
  7030. $receiptLog->uid = $this->staff [0] ['sid'];
  7031. $receiptLog->date = date ( "Y-m-d" );
  7032. $receiptLog->opinion = $opinion;
  7033. $receiptLog->img = $this->staff [0] ['avatar'];
  7034. $receiptLog->status = 1;
  7035. $receiptLog->rid = $rid;
  7036. $receiptLog->insert ();
  7037. }
  7038. if (isset ( $verifyStaff ['final'] )) { // rDetail
  7039. $receipt->verifyBreakup = $verifyString;
  7040. $receipt->status = 3;
  7041. $receiptDetailObj->status = 3;
  7042. $receiptDetailObj->update ( array (
  7043. 'where' => 'rid=' . $rid
  7044. ) );
  7045. if (! empty ( $roleId )) {
  7046. Doo::loadModel ( "role" );
  7047. $role = new role ();
  7048. $roleInfo = $role->getOne ( array (
  7049. 'where' => 'rid=' . $roleId,
  7050. 'asArray' => true
  7051. ) );
  7052. $receiptLog->rolename = $roleInfo ['name'];
  7053. }
  7054. $receiptLog->username = $this->staff [0] ['username'];
  7055. $receiptLog->uid = $this->staff [0] ['sid'];
  7056. $receiptLog->date = date ( "Y-m-d" );
  7057. $receiptLog->opinion = $opinion;
  7058. $receiptLog->img = $this->staff [0] ['avatar'];
  7059. $receiptLog->status = 3;
  7060. $receiptLog->rid = $rid;
  7061. $receiptLog->insert ();
  7062. // 微信企业号通知
  7063. $this->setWXMsg ( $rid, 3 );
  7064. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  7065. $receipt->status = 1;
  7066. $reviseSum = 0;
  7067. $receipt->verifyBreakup = $verifyString;
  7068. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  7069. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7070. foreach ( $reviseDetail as $key => $value ) {
  7071. $receiptDetailObj = new receiptDetail ();
  7072. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7073. $receiptDetailObj->item = $value ['description'];
  7074. $receiptDetailObj->itemCategory = "报销金额调整";
  7075. $receiptDetailObj->price = $value ['price'];
  7076. $receiptDetailObj->date = $receiptDetail ['date'];
  7077. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  7078. $receiptDetailObj->rid = $rid;
  7079. $receiptDetailObj->status = 1;
  7080. $receiptDetailObj->insert ();
  7081. $reviseSum += $value ['price'];
  7082. }
  7083. $itemStatistics = new itemStatistics ();
  7084. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7085. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7086. $itemStatistics->price = $reviseSum;
  7087. $itemStatistics->itemCategory = "报销金额调整";
  7088. $itemStatistics->date = $receiptDetail ['date'];
  7089. $itemStatistics->insert ();
  7090. }
  7091. $receiptDetailObj = new receiptDetail ();
  7092. $receiptDetailObj->status = 1;
  7093. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  7094. $receiptDetailObj->update ( array (
  7095. 'where' => 'rid=' . $rid
  7096. ) );
  7097. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7098. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7099. $stat = $statistics->getOne ( array (
  7100. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  7101. 'asArray' => true
  7102. ) );
  7103. if (empty ( $stat )) {
  7104. $statistics->date = $receiptDetail ['date'];
  7105. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7106. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7107. $statistics->agPrice = $receiptDetail ['sum'];
  7108. $statistics->rePrice = $reviseSum;
  7109. $statistics->insert ();
  7110. } else {
  7111. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  7112. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  7113. $statistics->update ( array (
  7114. 'where' => 'sid=' . $stat ['sid']
  7115. ) );
  7116. }
  7117. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7118. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7119. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  7120. foreach ( $accountItem ['cSum'] as $key => $value ) {
  7121. if ($key == "agencySum") {
  7122. $iStatistics = $itemStatistics->getOne ( array (
  7123. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  7124. 'asArray' => true
  7125. ) );
  7126. if (empty ( $iStatistics )) {
  7127. $itemStatistics->cid = $receiptDetail ['cid'];
  7128. ;
  7129. $itemStatistics->staff = $receiptDetail ['staff'];
  7130. $itemStatistics->price = $value;
  7131. $itemStatistics->itemCategory = $this->AGENCY;
  7132. $itemStatistics->date = $receiptDetail ['date'];
  7133. $itemStatistics->insert ();
  7134. } else {
  7135. if (! empty ( $value )) {
  7136. $itemStatistics->price = $value + $iStatistics ['price'];
  7137. $itemStatistics->update ( array (
  7138. 'where' => 'sid=' . $iStatistics ['sid']
  7139. ) );
  7140. }
  7141. }
  7142. } elseif ($key == "travelSum") {
  7143. $iStatistics = $itemStatistics->getOne ( array (
  7144. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  7145. 'asArray' => true
  7146. ) );
  7147. if (empty ( $iStatistics )) {
  7148. $itemStatistics->cid = $receiptDetail ['cid'];
  7149. $itemStatistics->staff = $receiptDetail ['staff'];
  7150. $itemStatistics->price = $value;
  7151. $itemStatistics->itemCategory = $this->TRAVEL;
  7152. $itemStatistics->date = $receiptDetail ['date'];
  7153. $itemStatistics->insert ();
  7154. } else {
  7155. if (! empty ( $value )) {
  7156. $itemStatistics->price = $value + $iStatistics ['price'];
  7157. $itemStatistics->update ( array (
  7158. 'where' => 'sid=' . $iStatistics ['sid']
  7159. ) );
  7160. }
  7161. }
  7162. } elseif ($key == "trainSum") {
  7163. $iStatistics = $itemStatistics->getOne ( array (
  7164. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  7165. 'asArray' => true
  7166. ) );
  7167. if (empty ( $iStatistics )) {
  7168. $itemStatistics->cid = $receiptDetail ['cid'];
  7169. $itemStatistics->staff = $receiptDetail ['staff'];
  7170. $itemStatistics->price = $value;
  7171. $itemStatistics->itemCategory = $this->TRAIN;
  7172. $itemStatistics->date = $receiptDetail ['date'];
  7173. $itemStatistics->insert ();
  7174. } else {
  7175. if (! empty ( $value )) {
  7176. $itemStatistics->price = $value + $iStatistics ['price'];
  7177. $itemStatistics->update ( array (
  7178. 'where' => 'sid=' . $iStatistics ['sid']
  7179. ) );
  7180. }
  7181. }
  7182. } elseif ($key == "otherSum") {
  7183. $iStatistics = $itemStatistics->getOne ( array (
  7184. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  7185. 'asArray' => true
  7186. ) );
  7187. if (empty ( $iStatistics )) {
  7188. $itemStatistics->cid = $receiptDetail ['cid'];
  7189. $itemStatistics->staff = $receiptDetail ['staff'];
  7190. $itemStatistics->price = $value;
  7191. $itemStatistics->itemCategory = $this->OTHER;
  7192. $itemStatistics->date = $receiptDetail ['date'];
  7193. $itemStatistics->insert ();
  7194. } else {
  7195. if (! empty ( $value )) {
  7196. $itemStatistics->price = $value + $iStatistics ['price'];
  7197. $itemStatistics->update ( array (
  7198. 'where' => 'sid=' . $iStatistics ['sid']
  7199. ) );
  7200. }
  7201. }
  7202. }
  7203. }
  7204. $receipt->pastDate = date ( "Y-m-d" );
  7205. // 微信企业号通知
  7206. $this->setWXMsg ( $rid, 1 );
  7207. }
  7208. $receipt->amount = $amount;
  7209. $receipt->update ( array (
  7210. 'where' => ' rid = ' . $rid
  7211. ) );
  7212. // 进入下一条审批费用新加需求
  7213. $vidList = array ();
  7214. $verifyDetail = $verify->find ( array (
  7215. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  7216. 'asArray' => true
  7217. ) );
  7218. foreach ( $verifyDetail as $key => $value ) {
  7219. array_push ( $vidList, $value ['vid'] );
  7220. }
  7221. $vid = implode ( ",", $vidList );
  7222. if (empty ( $verifyDetail ))
  7223. $vid = 0;
  7224. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  7225. $receipt=new receipt();
  7226. $rd = $receipt->getOne ( array (
  7227. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  7228. 'asc' => 'rid',
  7229. 'asArray' => true
  7230. ) );
  7231. if (empty ( $rd )) {
  7232. return '/approvalExpenses/pendApproval';
  7233. }
  7234. if ($rd ['Rtype'] == 1) {
  7235. if ($rd ['isBK'] == 1) {
  7236. return '/receiptburEdi/' . $rd ['rid'];
  7237. } else {
  7238. return '/expensesEdi/' . $rd ['rid'];
  7239. }
  7240. } elseif ($rd ['Rtype'] == 2) {
  7241. return '/remitApproval/' . $rd ['rid'];
  7242. } else {
  7243. return '/receiptburEdi/' . $rd ['rid'];
  7244. }
  7245. //return "/approvalExpenses/pendApproval";
  7246. }
  7247. }
  7248. function expensesRetreats() {
  7249. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7250. if (! empty ( $rid )) {
  7251. // 操作记录
  7252. Doo::loadModel ( "receipt" );
  7253. $receipt = new receipt ();
  7254. Doo::loadModel ( "receiptLog" );
  7255. $receiptLog = new receiptLog ();
  7256. Doo::loadModel ( "verify" );
  7257. $verify = new verify ();
  7258. $receiptInfo = $receipt->getOne ( array (
  7259. 'where' => 'rid=' . $rid,
  7260. 'asArray' => true
  7261. ) );
  7262. $vr = $verify->getOne ( array (
  7263. 'where' => 'vid=' . $receiptInfo ['verify'],
  7264. 'asArray' => true
  7265. ) );
  7266. $jd = json_decode ( $vr ['staff'] );
  7267. $roleId = 0;
  7268. foreach ( $jd as $key => $value ) {
  7269. if ($value [1] == 'ROLE') {
  7270. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7271. if ($pos !== false) {
  7272. $roleId = $value [0];
  7273. }
  7274. }
  7275. }
  7276. // 审批日志
  7277. // echo $roleId;die;
  7278. if (! empty ( $roleId )) {
  7279. Doo::loadModel ( "role" );
  7280. $role = new role ();
  7281. $roleInfo = $role->getOne ( array (
  7282. 'where' => 'rid=' . $roleId,
  7283. 'asArray' => true
  7284. ) );
  7285. $receiptLog->rolename = $roleInfo ['name'];
  7286. }
  7287. $receiptLog->username = $this->staff [0] ['username'];
  7288. $receiptLog->uid = $this->staff [0] ['sid'];
  7289. $receiptLog->date = date ( "Y-m-d" );
  7290. $receiptLog->opinion = '撤回';
  7291. $receiptLog->img = $this->staff [0] ['avatar'];
  7292. $receiptLog->status = 4;
  7293. $receiptLog->rid = $rid;
  7294. $receiptLog->insert ();
  7295. $receipt->status = 4;
  7296. $receipt->update ( array (
  7297. 'where' => 'rid=' . $rid
  7298. ) );
  7299. // 微信企业号通知
  7300. $this->setWXMsg ( $rid, 2 );
  7301. }
  7302. // echo "ddd";
  7303. return '/approvalExpenses/pendApproval';
  7304. }
  7305. function updateCheReceipt() {
  7306. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7307. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7308. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  7309. if (! empty ( $rid )) {
  7310. // 操作记录
  7311. Doo::loadModel ( "receipt" );
  7312. $receipt = new receipt ();
  7313. Doo::loadModel ( "receiptLog" );
  7314. $receiptLog = new receiptLog ();
  7315. Doo::loadModel ( "verify" );
  7316. $verify = new verify ();
  7317. $receiptInfo = $receipt->getOne ( array (
  7318. 'where' => 'rid=' . $rid . ' and status=2',
  7319. 'asArray' => true
  7320. ) );
  7321. if (empty ( $receiptInfo )) {
  7322. echo json_encode ( array (
  7323. 'status' => 2
  7324. ) );
  7325. die ();
  7326. }
  7327. $vr = $verify->getOne ( array (
  7328. 'where' => 'vid=' . $receiptInfo ['verify'],
  7329. 'asArray' => true
  7330. ) );
  7331. $jd = json_decode ( $vr ['staff'] );
  7332. $roleId = 0;
  7333. foreach ( $jd as $key => $value ) {
  7334. if ($value [1] == 'ROLE') {
  7335. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7336. if ($pos !== false) {
  7337. $roleId = $value [0];
  7338. }
  7339. }
  7340. }
  7341. // 审批日志
  7342. // echo $roleId;die;
  7343. if (! empty ( $roleId )) {
  7344. Doo::loadModel ( "role" );
  7345. $role = new role ();
  7346. $roleInfo = $role->getOne ( array (
  7347. 'where' => 'rid=' . $roleId,
  7348. 'asArray' => true
  7349. ) );
  7350. $receiptLog->rolename = $roleInfo ['name'];
  7351. }
  7352. $receiptLog->username = $this->staff [0] ['username'];
  7353. $receiptLog->uid = $this->staff [0] ['sid'];
  7354. $receiptLog->date = date ( "Y-m-d" );
  7355. $receiptLog->opinion = $opinion;
  7356. $receiptLog->img = $this->staff [0] ['avatar'];
  7357. $receiptLog->status = 4;
  7358. $receiptLog->rid = $rid;
  7359. $receiptLog->insert ();
  7360. $receipt->status = 4;
  7361. $receipt->update ( array (
  7362. 'where' => 'rid=' . $rid
  7363. ) );
  7364. // 微信企业号通知
  7365. $this->setWXMsg ( $rid, 2 );
  7366. echo json_encode ( array (
  7367. 'status' => 1
  7368. ) );
  7369. // Header("HTTP/1.1 303 See Other");
  7370. // Header("Location: /approvalExpenses/pendApproval");
  7371. die ();
  7372. }
  7373. echo json_encode ( array (
  7374. 'status' => 2
  7375. ) );
  7376. die ();
  7377. // echo "ddd";
  7378. // return '/saeaBorad';
  7379. }
  7380. function revisePrice() {
  7381. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  7382. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  7383. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7384. // echo $price;die;
  7385. if (! empty ( $rid )) {
  7386. Doo::loadModel ( "receipt" );
  7387. $receipt = new receipt ();
  7388. $receiptDetail = $receipt->getOne ( array (
  7389. 'where' => 'rid=' . $rid . ' and status=2 ',
  7390. 'asArray' => true
  7391. ) );
  7392. if (empty ( $receiptDetail ))
  7393. return "/approval";
  7394. $reviseDetail = array ();
  7395. if (empty ( $receiptDetail ['reviseDetail'] )) {
  7396. array_push ( $reviseDetail, array (
  7397. 'sid' => $this->staff [0] ['sid'],
  7398. 'name' => $this->staff [0] ['username'],
  7399. 'description' => $description,
  7400. 'price' => $price
  7401. ) );
  7402. $reviseDetailString = json_encode ( $reviseDetail );
  7403. $receipt->reviseDetail = $reviseDetailString;
  7404. $receipt->revisePrice = $price;
  7405. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7406. } else {
  7407. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7408. array_push ( $reviseDetail, array (
  7409. 'sid' => $this->staff [0] ['sid'],
  7410. 'name' => $this->staff [0] ['username'],
  7411. 'description' => $description,
  7412. 'price' => $price
  7413. ) );
  7414. $reviseDetailString = json_encode ( $reviseDetail );
  7415. $receipt->reviseDetail = $reviseDetailString;
  7416. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  7417. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7418. }
  7419. $receipt->update ( array (
  7420. 'where' => 'rid=' . $rid
  7421. ) );
  7422. }
  7423. return '/approvalEdi/' . $rid;
  7424. }
  7425. function personalCollect() {
  7426. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7427. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  7428. $this->showCache ( $path );
  7429. Doo::loadModel ( "receiptDetail" );
  7430. Doo::loadModel ( "itemStatistics" );
  7431. Doo::loadModel ( 'statistics' );
  7432. $statistics = new statistics ();
  7433. $itemStatistics = new itemStatistics ();
  7434. $receiptDetail = new receiptDetail ();
  7435. $receiptCollectList = $receiptDetail->find ( array (
  7436. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7437. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7438. 'groupby' => 'itemCategory,Month(date)',
  7439. 'asArray' => true
  7440. ) );
  7441. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  7442. 'where' => 'staff=' . $this->staff [0] ['sid'],
  7443. 'asArray' => true
  7444. ) );
  7445. // create collect html
  7446. $collectArray = array (
  7447. '日常相关费用' => array (),
  7448. '差旅相关费用' => array (),
  7449. '培训班费用' => array (),
  7450. '其他' => array ()
  7451. );
  7452. $adjustment = array ();
  7453. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  7454. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7455. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  7456. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7457. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  7458. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7459. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  7460. array_push ( $collectArray ['其他'], $collectHtml );
  7461. $data ['collectArray'] = $collectArray;
  7462. // statistics html
  7463. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7464. if (empty ( $stList ))
  7465. $stList = array (
  7466. 'rePrice' => 0,
  7467. 'agPrice' => 0
  7468. );
  7469. $data ['stList'] = array (
  7470. 'rePrice' => $stList ['rePrice'],
  7471. 'agPrice' => $stList ['agPrice'],
  7472. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7473. );
  7474. // Adjustment price html
  7475. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7476. array_push ( $adjustment, $collectHtml );
  7477. $data ['adjustment'] = $adjustment;
  7478. // total price html
  7479. $collectHtml = "";
  7480. $total = 0;
  7481. for($i = 1; $i <= 12; $i ++) {
  7482. $sumPrice = 0;
  7483. foreach ( $receiptCollectList as $key => $value ) {
  7484. if ($value ['month'] == $i) {
  7485. $sumPrice += $value ['price'];
  7486. }
  7487. }
  7488. if ($sumPrice == 0)
  7489. $collectHtml .= '<td class="taR">-</td>';
  7490. else
  7491. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7492. $total += $sumPrice;
  7493. }
  7494. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7495. $data ['totalPrice'] = $collectHtml;
  7496. $data ['year'] = $year;
  7497. $data ['totalYear'] = $total;
  7498. $data ['memu'] = "receipt";
  7499. $data ['staff'] = $this->staff;
  7500. $data ['receiptMemu'] = 'personalCollect';
  7501. $data ['verifyId'] = $this->verifyId;
  7502. $data ['executeId'] = $this->executeId;
  7503. // year staff status 2,4
  7504. if ($year < date ( "Y" )) {
  7505. Doo::loadModel ( 'receipt' );
  7506. $receipt = new receipt ();
  7507. $receiptList = $receipt->find ( array (
  7508. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7509. 'asArray' => true
  7510. ) );
  7511. if (empty ( $receiptList )) {
  7512. ob_start ();
  7513. $this->render ( "/admin/saea_slist_collect", $data );
  7514. $this->cacheFile ( $path );
  7515. die ();
  7516. }
  7517. }
  7518. $this->render ( "/admin/saea_slist_collect", $data );
  7519. }
  7520. function personalCollectDetail() {
  7521. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7522. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  7523. $this->showCache ( $path );
  7524. Doo::loadModel ( "receiptDetail" );
  7525. Doo::loadModel ( "itemStatistics" );
  7526. Doo::loadModel ( 'statistics' );
  7527. Doo::loadModel ( 'accountItem' );
  7528. $accountItem = new accountItem ();
  7529. $statistics = new statistics ();
  7530. $itemStatistics = new itemStatistics ();
  7531. $receiptDetail = new receiptDetail ();
  7532. $receiptCollectList = $receiptDetail->find ( array (
  7533. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  7534. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7535. 'groupby' => 'item,Month(date)',
  7536. 'asArray' => true
  7537. ) );
  7538. $accountList = $accountItem->find ( array (
  7539. 'asArray' => true
  7540. ) );
  7541. // create CollectDetail HTML
  7542. $collectHtml = array ();
  7543. foreach ( $accountList as $key => $value ) {
  7544. $html = "";
  7545. $asum = 0;
  7546. for($i = 1; $i <= 12; $i ++) {
  7547. $falg = true;
  7548. foreach ( $receiptCollectList as $v ) {
  7549. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7550. $asum += $v ['price'];
  7551. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7552. $falg = false;
  7553. break;
  7554. }
  7555. }
  7556. if ($falg)
  7557. $html .= '<td class="taR">-</td>';
  7558. }
  7559. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7560. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7561. }
  7562. $data ['collectHtml'] = $collectHtml;
  7563. // create Adjustment price html
  7564. $receiptCollectList = $receiptDetail->find ( array (
  7565. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7566. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7567. 'groupby' => 'itemCategory,Month(date)',
  7568. 'asArray' => true
  7569. ) );
  7570. $adjustment = array ();
  7571. $collectArray = array (
  7572. '日常相关费用' => array (),
  7573. '差旅相关费用' => array (),
  7574. '培训班费用' => array (),
  7575. '其他' => array ()
  7576. );
  7577. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7578. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7579. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7580. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7581. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7582. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7583. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7584. array_push ( $collectArray ['其他'], $collectHtml );
  7585. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7586. array_push ( $adjustment, $collectHtml );
  7587. // total price html
  7588. $collectHtml = "";
  7589. $total = 0;
  7590. for($i = 1; $i <= 12; $i ++) {
  7591. $sumPrice = 0;
  7592. foreach ( $receiptCollectList as $key => $value ) {
  7593. if ($value ['month'] == $i) {
  7594. $sumPrice += $value ['price'];
  7595. }
  7596. }
  7597. if ($sumPrice == 0)
  7598. $collectHtml .= '<td class="taR">-</td>';
  7599. else
  7600. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7601. $total += $sumPrice;
  7602. }
  7603. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7604. // statistics html
  7605. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7606. if (empty ( $stList ))
  7607. $stList = array (
  7608. 'rePrice' => 0,
  7609. 'agPrice' => 0
  7610. );
  7611. $data ['stList'] = array (
  7612. 'rePrice' => $stList ['rePrice'],
  7613. 'agPrice' => $stList ['agPrice'],
  7614. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7615. );
  7616. $data ['collectArray'] = $collectArray;
  7617. $data ['adjustment'] = $adjustment;
  7618. $data ['totalPrice'] = $collectHtml;
  7619. $data ['totalYear'] = $total;
  7620. $data ['year'] = $year;
  7621. $data ['memu'] = "receipt";
  7622. $data ['staff'] = $this->staff;
  7623. $data ['receiptMemu'] = 'personalCollect';
  7624. $data ['verifyId'] = $this->verifyId;
  7625. $data ['executeId'] = $this->executeId;
  7626. // year staff status 2,4
  7627. if ($year < date ( "Y" )) {
  7628. Doo::loadModel ( 'receipt' );
  7629. $receipt = new receipt ();
  7630. $receiptList = $receipt->find ( array (
  7631. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7632. 'asArray' => true
  7633. ) );
  7634. if (empty ( $receiptList )) {
  7635. ob_start ();
  7636. $this->render ( "/admin/saeaCollectArticles", $data );
  7637. $this->cacheFile ( $path );
  7638. die ();
  7639. }
  7640. }
  7641. $this->render ( "/admin/saeaCollectArticles", $data );
  7642. }
  7643. function companyCategoryCollect() {
  7644. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7645. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  7646. $this->showCache ( $path );
  7647. Doo::loadModel ( 'L_category' );
  7648. Doo::loadModel ( 'itemStatistics' );
  7649. Doo::loadModel ( 'statistics' );
  7650. $statistics = new statistics ();
  7651. $Lcategory = new L_category ();
  7652. $itemStatistics = new itemStatistics ();
  7653. $LcategoryList = $Lcategory->find ( array (
  7654. 'asArray' => true
  7655. ) ); // 'staff='.$this->staff[0]['sid']." and
  7656. $itemStatisticsList = $itemStatistics->find ( array (
  7657. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7658. 'where' => " Year(date)=" . $year,
  7659. 'groupby' => 'cid,Month(date)',
  7660. 'asArray' => true
  7661. ) );
  7662. // ceatre companyCollectHtml
  7663. foreach ( $LcategoryList as $value ) {
  7664. $html = "";
  7665. $asum = 0;
  7666. for($i = 1; $i <= 12; $i ++) {
  7667. $falg = true;
  7668. foreach ( $itemStatisticsList as $v ) {
  7669. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  7670. $asum += $v ['price'];
  7671. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7672. $falg = false;
  7673. break;
  7674. }
  7675. }
  7676. if ($falg)
  7677. $html .= '<td class="taR">-</td>';
  7678. }
  7679. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7680. $collectHtml [$value ['title']] = array (
  7681. 'html' => $html,
  7682. 'cid' => $value ['cid']
  7683. );
  7684. }
  7685. $data ['companyHtml'] = $collectHtml;
  7686. // total price html
  7687. $collectHtml = "";
  7688. $total = 0;
  7689. for($i = 1; $i <= 12; $i ++) {
  7690. $sumPrice = 0;
  7691. foreach ( $itemStatisticsList as $key => $value ) {
  7692. if ($value ['month'] == $i) {
  7693. $sumPrice += $value ['price'];
  7694. }
  7695. }
  7696. if ($sumPrice == 0)
  7697. $collectHtml .= '<td class="taR">-</td>';
  7698. else
  7699. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7700. $total += $sumPrice;
  7701. }
  7702. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7703. $data ['companyTotalHtml'] = $collectHtml;
  7704. $data ['total'] = $total;
  7705. // statistics html
  7706. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7707. if (empty ( $stList ))
  7708. $stList = array (
  7709. 'rePrice' => 0,
  7710. 'agPrice' => 0
  7711. );
  7712. $data ['stList'] = array (
  7713. 'rePrice' => $stList ['rePrice'],
  7714. 'agPrice' => $stList ['agPrice'],
  7715. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7716. );
  7717. $data ['year'] = $year;
  7718. $data ['memu'] = "receipt";
  7719. $data ['staff'] = $this->staff;
  7720. $data ['receiptMemu'] = 'companyCategoryCollect';
  7721. $data ['verifyId'] = $this->verifyId;
  7722. $data ['executeId'] = $this->executeId;
  7723. // year staff status 2,4
  7724. if ($year < date ( "Y" )) {
  7725. Doo::loadModel ( 'receipt' );
  7726. $receipt = new receipt ();
  7727. $receiptList = $receipt->find ( array (
  7728. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  7729. 'asArray' => true
  7730. ) );
  7731. if (empty ( $receiptList )) {
  7732. ob_start ();
  7733. $this->render ( "/admin/saeaCompanyCollect", $data );
  7734. $this->cacheFile ( $path );
  7735. die ();
  7736. }
  7737. }
  7738. $this->render ( "/admin/saeaCompanyCollect", $data );
  7739. }
  7740. function categoryCollectDetail() {
  7741. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7742. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  7743. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  7744. $this->showCache ( $path );
  7745. Doo::loadModel ( 'statistics' );
  7746. $statistics = new statistics ();
  7747. Doo::loadModel ( "receiptDetail" );
  7748. $receiptDetail = new receiptDetail ();
  7749. Doo::loadModel ( 'L_category' );
  7750. $Lcategory = new L_category ();
  7751. Doo::loadModel ( 'accountItem' );
  7752. $accountItem = new accountItem ();
  7753. $LcategoryList = $Lcategory->find ( array (
  7754. 'asArray' => true
  7755. ) );
  7756. if ($cid == 0) {
  7757. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7758. if ($cid == 0)
  7759. $cid = $LcategoryList [0] ['cid'];
  7760. }
  7761. $data ['LcategoryList'] = $LcategoryList;
  7762. $receiptCollectList = $receiptDetail->find ( array (
  7763. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  7764. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7765. 'groupby' => 'item,Month(pastDate)',
  7766. 'asArray' => true
  7767. ) );
  7768. $accountList = $accountItem->find ( array (
  7769. 'asArray' => true
  7770. ) );
  7771. // create CollectDetail HTML
  7772. $collectHtml = array ();
  7773. foreach ( $accountList as $key => $value ) {
  7774. $html = "";
  7775. $asum = 0;
  7776. for($i = 1; $i <= 12; $i ++) {
  7777. $falg = true;
  7778. foreach ( $receiptCollectList as $v ) {
  7779. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7780. $asum += $v ['price'];
  7781. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7782. $falg = false;
  7783. break;
  7784. }
  7785. }
  7786. if ($falg)
  7787. $html .= '<td class="taR">-</td>';
  7788. }
  7789. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7790. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7791. }
  7792. $data ['collectHtml'] = $collectHtml;
  7793. // create Adjustment price html
  7794. $receiptCollectList = $receiptDetail->find ( array (
  7795. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  7796. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7797. 'groupby' => 'itemCategory,Month(pastDate)',
  7798. 'asArray' => true
  7799. ) );
  7800. $adjustment = array ();
  7801. $collectArray = array (
  7802. '日常相关费用' => array (),
  7803. '差旅相关费用' => array (),
  7804. '培训班费用' => array (),
  7805. '其他' => array ()
  7806. );
  7807. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7808. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7809. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7810. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7811. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7812. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7813. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7814. array_push ( $collectArray ['其他'], $collectHtml );
  7815. $data ['collectArray'] = $collectArray;
  7816. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7817. array_push ( $adjustment, $collectHtml );
  7818. $data ['adjustment'] = $adjustment;
  7819. // total price html
  7820. $collectHtml = "";
  7821. $total = 0;
  7822. for($i = 1; $i <= 12; $i ++) {
  7823. $sumPrice = 0;
  7824. foreach ( $receiptCollectList as $key => $value ) {
  7825. if ($value ['month'] == $i) {
  7826. $sumPrice += $value ['price'];
  7827. }
  7828. }
  7829. if ($sumPrice == 0)
  7830. $collectHtml .= '<td class="taR">-</td>';
  7831. else
  7832. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7833. $total += $sumPrice;
  7834. }
  7835. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7836. // statistics html
  7837. $stList = $statistics->statisticsByCid ( $year, $cid );
  7838. if (empty ( $stList ))
  7839. $stList = array (
  7840. 'rePrice' => 0,
  7841. 'agPrice' => 0
  7842. );
  7843. $data ['stList'] = array (
  7844. 'rePrice' => $stList ['rePrice'],
  7845. 'agPrice' => $stList ['agPrice'],
  7846. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7847. );
  7848. $data ['totalYear'] = $total;
  7849. $data ['year'] = $year;
  7850. $data ['cid'] = $cid;
  7851. $data ['memu'] = "receipt";
  7852. $data ['staff'] = $this->staff;
  7853. $data ['receiptMemu'] = 'companyCategoryCollect';
  7854. $data ['verifyId'] = $this->verifyId;
  7855. $data ['executeId'] = $this->executeId;
  7856. // year staff status 2,4
  7857. if ($year < date ( "Y" )) {
  7858. Doo::loadModel ( 'receipt' );
  7859. $receipt = new receipt ();
  7860. $receiptList = $receipt->find ( array (
  7861. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  7862. 'asArray' => true
  7863. ) );
  7864. if (empty ( $receiptList )) {
  7865. ob_start ();
  7866. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7867. $this->cacheFile ( $path );
  7868. die ();
  7869. }
  7870. }
  7871. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7872. }
  7873. function staffCollect() {
  7874. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7875. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  7876. // $this->showCache($path);
  7877. Doo::loadModel ( 'statistics' );
  7878. $statistics = new statistics ();
  7879. Doo::loadModel ( "receiptDetail" );
  7880. $receiptDetail = new receiptDetail ();
  7881. Doo::loadModel ( 'L_category' );
  7882. $Lcategory = new L_category ();
  7883. Doo::loadModel ( 'accountItem' );
  7884. $accountItem = new accountItem ();
  7885. Doo::loadModel ( 'staff' );
  7886. $staff = new staff ();
  7887. Doo::loadModel ( 'itemStatistics' );
  7888. $itemStatistics = new itemStatistics ();
  7889. /*
  7890. * $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']));
  7891. */
  7892. // statistics html
  7893. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7894. if (empty ( $stList ))
  7895. $stList = array (
  7896. 'rePrice' => 0,
  7897. 'agPrice' => 0
  7898. );
  7899. $data ['stList'] = array (
  7900. 'rePrice' => $stList ['rePrice'],
  7901. 'agPrice' => $stList ['agPrice'],
  7902. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7903. );
  7904. // ---
  7905. $staffList = $staff->find ( array (
  7906. 'where' => 'username !="admin"',
  7907. 'asArray' => true
  7908. ) );
  7909. $LcategoryList = $Lcategory->find ( array (
  7910. 'asArray' => true
  7911. ) ); // 'staff='.$this->staff[0]['sid']." and
  7912. $itemStatisticsList = $itemStatistics->find ( array (
  7913. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7914. 'where' => " Year(date)=" . $year,
  7915. 'groupby' => 'staff,Month(date)',
  7916. 'asArray' => true
  7917. ) );
  7918. $categoryList = $staff->find ( array (
  7919. 'select' => 'COUNT(*) as count,cid,category',
  7920. 'where' => 'username !="admin"',
  7921. 'groupby' => 'cid',
  7922. 'asArray' => true
  7923. ) );
  7924. // print_r($itemStatisticsList);die;
  7925. // ceatre companyCollectHtml
  7926. foreach ( $categoryList as $vlu ) {
  7927. $count = $vlu ['count'] + 1;
  7928. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  7929. $m1 = 0;
  7930. $m2 = 0;
  7931. $m3 = 0;
  7932. $m4 = 0;
  7933. $m5 = 0;
  7934. $m6 = 0;
  7935. $m7 = 0;
  7936. $m8 = 0;
  7937. $m9 = 0;
  7938. $m10 = 0;
  7939. $m11 = 0;
  7940. $m12 = 0;
  7941. $m13 = 0;
  7942. foreach ( $staffList as $value ) {
  7943. if ($vlu ['cid'] == $value ['cid']) {
  7944. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  7945. $asum = 0;
  7946. for($i = 1; $i <= 12; $i ++) {
  7947. $falg = true;
  7948. foreach ( $itemStatisticsList as $v ) {
  7949. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  7950. if ($v ['month'] == 1)
  7951. $m1 += $v ['price'];
  7952. if ($v ['month'] == 2)
  7953. $m2 += $v ['price'];
  7954. if ($v ['month'] == 3)
  7955. $m3 += $v ['price'];
  7956. if ($v ['month'] == 4)
  7957. $m4 += $v ['price'];
  7958. if ($v ['month'] == 5)
  7959. $m5 += $v ['price'];
  7960. if ($v ['month'] == 6)
  7961. $m6 += $v ['price'];
  7962. if ($v ['month'] == 7)
  7963. $m7 += $v ['price'];
  7964. if ($v ['month'] == 8)
  7965. $m8 += $v ['price'];
  7966. if ($v ['month'] == 9)
  7967. $m9 += $v ['price'];
  7968. if ($v ['month'] == 10)
  7969. $m10 += $v ['price'];
  7970. if ($v ['month'] == 11)
  7971. $m11 += $v ['price'];
  7972. if ($v ['month'] == 12)
  7973. $m12 += $v ['price'];
  7974. $asum += $v ['price'];
  7975. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7976. $falg = false;
  7977. break;
  7978. }
  7979. }
  7980. if ($falg)
  7981. $html .= '<td class="taR">-</td>';
  7982. }
  7983. $m13 += $asum;
  7984. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7985. $collectHtml [$value ['username']] = array (
  7986. 'html' => $html,
  7987. 'sid' => $value ['sid']
  7988. );
  7989. $html = "";
  7990. }
  7991. }
  7992. $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>
  7993. <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>
  7994. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  7995. $collectHtml [$vlu ['cid']] = array (
  7996. 'html' => $hl,
  7997. 'sid' => ''
  7998. );
  7999. }
  8000. $data ['companyHtml'] = $collectHtml;
  8001. // total price html
  8002. $collectHtml = "";
  8003. $total = 0;
  8004. for($i = 1; $i <= 12; $i ++) {
  8005. $sumPrice = 0;
  8006. foreach ( $itemStatisticsList as $key => $value ) {
  8007. if ($value ['month'] == $i) {
  8008. $sumPrice += $value ['price'];
  8009. }
  8010. }
  8011. if ($sumPrice == 0)
  8012. $collectHtml .= '<td class="taR">-</td>';
  8013. else
  8014. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8015. $total += $sumPrice;
  8016. }
  8017. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8018. $data ['companyTotalHtml'] = $collectHtml;
  8019. $data ['total'] = $total;
  8020. $data ['year'] = $year;
  8021. $data ['memu'] = "receipt";
  8022. $data ['staff'] = $this->staff;
  8023. $data ['receiptMemu'] = 'companyCategoryCollect';
  8024. $data ['verifyId'] = $this->verifyId;
  8025. $data ['executeId'] = $this->executeId;
  8026. if ($year <= date ( "Y" )) {
  8027. Doo::loadModel ( 'receipt' );
  8028. $receipt = new receipt ();
  8029. $receiptList = $receipt->find ( array (
  8030. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  8031. 'asArray' => true
  8032. ) );
  8033. if (empty ( $receiptList )) { // generated files
  8034. ob_start ();
  8035. $this->render ( "/admin/saeaStaffCollectB", $data );
  8036. $this->cacheFile ( $path );
  8037. die ();
  8038. }
  8039. }
  8040. $this->render ( "/admin/saeaStaffCollectB", $data );
  8041. }
  8042. function staffCollectBak() {
  8043. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8044. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  8045. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  8046. $this->showCache ( $path );
  8047. Doo::loadModel ( 'statistics' );
  8048. $statistics = new statistics ();
  8049. Doo::loadModel ( "receiptDetail" );
  8050. $receiptDetail = new receiptDetail ();
  8051. Doo::loadModel ( 'L_category' );
  8052. $Lcategory = new L_category ();
  8053. Doo::loadModel ( 'accountItem' );
  8054. $accountItem = new accountItem ();
  8055. Doo::loadModel ( 'staff' );
  8056. $staff = new staff ();
  8057. Doo::loadModel ( 'itemStatistics' );
  8058. $itemStatistics = new itemStatistics ();
  8059. $itemStatisticsList = $itemStatistics->find ( array (
  8060. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8061. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8062. 'groupby' => 'staff,itemCategory,Month(date)',
  8063. 'asArray' => true
  8064. ) );
  8065. $itemCategoryList = $itemStatistics->find ( array (
  8066. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8067. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8068. 'groupby' => 'cid,itemCategory,Month(date)',
  8069. 'asArray' => true
  8070. ) );
  8071. $LcategoryList = $Lcategory->find ( array (
  8072. 'asArray' => true
  8073. ) );
  8074. $staffList = $staff->find ( array (
  8075. 'asArray' => true
  8076. ) );
  8077. $htmlArray = array ();
  8078. foreach ( $LcategoryList as $value ) {
  8079. $htmlArray [$value ['title']] = array ();
  8080. foreach ( $staffList as $v ) {
  8081. if ($value ['cid'] == $v ['cid']) {
  8082. $html = "";
  8083. $falg = true;
  8084. $staffSumPrice = 0;
  8085. foreach ( $itemStatisticsList as $a ) {
  8086. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  8087. if (empty ( $a ['price'] )) {
  8088. $html .= '<td class="taR">-</td>';
  8089. $falg = false;
  8090. break;
  8091. } else {
  8092. $staffSumPrice += $a ['price'];
  8093. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8094. $falg = false;
  8095. break;
  8096. }
  8097. }
  8098. }
  8099. if ($falg) {
  8100. $html .= '<td class="taR">-</td>';
  8101. $falg = true;
  8102. }
  8103. $falg = true;
  8104. foreach ( $itemStatisticsList as $a ) {
  8105. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  8106. if (empty ( $a ['price'] )) {
  8107. $html .= '<td class="taR">-</td>';
  8108. $falg = false;
  8109. break;
  8110. } else {
  8111. $staffSumPrice += $a ['price'];
  8112. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8113. $falg = false;
  8114. break;
  8115. }
  8116. }
  8117. }
  8118. if ($falg) {
  8119. $html .= '<td class="taR">-</td>';
  8120. $falg = true;
  8121. }
  8122. $falg = true;
  8123. foreach ( $itemStatisticsList as $a ) {
  8124. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  8125. if (empty ( $a ['price'] )) {
  8126. $html .= '<td class="taR">-</td>';
  8127. $falg = false;
  8128. break;
  8129. } else {
  8130. $staffSumPrice += $a ['price'];
  8131. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8132. $falg = false;
  8133. break;
  8134. }
  8135. }
  8136. }
  8137. if ($falg) {
  8138. $html .= '<td class="taR">-</td>';
  8139. $falg = true;
  8140. }
  8141. $falg = true;
  8142. foreach ( $itemStatisticsList as $a ) {
  8143. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  8144. if (! empty ( $a ['price'] )) {
  8145. $staffSumPrice += $a ['price'];
  8146. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8147. $falg = false;
  8148. break;
  8149. } else {
  8150. $html .= '<td class="taR">-</td>';
  8151. $falg = false;
  8152. break;
  8153. }
  8154. }
  8155. }
  8156. if ($falg) {
  8157. $html .= '<td class="taR">-</td>';
  8158. $falg = true;
  8159. }
  8160. $falg = true;
  8161. foreach ( $itemStatisticsList as $a ) {
  8162. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  8163. if (! empty ( $a ['price'] )) {
  8164. $staffSumPrice += $a ['price'];
  8165. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8166. $falg = false;
  8167. break;
  8168. } else {
  8169. $html .= '<td class="taR">-</td>';
  8170. $falg = false;
  8171. break;
  8172. }
  8173. }
  8174. }
  8175. if ($falg) {
  8176. $html .= '<td class="taR">-</td>';
  8177. $falg = true;
  8178. }
  8179. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  8180. $htmlArray [$value ['title']] [$v ['username']] = $html;
  8181. }
  8182. }
  8183. /* -- --- */
  8184. // 合计费用
  8185. $cateHtml = "";
  8186. $catePrice = 0;
  8187. $cateFalg = true;
  8188. foreach ( $itemCategoryList as $l ) {
  8189. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  8190. if (empty ( $l ['price'] )) {
  8191. $cateHtml .= '<td class="colGreen taR">-</td>';
  8192. $cateFalg = false;
  8193. break;
  8194. } else {
  8195. $catePrice += $l ['price'];
  8196. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8197. $cateFalg = false;
  8198. break;
  8199. }
  8200. }
  8201. }
  8202. if ($cateFalg) {
  8203. $cateHtml .= '<td class="colGreen taR">-</td>';
  8204. $cateFalg = true;
  8205. }
  8206. $cateFalg = true;
  8207. foreach ( $itemCategoryList as $l ) {
  8208. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  8209. if (empty ( $l ['price'] )) {
  8210. $cateHtml .= '<td class="colGreen taR">-</td>';
  8211. $cateFalg = false;
  8212. break;
  8213. } else {
  8214. $catePrice += $l ['price'];
  8215. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8216. $cateFalg = false;
  8217. break;
  8218. }
  8219. }
  8220. }
  8221. if ($cateFalg) {
  8222. $cateHtml .= '<td class="colGreen taR">-</td>';
  8223. $cateFalg = true;
  8224. }
  8225. $cateFalg = true;
  8226. foreach ( $itemCategoryList as $l ) {
  8227. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  8228. if (empty ( $l ['price'] )) {
  8229. $cateHtml .= '<td class="colGreen taR">-</td>';
  8230. $cateFalg = false;
  8231. break;
  8232. } else {
  8233. $catePrice += $l ['price'];
  8234. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8235. $cateFalg = false;
  8236. break;
  8237. }
  8238. }
  8239. }
  8240. if ($cateFalg) {
  8241. $cateHtml .= '<td class="colGreen taR">-</td>';
  8242. $cateFalg = true;
  8243. }
  8244. $cateFalg = true;
  8245. foreach ( $itemCategoryList as $l ) {
  8246. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  8247. if (empty ( $l ['price'] )) {
  8248. $cateHtml .= '<td class="colGreen taR">-</td>';
  8249. $cateFalg = false;
  8250. break;
  8251. } else {
  8252. $catePrice += $l ['price'];
  8253. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8254. $cateFalg = false;
  8255. break;
  8256. }
  8257. }
  8258. }
  8259. if ($cateFalg) {
  8260. $cateHtml .= '<td class="colGreen taR">-</td>';
  8261. $cateFalg = true;
  8262. }
  8263. $cateFalg = true;
  8264. foreach ( $itemCategoryList as $l ) {
  8265. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  8266. if (empty ( $l ['price'] )) {
  8267. $cateHtml .= '<td class="colGreen taR">-</td>';
  8268. $cateFalg = false;
  8269. break;
  8270. } else {
  8271. $catePrice += $l ['price'];
  8272. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8273. $cateFalg = false;
  8274. break;
  8275. }
  8276. }
  8277. }
  8278. if ($cateFalg) {
  8279. $cateHtml .= '<td class="colGreen taR">-</td>';
  8280. $cateFalg = true;
  8281. }
  8282. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  8283. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  8284. /* -- --- */
  8285. }
  8286. // print_r($htmlArray);die;
  8287. $data ['htmlArray'] = $htmlArray;
  8288. // statistics html
  8289. $stList = $statistics->getOne ( array (
  8290. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8291. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8292. 'groupby' => 'Month(date)',
  8293. 'asArray' => true
  8294. ) );
  8295. if (empty ( $stList ))
  8296. $stList = array (
  8297. 'rePrice' => 0,
  8298. 'agPrice' => 0
  8299. );
  8300. $data ['stList'] = array (
  8301. 'rePrice' => $stList ['rePrice'],
  8302. 'agPrice' => $stList ['agPrice'],
  8303. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8304. );
  8305. $monthHtml = "";
  8306. for($i = 1; $i <= 12; $i ++) {
  8307. if ($i == $month)
  8308. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8309. else
  8310. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8311. }
  8312. $data ['monthHtml'] = $monthHtml;
  8313. $data ['year'] = $year;
  8314. $data ['month'] = $month;
  8315. $data ['memu'] = "receipt";
  8316. $data ['staff'] = $this->staff;
  8317. $data ['receiptMemu'] = 'companyCategoryCollect';
  8318. $data ['verifyId'] = $this->verifyId;
  8319. $data ['executeId'] = $this->executeId;
  8320. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  8321. Doo::loadModel ( 'receipt' );
  8322. $receipt = new receipt ();
  8323. $receiptList = $receipt->find ( array (
  8324. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  8325. 'asArray' => true
  8326. ) );
  8327. if (empty ( $receiptList )) { // generated files
  8328. ob_start ();
  8329. $this->render ( "/admin/saeaStaffCollect", $data );
  8330. $this->cacheFile ( $path );
  8331. die ();
  8332. }
  8333. }
  8334. $this->render ( "/admin/saeaStaffCollect", $data );
  8335. }
  8336. function lyt() {
  8337. Doo::loadModel ( "receiptDetail" );
  8338. $receiptDetail = new receiptDetail ();
  8339. $receiptCollectList = $receiptDetail->find ( array (
  8340. 'where' => 'status=1 ',
  8341. 'asArray' => true
  8342. ) );
  8343. foreach ( $receiptCollectList as $key => $value ) {
  8344. $receiptDetail = new receiptDetail ();
  8345. $receiptDetail->pastDate = $value ['date'];
  8346. $receiptDetail->update ( array (
  8347. 'where' => "rdid= '" . $value ['rdid'] . "'"
  8348. ) );
  8349. }
  8350. }
  8351. function staffCollectMonthDetail() {
  8352. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8353. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8354. if (! $year)
  8355. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8356. if (! $month)
  8357. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8358. Doo::loadModel ( 'staff' );
  8359. $staff = new staff ();
  8360. Doo::loadModel ( "receiptDetail" );
  8361. $receiptDetail = new receiptDetail ();
  8362. Doo::loadModel ( 'accountItem' );
  8363. $accountItem = new accountItem ();
  8364. Doo::loadModel ( 'statistics' );
  8365. $statistics = new statistics ();
  8366. Doo::loadModel ( 'L_category' );
  8367. $lCategory = new L_category ();
  8368. $staffList = $staff->find ( array (
  8369. 'where' => 'username!="admin"',
  8370. 'asArray' => true
  8371. ) );
  8372. $categoryList = $staff->find ( array (
  8373. 'select' => 'COUNT(*) as count,cid,category',
  8374. 'where' => 'username !="admin"',
  8375. 'groupby' => 'cid',
  8376. 'asArray' => true
  8377. ) );
  8378. $list = array ();
  8379. foreach ( $categoryList as $vlu ) {
  8380. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8381. $r1 = 0;
  8382. $r2 = 0;
  8383. $r3 = 0;
  8384. $r4 = 0;
  8385. $r5 = 0;
  8386. $r6 = 0;
  8387. $r7 = 0;
  8388. $r8 = 0;
  8389. $r9 = 0;
  8390. $r10 = 0;
  8391. $r11 = 0;
  8392. $r12 = 0;
  8393. $r13 = 0;
  8394. $r14 = 0;
  8395. $r15 = 0;
  8396. $r16 = 0;
  8397. $r17 = 0;
  8398. $r18 = 0;
  8399. $c1 = 0;
  8400. $c2 = 0;
  8401. $c3 = 0;
  8402. $c4 = 0;
  8403. $c5 = 0;
  8404. $c6 = 0;
  8405. $p1 = 0;
  8406. $p2 = 0;
  8407. $p3 = 0;
  8408. $p4 = 0;
  8409. $p5 = 0;
  8410. $p6 = 0;
  8411. $p7 = 0;
  8412. $p8 = 0;
  8413. $p9 = 0;
  8414. $t1 = 0;
  8415. $t2 = 0;
  8416. $t3 = 0;
  8417. $t4 = 0;
  8418. $t5 = 0;
  8419. $s1 = 0;
  8420. $m1 = 0;
  8421. foreach ( $staffList as $value ) {
  8422. if ($vlu ['cid'] == $value ['cid']) {
  8423. // pastDate
  8424. $receiptCollectList = $receiptDetail->find ( array (
  8425. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8426. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8427. 'groupby' => 'item,Month(pastDate),itemCategory',
  8428. 'asArray' => true
  8429. ) );
  8430. // if ($value['sid']==42){
  8431. // print_r($receiptCollectList);die;
  8432. // }
  8433. if (! empty ( $receiptCollectList )) {
  8434. $receiptL = array (
  8435. '日常相关费用' => array (),
  8436. '差旅相关费用' => array (),
  8437. '培训班费用' => array (),
  8438. '其他' => array ()
  8439. );
  8440. $html = "";
  8441. $psum = 0;
  8442. $item = array (
  8443. '市内交通费',
  8444. '市内出租费',
  8445. '办事处房租',
  8446. '电话费',
  8447. '水费',
  8448. '电费',
  8449. '办公费用',
  8450. '邮寄费',
  8451. '其他费用',
  8452. '车辆费用',
  8453. '广告费',
  8454. '团队建设费',
  8455. '物业管理费',
  8456. '宽带费',
  8457. '人员薪酬',
  8458. '公积金',
  8459. '社保'
  8460. );
  8461. foreach ( $item as $va ) {
  8462. $falg = true;
  8463. foreach ( $receiptCollectList as $v ) {
  8464. if ($v ['itemCategory'] == '日常相关费用') {
  8465. if ($v ['item'] == $va) {
  8466. if ($va == '市内交通费')
  8467. $r1 += $v ['price'];
  8468. if ($va == '市内出租费')
  8469. $r2 += $v ['price'];
  8470. if ($va == '办事处房租')
  8471. $r3 += $v ['price'];
  8472. if ($va == '电话费')
  8473. $r4 += $v ['price'];
  8474. if ($va == '水费')
  8475. $r5 += $v ['price'];
  8476. if ($va == '电费')
  8477. $r6 += $v ['price'];
  8478. if ($va == '办公费用')
  8479. $r7 += $v ['price'];
  8480. if ($va == '邮寄费')
  8481. $r8 += $v ['price'];
  8482. if ($va == '其他费用')
  8483. $r9 += $v ['price'];
  8484. if ($va == '车辆费用')
  8485. $r10 += $v ['price'];
  8486. if ($va == '广告费')
  8487. $r11 += $v ['price'];
  8488. if ($va == '团队建设费')
  8489. $r13 += $v ['price'];
  8490. if ($va == '物业管理费')
  8491. $r14 += $v ['price'];
  8492. if ($va == '宽带费')
  8493. $r15 += $v ['price'];
  8494. if ($va == '公积金')
  8495. $r16 += $v ['price'];
  8496. if ($va == '社保')
  8497. $r17 += $v ['price'];
  8498. if ($va == '人员薪酬')
  8499. $r18 += $v ['price'];
  8500. $psum += $v ['price'];
  8501. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8502. $falg = false;
  8503. break;
  8504. }
  8505. }
  8506. }
  8507. if ($falg)
  8508. $html .= '<td class="taR">-</td>';
  8509. }
  8510. $r12 += $psum;
  8511. if (! empty ( $psum ))
  8512. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8513. else
  8514. $psum = '<td class="colGreen taR">-</td>';
  8515. $receiptL ['日常相关费用'] = $psum . $html;
  8516. /* ----------------------------------- */
  8517. $html = "";
  8518. $psum = 0;
  8519. $item = array (
  8520. '往来交通费',
  8521. '市内交通费',
  8522. '出差住宿费',
  8523. '出差补助',
  8524. '其他费用'
  8525. );
  8526. foreach ( $item as $va ) {
  8527. $falg = true;
  8528. foreach ( $receiptCollectList as $v ) {
  8529. if ($v ['itemCategory'] == '差旅相关费用') {
  8530. if ($v ['item'] == $va) {
  8531. if ($va == '往来交通费')
  8532. $c1 += $v ['price'];
  8533. if ($va == '市内交通费')
  8534. $c2 += $v ['price'];
  8535. if ($va == '出差住宿费')
  8536. $c3 += $v ['price'];
  8537. if ($va == '出差补助')
  8538. $c4 += $v ['price'];
  8539. if ($va == '其他费用')
  8540. $c5 += $v ['price'];
  8541. $psum += $v ['price'];
  8542. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8543. $falg = false;
  8544. break;
  8545. }
  8546. }
  8547. }
  8548. if ($falg)
  8549. $html .= '<td class="taR">-</td>';
  8550. }
  8551. $c6 += $psum;
  8552. if (! empty ( $psum ))
  8553. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8554. else
  8555. $psum = '<td class="colGreen taR">-</td>';
  8556. $receiptL ['差旅相关费用'] = $psum . $html;
  8557. /* ------------------------------------- */
  8558. $html = "";
  8559. $psum = 0;
  8560. $item = array (
  8561. '场租费',
  8562. '薪酬',
  8563. '住宿费',
  8564. '交通费',
  8565. '餐饮费',
  8566. '办公费',
  8567. '公关费',
  8568. '其他'
  8569. );
  8570. foreach ( $item as $va ) {
  8571. $falg = true;
  8572. foreach ( $receiptCollectList as $v ) {
  8573. if ($v ['itemCategory'] == '培训班费用') {
  8574. if ($v ['item'] == $va) {
  8575. if ($va == '场租费')
  8576. $p1 += $v ['price'];
  8577. if ($va == '薪酬')
  8578. $p2 += $v ['price'];
  8579. if ($va == '住宿费')
  8580. $p3 += $v ['price'];
  8581. if ($va == '交通费')
  8582. $p4 += $v ['price'];
  8583. if ($va == '餐饮费')
  8584. $p5 += $v ['price'];
  8585. if ($va == '办公费')
  8586. $p6 += $v ['price'];
  8587. if ($va == '公关费')
  8588. $p7 += $v ['price'];
  8589. if ($va == '其他')
  8590. $p8 += $v ['price'];
  8591. $psum += $v ['price'];
  8592. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8593. $falg = false;
  8594. break;
  8595. }
  8596. }
  8597. }
  8598. if ($falg)
  8599. $html .= '<td class="taR">-</td>';
  8600. }
  8601. $p9 += $psum;
  8602. if (! empty ( $psum ))
  8603. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8604. else
  8605. $psum = '<td class="colGreen taR">-</td>';
  8606. $receiptL ['培训班费用'] = $psum . $html;
  8607. /* ------------------------------------- */
  8608. $html = "";
  8609. $psum = 0;
  8610. $item = array (
  8611. '公关费',
  8612. '广告费',
  8613. '借款',
  8614. '可自加费用'
  8615. );
  8616. foreach ( $item as $va ) {
  8617. $falg = true;
  8618. foreach ( $receiptCollectList as $v ) {
  8619. if ($v ['itemCategory'] == '其他') {
  8620. // if ($value['sid']==42){
  8621. //
  8622. // echo var_dump($v['item']);
  8623. // echo var_dump($va);
  8624. // echo var_dump($v['item']==" ".$va);
  8625. // echo $v['item']."==".$va."/<br/>";
  8626. // //print_r( $receiptCollectList);//echo $va;
  8627. // }
  8628. if (trim ( $v ['item'] ) == $va) {
  8629. if ($va == '公关费')
  8630. $t1 += $v ['price'];
  8631. if ($va == '广告费') {
  8632. $t2 += $v ['price'];
  8633. }
  8634. if ($va == '借款')
  8635. $t3 += $v ['price'];
  8636. if ($va == '可自加费用')
  8637. $t4 += $v ['price'];
  8638. $psum += $v ['price'];
  8639. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8640. $falg = false;
  8641. break;
  8642. }
  8643. }
  8644. }
  8645. if ($falg)
  8646. $html .= '<td class="taR">-</td>';
  8647. }
  8648. $t5 += $psum;
  8649. if (! empty ( $psum ))
  8650. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8651. else
  8652. $psum = '<td class="colGreen taR">-</td>';
  8653. $receiptL ['其他'] = $psum . $html;
  8654. /* ------------------------------------- */
  8655. $html = "";
  8656. $psum = 0;
  8657. foreach ( $receiptCollectList as $v ) {
  8658. if ($v ['itemCategory'] == '报销金额调整') {
  8659. if (! empty ( $v ['price'] )) {
  8660. $psum += $v ['price'];
  8661. }
  8662. }
  8663. }
  8664. $s1 += $psum;
  8665. if (! empty ( $psum ))
  8666. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8667. else
  8668. $psum = '<td class="taR colOrange">-</td>';
  8669. $receiptL ['报销金额调整'] = $psum . $html;
  8670. } else {
  8671. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8672. <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>
  8673. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8674. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  8675. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8676. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8677. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8678. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8679. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  8680. }
  8681. $monthStaffPrice = $receiptDetail->find ( array (
  8682. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8683. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8684. 'groupby' => 'Month(pastDate)',
  8685. 'asArray' => true
  8686. ) );
  8687. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  8688. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  8689. $m1 += $monthStaffPrice [0] ['price'];
  8690. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  8691. } else
  8692. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  8693. $list [$value ['username']] = $receiptL;
  8694. }
  8695. }
  8696. $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>
  8697. <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>
  8698. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td><td class="taR">' . $r18 . '</td> <td class="taR">' . $r16 . '</td><td class="taR">' . $r17 . '</td>';
  8699. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  8700. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  8701. $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>
  8702. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  8703. $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>';
  8704. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  8705. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  8706. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  8707. }
  8708. $data ['list'] = $list;
  8709. $receiptCollectList = $receiptDetail->find ( array (
  8710. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8711. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8712. 'groupby' => 'item,Month(pastDate),itemCategory',
  8713. 'asArray' => true
  8714. ) );
  8715. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  8716. // statistics html
  8717. $stList = $statistics->getOne ( array (
  8718. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8719. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8720. 'groupby' => 'Month(date)',
  8721. 'asArray' => true
  8722. ) );
  8723. if (empty ( $stList ))
  8724. $stList = array (
  8725. 'rePrice' => 0,
  8726. 'agPrice' => 0
  8727. );
  8728. $data ['stList'] = array (
  8729. 'rePrice' => $stList ['rePrice'],
  8730. 'agPrice' => $stList ['agPrice'],
  8731. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8732. );
  8733. $monthHtml = "";
  8734. for($i = 1; $i <= 12; $i ++) {
  8735. if ($i == $month)
  8736. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8737. else
  8738. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8739. }
  8740. $data ['monthHtml'] = $monthHtml;
  8741. $data ['year'] = $year;
  8742. $data ['month'] = $month;
  8743. $data ['memu'] = "receipt";
  8744. $data ['staff'] = $this->staff;
  8745. $data ['receiptMemu'] = 'companyCategoryCollect';
  8746. $data ['verifyId'] = $this->verifyId;
  8747. $data ['executeId'] = $this->executeId;
  8748. $this->render ( "/admin/staffCollectMonthDetail", $data );
  8749. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  8750. }
  8751. function staffCollectMonthDetail2() {
  8752. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8753. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8754. if (! $year)
  8755. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8756. if (! $month)
  8757. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8758. Doo::loadModel ( 'staff' );
  8759. $staff = new staff ();
  8760. Doo::loadModel ( "receiptDetail" );
  8761. $receiptDetail = new receiptDetail ();
  8762. Doo::loadModel ( 'accountItem' );
  8763. $accountItem = new accountItem ();
  8764. Doo::loadModel ( 'statistics' );
  8765. $statistics = new statistics ();
  8766. Doo::loadModel ( 'L_category' );
  8767. $lCategory = new L_category ();
  8768. $staffList = $staff->find ( array (
  8769. 'where' => 'username!="admin"',
  8770. 'asArray' => true
  8771. ) );
  8772. $categoryList = $staff->find ( array (
  8773. 'select' => 'COUNT(*) as count,cid,category',
  8774. 'where' => 'username !="admin"',
  8775. 'groupby' => 'cid',
  8776. 'asArray' => true
  8777. ) );
  8778. $list = array ();
  8779. foreach ( $categoryList as $vlu ) {
  8780. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8781. $r1 = 0;
  8782. $r2 = 0;
  8783. $r3 = 0;
  8784. $r4 = 0;
  8785. $r5 = 0;
  8786. $r6 = 0;
  8787. $r7 = 0;
  8788. $r8 = 0;
  8789. $r9 = 0;
  8790. $r10 = 0;
  8791. $r11 = 0;
  8792. $r12 = 0;
  8793. $r13 = 0;
  8794. $r14 = 0;
  8795. $r15 = 0;
  8796. $c1 = 0;
  8797. $c2 = 0;
  8798. $c3 = 0;
  8799. $c4 = 0;
  8800. $c5 = 0;
  8801. $c6 = 0;
  8802. $p1 = 0;
  8803. $p2 = 0;
  8804. $p3 = 0;
  8805. $p4 = 0;
  8806. $p5 = 0;
  8807. $p6 = 0;
  8808. $p7 = 0;
  8809. $p8 = 0;
  8810. $p9 = 0;
  8811. $t1 = 0;
  8812. $t2 = 0;
  8813. $t3 = 0;
  8814. $t4 = 0;
  8815. $t5 = 0;
  8816. $s1 = 0;
  8817. $m1 = 0;
  8818. foreach ( $staffList as $value ) {
  8819. if ($vlu ['cid'] == $value ['cid']) {
  8820. $receiptCollectList = $receiptDetail->find ( array (
  8821. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  8822. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  8823. 'groupby' => 'item,Month(date),itemCategory',
  8824. 'asArray' => true
  8825. ) );
  8826. if (! empty ( $receiptCollectList )) {
  8827. $receiptL = array (
  8828. '日常相关费用' => array (),
  8829. '差旅相关费用' => array (),
  8830. '培训班费用' => array (),
  8831. '其他' => array ()
  8832. );
  8833. $html = "";
  8834. $psum = 0;
  8835. $item = array (
  8836. '市内交通费',
  8837. '市内出租费',
  8838. '办事处房租',
  8839. '电话费',
  8840. '水费',
  8841. '电费',
  8842. '办公费用',
  8843. '邮寄费',
  8844. '其他费用',
  8845. '车辆费用',
  8846. '广告费',
  8847. '团队建设费',
  8848. '物业管理费',
  8849. '宽带费'
  8850. );
  8851. foreach ( $item as $va ) {
  8852. $falg = true;
  8853. foreach ( $receiptCollectList as $v ) {
  8854. if ($v ['itemCategory'] == '日常相关费用') {
  8855. if ($v ['item'] == $va) {
  8856. if ($va == '市内交通费')
  8857. $r1 += $v ['price'];
  8858. if ($va == '市内出租费')
  8859. $r2 += $v ['price'];
  8860. if ($va == '办事处房租')
  8861. $r3 += $v ['price'];
  8862. if ($va == '电话费')
  8863. $r4 += $v ['price'];
  8864. if ($va == '水费')
  8865. $r5 += $v ['price'];
  8866. if ($va == '电费')
  8867. $r6 += $v ['price'];
  8868. if ($va == '办公费用')
  8869. $r7 += $v ['price'];
  8870. if ($va == '邮寄费')
  8871. $r8 += $v ['price'];
  8872. if ($va == '其他费用')
  8873. $r9 += $v ['price'];
  8874. if ($va == '车辆费用')
  8875. $r10 += $v ['price'];
  8876. if ($va == '广告费')
  8877. $r11 += $v ['price'];
  8878. if ($va == '团队建设费')
  8879. $r13 += $v ['price'];
  8880. if ($va == '物业管理费')
  8881. $r14 += $v ['price'];
  8882. if ($va == '宽带费')
  8883. $r15 += $v ['price'];
  8884. $psum += $v ['price'];
  8885. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8886. $falg = false;
  8887. break;
  8888. }
  8889. }
  8890. }
  8891. if ($falg)
  8892. $html .= '<td class="taR">-</td>';
  8893. }
  8894. $r12 += $psum;
  8895. if (! empty ( $psum ))
  8896. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8897. else
  8898. $psum = '<td class="colGreen taR">-</td>';
  8899. $receiptL ['日常相关费用'] = $psum . $html;
  8900. /* ----------------------------------- */
  8901. $html = "";
  8902. $psum = 0;
  8903. $item = array (
  8904. '往来交通费',
  8905. '市内交通费',
  8906. '出差住宿费',
  8907. '出差补助',
  8908. '其他费用'
  8909. );
  8910. foreach ( $item as $va ) {
  8911. $falg = true;
  8912. foreach ( $receiptCollectList as $v ) {
  8913. if ($v ['itemCategory'] == '差旅相关费用') {
  8914. if ($v ['item'] == $va) {
  8915. if ($va == '往来交通费')
  8916. $c1 += $v ['price'];
  8917. if ($va == '市内交通费')
  8918. $c2 += $v ['price'];
  8919. if ($va == '出差住宿费')
  8920. $c3 += $v ['price'];
  8921. if ($va == '出差补助')
  8922. $c4 += $v ['price'];
  8923. if ($va == '其他费用')
  8924. $c5 += $v ['price'];
  8925. $psum += $v ['price'];
  8926. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8927. $falg = false;
  8928. break;
  8929. }
  8930. }
  8931. }
  8932. if ($falg)
  8933. $html .= '<td class="taR">-</td>';
  8934. }
  8935. $c6 += $psum;
  8936. if (! empty ( $psum ))
  8937. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8938. else
  8939. $psum = '<td class="colGreen taR">-</td>';
  8940. $receiptL ['差旅相关费用'] = $psum . $html;
  8941. /* ------------------------------------- */
  8942. $html = "";
  8943. $psum = 0;
  8944. $item = array (
  8945. '场租费',
  8946. '薪酬',
  8947. '住宿费',
  8948. '交通费',
  8949. '餐饮费',
  8950. '办公费',
  8951. '公关费',
  8952. '其他'
  8953. );
  8954. foreach ( $item as $va ) {
  8955. $falg = true;
  8956. foreach ( $receiptCollectList as $v ) {
  8957. if ($v ['itemCategory'] == '培训班费用') {
  8958. if ($v ['item'] == $va) {
  8959. if ($va == '场租费')
  8960. $p1 += $v ['price'];
  8961. if ($va == '薪酬')
  8962. $p2 += $v ['price'];
  8963. if ($va == '住宿费')
  8964. $p3 += $v ['price'];
  8965. if ($va == '交通费')
  8966. $p4 += $v ['price'];
  8967. if ($va == '餐饮费')
  8968. $p5 += $v ['price'];
  8969. if ($va == '办公费')
  8970. $p6 += $v ['price'];
  8971. if ($va == '公关费')
  8972. $p7 += $v ['price'];
  8973. if ($va == '其他')
  8974. $p8 += $v ['price'];
  8975. $psum += $v ['price'];
  8976. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8977. $falg = false;
  8978. break;
  8979. }
  8980. }
  8981. }
  8982. if ($falg)
  8983. $html .= '<td class="taR">-</td>';
  8984. }
  8985. $p9 += $psum;
  8986. if (! empty ( $psum ))
  8987. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8988. else
  8989. $psum = '<td class="colGreen taR">-</td>';
  8990. $receiptL ['培训班费用'] = $psum . $html;
  8991. /* ------------------------------------- */
  8992. $html = "";
  8993. $psum = 0;
  8994. $item = array (
  8995. '公关费',
  8996. '广告费',
  8997. '借款',
  8998. '可自加费用'
  8999. );
  9000. foreach ( $item as $va ) {
  9001. $falg = true;
  9002. foreach ( $receiptCollectList as $v ) {
  9003. if ($v ['itemCategory'] == '其他') {
  9004. if ($v ['item'] == $va) {
  9005. if ($va == '公关费')
  9006. $t1 += $v ['price'];
  9007. if ($va == '广告费')
  9008. $t2 += $v ['price'];
  9009. if ($va == '借款')
  9010. $t3 += $v ['price'];
  9011. if ($va == '可自加费用')
  9012. $t4 += $v ['price'];
  9013. $psum += $v ['price'];
  9014. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9015. $falg = false;
  9016. break;
  9017. }
  9018. }
  9019. }
  9020. if ($falg)
  9021. $html .= '<td class="taR">-</td>';
  9022. }
  9023. $t5 += $psum;
  9024. if (! empty ( $psum ))
  9025. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9026. else
  9027. $psum = '<td class="colGreen taR">-</td>';
  9028. $receiptL ['其他'] = $psum . $html;
  9029. /* ------------------------------------- */
  9030. $html = "";
  9031. $psum = 0;
  9032. foreach ( $receiptCollectList as $v ) {
  9033. if ($v ['itemCategory'] == '报销金额调整') {
  9034. if (! empty ( $v ['price'] )) {
  9035. $psum += $v ['price'];
  9036. }
  9037. }
  9038. }
  9039. $s1 += $psum;
  9040. if (! empty ( $psum ))
  9041. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9042. else
  9043. $psum = '<td class="taR colOrange">-</td>';
  9044. $receiptL ['报销金额调整'] = $psum . $html;
  9045. } else {
  9046. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9047. <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>';
  9048. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9049. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9050. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9051. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9052. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9053. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9054. }
  9055. $monthStaffPrice = $receiptDetail->find ( array (
  9056. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9057. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9058. 'asArray' => true
  9059. ) );
  9060. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  9061. $m1 += $monthStaffPrice [0] ['price'];
  9062. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9063. } else
  9064. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9065. $list [$value ['username']] = $receiptL;
  9066. }
  9067. }
  9068. $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>
  9069. <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>
  9070. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  9071. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  9072. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  9073. $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>
  9074. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  9075. $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>';
  9076. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  9077. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  9078. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  9079. }
  9080. $data ['list'] = $list;
  9081. $receiptCollectList = $receiptDetail->find ( array (
  9082. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9083. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9084. 'groupby' => 'item,Month(date),itemCategory',
  9085. 'asArray' => true
  9086. ) );
  9087. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9088. // statistics html
  9089. $stList = $statistics->getOne ( array (
  9090. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9091. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9092. 'groupby' => 'Month(date)',
  9093. 'asArray' => true
  9094. ) );
  9095. if (empty ( $stList ))
  9096. $stList = array (
  9097. 'rePrice' => 0,
  9098. 'agPrice' => 0
  9099. );
  9100. $data ['stList'] = array (
  9101. 'rePrice' => $stList ['rePrice'],
  9102. 'agPrice' => $stList ['agPrice'],
  9103. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9104. );
  9105. $monthHtml = "";
  9106. for($i = 1; $i <= 12; $i ++) {
  9107. if ($i == $month)
  9108. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9109. else
  9110. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9111. }
  9112. $data ['monthHtml'] = $monthHtml;
  9113. $data ['year'] = $year;
  9114. $data ['month'] = $month;
  9115. $data ['memu'] = "receipt";
  9116. $data ['staff'] = $this->staff;
  9117. $data ['receiptMemu'] = 'companyCategoryCollect';
  9118. $data ['verifyId'] = $this->verifyId;
  9119. $data ['executeId'] = $this->executeId;
  9120. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  9121. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9122. }
  9123. function companyMonthCollectDetail() {
  9124. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9125. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9126. if (! $year)
  9127. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9128. if (! $month)
  9129. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9130. Doo::loadModel ( 'staff' );
  9131. $staff = new staff ();
  9132. Doo::loadModel ( "receiptDetail" );
  9133. $receiptDetail = new receiptDetail ();
  9134. Doo::loadModel ( 'accountItem' );
  9135. $accountItem = new accountItem ();
  9136. Doo::loadModel ( 'statistics' );
  9137. $statistics = new statistics ();
  9138. Doo::loadModel ( 'L_category' );
  9139. $lCategory = new L_category ();
  9140. $staffList = $staff->find ( array (
  9141. 'where' => 'username!="admin"',
  9142. 'asArray' => true
  9143. ) );
  9144. $categoryList = $lCategory->find ( array (
  9145. 'asArray' => true
  9146. ) );
  9147. $list = array ();
  9148. foreach ( $categoryList as $value ) {
  9149. $receiptCollectList = $receiptDetail->find ( array (
  9150. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9151. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9152. 'groupby' => 'item,Month(pastDate),itemCategory',
  9153. 'asArray' => true
  9154. ) );
  9155. if (! empty ( $receiptCollectList )) {
  9156. $receiptL = array (
  9157. '日常相关费用' => array (),
  9158. '差旅相关费用' => array (),
  9159. '培训班费用' => array (),
  9160. '其他' => array ()
  9161. );
  9162. $html = "";
  9163. $psum = 0;
  9164. $item = array (
  9165. '市内交通费',
  9166. '市内出租费',
  9167. '办事处房租',
  9168. '电话费',
  9169. '水费',
  9170. '电费',
  9171. '办公费用',
  9172. '邮寄费',
  9173. '其他费用',
  9174. '车辆费用',
  9175. '广告费',
  9176. '团队建设费'
  9177. );
  9178. foreach ( $item as $va ) {
  9179. $falg = true;
  9180. foreach ( $receiptCollectList as $v ) {
  9181. if ($v ['itemCategory'] == '日常相关费用') {
  9182. if ($v ['item'] == $va) {
  9183. $psum += $v ['price'];
  9184. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9185. $falg = false;
  9186. break;
  9187. }
  9188. }
  9189. }
  9190. if ($falg)
  9191. $html .= '<td class="taR">-</td>';
  9192. }
  9193. if (! empty ( $psum ))
  9194. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9195. else
  9196. $psum = '<td class="colGreen taR">-</td>';
  9197. $receiptL ['日常相关费用'] = $psum . $html;
  9198. /* ----------------------------------- */
  9199. $html = "";
  9200. $psum = 0;
  9201. $item = array (
  9202. '往来交通费',
  9203. '市内交通费',
  9204. '出差住宿费',
  9205. '出差补助',
  9206. '其他费用'
  9207. );
  9208. foreach ( $item as $va ) {
  9209. $falg = true;
  9210. foreach ( $receiptCollectList as $v ) {
  9211. if ($v ['itemCategory'] == '差旅相关费用') {
  9212. if ($v ['item'] == $va) {
  9213. $psum += $v ['price'];
  9214. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9215. $falg = false;
  9216. break;
  9217. }
  9218. }
  9219. }
  9220. if ($falg)
  9221. $html .= '<td class="taR">-</td>';
  9222. }
  9223. if (! empty ( $psum ))
  9224. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9225. else
  9226. $psum = '<td class="colGreen taR">-</td>';
  9227. $receiptL ['差旅相关费用'] = $psum . $html;
  9228. /* ------------------------------------- */
  9229. $html = "";
  9230. $psum = 0;
  9231. $item = array (
  9232. '场租费',
  9233. '薪酬',
  9234. '住宿费',
  9235. '交通费',
  9236. '餐饮费',
  9237. '办公费',
  9238. '公关费',
  9239. '其他'
  9240. );
  9241. foreach ( $item as $va ) {
  9242. $falg = true;
  9243. foreach ( $receiptCollectList as $v ) {
  9244. if ($v ['itemCategory'] == '培训班费用') {
  9245. if ($v ['item'] == $va) {
  9246. $psum += $v ['price'];
  9247. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9248. $falg = false;
  9249. break;
  9250. }
  9251. }
  9252. }
  9253. if ($falg)
  9254. $html .= '<td class="taR">-</td>';
  9255. }
  9256. if (! empty ( $psum ))
  9257. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9258. else
  9259. $psum = '<td class="colGreen taR">-</td>';
  9260. $receiptL ['培训班费用'] = $psum . $html;
  9261. /* ------------------------------------- */
  9262. $html = "";
  9263. $psum = 0;
  9264. $item = array (
  9265. '公关费',
  9266. '广告费',
  9267. '借款',
  9268. '可自加费用'
  9269. );
  9270. foreach ( $item as $va ) {
  9271. $falg = true;
  9272. foreach ( $receiptCollectList as $v ) {
  9273. if ($v ['itemCategory'] == '其他') {
  9274. if ($v ['item'] == $va) {
  9275. $psum += $v ['price'];
  9276. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9277. $falg = false;
  9278. break;
  9279. }
  9280. }
  9281. }
  9282. if ($falg)
  9283. $html .= '<td class="taR">-</td>';
  9284. }
  9285. if (! empty ( $psum ))
  9286. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9287. else
  9288. $psum = '<td class="colGreen taR">-</td>';
  9289. $receiptL ['其他'] = $psum . $html;
  9290. /* ------------------------------------- */
  9291. $html = "";
  9292. $psum = 0;
  9293. foreach ( $receiptCollectList as $v ) {
  9294. if ($v ['itemCategory'] == '报销金额调整') {
  9295. if (! empty ( $v ['price'] ))
  9296. $psum += $v ['price'];
  9297. }
  9298. }
  9299. if (! empty ( $psum ))
  9300. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9301. else
  9302. $psum = '<td class="taR colOrange">-</td>';
  9303. $receiptL ['报销金额调整'] = $psum . $html;
  9304. } else {
  9305. $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>
  9306. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9307. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9308. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9309. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9310. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9311. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9312. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9313. }
  9314. $monthStaffPrice = $receiptDetail->find ( array (
  9315. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9316. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9317. 'asArray' => true
  9318. ) );
  9319. if (! empty ( $monthStaffPrice [0] ['price'] ))
  9320. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9321. else
  9322. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9323. $list [$value ['title']] = $receiptL;
  9324. }
  9325. $data ['list'] = $list;
  9326. $receiptCollectList = $receiptDetail->find ( array (
  9327. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9328. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9329. 'groupby' => 'item,Month(pastDate),itemCategory',
  9330. 'asArray' => true
  9331. ) );
  9332. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9333. // print_r($data['monthPriceHtml']);
  9334. // foreach ($data['monthPriceHtml'] as $value){
  9335. // echo $value;
  9336. // }
  9337. // die;
  9338. // statistics html
  9339. $stList = $statistics->getOne ( array (
  9340. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9341. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9342. 'groupby' => 'Month(date)',
  9343. 'asArray' => true
  9344. ) );
  9345. if (empty ( $stList ))
  9346. $stList = array (
  9347. 'rePrice' => 0,
  9348. 'agPrice' => 0
  9349. );
  9350. $data ['stList'] = array (
  9351. 'rePrice' => $stList ['rePrice'],
  9352. 'agPrice' => $stList ['agPrice'],
  9353. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9354. );
  9355. $monthHtml = "";
  9356. for($i = 1; $i <= 12; $i ++) {
  9357. if ($i == $month)
  9358. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9359. else
  9360. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9361. }
  9362. $data ['monthHtml'] = $monthHtml;
  9363. $data ['year'] = $year;
  9364. $data ['month'] = $month;
  9365. $data ['memu'] = "receipt";
  9366. $data ['staff'] = $this->staff;
  9367. $data ['receiptMemu'] = 'companyCategoryCollect';
  9368. $data ['verifyId'] = $this->verifyId;
  9369. $data ['executeId'] = $this->executeId;
  9370. $this->render ( "/admin/companyMonthCollectDetail", $data );
  9371. }
  9372. function staffCollectDetail() {
  9373. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9374. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  9375. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  9376. if (! $staffname) {
  9377. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  9378. $staffname = urldecode ( $staffname );
  9379. }
  9380. Doo::loadModel ( 'staff' );
  9381. $staff = new staff ();
  9382. Doo::loadModel ( "receiptDetail" );
  9383. $receiptDetail = new receiptDetail ();
  9384. Doo::loadModel ( 'accountItem' );
  9385. $accountItem = new accountItem ();
  9386. Doo::loadModel ( 'statistics' );
  9387. $statistics = new statistics ();
  9388. Doo::loadModel ( 'L_category' );
  9389. $lCategory = new L_category ();
  9390. $staffList = $staff->find ( array (
  9391. 'asArray' => true
  9392. ) );
  9393. $stHtml = '';
  9394. $stTitle = "";
  9395. $staffId = 0;
  9396. $cid = 0;
  9397. $ocid = 0;
  9398. foreach ( $staffList as $value ) {
  9399. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  9400. $stTitle = $value ['category'] . '-' . $value ['username'];
  9401. $staffId = $value ['sid'];
  9402. $cid = $value ['cid'];
  9403. $ocid = $value ['cid'];
  9404. if (! empty ( $value ['othercid'] ))
  9405. $cid = $value ['cid'] . ',' . $value ['othercid'];
  9406. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9407. } elseif ($value ['username'] != 'admin')
  9408. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9409. }
  9410. $data ['lCategoryHtml'] = $lCategory->find ( array (
  9411. 'where' => 'cid in(' . $cid . ')',
  9412. 'asArray' => true
  9413. ) );
  9414. if (empty ( $pcid ))
  9415. $pcid = $ocid;
  9416. $data ['ocid'] = $pcid;
  9417. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  9418. $this->showCache ( $path );
  9419. //
  9420. $receiptCollectList = $receiptDetail->find ( array (
  9421. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9422. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9423. 'groupby' => 'item,Month(pastDate),itemCategory',
  9424. 'asArray' => true
  9425. ) );
  9426. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  9427. // print_r($receiptCollectList);
  9428. $accountList = $accountItem->find ( array (
  9429. 'asArray' => true
  9430. ) );
  9431. // create CollectDetail HTML
  9432. $collectHtml = array ();
  9433. foreach ( $accountList as $key => $value ) {
  9434. $html = "";
  9435. $asum = 0;
  9436. for($i = 1; $i <= 12; $i ++) {
  9437. $falg = true;
  9438. foreach ( $receiptCollectList as $v ) {
  9439. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9440. if ($v ['item'] == '可自加费用') {
  9441. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  9442. }
  9443. $asum += $v ['price'];
  9444. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9445. $falg = false;
  9446. break;
  9447. }
  9448. }
  9449. if ($falg)
  9450. $html .= '<td class="taR">-</td>';
  9451. }
  9452. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9453. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9454. }
  9455. $data ['collectHtml'] = $collectHtml;
  9456. // print_r($collectHtml);
  9457. // create Adjustment price html
  9458. $receiptCollectList = $receiptDetail->find ( array (
  9459. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9460. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9461. 'groupby' => 'itemCategory,Month(pastDate)',
  9462. 'asArray' => true
  9463. ) );
  9464. $adjustment = array ();
  9465. $collectArray = array (
  9466. '日常相关费用' => array (),
  9467. '差旅相关费用' => array (),
  9468. '培训班费用' => array (),
  9469. '其他' => array ()
  9470. );
  9471. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9472. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9473. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9474. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9475. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9476. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9477. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9478. array_push ( $collectArray ['其他'], $collectHtml );
  9479. $data ['collectArray'] = $collectArray;
  9480. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9481. array_push ( $adjustment, $collectHtml );
  9482. $data ['adjustment'] = $adjustment;
  9483. // total price html
  9484. $collectHtml = "";
  9485. $total = 0;
  9486. for($i = 1; $i <= 12; $i ++) {
  9487. $sumPrice = 0;
  9488. foreach ( $receiptCollectList as $key => $value ) {
  9489. if ($value ['month'] == $i) {
  9490. $sumPrice += $value ['price'];
  9491. }
  9492. }
  9493. if ($sumPrice == 0)
  9494. $collectHtml .= '<td class="taR">-</td>';
  9495. else
  9496. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9497. $total += $sumPrice;
  9498. }
  9499. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9500. // statistics html
  9501. $stList = $statistics->statisticsByYear ( $year, $staffId );
  9502. if (empty ( $stList ))
  9503. $stList = array (
  9504. 'rePrice' => 0,
  9505. 'agPrice' => 0
  9506. );
  9507. $data ['stList'] = array (
  9508. 'rePrice' => $stList ['rePrice'],
  9509. 'agPrice' => $stList ['agPrice'],
  9510. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9511. );
  9512. $data ['totalPrice'] = $collectHtml;
  9513. $data ['totalYear'] = $total;
  9514. $data ['stHtml'] = $stHtml;
  9515. $data ['year'] = $year;
  9516. $data ['stTitle'] = $stTitle;
  9517. $data ['memu'] = "receipt";
  9518. $data ['staff'] = $this->staff;
  9519. $data ['receiptMemu'] = 'companyCategoryCollect';
  9520. $data ['verifyId'] = $this->verifyId;
  9521. $data ['executeId'] = $this->executeId;
  9522. if ($year < date ( "Y" )) {
  9523. Doo::loadModel ( 'receipt' );
  9524. $receipt = new receipt ();
  9525. $receiptList = $receipt->find ( array (
  9526. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  9527. 'asArray' => true
  9528. ) );
  9529. if (empty ( $receiptList )) { // generated files
  9530. ob_start ();
  9531. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9532. $this->cacheFile ( $path );
  9533. die ();
  9534. }
  9535. }
  9536. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9537. }
  9538. function BUGFLAG() {
  9539. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  9540. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  9541. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9542. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9543. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  9544. if (empty ( $status ))
  9545. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  9546. $page_size = 12;
  9547. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  9548. $vidList = array ();
  9549. $button = 0;
  9550. Doo::loadModel ( 'verify' );
  9551. $verify = new verify ();
  9552. Doo::loadModel ( 'receipt' );
  9553. $receipt = new receipt ();
  9554. Doo::loadModel ( 'staff' );
  9555. $staff = new staff ();
  9556. Doo::loadModel ( 'L_category' );
  9557. $Lcategory = new L_category ();
  9558. $dateCondition = " and Year(date) =" . $year;
  9559. if (! empty ( $month ))
  9560. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  9561. $categoryList = $Lcategory->find ( array (
  9562. 'asArray' => true
  9563. ) );
  9564. $staffList = $staff->find ( array (
  9565. 'where' => 'cid=' . $cid,
  9566. 'asArray' => true
  9567. ) );
  9568. $cateCondition = "";
  9569. $staffCondition = "";
  9570. $approvalCondition = "";
  9571. if (! empty ( $cid ))
  9572. $cateCondition = ' and cid=' . $cid;
  9573. if (! empty ( $sid )) {
  9574. $staffCondition = ' and staff=' . $sid;
  9575. $cateCondition = "";
  9576. }
  9577. $approvalCondition = " and status=" . $status;
  9578. if ($status == 2) {
  9579. // 查找角色审批人
  9580. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9581. }
  9582. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  9583. $approvalCondition = ' and status=2 ';
  9584. }
  9585. if ($status == 1) {
  9586. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  9587. }
  9588. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  9589. $pageinfo ['page'] = array (
  9590. 'previous' => ''
  9591. );
  9592. if ($status == 0) {
  9593. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  9594. $receiptList = $receipt->find ( array (
  9595. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  9596. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  9597. 'desc' => 'rid',
  9598. 'asArray' => true
  9599. ) );
  9600. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9601. } else
  9602. $receiptList = $receipt->find ( array (
  9603. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  9604. 'desc' => 'rid',
  9605. 'asArray' => true
  9606. ) );
  9607. $rLRes = $receipt->find ( array (
  9608. '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,
  9609. 'desc' => 'rid',
  9610. 'asArray' => true
  9611. ) );
  9612. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9613. // print_r($pageinfo);
  9614. $Locate = 0;
  9615. foreach ( $receiptList as $key => $value ) {
  9616. $receiptList [$key] ['Locate'] = $Locate;
  9617. $Locate ++;
  9618. $receiptList [$key] ['reviseDetail'] = array ();
  9619. if (! empty ( $value ['reviseDetail'] ))
  9620. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  9621. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  9622. $categoryDetil = $Lcategory->getOne ( array (
  9623. 'where' => 'cid=' . $value ['cid'],
  9624. 'asArray' => true
  9625. ) );
  9626. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  9627. $verifyList = $verify->getOne ( array (
  9628. 'where' => 'vid=' . $value ['verify'],
  9629. 'asArray' => true
  9630. ) );
  9631. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  9632. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  9633. foreach ( $verifyList as $k => $v ) {
  9634. // init verifyStaff
  9635. $verifyList [$k] ['date'] = "";
  9636. $verifyList [$k] ['opinion'] = "";
  9637. $verifyList [$k] ['status'] = "";
  9638. if (empty ( $verifyStaff )) {
  9639. $verifyList [$k] ['date'] = "";
  9640. $verifyList [$k] ['opinion'] = "";
  9641. if ($v [0] == $this->staff [0] ['sid']) {
  9642. $verifyList [$k] ['status'] = 4;
  9643. $button = 4;
  9644. }
  9645. } else {
  9646. $flag = true;
  9647. foreach ( $verifyStaff as $m => $u ) {
  9648. if ($v [0] == $m) {
  9649. $verifyList [$k] ['date'] = $u ['date'];
  9650. $verifyList [$k] ['opinion'] = $u ['opinion'];
  9651. $verifyList [$k] ['status'] = $u ['status'];
  9652. $flag = false;
  9653. break;
  9654. }
  9655. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  9656. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  9657. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  9658. }
  9659. if ($flag) { // 检测可编辑
  9660. if ($v [0] == $this->staff [0] ['sid']) {
  9661. $verifyList [$k] ['status'] = 4;
  9662. $button = 4;
  9663. }
  9664. }
  9665. }
  9666. }
  9667. $receiptList [$key] ['verifyList'] = $verifyList;
  9668. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  9669. 'where' => 'sid=' . $value ['staff'],
  9670. 'asArray' => true
  9671. ) );
  9672. $receiptList [$key] ['button'] = $button;
  9673. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  9674. }
  9675. // print_r($receiptList);die;
  9676. // $data['verifyDetail']=$verifyDetail;
  9677. $mothHtml = "";
  9678. for($i = 1; $i <= 12; $i ++) {
  9679. if ($month == $i)
  9680. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  9681. else
  9682. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  9683. }
  9684. $data ['mothHtml'] = $mothHtml;
  9685. $data ['page'] = $pageinfo;
  9686. $data ['receiptList'] = $receiptList;
  9687. $data ['receiptApprovalCount'] = count ( $rLRes );
  9688. $data ['status'] = $status;
  9689. $data ['year'] = $year;
  9690. $data ['categoryList'] = $categoryList;
  9691. $data ['staffList'] = $staffList;
  9692. $data ['cid'] = $cid;
  9693. $data ['sid'] = $sid;
  9694. // print_r($receiptList);
  9695. $data ['memu'] = "receipt";
  9696. $data ['staff'] = $this->staff;
  9697. $data ['receiptMemu'] = 'approvalExpenses';
  9698. $data ['verifyId'] = $this->verifyId;
  9699. $data ['executeId'] = $this->executeId;
  9700. $this->render ( "/admin/FALG", $data );
  9701. }
  9702. function ajaxGetReceiptOrder() {
  9703. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  9704. if (! empty ( $receiptOrder )) {
  9705. Doo::loadModel ( 'receipt' );
  9706. $receipt = new receipt ();
  9707. Doo::loadModel ( 'staff' );
  9708. $staff = new staff ();
  9709. $receiptInfo = $receipt->getOne ( array (
  9710. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  9711. 'asArray' => true
  9712. ) );
  9713. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  9714. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  9715. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  9716. </tbody></table><table class="table table table-bordered"><tbody>';
  9717. foreach ( $verifyStaff as $key => $value ) {
  9718. $staffInfo = $staff->getOne ( array (
  9719. 'select' => 'username',
  9720. 'where' => ' sid="' . $key . '"',
  9721. 'asArray' => true
  9722. ) );
  9723. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  9724. }
  9725. $html .= '</tbody></table></div></div>';
  9726. echo json_encode ( array (
  9727. 'status' => 1,
  9728. 'receiptHtml' => $html
  9729. ) );
  9730. die ();
  9731. }
  9732. echo json_encode ( array (
  9733. 'status' => 2,
  9734. 'receiptHtml' => ''
  9735. ) );
  9736. die ();
  9737. }
  9738. function _getMonthCollectDetail($receiptCollectList) {
  9739. if (! empty ( $receiptCollectList )) {
  9740. $receiptL = array (
  9741. '日常相关费用' => array (),
  9742. '差旅相关费用' => array (),
  9743. '培训班费用' => array (),
  9744. '其他' => array ()
  9745. );
  9746. $html = "";
  9747. $psum = 0;
  9748. $item = array (
  9749. '市内交通费',
  9750. '市内出租费',
  9751. '办事处房租',
  9752. '电话费',
  9753. '水费',
  9754. '电费',
  9755. '办公费用',
  9756. '邮寄费',
  9757. '其他费用',
  9758. '车辆费用',
  9759. '广告费',
  9760. '团队建设费',
  9761. '物业管理费',
  9762. '宽带费'
  9763. );
  9764. foreach ( $item as $value ) {
  9765. $falg = true;
  9766. foreach ( $receiptCollectList as $v ) {
  9767. if ($v ['itemCategory'] == '日常相关费用') {
  9768. if ($v ['item'] == $value) {
  9769. $psum += $v ['price'];
  9770. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9771. $falg = false;
  9772. break;
  9773. }
  9774. }
  9775. }
  9776. if ($falg)
  9777. $html .= '<td class="taR">-</td>';
  9778. }
  9779. if (! empty ( $psum ))
  9780. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9781. else
  9782. $psum = '<td class="colGreen taR">-</td>';
  9783. $receiptL ['日常相关费用'] = $psum . $html;
  9784. /* ----------------------------------- */
  9785. $html = "";
  9786. $psum = 0;
  9787. $item = array (
  9788. '往来交通费',
  9789. '市内交通费',
  9790. '出差住宿费',
  9791. '出差补助',
  9792. '其他费用'
  9793. );
  9794. foreach ( $item as $value ) {
  9795. $falg = true;
  9796. foreach ( $receiptCollectList as $v ) {
  9797. if ($v ['itemCategory'] == '差旅相关费用') {
  9798. if ($v ['item'] == $value) {
  9799. $psum += $v ['price'];
  9800. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9801. $falg = false;
  9802. break;
  9803. }
  9804. }
  9805. }
  9806. if ($falg)
  9807. $html .= '<td class="taR">-</td>';
  9808. }
  9809. if (! empty ( $psum ))
  9810. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9811. else
  9812. $psum = '<td class="colGreen taR">-</td>';
  9813. $receiptL ['差旅相关费用'] = $psum . $html;
  9814. /* ------------------------------------- */
  9815. $html = "";
  9816. $psum = 0;
  9817. $item = array (
  9818. '场租费',
  9819. '薪酬',
  9820. '住宿费',
  9821. '交通费',
  9822. '餐饮费',
  9823. '办公费',
  9824. '公关费',
  9825. '其他'
  9826. );
  9827. foreach ( $item as $value ) {
  9828. $falg = true;
  9829. foreach ( $receiptCollectList as $v ) {
  9830. if ($v ['itemCategory'] == '培训班费用') {
  9831. if ($v ['item'] == $value) {
  9832. $psum += $v ['price'];
  9833. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9834. $falg = false;
  9835. break;
  9836. }
  9837. }
  9838. }
  9839. if ($falg)
  9840. $html .= '<td class="taR">-</td>';
  9841. }
  9842. if (! empty ( $psum ))
  9843. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9844. else
  9845. $psum = '<td class="colGreen taR">-</td>';
  9846. $receiptL ['培训班费用'] = $psum . $html;
  9847. /* ------------------------------------- */
  9848. $html = "";
  9849. $psum = 0;
  9850. $item = array (
  9851. '公关费',
  9852. '广告费',
  9853. '借款',
  9854. '可自加费用'
  9855. );
  9856. foreach ( $item as $value ) {
  9857. $falg = true;
  9858. foreach ( $receiptCollectList as $v ) {
  9859. if ($v ['itemCategory'] == '其他') {
  9860. if ($v ['item'] == $value) {
  9861. $psum += $v ['price'];
  9862. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9863. $falg = false;
  9864. break;
  9865. }
  9866. }
  9867. }
  9868. if ($falg)
  9869. $html .= '<td class="taR">-</td>';
  9870. }
  9871. if (! empty ( $psum ))
  9872. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9873. else
  9874. $psum = '<td class="colGreen taR">-</td>';
  9875. $receiptL ['其他'] = $psum . $html;
  9876. /* ------------------------------------- */
  9877. $html = "";
  9878. $psum = 0;
  9879. foreach ( $receiptCollectList as $v ) {
  9880. if ($v ['itemCategory'] == '报销金额调整') {
  9881. if (! empty ( $v ['price'] ))
  9882. $psum += $v ['price'];
  9883. }
  9884. }
  9885. if (! empty ( $psum ))
  9886. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9887. else
  9888. $psum = '<td class="taR colOrange">-</td>';
  9889. $receiptL ['报销金额调整'] = $psum . $html;
  9890. } else {
  9891. $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>
  9892. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9893. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9894. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9895. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9896. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9897. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9898. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9899. }
  9900. return $receiptL;
  9901. }
  9902. function eMail() {
  9903. Doo::loadModel ( 'staff' );
  9904. $staff = new staff ();
  9905. Doo::loadModel ( 'receipt' );
  9906. $receipt = new receipt ();
  9907. Doo::loadModel ( 'L_category' );
  9908. $Lcategory = new L_category ();
  9909. Doo::loadModel ( "verify" );
  9910. $verify = new verify ();
  9911. $staffList = $staff->find ( array (
  9912. 'asArray' => true
  9913. ) );
  9914. foreach ( $staffList as $key => $value ) {
  9915. if ($value ['username'] != 'admin') {
  9916. // 提交人
  9917. $receiptList = $receipt->find ( array (
  9918. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  9919. 'asArray' => true
  9920. ) );
  9921. if (! empty ( $receiptList )) {
  9922. $html = '<br><div><style></style>
  9923. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  9924. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  9925. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9926. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  9927. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9928. <tbody><tr>
  9929. <td style="padding: 0 40px;" align="left">
  9930. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9931. </td></tr><tr>
  9932. <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>
  9933. </tr>
  9934. </tbody> </table></td> </tr> <tr><td>
  9935. <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">
  9936. <tbody> <tr><td>
  9937. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  9938. 以下报销单完成了审批,等着收款吧:</p>
  9939. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  9940. foreach ( $receiptList as $k => $v ) {
  9941. $category = $Lcategory->getOne ( array (
  9942. 'where' => 'cid=' . $v ['cid'],
  9943. 'asArray' => true
  9944. ) );
  9945. $html .= '
  9946. <tr>
  9947. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  9948. <td align="left">
  9949. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  9950. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  9951. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  9952. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  9953. </tr>';
  9954. }
  9955. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  9956. <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>
  9957. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  9958. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  9959. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  9960. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9961. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9962. $receipt = new receipt ();
  9963. $receipt->notice = 1;
  9964. $receipt->update ( array (
  9965. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  9966. ) );
  9967. }
  9968. }
  9969. // 审批人
  9970. $verifyList = $verify->find ( array (
  9971. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  9972. 'asArray' => true
  9973. ) );
  9974. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  9975. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  9976. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9977. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  9978. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9979. <tbody><tr><td style="padding: 0 40px;" align="left">
  9980. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9981. </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>
  9982. </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">
  9983. <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>
  9984. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  9985. foreach ( $verifyList as $k => $v ) {
  9986. $receiptList = $receipt->find ( array (
  9987. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  9988. 'asArray' => true
  9989. ) );
  9990. foreach ( $receiptList as $r => $l ) {
  9991. $category = $Lcategory->getOne ( array (
  9992. 'where' => 'cid=' . $l ['cid'],
  9993. 'asArray' => true
  9994. ) );
  9995. $staffDetile = $staff->getOne ( array (
  9996. 'where' => 'sid=' . $l ['staff'],
  9997. 'asArray' => true
  9998. ) );
  9999. $html .= '
  10000. <tr>
  10001. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  10002. <td align="left">
  10003. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  10004. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  10005. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  10006. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  10007. </tr>';
  10008. }
  10009. }
  10010. $html .= '
  10011. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  10012. <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>
  10013. </tr></tbody></table></td></tr></tbody></table></div><br>';
  10014. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  10015. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  10016. // $receipt=new receipt();
  10017. // $receipt->notice=1;
  10018. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  10019. }
  10020. }
  10021. }
  10022. }
  10023. function setWXMsg($rid, $type) {
  10024. Doo::loadModel ( "receipt" );
  10025. $receipt = new receipt ();
  10026. $receiptDetail = $receipt->getOne ( array (
  10027. 'where' => 'rid=' . $rid,
  10028. 'asArray' => true
  10029. ) );
  10030. if (! empty ( $receiptDetail )) {
  10031. Doo::loadModel ( 'staff' );
  10032. $staff = new staff ();
  10033. $staffmsg = $staff->getOne ( array (
  10034. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  10035. 'asArray' => TRUE
  10036. ) );
  10037. if (! empty ( $staffmsg ['wxid'] )) {
  10038. require_once (SITE_PATH . '/protected/class/client.php');
  10039. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  10040. $user = $staffmsg ['wxid'];
  10041. $receiptName = '';
  10042. $msg = '';
  10043. switch ($receiptDetail ['Rtype']) {
  10044. case 0 :
  10045. $receiptName = '报销';
  10046. break;
  10047. case 1 :
  10048. $receiptName = '借款';
  10049. break;
  10050. case 2 :
  10051. $receiptName = '对公汇款';
  10052. break;
  10053. }
  10054. switch ($type) {
  10055. case 1 :
  10056. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  10057. break;
  10058. case 2 :
  10059. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  10060. break;
  10061. case 3 :
  10062. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  10063. break;
  10064. }
  10065. $result = $client->SendMsg ( $user, $msg, 'text' );
  10066. }
  10067. }
  10068. }
  10069. // Email发送函数
  10070. function SMail($toemail, $subject, $contents) {
  10071. Doo::loadClass ( 'class.phpmailer' );
  10072. $mail = new PHPMailer ();
  10073. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  10074. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  10075. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  10076. $mail->Password = "cDO1GjtY1seH"; // 密码
  10077. $mail->CharSet = "UTF8";
  10078. $mail->SMTPAuth = true;
  10079. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  10080. $mail->Mailer = "smtp";
  10081. $mail->Port = 25;
  10082. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  10083. $mail->MsgHTML ( $contents );
  10084. $mail->AddAddress ( $toemail );
  10085. $mail->CharSet = "UTF-8";
  10086. return $mail->Send ();
  10087. }
  10088. function swfupload() {
  10089. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  10090. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  10091. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  10092. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  10093. header ( "HTTP/1.1 500 Internal Server Error" );
  10094. echo "POST exceeded maximum allowed size.";
  10095. exit ( 0 );
  10096. }
  10097. // Settings
  10098. $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)
  10099. $upload_name = "Filedata";
  10100. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  10101. $extension_whitelist = array (
  10102. "doc",
  10103. "txt",
  10104. "jpg",
  10105. "gif",
  10106. "png"
  10107. ); // Allowed file extensions
  10108. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  10109. // Other variables
  10110. $MAX_FILENAME_LENGTH = 260;
  10111. $file_name = "";
  10112. $file_extension = "";
  10113. $uploadErrors = array (
  10114. 0 => "文件上传成功",
  10115. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  10116. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  10117. 3 => "上传的文件仅为部分文件",
  10118. 4 => "没有文件上传",
  10119. 6 => "缺少临时文件夹"
  10120. );
  10121. $nk = time ();
  10122. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  10123. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  10124. echo "文件无法保存.";
  10125. exit ( 0 );
  10126. }
  10127. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  10128. echo json_encode ( array (
  10129. 'filename' => $file_name,
  10130. 'id' => $nk
  10131. ) );
  10132. exit ( 0 );
  10133. }
  10134. function _GetFileEXT($filename) {
  10135. $pics = explode ( '.', $filename );
  10136. $num = count ( $pics );
  10137. return $pics [$num - 1];
  10138. }
  10139. /**
  10140. * 获取get或者POST值
  10141. * @param string $name 属性名称
  10142. * @return fixed 值
  10143. */
  10144. function get_args($name) {
  10145. if (isset ( $_GET [$name] )) {
  10146. if (is_array ( $_GET [$name] ))
  10147. return $_GET [$name];
  10148. else
  10149. return addslashes ( $_GET [$name] );
  10150. } elseif (isset ( $_POST [$name] )) {
  10151. if (is_array ( $_POST [$name] ))
  10152. return $_POST [$name];
  10153. else
  10154. return addslashes ( $_POST [$name] );
  10155. } else
  10156. return false;
  10157. }
  10158. function num_to_rmb($num) {
  10159. $c1 = "零壹贰叁肆伍陆柒捌玖";
  10160. $c2 = "分角元拾佰仟万拾佰仟亿";
  10161. // 精确到分后面就不要了,所以只留两个小数位
  10162. $num = round ( $num, 2 );
  10163. // 将数字转化为整数
  10164. $num = $num * 100;
  10165. if (strlen ( $num ) > 10) {
  10166. return "金额太大,请检查";
  10167. }
  10168. $i = 0;
  10169. $c = "";
  10170. while ( 1 ) {
  10171. if ($i == 0) {
  10172. // 获取最后一位数字
  10173. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  10174. } else {
  10175. $n = $num % 10;
  10176. }
  10177. // 每次将最后一位数字转化为中文
  10178. $p1 = substr ( $c1, 3 * $n, 3 );
  10179. $p2 = substr ( $c2, 3 * $i, 3 );
  10180. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  10181. $c = $p1 . $p2 . $c;
  10182. } else {
  10183. $c = $p1 . $c;
  10184. }
  10185. $i = $i + 1;
  10186. // 去掉数字最后一位了
  10187. $num = $num / 10;
  10188. $num = ( int ) $num;
  10189. // 结束循环
  10190. if ($num == 0) {
  10191. break;
  10192. }
  10193. }
  10194. $j = 0;
  10195. $slen = strlen ( $c );
  10196. while ( $j < $slen ) {
  10197. // utf8一个汉字相当3个字符
  10198. $m = substr ( $c, $j, 6 );
  10199. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  10200. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  10201. $left = substr ( $c, 0, $j );
  10202. $right = substr ( $c, $j + 3 );
  10203. $c = $left . $right;
  10204. $j = $j - 3;
  10205. $slen = $slen - 3;
  10206. }
  10207. $j = $j + 3;
  10208. }
  10209. // 这个是为了去掉类似23.0中最后一个“零”字
  10210. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  10211. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  10212. }
  10213. // 将处理的汉字加上“整”
  10214. if (empty ( $c )) {
  10215. return "零元整";
  10216. } else {
  10217. return $c . "整";
  10218. }
  10219. }
  10220. /**
  10221. * 获得分页数据
  10222. * @param unknown_type $table
  10223. * @param unknown_type $condition
  10224. * @param unknown_type $on_page
  10225. * @param unknown_type $page_size
  10226. */
  10227. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  10228. $page_c = "";
  10229. $page ['previous'] = $this->get_previous ( $on_page );
  10230. $page ['on_page'] = $on_page;
  10231. $total_count = $this->get_table_count ( $table, $condition );
  10232. $total = intval ( $total_count / $page_size );
  10233. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  10234. $page ['total_data'] = $total_count;
  10235. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  10236. $i = 1;
  10237. $page_max = 1;
  10238. $page_width = 3;
  10239. if ($on_page >= $page_width) {
  10240. $page_max = intval ( $on_page / $page_width ) + 1;
  10241. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  10242. }
  10243. for(; $i <= $page ['total_page']; $i ++) {
  10244. if ($i == $on_page)
  10245. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  10246. else
  10247. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  10248. if ($i == ($page_width * $page_max))
  10249. break;
  10250. }
  10251. $page ['page'] = $page_c;
  10252. $page ['lower'] = (-- $on_page) * $page_size;
  10253. return $page;
  10254. }
  10255. /**
  10256. * 获取总页数
  10257. * @param unknown_type $table
  10258. * @param unknown_type $condition
  10259. */
  10260. public function get_table_count($table = "", $condition = "") {
  10261. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10262. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10263. // echo $sql;die;
  10264. $query = Doo::db ()->query ( $sql );
  10265. $result = $query->fetch ();
  10266. return $result ['count'];
  10267. }
  10268. /**
  10269. * 获取上一页
  10270. * @param unknown_type $on_page
  10271. */
  10272. function get_previous($on_page = 1) {
  10273. return $on_page != 0 ? $on_page - 1 : $on_page;
  10274. }
  10275. }
  10276. ?>