ReceiptController.php 371 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class ReceiptController extends DooController {
  6. public $staff;
  7. public $verifyId;
  8. public $executeId;
  9. // public static $NEW2 = 0;
  10. public $AGENCY = "日常相关费用";
  11. public $TRAVEL = "差旅相关费用";
  12. public $TRAIN = "培训班费用";
  13. public $OTHER = "其他";
  14. private $MYREVEIPTCACHEPATH = "protected/cache/myReceipt/";
  15. private $PERSONALCOLLECTCACHEPATH = "protected/cache/personalCollect/";
  16. private $CATEGORYCOLLECTPATH = "protected/cache/categoryCollect/";
  17. private $STAFFCOLLECTPATH = "protected/cache/staffCollect/";
  18. private function showCache($path) {
  19. if (file_exists ( $path )) {
  20. echo "<!DOCTYPE html>";
  21. include $path;
  22. die ();
  23. }
  24. }
  25. private function cacheFile($path) {
  26. $content = ob_get_contents ();
  27. $fp = fopen ( $path, "w" );
  28. fwrite ( $fp, $content );
  29. fclose ( $fp );
  30. }
  31. private function collectHtml($receiptCollectList = array(), $itemCategory = "日常相关费用", $classType = "b") {
  32. $collectHtml = "";
  33. $sumPrice = 0.00;
  34. for($i = 1; $i <= 12; $i ++) {
  35. $falg = true;
  36. foreach ( $receiptCollectList as $key => $value ) {
  37. if ($value ['itemCategory'] == $itemCategory && $value ['month'] == $i) {
  38. $sumPrice += $value ['price'];
  39. if ($classType == "b") {
  40. $collectHtml .= '<td class="colGreen taR">¥' . $value ['price'] . '</td>';
  41. $falg = false;
  42. break;
  43. } else {
  44. $collectHtml .= '<td class="taR">¥' . $value ['price'] . '</td>';
  45. $falg = false;
  46. break;
  47. }
  48. }
  49. }
  50. if ($falg)
  51. $collectHtml .= '<td class="taR">-</td>';
  52. }
  53. $collectHtml .= '<td class="taR colGreen">¥' . $sumPrice . '</td>';
  54. return $collectHtml;
  55. }
  56. function __construct() {
  57. if (isset ( $_COOKIE ["staff"] )) {
  58. if (! empty ( $_COOKIE ["staff"] )) {
  59. Doo::loadModel ( 'staff' );
  60. Doo::loadModel ( 'verify' );
  61. $verify = new verify ();
  62. $staff = new staff ();
  63. Doo::loadModel ( "execute" );
  64. $execute = new execute ();
  65. $verifyList = $verify->find ( array (
  66. 'select' => 'staff',
  67. 'asArray' => true
  68. ) );
  69. $list = array ();
  70. // 判断角色的审批权限
  71. foreach ( $verifyList as $key => $value ) {
  72. $ver = json_decode ( $value ['staff'] );
  73. foreach ( $ver as $k => $v ) {
  74. if ($v [1] == 'ROLE') {
  75. $roleList = json_decode ( $v [3] );
  76. foreach ( $roleList as $t => $g ) {
  77. $gList = explode ( "_", $g );
  78. array_push ( $list, $gList [0] );
  79. // print_r($list);
  80. }
  81. } else
  82. array_push ( $list, $v [0] );
  83. }
  84. }
  85. // 判断执行人的审批权限
  86. $executeList = $execute->find ( array (
  87. 'select' => 'staff',
  88. 'asArray' => true
  89. ) );
  90. $list2 = array ();
  91. foreach ( $executeList as $key => $value ) {
  92. $ver = json_decode ( $value ['staff'] );
  93. foreach ( $ver as $k => $v ) {
  94. array_push ( $list2, $v [0] );
  95. }
  96. }
  97. $eidList = file_get_contents ( "protected/config/execute/execute.ini" );
  98. $eidList = array_filter ( explode ( ",", $eidList ) );
  99. $this->executeId = array_merge ( $list2, $eidList );
  100. $this->verifyId = $list;
  101. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  102. return "/";
  103. }
  104. }
  105. Doo::loadCore ( 'uri/DooUriRouter' );
  106. $router = new DooUriRouter ();
  107. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  108. if ($routeRs ['1'] != "login") {
  109. header ( 'Content-Type:text/html;charset=utf-8' );
  110. @header ( "Location: /login" );
  111. }
  112. }
  113. function saeaBorad() {
  114. Doo::loadModel ( 'receipt' );
  115. Doo::loadModel ( 'verify' );
  116. $verify = new verify ();
  117. $receipt = new receipt ();
  118. Doo::loadModel ( 'L_category' );
  119. $lCategory = new L_category ();
  120. Doo::loadModel ( "role" );
  121. $role = new role ();
  122. Doo::loadModel ( "receiptLog" );
  123. $receiptLog = new receiptLog ();
  124. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  125. $receiptDetail = $receipt->find ( array (
  126. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  127. 'desc' => 'rid',
  128. 'asArray' => true
  129. ) );
  130. foreach ( $receiptDetail as $key => $value ) {
  131. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  132. $veList = $verify->getOne ( array (
  133. 'where' => 'vid=' . $value ['verify'],
  134. 'asArray' => true
  135. ) );
  136. $v = json_decode ( $veList ['staff'] );
  137. array_push ( $v [0], $veList ['description'] );
  138. foreach ( $v as $n => $m ) {
  139. if ($m ['1'] == 'ROLE') {
  140. $roleInfo = $role->getOne ( array (
  141. 'where' => 'rid=' . $m [0],
  142. 'asArray' => true
  143. ) );
  144. $v [$n] [1] = $roleInfo ['name'];
  145. }
  146. }
  147. $receiptDetail [$key] ['staff'] = $v;
  148. $category = $lCategory->getOne ( array (
  149. 'where' => 'cid=' . $value ['cid'],
  150. 'asArray' => true
  151. ) );
  152. $receiptDetail [$key] ['category'] = $category ['title'];
  153. }
  154. // print_r($receiptLogList);
  155. $data ['receiptLogList'] = $receiptLogList;
  156. $data ['receiptDetail'] = $receiptDetail;
  157. $data ['memu'] = "receipt";
  158. $data ['staff'] = $this->staff;
  159. $data ['receiptMemu'] = 'saeaBorad';
  160. $data ['verifyId'] = $this->verifyId;
  161. $data ['executeId'] = $this->executeId;
  162. $this->render ( "/admin/saeaBorad", $data );
  163. }
  164. function remitAdd() {
  165. Doo::loadModel ( 'accountItem' );
  166. Doo::loadModel ( 'verify' );
  167. Doo::loadModel ( 'receipt' );
  168. Doo::loadModel ( 'L_category' );
  169. $lCategory = new L_category ();
  170. $receipt = new receipt ();
  171. $verify = new verify ();
  172. $accountItem = new accountItem ();
  173. Doo::loadModel ( "role" );
  174. $role = new role ();
  175. $acItem = $accountItem->find ( array (
  176. 'asArray' => true
  177. ) );
  178. $veList = $verify->find ( array (
  179. 'asArray' => true
  180. ) );
  181. foreach ( $veList as $key => $value ) {
  182. $v = json_decode ( $value ['staff'] );
  183. $list = array ();
  184. foreach ( $v as $n => $m ) {
  185. if ($m ['1'] == 'ROLE') {
  186. $roleInfo = $role->getOne ( array (
  187. 'where' => 'rid=' . $m [0],
  188. 'asArray' => true
  189. ) );
  190. $v [$n] [1] = $roleInfo ['name'];
  191. array_push ( $list, $roleInfo ['name'] );
  192. } else {
  193. array_push ( $list, $v [$n] [1] );
  194. }
  195. }
  196. $veList [$key] ['staff'] = implode ( '>', $list );
  197. }
  198. $data ['category'] = $lCategory->find ( array (
  199. 'asArray' => true
  200. ) );
  201. $data ['veList'] = $veList;
  202. $data ['acItem'] = $acItem;
  203. $data ['memu'] = "receipt";
  204. $data ['staff'] = $this->staff;
  205. $data ['receiptMemu'] = 'saeaBorad';
  206. $data ['verifyId'] = $this->verifyId;
  207. $data ['executeId'] = $this->executeId;
  208. $this->render ( "/admin/remitAdd", $data );
  209. }
  210. function remitAddDo() {
  211. $agency = $this->get_args ( 'agency' );
  212. $travel = $this->get_args ( 'travel' );
  213. $train = $this->get_args ( 'train' );
  214. $other = $this->get_args ( 'other' );
  215. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  216. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  217. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  218. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  219. // print_r($agency);die;
  220. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  221. Doo::loadModel ( 'receipt' );
  222. Doo::loadModel ( 'receiptDetail' );
  223. Doo::loadModel ( 'accountItem' );
  224. $accountItem = new accountItem ();
  225. $receipt = new receipt ();
  226. Doo::loadModel ( 'enclosur' );
  227. Doo::loadModel ( 'execute' );
  228. $execute = new execute ();
  229. $executeDetail = $execute->getOne ( array (
  230. 'where' => 'mold="对公汇款执行人"',
  231. 'asArray' => true
  232. ) );
  233. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  234. $aItem = $accountItem->find ( array (
  235. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  236. 'asArray' => true
  237. ) );
  238. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  239. $ag = $tr = $ta = $ot = 0;
  240. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  241. foreach ( $aItem as $key => $value ) {
  242. if ($value ['category'] == $this->AGENCY) {
  243. if (isset ( $agency [$ag] )) {
  244. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  245. array_push ( $accountJson [$this->AGENCY], array (
  246. 'aid' => $value ['aid'],
  247. 'name' => $value ['name'],
  248. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  249. ) );
  250. $sum += $agency [$ag];
  251. $agencySum += $agency [$ag];
  252. }
  253. }
  254. $ag ++;
  255. }
  256. }
  257. $accountJson ['cSum'] = array (
  258. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  259. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  260. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  261. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  262. );
  263. // 报销单
  264. $receipt->accountItem = json_encode ( $accountJson );
  265. $receipt->staff = $this->staff [0] ['sid'];
  266. $receipt->sum = number_format ( $sum, 2, '.', '' );
  267. $receipt->date = date ( "Y-m-d" );
  268. $receipt->cid = $cid;
  269. $receipt->status = 5;
  270. $receipt->Rtype = 2;
  271. // 修改审批流程加入角色
  272. $receipt->verify = $verify;
  273. $receipt->executeCopy = $executeDetail ['staff'];
  274. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  275. $receipt->explanation = $explanation;
  276. $rid = $receipt->insert ();
  277. // 附件
  278. if (! empty ( $enclosurName )) {
  279. $enclosurArray = explode ( '-', $enclosurName );
  280. foreach ( $enclosurArray as $value ) {
  281. $enclosur = new enclosur ();
  282. $enclosur->name = $value;
  283. $enclosur->rid = $rid;
  284. $enclosur->insert ();
  285. }
  286. // print_r($enclosurArray);die;
  287. }
  288. // 报销详情
  289. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  290. $receiptDetail = new receiptDetail ();
  291. $receiptDetail->staff = $this->staff [0] ['sid'];
  292. $receiptDetail->item = $value ['name'];
  293. $receiptDetail->itemCategory = $this->AGENCY;
  294. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  295. $receiptDetail->date = date ( "Y-m-d" );
  296. $receiptDetail->cid = $cid;
  297. $receiptDetail->rid = $rid;
  298. $receiptDetail->status = 4;
  299. $receiptDetail->insert ();
  300. }
  301. return "/saeaBorad";
  302. }else
  303. die ( 'illegal request' );
  304. }
  305. function remitEdit() {
  306. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  307. // echo $rid;
  308. Doo::loadModel ( 'accountItem' );
  309. Doo::loadModel ( 'verify' );
  310. Doo::loadModel ( 'receipt' );
  311. $receipt = new receipt ();
  312. $verify = new verify ();
  313. $accountItem = new accountItem ();
  314. Doo::loadModel ( 'L_category' );
  315. $lCategory = new L_category ();
  316. Doo::loadModel ( "role" );
  317. $role = new role ();
  318. $receiptDetail = $receipt->getOne ( array (
  319. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  320. 'asArray' => true
  321. ) );
  322. if (empty ( $receiptDetail ))
  323. return "/saeaCreate";
  324. $acItem = $accountItem->find ( array (
  325. 'asArray' => true
  326. ) );
  327. $veList = $verify->find ( array (
  328. 'asArray' => true
  329. ) );
  330. foreach ( $veList as $key => $value ) {
  331. $v = json_decode ( $value ['staff'] );
  332. $list = array ();
  333. foreach ( $v as $n => $m ) {
  334. if ($m ['1'] == 'ROLE') {
  335. $roleInfo = $role->getOne ( array (
  336. 'where' => 'rid=' . $m [0],
  337. 'asArray' => true
  338. ) );
  339. $v [$n] [1] = $roleInfo ['name'];
  340. array_push ( $list, $roleInfo ['name'] );
  341. } else {
  342. array_push ( $list, $v [$n] [1] );
  343. }
  344. }
  345. $veList [$key] ['staff'] = implode ( '>', $list );
  346. }
  347. // 配置编辑信息
  348. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  349. foreach ( $acItem as $key => $value ) {
  350. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  351. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  352. $acItem [$key] ['price'] = $v ['price'];
  353. }
  354. }
  355. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  356. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  357. $acItem [$key] ['price'] = $v ['price'];
  358. }
  359. }
  360. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  361. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  362. $acItem [$key] ['price'] = $v ['price'];
  363. }
  364. }
  365. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  366. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  367. $acItem [$key] ['price'] = $v ['price'];
  368. }
  369. }
  370. }
  371. $data ['category'] = $lCategory->find ( array (
  372. 'asArray' => true
  373. ) );
  374. $data ['cSum'] = $accountItemList ['cSum'];
  375. $data ['sum'] = $receiptDetail ['sum'];
  376. $data ['receiptDetail'] = $receiptDetail;
  377. $data ['veList'] = $veList;
  378. $data ['acItem'] = $acItem;
  379. $data ['memu'] = "receipt";
  380. $data ['staff'] = $this->staff;
  381. $data ['receiptMemu'] = 'saeaBorad';
  382. $data ['verify'] = $receiptDetail ['verify'];
  383. $data ['verifyId'] = $this->verifyId;
  384. $data ['executeId'] = $this->executeId;
  385. $data ['rid'] = $rid;
  386. $this->render ( "/admin/remitEdit", $data );
  387. }
  388. function remitEdiDo() {
  389. $agency = $this->get_args ( 'agency' );
  390. $travel = $this->get_args ( 'travel' );
  391. $train = $this->get_args ( 'train' );
  392. $other = $this->get_args ( 'other' );
  393. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  394. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  395. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  396. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  397. if (! empty ( $explanation )) {
  398. Doo::loadModel ( 'receipt' );
  399. Doo::loadModel ( 'receiptDetail' );
  400. Doo::loadModel ( 'accountItem' );
  401. $accountItem = new accountItem ();
  402. $receipt = new receipt ();
  403. Doo::loadModel ( 'execute' );
  404. $execute = new execute ();
  405. $executeDetail = $execute->getOne ( array (
  406. 'where' => 'mold="对公汇款执行人"',
  407. 'asArray' => true
  408. ) );
  409. $receiptDetail = $receipt->getOne ( array (
  410. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  411. 'asArray' => true
  412. ) );
  413. if (empty ( $receiptDetail ))
  414. return "/saeaBorad";
  415. $aItem = $accountItem->find ( array (
  416. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  417. 'asArray' => true
  418. ) );
  419. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  420. $ag = $tr = $ta = $ot = 0;
  421. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  422. foreach ( $aItem as $key => $value ) {
  423. if ($value ['category'] == $this->AGENCY) {
  424. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  425. array_push ( $accountJson [$this->AGENCY], array (
  426. 'aid' => $value ['aid'],
  427. 'name' => $value ['name'],
  428. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  429. ) );
  430. $sum += $agency [$ag];
  431. $agencySum += $agency [$ag];
  432. }
  433. $ag ++;
  434. }
  435. }
  436. $accountJson ['cSum'] = array (
  437. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  438. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  439. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  440. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  441. );
  442. // 报销单
  443. $rid = $receipt->rid = $receiptDetail ['rid'];
  444. $receipt->accountItem = json_encode ( $accountJson );
  445. $receipt->staff = $this->staff [0] ['sid'];
  446. $receipt->sum = number_format ( $sum, 2, '.', '' );
  447. $receipt->date = date ( "Y-m-d" );
  448. $receipt->cid = $cid;
  449. if ($receiptDetail ['Rtype'] == 1)
  450. $receipt->status = 7;
  451. else
  452. $receipt->status = 5;
  453. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  454. $receipt->verify = $verify;
  455. $receipt->executeCopy = $executeDetail ['staff'];
  456. $receipt->explanation = $explanation;
  457. $receipt->update ();
  458. $receiptDetail = new receiptDetail ();
  459. $receiptDetail->delete ( array (
  460. 'where' => 'rid=' . $rid
  461. ) );
  462. // 报销详情
  463. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  464. $receiptDetail = new receiptDetail ();
  465. $receiptDetail->staff = $this->staff [0] ['sid'];
  466. $receiptDetail->item = $value ['name'];
  467. $receiptDetail->itemCategory = $this->AGENCY;
  468. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  469. $receiptDetail->date = date ( "Y-m-d" );
  470. $receiptDetail->cid = $cid;
  471. $receiptDetail->rid = $rid;
  472. $receiptDetail->status = 4;
  473. $receiptDetail->insert ();
  474. }
  475. // return "/referReceipt/".$rid;
  476. }
  477. return "/saeaBorad";
  478. }
  479. function remitApproval() {
  480. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  481. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  482. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  483. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  484. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  485. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  486. if (empty ( $status ))
  487. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  488. $vidList = array ();
  489. $button = 0;
  490. Doo::loadModel ( 'verify' );
  491. Doo::loadModel ( 'receipt' );
  492. Doo::loadModel ( 'staff' );
  493. $staff = new staff ();
  494. $receipt = new receipt ();
  495. $verify = new verify ();
  496. Doo::loadModel ( 'L_category' );
  497. $Lcategory = new L_category ();
  498. Doo::loadModel ( 'enclosur' );
  499. $enclosur = new enclosur ();
  500. // user verify ID
  501. $verifyDetail = $verify->find ( array (
  502. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  503. 'asArray' => true
  504. ) );
  505. foreach ( $verifyDetail as $key => $value ) {
  506. array_push ( $vidList, $value ['vid'] );
  507. }
  508. $vid = implode ( ",", $vidList );
  509. if (empty ( $verifyDetail ))
  510. $vid = 0;
  511. $categoryList = $Lcategory->find ( array (
  512. 'asArray' => true
  513. ) );
  514. $staffList = $staff->find ( array (
  515. 'where' => 'cid=' . $cid,
  516. 'asArray' => true
  517. ) );
  518. $ap = "";
  519. if ($status == 4) {
  520. $ap = 4;
  521. $status = 2;
  522. }
  523. // get Receipt By verifyID status 2
  524. $receiptList = $receipt->find ( array (
  525. 'where' => 'rid =' . $rid.' and status=2',
  526. 'desc' => 'rid',
  527. 'asArray' => true
  528. ) );
  529. if(empty($receiptList)){
  530. die('illegal request');
  531. }
  532. $Locate = 0;
  533. $roleId = 0;
  534. if ($ap == 4)
  535. $status = 4;
  536. foreach ( $receiptList as $key => $value ) {
  537. $receiptList [$key] ['Locate'] = $Locate;
  538. $Locate ++;
  539. $receiptList [$key] ['reviseDetail'] = array ();
  540. if (! empty ( $value ['reviseDetail'] ))
  541. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  542. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  543. $categoryDetil = $Lcategory->getOne ( array (
  544. 'where' => 'cid=' . $value ['cid'],
  545. 'asArray' => true
  546. ) );
  547. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  548. // 检测编辑状态
  549. $verifyList = $verify->getOne ( array (
  550. 'where' => 'vid=' . $value ['verify'],
  551. 'asArray' => true
  552. ) );
  553. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  554. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  555. Doo::loadModel ( 'role' );
  556. $role = new role ();
  557. // print_r($verifyList);
  558. $flag = true;
  559. $roleKey = 0;
  560. $endStaffArray = array ();
  561. $roleArrayCopy = array ();
  562. foreach ( $verifyList as $k => $v ) {
  563. // init verifyStaff
  564. if ($v [1] == 'ROLE') {
  565. if (! empty ( $verifyStaff )) {
  566. $endStaffArray = end ( $verifyStaff );
  567. if ($v [0] == $endStaffArray ['nextStaff']) {
  568. $roleId = $v [0];
  569. }
  570. }
  571. $roleVerify = json_decode ( $v [3], true );
  572. $roleKey = $k;
  573. $roleArray = array ();
  574. $rolename = $role->getOne ( array (
  575. 'where' => 'rid=' . $v [0],
  576. 'asArray' => true
  577. ) );
  578. foreach ( $roleVerify as $o => $p ) {
  579. $staffID = explode ( '_', $p );
  580. $staffInfo = $staff->getOne ( array (
  581. 'where' => 'sid=' . $staffID [0],
  582. 'asArray' => true
  583. ) );
  584. // print_r($staffID);
  585. $exp = array (
  586. 0 => $staffInfo ['sid'],
  587. 1 => $staffID [1],
  588. 2 => $staffInfo ['avatar'],
  589. 'date' => '',
  590. 'date' => '',
  591. 'opinion' => '',
  592. 'status' => '',
  593. 'rolename' => $rolename ['name']
  594. );
  595. array_push ( $roleArray, $exp );
  596. }
  597. $roleArrayCopy [$v [0]] = $roleArray;
  598. // $verifyList[$k]['roleArray']=$roleArray;
  599. }
  600. // print_r($roleArray);
  601. $verifyList [$k] ['date'] = "";
  602. $verifyList [$k] ['opinion'] = "";
  603. $verifyList [$k] ['status'] = "";
  604. if (empty ( $verifyStaff )) {
  605. $verifyList [$k] ['date'] = "";
  606. $verifyList [$k] ['opinion'] = "";
  607. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  608. $verifyList [$k] ['status'] = 4;
  609. $button = 4;
  610. $flag = false;
  611. }
  612. } else {
  613. foreach ( $verifyStaff as $m => $u ) {
  614. if ($v [0] == $m) {
  615. $verifyList [$k] ['date'] = $u ['date'];
  616. $verifyList [$k] ['opinion'] = $u ['opinion'];
  617. $verifyList [$k] ['status'] = $u ['status'];
  618. $flag = false;
  619. break;
  620. }
  621. }
  622. $endStaffArray = end ( $verifyStaff );
  623. if (isset ( $endStaffArray ['ROLE'] )) {
  624. } else {
  625. $endKey = key ( $verifyStaff );
  626. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  627. $button = 4;
  628. $verifyList [$k] ['status'] = 4;
  629. }
  630. }
  631. }
  632. }
  633. $rolename ['name'] = '';
  634. if (! empty ( $roleId )) {
  635. Doo::loadModel ( 'role' );
  636. $role = new role ();
  637. $rolename = $role->getOne ( array (
  638. 'where' => 'rid=' . $roleId,
  639. 'asArray' => true
  640. ) );
  641. }
  642. if (! empty ( $verifyStaff ))
  643. $endStaffArray = end ( $verifyStaff );
  644. $KOP = false;
  645. foreach ( $roleArrayCopy as $P => $A ) {
  646. foreach ( $A as $MKI => $AVL ) {
  647. if (! empty ( $verifyStaff )) {
  648. // &&$rolename['rid']==$endStaffArray['nextStaff']
  649. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  650. $button = 4;
  651. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  652. }
  653. foreach ( $verifyStaff as $m => $u ) {
  654. $AVLFK = $AVL [0] . '_R';
  655. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  656. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  657. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  658. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  659. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  660. break;
  661. }
  662. }
  663. } else {
  664. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  665. $button = 4;
  666. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  667. }
  668. }
  669. // $roleArray[$MKI]['rolename']=$rolename['name'];
  670. $KOP = true;
  671. }
  672. }
  673. foreach ( $roleArrayCopy as $k => $v ) {
  674. foreach ( $verifyList as $m => $n ) {
  675. if ($n [0] == $k) {
  676. array_splice ( $verifyList, $m, 1, $v );
  677. }
  678. }
  679. }
  680. $receiptList [$key] ['verifyList'] = $verifyList;
  681. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  682. 'where' => 'sid=' . $value ['staff'],
  683. 'asArray' => true
  684. ) );
  685. $receiptList [$key] ['button'] = $button;
  686. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  687. }
  688. $mothHtml = "";
  689. for($i = 1; $i <= 12; $i ++) {
  690. if ($month == $i)
  691. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  692. else
  693. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  694. }
  695. // 获取审批日志
  696. Doo::loadModel ( 'receiptLog' );
  697. $receiptLog = new receiptLog ();
  698. $rlList = array ();
  699. $rlInfo = $receiptLog->getOne ( array (
  700. 'where' => 'rid=' . $rid . ' and status=4',
  701. 'asArray' => true
  702. ) );
  703. $tijdate = $receiptLog->getOne ( array (
  704. 'where' => 'rid=' . $rid . ' and status=2',
  705. 'asc' => 'rlid',
  706. 'asArray' => true
  707. ) );
  708. if (! empty ( $rlInfo )) {
  709. $rlList = $receiptLog->find ( array (
  710. 'where' => 'rid=' . $rid,
  711. 'asc' => 'rlid',
  712. 'asArray' => true
  713. ) );
  714. }
  715. $receiptList [0] ['rlList'] = $rlList;
  716. $enclosurList = $enclosur->find ( array (
  717. 'where' => 'rid=' . $rid,
  718. 'asArray' => true
  719. ) );
  720. $enclosurHtml = '';
  721. foreach ( $enclosurList as $value ) {
  722. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  723. }
  724. // print_r($receiptList);
  725. $data ['enclosurHtml'] = $enclosurHtml;
  726. $data ['rolename'] = $rolename ['name'];
  727. $data ['datetij'] = $tijdate ['date'];
  728. $data ['mothHtml'] = $mothHtml;
  729. $data ['rid'] = $rid;
  730. $data ['receiptList'] = $receiptList;
  731. $data ['receiptApprovalCount'] = count ( $receiptList );
  732. $data ['status'] = $status;
  733. $data ['year'] = $year;
  734. $data ['categoryList'] = $categoryList;
  735. $data ['staffList'] = $staffList;
  736. $data ['cid'] = $cid;
  737. $data ['sid'] = $sid;
  738. $data ['ap'] = $ap;
  739. $data ['memu'] = "receipt";
  740. $data ['staff'] = $this->staff;
  741. $data ['receiptMemu'] = 'approvalExpenses';
  742. $data ['verifyId'] = $this->verifyId;
  743. $data ['executeId'] = $this->executeId;
  744. $this->render ( "/admin/remitApproval", $data );
  745. }
  746. function saeaLoanAdd() {
  747. Doo::loadModel ( 'verify' );
  748. $verify = new verify ();
  749. Doo::loadModel ( "role" );
  750. $role = new role ();
  751. Doo::loadModel ( 'L_category' );
  752. $lCategory = new L_category ();
  753. $veList = $verify->find ( array (
  754. 'asArray' => true
  755. ) );
  756. foreach ( $veList as $key => $value ) {
  757. $v = json_decode ( $value ['staff'] );
  758. $list = array ();
  759. foreach ( $v as $n => $m ) {
  760. if ($m ['1'] == 'ROLE') {
  761. $roleInfo = $role->getOne ( array (
  762. 'where' => 'rid=' . $m [0],
  763. 'asArray' => true
  764. ) );
  765. $v [$n] [1] = $roleInfo ['name'];
  766. array_push ( $list, $roleInfo ['name'] );
  767. } else {
  768. array_push ( $list, $v [$n] [1] );
  769. }
  770. }
  771. $veList [$key] ['staff'] = implode ( '>', $list );
  772. }
  773. $data ['category'] = $lCategory->find ( array (
  774. 'asArray' => true
  775. ) );
  776. $data ['veList'] = $veList;
  777. $data ['memu'] = "receipt";
  778. $data ['staff'] = $this->staff;
  779. $data ['receiptMemu'] = 'saeaBorad';
  780. $data ['verifyId'] = $this->verifyId;
  781. $data ['executeId'] = $this->executeId;
  782. $this->render ( "/admin/saeaLoanAdd", $data );
  783. }
  784. function saeaLoanAddDo() {
  785. $agency = $this->get_args ( 'agency' );
  786. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  787. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  788. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  789. // die;
  790. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  791. Doo::loadModel ( 'receipt' );
  792. Doo::loadModel ( 'receiptDetail' );
  793. Doo::loadModel ( 'accountItem' );
  794. $accountItem = new accountItem ();
  795. $receipt = new receipt ();
  796. Doo::loadModel ( 'loanReceipt' );
  797. $loanReceipt = new loanReceipt ();
  798. Doo::loadModel ( 'execute' );
  799. $execute = new execute ();
  800. Doo::loadModel ( 'enclosur' );
  801. $executeDetail = $execute->getOne ( array (
  802. 'where' => 'mold="借款执行人"',
  803. 'asArray' => true
  804. ) );
  805. $aItem = $accountItem->find ( array (
  806. 'asArray' => true
  807. ) );
  808. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  809. $ag = $tr = $ta = $ot = 0;
  810. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  811. array_push ( $accountJson ['借款费用'], array (
  812. 'aid' => 0,
  813. 'name' => '申请金额',
  814. 'price' => number_format ( $agency, 2, '.', '' )
  815. ) );
  816. $sum += $agency;
  817. $agencySum += $agency;
  818. $accountJson ['cSum'] = array (
  819. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  820. 'agencySum' => number_format ( 0, 2, '.', '' ),
  821. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  822. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  823. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  824. );
  825. // 借款数据备份
  826. $loanReceipt->loanItem = json_encode ( $accountJson );
  827. $loanReceipt->staff = $this->staff [0] ['sid'];
  828. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  829. $loanReceipt->date = date ( "Y-m-d" );
  830. $loanReceipt->cid = $cid;
  831. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  832. $loanReceipt->status = 5;
  833. $loanReceipt->Rtype = 1;
  834. $loanReceipt->verify = $verify;
  835. $receipt->receiptOrder = $receipt->receiptOrder;
  836. $loanReceipt->explanation = $explanation;
  837. $loanRid = $loanReceipt->insert ();
  838. // 报销单
  839. $receipt->loanItem = json_encode ( $accountJson );
  840. $receipt->staff = $this->staff [0] ['sid'];
  841. $receipt->sum = number_format ( $sum, 2, '.', '' );
  842. $receipt->date = date ( "Y-m-d" );
  843. $receipt->cid = $cid;
  844. // 特殊状态
  845. $receipt->status = 5;
  846. $receipt->Rtype = 1;
  847. $receipt->loanRid = $loanRid;
  848. // 修改审批流程加入角色
  849. $receipt->verify = $verify;
  850. $receipt->executeCopy = $executeDetail ['staff'];
  851. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  852. $receipt->explanation = $explanation;
  853. $rid = $receipt->insert ();
  854. return "/saeaBorad";
  855. }else
  856. die ( 'illegal request' );
  857. }
  858. function saeaLoanEdi() {
  859. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  860. Doo::loadModel ( 'verify' );
  861. $verify = new verify ();
  862. Doo::loadModel ( "role" );
  863. $role = new role ();
  864. Doo::loadModel ( 'L_category' );
  865. $lCategory = new L_category ();
  866. Doo::loadModel ( 'receipt' );
  867. $receipt = new receipt ();
  868. $receiptInfo = $receipt->getOne ( array (
  869. 'where' => 'rid=' . $rid,
  870. 'asArray' => true
  871. ) );
  872. $veList = $verify->find ( array (
  873. 'asArray' => true
  874. ) );
  875. foreach ( $veList as $key => $value ) {
  876. $v = json_decode ( $value ['staff'] );
  877. $list = array ();
  878. foreach ( $v as $n => $m ) {
  879. if ($m ['1'] == 'ROLE') {
  880. $roleInfo = $role->getOne ( array (
  881. 'where' => 'rid=' . $m [0],
  882. 'asArray' => true
  883. ) );
  884. $v [$n] [1] = $roleInfo ['name'];
  885. array_push ( $list, $roleInfo ['name'] );
  886. } else {
  887. array_push ( $list, $v [$n] [1] );
  888. }
  889. }
  890. $veList [$key] ['staff'] = implode ( '>', $list );
  891. }
  892. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  893. $data ['receiptInfo'] = $receiptInfo;
  894. $data ['category'] = $lCategory->find ( array (
  895. 'asArray' => true
  896. ) );
  897. $data ['veList'] = $veList;
  898. $data ['memu'] = "receipt";
  899. $data ['staff'] = $this->staff;
  900. $data ['receiptMemu'] = 'saeaBorad';
  901. $data ['verifyId'] = $this->verifyId;
  902. $data ['executeId'] = $this->executeId;
  903. $this->render ( "/admin/saeaLoanEdi", $data );
  904. }
  905. function saeaLoanEdiDo() {
  906. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  907. $agency = $this->get_args ( 'agency' );
  908. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  909. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  910. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  911. // die;
  912. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )) {
  913. Doo::loadModel ( 'receipt' );
  914. Doo::loadModel ( 'receiptDetail' );
  915. Doo::loadModel ( 'accountItem' );
  916. $accountItem = new accountItem ();
  917. $receipt = new receipt ();
  918. Doo::loadModel ( 'loanReceipt' );
  919. $loanReceipt = new loanReceipt ();
  920. Doo::loadModel ( 'enclosur' );
  921. Doo::loadModel ( 'execute' );
  922. $execute = new execute ();
  923. $executeDetail = $execute->getOne ( array (
  924. 'where' => 'mold="借款执行人"',
  925. 'asArray' => true
  926. ) );
  927. $receiptDetail = $receipt->getOne ( array (
  928. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  929. 'asArray' => true
  930. ) );
  931. if (empty ( $receiptDetail ))
  932. die ( '参数错误' );
  933. $aItem = $accountItem->find ( array (
  934. 'asArray' => true
  935. ) );
  936. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  937. $ag = $tr = $ta = $ot = 0;
  938. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  939. array_push ( $accountJson ['借款费用'], array (
  940. 'aid' => 0,
  941. 'name' => '申请金额',
  942. 'price' => number_format ( $agency, 2, '.', '' )
  943. ) );
  944. $sum += $agency;
  945. $agencySum += $agency;
  946. $accountJson ['cSum'] = array (
  947. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  948. 'agencySum' => number_format ( 0, 2, '.', '' ),
  949. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  950. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  951. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  952. );
  953. // 报销单
  954. $receipt->loanItem = json_encode ( $accountJson );
  955. $receipt->sum = number_format ( $sum, 2, '.', '' );
  956. $receipt->cid = $cid;
  957. // 特殊状态
  958. // 修改审批流程加入角色
  959. if ($receiptDetail ['status'] != 4)
  960. $receipt->verify = $verify;
  961. $receipt->explanation = $explanation;
  962. $receipt->update ( array (
  963. 'where' => 'rid=' . $rid
  964. ) );
  965. // 借款数据更新
  966. $loanReceipt->loanItem = json_encode ( $accountJson );
  967. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  968. $loanReceipt->cid = $cid;
  969. if ($receiptDetail ['status'] != 4)
  970. $loanReceipt->verify = $verify;
  971. $loanReceipt->explanation = $explanation;
  972. $receipt->executeCopy = $executeDetail ['staff'];
  973. $loanReceipt->update ( array (
  974. 'where' => 'rid=' . $receiptDetail ['loanRid']
  975. ) );
  976. }
  977. return "/saeaBorad";
  978. }
  979. function saeaLoanReceiptAdd() {
  980. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  981. Doo::loadModel ( 'receipt' );
  982. $receipt = new receipt ();
  983. Doo::loadModel ( 'loanReceipt' );
  984. $loanReceipt = new loanReceipt ();
  985. Doo::loadModel ( 'L_category' );
  986. $Lcategory = new L_category ();
  987. Doo::loadModel ( 'verify' );
  988. Doo::loadModel ( 'statistics' );
  989. $statistics = new statistics ();
  990. $verify = new verify ();
  991. Doo::loadModel ( 'staff' );
  992. $staff = new staff ();
  993. $receiptDe = $receipt->getOne ( array (
  994. 'where' => 'rid=' . $rid,
  995. 'desc' => 'rid',
  996. 'asArray' => true
  997. ) );
  998. $receiptList = $loanReceipt->find ( array (
  999. 'where' => 'rid=' . $receiptDe ['loanRid'],
  1000. 'desc' => 'rid',
  1001. 'asArray' => true
  1002. ) );
  1003. $Locate = 0;
  1004. $roleId = 0;
  1005. $button = 0;
  1006. foreach ( $receiptList as $key => $value ) {
  1007. $receiptList [$key] ['Locate'] = $Locate;
  1008. $Locate ++;
  1009. $receiptList [$key] ['reviseDetail'] = array ();
  1010. if (! empty ( $value ['reviseDetail'] ))
  1011. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1012. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1013. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1014. $categoryDetil = $Lcategory->getOne ( array (
  1015. 'where' => 'cid=' . $value ['cid'],
  1016. 'asArray' => true
  1017. ) );
  1018. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1019. // 检测编辑状态
  1020. $verifyList = $verify->getOne ( array (
  1021. 'where' => 'vid=' . $value ['verify'],
  1022. 'asArray' => true
  1023. ) );
  1024. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1025. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1026. Doo::loadModel ( 'role' );
  1027. $role = new role ();
  1028. $flag = true;
  1029. $roleKey = 0;
  1030. $endStaffArray = array ();
  1031. $roleArrayCopy = array ();
  1032. foreach ( $verifyList as $k => $v ) {
  1033. // init verifyStaff
  1034. if ($v [1] == 'ROLE') {
  1035. if (! empty ( $verifyStaff )) {
  1036. $endStaffArray = end ( $verifyStaff );
  1037. // if ($v[0]==$endStaffArray['nextStaff']){
  1038. // $roleId=$v[0];
  1039. // }
  1040. }
  1041. $roleVerify = json_decode ( $v [3], true );
  1042. $roleKey = $k;
  1043. $roleArray = array ();
  1044. $rolename = $role->getOne ( array (
  1045. 'where' => 'rid=' . $v [0],
  1046. 'asArray' => true
  1047. ) );
  1048. foreach ( $roleVerify as $o => $p ) {
  1049. $staffID = explode ( '_', $p );
  1050. $staffInfo = $staff->getOne ( array (
  1051. 'where' => 'sid=' . $staffID [0],
  1052. 'asArray' => true
  1053. ) );
  1054. // print_r($staffID);
  1055. $exp = array (
  1056. 0 => $staffInfo ['sid'],
  1057. 1 => $staffID [1],
  1058. 2 => $staffInfo ['avatar'],
  1059. 'date' => '',
  1060. 'date' => '',
  1061. 'opinion' => '',
  1062. 'status' => '',
  1063. 'rolename' => $rolename ['name']
  1064. );
  1065. array_push ( $roleArray, $exp );
  1066. }
  1067. $roleArrayCopy [$v [0]] = $roleArray;
  1068. // $verifyList[$k]['roleArray']=$roleArray;
  1069. }
  1070. $verifyList [$k] ['date'] = "";
  1071. $verifyList [$k] ['opinion'] = "";
  1072. $verifyList [$k] ['status'] = "";
  1073. if (empty ( $verifyStaff )) {
  1074. $verifyList [$k] ['date'] = "";
  1075. $verifyList [$k] ['opinion'] = "";
  1076. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1077. $verifyList [$k] ['status'] = 4;
  1078. $flag = false;
  1079. }
  1080. } else {
  1081. foreach ( $verifyStaff as $m => $u ) {
  1082. if ($v [0] == $m) {
  1083. $verifyList [$k] ['date'] = $u ['date'];
  1084. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1085. $verifyList [$k] ['status'] = $u ['status'];
  1086. $flag = false;
  1087. break;
  1088. }
  1089. }
  1090. $endStaffArray = end ( $verifyStaff );
  1091. if (isset ( $endStaffArray ['ROLE'] )) {
  1092. } else {
  1093. // $endKey=key($verifyStaff);
  1094. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1095. // $button=4;
  1096. // $verifyList[$k]['status']=4;
  1097. // }
  1098. }
  1099. }
  1100. }
  1101. $rolename ['name'] = '';
  1102. if (! empty ( $roleId )) {
  1103. Doo::loadModel ( 'role' );
  1104. $role = new role ();
  1105. $rolename = $role->getOne ( array (
  1106. 'where' => 'rid=' . $roleId,
  1107. 'asArray' => true
  1108. ) );
  1109. }
  1110. if (! empty ( $verifyStaff ))
  1111. $endStaffArray = end ( $verifyStaff );
  1112. $KOP = false;
  1113. foreach ( $roleArrayCopy as $P => $A ) {
  1114. foreach ( $A as $MKI => $AVL ) {
  1115. if (! empty ( $verifyStaff )) {
  1116. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1117. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1118. $button = 4;
  1119. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1120. }
  1121. foreach ( $verifyStaff as $m => $u ) {
  1122. $AVLFK = $AVL [0] . '_R';
  1123. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1124. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1125. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1126. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1127. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1128. break;
  1129. }
  1130. }
  1131. } else {
  1132. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1133. $button = 4;
  1134. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1135. }
  1136. }
  1137. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1138. $KOP = true;
  1139. }
  1140. }
  1141. foreach ( $roleArrayCopy as $k => $v ) {
  1142. foreach ( $verifyList as $m => $n ) {
  1143. if ($n [0] == $k) {
  1144. array_splice ( $verifyList, $m, 1, $v );
  1145. }
  1146. }
  1147. }
  1148. $receiptList [$key] ['verifyList'] = $verifyList;
  1149. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1150. 'where' => 'sid=' . $value ['staff'],
  1151. 'asArray' => true
  1152. ) );
  1153. $receiptList [$key] ['button'] = $button;
  1154. //
  1155. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1156. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1157. }
  1158. $data ['receiptList'] = $receiptList;
  1159. Doo::loadModel ( 'L_category' );
  1160. $lCategory = new L_category ();
  1161. Doo::loadModel ( 'accountItem' );
  1162. $accountItem = new accountItem ();
  1163. $acItem = $accountItem->find ( array (
  1164. 'asArray' => true
  1165. ) );
  1166. $veList = $verify->find ( array (
  1167. 'asArray' => true
  1168. ) );
  1169. foreach ( $veList as $key => $value ) {
  1170. $v = json_decode ( $value ['staff'] );
  1171. $list = array ();
  1172. foreach ( $v as $n => $m ) {
  1173. if ($m ['1'] == 'ROLE') {
  1174. $roleInfo = $role->getOne ( array (
  1175. 'where' => 'rid=' . $m [0],
  1176. 'asArray' => true
  1177. ) );
  1178. $v [$n] [1] = $roleInfo ['name'];
  1179. array_push ( $list, $roleInfo ['name'] );
  1180. } else {
  1181. array_push ( $list, $v [$n] [1] );
  1182. }
  1183. }
  1184. $veList [$key] ['staff'] = implode ( '>', $list );
  1185. }
  1186. $data ['rid'] = $rid;
  1187. $data ['category'] = $lCategory->find ( array (
  1188. 'asArray' => true
  1189. ) );
  1190. $data ['veList'] = $veList;
  1191. $data ['acItem'] = $acItem;
  1192. $data ['memu'] = "receipt";
  1193. $data ['staff'] = $this->staff;
  1194. $data ['receiptMemu'] = 'saeaBorad';
  1195. $data ['verifyId'] = $this->verifyId;
  1196. $data ['executeId'] = $this->executeId;
  1197. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1198. }
  1199. function saeaLoanReceiptAddDo() {
  1200. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1201. $agency = $this->get_args ( 'agency' );
  1202. $travel = $this->get_args ( 'travel' );
  1203. $train = $this->get_args ( 'train' );
  1204. $other = $this->get_args ( 'other' );
  1205. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1206. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1207. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1208. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1209. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )) {
  1210. Doo::loadModel ( 'receipt' );
  1211. Doo::loadModel ( 'receiptDetail' );
  1212. Doo::loadModel ( 'accountItem' );
  1213. $accountItem = new accountItem ();
  1214. $receipt = new receipt ();
  1215. Doo::loadModel ( 'enclosur' );
  1216. Doo::loadModel ( 'execute' );
  1217. $execute = new execute ();
  1218. $executeDetail = $execute->getOne ( array (
  1219. 'where' => 'mold="借款费用执行人"',
  1220. 'asArray' => true
  1221. ) );
  1222. $receiptDet = $receipt->getOne ( array (
  1223. 'where' => 'rid=' . $rid,
  1224. 'asArray' => true
  1225. ) );
  1226. // if(!empty($receiptDetail))
  1227. // return "/referReceipt/".$receiptDetail['rid'];
  1228. $aItem = $accountItem->find ( array (
  1229. 'asArray' => true
  1230. ) );
  1231. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1232. $ag = $tr = $ta = $ot = 0;
  1233. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1234. foreach ( $aItem as $key => $value ) {
  1235. if ($value ['category'] == $this->AGENCY) {
  1236. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1237. array_push ( $accountJson [$this->AGENCY], array (
  1238. 'aid' => $value ['aid'],
  1239. 'name' => $value ['name'],
  1240. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1241. ) );
  1242. $sum += $agency [$ag];
  1243. $agencySum += $agency [$ag];
  1244. }
  1245. $ag ++;
  1246. }
  1247. if ($value ['category'] == $this->TRAVEL) {
  1248. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1249. array_push ( $accountJson [$this->TRAVEL], array (
  1250. 'aid' => $value ['aid'],
  1251. 'name' => $value ['name'],
  1252. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1253. ) );
  1254. $sum += $travel [$tr];
  1255. $travelSum += $travel [$tr];
  1256. }
  1257. $tr ++;
  1258. }
  1259. if ($value ['category'] == $this->TRAIN) {
  1260. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1261. array_push ( $accountJson [$this->TRAIN], array (
  1262. 'aid' => $value ['aid'],
  1263. 'name' => $value ['name'],
  1264. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1265. ) );
  1266. $sum += $train [$ta];
  1267. $trainSum += $train [$ta];
  1268. }
  1269. $ta ++;
  1270. }
  1271. if ($value ['category'] == $this->OTHER) {
  1272. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1273. array_push ( $accountJson [$this->OTHER], array (
  1274. 'aid' => $value ['aid'],
  1275. 'name' => $value ['name'],
  1276. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1277. ) );
  1278. $sum += $other [$ot];
  1279. $otherSum += $other [$ot];
  1280. }
  1281. $ot ++;
  1282. }
  1283. }
  1284. $accountJson ['cSum'] = array (
  1285. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1286. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1287. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1288. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1289. );
  1290. // 报销单
  1291. $receipt->accountItem = json_encode ( $accountJson );
  1292. $receipt->staff = $this->staff [0] ['sid'];
  1293. $receipt->loanSum = $receiptDet ['sum'];
  1294. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1295. $receipt->date = date ( "Y-m-d" );
  1296. $receipt->pastDate = '';
  1297. $receipt->cid = $cid;
  1298. $receipt->status = 7;
  1299. // 修改审批流程加入角色
  1300. $receipt->verify = $verify;
  1301. $receipt->verifyStaff = '';
  1302. $receipt->executeStaff = '';
  1303. $receipt->executeCopy = $executeDetail ['staff'];
  1304. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  1305. $receipt->explanation = $explanation;
  1306. $receipt->update ( array (
  1307. 'where' => 'rid=' . $rid
  1308. ) );
  1309. // 附件
  1310. if (! empty ( $enclosurName )) {
  1311. $enclosurArray = explode ( '-', $enclosurName );
  1312. foreach ( $enclosurArray as $value ) {
  1313. $enclosur = new enclosur ();
  1314. $enclosur->name = $value;
  1315. $enclosur->rid = $rid;
  1316. $enclosur->insert ();
  1317. }
  1318. // print_r($enclosurArray);die;
  1319. }
  1320. // 报销详情
  1321. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1322. $receiptDetail = new receiptDetail ();
  1323. $receiptDetail->staff = $this->staff [0] ['sid'];
  1324. $receiptDetail->item = $value ['name'];
  1325. $receiptDetail->itemCategory = $this->AGENCY;
  1326. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1327. $receiptDetail->date = date ( "Y-m-d" );
  1328. $receiptDetail->cid = $cid;
  1329. $receiptDetail->rid = $rid;
  1330. $receiptDetail->status = 4;
  1331. $receiptDetail->insert ();
  1332. }
  1333. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1334. $receiptDetail = new receiptDetail ();
  1335. $receiptDetail->staff = $this->staff [0] ['sid'];
  1336. $receiptDetail->item = $value ['name'];
  1337. $receiptDetail->itemCategory = $this->TRAVEL;
  1338. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1339. $receiptDetail->date = date ( "Y-m-d" );
  1340. $receiptDetail->cid = $cid;
  1341. $receiptDetail->rid = $rid;
  1342. $receiptDetail->status = 4;
  1343. $receiptDetail->insert ();
  1344. }
  1345. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1346. $receiptDetail = new receiptDetail ();
  1347. $receiptDetail->staff = $this->staff [0] ['sid'];
  1348. $receiptDetail->item = $value ['name'];
  1349. $receiptDetail->itemCategory = $this->TRAIN;
  1350. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1351. $receiptDetail->date = date ( "Y-m-d" );
  1352. $receiptDetail->cid = $cid;
  1353. $receiptDetail->rid = $rid;
  1354. $receiptDetail->status = 4;
  1355. $receiptDetail->insert ();
  1356. }
  1357. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1358. $receiptDetail = new receiptDetail ();
  1359. $receiptDetail->staff = $this->staff [0] ['sid'];
  1360. $receiptDetail->item = $value ['name'];
  1361. $receiptDetail->itemCategory = $this->OTHER;
  1362. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1363. $receiptDetail->date = date ( "Y-m-d" );
  1364. $receiptDetail->cid = $cid;
  1365. $receiptDetail->rid = $rid;
  1366. $receiptDetail->status = 4;
  1367. $receiptDetail->insert ();
  1368. }
  1369. return "/saeaBorad";
  1370. }
  1371. return "/saeaLoanReceiptAdd/" . $rid;
  1372. }
  1373. function saeaLoanReceiptEdi() {
  1374. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1375. // echo $rid;
  1376. Doo::loadModel ( 'accountItem' );
  1377. Doo::loadModel ( 'verify' );
  1378. Doo::loadModel ( 'receipt' );
  1379. $receipt = new receipt ();
  1380. $verify = new verify ();
  1381. $accountItem = new accountItem ();
  1382. Doo::loadModel ( 'L_category' );
  1383. $Lcategory = new L_category ();
  1384. Doo::loadModel ( "role" );
  1385. $role = new role ();
  1386. Doo::loadModel ( 'loanReceipt' );
  1387. $loanReceipt = new loanReceipt ();
  1388. Doo::loadModel ( 'staff' );
  1389. $staff = new staff ();
  1390. $receiptDetail = $receipt->getOne ( array (
  1391. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  1392. 'asArray' => true
  1393. ) );
  1394. if (empty ( $receiptDetail ))
  1395. return "/saeaBorad";
  1396. $receiptList = $loanReceipt->find ( array (
  1397. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1398. 'desc' => 'rid',
  1399. 'asArray' => true
  1400. ) );
  1401. $Locate = 0;
  1402. $roleId = 0;
  1403. $button = 0;
  1404. foreach ( $receiptList as $key => $value ) {
  1405. $receiptList [$key] ['Locate'] = $Locate;
  1406. $Locate ++;
  1407. $receiptList [$key] ['reviseDetail'] = array ();
  1408. if (! empty ( $value ['reviseDetail'] ))
  1409. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1410. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1411. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1412. $categoryDetil = $Lcategory->getOne ( array (
  1413. 'where' => 'cid=' . $value ['cid'],
  1414. 'asArray' => true
  1415. ) );
  1416. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1417. // 检测编辑状态
  1418. $verifyList = $verify->getOne ( array (
  1419. 'where' => 'vid=' . $value ['verify'],
  1420. 'asArray' => true
  1421. ) );
  1422. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1423. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1424. Doo::loadModel ( 'role' );
  1425. $role = new role ();
  1426. $flag = true;
  1427. $roleKey = 0;
  1428. $endStaffArray = array ();
  1429. $roleArrayCopy = array ();
  1430. foreach ( $verifyList as $k => $v ) {
  1431. // init verifyStaff
  1432. if ($v [1] == 'ROLE') {
  1433. if (! empty ( $verifyStaff )) {
  1434. $endStaffArray = end ( $verifyStaff );
  1435. // if ($v[0]==$endStaffArray['nextStaff']){
  1436. // $roleId=$v[0];
  1437. // }
  1438. }
  1439. $roleVerify = json_decode ( $v [3], true );
  1440. $roleKey = $k;
  1441. $roleArray = array ();
  1442. $rolename = $role->getOne ( array (
  1443. 'where' => 'rid=' . $v [0],
  1444. 'asArray' => true
  1445. ) );
  1446. foreach ( $roleVerify as $o => $p ) {
  1447. $staffID = explode ( '_', $p );
  1448. $staffInfo = $staff->getOne ( array (
  1449. 'where' => 'sid=' . $staffID [0],
  1450. 'asArray' => true
  1451. ) );
  1452. // print_r($staffID);
  1453. $exp = array (
  1454. 0 => $staffInfo ['sid'],
  1455. 1 => $staffID [1],
  1456. 2 => $staffInfo ['avatar'],
  1457. 'date' => '',
  1458. 'date' => '',
  1459. 'opinion' => '',
  1460. 'status' => '',
  1461. 'rolename' => $rolename ['name']
  1462. );
  1463. array_push ( $roleArray, $exp );
  1464. }
  1465. $roleArrayCopy [$v [0]] = $roleArray;
  1466. // $verifyList[$k]['roleArray']=$roleArray;
  1467. }
  1468. $verifyList [$k] ['date'] = "";
  1469. $verifyList [$k] ['opinion'] = "";
  1470. $verifyList [$k] ['status'] = "";
  1471. if (empty ( $verifyStaff )) {
  1472. $verifyList [$k] ['date'] = "";
  1473. $verifyList [$k] ['opinion'] = "";
  1474. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1475. $verifyList [$k] ['status'] = 4;
  1476. $flag = false;
  1477. }
  1478. } else {
  1479. foreach ( $verifyStaff as $m => $u ) {
  1480. if ($v [0] == $m) {
  1481. $verifyList [$k] ['date'] = $u ['date'];
  1482. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1483. $verifyList [$k] ['status'] = $u ['status'];
  1484. $flag = false;
  1485. break;
  1486. }
  1487. }
  1488. $endStaffArray = end ( $verifyStaff );
  1489. if (isset ( $endStaffArray ['ROLE'] )) {
  1490. } else {
  1491. // $endKey=key($verifyStaff);
  1492. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1493. // $button=4;
  1494. // $verifyList[$k]['status']=4;
  1495. // }
  1496. }
  1497. }
  1498. }
  1499. $rolename ['name'] = '';
  1500. if (! empty ( $roleId )) {
  1501. Doo::loadModel ( 'role' );
  1502. $role = new role ();
  1503. $rolename = $role->getOne ( array (
  1504. 'where' => 'rid=' . $roleId,
  1505. 'asArray' => true
  1506. ) );
  1507. }
  1508. if (! empty ( $verifyStaff ))
  1509. $endStaffArray = end ( $verifyStaff );
  1510. $KOP = false;
  1511. foreach ( $roleArrayCopy as $P => $A ) {
  1512. foreach ( $A as $MKI => $AVL ) {
  1513. if (! empty ( $verifyStaff )) {
  1514. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1515. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1516. $button = 4;
  1517. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1518. }
  1519. foreach ( $verifyStaff as $m => $u ) {
  1520. $AVLFK = $AVL [0] . '_R';
  1521. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1522. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1523. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1524. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1525. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1526. break;
  1527. }
  1528. }
  1529. } else {
  1530. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1531. $button = 4;
  1532. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1533. }
  1534. }
  1535. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1536. $KOP = true;
  1537. }
  1538. }
  1539. foreach ( $roleArrayCopy as $k => $v ) {
  1540. foreach ( $verifyList as $m => $n ) {
  1541. if ($n [0] == $k) {
  1542. array_splice ( $verifyList, $m, 1, $v );
  1543. }
  1544. }
  1545. }
  1546. $receiptList [$key] ['verifyList'] = $verifyList;
  1547. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1548. 'where' => 'sid=' . $value ['staff'],
  1549. 'asArray' => true
  1550. ) );
  1551. $receiptList [$key] ['button'] = $button;
  1552. //
  1553. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1554. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1555. }
  1556. $data ['receiptList'] = $receiptList;
  1557. $acItem = $accountItem->find ( array (
  1558. 'asArray' => true
  1559. ) );
  1560. $veList = $verify->find ( array (
  1561. 'asArray' => true
  1562. ) );
  1563. foreach ( $veList as $key => $value ) {
  1564. $v = json_decode ( $value ['staff'] );
  1565. $list = array ();
  1566. foreach ( $v as $n => $m ) {
  1567. if ($m ['1'] == 'ROLE') {
  1568. $roleInfo = $role->getOne ( array (
  1569. 'where' => 'rid=' . $m [0],
  1570. 'asArray' => true
  1571. ) );
  1572. $v [$n] [1] = $roleInfo ['name'];
  1573. array_push ( $list, $roleInfo ['name'] );
  1574. } else {
  1575. array_push ( $list, $v [$n] [1] );
  1576. }
  1577. }
  1578. $veList [$key] ['staff'] = implode ( '>', $list );
  1579. }
  1580. // 配置编辑信息
  1581. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1582. foreach ( $acItem as $key => $value ) {
  1583. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1584. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1585. $acItem [$key] ['price'] = $v ['price'];
  1586. }
  1587. }
  1588. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1589. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1590. $acItem [$key] ['price'] = $v ['price'];
  1591. }
  1592. }
  1593. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1594. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1595. $acItem [$key] ['price'] = $v ['price'];
  1596. }
  1597. }
  1598. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1599. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1600. $acItem [$key] ['price'] = $v ['price'];
  1601. }
  1602. }
  1603. }
  1604. $data ['category'] = $Lcategory->find ( array (
  1605. 'asArray' => true
  1606. ) );
  1607. $data ['cSum'] = $accountItemList ['cSum'];
  1608. $data ['sum'] = $receiptDetail ['sum'];
  1609. $data ['receiptDetail'] = $receiptDetail;
  1610. $data ['veList'] = $veList;
  1611. $data ['acItem'] = $acItem;
  1612. $data ['memu'] = "receipt";
  1613. $data ['staff'] = $this->staff;
  1614. $data ['receiptMemu'] = 'saeaBorad';
  1615. $data ['verify'] = $receiptDetail ['verify'];
  1616. $data ['verifyId'] = $this->verifyId;
  1617. $data ['executeId'] = $this->executeId;
  1618. $data ['rid'] = $rid;
  1619. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  1620. }
  1621. function confirmation() {
  1622. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1623. Doo::loadModel ( 'receipt' );
  1624. Doo::loadModel ( 'receiptDetail' );
  1625. $receipt = new receipt ();
  1626. $receiptDetail = new receiptDetail ();
  1627. Doo::loadModel ( 'statistics' );
  1628. Doo::loadModel ( 'itemStatistics' );
  1629. $statistics = new statistics ();
  1630. $itemStatistics = new itemStatistics ();
  1631. Doo::loadModel ( "verify" );
  1632. $verify = new verify ();
  1633. $receiptDetailList = $receipt->getOne ( array (
  1634. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  1635. 'asArray' => true
  1636. ) );
  1637. if (empty ( $receiptDetailList ))
  1638. return "/saeaBorad";
  1639. $verifyDetail = $verify->getOne ( array (
  1640. 'where' => ' vid =' . $receiptDetailList ['verify'],
  1641. 'asArray' => true
  1642. ) );
  1643. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  1644. if (empty ( $receiptDetailList ['nowStaff'] )) {
  1645. $nowStaff = "";
  1646. $nowStaffList = array ();
  1647. if ($verifyDetail [0] [1] == 'ROLE') {
  1648. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  1649. foreach ( $vStaffString as $key => $value ) {
  1650. $staffK = explode ( "_", $value );
  1651. array_push ( $nowStaffList, $staffK [0] );
  1652. }
  1653. $nowStaff = implode ( ',', $nowStaffList );
  1654. } else {
  1655. $nowStaff = $verifyDetail [0] [0];
  1656. }
  1657. $receipt->nowStaff = $nowStaff;
  1658. }
  1659. // echo $nowStaff;
  1660. // print_r($verifyDetail);die;
  1661. $receipt->rid = $receiptDetailList ['rid'];
  1662. $receipt->status = 2;
  1663. $receipt->update ();
  1664. // 操作日志
  1665. Doo::loadModel ( "receiptLog" );
  1666. $receiptLog = new receiptLog ();
  1667. $verify = new verify ();
  1668. $receiptInfo = $receipt->getOne ( array (
  1669. 'where' => 'rid=' . $rid,
  1670. 'asArray' => true
  1671. ) );
  1672. $vr = $verify->getOne ( array (
  1673. 'where' => 'vid=' . $receiptInfo ['verify'],
  1674. 'asArray' => true
  1675. ) );
  1676. $jd = json_decode ( $vr ['staff'] );
  1677. $roleId = 0;
  1678. foreach ( $jd as $key => $value ) {
  1679. if ($value [1] == 'ROLE') {
  1680. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  1681. if ($pos !== false) {
  1682. $roleId = $value [0];
  1683. }
  1684. }
  1685. }
  1686. // 审批日志
  1687. // echo $roleId;die;
  1688. if (! empty ( $roleId )) {
  1689. Doo::loadModel ( "role" );
  1690. $role = new role ();
  1691. $roleInfo = $role->getOne ( array (
  1692. 'where' => 'rid=' . $roleId,
  1693. 'asArray' => true
  1694. ) );
  1695. $receiptLog->rolename = $roleInfo ['name'];
  1696. }
  1697. $receiptLog->username = $this->staff [0] ['username'];
  1698. $receiptLog->uid = $this->staff [0] ['sid'];
  1699. $receiptLog->date = date ( "Y-m-d" );
  1700. $receiptLog->opinion = '提交审批';
  1701. $receiptLog->img = $this->staff [0] ['avatar'];
  1702. $receiptLog->status = 2;
  1703. $receiptLog->rid = $rid;
  1704. $receiptLog->insert ();
  1705. return "/expenses";
  1706. }
  1707. function expenses() {
  1708. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  1709. if (empty ( $item ))
  1710. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  1711. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1712. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  1713. Doo::loadModel ( 'receipt' );
  1714. $receipt = new receipt ();
  1715. Doo::loadModel ( 'L_category' );
  1716. $Lcategory = new L_category ();
  1717. Doo::loadModel ( 'verify' );
  1718. Doo::loadModel ( 'statistics' );
  1719. $statistics = new statistics ();
  1720. $verify = new verify ();
  1721. Doo::loadModel ( 'staff' );
  1722. $staff = new staff ();
  1723. $condition = "";
  1724. if ($item == "expenses")
  1725. $condition = " and Rtype=1 ";
  1726. elseif ($item == "receipts")
  1727. $condition = " and Rtype=0 ";
  1728. elseif ($item == "remits")
  1729. $condition = " and Rtype=2 ";
  1730. $dateCondition = " and Year(date) =" . $year;
  1731. if (! empty ( $moth )) {
  1732. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  1733. $stList = $statistics->getOne ( array (
  1734. 'select' => 'rePrice ,agPrice',
  1735. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  1736. 'asArray' => true
  1737. ) );
  1738. } else
  1739. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  1740. if (empty ( $stList ))
  1741. $stList = array (
  1742. 'rePrice' => 0,
  1743. 'agPrice' => 0
  1744. );
  1745. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  1746. if (! isset ( $noPassSum ['sum'] ))
  1747. $noPassSum ['sum'] = 0;
  1748. $data ['stList'] = array (
  1749. 'rePrice' => $stList ['rePrice'],
  1750. 'agPrice' => $stList ['agPrice'],
  1751. 'skPrice' => ($noPassSum ['sum'])
  1752. );
  1753. $receiptList = $receipt->find ( array (
  1754. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  1755. 'desc' => 'rid',
  1756. 'asArray' => true
  1757. ) );
  1758. $Locate = 0;
  1759. $roleId = 0;
  1760. $button = 0;
  1761. foreach ( $receiptList as $key => $value ) {
  1762. $receiptList [$key] ['Locate'] = $Locate;
  1763. $Locate ++;
  1764. $receiptList [$key] ['reviseDetail'] = array ();
  1765. if (! empty ( $value ['reviseDetail'] ))
  1766. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1767. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1768. $categoryDetil = $Lcategory->getOne ( array (
  1769. 'where' => 'cid=' . $value ['cid'],
  1770. 'asArray' => true
  1771. ) );
  1772. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1773. // 检测编辑状态
  1774. $verifyList = $verify->getOne ( array (
  1775. 'where' => 'vid=' . $value ['verify'],
  1776. 'asArray' => true
  1777. ) );
  1778. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1779. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1780. Doo::loadModel ( 'role' );
  1781. $role = new role ();
  1782. $flag = true;
  1783. $roleKey = 0;
  1784. $endStaffArray = array ();
  1785. $roleArrayCopy = array ();
  1786. foreach ( $verifyList as $k => $v ) {
  1787. // init verifyStaff
  1788. if ($v [1] == 'ROLE') {
  1789. if (! empty ( $verifyStaff )) {
  1790. $endStaffArray = end ( $verifyStaff );
  1791. // if ($v[0]==$endStaffArray['nextStaff']){
  1792. // $roleId=$v[0];
  1793. // }
  1794. }
  1795. $roleVerify = json_decode ( $v [3], true );
  1796. $roleKey = $k;
  1797. $roleArray = array ();
  1798. $rolename = $role->getOne ( array (
  1799. 'where' => 'rid=' . $v [0],
  1800. 'asArray' => true
  1801. ) );
  1802. foreach ( $roleVerify as $o => $p ) {
  1803. $staffID = explode ( '_', $p );
  1804. $staffInfo = $staff->getOne ( array (
  1805. 'where' => 'sid=' . $staffID [0],
  1806. 'asArray' => true
  1807. ) );
  1808. // print_r($staffID);
  1809. $exp = array (
  1810. 0 => $staffInfo ['sid'],
  1811. 1 => $staffID [1],
  1812. 2 => $staffInfo ['avatar'],
  1813. 'date' => '',
  1814. 'date' => '',
  1815. 'opinion' => '',
  1816. 'status' => '',
  1817. 'rolename' => $rolename ['name']
  1818. );
  1819. array_push ( $roleArray, $exp );
  1820. }
  1821. $roleArrayCopy [$v [0]] = $roleArray;
  1822. // $verifyList[$k]['roleArray']=$roleArray;
  1823. }
  1824. $verifyList [$k] ['date'] = "";
  1825. $verifyList [$k] ['opinion'] = "";
  1826. $verifyList [$k] ['status'] = "";
  1827. if (empty ( $verifyStaff )) {
  1828. $verifyList [$k] ['date'] = "";
  1829. $verifyList [$k] ['opinion'] = "";
  1830. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1831. $verifyList [$k] ['status'] = 4;
  1832. $flag = false;
  1833. }
  1834. } else {
  1835. foreach ( $verifyStaff as $m => $u ) {
  1836. if ($v [0] == $m) {
  1837. $verifyList [$k] ['date'] = $u ['date'];
  1838. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1839. $verifyList [$k] ['status'] = $u ['status'];
  1840. $flag = false;
  1841. break;
  1842. }
  1843. }
  1844. $endStaffArray = end ( $verifyStaff );
  1845. if (isset ( $endStaffArray ['ROLE'] )) {
  1846. } else {
  1847. // $endKey=key($verifyStaff);
  1848. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1849. // $button=4;
  1850. // $verifyList[$k]['status']=4;
  1851. // }
  1852. }
  1853. }
  1854. }
  1855. $rolename ['name'] = '';
  1856. if (! empty ( $roleId )) {
  1857. Doo::loadModel ( 'role' );
  1858. $role = new role ();
  1859. $rolename = $role->getOne ( array (
  1860. 'where' => 'rid=' . $roleId,
  1861. 'asArray' => true
  1862. ) );
  1863. }
  1864. if (! empty ( $verifyStaff ))
  1865. $endStaffArray = end ( $verifyStaff );
  1866. $KOP = false;
  1867. foreach ( $roleArrayCopy as $P => $A ) {
  1868. foreach ( $A as $MKI => $AVL ) {
  1869. if (! empty ( $verifyStaff )) {
  1870. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1871. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1872. $button = 4;
  1873. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1874. }
  1875. foreach ( $verifyStaff as $m => $u ) {
  1876. $AVLFK = $AVL [0] . '_R';
  1877. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1878. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1879. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1880. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1881. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1882. break;
  1883. }
  1884. }
  1885. } else {
  1886. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1887. $button = 4;
  1888. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1889. }
  1890. }
  1891. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1892. $KOP = true;
  1893. }
  1894. }
  1895. foreach ( $roleArrayCopy as $k => $v ) {
  1896. foreach ( $verifyList as $m => $n ) {
  1897. if ($n [0] == $k) {
  1898. array_splice ( $verifyList, $m, 1, $v );
  1899. }
  1900. }
  1901. }
  1902. $receiptList [$key] ['verifyList'] = $verifyList;
  1903. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1904. 'where' => 'sid=' . $value ['staff'],
  1905. 'asArray' => true
  1906. ) );
  1907. $receiptList [$key] ['button'] = $button;
  1908. }
  1909. // print_r($receiptList);die;
  1910. $mothHtml = "";
  1911. for($i = 1; $i <= 12; $i ++) {
  1912. if ($moth == $i)
  1913. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  1914. else
  1915. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  1916. }
  1917. $data ['mothHtml'] = $mothHtml;
  1918. $data ['receiptList'] = $receiptList;
  1919. $data ['memu'] = "receipt";
  1920. $data ['staff'] = $this->staff;
  1921. $data ['receiptMemu'] = 'expenses';
  1922. $data ['verifyId'] = $this->verifyId;
  1923. $data ['executeId'] = $this->executeId;
  1924. $data ['item'] = $item;
  1925. $data ['year'] = $year;
  1926. $this->render ( "/admin/expenses", $data );
  1927. }
  1928. function expensesCollect() {
  1929. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1930. Doo::loadModel ( 'receipt' );
  1931. $receipt = new receipt ();
  1932. Doo::loadModel ( 'L_category' );
  1933. $Lcategory = new L_category ();
  1934. Doo::loadModel ( 'verify' );
  1935. Doo::loadModel ( 'statistics' );
  1936. $statistics = new statistics ();
  1937. $verify = new verify ();
  1938. Doo::loadModel ( 'staff' );
  1939. $staff = new staff ();
  1940. Doo::loadModel ( 'loanReceipt' );
  1941. $loanReceipt = new loanReceipt ();
  1942. $receiptList = $receipt->find ( array (
  1943. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  1944. 'desc' => 'rid',
  1945. 'asArray' => true
  1946. ) );
  1947. $loanList = $loanReceipt->find ( array (
  1948. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  1949. 'desc' => 'rid',
  1950. 'asArray' => true
  1951. ) );
  1952. /*
  1953. * $Locate=0;$roleId=0;$button=0; foreach ($loanList as $key=>$value){ $loanList[$key]['Locate']=$Locate;$Locate++; $loanList[$key]['reviseDetail']=array(); if (!empty($value['reviseDetail'])) $loanList[$key]['reviseDetail']=json_decode($value['reviseDetail'],true); $loanList[$key]['accountItem']=json_decode($value['accountItem'],true); $loanList[$key]['loanItem']=json_decode($value['loanItem'],true); $categoryDetil=$Lcategory->getOne(array('where'=>'cid='.$value['cid'],'asArray'=>true)); $loanList[$key]['category']=$categoryDetil['title']; //检测编辑状态 if ($value['status']==3||$value['status']==1||$value['status']==8||$value['status']==9) $verifyList['staff']=$value['verifyBreakup']; else $verifyList=$verify->getOne(array('where'=>'vid='.$value['verify'],'asArray'=>true)); $verifyList=json_decode($verifyList['staff'],true);//status opinion $verifyStaff=json_decode($value['verifyStaff'],true); Doo::loadModel('role'); $role=new role(); $flag=true;$roleKey=0;$endStaffArray=array();$roleArrayCopy=array(); foreach ($verifyList as $k=>$v){ //init verifyStaff if ($v[1]=='ROLE'){ if (!empty($verifyStaff)){ $endStaffArray=end($verifyStaff); // if ($v[0]==$endStaffArray['nextStaff']){ // $roleId=$v[0]; // } } $roleVerify=json_decode($v[3],true); $roleKey=$k;$roleArray=array(); $rolename=$role->getOne(array('where'=>'rid='.$v[0],'asArray'=>true)); foreach ($roleVerify as $o=>$p){ $staffID=explode ('_',$p); $staffInfo=$staff->getOne(array('where'=>'sid='.$staffID[0],'asArray'=>true)); //print_r($staffID); $exp=array(0=>$staffInfo['sid'],1=>$staffID[1],2=>$staffInfo['avatar'],'date'=>'','date'=>'','opinion'=>'','status'=>'','rolename'=>$rolename['name']); array_push($roleArray, $exp); } $roleArrayCopy[$v[0]]=$roleArray; //$verifyList[$k]['roleArray']=$roleArray; } $verifyList[$k]['date']=""; $verifyList[$k]['opinion']=""; $verifyList[$k]['status']=""; if (empty($verifyStaff)){ $verifyList[$k]['date']=""; $verifyList[$k]['opinion']=""; if (($verifyList[0][0]==$this->staff[0]['sid'])&&$flag){ $verifyList[$k]['status']=4; $flag=false; } }else{ foreach ($verifyStaff as $m=>$u){ if ($v[0]==$m){ $verifyList[$k]['date']=$u['date']; $verifyList[$k]['opinion']=$u['opinion']; $verifyList[$k]['status']=$u['status']; $flag=false; break; } } $endStaffArray=end($verifyStaff); if (isset($endStaffArray['ROLE'])){ }else{ // $endKey=key($verifyStaff); // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){ // $button=4; // $verifyList[$k]['status']=4; // } } } } $rolename['name']=''; if (!empty($roleId)){ Doo::loadModel('role'); $role=new role(); $rolename=$role->getOne(array('where'=>'rid='.$roleId,'asArray'=>true)); } if (!empty($verifyStaff)) $endStaffArray=end($verifyStaff); $KOP=false; foreach ($roleArrayCopy as $P=>$A){ foreach ( $A as $MKI=>$AVL){ if (!empty($verifyStaff)){ //&&$rolename['rid']==$endStaffArray['nextStaff'] if ($this->staff[0]['sid']==$AVL[0]&&isset($endStaffArray['ROLE'])&&$rolename['rid']==$endStaffArray['nextStaff']){ $button=4; $roleArrayCopy[$P][$MKI]['status']=4; } foreach ($verifyStaff as $m=>$u){ $AVLFK=$AVL[0].'_R'; //echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>'; if (strcmp($AVLFK,$m)==0){//&&isset($u['ROLE'])&&$u['ROLE']==1 $roleArrayCopy[$P][$MKI]['date']=$u['date']; $roleArrayCopy[$P][$MKI]['opinion']=$u['opinion']; $roleArrayCopy[$P][$MKI]['status']=$u['status']; break; } } }else{ if ($this->staff[0]['sid']==$AVL[0]&&$verifyList[0][1]=='ROLE'){ $button=4; $roleArrayCopy[$P][$MKI]['status']=4; } } //$roleArray[$MKI]['rolename']=$rolename['name']; $KOP=true; } } foreach ($roleArrayCopy as $k=>$v){ foreach ($verifyList as $m=>$n){ if ($n[0]==$k){ array_splice($verifyList,$m,1,$v); } } } $loanList[$key]['verifyList']=$verifyList; $loanList[$key]['staffDetail']=$staff->getOne(array('where'=>'sid='.$value['staff'],'asArray'=>true)); $loanList[$key]['button']=$button; //$loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']); } $data['loanList']=$loanList;
  1954. */
  1955. $Locate = 0;
  1956. $roleId = 0;
  1957. $button = 0;
  1958. foreach ( $receiptList as $key => $value ) {
  1959. $receiptList [$key] ['Locate'] = $Locate;
  1960. $Locate ++;
  1961. $receiptList [$key] ['reviseDetail'] = array ();
  1962. if (! empty ( $value ['reviseDetail'] ))
  1963. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1964. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1965. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1966. $categoryDetil = $Lcategory->getOne ( array (
  1967. 'where' => 'cid=' . $value ['cid'],
  1968. 'asArray' => true
  1969. ) );
  1970. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1971. // 检测编辑状态
  1972. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  1973. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  1974. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  1975. else
  1976. $verifyList ['staff'] = $value ['verifyBreakup'];
  1977. } else
  1978. $verifyList = $verify->getOne ( array (
  1979. 'where' => 'vid=' . $value ['verify'],
  1980. 'asArray' => true
  1981. ) );
  1982. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1983. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1984. Doo::loadModel ( 'role' );
  1985. $role = new role ();
  1986. $flag = true;
  1987. $roleKey = 0;
  1988. $endStaffArray = array ();
  1989. $roleArrayCopy = array ();
  1990. foreach ( $verifyList as $k => $v ) {
  1991. // init verifyStaff
  1992. if ($v [1] == 'ROLE') {
  1993. if (! empty ( $verifyStaff )) {
  1994. $endStaffArray = end ( $verifyStaff );
  1995. // if ($v[0]==$endStaffArray['nextStaff']){
  1996. // $roleId=$v[0];
  1997. // }
  1998. }
  1999. $roleVerify = json_decode ( $v [3], true );
  2000. $roleKey = $k;
  2001. $roleArray = array ();
  2002. $rolename = $role->getOne ( array (
  2003. 'where' => 'rid=' . $v [0],
  2004. 'asArray' => true
  2005. ) );
  2006. foreach ( $roleVerify as $o => $p ) {
  2007. $staffID = explode ( '_', $p );
  2008. $staffInfo = $staff->getOne ( array (
  2009. 'where' => 'sid=' . $staffID [0],
  2010. 'asArray' => true
  2011. ) );
  2012. // print_r($staffID);
  2013. $exp = array (
  2014. 0 => $staffInfo ['sid'],
  2015. 1 => $staffID [1],
  2016. 2 => $staffInfo ['avatar'],
  2017. 'date' => '',
  2018. 'date' => '',
  2019. 'opinion' => '',
  2020. 'status' => '',
  2021. 'rolename' => $rolename ['name']
  2022. );
  2023. array_push ( $roleArray, $exp );
  2024. }
  2025. $roleArrayCopy [$v [0]] = $roleArray;
  2026. // $verifyList[$k]['roleArray']=$roleArray;
  2027. }
  2028. $verifyList [$k] ['date'] = "";
  2029. $verifyList [$k] ['opinion'] = "";
  2030. $verifyList [$k] ['status'] = "";
  2031. if (empty ( $verifyStaff )) {
  2032. $verifyList [$k] ['date'] = "";
  2033. $verifyList [$k] ['opinion'] = "";
  2034. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2035. $verifyList [$k] ['status'] = 4;
  2036. $flag = false;
  2037. }
  2038. } else {
  2039. foreach ( $verifyStaff as $m => $u ) {
  2040. if ($v [0] == $m) {
  2041. $verifyList [$k] ['date'] = $u ['date'];
  2042. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2043. $verifyList [$k] ['status'] = $u ['status'];
  2044. $flag = false;
  2045. break;
  2046. }
  2047. }
  2048. $endStaffArray = end ( $verifyStaff );
  2049. if (isset ( $endStaffArray ['ROLE'] )) {
  2050. } else {
  2051. // $endKey=key($verifyStaff);
  2052. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2053. // $button=4;
  2054. // $verifyList[$k]['status']=4;
  2055. // }
  2056. }
  2057. }
  2058. }
  2059. $rolename ['name'] = '';
  2060. if (! empty ( $roleId )) {
  2061. Doo::loadModel ( 'role' );
  2062. $role = new role ();
  2063. $rolename = $role->getOne ( array (
  2064. 'where' => 'rid=' . $roleId,
  2065. 'asArray' => true
  2066. ) );
  2067. }
  2068. if (! empty ( $verifyStaff ))
  2069. $endStaffArray = end ( $verifyStaff );
  2070. $KOP = false;
  2071. foreach ( $roleArrayCopy as $P => $A ) {
  2072. foreach ( $A as $MKI => $AVL ) {
  2073. if (! empty ( $verifyStaff )) {
  2074. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2075. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2076. $button = 4;
  2077. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2078. }
  2079. foreach ( $verifyStaff as $m => $u ) {
  2080. $AVLFK = $AVL [0] . '_R';
  2081. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2082. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2083. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2084. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2085. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2086. break;
  2087. }
  2088. }
  2089. } else {
  2090. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2091. $button = 4;
  2092. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2093. }
  2094. }
  2095. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2096. $KOP = true;
  2097. }
  2098. }
  2099. foreach ( $roleArrayCopy as $k => $v ) {
  2100. foreach ( $verifyList as $m => $n ) {
  2101. if ($n [0] == $k) {
  2102. array_splice ( $verifyList, $m, 1, $v );
  2103. }
  2104. }
  2105. }
  2106. // 费用执行人相关数据
  2107. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2108. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2109. foreach ( $executeCopy as $k => $v ) {
  2110. $executeCopy [$k] ['date'] = '';
  2111. $executeCopy [$k] ['opinion'] = '';
  2112. $executeCopy [$k] ['status'] = '';
  2113. if (! empty ( $executeStaff ))
  2114. foreach ( $executeStaff as $m => $u ) {
  2115. if ($v [0] == $m) {
  2116. $executeCopy [$k] ['date'] = $u ['date'];
  2117. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2118. $executeCopy [$k] ['status'] = $u ['status'];
  2119. break;
  2120. }
  2121. }
  2122. }
  2123. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2124. $receiptList [$key] ['verifyList'] = $verifyList;
  2125. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2126. 'where' => 'sid=' . $value ['staff'],
  2127. 'asArray' => true
  2128. ) );
  2129. $receiptList [$key] ['button'] = $button;
  2130. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2131. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2132. $relust = $value ['sum'] - $value ['loanSum'];
  2133. $receiptList [$key] ['relust'] = $relust;
  2134. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2135. }
  2136. Doo::loadModel ( 'enclosur' );
  2137. $enclosur = new enclosur ();
  2138. $enclosurList = $enclosur->find ( array (
  2139. 'where' => 'rid=' . $rid,
  2140. 'asArray' => true
  2141. ) );
  2142. $enclosurHtml = '';
  2143. foreach ( $enclosurList as $value ) {
  2144. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2145. }
  2146. $data ['enclosurHtml'] = $enclosurHtml;
  2147. // print_r($receiptList);
  2148. $data ['receiptList'] = $receiptList;
  2149. $data ['memu'] = "receipt";
  2150. $data ['staff'] = $this->staff;
  2151. $data ['receiptMemu'] = 'expenses';
  2152. $data ['verifyId'] = $this->verifyId;
  2153. $data ['executeId'] = $this->executeId;
  2154. $this->render ( "/admin/expensesCollect", $data );
  2155. }
  2156. function approvalExpenses() {
  2157. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  2158. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2159. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2160. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2161. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2162. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  2163. //echo $rdate;
  2164. if (empty ( $status ))
  2165. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  2166. $page_size = 12;
  2167. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2168. $vidList = array ();
  2169. $button = 0;
  2170. Doo::loadModel ( 'verify' );
  2171. $verify = new verify ();
  2172. Doo::loadModel ( 'receipt' );
  2173. $receipt = new receipt ();
  2174. Doo::loadModel ( 'staff' );
  2175. $staff = new staff ();
  2176. Doo::loadModel ( 'L_category' );
  2177. $Lcategory = new L_category ();
  2178. // user verify ID
  2179. $verifyDetail = $verify->find ( array (
  2180. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  2181. 'asArray' => true
  2182. ) );
  2183. foreach ( $verifyDetail as $key => $value ) {
  2184. array_push ( $vidList, $value ['vid'] );
  2185. }
  2186. $vid = implode ( ",", $vidList );
  2187. if (empty ( $verifyDetail ))
  2188. $vid = 0;
  2189. // if ($status==0)
  2190. // $dateCondition="";
  2191. // else
  2192. $dateCondition = " and Year(date) =" . $year;
  2193. /*
  2194. if (! empty ( $month ))
  2195. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  2196. if($status == 'done'){
  2197. $dateCondition = " and Year(pastDate) =" . $year;
  2198. if (! empty ( $month ))
  2199. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  2200. }
  2201. */
  2202. //date ( 'Y-m' )
  2203. if(!empty($rdate)&&$status == 'done')
  2204. $dateCondition=" and date_format(pastDate,'%Y-%m')='".$rdate."' ";
  2205. elseif (!empty($rdate))
  2206. $dateCondition=" and date_format(date,'%Y-%m')='".$rdate."' ";
  2207. $categoryList = $Lcategory->find ( array (
  2208. 'asArray' => true
  2209. ) );
  2210. $staffList = $staff->find ( array (
  2211. 'where' => 'cid=' . $cid,
  2212. 'asArray' => true
  2213. ) );
  2214. $cateCondition = "";
  2215. $staffCondition = "";
  2216. $approvalCondition = "";
  2217. if (! empty ( $cid )){
  2218. $cateCondition = ' and cid=' . $cid;
  2219. }
  2220. if (! empty ( $sid )) {
  2221. $staffCondition = ' and cid=' . $cid.' and staff=' . $sid;
  2222. $cateCondition = "";
  2223. }
  2224. $get="?year=".$year."&month=".$month."&cid=".$cid."&sid=".$sid;
  2225. if ($status == 'pendApproval') {
  2226. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  2227. }
  2228. if ($status == 'ongoing') {
  2229. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  2230. }
  2231. if ($status == 'done') {
  2232. $approvalCondition = ' and (status=8 or status=9 ) ';
  2233. }
  2234. if ($status == 'termination') {
  2235. $approvalCondition = " and status=3";
  2236. }
  2237. // $approvalCondition = " and status=" . $status;
  2238. // if ($status == 2) {
  2239. // // 查找角色审批人
  2240. // }
  2241. // if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  2242. // $approvalCondition = ' and status=2 ';
  2243. // }
  2244. // if ($status == 1) {
  2245. // $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  2246. // }
  2247. // if ($status == 8) {
  2248. // $approvalCondition = ' and (status=' . $status . ' or status=9 ) ';
  2249. // }
  2250. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  2251. $pageinfo ['page'] = array (
  2252. 'previous' => ''
  2253. );
  2254. // if ($status == 0) {
  2255. // $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  2256. // $receiptList = $receipt->find ( array (
  2257. // 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ')',
  2258. // 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2259. // 'desc' => 'rid',
  2260. // 'asArray' => true
  2261. // ) );
  2262. // //echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2263. // } else
  2264. if ($status == 'done' || $status == 'termination') {
  2265. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/".$status, $get, "" );
  2266. $receiptList = $receipt->find ( array (
  2267. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
  2268. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2269. 'desc' => 'rid',
  2270. 'asArray' => true
  2271. ) );
  2272. } else
  2273. $receiptList = $receipt->find ( array (
  2274. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
  2275. 'desc' => 'rid',
  2276. 'asArray' => true
  2277. ) );
  2278. $rLRes = $receipt->find ( array (
  2279. 'where' => 'status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )' . $cateCondition . $staffCondition,
  2280. 'desc' => 'rid',
  2281. 'asArray' => true
  2282. ) );
  2283. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2284. // print_r($pageinfo);
  2285. $Locate = 0;
  2286. $reportList=$reportCateList=array();
  2287. foreach ( $receiptList as $key => $value ) {
  2288. $receiptList [$key] ['Locate'] = $Locate;
  2289. $Locate ++;
  2290. $receiptList [$key] ['reviseDetail'] = array ();
  2291. if (! empty ( $value ['reviseDetail'] ))
  2292. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2293. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2294. $categoryDetil = $Lcategory->getOne ( array (
  2295. 'where' => 'cid=' . $value ['cid'],
  2296. 'asArray' => true
  2297. ) );
  2298. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2299. $verifyList = $verify->getOne ( array (
  2300. 'where' => 'vid=' . $value ['verify'],
  2301. 'asArray' => true
  2302. ) );
  2303. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2304. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2305. foreach ( $verifyList as $k => $v ) {
  2306. // init verifyStaff
  2307. $verifyList [$k] ['date'] = "";
  2308. $verifyList [$k] ['opinion'] = "";
  2309. $verifyList [$k] ['status'] = "";
  2310. if (empty ( $verifyStaff )) {
  2311. $verifyList [$k] ['date'] = "";
  2312. $verifyList [$k] ['opinion'] = "";
  2313. if ($v [0] == $this->staff [0] ['sid']) {
  2314. $verifyList [$k] ['status'] = 4;
  2315. $button = 4;
  2316. }
  2317. } else {
  2318. $flag = true;
  2319. foreach ( $verifyStaff as $m => $u ) {
  2320. if ($v [0] == $m) {
  2321. $verifyList [$k] ['date'] = $u ['date'];
  2322. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2323. $verifyList [$k] ['status'] = $u ['status'];
  2324. $flag = false;
  2325. break;
  2326. }
  2327. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  2328. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  2329. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  2330. }
  2331. if ($flag) { // 检测可编辑
  2332. if ($v [0] == $this->staff [0] ['sid']) {
  2333. $verifyList [$k] ['status'] = 4;
  2334. $button = 4;
  2335. }
  2336. }
  2337. }
  2338. }
  2339. $receiptList [$key] ['verifyList'] = $verifyList;
  2340. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2341. 'where' => 'sid=' . $value ['staff'],
  2342. 'asArray' => true
  2343. ) );
  2344. array_push($reportList, $receiptList [$key] ['staffDetail']['sid'].'-'.$receiptList [$key] ['staffDetail']['username'].'-'.$receiptList [$key] ['staffDetail']['category']);
  2345. array_push($reportCateList, $receiptList [$key] ['staffDetail']['cid'].'-'.$receiptList [$key] ['staffDetail']['category']);
  2346. $receiptList [$key] ['button'] = $button;
  2347. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  2348. }
  2349. $reportList=array_unique($reportList);
  2350. $reportHtml='';
  2351. foreach ($reportList as $key=>$value){
  2352. $v=explode("-", $value);
  2353. $reportHtml.='<option node-all=\'true\' node-cate=\''.$v[2].'\' value="'.$v[1].'">'.$v[1].'</option>';
  2354. }
  2355. //print_r($reportList)
  2356. $data['reportHtml']=$reportHtml;
  2357. $reportCateList=array_unique($reportCateList);
  2358. $reportCateHtml='';
  2359. foreach ($reportCateList as $key=>$value){
  2360. $v=explode("-", $value);
  2361. $reportCateHtml.='<option value="'.$v[1].'">'.$v[1].'</option>';
  2362. }
  2363. //$reportHtml.='<option value="ALL">'.$value[''].'</option>';
  2364. $data['reportCateHtml']=$reportCateHtml;
  2365. // print_r($receiptList);die;
  2366. // $data['verifyDetail']=$verifyDetail;
  2367. $mothHtml = "";
  2368. for($i = 1; $i <= 12; $i ++) {
  2369. if ($month == $i)
  2370. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2371. else
  2372. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2373. }
  2374. $data ['mothHtml'] = $mothHtml;
  2375. $data ['page'] = $pageinfo;
  2376. $data ['receiptList'] = $receiptList;
  2377. $data ['receiptApprovalCount'] = count ( $rLRes );
  2378. $data ['status'] = $status;
  2379. $data ['year'] = $year;
  2380. $data ['categoryList'] = $categoryList;
  2381. $data ['staffList'] = $staffList;
  2382. $data ['cid'] = $cid;
  2383. $data ['sid'] = $sid;
  2384. // print_r($receiptList);
  2385. $data ['memu'] = "receipt";
  2386. $data ['staff'] = $this->staff;
  2387. $data ['receiptMemu'] = 'approvalExpenses';
  2388. $data ['verifyId'] = $this->verifyId;
  2389. $data ['executeId'] = $this->executeId;
  2390. $this->render ( "/admin/approvalExpenses", $data );
  2391. }
  2392. function expensesDoc() {
  2393. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2394. Doo::loadModel ( 'receipt' );
  2395. $receipt = new receipt ();
  2396. Doo::loadModel ( 'L_category' );
  2397. $Lcategory = new L_category ();
  2398. Doo::loadModel ( 'verify' );
  2399. Doo::loadModel ( 'statistics' );
  2400. $statistics = new statistics ();
  2401. $verify = new verify ();
  2402. Doo::loadModel ( 'staff' );
  2403. $staff = new staff ();
  2404. Doo::loadModel ( 'loanReceipt' );
  2405. $loanReceipt = new loanReceipt ();
  2406. $receiptList = $receipt->find ( array (
  2407. 'where' => ' rid=' . $rid,
  2408. 'desc' => 'rid',
  2409. 'asArray' => true
  2410. ) );
  2411. $loanList = array ();
  2412. if (! empty ( $receiptList ))
  2413. $loanList = $loanReceipt->find ( array (
  2414. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2415. 'desc' => 'rid',
  2416. 'asArray' => true
  2417. ) );
  2418. $Locate = 0;
  2419. $roleId = 0;
  2420. $button = 0;
  2421. foreach ( $loanList as $key => $value ) {
  2422. $loanList [$key] ['Locate'] = $Locate;
  2423. $Locate ++;
  2424. $loanList [$key] ['reviseDetail'] = array ();
  2425. if (! empty ( $value ['reviseDetail'] ))
  2426. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2427. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2428. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2429. $categoryDetil = $Lcategory->getOne ( array (
  2430. 'where' => 'cid=' . $value ['cid'],
  2431. 'asArray' => true
  2432. ) );
  2433. $loanList [$key] ['category'] = $categoryDetil ['title'];
  2434. // 检测编辑状态
  2435. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  2436. $verifyList ['staff'] = $value ['verifyBreakup'];
  2437. else
  2438. $verifyList = $verify->getOne ( array (
  2439. 'where' => 'vid=' . $value ['verify'],
  2440. 'asArray' => true
  2441. ) );
  2442. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2443. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2444. Doo::loadModel ( 'role' );
  2445. $role = new role ();
  2446. $flag = true;
  2447. $roleKey = 0;
  2448. $endStaffArray = array ();
  2449. $roleArrayCopy = array ();
  2450. foreach ( $verifyList as $k => $v ) {
  2451. // init verifyStaff
  2452. if ($v [1] == 'ROLE') {
  2453. if (! empty ( $verifyStaff )) {
  2454. $endStaffArray = end ( $verifyStaff );
  2455. // if ($v[0]==$endStaffArray['nextStaff']){
  2456. // $roleId=$v[0];
  2457. // }
  2458. }
  2459. $roleVerify = json_decode ( $v [3], true );
  2460. $roleKey = $k;
  2461. $roleArray = array ();
  2462. $rolename = $role->getOne ( array (
  2463. 'where' => 'rid=' . $v [0],
  2464. 'asArray' => true
  2465. ) );
  2466. foreach ( $roleVerify as $o => $p ) {
  2467. $staffID = explode ( '_', $p );
  2468. $staffInfo = $staff->getOne ( array (
  2469. 'where' => 'sid=' . $staffID [0],
  2470. 'asArray' => true
  2471. ) );
  2472. // print_r($staffID);
  2473. $exp = array (
  2474. 0 => $staffInfo ['sid'],
  2475. 1 => $staffID [1],
  2476. 2 => $staffInfo ['avatar'],
  2477. 'date' => '',
  2478. 'date' => '',
  2479. 'opinion' => '',
  2480. 'status' => '',
  2481. 'rolename' => $rolename ['name']
  2482. );
  2483. array_push ( $roleArray, $exp );
  2484. }
  2485. $roleArrayCopy [$v [0]] = $roleArray;
  2486. // $verifyList[$k]['roleArray']=$roleArray;
  2487. }
  2488. $verifyList [$k] ['date'] = "";
  2489. $verifyList [$k] ['opinion'] = "";
  2490. $verifyList [$k] ['status'] = "";
  2491. if (empty ( $verifyStaff )) {
  2492. $verifyList [$k] ['date'] = "";
  2493. $verifyList [$k] ['opinion'] = "";
  2494. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2495. $verifyList [$k] ['status'] = 4;
  2496. $flag = false;
  2497. }
  2498. } else {
  2499. foreach ( $verifyStaff as $m => $u ) {
  2500. if ($v [0] == $m) {
  2501. $verifyList [$k] ['date'] = $u ['date'];
  2502. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2503. $verifyList [$k] ['status'] = $u ['status'];
  2504. $flag = false;
  2505. break;
  2506. }
  2507. }
  2508. $endStaffArray = end ( $verifyStaff );
  2509. if (isset ( $endStaffArray ['ROLE'] )) {
  2510. } else {
  2511. // $endKey=key($verifyStaff);
  2512. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2513. // $button=4;
  2514. // $verifyList[$k]['status']=4;
  2515. // }
  2516. }
  2517. }
  2518. }
  2519. $rolename ['name'] = '';
  2520. if (! empty ( $roleId )) {
  2521. Doo::loadModel ( 'role' );
  2522. $role = new role ();
  2523. $rolename = $role->getOne ( array (
  2524. 'where' => 'rid=' . $roleId,
  2525. 'asArray' => true
  2526. ) );
  2527. }
  2528. if (! empty ( $verifyStaff ))
  2529. $endStaffArray = end ( $verifyStaff );
  2530. $KOP = false;
  2531. foreach ( $roleArrayCopy as $P => $A ) {
  2532. foreach ( $A as $MKI => $AVL ) {
  2533. if (! empty ( $verifyStaff )) {
  2534. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2535. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2536. $button = 4;
  2537. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2538. }
  2539. foreach ( $verifyStaff as $m => $u ) {
  2540. $AVLFK = $AVL [0] . '_R';
  2541. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2542. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2543. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2544. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2545. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2546. break;
  2547. }
  2548. }
  2549. } else {
  2550. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2551. $button = 4;
  2552. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2553. }
  2554. }
  2555. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2556. $KOP = true;
  2557. }
  2558. }
  2559. foreach ( $roleArrayCopy as $k => $v ) {
  2560. foreach ( $verifyList as $m => $n ) {
  2561. if ($n [0] == $k) {
  2562. array_splice ( $verifyList, $m, 1, $v );
  2563. }
  2564. }
  2565. }
  2566. $loanList [$key] ['verifyList'] = $verifyList;
  2567. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  2568. 'where' => 'sid=' . $value ['staff'],
  2569. 'asArray' => true
  2570. ) );
  2571. $loanList [$key] ['button'] = $button;
  2572. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  2573. }
  2574. $data ['loanList'] = $loanList;
  2575. // print_r($loanList);
  2576. $Locate = 0;
  2577. $roleId = 0;
  2578. $button = 0;
  2579. foreach ( $receiptList as $key => $value ) {
  2580. $receiptList [$key] ['Locate'] = $Locate;
  2581. $Locate ++;
  2582. $receiptList [$key] ['reviseDetail'] = array ();
  2583. if (! empty ( $value ['reviseDetail'] ))
  2584. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2585. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2586. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2587. $categoryDetil = $Lcategory->getOne ( array (
  2588. 'where' => 'cid=' . $value ['cid'],
  2589. 'asArray' => true
  2590. ) );
  2591. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2592. // 检测编辑状态
  2593. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  2594. $verifyList ['staff'] = $value ['verifyBreakup'];
  2595. } else
  2596. $verifyList = $verify->getOne ( array (
  2597. 'where' => 'vid=' . $value ['verify'],
  2598. 'asArray' => true
  2599. ) );
  2600. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2601. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2602. Doo::loadModel ( 'role' );
  2603. $role = new role ();
  2604. if ($verifyList == NULL)
  2605. $verifyList = array ();
  2606. $flag = true;
  2607. $roleKey = 0;
  2608. $endStaffArray = array ();
  2609. $roleArrayCopy = array ();
  2610. foreach ( $verifyList as $k => $v ) {
  2611. // init verifyStaff
  2612. if ($v [1] == 'ROLE') {
  2613. if (! empty ( $verifyStaff )) {
  2614. $endStaffArray = end ( $verifyStaff );
  2615. // if ($v[0]==$endStaffArray['nextStaff']){
  2616. // $roleId=$v[0];
  2617. // }
  2618. }
  2619. $roleVerify = json_decode ( $v [3], true );
  2620. $roleKey = $k;
  2621. $roleArray = array ();
  2622. $rolename = $role->getOne ( array (
  2623. 'where' => 'rid=' . $v [0],
  2624. 'asArray' => true
  2625. ) );
  2626. foreach ( $roleVerify as $o => $p ) {
  2627. $staffID = explode ( '_', $p );
  2628. $staffInfo = $staff->getOne ( array (
  2629. 'where' => 'sid=' . $staffID [0],
  2630. 'asArray' => true
  2631. ) );
  2632. // print_r($staffID);
  2633. $exp = array (
  2634. 0 => $staffInfo ['sid'],
  2635. 1 => $staffID [1],
  2636. 2 => $staffInfo ['avatar'],
  2637. 'date' => '',
  2638. 'date' => '',
  2639. 'opinion' => '',
  2640. 'status' => '',
  2641. 'rolename' => $rolename ['name']
  2642. );
  2643. array_push ( $roleArray, $exp );
  2644. }
  2645. $roleArrayCopy [$v [0]] = $roleArray;
  2646. // $verifyList[$k]['roleArray']=$roleArray;
  2647. }
  2648. $verifyList [$k] ['date'] = "";
  2649. $verifyList [$k] ['opinion'] = "";
  2650. $verifyList [$k] ['status'] = "";
  2651. if (empty ( $verifyStaff )) {
  2652. $verifyList [$k] ['date'] = "";
  2653. $verifyList [$k] ['opinion'] = "";
  2654. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2655. $verifyList [$k] ['status'] = 4;
  2656. $flag = false;
  2657. }
  2658. } else {
  2659. foreach ( $verifyStaff as $m => $u ) {
  2660. if ($v [0] == $m) {
  2661. $verifyList [$k] ['date'] = $u ['date'];
  2662. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2663. $verifyList [$k] ['status'] = $u ['status'];
  2664. $flag = false;
  2665. break;
  2666. }
  2667. }
  2668. $endStaffArray = end ( $verifyStaff );
  2669. if (isset ( $endStaffArray ['ROLE'] )) {
  2670. } else {
  2671. // $endKey=key($verifyStaff);
  2672. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2673. // $button=4;
  2674. // $verifyList[$k]['status']=4;
  2675. // }
  2676. }
  2677. }
  2678. }
  2679. $rolename ['name'] = '';
  2680. if (! empty ( $roleId )) {
  2681. Doo::loadModel ( 'role' );
  2682. $role = new role ();
  2683. $rolename = $role->getOne ( array (
  2684. 'where' => 'rid=' . $roleId,
  2685. 'asArray' => true
  2686. ) );
  2687. }
  2688. if (! empty ( $verifyStaff ))
  2689. $endStaffArray = end ( $verifyStaff );
  2690. $KOP = false;
  2691. foreach ( $roleArrayCopy as $P => $A ) {
  2692. foreach ( $A as $MKI => $AVL ) {
  2693. if (! empty ( $verifyStaff )) {
  2694. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2695. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2696. $button = 4;
  2697. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2698. }
  2699. foreach ( $verifyStaff as $m => $u ) {
  2700. $AVLFK = $AVL [0] . '_R';
  2701. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2702. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2703. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2704. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2705. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2706. break;
  2707. }
  2708. }
  2709. } else {
  2710. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2711. $button = 4;
  2712. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2713. }
  2714. }
  2715. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2716. $KOP = true;
  2717. }
  2718. }
  2719. foreach ( $roleArrayCopy as $k => $v ) {
  2720. foreach ( $verifyList as $m => $n ) {
  2721. if ($n [0] == $k) {
  2722. array_splice ( $verifyList, $m, 1, $v );
  2723. }
  2724. }
  2725. }
  2726. // 费用执行人相关数据
  2727. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2728. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2729. foreach ( $executeCopy as $k => $v ) {
  2730. $executeCopy [$k] ['date'] = '';
  2731. $executeCopy [$k] ['opinion'] = '';
  2732. $executeCopy [$k] ['status'] = '';
  2733. if (! empty ( $executeStaff ))
  2734. foreach ( $executeStaff as $m => $u ) {
  2735. if ($v [0] == $m) {
  2736. $executeCopy [$k] ['date'] = $u ['date'];
  2737. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2738. $executeCopy [$k] ['status'] = $u ['status'];
  2739. break;
  2740. }
  2741. }
  2742. }
  2743. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2744. $receiptList [$key] ['verifyList'] = $verifyList;
  2745. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2746. 'where' => 'sid=' . $value ['staff'],
  2747. 'asArray' => true
  2748. ) );
  2749. $receiptList [$key] ['button'] = $button;
  2750. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2751. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2752. $relust = $value ['sum'] - $value ['loanSum'];
  2753. $receiptList [$key] ['relust'] = $relust;
  2754. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2755. }
  2756. // print_r($receiptList);
  2757. // 获取审批日志
  2758. Doo::loadModel ( 'receiptLog' );
  2759. $receiptLog = new receiptLog ();
  2760. $rlList = array ();
  2761. $rlInfo = $receiptLog->getOne ( array (
  2762. 'where' => 'rid=' . $rid . ' and status=4',
  2763. 'asArray' => true
  2764. ) );
  2765. $tijdate = $receiptLog->getOne ( array (
  2766. 'where' => 'rid=' . $rid . ' and status=2',
  2767. 'asc' => 'rlid',
  2768. 'asArray' => true
  2769. ) );
  2770. if (! empty ( $rlInfo )) {
  2771. $rlList = $receiptLog->find ( array (
  2772. 'where' => 'rid=' . $rid,
  2773. 'asc' => 'rlid',
  2774. 'asArray' => true
  2775. ) );
  2776. }
  2777. Doo::loadModel ( 'enclosur' );
  2778. $enclosur = new enclosur ();
  2779. $enclosurList = $enclosur->find ( array (
  2780. 'where' => 'rid=' . $rid,
  2781. 'asArray' => true
  2782. ) );
  2783. $enclosurHtml = '';
  2784. foreach ( $enclosurList as $value ) {
  2785. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2786. }
  2787. $data ['enclosurHtml'] = $enclosurHtml;
  2788. $receiptList [0] ['rlList'] = $rlList;
  2789. $data ['receiptList'] = $receiptList;
  2790. $data ['memu'] = "receipt";
  2791. $data ['staff'] = $this->staff;
  2792. $data ['receiptMemu'] = 'approvalExpenses';
  2793. $data ['verifyId'] = $this->verifyId;
  2794. $data ['executeId'] = $this->executeId;
  2795. $this->render ( "/admin/expensesDoc", $data );
  2796. }
  2797. function expensesEdi() {
  2798. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2799. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  2800. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2801. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2802. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2803. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2804. if (empty ( $status ))
  2805. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  2806. $vidList = array ();
  2807. $button = 0;
  2808. Doo::loadModel ( 'verify' );
  2809. Doo::loadModel ( 'receipt' );
  2810. Doo::loadModel ( 'staff' );
  2811. $staff = new staff ();
  2812. $receipt = new receipt ();
  2813. $verify = new verify ();
  2814. Doo::loadModel ( 'L_category' );
  2815. $Lcategory = new L_category ();
  2816. Doo::loadModel ( 'enclosur' );
  2817. $enclosur = new enclosur ();
  2818. // user verify ID
  2819. $verifyDetail = $verify->find ( array (
  2820. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  2821. 'asArray' => true
  2822. ) );
  2823. foreach ( $verifyDetail as $key => $value ) {
  2824. array_push ( $vidList, $value ['vid'] );
  2825. }
  2826. $vid = implode ( ",", $vidList );
  2827. if (empty ( $verifyDetail ))
  2828. $vid = 0;
  2829. $categoryList = $Lcategory->find ( array (
  2830. 'asArray' => true
  2831. ) );
  2832. $staffList = $staff->find ( array (
  2833. 'where' => 'cid=' . $cid,
  2834. 'asArray' => true
  2835. ) );
  2836. $ap = "";
  2837. if ($status == 4) {
  2838. $ap = 4;
  2839. $status = 2;
  2840. }
  2841. // get Receipt By verifyID status 2
  2842. $receiptList = $receipt->find ( array (
  2843. 'where' => 'rid =' . $rid.' and status=2',
  2844. 'desc' => 'rid',
  2845. 'asArray' => true
  2846. ) );
  2847. if (empty($receiptList)){
  2848. die ( 'illegal request' );
  2849. }
  2850. $Locate = 0;
  2851. $roleId = 0;
  2852. if ($ap == 4)
  2853. $status = 4;
  2854. foreach ( $receiptList as $key => $value ) {
  2855. $receiptList [$key] ['Locate'] = $Locate;
  2856. $Locate ++;
  2857. $receiptList [$key] ['reviseDetail'] = array ();
  2858. if (! empty ( $value ['reviseDetail'] ))
  2859. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2860. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2861. $categoryDetil = $Lcategory->getOne ( array (
  2862. 'where' => 'cid=' . $value ['cid'],
  2863. 'asArray' => true
  2864. ) );
  2865. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2866. // 检测编辑状态
  2867. $verifyList = $verify->getOne ( array (
  2868. 'where' => 'vid=' . $value ['verify'],
  2869. 'asArray' => true
  2870. ) );
  2871. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2872. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2873. Doo::loadModel ( 'role' );
  2874. $role = new role ();
  2875. // print_r($verifyList);
  2876. $flag = true;
  2877. $roleKey = 0;
  2878. $endStaffArray = array ();
  2879. $roleArrayCopy = array ();
  2880. foreach ( $verifyList as $k => $v ) {
  2881. // init verifyStaff
  2882. if ($v [1] == 'ROLE') {
  2883. if (! empty ( $verifyStaff )) {
  2884. $endStaffArray = end ( $verifyStaff );
  2885. if ($v [0] == $endStaffArray ['nextStaff']) {
  2886. $roleId = $v [0];
  2887. }
  2888. }
  2889. $roleVerify = json_decode ( $v [3], true );
  2890. $roleKey = $k;
  2891. $roleArray = array ();
  2892. $rolename = $role->getOne ( array (
  2893. 'where' => 'rid=' . $v [0],
  2894. 'asArray' => true
  2895. ) );
  2896. foreach ( $roleVerify as $o => $p ) {
  2897. $staffID = explode ( '_', $p );
  2898. $staffInfo = $staff->getOne ( array (
  2899. 'where' => 'sid=' . $staffID [0],
  2900. 'asArray' => true
  2901. ) );
  2902. // print_r($staffID);
  2903. $exp = array (
  2904. 0 => $staffInfo ['sid'],
  2905. 1 => $staffID [1],
  2906. 2 => $staffInfo ['avatar'],
  2907. 'date' => '',
  2908. 'date' => '',
  2909. 'opinion' => '',
  2910. 'status' => '',
  2911. 'rolename' => $rolename ['name']
  2912. );
  2913. array_push ( $roleArray, $exp );
  2914. }
  2915. $roleArrayCopy [$v [0]] = $roleArray;
  2916. // $verifyList[$k]['roleArray']=$roleArray;
  2917. }
  2918. // print_r($roleArray);
  2919. $verifyList [$k] ['date'] = "";
  2920. $verifyList [$k] ['opinion'] = "";
  2921. $verifyList [$k] ['status'] = "";
  2922. if (empty ( $verifyStaff )) {
  2923. $verifyList [$k] ['date'] = "";
  2924. $verifyList [$k] ['opinion'] = "";
  2925. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2926. $verifyList [$k] ['status'] = 4;
  2927. $button = 4;
  2928. $flag = false;
  2929. }
  2930. } else {
  2931. foreach ( $verifyStaff as $m => $u ) {
  2932. if ($v [0] == $m) {
  2933. $verifyList [$k] ['date'] = $u ['date'];
  2934. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2935. $verifyList [$k] ['status'] = $u ['status'];
  2936. $flag = false;
  2937. break;
  2938. }
  2939. }
  2940. $endStaffArray = end ( $verifyStaff );
  2941. if (isset ( $endStaffArray ['ROLE'] )) {
  2942. } else {
  2943. $endKey = key ( $verifyStaff );
  2944. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  2945. $button = 4;
  2946. $verifyList [$k] ['status'] = 4;
  2947. }
  2948. }
  2949. }
  2950. }
  2951. $rolename ['name'] = '';
  2952. if (! empty ( $roleId )) {
  2953. Doo::loadModel ( 'role' );
  2954. $role = new role ();
  2955. $rolename = $role->getOne ( array (
  2956. 'where' => 'rid=' . $roleId,
  2957. 'asArray' => true
  2958. ) );
  2959. }
  2960. if (! empty ( $verifyStaff ))
  2961. $endStaffArray = end ( $verifyStaff );
  2962. $KOP = false;
  2963. foreach ( $roleArrayCopy as $P => $A ) {
  2964. foreach ( $A as $MKI => $AVL ) {
  2965. if (! empty ( $verifyStaff )) {
  2966. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2967. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2968. $button = 4;
  2969. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2970. }
  2971. foreach ( $verifyStaff as $m => $u ) {
  2972. $AVLFK = $AVL [0] . '_R';
  2973. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2974. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2975. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2976. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2977. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2978. break;
  2979. }
  2980. }
  2981. } else {
  2982. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2983. $button = 4;
  2984. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2985. }
  2986. }
  2987. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2988. $KOP = true;
  2989. }
  2990. }
  2991. // print_r($roleArrayCopy);
  2992. // echo $roleKey;
  2993. foreach ( $roleArrayCopy as $k => $v ) {
  2994. foreach ( $verifyList as $m => $n ) {
  2995. if ($n [0] == $k) {
  2996. array_splice ( $verifyList, $m, 1, $v );
  2997. }
  2998. }
  2999. }
  3000. $receiptList [$key] ['verifyList'] = $verifyList;
  3001. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3002. 'where' => 'sid=' . $value ['staff'],
  3003. 'asArray' => true
  3004. ) );
  3005. $receiptList [$key] ['button'] = $button;
  3006. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  3007. }
  3008. // $data['verifyDetail']=$verifyDetail;
  3009. $mothHtml = "";
  3010. for($i = 1; $i <= 12; $i ++) {
  3011. if ($month == $i)
  3012. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3013. else
  3014. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3015. }
  3016. // 获取审批日志
  3017. Doo::loadModel ( 'receiptLog' );
  3018. $receiptLog = new receiptLog ();
  3019. $rlList = array ();
  3020. $rlInfo = $receiptLog->getOne ( array (
  3021. 'where' => 'rid=' . $rid . ' and status=4',
  3022. 'asArray' => true
  3023. ) );
  3024. $tijdate = $receiptLog->getOne ( array (
  3025. 'where' => 'rid=' . $rid . ' and status=2',
  3026. 'asc' => 'rlid',
  3027. 'asArray' => true
  3028. ) );
  3029. if (! empty ( $rlInfo )) {
  3030. $rlList = $receiptLog->find ( array (
  3031. 'where' => 'rid=' . $rid,
  3032. 'asc' => 'rlid',
  3033. 'asArray' => true
  3034. ) );
  3035. }
  3036. $receiptList [0] ['rlList'] = $rlList;
  3037. $enclosurList = $enclosur->find ( array (
  3038. 'where' => 'rid=' . $rid,
  3039. 'asArray' => true
  3040. ) );
  3041. $enclosurHtml = '';
  3042. foreach ( $enclosurList as $value ) {
  3043. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3044. }
  3045. // print_r($receiptList);
  3046. $data ['rid'] = $rid;
  3047. $data ['enclosurHtml'] = $enclosurHtml;
  3048. $data ['rolename'] = $rolename ['name'];
  3049. $data ['datetij'] = $tijdate ['date'];
  3050. $data ['mothHtml'] = $mothHtml;
  3051. $data ['receiptList'] = $receiptList;
  3052. $data ['receiptApprovalCount'] = count ( $receiptList );
  3053. $data ['status'] = $status;
  3054. $data ['year'] = $year;
  3055. $data ['categoryList'] = $categoryList;
  3056. $data ['staffList'] = $staffList;
  3057. $data ['cid'] = $cid;
  3058. $data ['sid'] = $sid;
  3059. $data ['ap'] = $ap;
  3060. $data ['memu'] = "receipt";
  3061. $data ['staff'] = $this->staff;
  3062. $data ['receiptMemu'] = 'approvalExpenses';
  3063. $data ['verifyId'] = $this->verifyId;
  3064. $data ['executeId'] = $this->executeId;
  3065. $this->render ( "/admin/expensesEdi", $data );
  3066. }
  3067. function expensesDefray() {
  3068. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3069. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3070. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3071. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  3072. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  3073. if (! empty ( $rid )) {
  3074. Doo::loadModel ( "verify" );
  3075. $verify = new verify ();
  3076. Doo::loadModel ( "receiptDetail" );
  3077. $receiptDetailObj = new receiptDetail ();
  3078. Doo::loadModel ( "itemStatistics" );
  3079. Doo::loadModel ( "statistics" );
  3080. $statistics = new statistics ();
  3081. $itemStatistics = new itemStatistics ();
  3082. Doo::loadModel ( "receipt" );
  3083. $receipt = new receipt ();
  3084. Doo::loadModel ( "loanReceipt" );
  3085. $loanReceipt = new loanReceipt ();
  3086. $receiptDetail = $receipt->getOne ( array (
  3087. 'where' => 'rid=' . $rid . ' and status=2 ',
  3088. 'asArray' => true
  3089. ) );
  3090. $nslist=explode(',', $receiptDetail['nowStaff']);
  3091. $nsflag=true;
  3092. foreach ($nslist as $value){
  3093. if ($value==$this->staff['0']['sid']){
  3094. $nsflag=false;break;
  3095. }
  3096. }
  3097. //print_r($nslist);die;
  3098. if (empty ( $receiptDetail )||$nsflag)
  3099. return "/approvalExpenses/pendApproval";
  3100. $verifyDetail = $verify->getOne ( array (
  3101. 'where' => ' vid =' . $receiptDetail ['verify'],
  3102. 'asArray' => true
  3103. ) );
  3104. $verifyString = $verifyDetail ['staff'];
  3105. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3106. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  3107. if (empty ( $opinion )) {
  3108. if ($status == 3)
  3109. $opinion = "终止";
  3110. else
  3111. $opinion = "同意支付";
  3112. }
  3113. $nowStaff = 0;
  3114. $nowStaffList = array ();
  3115. if (empty ( $verifyStaff )) {
  3116. // 还需加入是否已经进入角色审批
  3117. if ($verifyDetail [0] [1] == 'ROLE') {
  3118. // print_r($verifyDetail);echo "ddd";
  3119. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3120. foreach ( $vStaffString as $key => $value ) {
  3121. $staffK = explode ( "_", $value );
  3122. if ($staffK [0] != $this->staff [0] ['sid'])
  3123. array_push ( $nowStaffList, $staffK [0] );
  3124. }
  3125. // print_r($verifyDetail);
  3126. // die;
  3127. if (! empty ( $nowStaffList )) {
  3128. $nowStaff = implode ( ',', $nowStaffList );
  3129. $verifyStaff = array (
  3130. $this->staff [0] ['sid'] . "_R" => array (
  3131. 'date' => date ( 'Y-m-d' ),
  3132. 'opinion' => $opinion,
  3133. 'status' => $status,
  3134. 'nextStaff' => $verifyDetail [0] [0],
  3135. 'ROLE' => 1
  3136. )
  3137. );
  3138. } else {
  3139. $nowStaff = $verifyDetail [1] [0];
  3140. $verifyStaff = array (
  3141. $this->staff [0] ['sid'] . "_R" => array (
  3142. 'date' => date ( 'Y-m-d' ),
  3143. 'opinion' => $opinion,
  3144. 'status' => $status,
  3145. 'nextStaff' => $verifyDetail [1] [0]
  3146. )
  3147. );
  3148. }
  3149. } else {
  3150. if ($verifyDetail [1] [1] == 'ROLE') {
  3151. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  3152. // echo "dd";
  3153. foreach ( $vStaffString as $key => $value ) {
  3154. $staffK = explode ( "_", $value );
  3155. array_push ( $nowStaffList, $staffK [0] );
  3156. }
  3157. $nowStaff = implode ( ',', $nowStaffList );
  3158. $verifyStaff = array (
  3159. $this->staff [0] ['sid'] => array (
  3160. 'date' => date ( 'Y-m-d' ),
  3161. 'opinion' => $opinion,
  3162. 'status' => $status,
  3163. 'nextStaff' => $verifyDetail [1] [0],
  3164. 'ROLE' => 1
  3165. )
  3166. );
  3167. } else {
  3168. $nowStaff = $verifyDetail [1] [0];
  3169. $verifyStaff = array (
  3170. $this->staff [0] ['sid'] => array (
  3171. 'date' => date ( 'Y-m-d' ),
  3172. 'opinion' => $opinion,
  3173. 'status' => $status,
  3174. 'nextStaff' => $verifyDetail [1] [0]
  3175. )
  3176. );
  3177. }
  3178. }
  3179. if ($status == 3)
  3180. $verifyStaff = array (
  3181. 'final' => $status,
  3182. $this->staff [0] ['sid'] => array (
  3183. 'date' => date ( 'Y-m-d' ),
  3184. 'opinion' => $opinion,
  3185. 'status' => $status
  3186. )
  3187. );
  3188. $vStaffString = json_encode ( $verifyStaff );
  3189. $receipt->nowStaff = $nowStaff;
  3190. $receipt->verifyStaff = $vStaffString;
  3191. $loanReceipt->nowStaff = $nowStaff;
  3192. $loanReceipt->verifyStaff = $vStaffString;
  3193. } else {
  3194. $VS = end ( $verifyStaff );
  3195. // 非角色审批
  3196. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  3197. $nextStaff = 0;
  3198. $roleSTF = false;
  3199. foreach ( $verifyDetail as $key => $value ) {
  3200. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  3201. if (isset ( $verifyDetail [$key + 1] )) {
  3202. $nextStaff = $verifyDetail [$key + 1] [0];
  3203. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  3204. $roleSTF = true;
  3205. }
  3206. break;
  3207. }
  3208. }
  3209. if (! $roleSTF) {
  3210. $nowStaff = $nextStaff;
  3211. $verifyStaff [$this->staff [0] ['sid']] = array (
  3212. 'date' => date ( 'Y-m-d' ),
  3213. 'opinion' => $opinion,
  3214. 'status' => $status,
  3215. 'nextStaff' => $nextStaff
  3216. );
  3217. } else {
  3218. // 获取角色下的所有用户ID
  3219. $nowStaffList = array ();
  3220. foreach ( $verifyDetail as $vfk ) {
  3221. if ($vfk [1] == 'ROLE') {
  3222. $vStaffString = json_decode ( $vfk [3] );
  3223. foreach ( $vStaffString as $key => $value ) {
  3224. $staffK = explode ( "_", $value );
  3225. array_push ( $nowStaffList, $staffK [0] );
  3226. }
  3227. }
  3228. }
  3229. $nowStaff = implode ( ',', $nowStaffList );
  3230. $verifyStaff [$this->staff [0] ['sid']] = array (
  3231. 'date' => date ( 'Y-m-d' ),
  3232. 'opinion' => $opinion,
  3233. 'status' => $status,
  3234. 'nextStaff' => $nextStaff,
  3235. 'ROLE' => 0
  3236. );
  3237. }
  3238. if ($status == 3) {
  3239. $verifyStaff ['final'] = $status;
  3240. $verifyStaff [$this->staff [0] ['sid']] = array (
  3241. 'date' => date ( 'Y-m-d' ),
  3242. 'opinion' => $opinion,
  3243. 'status' => $status
  3244. );
  3245. }
  3246. $vStaffString = json_encode ( $verifyStaff );
  3247. $receipt->nowStaff = $nowStaff;
  3248. $receipt->verifyStaff = $vStaffString;
  3249. $loanReceipt->nowStaff = $nowStaff;
  3250. $loanReceipt->verifyStaff = $vStaffString;
  3251. }
  3252. // 角色审批
  3253. if (isset ( $VS ['ROLE'] )) {
  3254. // 找出角色人 当前审批角色组
  3255. $verifyJSStaff = array ();
  3256. $nowStaffList2 = array ();
  3257. foreach ( $verifyDetail as $key => $value ) {
  3258. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  3259. $verifyJSStaff = json_decode ( $value [3] );
  3260. foreach ( $verifyJSStaff as $m ) {
  3261. $staffK = explode ( "_", $m );
  3262. array_push ( $nowStaffList2, $staffK [0] );
  3263. }
  3264. // print_r($nowStaffList2);
  3265. }
  3266. }
  3267. $RoleVerifyStaff = array ();
  3268. foreach ( $verifyStaff as $key => $value ) {
  3269. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  3270. foreach ( $nowStaffList2 as $m ) {
  3271. if ($key == $m . "_R")
  3272. $RoleVerifyStaff [$key] = $value;
  3273. }
  3274. }
  3275. }
  3276. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  3277. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  3278. // 下一个审批人ID
  3279. $nextStaff = 0;
  3280. $falg = false;
  3281. foreach ( $verifyDetail as $key => $value ) {
  3282. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  3283. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  3284. $falg = true;
  3285. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  3286. $nowStaffList = array ();
  3287. foreach ( $vStaffString as $v ) {
  3288. $staffK = explode ( "_", $v );
  3289. array_push ( $nowStaffList, $staffK [0] );
  3290. }
  3291. $nowStaff = implode ( ',', $nowStaffList );
  3292. $nextStaff = $verifyDetail [$key + 1] [0];
  3293. } elseif (isset ( $verifyDetail [$key + 1] )) {
  3294. $nextStaff = $verifyDetail [$key + 1] [0];
  3295. $nowStaff = $nextStaff;
  3296. } else
  3297. $nowStaff = '';
  3298. break;
  3299. }
  3300. }
  3301. if ($falg)
  3302. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3303. 'date' => date ( 'Y-m-d' ),
  3304. 'opinion' => $opinion,
  3305. 'status' => $status,
  3306. 'nextStaff' => $nextStaff,
  3307. 'ROLE' => 1
  3308. );
  3309. else
  3310. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3311. 'date' => date ( 'Y-m-d' ),
  3312. 'opinion' => $opinion,
  3313. 'status' => $status,
  3314. 'nextStaff' => $nextStaff
  3315. );
  3316. // print_r($verifyStaff);
  3317. // echo $nowStaff;die;
  3318. } else { // 进入下一个角色或者审批人
  3319. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  3320. //
  3321. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  3322. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3323. 'date' => date ( 'Y-m-d' ),
  3324. 'opinion' => $opinion,
  3325. 'status' => $status,
  3326. 'nextStaff' => $VS ['nextStaff'],
  3327. 'ROLE' => 1
  3328. );
  3329. // print_r($verifyStaff);
  3330. // die;
  3331. }
  3332. if ($status == 3) {
  3333. $verifyStaff ['final'] = $status;
  3334. $verifyStaff [$this->staff [0] ['sid']] = array (
  3335. 'date' => date ( 'Y-m-d' ),
  3336. 'opinion' => $opinion,
  3337. 'status' => $status
  3338. );
  3339. }
  3340. $vStaffString = json_encode ( $verifyStaff );
  3341. $receipt->verifyStaff = $vStaffString;
  3342. $receipt->nowStaff = $nowStaff;
  3343. $loanReceipt->nowStaff = $nowStaff;
  3344. $loanReceipt->verifyStaff = $vStaffString;
  3345. // die;
  3346. // }
  3347. // print_r($verifyStaff);
  3348. // die;
  3349. }
  3350. // print_r($verifyStaff);die;
  3351. }
  3352. // print_r($verifyDetail);
  3353. $roleKey = 0;
  3354. $roleId = 0;
  3355. $verifyDetailCopy = array ();
  3356. foreach ( $verifyDetail as $k => $v ) {
  3357. if ($v [1] == 'ROLE') {
  3358. $roleId = $v [0];
  3359. $roleVerify = json_decode ( $v [3], true );
  3360. $roleKey = $k;
  3361. $roleArray = array ();
  3362. foreach ( $roleVerify as $o => $p ) {
  3363. $staffID = explode ( '_', $p );
  3364. $exp = array (
  3365. 0 => $staffID [0],
  3366. 1 => $staffID [1]
  3367. );
  3368. array_push ( $roleArray, $exp );
  3369. }
  3370. $verifyDetailCopy [$v [0]] = $roleArray;
  3371. }
  3372. }
  3373. // print_r($verifyDetail);
  3374. foreach ( $verifyDetailCopy as $k => $v ) {
  3375. foreach ( $verifyDetail as $m => $n ) {
  3376. if ($n [0] == $k) {
  3377. array_splice ( $verifyDetail, $m, 1, $v );
  3378. }
  3379. }
  3380. }
  3381. // 审批日志
  3382. if (! isset ( $verifyStaff ['final'] )) {
  3383. Doo::loadModel ( "receiptLog" );
  3384. $receiptLog = new receiptLog ();
  3385. if (! empty ( $roleId )) {
  3386. Doo::loadModel ( "role" );
  3387. $role = new role ();
  3388. $roleInfo = $role->getOne ( array (
  3389. 'where' => 'rid=' . $roleId,
  3390. 'asArray' => true
  3391. ) );
  3392. $receiptLog->rolename = $roleInfo ['name'];
  3393. }
  3394. $receiptLog->username = $this->staff [0] ['username'];
  3395. $receiptLog->uid = $this->staff [0] ['sid'];
  3396. $receiptLog->date = date ( "Y-m-d" );
  3397. $receiptLog->opinion = $opinion;
  3398. $receiptLog->img = $this->staff [0] ['avatar'];
  3399. $receiptLog->status = 1;
  3400. $receiptLog->rid = $rid;
  3401. $receiptLog->insert ();
  3402. }
  3403. if (isset ( $verifyStaff ['final'] )) { // rDetail
  3404. $receipt->status = 3;
  3405. $receipt->verifyBreakup = $verifyString;
  3406. $receiptDetailObj->status = 3;
  3407. $receiptDetailObj->update ( array (
  3408. 'where' => 'rid=' . $rid
  3409. ) );
  3410. // 微信企业号通知
  3411. $this->setWXMsg ( $rid, 3 );
  3412. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  3413. $receipt->status = 6;
  3414. $receipt->pastDate = date ( "Y-m-d" );
  3415. $receipt->isBK = 1;
  3416. $loanReceipt->verifyBreakup = $verifyString;
  3417. $loanReceipt->status = 1;
  3418. $loanReceipt->pastDate = date ( "Y-m-d" );
  3419. $loanReceipt->amount = $receiptDetail ['amount'];
  3420. $loanReceipt->update ( array (
  3421. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  3422. ) );
  3423. // 微信企业号通知
  3424. $this->setWXMsg ( $rid, 1 );
  3425. }
  3426. $receipt->amount = $amount;
  3427. $receipt->update ( array (
  3428. 'where' => ' rid = ' . $rid
  3429. ) );
  3430. return "/approvalExpenses/pendApproval";
  3431. }
  3432. }
  3433. function ajaxExamineExe() {
  3434. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3435. Doo::loadModel ( 'receipt' );
  3436. $receipt = new receipt ();
  3437. Doo::loadClass ( 'XDeode' );
  3438. $XDeode = new XDeode ( 5 );
  3439. if (! empty ( $rid )) {
  3440. $rLRes = $receipt->find ( array (
  3441. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  3442. 'asArray' => true
  3443. ) );
  3444. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  3445. echo json_encode ( array (
  3446. 'status' => 1,
  3447. 'receipt' => $rLRes [0]
  3448. ) );
  3449. die ();
  3450. }
  3451. echo json_encode ( array (
  3452. 'status' => 0,
  3453. 'receipt' => array ()
  3454. ) );
  3455. die ();
  3456. }
  3457. function implement() {
  3458. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3459. Doo::loadClass ( 'XDeode' );
  3460. $XDeode = new XDeode ( 5 );
  3461. Doo::loadModel ( 'receipt' );
  3462. $receipt = new receipt ();
  3463. Doo::loadModel ( 'L_category' );
  3464. $Lcategory = new L_category ();
  3465. Doo::loadModel ( 'verify' );
  3466. $verify = new verify ();
  3467. Doo::loadModel ( 'staff' );
  3468. $staff = new staff ();
  3469. Doo::loadModel ( "execute" );
  3470. $execute = new execute ();
  3471. $rid = $XDeode->decode ( $rid );
  3472. $receiptList = $receipt->find ( array (
  3473. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  3474. 'desc' => 'rid',
  3475. 'asArray' => true
  3476. ) );
  3477. Doo::loadModel ( 'loanReceipt' );
  3478. $loanReceipt = new loanReceipt ();
  3479. // print_r($receiptList);
  3480. $loanList = array ();
  3481. if (! isset ( $receiptList ))
  3482. $loanList = $loanReceipt->find ( array (
  3483. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3484. 'desc' => 'rid',
  3485. 'asArray' => true
  3486. ) );
  3487. $Locate = 0;
  3488. $roleId = 0;
  3489. $button = 0;
  3490. foreach ( $loanList as $key => $value ) {
  3491. $loanList [$key] ['Locate'] = $Locate;
  3492. $Locate ++;
  3493. $loanList [$key] ['reviseDetail'] = array ();
  3494. if (! empty ( $value ['reviseDetail'] ))
  3495. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3496. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3497. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3498. $categoryDetil = $Lcategory->getOne ( array (
  3499. 'where' => 'cid=' . $value ['cid'],
  3500. 'asArray' => true
  3501. ) );
  3502. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3503. // 检测编辑状态
  3504. $verifyList = $verify->getOne ( array (
  3505. 'where' => 'vid=' . $value ['verify'],
  3506. 'asArray' => true
  3507. ) );
  3508. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3509. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3510. Doo::loadModel ( 'role' );
  3511. $role = new role ();
  3512. $flag = true;
  3513. $roleKey = 0;
  3514. $endStaffArray = array ();
  3515. $roleArrayCopy = array ();
  3516. foreach ( $verifyList as $k => $v ) {
  3517. // init verifyStaff
  3518. if ($v [1] == 'ROLE') {
  3519. if (! empty ( $verifyStaff )) {
  3520. $endStaffArray = end ( $verifyStaff );
  3521. // if ($v[0]==$endStaffArray['nextStaff']){
  3522. // $roleId=$v[0];
  3523. // }
  3524. }
  3525. $roleVerify = json_decode ( $v [3], true );
  3526. $roleKey = $k;
  3527. $roleArray = array ();
  3528. $rolename = $role->getOne ( array (
  3529. 'where' => 'rid=' . $v [0],
  3530. 'asArray' => true
  3531. ) );
  3532. foreach ( $roleVerify as $o => $p ) {
  3533. $staffID = explode ( '_', $p );
  3534. $staffInfo = $staff->getOne ( array (
  3535. 'where' => 'sid=' . $staffID [0],
  3536. 'asArray' => true
  3537. ) );
  3538. // print_r($staffID);
  3539. $exp = array (
  3540. 0 => $staffInfo ['sid'],
  3541. 1 => $staffID [1],
  3542. 2 => $staffInfo ['avatar'],
  3543. 'date' => '',
  3544. 'date' => '',
  3545. 'opinion' => '',
  3546. 'status' => '',
  3547. 'rolename' => $rolename ['name']
  3548. );
  3549. array_push ( $roleArray, $exp );
  3550. }
  3551. $roleArrayCopy [$v [0]] = $roleArray;
  3552. // $verifyList[$k]['roleArray']=$roleArray;
  3553. }
  3554. $verifyList [$k] ['date'] = "";
  3555. $verifyList [$k] ['opinion'] = "";
  3556. $verifyList [$k] ['status'] = "";
  3557. if (empty ( $verifyStaff )) {
  3558. $verifyList [$k] ['date'] = "";
  3559. $verifyList [$k] ['opinion'] = "";
  3560. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3561. $verifyList [$k] ['status'] = 4;
  3562. $flag = false;
  3563. }
  3564. } else {
  3565. foreach ( $verifyStaff as $m => $u ) {
  3566. if ($v [0] == $m) {
  3567. $verifyList [$k] ['date'] = $u ['date'];
  3568. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3569. $verifyList [$k] ['status'] = $u ['status'];
  3570. $flag = false;
  3571. break;
  3572. }
  3573. }
  3574. $endStaffArray = end ( $verifyStaff );
  3575. if (isset ( $endStaffArray ['ROLE'] )) {
  3576. } else {
  3577. // $endKey=key($verifyStaff);
  3578. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3579. // $button=4;
  3580. // $verifyList[$k]['status']=4;
  3581. // }
  3582. }
  3583. }
  3584. }
  3585. $rolename ['name'] = '';
  3586. if (! empty ( $roleId )) {
  3587. Doo::loadModel ( 'role' );
  3588. $role = new role ();
  3589. $rolename = $role->getOne ( array (
  3590. 'where' => 'rid=' . $roleId,
  3591. 'asArray' => true
  3592. ) );
  3593. }
  3594. if (! empty ( $verifyStaff ))
  3595. $endStaffArray = end ( $verifyStaff );
  3596. $KOP = false;
  3597. foreach ( $roleArrayCopy as $P => $A ) {
  3598. foreach ( $A as $MKI => $AVL ) {
  3599. if (! empty ( $verifyStaff )) {
  3600. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3601. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3602. $button = 4;
  3603. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3604. }
  3605. foreach ( $verifyStaff as $m => $u ) {
  3606. $AVLFK = $AVL [0] . '_R';
  3607. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3608. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3609. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3610. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3611. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3612. break;
  3613. }
  3614. }
  3615. } else {
  3616. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3617. $button = 4;
  3618. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3619. }
  3620. }
  3621. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3622. $KOP = true;
  3623. }
  3624. }
  3625. foreach ( $roleArrayCopy as $k => $v ) {
  3626. foreach ( $verifyList as $m => $n ) {
  3627. if ($n [0] == $k) {
  3628. array_splice ( $verifyList, $m, 1, $v );
  3629. }
  3630. }
  3631. }
  3632. $loanList [$key] ['verifyList'] = $verifyList;
  3633. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3634. 'where' => 'sid=' . $value ['staff'],
  3635. 'asArray' => true
  3636. ) );
  3637. }
  3638. $data ['loanList'] = $loanList;
  3639. $Locate = 0;
  3640. $roleId = 0;
  3641. $button = 0;
  3642. foreach ( $receiptList as $key => $value ) {
  3643. $button2 = 0;
  3644. $receiptList [$key] ['Locate'] = $Locate;
  3645. $Locate ++;
  3646. $receiptList [$key] ['reviseDetail'] = array ();
  3647. if (! empty ( $value ['reviseDetail'] ))
  3648. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3649. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3650. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3651. $categoryDetil = $Lcategory->getOne ( array (
  3652. 'where' => 'cid=' . $value ['cid'],
  3653. 'asArray' => true
  3654. ) );
  3655. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3656. $executeList = json_decode ( $value ['executeCopy'], true );
  3657. $executeStaff = array ();
  3658. if (! empty ( $value ['executeStaff'] ))
  3659. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3660. if (isset ( $executeList )) {
  3661. foreach ( $executeList as $op => $lo ) {
  3662. $executeList [$op] ['date'] = "";
  3663. $executeList [$op] ['opinion'] = "";
  3664. $executeList [$op] ['status'] = "";
  3665. foreach ( $executeStaff as $m => $u ) {
  3666. if ($lo [0] == $m) {
  3667. $executeList [$op] ['date'] = $u ['date'];
  3668. $executeList [$op] ['opinion'] = $u ['opinion'];
  3669. $executeList [$op] ['status'] = $u ['status'];
  3670. break;
  3671. }
  3672. }
  3673. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  3674. $button2 = 1;
  3675. $executeList [$op] ['status'] = 4;
  3676. }
  3677. }
  3678. }
  3679. // 检测编辑状态
  3680. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3681. $verifyList ['staff'] = $value ['verifyBreakup'];
  3682. } else
  3683. $verifyList = $verify->getOne ( array (
  3684. 'where' => 'vid=' . $value ['verify'],
  3685. 'asArray' => true
  3686. ) );
  3687. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3688. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3689. Doo::loadModel ( 'role' );
  3690. $role = new role ();
  3691. if ($verifyList == NULL)
  3692. $verifyList = array ();
  3693. $flag = true;
  3694. $roleKey = 0;
  3695. $endStaffArray = array ();
  3696. $roleArrayCopy = array ();
  3697. foreach ( $verifyList as $k => $v ) {
  3698. // init verifyStaff
  3699. if ($v [1] == 'ROLE') {
  3700. if (! empty ( $verifyStaff )) {
  3701. $endStaffArray = end ( $verifyStaff );
  3702. // if ($v[0]==$endStaffArray['nextStaff']){
  3703. // $roleId=$v[0];
  3704. // }
  3705. }
  3706. $roleVerify = json_decode ( $v [3], true );
  3707. $roleKey = $k;
  3708. $roleArray = array ();
  3709. $rolename = $role->getOne ( array (
  3710. 'where' => 'rid=' . $v [0],
  3711. 'asArray' => true
  3712. ) );
  3713. foreach ( $roleVerify as $o => $p ) {
  3714. $staffID = explode ( '_', $p );
  3715. $staffInfo = $staff->getOne ( array (
  3716. 'where' => 'sid=' . $staffID [0],
  3717. 'asArray' => true
  3718. ) );
  3719. // print_r($staffID);
  3720. $exp = array (
  3721. 0 => $staffInfo ['sid'],
  3722. 1 => $staffID [1],
  3723. 2 => $staffInfo ['avatar'],
  3724. 'date' => '',
  3725. 'date' => '',
  3726. 'opinion' => '',
  3727. 'status' => '',
  3728. 'rolename' => $rolename ['name']
  3729. );
  3730. array_push ( $roleArray, $exp );
  3731. }
  3732. $roleArrayCopy [$v [0]] = $roleArray;
  3733. // $verifyList[$k]['roleArray']=$roleArray;
  3734. }
  3735. $verifyList [$k] ['date'] = "";
  3736. $verifyList [$k] ['opinion'] = "";
  3737. $verifyList [$k] ['status'] = "";
  3738. if (empty ( $verifyStaff )) {
  3739. $verifyList [$k] ['date'] = "";
  3740. $verifyList [$k] ['opinion'] = "";
  3741. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3742. $verifyList [$k] ['status'] = 4;
  3743. $flag = false;
  3744. }
  3745. } else {
  3746. foreach ( $verifyStaff as $m => $u ) {
  3747. if ($v [0] == $m) {
  3748. $verifyList [$k] ['date'] = $u ['date'];
  3749. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3750. $verifyList [$k] ['status'] = $u ['status'];
  3751. $flag = false;
  3752. break;
  3753. }
  3754. }
  3755. $endStaffArray = end ( $verifyStaff );
  3756. if (isset ( $endStaffArray ['ROLE'] )) {
  3757. } else {
  3758. // $endKey=key($verifyStaff);
  3759. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3760. // $button=4;
  3761. // $verifyList[$k]['status']=4;
  3762. // }
  3763. }
  3764. }
  3765. }
  3766. $rolename ['name'] = '';
  3767. if (! empty ( $roleId )) {
  3768. Doo::loadModel ( 'role' );
  3769. $role = new role ();
  3770. $rolename = $role->getOne ( array (
  3771. 'where' => 'rid=' . $roleId,
  3772. 'asArray' => true
  3773. ) );
  3774. }
  3775. if (! empty ( $verifyStaff ))
  3776. $endStaffArray = end ( $verifyStaff );
  3777. $KOP = false;
  3778. foreach ( $roleArrayCopy as $P => $A ) {
  3779. foreach ( $A as $MKI => $AVL ) {
  3780. if (! empty ( $verifyStaff )) {
  3781. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3782. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3783. $button = 4;
  3784. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3785. }
  3786. foreach ( $verifyStaff as $m => $u ) {
  3787. $AVLFK = $AVL [0] . '_R';
  3788. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3789. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3790. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3791. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3792. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3793. break;
  3794. }
  3795. }
  3796. } else {
  3797. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3798. $button = 4;
  3799. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3800. }
  3801. }
  3802. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3803. $KOP = true;
  3804. }
  3805. }
  3806. foreach ( $roleArrayCopy as $k => $v ) {
  3807. foreach ( $verifyList as $m => $n ) {
  3808. if ($n [0] == $k) {
  3809. array_splice ( $verifyList, $m, 1, $v );
  3810. }
  3811. }
  3812. }
  3813. $receiptList [$key] ['verifyList'] = $verifyList;
  3814. $receiptList [$key] ['executeList'] = $executeList;
  3815. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3816. 'where' => 'sid=' . $value ['staff'],
  3817. 'asArray' => true
  3818. ) );
  3819. $receiptList [$key] ['button2'] = $button2;
  3820. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3821. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3822. $relust = $value ['sum'] - $value ['loanSum'];
  3823. $receiptList [$key] ['relust'] = $relust;
  3824. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  3825. }
  3826. // print_r($receiptList[$key]['executeList']);
  3827. $data ['receiptList'] = $receiptList;
  3828. $data ['memu'] = "receipt";
  3829. $data ['staff'] = $this->staff;
  3830. $data ['receiptMemu'] = 'implement';
  3831. $data ['verifyId'] = $this->verifyId;
  3832. $data ['executeId'] = $this->executeId;
  3833. $this->render ( "/admin/implement", $data );
  3834. }
  3835. function implementDo() {
  3836. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3837. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3838. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  3839. if (! empty ( $rid ) && $amount != '') {
  3840. Doo::loadModel ( 'receipt' );
  3841. $receipt = new receipt ();
  3842. Doo::loadClass ( 'XDeode' );
  3843. $XDeode = new XDeode ( 5 );
  3844. $rinfo = $receipt->getOne ( array (
  3845. 'where' => 'rid=' . $rid,
  3846. 'asArray' => true
  3847. ) );
  3848. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  3849. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  3850. if (empty ( $executeStaff )) {
  3851. $executeStaff = array (
  3852. $this->staff [0] ['sid'] => array (
  3853. 'date' => date ( 'Y-m-d' ),
  3854. 'opinion' => $implementOpinions,
  3855. 'status' => 1
  3856. )
  3857. );
  3858. } else {
  3859. $executeStaff [$this->staff [0] ['sid']] = array (
  3860. 'date' => date ( 'Y-m-d' ),
  3861. 'opinion' => $implementOpinions,
  3862. 'status' => 1
  3863. );
  3864. }
  3865. if (count ( $executeStaff ) == count ( $executeCopy )) {
  3866. $receipt->executeStaff = json_encode ( $executeStaff );
  3867. $receipt->status = 8;
  3868. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  3869. $receipt->status = 9;
  3870. if($rinfo ['status']==6){
  3871. $receipt->loanDate=date ( "Y-m-d" );
  3872. }
  3873. $receipt->executeDate = date ( "Y-m-d" );
  3874. } else {
  3875. $receipt->executeStaff = json_encode ( $executeStaff );
  3876. }
  3877. $receipt->amount = $amount;
  3878. $receipt->update ( array (
  3879. 'where' => 'rid=' . $rid
  3880. ) );
  3881. }
  3882. $ridKey = $XDeode->encode ( $rid );
  3883. return "/hisImplement";
  3884. //return "/implement/" . $ridKey . ".html";
  3885. }
  3886. function receiptburEdi() {
  3887. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3888. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  3889. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  3890. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  3891. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3892. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  3893. if (empty ( $status ))
  3894. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  3895. $vidList = array ();
  3896. $button = 0;
  3897. Doo::loadModel ( 'verify' );
  3898. Doo::loadModel ( 'receipt' );
  3899. Doo::loadModel ( 'staff' );
  3900. $staff = new staff ();
  3901. $receipt = new receipt ();
  3902. $verify = new verify ();
  3903. Doo::loadModel ( 'L_category' );
  3904. $Lcategory = new L_category ();
  3905. Doo::loadModel ( 'enclosur' );
  3906. $enclosur = new enclosur ();
  3907. Doo::loadModel ( 'loanReceipt' );
  3908. $loanReceipt = new loanReceipt ();
  3909. // user verify ID
  3910. $verifyDetail = $verify->find ( array (
  3911. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  3912. 'asArray' => true
  3913. ) );
  3914. foreach ( $verifyDetail as $key => $value ) {
  3915. array_push ( $vidList, $value ['vid'] );
  3916. }
  3917. $vid = implode ( ",", $vidList );
  3918. if (empty ( $verifyDetail ))
  3919. $vid = 0;
  3920. $categoryList = $Lcategory->find ( array (
  3921. 'asArray' => true
  3922. ) );
  3923. $staffList = $staff->find ( array (
  3924. 'where' => 'cid=' . $cid,
  3925. 'asArray' => true
  3926. ) );
  3927. $ap = "";
  3928. if ($status == 4) {
  3929. $ap = 4;
  3930. $status = 2;
  3931. }
  3932. // get Receipt By verifyID status 2
  3933. $receiptList = $receipt->find ( array (
  3934. 'where' => 'rid =' . $rid.' and status=2',
  3935. 'desc' => 'rid',
  3936. 'asArray' => true
  3937. ) );
  3938. if(empty($receiptList)){
  3939. die ( 'illegal request' );
  3940. }
  3941. $loanList = $loanReceipt->find ( array (
  3942. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3943. 'desc' => 'rid',
  3944. 'asArray' => true
  3945. ) );
  3946. $Locate = 0;
  3947. $roleId = 0;
  3948. $button = 0;
  3949. foreach ( $loanList as $key => $value ) {
  3950. $loanList [$key] ['Locate'] = $Locate;
  3951. $Locate ++;
  3952. $loanList [$key] ['reviseDetail'] = array ();
  3953. if (! empty ( $value ['reviseDetail'] ))
  3954. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3955. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3956. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3957. $categoryDetil = $Lcategory->getOne ( array (
  3958. 'where' => 'cid=' . $value ['cid'],
  3959. 'asArray' => true
  3960. ) );
  3961. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3962. // 检测编辑状态
  3963. $verifyList = $verify->getOne ( array (
  3964. 'where' => 'vid=' . $value ['verify'],
  3965. 'asArray' => true
  3966. ) );
  3967. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3968. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3969. Doo::loadModel ( 'role' );
  3970. $role = new role ();
  3971. $flag = true;
  3972. $roleKey = 0;
  3973. $endStaffArray = array ();
  3974. $roleArrayCopy = array ();
  3975. foreach ( $verifyList as $k => $v ) {
  3976. // init verifyStaff
  3977. if ($v [1] == 'ROLE') {
  3978. if (! empty ( $verifyStaff )) {
  3979. $endStaffArray = end ( $verifyStaff );
  3980. }
  3981. $roleVerify = json_decode ( $v [3], true );
  3982. $roleKey = $k;
  3983. $roleArray = array ();
  3984. $rolename = $role->getOne ( array (
  3985. 'where' => 'rid=' . $v [0],
  3986. 'asArray' => true
  3987. ) );
  3988. foreach ( $roleVerify as $o => $p ) {
  3989. $staffID = explode ( '_', $p );
  3990. $staffInfo = $staff->getOne ( array (
  3991. 'where' => 'sid=' . $staffID [0],
  3992. 'asArray' => true
  3993. ) );
  3994. // print_r($staffID);
  3995. $exp = array (
  3996. 0 => $staffInfo ['sid'],
  3997. 1 => $staffID [1],
  3998. 2 => $staffInfo ['avatar'],
  3999. 'date' => '',
  4000. 'date' => '',
  4001. 'opinion' => '',
  4002. 'status' => '',
  4003. 'rolename' => $rolename ['name']
  4004. );
  4005. array_push ( $roleArray, $exp );
  4006. }
  4007. $roleArrayCopy [$v [0]] = $roleArray;
  4008. // $verifyList[$k]['roleArray']=$roleArray;
  4009. }
  4010. $verifyList [$k] ['date'] = "";
  4011. $verifyList [$k] ['opinion'] = "";
  4012. $verifyList [$k] ['status'] = "";
  4013. if (empty ( $verifyStaff )) {
  4014. $verifyList [$k] ['date'] = "";
  4015. $verifyList [$k] ['opinion'] = "";
  4016. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4017. $verifyList [$k] ['status'] = 4;
  4018. $flag = false;
  4019. }
  4020. } else {
  4021. foreach ( $verifyStaff as $m => $u ) {
  4022. if ($v [0] == $m) {
  4023. $verifyList [$k] ['date'] = $u ['date'];
  4024. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4025. $verifyList [$k] ['status'] = $u ['status'];
  4026. $flag = false;
  4027. break;
  4028. }
  4029. }
  4030. $endStaffArray = end ( $verifyStaff );
  4031. if (isset ( $endStaffArray ['ROLE'] )) {
  4032. } else {
  4033. }
  4034. }
  4035. }
  4036. $rolename ['name'] = '';
  4037. if (! empty ( $roleId )) {
  4038. Doo::loadModel ( 'role' );
  4039. $role = new role ();
  4040. $rolename = $role->getOne ( array (
  4041. 'where' => 'rid=' . $roleId,
  4042. 'asArray' => true
  4043. ) );
  4044. }
  4045. if (! empty ( $verifyStaff ))
  4046. $endStaffArray = end ( $verifyStaff );
  4047. $KOP = false;
  4048. foreach ( $roleArrayCopy as $P => $A ) {
  4049. foreach ( $A as $MKI => $AVL ) {
  4050. if (! empty ( $verifyStaff )) {
  4051. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4052. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4053. $button = 4;
  4054. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4055. }
  4056. foreach ( $verifyStaff as $m => $u ) {
  4057. $AVLFK = $AVL [0] . '_R';
  4058. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4059. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4060. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4061. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4062. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4063. break;
  4064. }
  4065. }
  4066. } else {
  4067. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4068. $button = 4;
  4069. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4070. }
  4071. }
  4072. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4073. $KOP = true;
  4074. }
  4075. }
  4076. foreach ( $roleArrayCopy as $k => $v ) {
  4077. foreach ( $verifyList as $m => $n ) {
  4078. if ($n [0] == $k) {
  4079. array_splice ( $verifyList, $m, 1, $v );
  4080. }
  4081. }
  4082. }
  4083. $loanList [$key] ['verifyList'] = $verifyList;
  4084. }
  4085. $htmlLoan = '';
  4086. if (isset ( $loanList [0] )) {
  4087. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  4088. if ($value ['status'] == 1)
  4089. $htmlLoan .= '<li class="done" >';
  4090. elseif ($value ['status'] == 3)
  4091. $htmlLoan .= '<li class="undone" >';
  4092. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  4093. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  4094. if (isset ( $value ['rolename'] ))
  4095. $htmlLoan .= $value ['rolename'];
  4096. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  4097. }
  4098. $data ['loanDate'] = $loanList [0] ['date'];
  4099. }
  4100. $data ['htmlLoan'] = $htmlLoan;
  4101. $data['loanReceiptDate']=$loanList [0] ['date'];
  4102. //$data ['LoanReceipt']=$loanList[0];
  4103. // print_r($loanList);
  4104. $Locate = 0;
  4105. $roleId = 0;
  4106. $button = 0;
  4107. if ($ap == 4)
  4108. $status = 4;
  4109. foreach ( $receiptList as $key => $value ) {
  4110. $receiptList [$key] ['Locate'] = $Locate;
  4111. $Locate ++;
  4112. $receiptList [$key] ['reviseDetail'] = array ();
  4113. if (! empty ( $value ['reviseDetail'] ))
  4114. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4115. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4116. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4117. $categoryDetil = $Lcategory->getOne ( array (
  4118. 'where' => 'cid=' . $value ['cid'],
  4119. 'asArray' => true
  4120. ) );
  4121. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4122. // 检测编辑状态
  4123. $verifyList = $verify->getOne ( array (
  4124. 'where' => 'vid=' . $value ['verify'],
  4125. 'asArray' => true
  4126. ) );
  4127. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4128. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4129. Doo::loadModel ( 'role' );
  4130. $role = new role ();
  4131. // print_r($verifyList);
  4132. $flag = true;
  4133. $roleKey = 0;
  4134. $endStaffArray = array ();
  4135. $roleArrayCopy = array ();
  4136. foreach ( $verifyList as $k => $v ) {
  4137. // init verifyStaff
  4138. if ($v [1] == 'ROLE') {
  4139. if (! empty ( $verifyStaff )) {
  4140. $endStaffArray = end ( $verifyStaff );
  4141. if ($v [0] == $endStaffArray ['nextStaff']) {
  4142. $roleId = $v [0];
  4143. }
  4144. }
  4145. $roleVerify = json_decode ( $v [3], true );
  4146. $roleKey = $k;
  4147. $roleArray = array ();
  4148. $rolename = $role->getOne ( array (
  4149. 'where' => 'rid=' . $v [0],
  4150. 'asArray' => true
  4151. ) );
  4152. foreach ( $roleVerify as $o => $p ) {
  4153. $staffID = explode ( '_', $p );
  4154. $staffInfo = $staff->getOne ( array (
  4155. 'where' => 'sid=' . $staffID [0],
  4156. 'asArray' => true
  4157. ) );
  4158. // print_r($staffID);
  4159. $exp = array (
  4160. 0 => $staffInfo ['sid'],
  4161. 1 => $staffID [1],
  4162. 2 => $staffInfo ['avatar'],
  4163. 'date' => '',
  4164. 'date' => '',
  4165. 'opinion' => '',
  4166. 'status' => '',
  4167. 'rolename' => $rolename ['name']
  4168. );
  4169. array_push ( $roleArray, $exp );
  4170. }
  4171. $roleArrayCopy [$v [0]] = $roleArray;
  4172. // $verifyList[$k]['roleArray']=$roleArray;
  4173. }
  4174. // print_r($roleArray);
  4175. $verifyList [$k] ['date'] = "";
  4176. $verifyList [$k] ['opinion'] = "";
  4177. $verifyList [$k] ['status'] = "";
  4178. if (empty ( $verifyStaff )) {
  4179. $verifyList [$k] ['date'] = "";
  4180. $verifyList [$k] ['opinion'] = "";
  4181. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4182. $verifyList [$k] ['status'] = 4;
  4183. $button = 4;
  4184. $flag = false;
  4185. }
  4186. } else {
  4187. foreach ( $verifyStaff as $m => $u ) {
  4188. if ($v [0] == $m) {
  4189. $verifyList [$k] ['date'] = $u ['date'];
  4190. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4191. $verifyList [$k] ['status'] = $u ['status'];
  4192. $flag = false;
  4193. break;
  4194. }
  4195. }
  4196. $endStaffArray = end ( $verifyStaff );
  4197. if (isset ( $endStaffArray ['ROLE'] )) {
  4198. } else {
  4199. $endKey = key ( $verifyStaff );
  4200. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4201. $button = 4;
  4202. $verifyList [$k] ['status'] = 4;
  4203. }
  4204. }
  4205. }
  4206. }
  4207. $rolename ['name'] = '';
  4208. if (! empty ( $roleId )) {
  4209. Doo::loadModel ( 'role' );
  4210. $role = new role ();
  4211. $rolename = $role->getOne ( array (
  4212. 'where' => 'rid=' . $roleId,
  4213. 'asArray' => true
  4214. ) );
  4215. }
  4216. if (! empty ( $verifyStaff ))
  4217. $endStaffArray = end ( $verifyStaff );
  4218. $KOP = false;
  4219. foreach ( $roleArrayCopy as $P => $A ) {
  4220. foreach ( $A as $MKI => $AVL ) {
  4221. if (! empty ( $verifyStaff )) {
  4222. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4223. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4224. $button = 4;
  4225. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4226. }
  4227. foreach ( $verifyStaff as $m => $u ) {
  4228. $AVLFK = $AVL [0] . '_R';
  4229. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4230. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4231. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4232. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4233. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4234. break;
  4235. }
  4236. }
  4237. } else {
  4238. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4239. $button = 4;
  4240. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4241. }
  4242. }
  4243. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4244. $KOP = true;
  4245. }
  4246. }
  4247. foreach ( $roleArrayCopy as $k => $v ) {
  4248. foreach ( $verifyList as $m => $n ) {
  4249. if ($n [0] == $k) {
  4250. array_splice ( $verifyList, $m, 1, $v );
  4251. }
  4252. }
  4253. }
  4254. // print_r($verifyList);
  4255. $receiptList [$key] ['verifyList'] = $verifyList;
  4256. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4257. 'where' => 'sid=' . $value ['staff'],
  4258. 'asArray' => true
  4259. ) );
  4260. $receiptList [$key] ['button'] = $button;
  4261. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4262. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4263. $relust = $value ['sum'] - $value ['loanSum'];
  4264. $receiptList [$key] ['relust'] = $relust;
  4265. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4266. }
  4267. // print_r($receiptList);die;
  4268. // $data['verifyDetail']=$verifyDetail;
  4269. $mothHtml = "";
  4270. for($i = 1; $i <= 12; $i ++) {
  4271. if ($month == $i)
  4272. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4273. else
  4274. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4275. }
  4276. // 获取审批日志
  4277. Doo::loadModel ( 'receiptLog' );
  4278. $receiptLog = new receiptLog ();
  4279. $rlList = array ();
  4280. $rlInfo = $receiptLog->getOne ( array (
  4281. 'where' => 'rid=' . $rid . ' and status=4',
  4282. 'asArray' => true
  4283. ) );
  4284. $tijdate = $receiptLog->getOne ( array (
  4285. 'where' => 'rid=' . $rid . ' and status=2',
  4286. 'asc' => 'rlid',
  4287. 'asArray' => true
  4288. ) );
  4289. if (! empty ( $rlInfo )) {
  4290. $rlList = $receiptLog->find ( array (
  4291. 'where' => 'rid=' . $rid,
  4292. 'asc' => 'rlid',
  4293. 'asArray' => true
  4294. ) );
  4295. }
  4296. // echo $rid;
  4297. // print_r($receiptList);
  4298. $receiptList [0] ['rlList'] = $rlList;
  4299. // print_r($receiptList);
  4300. $enclosurList = $enclosur->find ( array (
  4301. 'where' => 'rid=' . $rid,
  4302. 'asArray' => true
  4303. ) );
  4304. $enclosurHtml = '';
  4305. foreach ( $enclosurList as $value ) {
  4306. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4307. }
  4308. $data ['enclosurHtml'] = $enclosurHtml;
  4309. $data ['rolename'] = $rolename ['name'];
  4310. $data ['mothHtml'] = $mothHtml;
  4311. //print_r($receiptList);
  4312. $data ['rid'] = $rid;
  4313. $data ['tijdate'] = $tijdate ['date'];
  4314. $data ['receiptList'] = $receiptList;
  4315. $data ['receiptApprovalCount'] = count ( $receiptList );
  4316. $data ['status'] = $status;
  4317. $data ['year'] = $year;
  4318. $data ['categoryList'] = $categoryList;
  4319. $data ['staffList'] = $staffList;
  4320. $data ['cid'] = $cid;
  4321. $data ['sid'] = $sid;
  4322. $data ['ap'] = $ap;
  4323. $data ['memu'] = "receipt";
  4324. $data ['staff'] = $this->staff;
  4325. $data ['receiptMemu'] = 'approvalExpenses';
  4326. $data ['verifyId'] = $this->verifyId;
  4327. $data ['executeId'] = $this->executeId;
  4328. $this->render ( "/admin/receiptburEdi", $data );
  4329. }
  4330. function hisImplement() {
  4331. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4332. if (empty ( $item ))
  4333. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "pendImplement";
  4334. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  4335. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4336. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  4337. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  4338. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  4339. Doo::loadModel ( 'receipt' );
  4340. $receipt = new receipt ();
  4341. Doo::loadModel ( 'L_category' );
  4342. $Lcategory = new L_category ();
  4343. Doo::loadModel ( 'verify' );
  4344. Doo::loadModel ( 'statistics' );
  4345. $statistics = new statistics ();
  4346. $verify = new verify ();
  4347. Doo::loadModel ( 'staff' );
  4348. $staff = new staff ();
  4349. Doo::loadClass ( 'XDeode' );
  4350. $XDeode = new XDeode ( 5 );
  4351. $condition = "";
  4352. if ($item == "expenses")
  4353. $condition = " and Rtype=1 ";
  4354. elseif ($item == "receipts")
  4355. $condition = " and Rtype=0 ";
  4356. elseif ($item == "remits")
  4357. $condition = " and Rtype=2 ";
  4358. elseif($item =="pendImplement"){
  4359. $condition = ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  4360. }
  4361. //'and (executeCopy like "%["' . $this->staff [0] ['sid'] . '"%" and executeStaff not like "%{"' . $this->staff [0] ['sid'] . '"%" )';
  4362. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  4363. $sopString = "";
  4364. if (empty($rdate))
  4365. $dateCondition = " and Year(date) =" . $year;
  4366. else
  4367. $dateCondition=" and date_format(date,'%Y-%m-%d')='".$rdate."' ";
  4368. if ($item == 'teipts') {
  4369. $statusCon = '(status=1 or status=6 )';
  4370. $dateCondition=" and date_format(pastDate,'%Y-%m-%d')='".$rdate."' ";
  4371. } elseif ($item == 'alerpts') {
  4372. $statusCon = '(status=8 or status=9 )';
  4373. if (empty($rdate))
  4374. $dateCondition = " and Year(date) =" . $year;
  4375. else
  4376. $dateCondition=" and date_format(executeDate,'%Y-%m-%d')='".$rdate."' ";
  4377. }
  4378. /*
  4379. if ($item == 'teipts') {
  4380. $statusCon = '(status=1 or status=6 )';
  4381. $dateCondition = " and Year(pastDate) =" . $year;
  4382. if ($moth != 'MONTH')
  4383. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth;
  4384. if ($day != 'DAY')
  4385. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth . " and day(pastDate)=" . $day;
  4386. } elseif ($item == 'alerpts') {
  4387. $statusCon = '(status=8 or status=9 )';
  4388. $dateCondition = " and Year(executeDate) =" . $year;
  4389. if ($moth != 'MONTH')
  4390. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  4391. if ($day != 'DAY')
  4392. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  4393. }
  4394. */
  4395. if ($sop != 'SOP')
  4396. $sopString = " and staff=" . $sop;
  4397. // $noPassSum=$receipt->receiptByYear($year,$this->staff[0]['sid']); and (status=1 or status=6)
  4398. $receiptList = $receipt->find ( array (
  4399. 'where' => $statusCon . $condition . $dateCondition . $sopString,
  4400. 'desc' => 'rid',
  4401. 'asArray' => true
  4402. ) );
  4403. // 员工筛选
  4404. $receiptList2 = $receipt->find ( array (
  4405. 'where' => $statusCon . $condition . $dateCondition,
  4406. 'desc' => 'rid',
  4407. 'asArray' => true
  4408. ) );
  4409. $sopStaff = array ();
  4410. foreach ( $receiptList2 as $key => $value ) {
  4411. $staffDetail = $staff->getOne ( array (
  4412. 'where' => 'sid=' . $value ['staff'],
  4413. 'asArray' => true
  4414. ) );
  4415. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  4416. }
  4417. $Locate = 0;
  4418. $roleId = 0;
  4419. $button = 0;
  4420. foreach ( $receiptList as $key => $value ) {
  4421. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4422. $receiptList [$key] ['Texe'] = 'false';
  4423. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  4424. $receiptList [$key] ['Texe'] = 'true';
  4425. }
  4426. $receiptList [$key] ['TRexe'] = 'true';
  4427. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  4428. $receiptList [$key] ['TRexe'] = 'false';
  4429. }
  4430. $receiptList [$key] ['Locate'] = $Locate;
  4431. $Locate ++;
  4432. $receiptList [$key] ['reviseDetail'] = array ();
  4433. if (! empty ( $value ['reviseDetail'] ))
  4434. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4435. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4436. $categoryDetil = $Lcategory->getOne ( array (
  4437. 'where' => 'cid=' . $value ['cid'],
  4438. 'asArray' => true
  4439. ) );
  4440. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4441. // 检测编辑状态
  4442. $verifyList = $verify->getOne ( array (
  4443. 'where' => 'vid=' . $value ['verify'],
  4444. 'asArray' => true
  4445. ) );
  4446. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4447. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4448. Doo::loadModel ( 'role' );
  4449. $role = new role ();
  4450. $flag = true;
  4451. $roleKey = 0;
  4452. $endStaffArray = array ();
  4453. $roleArrayCopy = array ();
  4454. foreach ( $verifyList as $k => $v ) {
  4455. // init verifyStaff
  4456. if ($v [1] == 'ROLE') {
  4457. if (! empty ( $verifyStaff )) {
  4458. $endStaffArray = end ( $verifyStaff );
  4459. }
  4460. $roleVerify = json_decode ( $v [3], true );
  4461. $roleKey = $k;
  4462. $roleArray = array ();
  4463. $rolename = $role->getOne ( array (
  4464. 'where' => 'rid=' . $v [0],
  4465. 'asArray' => true
  4466. ) );
  4467. foreach ( $roleVerify as $o => $p ) {
  4468. $staffID = explode ( '_', $p );
  4469. $staffInfo = $staff->getOne ( array (
  4470. 'where' => 'sid=' . $staffID [0],
  4471. 'asArray' => true
  4472. ) );
  4473. $exp = array (
  4474. 0 => $staffInfo ['sid'],
  4475. 1 => $staffID [1],
  4476. 2 => $staffInfo ['avatar'],
  4477. 'date' => '',
  4478. 'date' => '',
  4479. 'opinion' => '',
  4480. 'status' => '',
  4481. 'rolename' => $rolename ['name']
  4482. );
  4483. array_push ( $roleArray, $exp );
  4484. }
  4485. $roleArrayCopy [$v [0]] = $roleArray;
  4486. }
  4487. $verifyList [$k] ['date'] = "";
  4488. $verifyList [$k] ['opinion'] = "";
  4489. $verifyList [$k] ['status'] = "";
  4490. if (empty ( $verifyStaff )) {
  4491. $verifyList [$k] ['date'] = "";
  4492. $verifyList [$k] ['opinion'] = "";
  4493. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4494. $verifyList [$k] ['status'] = 4;
  4495. $flag = false;
  4496. }
  4497. } else {
  4498. foreach ( $verifyStaff as $m => $u ) {
  4499. if ($v [0] == $m) {
  4500. $verifyList [$k] ['date'] = $u ['date'];
  4501. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4502. $verifyList [$k] ['status'] = $u ['status'];
  4503. $flag = false;
  4504. break;
  4505. }
  4506. }
  4507. $endStaffArray = end ( $verifyStaff );
  4508. }
  4509. }
  4510. $rolename ['name'] = '';
  4511. if (! empty ( $roleId )) {
  4512. Doo::loadModel ( 'role' );
  4513. $role = new role ();
  4514. $rolename = $role->getOne ( array (
  4515. 'where' => 'rid=' . $roleId,
  4516. 'asArray' => true
  4517. ) );
  4518. }
  4519. if (! empty ( $verifyStaff ))
  4520. $endStaffArray = end ( $verifyStaff );
  4521. $KOP = false;
  4522. foreach ( $roleArrayCopy as $P => $A ) {
  4523. foreach ( $A as $MKI => $AVL ) {
  4524. if (! empty ( $verifyStaff )) {
  4525. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4526. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4527. $button = 4;
  4528. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4529. }
  4530. foreach ( $verifyStaff as $m => $u ) {
  4531. $AVLFK = $AVL [0] . '_R';
  4532. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4533. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4534. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4535. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4536. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4537. break;
  4538. }
  4539. }
  4540. } else {
  4541. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4542. $button = 4;
  4543. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4544. }
  4545. }
  4546. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4547. $KOP = true;
  4548. }
  4549. }
  4550. foreach ( $roleArrayCopy as $k => $v ) {
  4551. foreach ( $verifyList as $m => $n ) {
  4552. if ($n [0] == $k) {
  4553. array_splice ( $verifyList, $m, 1, $v );
  4554. }
  4555. }
  4556. }
  4557. $receiptList [$key] ['verifyList'] = $verifyList;
  4558. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4559. 'where' => 'sid=' . $value ['staff'],
  4560. 'asArray' => true
  4561. ) );
  4562. $receiptList [$key] ['button'] = $button;
  4563. }
  4564. // print_r($receiptList);
  4565. $mothHtml = "";
  4566. for($i = 1; $i <= 12; $i ++) {
  4567. if ($moth == $i)
  4568. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4569. else
  4570. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4571. }
  4572. $dayHtml = "";
  4573. if ($day != "DAY" || $moth != "MONTH") {
  4574. for($i = 1; $i <= 31; $i ++) {
  4575. if ($day == $i)
  4576. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  4577. else
  4578. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  4579. }
  4580. }
  4581. $sopHtml = "";
  4582. foreach ( $sopStaff as $key => $value ) {
  4583. if ($sop == $key)
  4584. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4585. else
  4586. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4587. }
  4588. $data['rdate']=$rdate;
  4589. $data ['sopHtml'] = $sopHtml;
  4590. $data ['dayHtml'] = $dayHtml;
  4591. $data ['mothHtml'] = $mothHtml;
  4592. $data ['receiptList'] = $receiptList;
  4593. $data ['memu'] = "receipt";
  4594. $data ['staff'] = $this->staff;
  4595. $data ['receiptMemu'] = 'implement';
  4596. $data ['verifyId'] = $this->verifyId;
  4597. $data ['executeId'] = $this->executeId;
  4598. $data ['item'] = $item;
  4599. $data ['year'] = $year;
  4600. $data ['moth'] = $moth;
  4601. $data ['day'] = $day;
  4602. $data ['sop'] = $sop;
  4603. $this->render ( "/admin/hisImplement", $data );
  4604. }
  4605. function ajaxExamine() {
  4606. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4607. Doo::loadModel ( 'receipt' );
  4608. $receipt = new receipt ();
  4609. if (! empty ( $rid )) {
  4610. $rLRes = $receipt->find ( array (
  4611. '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,
  4612. 'asArray' => true
  4613. ) );
  4614. echo json_encode ( array (
  4615. 'status' => 1,
  4616. 'receipt' => $rLRes [0]
  4617. ) );
  4618. die ();
  4619. }
  4620. echo json_encode ( array (
  4621. 'status' => 0,
  4622. 'receipt' => array ()
  4623. ) );
  4624. die ();
  4625. }
  4626. /*
  4627. * 废弃
  4628. */
  4629. function myReceipt() {
  4630. // all approval past withdraw
  4631. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4632. if (empty ( $item ))
  4633. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4634. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4635. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  4636. Doo::loadModel ( 'receipt' );
  4637. $receipt = new receipt ();
  4638. // pre-loaded
  4639. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4640. // have cache
  4641. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  4642. if (! empty ( $moth )) // yearPage
  4643. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  4644. $this->showCache ( $path );
  4645. }
  4646. Doo::loadModel ( 'L_category' );
  4647. $Lcategory = new L_category ();
  4648. Doo::loadModel ( 'verify' );
  4649. Doo::loadModel ( 'statistics' );
  4650. $statistics = new statistics ();
  4651. $verify = new verify ();
  4652. Doo::loadModel ( 'staff' );
  4653. $staff = new staff ();
  4654. $condition = " and status!=0 ";
  4655. if ($item == "approval")
  4656. $condition = " and status=2 ";
  4657. elseif ($item == "withdraw")
  4658. $condition = " and status=3 ";
  4659. elseif ($item == "past")
  4660. $condition = " and status=1 ";
  4661. elseif ($item == "whdw")
  4662. $condition = " and status=4 ";
  4663. $dateCondition = " and Year(date) =" . $year;
  4664. if (! empty ( $moth )) {
  4665. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  4666. $stList = $statistics->getOne ( array (
  4667. 'select' => 'rePrice ,agPrice',
  4668. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  4669. 'asArray' => true
  4670. ) );
  4671. } else
  4672. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  4673. if (empty ( $stList ))
  4674. $stList = array (
  4675. 'rePrice' => 0,
  4676. 'agPrice' => 0
  4677. );
  4678. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  4679. $data ['stList'] = array (
  4680. 'rePrice' => $stList ['rePrice'],
  4681. 'agPrice' => $stList ['agPrice'],
  4682. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  4683. );
  4684. $receiptList = $receipt->find ( array (
  4685. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  4686. 'desc' => 'rid',
  4687. 'asArray' => true
  4688. ) );
  4689. $Locate = 0;
  4690. $roleId = 0;
  4691. $button = 0;
  4692. foreach ( $receiptList as $key => $value ) {
  4693. $receiptList [$key] ['Locate'] = $Locate;
  4694. $Locate ++;
  4695. $receiptList [$key] ['reviseDetail'] = array ();
  4696. if (! empty ( $value ['reviseDetail'] ))
  4697. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4698. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4699. $categoryDetil = $Lcategory->getOne ( array (
  4700. 'where' => 'cid=' . $value ['cid'],
  4701. 'asArray' => true
  4702. ) );
  4703. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4704. // 检测编辑状态
  4705. $verifyList = $verify->getOne ( array (
  4706. 'where' => 'vid=' . $value ['verify'],
  4707. 'asArray' => true
  4708. ) );
  4709. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4710. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4711. Doo::loadModel ( 'role' );
  4712. $role = new role ();
  4713. $flag = true;
  4714. $roleKey = 0;
  4715. $endStaffArray = array ();
  4716. $roleArrayCopy = array ();
  4717. foreach ( $verifyList as $k => $v ) {
  4718. // init verifyStaff
  4719. if ($v [1] == 'ROLE') {
  4720. if (! empty ( $verifyStaff )) {
  4721. $endStaffArray = end ( $verifyStaff );
  4722. // if ($v[0]==$endStaffArray['nextStaff']){
  4723. // $roleId=$v[0];
  4724. // }
  4725. }
  4726. $roleVerify = json_decode ( $v [3], true );
  4727. $roleKey = $k;
  4728. $roleArray = array ();
  4729. $rolename = $role->getOne ( array (
  4730. 'where' => 'rid=' . $v [0],
  4731. 'asArray' => true
  4732. ) );
  4733. foreach ( $roleVerify as $o => $p ) {
  4734. $staffID = explode ( '_', $p );
  4735. $staffInfo = $staff->getOne ( array (
  4736. 'where' => 'sid=' . $staffID [0],
  4737. 'asArray' => true
  4738. ) );
  4739. // print_r($staffID);
  4740. $exp = array (
  4741. 0 => $staffInfo ['sid'],
  4742. 1 => $staffID [1],
  4743. 2 => $staffInfo ['avatar'],
  4744. 'date' => '',
  4745. 'date' => '',
  4746. 'opinion' => '',
  4747. 'status' => '',
  4748. 'rolename' => $rolename ['name']
  4749. );
  4750. array_push ( $roleArray, $exp );
  4751. }
  4752. $roleArrayCopy [$v [0]] = $roleArray;
  4753. // $verifyList[$k]['roleArray']=$roleArray;
  4754. }
  4755. $verifyList [$k] ['date'] = "";
  4756. $verifyList [$k] ['opinion'] = "";
  4757. $verifyList [$k] ['status'] = "";
  4758. if (empty ( $verifyStaff )) {
  4759. $verifyList [$k] ['date'] = "";
  4760. $verifyList [$k] ['opinion'] = "";
  4761. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4762. $verifyList [$k] ['status'] = 4;
  4763. $flag = false;
  4764. }
  4765. } else {
  4766. foreach ( $verifyStaff as $m => $u ) {
  4767. if ($v [0] == $m) {
  4768. $verifyList [$k] ['date'] = $u ['date'];
  4769. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4770. $verifyList [$k] ['status'] = $u ['status'];
  4771. $flag = false;
  4772. break;
  4773. }
  4774. }
  4775. $endStaffArray = end ( $verifyStaff );
  4776. if (isset ( $endStaffArray ['ROLE'] )) {
  4777. } else {
  4778. // $endKey=key($verifyStaff);
  4779. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4780. // $button=4;
  4781. // $verifyList[$k]['status']=4;
  4782. // }
  4783. }
  4784. }
  4785. }
  4786. $rolename ['name'] = '';
  4787. if (! empty ( $roleId )) {
  4788. Doo::loadModel ( 'role' );
  4789. $role = new role ();
  4790. $rolename = $role->getOne ( array (
  4791. 'where' => 'rid=' . $roleId,
  4792. 'asArray' => true
  4793. ) );
  4794. }
  4795. if (! empty ( $verifyStaff ))
  4796. $endStaffArray = end ( $verifyStaff );
  4797. $KOP = false;
  4798. foreach ( $roleArrayCopy as $P => $A ) {
  4799. foreach ( $A as $MKI => $AVL ) {
  4800. if (! empty ( $verifyStaff )) {
  4801. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4802. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4803. $button = 4;
  4804. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4805. }
  4806. foreach ( $verifyStaff as $m => $u ) {
  4807. $AVLFK = $AVL [0] . '_R';
  4808. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4809. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4810. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4811. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4812. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4813. break;
  4814. }
  4815. }
  4816. } else {
  4817. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4818. $button = 4;
  4819. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4820. }
  4821. }
  4822. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4823. $KOP = true;
  4824. }
  4825. }
  4826. foreach ( $roleArrayCopy as $k => $v ) {
  4827. foreach ( $verifyList as $m => $n ) {
  4828. if ($n [0] == $k) {
  4829. array_splice ( $verifyList, $m, 1, $v );
  4830. }
  4831. }
  4832. }
  4833. $receiptList [$key] ['verifyList'] = $verifyList;
  4834. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4835. 'where' => 'sid=' . $value ['staff'],
  4836. 'asArray' => true
  4837. ) );
  4838. $receiptList [$key] ['button'] = $button;
  4839. }
  4840. // print_r($receiptList);die;
  4841. $mothHtml = "";
  4842. for($i = 1; $i <= 12; $i ++) {
  4843. if ($moth == $i)
  4844. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4845. else
  4846. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4847. }
  4848. $data ['mothHtml'] = $mothHtml;
  4849. $data ['receiptList'] = $receiptList;
  4850. $data ['memu'] = "receipt";
  4851. $data ['staff'] = $this->staff;
  4852. $data ['receiptMemu'] = 'receipt';
  4853. $data ['verifyId'] = $this->verifyId;
  4854. $data ['executeId'] = $this->executeId;
  4855. $data ['item'] = $item;
  4856. $data ['year'] = $year;
  4857. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4858. // sufficient condition to generate cache
  4859. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  4860. $receiptList = $receipt->find ( array (
  4861. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  4862. 'asArray' => true
  4863. ) );
  4864. if (empty ( $receiptList )) { // generated files
  4865. ob_start ();
  4866. $this->render ( "/admin/saea_myList", $data );
  4867. $this->cacheFile ( $path );
  4868. die ();
  4869. // $content = ob_get_contents();
  4870. // $fp = fopen($path, "w");
  4871. // fwrite($fp, $content);
  4872. // fclose($fp);
  4873. }
  4874. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  4875. $receiptList = $receipt->find ( array (
  4876. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  4877. 'asArray' => true
  4878. ) );
  4879. if (empty ( $receiptList )) { // generated files
  4880. ob_start ();
  4881. $this->render ( "/admin/saea_myList", $data );
  4882. $this->cacheFile ( $path );
  4883. die ();
  4884. }
  4885. }
  4886. }
  4887. $this->render ( "/admin/saea_myList", $data );
  4888. }
  4889. function saeaCreate() {
  4890. Doo::loadModel ( 'accountItem' );
  4891. Doo::loadModel ( 'verify' );
  4892. Doo::loadModel ( 'receipt' );
  4893. Doo::loadModel ( 'L_category' );
  4894. $lCategory = new L_category ();
  4895. $receipt = new receipt ();
  4896. $verify = new verify ();
  4897. $accountItem = new accountItem ();
  4898. Doo::loadModel ( "role" );
  4899. $role = new role ();
  4900. $acItem = $accountItem->find ( array (
  4901. 'asArray' => true
  4902. ) );
  4903. $veList = $verify->find ( array (
  4904. 'asArray' => true
  4905. ) );
  4906. foreach ( $veList as $key => $value ) {
  4907. $v = json_decode ( $value ['staff'] );
  4908. $list = array ();
  4909. foreach ( $v as $n => $m ) {
  4910. if ($m ['1'] == 'ROLE') {
  4911. $roleInfo = $role->getOne ( array (
  4912. 'where' => 'rid=' . $m [0],
  4913. 'asArray' => true
  4914. ) );
  4915. $v [$n] [1] = $roleInfo ['name'];
  4916. array_push ( $list, $roleInfo ['name'] );
  4917. } else {
  4918. array_push ( $list, $v [$n] [1] );
  4919. }
  4920. }
  4921. $veList [$key] ['staff'] = implode ( '>', $list );
  4922. }
  4923. $data ['category'] = $lCategory->find ( array (
  4924. 'asArray' => true
  4925. ) );
  4926. $data ['veList'] = $veList;
  4927. $data ['acItem'] = $acItem;
  4928. $data ['memu'] = "receipt";
  4929. $data ['staff'] = $this->staff;
  4930. $data ['receiptMemu'] = 'saeaBorad';
  4931. $data ['verifyId'] = $this->verifyId;
  4932. $data ['executeId'] = $this->executeId;
  4933. $this->render ( "/admin/saea_create", $data );
  4934. }
  4935. function addReceipt() {
  4936. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  4937. $agency = $this->get_args ( 'agency' );
  4938. $travel = $this->get_args ( 'travel' );
  4939. $train = $this->get_args ( 'train' );
  4940. $other = $this->get_args ( 'other' );
  4941. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  4942. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  4943. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  4944. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  4945. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  4946. Doo::loadModel ( 'receipt' );
  4947. Doo::loadModel ( 'receiptDetail' );
  4948. Doo::loadModel ( 'accountItem' );
  4949. $accountItem = new accountItem ();
  4950. $receipt = new receipt ();
  4951. Doo::loadModel ( 'enclosur' );
  4952. Doo::loadModel ( 'execute' );
  4953. $execute = new execute ();
  4954. $executeDetail = $execute->getOne ( array (
  4955. 'where' => 'mold="报销单执行人"',
  4956. 'asArray' => true
  4957. ) );
  4958. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  4959. // if(!empty($receiptDetail))
  4960. // return "/referReceipt/".$receiptDetail['rid'];
  4961. $aItem = $accountItem->find ( array (
  4962. 'asArray' => true
  4963. ) );
  4964. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  4965. $ag = $tr = $ta = $ot = 0;
  4966. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  4967. foreach ( $aItem as $key => $value ) {
  4968. if ($value ['category'] == $this->AGENCY) {
  4969. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  4970. array_push ( $accountJson [$this->AGENCY], array (
  4971. 'aid' => $value ['aid'],
  4972. 'name' => $value ['name'],
  4973. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  4974. ) );
  4975. $sum += $agency [$ag];
  4976. $agencySum += $agency [$ag];
  4977. }
  4978. $ag ++;
  4979. }
  4980. if ($value ['category'] == $this->TRAVEL) {
  4981. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  4982. array_push ( $accountJson [$this->TRAVEL], array (
  4983. 'aid' => $value ['aid'],
  4984. 'name' => $value ['name'],
  4985. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  4986. ) );
  4987. $sum += $travel [$tr];
  4988. $travelSum += $travel [$tr];
  4989. }
  4990. $tr ++;
  4991. }
  4992. if ($value ['category'] == $this->TRAIN) {
  4993. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  4994. array_push ( $accountJson [$this->TRAIN], array (
  4995. 'aid' => $value ['aid'],
  4996. 'name' => $value ['name'],
  4997. 'price' => number_format ( $train [$ta], 2, '.', '' )
  4998. ) );
  4999. $sum += $train [$ta];
  5000. $trainSum += $train [$ta];
  5001. }
  5002. $ta ++;
  5003. }
  5004. if ($value ['category'] == $this->OTHER) {
  5005. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5006. array_push ( $accountJson [$this->OTHER], array (
  5007. 'aid' => $value ['aid'],
  5008. 'name' => $value ['name'],
  5009. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5010. ) );
  5011. $sum += $other [$ot];
  5012. $otherSum += $other [$ot];
  5013. }
  5014. $ot ++;
  5015. }
  5016. }
  5017. $accountJson ['cSum'] = array (
  5018. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5019. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5020. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5021. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5022. );
  5023. // 报销单
  5024. $receipt->accountItem = json_encode ( $accountJson );
  5025. $receipt->staff = $this->staff [0] ['sid'];
  5026. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5027. $receipt->date = date ( "Y-m-d" );
  5028. $receipt->cid = $cid;
  5029. $receipt->status = 5;
  5030. // 修改审批流程加入角色
  5031. $receipt->verify = $verify;
  5032. $receipt->executeCopy = $executeDetail ['staff'];
  5033. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  5034. $receipt->explanation = $explanation;
  5035. $rid = $receipt->insert ();
  5036. // 附件
  5037. if (! empty ( $enclosurName )) {
  5038. $enclosurArray = explode ( '-', $enclosurName );
  5039. foreach ( $enclosurArray as $value ) {
  5040. $enclosur = new enclosur ();
  5041. $enclosur->name = $value;
  5042. $enclosur->rid = $rid;
  5043. $enclosur->insert ();
  5044. }
  5045. // print_r($enclosurArray);die;
  5046. }
  5047. // 报销详情
  5048. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5049. $receiptDetail = new receiptDetail ();
  5050. $receiptDetail->staff = $this->staff [0] ['sid'];
  5051. $receiptDetail->item = $value ['name'];
  5052. $receiptDetail->itemCategory = $this->AGENCY;
  5053. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5054. $receiptDetail->date = date ( "Y-m-d" );
  5055. $receiptDetail->cid = $cid;
  5056. $receiptDetail->rid = $rid;
  5057. $receiptDetail->status = 4;
  5058. $receiptDetail->insert ();
  5059. }
  5060. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5061. $receiptDetail = new receiptDetail ();
  5062. $receiptDetail->staff = $this->staff [0] ['sid'];
  5063. $receiptDetail->item = $value ['name'];
  5064. $receiptDetail->itemCategory = $this->TRAVEL;
  5065. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5066. $receiptDetail->date = date ( "Y-m-d" );
  5067. $receiptDetail->cid = $cid;
  5068. $receiptDetail->rid = $rid;
  5069. $receiptDetail->status = 4;
  5070. $receiptDetail->insert ();
  5071. }
  5072. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5073. $receiptDetail = new receiptDetail ();
  5074. $receiptDetail->staff = $this->staff [0] ['sid'];
  5075. $receiptDetail->item = $value ['name'];
  5076. $receiptDetail->itemCategory = $this->TRAIN;
  5077. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5078. $receiptDetail->date = date ( "Y-m-d" );
  5079. $receiptDetail->cid = $cid;
  5080. $receiptDetail->rid = $rid;
  5081. $receiptDetail->status = 4;
  5082. $receiptDetail->insert ();
  5083. }
  5084. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5085. $receiptDetail = new receiptDetail ();
  5086. $receiptDetail->staff = $this->staff [0] ['sid'];
  5087. $receiptDetail->item = $value ['name'];
  5088. $receiptDetail->itemCategory = $this->OTHER;
  5089. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5090. $receiptDetail->date = date ( "Y-m-d" );
  5091. $receiptDetail->cid = $cid;
  5092. $receiptDetail->rid = $rid;
  5093. $receiptDetail->status = 4;
  5094. $receiptDetail->insert ();
  5095. }
  5096. return "/saeaBorad";
  5097. }else
  5098. die ( 'illegal request' );
  5099. }
  5100. function referReceipt() {
  5101. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  5102. Doo::loadModel ( 'receipt' );
  5103. Doo::loadModel ( 'verify' );
  5104. $verify = new verify ();
  5105. $receipt = new receipt ();
  5106. Doo::loadModel ( 'L_category' );
  5107. $lCategory = new L_category ();
  5108. Doo::loadModel ( "role" );
  5109. $role = new role ();
  5110. $receiptDetail = $receipt->find ( array (
  5111. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  5112. 'asArray' => true
  5113. ) );
  5114. if (empty ( $receiptDetail ))
  5115. return "/addReceipt";
  5116. foreach ( $receiptDetail as $key => $value ) {
  5117. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5118. $veList = $verify->getOne ( array (
  5119. 'where' => 'vid=' . $value ['verify'],
  5120. 'asArray' => true
  5121. ) );
  5122. $v = json_decode ( $veList ['staff'] );
  5123. array_push ( $v [0], $veList ['description'] );
  5124. foreach ( $v as $n => $m ) {
  5125. if ($m ['1'] == 'ROLE') {
  5126. $roleInfo = $role->getOne ( array (
  5127. 'where' => 'rid=' . $m [0],
  5128. 'asArray' => true
  5129. ) );
  5130. $v [$n] [1] = $roleInfo ['name'];
  5131. }
  5132. }
  5133. $receiptDetail [$key] ['staff'] = $v;
  5134. $category = $lCategory->getOne ( array (
  5135. 'where' => 'cid=' . $value ['cid'],
  5136. 'asArray' => true
  5137. ) );
  5138. $receiptDetail [$key] ['category'] = $category ['title'];
  5139. }
  5140. // print_r($receiptDetail);
  5141. $data ['receiptDetail'] = $receiptDetail;
  5142. $data ['memu'] = "receipt";
  5143. $data ['staff'] = $this->staff;
  5144. $data ['receiptMemu'] = 'saeaCreate';
  5145. $data ['verifyId'] = $this->verifyId;
  5146. $data ['executeId'] = $this->executeId;
  5147. $this->render ( "/admin/saea_confirm", $data );
  5148. }
  5149. function editReceipt() {
  5150. // edit status 4
  5151. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5152. // echo $rid;
  5153. Doo::loadModel ( 'accountItem' );
  5154. Doo::loadModel ( 'verify' );
  5155. Doo::loadModel ( 'receipt' );
  5156. $receipt = new receipt ();
  5157. $verify = new verify ();
  5158. $accountItem = new accountItem ();
  5159. Doo::loadModel ( 'L_category' );
  5160. $lCategory = new L_category ();
  5161. Doo::loadModel ( "role" );
  5162. $role = new role ();
  5163. $receiptDetail = $receipt->getOne ( array (
  5164. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  5165. 'asArray' => true
  5166. ) );
  5167. if (empty ( $receiptDetail ))
  5168. return "/saeaCreate";
  5169. $acItem = $accountItem->find ( array (
  5170. 'asArray' => true
  5171. ) );
  5172. $veList = $verify->find ( array (
  5173. 'asArray' => true
  5174. ) );
  5175. foreach ( $veList as $key => $value ) {
  5176. $v = json_decode ( $value ['staff'] );
  5177. $list = array ();
  5178. foreach ( $v as $n => $m ) {
  5179. if ($m ['1'] == 'ROLE') {
  5180. $roleInfo = $role->getOne ( array (
  5181. 'where' => 'rid=' . $m [0],
  5182. 'asArray' => true
  5183. ) );
  5184. $v [$n] [1] = $roleInfo ['name'];
  5185. array_push ( $list, $roleInfo ['name'] );
  5186. } else {
  5187. array_push ( $list, $v [$n] [1] );
  5188. }
  5189. }
  5190. $veList [$key] ['staff'] = implode ( '>', $list );
  5191. }
  5192. // 配置编辑信息
  5193. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  5194. foreach ( $acItem as $key => $value ) {
  5195. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  5196. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  5197. $acItem [$key] ['price'] = $v ['price'];
  5198. }
  5199. }
  5200. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  5201. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  5202. $acItem [$key] ['price'] = $v ['price'];
  5203. }
  5204. }
  5205. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  5206. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  5207. $acItem [$key] ['price'] = $v ['price'];
  5208. }
  5209. }
  5210. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  5211. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  5212. $acItem [$key] ['price'] = $v ['price'];
  5213. }
  5214. }
  5215. }
  5216. $data ['category'] = $lCategory->find ( array (
  5217. 'asArray' => true
  5218. ) );
  5219. $data ['cSum'] = $accountItemList ['cSum'];
  5220. $data ['sum'] = $receiptDetail ['sum'];
  5221. $data ['receiptDetail'] = $receiptDetail;
  5222. $data ['veList'] = $veList;
  5223. $data ['acItem'] = $acItem;
  5224. $data ['memu'] = "receipt";
  5225. $data ['staff'] = $this->staff;
  5226. $data ['receiptMemu'] = 'saeaBorad';
  5227. $data ['verify'] = $receiptDetail ['verify'];
  5228. $data ['verifyId'] = $this->verifyId;
  5229. $data ['executeId'] = $this->executeId;
  5230. $data ['rid'] = $rid;
  5231. $this->render ( "/admin/saea_edit", $data );
  5232. }
  5233. function updateReceipt() {
  5234. $agency = $this->get_args ( 'agency' );
  5235. $travel = $this->get_args ( 'travel' );
  5236. $train = $this->get_args ( 'train' );
  5237. $other = $this->get_args ( 'other' );
  5238. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5239. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5240. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5241. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5242. if (! empty ( $explanation )) {
  5243. Doo::loadModel ( 'receipt' );
  5244. Doo::loadModel ( 'receiptDetail' );
  5245. Doo::loadModel ( 'accountItem' );
  5246. $accountItem = new accountItem ();
  5247. $receipt = new receipt ();
  5248. Doo::loadModel ( 'execute' );
  5249. $execute = new execute ();
  5250. $receiptDetail = $receipt->getOne ( array (
  5251. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  5252. 'asArray' => true
  5253. ) );
  5254. if (empty ( $receiptDetail ))
  5255. return "/saeaBorad";
  5256. if ($receiptDetail ['Rtype'] == 1)
  5257. $executeDetail = $execute->getOne ( array (
  5258. 'where' => 'mold="借款费用执行人"',
  5259. 'asArray' => true
  5260. ) );
  5261. else
  5262. $executeDetail = $execute->getOne ( array (
  5263. 'where' => 'mold="报销单执行人"',
  5264. 'asArray' => true
  5265. ) );
  5266. $aItem = $accountItem->find ( array (
  5267. 'asArray' => true
  5268. ) );
  5269. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5270. $ag = $tr = $ta = $ot = 0;
  5271. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5272. foreach ( $aItem as $key => $value ) {
  5273. if ($value ['category'] == $this->AGENCY) {
  5274. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5275. array_push ( $accountJson [$this->AGENCY], array (
  5276. 'aid' => $value ['aid'],
  5277. 'name' => $value ['name'],
  5278. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5279. ) );
  5280. $sum += $agency [$ag];
  5281. $agencySum += $agency [$ag];
  5282. }
  5283. $ag ++;
  5284. }
  5285. if ($value ['category'] == $this->TRAVEL) {
  5286. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5287. array_push ( $accountJson [$this->TRAVEL], array (
  5288. 'aid' => $value ['aid'],
  5289. 'name' => $value ['name'],
  5290. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5291. ) );
  5292. $sum += $travel [$tr];
  5293. $travelSum += $travel [$tr];
  5294. }
  5295. $tr ++;
  5296. }
  5297. if ($value ['category'] == $this->TRAIN) {
  5298. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5299. array_push ( $accountJson [$this->TRAIN], array (
  5300. 'aid' => $value ['aid'],
  5301. 'name' => $value ['name'],
  5302. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5303. ) );
  5304. $sum += $train [$ta];
  5305. $trainSum += $train [$ta];
  5306. }
  5307. $ta ++;
  5308. }
  5309. if ($value ['category'] == $this->OTHER) {
  5310. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5311. array_push ( $accountJson [$this->OTHER], array (
  5312. 'aid' => $value ['aid'],
  5313. 'name' => $value ['name'],
  5314. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5315. ) );
  5316. $sum += $other [$ot];
  5317. $otherSum += $other [$ot];
  5318. }
  5319. $ot ++;
  5320. }
  5321. }
  5322. $accountJson ['cSum'] = array (
  5323. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5324. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5325. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5326. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5327. );
  5328. // 报销单
  5329. $rid = $receipt->rid = $receiptDetail ['rid'];
  5330. $receipt->accountItem = json_encode ( $accountJson );
  5331. $receipt->staff = $this->staff [0] ['sid'];
  5332. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5333. $receipt->date = date ( "Y-m-d" );
  5334. $receipt->cid = $cid;
  5335. if (($receiptDetail ['status'] != 4)) {
  5336. if ($receiptDetail ['Rtype'] == 1)
  5337. $receipt->status = 7;
  5338. else
  5339. $receipt->status = 5;
  5340. }
  5341. if ($receiptDetail != 4 && ! empty ( $verify ))
  5342. $receipt->verify = $verify;
  5343. $receipt->executeCopy = $executeDetail ['staff'];
  5344. $receipt->explanation = $explanation;
  5345. $receipt->update ();
  5346. $receiptDetail = new receiptDetail ();
  5347. $receiptDetail->delete ( array (
  5348. 'where' => 'rid=' . $rid
  5349. ) );
  5350. // 报销详情
  5351. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5352. $receiptDetail = new receiptDetail ();
  5353. $receiptDetail->staff = $this->staff [0] ['sid'];
  5354. $receiptDetail->item = $value ['name'];
  5355. $receiptDetail->itemCategory = $this->AGENCY;
  5356. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5357. $receiptDetail->date = date ( "Y-m-d" );
  5358. $receiptDetail->cid = $cid;
  5359. $receiptDetail->rid = $rid;
  5360. $receiptDetail->status = 4;
  5361. $receiptDetail->insert ();
  5362. }
  5363. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5364. $receiptDetail = new receiptDetail ();
  5365. $receiptDetail->staff = $this->staff [0] ['sid'];
  5366. $receiptDetail->item = $value ['name'];
  5367. $receiptDetail->itemCategory = $this->TRAVEL;
  5368. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5369. $receiptDetail->date = date ( "Y-m-d" );
  5370. $receiptDetail->cid = $cid;
  5371. $receiptDetail->rid = $rid;
  5372. $receiptDetail->status = 4;
  5373. $receiptDetail->insert ();
  5374. }
  5375. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5376. $receiptDetail = new receiptDetail ();
  5377. $receiptDetail->staff = $this->staff [0] ['sid'];
  5378. $receiptDetail->item = $value ['name'];
  5379. $receiptDetail->itemCategory = $this->TRAIN;
  5380. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5381. $receiptDetail->date = date ( "Y-m-d" );
  5382. $receiptDetail->cid = $cid;
  5383. $receiptDetail->rid = $rid;
  5384. $receiptDetail->status = 4;
  5385. $receiptDetail->insert ();
  5386. }
  5387. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5388. $receiptDetail = new receiptDetail ();
  5389. $receiptDetail->staff = $this->staff [0] ['sid'];
  5390. $receiptDetail->item = $value ['name'];
  5391. $receiptDetail->itemCategory = $this->OTHER;
  5392. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5393. $receiptDetail->date = date ( "Y-m-d" );
  5394. $receiptDetail->cid = $cid;
  5395. $receiptDetail->rid = $rid;
  5396. $receiptDetail->status = 4;
  5397. $receiptDetail->insert ();
  5398. }
  5399. // return "/referReceipt/".$rid;
  5400. }
  5401. return "/saeaBorad";
  5402. }
  5403. function approvedReceipt() {
  5404. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5405. Doo::loadModel ( 'receipt' );
  5406. Doo::loadModel ( 'receiptDetail' );
  5407. $receipt = new receipt ();
  5408. $receiptDetail = new receiptDetail ();
  5409. Doo::loadModel ( 'statistics' );
  5410. Doo::loadModel ( 'itemStatistics' );
  5411. $statistics = new statistics ();
  5412. $itemStatistics = new itemStatistics ();
  5413. Doo::loadModel ( "verify" );
  5414. $verify = new verify ();
  5415. // 审批状态的判定
  5416. $receiptDetailList = $receipt->getOne ( array (
  5417. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  5418. 'asArray' => true
  5419. ) );
  5420. if (empty ( $receiptDetailList ))
  5421. return "/saeaBorad";
  5422. $verifyDetail = $verify->getOne ( array (
  5423. 'where' => ' vid =' . $receiptDetailList ['verify'],
  5424. 'asArray' => true
  5425. ) );
  5426. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5427. if (empty ( $receiptDetailList ['nowStaff'] )) {
  5428. $nowStaff = "";
  5429. $nowStaffList = array ();
  5430. if ($verifyDetail [0] [1] == 'ROLE') {
  5431. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5432. foreach ( $vStaffString as $key => $value ) {
  5433. $staffK = explode ( "_", $value );
  5434. array_push ( $nowStaffList, $staffK [0] );
  5435. }
  5436. $nowStaff = implode ( ',', $nowStaffList );
  5437. } else {
  5438. $nowStaff = $verifyDetail [0] [0];
  5439. }
  5440. $receipt->nowStaff = $nowStaff;
  5441. }
  5442. // echo $nowStaff;
  5443. // print_r($verifyDetail);die;
  5444. $receipt->rid = $receiptDetailList ['rid'];
  5445. $receipt->date = date ( "Y-m-d" );
  5446. $receipt->status = 2;
  5447. $receipt->update ();
  5448. $receiptDetail->status = 2;
  5449. $receiptDetail->update ( array (
  5450. 'where' => 'rid=' . $receiptDetailList ['rid']
  5451. ) );
  5452. Doo::loadModel ( "receiptLog" );
  5453. $receiptLog = new receiptLog ();
  5454. Doo::loadModel ( "verify" );
  5455. $verify = new verify ();
  5456. $receiptInfo = $receipt->getOne ( array (
  5457. 'where' => 'rid=' . $rid,
  5458. 'asArray' => true
  5459. ) );
  5460. $vr = $verify->getOne ( array (
  5461. 'where' => 'vid=' . $receiptInfo ['verify'],
  5462. 'asArray' => true
  5463. ) );
  5464. $jd = json_decode ( $vr ['staff'] );
  5465. $roleId = 0;
  5466. foreach ( $jd as $key => $value ) {
  5467. if ($value [1] == 'ROLE') {
  5468. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  5469. if ($pos !== false) {
  5470. $roleId = $value [0];
  5471. }
  5472. }
  5473. }
  5474. // 审批日志
  5475. // echo $roleId;die;
  5476. if (! empty ( $roleId )) {
  5477. Doo::loadModel ( "role" );
  5478. $role = new role ();
  5479. $roleInfo = $role->getOne ( array (
  5480. 'where' => 'rid=' . $roleId,
  5481. 'asArray' => true
  5482. ) );
  5483. $receiptLog->rolename = $roleInfo ['name'];
  5484. }
  5485. $receiptLog->username = $this->staff [0] ['username'];
  5486. $receiptLog->uid = $this->staff [0] ['sid'];
  5487. $receiptLog->date = date ( "Y-m-d" );
  5488. $receiptLog->opinion = '提交审批';
  5489. $receiptLog->img = $this->staff [0] ['avatar'];
  5490. $receiptLog->status = 2;
  5491. $receiptLog->rid = $rid;
  5492. $receiptLog->insert ();
  5493. // statistics item
  5494. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  5495. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  5496. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  5497. $stat = $statistics->getOne ( array (
  5498. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5499. 'asArray' => true
  5500. ) );
  5501. if (empty ( $stat )) {
  5502. $statistics->date = date ( "Y-m-d" );
  5503. $statistics->cid = $this->staff [0] ['cid'];
  5504. $statistics->staff = $this->staff [0] ['sid'];
  5505. $statistics->agPrice = 0;
  5506. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5507. $statistics->insert ();
  5508. } else {
  5509. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5510. $statistics->update ( array (
  5511. 'where' => 'sid=' . $stat ['sid']
  5512. ) );
  5513. }
  5514. return "/expenses";
  5515. }
  5516. function approval() {
  5517. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5518. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5519. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5520. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5521. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5522. if (empty ( $status ))
  5523. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5524. $vidList = array ();
  5525. $button = 0;
  5526. Doo::loadModel ( 'verify' );
  5527. $verify = new verify ();
  5528. Doo::loadModel ( 'receipt' );
  5529. $receipt = new receipt ();
  5530. Doo::loadModel ( 'staff' );
  5531. $staff = new staff ();
  5532. Doo::loadModel ( 'L_category' );
  5533. $Lcategory = new L_category ();
  5534. // user verify ID
  5535. $verifyDetail = $verify->find ( array (
  5536. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5537. 'asArray' => true
  5538. ) );
  5539. foreach ( $verifyDetail as $key => $value ) {
  5540. array_push ( $vidList, $value ['vid'] );
  5541. }
  5542. $vid = implode ( ",", $vidList );
  5543. if (empty ( $verifyDetail ))
  5544. $vid = 0;
  5545. /*
  5546. */
  5547. $dateCondition = " and Year(date) =" . $year;
  5548. if (! empty ( $month ))
  5549. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  5550. $categoryList = $Lcategory->find ( array (
  5551. 'asArray' => true
  5552. ) );
  5553. $staffList = $staff->find ( array (
  5554. 'where' => 'cid=' . $cid,
  5555. 'asArray' => true
  5556. ) );
  5557. $cateCondition = "";
  5558. $staffCondition = "";
  5559. $approvalCondition = "";
  5560. if (! empty ( $cid ))
  5561. $cateCondition = ' and cid=' . $cid;
  5562. if (! empty ( $sid )) {
  5563. $staffCondition = ' and staff=' . $sid;
  5564. $cateCondition = "";
  5565. }
  5566. // elseif($status==1){
  5567. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  5568. // }
  5569. if ($status == 2) {
  5570. // 查找角色审批人
  5571. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  5572. }
  5573. $ap = "";
  5574. if ($status == 4) {
  5575. $ap = 4;
  5576. $status = 2;
  5577. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  5578. }
  5579. if ($status == 5) {
  5580. $status = 4;
  5581. $ap = 5;
  5582. }
  5583. // echo $vid;
  5584. // get Receipt By verifyID status 2 .$approvalCondition
  5585. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  5586. $receiptList = $receipt->find ( array (
  5587. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  5588. 'desc' => 'rid',
  5589. 'asArray' => true
  5590. ) );
  5591. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  5592. $Locate = 0;
  5593. if ($ap == 4)
  5594. $status = 4;
  5595. elseif ($ap == 5)
  5596. $status = 5;
  5597. foreach ( $receiptList as $key => $value ) {
  5598. $receiptList [$key] ['Locate'] = $Locate;
  5599. $Locate ++;
  5600. $receiptList [$key] ['reviseDetail'] = array ();
  5601. if (! empty ( $value ['reviseDetail'] ))
  5602. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5603. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5604. $categoryDetil = $Lcategory->getOne ( array (
  5605. 'where' => 'cid=' . $value ['cid'],
  5606. 'asArray' => true
  5607. ) );
  5608. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5609. $verifyList = $verify->getOne ( array (
  5610. 'where' => 'vid=' . $value ['verify'],
  5611. 'asArray' => true
  5612. ) );
  5613. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5614. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5615. foreach ( $verifyList as $k => $v ) {
  5616. // init verifyStaff
  5617. $verifyList [$k] ['date'] = "";
  5618. $verifyList [$k] ['opinion'] = "";
  5619. $verifyList [$k] ['status'] = "";
  5620. if (empty ( $verifyStaff )) {
  5621. $verifyList [$k] ['date'] = "";
  5622. $verifyList [$k] ['opinion'] = "";
  5623. if ($v [0] == $this->staff [0] ['sid']) {
  5624. $verifyList [$k] ['status'] = 4;
  5625. $button = 4;
  5626. }
  5627. } else {
  5628. $flag = true;
  5629. foreach ( $verifyStaff as $m => $u ) {
  5630. if ($v [0] == $m) {
  5631. $verifyList [$k] ['date'] = $u ['date'];
  5632. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5633. $verifyList [$k] ['status'] = $u ['status'];
  5634. $flag = false;
  5635. break;
  5636. }
  5637. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  5638. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  5639. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  5640. }
  5641. if ($flag) { // 检测可编辑
  5642. if ($v [0] == $this->staff [0] ['sid']) {
  5643. $verifyList [$k] ['status'] = 4;
  5644. $button = 4;
  5645. }
  5646. }
  5647. }
  5648. }
  5649. $receiptList [$key] ['verifyList'] = $verifyList;
  5650. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5651. 'where' => 'sid=' . $value ['staff'],
  5652. 'asArray' => true
  5653. ) );
  5654. $receiptList [$key] ['button'] = $button;
  5655. }
  5656. // print_r($receiptList);die;
  5657. // $data['verifyDetail']=$verifyDetail;
  5658. $mothHtml = "";
  5659. for($i = 1; $i <= 12; $i ++) {
  5660. if ($month == $i)
  5661. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5662. else
  5663. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5664. }
  5665. $data ['mothHtml'] = $mothHtml;
  5666. $data ['receiptList'] = $receiptList;
  5667. $data ['receiptApprovalCount'] = count ( $receiptList );
  5668. $data ['status'] = $status;
  5669. $data ['year'] = $year;
  5670. $data ['categoryList'] = $categoryList;
  5671. $data ['staffList'] = $staffList;
  5672. $data ['cid'] = $cid;
  5673. $data ['sid'] = $sid;
  5674. $data ['ap'] = $ap;
  5675. $data ['memu'] = "receipt";
  5676. $data ['staff'] = $this->staff;
  5677. $data ['receiptMemu'] = 'approval';
  5678. $data ['verifyId'] = $this->verifyId;
  5679. $data ['executeId'] = $this->executeId;
  5680. $this->render ( "/admin/saea_reportList", $data );
  5681. }
  5682. function approvalDetails() {
  5683. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5684. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5685. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5686. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5687. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5688. Doo::loadModel ( 'verify' );
  5689. $verify = new verify ();
  5690. Doo::loadModel ( 'receipt' );
  5691. $receipt = new receipt ();
  5692. Doo::loadModel ( 'staff' );
  5693. $staff = new staff ();
  5694. Doo::loadModel ( 'L_category' );
  5695. $Lcategory = new L_category ();
  5696. Doo::loadModel ( 'enclosur' );
  5697. $enclosur = new enclosur ();
  5698. $vidList = array ();
  5699. $verifyDetail = $verify->find ( array (
  5700. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5701. 'asArray' => true
  5702. ) );
  5703. foreach ( $verifyDetail as $key => $value ) {
  5704. array_push ( $vidList, $value ['vid'] );
  5705. }
  5706. $vid = implode ( ",", $vidList );
  5707. if (empty ( $verifyDetail ))
  5708. $vid = 0;
  5709. $categoryList = $Lcategory->find ( array (
  5710. 'asArray' => true
  5711. ) );
  5712. $staffList = $staff->find ( array (
  5713. 'where' => 'cid=' . $cid,
  5714. 'asArray' => true
  5715. ) );
  5716. $ap = 0;
  5717. $receiptList = $receipt->find ( array (
  5718. 'where' => 'rid =' . $rid,
  5719. 'desc' => 'rid',
  5720. 'asArray' => true
  5721. ) );
  5722. $Locate = 0;
  5723. $roleId = 0;
  5724. $button = 0;
  5725. foreach ( $receiptList as $key => $value ) {
  5726. $receiptList [$key] ['Locate'] = $Locate;
  5727. $Locate ++;
  5728. $receiptList [$key] ['reviseDetail'] = array ();
  5729. if (! empty ( $value ['reviseDetail'] ))
  5730. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5731. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5732. $categoryDetil = $Lcategory->getOne ( array (
  5733. 'where' => 'cid=' . $value ['cid'],
  5734. 'asArray' => true
  5735. ) );
  5736. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5737. // 检测编辑状态
  5738. $verifyList = $verify->getOne ( array (
  5739. 'where' => 'vid=' . $value ['verify'],
  5740. 'asArray' => true
  5741. ) );
  5742. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5743. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5744. Doo::loadModel ( 'role' );
  5745. $role = new role ();
  5746. // print_r($verifyList);
  5747. $flag = true;
  5748. $roleKey = 0;
  5749. $endStaffArray = array ();
  5750. $roleArrayCopy = array ();
  5751. foreach ( $verifyList as $k => $v ) {
  5752. // init verifyStaff
  5753. if ($v [1] == 'ROLE') {
  5754. if (! empty ( $verifyStaff )) {
  5755. $endStaffArray = end ( $verifyStaff );
  5756. if ($v [0] == $endStaffArray ['nextStaff']) {
  5757. $roleId = $v [0];
  5758. }
  5759. }
  5760. $roleVerify = json_decode ( $v [3], true );
  5761. $roleKey = $k;
  5762. $roleArray = array ();
  5763. $rolename = $role->getOne ( array (
  5764. 'where' => 'rid=' . $v [0],
  5765. 'asArray' => true
  5766. ) );
  5767. foreach ( $roleVerify as $o => $p ) {
  5768. $staffID = explode ( '_', $p );
  5769. $staffInfo = $staff->getOne ( array (
  5770. 'where' => 'sid=' . $staffID [0],
  5771. 'asArray' => true
  5772. ) );
  5773. // print_r($staffID);
  5774. $exp = array (
  5775. 0 => $staffInfo ['sid'],
  5776. 1 => $staffID [1],
  5777. 2 => $staffInfo ['avatar'],
  5778. 'date' => '',
  5779. 'date' => '',
  5780. 'opinion' => '',
  5781. 'status' => '',
  5782. 'rolename' => $rolename ['name']
  5783. );
  5784. array_push ( $roleArray, $exp );
  5785. }
  5786. $roleArrayCopy [$v [0]] = $roleArray;
  5787. // $verifyList[$k]['roleArray']=$roleArray;
  5788. }
  5789. // print_r($roleArray);
  5790. $verifyList [$k] ['date'] = "";
  5791. $verifyList [$k] ['opinion'] = "";
  5792. $verifyList [$k] ['status'] = "";
  5793. if (empty ( $verifyStaff )) {
  5794. $verifyList [$k] ['date'] = "";
  5795. $verifyList [$k] ['opinion'] = "";
  5796. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5797. $verifyList [$k] ['status'] = 4;
  5798. $button = 4;
  5799. $flag = false;
  5800. }
  5801. } else {
  5802. foreach ( $verifyStaff as $m => $u ) {
  5803. if ($v [0] == $m) {
  5804. $verifyList [$k] ['date'] = $u ['date'];
  5805. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5806. $verifyList [$k] ['status'] = $u ['status'];
  5807. $flag = false;
  5808. break;
  5809. }
  5810. }
  5811. $endStaffArray = end ( $verifyStaff );
  5812. if (isset ( $endStaffArray ['ROLE'] )) {
  5813. } else {
  5814. $endKey = key ( $verifyStaff );
  5815. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5816. $button = 4;
  5817. $verifyList [$k] ['status'] = 4;
  5818. }
  5819. }
  5820. }
  5821. }
  5822. $rolename ['name'] = '';
  5823. if (! empty ( $roleId )) {
  5824. Doo::loadModel ( 'role' );
  5825. $role = new role ();
  5826. $rolename = $role->getOne ( array (
  5827. 'where' => 'rid=' . $roleId,
  5828. 'asArray' => true
  5829. ) );
  5830. }
  5831. if (! empty ( $verifyStaff ))
  5832. $endStaffArray = end ( $verifyStaff );
  5833. $KOP = false;
  5834. foreach ( $roleArrayCopy as $P => $A ) {
  5835. foreach ( $A as $MKI => $AVL ) {
  5836. if (! empty ( $verifyStaff )) {
  5837. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5838. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5839. $button = 4;
  5840. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5841. }
  5842. foreach ( $verifyStaff as $m => $u ) {
  5843. $AVLFK = $AVL [0] . '_R';
  5844. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5845. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5846. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5847. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5848. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5849. break;
  5850. }
  5851. }
  5852. } else {
  5853. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5854. $button = 4;
  5855. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5856. }
  5857. }
  5858. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5859. $KOP = true;
  5860. }
  5861. }
  5862. foreach ( $roleArrayCopy as $k => $v ) {
  5863. foreach ( $verifyList as $m => $n ) {
  5864. if ($n [0] == $k) {
  5865. array_splice ( $verifyList, $m, 1, $v );
  5866. }
  5867. }
  5868. }
  5869. $receiptList [$key] ['verifyList'] = $verifyList;
  5870. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5871. 'where' => 'sid=' . $value ['staff'],
  5872. 'asArray' => true
  5873. ) );
  5874. $receiptList [$key] ['button'] = $button;
  5875. }
  5876. $mothHtml = "";
  5877. for($i = 1; $i <= 12; $i ++) {
  5878. if ($month == $i)
  5879. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5880. else
  5881. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5882. }
  5883. // 获取审批日志
  5884. Doo::loadModel ( 'receiptLog' );
  5885. $receiptLog = new receiptLog ();
  5886. $rlList = array ();
  5887. $rlInfo = $receiptLog->getOne ( array (
  5888. 'where' => 'rid=' . $rid . ' and status=4',
  5889. 'asArray' => true
  5890. ) );
  5891. $tijdate = $receiptLog->getOne ( array (
  5892. 'where' => 'rid=' . $rid . ' and status=2',
  5893. 'asc' => 'rlid',
  5894. 'asArray' => true
  5895. ) );
  5896. if (! empty ( $rlInfo )) {
  5897. $rlList = $receiptLog->find ( array (
  5898. 'where' => 'rid=' . $rid,
  5899. 'asc' => 'rlid',
  5900. 'asArray' => true
  5901. ) );
  5902. }
  5903. $receiptList [0] ['rlList'] = $rlList;
  5904. $enclosurList = $enclosur->find ( array (
  5905. 'where' => 'rid=' . $rid,
  5906. 'asArray' => true
  5907. ) );
  5908. $enclosurHtml = '';
  5909. foreach ( $enclosurList as $value ) {
  5910. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5911. }
  5912. $data ['enclosurHtml'] = $enclosurHtml;
  5913. $data ['rolename'] = $rolename ['name'];
  5914. $data ['datetij'] = $tijdate ['date'];
  5915. $data ['mothHtml'] = $mothHtml;
  5916. $data ['receiptList'] = $receiptList;
  5917. $data ['receiptApprovalCount'] = count ( $receiptList );
  5918. $data ['year'] = $year;
  5919. $data ['categoryList'] = $categoryList;
  5920. $data ['staffList'] = $staffList;
  5921. $data ['cid'] = $cid;
  5922. $data ['sid'] = $sid;
  5923. $data ['status'] = 0;
  5924. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  5925. $ap = 4;
  5926. } else
  5927. $data ['status'] = $receiptList [0] ['status'];
  5928. if ($receiptList [0] ['status'] == 4) {
  5929. $data ['status'] = 5;
  5930. $ap = 0;
  5931. }
  5932. $data ['ap'] = $ap;
  5933. $data ['memu'] = "receipt";
  5934. $data ['staff'] = $this->staff;
  5935. $data ['receiptMemu'] = 'approval';
  5936. $data ['verifyId'] = $this->verifyId;
  5937. $data ['executeId'] = $this->executeId;
  5938. $this->render ( "/admin/saeaReportListReport", $data );
  5939. }
  5940. function approvalEdi() {
  5941. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5942. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5943. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5944. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5945. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5946. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5947. if (empty ( $status ))
  5948. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5949. $vidList = array ();
  5950. $button = 0;
  5951. Doo::loadModel ( 'verify' );
  5952. Doo::loadModel ( 'receipt' );
  5953. Doo::loadModel ( 'staff' );
  5954. $staff = new staff ();
  5955. $receipt = new receipt ();
  5956. $verify = new verify ();
  5957. Doo::loadModel ( 'L_category' );
  5958. $Lcategory = new L_category ();
  5959. Doo::loadModel ( 'enclosur' );
  5960. $enclosur = new enclosur ();
  5961. // user verify ID
  5962. $verifyDetail = $verify->find ( array (
  5963. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5964. 'asArray' => true
  5965. ) );
  5966. foreach ( $verifyDetail as $key => $value ) {
  5967. array_push ( $vidList, $value ['vid'] );
  5968. }
  5969. $vid = implode ( ",", $vidList );
  5970. if (empty ( $verifyDetail ))
  5971. $vid = 0;
  5972. $categoryList = $Lcategory->find ( array (
  5973. 'asArray' => true
  5974. ) );
  5975. $staffList = $staff->find ( array (
  5976. 'where' => 'cid=' . $cid,
  5977. 'asArray' => true
  5978. ) );
  5979. $ap = "";
  5980. if ($status == 4) {
  5981. $ap = 4;
  5982. $status = 2;
  5983. }
  5984. // get Receipt By verifyID status 2
  5985. $receiptList = $receipt->find ( array (
  5986. 'where' => 'rid =' . $rid,
  5987. 'desc' => 'rid',
  5988. 'asArray' => true
  5989. ) );
  5990. $Locate = 0;
  5991. $roleId = 0;
  5992. if ($ap == 4)
  5993. $status = 4;
  5994. foreach ( $receiptList as $key => $value ) {
  5995. $receiptList [$key] ['Locate'] = $Locate;
  5996. $Locate ++;
  5997. $receiptList [$key] ['reviseDetail'] = array ();
  5998. if (! empty ( $value ['reviseDetail'] ))
  5999. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6000. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6001. $categoryDetil = $Lcategory->getOne ( array (
  6002. 'where' => 'cid=' . $value ['cid'],
  6003. 'asArray' => true
  6004. ) );
  6005. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6006. // 检测编辑状态
  6007. $verifyList = $verify->getOne ( array (
  6008. 'where' => 'vid=' . $value ['verify'],
  6009. 'asArray' => true
  6010. ) );
  6011. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6012. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6013. // print_r($verifyList);
  6014. //
  6015. // if (empty($verifyStaff)){
  6016. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6017. // $verifyList[0]['status']=4;$button=4;
  6018. // }
  6019. //
  6020. // }else{
  6021. //
  6022. // }
  6023. // die;
  6024. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  6025. // echo array_search("green",$a);
  6026. //
  6027. Doo::loadModel ( 'role' );
  6028. $role = new role ();
  6029. // print_r($verifyList);
  6030. $flag = true;
  6031. $roleKey = 0;
  6032. $endStaffArray = array ();
  6033. $roleArrayCopy = array ();
  6034. foreach ( $verifyList as $k => $v ) {
  6035. // init verifyStaff
  6036. if ($v [1] == 'ROLE') {
  6037. if (! empty ( $verifyStaff )) {
  6038. $endStaffArray = end ( $verifyStaff );
  6039. if ($v [0] == $endStaffArray ['nextStaff']) {
  6040. $roleId = $v [0];
  6041. }
  6042. }
  6043. $roleVerify = json_decode ( $v [3], true );
  6044. $roleKey = $k;
  6045. $roleArray = array ();
  6046. $rolename = $role->getOne ( array (
  6047. 'where' => 'rid=' . $v [0],
  6048. 'asArray' => true
  6049. ) );
  6050. foreach ( $roleVerify as $o => $p ) {
  6051. $staffID = explode ( '_', $p );
  6052. $staffInfo = $staff->getOne ( array (
  6053. 'where' => 'sid=' . $staffID [0],
  6054. 'asArray' => true
  6055. ) );
  6056. // print_r($staffID);
  6057. $exp = array (
  6058. 0 => $staffInfo ['sid'],
  6059. 1 => $staffID [1],
  6060. 2 => $staffInfo ['avatar'],
  6061. 'date' => '',
  6062. 'date' => '',
  6063. 'opinion' => '',
  6064. 'status' => '',
  6065. 'rolename' => $rolename ['name']
  6066. );
  6067. array_push ( $roleArray, $exp );
  6068. }
  6069. $roleArrayCopy [$v [0]] = $roleArray;
  6070. // $verifyList[$k]['roleArray']=$roleArray;
  6071. }
  6072. // print_r($roleArray);
  6073. $verifyList [$k] ['date'] = "";
  6074. $verifyList [$k] ['opinion'] = "";
  6075. $verifyList [$k] ['status'] = "";
  6076. if (empty ( $verifyStaff )) {
  6077. $verifyList [$k] ['date'] = "";
  6078. $verifyList [$k] ['opinion'] = "";
  6079. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6080. $verifyList [$k] ['status'] = 4;
  6081. $button = 4;
  6082. $flag = false;
  6083. }
  6084. } else {
  6085. foreach ( $verifyStaff as $m => $u ) {
  6086. if ($v [0] == $m) {
  6087. $verifyList [$k] ['date'] = $u ['date'];
  6088. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6089. $verifyList [$k] ['status'] = $u ['status'];
  6090. $flag = false;
  6091. break;
  6092. }
  6093. }
  6094. $endStaffArray = end ( $verifyStaff );
  6095. if (isset ( $endStaffArray ['ROLE'] )) {
  6096. } else {
  6097. $endKey = key ( $verifyStaff );
  6098. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6099. $button = 4;
  6100. $verifyList [$k] ['status'] = 4;
  6101. }
  6102. }
  6103. // print_r($endStaffArray);die;
  6104. // if (empty($verifyStaff)){
  6105. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6106. // $verifyList[$k]['status']=4;$button=4;
  6107. // }
  6108. //
  6109. // }else{
  6110. //
  6111. // }
  6112. // if($flag){//检测可编辑
  6113. // if($v[0]==$this->staff[0]['sid']){
  6114. // $verifyList[$k]['status']=4;$button=4;
  6115. // }
  6116. // }
  6117. }
  6118. }
  6119. $rolename ['name'] = '';
  6120. if (! empty ( $roleId )) {
  6121. Doo::loadModel ( 'role' );
  6122. $role = new role ();
  6123. $rolename = $role->getOne ( array (
  6124. 'where' => 'rid=' . $roleId,
  6125. 'asArray' => true
  6126. ) );
  6127. }
  6128. if (! empty ( $verifyStaff ))
  6129. $endStaffArray = end ( $verifyStaff );
  6130. $KOP = false;
  6131. foreach ( $roleArrayCopy as $P => $A ) {
  6132. foreach ( $A as $MKI => $AVL ) {
  6133. if (! empty ( $verifyStaff )) {
  6134. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6135. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6136. $button = 4;
  6137. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6138. }
  6139. foreach ( $verifyStaff as $m => $u ) {
  6140. $AVLFK = $AVL [0] . '_R';
  6141. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6142. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6143. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6144. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6145. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6146. break;
  6147. }
  6148. }
  6149. } else {
  6150. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6151. $button = 4;
  6152. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6153. }
  6154. }
  6155. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6156. $KOP = true;
  6157. }
  6158. }
  6159. // print_r($roleArrayCopy);
  6160. // echo $roleKey;
  6161. foreach ( $roleArrayCopy as $k => $v ) {
  6162. foreach ( $verifyList as $m => $n ) {
  6163. if ($n [0] == $k) {
  6164. array_splice ( $verifyList, $m, 1, $v );
  6165. }
  6166. }
  6167. }
  6168. // if ($KOP)
  6169. // array_splice($verifyList,$roleKey,1,$roleArray);
  6170. // print_r($verifyList);
  6171. $receiptList [$key] ['verifyList'] = $verifyList;
  6172. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6173. 'where' => 'sid=' . $value ['staff'],
  6174. 'asArray' => true
  6175. ) );
  6176. $receiptList [$key] ['button'] = $button;
  6177. }
  6178. // $data['verifyDetail']=$verifyDetail;
  6179. $mothHtml = "";
  6180. for($i = 1; $i <= 12; $i ++) {
  6181. if ($month == $i)
  6182. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6183. else
  6184. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6185. }
  6186. // 获取审批日志
  6187. Doo::loadModel ( 'receiptLog' );
  6188. $receiptLog = new receiptLog ();
  6189. $rlList = array ();
  6190. $rlInfo = $receiptLog->getOne ( array (
  6191. 'where' => 'rid=' . $rid . ' and status=4',
  6192. 'asArray' => true
  6193. ) );
  6194. $tijdate = $receiptLog->getOne ( array (
  6195. 'where' => 'rid=' . $rid . ' and status=2',
  6196. 'asc' => 'rlid',
  6197. 'asArray' => true
  6198. ) );
  6199. if (! empty ( $rlInfo )) {
  6200. $rlList = $receiptLog->find ( array (
  6201. 'where' => 'rid=' . $rid,
  6202. 'asc' => 'rlid',
  6203. 'asArray' => true
  6204. ) );
  6205. }
  6206. $receiptList [0] ['rlList'] = $rlList;
  6207. $enclosurList = $enclosur->find ( array (
  6208. 'where' => 'rid=' . $rid,
  6209. 'asArray' => true
  6210. ) );
  6211. $enclosurHtml = '';
  6212. foreach ( $enclosurList as $value ) {
  6213. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6214. }
  6215. $data ['enclosurHtml'] = $enclosurHtml;
  6216. $data ['rolename'] = $rolename ['name'];
  6217. $data ['datetij'] = $tijdate ['date'];
  6218. $data ['mothHtml'] = $mothHtml;
  6219. $data ['receiptList'] = $receiptList;
  6220. $data ['receiptApprovalCount'] = count ( $receiptList );
  6221. $data ['status'] = $status;
  6222. $data ['year'] = $year;
  6223. $data ['categoryList'] = $categoryList;
  6224. $data ['staffList'] = $staffList;
  6225. $data ['cid'] = $cid;
  6226. $data ['sid'] = $sid;
  6227. $data ['ap'] = $ap;
  6228. $data ['memu'] = "receipt";
  6229. $data ['staff'] = $this->staff;
  6230. $data ['receiptMemu'] = 'approval';
  6231. $data ['verifyId'] = $this->verifyId;
  6232. $data ['executeId'] = $this->executeId;
  6233. $this->render ( "/admin/saeaReportListReport", $data );
  6234. }
  6235. function remittanceHky() {
  6236. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6237. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  6238. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6239. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  6240. $page_size = 15;
  6241. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  6242. Doo::loadModel ( 'receipt' );
  6243. $receipt = new receipt ();
  6244. Doo::loadModel ( 'staff' );
  6245. $staff = new staff ();
  6246. $dateCondition = " and Year(executeDate) =" . $year;
  6247. if ($moth != 'MONTH')
  6248. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  6249. if ($day != 'DAY' && $moth != 'MONTH')
  6250. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  6251. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  6252. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  6253. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  6254. $limit = $pageinfo ['lower'] . ',' . $page_size;
  6255. $dayList = $receipt->find ( array (
  6256. 'select' => 'executeDate,sum(amount) as amount',
  6257. 'where' => $sql,
  6258. 'desc' => 'executeDate',
  6259. 'groupby' => 'executeDate',
  6260. 'limit' => $limit,
  6261. 'asArray' => true
  6262. ) );
  6263. // print_r($dayList);
  6264. foreach ( $dayList as $key => $value ) {
  6265. $remitString = "";
  6266. $receiptList = $receipt->find ( array (
  6267. 'select' => 'rid,executeDate,amount,staff,cid',
  6268. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  6269. 'desc' => 'executeDate',
  6270. 'asArray' => true
  6271. ) );
  6272. foreach ( $receiptList as $k => $v ) {
  6273. $sinfo = $staff->getOne ( array (
  6274. 'select' => 'username,category',
  6275. 'where' => ' sid=' . $v ['staff'],
  6276. 'asArray' => true
  6277. ) );
  6278. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  6279. }
  6280. $dayList [$key] ['staff'] = $remitString;
  6281. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  6282. }
  6283. // print_r($dayList);
  6284. $mothHtml = "";
  6285. for($i = 1; $i <= 12; $i ++) {
  6286. if ($moth == $i)
  6287. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6288. else
  6289. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6290. }
  6291. $dayHtml = "";
  6292. if ($day != "DAY" || $moth != "MONTH") {
  6293. for($i = 1; $i <= 31; $i ++) {
  6294. if ($day == $i)
  6295. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6296. else
  6297. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6298. }
  6299. }
  6300. $data ['page'] = $pageinfo;
  6301. $data ['year'] = $year;
  6302. $data ['moth'] = $moth;
  6303. $data ['day'] = $day;
  6304. $data ['get'] = $get;
  6305. $data ['dayHtml'] = $dayHtml;
  6306. $data ['mothHtml'] = $mothHtml;
  6307. $data ['receiptList'] = $dayList;
  6308. $data ['memu'] = "receipt";
  6309. $data ['staff'] = $this->staff;
  6310. $data ['receiptMemu'] = 'remittanceHky';
  6311. $data ['verifyId'] = $this->verifyId;
  6312. $data ['executeId'] = $this->executeId;
  6313. $this->render ( "/admin/remittanceHky", $data );
  6314. }
  6315. function remittancep() {
  6316. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  6317. Doo::loadModel ( 'receipt' );
  6318. $receipt = new receipt ();
  6319. Doo::loadModel ( 'staff' );
  6320. $staff = new staff ();
  6321. Doo::loadClass ( 'XDeode' );
  6322. $XDeode = new XDeode ( 5 );
  6323. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  6324. $rplist = $receipt->find ( array (
  6325. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6326. 'asArray' => true
  6327. ) );
  6328. $dayList = $receipt->find ( array (
  6329. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6330. 'desc' => 'executeDate',
  6331. 'groupby' => 'staff',
  6332. 'asArray' => true
  6333. ) );
  6334. $html = '';
  6335. foreach ( $dayList as $key => $value ) {
  6336. $sinfo = $staff->getOne ( array (
  6337. 'select' => 'username,category',
  6338. 'where' => ' sid=' . $value ['staff'],
  6339. 'asArray' => true
  6340. ) );
  6341. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  6342. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  6343. $au = 0;
  6344. foreach ( $rplist as $k => $v ) {
  6345. if ($value ['staff'] == $v ['staff']) {
  6346. $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>';
  6347. $au += $v ['amount'];
  6348. }
  6349. }
  6350. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  6351. }
  6352. $data ['html'] = $html;
  6353. $data ['memu'] = "receipt";
  6354. $data ['staff'] = $this->staff;
  6355. $data ['receiptMemu'] = 'remittanceHky';
  6356. $data ['verifyId'] = $this->verifyId;
  6357. $data ['executeId'] = $this->executeId;
  6358. $this->render ( "/admin/remittancep", $data );
  6359. }
  6360. function ajaxGetReceiptDetails() {
  6361. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  6362. Doo::loadClass ( 'XDeode' );
  6363. $XDeode = new XDeode ( 5 );
  6364. $rid = $XDeode->decode ( $rid );
  6365. if (empty ( $rid )) {
  6366. echo json_encode ( array (
  6367. 'status' => 2,
  6368. 'msg' => 'illegal request'
  6369. ) );
  6370. die ();
  6371. }
  6372. Doo::loadModel ( 'receipt' );
  6373. $receipt = new receipt ();
  6374. Doo::loadModel ( 'staff' );
  6375. $staff = new staff ();
  6376. $rinfo = $receipt->getOne ( array (
  6377. 'where' => 'rid= ' . $rid,
  6378. 'asArray' => true
  6379. ) );
  6380. $sinfo = $staff->getOne ( array (
  6381. 'select' => 'username,category',
  6382. 'where' => ' sid=' . $rinfo ['staff'],
  6383. 'asArray' => true
  6384. ) );
  6385. $rinfo ['reviseDetail'] = array ();
  6386. if (! empty ( $rinfo ['reviseDetail'] ))
  6387. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  6388. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  6389. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  6390. $rinfo ['category'] = $sinfo ['category'];
  6391. $verifyStaff = array ();
  6392. if (! empty ( $rinfo ['verifyStaff'] ))
  6393. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  6394. $relust = $rinfo ['sum'] - $rinfo ['loanSum'];
  6395. $rinfo ['relust'] = $relust;
  6396. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  6397. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  6398. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  6399. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  6400. // 费用执行人相关数据
  6401. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6402. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6403. foreach ( $executeCopy as $k => $v ) {
  6404. $executeCopy [$k] ['date'] = '';
  6405. $executeCopy [$k] ['opinion'] = '';
  6406. $executeCopy [$k] ['status'] = '';
  6407. if (! empty ( $executeStaff ))
  6408. foreach ( $executeStaff as $m => $u ) {
  6409. if ($v [0] == $m) {
  6410. $executeCopy [$k] ['date'] = $u ['date'];
  6411. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  6412. $executeCopy [$k] ['status'] = $u ['status'];
  6413. break;
  6414. }
  6415. }
  6416. }
  6417. $rinfo ['executeCopy'] = $executeCopy;
  6418. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  6419. if ($rinfo ['Rtype'] == 1) { // 借款费用
  6420. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6421. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  6422. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  6423. $html .= '<tr><th>' . $value ['name'] . '</th>
  6424. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6425. }
  6426. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6427. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6428. <tr><th class="taC" colspan="2">费用说明</th>
  6429. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6430. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6431. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  6432. </tbody></table>';
  6433. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  6434. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6435. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6436. foreach ( $rinfo ['accountItem'] ['日常相关费用'] 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="taR">合计</th>
  6441. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6442. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6443. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6444. $html .= '<tr><th>' . $value ['name'] . '</th>
  6445. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6446. }
  6447. $html .= '<tr><th class="taR">合计</th>
  6448. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  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'] ['trainSum'] . '</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'] ['otherSum'] . '</td></tr>';
  6463. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6464. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6465. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6466. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6467. }
  6468. $html .= '<tr><th class="taR">合计</th>
  6469. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6470. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6471. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6472. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6473. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6474. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6475. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6476. <tr';
  6477. if ($rinfo ['relust'] >= 0) {
  6478. $html .= 'class="success"';
  6479. } else {
  6480. $html .= 'class="error"';
  6481. }
  6482. $html .= '><td class="taR"><b>借款结余</b></td>
  6483. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  6484. </tbody></table>
  6485. ';
  6486. }
  6487. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  6488. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6489. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  6490. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6491. $html .= '<tr><th>' . $value ['name'] . '</th>
  6492. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6493. }
  6494. $html .= '<tr><th class="taR">合计</th>
  6495. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6496. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6497. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6498. <tr><th class="taC" colspan="2">费用说明</th>
  6499. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6500. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6501. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6502. </tbody></table>';
  6503. } else {
  6504. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6505. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6506. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6507. $html .= '<tr><th>' . $value ['name'] . '</th>
  6508. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6509. }
  6510. $html .= '<tr><th class="taR">合计</th>
  6511. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6512. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6513. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6514. $html .= '<tr><th>' . $value ['name'] . '</th>
  6515. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6516. }
  6517. $html .= '<tr><th class="taR">合计</th>
  6518. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  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'] ['trainSum'] . '</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'] ['otherSum'] . '</td></tr>';
  6533. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6534. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6535. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6536. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6537. }
  6538. $html .= '<tr><th class="taR">合计</th>
  6539. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6540. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6541. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6542. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6543. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6544. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6545. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  6546. $html .= '</tbody></table>';
  6547. /*
  6548. * <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>
  6549. * <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>
  6550. * <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>
  6551. * <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>
  6552. * <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>
  6553. * <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>
  6554. * </tbody> </table>
  6555. */
  6556. }
  6557. // print_r($verifyStaff);die;
  6558. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  6559. foreach ( $verifyStaff as $key => $value ) {
  6560. $key = trim ( strtr ( $key, '_R', ' ' ) );
  6561. $sinfo = $staff->getOne ( array (
  6562. 'select' => 'username',
  6563. 'where' => ' sid=' . $key,
  6564. 'asArray' => true
  6565. ) );
  6566. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6567. }
  6568. $html .= '</tbody></table>';
  6569. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  6570. foreach ( $rinfo ['executeCopy'] as $value ) {
  6571. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6572. }
  6573. $html .= '</tbody></table>';
  6574. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  6575. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  6576. </tr></table>';
  6577. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  6578. echo json_encode ( array (
  6579. 'status' => 1,
  6580. 'html' => $html
  6581. ) );
  6582. die ();
  6583. }
  6584. function remittance() {
  6585. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6586. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6587. Doo::loadModel ( 'receipt' );
  6588. $receipt = new receipt ();
  6589. Doo::loadModel ( 'staff' );
  6590. $staff = new staff ();
  6591. $dateCondition = " and Year(pastDate) =" . $year;
  6592. if (! empty ( $month ))
  6593. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  6594. // get Receipt By verifyID status 1
  6595. $receiptList = $receipt->find ( array (
  6596. 'select' => 'sum(sum) as sum,staff,pastDate',
  6597. 'where' => ' status=1' . $dateCondition,
  6598. 'desc' => 'pastDate',
  6599. 'groupby' => 'staff,pastDate',
  6600. 'asArray' => true
  6601. ) );
  6602. $dateList = $receipt->find ( array (
  6603. 'select' => 'pastDate,verifyStaff',
  6604. 'where' => ' status=1' . $dateCondition,
  6605. 'desc' => 'pastDate',
  6606. 'groupby' => 'pastDate',
  6607. 'asArray' => true
  6608. ) );
  6609. $dataList = array ();
  6610. foreach ( $dateList as $d => $a ) {
  6611. $dataList [$a ['pastDate']] = array ();
  6612. $daySum = 0;
  6613. foreach ( $receiptList as $key => $value ) {
  6614. if ($a ['pastDate'] == $value ['pastDate']) {
  6615. $oderList = $receipt->find ( array (
  6616. 'select' => 'receiptOrder',
  6617. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  6618. 'asArray' => true
  6619. ) );
  6620. $list = array ();
  6621. $html = "";
  6622. foreach ( $oderList as $v ) {
  6623. array_push ( $list, $v ['receiptOrder'] );
  6624. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  6625. }
  6626. $receiptList [$key] ['receiptOrder'] = $html;
  6627. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  6628. $sinfo = $staff->getOne ( array (
  6629. 'select' => 'username ',
  6630. 'where' => ' sid=' . $value ['staff'],
  6631. 'asArray' => true
  6632. ) );
  6633. $receiptList [$key] ['username'] = $sinfo ['username'];
  6634. $daySum += $value ['sum'];
  6635. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  6636. }
  6637. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  6638. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  6639. }
  6640. }
  6641. // print_r($dataList);
  6642. $data ['dataList'] = $dataList;
  6643. $mothHtml = "";
  6644. for($i = 1; $i <= 12; $i ++) {
  6645. if ($month == $i)
  6646. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6647. else
  6648. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6649. }
  6650. $data ['year'] = $year;
  6651. $data ['mothHtml'] = $mothHtml;
  6652. $data ['memu'] = "receipt";
  6653. $data ['staff'] = $this->staff;
  6654. $data ['receiptMemu'] = 'approval';
  6655. $data ['verifyId'] = $this->verifyId;
  6656. $data ['executeId'] = $this->executeId;
  6657. $this->render ( "/admin/saeaReportListPay", $data );
  6658. }
  6659. function revocationAdjustment() {
  6660. $sid = isset ( $this->params ['sid'] ) && is_numeric ( $this->params ['sid'] ) ? $this->params ['sid'] : 0;
  6661. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  6662. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6663. // echo $price;die;
  6664. if ((! empty ( $sid )) && ($price != - 99999) && (! empty ( $rid ))) {
  6665. Doo::loadModel ( 'receipt' );
  6666. $receipt = new receipt ();
  6667. $receiptDetail = $receipt->getOne ( array (
  6668. 'where' => 'rid=' . $rid,
  6669. 'asArray' => true
  6670. ) );
  6671. if (empty ( $receiptDetail ['reviseDetail'] ))
  6672. return "/approval";
  6673. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  6674. $RD = array ();
  6675. foreach ( $reviseDetail as $key => $value ) {
  6676. if ($value ['price'] == $price && $value ['sid'] == $sid)
  6677. continue;
  6678. array_push ( $RD, $value );
  6679. }
  6680. $reviseDetailString = json_encode ( $RD );
  6681. $receipt->reviseDetail = $reviseDetailString;
  6682. $receipt->sum = $receiptDetail ['sum'] - $price;
  6683. $receipt->revisePrice = $receiptDetail ['revisePrice'] - $price;
  6684. $receipt->update ( array (
  6685. 'where' => 'rid=' . $rid
  6686. ) );
  6687. }
  6688. // approvalEdi/37
  6689. return "/approvalEdi/" . $rid;
  6690. }
  6691. function updateApprovalReceipt() {
  6692. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6693. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  6694. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6695. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  6696. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  6697. if (! empty ( $rid )) {
  6698. Doo::loadModel ( "verify" );
  6699. $verify = new verify ();
  6700. Doo::loadModel ( "receiptDetail" );
  6701. $receiptDetailObj = new receiptDetail ();
  6702. Doo::loadModel ( "itemStatistics" );
  6703. Doo::loadModel ( "statistics" );
  6704. $statistics = new statistics ();
  6705. $itemStatistics = new itemStatistics ();
  6706. Doo::loadModel ( "receipt" );
  6707. $receipt = new receipt ();
  6708. $receiptDetail = $receipt->getOne ( array (
  6709. 'where' => 'rid=' . $rid . ' and status=2 ',
  6710. 'asArray' => true
  6711. ) );
  6712. $nslist=explode(',', $receiptDetail['nowStaff']);
  6713. $nsflag=true;
  6714. foreach ($nslist as $value){
  6715. if ($value==$this->staff['0']['sid']){
  6716. $nsflag=false;break;
  6717. }
  6718. }
  6719. if (empty ( $receiptDetail )||$nsflag)
  6720. return "/approval";
  6721. $verifyDetail = $verify->getOne ( array (
  6722. 'where' => ' vid =' . $receiptDetail ['verify'],
  6723. 'asArray' => true
  6724. ) );
  6725. $verifyString = $verifyDetail ['staff'];
  6726. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  6727. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  6728. if (empty ( $opinion )) {
  6729. if ($status == 3)
  6730. $opinion = "终止";
  6731. else
  6732. $opinion = "同意支付";
  6733. }
  6734. $nowStaff = 0;
  6735. $nowStaffList = array ();
  6736. if (empty ( $verifyStaff )) {
  6737. // 还需加入是否已经进入角色审批
  6738. if ($verifyDetail [0] [1] == 'ROLE') {
  6739. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  6740. foreach ( $vStaffString as $key => $value ) {
  6741. $staffK = explode ( "_", $value );
  6742. if ($staffK [0] != $this->staff [0] ['sid'])
  6743. array_push ( $nowStaffList, $staffK [0] );
  6744. }
  6745. // print_r($verifyDetail);
  6746. // die;
  6747. if (! empty ( $nowStaffList )) {
  6748. $nowStaff = implode ( ',', $nowStaffList );
  6749. $verifyStaff = array (
  6750. $this->staff [0] ['sid'] . "_R" => array (
  6751. 'date' => date ( 'Y-m-d' ),
  6752. 'opinion' => $opinion,
  6753. 'status' => $status,
  6754. 'nextStaff' => $verifyDetail [0] [0],
  6755. 'ROLE' => 1
  6756. )
  6757. );
  6758. } else {
  6759. $nowStaff = $verifyDetail [1] [0];
  6760. $verifyStaff = array (
  6761. $this->staff [0] ['sid'] . "_R" => array (
  6762. 'date' => date ( 'Y-m-d' ),
  6763. 'opinion' => $opinion,
  6764. 'status' => $status,
  6765. 'nextStaff' => $verifyDetail [1] [0]
  6766. )
  6767. );
  6768. }
  6769. } else {
  6770. if ($verifyDetail [1] [1] == 'ROLE') {
  6771. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  6772. // echo "dd";
  6773. foreach ( $vStaffString as $key => $value ) {
  6774. $staffK = explode ( "_", $value );
  6775. array_push ( $nowStaffList, $staffK [0] );
  6776. }
  6777. $nowStaff = implode ( ',', $nowStaffList );
  6778. $verifyStaff = array (
  6779. $this->staff [0] ['sid'] => array (
  6780. 'date' => date ( 'Y-m-d' ),
  6781. 'opinion' => $opinion,
  6782. 'status' => $status,
  6783. 'nextStaff' => $verifyDetail [1] [0],
  6784. 'ROLE' => 1
  6785. )
  6786. );
  6787. } else {
  6788. $nowStaff = $verifyDetail [1] [0];
  6789. $verifyStaff = array (
  6790. $this->staff [0] ['sid'] => array (
  6791. 'date' => date ( 'Y-m-d' ),
  6792. 'opinion' => $opinion,
  6793. 'status' => $status,
  6794. 'nextStaff' => $verifyDetail [1] [0]
  6795. )
  6796. );
  6797. }
  6798. }
  6799. if ($status == 3)
  6800. $verifyStaff = array (
  6801. 'final' => $status,
  6802. $this->staff [0] ['sid'] => array (
  6803. 'date' => date ( 'Y-m-d' ),
  6804. 'opinion' => $opinion,
  6805. 'status' => $status
  6806. )
  6807. );
  6808. $vStaffString = json_encode ( $verifyStaff );
  6809. $receipt->nowStaff = $nowStaff;
  6810. $receipt->verifyStaff = $vStaffString;
  6811. } else {
  6812. $VS = end ( $verifyStaff );
  6813. // 非角色审批
  6814. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  6815. $nextStaff = 0;
  6816. $roleSTF = false;
  6817. foreach ( $verifyDetail as $key => $value ) {
  6818. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  6819. if (isset ( $verifyDetail [$key + 1] )) {
  6820. $nextStaff = $verifyDetail [$key + 1] [0];
  6821. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  6822. $roleSTF = true;
  6823. }
  6824. break;
  6825. }
  6826. }
  6827. if (! $roleSTF) {
  6828. $nowStaff = $nextStaff;
  6829. $verifyStaff [$this->staff [0] ['sid']] = array (
  6830. 'date' => date ( 'Y-m-d' ),
  6831. 'opinion' => $opinion,
  6832. 'status' => $status,
  6833. 'nextStaff' => $nextStaff
  6834. );
  6835. } else {
  6836. // 获取角色下的所有用户ID
  6837. $nowStaffList = array ();
  6838. foreach ( $verifyDetail as $vfk ) {
  6839. if ($vfk [1] == 'ROLE') {
  6840. $vStaffString = json_decode ( $vfk [3] );
  6841. foreach ( $vStaffString as $key => $value ) {
  6842. $staffK = explode ( "_", $value );
  6843. array_push ( $nowStaffList, $staffK [0] );
  6844. }
  6845. }
  6846. }
  6847. $nowStaff = implode ( ',', $nowStaffList );
  6848. $verifyStaff [$this->staff [0] ['sid']] = array (
  6849. 'date' => date ( 'Y-m-d' ),
  6850. 'opinion' => $opinion,
  6851. 'status' => $status,
  6852. 'nextStaff' => $nextStaff,
  6853. 'ROLE' => 0
  6854. );
  6855. }
  6856. if ($status == 3) {
  6857. $verifyStaff ['final'] = $status;
  6858. $verifyStaff [$this->staff [0] ['sid']] = array (
  6859. 'date' => date ( 'Y-m-d' ),
  6860. 'opinion' => $opinion,
  6861. 'status' => $status
  6862. );
  6863. }
  6864. $vStaffString = json_encode ( $verifyStaff );
  6865. $receipt->nowStaff = $nowStaff;
  6866. $receipt->verifyStaff = $vStaffString;
  6867. }
  6868. // 角色审批
  6869. if (isset ( $VS ['ROLE'] )) {
  6870. // 找出角色人 当前审批角色组
  6871. $verifyJSStaff = array ();
  6872. $nowStaffList2 = array ();
  6873. foreach ( $verifyDetail as $key => $value ) {
  6874. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  6875. $verifyJSStaff = json_decode ( $value [3] );
  6876. foreach ( $verifyJSStaff as $m ) {
  6877. $staffK = explode ( "_", $m );
  6878. array_push ( $nowStaffList2, $staffK [0] );
  6879. }
  6880. // print_r($nowStaffList2);
  6881. }
  6882. }
  6883. $RoleVerifyStaff = array ();
  6884. foreach ( $verifyStaff as $key => $value ) {
  6885. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  6886. foreach ( $nowStaffList2 as $m ) {
  6887. if ($key == $m . "_R")
  6888. $RoleVerifyStaff [$key] = $value;
  6889. }
  6890. }
  6891. }
  6892. // print_r($verifyStaff);
  6893. // print_r($nowStaffList2);
  6894. // print_r($RoleVerifyStaff);
  6895. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  6896. // print_r($verifyJSStaff);
  6897. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  6898. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  6899. // 下一个审批人ID
  6900. $nextStaff = 0;
  6901. $falg = false;
  6902. foreach ( $verifyDetail as $key => $value ) {
  6903. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  6904. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  6905. $falg = true;
  6906. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  6907. $nowStaffList = array ();
  6908. foreach ( $vStaffString as $v ) {
  6909. $staffK = explode ( "_", $v );
  6910. array_push ( $nowStaffList, $staffK [0] );
  6911. }
  6912. $nowStaff = implode ( ',', $nowStaffList );
  6913. $nextStaff = $verifyDetail [$key + 1] [0];
  6914. } elseif (isset ( $verifyDetail [$key + 1] )) {
  6915. $nextStaff = $verifyDetail [$key + 1] [0];
  6916. $nowStaff = $nextStaff;
  6917. } else
  6918. $nowStaff = '';
  6919. break;
  6920. }
  6921. }
  6922. if ($falg)
  6923. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6924. 'date' => date ( 'Y-m-d' ),
  6925. 'opinion' => $opinion,
  6926. 'status' => $status,
  6927. 'nextStaff' => $nextStaff,
  6928. 'ROLE' => 1
  6929. );
  6930. else
  6931. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6932. 'date' => date ( 'Y-m-d' ),
  6933. 'opinion' => $opinion,
  6934. 'status' => $status,
  6935. 'nextStaff' => $nextStaff
  6936. );
  6937. // print_r($verifyStaff);
  6938. // echo $nowStaff;die;
  6939. } else { // 进入下一个角色或者审批人
  6940. /*
  6941. *
  6942. */
  6943. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  6944. //
  6945. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  6946. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6947. 'date' => date ( 'Y-m-d' ),
  6948. 'opinion' => $opinion,
  6949. 'status' => $status,
  6950. 'nextStaff' => $VS ['nextStaff'],
  6951. 'ROLE' => 1
  6952. );
  6953. // print_r($verifyStaff);
  6954. // die;
  6955. }
  6956. if ($status == 3) {
  6957. $verifyStaff ['final'] = $status;
  6958. $verifyStaff [$this->staff [0] ['sid']] = array (
  6959. 'date' => date ( 'Y-m-d' ),
  6960. 'opinion' => $opinion,
  6961. 'status' => $status
  6962. );
  6963. }
  6964. $vStaffString = json_encode ( $verifyStaff );
  6965. $receipt->verifyStaff = $vStaffString;
  6966. $receipt->nowStaff = $nowStaff;
  6967. // die;
  6968. // }
  6969. // print_r($verifyStaff);
  6970. // die;
  6971. }
  6972. // print_r($verifyStaff);die;
  6973. }
  6974. // print_r($verifyDetail);
  6975. $roleKey = 0;
  6976. $roleId = 0;
  6977. $verifyDetailCopy = array ();
  6978. foreach ( $verifyDetail as $k => $v ) {
  6979. if ($v [1] == 'ROLE') {
  6980. $roleId = $v [0];
  6981. $roleVerify = json_decode ( $v [3], true );
  6982. $roleKey = $k;
  6983. $roleArray = array ();
  6984. foreach ( $roleVerify as $o => $p ) {
  6985. $staffID = explode ( '_', $p );
  6986. $exp = array (
  6987. 0 => $staffID [0],
  6988. 1 => $staffID [1]
  6989. );
  6990. array_push ( $roleArray, $exp );
  6991. }
  6992. $verifyDetailCopy [$v [0]] = $roleArray;
  6993. }
  6994. }
  6995. // print_r($verifyDetail);
  6996. foreach ( $verifyDetailCopy as $k => $v ) {
  6997. foreach ( $verifyDetail as $m => $n ) {
  6998. if ($n [0] == $k) {
  6999. array_splice ( $verifyDetail, $m, 1, $v );
  7000. }
  7001. }
  7002. }
  7003. // die;
  7004. // if (!empty($roleArray))
  7005. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  7006. // echo $roleId;
  7007. // print_r($verifyStaff);
  7008. // print_r($verifyDetail);
  7009. // die;
  7010. Doo::loadModel ( "receiptLog" );
  7011. $receiptLog = new receiptLog ();
  7012. // 审批日志
  7013. if (! isset ( $verifyStaff ['final'] )) {
  7014. if (! empty ( $roleId )) {
  7015. Doo::loadModel ( "role" );
  7016. $role = new role ();
  7017. $roleInfo = $role->getOne ( array (
  7018. 'where' => 'rid=' . $roleId,
  7019. 'asArray' => true
  7020. ) );
  7021. $receiptLog->rolename = $roleInfo ['name'];
  7022. }
  7023. $receiptLog->username = $this->staff [0] ['username'];
  7024. $receiptLog->uid = $this->staff [0] ['sid'];
  7025. $receiptLog->date = date ( "Y-m-d" );
  7026. $receiptLog->opinion = $opinion;
  7027. $receiptLog->img = $this->staff [0] ['avatar'];
  7028. $receiptLog->status = 1;
  7029. $receiptLog->rid = $rid;
  7030. $receiptLog->insert ();
  7031. }
  7032. if (isset ( $verifyStaff ['final'] )) { // rDetail
  7033. $receipt->verifyBreakup = $verifyString;
  7034. $receipt->status = 3;
  7035. $receiptDetailObj->status = 3;
  7036. $receiptDetailObj->update ( array (
  7037. 'where' => 'rid=' . $rid
  7038. ) );
  7039. if (! empty ( $roleId )) {
  7040. Doo::loadModel ( "role" );
  7041. $role = new role ();
  7042. $roleInfo = $role->getOne ( array (
  7043. 'where' => 'rid=' . $roleId,
  7044. 'asArray' => true
  7045. ) );
  7046. $receiptLog->rolename = $roleInfo ['name'];
  7047. }
  7048. $receiptLog->username = $this->staff [0] ['username'];
  7049. $receiptLog->uid = $this->staff [0] ['sid'];
  7050. $receiptLog->date = date ( "Y-m-d" );
  7051. $receiptLog->opinion = $opinion;
  7052. $receiptLog->img = $this->staff [0] ['avatar'];
  7053. $receiptLog->status = 3;
  7054. $receiptLog->rid = $rid;
  7055. $receiptLog->insert ();
  7056. // 微信企业号通知
  7057. $this->setWXMsg ( $rid, 3 );
  7058. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  7059. $receipt->status = 1;
  7060. $reviseSum = 0;
  7061. $receipt->verifyBreakup = $verifyString;
  7062. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  7063. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7064. foreach ( $reviseDetail as $key => $value ) {
  7065. $receiptDetailObj = new receiptDetail ();
  7066. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7067. $receiptDetailObj->item = $value ['description'];
  7068. $receiptDetailObj->itemCategory = "报销金额调整";
  7069. $receiptDetailObj->price = $value ['price'];
  7070. $receiptDetailObj->date = $receiptDetail ['date'];
  7071. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  7072. $receiptDetailObj->rid = $rid;
  7073. $receiptDetailObj->status = 1;
  7074. $receiptDetailObj->insert ();
  7075. $reviseSum += $value ['price'];
  7076. }
  7077. $itemStatistics = new itemStatistics ();
  7078. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7079. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7080. $itemStatistics->price = $reviseSum;
  7081. $itemStatistics->itemCategory = "报销金额调整";
  7082. $itemStatistics->date = $receiptDetail ['date'];
  7083. $itemStatistics->insert ();
  7084. }
  7085. $receiptDetailObj = new receiptDetail ();
  7086. $receiptDetailObj->status = 1;
  7087. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  7088. $receiptDetailObj->update ( array (
  7089. 'where' => 'rid=' . $rid
  7090. ) );
  7091. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7092. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7093. $stat = $statistics->getOne ( array (
  7094. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  7095. 'asArray' => true
  7096. ) );
  7097. if (empty ( $stat )) {
  7098. $statistics->date = $receiptDetail ['date'];
  7099. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7100. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7101. $statistics->agPrice = $receiptDetail ['sum'];
  7102. $statistics->rePrice = $reviseSum;
  7103. $statistics->insert ();
  7104. } else {
  7105. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  7106. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  7107. $statistics->update ( array (
  7108. 'where' => 'sid=' . $stat ['sid']
  7109. ) );
  7110. }
  7111. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7112. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7113. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  7114. foreach ( $accountItem ['cSum'] as $key => $value ) {
  7115. if ($key == "agencySum") {
  7116. $iStatistics = $itemStatistics->getOne ( array (
  7117. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  7118. 'asArray' => true
  7119. ) );
  7120. if (empty ( $iStatistics )) {
  7121. $itemStatistics->cid = $receiptDetail ['cid'];
  7122. ;
  7123. $itemStatistics->staff = $receiptDetail ['staff'];
  7124. $itemStatistics->price = $value;
  7125. $itemStatistics->itemCategory = $this->AGENCY;
  7126. $itemStatistics->date = $receiptDetail ['date'];
  7127. $itemStatistics->insert ();
  7128. } else {
  7129. if (! empty ( $value )) {
  7130. $itemStatistics->price = $value + $iStatistics ['price'];
  7131. $itemStatistics->update ( array (
  7132. 'where' => 'sid=' . $iStatistics ['sid']
  7133. ) );
  7134. }
  7135. }
  7136. } elseif ($key == "travelSum") {
  7137. $iStatistics = $itemStatistics->getOne ( array (
  7138. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  7139. 'asArray' => true
  7140. ) );
  7141. if (empty ( $iStatistics )) {
  7142. $itemStatistics->cid = $receiptDetail ['cid'];
  7143. $itemStatistics->staff = $receiptDetail ['staff'];
  7144. $itemStatistics->price = $value;
  7145. $itemStatistics->itemCategory = $this->TRAVEL;
  7146. $itemStatistics->date = $receiptDetail ['date'];
  7147. $itemStatistics->insert ();
  7148. } else {
  7149. if (! empty ( $value )) {
  7150. $itemStatistics->price = $value + $iStatistics ['price'];
  7151. $itemStatistics->update ( array (
  7152. 'where' => 'sid=' . $iStatistics ['sid']
  7153. ) );
  7154. }
  7155. }
  7156. } elseif ($key == "trainSum") {
  7157. $iStatistics = $itemStatistics->getOne ( array (
  7158. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  7159. 'asArray' => true
  7160. ) );
  7161. if (empty ( $iStatistics )) {
  7162. $itemStatistics->cid = $receiptDetail ['cid'];
  7163. $itemStatistics->staff = $receiptDetail ['staff'];
  7164. $itemStatistics->price = $value;
  7165. $itemStatistics->itemCategory = $this->TRAIN;
  7166. $itemStatistics->date = $receiptDetail ['date'];
  7167. $itemStatistics->insert ();
  7168. } else {
  7169. if (! empty ( $value )) {
  7170. $itemStatistics->price = $value + $iStatistics ['price'];
  7171. $itemStatistics->update ( array (
  7172. 'where' => 'sid=' . $iStatistics ['sid']
  7173. ) );
  7174. }
  7175. }
  7176. } elseif ($key == "otherSum") {
  7177. $iStatistics = $itemStatistics->getOne ( array (
  7178. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  7179. 'asArray' => true
  7180. ) );
  7181. if (empty ( $iStatistics )) {
  7182. $itemStatistics->cid = $receiptDetail ['cid'];
  7183. $itemStatistics->staff = $receiptDetail ['staff'];
  7184. $itemStatistics->price = $value;
  7185. $itemStatistics->itemCategory = $this->OTHER;
  7186. $itemStatistics->date = $receiptDetail ['date'];
  7187. $itemStatistics->insert ();
  7188. } else {
  7189. if (! empty ( $value )) {
  7190. $itemStatistics->price = $value + $iStatistics ['price'];
  7191. $itemStatistics->update ( array (
  7192. 'where' => 'sid=' . $iStatistics ['sid']
  7193. ) );
  7194. }
  7195. }
  7196. }
  7197. }
  7198. $receipt->pastDate = date ( "Y-m-d" );
  7199. // 微信企业号通知
  7200. $this->setWXMsg ( $rid, 1 );
  7201. }
  7202. $receipt->amount = $amount;
  7203. $receipt->update ( array (
  7204. 'where' => ' rid = ' . $rid
  7205. ) );
  7206. return "/approvalExpenses/pendApproval";
  7207. }
  7208. }
  7209. function expensesRetreats() {
  7210. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7211. if (! empty ( $rid )) {
  7212. // 操作记录
  7213. Doo::loadModel ( "receipt" );
  7214. $receipt = new receipt ();
  7215. Doo::loadModel ( "receiptLog" );
  7216. $receiptLog = new receiptLog ();
  7217. Doo::loadModel ( "verify" );
  7218. $verify = new verify ();
  7219. $receiptInfo = $receipt->getOne ( array (
  7220. 'where' => 'rid=' . $rid,
  7221. 'asArray' => true
  7222. ) );
  7223. $vr = $verify->getOne ( array (
  7224. 'where' => 'vid=' . $receiptInfo ['verify'],
  7225. 'asArray' => true
  7226. ) );
  7227. $jd = json_decode ( $vr ['staff'] );
  7228. $roleId = 0;
  7229. foreach ( $jd as $key => $value ) {
  7230. if ($value [1] == 'ROLE') {
  7231. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7232. if ($pos !== false) {
  7233. $roleId = $value [0];
  7234. }
  7235. }
  7236. }
  7237. // 审批日志
  7238. // echo $roleId;die;
  7239. if (! empty ( $roleId )) {
  7240. Doo::loadModel ( "role" );
  7241. $role = new role ();
  7242. $roleInfo = $role->getOne ( array (
  7243. 'where' => 'rid=' . $roleId,
  7244. 'asArray' => true
  7245. ) );
  7246. $receiptLog->rolename = $roleInfo ['name'];
  7247. }
  7248. $receiptLog->username = $this->staff [0] ['username'];
  7249. $receiptLog->uid = $this->staff [0] ['sid'];
  7250. $receiptLog->date = date ( "Y-m-d" );
  7251. $receiptLog->opinion = '撤回';
  7252. $receiptLog->img = $this->staff [0] ['avatar'];
  7253. $receiptLog->status = 4;
  7254. $receiptLog->rid = $rid;
  7255. $receiptLog->insert ();
  7256. $receipt->status = 4;
  7257. $receipt->update ( array (
  7258. 'where' => 'rid=' . $rid
  7259. ) );
  7260. // 微信企业号通知
  7261. $this->setWXMsg ( $rid, 2 );
  7262. }
  7263. // echo "ddd";
  7264. return '/approvalExpenses/pendApproval';
  7265. }
  7266. function updateCheReceipt() {
  7267. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7268. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7269. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  7270. if (! empty ( $rid )) {
  7271. // 操作记录
  7272. Doo::loadModel ( "receipt" );
  7273. $receipt = new receipt ();
  7274. Doo::loadModel ( "receiptLog" );
  7275. $receiptLog = new receiptLog ();
  7276. Doo::loadModel ( "verify" );
  7277. $verify = new verify ();
  7278. $receiptInfo = $receipt->getOne ( array (
  7279. 'where' => 'rid=' . $rid.' and status=2',
  7280. 'asArray' => true
  7281. ) );
  7282. if(empty($receiptInfo)){
  7283. echo json_encode ( array (
  7284. 'status' => 2
  7285. ) );
  7286. die ();
  7287. }
  7288. $vr = $verify->getOne ( array (
  7289. 'where' => 'vid=' . $receiptInfo ['verify'],
  7290. 'asArray' => true
  7291. ) );
  7292. $jd = json_decode ( $vr ['staff'] );
  7293. $roleId = 0;
  7294. foreach ( $jd as $key => $value ) {
  7295. if ($value [1] == 'ROLE') {
  7296. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7297. if ($pos !== false) {
  7298. $roleId = $value [0];
  7299. }
  7300. }
  7301. }
  7302. // 审批日志
  7303. // echo $roleId;die;
  7304. if (! empty ( $roleId )) {
  7305. Doo::loadModel ( "role" );
  7306. $role = new role ();
  7307. $roleInfo = $role->getOne ( array (
  7308. 'where' => 'rid=' . $roleId,
  7309. 'asArray' => true
  7310. ) );
  7311. $receiptLog->rolename = $roleInfo ['name'];
  7312. }
  7313. $receiptLog->username = $this->staff [0] ['username'];
  7314. $receiptLog->uid = $this->staff [0] ['sid'];
  7315. $receiptLog->date = date ( "Y-m-d" );
  7316. $receiptLog->opinion = $opinion;
  7317. $receiptLog->img = $this->staff [0] ['avatar'];
  7318. $receiptLog->status = 4;
  7319. $receiptLog->rid = $rid;
  7320. $receiptLog->insert ();
  7321. $receipt->status = 4;
  7322. $receipt->update ( array (
  7323. 'where' => 'rid=' . $rid
  7324. ) );
  7325. // 微信企业号通知
  7326. $this->setWXMsg ( $rid, 2 );
  7327. echo json_encode ( array (
  7328. 'status' => 1
  7329. ) );
  7330. //Header("HTTP/1.1 303 See Other");
  7331. //Header("Location: /approvalExpenses/pendApproval");
  7332. die;
  7333. }
  7334. echo json_encode ( array (
  7335. 'status' => 2
  7336. ) );
  7337. die ();
  7338. // echo "ddd";
  7339. // return '/saeaBorad';
  7340. }
  7341. function revisePrice() {
  7342. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  7343. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  7344. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7345. // echo $price;die;
  7346. if (! empty ( $rid )) {
  7347. Doo::loadModel ( "receipt" );
  7348. $receipt = new receipt ();
  7349. $receiptDetail = $receipt->getOne ( array (
  7350. 'where' => 'rid=' . $rid . ' and status=2 ',
  7351. 'asArray' => true
  7352. ) );
  7353. if (empty ( $receiptDetail ))
  7354. return "/approval";
  7355. $reviseDetail = array ();
  7356. if (empty ( $receiptDetail ['reviseDetail'] )) {
  7357. array_push ( $reviseDetail, array (
  7358. 'sid' => $this->staff [0] ['sid'],
  7359. 'name' => $this->staff [0] ['username'],
  7360. 'description' => $description,
  7361. 'price' => $price
  7362. ) );
  7363. $reviseDetailString = json_encode ( $reviseDetail );
  7364. $receipt->reviseDetail = $reviseDetailString;
  7365. $receipt->revisePrice = $price;
  7366. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7367. } else {
  7368. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7369. array_push ( $reviseDetail, array (
  7370. 'sid' => $this->staff [0] ['sid'],
  7371. 'name' => $this->staff [0] ['username'],
  7372. 'description' => $description,
  7373. 'price' => $price
  7374. ) );
  7375. $reviseDetailString = json_encode ( $reviseDetail );
  7376. $receipt->reviseDetail = $reviseDetailString;
  7377. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  7378. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7379. }
  7380. $receipt->update ( array (
  7381. 'where' => 'rid=' . $rid
  7382. ) );
  7383. }
  7384. return '/approvalEdi/' . $rid;
  7385. }
  7386. function personalCollect() {
  7387. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7388. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  7389. $this->showCache ( $path );
  7390. Doo::loadModel ( "receiptDetail" );
  7391. Doo::loadModel ( "itemStatistics" );
  7392. Doo::loadModel ( 'statistics' );
  7393. $statistics = new statistics ();
  7394. $itemStatistics = new itemStatistics ();
  7395. $receiptDetail = new receiptDetail ();
  7396. $receiptCollectList = $receiptDetail->find ( array (
  7397. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7398. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7399. 'groupby' => 'itemCategory,Month(date)',
  7400. 'asArray' => true
  7401. ) );
  7402. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  7403. 'where' => 'staff=' . $this->staff [0] ['sid'],
  7404. 'asArray' => true
  7405. ) );
  7406. // create collect html
  7407. $collectArray = array (
  7408. '日常相关费用' => array (),
  7409. '差旅相关费用' => array (),
  7410. '培训班费用' => array (),
  7411. '其他' => array ()
  7412. );
  7413. $adjustment = array ();
  7414. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  7415. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7416. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  7417. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7418. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  7419. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7420. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  7421. array_push ( $collectArray ['其他'], $collectHtml );
  7422. $data ['collectArray'] = $collectArray;
  7423. // statistics html
  7424. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7425. if (empty ( $stList ))
  7426. $stList = array (
  7427. 'rePrice' => 0,
  7428. 'agPrice' => 0
  7429. );
  7430. $data ['stList'] = array (
  7431. 'rePrice' => $stList ['rePrice'],
  7432. 'agPrice' => $stList ['agPrice'],
  7433. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7434. );
  7435. // Adjustment price html
  7436. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7437. array_push ( $adjustment, $collectHtml );
  7438. $data ['adjustment'] = $adjustment;
  7439. // total price html
  7440. $collectHtml = "";
  7441. $total = 0;
  7442. for($i = 1; $i <= 12; $i ++) {
  7443. $sumPrice = 0;
  7444. foreach ( $receiptCollectList as $key => $value ) {
  7445. if ($value ['month'] == $i) {
  7446. $sumPrice += $value ['price'];
  7447. }
  7448. }
  7449. if ($sumPrice == 0)
  7450. $collectHtml .= '<td class="taR">-</td>';
  7451. else
  7452. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7453. $total += $sumPrice;
  7454. }
  7455. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7456. $data ['totalPrice'] = $collectHtml;
  7457. $data ['year'] = $year;
  7458. $data ['totalYear'] = $total;
  7459. $data ['memu'] = "receipt";
  7460. $data ['staff'] = $this->staff;
  7461. $data ['receiptMemu'] = 'personalCollect';
  7462. $data ['verifyId'] = $this->verifyId;
  7463. $data ['executeId'] = $this->executeId;
  7464. // year staff status 2,4
  7465. if ($year < date ( "Y" )) {
  7466. Doo::loadModel ( 'receipt' );
  7467. $receipt = new receipt ();
  7468. $receiptList = $receipt->find ( array (
  7469. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7470. 'asArray' => true
  7471. ) );
  7472. if (empty ( $receiptList )) {
  7473. ob_start ();
  7474. $this->render ( "/admin/saea_slist_collect", $data );
  7475. $this->cacheFile ( $path );
  7476. die ();
  7477. }
  7478. }
  7479. $this->render ( "/admin/saea_slist_collect", $data );
  7480. }
  7481. function personalCollectDetail() {
  7482. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7483. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  7484. $this->showCache ( $path );
  7485. Doo::loadModel ( "receiptDetail" );
  7486. Doo::loadModel ( "itemStatistics" );
  7487. Doo::loadModel ( 'statistics' );
  7488. Doo::loadModel ( 'accountItem' );
  7489. $accountItem = new accountItem ();
  7490. $statistics = new statistics ();
  7491. $itemStatistics = new itemStatistics ();
  7492. $receiptDetail = new receiptDetail ();
  7493. $receiptCollectList = $receiptDetail->find ( array (
  7494. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  7495. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7496. 'groupby' => 'item,Month(date)',
  7497. 'asArray' => true
  7498. ) );
  7499. $accountList = $accountItem->find ( array (
  7500. 'asArray' => true
  7501. ) );
  7502. // create CollectDetail HTML
  7503. $collectHtml = array ();
  7504. foreach ( $accountList as $key => $value ) {
  7505. $html = "";
  7506. $asum = 0;
  7507. for($i = 1; $i <= 12; $i ++) {
  7508. $falg = true;
  7509. foreach ( $receiptCollectList as $v ) {
  7510. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7511. $asum += $v ['price'];
  7512. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7513. $falg = false;
  7514. break;
  7515. }
  7516. }
  7517. if ($falg)
  7518. $html .= '<td class="taR">-</td>';
  7519. }
  7520. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7521. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7522. }
  7523. $data ['collectHtml'] = $collectHtml;
  7524. // create Adjustment price html
  7525. $receiptCollectList = $receiptDetail->find ( array (
  7526. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7527. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7528. 'groupby' => 'itemCategory,Month(date)',
  7529. 'asArray' => true
  7530. ) );
  7531. $adjustment = array ();
  7532. $collectArray = array (
  7533. '日常相关费用' => array (),
  7534. '差旅相关费用' => array (),
  7535. '培训班费用' => array (),
  7536. '其他' => array ()
  7537. );
  7538. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7539. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7540. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7541. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7542. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7543. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7544. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7545. array_push ( $collectArray ['其他'], $collectHtml );
  7546. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7547. array_push ( $adjustment, $collectHtml );
  7548. // total price html
  7549. $collectHtml = "";
  7550. $total = 0;
  7551. for($i = 1; $i <= 12; $i ++) {
  7552. $sumPrice = 0;
  7553. foreach ( $receiptCollectList as $key => $value ) {
  7554. if ($value ['month'] == $i) {
  7555. $sumPrice += $value ['price'];
  7556. }
  7557. }
  7558. if ($sumPrice == 0)
  7559. $collectHtml .= '<td class="taR">-</td>';
  7560. else
  7561. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7562. $total += $sumPrice;
  7563. }
  7564. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7565. // statistics html
  7566. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7567. if (empty ( $stList ))
  7568. $stList = array (
  7569. 'rePrice' => 0,
  7570. 'agPrice' => 0
  7571. );
  7572. $data ['stList'] = array (
  7573. 'rePrice' => $stList ['rePrice'],
  7574. 'agPrice' => $stList ['agPrice'],
  7575. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7576. );
  7577. $data ['collectArray'] = $collectArray;
  7578. $data ['adjustment'] = $adjustment;
  7579. $data ['totalPrice'] = $collectHtml;
  7580. $data ['totalYear'] = $total;
  7581. $data ['year'] = $year;
  7582. $data ['memu'] = "receipt";
  7583. $data ['staff'] = $this->staff;
  7584. $data ['receiptMemu'] = 'personalCollect';
  7585. $data ['verifyId'] = $this->verifyId;
  7586. $data ['executeId'] = $this->executeId;
  7587. // year staff status 2,4
  7588. if ($year < date ( "Y" )) {
  7589. Doo::loadModel ( 'receipt' );
  7590. $receipt = new receipt ();
  7591. $receiptList = $receipt->find ( array (
  7592. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7593. 'asArray' => true
  7594. ) );
  7595. if (empty ( $receiptList )) {
  7596. ob_start ();
  7597. $this->render ( "/admin/saeaCollectArticles", $data );
  7598. $this->cacheFile ( $path );
  7599. die ();
  7600. }
  7601. }
  7602. $this->render ( "/admin/saeaCollectArticles", $data );
  7603. }
  7604. function companyCategoryCollect() {
  7605. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7606. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  7607. $this->showCache ( $path );
  7608. Doo::loadModel ( 'L_category' );
  7609. Doo::loadModel ( 'itemStatistics' );
  7610. Doo::loadModel ( 'statistics' );
  7611. $statistics = new statistics ();
  7612. $Lcategory = new L_category ();
  7613. $itemStatistics = new itemStatistics ();
  7614. $LcategoryList = $Lcategory->find ( array (
  7615. 'asArray' => true
  7616. ) ); // 'staff='.$this->staff[0]['sid']." and
  7617. $itemStatisticsList = $itemStatistics->find ( array (
  7618. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7619. 'where' => " Year(date)=" . $year,
  7620. 'groupby' => 'cid,Month(date)',
  7621. 'asArray' => true
  7622. ) );
  7623. // ceatre companyCollectHtml
  7624. foreach ( $LcategoryList as $value ) {
  7625. $html = "";
  7626. $asum = 0;
  7627. for($i = 1; $i <= 12; $i ++) {
  7628. $falg = true;
  7629. foreach ( $itemStatisticsList as $v ) {
  7630. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  7631. $asum += $v ['price'];
  7632. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7633. $falg = false;
  7634. break;
  7635. }
  7636. }
  7637. if ($falg)
  7638. $html .= '<td class="taR">-</td>';
  7639. }
  7640. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7641. $collectHtml [$value ['title']] = array (
  7642. 'html' => $html,
  7643. 'cid' => $value ['cid']
  7644. );
  7645. }
  7646. $data ['companyHtml'] = $collectHtml;
  7647. // total price html
  7648. $collectHtml = "";
  7649. $total = 0;
  7650. for($i = 1; $i <= 12; $i ++) {
  7651. $sumPrice = 0;
  7652. foreach ( $itemStatisticsList as $key => $value ) {
  7653. if ($value ['month'] == $i) {
  7654. $sumPrice += $value ['price'];
  7655. }
  7656. }
  7657. if ($sumPrice == 0)
  7658. $collectHtml .= '<td class="taR">-</td>';
  7659. else
  7660. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7661. $total += $sumPrice;
  7662. }
  7663. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7664. $data ['companyTotalHtml'] = $collectHtml;
  7665. $data ['total'] = $total;
  7666. // statistics html
  7667. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7668. if (empty ( $stList ))
  7669. $stList = array (
  7670. 'rePrice' => 0,
  7671. 'agPrice' => 0
  7672. );
  7673. $data ['stList'] = array (
  7674. 'rePrice' => $stList ['rePrice'],
  7675. 'agPrice' => $stList ['agPrice'],
  7676. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7677. );
  7678. $data ['year'] = $year;
  7679. $data ['memu'] = "receipt";
  7680. $data ['staff'] = $this->staff;
  7681. $data ['receiptMemu'] = 'companyCategoryCollect';
  7682. $data ['verifyId'] = $this->verifyId;
  7683. $data ['executeId'] = $this->executeId;
  7684. // year staff status 2,4
  7685. if ($year < date ( "Y" )) {
  7686. Doo::loadModel ( 'receipt' );
  7687. $receipt = new receipt ();
  7688. $receiptList = $receipt->find ( array (
  7689. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  7690. 'asArray' => true
  7691. ) );
  7692. if (empty ( $receiptList )) {
  7693. ob_start ();
  7694. $this->render ( "/admin/saeaCompanyCollect", $data );
  7695. $this->cacheFile ( $path );
  7696. die ();
  7697. }
  7698. }
  7699. $this->render ( "/admin/saeaCompanyCollect", $data );
  7700. }
  7701. function categoryCollectDetail() {
  7702. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7703. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  7704. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  7705. $this->showCache ( $path );
  7706. Doo::loadModel ( 'statistics' );
  7707. $statistics = new statistics ();
  7708. Doo::loadModel ( "receiptDetail" );
  7709. $receiptDetail = new receiptDetail ();
  7710. Doo::loadModel ( 'L_category' );
  7711. $Lcategory = new L_category ();
  7712. Doo::loadModel ( 'accountItem' );
  7713. $accountItem = new accountItem ();
  7714. $LcategoryList = $Lcategory->find ( array (
  7715. 'asArray' => true
  7716. ) );
  7717. if ($cid == 0) {
  7718. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7719. if ($cid == 0)
  7720. $cid = $LcategoryList [0] ['cid'];
  7721. }
  7722. $data ['LcategoryList'] = $LcategoryList;
  7723. $receiptCollectList = $receiptDetail->find ( array (
  7724. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  7725. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7726. 'groupby' => 'item,Month(pastDate)',
  7727. 'asArray' => true
  7728. ) );
  7729. $accountList = $accountItem->find ( array (
  7730. 'asArray' => true
  7731. ) );
  7732. // create CollectDetail HTML
  7733. $collectHtml = array ();
  7734. foreach ( $accountList as $key => $value ) {
  7735. $html = "";
  7736. $asum = 0;
  7737. for($i = 1; $i <= 12; $i ++) {
  7738. $falg = true;
  7739. foreach ( $receiptCollectList as $v ) {
  7740. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7741. $asum += $v ['price'];
  7742. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7743. $falg = false;
  7744. break;
  7745. }
  7746. }
  7747. if ($falg)
  7748. $html .= '<td class="taR">-</td>';
  7749. }
  7750. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7751. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7752. }
  7753. $data ['collectHtml'] = $collectHtml;
  7754. // create Adjustment price html
  7755. $receiptCollectList = $receiptDetail->find ( array (
  7756. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  7757. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7758. 'groupby' => 'itemCategory,Month(pastDate)',
  7759. 'asArray' => true
  7760. ) );
  7761. $adjustment = array ();
  7762. $collectArray = array (
  7763. '日常相关费用' => array (),
  7764. '差旅相关费用' => array (),
  7765. '培训班费用' => array (),
  7766. '其他' => array ()
  7767. );
  7768. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7769. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7770. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7771. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7772. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7773. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7774. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7775. array_push ( $collectArray ['其他'], $collectHtml );
  7776. $data ['collectArray'] = $collectArray;
  7777. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7778. array_push ( $adjustment, $collectHtml );
  7779. $data ['adjustment'] = $adjustment;
  7780. // total price html
  7781. $collectHtml = "";
  7782. $total = 0;
  7783. for($i = 1; $i <= 12; $i ++) {
  7784. $sumPrice = 0;
  7785. foreach ( $receiptCollectList as $key => $value ) {
  7786. if ($value ['month'] == $i) {
  7787. $sumPrice += $value ['price'];
  7788. }
  7789. }
  7790. if ($sumPrice == 0)
  7791. $collectHtml .= '<td class="taR">-</td>';
  7792. else
  7793. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7794. $total += $sumPrice;
  7795. }
  7796. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7797. // statistics html
  7798. $stList = $statistics->statisticsByCid ( $year, $cid );
  7799. if (empty ( $stList ))
  7800. $stList = array (
  7801. 'rePrice' => 0,
  7802. 'agPrice' => 0
  7803. );
  7804. $data ['stList'] = array (
  7805. 'rePrice' => $stList ['rePrice'],
  7806. 'agPrice' => $stList ['agPrice'],
  7807. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7808. );
  7809. $data ['totalYear'] = $total;
  7810. $data ['year'] = $year;
  7811. $data ['cid'] = $cid;
  7812. $data ['memu'] = "receipt";
  7813. $data ['staff'] = $this->staff;
  7814. $data ['receiptMemu'] = 'companyCategoryCollect';
  7815. $data ['verifyId'] = $this->verifyId;
  7816. $data ['executeId'] = $this->executeId;
  7817. // year staff status 2,4
  7818. if ($year < date ( "Y" )) {
  7819. Doo::loadModel ( 'receipt' );
  7820. $receipt = new receipt ();
  7821. $receiptList = $receipt->find ( array (
  7822. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  7823. 'asArray' => true
  7824. ) );
  7825. if (empty ( $receiptList )) {
  7826. ob_start ();
  7827. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7828. $this->cacheFile ( $path );
  7829. die ();
  7830. }
  7831. }
  7832. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7833. }
  7834. function staffCollect() {
  7835. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7836. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  7837. // $this->showCache($path);
  7838. Doo::loadModel ( 'statistics' );
  7839. $statistics = new statistics ();
  7840. Doo::loadModel ( "receiptDetail" );
  7841. $receiptDetail = new receiptDetail ();
  7842. Doo::loadModel ( 'L_category' );
  7843. $Lcategory = new L_category ();
  7844. Doo::loadModel ( 'accountItem' );
  7845. $accountItem = new accountItem ();
  7846. Doo::loadModel ( 'staff' );
  7847. $staff = new staff ();
  7848. Doo::loadModel ( 'itemStatistics' );
  7849. $itemStatistics = new itemStatistics ();
  7850. /*
  7851. * $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']));
  7852. */
  7853. // statistics html
  7854. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7855. if (empty ( $stList ))
  7856. $stList = array (
  7857. 'rePrice' => 0,
  7858. 'agPrice' => 0
  7859. );
  7860. $data ['stList'] = array (
  7861. 'rePrice' => $stList ['rePrice'],
  7862. 'agPrice' => $stList ['agPrice'],
  7863. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7864. );
  7865. // ---
  7866. $staffList = $staff->find ( array (
  7867. 'where' => 'username !="admin"',
  7868. 'asArray' => true
  7869. ) );
  7870. $LcategoryList = $Lcategory->find ( array (
  7871. 'asArray' => true
  7872. ) ); // 'staff='.$this->staff[0]['sid']." and
  7873. $itemStatisticsList = $itemStatistics->find ( array (
  7874. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7875. 'where' => " Year(date)=" . $year,
  7876. 'groupby' => 'staff,Month(date)',
  7877. 'asArray' => true
  7878. ) );
  7879. $categoryList = $staff->find ( array (
  7880. 'select' => 'COUNT(*) as count,cid,category',
  7881. 'where' => 'username !="admin"',
  7882. 'groupby' => 'cid',
  7883. 'asArray' => true
  7884. ) );
  7885. // print_r($itemStatisticsList);die;
  7886. // ceatre companyCollectHtml
  7887. foreach ( $categoryList as $vlu ) {
  7888. $count = $vlu ['count'] + 1;
  7889. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  7890. $m1 = 0;
  7891. $m2 = 0;
  7892. $m3 = 0;
  7893. $m4 = 0;
  7894. $m5 = 0;
  7895. $m6 = 0;
  7896. $m7 = 0;
  7897. $m8 = 0;
  7898. $m9 = 0;
  7899. $m10 = 0;
  7900. $m11 = 0;
  7901. $m12 = 0;
  7902. $m13 = 0;
  7903. foreach ( $staffList as $value ) {
  7904. if ($vlu ['cid'] == $value ['cid']) {
  7905. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  7906. $asum = 0;
  7907. for($i = 1; $i <= 12; $i ++) {
  7908. $falg = true;
  7909. foreach ( $itemStatisticsList as $v ) {
  7910. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  7911. if ($v ['month'] == 1)
  7912. $m1 += $v ['price'];
  7913. if ($v ['month'] == 2)
  7914. $m2 += $v ['price'];
  7915. if ($v ['month'] == 3)
  7916. $m3 += $v ['price'];
  7917. if ($v ['month'] == 4)
  7918. $m4 += $v ['price'];
  7919. if ($v ['month'] == 5)
  7920. $m5 += $v ['price'];
  7921. if ($v ['month'] == 6)
  7922. $m6 += $v ['price'];
  7923. if ($v ['month'] == 7)
  7924. $m7 += $v ['price'];
  7925. if ($v ['month'] == 8)
  7926. $m8 += $v ['price'];
  7927. if ($v ['month'] == 9)
  7928. $m9 += $v ['price'];
  7929. if ($v ['month'] == 10)
  7930. $m10 += $v ['price'];
  7931. if ($v ['month'] == 11)
  7932. $m11 += $v ['price'];
  7933. if ($v ['month'] == 12)
  7934. $m12 += $v ['price'];
  7935. $asum += $v ['price'];
  7936. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7937. $falg = false;
  7938. break;
  7939. }
  7940. }
  7941. if ($falg)
  7942. $html .= '<td class="taR">-</td>';
  7943. }
  7944. $m13 += $asum;
  7945. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7946. $collectHtml [$value ['username']] = array (
  7947. 'html' => $html,
  7948. 'sid' => $value ['sid']
  7949. );
  7950. $html = "";
  7951. }
  7952. }
  7953. $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>
  7954. <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>
  7955. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  7956. $collectHtml [$vlu ['cid']] = array (
  7957. 'html' => $hl,
  7958. 'sid' => ''
  7959. );
  7960. }
  7961. $data ['companyHtml'] = $collectHtml;
  7962. // total price html
  7963. $collectHtml = "";
  7964. $total = 0;
  7965. for($i = 1; $i <= 12; $i ++) {
  7966. $sumPrice = 0;
  7967. foreach ( $itemStatisticsList as $key => $value ) {
  7968. if ($value ['month'] == $i) {
  7969. $sumPrice += $value ['price'];
  7970. }
  7971. }
  7972. if ($sumPrice == 0)
  7973. $collectHtml .= '<td class="taR">-</td>';
  7974. else
  7975. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7976. $total += $sumPrice;
  7977. }
  7978. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7979. $data ['companyTotalHtml'] = $collectHtml;
  7980. $data ['total'] = $total;
  7981. $data ['year'] = $year;
  7982. $data ['memu'] = "receipt";
  7983. $data ['staff'] = $this->staff;
  7984. $data ['receiptMemu'] = 'companyCategoryCollect';
  7985. $data ['verifyId'] = $this->verifyId;
  7986. $data ['executeId'] = $this->executeId;
  7987. if ($year <= date ( "Y" )) {
  7988. Doo::loadModel ( 'receipt' );
  7989. $receipt = new receipt ();
  7990. $receiptList = $receipt->find ( array (
  7991. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  7992. 'asArray' => true
  7993. ) );
  7994. if (empty ( $receiptList )) { // generated files
  7995. ob_start ();
  7996. $this->render ( "/admin/saeaStaffCollectB", $data );
  7997. $this->cacheFile ( $path );
  7998. die ();
  7999. }
  8000. }
  8001. $this->render ( "/admin/saeaStaffCollectB", $data );
  8002. }
  8003. function staffCollectBak() {
  8004. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8005. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  8006. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  8007. $this->showCache ( $path );
  8008. Doo::loadModel ( 'statistics' );
  8009. $statistics = new statistics ();
  8010. Doo::loadModel ( "receiptDetail" );
  8011. $receiptDetail = new receiptDetail ();
  8012. Doo::loadModel ( 'L_category' );
  8013. $Lcategory = new L_category ();
  8014. Doo::loadModel ( 'accountItem' );
  8015. $accountItem = new accountItem ();
  8016. Doo::loadModel ( 'staff' );
  8017. $staff = new staff ();
  8018. Doo::loadModel ( 'itemStatistics' );
  8019. $itemStatistics = new itemStatistics ();
  8020. $itemStatisticsList = $itemStatistics->find ( array (
  8021. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8022. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8023. 'groupby' => 'staff,itemCategory,Month(date)',
  8024. 'asArray' => true
  8025. ) );
  8026. $itemCategoryList = $itemStatistics->find ( array (
  8027. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8028. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8029. 'groupby' => 'cid,itemCategory,Month(date)',
  8030. 'asArray' => true
  8031. ) );
  8032. $LcategoryList = $Lcategory->find ( array (
  8033. 'asArray' => true
  8034. ) );
  8035. $staffList = $staff->find ( array (
  8036. 'asArray' => true
  8037. ) );
  8038. $htmlArray = array ();
  8039. foreach ( $LcategoryList as $value ) {
  8040. $htmlArray [$value ['title']] = array ();
  8041. foreach ( $staffList as $v ) {
  8042. if ($value ['cid'] == $v ['cid']) {
  8043. $html = "";
  8044. $falg = true;
  8045. $staffSumPrice = 0;
  8046. foreach ( $itemStatisticsList as $a ) {
  8047. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  8048. if (empty ( $a ['price'] )) {
  8049. $html .= '<td class="taR">-</td>';
  8050. $falg = false;
  8051. break;
  8052. } else {
  8053. $staffSumPrice += $a ['price'];
  8054. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8055. $falg = false;
  8056. break;
  8057. }
  8058. }
  8059. }
  8060. if ($falg) {
  8061. $html .= '<td class="taR">-</td>';
  8062. $falg = true;
  8063. }
  8064. $falg = true;
  8065. foreach ( $itemStatisticsList as $a ) {
  8066. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  8067. if (empty ( $a ['price'] )) {
  8068. $html .= '<td class="taR">-</td>';
  8069. $falg = false;
  8070. break;
  8071. } else {
  8072. $staffSumPrice += $a ['price'];
  8073. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8074. $falg = false;
  8075. break;
  8076. }
  8077. }
  8078. }
  8079. if ($falg) {
  8080. $html .= '<td class="taR">-</td>';
  8081. $falg = true;
  8082. }
  8083. $falg = true;
  8084. foreach ( $itemStatisticsList as $a ) {
  8085. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  8086. if (empty ( $a ['price'] )) {
  8087. $html .= '<td class="taR">-</td>';
  8088. $falg = false;
  8089. break;
  8090. } else {
  8091. $staffSumPrice += $a ['price'];
  8092. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8093. $falg = false;
  8094. break;
  8095. }
  8096. }
  8097. }
  8098. if ($falg) {
  8099. $html .= '<td class="taR">-</td>';
  8100. $falg = true;
  8101. }
  8102. $falg = true;
  8103. foreach ( $itemStatisticsList as $a ) {
  8104. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  8105. if (! empty ( $a ['price'] )) {
  8106. $staffSumPrice += $a ['price'];
  8107. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8108. $falg = false;
  8109. break;
  8110. } else {
  8111. $html .= '<td class="taR">-</td>';
  8112. $falg = false;
  8113. break;
  8114. }
  8115. }
  8116. }
  8117. if ($falg) {
  8118. $html .= '<td class="taR">-</td>';
  8119. $falg = true;
  8120. }
  8121. $falg = true;
  8122. foreach ( $itemStatisticsList as $a ) {
  8123. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  8124. if (! empty ( $a ['price'] )) {
  8125. $staffSumPrice += $a ['price'];
  8126. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8127. $falg = false;
  8128. break;
  8129. } else {
  8130. $html .= '<td class="taR">-</td>';
  8131. $falg = false;
  8132. break;
  8133. }
  8134. }
  8135. }
  8136. if ($falg) {
  8137. $html .= '<td class="taR">-</td>';
  8138. $falg = true;
  8139. }
  8140. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  8141. $htmlArray [$value ['title']] [$v ['username']] = $html;
  8142. }
  8143. }
  8144. /* -- --- */
  8145. // 合计费用
  8146. $cateHtml = "";
  8147. $catePrice = 0;
  8148. $cateFalg = true;
  8149. foreach ( $itemCategoryList as $l ) {
  8150. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  8151. if (empty ( $l ['price'] )) {
  8152. $cateHtml .= '<td class="colGreen taR">-</td>';
  8153. $cateFalg = false;
  8154. break;
  8155. } else {
  8156. $catePrice += $l ['price'];
  8157. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8158. $cateFalg = false;
  8159. break;
  8160. }
  8161. }
  8162. }
  8163. if ($cateFalg) {
  8164. $cateHtml .= '<td class="colGreen taR">-</td>';
  8165. $cateFalg = true;
  8166. }
  8167. $cateFalg = true;
  8168. foreach ( $itemCategoryList as $l ) {
  8169. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  8170. if (empty ( $l ['price'] )) {
  8171. $cateHtml .= '<td class="colGreen taR">-</td>';
  8172. $cateFalg = false;
  8173. break;
  8174. } else {
  8175. $catePrice += $l ['price'];
  8176. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8177. $cateFalg = false;
  8178. break;
  8179. }
  8180. }
  8181. }
  8182. if ($cateFalg) {
  8183. $cateHtml .= '<td class="colGreen taR">-</td>';
  8184. $cateFalg = true;
  8185. }
  8186. $cateFalg = true;
  8187. foreach ( $itemCategoryList as $l ) {
  8188. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  8189. if (empty ( $l ['price'] )) {
  8190. $cateHtml .= '<td class="colGreen taR">-</td>';
  8191. $cateFalg = false;
  8192. break;
  8193. } else {
  8194. $catePrice += $l ['price'];
  8195. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8196. $cateFalg = false;
  8197. break;
  8198. }
  8199. }
  8200. }
  8201. if ($cateFalg) {
  8202. $cateHtml .= '<td class="colGreen taR">-</td>';
  8203. $cateFalg = true;
  8204. }
  8205. $cateFalg = true;
  8206. foreach ( $itemCategoryList as $l ) {
  8207. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  8208. if (empty ( $l ['price'] )) {
  8209. $cateHtml .= '<td class="colGreen taR">-</td>';
  8210. $cateFalg = false;
  8211. break;
  8212. } else {
  8213. $catePrice += $l ['price'];
  8214. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8215. $cateFalg = false;
  8216. break;
  8217. }
  8218. }
  8219. }
  8220. if ($cateFalg) {
  8221. $cateHtml .= '<td class="colGreen taR">-</td>';
  8222. $cateFalg = true;
  8223. }
  8224. $cateFalg = true;
  8225. foreach ( $itemCategoryList as $l ) {
  8226. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  8227. if (empty ( $l ['price'] )) {
  8228. $cateHtml .= '<td class="colGreen taR">-</td>';
  8229. $cateFalg = false;
  8230. break;
  8231. } else {
  8232. $catePrice += $l ['price'];
  8233. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8234. $cateFalg = false;
  8235. break;
  8236. }
  8237. }
  8238. }
  8239. if ($cateFalg) {
  8240. $cateHtml .= '<td class="colGreen taR">-</td>';
  8241. $cateFalg = true;
  8242. }
  8243. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  8244. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  8245. /* -- --- */
  8246. }
  8247. // print_r($htmlArray);die;
  8248. $data ['htmlArray'] = $htmlArray;
  8249. // statistics html
  8250. $stList = $statistics->getOne ( array (
  8251. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8252. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8253. 'groupby' => 'Month(date)',
  8254. 'asArray' => true
  8255. ) );
  8256. if (empty ( $stList ))
  8257. $stList = array (
  8258. 'rePrice' => 0,
  8259. 'agPrice' => 0
  8260. );
  8261. $data ['stList'] = array (
  8262. 'rePrice' => $stList ['rePrice'],
  8263. 'agPrice' => $stList ['agPrice'],
  8264. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8265. );
  8266. $monthHtml = "";
  8267. for($i = 1; $i <= 12; $i ++) {
  8268. if ($i == $month)
  8269. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8270. else
  8271. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8272. }
  8273. $data ['monthHtml'] = $monthHtml;
  8274. $data ['year'] = $year;
  8275. $data ['month'] = $month;
  8276. $data ['memu'] = "receipt";
  8277. $data ['staff'] = $this->staff;
  8278. $data ['receiptMemu'] = 'companyCategoryCollect';
  8279. $data ['verifyId'] = $this->verifyId;
  8280. $data ['executeId'] = $this->executeId;
  8281. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  8282. Doo::loadModel ( 'receipt' );
  8283. $receipt = new receipt ();
  8284. $receiptList = $receipt->find ( array (
  8285. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  8286. 'asArray' => true
  8287. ) );
  8288. if (empty ( $receiptList )) { // generated files
  8289. ob_start ();
  8290. $this->render ( "/admin/saeaStaffCollect", $data );
  8291. $this->cacheFile ( $path );
  8292. die ();
  8293. }
  8294. }
  8295. $this->render ( "/admin/saeaStaffCollect", $data );
  8296. }
  8297. function lyt() {
  8298. Doo::loadModel ( "receiptDetail" );
  8299. $receiptDetail = new receiptDetail ();
  8300. $receiptCollectList = $receiptDetail->find ( array (
  8301. 'where' => 'status=1 ',
  8302. 'asArray' => true
  8303. ) );
  8304. foreach ( $receiptCollectList as $key => $value ) {
  8305. $receiptDetail = new receiptDetail ();
  8306. $receiptDetail->pastDate = $value ['date'];
  8307. $receiptDetail->update ( array (
  8308. 'where' => "rdid= '" . $value ['rdid'] . "'"
  8309. ) );
  8310. }
  8311. }
  8312. function staffCollectMonthDetail() {
  8313. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8314. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8315. if (! $year)
  8316. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8317. if (! $month)
  8318. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8319. Doo::loadModel ( 'staff' );
  8320. $staff = new staff ();
  8321. Doo::loadModel ( "receiptDetail" );
  8322. $receiptDetail = new receiptDetail ();
  8323. Doo::loadModel ( 'accountItem' );
  8324. $accountItem = new accountItem ();
  8325. Doo::loadModel ( 'statistics' );
  8326. $statistics = new statistics ();
  8327. Doo::loadModel ( 'L_category' );
  8328. $lCategory = new L_category ();
  8329. $staffList = $staff->find ( array (
  8330. 'where' => 'username!="admin"',
  8331. 'asArray' => true
  8332. ) );
  8333. $categoryList = $staff->find ( array (
  8334. 'select' => 'COUNT(*) as count,cid,category',
  8335. 'where' => 'username !="admin"',
  8336. 'groupby' => 'cid',
  8337. 'asArray' => true
  8338. ) );
  8339. $list = array ();
  8340. foreach ( $categoryList as $vlu ) {
  8341. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8342. $r1 = 0;
  8343. $r2 = 0;
  8344. $r3 = 0;
  8345. $r4 = 0;
  8346. $r5 = 0;
  8347. $r6 = 0;
  8348. $r7 = 0;
  8349. $r8 = 0;
  8350. $r9 = 0;
  8351. $r10 = 0;
  8352. $r11 = 0;
  8353. $r12 = 0;
  8354. $r13 = 0;
  8355. $r14 = 0;
  8356. $r15 = 0;
  8357. $r16=0;
  8358. $r17=0;
  8359. $r18=0;
  8360. $c1 = 0;
  8361. $c2 = 0;
  8362. $c3 = 0;
  8363. $c4 = 0;
  8364. $c5 = 0;
  8365. $c6 = 0;
  8366. $p1 = 0;
  8367. $p2 = 0;
  8368. $p3 = 0;
  8369. $p4 = 0;
  8370. $p5 = 0;
  8371. $p6 = 0;
  8372. $p7 = 0;
  8373. $p8 = 0;
  8374. $p9 = 0;
  8375. $t1 = 0;
  8376. $t2 = 0;
  8377. $t3 = 0;
  8378. $t4 = 0;
  8379. $t5 = 0;
  8380. $s1 = 0;
  8381. $m1 = 0;
  8382. foreach ( $staffList as $value ) {
  8383. if ($vlu ['cid'] == $value ['cid']) {
  8384. // pastDate
  8385. $receiptCollectList = $receiptDetail->find ( array (
  8386. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8387. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8388. 'groupby' => 'item,Month(pastDate),itemCategory',
  8389. 'asArray' => true
  8390. ) );
  8391. // if ($value['sid']==42){
  8392. // print_r($receiptCollectList);die;
  8393. // }
  8394. if (! empty ( $receiptCollectList )) {
  8395. $receiptL = array (
  8396. '日常相关费用' => array (),
  8397. '差旅相关费用' => array (),
  8398. '培训班费用' => array (),
  8399. '其他' => array ()
  8400. );
  8401. $html = "";
  8402. $psum = 0;
  8403. $item = array (
  8404. '市内交通费',
  8405. '市内出租费',
  8406. '办事处房租',
  8407. '电话费',
  8408. '水费',
  8409. '电费',
  8410. '办公费用',
  8411. '邮寄费',
  8412. '其他费用',
  8413. '车辆费用',
  8414. '广告费',
  8415. '团队建设费',
  8416. '物业管理费',
  8417. '宽带费',
  8418. '人员薪酬',
  8419. '公积金',
  8420. '社保'
  8421. );
  8422. foreach ( $item as $va ) {
  8423. $falg = true;
  8424. foreach ( $receiptCollectList as $v ) {
  8425. if ($v ['itemCategory'] == '日常相关费用') {
  8426. if ($v ['item'] == $va) {
  8427. if ($va == '市内交通费')
  8428. $r1 += $v ['price'];
  8429. if ($va == '市内出租费')
  8430. $r2 += $v ['price'];
  8431. if ($va == '办事处房租')
  8432. $r3 += $v ['price'];
  8433. if ($va == '电话费')
  8434. $r4 += $v ['price'];
  8435. if ($va == '水费')
  8436. $r5 += $v ['price'];
  8437. if ($va == '电费')
  8438. $r6 += $v ['price'];
  8439. if ($va == '办公费用')
  8440. $r7 += $v ['price'];
  8441. if ($va == '邮寄费')
  8442. $r8 += $v ['price'];
  8443. if ($va == '其他费用')
  8444. $r9 += $v ['price'];
  8445. if ($va == '车辆费用')
  8446. $r10 += $v ['price'];
  8447. if ($va == '广告费')
  8448. $r11 += $v ['price'];
  8449. if ($va == '团队建设费')
  8450. $r13 += $v ['price'];
  8451. if ($va == '物业管理费')
  8452. $r14 += $v ['price'];
  8453. if ($va == '宽带费')
  8454. $r15 += $v ['price'];
  8455. if ($va == '公积金')
  8456. $r16 += $v ['price'];
  8457. if ($va == '社保')
  8458. $r17 += $v ['price'];
  8459. if ($va == '人员薪酬')
  8460. $r18 += $v ['price'];
  8461. $psum += $v ['price'];
  8462. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8463. $falg = false;
  8464. break;
  8465. }
  8466. }
  8467. }
  8468. if ($falg)
  8469. $html .= '<td class="taR">-</td>';
  8470. }
  8471. $r12 += $psum;
  8472. if (! empty ( $psum ))
  8473. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8474. else
  8475. $psum = '<td class="colGreen taR">-</td>';
  8476. $receiptL ['日常相关费用'] = $psum . $html;
  8477. /* ----------------------------------- */
  8478. $html = "";
  8479. $psum = 0;
  8480. $item = array (
  8481. '往来交通费',
  8482. '市内交通费',
  8483. '出差住宿费',
  8484. '出差补助',
  8485. '其他费用'
  8486. );
  8487. foreach ( $item as $va ) {
  8488. $falg = true;
  8489. foreach ( $receiptCollectList as $v ) {
  8490. if ($v ['itemCategory'] == '差旅相关费用') {
  8491. if ($v ['item'] == $va) {
  8492. if ($va == '往来交通费')
  8493. $c1 += $v ['price'];
  8494. if ($va == '市内交通费')
  8495. $c2 += $v ['price'];
  8496. if ($va == '出差住宿费')
  8497. $c3 += $v ['price'];
  8498. if ($va == '出差补助')
  8499. $c4 += $v ['price'];
  8500. if ($va == '其他费用')
  8501. $c5 += $v ['price'];
  8502. $psum += $v ['price'];
  8503. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8504. $falg = false;
  8505. break;
  8506. }
  8507. }
  8508. }
  8509. if ($falg)
  8510. $html .= '<td class="taR">-</td>';
  8511. }
  8512. $c6 += $psum;
  8513. if (! empty ( $psum ))
  8514. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8515. else
  8516. $psum = '<td class="colGreen taR">-</td>';
  8517. $receiptL ['差旅相关费用'] = $psum . $html;
  8518. /* ------------------------------------- */
  8519. $html = "";
  8520. $psum = 0;
  8521. $item = array (
  8522. '场租费',
  8523. '薪酬',
  8524. '住宿费',
  8525. '交通费',
  8526. '餐饮费',
  8527. '办公费',
  8528. '公关费',
  8529. '其他'
  8530. );
  8531. foreach ( $item as $va ) {
  8532. $falg = true;
  8533. foreach ( $receiptCollectList as $v ) {
  8534. if ($v ['itemCategory'] == '培训班费用') {
  8535. if ($v ['item'] == $va) {
  8536. if ($va == '场租费')
  8537. $p1 += $v ['price'];
  8538. if ($va == '薪酬')
  8539. $p2 += $v ['price'];
  8540. if ($va == '住宿费')
  8541. $p3 += $v ['price'];
  8542. if ($va == '交通费')
  8543. $p4 += $v ['price'];
  8544. if ($va == '餐饮费')
  8545. $p5 += $v ['price'];
  8546. if ($va == '办公费')
  8547. $p6 += $v ['price'];
  8548. if ($va == '公关费')
  8549. $p7 += $v ['price'];
  8550. if ($va == '其他')
  8551. $p8 += $v ['price'];
  8552. $psum += $v ['price'];
  8553. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8554. $falg = false;
  8555. break;
  8556. }
  8557. }
  8558. }
  8559. if ($falg)
  8560. $html .= '<td class="taR">-</td>';
  8561. }
  8562. $p9 += $psum;
  8563. if (! empty ( $psum ))
  8564. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8565. else
  8566. $psum = '<td class="colGreen taR">-</td>';
  8567. $receiptL ['培训班费用'] = $psum . $html;
  8568. /* ------------------------------------- */
  8569. $html = "";
  8570. $psum = 0;
  8571. $item = array (
  8572. '公关费',
  8573. '广告费',
  8574. '借款',
  8575. '可自加费用'
  8576. );
  8577. foreach ( $item as $va ) {
  8578. $falg = true;
  8579. foreach ( $receiptCollectList as $v ) {
  8580. if ($v ['itemCategory'] == '其他') {
  8581. // if ($value['sid']==42){
  8582. //
  8583. // echo var_dump($v['item']);
  8584. // echo var_dump($va);
  8585. // echo var_dump($v['item']==" ".$va);
  8586. // echo $v['item']."==".$va."/<br/>";
  8587. // //print_r( $receiptCollectList);//echo $va;
  8588. // }
  8589. if (trim ( $v ['item'] ) == $va) {
  8590. if ($va == '公关费')
  8591. $t1 += $v ['price'];
  8592. if ($va == '广告费') {
  8593. $t2 += $v ['price'];
  8594. }
  8595. if ($va == '借款')
  8596. $t3 += $v ['price'];
  8597. if ($va == '可自加费用')
  8598. $t4 += $v ['price'];
  8599. $psum += $v ['price'];
  8600. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8601. $falg = false;
  8602. break;
  8603. }
  8604. }
  8605. }
  8606. if ($falg)
  8607. $html .= '<td class="taR">-</td>';
  8608. }
  8609. $t5 += $psum;
  8610. if (! empty ( $psum ))
  8611. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8612. else
  8613. $psum = '<td class="colGreen taR">-</td>';
  8614. $receiptL ['其他'] = $psum . $html;
  8615. /* ------------------------------------- */
  8616. $html = "";
  8617. $psum = 0;
  8618. foreach ( $receiptCollectList as $v ) {
  8619. if ($v ['itemCategory'] == '报销金额调整') {
  8620. if (! empty ( $v ['price'] )) {
  8621. $psum += $v ['price'];
  8622. }
  8623. }
  8624. }
  8625. $s1 += $psum;
  8626. if (! empty ( $psum ))
  8627. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8628. else
  8629. $psum = '<td class="taR colOrange">-</td>';
  8630. $receiptL ['报销金额调整'] = $psum . $html;
  8631. } else {
  8632. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8633. <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>
  8634. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8635. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  8636. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8637. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8638. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8639. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8640. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  8641. }
  8642. $monthStaffPrice = $receiptDetail->find ( array (
  8643. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8644. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8645. 'groupby' => 'Month(pastDate)',
  8646. 'asArray' => true
  8647. ) );
  8648. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  8649. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  8650. $m1 += $monthStaffPrice [0] ['price'];
  8651. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  8652. } else
  8653. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  8654. $list [$value ['username']] = $receiptL;
  8655. }
  8656. }
  8657. $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>
  8658. <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>
  8659. <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>';
  8660. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  8661. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  8662. $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>
  8663. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  8664. $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>';
  8665. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  8666. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  8667. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  8668. }
  8669. $data ['list'] = $list;
  8670. $receiptCollectList = $receiptDetail->find ( array (
  8671. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8672. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8673. 'groupby' => 'item,Month(pastDate),itemCategory',
  8674. 'asArray' => true
  8675. ) );
  8676. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  8677. // statistics html
  8678. $stList = $statistics->getOne ( array (
  8679. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8680. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8681. 'groupby' => 'Month(date)',
  8682. 'asArray' => true
  8683. ) );
  8684. if (empty ( $stList ))
  8685. $stList = array (
  8686. 'rePrice' => 0,
  8687. 'agPrice' => 0
  8688. );
  8689. $data ['stList'] = array (
  8690. 'rePrice' => $stList ['rePrice'],
  8691. 'agPrice' => $stList ['agPrice'],
  8692. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8693. );
  8694. $monthHtml = "";
  8695. for($i = 1; $i <= 12; $i ++) {
  8696. if ($i == $month)
  8697. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8698. else
  8699. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8700. }
  8701. $data ['monthHtml'] = $monthHtml;
  8702. $data ['year'] = $year;
  8703. $data ['month'] = $month;
  8704. $data ['memu'] = "receipt";
  8705. $data ['staff'] = $this->staff;
  8706. $data ['receiptMemu'] = 'companyCategoryCollect';
  8707. $data ['verifyId'] = $this->verifyId;
  8708. $data ['executeId'] = $this->executeId;
  8709. $this->render ( "/admin/staffCollectMonthDetail", $data );
  8710. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  8711. }
  8712. function staffCollectMonthDetail2() {
  8713. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8714. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8715. if (! $year)
  8716. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8717. if (! $month)
  8718. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8719. Doo::loadModel ( 'staff' );
  8720. $staff = new staff ();
  8721. Doo::loadModel ( "receiptDetail" );
  8722. $receiptDetail = new receiptDetail ();
  8723. Doo::loadModel ( 'accountItem' );
  8724. $accountItem = new accountItem ();
  8725. Doo::loadModel ( 'statistics' );
  8726. $statistics = new statistics ();
  8727. Doo::loadModel ( 'L_category' );
  8728. $lCategory = new L_category ();
  8729. $staffList = $staff->find ( array (
  8730. 'where' => 'username!="admin"',
  8731. 'asArray' => true
  8732. ) );
  8733. $categoryList = $staff->find ( array (
  8734. 'select' => 'COUNT(*) as count,cid,category',
  8735. 'where' => 'username !="admin"',
  8736. 'groupby' => 'cid',
  8737. 'asArray' => true
  8738. ) );
  8739. $list = array ();
  8740. foreach ( $categoryList as $vlu ) {
  8741. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8742. $r1 = 0;
  8743. $r2 = 0;
  8744. $r3 = 0;
  8745. $r4 = 0;
  8746. $r5 = 0;
  8747. $r6 = 0;
  8748. $r7 = 0;
  8749. $r8 = 0;
  8750. $r9 = 0;
  8751. $r10 = 0;
  8752. $r11 = 0;
  8753. $r12 = 0;
  8754. $r13 = 0;
  8755. $r14 = 0;
  8756. $r15 = 0;
  8757. $c1 = 0;
  8758. $c2 = 0;
  8759. $c3 = 0;
  8760. $c4 = 0;
  8761. $c5 = 0;
  8762. $c6 = 0;
  8763. $p1 = 0;
  8764. $p2 = 0;
  8765. $p3 = 0;
  8766. $p4 = 0;
  8767. $p5 = 0;
  8768. $p6 = 0;
  8769. $p7 = 0;
  8770. $p8 = 0;
  8771. $p9 = 0;
  8772. $t1 = 0;
  8773. $t2 = 0;
  8774. $t3 = 0;
  8775. $t4 = 0;
  8776. $t5 = 0;
  8777. $s1 = 0;
  8778. $m1 = 0;
  8779. foreach ( $staffList as $value ) {
  8780. if ($vlu ['cid'] == $value ['cid']) {
  8781. $receiptCollectList = $receiptDetail->find ( array (
  8782. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  8783. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  8784. 'groupby' => 'item,Month(date),itemCategory',
  8785. 'asArray' => true
  8786. ) );
  8787. if (! empty ( $receiptCollectList )) {
  8788. $receiptL = array (
  8789. '日常相关费用' => array (),
  8790. '差旅相关费用' => array (),
  8791. '培训班费用' => array (),
  8792. '其他' => array ()
  8793. );
  8794. $html = "";
  8795. $psum = 0;
  8796. $item = array (
  8797. '市内交通费',
  8798. '市内出租费',
  8799. '办事处房租',
  8800. '电话费',
  8801. '水费',
  8802. '电费',
  8803. '办公费用',
  8804. '邮寄费',
  8805. '其他费用',
  8806. '车辆费用',
  8807. '广告费',
  8808. '团队建设费',
  8809. '物业管理费',
  8810. '宽带费'
  8811. );
  8812. foreach ( $item as $va ) {
  8813. $falg = true;
  8814. foreach ( $receiptCollectList as $v ) {
  8815. if ($v ['itemCategory'] == '日常相关费用') {
  8816. if ($v ['item'] == $va) {
  8817. if ($va == '市内交通费')
  8818. $r1 += $v ['price'];
  8819. if ($va == '市内出租费')
  8820. $r2 += $v ['price'];
  8821. if ($va == '办事处房租')
  8822. $r3 += $v ['price'];
  8823. if ($va == '电话费')
  8824. $r4 += $v ['price'];
  8825. if ($va == '水费')
  8826. $r5 += $v ['price'];
  8827. if ($va == '电费')
  8828. $r6 += $v ['price'];
  8829. if ($va == '办公费用')
  8830. $r7 += $v ['price'];
  8831. if ($va == '邮寄费')
  8832. $r8 += $v ['price'];
  8833. if ($va == '其他费用')
  8834. $r9 += $v ['price'];
  8835. if ($va == '车辆费用')
  8836. $r10 += $v ['price'];
  8837. if ($va == '广告费')
  8838. $r11 += $v ['price'];
  8839. if ($va == '团队建设费')
  8840. $r13 += $v ['price'];
  8841. if ($va == '物业管理费')
  8842. $r14 += $v ['price'];
  8843. if ($va == '宽带费')
  8844. $r15 += $v ['price'];
  8845. $psum += $v ['price'];
  8846. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8847. $falg = false;
  8848. break;
  8849. }
  8850. }
  8851. }
  8852. if ($falg)
  8853. $html .= '<td class="taR">-</td>';
  8854. }
  8855. $r12 += $psum;
  8856. if (! empty ( $psum ))
  8857. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8858. else
  8859. $psum = '<td class="colGreen taR">-</td>';
  8860. $receiptL ['日常相关费用'] = $psum . $html;
  8861. /* ----------------------------------- */
  8862. $html = "";
  8863. $psum = 0;
  8864. $item = array (
  8865. '往来交通费',
  8866. '市内交通费',
  8867. '出差住宿费',
  8868. '出差补助',
  8869. '其他费用'
  8870. );
  8871. foreach ( $item as $va ) {
  8872. $falg = true;
  8873. foreach ( $receiptCollectList as $v ) {
  8874. if ($v ['itemCategory'] == '差旅相关费用') {
  8875. if ($v ['item'] == $va) {
  8876. if ($va == '往来交通费')
  8877. $c1 += $v ['price'];
  8878. if ($va == '市内交通费')
  8879. $c2 += $v ['price'];
  8880. if ($va == '出差住宿费')
  8881. $c3 += $v ['price'];
  8882. if ($va == '出差补助')
  8883. $c4 += $v ['price'];
  8884. if ($va == '其他费用')
  8885. $c5 += $v ['price'];
  8886. $psum += $v ['price'];
  8887. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8888. $falg = false;
  8889. break;
  8890. }
  8891. }
  8892. }
  8893. if ($falg)
  8894. $html .= '<td class="taR">-</td>';
  8895. }
  8896. $c6 += $psum;
  8897. if (! empty ( $psum ))
  8898. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8899. else
  8900. $psum = '<td class="colGreen taR">-</td>';
  8901. $receiptL ['差旅相关费用'] = $psum . $html;
  8902. /* ------------------------------------- */
  8903. $html = "";
  8904. $psum = 0;
  8905. $item = array (
  8906. '场租费',
  8907. '薪酬',
  8908. '住宿费',
  8909. '交通费',
  8910. '餐饮费',
  8911. '办公费',
  8912. '公关费',
  8913. '其他'
  8914. );
  8915. foreach ( $item as $va ) {
  8916. $falg = true;
  8917. foreach ( $receiptCollectList as $v ) {
  8918. if ($v ['itemCategory'] == '培训班费用') {
  8919. if ($v ['item'] == $va) {
  8920. if ($va == '场租费')
  8921. $p1 += $v ['price'];
  8922. if ($va == '薪酬')
  8923. $p2 += $v ['price'];
  8924. if ($va == '住宿费')
  8925. $p3 += $v ['price'];
  8926. if ($va == '交通费')
  8927. $p4 += $v ['price'];
  8928. if ($va == '餐饮费')
  8929. $p5 += $v ['price'];
  8930. if ($va == '办公费')
  8931. $p6 += $v ['price'];
  8932. if ($va == '公关费')
  8933. $p7 += $v ['price'];
  8934. if ($va == '其他')
  8935. $p8 += $v ['price'];
  8936. $psum += $v ['price'];
  8937. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8938. $falg = false;
  8939. break;
  8940. }
  8941. }
  8942. }
  8943. if ($falg)
  8944. $html .= '<td class="taR">-</td>';
  8945. }
  8946. $p9 += $psum;
  8947. if (! empty ( $psum ))
  8948. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8949. else
  8950. $psum = '<td class="colGreen taR">-</td>';
  8951. $receiptL ['培训班费用'] = $psum . $html;
  8952. /* ------------------------------------- */
  8953. $html = "";
  8954. $psum = 0;
  8955. $item = array (
  8956. '公关费',
  8957. '广告费',
  8958. '借款',
  8959. '可自加费用'
  8960. );
  8961. foreach ( $item as $va ) {
  8962. $falg = true;
  8963. foreach ( $receiptCollectList as $v ) {
  8964. if ($v ['itemCategory'] == '其他') {
  8965. if ($v ['item'] == $va) {
  8966. if ($va == '公关费')
  8967. $t1 += $v ['price'];
  8968. if ($va == '广告费')
  8969. $t2 += $v ['price'];
  8970. if ($va == '借款')
  8971. $t3 += $v ['price'];
  8972. if ($va == '可自加费用')
  8973. $t4 += $v ['price'];
  8974. $psum += $v ['price'];
  8975. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8976. $falg = false;
  8977. break;
  8978. }
  8979. }
  8980. }
  8981. if ($falg)
  8982. $html .= '<td class="taR">-</td>';
  8983. }
  8984. $t5 += $psum;
  8985. if (! empty ( $psum ))
  8986. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8987. else
  8988. $psum = '<td class="colGreen taR">-</td>';
  8989. $receiptL ['其他'] = $psum . $html;
  8990. /* ------------------------------------- */
  8991. $html = "";
  8992. $psum = 0;
  8993. foreach ( $receiptCollectList as $v ) {
  8994. if ($v ['itemCategory'] == '报销金额调整') {
  8995. if (! empty ( $v ['price'] )) {
  8996. $psum += $v ['price'];
  8997. }
  8998. }
  8999. }
  9000. $s1 += $psum;
  9001. if (! empty ( $psum ))
  9002. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9003. else
  9004. $psum = '<td class="taR colOrange">-</td>';
  9005. $receiptL ['报销金额调整'] = $psum . $html;
  9006. } else {
  9007. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9008. <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>';
  9009. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9010. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9011. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9012. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9013. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9014. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9015. }
  9016. $monthStaffPrice = $receiptDetail->find ( array (
  9017. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9018. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9019. 'asArray' => true
  9020. ) );
  9021. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  9022. $m1 += $monthStaffPrice [0] ['price'];
  9023. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9024. } else
  9025. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9026. $list [$value ['username']] = $receiptL;
  9027. }
  9028. }
  9029. $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>
  9030. <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>
  9031. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  9032. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  9033. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  9034. $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>
  9035. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  9036. $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>';
  9037. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  9038. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  9039. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  9040. }
  9041. $data ['list'] = $list;
  9042. $receiptCollectList = $receiptDetail->find ( array (
  9043. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9044. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9045. 'groupby' => 'item,Month(date),itemCategory',
  9046. 'asArray' => true
  9047. ) );
  9048. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9049. // statistics html
  9050. $stList = $statistics->getOne ( array (
  9051. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9052. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9053. 'groupby' => 'Month(date)',
  9054. 'asArray' => true
  9055. ) );
  9056. if (empty ( $stList ))
  9057. $stList = array (
  9058. 'rePrice' => 0,
  9059. 'agPrice' => 0
  9060. );
  9061. $data ['stList'] = array (
  9062. 'rePrice' => $stList ['rePrice'],
  9063. 'agPrice' => $stList ['agPrice'],
  9064. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9065. );
  9066. $monthHtml = "";
  9067. for($i = 1; $i <= 12; $i ++) {
  9068. if ($i == $month)
  9069. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9070. else
  9071. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9072. }
  9073. $data ['monthHtml'] = $monthHtml;
  9074. $data ['year'] = $year;
  9075. $data ['month'] = $month;
  9076. $data ['memu'] = "receipt";
  9077. $data ['staff'] = $this->staff;
  9078. $data ['receiptMemu'] = 'companyCategoryCollect';
  9079. $data ['verifyId'] = $this->verifyId;
  9080. $data ['executeId'] = $this->executeId;
  9081. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  9082. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9083. }
  9084. function companyMonthCollectDetail() {
  9085. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9086. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9087. if (! $year)
  9088. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9089. if (! $month)
  9090. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9091. Doo::loadModel ( 'staff' );
  9092. $staff = new staff ();
  9093. Doo::loadModel ( "receiptDetail" );
  9094. $receiptDetail = new receiptDetail ();
  9095. Doo::loadModel ( 'accountItem' );
  9096. $accountItem = new accountItem ();
  9097. Doo::loadModel ( 'statistics' );
  9098. $statistics = new statistics ();
  9099. Doo::loadModel ( 'L_category' );
  9100. $lCategory = new L_category ();
  9101. $staffList = $staff->find ( array (
  9102. 'where' => 'username!="admin"',
  9103. 'asArray' => true
  9104. ) );
  9105. $categoryList = $lCategory->find ( array (
  9106. 'asArray' => true
  9107. ) );
  9108. $list = array ();
  9109. foreach ( $categoryList as $value ) {
  9110. $receiptCollectList = $receiptDetail->find ( array (
  9111. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9112. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9113. 'groupby' => 'item,Month(pastDate),itemCategory',
  9114. 'asArray' => true
  9115. ) );
  9116. if (! empty ( $receiptCollectList )) {
  9117. $receiptL = array (
  9118. '日常相关费用' => array (),
  9119. '差旅相关费用' => array (),
  9120. '培训班费用' => array (),
  9121. '其他' => array ()
  9122. );
  9123. $html = "";
  9124. $psum = 0;
  9125. $item = array (
  9126. '市内交通费',
  9127. '市内出租费',
  9128. '办事处房租',
  9129. '电话费',
  9130. '水费',
  9131. '电费',
  9132. '办公费用',
  9133. '邮寄费',
  9134. '其他费用',
  9135. '车辆费用',
  9136. '广告费',
  9137. '团队建设费'
  9138. );
  9139. foreach ( $item as $va ) {
  9140. $falg = true;
  9141. foreach ( $receiptCollectList as $v ) {
  9142. if ($v ['itemCategory'] == '日常相关费用') {
  9143. if ($v ['item'] == $va) {
  9144. $psum += $v ['price'];
  9145. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9146. $falg = false;
  9147. break;
  9148. }
  9149. }
  9150. }
  9151. if ($falg)
  9152. $html .= '<td class="taR">-</td>';
  9153. }
  9154. if (! empty ( $psum ))
  9155. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9156. else
  9157. $psum = '<td class="colGreen taR">-</td>';
  9158. $receiptL ['日常相关费用'] = $psum . $html;
  9159. /* ----------------------------------- */
  9160. $html = "";
  9161. $psum = 0;
  9162. $item = array (
  9163. '往来交通费',
  9164. '市内交通费',
  9165. '出差住宿费',
  9166. '出差补助',
  9167. '其他费用'
  9168. );
  9169. foreach ( $item as $va ) {
  9170. $falg = true;
  9171. foreach ( $receiptCollectList as $v ) {
  9172. if ($v ['itemCategory'] == '差旅相关费用') {
  9173. if ($v ['item'] == $va) {
  9174. $psum += $v ['price'];
  9175. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9176. $falg = false;
  9177. break;
  9178. }
  9179. }
  9180. }
  9181. if ($falg)
  9182. $html .= '<td class="taR">-</td>';
  9183. }
  9184. if (! empty ( $psum ))
  9185. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9186. else
  9187. $psum = '<td class="colGreen taR">-</td>';
  9188. $receiptL ['差旅相关费用'] = $psum . $html;
  9189. /* ------------------------------------- */
  9190. $html = "";
  9191. $psum = 0;
  9192. $item = array (
  9193. '场租费',
  9194. '薪酬',
  9195. '住宿费',
  9196. '交通费',
  9197. '餐饮费',
  9198. '办公费',
  9199. '公关费',
  9200. '其他'
  9201. );
  9202. foreach ( $item as $va ) {
  9203. $falg = true;
  9204. foreach ( $receiptCollectList as $v ) {
  9205. if ($v ['itemCategory'] == '培训班费用') {
  9206. if ($v ['item'] == $va) {
  9207. $psum += $v ['price'];
  9208. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9209. $falg = false;
  9210. break;
  9211. }
  9212. }
  9213. }
  9214. if ($falg)
  9215. $html .= '<td class="taR">-</td>';
  9216. }
  9217. if (! empty ( $psum ))
  9218. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9219. else
  9220. $psum = '<td class="colGreen taR">-</td>';
  9221. $receiptL ['培训班费用'] = $psum . $html;
  9222. /* ------------------------------------- */
  9223. $html = "";
  9224. $psum = 0;
  9225. $item = array (
  9226. '公关费',
  9227. '广告费',
  9228. '借款',
  9229. '可自加费用'
  9230. );
  9231. foreach ( $item as $va ) {
  9232. $falg = true;
  9233. foreach ( $receiptCollectList as $v ) {
  9234. if ($v ['itemCategory'] == '其他') {
  9235. if ($v ['item'] == $va) {
  9236. $psum += $v ['price'];
  9237. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9238. $falg = false;
  9239. break;
  9240. }
  9241. }
  9242. }
  9243. if ($falg)
  9244. $html .= '<td class="taR">-</td>';
  9245. }
  9246. if (! empty ( $psum ))
  9247. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9248. else
  9249. $psum = '<td class="colGreen taR">-</td>';
  9250. $receiptL ['其他'] = $psum . $html;
  9251. /* ------------------------------------- */
  9252. $html = "";
  9253. $psum = 0;
  9254. foreach ( $receiptCollectList as $v ) {
  9255. if ($v ['itemCategory'] == '报销金额调整') {
  9256. if (! empty ( $v ['price'] ))
  9257. $psum += $v ['price'];
  9258. }
  9259. }
  9260. if (! empty ( $psum ))
  9261. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9262. else
  9263. $psum = '<td class="taR colOrange">-</td>';
  9264. $receiptL ['报销金额调整'] = $psum . $html;
  9265. } else {
  9266. $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>
  9267. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9268. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9269. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9270. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9271. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9272. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9273. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9274. }
  9275. $monthStaffPrice = $receiptDetail->find ( array (
  9276. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9277. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9278. 'asArray' => true
  9279. ) );
  9280. if (! empty ( $monthStaffPrice [0] ['price'] ))
  9281. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9282. else
  9283. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9284. $list [$value ['title']] = $receiptL;
  9285. }
  9286. $data ['list'] = $list;
  9287. $receiptCollectList = $receiptDetail->find ( array (
  9288. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9289. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9290. 'groupby' => 'item,Month(pastDate),itemCategory',
  9291. 'asArray' => true
  9292. ) );
  9293. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9294. // print_r($data['monthPriceHtml']);
  9295. // foreach ($data['monthPriceHtml'] as $value){
  9296. // echo $value;
  9297. // }
  9298. // die;
  9299. // statistics html
  9300. $stList = $statistics->getOne ( array (
  9301. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9302. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9303. 'groupby' => 'Month(date)',
  9304. 'asArray' => true
  9305. ) );
  9306. if (empty ( $stList ))
  9307. $stList = array (
  9308. 'rePrice' => 0,
  9309. 'agPrice' => 0
  9310. );
  9311. $data ['stList'] = array (
  9312. 'rePrice' => $stList ['rePrice'],
  9313. 'agPrice' => $stList ['agPrice'],
  9314. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9315. );
  9316. $monthHtml = "";
  9317. for($i = 1; $i <= 12; $i ++) {
  9318. if ($i == $month)
  9319. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9320. else
  9321. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9322. }
  9323. $data ['monthHtml'] = $monthHtml;
  9324. $data ['year'] = $year;
  9325. $data ['month'] = $month;
  9326. $data ['memu'] = "receipt";
  9327. $data ['staff'] = $this->staff;
  9328. $data ['receiptMemu'] = 'companyCategoryCollect';
  9329. $data ['verifyId'] = $this->verifyId;
  9330. $data ['executeId'] = $this->executeId;
  9331. $this->render ( "/admin/companyMonthCollectDetail", $data );
  9332. }
  9333. function staffCollectDetail() {
  9334. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9335. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  9336. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  9337. if (! $staffname) {
  9338. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  9339. $staffname = urldecode ( $staffname );
  9340. }
  9341. Doo::loadModel ( 'staff' );
  9342. $staff = new staff ();
  9343. Doo::loadModel ( "receiptDetail" );
  9344. $receiptDetail = new receiptDetail ();
  9345. Doo::loadModel ( 'accountItem' );
  9346. $accountItem = new accountItem ();
  9347. Doo::loadModel ( 'statistics' );
  9348. $statistics = new statistics ();
  9349. Doo::loadModel ( 'L_category' );
  9350. $lCategory = new L_category ();
  9351. $staffList = $staff->find ( array (
  9352. 'asArray' => true
  9353. ) );
  9354. $stHtml = '';
  9355. $stTitle = "";
  9356. $staffId = 0;
  9357. $cid = 0;
  9358. $ocid = 0;
  9359. foreach ( $staffList as $value ) {
  9360. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  9361. $stTitle = $value ['category'] . '-' . $value ['username'];
  9362. $staffId = $value ['sid'];
  9363. $cid = $value ['cid'];
  9364. $ocid = $value ['cid'];
  9365. if (! empty ( $value ['othercid'] ))
  9366. $cid = $value ['cid'] . ',' . $value ['othercid'];
  9367. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9368. } elseif ($value ['username'] != 'admin')
  9369. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9370. }
  9371. $data ['lCategoryHtml'] = $lCategory->find ( array (
  9372. 'where' => 'cid in(' . $cid . ')',
  9373. 'asArray' => true
  9374. ) );
  9375. if (empty ( $pcid ))
  9376. $pcid = $ocid;
  9377. $data ['ocid'] = $pcid;
  9378. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  9379. $this->showCache ( $path );
  9380. //
  9381. $receiptCollectList = $receiptDetail->find ( array (
  9382. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9383. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9384. 'groupby' => 'item,Month(pastDate),itemCategory',
  9385. 'asArray' => true
  9386. ) );
  9387. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  9388. // print_r($receiptCollectList);
  9389. $accountList = $accountItem->find ( array (
  9390. 'asArray' => true
  9391. ) );
  9392. // create CollectDetail HTML
  9393. $collectHtml = array ();
  9394. foreach ( $accountList as $key => $value ) {
  9395. $html = "";
  9396. $asum = 0;
  9397. for($i = 1; $i <= 12; $i ++) {
  9398. $falg = true;
  9399. foreach ( $receiptCollectList as $v ) {
  9400. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9401. if ($v ['item'] == '可自加费用') {
  9402. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  9403. }
  9404. $asum += $v ['price'];
  9405. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9406. $falg = false;
  9407. break;
  9408. }
  9409. }
  9410. if ($falg)
  9411. $html .= '<td class="taR">-</td>';
  9412. }
  9413. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9414. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9415. }
  9416. $data ['collectHtml'] = $collectHtml;
  9417. // print_r($collectHtml);
  9418. // create Adjustment price html
  9419. $receiptCollectList = $receiptDetail->find ( array (
  9420. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9421. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9422. 'groupby' => 'itemCategory,Month(pastDate)',
  9423. 'asArray' => true
  9424. ) );
  9425. $adjustment = array ();
  9426. $collectArray = array (
  9427. '日常相关费用' => array (),
  9428. '差旅相关费用' => array (),
  9429. '培训班费用' => array (),
  9430. '其他' => array ()
  9431. );
  9432. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9433. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9434. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9435. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9436. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9437. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9438. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9439. array_push ( $collectArray ['其他'], $collectHtml );
  9440. $data ['collectArray'] = $collectArray;
  9441. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9442. array_push ( $adjustment, $collectHtml );
  9443. $data ['adjustment'] = $adjustment;
  9444. // total price html
  9445. $collectHtml = "";
  9446. $total = 0;
  9447. for($i = 1; $i <= 12; $i ++) {
  9448. $sumPrice = 0;
  9449. foreach ( $receiptCollectList as $key => $value ) {
  9450. if ($value ['month'] == $i) {
  9451. $sumPrice += $value ['price'];
  9452. }
  9453. }
  9454. if ($sumPrice == 0)
  9455. $collectHtml .= '<td class="taR">-</td>';
  9456. else
  9457. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9458. $total += $sumPrice;
  9459. }
  9460. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9461. // statistics html
  9462. $stList = $statistics->statisticsByYear ( $year, $staffId );
  9463. if (empty ( $stList ))
  9464. $stList = array (
  9465. 'rePrice' => 0,
  9466. 'agPrice' => 0
  9467. );
  9468. $data ['stList'] = array (
  9469. 'rePrice' => $stList ['rePrice'],
  9470. 'agPrice' => $stList ['agPrice'],
  9471. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9472. );
  9473. $data ['totalPrice'] = $collectHtml;
  9474. $data ['totalYear'] = $total;
  9475. $data ['stHtml'] = $stHtml;
  9476. $data ['year'] = $year;
  9477. $data ['stTitle'] = $stTitle;
  9478. $data ['memu'] = "receipt";
  9479. $data ['staff'] = $this->staff;
  9480. $data ['receiptMemu'] = 'companyCategoryCollect';
  9481. $data ['verifyId'] = $this->verifyId;
  9482. $data ['executeId'] = $this->executeId;
  9483. if ($year < date ( "Y" )) {
  9484. Doo::loadModel ( 'receipt' );
  9485. $receipt = new receipt ();
  9486. $receiptList = $receipt->find ( array (
  9487. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  9488. 'asArray' => true
  9489. ) );
  9490. if (empty ( $receiptList )) { // generated files
  9491. ob_start ();
  9492. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9493. $this->cacheFile ( $path );
  9494. die ();
  9495. }
  9496. }
  9497. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9498. }
  9499. function BUGFLAG() {
  9500. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  9501. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  9502. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9503. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9504. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  9505. if (empty ( $status ))
  9506. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  9507. $page_size = 12;
  9508. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  9509. $vidList = array ();
  9510. $button = 0;
  9511. Doo::loadModel ( 'verify' );
  9512. $verify = new verify ();
  9513. Doo::loadModel ( 'receipt' );
  9514. $receipt = new receipt ();
  9515. Doo::loadModel ( 'staff' );
  9516. $staff = new staff ();
  9517. Doo::loadModel ( 'L_category' );
  9518. $Lcategory = new L_category ();
  9519. $dateCondition = " and Year(date) =" . $year;
  9520. if (! empty ( $month ))
  9521. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  9522. $categoryList = $Lcategory->find ( array (
  9523. 'asArray' => true
  9524. ) );
  9525. $staffList = $staff->find ( array (
  9526. 'where' => 'cid=' . $cid,
  9527. 'asArray' => true
  9528. ) );
  9529. $cateCondition = "";
  9530. $staffCondition = "";
  9531. $approvalCondition = "";
  9532. if (! empty ( $cid ))
  9533. $cateCondition = ' and cid=' . $cid;
  9534. if (! empty ( $sid )) {
  9535. $staffCondition = ' and staff=' . $sid;
  9536. $cateCondition = "";
  9537. }
  9538. $approvalCondition = " and status=" . $status;
  9539. if ($status == 2) {
  9540. // 查找角色审批人
  9541. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9542. }
  9543. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  9544. $approvalCondition = ' and status=2 ';
  9545. }
  9546. if ($status == 1) {
  9547. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  9548. }
  9549. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  9550. $pageinfo ['page'] = array (
  9551. 'previous' => ''
  9552. );
  9553. if ($status == 0) {
  9554. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  9555. $receiptList = $receipt->find ( array (
  9556. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  9557. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  9558. 'desc' => 'rid',
  9559. 'asArray' => true
  9560. ) );
  9561. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9562. } else
  9563. $receiptList = $receipt->find ( array (
  9564. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  9565. 'desc' => 'rid',
  9566. 'asArray' => true
  9567. ) );
  9568. $rLRes = $receipt->find ( array (
  9569. '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,
  9570. 'desc' => 'rid',
  9571. 'asArray' => true
  9572. ) );
  9573. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9574. // print_r($pageinfo);
  9575. $Locate = 0;
  9576. foreach ( $receiptList as $key => $value ) {
  9577. $receiptList [$key] ['Locate'] = $Locate;
  9578. $Locate ++;
  9579. $receiptList [$key] ['reviseDetail'] = array ();
  9580. if (! empty ( $value ['reviseDetail'] ))
  9581. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  9582. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  9583. $categoryDetil = $Lcategory->getOne ( array (
  9584. 'where' => 'cid=' . $value ['cid'],
  9585. 'asArray' => true
  9586. ) );
  9587. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  9588. $verifyList = $verify->getOne ( array (
  9589. 'where' => 'vid=' . $value ['verify'],
  9590. 'asArray' => true
  9591. ) );
  9592. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  9593. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  9594. foreach ( $verifyList as $k => $v ) {
  9595. // init verifyStaff
  9596. $verifyList [$k] ['date'] = "";
  9597. $verifyList [$k] ['opinion'] = "";
  9598. $verifyList [$k] ['status'] = "";
  9599. if (empty ( $verifyStaff )) {
  9600. $verifyList [$k] ['date'] = "";
  9601. $verifyList [$k] ['opinion'] = "";
  9602. if ($v [0] == $this->staff [0] ['sid']) {
  9603. $verifyList [$k] ['status'] = 4;
  9604. $button = 4;
  9605. }
  9606. } else {
  9607. $flag = true;
  9608. foreach ( $verifyStaff as $m => $u ) {
  9609. if ($v [0] == $m) {
  9610. $verifyList [$k] ['date'] = $u ['date'];
  9611. $verifyList [$k] ['opinion'] = $u ['opinion'];
  9612. $verifyList [$k] ['status'] = $u ['status'];
  9613. $flag = false;
  9614. break;
  9615. }
  9616. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  9617. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  9618. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  9619. }
  9620. if ($flag) { // 检测可编辑
  9621. if ($v [0] == $this->staff [0] ['sid']) {
  9622. $verifyList [$k] ['status'] = 4;
  9623. $button = 4;
  9624. }
  9625. }
  9626. }
  9627. }
  9628. $receiptList [$key] ['verifyList'] = $verifyList;
  9629. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  9630. 'where' => 'sid=' . $value ['staff'],
  9631. 'asArray' => true
  9632. ) );
  9633. $receiptList [$key] ['button'] = $button;
  9634. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  9635. }
  9636. // print_r($receiptList);die;
  9637. // $data['verifyDetail']=$verifyDetail;
  9638. $mothHtml = "";
  9639. for($i = 1; $i <= 12; $i ++) {
  9640. if ($month == $i)
  9641. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  9642. else
  9643. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  9644. }
  9645. $data ['mothHtml'] = $mothHtml;
  9646. $data ['page'] = $pageinfo;
  9647. $data ['receiptList'] = $receiptList;
  9648. $data ['receiptApprovalCount'] = count ( $rLRes );
  9649. $data ['status'] = $status;
  9650. $data ['year'] = $year;
  9651. $data ['categoryList'] = $categoryList;
  9652. $data ['staffList'] = $staffList;
  9653. $data ['cid'] = $cid;
  9654. $data ['sid'] = $sid;
  9655. // print_r($receiptList);
  9656. $data ['memu'] = "receipt";
  9657. $data ['staff'] = $this->staff;
  9658. $data ['receiptMemu'] = 'approvalExpenses';
  9659. $data ['verifyId'] = $this->verifyId;
  9660. $data ['executeId'] = $this->executeId;
  9661. $this->render ( "/admin/FALG", $data );
  9662. }
  9663. function ajaxGetReceiptOrder() {
  9664. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  9665. if (! empty ( $receiptOrder )) {
  9666. Doo::loadModel ( 'receipt' );
  9667. $receipt = new receipt ();
  9668. Doo::loadModel ( 'staff' );
  9669. $staff = new staff ();
  9670. $receiptInfo = $receipt->getOne ( array (
  9671. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  9672. 'asArray' => true
  9673. ) );
  9674. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  9675. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  9676. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  9677. </tbody></table><table class="table table table-bordered"><tbody>';
  9678. foreach ( $verifyStaff as $key => $value ) {
  9679. $staffInfo = $staff->getOne ( array (
  9680. 'select' => 'username',
  9681. 'where' => ' sid="' . $key . '"',
  9682. 'asArray' => true
  9683. ) );
  9684. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  9685. }
  9686. $html .= '</tbody></table></div></div>';
  9687. echo json_encode ( array (
  9688. 'status' => 1,
  9689. 'receiptHtml' => $html
  9690. ) );
  9691. die ();
  9692. }
  9693. echo json_encode ( array (
  9694. 'status' => 2,
  9695. 'receiptHtml' => ''
  9696. ) );
  9697. die ();
  9698. }
  9699. function _getMonthCollectDetail($receiptCollectList) {
  9700. if (! empty ( $receiptCollectList )) {
  9701. $receiptL = array (
  9702. '日常相关费用' => array (),
  9703. '差旅相关费用' => array (),
  9704. '培训班费用' => array (),
  9705. '其他' => array ()
  9706. );
  9707. $html = "";
  9708. $psum = 0;
  9709. $item = array (
  9710. '市内交通费',
  9711. '市内出租费',
  9712. '办事处房租',
  9713. '电话费',
  9714. '水费',
  9715. '电费',
  9716. '办公费用',
  9717. '邮寄费',
  9718. '其他费用',
  9719. '车辆费用',
  9720. '广告费',
  9721. '团队建设费',
  9722. '物业管理费',
  9723. '宽带费'
  9724. );
  9725. foreach ( $item as $value ) {
  9726. $falg = true;
  9727. foreach ( $receiptCollectList as $v ) {
  9728. if ($v ['itemCategory'] == '日常相关费用') {
  9729. if ($v ['item'] == $value) {
  9730. $psum += $v ['price'];
  9731. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9732. $falg = false;
  9733. break;
  9734. }
  9735. }
  9736. }
  9737. if ($falg)
  9738. $html .= '<td class="taR">-</td>';
  9739. }
  9740. if (! empty ( $psum ))
  9741. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9742. else
  9743. $psum = '<td class="colGreen taR">-</td>';
  9744. $receiptL ['日常相关费用'] = $psum . $html;
  9745. /* ----------------------------------- */
  9746. $html = "";
  9747. $psum = 0;
  9748. $item = array (
  9749. '往来交通费',
  9750. '市内交通费',
  9751. '出差住宿费',
  9752. '出差补助',
  9753. '其他费用'
  9754. );
  9755. foreach ( $item as $value ) {
  9756. $falg = true;
  9757. foreach ( $receiptCollectList as $v ) {
  9758. if ($v ['itemCategory'] == '差旅相关费用') {
  9759. if ($v ['item'] == $value) {
  9760. $psum += $v ['price'];
  9761. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9762. $falg = false;
  9763. break;
  9764. }
  9765. }
  9766. }
  9767. if ($falg)
  9768. $html .= '<td class="taR">-</td>';
  9769. }
  9770. if (! empty ( $psum ))
  9771. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9772. else
  9773. $psum = '<td class="colGreen taR">-</td>';
  9774. $receiptL ['差旅相关费用'] = $psum . $html;
  9775. /* ------------------------------------- */
  9776. $html = "";
  9777. $psum = 0;
  9778. $item = array (
  9779. '场租费',
  9780. '薪酬',
  9781. '住宿费',
  9782. '交通费',
  9783. '餐饮费',
  9784. '办公费',
  9785. '公关费',
  9786. '其他'
  9787. );
  9788. foreach ( $item as $value ) {
  9789. $falg = true;
  9790. foreach ( $receiptCollectList as $v ) {
  9791. if ($v ['itemCategory'] == '培训班费用') {
  9792. if ($v ['item'] == $value) {
  9793. $psum += $v ['price'];
  9794. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9795. $falg = false;
  9796. break;
  9797. }
  9798. }
  9799. }
  9800. if ($falg)
  9801. $html .= '<td class="taR">-</td>';
  9802. }
  9803. if (! empty ( $psum ))
  9804. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9805. else
  9806. $psum = '<td class="colGreen taR">-</td>';
  9807. $receiptL ['培训班费用'] = $psum . $html;
  9808. /* ------------------------------------- */
  9809. $html = "";
  9810. $psum = 0;
  9811. $item = array (
  9812. '公关费',
  9813. '广告费',
  9814. '借款',
  9815. '可自加费用'
  9816. );
  9817. foreach ( $item as $value ) {
  9818. $falg = true;
  9819. foreach ( $receiptCollectList as $v ) {
  9820. if ($v ['itemCategory'] == '其他') {
  9821. if ($v ['item'] == $value) {
  9822. $psum += $v ['price'];
  9823. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9824. $falg = false;
  9825. break;
  9826. }
  9827. }
  9828. }
  9829. if ($falg)
  9830. $html .= '<td class="taR">-</td>';
  9831. }
  9832. if (! empty ( $psum ))
  9833. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9834. else
  9835. $psum = '<td class="colGreen taR">-</td>';
  9836. $receiptL ['其他'] = $psum . $html;
  9837. /* ------------------------------------- */
  9838. $html = "";
  9839. $psum = 0;
  9840. foreach ( $receiptCollectList as $v ) {
  9841. if ($v ['itemCategory'] == '报销金额调整') {
  9842. if (! empty ( $v ['price'] ))
  9843. $psum += $v ['price'];
  9844. }
  9845. }
  9846. if (! empty ( $psum ))
  9847. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9848. else
  9849. $psum = '<td class="taR colOrange">-</td>';
  9850. $receiptL ['报销金额调整'] = $psum . $html;
  9851. } else {
  9852. $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>
  9853. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9854. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9855. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9856. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9857. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9858. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9859. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9860. }
  9861. return $receiptL;
  9862. }
  9863. function eMail() {
  9864. Doo::loadModel ( 'staff' );
  9865. $staff = new staff ();
  9866. Doo::loadModel ( 'receipt' );
  9867. $receipt = new receipt ();
  9868. Doo::loadModel ( 'L_category' );
  9869. $Lcategory = new L_category ();
  9870. Doo::loadModel ( "verify" );
  9871. $verify = new verify ();
  9872. $staffList = $staff->find ( array (
  9873. 'asArray' => true
  9874. ) );
  9875. foreach ( $staffList as $key => $value ) {
  9876. if ($value ['username'] != 'admin') {
  9877. // 提交人
  9878. $receiptList = $receipt->find ( array (
  9879. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  9880. 'asArray' => true
  9881. ) );
  9882. if (! empty ( $receiptList )) {
  9883. $html = '<br><div><style></style>
  9884. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  9885. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  9886. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9887. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  9888. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9889. <tbody><tr>
  9890. <td style="padding: 0 40px;" align="left">
  9891. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9892. </td></tr><tr>
  9893. <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>
  9894. </tr>
  9895. </tbody> </table></td> </tr> <tr><td>
  9896. <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">
  9897. <tbody> <tr><td>
  9898. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  9899. 以下报销单完成了审批,等着收款吧:</p>
  9900. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  9901. foreach ( $receiptList as $k => $v ) {
  9902. $category = $Lcategory->getOne ( array (
  9903. 'where' => 'cid=' . $v ['cid'],
  9904. 'asArray' => true
  9905. ) );
  9906. $html .= '
  9907. <tr>
  9908. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  9909. <td align="left">
  9910. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  9911. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  9912. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  9913. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  9914. </tr>';
  9915. }
  9916. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  9917. <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>
  9918. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  9919. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  9920. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  9921. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9922. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9923. $receipt = new receipt ();
  9924. $receipt->notice = 1;
  9925. $receipt->update ( array (
  9926. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  9927. ) );
  9928. }
  9929. }
  9930. // 审批人
  9931. $verifyList = $verify->find ( array (
  9932. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  9933. 'asArray' => true
  9934. ) );
  9935. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  9936. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  9937. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9938. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  9939. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9940. <tbody><tr><td style="padding: 0 40px;" align="left">
  9941. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9942. </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>
  9943. </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">
  9944. <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>
  9945. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  9946. foreach ( $verifyList as $k => $v ) {
  9947. $receiptList = $receipt->find ( array (
  9948. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  9949. 'asArray' => true
  9950. ) );
  9951. foreach ( $receiptList as $r => $l ) {
  9952. $category = $Lcategory->getOne ( array (
  9953. 'where' => 'cid=' . $l ['cid'],
  9954. 'asArray' => true
  9955. ) );
  9956. $staffDetile = $staff->getOne ( array (
  9957. 'where' => 'sid=' . $l ['staff'],
  9958. 'asArray' => true
  9959. ) );
  9960. $html .= '
  9961. <tr>
  9962. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  9963. <td align="left">
  9964. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  9965. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  9966. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  9967. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  9968. </tr>';
  9969. }
  9970. }
  9971. $html .= '
  9972. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  9973. <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>
  9974. </tr></tbody></table></td></tr></tbody></table></div><br>';
  9975. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  9976. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  9977. // $receipt=new receipt();
  9978. // $receipt->notice=1;
  9979. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  9980. }
  9981. }
  9982. }
  9983. }
  9984. function setWXMsg($rid, $type) {
  9985. Doo::loadModel ( "receipt" );
  9986. $receipt = new receipt ();
  9987. $receiptDetail = $receipt->getOne ( array (
  9988. 'where' => 'rid=' . $rid,
  9989. 'asArray' => true
  9990. ) );
  9991. if (! empty ( $receiptDetail )) {
  9992. Doo::loadModel ( 'staff' );
  9993. $staff = new staff ();
  9994. $staffmsg = $staff->getOne ( array (
  9995. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  9996. 'asArray' => TRUE
  9997. ) );
  9998. if (! empty ( $staffmsg ['wxid'] )) {
  9999. require_once (SITE_PATH . '/protected/class/client.php');
  10000. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  10001. $user = $staffmsg ['wxid'];
  10002. $receiptName = '';
  10003. $msg = '';
  10004. switch ($receiptDetail ['Rtype']) {
  10005. case 0 :
  10006. $receiptName = '报销';
  10007. break;
  10008. case 1 :
  10009. $receiptName = '借款';
  10010. break;
  10011. case 2 :
  10012. $receiptName = '对公汇款';
  10013. break;
  10014. }
  10015. switch ($type) {
  10016. case 1 :
  10017. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  10018. break;
  10019. case 2 :
  10020. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  10021. break;
  10022. case 3 :
  10023. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  10024. break;
  10025. }
  10026. $result = $client->SendMsg ( $user, $msg, 'text' );
  10027. }
  10028. }
  10029. }
  10030. // Email发送函数
  10031. function SMail($toemail, $subject, $contents) {
  10032. Doo::loadClass ( 'class.phpmailer' );
  10033. $mail = new PHPMailer ();
  10034. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  10035. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  10036. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  10037. $mail->Password = "cDO1GjtY1seH"; // 密码
  10038. $mail->CharSet = "UTF8";
  10039. $mail->SMTPAuth = true;
  10040. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  10041. $mail->Mailer = "smtp";
  10042. $mail->Port = 25;
  10043. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  10044. $mail->MsgHTML ( $contents );
  10045. $mail->AddAddress ( $toemail );
  10046. $mail->CharSet = "UTF-8";
  10047. return $mail->Send ();
  10048. }
  10049. function swfupload() {
  10050. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  10051. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  10052. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  10053. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  10054. header ( "HTTP/1.1 500 Internal Server Error" );
  10055. echo "POST exceeded maximum allowed size.";
  10056. exit ( 0 );
  10057. }
  10058. // Settings
  10059. $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)
  10060. $upload_name = "Filedata";
  10061. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  10062. $extension_whitelist = array (
  10063. "doc",
  10064. "txt",
  10065. "jpg",
  10066. "gif",
  10067. "png"
  10068. ); // Allowed file extensions
  10069. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  10070. // Other variables
  10071. $MAX_FILENAME_LENGTH = 260;
  10072. $file_name = "";
  10073. $file_extension = "";
  10074. $uploadErrors = array (
  10075. 0 => "文件上传成功",
  10076. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  10077. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  10078. 3 => "上传的文件仅为部分文件",
  10079. 4 => "没有文件上传",
  10080. 6 => "缺少临时文件夹"
  10081. );
  10082. $nk = time ();
  10083. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  10084. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  10085. echo "文件无法保存.";
  10086. exit ( 0 );
  10087. }
  10088. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  10089. echo json_encode ( array (
  10090. 'filename' => $file_name,
  10091. 'id' => $nk
  10092. ) );
  10093. exit ( 0 );
  10094. }
  10095. function _GetFileEXT($filename) {
  10096. $pics = explode ( '.', $filename );
  10097. $num = count ( $pics );
  10098. return $pics [$num - 1];
  10099. }
  10100. /**
  10101. * 获取get或者POST值
  10102. * @param string $name 属性名称
  10103. * @return fixed 值
  10104. */
  10105. function get_args($name) {
  10106. if (isset ( $_GET [$name] )) {
  10107. if (is_array ( $_GET [$name] ))
  10108. return $_GET [$name];
  10109. else
  10110. return addslashes ( $_GET [$name] );
  10111. } elseif (isset ( $_POST [$name] )) {
  10112. if (is_array ( $_POST [$name] ))
  10113. return $_POST [$name];
  10114. else
  10115. return addslashes ( $_POST [$name] );
  10116. } else
  10117. return false;
  10118. }
  10119. function num_to_rmb($num) {
  10120. $c1 = "零壹贰叁肆伍陆柒捌玖";
  10121. $c2 = "分角元拾佰仟万拾佰仟亿";
  10122. // 精确到分后面就不要了,所以只留两个小数位
  10123. $num = round ( $num, 2 );
  10124. // 将数字转化为整数
  10125. $num = $num * 100;
  10126. if (strlen ( $num ) > 10) {
  10127. return "金额太大,请检查";
  10128. }
  10129. $i = 0;
  10130. $c = "";
  10131. while ( 1 ) {
  10132. if ($i == 0) {
  10133. // 获取最后一位数字
  10134. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  10135. } else {
  10136. $n = $num % 10;
  10137. }
  10138. // 每次将最后一位数字转化为中文
  10139. $p1 = substr ( $c1, 3 * $n, 3 );
  10140. $p2 = substr ( $c2, 3 * $i, 3 );
  10141. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  10142. $c = $p1 . $p2 . $c;
  10143. } else {
  10144. $c = $p1 . $c;
  10145. }
  10146. $i = $i + 1;
  10147. // 去掉数字最后一位了
  10148. $num = $num / 10;
  10149. $num = ( int ) $num;
  10150. // 结束循环
  10151. if ($num == 0) {
  10152. break;
  10153. }
  10154. }
  10155. $j = 0;
  10156. $slen = strlen ( $c );
  10157. while ( $j < $slen ) {
  10158. // utf8一个汉字相当3个字符
  10159. $m = substr ( $c, $j, 6 );
  10160. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  10161. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  10162. $left = substr ( $c, 0, $j );
  10163. $right = substr ( $c, $j + 3 );
  10164. $c = $left . $right;
  10165. $j = $j - 3;
  10166. $slen = $slen - 3;
  10167. }
  10168. $j = $j + 3;
  10169. }
  10170. // 这个是为了去掉类似23.0中最后一个“零”字
  10171. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  10172. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  10173. }
  10174. // 将处理的汉字加上“整”
  10175. if (empty ( $c )) {
  10176. return "零元整";
  10177. } else {
  10178. return $c . "整";
  10179. }
  10180. }
  10181. /**
  10182. * 获得分页数据
  10183. * @param unknown_type $table
  10184. * @param unknown_type $condition
  10185. * @param unknown_type $on_page
  10186. * @param unknown_type $page_size
  10187. */
  10188. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  10189. $page_c = "";
  10190. $page ['previous'] = $this->get_previous ( $on_page );
  10191. $page ['on_page'] = $on_page;
  10192. $total_count = $this->get_table_count ( $table, $condition );
  10193. $total = intval ( $total_count / $page_size );
  10194. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  10195. $page ['total_data'] = $total_count;
  10196. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  10197. $i = 1;
  10198. $page_max = 1;
  10199. $page_width = 3;
  10200. if ($on_page >= $page_width) {
  10201. $page_max = intval ( $on_page / $page_width ) + 1;
  10202. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  10203. }
  10204. for(; $i <= $page ['total_page']; $i ++) {
  10205. if ($i == $on_page)
  10206. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  10207. else
  10208. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  10209. if ($i == ($page_width * $page_max))
  10210. break;
  10211. }
  10212. $page ['page'] = $page_c;
  10213. $page ['lower'] = (-- $on_page) * $page_size;
  10214. return $page;
  10215. }
  10216. /**
  10217. * 获取总页数
  10218. * @param unknown_type $table
  10219. * @param unknown_type $condition
  10220. */
  10221. public function get_table_count($table = "", $condition = "") {
  10222. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10223. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10224. // echo $sql;die;
  10225. $query = Doo::db ()->query ( $sql );
  10226. $result = $query->fetch ();
  10227. return $result ['count'];
  10228. }
  10229. /**
  10230. * 获取上一页
  10231. * @param unknown_type $on_page
  10232. */
  10233. function get_previous($on_page = 1) {
  10234. return $on_page != 0 ? $on_page - 1 : $on_page;
  10235. }
  10236. }
  10237. ?>