ReceiptController.php 371 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576
  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. }
  302. return "/saeaBorad";
  303. }
  304. function remitEdit() {
  305. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  306. // echo $rid;
  307. Doo::loadModel ( 'accountItem' );
  308. Doo::loadModel ( 'verify' );
  309. Doo::loadModel ( 'receipt' );
  310. $receipt = new receipt ();
  311. $verify = new verify ();
  312. $accountItem = new accountItem ();
  313. Doo::loadModel ( 'L_category' );
  314. $lCategory = new L_category ();
  315. Doo::loadModel ( "role" );
  316. $role = new role ();
  317. $receiptDetail = $receipt->getOne ( array (
  318. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  319. 'asArray' => true
  320. ) );
  321. if (empty ( $receiptDetail ))
  322. return "/saeaCreate";
  323. $acItem = $accountItem->find ( array (
  324. 'asArray' => true
  325. ) );
  326. $veList = $verify->find ( array (
  327. 'asArray' => true
  328. ) );
  329. foreach ( $veList as $key => $value ) {
  330. $v = json_decode ( $value ['staff'] );
  331. $list = array ();
  332. foreach ( $v as $n => $m ) {
  333. if ($m ['1'] == 'ROLE') {
  334. $roleInfo = $role->getOne ( array (
  335. 'where' => 'rid=' . $m [0],
  336. 'asArray' => true
  337. ) );
  338. $v [$n] [1] = $roleInfo ['name'];
  339. array_push ( $list, $roleInfo ['name'] );
  340. } else {
  341. array_push ( $list, $v [$n] [1] );
  342. }
  343. }
  344. $veList [$key] ['staff'] = implode ( '>', $list );
  345. }
  346. // 配置编辑信息
  347. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  348. foreach ( $acItem as $key => $value ) {
  349. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  350. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  351. $acItem [$key] ['price'] = $v ['price'];
  352. }
  353. }
  354. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  355. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  356. $acItem [$key] ['price'] = $v ['price'];
  357. }
  358. }
  359. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  360. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  361. $acItem [$key] ['price'] = $v ['price'];
  362. }
  363. }
  364. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  365. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  366. $acItem [$key] ['price'] = $v ['price'];
  367. }
  368. }
  369. }
  370. $data ['category'] = $lCategory->find ( array (
  371. 'asArray' => true
  372. ) );
  373. $data ['cSum'] = $accountItemList ['cSum'];
  374. $data ['sum'] = $receiptDetail ['sum'];
  375. $data ['receiptDetail'] = $receiptDetail;
  376. $data ['veList'] = $veList;
  377. $data ['acItem'] = $acItem;
  378. $data ['memu'] = "receipt";
  379. $data ['staff'] = $this->staff;
  380. $data ['receiptMemu'] = 'saeaBorad';
  381. $data ['verify'] = $receiptDetail ['verify'];
  382. $data ['verifyId'] = $this->verifyId;
  383. $data ['executeId'] = $this->executeId;
  384. $data ['rid'] = $rid;
  385. $this->render ( "/admin/remitEdit", $data );
  386. }
  387. function remitEdiDo() {
  388. $agency = $this->get_args ( 'agency' );
  389. $travel = $this->get_args ( 'travel' );
  390. $train = $this->get_args ( 'train' );
  391. $other = $this->get_args ( 'other' );
  392. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  393. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  394. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  395. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  396. if (! empty ( $explanation )) {
  397. Doo::loadModel ( 'receipt' );
  398. Doo::loadModel ( 'receiptDetail' );
  399. Doo::loadModel ( 'accountItem' );
  400. $accountItem = new accountItem ();
  401. $receipt = new receipt ();
  402. Doo::loadModel ( 'execute' );
  403. $execute = new execute ();
  404. $executeDetail = $execute->getOne ( array (
  405. 'where' => 'mold="对公汇款执行人"',
  406. 'asArray' => true
  407. ) );
  408. $receiptDetail = $receipt->getOne ( array (
  409. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  410. 'asArray' => true
  411. ) );
  412. if (empty ( $receiptDetail ))
  413. return "/saeaBorad";
  414. $aItem = $accountItem->find ( array (
  415. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  416. 'asArray' => true
  417. ) );
  418. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  419. $ag = $tr = $ta = $ot = 0;
  420. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  421. foreach ( $aItem as $key => $value ) {
  422. if ($value ['category'] == $this->AGENCY) {
  423. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  424. array_push ( $accountJson [$this->AGENCY], array (
  425. 'aid' => $value ['aid'],
  426. 'name' => $value ['name'],
  427. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  428. ) );
  429. $sum += $agency [$ag];
  430. $agencySum += $agency [$ag];
  431. }
  432. $ag ++;
  433. }
  434. }
  435. $accountJson ['cSum'] = array (
  436. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  437. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  438. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  439. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  440. );
  441. // 报销单
  442. $rid = $receipt->rid = $receiptDetail ['rid'];
  443. $receipt->accountItem = json_encode ( $accountJson );
  444. $receipt->staff = $this->staff [0] ['sid'];
  445. $receipt->sum = number_format ( $sum, 2, '.', '' );
  446. $receipt->date = date ( "Y-m-d" );
  447. $receipt->cid = $cid;
  448. if ($receiptDetail ['Rtype'] == 1)
  449. $receipt->status = 7;
  450. else
  451. $receipt->status = 5;
  452. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  453. $receipt->verify = $verify;
  454. $receipt->executeCopy = $executeDetail ['staff'];
  455. $receipt->explanation = $explanation;
  456. $receipt->update ();
  457. $receiptDetail = new receiptDetail ();
  458. $receiptDetail->delete ( array (
  459. 'where' => 'rid=' . $rid
  460. ) );
  461. // 报销详情
  462. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  463. $receiptDetail = new receiptDetail ();
  464. $receiptDetail->staff = $this->staff [0] ['sid'];
  465. $receiptDetail->item = $value ['name'];
  466. $receiptDetail->itemCategory = $this->AGENCY;
  467. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  468. $receiptDetail->date = date ( "Y-m-d" );
  469. $receiptDetail->cid = $cid;
  470. $receiptDetail->rid = $rid;
  471. $receiptDetail->status = 4;
  472. $receiptDetail->insert ();
  473. }
  474. // return "/referReceipt/".$rid;
  475. }
  476. return "/saeaBorad";
  477. }
  478. function remitApproval() {
  479. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  480. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  481. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  482. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  483. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  484. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  485. if (empty ( $status ))
  486. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  487. $vidList = array ();
  488. $button = 0;
  489. Doo::loadModel ( 'verify' );
  490. Doo::loadModel ( 'receipt' );
  491. Doo::loadModel ( 'staff' );
  492. $staff = new staff ();
  493. $receipt = new receipt ();
  494. $verify = new verify ();
  495. Doo::loadModel ( 'L_category' );
  496. $Lcategory = new L_category ();
  497. Doo::loadModel ( 'enclosur' );
  498. $enclosur = new enclosur ();
  499. // user verify ID
  500. $verifyDetail = $verify->find ( array (
  501. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  502. 'asArray' => true
  503. ) );
  504. foreach ( $verifyDetail as $key => $value ) {
  505. array_push ( $vidList, $value ['vid'] );
  506. }
  507. $vid = implode ( ",", $vidList );
  508. if (empty ( $verifyDetail ))
  509. $vid = 0;
  510. $categoryList = $Lcategory->find ( array (
  511. 'asArray' => true
  512. ) );
  513. $staffList = $staff->find ( array (
  514. 'where' => 'cid=' . $cid,
  515. 'asArray' => true
  516. ) );
  517. $ap = "";
  518. if ($status == 4) {
  519. $ap = 4;
  520. $status = 2;
  521. }
  522. // get Receipt By verifyID status 2
  523. $receiptList = $receipt->find ( array (
  524. 'where' => 'rid =' . $rid.' and status=2',
  525. 'desc' => 'rid',
  526. 'asArray' => true
  527. ) );
  528. if(empty($receiptList)){
  529. die('illegal request');
  530. }
  531. $Locate = 0;
  532. $roleId = 0;
  533. if ($ap == 4)
  534. $status = 4;
  535. foreach ( $receiptList as $key => $value ) {
  536. $receiptList [$key] ['Locate'] = $Locate;
  537. $Locate ++;
  538. $receiptList [$key] ['reviseDetail'] = array ();
  539. if (! empty ( $value ['reviseDetail'] ))
  540. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  541. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  542. $categoryDetil = $Lcategory->getOne ( array (
  543. 'where' => 'cid=' . $value ['cid'],
  544. 'asArray' => true
  545. ) );
  546. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  547. // 检测编辑状态
  548. $verifyList = $verify->getOne ( array (
  549. 'where' => 'vid=' . $value ['verify'],
  550. 'asArray' => true
  551. ) );
  552. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  553. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  554. Doo::loadModel ( 'role' );
  555. $role = new role ();
  556. // print_r($verifyList);
  557. $flag = true;
  558. $roleKey = 0;
  559. $endStaffArray = array ();
  560. $roleArrayCopy = array ();
  561. foreach ( $verifyList as $k => $v ) {
  562. // init verifyStaff
  563. if ($v [1] == 'ROLE') {
  564. if (! empty ( $verifyStaff )) {
  565. $endStaffArray = end ( $verifyStaff );
  566. if ($v [0] == $endStaffArray ['nextStaff']) {
  567. $roleId = $v [0];
  568. }
  569. }
  570. $roleVerify = json_decode ( $v [3], true );
  571. $roleKey = $k;
  572. $roleArray = array ();
  573. $rolename = $role->getOne ( array (
  574. 'where' => 'rid=' . $v [0],
  575. 'asArray' => true
  576. ) );
  577. foreach ( $roleVerify as $o => $p ) {
  578. $staffID = explode ( '_', $p );
  579. $staffInfo = $staff->getOne ( array (
  580. 'where' => 'sid=' . $staffID [0],
  581. 'asArray' => true
  582. ) );
  583. // print_r($staffID);
  584. $exp = array (
  585. 0 => $staffInfo ['sid'],
  586. 1 => $staffID [1],
  587. 2 => $staffInfo ['avatar'],
  588. 'date' => '',
  589. 'date' => '',
  590. 'opinion' => '',
  591. 'status' => '',
  592. 'rolename' => $rolename ['name']
  593. );
  594. array_push ( $roleArray, $exp );
  595. }
  596. $roleArrayCopy [$v [0]] = $roleArray;
  597. // $verifyList[$k]['roleArray']=$roleArray;
  598. }
  599. // print_r($roleArray);
  600. $verifyList [$k] ['date'] = "";
  601. $verifyList [$k] ['opinion'] = "";
  602. $verifyList [$k] ['status'] = "";
  603. if (empty ( $verifyStaff )) {
  604. $verifyList [$k] ['date'] = "";
  605. $verifyList [$k] ['opinion'] = "";
  606. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  607. $verifyList [$k] ['status'] = 4;
  608. $button = 4;
  609. $flag = false;
  610. }
  611. } else {
  612. foreach ( $verifyStaff as $m => $u ) {
  613. if ($v [0] == $m) {
  614. $verifyList [$k] ['date'] = $u ['date'];
  615. $verifyList [$k] ['opinion'] = $u ['opinion'];
  616. $verifyList [$k] ['status'] = $u ['status'];
  617. $flag = false;
  618. break;
  619. }
  620. }
  621. $endStaffArray = end ( $verifyStaff );
  622. if (isset ( $endStaffArray ['ROLE'] )) {
  623. } else {
  624. $endKey = key ( $verifyStaff );
  625. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  626. $button = 4;
  627. $verifyList [$k] ['status'] = 4;
  628. }
  629. }
  630. }
  631. }
  632. $rolename ['name'] = '';
  633. if (! empty ( $roleId )) {
  634. Doo::loadModel ( 'role' );
  635. $role = new role ();
  636. $rolename = $role->getOne ( array (
  637. 'where' => 'rid=' . $roleId,
  638. 'asArray' => true
  639. ) );
  640. }
  641. if (! empty ( $verifyStaff ))
  642. $endStaffArray = end ( $verifyStaff );
  643. $KOP = false;
  644. foreach ( $roleArrayCopy as $P => $A ) {
  645. foreach ( $A as $MKI => $AVL ) {
  646. if (! empty ( $verifyStaff )) {
  647. // &&$rolename['rid']==$endStaffArray['nextStaff']
  648. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  649. $button = 4;
  650. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  651. }
  652. foreach ( $verifyStaff as $m => $u ) {
  653. $AVLFK = $AVL [0] . '_R';
  654. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  655. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  656. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  657. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  658. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  659. break;
  660. }
  661. }
  662. } else {
  663. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  664. $button = 4;
  665. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  666. }
  667. }
  668. // $roleArray[$MKI]['rolename']=$rolename['name'];
  669. $KOP = true;
  670. }
  671. }
  672. foreach ( $roleArrayCopy as $k => $v ) {
  673. foreach ( $verifyList as $m => $n ) {
  674. if ($n [0] == $k) {
  675. array_splice ( $verifyList, $m, 1, $v );
  676. }
  677. }
  678. }
  679. $receiptList [$key] ['verifyList'] = $verifyList;
  680. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  681. 'where' => 'sid=' . $value ['staff'],
  682. 'asArray' => true
  683. ) );
  684. $receiptList [$key] ['button'] = $button;
  685. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  686. }
  687. $mothHtml = "";
  688. for($i = 1; $i <= 12; $i ++) {
  689. if ($month == $i)
  690. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  691. else
  692. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  693. }
  694. // 获取审批日志
  695. Doo::loadModel ( 'receiptLog' );
  696. $receiptLog = new receiptLog ();
  697. $rlList = array ();
  698. $rlInfo = $receiptLog->getOne ( array (
  699. 'where' => 'rid=' . $rid . ' and status=4',
  700. 'asArray' => true
  701. ) );
  702. $tijdate = $receiptLog->getOne ( array (
  703. 'where' => 'rid=' . $rid . ' and status=2',
  704. 'asc' => 'rlid',
  705. 'asArray' => true
  706. ) );
  707. if (! empty ( $rlInfo )) {
  708. $rlList = $receiptLog->find ( array (
  709. 'where' => 'rid=' . $rid,
  710. 'asc' => 'rlid',
  711. 'asArray' => true
  712. ) );
  713. }
  714. $receiptList [0] ['rlList'] = $rlList;
  715. $enclosurList = $enclosur->find ( array (
  716. 'where' => 'rid=' . $rid,
  717. 'asArray' => true
  718. ) );
  719. $enclosurHtml = '';
  720. foreach ( $enclosurList as $value ) {
  721. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  722. }
  723. // print_r($receiptList);
  724. $data ['enclosurHtml'] = $enclosurHtml;
  725. $data ['rolename'] = $rolename ['name'];
  726. $data ['datetij'] = $tijdate ['date'];
  727. $data ['mothHtml'] = $mothHtml;
  728. $data ['rid'] = $rid;
  729. $data ['receiptList'] = $receiptList;
  730. $data ['receiptApprovalCount'] = count ( $receiptList );
  731. $data ['status'] = $status;
  732. $data ['year'] = $year;
  733. $data ['categoryList'] = $categoryList;
  734. $data ['staffList'] = $staffList;
  735. $data ['cid'] = $cid;
  736. $data ['sid'] = $sid;
  737. $data ['ap'] = $ap;
  738. $data ['memu'] = "receipt";
  739. $data ['staff'] = $this->staff;
  740. $data ['receiptMemu'] = 'approvalExpenses';
  741. $data ['verifyId'] = $this->verifyId;
  742. $data ['executeId'] = $this->executeId;
  743. $this->render ( "/admin/remitApproval", $data );
  744. }
  745. function saeaLoanAdd() {
  746. Doo::loadModel ( 'verify' );
  747. $verify = new verify ();
  748. Doo::loadModel ( "role" );
  749. $role = new role ();
  750. Doo::loadModel ( 'L_category' );
  751. $lCategory = new L_category ();
  752. $veList = $verify->find ( array (
  753. 'asArray' => true
  754. ) );
  755. foreach ( $veList as $key => $value ) {
  756. $v = json_decode ( $value ['staff'] );
  757. $list = array ();
  758. foreach ( $v as $n => $m ) {
  759. if ($m ['1'] == 'ROLE') {
  760. $roleInfo = $role->getOne ( array (
  761. 'where' => 'rid=' . $m [0],
  762. 'asArray' => true
  763. ) );
  764. $v [$n] [1] = $roleInfo ['name'];
  765. array_push ( $list, $roleInfo ['name'] );
  766. } else {
  767. array_push ( $list, $v [$n] [1] );
  768. }
  769. }
  770. $veList [$key] ['staff'] = implode ( '>', $list );
  771. }
  772. $data ['category'] = $lCategory->find ( array (
  773. 'asArray' => true
  774. ) );
  775. $data ['veList'] = $veList;
  776. $data ['memu'] = "receipt";
  777. $data ['staff'] = $this->staff;
  778. $data ['receiptMemu'] = 'saeaBorad';
  779. $data ['verifyId'] = $this->verifyId;
  780. $data ['executeId'] = $this->executeId;
  781. $this->render ( "/admin/saeaLoanAdd", $data );
  782. }
  783. function saeaLoanAddDo() {
  784. $agency = $this->get_args ( 'agency' );
  785. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  786. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  787. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  788. // die;
  789. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  790. Doo::loadModel ( 'receipt' );
  791. Doo::loadModel ( 'receiptDetail' );
  792. Doo::loadModel ( 'accountItem' );
  793. $accountItem = new accountItem ();
  794. $receipt = new receipt ();
  795. Doo::loadModel ( 'loanReceipt' );
  796. $loanReceipt = new loanReceipt ();
  797. Doo::loadModel ( 'execute' );
  798. $execute = new execute ();
  799. Doo::loadModel ( 'enclosur' );
  800. $executeDetail = $execute->getOne ( array (
  801. 'where' => 'mold="借款执行人"',
  802. 'asArray' => true
  803. ) );
  804. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  805. // if(!empty($receiptDetail))
  806. // return "/referReceipt/".$receiptDetail['rid'];
  807. $aItem = $accountItem->find ( array (
  808. 'asArray' => true
  809. ) );
  810. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  811. $ag = $tr = $ta = $ot = 0;
  812. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  813. array_push ( $accountJson ['借款费用'], array (
  814. 'aid' => 0,
  815. 'name' => '申请金额',
  816. 'price' => number_format ( $agency, 2, '.', '' )
  817. ) );
  818. $sum += $agency;
  819. $agencySum += $agency;
  820. $accountJson ['cSum'] = array (
  821. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  822. 'agencySum' => number_format ( 0, 2, '.', '' ),
  823. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  824. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  825. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  826. );
  827. // 借款数据备份
  828. $loanReceipt->loanItem = json_encode ( $accountJson );
  829. $loanReceipt->staff = $this->staff [0] ['sid'];
  830. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  831. $loanReceipt->date = date ( "Y-m-d" );
  832. $loanReceipt->cid = $cid;
  833. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  834. $loanReceipt->status = 5;
  835. $loanReceipt->Rtype = 1;
  836. $loanReceipt->verify = $verify;
  837. $receipt->receiptOrder = $receipt->receiptOrder;
  838. $loanReceipt->explanation = $explanation;
  839. $loanRid = $loanReceipt->insert ();
  840. // 报销单
  841. $receipt->loanItem = json_encode ( $accountJson );
  842. $receipt->staff = $this->staff [0] ['sid'];
  843. $receipt->sum = number_format ( $sum, 2, '.', '' );
  844. $receipt->date = date ( "Y-m-d" );
  845. $receipt->cid = $cid;
  846. // 特殊状态
  847. $receipt->status = 5;
  848. $receipt->Rtype = 1;
  849. $receipt->loanRid = $loanRid;
  850. // 修改审批流程加入角色
  851. $receipt->verify = $verify;
  852. $receipt->executeCopy = $executeDetail ['staff'];
  853. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  854. $receipt->explanation = $explanation;
  855. $rid = $receipt->insert ();
  856. // 执行数据备份
  857. // $executeCopy->rid=$rid;
  858. // $executeCopy->staff=$executeDetail['staff'];
  859. // $executeCopy->eid=$executeDetail['eid'];
  860. // $ecid=$executeCopy->insert();
  861. }
  862. return "/saeaBorad";
  863. }
  864. function saeaLoanEdi() {
  865. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  866. Doo::loadModel ( 'verify' );
  867. $verify = new verify ();
  868. Doo::loadModel ( "role" );
  869. $role = new role ();
  870. Doo::loadModel ( 'L_category' );
  871. $lCategory = new L_category ();
  872. Doo::loadModel ( 'receipt' );
  873. $receipt = new receipt ();
  874. $receiptInfo = $receipt->getOne ( array (
  875. 'where' => 'rid=' . $rid,
  876. 'asArray' => true
  877. ) );
  878. $veList = $verify->find ( array (
  879. 'asArray' => true
  880. ) );
  881. foreach ( $veList as $key => $value ) {
  882. $v = json_decode ( $value ['staff'] );
  883. $list = array ();
  884. foreach ( $v as $n => $m ) {
  885. if ($m ['1'] == 'ROLE') {
  886. $roleInfo = $role->getOne ( array (
  887. 'where' => 'rid=' . $m [0],
  888. 'asArray' => true
  889. ) );
  890. $v [$n] [1] = $roleInfo ['name'];
  891. array_push ( $list, $roleInfo ['name'] );
  892. } else {
  893. array_push ( $list, $v [$n] [1] );
  894. }
  895. }
  896. $veList [$key] ['staff'] = implode ( '>', $list );
  897. }
  898. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  899. $data ['receiptInfo'] = $receiptInfo;
  900. $data ['category'] = $lCategory->find ( array (
  901. 'asArray' => true
  902. ) );
  903. $data ['veList'] = $veList;
  904. $data ['memu'] = "receipt";
  905. $data ['staff'] = $this->staff;
  906. $data ['receiptMemu'] = 'saeaBorad';
  907. $data ['verifyId'] = $this->verifyId;
  908. $data ['executeId'] = $this->executeId;
  909. $this->render ( "/admin/saeaLoanEdi", $data );
  910. }
  911. function saeaLoanEdiDo() {
  912. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  913. $agency = $this->get_args ( 'agency' );
  914. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  915. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  916. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  917. // die;
  918. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )) {
  919. Doo::loadModel ( 'receipt' );
  920. Doo::loadModel ( 'receiptDetail' );
  921. Doo::loadModel ( 'accountItem' );
  922. $accountItem = new accountItem ();
  923. $receipt = new receipt ();
  924. Doo::loadModel ( 'loanReceipt' );
  925. $loanReceipt = new loanReceipt ();
  926. Doo::loadModel ( 'enclosur' );
  927. Doo::loadModel ( 'execute' );
  928. $execute = new execute ();
  929. $executeDetail = $execute->getOne ( array (
  930. 'where' => 'mold="借款执行人"',
  931. 'asArray' => true
  932. ) );
  933. $receiptDetail = $receipt->getOne ( array (
  934. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  935. 'asArray' => true
  936. ) );
  937. if (empty ( $receiptDetail ))
  938. die ( '参数错误' );
  939. $aItem = $accountItem->find ( array (
  940. 'asArray' => true
  941. ) );
  942. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  943. $ag = $tr = $ta = $ot = 0;
  944. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  945. array_push ( $accountJson ['借款费用'], array (
  946. 'aid' => 0,
  947. 'name' => '申请金额',
  948. 'price' => number_format ( $agency, 2, '.', '' )
  949. ) );
  950. $sum += $agency;
  951. $agencySum += $agency;
  952. $accountJson ['cSum'] = array (
  953. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  954. 'agencySum' => number_format ( 0, 2, '.', '' ),
  955. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  956. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  957. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  958. );
  959. // 报销单
  960. $receipt->loanItem = json_encode ( $accountJson );
  961. $receipt->sum = number_format ( $sum, 2, '.', '' );
  962. $receipt->cid = $cid;
  963. // 特殊状态
  964. // 修改审批流程加入角色
  965. if ($receiptDetail ['status'] != 4)
  966. $receipt->verify = $verify;
  967. $receipt->explanation = $explanation;
  968. $receipt->update ( array (
  969. 'where' => 'rid=' . $rid
  970. ) );
  971. // 借款数据更新
  972. $loanReceipt->loanItem = json_encode ( $accountJson );
  973. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  974. $loanReceipt->cid = $cid;
  975. if ($receiptDetail ['status'] != 4)
  976. $loanReceipt->verify = $verify;
  977. $loanReceipt->explanation = $explanation;
  978. $receipt->executeCopy = $executeDetail ['staff'];
  979. $loanReceipt->update ( array (
  980. 'where' => 'rid=' . $receiptDetail ['loanRid']
  981. ) );
  982. }
  983. return "/saeaBorad";
  984. }
  985. function saeaLoanReceiptAdd() {
  986. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  987. Doo::loadModel ( 'receipt' );
  988. $receipt = new receipt ();
  989. Doo::loadModel ( 'loanReceipt' );
  990. $loanReceipt = new loanReceipt ();
  991. Doo::loadModel ( 'L_category' );
  992. $Lcategory = new L_category ();
  993. Doo::loadModel ( 'verify' );
  994. Doo::loadModel ( 'statistics' );
  995. $statistics = new statistics ();
  996. $verify = new verify ();
  997. Doo::loadModel ( 'staff' );
  998. $staff = new staff ();
  999. $receiptDe = $receipt->getOne ( array (
  1000. 'where' => 'rid=' . $rid,
  1001. 'desc' => 'rid',
  1002. 'asArray' => true
  1003. ) );
  1004. $receiptList = $loanReceipt->find ( array (
  1005. 'where' => 'rid=' . $receiptDe ['loanRid'],
  1006. 'desc' => 'rid',
  1007. 'asArray' => true
  1008. ) );
  1009. $Locate = 0;
  1010. $roleId = 0;
  1011. $button = 0;
  1012. foreach ( $receiptList as $key => $value ) {
  1013. $receiptList [$key] ['Locate'] = $Locate;
  1014. $Locate ++;
  1015. $receiptList [$key] ['reviseDetail'] = array ();
  1016. if (! empty ( $value ['reviseDetail'] ))
  1017. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1018. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1019. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1020. $categoryDetil = $Lcategory->getOne ( array (
  1021. 'where' => 'cid=' . $value ['cid'],
  1022. 'asArray' => true
  1023. ) );
  1024. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1025. // 检测编辑状态
  1026. $verifyList = $verify->getOne ( array (
  1027. 'where' => 'vid=' . $value ['verify'],
  1028. 'asArray' => true
  1029. ) );
  1030. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1031. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1032. Doo::loadModel ( 'role' );
  1033. $role = new role ();
  1034. $flag = true;
  1035. $roleKey = 0;
  1036. $endStaffArray = array ();
  1037. $roleArrayCopy = array ();
  1038. foreach ( $verifyList as $k => $v ) {
  1039. // init verifyStaff
  1040. if ($v [1] == 'ROLE') {
  1041. if (! empty ( $verifyStaff )) {
  1042. $endStaffArray = end ( $verifyStaff );
  1043. // if ($v[0]==$endStaffArray['nextStaff']){
  1044. // $roleId=$v[0];
  1045. // }
  1046. }
  1047. $roleVerify = json_decode ( $v [3], true );
  1048. $roleKey = $k;
  1049. $roleArray = array ();
  1050. $rolename = $role->getOne ( array (
  1051. 'where' => 'rid=' . $v [0],
  1052. 'asArray' => true
  1053. ) );
  1054. foreach ( $roleVerify as $o => $p ) {
  1055. $staffID = explode ( '_', $p );
  1056. $staffInfo = $staff->getOne ( array (
  1057. 'where' => 'sid=' . $staffID [0],
  1058. 'asArray' => true
  1059. ) );
  1060. // print_r($staffID);
  1061. $exp = array (
  1062. 0 => $staffInfo ['sid'],
  1063. 1 => $staffID [1],
  1064. 2 => $staffInfo ['avatar'],
  1065. 'date' => '',
  1066. 'date' => '',
  1067. 'opinion' => '',
  1068. 'status' => '',
  1069. 'rolename' => $rolename ['name']
  1070. );
  1071. array_push ( $roleArray, $exp );
  1072. }
  1073. $roleArrayCopy [$v [0]] = $roleArray;
  1074. // $verifyList[$k]['roleArray']=$roleArray;
  1075. }
  1076. $verifyList [$k] ['date'] = "";
  1077. $verifyList [$k] ['opinion'] = "";
  1078. $verifyList [$k] ['status'] = "";
  1079. if (empty ( $verifyStaff )) {
  1080. $verifyList [$k] ['date'] = "";
  1081. $verifyList [$k] ['opinion'] = "";
  1082. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1083. $verifyList [$k] ['status'] = 4;
  1084. $flag = false;
  1085. }
  1086. } else {
  1087. foreach ( $verifyStaff as $m => $u ) {
  1088. if ($v [0] == $m) {
  1089. $verifyList [$k] ['date'] = $u ['date'];
  1090. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1091. $verifyList [$k] ['status'] = $u ['status'];
  1092. $flag = false;
  1093. break;
  1094. }
  1095. }
  1096. $endStaffArray = end ( $verifyStaff );
  1097. if (isset ( $endStaffArray ['ROLE'] )) {
  1098. } else {
  1099. // $endKey=key($verifyStaff);
  1100. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1101. // $button=4;
  1102. // $verifyList[$k]['status']=4;
  1103. // }
  1104. }
  1105. }
  1106. }
  1107. $rolename ['name'] = '';
  1108. if (! empty ( $roleId )) {
  1109. Doo::loadModel ( 'role' );
  1110. $role = new role ();
  1111. $rolename = $role->getOne ( array (
  1112. 'where' => 'rid=' . $roleId,
  1113. 'asArray' => true
  1114. ) );
  1115. }
  1116. if (! empty ( $verifyStaff ))
  1117. $endStaffArray = end ( $verifyStaff );
  1118. $KOP = false;
  1119. foreach ( $roleArrayCopy as $P => $A ) {
  1120. foreach ( $A as $MKI => $AVL ) {
  1121. if (! empty ( $verifyStaff )) {
  1122. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1123. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1124. $button = 4;
  1125. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1126. }
  1127. foreach ( $verifyStaff as $m => $u ) {
  1128. $AVLFK = $AVL [0] . '_R';
  1129. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1130. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1131. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1132. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1133. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1134. break;
  1135. }
  1136. }
  1137. } else {
  1138. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1139. $button = 4;
  1140. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1141. }
  1142. }
  1143. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1144. $KOP = true;
  1145. }
  1146. }
  1147. foreach ( $roleArrayCopy as $k => $v ) {
  1148. foreach ( $verifyList as $m => $n ) {
  1149. if ($n [0] == $k) {
  1150. array_splice ( $verifyList, $m, 1, $v );
  1151. }
  1152. }
  1153. }
  1154. $receiptList [$key] ['verifyList'] = $verifyList;
  1155. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1156. 'where' => 'sid=' . $value ['staff'],
  1157. 'asArray' => true
  1158. ) );
  1159. $receiptList [$key] ['button'] = $button;
  1160. //
  1161. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1162. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1163. }
  1164. $data ['receiptList'] = $receiptList;
  1165. Doo::loadModel ( 'L_category' );
  1166. $lCategory = new L_category ();
  1167. Doo::loadModel ( 'accountItem' );
  1168. $accountItem = new accountItem ();
  1169. $acItem = $accountItem->find ( array (
  1170. 'asArray' => true
  1171. ) );
  1172. $veList = $verify->find ( array (
  1173. 'asArray' => true
  1174. ) );
  1175. foreach ( $veList as $key => $value ) {
  1176. $v = json_decode ( $value ['staff'] );
  1177. $list = array ();
  1178. foreach ( $v as $n => $m ) {
  1179. if ($m ['1'] == 'ROLE') {
  1180. $roleInfo = $role->getOne ( array (
  1181. 'where' => 'rid=' . $m [0],
  1182. 'asArray' => true
  1183. ) );
  1184. $v [$n] [1] = $roleInfo ['name'];
  1185. array_push ( $list, $roleInfo ['name'] );
  1186. } else {
  1187. array_push ( $list, $v [$n] [1] );
  1188. }
  1189. }
  1190. $veList [$key] ['staff'] = implode ( '>', $list );
  1191. }
  1192. $data ['rid'] = $rid;
  1193. $data ['category'] = $lCategory->find ( array (
  1194. 'asArray' => true
  1195. ) );
  1196. $data ['veList'] = $veList;
  1197. $data ['acItem'] = $acItem;
  1198. $data ['memu'] = "receipt";
  1199. $data ['staff'] = $this->staff;
  1200. $data ['receiptMemu'] = 'saeaBorad';
  1201. $data ['verifyId'] = $this->verifyId;
  1202. $data ['executeId'] = $this->executeId;
  1203. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1204. }
  1205. function saeaLoanReceiptAddDo() {
  1206. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1207. $agency = $this->get_args ( 'agency' );
  1208. $travel = $this->get_args ( 'travel' );
  1209. $train = $this->get_args ( 'train' );
  1210. $other = $this->get_args ( 'other' );
  1211. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1212. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1213. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1214. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1215. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )) {
  1216. Doo::loadModel ( 'receipt' );
  1217. Doo::loadModel ( 'receiptDetail' );
  1218. Doo::loadModel ( 'accountItem' );
  1219. $accountItem = new accountItem ();
  1220. $receipt = new receipt ();
  1221. Doo::loadModel ( 'enclosur' );
  1222. Doo::loadModel ( 'execute' );
  1223. $execute = new execute ();
  1224. $executeDetail = $execute->getOne ( array (
  1225. 'where' => 'mold="借款费用执行人"',
  1226. 'asArray' => true
  1227. ) );
  1228. $receiptDet = $receipt->getOne ( array (
  1229. 'where' => 'rid=' . $rid,
  1230. 'asArray' => true
  1231. ) );
  1232. // if(!empty($receiptDetail))
  1233. // return "/referReceipt/".$receiptDetail['rid'];
  1234. $aItem = $accountItem->find ( array (
  1235. 'asArray' => true
  1236. ) );
  1237. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1238. $ag = $tr = $ta = $ot = 0;
  1239. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1240. foreach ( $aItem as $key => $value ) {
  1241. if ($value ['category'] == $this->AGENCY) {
  1242. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1243. array_push ( $accountJson [$this->AGENCY], array (
  1244. 'aid' => $value ['aid'],
  1245. 'name' => $value ['name'],
  1246. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1247. ) );
  1248. $sum += $agency [$ag];
  1249. $agencySum += $agency [$ag];
  1250. }
  1251. $ag ++;
  1252. }
  1253. if ($value ['category'] == $this->TRAVEL) {
  1254. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1255. array_push ( $accountJson [$this->TRAVEL], array (
  1256. 'aid' => $value ['aid'],
  1257. 'name' => $value ['name'],
  1258. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1259. ) );
  1260. $sum += $travel [$tr];
  1261. $travelSum += $travel [$tr];
  1262. }
  1263. $tr ++;
  1264. }
  1265. if ($value ['category'] == $this->TRAIN) {
  1266. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1267. array_push ( $accountJson [$this->TRAIN], array (
  1268. 'aid' => $value ['aid'],
  1269. 'name' => $value ['name'],
  1270. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1271. ) );
  1272. $sum += $train [$ta];
  1273. $trainSum += $train [$ta];
  1274. }
  1275. $ta ++;
  1276. }
  1277. if ($value ['category'] == $this->OTHER) {
  1278. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1279. array_push ( $accountJson [$this->OTHER], array (
  1280. 'aid' => $value ['aid'],
  1281. 'name' => $value ['name'],
  1282. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1283. ) );
  1284. $sum += $other [$ot];
  1285. $otherSum += $other [$ot];
  1286. }
  1287. $ot ++;
  1288. }
  1289. }
  1290. $accountJson ['cSum'] = array (
  1291. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1292. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1293. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1294. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1295. );
  1296. // 报销单
  1297. $receipt->accountItem = json_encode ( $accountJson );
  1298. $receipt->staff = $this->staff [0] ['sid'];
  1299. $receipt->loanSum = $receiptDet ['sum'];
  1300. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1301. $receipt->date = date ( "Y-m-d" );
  1302. $receipt->pastDate = '';
  1303. $receipt->cid = $cid;
  1304. $receipt->status = 7;
  1305. // 修改审批流程加入角色
  1306. $receipt->verify = $verify;
  1307. $receipt->verifyStaff = '';
  1308. $receipt->executeStaff = '';
  1309. $receipt->executeCopy = $executeDetail ['staff'];
  1310. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  1311. $receipt->explanation = $explanation;
  1312. $receipt->update ( array (
  1313. 'where' => 'rid=' . $rid
  1314. ) );
  1315. // 附件
  1316. if (! empty ( $enclosurName )) {
  1317. $enclosurArray = explode ( '-', $enclosurName );
  1318. foreach ( $enclosurArray as $value ) {
  1319. $enclosur = new enclosur ();
  1320. $enclosur->name = $value;
  1321. $enclosur->rid = $rid;
  1322. $enclosur->insert ();
  1323. }
  1324. // print_r($enclosurArray);die;
  1325. }
  1326. // 报销详情
  1327. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1328. $receiptDetail = new receiptDetail ();
  1329. $receiptDetail->staff = $this->staff [0] ['sid'];
  1330. $receiptDetail->item = $value ['name'];
  1331. $receiptDetail->itemCategory = $this->AGENCY;
  1332. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1333. $receiptDetail->date = date ( "Y-m-d" );
  1334. $receiptDetail->cid = $cid;
  1335. $receiptDetail->rid = $rid;
  1336. $receiptDetail->status = 4;
  1337. $receiptDetail->insert ();
  1338. }
  1339. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1340. $receiptDetail = new receiptDetail ();
  1341. $receiptDetail->staff = $this->staff [0] ['sid'];
  1342. $receiptDetail->item = $value ['name'];
  1343. $receiptDetail->itemCategory = $this->TRAVEL;
  1344. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1345. $receiptDetail->date = date ( "Y-m-d" );
  1346. $receiptDetail->cid = $cid;
  1347. $receiptDetail->rid = $rid;
  1348. $receiptDetail->status = 4;
  1349. $receiptDetail->insert ();
  1350. }
  1351. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1352. $receiptDetail = new receiptDetail ();
  1353. $receiptDetail->staff = $this->staff [0] ['sid'];
  1354. $receiptDetail->item = $value ['name'];
  1355. $receiptDetail->itemCategory = $this->TRAIN;
  1356. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1357. $receiptDetail->date = date ( "Y-m-d" );
  1358. $receiptDetail->cid = $cid;
  1359. $receiptDetail->rid = $rid;
  1360. $receiptDetail->status = 4;
  1361. $receiptDetail->insert ();
  1362. }
  1363. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1364. $receiptDetail = new receiptDetail ();
  1365. $receiptDetail->staff = $this->staff [0] ['sid'];
  1366. $receiptDetail->item = $value ['name'];
  1367. $receiptDetail->itemCategory = $this->OTHER;
  1368. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1369. $receiptDetail->date = date ( "Y-m-d" );
  1370. $receiptDetail->cid = $cid;
  1371. $receiptDetail->rid = $rid;
  1372. $receiptDetail->status = 4;
  1373. $receiptDetail->insert ();
  1374. }
  1375. return "/saeaBorad";
  1376. }
  1377. return "/saeaLoanReceiptAdd/" . $rid;
  1378. }
  1379. function saeaLoanReceiptEdi() {
  1380. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1381. // echo $rid;
  1382. Doo::loadModel ( 'accountItem' );
  1383. Doo::loadModel ( 'verify' );
  1384. Doo::loadModel ( 'receipt' );
  1385. $receipt = new receipt ();
  1386. $verify = new verify ();
  1387. $accountItem = new accountItem ();
  1388. Doo::loadModel ( 'L_category' );
  1389. $Lcategory = new L_category ();
  1390. Doo::loadModel ( "role" );
  1391. $role = new role ();
  1392. Doo::loadModel ( 'loanReceipt' );
  1393. $loanReceipt = new loanReceipt ();
  1394. Doo::loadModel ( 'staff' );
  1395. $staff = new staff ();
  1396. $receiptDetail = $receipt->getOne ( array (
  1397. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  1398. 'asArray' => true
  1399. ) );
  1400. if (empty ( $receiptDetail ))
  1401. return "/saeaBorad";
  1402. $receiptList = $loanReceipt->find ( array (
  1403. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1404. 'desc' => 'rid',
  1405. 'asArray' => true
  1406. ) );
  1407. $Locate = 0;
  1408. $roleId = 0;
  1409. $button = 0;
  1410. foreach ( $receiptList as $key => $value ) {
  1411. $receiptList [$key] ['Locate'] = $Locate;
  1412. $Locate ++;
  1413. $receiptList [$key] ['reviseDetail'] = array ();
  1414. if (! empty ( $value ['reviseDetail'] ))
  1415. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1416. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1417. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1418. $categoryDetil = $Lcategory->getOne ( array (
  1419. 'where' => 'cid=' . $value ['cid'],
  1420. 'asArray' => true
  1421. ) );
  1422. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1423. // 检测编辑状态
  1424. $verifyList = $verify->getOne ( array (
  1425. 'where' => 'vid=' . $value ['verify'],
  1426. 'asArray' => true
  1427. ) );
  1428. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1429. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1430. Doo::loadModel ( 'role' );
  1431. $role = new role ();
  1432. $flag = true;
  1433. $roleKey = 0;
  1434. $endStaffArray = array ();
  1435. $roleArrayCopy = array ();
  1436. foreach ( $verifyList as $k => $v ) {
  1437. // init verifyStaff
  1438. if ($v [1] == 'ROLE') {
  1439. if (! empty ( $verifyStaff )) {
  1440. $endStaffArray = end ( $verifyStaff );
  1441. // if ($v[0]==$endStaffArray['nextStaff']){
  1442. // $roleId=$v[0];
  1443. // }
  1444. }
  1445. $roleVerify = json_decode ( $v [3], true );
  1446. $roleKey = $k;
  1447. $roleArray = array ();
  1448. $rolename = $role->getOne ( array (
  1449. 'where' => 'rid=' . $v [0],
  1450. 'asArray' => true
  1451. ) );
  1452. foreach ( $roleVerify as $o => $p ) {
  1453. $staffID = explode ( '_', $p );
  1454. $staffInfo = $staff->getOne ( array (
  1455. 'where' => 'sid=' . $staffID [0],
  1456. 'asArray' => true
  1457. ) );
  1458. // print_r($staffID);
  1459. $exp = array (
  1460. 0 => $staffInfo ['sid'],
  1461. 1 => $staffID [1],
  1462. 2 => $staffInfo ['avatar'],
  1463. 'date' => '',
  1464. 'date' => '',
  1465. 'opinion' => '',
  1466. 'status' => '',
  1467. 'rolename' => $rolename ['name']
  1468. );
  1469. array_push ( $roleArray, $exp );
  1470. }
  1471. $roleArrayCopy [$v [0]] = $roleArray;
  1472. // $verifyList[$k]['roleArray']=$roleArray;
  1473. }
  1474. $verifyList [$k] ['date'] = "";
  1475. $verifyList [$k] ['opinion'] = "";
  1476. $verifyList [$k] ['status'] = "";
  1477. if (empty ( $verifyStaff )) {
  1478. $verifyList [$k] ['date'] = "";
  1479. $verifyList [$k] ['opinion'] = "";
  1480. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1481. $verifyList [$k] ['status'] = 4;
  1482. $flag = false;
  1483. }
  1484. } else {
  1485. foreach ( $verifyStaff as $m => $u ) {
  1486. if ($v [0] == $m) {
  1487. $verifyList [$k] ['date'] = $u ['date'];
  1488. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1489. $verifyList [$k] ['status'] = $u ['status'];
  1490. $flag = false;
  1491. break;
  1492. }
  1493. }
  1494. $endStaffArray = end ( $verifyStaff );
  1495. if (isset ( $endStaffArray ['ROLE'] )) {
  1496. } else {
  1497. // $endKey=key($verifyStaff);
  1498. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1499. // $button=4;
  1500. // $verifyList[$k]['status']=4;
  1501. // }
  1502. }
  1503. }
  1504. }
  1505. $rolename ['name'] = '';
  1506. if (! empty ( $roleId )) {
  1507. Doo::loadModel ( 'role' );
  1508. $role = new role ();
  1509. $rolename = $role->getOne ( array (
  1510. 'where' => 'rid=' . $roleId,
  1511. 'asArray' => true
  1512. ) );
  1513. }
  1514. if (! empty ( $verifyStaff ))
  1515. $endStaffArray = end ( $verifyStaff );
  1516. $KOP = false;
  1517. foreach ( $roleArrayCopy as $P => $A ) {
  1518. foreach ( $A as $MKI => $AVL ) {
  1519. if (! empty ( $verifyStaff )) {
  1520. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1521. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1522. $button = 4;
  1523. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1524. }
  1525. foreach ( $verifyStaff as $m => $u ) {
  1526. $AVLFK = $AVL [0] . '_R';
  1527. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1528. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1529. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1530. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1531. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1532. break;
  1533. }
  1534. }
  1535. } else {
  1536. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1537. $button = 4;
  1538. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1539. }
  1540. }
  1541. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1542. $KOP = true;
  1543. }
  1544. }
  1545. foreach ( $roleArrayCopy as $k => $v ) {
  1546. foreach ( $verifyList as $m => $n ) {
  1547. if ($n [0] == $k) {
  1548. array_splice ( $verifyList, $m, 1, $v );
  1549. }
  1550. }
  1551. }
  1552. $receiptList [$key] ['verifyList'] = $verifyList;
  1553. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1554. 'where' => 'sid=' . $value ['staff'],
  1555. 'asArray' => true
  1556. ) );
  1557. $receiptList [$key] ['button'] = $button;
  1558. //
  1559. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1560. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1561. }
  1562. $data ['receiptList'] = $receiptList;
  1563. $acItem = $accountItem->find ( array (
  1564. 'asArray' => true
  1565. ) );
  1566. $veList = $verify->find ( array (
  1567. 'asArray' => true
  1568. ) );
  1569. foreach ( $veList as $key => $value ) {
  1570. $v = json_decode ( $value ['staff'] );
  1571. $list = array ();
  1572. foreach ( $v as $n => $m ) {
  1573. if ($m ['1'] == 'ROLE') {
  1574. $roleInfo = $role->getOne ( array (
  1575. 'where' => 'rid=' . $m [0],
  1576. 'asArray' => true
  1577. ) );
  1578. $v [$n] [1] = $roleInfo ['name'];
  1579. array_push ( $list, $roleInfo ['name'] );
  1580. } else {
  1581. array_push ( $list, $v [$n] [1] );
  1582. }
  1583. }
  1584. $veList [$key] ['staff'] = implode ( '>', $list );
  1585. }
  1586. // 配置编辑信息
  1587. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1588. foreach ( $acItem as $key => $value ) {
  1589. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1590. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1591. $acItem [$key] ['price'] = $v ['price'];
  1592. }
  1593. }
  1594. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1595. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1596. $acItem [$key] ['price'] = $v ['price'];
  1597. }
  1598. }
  1599. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1600. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1601. $acItem [$key] ['price'] = $v ['price'];
  1602. }
  1603. }
  1604. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1605. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1606. $acItem [$key] ['price'] = $v ['price'];
  1607. }
  1608. }
  1609. }
  1610. $data ['category'] = $Lcategory->find ( array (
  1611. 'asArray' => true
  1612. ) );
  1613. $data ['cSum'] = $accountItemList ['cSum'];
  1614. $data ['sum'] = $receiptDetail ['sum'];
  1615. $data ['receiptDetail'] = $receiptDetail;
  1616. $data ['veList'] = $veList;
  1617. $data ['acItem'] = $acItem;
  1618. $data ['memu'] = "receipt";
  1619. $data ['staff'] = $this->staff;
  1620. $data ['receiptMemu'] = 'saeaBorad';
  1621. $data ['verify'] = $receiptDetail ['verify'];
  1622. $data ['verifyId'] = $this->verifyId;
  1623. $data ['executeId'] = $this->executeId;
  1624. $data ['rid'] = $rid;
  1625. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  1626. }
  1627. function confirmation() {
  1628. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1629. Doo::loadModel ( 'receipt' );
  1630. Doo::loadModel ( 'receiptDetail' );
  1631. $receipt = new receipt ();
  1632. $receiptDetail = new receiptDetail ();
  1633. Doo::loadModel ( 'statistics' );
  1634. Doo::loadModel ( 'itemStatistics' );
  1635. $statistics = new statistics ();
  1636. $itemStatistics = new itemStatistics ();
  1637. Doo::loadModel ( "verify" );
  1638. $verify = new verify ();
  1639. $receiptDetailList = $receipt->getOne ( array (
  1640. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  1641. 'asArray' => true
  1642. ) );
  1643. if (empty ( $receiptDetailList ))
  1644. return "/saeaBorad";
  1645. $verifyDetail = $verify->getOne ( array (
  1646. 'where' => ' vid =' . $receiptDetailList ['verify'],
  1647. 'asArray' => true
  1648. ) );
  1649. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  1650. if (empty ( $receiptDetailList ['nowStaff'] )) {
  1651. $nowStaff = "";
  1652. $nowStaffList = array ();
  1653. if ($verifyDetail [0] [1] == 'ROLE') {
  1654. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  1655. foreach ( $vStaffString as $key => $value ) {
  1656. $staffK = explode ( "_", $value );
  1657. array_push ( $nowStaffList, $staffK [0] );
  1658. }
  1659. $nowStaff = implode ( ',', $nowStaffList );
  1660. } else {
  1661. $nowStaff = $verifyDetail [0] [0];
  1662. }
  1663. $receipt->nowStaff = $nowStaff;
  1664. }
  1665. // echo $nowStaff;
  1666. // print_r($verifyDetail);die;
  1667. $receipt->rid = $receiptDetailList ['rid'];
  1668. $receipt->status = 2;
  1669. $receipt->update ();
  1670. // 操作日志
  1671. Doo::loadModel ( "receiptLog" );
  1672. $receiptLog = new receiptLog ();
  1673. $verify = new verify ();
  1674. $receiptInfo = $receipt->getOne ( array (
  1675. 'where' => 'rid=' . $rid,
  1676. 'asArray' => true
  1677. ) );
  1678. $vr = $verify->getOne ( array (
  1679. 'where' => 'vid=' . $receiptInfo ['verify'],
  1680. 'asArray' => true
  1681. ) );
  1682. $jd = json_decode ( $vr ['staff'] );
  1683. $roleId = 0;
  1684. foreach ( $jd as $key => $value ) {
  1685. if ($value [1] == 'ROLE') {
  1686. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  1687. if ($pos !== false) {
  1688. $roleId = $value [0];
  1689. }
  1690. }
  1691. }
  1692. // 审批日志
  1693. // echo $roleId;die;
  1694. if (! empty ( $roleId )) {
  1695. Doo::loadModel ( "role" );
  1696. $role = new role ();
  1697. $roleInfo = $role->getOne ( array (
  1698. 'where' => 'rid=' . $roleId,
  1699. 'asArray' => true
  1700. ) );
  1701. $receiptLog->rolename = $roleInfo ['name'];
  1702. }
  1703. $receiptLog->username = $this->staff [0] ['username'];
  1704. $receiptLog->uid = $this->staff [0] ['sid'];
  1705. $receiptLog->date = date ( "Y-m-d" );
  1706. $receiptLog->opinion = '提交审批';
  1707. $receiptLog->img = $this->staff [0] ['avatar'];
  1708. $receiptLog->status = 2;
  1709. $receiptLog->rid = $rid;
  1710. $receiptLog->insert ();
  1711. return "/expenses";
  1712. }
  1713. function expenses() {
  1714. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  1715. if (empty ( $item ))
  1716. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  1717. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1718. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  1719. Doo::loadModel ( 'receipt' );
  1720. $receipt = new receipt ();
  1721. Doo::loadModel ( 'L_category' );
  1722. $Lcategory = new L_category ();
  1723. Doo::loadModel ( 'verify' );
  1724. Doo::loadModel ( 'statistics' );
  1725. $statistics = new statistics ();
  1726. $verify = new verify ();
  1727. Doo::loadModel ( 'staff' );
  1728. $staff = new staff ();
  1729. $condition = "";
  1730. if ($item == "expenses")
  1731. $condition = " and Rtype=1 ";
  1732. elseif ($item == "receipts")
  1733. $condition = " and Rtype=0 ";
  1734. elseif ($item == "remits")
  1735. $condition = " and Rtype=2 ";
  1736. $dateCondition = " and Year(date) =" . $year;
  1737. if (! empty ( $moth )) {
  1738. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  1739. $stList = $statistics->getOne ( array (
  1740. 'select' => 'rePrice ,agPrice',
  1741. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  1742. 'asArray' => true
  1743. ) );
  1744. } else
  1745. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  1746. if (empty ( $stList ))
  1747. $stList = array (
  1748. 'rePrice' => 0,
  1749. 'agPrice' => 0
  1750. );
  1751. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  1752. if (! isset ( $noPassSum ['sum'] ))
  1753. $noPassSum ['sum'] = 0;
  1754. $data ['stList'] = array (
  1755. 'rePrice' => $stList ['rePrice'],
  1756. 'agPrice' => $stList ['agPrice'],
  1757. 'skPrice' => ($noPassSum ['sum'])
  1758. );
  1759. $receiptList = $receipt->find ( array (
  1760. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  1761. 'desc' => 'rid',
  1762. 'asArray' => true
  1763. ) );
  1764. $Locate = 0;
  1765. $roleId = 0;
  1766. $button = 0;
  1767. foreach ( $receiptList as $key => $value ) {
  1768. $receiptList [$key] ['Locate'] = $Locate;
  1769. $Locate ++;
  1770. $receiptList [$key] ['reviseDetail'] = array ();
  1771. if (! empty ( $value ['reviseDetail'] ))
  1772. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1773. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1774. $categoryDetil = $Lcategory->getOne ( array (
  1775. 'where' => 'cid=' . $value ['cid'],
  1776. 'asArray' => true
  1777. ) );
  1778. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1779. // 检测编辑状态
  1780. $verifyList = $verify->getOne ( array (
  1781. 'where' => 'vid=' . $value ['verify'],
  1782. 'asArray' => true
  1783. ) );
  1784. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1785. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1786. Doo::loadModel ( 'role' );
  1787. $role = new role ();
  1788. $flag = true;
  1789. $roleKey = 0;
  1790. $endStaffArray = array ();
  1791. $roleArrayCopy = array ();
  1792. foreach ( $verifyList as $k => $v ) {
  1793. // init verifyStaff
  1794. if ($v [1] == 'ROLE') {
  1795. if (! empty ( $verifyStaff )) {
  1796. $endStaffArray = end ( $verifyStaff );
  1797. // if ($v[0]==$endStaffArray['nextStaff']){
  1798. // $roleId=$v[0];
  1799. // }
  1800. }
  1801. $roleVerify = json_decode ( $v [3], true );
  1802. $roleKey = $k;
  1803. $roleArray = array ();
  1804. $rolename = $role->getOne ( array (
  1805. 'where' => 'rid=' . $v [0],
  1806. 'asArray' => true
  1807. ) );
  1808. foreach ( $roleVerify as $o => $p ) {
  1809. $staffID = explode ( '_', $p );
  1810. $staffInfo = $staff->getOne ( array (
  1811. 'where' => 'sid=' . $staffID [0],
  1812. 'asArray' => true
  1813. ) );
  1814. // print_r($staffID);
  1815. $exp = array (
  1816. 0 => $staffInfo ['sid'],
  1817. 1 => $staffID [1],
  1818. 2 => $staffInfo ['avatar'],
  1819. 'date' => '',
  1820. 'date' => '',
  1821. 'opinion' => '',
  1822. 'status' => '',
  1823. 'rolename' => $rolename ['name']
  1824. );
  1825. array_push ( $roleArray, $exp );
  1826. }
  1827. $roleArrayCopy [$v [0]] = $roleArray;
  1828. // $verifyList[$k]['roleArray']=$roleArray;
  1829. }
  1830. $verifyList [$k] ['date'] = "";
  1831. $verifyList [$k] ['opinion'] = "";
  1832. $verifyList [$k] ['status'] = "";
  1833. if (empty ( $verifyStaff )) {
  1834. $verifyList [$k] ['date'] = "";
  1835. $verifyList [$k] ['opinion'] = "";
  1836. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1837. $verifyList [$k] ['status'] = 4;
  1838. $flag = false;
  1839. }
  1840. } else {
  1841. foreach ( $verifyStaff as $m => $u ) {
  1842. if ($v [0] == $m) {
  1843. $verifyList [$k] ['date'] = $u ['date'];
  1844. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1845. $verifyList [$k] ['status'] = $u ['status'];
  1846. $flag = false;
  1847. break;
  1848. }
  1849. }
  1850. $endStaffArray = end ( $verifyStaff );
  1851. if (isset ( $endStaffArray ['ROLE'] )) {
  1852. } else {
  1853. // $endKey=key($verifyStaff);
  1854. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1855. // $button=4;
  1856. // $verifyList[$k]['status']=4;
  1857. // }
  1858. }
  1859. }
  1860. }
  1861. $rolename ['name'] = '';
  1862. if (! empty ( $roleId )) {
  1863. Doo::loadModel ( 'role' );
  1864. $role = new role ();
  1865. $rolename = $role->getOne ( array (
  1866. 'where' => 'rid=' . $roleId,
  1867. 'asArray' => true
  1868. ) );
  1869. }
  1870. if (! empty ( $verifyStaff ))
  1871. $endStaffArray = end ( $verifyStaff );
  1872. $KOP = false;
  1873. foreach ( $roleArrayCopy as $P => $A ) {
  1874. foreach ( $A as $MKI => $AVL ) {
  1875. if (! empty ( $verifyStaff )) {
  1876. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1877. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1878. $button = 4;
  1879. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1880. }
  1881. foreach ( $verifyStaff as $m => $u ) {
  1882. $AVLFK = $AVL [0] . '_R';
  1883. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1884. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1885. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1886. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1887. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1888. break;
  1889. }
  1890. }
  1891. } else {
  1892. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1893. $button = 4;
  1894. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1895. }
  1896. }
  1897. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1898. $KOP = true;
  1899. }
  1900. }
  1901. foreach ( $roleArrayCopy as $k => $v ) {
  1902. foreach ( $verifyList as $m => $n ) {
  1903. if ($n [0] == $k) {
  1904. array_splice ( $verifyList, $m, 1, $v );
  1905. }
  1906. }
  1907. }
  1908. $receiptList [$key] ['verifyList'] = $verifyList;
  1909. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1910. 'where' => 'sid=' . $value ['staff'],
  1911. 'asArray' => true
  1912. ) );
  1913. $receiptList [$key] ['button'] = $button;
  1914. }
  1915. // print_r($receiptList);die;
  1916. $mothHtml = "";
  1917. for($i = 1; $i <= 12; $i ++) {
  1918. if ($moth == $i)
  1919. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  1920. else
  1921. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  1922. }
  1923. $data ['mothHtml'] = $mothHtml;
  1924. $data ['receiptList'] = $receiptList;
  1925. $data ['memu'] = "receipt";
  1926. $data ['staff'] = $this->staff;
  1927. $data ['receiptMemu'] = 'expenses';
  1928. $data ['verifyId'] = $this->verifyId;
  1929. $data ['executeId'] = $this->executeId;
  1930. $data ['item'] = $item;
  1931. $data ['year'] = $year;
  1932. $this->render ( "/admin/expenses", $data );
  1933. }
  1934. function expensesCollect() {
  1935. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1936. Doo::loadModel ( 'receipt' );
  1937. $receipt = new receipt ();
  1938. Doo::loadModel ( 'L_category' );
  1939. $Lcategory = new L_category ();
  1940. Doo::loadModel ( 'verify' );
  1941. Doo::loadModel ( 'statistics' );
  1942. $statistics = new statistics ();
  1943. $verify = new verify ();
  1944. Doo::loadModel ( 'staff' );
  1945. $staff = new staff ();
  1946. Doo::loadModel ( 'loanReceipt' );
  1947. $loanReceipt = new loanReceipt ();
  1948. $receiptList = $receipt->find ( array (
  1949. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  1950. 'desc' => 'rid',
  1951. 'asArray' => true
  1952. ) );
  1953. $loanList = $loanReceipt->find ( array (
  1954. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  1955. 'desc' => 'rid',
  1956. 'asArray' => true
  1957. ) );
  1958. /*
  1959. * $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;
  1960. */
  1961. $Locate = 0;
  1962. $roleId = 0;
  1963. $button = 0;
  1964. foreach ( $receiptList as $key => $value ) {
  1965. $receiptList [$key] ['Locate'] = $Locate;
  1966. $Locate ++;
  1967. $receiptList [$key] ['reviseDetail'] = array ();
  1968. if (! empty ( $value ['reviseDetail'] ))
  1969. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1970. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1971. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1972. $categoryDetil = $Lcategory->getOne ( array (
  1973. 'where' => 'cid=' . $value ['cid'],
  1974. 'asArray' => true
  1975. ) );
  1976. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1977. // 检测编辑状态
  1978. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  1979. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  1980. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  1981. else
  1982. $verifyList ['staff'] = $value ['verifyBreakup'];
  1983. } else
  1984. $verifyList = $verify->getOne ( array (
  1985. 'where' => 'vid=' . $value ['verify'],
  1986. 'asArray' => true
  1987. ) );
  1988. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1989. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1990. Doo::loadModel ( 'role' );
  1991. $role = new role ();
  1992. $flag = true;
  1993. $roleKey = 0;
  1994. $endStaffArray = array ();
  1995. $roleArrayCopy = array ();
  1996. foreach ( $verifyList as $k => $v ) {
  1997. // init verifyStaff
  1998. if ($v [1] == 'ROLE') {
  1999. if (! empty ( $verifyStaff )) {
  2000. $endStaffArray = end ( $verifyStaff );
  2001. // if ($v[0]==$endStaffArray['nextStaff']){
  2002. // $roleId=$v[0];
  2003. // }
  2004. }
  2005. $roleVerify = json_decode ( $v [3], true );
  2006. $roleKey = $k;
  2007. $roleArray = array ();
  2008. $rolename = $role->getOne ( array (
  2009. 'where' => 'rid=' . $v [0],
  2010. 'asArray' => true
  2011. ) );
  2012. foreach ( $roleVerify as $o => $p ) {
  2013. $staffID = explode ( '_', $p );
  2014. $staffInfo = $staff->getOne ( array (
  2015. 'where' => 'sid=' . $staffID [0],
  2016. 'asArray' => true
  2017. ) );
  2018. // print_r($staffID);
  2019. $exp = array (
  2020. 0 => $staffInfo ['sid'],
  2021. 1 => $staffID [1],
  2022. 2 => $staffInfo ['avatar'],
  2023. 'date' => '',
  2024. 'date' => '',
  2025. 'opinion' => '',
  2026. 'status' => '',
  2027. 'rolename' => $rolename ['name']
  2028. );
  2029. array_push ( $roleArray, $exp );
  2030. }
  2031. $roleArrayCopy [$v [0]] = $roleArray;
  2032. // $verifyList[$k]['roleArray']=$roleArray;
  2033. }
  2034. $verifyList [$k] ['date'] = "";
  2035. $verifyList [$k] ['opinion'] = "";
  2036. $verifyList [$k] ['status'] = "";
  2037. if (empty ( $verifyStaff )) {
  2038. $verifyList [$k] ['date'] = "";
  2039. $verifyList [$k] ['opinion'] = "";
  2040. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2041. $verifyList [$k] ['status'] = 4;
  2042. $flag = false;
  2043. }
  2044. } else {
  2045. foreach ( $verifyStaff as $m => $u ) {
  2046. if ($v [0] == $m) {
  2047. $verifyList [$k] ['date'] = $u ['date'];
  2048. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2049. $verifyList [$k] ['status'] = $u ['status'];
  2050. $flag = false;
  2051. break;
  2052. }
  2053. }
  2054. $endStaffArray = end ( $verifyStaff );
  2055. if (isset ( $endStaffArray ['ROLE'] )) {
  2056. } else {
  2057. // $endKey=key($verifyStaff);
  2058. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2059. // $button=4;
  2060. // $verifyList[$k]['status']=4;
  2061. // }
  2062. }
  2063. }
  2064. }
  2065. $rolename ['name'] = '';
  2066. if (! empty ( $roleId )) {
  2067. Doo::loadModel ( 'role' );
  2068. $role = new role ();
  2069. $rolename = $role->getOne ( array (
  2070. 'where' => 'rid=' . $roleId,
  2071. 'asArray' => true
  2072. ) );
  2073. }
  2074. if (! empty ( $verifyStaff ))
  2075. $endStaffArray = end ( $verifyStaff );
  2076. $KOP = false;
  2077. foreach ( $roleArrayCopy as $P => $A ) {
  2078. foreach ( $A as $MKI => $AVL ) {
  2079. if (! empty ( $verifyStaff )) {
  2080. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2081. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2082. $button = 4;
  2083. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2084. }
  2085. foreach ( $verifyStaff as $m => $u ) {
  2086. $AVLFK = $AVL [0] . '_R';
  2087. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2088. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2089. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2090. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2091. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2092. break;
  2093. }
  2094. }
  2095. } else {
  2096. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2097. $button = 4;
  2098. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2099. }
  2100. }
  2101. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2102. $KOP = true;
  2103. }
  2104. }
  2105. foreach ( $roleArrayCopy as $k => $v ) {
  2106. foreach ( $verifyList as $m => $n ) {
  2107. if ($n [0] == $k) {
  2108. array_splice ( $verifyList, $m, 1, $v );
  2109. }
  2110. }
  2111. }
  2112. // 费用执行人相关数据
  2113. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2114. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2115. foreach ( $executeCopy as $k => $v ) {
  2116. $executeCopy [$k] ['date'] = '';
  2117. $executeCopy [$k] ['opinion'] = '';
  2118. $executeCopy [$k] ['status'] = '';
  2119. if (! empty ( $executeStaff ))
  2120. foreach ( $executeStaff as $m => $u ) {
  2121. if ($v [0] == $m) {
  2122. $executeCopy [$k] ['date'] = $u ['date'];
  2123. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2124. $executeCopy [$k] ['status'] = $u ['status'];
  2125. break;
  2126. }
  2127. }
  2128. }
  2129. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2130. $receiptList [$key] ['verifyList'] = $verifyList;
  2131. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2132. 'where' => 'sid=' . $value ['staff'],
  2133. 'asArray' => true
  2134. ) );
  2135. $receiptList [$key] ['button'] = $button;
  2136. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2137. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2138. $relust = $value ['sum'] - $value ['loanSum'];
  2139. $receiptList [$key] ['relust'] = $relust;
  2140. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2141. }
  2142. Doo::loadModel ( 'enclosur' );
  2143. $enclosur = new enclosur ();
  2144. $enclosurList = $enclosur->find ( array (
  2145. 'where' => 'rid=' . $rid,
  2146. 'asArray' => true
  2147. ) );
  2148. $enclosurHtml = '';
  2149. foreach ( $enclosurList as $value ) {
  2150. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2151. }
  2152. $data ['enclosurHtml'] = $enclosurHtml;
  2153. // print_r($receiptList);
  2154. $data ['receiptList'] = $receiptList;
  2155. $data ['memu'] = "receipt";
  2156. $data ['staff'] = $this->staff;
  2157. $data ['receiptMemu'] = 'expenses';
  2158. $data ['verifyId'] = $this->verifyId;
  2159. $data ['executeId'] = $this->executeId;
  2160. $this->render ( "/admin/expensesCollect", $data );
  2161. }
  2162. function approvalExpenses() {
  2163. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  2164. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2165. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2166. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2167. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2168. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  2169. //echo $rdate;
  2170. if (empty ( $status ))
  2171. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  2172. $page_size = 12;
  2173. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2174. $vidList = array ();
  2175. $button = 0;
  2176. Doo::loadModel ( 'verify' );
  2177. $verify = new verify ();
  2178. Doo::loadModel ( 'receipt' );
  2179. $receipt = new receipt ();
  2180. Doo::loadModel ( 'staff' );
  2181. $staff = new staff ();
  2182. Doo::loadModel ( 'L_category' );
  2183. $Lcategory = new L_category ();
  2184. // user verify ID
  2185. $verifyDetail = $verify->find ( array (
  2186. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  2187. 'asArray' => true
  2188. ) );
  2189. foreach ( $verifyDetail as $key => $value ) {
  2190. array_push ( $vidList, $value ['vid'] );
  2191. }
  2192. $vid = implode ( ",", $vidList );
  2193. if (empty ( $verifyDetail ))
  2194. $vid = 0;
  2195. // if ($status==0)
  2196. // $dateCondition="";
  2197. // else
  2198. $dateCondition = " and Year(date) =" . $year;
  2199. /*
  2200. if (! empty ( $month ))
  2201. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  2202. if($status == 'done'){
  2203. $dateCondition = " and Year(pastDate) =" . $year;
  2204. if (! empty ( $month ))
  2205. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  2206. }
  2207. */
  2208. //date ( 'Y-m' )
  2209. if(!empty($rdate)&&$status == 'done')
  2210. $dateCondition=" and date_format(pastDate,'%Y-%m')='".$rdate."' ";
  2211. elseif (!empty($rdate))
  2212. $dateCondition=" and date_format(date,'%Y-%m')='".$rdate."' ";
  2213. $categoryList = $Lcategory->find ( array (
  2214. 'asArray' => true
  2215. ) );
  2216. $staffList = $staff->find ( array (
  2217. 'where' => 'cid=' . $cid,
  2218. 'asArray' => true
  2219. ) );
  2220. $cateCondition = "";
  2221. $staffCondition = "";
  2222. $approvalCondition = "";
  2223. if (! empty ( $cid )){
  2224. $cateCondition = ' and cid=' . $cid;
  2225. }
  2226. if (! empty ( $sid )) {
  2227. $staffCondition = ' and cid=' . $cid.' and staff=' . $sid;
  2228. $cateCondition = "";
  2229. }
  2230. $get="?year=".$year."&month=".$month."&cid=".$cid."&sid=".$sid;
  2231. if ($status == 'pendApproval') {
  2232. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  2233. }
  2234. if ($status == 'ongoing') {
  2235. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  2236. }
  2237. if ($status == 'done') {
  2238. $approvalCondition = ' and (status=8 or status=9 ) ';
  2239. }
  2240. if ($status == 'termination') {
  2241. $approvalCondition = " and status=3";
  2242. }
  2243. // $approvalCondition = " and status=" . $status;
  2244. // if ($status == 2) {
  2245. // // 查找角色审批人
  2246. // }
  2247. // if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  2248. // $approvalCondition = ' and status=2 ';
  2249. // }
  2250. // if ($status == 1) {
  2251. // $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  2252. // }
  2253. // if ($status == 8) {
  2254. // $approvalCondition = ' and (status=' . $status . ' or status=9 ) ';
  2255. // }
  2256. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  2257. $pageinfo ['page'] = array (
  2258. 'previous' => ''
  2259. );
  2260. // if ($status == 0) {
  2261. // $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  2262. // $receiptList = $receipt->find ( array (
  2263. // 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ')',
  2264. // 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2265. // 'desc' => 'rid',
  2266. // 'asArray' => true
  2267. // ) );
  2268. // //echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2269. // } else
  2270. if ($status == 'done' || $status == 'termination') {
  2271. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/".$status, $get, "" );
  2272. $receiptList = $receipt->find ( array (
  2273. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
  2274. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2275. 'desc' => 'rid',
  2276. 'asArray' => true
  2277. ) );
  2278. } else
  2279. $receiptList = $receipt->find ( array (
  2280. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
  2281. 'desc' => 'rid',
  2282. 'asArray' => true
  2283. ) );
  2284. $rLRes = $receipt->find ( array (
  2285. '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,
  2286. 'desc' => 'rid',
  2287. 'asArray' => true
  2288. ) );
  2289. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2290. // print_r($pageinfo);
  2291. $Locate = 0;
  2292. $reportList=$reportCateList=array();
  2293. foreach ( $receiptList as $key => $value ) {
  2294. $receiptList [$key] ['Locate'] = $Locate;
  2295. $Locate ++;
  2296. $receiptList [$key] ['reviseDetail'] = array ();
  2297. if (! empty ( $value ['reviseDetail'] ))
  2298. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2299. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2300. $categoryDetil = $Lcategory->getOne ( array (
  2301. 'where' => 'cid=' . $value ['cid'],
  2302. 'asArray' => true
  2303. ) );
  2304. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2305. $verifyList = $verify->getOne ( array (
  2306. 'where' => 'vid=' . $value ['verify'],
  2307. 'asArray' => true
  2308. ) );
  2309. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2310. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2311. foreach ( $verifyList as $k => $v ) {
  2312. // init verifyStaff
  2313. $verifyList [$k] ['date'] = "";
  2314. $verifyList [$k] ['opinion'] = "";
  2315. $verifyList [$k] ['status'] = "";
  2316. if (empty ( $verifyStaff )) {
  2317. $verifyList [$k] ['date'] = "";
  2318. $verifyList [$k] ['opinion'] = "";
  2319. if ($v [0] == $this->staff [0] ['sid']) {
  2320. $verifyList [$k] ['status'] = 4;
  2321. $button = 4;
  2322. }
  2323. } else {
  2324. $flag = true;
  2325. foreach ( $verifyStaff as $m => $u ) {
  2326. if ($v [0] == $m) {
  2327. $verifyList [$k] ['date'] = $u ['date'];
  2328. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2329. $verifyList [$k] ['status'] = $u ['status'];
  2330. $flag = false;
  2331. break;
  2332. }
  2333. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  2334. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  2335. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  2336. }
  2337. if ($flag) { // 检测可编辑
  2338. if ($v [0] == $this->staff [0] ['sid']) {
  2339. $verifyList [$k] ['status'] = 4;
  2340. $button = 4;
  2341. }
  2342. }
  2343. }
  2344. }
  2345. $receiptList [$key] ['verifyList'] = $verifyList;
  2346. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2347. 'where' => 'sid=' . $value ['staff'],
  2348. 'asArray' => true
  2349. ) );
  2350. array_push($reportList, $receiptList [$key] ['staffDetail']['sid'].'-'.$receiptList [$key] ['staffDetail']['username'].'-'.$receiptList [$key] ['staffDetail']['category']);
  2351. array_push($reportCateList, $receiptList [$key] ['staffDetail']['cid'].'-'.$receiptList [$key] ['staffDetail']['category']);
  2352. $receiptList [$key] ['button'] = $button;
  2353. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  2354. }
  2355. $reportList=array_unique($reportList);
  2356. $reportHtml='';
  2357. foreach ($reportList as $key=>$value){
  2358. $v=explode("-", $value);
  2359. $reportHtml.='<option node-all=\'true\' node-cate=\''.$v[2].'\' value="'.$v[1].'">'.$v[1].'</option>';
  2360. }
  2361. //print_r($reportList)
  2362. $data['reportHtml']=$reportHtml;
  2363. $reportCateList=array_unique($reportCateList);
  2364. $reportCateHtml='';
  2365. foreach ($reportCateList as $key=>$value){
  2366. $v=explode("-", $value);
  2367. $reportCateHtml.='<option value="'.$v[1].'">'.$v[1].'</option>';
  2368. }
  2369. //$reportHtml.='<option value="ALL">'.$value[''].'</option>';
  2370. $data['reportCateHtml']=$reportCateHtml;
  2371. // print_r($receiptList);die;
  2372. // $data['verifyDetail']=$verifyDetail;
  2373. $mothHtml = "";
  2374. for($i = 1; $i <= 12; $i ++) {
  2375. if ($month == $i)
  2376. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2377. else
  2378. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2379. }
  2380. $data ['mothHtml'] = $mothHtml;
  2381. $data ['page'] = $pageinfo;
  2382. $data ['receiptList'] = $receiptList;
  2383. $data ['receiptApprovalCount'] = count ( $rLRes );
  2384. $data ['status'] = $status;
  2385. $data ['year'] = $year;
  2386. $data ['categoryList'] = $categoryList;
  2387. $data ['staffList'] = $staffList;
  2388. $data ['cid'] = $cid;
  2389. $data ['sid'] = $sid;
  2390. // print_r($receiptList);
  2391. $data ['memu'] = "receipt";
  2392. $data ['staff'] = $this->staff;
  2393. $data ['receiptMemu'] = 'approvalExpenses';
  2394. $data ['verifyId'] = $this->verifyId;
  2395. $data ['executeId'] = $this->executeId;
  2396. $this->render ( "/admin/approvalExpenses", $data );
  2397. }
  2398. function expensesDoc() {
  2399. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2400. Doo::loadModel ( 'receipt' );
  2401. $receipt = new receipt ();
  2402. Doo::loadModel ( 'L_category' );
  2403. $Lcategory = new L_category ();
  2404. Doo::loadModel ( 'verify' );
  2405. Doo::loadModel ( 'statistics' );
  2406. $statistics = new statistics ();
  2407. $verify = new verify ();
  2408. Doo::loadModel ( 'staff' );
  2409. $staff = new staff ();
  2410. Doo::loadModel ( 'loanReceipt' );
  2411. $loanReceipt = new loanReceipt ();
  2412. $receiptList = $receipt->find ( array (
  2413. 'where' => ' rid=' . $rid,
  2414. 'desc' => 'rid',
  2415. 'asArray' => true
  2416. ) );
  2417. $loanList = array ();
  2418. if (! empty ( $receiptList ))
  2419. $loanList = $loanReceipt->find ( array (
  2420. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2421. 'desc' => 'rid',
  2422. 'asArray' => true
  2423. ) );
  2424. $Locate = 0;
  2425. $roleId = 0;
  2426. $button = 0;
  2427. foreach ( $loanList as $key => $value ) {
  2428. $loanList [$key] ['Locate'] = $Locate;
  2429. $Locate ++;
  2430. $loanList [$key] ['reviseDetail'] = array ();
  2431. if (! empty ( $value ['reviseDetail'] ))
  2432. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2433. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2434. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2435. $categoryDetil = $Lcategory->getOne ( array (
  2436. 'where' => 'cid=' . $value ['cid'],
  2437. 'asArray' => true
  2438. ) );
  2439. $loanList [$key] ['category'] = $categoryDetil ['title'];
  2440. // 检测编辑状态
  2441. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  2442. $verifyList ['staff'] = $value ['verifyBreakup'];
  2443. else
  2444. $verifyList = $verify->getOne ( array (
  2445. 'where' => 'vid=' . $value ['verify'],
  2446. 'asArray' => true
  2447. ) );
  2448. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2449. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2450. Doo::loadModel ( 'role' );
  2451. $role = new role ();
  2452. $flag = true;
  2453. $roleKey = 0;
  2454. $endStaffArray = array ();
  2455. $roleArrayCopy = array ();
  2456. foreach ( $verifyList as $k => $v ) {
  2457. // init verifyStaff
  2458. if ($v [1] == 'ROLE') {
  2459. if (! empty ( $verifyStaff )) {
  2460. $endStaffArray = end ( $verifyStaff );
  2461. // if ($v[0]==$endStaffArray['nextStaff']){
  2462. // $roleId=$v[0];
  2463. // }
  2464. }
  2465. $roleVerify = json_decode ( $v [3], true );
  2466. $roleKey = $k;
  2467. $roleArray = array ();
  2468. $rolename = $role->getOne ( array (
  2469. 'where' => 'rid=' . $v [0],
  2470. 'asArray' => true
  2471. ) );
  2472. foreach ( $roleVerify as $o => $p ) {
  2473. $staffID = explode ( '_', $p );
  2474. $staffInfo = $staff->getOne ( array (
  2475. 'where' => 'sid=' . $staffID [0],
  2476. 'asArray' => true
  2477. ) );
  2478. // print_r($staffID);
  2479. $exp = array (
  2480. 0 => $staffInfo ['sid'],
  2481. 1 => $staffID [1],
  2482. 2 => $staffInfo ['avatar'],
  2483. 'date' => '',
  2484. 'date' => '',
  2485. 'opinion' => '',
  2486. 'status' => '',
  2487. 'rolename' => $rolename ['name']
  2488. );
  2489. array_push ( $roleArray, $exp );
  2490. }
  2491. $roleArrayCopy [$v [0]] = $roleArray;
  2492. // $verifyList[$k]['roleArray']=$roleArray;
  2493. }
  2494. $verifyList [$k] ['date'] = "";
  2495. $verifyList [$k] ['opinion'] = "";
  2496. $verifyList [$k] ['status'] = "";
  2497. if (empty ( $verifyStaff )) {
  2498. $verifyList [$k] ['date'] = "";
  2499. $verifyList [$k] ['opinion'] = "";
  2500. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2501. $verifyList [$k] ['status'] = 4;
  2502. $flag = false;
  2503. }
  2504. } else {
  2505. foreach ( $verifyStaff as $m => $u ) {
  2506. if ($v [0] == $m) {
  2507. $verifyList [$k] ['date'] = $u ['date'];
  2508. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2509. $verifyList [$k] ['status'] = $u ['status'];
  2510. $flag = false;
  2511. break;
  2512. }
  2513. }
  2514. $endStaffArray = end ( $verifyStaff );
  2515. if (isset ( $endStaffArray ['ROLE'] )) {
  2516. } else {
  2517. // $endKey=key($verifyStaff);
  2518. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2519. // $button=4;
  2520. // $verifyList[$k]['status']=4;
  2521. // }
  2522. }
  2523. }
  2524. }
  2525. $rolename ['name'] = '';
  2526. if (! empty ( $roleId )) {
  2527. Doo::loadModel ( 'role' );
  2528. $role = new role ();
  2529. $rolename = $role->getOne ( array (
  2530. 'where' => 'rid=' . $roleId,
  2531. 'asArray' => true
  2532. ) );
  2533. }
  2534. if (! empty ( $verifyStaff ))
  2535. $endStaffArray = end ( $verifyStaff );
  2536. $KOP = false;
  2537. foreach ( $roleArrayCopy as $P => $A ) {
  2538. foreach ( $A as $MKI => $AVL ) {
  2539. if (! empty ( $verifyStaff )) {
  2540. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2541. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2542. $button = 4;
  2543. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2544. }
  2545. foreach ( $verifyStaff as $m => $u ) {
  2546. $AVLFK = $AVL [0] . '_R';
  2547. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2548. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2549. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2550. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2551. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2552. break;
  2553. }
  2554. }
  2555. } else {
  2556. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2557. $button = 4;
  2558. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2559. }
  2560. }
  2561. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2562. $KOP = true;
  2563. }
  2564. }
  2565. foreach ( $roleArrayCopy as $k => $v ) {
  2566. foreach ( $verifyList as $m => $n ) {
  2567. if ($n [0] == $k) {
  2568. array_splice ( $verifyList, $m, 1, $v );
  2569. }
  2570. }
  2571. }
  2572. $loanList [$key] ['verifyList'] = $verifyList;
  2573. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  2574. 'where' => 'sid=' . $value ['staff'],
  2575. 'asArray' => true
  2576. ) );
  2577. $loanList [$key] ['button'] = $button;
  2578. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  2579. }
  2580. $data ['loanList'] = $loanList;
  2581. // print_r($loanList);
  2582. $Locate = 0;
  2583. $roleId = 0;
  2584. $button = 0;
  2585. foreach ( $receiptList as $key => $value ) {
  2586. $receiptList [$key] ['Locate'] = $Locate;
  2587. $Locate ++;
  2588. $receiptList [$key] ['reviseDetail'] = array ();
  2589. if (! empty ( $value ['reviseDetail'] ))
  2590. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2591. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2592. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2593. $categoryDetil = $Lcategory->getOne ( array (
  2594. 'where' => 'cid=' . $value ['cid'],
  2595. 'asArray' => true
  2596. ) );
  2597. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2598. // 检测编辑状态
  2599. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  2600. $verifyList ['staff'] = $value ['verifyBreakup'];
  2601. } else
  2602. $verifyList = $verify->getOne ( array (
  2603. 'where' => 'vid=' . $value ['verify'],
  2604. 'asArray' => true
  2605. ) );
  2606. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2607. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2608. Doo::loadModel ( 'role' );
  2609. $role = new role ();
  2610. if ($verifyList == NULL)
  2611. $verifyList = array ();
  2612. $flag = true;
  2613. $roleKey = 0;
  2614. $endStaffArray = array ();
  2615. $roleArrayCopy = array ();
  2616. foreach ( $verifyList as $k => $v ) {
  2617. // init verifyStaff
  2618. if ($v [1] == 'ROLE') {
  2619. if (! empty ( $verifyStaff )) {
  2620. $endStaffArray = end ( $verifyStaff );
  2621. // if ($v[0]==$endStaffArray['nextStaff']){
  2622. // $roleId=$v[0];
  2623. // }
  2624. }
  2625. $roleVerify = json_decode ( $v [3], true );
  2626. $roleKey = $k;
  2627. $roleArray = array ();
  2628. $rolename = $role->getOne ( array (
  2629. 'where' => 'rid=' . $v [0],
  2630. 'asArray' => true
  2631. ) );
  2632. foreach ( $roleVerify as $o => $p ) {
  2633. $staffID = explode ( '_', $p );
  2634. $staffInfo = $staff->getOne ( array (
  2635. 'where' => 'sid=' . $staffID [0],
  2636. 'asArray' => true
  2637. ) );
  2638. // print_r($staffID);
  2639. $exp = array (
  2640. 0 => $staffInfo ['sid'],
  2641. 1 => $staffID [1],
  2642. 2 => $staffInfo ['avatar'],
  2643. 'date' => '',
  2644. 'date' => '',
  2645. 'opinion' => '',
  2646. 'status' => '',
  2647. 'rolename' => $rolename ['name']
  2648. );
  2649. array_push ( $roleArray, $exp );
  2650. }
  2651. $roleArrayCopy [$v [0]] = $roleArray;
  2652. // $verifyList[$k]['roleArray']=$roleArray;
  2653. }
  2654. $verifyList [$k] ['date'] = "";
  2655. $verifyList [$k] ['opinion'] = "";
  2656. $verifyList [$k] ['status'] = "";
  2657. if (empty ( $verifyStaff )) {
  2658. $verifyList [$k] ['date'] = "";
  2659. $verifyList [$k] ['opinion'] = "";
  2660. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2661. $verifyList [$k] ['status'] = 4;
  2662. $flag = false;
  2663. }
  2664. } else {
  2665. foreach ( $verifyStaff as $m => $u ) {
  2666. if ($v [0] == $m) {
  2667. $verifyList [$k] ['date'] = $u ['date'];
  2668. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2669. $verifyList [$k] ['status'] = $u ['status'];
  2670. $flag = false;
  2671. break;
  2672. }
  2673. }
  2674. $endStaffArray = end ( $verifyStaff );
  2675. if (isset ( $endStaffArray ['ROLE'] )) {
  2676. } else {
  2677. // $endKey=key($verifyStaff);
  2678. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2679. // $button=4;
  2680. // $verifyList[$k]['status']=4;
  2681. // }
  2682. }
  2683. }
  2684. }
  2685. $rolename ['name'] = '';
  2686. if (! empty ( $roleId )) {
  2687. Doo::loadModel ( 'role' );
  2688. $role = new role ();
  2689. $rolename = $role->getOne ( array (
  2690. 'where' => 'rid=' . $roleId,
  2691. 'asArray' => true
  2692. ) );
  2693. }
  2694. if (! empty ( $verifyStaff ))
  2695. $endStaffArray = end ( $verifyStaff );
  2696. $KOP = false;
  2697. foreach ( $roleArrayCopy as $P => $A ) {
  2698. foreach ( $A as $MKI => $AVL ) {
  2699. if (! empty ( $verifyStaff )) {
  2700. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2701. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2702. $button = 4;
  2703. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2704. }
  2705. foreach ( $verifyStaff as $m => $u ) {
  2706. $AVLFK = $AVL [0] . '_R';
  2707. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2708. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2709. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2710. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2711. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2712. break;
  2713. }
  2714. }
  2715. } else {
  2716. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2717. $button = 4;
  2718. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2719. }
  2720. }
  2721. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2722. $KOP = true;
  2723. }
  2724. }
  2725. foreach ( $roleArrayCopy as $k => $v ) {
  2726. foreach ( $verifyList as $m => $n ) {
  2727. if ($n [0] == $k) {
  2728. array_splice ( $verifyList, $m, 1, $v );
  2729. }
  2730. }
  2731. }
  2732. // 费用执行人相关数据
  2733. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2734. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2735. foreach ( $executeCopy as $k => $v ) {
  2736. $executeCopy [$k] ['date'] = '';
  2737. $executeCopy [$k] ['opinion'] = '';
  2738. $executeCopy [$k] ['status'] = '';
  2739. if (! empty ( $executeStaff ))
  2740. foreach ( $executeStaff as $m => $u ) {
  2741. if ($v [0] == $m) {
  2742. $executeCopy [$k] ['date'] = $u ['date'];
  2743. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2744. $executeCopy [$k] ['status'] = $u ['status'];
  2745. break;
  2746. }
  2747. }
  2748. }
  2749. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2750. $receiptList [$key] ['verifyList'] = $verifyList;
  2751. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2752. 'where' => 'sid=' . $value ['staff'],
  2753. 'asArray' => true
  2754. ) );
  2755. $receiptList [$key] ['button'] = $button;
  2756. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2757. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2758. $relust = $value ['sum'] - $value ['loanSum'];
  2759. $receiptList [$key] ['relust'] = $relust;
  2760. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2761. }
  2762. // print_r($receiptList);
  2763. // 获取审批日志
  2764. Doo::loadModel ( 'receiptLog' );
  2765. $receiptLog = new receiptLog ();
  2766. $rlList = array ();
  2767. $rlInfo = $receiptLog->getOne ( array (
  2768. 'where' => 'rid=' . $rid . ' and status=4',
  2769. 'asArray' => true
  2770. ) );
  2771. $tijdate = $receiptLog->getOne ( array (
  2772. 'where' => 'rid=' . $rid . ' and status=2',
  2773. 'asc' => 'rlid',
  2774. 'asArray' => true
  2775. ) );
  2776. if (! empty ( $rlInfo )) {
  2777. $rlList = $receiptLog->find ( array (
  2778. 'where' => 'rid=' . $rid,
  2779. 'asc' => 'rlid',
  2780. 'asArray' => true
  2781. ) );
  2782. }
  2783. Doo::loadModel ( 'enclosur' );
  2784. $enclosur = new enclosur ();
  2785. $enclosurList = $enclosur->find ( array (
  2786. 'where' => 'rid=' . $rid,
  2787. 'asArray' => true
  2788. ) );
  2789. $enclosurHtml = '';
  2790. foreach ( $enclosurList as $value ) {
  2791. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2792. }
  2793. $data ['enclosurHtml'] = $enclosurHtml;
  2794. $receiptList [0] ['rlList'] = $rlList;
  2795. $data ['receiptList'] = $receiptList;
  2796. $data ['memu'] = "receipt";
  2797. $data ['staff'] = $this->staff;
  2798. $data ['receiptMemu'] = 'approvalExpenses';
  2799. $data ['verifyId'] = $this->verifyId;
  2800. $data ['executeId'] = $this->executeId;
  2801. $this->render ( "/admin/expensesDoc", $data );
  2802. }
  2803. function expensesEdi() {
  2804. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2805. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  2806. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2807. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2808. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2809. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2810. if (empty ( $status ))
  2811. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  2812. $vidList = array ();
  2813. $button = 0;
  2814. Doo::loadModel ( 'verify' );
  2815. Doo::loadModel ( 'receipt' );
  2816. Doo::loadModel ( 'staff' );
  2817. $staff = new staff ();
  2818. $receipt = new receipt ();
  2819. $verify = new verify ();
  2820. Doo::loadModel ( 'L_category' );
  2821. $Lcategory = new L_category ();
  2822. Doo::loadModel ( 'enclosur' );
  2823. $enclosur = new enclosur ();
  2824. // user verify ID
  2825. $verifyDetail = $verify->find ( array (
  2826. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  2827. 'asArray' => true
  2828. ) );
  2829. foreach ( $verifyDetail as $key => $value ) {
  2830. array_push ( $vidList, $value ['vid'] );
  2831. }
  2832. $vid = implode ( ",", $vidList );
  2833. if (empty ( $verifyDetail ))
  2834. $vid = 0;
  2835. $categoryList = $Lcategory->find ( array (
  2836. 'asArray' => true
  2837. ) );
  2838. $staffList = $staff->find ( array (
  2839. 'where' => 'cid=' . $cid,
  2840. 'asArray' => true
  2841. ) );
  2842. $ap = "";
  2843. if ($status == 4) {
  2844. $ap = 4;
  2845. $status = 2;
  2846. }
  2847. // get Receipt By verifyID status 2
  2848. $receiptList = $receipt->find ( array (
  2849. 'where' => 'rid =' . $rid.' and status=2',
  2850. 'desc' => 'rid',
  2851. 'asArray' => true
  2852. ) );
  2853. if (empty($receiptList)){
  2854. die ( 'illegal request' );
  2855. }
  2856. $Locate = 0;
  2857. $roleId = 0;
  2858. if ($ap == 4)
  2859. $status = 4;
  2860. foreach ( $receiptList as $key => $value ) {
  2861. $receiptList [$key] ['Locate'] = $Locate;
  2862. $Locate ++;
  2863. $receiptList [$key] ['reviseDetail'] = array ();
  2864. if (! empty ( $value ['reviseDetail'] ))
  2865. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2866. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2867. $categoryDetil = $Lcategory->getOne ( array (
  2868. 'where' => 'cid=' . $value ['cid'],
  2869. 'asArray' => true
  2870. ) );
  2871. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2872. // 检测编辑状态
  2873. $verifyList = $verify->getOne ( array (
  2874. 'where' => 'vid=' . $value ['verify'],
  2875. 'asArray' => true
  2876. ) );
  2877. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2878. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2879. Doo::loadModel ( 'role' );
  2880. $role = new role ();
  2881. // print_r($verifyList);
  2882. $flag = true;
  2883. $roleKey = 0;
  2884. $endStaffArray = array ();
  2885. $roleArrayCopy = array ();
  2886. foreach ( $verifyList as $k => $v ) {
  2887. // init verifyStaff
  2888. if ($v [1] == 'ROLE') {
  2889. if (! empty ( $verifyStaff )) {
  2890. $endStaffArray = end ( $verifyStaff );
  2891. if ($v [0] == $endStaffArray ['nextStaff']) {
  2892. $roleId = $v [0];
  2893. }
  2894. }
  2895. $roleVerify = json_decode ( $v [3], true );
  2896. $roleKey = $k;
  2897. $roleArray = array ();
  2898. $rolename = $role->getOne ( array (
  2899. 'where' => 'rid=' . $v [0],
  2900. 'asArray' => true
  2901. ) );
  2902. foreach ( $roleVerify as $o => $p ) {
  2903. $staffID = explode ( '_', $p );
  2904. $staffInfo = $staff->getOne ( array (
  2905. 'where' => 'sid=' . $staffID [0],
  2906. 'asArray' => true
  2907. ) );
  2908. // print_r($staffID);
  2909. $exp = array (
  2910. 0 => $staffInfo ['sid'],
  2911. 1 => $staffID [1],
  2912. 2 => $staffInfo ['avatar'],
  2913. 'date' => '',
  2914. 'date' => '',
  2915. 'opinion' => '',
  2916. 'status' => '',
  2917. 'rolename' => $rolename ['name']
  2918. );
  2919. array_push ( $roleArray, $exp );
  2920. }
  2921. $roleArrayCopy [$v [0]] = $roleArray;
  2922. // $verifyList[$k]['roleArray']=$roleArray;
  2923. }
  2924. // print_r($roleArray);
  2925. $verifyList [$k] ['date'] = "";
  2926. $verifyList [$k] ['opinion'] = "";
  2927. $verifyList [$k] ['status'] = "";
  2928. if (empty ( $verifyStaff )) {
  2929. $verifyList [$k] ['date'] = "";
  2930. $verifyList [$k] ['opinion'] = "";
  2931. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2932. $verifyList [$k] ['status'] = 4;
  2933. $button = 4;
  2934. $flag = false;
  2935. }
  2936. } else {
  2937. foreach ( $verifyStaff as $m => $u ) {
  2938. if ($v [0] == $m) {
  2939. $verifyList [$k] ['date'] = $u ['date'];
  2940. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2941. $verifyList [$k] ['status'] = $u ['status'];
  2942. $flag = false;
  2943. break;
  2944. }
  2945. }
  2946. $endStaffArray = end ( $verifyStaff );
  2947. if (isset ( $endStaffArray ['ROLE'] )) {
  2948. } else {
  2949. $endKey = key ( $verifyStaff );
  2950. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  2951. $button = 4;
  2952. $verifyList [$k] ['status'] = 4;
  2953. }
  2954. }
  2955. }
  2956. }
  2957. $rolename ['name'] = '';
  2958. if (! empty ( $roleId )) {
  2959. Doo::loadModel ( 'role' );
  2960. $role = new role ();
  2961. $rolename = $role->getOne ( array (
  2962. 'where' => 'rid=' . $roleId,
  2963. 'asArray' => true
  2964. ) );
  2965. }
  2966. if (! empty ( $verifyStaff ))
  2967. $endStaffArray = end ( $verifyStaff );
  2968. $KOP = false;
  2969. foreach ( $roleArrayCopy as $P => $A ) {
  2970. foreach ( $A as $MKI => $AVL ) {
  2971. if (! empty ( $verifyStaff )) {
  2972. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2973. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2974. $button = 4;
  2975. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2976. }
  2977. foreach ( $verifyStaff as $m => $u ) {
  2978. $AVLFK = $AVL [0] . '_R';
  2979. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2980. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2981. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2982. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2983. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2984. break;
  2985. }
  2986. }
  2987. } else {
  2988. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2989. $button = 4;
  2990. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2991. }
  2992. }
  2993. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2994. $KOP = true;
  2995. }
  2996. }
  2997. // print_r($roleArrayCopy);
  2998. // echo $roleKey;
  2999. foreach ( $roleArrayCopy as $k => $v ) {
  3000. foreach ( $verifyList as $m => $n ) {
  3001. if ($n [0] == $k) {
  3002. array_splice ( $verifyList, $m, 1, $v );
  3003. }
  3004. }
  3005. }
  3006. $receiptList [$key] ['verifyList'] = $verifyList;
  3007. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3008. 'where' => 'sid=' . $value ['staff'],
  3009. 'asArray' => true
  3010. ) );
  3011. $receiptList [$key] ['button'] = $button;
  3012. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  3013. }
  3014. // $data['verifyDetail']=$verifyDetail;
  3015. $mothHtml = "";
  3016. for($i = 1; $i <= 12; $i ++) {
  3017. if ($month == $i)
  3018. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3019. else
  3020. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3021. }
  3022. // 获取审批日志
  3023. Doo::loadModel ( 'receiptLog' );
  3024. $receiptLog = new receiptLog ();
  3025. $rlList = array ();
  3026. $rlInfo = $receiptLog->getOne ( array (
  3027. 'where' => 'rid=' . $rid . ' and status=4',
  3028. 'asArray' => true
  3029. ) );
  3030. $tijdate = $receiptLog->getOne ( array (
  3031. 'where' => 'rid=' . $rid . ' and status=2',
  3032. 'asc' => 'rlid',
  3033. 'asArray' => true
  3034. ) );
  3035. if (! empty ( $rlInfo )) {
  3036. $rlList = $receiptLog->find ( array (
  3037. 'where' => 'rid=' . $rid,
  3038. 'asc' => 'rlid',
  3039. 'asArray' => true
  3040. ) );
  3041. }
  3042. $receiptList [0] ['rlList'] = $rlList;
  3043. $enclosurList = $enclosur->find ( array (
  3044. 'where' => 'rid=' . $rid,
  3045. 'asArray' => true
  3046. ) );
  3047. $enclosurHtml = '';
  3048. foreach ( $enclosurList as $value ) {
  3049. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3050. }
  3051. // print_r($receiptList);
  3052. $data ['rid'] = $rid;
  3053. $data ['enclosurHtml'] = $enclosurHtml;
  3054. $data ['rolename'] = $rolename ['name'];
  3055. $data ['datetij'] = $tijdate ['date'];
  3056. $data ['mothHtml'] = $mothHtml;
  3057. $data ['receiptList'] = $receiptList;
  3058. $data ['receiptApprovalCount'] = count ( $receiptList );
  3059. $data ['status'] = $status;
  3060. $data ['year'] = $year;
  3061. $data ['categoryList'] = $categoryList;
  3062. $data ['staffList'] = $staffList;
  3063. $data ['cid'] = $cid;
  3064. $data ['sid'] = $sid;
  3065. $data ['ap'] = $ap;
  3066. $data ['memu'] = "receipt";
  3067. $data ['staff'] = $this->staff;
  3068. $data ['receiptMemu'] = 'approvalExpenses';
  3069. $data ['verifyId'] = $this->verifyId;
  3070. $data ['executeId'] = $this->executeId;
  3071. $this->render ( "/admin/expensesEdi", $data );
  3072. }
  3073. function expensesDefray() {
  3074. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3075. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3076. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3077. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  3078. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  3079. if (! empty ( $rid )) {
  3080. Doo::loadModel ( "verify" );
  3081. $verify = new verify ();
  3082. Doo::loadModel ( "receiptDetail" );
  3083. $receiptDetailObj = new receiptDetail ();
  3084. Doo::loadModel ( "itemStatistics" );
  3085. Doo::loadModel ( "statistics" );
  3086. $statistics = new statistics ();
  3087. $itemStatistics = new itemStatistics ();
  3088. Doo::loadModel ( "receipt" );
  3089. $receipt = new receipt ();
  3090. Doo::loadModel ( "loanReceipt" );
  3091. $loanReceipt = new loanReceipt ();
  3092. $receiptDetail = $receipt->getOne ( array (
  3093. 'where' => 'rid=' . $rid . ' and status=2 ',
  3094. 'asArray' => true
  3095. ) );
  3096. if (empty ( $receiptDetail )||$receiptDetail['nowStaff']!=$this->staff['0']['sid'])
  3097. return "/approvalExpenses/pendApproval";
  3098. $verifyDetail = $verify->getOne ( array (
  3099. 'where' => ' vid =' . $receiptDetail ['verify'],
  3100. 'asArray' => true
  3101. ) );
  3102. $verifyString = $verifyDetail ['staff'];
  3103. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3104. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  3105. if (empty ( $opinion )) {
  3106. if ($status == 3)
  3107. $opinion = "终止";
  3108. else
  3109. $opinion = "同意支付";
  3110. }
  3111. $nowStaff = 0;
  3112. $nowStaffList = array ();
  3113. if (empty ( $verifyStaff )) {
  3114. // 还需加入是否已经进入角色审批
  3115. if ($verifyDetail [0] [1] == 'ROLE') {
  3116. // print_r($verifyDetail);echo "ddd";
  3117. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3118. foreach ( $vStaffString as $key => $value ) {
  3119. $staffK = explode ( "_", $value );
  3120. if ($staffK [0] != $this->staff [0] ['sid'])
  3121. array_push ( $nowStaffList, $staffK [0] );
  3122. }
  3123. // print_r($verifyDetail);
  3124. // die;
  3125. if (! empty ( $nowStaffList )) {
  3126. $nowStaff = implode ( ',', $nowStaffList );
  3127. $verifyStaff = array (
  3128. $this->staff [0] ['sid'] . "_R" => array (
  3129. 'date' => date ( 'Y-m-d' ),
  3130. 'opinion' => $opinion,
  3131. 'status' => $status,
  3132. 'nextStaff' => $verifyDetail [0] [0],
  3133. 'ROLE' => 1
  3134. )
  3135. );
  3136. } else {
  3137. $nowStaff = $verifyDetail [1] [0];
  3138. $verifyStaff = array (
  3139. $this->staff [0] ['sid'] . "_R" => array (
  3140. 'date' => date ( 'Y-m-d' ),
  3141. 'opinion' => $opinion,
  3142. 'status' => $status,
  3143. 'nextStaff' => $verifyDetail [1] [0]
  3144. )
  3145. );
  3146. }
  3147. } else {
  3148. if ($verifyDetail [1] [1] == 'ROLE') {
  3149. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  3150. // echo "dd";
  3151. foreach ( $vStaffString as $key => $value ) {
  3152. $staffK = explode ( "_", $value );
  3153. array_push ( $nowStaffList, $staffK [0] );
  3154. }
  3155. $nowStaff = implode ( ',', $nowStaffList );
  3156. $verifyStaff = array (
  3157. $this->staff [0] ['sid'] => array (
  3158. 'date' => date ( 'Y-m-d' ),
  3159. 'opinion' => $opinion,
  3160. 'status' => $status,
  3161. 'nextStaff' => $verifyDetail [1] [0],
  3162. 'ROLE' => 1
  3163. )
  3164. );
  3165. } else {
  3166. $nowStaff = $verifyDetail [1] [0];
  3167. $verifyStaff = array (
  3168. $this->staff [0] ['sid'] => array (
  3169. 'date' => date ( 'Y-m-d' ),
  3170. 'opinion' => $opinion,
  3171. 'status' => $status,
  3172. 'nextStaff' => $verifyDetail [1] [0]
  3173. )
  3174. );
  3175. }
  3176. }
  3177. if ($status == 3)
  3178. $verifyStaff = array (
  3179. 'final' => $status,
  3180. $this->staff [0] ['sid'] => array (
  3181. 'date' => date ( 'Y-m-d' ),
  3182. 'opinion' => $opinion,
  3183. 'status' => $status
  3184. )
  3185. );
  3186. $vStaffString = json_encode ( $verifyStaff );
  3187. $receipt->nowStaff = $nowStaff;
  3188. $receipt->verifyStaff = $vStaffString;
  3189. $loanReceipt->nowStaff = $nowStaff;
  3190. $loanReceipt->verifyStaff = $vStaffString;
  3191. } else {
  3192. $VS = end ( $verifyStaff );
  3193. // 非角色审批
  3194. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  3195. $nextStaff = 0;
  3196. $roleSTF = false;
  3197. foreach ( $verifyDetail as $key => $value ) {
  3198. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  3199. if (isset ( $verifyDetail [$key + 1] )) {
  3200. $nextStaff = $verifyDetail [$key + 1] [0];
  3201. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  3202. $roleSTF = true;
  3203. }
  3204. break;
  3205. }
  3206. }
  3207. if (! $roleSTF) {
  3208. $nowStaff = $nextStaff;
  3209. $verifyStaff [$this->staff [0] ['sid']] = array (
  3210. 'date' => date ( 'Y-m-d' ),
  3211. 'opinion' => $opinion,
  3212. 'status' => $status,
  3213. 'nextStaff' => $nextStaff
  3214. );
  3215. } else {
  3216. // 获取角色下的所有用户ID
  3217. $nowStaffList = array ();
  3218. foreach ( $verifyDetail as $vfk ) {
  3219. if ($vfk [1] == 'ROLE') {
  3220. $vStaffString = json_decode ( $vfk [3] );
  3221. foreach ( $vStaffString as $key => $value ) {
  3222. $staffK = explode ( "_", $value );
  3223. array_push ( $nowStaffList, $staffK [0] );
  3224. }
  3225. }
  3226. }
  3227. $nowStaff = implode ( ',', $nowStaffList );
  3228. $verifyStaff [$this->staff [0] ['sid']] = array (
  3229. 'date' => date ( 'Y-m-d' ),
  3230. 'opinion' => $opinion,
  3231. 'status' => $status,
  3232. 'nextStaff' => $nextStaff,
  3233. 'ROLE' => 0
  3234. );
  3235. }
  3236. if ($status == 3) {
  3237. $verifyStaff ['final'] = $status;
  3238. $verifyStaff [$this->staff [0] ['sid']] = array (
  3239. 'date' => date ( 'Y-m-d' ),
  3240. 'opinion' => $opinion,
  3241. 'status' => $status
  3242. );
  3243. }
  3244. $vStaffString = json_encode ( $verifyStaff );
  3245. $receipt->nowStaff = $nowStaff;
  3246. $receipt->verifyStaff = $vStaffString;
  3247. $loanReceipt->nowStaff = $nowStaff;
  3248. $loanReceipt->verifyStaff = $vStaffString;
  3249. }
  3250. // 角色审批
  3251. if (isset ( $VS ['ROLE'] )) {
  3252. // 找出角色人 当前审批角色组
  3253. $verifyJSStaff = array ();
  3254. $nowStaffList2 = array ();
  3255. foreach ( $verifyDetail as $key => $value ) {
  3256. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  3257. $verifyJSStaff = json_decode ( $value [3] );
  3258. foreach ( $verifyJSStaff as $m ) {
  3259. $staffK = explode ( "_", $m );
  3260. array_push ( $nowStaffList2, $staffK [0] );
  3261. }
  3262. // print_r($nowStaffList2);
  3263. }
  3264. }
  3265. $RoleVerifyStaff = array ();
  3266. foreach ( $verifyStaff as $key => $value ) {
  3267. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  3268. foreach ( $nowStaffList2 as $m ) {
  3269. if ($key == $m . "_R")
  3270. $RoleVerifyStaff [$key] = $value;
  3271. }
  3272. }
  3273. }
  3274. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  3275. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  3276. // 下一个审批人ID
  3277. $nextStaff = 0;
  3278. $falg = false;
  3279. foreach ( $verifyDetail as $key => $value ) {
  3280. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  3281. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  3282. $falg = true;
  3283. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  3284. $nowStaffList = array ();
  3285. foreach ( $vStaffString as $v ) {
  3286. $staffK = explode ( "_", $v );
  3287. array_push ( $nowStaffList, $staffK [0] );
  3288. }
  3289. $nowStaff = implode ( ',', $nowStaffList );
  3290. $nextStaff = $verifyDetail [$key + 1] [0];
  3291. } elseif (isset ( $verifyDetail [$key + 1] )) {
  3292. $nextStaff = $verifyDetail [$key + 1] [0];
  3293. $nowStaff = $nextStaff;
  3294. } else
  3295. $nowStaff = '';
  3296. break;
  3297. }
  3298. }
  3299. if ($falg)
  3300. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3301. 'date' => date ( 'Y-m-d' ),
  3302. 'opinion' => $opinion,
  3303. 'status' => $status,
  3304. 'nextStaff' => $nextStaff,
  3305. 'ROLE' => 1
  3306. );
  3307. else
  3308. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3309. 'date' => date ( 'Y-m-d' ),
  3310. 'opinion' => $opinion,
  3311. 'status' => $status,
  3312. 'nextStaff' => $nextStaff
  3313. );
  3314. // print_r($verifyStaff);
  3315. // echo $nowStaff;die;
  3316. } else { // 进入下一个角色或者审批人
  3317. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  3318. //
  3319. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  3320. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3321. 'date' => date ( 'Y-m-d' ),
  3322. 'opinion' => $opinion,
  3323. 'status' => $status,
  3324. 'nextStaff' => $VS ['nextStaff'],
  3325. 'ROLE' => 1
  3326. );
  3327. // print_r($verifyStaff);
  3328. // die;
  3329. }
  3330. if ($status == 3) {
  3331. $verifyStaff ['final'] = $status;
  3332. $verifyStaff [$this->staff [0] ['sid']] = array (
  3333. 'date' => date ( 'Y-m-d' ),
  3334. 'opinion' => $opinion,
  3335. 'status' => $status
  3336. );
  3337. }
  3338. $vStaffString = json_encode ( $verifyStaff );
  3339. $receipt->verifyStaff = $vStaffString;
  3340. $receipt->nowStaff = $nowStaff;
  3341. $loanReceipt->nowStaff = $nowStaff;
  3342. $loanReceipt->verifyStaff = $vStaffString;
  3343. // die;
  3344. // }
  3345. // print_r($verifyStaff);
  3346. // die;
  3347. }
  3348. // print_r($verifyStaff);die;
  3349. }
  3350. // print_r($verifyDetail);
  3351. $roleKey = 0;
  3352. $roleId = 0;
  3353. $verifyDetailCopy = array ();
  3354. foreach ( $verifyDetail as $k => $v ) {
  3355. if ($v [1] == 'ROLE') {
  3356. $roleId = $v [0];
  3357. $roleVerify = json_decode ( $v [3], true );
  3358. $roleKey = $k;
  3359. $roleArray = array ();
  3360. foreach ( $roleVerify as $o => $p ) {
  3361. $staffID = explode ( '_', $p );
  3362. $exp = array (
  3363. 0 => $staffID [0],
  3364. 1 => $staffID [1]
  3365. );
  3366. array_push ( $roleArray, $exp );
  3367. }
  3368. $verifyDetailCopy [$v [0]] = $roleArray;
  3369. }
  3370. }
  3371. // print_r($verifyDetail);
  3372. foreach ( $verifyDetailCopy as $k => $v ) {
  3373. foreach ( $verifyDetail as $m => $n ) {
  3374. if ($n [0] == $k) {
  3375. array_splice ( $verifyDetail, $m, 1, $v );
  3376. }
  3377. }
  3378. }
  3379. // 审批日志
  3380. if (! isset ( $verifyStaff ['final'] )) {
  3381. Doo::loadModel ( "receiptLog" );
  3382. $receiptLog = new receiptLog ();
  3383. if (! empty ( $roleId )) {
  3384. Doo::loadModel ( "role" );
  3385. $role = new role ();
  3386. $roleInfo = $role->getOne ( array (
  3387. 'where' => 'rid=' . $roleId,
  3388. 'asArray' => true
  3389. ) );
  3390. $receiptLog->rolename = $roleInfo ['name'];
  3391. }
  3392. $receiptLog->username = $this->staff [0] ['username'];
  3393. $receiptLog->uid = $this->staff [0] ['sid'];
  3394. $receiptLog->date = date ( "Y-m-d" );
  3395. $receiptLog->opinion = $opinion;
  3396. $receiptLog->img = $this->staff [0] ['avatar'];
  3397. $receiptLog->status = 1;
  3398. $receiptLog->rid = $rid;
  3399. $receiptLog->insert ();
  3400. }
  3401. if (isset ( $verifyStaff ['final'] )) { // rDetail
  3402. $receipt->status = 3;
  3403. $receipt->verifyBreakup = $verifyString;
  3404. $receiptDetailObj->status = 3;
  3405. $receiptDetailObj->update ( array (
  3406. 'where' => 'rid=' . $rid
  3407. ) );
  3408. // 微信企业号通知
  3409. $this->setWXMsg ( $rid, 3 );
  3410. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  3411. $receipt->status = 6;
  3412. $receipt->pastDate = date ( "Y-m-d" );
  3413. $receipt->isBK = 1;
  3414. $loanReceipt->verifyBreakup = $verifyString;
  3415. $loanReceipt->status = 1;
  3416. $loanReceipt->pastDate = date ( "Y-m-d" );
  3417. $loanReceipt->amount = $receiptDetail ['amount'];
  3418. $loanReceipt->update ( array (
  3419. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  3420. ) );
  3421. // 微信企业号通知
  3422. $this->setWXMsg ( $rid, 1 );
  3423. }
  3424. $receipt->amount = $amount;
  3425. $receipt->update ( array (
  3426. 'where' => ' rid = ' . $rid
  3427. ) );
  3428. return "/approvalExpenses/pendApproval";
  3429. }
  3430. }
  3431. function ajaxExamineExe() {
  3432. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3433. Doo::loadModel ( 'receipt' );
  3434. $receipt = new receipt ();
  3435. Doo::loadClass ( 'XDeode' );
  3436. $XDeode = new XDeode ( 5 );
  3437. if (! empty ( $rid )) {
  3438. $rLRes = $receipt->find ( array (
  3439. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  3440. 'asArray' => true
  3441. ) );
  3442. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  3443. echo json_encode ( array (
  3444. 'status' => 1,
  3445. 'receipt' => $rLRes [0]
  3446. ) );
  3447. die ();
  3448. }
  3449. echo json_encode ( array (
  3450. 'status' => 0,
  3451. 'receipt' => array ()
  3452. ) );
  3453. die ();
  3454. }
  3455. function implement() {
  3456. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3457. Doo::loadClass ( 'XDeode' );
  3458. $XDeode = new XDeode ( 5 );
  3459. Doo::loadModel ( 'receipt' );
  3460. $receipt = new receipt ();
  3461. Doo::loadModel ( 'L_category' );
  3462. $Lcategory = new L_category ();
  3463. Doo::loadModel ( 'verify' );
  3464. $verify = new verify ();
  3465. Doo::loadModel ( 'staff' );
  3466. $staff = new staff ();
  3467. Doo::loadModel ( "execute" );
  3468. $execute = new execute ();
  3469. $rid = $XDeode->decode ( $rid );
  3470. $receiptList = $receipt->find ( array (
  3471. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  3472. 'desc' => 'rid',
  3473. 'asArray' => true
  3474. ) );
  3475. Doo::loadModel ( 'loanReceipt' );
  3476. $loanReceipt = new loanReceipt ();
  3477. // print_r($receiptList);
  3478. $loanList = array ();
  3479. if (! isset ( $receiptList ))
  3480. $loanList = $loanReceipt->find ( array (
  3481. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3482. 'desc' => 'rid',
  3483. 'asArray' => true
  3484. ) );
  3485. $Locate = 0;
  3486. $roleId = 0;
  3487. $button = 0;
  3488. foreach ( $loanList as $key => $value ) {
  3489. $loanList [$key] ['Locate'] = $Locate;
  3490. $Locate ++;
  3491. $loanList [$key] ['reviseDetail'] = array ();
  3492. if (! empty ( $value ['reviseDetail'] ))
  3493. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3494. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3495. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3496. $categoryDetil = $Lcategory->getOne ( array (
  3497. 'where' => 'cid=' . $value ['cid'],
  3498. 'asArray' => true
  3499. ) );
  3500. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3501. // 检测编辑状态
  3502. $verifyList = $verify->getOne ( array (
  3503. 'where' => 'vid=' . $value ['verify'],
  3504. 'asArray' => true
  3505. ) );
  3506. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3507. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3508. Doo::loadModel ( 'role' );
  3509. $role = new role ();
  3510. $flag = true;
  3511. $roleKey = 0;
  3512. $endStaffArray = array ();
  3513. $roleArrayCopy = array ();
  3514. foreach ( $verifyList as $k => $v ) {
  3515. // init verifyStaff
  3516. if ($v [1] == 'ROLE') {
  3517. if (! empty ( $verifyStaff )) {
  3518. $endStaffArray = end ( $verifyStaff );
  3519. // if ($v[0]==$endStaffArray['nextStaff']){
  3520. // $roleId=$v[0];
  3521. // }
  3522. }
  3523. $roleVerify = json_decode ( $v [3], true );
  3524. $roleKey = $k;
  3525. $roleArray = array ();
  3526. $rolename = $role->getOne ( array (
  3527. 'where' => 'rid=' . $v [0],
  3528. 'asArray' => true
  3529. ) );
  3530. foreach ( $roleVerify as $o => $p ) {
  3531. $staffID = explode ( '_', $p );
  3532. $staffInfo = $staff->getOne ( array (
  3533. 'where' => 'sid=' . $staffID [0],
  3534. 'asArray' => true
  3535. ) );
  3536. // print_r($staffID);
  3537. $exp = array (
  3538. 0 => $staffInfo ['sid'],
  3539. 1 => $staffID [1],
  3540. 2 => $staffInfo ['avatar'],
  3541. 'date' => '',
  3542. 'date' => '',
  3543. 'opinion' => '',
  3544. 'status' => '',
  3545. 'rolename' => $rolename ['name']
  3546. );
  3547. array_push ( $roleArray, $exp );
  3548. }
  3549. $roleArrayCopy [$v [0]] = $roleArray;
  3550. // $verifyList[$k]['roleArray']=$roleArray;
  3551. }
  3552. $verifyList [$k] ['date'] = "";
  3553. $verifyList [$k] ['opinion'] = "";
  3554. $verifyList [$k] ['status'] = "";
  3555. if (empty ( $verifyStaff )) {
  3556. $verifyList [$k] ['date'] = "";
  3557. $verifyList [$k] ['opinion'] = "";
  3558. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3559. $verifyList [$k] ['status'] = 4;
  3560. $flag = false;
  3561. }
  3562. } else {
  3563. foreach ( $verifyStaff as $m => $u ) {
  3564. if ($v [0] == $m) {
  3565. $verifyList [$k] ['date'] = $u ['date'];
  3566. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3567. $verifyList [$k] ['status'] = $u ['status'];
  3568. $flag = false;
  3569. break;
  3570. }
  3571. }
  3572. $endStaffArray = end ( $verifyStaff );
  3573. if (isset ( $endStaffArray ['ROLE'] )) {
  3574. } else {
  3575. // $endKey=key($verifyStaff);
  3576. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3577. // $button=4;
  3578. // $verifyList[$k]['status']=4;
  3579. // }
  3580. }
  3581. }
  3582. }
  3583. $rolename ['name'] = '';
  3584. if (! empty ( $roleId )) {
  3585. Doo::loadModel ( 'role' );
  3586. $role = new role ();
  3587. $rolename = $role->getOne ( array (
  3588. 'where' => 'rid=' . $roleId,
  3589. 'asArray' => true
  3590. ) );
  3591. }
  3592. if (! empty ( $verifyStaff ))
  3593. $endStaffArray = end ( $verifyStaff );
  3594. $KOP = false;
  3595. foreach ( $roleArrayCopy as $P => $A ) {
  3596. foreach ( $A as $MKI => $AVL ) {
  3597. if (! empty ( $verifyStaff )) {
  3598. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3599. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3600. $button = 4;
  3601. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3602. }
  3603. foreach ( $verifyStaff as $m => $u ) {
  3604. $AVLFK = $AVL [0] . '_R';
  3605. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3606. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3607. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3608. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3609. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3610. break;
  3611. }
  3612. }
  3613. } else {
  3614. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3615. $button = 4;
  3616. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3617. }
  3618. }
  3619. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3620. $KOP = true;
  3621. }
  3622. }
  3623. foreach ( $roleArrayCopy as $k => $v ) {
  3624. foreach ( $verifyList as $m => $n ) {
  3625. if ($n [0] == $k) {
  3626. array_splice ( $verifyList, $m, 1, $v );
  3627. }
  3628. }
  3629. }
  3630. $loanList [$key] ['verifyList'] = $verifyList;
  3631. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3632. 'where' => 'sid=' . $value ['staff'],
  3633. 'asArray' => true
  3634. ) );
  3635. }
  3636. $data ['loanList'] = $loanList;
  3637. $Locate = 0;
  3638. $roleId = 0;
  3639. $button = 0;
  3640. foreach ( $receiptList as $key => $value ) {
  3641. $button2 = 0;
  3642. $receiptList [$key] ['Locate'] = $Locate;
  3643. $Locate ++;
  3644. $receiptList [$key] ['reviseDetail'] = array ();
  3645. if (! empty ( $value ['reviseDetail'] ))
  3646. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3647. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3648. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3649. $categoryDetil = $Lcategory->getOne ( array (
  3650. 'where' => 'cid=' . $value ['cid'],
  3651. 'asArray' => true
  3652. ) );
  3653. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3654. $executeList = json_decode ( $value ['executeCopy'], true );
  3655. $executeStaff = array ();
  3656. if (! empty ( $value ['executeStaff'] ))
  3657. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3658. if (isset ( $executeList )) {
  3659. foreach ( $executeList as $op => $lo ) {
  3660. $executeList [$op] ['date'] = "";
  3661. $executeList [$op] ['opinion'] = "";
  3662. $executeList [$op] ['status'] = "";
  3663. foreach ( $executeStaff as $m => $u ) {
  3664. if ($lo [0] == $m) {
  3665. $executeList [$op] ['date'] = $u ['date'];
  3666. $executeList [$op] ['opinion'] = $u ['opinion'];
  3667. $executeList [$op] ['status'] = $u ['status'];
  3668. break;
  3669. }
  3670. }
  3671. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  3672. $button2 = 1;
  3673. $executeList [$op] ['status'] = 4;
  3674. }
  3675. }
  3676. }
  3677. // 检测编辑状态
  3678. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3679. $verifyList ['staff'] = $value ['verifyBreakup'];
  3680. } else
  3681. $verifyList = $verify->getOne ( array (
  3682. 'where' => 'vid=' . $value ['verify'],
  3683. 'asArray' => true
  3684. ) );
  3685. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3686. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3687. Doo::loadModel ( 'role' );
  3688. $role = new role ();
  3689. if ($verifyList == NULL)
  3690. $verifyList = array ();
  3691. $flag = true;
  3692. $roleKey = 0;
  3693. $endStaffArray = array ();
  3694. $roleArrayCopy = array ();
  3695. foreach ( $verifyList as $k => $v ) {
  3696. // init verifyStaff
  3697. if ($v [1] == 'ROLE') {
  3698. if (! empty ( $verifyStaff )) {
  3699. $endStaffArray = end ( $verifyStaff );
  3700. // if ($v[0]==$endStaffArray['nextStaff']){
  3701. // $roleId=$v[0];
  3702. // }
  3703. }
  3704. $roleVerify = json_decode ( $v [3], true );
  3705. $roleKey = $k;
  3706. $roleArray = array ();
  3707. $rolename = $role->getOne ( array (
  3708. 'where' => 'rid=' . $v [0],
  3709. 'asArray' => true
  3710. ) );
  3711. foreach ( $roleVerify as $o => $p ) {
  3712. $staffID = explode ( '_', $p );
  3713. $staffInfo = $staff->getOne ( array (
  3714. 'where' => 'sid=' . $staffID [0],
  3715. 'asArray' => true
  3716. ) );
  3717. // print_r($staffID);
  3718. $exp = array (
  3719. 0 => $staffInfo ['sid'],
  3720. 1 => $staffID [1],
  3721. 2 => $staffInfo ['avatar'],
  3722. 'date' => '',
  3723. 'date' => '',
  3724. 'opinion' => '',
  3725. 'status' => '',
  3726. 'rolename' => $rolename ['name']
  3727. );
  3728. array_push ( $roleArray, $exp );
  3729. }
  3730. $roleArrayCopy [$v [0]] = $roleArray;
  3731. // $verifyList[$k]['roleArray']=$roleArray;
  3732. }
  3733. $verifyList [$k] ['date'] = "";
  3734. $verifyList [$k] ['opinion'] = "";
  3735. $verifyList [$k] ['status'] = "";
  3736. if (empty ( $verifyStaff )) {
  3737. $verifyList [$k] ['date'] = "";
  3738. $verifyList [$k] ['opinion'] = "";
  3739. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3740. $verifyList [$k] ['status'] = 4;
  3741. $flag = false;
  3742. }
  3743. } else {
  3744. foreach ( $verifyStaff as $m => $u ) {
  3745. if ($v [0] == $m) {
  3746. $verifyList [$k] ['date'] = $u ['date'];
  3747. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3748. $verifyList [$k] ['status'] = $u ['status'];
  3749. $flag = false;
  3750. break;
  3751. }
  3752. }
  3753. $endStaffArray = end ( $verifyStaff );
  3754. if (isset ( $endStaffArray ['ROLE'] )) {
  3755. } else {
  3756. // $endKey=key($verifyStaff);
  3757. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3758. // $button=4;
  3759. // $verifyList[$k]['status']=4;
  3760. // }
  3761. }
  3762. }
  3763. }
  3764. $rolename ['name'] = '';
  3765. if (! empty ( $roleId )) {
  3766. Doo::loadModel ( 'role' );
  3767. $role = new role ();
  3768. $rolename = $role->getOne ( array (
  3769. 'where' => 'rid=' . $roleId,
  3770. 'asArray' => true
  3771. ) );
  3772. }
  3773. if (! empty ( $verifyStaff ))
  3774. $endStaffArray = end ( $verifyStaff );
  3775. $KOP = false;
  3776. foreach ( $roleArrayCopy as $P => $A ) {
  3777. foreach ( $A as $MKI => $AVL ) {
  3778. if (! empty ( $verifyStaff )) {
  3779. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3780. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3781. $button = 4;
  3782. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3783. }
  3784. foreach ( $verifyStaff as $m => $u ) {
  3785. $AVLFK = $AVL [0] . '_R';
  3786. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3787. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3788. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3789. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3790. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3791. break;
  3792. }
  3793. }
  3794. } else {
  3795. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3796. $button = 4;
  3797. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3798. }
  3799. }
  3800. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3801. $KOP = true;
  3802. }
  3803. }
  3804. foreach ( $roleArrayCopy as $k => $v ) {
  3805. foreach ( $verifyList as $m => $n ) {
  3806. if ($n [0] == $k) {
  3807. array_splice ( $verifyList, $m, 1, $v );
  3808. }
  3809. }
  3810. }
  3811. $receiptList [$key] ['verifyList'] = $verifyList;
  3812. $receiptList [$key] ['executeList'] = $executeList;
  3813. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3814. 'where' => 'sid=' . $value ['staff'],
  3815. 'asArray' => true
  3816. ) );
  3817. $receiptList [$key] ['button2'] = $button2;
  3818. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3819. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3820. $relust = $value ['sum'] - $value ['loanSum'];
  3821. $receiptList [$key] ['relust'] = $relust;
  3822. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  3823. }
  3824. // print_r($receiptList[$key]['executeList']);
  3825. $data ['receiptList'] = $receiptList;
  3826. $data ['memu'] = "receipt";
  3827. $data ['staff'] = $this->staff;
  3828. $data ['receiptMemu'] = 'implement';
  3829. $data ['verifyId'] = $this->verifyId;
  3830. $data ['executeId'] = $this->executeId;
  3831. $this->render ( "/admin/implement", $data );
  3832. }
  3833. function implementDo() {
  3834. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3835. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3836. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  3837. if (! empty ( $rid ) && $amount != '') {
  3838. Doo::loadModel ( 'receipt' );
  3839. $receipt = new receipt ();
  3840. Doo::loadClass ( 'XDeode' );
  3841. $XDeode = new XDeode ( 5 );
  3842. $rinfo = $receipt->getOne ( array (
  3843. 'where' => 'rid=' . $rid,
  3844. 'asArray' => true
  3845. ) );
  3846. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  3847. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  3848. if (empty ( $executeStaff )) {
  3849. $executeStaff = array (
  3850. $this->staff [0] ['sid'] => array (
  3851. 'date' => date ( 'Y-m-d' ),
  3852. 'opinion' => $implementOpinions,
  3853. 'status' => 1
  3854. )
  3855. );
  3856. } else {
  3857. $executeStaff [$this->staff [0] ['sid']] = array (
  3858. 'date' => date ( 'Y-m-d' ),
  3859. 'opinion' => $implementOpinions,
  3860. 'status' => 1
  3861. );
  3862. }
  3863. if (count ( $executeStaff ) == count ( $executeCopy )) {
  3864. $receipt->executeStaff = json_encode ( $executeStaff );
  3865. $receipt->status = 8;
  3866. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  3867. $receipt->status = 9;
  3868. if($rinfo ['status']==6){
  3869. $receipt->loanDate=date ( "Y-m-d" );
  3870. }
  3871. $receipt->executeDate = date ( "Y-m-d" );
  3872. } else {
  3873. $receipt->executeStaff = json_encode ( $executeStaff );
  3874. }
  3875. $receipt->amount = $amount;
  3876. $receipt->update ( array (
  3877. 'where' => 'rid=' . $rid
  3878. ) );
  3879. }
  3880. $ridKey = $XDeode->encode ( $rid );
  3881. return "/hisImplement";
  3882. //return "/implement/" . $ridKey . ".html";
  3883. }
  3884. function receiptburEdi() {
  3885. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3886. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  3887. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  3888. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  3889. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3890. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  3891. if (empty ( $status ))
  3892. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  3893. $vidList = array ();
  3894. $button = 0;
  3895. Doo::loadModel ( 'verify' );
  3896. Doo::loadModel ( 'receipt' );
  3897. Doo::loadModel ( 'staff' );
  3898. $staff = new staff ();
  3899. $receipt = new receipt ();
  3900. $verify = new verify ();
  3901. Doo::loadModel ( 'L_category' );
  3902. $Lcategory = new L_category ();
  3903. Doo::loadModel ( 'enclosur' );
  3904. $enclosur = new enclosur ();
  3905. Doo::loadModel ( 'loanReceipt' );
  3906. $loanReceipt = new loanReceipt ();
  3907. // user verify ID
  3908. $verifyDetail = $verify->find ( array (
  3909. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  3910. 'asArray' => true
  3911. ) );
  3912. foreach ( $verifyDetail as $key => $value ) {
  3913. array_push ( $vidList, $value ['vid'] );
  3914. }
  3915. $vid = implode ( ",", $vidList );
  3916. if (empty ( $verifyDetail ))
  3917. $vid = 0;
  3918. $categoryList = $Lcategory->find ( array (
  3919. 'asArray' => true
  3920. ) );
  3921. $staffList = $staff->find ( array (
  3922. 'where' => 'cid=' . $cid,
  3923. 'asArray' => true
  3924. ) );
  3925. $ap = "";
  3926. if ($status == 4) {
  3927. $ap = 4;
  3928. $status = 2;
  3929. }
  3930. // get Receipt By verifyID status 2
  3931. $receiptList = $receipt->find ( array (
  3932. 'where' => 'rid =' . $rid.' and status=2',
  3933. 'desc' => 'rid',
  3934. 'asArray' => true
  3935. ) );
  3936. if(empty($receiptList)){
  3937. die ( 'illegal request' );
  3938. }
  3939. $loanList = $loanReceipt->find ( array (
  3940. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3941. 'desc' => 'rid',
  3942. 'asArray' => true
  3943. ) );
  3944. $Locate = 0;
  3945. $roleId = 0;
  3946. $button = 0;
  3947. foreach ( $loanList as $key => $value ) {
  3948. $loanList [$key] ['Locate'] = $Locate;
  3949. $Locate ++;
  3950. $loanList [$key] ['reviseDetail'] = array ();
  3951. if (! empty ( $value ['reviseDetail'] ))
  3952. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3953. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3954. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3955. $categoryDetil = $Lcategory->getOne ( array (
  3956. 'where' => 'cid=' . $value ['cid'],
  3957. 'asArray' => true
  3958. ) );
  3959. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3960. // 检测编辑状态
  3961. $verifyList = $verify->getOne ( array (
  3962. 'where' => 'vid=' . $value ['verify'],
  3963. 'asArray' => true
  3964. ) );
  3965. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3966. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3967. Doo::loadModel ( 'role' );
  3968. $role = new role ();
  3969. $flag = true;
  3970. $roleKey = 0;
  3971. $endStaffArray = array ();
  3972. $roleArrayCopy = array ();
  3973. foreach ( $verifyList as $k => $v ) {
  3974. // init verifyStaff
  3975. if ($v [1] == 'ROLE') {
  3976. if (! empty ( $verifyStaff )) {
  3977. $endStaffArray = end ( $verifyStaff );
  3978. }
  3979. $roleVerify = json_decode ( $v [3], true );
  3980. $roleKey = $k;
  3981. $roleArray = array ();
  3982. $rolename = $role->getOne ( array (
  3983. 'where' => 'rid=' . $v [0],
  3984. 'asArray' => true
  3985. ) );
  3986. foreach ( $roleVerify as $o => $p ) {
  3987. $staffID = explode ( '_', $p );
  3988. $staffInfo = $staff->getOne ( array (
  3989. 'where' => 'sid=' . $staffID [0],
  3990. 'asArray' => true
  3991. ) );
  3992. // print_r($staffID);
  3993. $exp = array (
  3994. 0 => $staffInfo ['sid'],
  3995. 1 => $staffID [1],
  3996. 2 => $staffInfo ['avatar'],
  3997. 'date' => '',
  3998. 'date' => '',
  3999. 'opinion' => '',
  4000. 'status' => '',
  4001. 'rolename' => $rolename ['name']
  4002. );
  4003. array_push ( $roleArray, $exp );
  4004. }
  4005. $roleArrayCopy [$v [0]] = $roleArray;
  4006. // $verifyList[$k]['roleArray']=$roleArray;
  4007. }
  4008. $verifyList [$k] ['date'] = "";
  4009. $verifyList [$k] ['opinion'] = "";
  4010. $verifyList [$k] ['status'] = "";
  4011. if (empty ( $verifyStaff )) {
  4012. $verifyList [$k] ['date'] = "";
  4013. $verifyList [$k] ['opinion'] = "";
  4014. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4015. $verifyList [$k] ['status'] = 4;
  4016. $flag = false;
  4017. }
  4018. } else {
  4019. foreach ( $verifyStaff as $m => $u ) {
  4020. if ($v [0] == $m) {
  4021. $verifyList [$k] ['date'] = $u ['date'];
  4022. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4023. $verifyList [$k] ['status'] = $u ['status'];
  4024. $flag = false;
  4025. break;
  4026. }
  4027. }
  4028. $endStaffArray = end ( $verifyStaff );
  4029. if (isset ( $endStaffArray ['ROLE'] )) {
  4030. } else {
  4031. }
  4032. }
  4033. }
  4034. $rolename ['name'] = '';
  4035. if (! empty ( $roleId )) {
  4036. Doo::loadModel ( 'role' );
  4037. $role = new role ();
  4038. $rolename = $role->getOne ( array (
  4039. 'where' => 'rid=' . $roleId,
  4040. 'asArray' => true
  4041. ) );
  4042. }
  4043. if (! empty ( $verifyStaff ))
  4044. $endStaffArray = end ( $verifyStaff );
  4045. $KOP = false;
  4046. foreach ( $roleArrayCopy as $P => $A ) {
  4047. foreach ( $A as $MKI => $AVL ) {
  4048. if (! empty ( $verifyStaff )) {
  4049. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4050. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4051. $button = 4;
  4052. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4053. }
  4054. foreach ( $verifyStaff as $m => $u ) {
  4055. $AVLFK = $AVL [0] . '_R';
  4056. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4057. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4058. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4059. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4060. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4061. break;
  4062. }
  4063. }
  4064. } else {
  4065. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4066. $button = 4;
  4067. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4068. }
  4069. }
  4070. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4071. $KOP = true;
  4072. }
  4073. }
  4074. foreach ( $roleArrayCopy as $k => $v ) {
  4075. foreach ( $verifyList as $m => $n ) {
  4076. if ($n [0] == $k) {
  4077. array_splice ( $verifyList, $m, 1, $v );
  4078. }
  4079. }
  4080. }
  4081. $loanList [$key] ['verifyList'] = $verifyList;
  4082. }
  4083. $htmlLoan = '';
  4084. if (isset ( $loanList [0] )) {
  4085. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  4086. if ($value ['status'] == 1)
  4087. $htmlLoan .= '<li class="done" >';
  4088. elseif ($value ['status'] == 3)
  4089. $htmlLoan .= '<li class="undone" >';
  4090. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  4091. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  4092. if (isset ( $value ['rolename'] ))
  4093. $htmlLoan .= $value ['rolename'];
  4094. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  4095. }
  4096. $data ['loanDate'] = $loanList [0] ['date'];
  4097. }
  4098. $data ['htmlLoan'] = $htmlLoan;
  4099. $data['loanReceiptDate']=$loanList [0] ['date'];
  4100. //$data ['LoanReceipt']=$loanList[0];
  4101. // print_r($loanList);
  4102. $Locate = 0;
  4103. $roleId = 0;
  4104. $button = 0;
  4105. if ($ap == 4)
  4106. $status = 4;
  4107. foreach ( $receiptList as $key => $value ) {
  4108. $receiptList [$key] ['Locate'] = $Locate;
  4109. $Locate ++;
  4110. $receiptList [$key] ['reviseDetail'] = array ();
  4111. if (! empty ( $value ['reviseDetail'] ))
  4112. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4113. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4114. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4115. $categoryDetil = $Lcategory->getOne ( array (
  4116. 'where' => 'cid=' . $value ['cid'],
  4117. 'asArray' => true
  4118. ) );
  4119. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4120. // 检测编辑状态
  4121. $verifyList = $verify->getOne ( array (
  4122. 'where' => 'vid=' . $value ['verify'],
  4123. 'asArray' => true
  4124. ) );
  4125. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4126. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4127. Doo::loadModel ( 'role' );
  4128. $role = new role ();
  4129. // print_r($verifyList);
  4130. $flag = true;
  4131. $roleKey = 0;
  4132. $endStaffArray = array ();
  4133. $roleArrayCopy = array ();
  4134. foreach ( $verifyList as $k => $v ) {
  4135. // init verifyStaff
  4136. if ($v [1] == 'ROLE') {
  4137. if (! empty ( $verifyStaff )) {
  4138. $endStaffArray = end ( $verifyStaff );
  4139. if ($v [0] == $endStaffArray ['nextStaff']) {
  4140. $roleId = $v [0];
  4141. }
  4142. }
  4143. $roleVerify = json_decode ( $v [3], true );
  4144. $roleKey = $k;
  4145. $roleArray = array ();
  4146. $rolename = $role->getOne ( array (
  4147. 'where' => 'rid=' . $v [0],
  4148. 'asArray' => true
  4149. ) );
  4150. foreach ( $roleVerify as $o => $p ) {
  4151. $staffID = explode ( '_', $p );
  4152. $staffInfo = $staff->getOne ( array (
  4153. 'where' => 'sid=' . $staffID [0],
  4154. 'asArray' => true
  4155. ) );
  4156. // print_r($staffID);
  4157. $exp = array (
  4158. 0 => $staffInfo ['sid'],
  4159. 1 => $staffID [1],
  4160. 2 => $staffInfo ['avatar'],
  4161. 'date' => '',
  4162. 'date' => '',
  4163. 'opinion' => '',
  4164. 'status' => '',
  4165. 'rolename' => $rolename ['name']
  4166. );
  4167. array_push ( $roleArray, $exp );
  4168. }
  4169. $roleArrayCopy [$v [0]] = $roleArray;
  4170. // $verifyList[$k]['roleArray']=$roleArray;
  4171. }
  4172. // print_r($roleArray);
  4173. $verifyList [$k] ['date'] = "";
  4174. $verifyList [$k] ['opinion'] = "";
  4175. $verifyList [$k] ['status'] = "";
  4176. if (empty ( $verifyStaff )) {
  4177. $verifyList [$k] ['date'] = "";
  4178. $verifyList [$k] ['opinion'] = "";
  4179. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4180. $verifyList [$k] ['status'] = 4;
  4181. $button = 4;
  4182. $flag = false;
  4183. }
  4184. } else {
  4185. foreach ( $verifyStaff as $m => $u ) {
  4186. if ($v [0] == $m) {
  4187. $verifyList [$k] ['date'] = $u ['date'];
  4188. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4189. $verifyList [$k] ['status'] = $u ['status'];
  4190. $flag = false;
  4191. break;
  4192. }
  4193. }
  4194. $endStaffArray = end ( $verifyStaff );
  4195. if (isset ( $endStaffArray ['ROLE'] )) {
  4196. } else {
  4197. $endKey = key ( $verifyStaff );
  4198. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4199. $button = 4;
  4200. $verifyList [$k] ['status'] = 4;
  4201. }
  4202. }
  4203. }
  4204. }
  4205. $rolename ['name'] = '';
  4206. if (! empty ( $roleId )) {
  4207. Doo::loadModel ( 'role' );
  4208. $role = new role ();
  4209. $rolename = $role->getOne ( array (
  4210. 'where' => 'rid=' . $roleId,
  4211. 'asArray' => true
  4212. ) );
  4213. }
  4214. if (! empty ( $verifyStaff ))
  4215. $endStaffArray = end ( $verifyStaff );
  4216. $KOP = false;
  4217. foreach ( $roleArrayCopy as $P => $A ) {
  4218. foreach ( $A as $MKI => $AVL ) {
  4219. if (! empty ( $verifyStaff )) {
  4220. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4221. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4222. $button = 4;
  4223. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4224. }
  4225. foreach ( $verifyStaff as $m => $u ) {
  4226. $AVLFK = $AVL [0] . '_R';
  4227. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4228. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4229. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4230. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4231. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4232. break;
  4233. }
  4234. }
  4235. } else {
  4236. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4237. $button = 4;
  4238. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4239. }
  4240. }
  4241. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4242. $KOP = true;
  4243. }
  4244. }
  4245. foreach ( $roleArrayCopy as $k => $v ) {
  4246. foreach ( $verifyList as $m => $n ) {
  4247. if ($n [0] == $k) {
  4248. array_splice ( $verifyList, $m, 1, $v );
  4249. }
  4250. }
  4251. }
  4252. // print_r($verifyList);
  4253. $receiptList [$key] ['verifyList'] = $verifyList;
  4254. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4255. 'where' => 'sid=' . $value ['staff'],
  4256. 'asArray' => true
  4257. ) );
  4258. $receiptList [$key] ['button'] = $button;
  4259. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4260. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4261. $relust = $value ['sum'] - $value ['loanSum'];
  4262. $receiptList [$key] ['relust'] = $relust;
  4263. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4264. }
  4265. // print_r($receiptList);die;
  4266. // $data['verifyDetail']=$verifyDetail;
  4267. $mothHtml = "";
  4268. for($i = 1; $i <= 12; $i ++) {
  4269. if ($month == $i)
  4270. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4271. else
  4272. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4273. }
  4274. // 获取审批日志
  4275. Doo::loadModel ( 'receiptLog' );
  4276. $receiptLog = new receiptLog ();
  4277. $rlList = array ();
  4278. $rlInfo = $receiptLog->getOne ( array (
  4279. 'where' => 'rid=' . $rid . ' and status=4',
  4280. 'asArray' => true
  4281. ) );
  4282. $tijdate = $receiptLog->getOne ( array (
  4283. 'where' => 'rid=' . $rid . ' and status=2',
  4284. 'asc' => 'rlid',
  4285. 'asArray' => true
  4286. ) );
  4287. if (! empty ( $rlInfo )) {
  4288. $rlList = $receiptLog->find ( array (
  4289. 'where' => 'rid=' . $rid,
  4290. 'asc' => 'rlid',
  4291. 'asArray' => true
  4292. ) );
  4293. }
  4294. // echo $rid;
  4295. // print_r($receiptList);
  4296. $receiptList [0] ['rlList'] = $rlList;
  4297. // print_r($receiptList);
  4298. $enclosurList = $enclosur->find ( array (
  4299. 'where' => 'rid=' . $rid,
  4300. 'asArray' => true
  4301. ) );
  4302. $enclosurHtml = '';
  4303. foreach ( $enclosurList as $value ) {
  4304. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4305. }
  4306. $data ['enclosurHtml'] = $enclosurHtml;
  4307. $data ['rolename'] = $rolename ['name'];
  4308. $data ['mothHtml'] = $mothHtml;
  4309. //print_r($receiptList);
  4310. $data ['rid'] = $rid;
  4311. $data ['tijdate'] = $tijdate ['date'];
  4312. $data ['receiptList'] = $receiptList;
  4313. $data ['receiptApprovalCount'] = count ( $receiptList );
  4314. $data ['status'] = $status;
  4315. $data ['year'] = $year;
  4316. $data ['categoryList'] = $categoryList;
  4317. $data ['staffList'] = $staffList;
  4318. $data ['cid'] = $cid;
  4319. $data ['sid'] = $sid;
  4320. $data ['ap'] = $ap;
  4321. $data ['memu'] = "receipt";
  4322. $data ['staff'] = $this->staff;
  4323. $data ['receiptMemu'] = 'approvalExpenses';
  4324. $data ['verifyId'] = $this->verifyId;
  4325. $data ['executeId'] = $this->executeId;
  4326. $this->render ( "/admin/receiptburEdi", $data );
  4327. }
  4328. function hisImplement() {
  4329. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4330. if (empty ( $item ))
  4331. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "pendImplement";
  4332. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  4333. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4334. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  4335. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  4336. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  4337. Doo::loadModel ( 'receipt' );
  4338. $receipt = new receipt ();
  4339. Doo::loadModel ( 'L_category' );
  4340. $Lcategory = new L_category ();
  4341. Doo::loadModel ( 'verify' );
  4342. Doo::loadModel ( 'statistics' );
  4343. $statistics = new statistics ();
  4344. $verify = new verify ();
  4345. Doo::loadModel ( 'staff' );
  4346. $staff = new staff ();
  4347. Doo::loadClass ( 'XDeode' );
  4348. $XDeode = new XDeode ( 5 );
  4349. $condition = "";
  4350. if ($item == "expenses")
  4351. $condition = " and Rtype=1 ";
  4352. elseif ($item == "receipts")
  4353. $condition = " and Rtype=0 ";
  4354. elseif ($item == "remits")
  4355. $condition = " and Rtype=2 ";
  4356. elseif($item =="pendImplement"){
  4357. $condition = ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  4358. }
  4359. //'and (executeCopy like "%["' . $this->staff [0] ['sid'] . '"%" and executeStaff not like "%{"' . $this->staff [0] ['sid'] . '"%" )';
  4360. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  4361. $sopString = "";
  4362. if (empty($rdate))
  4363. $dateCondition = " and Year(date) =" . $year;
  4364. else
  4365. $dateCondition=" and date_format(date,'%Y-%m-%d')='".$rdate."' ";
  4366. if ($item == 'teipts') {
  4367. $statusCon = '(status=1 or status=6 )';
  4368. $dateCondition=" and date_format(pastDate,'%Y-%m-%d')='".$rdate."' ";
  4369. } elseif ($item == 'alerpts') {
  4370. $statusCon = '(status=8 or status=9 )';
  4371. if (empty($rdate))
  4372. $dateCondition = " and Year(date) =" . $year;
  4373. else
  4374. $dateCondition=" and date_format(executeDate,'%Y-%m-%d')='".$rdate."' ";
  4375. }
  4376. /*
  4377. if ($item == 'teipts') {
  4378. $statusCon = '(status=1 or status=6 )';
  4379. $dateCondition = " and Year(pastDate) =" . $year;
  4380. if ($moth != 'MONTH')
  4381. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth;
  4382. if ($day != 'DAY')
  4383. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth . " and day(pastDate)=" . $day;
  4384. } elseif ($item == 'alerpts') {
  4385. $statusCon = '(status=8 or status=9 )';
  4386. $dateCondition = " and Year(executeDate) =" . $year;
  4387. if ($moth != 'MONTH')
  4388. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  4389. if ($day != 'DAY')
  4390. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  4391. }
  4392. */
  4393. if ($sop != 'SOP')
  4394. $sopString = " and staff=" . $sop;
  4395. // $noPassSum=$receipt->receiptByYear($year,$this->staff[0]['sid']); and (status=1 or status=6)
  4396. $receiptList = $receipt->find ( array (
  4397. 'where' => $statusCon . $condition . $dateCondition . $sopString,
  4398. 'desc' => 'rid',
  4399. 'asArray' => true
  4400. ) );
  4401. // 员工筛选
  4402. $receiptList2 = $receipt->find ( array (
  4403. 'where' => $statusCon . $condition . $dateCondition,
  4404. 'desc' => 'rid',
  4405. 'asArray' => true
  4406. ) );
  4407. $sopStaff = array ();
  4408. foreach ( $receiptList2 as $key => $value ) {
  4409. $staffDetail = $staff->getOne ( array (
  4410. 'where' => 'sid=' . $value ['staff'],
  4411. 'asArray' => true
  4412. ) );
  4413. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  4414. }
  4415. $Locate = 0;
  4416. $roleId = 0;
  4417. $button = 0;
  4418. foreach ( $receiptList as $key => $value ) {
  4419. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4420. $receiptList [$key] ['Texe'] = 'false';
  4421. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  4422. $receiptList [$key] ['Texe'] = 'true';
  4423. }
  4424. $receiptList [$key] ['TRexe'] = 'true';
  4425. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  4426. $receiptList [$key] ['TRexe'] = 'false';
  4427. }
  4428. $receiptList [$key] ['Locate'] = $Locate;
  4429. $Locate ++;
  4430. $receiptList [$key] ['reviseDetail'] = array ();
  4431. if (! empty ( $value ['reviseDetail'] ))
  4432. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4433. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4434. $categoryDetil = $Lcategory->getOne ( array (
  4435. 'where' => 'cid=' . $value ['cid'],
  4436. 'asArray' => true
  4437. ) );
  4438. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4439. // 检测编辑状态
  4440. $verifyList = $verify->getOne ( array (
  4441. 'where' => 'vid=' . $value ['verify'],
  4442. 'asArray' => true
  4443. ) );
  4444. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4445. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4446. Doo::loadModel ( 'role' );
  4447. $role = new role ();
  4448. $flag = true;
  4449. $roleKey = 0;
  4450. $endStaffArray = array ();
  4451. $roleArrayCopy = array ();
  4452. foreach ( $verifyList as $k => $v ) {
  4453. // init verifyStaff
  4454. if ($v [1] == 'ROLE') {
  4455. if (! empty ( $verifyStaff )) {
  4456. $endStaffArray = end ( $verifyStaff );
  4457. }
  4458. $roleVerify = json_decode ( $v [3], true );
  4459. $roleKey = $k;
  4460. $roleArray = array ();
  4461. $rolename = $role->getOne ( array (
  4462. 'where' => 'rid=' . $v [0],
  4463. 'asArray' => true
  4464. ) );
  4465. foreach ( $roleVerify as $o => $p ) {
  4466. $staffID = explode ( '_', $p );
  4467. $staffInfo = $staff->getOne ( array (
  4468. 'where' => 'sid=' . $staffID [0],
  4469. 'asArray' => true
  4470. ) );
  4471. $exp = array (
  4472. 0 => $staffInfo ['sid'],
  4473. 1 => $staffID [1],
  4474. 2 => $staffInfo ['avatar'],
  4475. 'date' => '',
  4476. 'date' => '',
  4477. 'opinion' => '',
  4478. 'status' => '',
  4479. 'rolename' => $rolename ['name']
  4480. );
  4481. array_push ( $roleArray, $exp );
  4482. }
  4483. $roleArrayCopy [$v [0]] = $roleArray;
  4484. }
  4485. $verifyList [$k] ['date'] = "";
  4486. $verifyList [$k] ['opinion'] = "";
  4487. $verifyList [$k] ['status'] = "";
  4488. if (empty ( $verifyStaff )) {
  4489. $verifyList [$k] ['date'] = "";
  4490. $verifyList [$k] ['opinion'] = "";
  4491. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4492. $verifyList [$k] ['status'] = 4;
  4493. $flag = false;
  4494. }
  4495. } else {
  4496. foreach ( $verifyStaff as $m => $u ) {
  4497. if ($v [0] == $m) {
  4498. $verifyList [$k] ['date'] = $u ['date'];
  4499. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4500. $verifyList [$k] ['status'] = $u ['status'];
  4501. $flag = false;
  4502. break;
  4503. }
  4504. }
  4505. $endStaffArray = end ( $verifyStaff );
  4506. }
  4507. }
  4508. $rolename ['name'] = '';
  4509. if (! empty ( $roleId )) {
  4510. Doo::loadModel ( 'role' );
  4511. $role = new role ();
  4512. $rolename = $role->getOne ( array (
  4513. 'where' => 'rid=' . $roleId,
  4514. 'asArray' => true
  4515. ) );
  4516. }
  4517. if (! empty ( $verifyStaff ))
  4518. $endStaffArray = end ( $verifyStaff );
  4519. $KOP = false;
  4520. foreach ( $roleArrayCopy as $P => $A ) {
  4521. foreach ( $A as $MKI => $AVL ) {
  4522. if (! empty ( $verifyStaff )) {
  4523. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4524. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4525. $button = 4;
  4526. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4527. }
  4528. foreach ( $verifyStaff as $m => $u ) {
  4529. $AVLFK = $AVL [0] . '_R';
  4530. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4531. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4532. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4533. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4534. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4535. break;
  4536. }
  4537. }
  4538. } else {
  4539. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4540. $button = 4;
  4541. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4542. }
  4543. }
  4544. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4545. $KOP = true;
  4546. }
  4547. }
  4548. foreach ( $roleArrayCopy as $k => $v ) {
  4549. foreach ( $verifyList as $m => $n ) {
  4550. if ($n [0] == $k) {
  4551. array_splice ( $verifyList, $m, 1, $v );
  4552. }
  4553. }
  4554. }
  4555. $receiptList [$key] ['verifyList'] = $verifyList;
  4556. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4557. 'where' => 'sid=' . $value ['staff'],
  4558. 'asArray' => true
  4559. ) );
  4560. $receiptList [$key] ['button'] = $button;
  4561. }
  4562. // print_r($receiptList);
  4563. $mothHtml = "";
  4564. for($i = 1; $i <= 12; $i ++) {
  4565. if ($moth == $i)
  4566. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4567. else
  4568. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4569. }
  4570. $dayHtml = "";
  4571. if ($day != "DAY" || $moth != "MONTH") {
  4572. for($i = 1; $i <= 31; $i ++) {
  4573. if ($day == $i)
  4574. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  4575. else
  4576. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  4577. }
  4578. }
  4579. $sopHtml = "";
  4580. foreach ( $sopStaff as $key => $value ) {
  4581. if ($sop == $key)
  4582. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4583. else
  4584. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4585. }
  4586. $data['rdate']=$rdate;
  4587. $data ['sopHtml'] = $sopHtml;
  4588. $data ['dayHtml'] = $dayHtml;
  4589. $data ['mothHtml'] = $mothHtml;
  4590. $data ['receiptList'] = $receiptList;
  4591. $data ['memu'] = "receipt";
  4592. $data ['staff'] = $this->staff;
  4593. $data ['receiptMemu'] = 'implement';
  4594. $data ['verifyId'] = $this->verifyId;
  4595. $data ['executeId'] = $this->executeId;
  4596. $data ['item'] = $item;
  4597. $data ['year'] = $year;
  4598. $data ['moth'] = $moth;
  4599. $data ['day'] = $day;
  4600. $data ['sop'] = $sop;
  4601. $this->render ( "/admin/hisImplement", $data );
  4602. }
  4603. function ajaxExamine() {
  4604. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4605. Doo::loadModel ( 'receipt' );
  4606. $receipt = new receipt ();
  4607. if (! empty ( $rid )) {
  4608. $rLRes = $receipt->find ( array (
  4609. '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,
  4610. 'asArray' => true
  4611. ) );
  4612. echo json_encode ( array (
  4613. 'status' => 1,
  4614. 'receipt' => $rLRes [0]
  4615. ) );
  4616. die ();
  4617. }
  4618. echo json_encode ( array (
  4619. 'status' => 0,
  4620. 'receipt' => array ()
  4621. ) );
  4622. die ();
  4623. }
  4624. /*
  4625. * 废弃
  4626. */
  4627. function myReceipt() {
  4628. // all approval past withdraw
  4629. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4630. if (empty ( $item ))
  4631. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4632. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4633. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  4634. Doo::loadModel ( 'receipt' );
  4635. $receipt = new receipt ();
  4636. // pre-loaded
  4637. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4638. // have cache
  4639. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  4640. if (! empty ( $moth )) // yearPage
  4641. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  4642. $this->showCache ( $path );
  4643. }
  4644. Doo::loadModel ( 'L_category' );
  4645. $Lcategory = new L_category ();
  4646. Doo::loadModel ( 'verify' );
  4647. Doo::loadModel ( 'statistics' );
  4648. $statistics = new statistics ();
  4649. $verify = new verify ();
  4650. Doo::loadModel ( 'staff' );
  4651. $staff = new staff ();
  4652. $condition = " and status!=0 ";
  4653. if ($item == "approval")
  4654. $condition = " and status=2 ";
  4655. elseif ($item == "withdraw")
  4656. $condition = " and status=3 ";
  4657. elseif ($item == "past")
  4658. $condition = " and status=1 ";
  4659. elseif ($item == "whdw")
  4660. $condition = " and status=4 ";
  4661. $dateCondition = " and Year(date) =" . $year;
  4662. if (! empty ( $moth )) {
  4663. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  4664. $stList = $statistics->getOne ( array (
  4665. 'select' => 'rePrice ,agPrice',
  4666. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  4667. 'asArray' => true
  4668. ) );
  4669. } else
  4670. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  4671. if (empty ( $stList ))
  4672. $stList = array (
  4673. 'rePrice' => 0,
  4674. 'agPrice' => 0
  4675. );
  4676. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  4677. $data ['stList'] = array (
  4678. 'rePrice' => $stList ['rePrice'],
  4679. 'agPrice' => $stList ['agPrice'],
  4680. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  4681. );
  4682. $receiptList = $receipt->find ( array (
  4683. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  4684. 'desc' => 'rid',
  4685. 'asArray' => true
  4686. ) );
  4687. $Locate = 0;
  4688. $roleId = 0;
  4689. $button = 0;
  4690. foreach ( $receiptList as $key => $value ) {
  4691. $receiptList [$key] ['Locate'] = $Locate;
  4692. $Locate ++;
  4693. $receiptList [$key] ['reviseDetail'] = array ();
  4694. if (! empty ( $value ['reviseDetail'] ))
  4695. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4696. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4697. $categoryDetil = $Lcategory->getOne ( array (
  4698. 'where' => 'cid=' . $value ['cid'],
  4699. 'asArray' => true
  4700. ) );
  4701. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4702. // 检测编辑状态
  4703. $verifyList = $verify->getOne ( array (
  4704. 'where' => 'vid=' . $value ['verify'],
  4705. 'asArray' => true
  4706. ) );
  4707. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4708. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4709. Doo::loadModel ( 'role' );
  4710. $role = new role ();
  4711. $flag = true;
  4712. $roleKey = 0;
  4713. $endStaffArray = array ();
  4714. $roleArrayCopy = array ();
  4715. foreach ( $verifyList as $k => $v ) {
  4716. // init verifyStaff
  4717. if ($v [1] == 'ROLE') {
  4718. if (! empty ( $verifyStaff )) {
  4719. $endStaffArray = end ( $verifyStaff );
  4720. // if ($v[0]==$endStaffArray['nextStaff']){
  4721. // $roleId=$v[0];
  4722. // }
  4723. }
  4724. $roleVerify = json_decode ( $v [3], true );
  4725. $roleKey = $k;
  4726. $roleArray = array ();
  4727. $rolename = $role->getOne ( array (
  4728. 'where' => 'rid=' . $v [0],
  4729. 'asArray' => true
  4730. ) );
  4731. foreach ( $roleVerify as $o => $p ) {
  4732. $staffID = explode ( '_', $p );
  4733. $staffInfo = $staff->getOne ( array (
  4734. 'where' => 'sid=' . $staffID [0],
  4735. 'asArray' => true
  4736. ) );
  4737. // print_r($staffID);
  4738. $exp = array (
  4739. 0 => $staffInfo ['sid'],
  4740. 1 => $staffID [1],
  4741. 2 => $staffInfo ['avatar'],
  4742. 'date' => '',
  4743. 'date' => '',
  4744. 'opinion' => '',
  4745. 'status' => '',
  4746. 'rolename' => $rolename ['name']
  4747. );
  4748. array_push ( $roleArray, $exp );
  4749. }
  4750. $roleArrayCopy [$v [0]] = $roleArray;
  4751. // $verifyList[$k]['roleArray']=$roleArray;
  4752. }
  4753. $verifyList [$k] ['date'] = "";
  4754. $verifyList [$k] ['opinion'] = "";
  4755. $verifyList [$k] ['status'] = "";
  4756. if (empty ( $verifyStaff )) {
  4757. $verifyList [$k] ['date'] = "";
  4758. $verifyList [$k] ['opinion'] = "";
  4759. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4760. $verifyList [$k] ['status'] = 4;
  4761. $flag = false;
  4762. }
  4763. } else {
  4764. foreach ( $verifyStaff as $m => $u ) {
  4765. if ($v [0] == $m) {
  4766. $verifyList [$k] ['date'] = $u ['date'];
  4767. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4768. $verifyList [$k] ['status'] = $u ['status'];
  4769. $flag = false;
  4770. break;
  4771. }
  4772. }
  4773. $endStaffArray = end ( $verifyStaff );
  4774. if (isset ( $endStaffArray ['ROLE'] )) {
  4775. } else {
  4776. // $endKey=key($verifyStaff);
  4777. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4778. // $button=4;
  4779. // $verifyList[$k]['status']=4;
  4780. // }
  4781. }
  4782. }
  4783. }
  4784. $rolename ['name'] = '';
  4785. if (! empty ( $roleId )) {
  4786. Doo::loadModel ( 'role' );
  4787. $role = new role ();
  4788. $rolename = $role->getOne ( array (
  4789. 'where' => 'rid=' . $roleId,
  4790. 'asArray' => true
  4791. ) );
  4792. }
  4793. if (! empty ( $verifyStaff ))
  4794. $endStaffArray = end ( $verifyStaff );
  4795. $KOP = false;
  4796. foreach ( $roleArrayCopy as $P => $A ) {
  4797. foreach ( $A as $MKI => $AVL ) {
  4798. if (! empty ( $verifyStaff )) {
  4799. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4800. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4801. $button = 4;
  4802. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4803. }
  4804. foreach ( $verifyStaff as $m => $u ) {
  4805. $AVLFK = $AVL [0] . '_R';
  4806. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4807. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4808. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4809. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4810. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4811. break;
  4812. }
  4813. }
  4814. } else {
  4815. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4816. $button = 4;
  4817. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4818. }
  4819. }
  4820. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4821. $KOP = true;
  4822. }
  4823. }
  4824. foreach ( $roleArrayCopy as $k => $v ) {
  4825. foreach ( $verifyList as $m => $n ) {
  4826. if ($n [0] == $k) {
  4827. array_splice ( $verifyList, $m, 1, $v );
  4828. }
  4829. }
  4830. }
  4831. $receiptList [$key] ['verifyList'] = $verifyList;
  4832. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4833. 'where' => 'sid=' . $value ['staff'],
  4834. 'asArray' => true
  4835. ) );
  4836. $receiptList [$key] ['button'] = $button;
  4837. }
  4838. // print_r($receiptList);die;
  4839. $mothHtml = "";
  4840. for($i = 1; $i <= 12; $i ++) {
  4841. if ($moth == $i)
  4842. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4843. else
  4844. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4845. }
  4846. $data ['mothHtml'] = $mothHtml;
  4847. $data ['receiptList'] = $receiptList;
  4848. $data ['memu'] = "receipt";
  4849. $data ['staff'] = $this->staff;
  4850. $data ['receiptMemu'] = 'receipt';
  4851. $data ['verifyId'] = $this->verifyId;
  4852. $data ['executeId'] = $this->executeId;
  4853. $data ['item'] = $item;
  4854. $data ['year'] = $year;
  4855. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4856. // sufficient condition to generate cache
  4857. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  4858. $receiptList = $receipt->find ( array (
  4859. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  4860. 'asArray' => true
  4861. ) );
  4862. if (empty ( $receiptList )) { // generated files
  4863. ob_start ();
  4864. $this->render ( "/admin/saea_myList", $data );
  4865. $this->cacheFile ( $path );
  4866. die ();
  4867. // $content = ob_get_contents();
  4868. // $fp = fopen($path, "w");
  4869. // fwrite($fp, $content);
  4870. // fclose($fp);
  4871. }
  4872. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  4873. $receiptList = $receipt->find ( array (
  4874. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  4875. 'asArray' => true
  4876. ) );
  4877. if (empty ( $receiptList )) { // generated files
  4878. ob_start ();
  4879. $this->render ( "/admin/saea_myList", $data );
  4880. $this->cacheFile ( $path );
  4881. die ();
  4882. }
  4883. }
  4884. }
  4885. $this->render ( "/admin/saea_myList", $data );
  4886. }
  4887. function saeaCreate() {
  4888. Doo::loadModel ( 'accountItem' );
  4889. Doo::loadModel ( 'verify' );
  4890. Doo::loadModel ( 'receipt' );
  4891. Doo::loadModel ( 'L_category' );
  4892. $lCategory = new L_category ();
  4893. $receipt = new receipt ();
  4894. $verify = new verify ();
  4895. $accountItem = new accountItem ();
  4896. Doo::loadModel ( "role" );
  4897. $role = new role ();
  4898. $acItem = $accountItem->find ( array (
  4899. 'asArray' => true
  4900. ) );
  4901. $veList = $verify->find ( array (
  4902. 'asArray' => true
  4903. ) );
  4904. foreach ( $veList as $key => $value ) {
  4905. $v = json_decode ( $value ['staff'] );
  4906. $list = array ();
  4907. foreach ( $v as $n => $m ) {
  4908. if ($m ['1'] == 'ROLE') {
  4909. $roleInfo = $role->getOne ( array (
  4910. 'where' => 'rid=' . $m [0],
  4911. 'asArray' => true
  4912. ) );
  4913. $v [$n] [1] = $roleInfo ['name'];
  4914. array_push ( $list, $roleInfo ['name'] );
  4915. } else {
  4916. array_push ( $list, $v [$n] [1] );
  4917. }
  4918. }
  4919. $veList [$key] ['staff'] = implode ( '>', $list );
  4920. }
  4921. $data ['category'] = $lCategory->find ( array (
  4922. 'asArray' => true
  4923. ) );
  4924. $data ['veList'] = $veList;
  4925. $data ['acItem'] = $acItem;
  4926. $data ['memu'] = "receipt";
  4927. $data ['staff'] = $this->staff;
  4928. $data ['receiptMemu'] = 'saeaBorad';
  4929. $data ['verifyId'] = $this->verifyId;
  4930. $data ['executeId'] = $this->executeId;
  4931. $this->render ( "/admin/saea_create", $data );
  4932. }
  4933. function addReceipt() {
  4934. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  4935. $agency = $this->get_args ( 'agency' );
  4936. $travel = $this->get_args ( 'travel' );
  4937. $train = $this->get_args ( 'train' );
  4938. $other = $this->get_args ( 'other' );
  4939. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  4940. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  4941. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  4942. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  4943. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  4944. Doo::loadModel ( 'receipt' );
  4945. Doo::loadModel ( 'receiptDetail' );
  4946. Doo::loadModel ( 'accountItem' );
  4947. $accountItem = new accountItem ();
  4948. $receipt = new receipt ();
  4949. Doo::loadModel ( 'enclosur' );
  4950. Doo::loadModel ( 'execute' );
  4951. $execute = new execute ();
  4952. $executeDetail = $execute->getOne ( array (
  4953. 'where' => 'mold="报销单执行人"',
  4954. 'asArray' => true
  4955. ) );
  4956. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  4957. // if(!empty($receiptDetail))
  4958. // return "/referReceipt/".$receiptDetail['rid'];
  4959. $aItem = $accountItem->find ( array (
  4960. 'asArray' => true
  4961. ) );
  4962. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  4963. $ag = $tr = $ta = $ot = 0;
  4964. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  4965. foreach ( $aItem as $key => $value ) {
  4966. if ($value ['category'] == $this->AGENCY) {
  4967. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  4968. array_push ( $accountJson [$this->AGENCY], array (
  4969. 'aid' => $value ['aid'],
  4970. 'name' => $value ['name'],
  4971. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  4972. ) );
  4973. $sum += $agency [$ag];
  4974. $agencySum += $agency [$ag];
  4975. }
  4976. $ag ++;
  4977. }
  4978. if ($value ['category'] == $this->TRAVEL) {
  4979. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  4980. array_push ( $accountJson [$this->TRAVEL], array (
  4981. 'aid' => $value ['aid'],
  4982. 'name' => $value ['name'],
  4983. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  4984. ) );
  4985. $sum += $travel [$tr];
  4986. $travelSum += $travel [$tr];
  4987. }
  4988. $tr ++;
  4989. }
  4990. if ($value ['category'] == $this->TRAIN) {
  4991. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  4992. array_push ( $accountJson [$this->TRAIN], array (
  4993. 'aid' => $value ['aid'],
  4994. 'name' => $value ['name'],
  4995. 'price' => number_format ( $train [$ta], 2, '.', '' )
  4996. ) );
  4997. $sum += $train [$ta];
  4998. $trainSum += $train [$ta];
  4999. }
  5000. $ta ++;
  5001. }
  5002. if ($value ['category'] == $this->OTHER) {
  5003. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5004. array_push ( $accountJson [$this->OTHER], array (
  5005. 'aid' => $value ['aid'],
  5006. 'name' => $value ['name'],
  5007. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5008. ) );
  5009. $sum += $other [$ot];
  5010. $otherSum += $other [$ot];
  5011. }
  5012. $ot ++;
  5013. }
  5014. }
  5015. $accountJson ['cSum'] = array (
  5016. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5017. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5018. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5019. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5020. );
  5021. // 报销单
  5022. $receipt->accountItem = json_encode ( $accountJson );
  5023. $receipt->staff = $this->staff [0] ['sid'];
  5024. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5025. $receipt->date = date ( "Y-m-d" );
  5026. $receipt->cid = $cid;
  5027. $receipt->status = 5;
  5028. // 修改审批流程加入角色
  5029. $receipt->verify = $verify;
  5030. $receipt->executeCopy = $executeDetail ['staff'];
  5031. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  5032. $receipt->explanation = $explanation;
  5033. $rid = $receipt->insert ();
  5034. // 附件
  5035. if (! empty ( $enclosurName )) {
  5036. $enclosurArray = explode ( '-', $enclosurName );
  5037. foreach ( $enclosurArray as $value ) {
  5038. $enclosur = new enclosur ();
  5039. $enclosur->name = $value;
  5040. $enclosur->rid = $rid;
  5041. $enclosur->insert ();
  5042. }
  5043. // print_r($enclosurArray);die;
  5044. }
  5045. // 报销详情
  5046. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5047. $receiptDetail = new receiptDetail ();
  5048. $receiptDetail->staff = $this->staff [0] ['sid'];
  5049. $receiptDetail->item = $value ['name'];
  5050. $receiptDetail->itemCategory = $this->AGENCY;
  5051. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5052. $receiptDetail->date = date ( "Y-m-d" );
  5053. $receiptDetail->cid = $cid;
  5054. $receiptDetail->rid = $rid;
  5055. $receiptDetail->status = 4;
  5056. $receiptDetail->insert ();
  5057. }
  5058. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5059. $receiptDetail = new receiptDetail ();
  5060. $receiptDetail->staff = $this->staff [0] ['sid'];
  5061. $receiptDetail->item = $value ['name'];
  5062. $receiptDetail->itemCategory = $this->TRAVEL;
  5063. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5064. $receiptDetail->date = date ( "Y-m-d" );
  5065. $receiptDetail->cid = $cid;
  5066. $receiptDetail->rid = $rid;
  5067. $receiptDetail->status = 4;
  5068. $receiptDetail->insert ();
  5069. }
  5070. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5071. $receiptDetail = new receiptDetail ();
  5072. $receiptDetail->staff = $this->staff [0] ['sid'];
  5073. $receiptDetail->item = $value ['name'];
  5074. $receiptDetail->itemCategory = $this->TRAIN;
  5075. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5076. $receiptDetail->date = date ( "Y-m-d" );
  5077. $receiptDetail->cid = $cid;
  5078. $receiptDetail->rid = $rid;
  5079. $receiptDetail->status = 4;
  5080. $receiptDetail->insert ();
  5081. }
  5082. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5083. $receiptDetail = new receiptDetail ();
  5084. $receiptDetail->staff = $this->staff [0] ['sid'];
  5085. $receiptDetail->item = $value ['name'];
  5086. $receiptDetail->itemCategory = $this->OTHER;
  5087. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5088. $receiptDetail->date = date ( "Y-m-d" );
  5089. $receiptDetail->cid = $cid;
  5090. $receiptDetail->rid = $rid;
  5091. $receiptDetail->status = 4;
  5092. $receiptDetail->insert ();
  5093. }
  5094. // return "/referReceipt/".$rid;
  5095. }
  5096. return "/saeaBorad";
  5097. }
  5098. function referReceipt() {
  5099. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  5100. Doo::loadModel ( 'receipt' );
  5101. Doo::loadModel ( 'verify' );
  5102. $verify = new verify ();
  5103. $receipt = new receipt ();
  5104. Doo::loadModel ( 'L_category' );
  5105. $lCategory = new L_category ();
  5106. Doo::loadModel ( "role" );
  5107. $role = new role ();
  5108. $receiptDetail = $receipt->find ( array (
  5109. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  5110. 'asArray' => true
  5111. ) );
  5112. if (empty ( $receiptDetail ))
  5113. return "/addReceipt";
  5114. foreach ( $receiptDetail as $key => $value ) {
  5115. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5116. $veList = $verify->getOne ( array (
  5117. 'where' => 'vid=' . $value ['verify'],
  5118. 'asArray' => true
  5119. ) );
  5120. $v = json_decode ( $veList ['staff'] );
  5121. array_push ( $v [0], $veList ['description'] );
  5122. foreach ( $v as $n => $m ) {
  5123. if ($m ['1'] == 'ROLE') {
  5124. $roleInfo = $role->getOne ( array (
  5125. 'where' => 'rid=' . $m [0],
  5126. 'asArray' => true
  5127. ) );
  5128. $v [$n] [1] = $roleInfo ['name'];
  5129. }
  5130. }
  5131. $receiptDetail [$key] ['staff'] = $v;
  5132. $category = $lCategory->getOne ( array (
  5133. 'where' => 'cid=' . $value ['cid'],
  5134. 'asArray' => true
  5135. ) );
  5136. $receiptDetail [$key] ['category'] = $category ['title'];
  5137. }
  5138. // print_r($receiptDetail);
  5139. $data ['receiptDetail'] = $receiptDetail;
  5140. $data ['memu'] = "receipt";
  5141. $data ['staff'] = $this->staff;
  5142. $data ['receiptMemu'] = 'saeaCreate';
  5143. $data ['verifyId'] = $this->verifyId;
  5144. $data ['executeId'] = $this->executeId;
  5145. $this->render ( "/admin/saea_confirm", $data );
  5146. }
  5147. function editReceipt() {
  5148. // edit status 4
  5149. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5150. // echo $rid;
  5151. Doo::loadModel ( 'accountItem' );
  5152. Doo::loadModel ( 'verify' );
  5153. Doo::loadModel ( 'receipt' );
  5154. $receipt = new receipt ();
  5155. $verify = new verify ();
  5156. $accountItem = new accountItem ();
  5157. Doo::loadModel ( 'L_category' );
  5158. $lCategory = new L_category ();
  5159. Doo::loadModel ( "role" );
  5160. $role = new role ();
  5161. $receiptDetail = $receipt->getOne ( array (
  5162. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  5163. 'asArray' => true
  5164. ) );
  5165. if (empty ( $receiptDetail ))
  5166. return "/saeaCreate";
  5167. $acItem = $accountItem->find ( array (
  5168. 'asArray' => true
  5169. ) );
  5170. $veList = $verify->find ( array (
  5171. 'asArray' => true
  5172. ) );
  5173. foreach ( $veList as $key => $value ) {
  5174. $v = json_decode ( $value ['staff'] );
  5175. $list = array ();
  5176. foreach ( $v as $n => $m ) {
  5177. if ($m ['1'] == 'ROLE') {
  5178. $roleInfo = $role->getOne ( array (
  5179. 'where' => 'rid=' . $m [0],
  5180. 'asArray' => true
  5181. ) );
  5182. $v [$n] [1] = $roleInfo ['name'];
  5183. array_push ( $list, $roleInfo ['name'] );
  5184. } else {
  5185. array_push ( $list, $v [$n] [1] );
  5186. }
  5187. }
  5188. $veList [$key] ['staff'] = implode ( '>', $list );
  5189. }
  5190. // 配置编辑信息
  5191. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  5192. foreach ( $acItem as $key => $value ) {
  5193. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  5194. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  5195. $acItem [$key] ['price'] = $v ['price'];
  5196. }
  5197. }
  5198. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  5199. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  5200. $acItem [$key] ['price'] = $v ['price'];
  5201. }
  5202. }
  5203. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  5204. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  5205. $acItem [$key] ['price'] = $v ['price'];
  5206. }
  5207. }
  5208. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  5209. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  5210. $acItem [$key] ['price'] = $v ['price'];
  5211. }
  5212. }
  5213. }
  5214. $data ['category'] = $lCategory->find ( array (
  5215. 'asArray' => true
  5216. ) );
  5217. $data ['cSum'] = $accountItemList ['cSum'];
  5218. $data ['sum'] = $receiptDetail ['sum'];
  5219. $data ['receiptDetail'] = $receiptDetail;
  5220. $data ['veList'] = $veList;
  5221. $data ['acItem'] = $acItem;
  5222. $data ['memu'] = "receipt";
  5223. $data ['staff'] = $this->staff;
  5224. $data ['receiptMemu'] = 'saeaBorad';
  5225. $data ['verify'] = $receiptDetail ['verify'];
  5226. $data ['verifyId'] = $this->verifyId;
  5227. $data ['executeId'] = $this->executeId;
  5228. $data ['rid'] = $rid;
  5229. $this->render ( "/admin/saea_edit", $data );
  5230. }
  5231. function updateReceipt() {
  5232. $agency = $this->get_args ( 'agency' );
  5233. $travel = $this->get_args ( 'travel' );
  5234. $train = $this->get_args ( 'train' );
  5235. $other = $this->get_args ( 'other' );
  5236. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5237. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5238. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5239. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5240. if (! empty ( $explanation )) {
  5241. Doo::loadModel ( 'receipt' );
  5242. Doo::loadModel ( 'receiptDetail' );
  5243. Doo::loadModel ( 'accountItem' );
  5244. $accountItem = new accountItem ();
  5245. $receipt = new receipt ();
  5246. Doo::loadModel ( 'execute' );
  5247. $execute = new execute ();
  5248. $receiptDetail = $receipt->getOne ( array (
  5249. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  5250. 'asArray' => true
  5251. ) );
  5252. if (empty ( $receiptDetail ))
  5253. return "/saeaBorad";
  5254. if ($receiptDetail ['Rtype'] == 1)
  5255. $executeDetail = $execute->getOne ( array (
  5256. 'where' => 'mold="借款费用执行人"',
  5257. 'asArray' => true
  5258. ) );
  5259. else
  5260. $executeDetail = $execute->getOne ( array (
  5261. 'where' => 'mold="报销单执行人"',
  5262. 'asArray' => true
  5263. ) );
  5264. $aItem = $accountItem->find ( array (
  5265. 'asArray' => true
  5266. ) );
  5267. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5268. $ag = $tr = $ta = $ot = 0;
  5269. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5270. foreach ( $aItem as $key => $value ) {
  5271. if ($value ['category'] == $this->AGENCY) {
  5272. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5273. array_push ( $accountJson [$this->AGENCY], array (
  5274. 'aid' => $value ['aid'],
  5275. 'name' => $value ['name'],
  5276. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5277. ) );
  5278. $sum += $agency [$ag];
  5279. $agencySum += $agency [$ag];
  5280. }
  5281. $ag ++;
  5282. }
  5283. if ($value ['category'] == $this->TRAVEL) {
  5284. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5285. array_push ( $accountJson [$this->TRAVEL], array (
  5286. 'aid' => $value ['aid'],
  5287. 'name' => $value ['name'],
  5288. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5289. ) );
  5290. $sum += $travel [$tr];
  5291. $travelSum += $travel [$tr];
  5292. }
  5293. $tr ++;
  5294. }
  5295. if ($value ['category'] == $this->TRAIN) {
  5296. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5297. array_push ( $accountJson [$this->TRAIN], array (
  5298. 'aid' => $value ['aid'],
  5299. 'name' => $value ['name'],
  5300. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5301. ) );
  5302. $sum += $train [$ta];
  5303. $trainSum += $train [$ta];
  5304. }
  5305. $ta ++;
  5306. }
  5307. if ($value ['category'] == $this->OTHER) {
  5308. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5309. array_push ( $accountJson [$this->OTHER], array (
  5310. 'aid' => $value ['aid'],
  5311. 'name' => $value ['name'],
  5312. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5313. ) );
  5314. $sum += $other [$ot];
  5315. $otherSum += $other [$ot];
  5316. }
  5317. $ot ++;
  5318. }
  5319. }
  5320. $accountJson ['cSum'] = array (
  5321. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5322. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5323. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5324. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5325. );
  5326. // 报销单
  5327. $rid = $receipt->rid = $receiptDetail ['rid'];
  5328. $receipt->accountItem = json_encode ( $accountJson );
  5329. $receipt->staff = $this->staff [0] ['sid'];
  5330. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5331. $receipt->date = date ( "Y-m-d" );
  5332. $receipt->cid = $cid;
  5333. if (($receiptDetail ['status'] != 4)) {
  5334. if ($receiptDetail ['Rtype'] == 1)
  5335. $receipt->status = 7;
  5336. else
  5337. $receipt->status = 5;
  5338. }
  5339. if ($receiptDetail != 4 && ! empty ( $verify ))
  5340. $receipt->verify = $verify;
  5341. $receipt->executeCopy = $executeDetail ['staff'];
  5342. $receipt->explanation = $explanation;
  5343. $receipt->update ();
  5344. $receiptDetail = new receiptDetail ();
  5345. $receiptDetail->delete ( array (
  5346. 'where' => 'rid=' . $rid
  5347. ) );
  5348. // 报销详情
  5349. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5350. $receiptDetail = new receiptDetail ();
  5351. $receiptDetail->staff = $this->staff [0] ['sid'];
  5352. $receiptDetail->item = $value ['name'];
  5353. $receiptDetail->itemCategory = $this->AGENCY;
  5354. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5355. $receiptDetail->date = date ( "Y-m-d" );
  5356. $receiptDetail->cid = $cid;
  5357. $receiptDetail->rid = $rid;
  5358. $receiptDetail->status = 4;
  5359. $receiptDetail->insert ();
  5360. }
  5361. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5362. $receiptDetail = new receiptDetail ();
  5363. $receiptDetail->staff = $this->staff [0] ['sid'];
  5364. $receiptDetail->item = $value ['name'];
  5365. $receiptDetail->itemCategory = $this->TRAVEL;
  5366. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5367. $receiptDetail->date = date ( "Y-m-d" );
  5368. $receiptDetail->cid = $cid;
  5369. $receiptDetail->rid = $rid;
  5370. $receiptDetail->status = 4;
  5371. $receiptDetail->insert ();
  5372. }
  5373. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5374. $receiptDetail = new receiptDetail ();
  5375. $receiptDetail->staff = $this->staff [0] ['sid'];
  5376. $receiptDetail->item = $value ['name'];
  5377. $receiptDetail->itemCategory = $this->TRAIN;
  5378. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5379. $receiptDetail->date = date ( "Y-m-d" );
  5380. $receiptDetail->cid = $cid;
  5381. $receiptDetail->rid = $rid;
  5382. $receiptDetail->status = 4;
  5383. $receiptDetail->insert ();
  5384. }
  5385. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5386. $receiptDetail = new receiptDetail ();
  5387. $receiptDetail->staff = $this->staff [0] ['sid'];
  5388. $receiptDetail->item = $value ['name'];
  5389. $receiptDetail->itemCategory = $this->OTHER;
  5390. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5391. $receiptDetail->date = date ( "Y-m-d" );
  5392. $receiptDetail->cid = $cid;
  5393. $receiptDetail->rid = $rid;
  5394. $receiptDetail->status = 4;
  5395. $receiptDetail->insert ();
  5396. }
  5397. // return "/referReceipt/".$rid;
  5398. }
  5399. return "/saeaBorad";
  5400. }
  5401. function approvedReceipt() {
  5402. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5403. Doo::loadModel ( 'receipt' );
  5404. Doo::loadModel ( 'receiptDetail' );
  5405. $receipt = new receipt ();
  5406. $receiptDetail = new receiptDetail ();
  5407. Doo::loadModel ( 'statistics' );
  5408. Doo::loadModel ( 'itemStatistics' );
  5409. $statistics = new statistics ();
  5410. $itemStatistics = new itemStatistics ();
  5411. Doo::loadModel ( "verify" );
  5412. $verify = new verify ();
  5413. // 审批状态的判定
  5414. $receiptDetailList = $receipt->getOne ( array (
  5415. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  5416. 'asArray' => true
  5417. ) );
  5418. if (empty ( $receiptDetailList ))
  5419. return "/saeaBorad";
  5420. $verifyDetail = $verify->getOne ( array (
  5421. 'where' => ' vid =' . $receiptDetailList ['verify'],
  5422. 'asArray' => true
  5423. ) );
  5424. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5425. if (empty ( $receiptDetailList ['nowStaff'] )) {
  5426. $nowStaff = "";
  5427. $nowStaffList = array ();
  5428. if ($verifyDetail [0] [1] == 'ROLE') {
  5429. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5430. foreach ( $vStaffString as $key => $value ) {
  5431. $staffK = explode ( "_", $value );
  5432. array_push ( $nowStaffList, $staffK [0] );
  5433. }
  5434. $nowStaff = implode ( ',', $nowStaffList );
  5435. } else {
  5436. $nowStaff = $verifyDetail [0] [0];
  5437. }
  5438. $receipt->nowStaff = $nowStaff;
  5439. }
  5440. // echo $nowStaff;
  5441. // print_r($verifyDetail);die;
  5442. $receipt->rid = $receiptDetailList ['rid'];
  5443. $receipt->date = date ( "Y-m-d" );
  5444. $receipt->status = 2;
  5445. $receipt->update ();
  5446. $receiptDetail->status = 2;
  5447. $receiptDetail->update ( array (
  5448. 'where' => 'rid=' . $receiptDetailList ['rid']
  5449. ) );
  5450. Doo::loadModel ( "receiptLog" );
  5451. $receiptLog = new receiptLog ();
  5452. Doo::loadModel ( "verify" );
  5453. $verify = new verify ();
  5454. $receiptInfo = $receipt->getOne ( array (
  5455. 'where' => 'rid=' . $rid,
  5456. 'asArray' => true
  5457. ) );
  5458. $vr = $verify->getOne ( array (
  5459. 'where' => 'vid=' . $receiptInfo ['verify'],
  5460. 'asArray' => true
  5461. ) );
  5462. $jd = json_decode ( $vr ['staff'] );
  5463. $roleId = 0;
  5464. foreach ( $jd as $key => $value ) {
  5465. if ($value [1] == 'ROLE') {
  5466. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  5467. if ($pos !== false) {
  5468. $roleId = $value [0];
  5469. }
  5470. }
  5471. }
  5472. // 审批日志
  5473. // echo $roleId;die;
  5474. if (! empty ( $roleId )) {
  5475. Doo::loadModel ( "role" );
  5476. $role = new role ();
  5477. $roleInfo = $role->getOne ( array (
  5478. 'where' => 'rid=' . $roleId,
  5479. 'asArray' => true
  5480. ) );
  5481. $receiptLog->rolename = $roleInfo ['name'];
  5482. }
  5483. $receiptLog->username = $this->staff [0] ['username'];
  5484. $receiptLog->uid = $this->staff [0] ['sid'];
  5485. $receiptLog->date = date ( "Y-m-d" );
  5486. $receiptLog->opinion = '提交审批';
  5487. $receiptLog->img = $this->staff [0] ['avatar'];
  5488. $receiptLog->status = 2;
  5489. $receiptLog->rid = $rid;
  5490. $receiptLog->insert ();
  5491. // statistics item
  5492. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  5493. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  5494. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  5495. $stat = $statistics->getOne ( array (
  5496. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5497. 'asArray' => true
  5498. ) );
  5499. if (empty ( $stat )) {
  5500. $statistics->date = date ( "Y-m-d" );
  5501. $statistics->cid = $this->staff [0] ['cid'];
  5502. $statistics->staff = $this->staff [0] ['sid'];
  5503. $statistics->agPrice = 0;
  5504. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5505. $statistics->insert ();
  5506. } else {
  5507. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5508. $statistics->update ( array (
  5509. 'where' => 'sid=' . $stat ['sid']
  5510. ) );
  5511. }
  5512. return "/expenses";
  5513. }
  5514. function approval() {
  5515. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5516. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5517. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5518. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5519. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5520. if (empty ( $status ))
  5521. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5522. $vidList = array ();
  5523. $button = 0;
  5524. Doo::loadModel ( 'verify' );
  5525. $verify = new verify ();
  5526. Doo::loadModel ( 'receipt' );
  5527. $receipt = new receipt ();
  5528. Doo::loadModel ( 'staff' );
  5529. $staff = new staff ();
  5530. Doo::loadModel ( 'L_category' );
  5531. $Lcategory = new L_category ();
  5532. // user verify ID
  5533. $verifyDetail = $verify->find ( array (
  5534. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5535. 'asArray' => true
  5536. ) );
  5537. foreach ( $verifyDetail as $key => $value ) {
  5538. array_push ( $vidList, $value ['vid'] );
  5539. }
  5540. $vid = implode ( ",", $vidList );
  5541. if (empty ( $verifyDetail ))
  5542. $vid = 0;
  5543. /*
  5544. */
  5545. $dateCondition = " and Year(date) =" . $year;
  5546. if (! empty ( $month ))
  5547. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  5548. $categoryList = $Lcategory->find ( array (
  5549. 'asArray' => true
  5550. ) );
  5551. $staffList = $staff->find ( array (
  5552. 'where' => 'cid=' . $cid,
  5553. 'asArray' => true
  5554. ) );
  5555. $cateCondition = "";
  5556. $staffCondition = "";
  5557. $approvalCondition = "";
  5558. if (! empty ( $cid ))
  5559. $cateCondition = ' and cid=' . $cid;
  5560. if (! empty ( $sid )) {
  5561. $staffCondition = ' and staff=' . $sid;
  5562. $cateCondition = "";
  5563. }
  5564. // elseif($status==1){
  5565. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  5566. // }
  5567. if ($status == 2) {
  5568. // 查找角色审批人
  5569. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  5570. }
  5571. $ap = "";
  5572. if ($status == 4) {
  5573. $ap = 4;
  5574. $status = 2;
  5575. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  5576. }
  5577. if ($status == 5) {
  5578. $status = 4;
  5579. $ap = 5;
  5580. }
  5581. // echo $vid;
  5582. // get Receipt By verifyID status 2 .$approvalCondition
  5583. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  5584. $receiptList = $receipt->find ( array (
  5585. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  5586. 'desc' => 'rid',
  5587. 'asArray' => true
  5588. ) );
  5589. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  5590. $Locate = 0;
  5591. if ($ap == 4)
  5592. $status = 4;
  5593. elseif ($ap == 5)
  5594. $status = 5;
  5595. foreach ( $receiptList as $key => $value ) {
  5596. $receiptList [$key] ['Locate'] = $Locate;
  5597. $Locate ++;
  5598. $receiptList [$key] ['reviseDetail'] = array ();
  5599. if (! empty ( $value ['reviseDetail'] ))
  5600. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5601. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5602. $categoryDetil = $Lcategory->getOne ( array (
  5603. 'where' => 'cid=' . $value ['cid'],
  5604. 'asArray' => true
  5605. ) );
  5606. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5607. $verifyList = $verify->getOne ( array (
  5608. 'where' => 'vid=' . $value ['verify'],
  5609. 'asArray' => true
  5610. ) );
  5611. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5612. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5613. foreach ( $verifyList as $k => $v ) {
  5614. // init verifyStaff
  5615. $verifyList [$k] ['date'] = "";
  5616. $verifyList [$k] ['opinion'] = "";
  5617. $verifyList [$k] ['status'] = "";
  5618. if (empty ( $verifyStaff )) {
  5619. $verifyList [$k] ['date'] = "";
  5620. $verifyList [$k] ['opinion'] = "";
  5621. if ($v [0] == $this->staff [0] ['sid']) {
  5622. $verifyList [$k] ['status'] = 4;
  5623. $button = 4;
  5624. }
  5625. } else {
  5626. $flag = true;
  5627. foreach ( $verifyStaff as $m => $u ) {
  5628. if ($v [0] == $m) {
  5629. $verifyList [$k] ['date'] = $u ['date'];
  5630. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5631. $verifyList [$k] ['status'] = $u ['status'];
  5632. $flag = false;
  5633. break;
  5634. }
  5635. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  5636. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  5637. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  5638. }
  5639. if ($flag) { // 检测可编辑
  5640. if ($v [0] == $this->staff [0] ['sid']) {
  5641. $verifyList [$k] ['status'] = 4;
  5642. $button = 4;
  5643. }
  5644. }
  5645. }
  5646. }
  5647. $receiptList [$key] ['verifyList'] = $verifyList;
  5648. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5649. 'where' => 'sid=' . $value ['staff'],
  5650. 'asArray' => true
  5651. ) );
  5652. $receiptList [$key] ['button'] = $button;
  5653. }
  5654. // print_r($receiptList);die;
  5655. // $data['verifyDetail']=$verifyDetail;
  5656. $mothHtml = "";
  5657. for($i = 1; $i <= 12; $i ++) {
  5658. if ($month == $i)
  5659. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5660. else
  5661. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5662. }
  5663. $data ['mothHtml'] = $mothHtml;
  5664. $data ['receiptList'] = $receiptList;
  5665. $data ['receiptApprovalCount'] = count ( $receiptList );
  5666. $data ['status'] = $status;
  5667. $data ['year'] = $year;
  5668. $data ['categoryList'] = $categoryList;
  5669. $data ['staffList'] = $staffList;
  5670. $data ['cid'] = $cid;
  5671. $data ['sid'] = $sid;
  5672. $data ['ap'] = $ap;
  5673. $data ['memu'] = "receipt";
  5674. $data ['staff'] = $this->staff;
  5675. $data ['receiptMemu'] = 'approval';
  5676. $data ['verifyId'] = $this->verifyId;
  5677. $data ['executeId'] = $this->executeId;
  5678. $this->render ( "/admin/saea_reportList", $data );
  5679. }
  5680. function approvalDetails() {
  5681. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5682. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5683. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5684. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5685. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5686. Doo::loadModel ( 'verify' );
  5687. $verify = new verify ();
  5688. Doo::loadModel ( 'receipt' );
  5689. $receipt = new receipt ();
  5690. Doo::loadModel ( 'staff' );
  5691. $staff = new staff ();
  5692. Doo::loadModel ( 'L_category' );
  5693. $Lcategory = new L_category ();
  5694. Doo::loadModel ( 'enclosur' );
  5695. $enclosur = new enclosur ();
  5696. $vidList = array ();
  5697. $verifyDetail = $verify->find ( array (
  5698. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5699. 'asArray' => true
  5700. ) );
  5701. foreach ( $verifyDetail as $key => $value ) {
  5702. array_push ( $vidList, $value ['vid'] );
  5703. }
  5704. $vid = implode ( ",", $vidList );
  5705. if (empty ( $verifyDetail ))
  5706. $vid = 0;
  5707. $categoryList = $Lcategory->find ( array (
  5708. 'asArray' => true
  5709. ) );
  5710. $staffList = $staff->find ( array (
  5711. 'where' => 'cid=' . $cid,
  5712. 'asArray' => true
  5713. ) );
  5714. $ap = 0;
  5715. $receiptList = $receipt->find ( array (
  5716. 'where' => 'rid =' . $rid,
  5717. 'desc' => 'rid',
  5718. 'asArray' => true
  5719. ) );
  5720. $Locate = 0;
  5721. $roleId = 0;
  5722. $button = 0;
  5723. foreach ( $receiptList as $key => $value ) {
  5724. $receiptList [$key] ['Locate'] = $Locate;
  5725. $Locate ++;
  5726. $receiptList [$key] ['reviseDetail'] = array ();
  5727. if (! empty ( $value ['reviseDetail'] ))
  5728. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5729. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5730. $categoryDetil = $Lcategory->getOne ( array (
  5731. 'where' => 'cid=' . $value ['cid'],
  5732. 'asArray' => true
  5733. ) );
  5734. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5735. // 检测编辑状态
  5736. $verifyList = $verify->getOne ( array (
  5737. 'where' => 'vid=' . $value ['verify'],
  5738. 'asArray' => true
  5739. ) );
  5740. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5741. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5742. Doo::loadModel ( 'role' );
  5743. $role = new role ();
  5744. // print_r($verifyList);
  5745. $flag = true;
  5746. $roleKey = 0;
  5747. $endStaffArray = array ();
  5748. $roleArrayCopy = array ();
  5749. foreach ( $verifyList as $k => $v ) {
  5750. // init verifyStaff
  5751. if ($v [1] == 'ROLE') {
  5752. if (! empty ( $verifyStaff )) {
  5753. $endStaffArray = end ( $verifyStaff );
  5754. if ($v [0] == $endStaffArray ['nextStaff']) {
  5755. $roleId = $v [0];
  5756. }
  5757. }
  5758. $roleVerify = json_decode ( $v [3], true );
  5759. $roleKey = $k;
  5760. $roleArray = array ();
  5761. $rolename = $role->getOne ( array (
  5762. 'where' => 'rid=' . $v [0],
  5763. 'asArray' => true
  5764. ) );
  5765. foreach ( $roleVerify as $o => $p ) {
  5766. $staffID = explode ( '_', $p );
  5767. $staffInfo = $staff->getOne ( array (
  5768. 'where' => 'sid=' . $staffID [0],
  5769. 'asArray' => true
  5770. ) );
  5771. // print_r($staffID);
  5772. $exp = array (
  5773. 0 => $staffInfo ['sid'],
  5774. 1 => $staffID [1],
  5775. 2 => $staffInfo ['avatar'],
  5776. 'date' => '',
  5777. 'date' => '',
  5778. 'opinion' => '',
  5779. 'status' => '',
  5780. 'rolename' => $rolename ['name']
  5781. );
  5782. array_push ( $roleArray, $exp );
  5783. }
  5784. $roleArrayCopy [$v [0]] = $roleArray;
  5785. // $verifyList[$k]['roleArray']=$roleArray;
  5786. }
  5787. // print_r($roleArray);
  5788. $verifyList [$k] ['date'] = "";
  5789. $verifyList [$k] ['opinion'] = "";
  5790. $verifyList [$k] ['status'] = "";
  5791. if (empty ( $verifyStaff )) {
  5792. $verifyList [$k] ['date'] = "";
  5793. $verifyList [$k] ['opinion'] = "";
  5794. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5795. $verifyList [$k] ['status'] = 4;
  5796. $button = 4;
  5797. $flag = false;
  5798. }
  5799. } else {
  5800. foreach ( $verifyStaff as $m => $u ) {
  5801. if ($v [0] == $m) {
  5802. $verifyList [$k] ['date'] = $u ['date'];
  5803. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5804. $verifyList [$k] ['status'] = $u ['status'];
  5805. $flag = false;
  5806. break;
  5807. }
  5808. }
  5809. $endStaffArray = end ( $verifyStaff );
  5810. if (isset ( $endStaffArray ['ROLE'] )) {
  5811. } else {
  5812. $endKey = key ( $verifyStaff );
  5813. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5814. $button = 4;
  5815. $verifyList [$k] ['status'] = 4;
  5816. }
  5817. }
  5818. }
  5819. }
  5820. $rolename ['name'] = '';
  5821. if (! empty ( $roleId )) {
  5822. Doo::loadModel ( 'role' );
  5823. $role = new role ();
  5824. $rolename = $role->getOne ( array (
  5825. 'where' => 'rid=' . $roleId,
  5826. 'asArray' => true
  5827. ) );
  5828. }
  5829. if (! empty ( $verifyStaff ))
  5830. $endStaffArray = end ( $verifyStaff );
  5831. $KOP = false;
  5832. foreach ( $roleArrayCopy as $P => $A ) {
  5833. foreach ( $A as $MKI => $AVL ) {
  5834. if (! empty ( $verifyStaff )) {
  5835. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5836. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5837. $button = 4;
  5838. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5839. }
  5840. foreach ( $verifyStaff as $m => $u ) {
  5841. $AVLFK = $AVL [0] . '_R';
  5842. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5843. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5844. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5845. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5846. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5847. break;
  5848. }
  5849. }
  5850. } else {
  5851. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5852. $button = 4;
  5853. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5854. }
  5855. }
  5856. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5857. $KOP = true;
  5858. }
  5859. }
  5860. foreach ( $roleArrayCopy as $k => $v ) {
  5861. foreach ( $verifyList as $m => $n ) {
  5862. if ($n [0] == $k) {
  5863. array_splice ( $verifyList, $m, 1, $v );
  5864. }
  5865. }
  5866. }
  5867. $receiptList [$key] ['verifyList'] = $verifyList;
  5868. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5869. 'where' => 'sid=' . $value ['staff'],
  5870. 'asArray' => true
  5871. ) );
  5872. $receiptList [$key] ['button'] = $button;
  5873. }
  5874. $mothHtml = "";
  5875. for($i = 1; $i <= 12; $i ++) {
  5876. if ($month == $i)
  5877. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5878. else
  5879. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5880. }
  5881. // 获取审批日志
  5882. Doo::loadModel ( 'receiptLog' );
  5883. $receiptLog = new receiptLog ();
  5884. $rlList = array ();
  5885. $rlInfo = $receiptLog->getOne ( array (
  5886. 'where' => 'rid=' . $rid . ' and status=4',
  5887. 'asArray' => true
  5888. ) );
  5889. $tijdate = $receiptLog->getOne ( array (
  5890. 'where' => 'rid=' . $rid . ' and status=2',
  5891. 'asc' => 'rlid',
  5892. 'asArray' => true
  5893. ) );
  5894. if (! empty ( $rlInfo )) {
  5895. $rlList = $receiptLog->find ( array (
  5896. 'where' => 'rid=' . $rid,
  5897. 'asc' => 'rlid',
  5898. 'asArray' => true
  5899. ) );
  5900. }
  5901. $receiptList [0] ['rlList'] = $rlList;
  5902. $enclosurList = $enclosur->find ( array (
  5903. 'where' => 'rid=' . $rid,
  5904. 'asArray' => true
  5905. ) );
  5906. $enclosurHtml = '';
  5907. foreach ( $enclosurList as $value ) {
  5908. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5909. }
  5910. $data ['enclosurHtml'] = $enclosurHtml;
  5911. $data ['rolename'] = $rolename ['name'];
  5912. $data ['datetij'] = $tijdate ['date'];
  5913. $data ['mothHtml'] = $mothHtml;
  5914. $data ['receiptList'] = $receiptList;
  5915. $data ['receiptApprovalCount'] = count ( $receiptList );
  5916. $data ['year'] = $year;
  5917. $data ['categoryList'] = $categoryList;
  5918. $data ['staffList'] = $staffList;
  5919. $data ['cid'] = $cid;
  5920. $data ['sid'] = $sid;
  5921. $data ['status'] = 0;
  5922. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  5923. $ap = 4;
  5924. } else
  5925. $data ['status'] = $receiptList [0] ['status'];
  5926. if ($receiptList [0] ['status'] == 4) {
  5927. $data ['status'] = 5;
  5928. $ap = 0;
  5929. }
  5930. $data ['ap'] = $ap;
  5931. $data ['memu'] = "receipt";
  5932. $data ['staff'] = $this->staff;
  5933. $data ['receiptMemu'] = 'approval';
  5934. $data ['verifyId'] = $this->verifyId;
  5935. $data ['executeId'] = $this->executeId;
  5936. $this->render ( "/admin/saeaReportListReport", $data );
  5937. }
  5938. function approvalEdi() {
  5939. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5940. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5941. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5942. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5943. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5944. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5945. if (empty ( $status ))
  5946. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5947. $vidList = array ();
  5948. $button = 0;
  5949. Doo::loadModel ( 'verify' );
  5950. Doo::loadModel ( 'receipt' );
  5951. Doo::loadModel ( 'staff' );
  5952. $staff = new staff ();
  5953. $receipt = new receipt ();
  5954. $verify = new verify ();
  5955. Doo::loadModel ( 'L_category' );
  5956. $Lcategory = new L_category ();
  5957. Doo::loadModel ( 'enclosur' );
  5958. $enclosur = new enclosur ();
  5959. // user verify ID
  5960. $verifyDetail = $verify->find ( array (
  5961. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5962. 'asArray' => true
  5963. ) );
  5964. foreach ( $verifyDetail as $key => $value ) {
  5965. array_push ( $vidList, $value ['vid'] );
  5966. }
  5967. $vid = implode ( ",", $vidList );
  5968. if (empty ( $verifyDetail ))
  5969. $vid = 0;
  5970. $categoryList = $Lcategory->find ( array (
  5971. 'asArray' => true
  5972. ) );
  5973. $staffList = $staff->find ( array (
  5974. 'where' => 'cid=' . $cid,
  5975. 'asArray' => true
  5976. ) );
  5977. $ap = "";
  5978. if ($status == 4) {
  5979. $ap = 4;
  5980. $status = 2;
  5981. }
  5982. // get Receipt By verifyID status 2
  5983. $receiptList = $receipt->find ( array (
  5984. 'where' => 'rid =' . $rid,
  5985. 'desc' => 'rid',
  5986. 'asArray' => true
  5987. ) );
  5988. $Locate = 0;
  5989. $roleId = 0;
  5990. if ($ap == 4)
  5991. $status = 4;
  5992. foreach ( $receiptList as $key => $value ) {
  5993. $receiptList [$key] ['Locate'] = $Locate;
  5994. $Locate ++;
  5995. $receiptList [$key] ['reviseDetail'] = array ();
  5996. if (! empty ( $value ['reviseDetail'] ))
  5997. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5998. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5999. $categoryDetil = $Lcategory->getOne ( array (
  6000. 'where' => 'cid=' . $value ['cid'],
  6001. 'asArray' => true
  6002. ) );
  6003. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6004. // 检测编辑状态
  6005. $verifyList = $verify->getOne ( array (
  6006. 'where' => 'vid=' . $value ['verify'],
  6007. 'asArray' => true
  6008. ) );
  6009. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6010. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6011. // print_r($verifyList);
  6012. //
  6013. // if (empty($verifyStaff)){
  6014. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6015. // $verifyList[0]['status']=4;$button=4;
  6016. // }
  6017. //
  6018. // }else{
  6019. //
  6020. // }
  6021. // die;
  6022. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  6023. // echo array_search("green",$a);
  6024. //
  6025. Doo::loadModel ( 'role' );
  6026. $role = new role ();
  6027. // print_r($verifyList);
  6028. $flag = true;
  6029. $roleKey = 0;
  6030. $endStaffArray = array ();
  6031. $roleArrayCopy = array ();
  6032. foreach ( $verifyList as $k => $v ) {
  6033. // init verifyStaff
  6034. if ($v [1] == 'ROLE') {
  6035. if (! empty ( $verifyStaff )) {
  6036. $endStaffArray = end ( $verifyStaff );
  6037. if ($v [0] == $endStaffArray ['nextStaff']) {
  6038. $roleId = $v [0];
  6039. }
  6040. }
  6041. $roleVerify = json_decode ( $v [3], true );
  6042. $roleKey = $k;
  6043. $roleArray = array ();
  6044. $rolename = $role->getOne ( array (
  6045. 'where' => 'rid=' . $v [0],
  6046. 'asArray' => true
  6047. ) );
  6048. foreach ( $roleVerify as $o => $p ) {
  6049. $staffID = explode ( '_', $p );
  6050. $staffInfo = $staff->getOne ( array (
  6051. 'where' => 'sid=' . $staffID [0],
  6052. 'asArray' => true
  6053. ) );
  6054. // print_r($staffID);
  6055. $exp = array (
  6056. 0 => $staffInfo ['sid'],
  6057. 1 => $staffID [1],
  6058. 2 => $staffInfo ['avatar'],
  6059. 'date' => '',
  6060. 'date' => '',
  6061. 'opinion' => '',
  6062. 'status' => '',
  6063. 'rolename' => $rolename ['name']
  6064. );
  6065. array_push ( $roleArray, $exp );
  6066. }
  6067. $roleArrayCopy [$v [0]] = $roleArray;
  6068. // $verifyList[$k]['roleArray']=$roleArray;
  6069. }
  6070. // print_r($roleArray);
  6071. $verifyList [$k] ['date'] = "";
  6072. $verifyList [$k] ['opinion'] = "";
  6073. $verifyList [$k] ['status'] = "";
  6074. if (empty ( $verifyStaff )) {
  6075. $verifyList [$k] ['date'] = "";
  6076. $verifyList [$k] ['opinion'] = "";
  6077. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6078. $verifyList [$k] ['status'] = 4;
  6079. $button = 4;
  6080. $flag = false;
  6081. }
  6082. } else {
  6083. foreach ( $verifyStaff as $m => $u ) {
  6084. if ($v [0] == $m) {
  6085. $verifyList [$k] ['date'] = $u ['date'];
  6086. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6087. $verifyList [$k] ['status'] = $u ['status'];
  6088. $flag = false;
  6089. break;
  6090. }
  6091. }
  6092. $endStaffArray = end ( $verifyStaff );
  6093. if (isset ( $endStaffArray ['ROLE'] )) {
  6094. } else {
  6095. $endKey = key ( $verifyStaff );
  6096. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6097. $button = 4;
  6098. $verifyList [$k] ['status'] = 4;
  6099. }
  6100. }
  6101. // print_r($endStaffArray);die;
  6102. // if (empty($verifyStaff)){
  6103. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6104. // $verifyList[$k]['status']=4;$button=4;
  6105. // }
  6106. //
  6107. // }else{
  6108. //
  6109. // }
  6110. // if($flag){//检测可编辑
  6111. // if($v[0]==$this->staff[0]['sid']){
  6112. // $verifyList[$k]['status']=4;$button=4;
  6113. // }
  6114. // }
  6115. }
  6116. }
  6117. $rolename ['name'] = '';
  6118. if (! empty ( $roleId )) {
  6119. Doo::loadModel ( 'role' );
  6120. $role = new role ();
  6121. $rolename = $role->getOne ( array (
  6122. 'where' => 'rid=' . $roleId,
  6123. 'asArray' => true
  6124. ) );
  6125. }
  6126. if (! empty ( $verifyStaff ))
  6127. $endStaffArray = end ( $verifyStaff );
  6128. $KOP = false;
  6129. foreach ( $roleArrayCopy as $P => $A ) {
  6130. foreach ( $A as $MKI => $AVL ) {
  6131. if (! empty ( $verifyStaff )) {
  6132. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6133. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6134. $button = 4;
  6135. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6136. }
  6137. foreach ( $verifyStaff as $m => $u ) {
  6138. $AVLFK = $AVL [0] . '_R';
  6139. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6140. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6141. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6142. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6143. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6144. break;
  6145. }
  6146. }
  6147. } else {
  6148. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6149. $button = 4;
  6150. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6151. }
  6152. }
  6153. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6154. $KOP = true;
  6155. }
  6156. }
  6157. // print_r($roleArrayCopy);
  6158. // echo $roleKey;
  6159. foreach ( $roleArrayCopy as $k => $v ) {
  6160. foreach ( $verifyList as $m => $n ) {
  6161. if ($n [0] == $k) {
  6162. array_splice ( $verifyList, $m, 1, $v );
  6163. }
  6164. }
  6165. }
  6166. // if ($KOP)
  6167. // array_splice($verifyList,$roleKey,1,$roleArray);
  6168. // print_r($verifyList);
  6169. $receiptList [$key] ['verifyList'] = $verifyList;
  6170. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6171. 'where' => 'sid=' . $value ['staff'],
  6172. 'asArray' => true
  6173. ) );
  6174. $receiptList [$key] ['button'] = $button;
  6175. }
  6176. // $data['verifyDetail']=$verifyDetail;
  6177. $mothHtml = "";
  6178. for($i = 1; $i <= 12; $i ++) {
  6179. if ($month == $i)
  6180. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6181. else
  6182. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6183. }
  6184. // 获取审批日志
  6185. Doo::loadModel ( 'receiptLog' );
  6186. $receiptLog = new receiptLog ();
  6187. $rlList = array ();
  6188. $rlInfo = $receiptLog->getOne ( array (
  6189. 'where' => 'rid=' . $rid . ' and status=4',
  6190. 'asArray' => true
  6191. ) );
  6192. $tijdate = $receiptLog->getOne ( array (
  6193. 'where' => 'rid=' . $rid . ' and status=2',
  6194. 'asc' => 'rlid',
  6195. 'asArray' => true
  6196. ) );
  6197. if (! empty ( $rlInfo )) {
  6198. $rlList = $receiptLog->find ( array (
  6199. 'where' => 'rid=' . $rid,
  6200. 'asc' => 'rlid',
  6201. 'asArray' => true
  6202. ) );
  6203. }
  6204. $receiptList [0] ['rlList'] = $rlList;
  6205. $enclosurList = $enclosur->find ( array (
  6206. 'where' => 'rid=' . $rid,
  6207. 'asArray' => true
  6208. ) );
  6209. $enclosurHtml = '';
  6210. foreach ( $enclosurList as $value ) {
  6211. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6212. }
  6213. $data ['enclosurHtml'] = $enclosurHtml;
  6214. $data ['rolename'] = $rolename ['name'];
  6215. $data ['datetij'] = $tijdate ['date'];
  6216. $data ['mothHtml'] = $mothHtml;
  6217. $data ['receiptList'] = $receiptList;
  6218. $data ['receiptApprovalCount'] = count ( $receiptList );
  6219. $data ['status'] = $status;
  6220. $data ['year'] = $year;
  6221. $data ['categoryList'] = $categoryList;
  6222. $data ['staffList'] = $staffList;
  6223. $data ['cid'] = $cid;
  6224. $data ['sid'] = $sid;
  6225. $data ['ap'] = $ap;
  6226. $data ['memu'] = "receipt";
  6227. $data ['staff'] = $this->staff;
  6228. $data ['receiptMemu'] = 'approval';
  6229. $data ['verifyId'] = $this->verifyId;
  6230. $data ['executeId'] = $this->executeId;
  6231. $this->render ( "/admin/saeaReportListReport", $data );
  6232. }
  6233. function remittanceHky() {
  6234. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6235. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  6236. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6237. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  6238. $page_size = 15;
  6239. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  6240. Doo::loadModel ( 'receipt' );
  6241. $receipt = new receipt ();
  6242. Doo::loadModel ( 'staff' );
  6243. $staff = new staff ();
  6244. $dateCondition = " and Year(executeDate) =" . $year;
  6245. if ($moth != 'MONTH')
  6246. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  6247. if ($day != 'DAY' && $moth != 'MONTH')
  6248. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  6249. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  6250. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  6251. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  6252. $limit = $pageinfo ['lower'] . ',' . $page_size;
  6253. $dayList = $receipt->find ( array (
  6254. 'select' => 'executeDate,sum(amount) as amount',
  6255. 'where' => $sql,
  6256. 'desc' => 'executeDate',
  6257. 'groupby' => 'executeDate',
  6258. 'limit' => $limit,
  6259. 'asArray' => true
  6260. ) );
  6261. // print_r($dayList);
  6262. foreach ( $dayList as $key => $value ) {
  6263. $remitString = "";
  6264. $receiptList = $receipt->find ( array (
  6265. 'select' => 'rid,executeDate,amount,staff,cid',
  6266. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  6267. 'desc' => 'executeDate',
  6268. 'asArray' => true
  6269. ) );
  6270. foreach ( $receiptList as $k => $v ) {
  6271. $sinfo = $staff->getOne ( array (
  6272. 'select' => 'username,category',
  6273. 'where' => ' sid=' . $v ['staff'],
  6274. 'asArray' => true
  6275. ) );
  6276. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  6277. }
  6278. $dayList [$key] ['staff'] = $remitString;
  6279. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  6280. }
  6281. // print_r($dayList);
  6282. $mothHtml = "";
  6283. for($i = 1; $i <= 12; $i ++) {
  6284. if ($moth == $i)
  6285. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6286. else
  6287. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6288. }
  6289. $dayHtml = "";
  6290. if ($day != "DAY" || $moth != "MONTH") {
  6291. for($i = 1; $i <= 31; $i ++) {
  6292. if ($day == $i)
  6293. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6294. else
  6295. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6296. }
  6297. }
  6298. $data ['page'] = $pageinfo;
  6299. $data ['year'] = $year;
  6300. $data ['moth'] = $moth;
  6301. $data ['day'] = $day;
  6302. $data ['get'] = $get;
  6303. $data ['dayHtml'] = $dayHtml;
  6304. $data ['mothHtml'] = $mothHtml;
  6305. $data ['receiptList'] = $dayList;
  6306. $data ['memu'] = "receipt";
  6307. $data ['staff'] = $this->staff;
  6308. $data ['receiptMemu'] = 'remittanceHky';
  6309. $data ['verifyId'] = $this->verifyId;
  6310. $data ['executeId'] = $this->executeId;
  6311. $this->render ( "/admin/remittanceHky", $data );
  6312. }
  6313. function remittancep() {
  6314. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  6315. Doo::loadModel ( 'receipt' );
  6316. $receipt = new receipt ();
  6317. Doo::loadModel ( 'staff' );
  6318. $staff = new staff ();
  6319. Doo::loadClass ( 'XDeode' );
  6320. $XDeode = new XDeode ( 5 );
  6321. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  6322. $rplist = $receipt->find ( array (
  6323. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6324. 'asArray' => true
  6325. ) );
  6326. $dayList = $receipt->find ( array (
  6327. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6328. 'desc' => 'executeDate',
  6329. 'groupby' => 'staff',
  6330. 'asArray' => true
  6331. ) );
  6332. $html = '';
  6333. foreach ( $dayList as $key => $value ) {
  6334. $sinfo = $staff->getOne ( array (
  6335. 'select' => 'username,category',
  6336. 'where' => ' sid=' . $value ['staff'],
  6337. 'asArray' => true
  6338. ) );
  6339. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  6340. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  6341. $au = 0;
  6342. foreach ( $rplist as $k => $v ) {
  6343. if ($value ['staff'] == $v ['staff']) {
  6344. $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>';
  6345. $au += $v ['amount'];
  6346. }
  6347. }
  6348. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  6349. }
  6350. $data ['html'] = $html;
  6351. $data ['memu'] = "receipt";
  6352. $data ['staff'] = $this->staff;
  6353. $data ['receiptMemu'] = 'remittanceHky';
  6354. $data ['verifyId'] = $this->verifyId;
  6355. $data ['executeId'] = $this->executeId;
  6356. $this->render ( "/admin/remittancep", $data );
  6357. }
  6358. function ajaxGetReceiptDetails() {
  6359. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  6360. Doo::loadClass ( 'XDeode' );
  6361. $XDeode = new XDeode ( 5 );
  6362. $rid = $XDeode->decode ( $rid );
  6363. if (empty ( $rid )) {
  6364. echo json_encode ( array (
  6365. 'status' => 2,
  6366. 'msg' => 'illegal request'
  6367. ) );
  6368. die ();
  6369. }
  6370. Doo::loadModel ( 'receipt' );
  6371. $receipt = new receipt ();
  6372. Doo::loadModel ( 'staff' );
  6373. $staff = new staff ();
  6374. $rinfo = $receipt->getOne ( array (
  6375. 'where' => 'rid= ' . $rid,
  6376. 'asArray' => true
  6377. ) );
  6378. $sinfo = $staff->getOne ( array (
  6379. 'select' => 'username,category',
  6380. 'where' => ' sid=' . $rinfo ['staff'],
  6381. 'asArray' => true
  6382. ) );
  6383. $rinfo ['reviseDetail'] = array ();
  6384. if (! empty ( $rinfo ['reviseDetail'] ))
  6385. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  6386. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  6387. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  6388. $rinfo ['category'] = $sinfo ['category'];
  6389. $verifyStaff = array ();
  6390. if (! empty ( $rinfo ['verifyStaff'] ))
  6391. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  6392. $relust = $rinfo ['sum'] - $rinfo ['loanSum'];
  6393. $rinfo ['relust'] = $relust;
  6394. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  6395. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  6396. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  6397. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  6398. // 费用执行人相关数据
  6399. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6400. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6401. foreach ( $executeCopy as $k => $v ) {
  6402. $executeCopy [$k] ['date'] = '';
  6403. $executeCopy [$k] ['opinion'] = '';
  6404. $executeCopy [$k] ['status'] = '';
  6405. if (! empty ( $executeStaff ))
  6406. foreach ( $executeStaff as $m => $u ) {
  6407. if ($v [0] == $m) {
  6408. $executeCopy [$k] ['date'] = $u ['date'];
  6409. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  6410. $executeCopy [$k] ['status'] = $u ['status'];
  6411. break;
  6412. }
  6413. }
  6414. }
  6415. $rinfo ['executeCopy'] = $executeCopy;
  6416. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  6417. if ($rinfo ['Rtype'] == 1) { // 借款费用
  6418. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6419. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  6420. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  6421. $html .= '<tr><th>' . $value ['name'] . '</th>
  6422. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6423. }
  6424. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6425. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6426. <tr><th class="taC" colspan="2">费用说明</th>
  6427. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6428. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6429. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  6430. </tbody></table>';
  6431. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  6432. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6433. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6434. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6435. $html .= '<tr><th>' . $value ['name'] . '</th>
  6436. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6437. }
  6438. $html .= '<tr><th class="taR">合计</th>
  6439. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6440. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6441. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6442. $html .= '<tr><th>' . $value ['name'] . '</th>
  6443. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6444. }
  6445. $html .= '<tr><th class="taR">合计</th>
  6446. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6447. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6448. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6449. $html .= '<tr><th>' . $value ['name'] . '</th>
  6450. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6451. }
  6452. $html .= '<tr><th class="taR">合计</th>
  6453. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6454. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6455. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6456. $html .= '<tr><th>' . $value ['name'] . '</th>
  6457. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6458. }
  6459. $html .= '<tr><th class="taR">合计</th>
  6460. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6461. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6462. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6463. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6464. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6465. }
  6466. $html .= '<tr><th class="taR">合计</th>
  6467. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6468. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6469. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6470. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6471. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6472. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6473. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6474. <tr';
  6475. if ($rinfo ['relust'] >= 0) {
  6476. $html .= 'class="success"';
  6477. } else {
  6478. $html .= 'class="error"';
  6479. }
  6480. $html .= '><td class="taR"><b>借款结余</b></td>
  6481. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  6482. </tbody></table>
  6483. ';
  6484. }
  6485. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  6486. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6487. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  6488. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6489. $html .= '<tr><th>' . $value ['name'] . '</th>
  6490. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6491. }
  6492. $html .= '<tr><th class="taR">合计</th>
  6493. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6494. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6495. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6496. <tr><th class="taC" colspan="2">费用说明</th>
  6497. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6498. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6499. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6500. </tbody></table>';
  6501. } else {
  6502. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6503. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6504. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6505. $html .= '<tr><th>' . $value ['name'] . '</th>
  6506. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6507. }
  6508. $html .= '<tr><th class="taR">合计</th>
  6509. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6510. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6511. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6512. $html .= '<tr><th>' . $value ['name'] . '</th>
  6513. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6514. }
  6515. $html .= '<tr><th class="taR">合计</th>
  6516. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6517. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6518. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6519. $html .= '<tr><th>' . $value ['name'] . '</th>
  6520. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6521. }
  6522. $html .= '<tr><th class="taR">合计</th>
  6523. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6524. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6525. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6526. $html .= '<tr><th>' . $value ['name'] . '</th>
  6527. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6528. }
  6529. $html .= '<tr><th class="taR">合计</th>
  6530. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6531. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6532. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6533. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6534. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6535. }
  6536. $html .= '<tr><th class="taR">合计</th>
  6537. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6538. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6539. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6540. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6541. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6542. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6543. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  6544. $html .= '</tbody></table>';
  6545. /*
  6546. * <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>
  6547. * <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>
  6548. * <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>
  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.otherSum}}</td></tr>
  6550. * <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>
  6551. * <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>
  6552. * </tbody> </table>
  6553. */
  6554. }
  6555. // print_r($verifyStaff);die;
  6556. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  6557. foreach ( $verifyStaff as $key => $value ) {
  6558. $key = trim ( strtr ( $key, '_R', ' ' ) );
  6559. $sinfo = $staff->getOne ( array (
  6560. 'select' => 'username',
  6561. 'where' => ' sid=' . $key,
  6562. 'asArray' => true
  6563. ) );
  6564. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6565. }
  6566. $html .= '</tbody></table>';
  6567. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  6568. foreach ( $rinfo ['executeCopy'] as $value ) {
  6569. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6570. }
  6571. $html .= '</tbody></table>';
  6572. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  6573. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  6574. </tr></table>';
  6575. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  6576. echo json_encode ( array (
  6577. 'status' => 1,
  6578. 'html' => $html
  6579. ) );
  6580. die ();
  6581. }
  6582. function remittance() {
  6583. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6584. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6585. Doo::loadModel ( 'receipt' );
  6586. $receipt = new receipt ();
  6587. Doo::loadModel ( 'staff' );
  6588. $staff = new staff ();
  6589. $dateCondition = " and Year(pastDate) =" . $year;
  6590. if (! empty ( $month ))
  6591. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  6592. // get Receipt By verifyID status 1
  6593. $receiptList = $receipt->find ( array (
  6594. 'select' => 'sum(sum) as sum,staff,pastDate',
  6595. 'where' => ' status=1' . $dateCondition,
  6596. 'desc' => 'pastDate',
  6597. 'groupby' => 'staff,pastDate',
  6598. 'asArray' => true
  6599. ) );
  6600. $dateList = $receipt->find ( array (
  6601. 'select' => 'pastDate,verifyStaff',
  6602. 'where' => ' status=1' . $dateCondition,
  6603. 'desc' => 'pastDate',
  6604. 'groupby' => 'pastDate',
  6605. 'asArray' => true
  6606. ) );
  6607. $dataList = array ();
  6608. foreach ( $dateList as $d => $a ) {
  6609. $dataList [$a ['pastDate']] = array ();
  6610. $daySum = 0;
  6611. foreach ( $receiptList as $key => $value ) {
  6612. if ($a ['pastDate'] == $value ['pastDate']) {
  6613. $oderList = $receipt->find ( array (
  6614. 'select' => 'receiptOrder',
  6615. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  6616. 'asArray' => true
  6617. ) );
  6618. $list = array ();
  6619. $html = "";
  6620. foreach ( $oderList as $v ) {
  6621. array_push ( $list, $v ['receiptOrder'] );
  6622. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  6623. }
  6624. $receiptList [$key] ['receiptOrder'] = $html;
  6625. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  6626. $sinfo = $staff->getOne ( array (
  6627. 'select' => 'username ',
  6628. 'where' => ' sid=' . $value ['staff'],
  6629. 'asArray' => true
  6630. ) );
  6631. $receiptList [$key] ['username'] = $sinfo ['username'];
  6632. $daySum += $value ['sum'];
  6633. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  6634. }
  6635. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  6636. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  6637. }
  6638. }
  6639. // print_r($dataList);
  6640. $data ['dataList'] = $dataList;
  6641. $mothHtml = "";
  6642. for($i = 1; $i <= 12; $i ++) {
  6643. if ($month == $i)
  6644. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6645. else
  6646. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6647. }
  6648. $data ['year'] = $year;
  6649. $data ['mothHtml'] = $mothHtml;
  6650. $data ['memu'] = "receipt";
  6651. $data ['staff'] = $this->staff;
  6652. $data ['receiptMemu'] = 'approval';
  6653. $data ['verifyId'] = $this->verifyId;
  6654. $data ['executeId'] = $this->executeId;
  6655. $this->render ( "/admin/saeaReportListPay", $data );
  6656. }
  6657. function revocationAdjustment() {
  6658. $sid = isset ( $this->params ['sid'] ) && is_numeric ( $this->params ['sid'] ) ? $this->params ['sid'] : 0;
  6659. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  6660. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6661. // echo $price;die;
  6662. if ((! empty ( $sid )) && ($price != - 99999) && (! empty ( $rid ))) {
  6663. Doo::loadModel ( 'receipt' );
  6664. $receipt = new receipt ();
  6665. $receiptDetail = $receipt->getOne ( array (
  6666. 'where' => 'rid=' . $rid,
  6667. 'asArray' => true
  6668. ) );
  6669. if (empty ( $receiptDetail ['reviseDetail'] ))
  6670. return "/approval";
  6671. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  6672. $RD = array ();
  6673. foreach ( $reviseDetail as $key => $value ) {
  6674. if ($value ['price'] == $price && $value ['sid'] == $sid)
  6675. continue;
  6676. array_push ( $RD, $value );
  6677. }
  6678. $reviseDetailString = json_encode ( $RD );
  6679. $receipt->reviseDetail = $reviseDetailString;
  6680. $receipt->sum = $receiptDetail ['sum'] - $price;
  6681. $receipt->revisePrice = $receiptDetail ['revisePrice'] - $price;
  6682. $receipt->update ( array (
  6683. 'where' => 'rid=' . $rid
  6684. ) );
  6685. }
  6686. // approvalEdi/37
  6687. return "/approvalEdi/" . $rid;
  6688. }
  6689. function updateApprovalReceipt() {
  6690. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6691. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  6692. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6693. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  6694. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  6695. if (! empty ( $rid )) {
  6696. Doo::loadModel ( "verify" );
  6697. $verify = new verify ();
  6698. Doo::loadModel ( "receiptDetail" );
  6699. $receiptDetailObj = new receiptDetail ();
  6700. Doo::loadModel ( "itemStatistics" );
  6701. Doo::loadModel ( "statistics" );
  6702. $statistics = new statistics ();
  6703. $itemStatistics = new itemStatistics ();
  6704. Doo::loadModel ( "receipt" );
  6705. $receipt = new receipt ();
  6706. $receiptDetail = $receipt->getOne ( array (
  6707. 'where' => 'rid=' . $rid . ' and status=2 ',
  6708. 'asArray' => true
  6709. ) );
  6710. if (empty ( $receiptDetail ))
  6711. return "/approval";
  6712. $verifyDetail = $verify->getOne ( array (
  6713. 'where' => ' vid =' . $receiptDetail ['verify'],
  6714. 'asArray' => true
  6715. ) );
  6716. $verifyString = $verifyDetail ['staff'];
  6717. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  6718. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  6719. if (empty ( $opinion )) {
  6720. if ($status == 3)
  6721. $opinion = "终止";
  6722. else
  6723. $opinion = "同意支付";
  6724. }
  6725. $nowStaff = 0;
  6726. $nowStaffList = array ();
  6727. if (empty ( $verifyStaff )) {
  6728. // 还需加入是否已经进入角色审批
  6729. if ($verifyDetail [0] [1] == 'ROLE') {
  6730. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  6731. foreach ( $vStaffString as $key => $value ) {
  6732. $staffK = explode ( "_", $value );
  6733. if ($staffK [0] != $this->staff [0] ['sid'])
  6734. array_push ( $nowStaffList, $staffK [0] );
  6735. }
  6736. // print_r($verifyDetail);
  6737. // die;
  6738. if (! empty ( $nowStaffList )) {
  6739. $nowStaff = implode ( ',', $nowStaffList );
  6740. $verifyStaff = array (
  6741. $this->staff [0] ['sid'] . "_R" => array (
  6742. 'date' => date ( 'Y-m-d' ),
  6743. 'opinion' => $opinion,
  6744. 'status' => $status,
  6745. 'nextStaff' => $verifyDetail [0] [0],
  6746. 'ROLE' => 1
  6747. )
  6748. );
  6749. } else {
  6750. $nowStaff = $verifyDetail [1] [0];
  6751. $verifyStaff = array (
  6752. $this->staff [0] ['sid'] . "_R" => array (
  6753. 'date' => date ( 'Y-m-d' ),
  6754. 'opinion' => $opinion,
  6755. 'status' => $status,
  6756. 'nextStaff' => $verifyDetail [1] [0]
  6757. )
  6758. );
  6759. }
  6760. } else {
  6761. if ($verifyDetail [1] [1] == 'ROLE') {
  6762. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  6763. // echo "dd";
  6764. foreach ( $vStaffString as $key => $value ) {
  6765. $staffK = explode ( "_", $value );
  6766. array_push ( $nowStaffList, $staffK [0] );
  6767. }
  6768. $nowStaff = implode ( ',', $nowStaffList );
  6769. $verifyStaff = array (
  6770. $this->staff [0] ['sid'] => array (
  6771. 'date' => date ( 'Y-m-d' ),
  6772. 'opinion' => $opinion,
  6773. 'status' => $status,
  6774. 'nextStaff' => $verifyDetail [1] [0],
  6775. 'ROLE' => 1
  6776. )
  6777. );
  6778. } else {
  6779. $nowStaff = $verifyDetail [1] [0];
  6780. $verifyStaff = array (
  6781. $this->staff [0] ['sid'] => array (
  6782. 'date' => date ( 'Y-m-d' ),
  6783. 'opinion' => $opinion,
  6784. 'status' => $status,
  6785. 'nextStaff' => $verifyDetail [1] [0]
  6786. )
  6787. );
  6788. }
  6789. }
  6790. if ($status == 3)
  6791. $verifyStaff = array (
  6792. 'final' => $status,
  6793. $this->staff [0] ['sid'] => array (
  6794. 'date' => date ( 'Y-m-d' ),
  6795. 'opinion' => $opinion,
  6796. 'status' => $status
  6797. )
  6798. );
  6799. $vStaffString = json_encode ( $verifyStaff );
  6800. $receipt->nowStaff = $nowStaff;
  6801. $receipt->verifyStaff = $vStaffString;
  6802. } else {
  6803. $VS = end ( $verifyStaff );
  6804. // 非角色审批
  6805. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  6806. $nextStaff = 0;
  6807. $roleSTF = false;
  6808. foreach ( $verifyDetail as $key => $value ) {
  6809. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  6810. if (isset ( $verifyDetail [$key + 1] )) {
  6811. $nextStaff = $verifyDetail [$key + 1] [0];
  6812. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  6813. $roleSTF = true;
  6814. }
  6815. break;
  6816. }
  6817. }
  6818. if (! $roleSTF) {
  6819. $nowStaff = $nextStaff;
  6820. $verifyStaff [$this->staff [0] ['sid']] = array (
  6821. 'date' => date ( 'Y-m-d' ),
  6822. 'opinion' => $opinion,
  6823. 'status' => $status,
  6824. 'nextStaff' => $nextStaff
  6825. );
  6826. } else {
  6827. // 获取角色下的所有用户ID
  6828. $nowStaffList = array ();
  6829. foreach ( $verifyDetail as $vfk ) {
  6830. if ($vfk [1] == 'ROLE') {
  6831. $vStaffString = json_decode ( $vfk [3] );
  6832. foreach ( $vStaffString as $key => $value ) {
  6833. $staffK = explode ( "_", $value );
  6834. array_push ( $nowStaffList, $staffK [0] );
  6835. }
  6836. }
  6837. }
  6838. $nowStaff = implode ( ',', $nowStaffList );
  6839. $verifyStaff [$this->staff [0] ['sid']] = array (
  6840. 'date' => date ( 'Y-m-d' ),
  6841. 'opinion' => $opinion,
  6842. 'status' => $status,
  6843. 'nextStaff' => $nextStaff,
  6844. 'ROLE' => 0
  6845. );
  6846. }
  6847. if ($status == 3) {
  6848. $verifyStaff ['final'] = $status;
  6849. $verifyStaff [$this->staff [0] ['sid']] = array (
  6850. 'date' => date ( 'Y-m-d' ),
  6851. 'opinion' => $opinion,
  6852. 'status' => $status
  6853. );
  6854. }
  6855. $vStaffString = json_encode ( $verifyStaff );
  6856. $receipt->nowStaff = $nowStaff;
  6857. $receipt->verifyStaff = $vStaffString;
  6858. }
  6859. // 角色审批
  6860. if (isset ( $VS ['ROLE'] )) {
  6861. // 找出角色人 当前审批角色组
  6862. $verifyJSStaff = array ();
  6863. $nowStaffList2 = array ();
  6864. foreach ( $verifyDetail as $key => $value ) {
  6865. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  6866. $verifyJSStaff = json_decode ( $value [3] );
  6867. foreach ( $verifyJSStaff as $m ) {
  6868. $staffK = explode ( "_", $m );
  6869. array_push ( $nowStaffList2, $staffK [0] );
  6870. }
  6871. // print_r($nowStaffList2);
  6872. }
  6873. }
  6874. $RoleVerifyStaff = array ();
  6875. foreach ( $verifyStaff as $key => $value ) {
  6876. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  6877. foreach ( $nowStaffList2 as $m ) {
  6878. if ($key == $m . "_R")
  6879. $RoleVerifyStaff [$key] = $value;
  6880. }
  6881. }
  6882. }
  6883. // print_r($verifyStaff);
  6884. // print_r($nowStaffList2);
  6885. // print_r($RoleVerifyStaff);
  6886. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  6887. // print_r($verifyJSStaff);
  6888. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  6889. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  6890. // 下一个审批人ID
  6891. $nextStaff = 0;
  6892. $falg = false;
  6893. foreach ( $verifyDetail as $key => $value ) {
  6894. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  6895. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  6896. $falg = true;
  6897. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  6898. $nowStaffList = array ();
  6899. foreach ( $vStaffString as $v ) {
  6900. $staffK = explode ( "_", $v );
  6901. array_push ( $nowStaffList, $staffK [0] );
  6902. }
  6903. $nowStaff = implode ( ',', $nowStaffList );
  6904. $nextStaff = $verifyDetail [$key + 1] [0];
  6905. } elseif (isset ( $verifyDetail [$key + 1] )) {
  6906. $nextStaff = $verifyDetail [$key + 1] [0];
  6907. $nowStaff = $nextStaff;
  6908. } else
  6909. $nowStaff = '';
  6910. break;
  6911. }
  6912. }
  6913. if ($falg)
  6914. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6915. 'date' => date ( 'Y-m-d' ),
  6916. 'opinion' => $opinion,
  6917. 'status' => $status,
  6918. 'nextStaff' => $nextStaff,
  6919. 'ROLE' => 1
  6920. );
  6921. else
  6922. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6923. 'date' => date ( 'Y-m-d' ),
  6924. 'opinion' => $opinion,
  6925. 'status' => $status,
  6926. 'nextStaff' => $nextStaff
  6927. );
  6928. // print_r($verifyStaff);
  6929. // echo $nowStaff;die;
  6930. } else { // 进入下一个角色或者审批人
  6931. /*
  6932. *
  6933. */
  6934. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  6935. //
  6936. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  6937. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6938. 'date' => date ( 'Y-m-d' ),
  6939. 'opinion' => $opinion,
  6940. 'status' => $status,
  6941. 'nextStaff' => $VS ['nextStaff'],
  6942. 'ROLE' => 1
  6943. );
  6944. // print_r($verifyStaff);
  6945. // die;
  6946. }
  6947. if ($status == 3) {
  6948. $verifyStaff ['final'] = $status;
  6949. $verifyStaff [$this->staff [0] ['sid']] = array (
  6950. 'date' => date ( 'Y-m-d' ),
  6951. 'opinion' => $opinion,
  6952. 'status' => $status
  6953. );
  6954. }
  6955. $vStaffString = json_encode ( $verifyStaff );
  6956. $receipt->verifyStaff = $vStaffString;
  6957. $receipt->nowStaff = $nowStaff;
  6958. // die;
  6959. // }
  6960. // print_r($verifyStaff);
  6961. // die;
  6962. }
  6963. // print_r($verifyStaff);die;
  6964. }
  6965. // print_r($verifyDetail);
  6966. $roleKey = 0;
  6967. $roleId = 0;
  6968. $verifyDetailCopy = array ();
  6969. foreach ( $verifyDetail as $k => $v ) {
  6970. if ($v [1] == 'ROLE') {
  6971. $roleId = $v [0];
  6972. $roleVerify = json_decode ( $v [3], true );
  6973. $roleKey = $k;
  6974. $roleArray = array ();
  6975. foreach ( $roleVerify as $o => $p ) {
  6976. $staffID = explode ( '_', $p );
  6977. $exp = array (
  6978. 0 => $staffID [0],
  6979. 1 => $staffID [1]
  6980. );
  6981. array_push ( $roleArray, $exp );
  6982. }
  6983. $verifyDetailCopy [$v [0]] = $roleArray;
  6984. }
  6985. }
  6986. // print_r($verifyDetail);
  6987. foreach ( $verifyDetailCopy as $k => $v ) {
  6988. foreach ( $verifyDetail as $m => $n ) {
  6989. if ($n [0] == $k) {
  6990. array_splice ( $verifyDetail, $m, 1, $v );
  6991. }
  6992. }
  6993. }
  6994. // die;
  6995. // if (!empty($roleArray))
  6996. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  6997. // echo $roleId;
  6998. // print_r($verifyStaff);
  6999. // print_r($verifyDetail);
  7000. // die;
  7001. Doo::loadModel ( "receiptLog" );
  7002. $receiptLog = new receiptLog ();
  7003. // 审批日志
  7004. if (! isset ( $verifyStaff ['final'] )) {
  7005. if (! empty ( $roleId )) {
  7006. Doo::loadModel ( "role" );
  7007. $role = new role ();
  7008. $roleInfo = $role->getOne ( array (
  7009. 'where' => 'rid=' . $roleId,
  7010. 'asArray' => true
  7011. ) );
  7012. $receiptLog->rolename = $roleInfo ['name'];
  7013. }
  7014. $receiptLog->username = $this->staff [0] ['username'];
  7015. $receiptLog->uid = $this->staff [0] ['sid'];
  7016. $receiptLog->date = date ( "Y-m-d" );
  7017. $receiptLog->opinion = $opinion;
  7018. $receiptLog->img = $this->staff [0] ['avatar'];
  7019. $receiptLog->status = 1;
  7020. $receiptLog->rid = $rid;
  7021. $receiptLog->insert ();
  7022. }
  7023. if (isset ( $verifyStaff ['final'] )) { // rDetail
  7024. $receipt->verifyBreakup = $verifyString;
  7025. $receipt->status = 3;
  7026. $receiptDetailObj->status = 3;
  7027. $receiptDetailObj->update ( array (
  7028. 'where' => 'rid=' . $rid
  7029. ) );
  7030. if (! empty ( $roleId )) {
  7031. Doo::loadModel ( "role" );
  7032. $role = new role ();
  7033. $roleInfo = $role->getOne ( array (
  7034. 'where' => 'rid=' . $roleId,
  7035. 'asArray' => true
  7036. ) );
  7037. $receiptLog->rolename = $roleInfo ['name'];
  7038. }
  7039. $receiptLog->username = $this->staff [0] ['username'];
  7040. $receiptLog->uid = $this->staff [0] ['sid'];
  7041. $receiptLog->date = date ( "Y-m-d" );
  7042. $receiptLog->opinion = $opinion;
  7043. $receiptLog->img = $this->staff [0] ['avatar'];
  7044. $receiptLog->status = 3;
  7045. $receiptLog->rid = $rid;
  7046. $receiptLog->insert ();
  7047. // 微信企业号通知
  7048. $this->setWXMsg ( $rid, 3 );
  7049. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  7050. $receipt->status = 1;
  7051. $reviseSum = 0;
  7052. $receipt->verifyBreakup = $verifyString;
  7053. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  7054. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7055. foreach ( $reviseDetail as $key => $value ) {
  7056. $receiptDetailObj = new receiptDetail ();
  7057. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7058. $receiptDetailObj->item = $value ['description'];
  7059. $receiptDetailObj->itemCategory = "报销金额调整";
  7060. $receiptDetailObj->price = $value ['price'];
  7061. $receiptDetailObj->date = $receiptDetail ['date'];
  7062. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  7063. $receiptDetailObj->rid = $rid;
  7064. $receiptDetailObj->status = 1;
  7065. $receiptDetailObj->insert ();
  7066. $reviseSum += $value ['price'];
  7067. }
  7068. $itemStatistics = new itemStatistics ();
  7069. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7070. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7071. $itemStatistics->price = $reviseSum;
  7072. $itemStatistics->itemCategory = "报销金额调整";
  7073. $itemStatistics->date = $receiptDetail ['date'];
  7074. $itemStatistics->insert ();
  7075. }
  7076. $receiptDetailObj = new receiptDetail ();
  7077. $receiptDetailObj->status = 1;
  7078. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  7079. $receiptDetailObj->update ( array (
  7080. 'where' => 'rid=' . $rid
  7081. ) );
  7082. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7083. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7084. $stat = $statistics->getOne ( array (
  7085. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  7086. 'asArray' => true
  7087. ) );
  7088. if (empty ( $stat )) {
  7089. $statistics->date = $receiptDetail ['date'];
  7090. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7091. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7092. $statistics->agPrice = $receiptDetail ['sum'];
  7093. $statistics->rePrice = $reviseSum;
  7094. $statistics->insert ();
  7095. } else {
  7096. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  7097. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  7098. $statistics->update ( array (
  7099. 'where' => 'sid=' . $stat ['sid']
  7100. ) );
  7101. }
  7102. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7103. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7104. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  7105. foreach ( $accountItem ['cSum'] as $key => $value ) {
  7106. if ($key == "agencySum") {
  7107. $iStatistics = $itemStatistics->getOne ( array (
  7108. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  7109. 'asArray' => true
  7110. ) );
  7111. if (empty ( $iStatistics )) {
  7112. $itemStatistics->cid = $receiptDetail ['cid'];
  7113. ;
  7114. $itemStatistics->staff = $receiptDetail ['staff'];
  7115. $itemStatistics->price = $value;
  7116. $itemStatistics->itemCategory = $this->AGENCY;
  7117. $itemStatistics->date = $receiptDetail ['date'];
  7118. $itemStatistics->insert ();
  7119. } else {
  7120. if (! empty ( $value )) {
  7121. $itemStatistics->price = $value + $iStatistics ['price'];
  7122. $itemStatistics->update ( array (
  7123. 'where' => 'sid=' . $iStatistics ['sid']
  7124. ) );
  7125. }
  7126. }
  7127. } elseif ($key == "travelSum") {
  7128. $iStatistics = $itemStatistics->getOne ( array (
  7129. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  7130. 'asArray' => true
  7131. ) );
  7132. if (empty ( $iStatistics )) {
  7133. $itemStatistics->cid = $receiptDetail ['cid'];
  7134. $itemStatistics->staff = $receiptDetail ['staff'];
  7135. $itemStatistics->price = $value;
  7136. $itemStatistics->itemCategory = $this->TRAVEL;
  7137. $itemStatistics->date = $receiptDetail ['date'];
  7138. $itemStatistics->insert ();
  7139. } else {
  7140. if (! empty ( $value )) {
  7141. $itemStatistics->price = $value + $iStatistics ['price'];
  7142. $itemStatistics->update ( array (
  7143. 'where' => 'sid=' . $iStatistics ['sid']
  7144. ) );
  7145. }
  7146. }
  7147. } elseif ($key == "trainSum") {
  7148. $iStatistics = $itemStatistics->getOne ( array (
  7149. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  7150. 'asArray' => true
  7151. ) );
  7152. if (empty ( $iStatistics )) {
  7153. $itemStatistics->cid = $receiptDetail ['cid'];
  7154. $itemStatistics->staff = $receiptDetail ['staff'];
  7155. $itemStatistics->price = $value;
  7156. $itemStatistics->itemCategory = $this->TRAIN;
  7157. $itemStatistics->date = $receiptDetail ['date'];
  7158. $itemStatistics->insert ();
  7159. } else {
  7160. if (! empty ( $value )) {
  7161. $itemStatistics->price = $value + $iStatistics ['price'];
  7162. $itemStatistics->update ( array (
  7163. 'where' => 'sid=' . $iStatistics ['sid']
  7164. ) );
  7165. }
  7166. }
  7167. } elseif ($key == "otherSum") {
  7168. $iStatistics = $itemStatistics->getOne ( array (
  7169. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  7170. 'asArray' => true
  7171. ) );
  7172. if (empty ( $iStatistics )) {
  7173. $itemStatistics->cid = $receiptDetail ['cid'];
  7174. $itemStatistics->staff = $receiptDetail ['staff'];
  7175. $itemStatistics->price = $value;
  7176. $itemStatistics->itemCategory = $this->OTHER;
  7177. $itemStatistics->date = $receiptDetail ['date'];
  7178. $itemStatistics->insert ();
  7179. } else {
  7180. if (! empty ( $value )) {
  7181. $itemStatistics->price = $value + $iStatistics ['price'];
  7182. $itemStatistics->update ( array (
  7183. 'where' => 'sid=' . $iStatistics ['sid']
  7184. ) );
  7185. }
  7186. }
  7187. }
  7188. }
  7189. $receipt->pastDate = date ( "Y-m-d" );
  7190. // 微信企业号通知
  7191. $this->setWXMsg ( $rid, 1 );
  7192. }
  7193. $receipt->amount = $amount;
  7194. $receipt->update ( array (
  7195. 'where' => ' rid = ' . $rid
  7196. ) );
  7197. return "/approvalExpenses/pendApproval";
  7198. }
  7199. }
  7200. function expensesRetreats() {
  7201. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7202. if (! empty ( $rid )) {
  7203. // 操作记录
  7204. Doo::loadModel ( "receipt" );
  7205. $receipt = new receipt ();
  7206. Doo::loadModel ( "receiptLog" );
  7207. $receiptLog = new receiptLog ();
  7208. Doo::loadModel ( "verify" );
  7209. $verify = new verify ();
  7210. $receiptInfo = $receipt->getOne ( array (
  7211. 'where' => 'rid=' . $rid,
  7212. 'asArray' => true
  7213. ) );
  7214. $vr = $verify->getOne ( array (
  7215. 'where' => 'vid=' . $receiptInfo ['verify'],
  7216. 'asArray' => true
  7217. ) );
  7218. $jd = json_decode ( $vr ['staff'] );
  7219. $roleId = 0;
  7220. foreach ( $jd as $key => $value ) {
  7221. if ($value [1] == 'ROLE') {
  7222. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7223. if ($pos !== false) {
  7224. $roleId = $value [0];
  7225. }
  7226. }
  7227. }
  7228. // 审批日志
  7229. // echo $roleId;die;
  7230. if (! empty ( $roleId )) {
  7231. Doo::loadModel ( "role" );
  7232. $role = new role ();
  7233. $roleInfo = $role->getOne ( array (
  7234. 'where' => 'rid=' . $roleId,
  7235. 'asArray' => true
  7236. ) );
  7237. $receiptLog->rolename = $roleInfo ['name'];
  7238. }
  7239. $receiptLog->username = $this->staff [0] ['username'];
  7240. $receiptLog->uid = $this->staff [0] ['sid'];
  7241. $receiptLog->date = date ( "Y-m-d" );
  7242. $receiptLog->opinion = '撤回';
  7243. $receiptLog->img = $this->staff [0] ['avatar'];
  7244. $receiptLog->status = 4;
  7245. $receiptLog->rid = $rid;
  7246. $receiptLog->insert ();
  7247. $receipt->status = 4;
  7248. $receipt->update ( array (
  7249. 'where' => 'rid=' . $rid
  7250. ) );
  7251. // 微信企业号通知
  7252. $this->setWXMsg ( $rid, 2 );
  7253. }
  7254. // echo "ddd";
  7255. return '/approvalExpenses/pendApproval';
  7256. }
  7257. function updateCheReceipt() {
  7258. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7259. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7260. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  7261. if (! empty ( $rid )) {
  7262. // 操作记录
  7263. Doo::loadModel ( "receipt" );
  7264. $receipt = new receipt ();
  7265. Doo::loadModel ( "receiptLog" );
  7266. $receiptLog = new receiptLog ();
  7267. Doo::loadModel ( "verify" );
  7268. $verify = new verify ();
  7269. $receiptInfo = $receipt->getOne ( array (
  7270. 'where' => 'rid=' . $rid.' and status=2',
  7271. 'asArray' => true
  7272. ) );
  7273. if(empty($receiptInfo)){
  7274. echo json_encode ( array (
  7275. 'status' => 2
  7276. ) );
  7277. die ();
  7278. }
  7279. $vr = $verify->getOne ( array (
  7280. 'where' => 'vid=' . $receiptInfo ['verify'],
  7281. 'asArray' => true
  7282. ) );
  7283. $jd = json_decode ( $vr ['staff'] );
  7284. $roleId = 0;
  7285. foreach ( $jd as $key => $value ) {
  7286. if ($value [1] == 'ROLE') {
  7287. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7288. if ($pos !== false) {
  7289. $roleId = $value [0];
  7290. }
  7291. }
  7292. }
  7293. // 审批日志
  7294. // echo $roleId;die;
  7295. if (! empty ( $roleId )) {
  7296. Doo::loadModel ( "role" );
  7297. $role = new role ();
  7298. $roleInfo = $role->getOne ( array (
  7299. 'where' => 'rid=' . $roleId,
  7300. 'asArray' => true
  7301. ) );
  7302. $receiptLog->rolename = $roleInfo ['name'];
  7303. }
  7304. $receiptLog->username = $this->staff [0] ['username'];
  7305. $receiptLog->uid = $this->staff [0] ['sid'];
  7306. $receiptLog->date = date ( "Y-m-d" );
  7307. $receiptLog->opinion = $opinion;
  7308. $receiptLog->img = $this->staff [0] ['avatar'];
  7309. $receiptLog->status = 4;
  7310. $receiptLog->rid = $rid;
  7311. $receiptLog->insert ();
  7312. $receipt->status = 4;
  7313. $receipt->update ( array (
  7314. 'where' => 'rid=' . $rid
  7315. ) );
  7316. // 微信企业号通知
  7317. $this->setWXMsg ( $rid, 2 );
  7318. echo json_encode ( array (
  7319. 'status' => 1
  7320. ) );
  7321. //Header("HTTP/1.1 303 See Other");
  7322. //Header("Location: /approvalExpenses/pendApproval");
  7323. die;
  7324. }
  7325. echo json_encode ( array (
  7326. 'status' => 2
  7327. ) );
  7328. die ();
  7329. // echo "ddd";
  7330. // return '/saeaBorad';
  7331. }
  7332. function revisePrice() {
  7333. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  7334. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  7335. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7336. // echo $price;die;
  7337. if (! empty ( $rid )) {
  7338. Doo::loadModel ( "receipt" );
  7339. $receipt = new receipt ();
  7340. $receiptDetail = $receipt->getOne ( array (
  7341. 'where' => 'rid=' . $rid . ' and status=2 ',
  7342. 'asArray' => true
  7343. ) );
  7344. if (empty ( $receiptDetail ))
  7345. return "/approval";
  7346. $reviseDetail = array ();
  7347. if (empty ( $receiptDetail ['reviseDetail'] )) {
  7348. array_push ( $reviseDetail, array (
  7349. 'sid' => $this->staff [0] ['sid'],
  7350. 'name' => $this->staff [0] ['username'],
  7351. 'description' => $description,
  7352. 'price' => $price
  7353. ) );
  7354. $reviseDetailString = json_encode ( $reviseDetail );
  7355. $receipt->reviseDetail = $reviseDetailString;
  7356. $receipt->revisePrice = $price;
  7357. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7358. } else {
  7359. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7360. array_push ( $reviseDetail, array (
  7361. 'sid' => $this->staff [0] ['sid'],
  7362. 'name' => $this->staff [0] ['username'],
  7363. 'description' => $description,
  7364. 'price' => $price
  7365. ) );
  7366. $reviseDetailString = json_encode ( $reviseDetail );
  7367. $receipt->reviseDetail = $reviseDetailString;
  7368. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  7369. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7370. }
  7371. $receipt->update ( array (
  7372. 'where' => 'rid=' . $rid
  7373. ) );
  7374. }
  7375. return '/approvalEdi/' . $rid;
  7376. }
  7377. function personalCollect() {
  7378. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7379. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  7380. $this->showCache ( $path );
  7381. Doo::loadModel ( "receiptDetail" );
  7382. Doo::loadModel ( "itemStatistics" );
  7383. Doo::loadModel ( 'statistics' );
  7384. $statistics = new statistics ();
  7385. $itemStatistics = new itemStatistics ();
  7386. $receiptDetail = new receiptDetail ();
  7387. $receiptCollectList = $receiptDetail->find ( array (
  7388. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7389. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7390. 'groupby' => 'itemCategory,Month(date)',
  7391. 'asArray' => true
  7392. ) );
  7393. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  7394. 'where' => 'staff=' . $this->staff [0] ['sid'],
  7395. 'asArray' => true
  7396. ) );
  7397. // create collect html
  7398. $collectArray = array (
  7399. '日常相关费用' => array (),
  7400. '差旅相关费用' => array (),
  7401. '培训班费用' => array (),
  7402. '其他' => array ()
  7403. );
  7404. $adjustment = array ();
  7405. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  7406. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7407. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  7408. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7409. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  7410. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7411. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  7412. array_push ( $collectArray ['其他'], $collectHtml );
  7413. $data ['collectArray'] = $collectArray;
  7414. // statistics html
  7415. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7416. if (empty ( $stList ))
  7417. $stList = array (
  7418. 'rePrice' => 0,
  7419. 'agPrice' => 0
  7420. );
  7421. $data ['stList'] = array (
  7422. 'rePrice' => $stList ['rePrice'],
  7423. 'agPrice' => $stList ['agPrice'],
  7424. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7425. );
  7426. // Adjustment price html
  7427. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7428. array_push ( $adjustment, $collectHtml );
  7429. $data ['adjustment'] = $adjustment;
  7430. // total price html
  7431. $collectHtml = "";
  7432. $total = 0;
  7433. for($i = 1; $i <= 12; $i ++) {
  7434. $sumPrice = 0;
  7435. foreach ( $receiptCollectList as $key => $value ) {
  7436. if ($value ['month'] == $i) {
  7437. $sumPrice += $value ['price'];
  7438. }
  7439. }
  7440. if ($sumPrice == 0)
  7441. $collectHtml .= '<td class="taR">-</td>';
  7442. else
  7443. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7444. $total += $sumPrice;
  7445. }
  7446. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7447. $data ['totalPrice'] = $collectHtml;
  7448. $data ['year'] = $year;
  7449. $data ['totalYear'] = $total;
  7450. $data ['memu'] = "receipt";
  7451. $data ['staff'] = $this->staff;
  7452. $data ['receiptMemu'] = 'personalCollect';
  7453. $data ['verifyId'] = $this->verifyId;
  7454. $data ['executeId'] = $this->executeId;
  7455. // year staff status 2,4
  7456. if ($year < date ( "Y" )) {
  7457. Doo::loadModel ( 'receipt' );
  7458. $receipt = new receipt ();
  7459. $receiptList = $receipt->find ( array (
  7460. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7461. 'asArray' => true
  7462. ) );
  7463. if (empty ( $receiptList )) {
  7464. ob_start ();
  7465. $this->render ( "/admin/saea_slist_collect", $data );
  7466. $this->cacheFile ( $path );
  7467. die ();
  7468. }
  7469. }
  7470. $this->render ( "/admin/saea_slist_collect", $data );
  7471. }
  7472. function personalCollectDetail() {
  7473. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7474. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  7475. $this->showCache ( $path );
  7476. Doo::loadModel ( "receiptDetail" );
  7477. Doo::loadModel ( "itemStatistics" );
  7478. Doo::loadModel ( 'statistics' );
  7479. Doo::loadModel ( 'accountItem' );
  7480. $accountItem = new accountItem ();
  7481. $statistics = new statistics ();
  7482. $itemStatistics = new itemStatistics ();
  7483. $receiptDetail = new receiptDetail ();
  7484. $receiptCollectList = $receiptDetail->find ( array (
  7485. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  7486. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7487. 'groupby' => 'item,Month(date)',
  7488. 'asArray' => true
  7489. ) );
  7490. $accountList = $accountItem->find ( array (
  7491. 'asArray' => true
  7492. ) );
  7493. // create CollectDetail HTML
  7494. $collectHtml = array ();
  7495. foreach ( $accountList as $key => $value ) {
  7496. $html = "";
  7497. $asum = 0;
  7498. for($i = 1; $i <= 12; $i ++) {
  7499. $falg = true;
  7500. foreach ( $receiptCollectList as $v ) {
  7501. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7502. $asum += $v ['price'];
  7503. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7504. $falg = false;
  7505. break;
  7506. }
  7507. }
  7508. if ($falg)
  7509. $html .= '<td class="taR">-</td>';
  7510. }
  7511. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7512. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7513. }
  7514. $data ['collectHtml'] = $collectHtml;
  7515. // create Adjustment price html
  7516. $receiptCollectList = $receiptDetail->find ( array (
  7517. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7518. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7519. 'groupby' => 'itemCategory,Month(date)',
  7520. 'asArray' => true
  7521. ) );
  7522. $adjustment = array ();
  7523. $collectArray = array (
  7524. '日常相关费用' => array (),
  7525. '差旅相关费用' => array (),
  7526. '培训班费用' => array (),
  7527. '其他' => array ()
  7528. );
  7529. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7530. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7531. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7532. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7533. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7534. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7535. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7536. array_push ( $collectArray ['其他'], $collectHtml );
  7537. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7538. array_push ( $adjustment, $collectHtml );
  7539. // total price html
  7540. $collectHtml = "";
  7541. $total = 0;
  7542. for($i = 1; $i <= 12; $i ++) {
  7543. $sumPrice = 0;
  7544. foreach ( $receiptCollectList as $key => $value ) {
  7545. if ($value ['month'] == $i) {
  7546. $sumPrice += $value ['price'];
  7547. }
  7548. }
  7549. if ($sumPrice == 0)
  7550. $collectHtml .= '<td class="taR">-</td>';
  7551. else
  7552. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7553. $total += $sumPrice;
  7554. }
  7555. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7556. // statistics html
  7557. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7558. if (empty ( $stList ))
  7559. $stList = array (
  7560. 'rePrice' => 0,
  7561. 'agPrice' => 0
  7562. );
  7563. $data ['stList'] = array (
  7564. 'rePrice' => $stList ['rePrice'],
  7565. 'agPrice' => $stList ['agPrice'],
  7566. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7567. );
  7568. $data ['collectArray'] = $collectArray;
  7569. $data ['adjustment'] = $adjustment;
  7570. $data ['totalPrice'] = $collectHtml;
  7571. $data ['totalYear'] = $total;
  7572. $data ['year'] = $year;
  7573. $data ['memu'] = "receipt";
  7574. $data ['staff'] = $this->staff;
  7575. $data ['receiptMemu'] = 'personalCollect';
  7576. $data ['verifyId'] = $this->verifyId;
  7577. $data ['executeId'] = $this->executeId;
  7578. // year staff status 2,4
  7579. if ($year < date ( "Y" )) {
  7580. Doo::loadModel ( 'receipt' );
  7581. $receipt = new receipt ();
  7582. $receiptList = $receipt->find ( array (
  7583. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7584. 'asArray' => true
  7585. ) );
  7586. if (empty ( $receiptList )) {
  7587. ob_start ();
  7588. $this->render ( "/admin/saeaCollectArticles", $data );
  7589. $this->cacheFile ( $path );
  7590. die ();
  7591. }
  7592. }
  7593. $this->render ( "/admin/saeaCollectArticles", $data );
  7594. }
  7595. function companyCategoryCollect() {
  7596. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7597. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  7598. $this->showCache ( $path );
  7599. Doo::loadModel ( 'L_category' );
  7600. Doo::loadModel ( 'itemStatistics' );
  7601. Doo::loadModel ( 'statistics' );
  7602. $statistics = new statistics ();
  7603. $Lcategory = new L_category ();
  7604. $itemStatistics = new itemStatistics ();
  7605. $LcategoryList = $Lcategory->find ( array (
  7606. 'asArray' => true
  7607. ) ); // 'staff='.$this->staff[0]['sid']." and
  7608. $itemStatisticsList = $itemStatistics->find ( array (
  7609. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7610. 'where' => " Year(date)=" . $year,
  7611. 'groupby' => 'cid,Month(date)',
  7612. 'asArray' => true
  7613. ) );
  7614. // ceatre companyCollectHtml
  7615. foreach ( $LcategoryList as $value ) {
  7616. $html = "";
  7617. $asum = 0;
  7618. for($i = 1; $i <= 12; $i ++) {
  7619. $falg = true;
  7620. foreach ( $itemStatisticsList as $v ) {
  7621. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  7622. $asum += $v ['price'];
  7623. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7624. $falg = false;
  7625. break;
  7626. }
  7627. }
  7628. if ($falg)
  7629. $html .= '<td class="taR">-</td>';
  7630. }
  7631. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7632. $collectHtml [$value ['title']] = array (
  7633. 'html' => $html,
  7634. 'cid' => $value ['cid']
  7635. );
  7636. }
  7637. $data ['companyHtml'] = $collectHtml;
  7638. // total price html
  7639. $collectHtml = "";
  7640. $total = 0;
  7641. for($i = 1; $i <= 12; $i ++) {
  7642. $sumPrice = 0;
  7643. foreach ( $itemStatisticsList as $key => $value ) {
  7644. if ($value ['month'] == $i) {
  7645. $sumPrice += $value ['price'];
  7646. }
  7647. }
  7648. if ($sumPrice == 0)
  7649. $collectHtml .= '<td class="taR">-</td>';
  7650. else
  7651. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7652. $total += $sumPrice;
  7653. }
  7654. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7655. $data ['companyTotalHtml'] = $collectHtml;
  7656. $data ['total'] = $total;
  7657. // statistics html
  7658. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7659. if (empty ( $stList ))
  7660. $stList = array (
  7661. 'rePrice' => 0,
  7662. 'agPrice' => 0
  7663. );
  7664. $data ['stList'] = array (
  7665. 'rePrice' => $stList ['rePrice'],
  7666. 'agPrice' => $stList ['agPrice'],
  7667. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7668. );
  7669. $data ['year'] = $year;
  7670. $data ['memu'] = "receipt";
  7671. $data ['staff'] = $this->staff;
  7672. $data ['receiptMemu'] = 'companyCategoryCollect';
  7673. $data ['verifyId'] = $this->verifyId;
  7674. $data ['executeId'] = $this->executeId;
  7675. // year staff status 2,4
  7676. if ($year < date ( "Y" )) {
  7677. Doo::loadModel ( 'receipt' );
  7678. $receipt = new receipt ();
  7679. $receiptList = $receipt->find ( array (
  7680. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  7681. 'asArray' => true
  7682. ) );
  7683. if (empty ( $receiptList )) {
  7684. ob_start ();
  7685. $this->render ( "/admin/saeaCompanyCollect", $data );
  7686. $this->cacheFile ( $path );
  7687. die ();
  7688. }
  7689. }
  7690. $this->render ( "/admin/saeaCompanyCollect", $data );
  7691. }
  7692. function categoryCollectDetail() {
  7693. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7694. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  7695. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  7696. $this->showCache ( $path );
  7697. Doo::loadModel ( 'statistics' );
  7698. $statistics = new statistics ();
  7699. Doo::loadModel ( "receiptDetail" );
  7700. $receiptDetail = new receiptDetail ();
  7701. Doo::loadModel ( 'L_category' );
  7702. $Lcategory = new L_category ();
  7703. Doo::loadModel ( 'accountItem' );
  7704. $accountItem = new accountItem ();
  7705. $LcategoryList = $Lcategory->find ( array (
  7706. 'asArray' => true
  7707. ) );
  7708. if ($cid == 0) {
  7709. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7710. if ($cid == 0)
  7711. $cid = $LcategoryList [0] ['cid'];
  7712. }
  7713. $data ['LcategoryList'] = $LcategoryList;
  7714. $receiptCollectList = $receiptDetail->find ( array (
  7715. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  7716. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7717. 'groupby' => 'item,Month(pastDate)',
  7718. 'asArray' => true
  7719. ) );
  7720. $accountList = $accountItem->find ( array (
  7721. 'asArray' => true
  7722. ) );
  7723. // create CollectDetail HTML
  7724. $collectHtml = array ();
  7725. foreach ( $accountList as $key => $value ) {
  7726. $html = "";
  7727. $asum = 0;
  7728. for($i = 1; $i <= 12; $i ++) {
  7729. $falg = true;
  7730. foreach ( $receiptCollectList as $v ) {
  7731. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7732. $asum += $v ['price'];
  7733. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7734. $falg = false;
  7735. break;
  7736. }
  7737. }
  7738. if ($falg)
  7739. $html .= '<td class="taR">-</td>';
  7740. }
  7741. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7742. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7743. }
  7744. $data ['collectHtml'] = $collectHtml;
  7745. // create Adjustment price html
  7746. $receiptCollectList = $receiptDetail->find ( array (
  7747. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  7748. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7749. 'groupby' => 'itemCategory,Month(pastDate)',
  7750. 'asArray' => true
  7751. ) );
  7752. $adjustment = array ();
  7753. $collectArray = array (
  7754. '日常相关费用' => array (),
  7755. '差旅相关费用' => array (),
  7756. '培训班费用' => array (),
  7757. '其他' => array ()
  7758. );
  7759. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7760. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7761. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7762. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7763. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7764. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7765. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7766. array_push ( $collectArray ['其他'], $collectHtml );
  7767. $data ['collectArray'] = $collectArray;
  7768. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7769. array_push ( $adjustment, $collectHtml );
  7770. $data ['adjustment'] = $adjustment;
  7771. // total price html
  7772. $collectHtml = "";
  7773. $total = 0;
  7774. for($i = 1; $i <= 12; $i ++) {
  7775. $sumPrice = 0;
  7776. foreach ( $receiptCollectList as $key => $value ) {
  7777. if ($value ['month'] == $i) {
  7778. $sumPrice += $value ['price'];
  7779. }
  7780. }
  7781. if ($sumPrice == 0)
  7782. $collectHtml .= '<td class="taR">-</td>';
  7783. else
  7784. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7785. $total += $sumPrice;
  7786. }
  7787. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7788. // statistics html
  7789. $stList = $statistics->statisticsByCid ( $year, $cid );
  7790. if (empty ( $stList ))
  7791. $stList = array (
  7792. 'rePrice' => 0,
  7793. 'agPrice' => 0
  7794. );
  7795. $data ['stList'] = array (
  7796. 'rePrice' => $stList ['rePrice'],
  7797. 'agPrice' => $stList ['agPrice'],
  7798. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7799. );
  7800. $data ['totalYear'] = $total;
  7801. $data ['year'] = $year;
  7802. $data ['cid'] = $cid;
  7803. $data ['memu'] = "receipt";
  7804. $data ['staff'] = $this->staff;
  7805. $data ['receiptMemu'] = 'companyCategoryCollect';
  7806. $data ['verifyId'] = $this->verifyId;
  7807. $data ['executeId'] = $this->executeId;
  7808. // year staff status 2,4
  7809. if ($year < date ( "Y" )) {
  7810. Doo::loadModel ( 'receipt' );
  7811. $receipt = new receipt ();
  7812. $receiptList = $receipt->find ( array (
  7813. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  7814. 'asArray' => true
  7815. ) );
  7816. if (empty ( $receiptList )) {
  7817. ob_start ();
  7818. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7819. $this->cacheFile ( $path );
  7820. die ();
  7821. }
  7822. }
  7823. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7824. }
  7825. function staffCollect() {
  7826. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7827. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  7828. // $this->showCache($path);
  7829. Doo::loadModel ( 'statistics' );
  7830. $statistics = new statistics ();
  7831. Doo::loadModel ( "receiptDetail" );
  7832. $receiptDetail = new receiptDetail ();
  7833. Doo::loadModel ( 'L_category' );
  7834. $Lcategory = new L_category ();
  7835. Doo::loadModel ( 'accountItem' );
  7836. $accountItem = new accountItem ();
  7837. Doo::loadModel ( 'staff' );
  7838. $staff = new staff ();
  7839. Doo::loadModel ( 'itemStatistics' );
  7840. $itemStatistics = new itemStatistics ();
  7841. /*
  7842. * $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']));
  7843. */
  7844. // statistics html
  7845. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7846. if (empty ( $stList ))
  7847. $stList = array (
  7848. 'rePrice' => 0,
  7849. 'agPrice' => 0
  7850. );
  7851. $data ['stList'] = array (
  7852. 'rePrice' => $stList ['rePrice'],
  7853. 'agPrice' => $stList ['agPrice'],
  7854. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7855. );
  7856. // ---
  7857. $staffList = $staff->find ( array (
  7858. 'where' => 'username !="admin"',
  7859. 'asArray' => true
  7860. ) );
  7861. $LcategoryList = $Lcategory->find ( array (
  7862. 'asArray' => true
  7863. ) ); // 'staff='.$this->staff[0]['sid']." and
  7864. $itemStatisticsList = $itemStatistics->find ( array (
  7865. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7866. 'where' => " Year(date)=" . $year,
  7867. 'groupby' => 'staff,Month(date)',
  7868. 'asArray' => true
  7869. ) );
  7870. $categoryList = $staff->find ( array (
  7871. 'select' => 'COUNT(*) as count,cid,category',
  7872. 'where' => 'username !="admin"',
  7873. 'groupby' => 'cid',
  7874. 'asArray' => true
  7875. ) );
  7876. // print_r($itemStatisticsList);die;
  7877. // ceatre companyCollectHtml
  7878. foreach ( $categoryList as $vlu ) {
  7879. $count = $vlu ['count'] + 1;
  7880. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  7881. $m1 = 0;
  7882. $m2 = 0;
  7883. $m3 = 0;
  7884. $m4 = 0;
  7885. $m5 = 0;
  7886. $m6 = 0;
  7887. $m7 = 0;
  7888. $m8 = 0;
  7889. $m9 = 0;
  7890. $m10 = 0;
  7891. $m11 = 0;
  7892. $m12 = 0;
  7893. $m13 = 0;
  7894. foreach ( $staffList as $value ) {
  7895. if ($vlu ['cid'] == $value ['cid']) {
  7896. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  7897. $asum = 0;
  7898. for($i = 1; $i <= 12; $i ++) {
  7899. $falg = true;
  7900. foreach ( $itemStatisticsList as $v ) {
  7901. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  7902. if ($v ['month'] == 1)
  7903. $m1 += $v ['price'];
  7904. if ($v ['month'] == 2)
  7905. $m2 += $v ['price'];
  7906. if ($v ['month'] == 3)
  7907. $m3 += $v ['price'];
  7908. if ($v ['month'] == 4)
  7909. $m4 += $v ['price'];
  7910. if ($v ['month'] == 5)
  7911. $m5 += $v ['price'];
  7912. if ($v ['month'] == 6)
  7913. $m6 += $v ['price'];
  7914. if ($v ['month'] == 7)
  7915. $m7 += $v ['price'];
  7916. if ($v ['month'] == 8)
  7917. $m8 += $v ['price'];
  7918. if ($v ['month'] == 9)
  7919. $m9 += $v ['price'];
  7920. if ($v ['month'] == 10)
  7921. $m10 += $v ['price'];
  7922. if ($v ['month'] == 11)
  7923. $m11 += $v ['price'];
  7924. if ($v ['month'] == 12)
  7925. $m12 += $v ['price'];
  7926. $asum += $v ['price'];
  7927. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7928. $falg = false;
  7929. break;
  7930. }
  7931. }
  7932. if ($falg)
  7933. $html .= '<td class="taR">-</td>';
  7934. }
  7935. $m13 += $asum;
  7936. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7937. $collectHtml [$value ['username']] = array (
  7938. 'html' => $html,
  7939. 'sid' => $value ['sid']
  7940. );
  7941. $html = "";
  7942. }
  7943. }
  7944. $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>
  7945. <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>
  7946. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  7947. $collectHtml [$vlu ['cid']] = array (
  7948. 'html' => $hl,
  7949. 'sid' => ''
  7950. );
  7951. }
  7952. $data ['companyHtml'] = $collectHtml;
  7953. // total price html
  7954. $collectHtml = "";
  7955. $total = 0;
  7956. for($i = 1; $i <= 12; $i ++) {
  7957. $sumPrice = 0;
  7958. foreach ( $itemStatisticsList as $key => $value ) {
  7959. if ($value ['month'] == $i) {
  7960. $sumPrice += $value ['price'];
  7961. }
  7962. }
  7963. if ($sumPrice == 0)
  7964. $collectHtml .= '<td class="taR">-</td>';
  7965. else
  7966. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7967. $total += $sumPrice;
  7968. }
  7969. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7970. $data ['companyTotalHtml'] = $collectHtml;
  7971. $data ['total'] = $total;
  7972. $data ['year'] = $year;
  7973. $data ['memu'] = "receipt";
  7974. $data ['staff'] = $this->staff;
  7975. $data ['receiptMemu'] = 'companyCategoryCollect';
  7976. $data ['verifyId'] = $this->verifyId;
  7977. $data ['executeId'] = $this->executeId;
  7978. if ($year <= date ( "Y" )) {
  7979. Doo::loadModel ( 'receipt' );
  7980. $receipt = new receipt ();
  7981. $receiptList = $receipt->find ( array (
  7982. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  7983. 'asArray' => true
  7984. ) );
  7985. if (empty ( $receiptList )) { // generated files
  7986. ob_start ();
  7987. $this->render ( "/admin/saeaStaffCollectB", $data );
  7988. $this->cacheFile ( $path );
  7989. die ();
  7990. }
  7991. }
  7992. $this->render ( "/admin/saeaStaffCollectB", $data );
  7993. }
  7994. function staffCollectBak() {
  7995. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7996. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  7997. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  7998. $this->showCache ( $path );
  7999. Doo::loadModel ( 'statistics' );
  8000. $statistics = new statistics ();
  8001. Doo::loadModel ( "receiptDetail" );
  8002. $receiptDetail = new receiptDetail ();
  8003. Doo::loadModel ( 'L_category' );
  8004. $Lcategory = new L_category ();
  8005. Doo::loadModel ( 'accountItem' );
  8006. $accountItem = new accountItem ();
  8007. Doo::loadModel ( 'staff' );
  8008. $staff = new staff ();
  8009. Doo::loadModel ( 'itemStatistics' );
  8010. $itemStatistics = new itemStatistics ();
  8011. $itemStatisticsList = $itemStatistics->find ( array (
  8012. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8013. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8014. 'groupby' => 'staff,itemCategory,Month(date)',
  8015. 'asArray' => true
  8016. ) );
  8017. $itemCategoryList = $itemStatistics->find ( array (
  8018. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8019. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8020. 'groupby' => 'cid,itemCategory,Month(date)',
  8021. 'asArray' => true
  8022. ) );
  8023. $LcategoryList = $Lcategory->find ( array (
  8024. 'asArray' => true
  8025. ) );
  8026. $staffList = $staff->find ( array (
  8027. 'asArray' => true
  8028. ) );
  8029. $htmlArray = array ();
  8030. foreach ( $LcategoryList as $value ) {
  8031. $htmlArray [$value ['title']] = array ();
  8032. foreach ( $staffList as $v ) {
  8033. if ($value ['cid'] == $v ['cid']) {
  8034. $html = "";
  8035. $falg = true;
  8036. $staffSumPrice = 0;
  8037. foreach ( $itemStatisticsList as $a ) {
  8038. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  8039. if (empty ( $a ['price'] )) {
  8040. $html .= '<td class="taR">-</td>';
  8041. $falg = false;
  8042. break;
  8043. } else {
  8044. $staffSumPrice += $a ['price'];
  8045. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8046. $falg = false;
  8047. break;
  8048. }
  8049. }
  8050. }
  8051. if ($falg) {
  8052. $html .= '<td class="taR">-</td>';
  8053. $falg = true;
  8054. }
  8055. $falg = true;
  8056. foreach ( $itemStatisticsList as $a ) {
  8057. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  8058. if (empty ( $a ['price'] )) {
  8059. $html .= '<td class="taR">-</td>';
  8060. $falg = false;
  8061. break;
  8062. } else {
  8063. $staffSumPrice += $a ['price'];
  8064. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8065. $falg = false;
  8066. break;
  8067. }
  8068. }
  8069. }
  8070. if ($falg) {
  8071. $html .= '<td class="taR">-</td>';
  8072. $falg = true;
  8073. }
  8074. $falg = true;
  8075. foreach ( $itemStatisticsList as $a ) {
  8076. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  8077. if (empty ( $a ['price'] )) {
  8078. $html .= '<td class="taR">-</td>';
  8079. $falg = false;
  8080. break;
  8081. } else {
  8082. $staffSumPrice += $a ['price'];
  8083. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8084. $falg = false;
  8085. break;
  8086. }
  8087. }
  8088. }
  8089. if ($falg) {
  8090. $html .= '<td class="taR">-</td>';
  8091. $falg = true;
  8092. }
  8093. $falg = true;
  8094. foreach ( $itemStatisticsList as $a ) {
  8095. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  8096. if (! empty ( $a ['price'] )) {
  8097. $staffSumPrice += $a ['price'];
  8098. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8099. $falg = false;
  8100. break;
  8101. } else {
  8102. $html .= '<td class="taR">-</td>';
  8103. $falg = false;
  8104. break;
  8105. }
  8106. }
  8107. }
  8108. if ($falg) {
  8109. $html .= '<td class="taR">-</td>';
  8110. $falg = true;
  8111. }
  8112. $falg = true;
  8113. foreach ( $itemStatisticsList as $a ) {
  8114. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  8115. if (! empty ( $a ['price'] )) {
  8116. $staffSumPrice += $a ['price'];
  8117. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8118. $falg = false;
  8119. break;
  8120. } else {
  8121. $html .= '<td class="taR">-</td>';
  8122. $falg = false;
  8123. break;
  8124. }
  8125. }
  8126. }
  8127. if ($falg) {
  8128. $html .= '<td class="taR">-</td>';
  8129. $falg = true;
  8130. }
  8131. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  8132. $htmlArray [$value ['title']] [$v ['username']] = $html;
  8133. }
  8134. }
  8135. /* -- --- */
  8136. // 合计费用
  8137. $cateHtml = "";
  8138. $catePrice = 0;
  8139. $cateFalg = true;
  8140. foreach ( $itemCategoryList as $l ) {
  8141. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  8142. if (empty ( $l ['price'] )) {
  8143. $cateHtml .= '<td class="colGreen taR">-</td>';
  8144. $cateFalg = false;
  8145. break;
  8146. } else {
  8147. $catePrice += $l ['price'];
  8148. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8149. $cateFalg = false;
  8150. break;
  8151. }
  8152. }
  8153. }
  8154. if ($cateFalg) {
  8155. $cateHtml .= '<td class="colGreen taR">-</td>';
  8156. $cateFalg = true;
  8157. }
  8158. $cateFalg = true;
  8159. foreach ( $itemCategoryList as $l ) {
  8160. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  8161. if (empty ( $l ['price'] )) {
  8162. $cateHtml .= '<td class="colGreen taR">-</td>';
  8163. $cateFalg = false;
  8164. break;
  8165. } else {
  8166. $catePrice += $l ['price'];
  8167. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8168. $cateFalg = false;
  8169. break;
  8170. }
  8171. }
  8172. }
  8173. if ($cateFalg) {
  8174. $cateHtml .= '<td class="colGreen taR">-</td>';
  8175. $cateFalg = true;
  8176. }
  8177. $cateFalg = true;
  8178. foreach ( $itemCategoryList as $l ) {
  8179. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  8180. if (empty ( $l ['price'] )) {
  8181. $cateHtml .= '<td class="colGreen taR">-</td>';
  8182. $cateFalg = false;
  8183. break;
  8184. } else {
  8185. $catePrice += $l ['price'];
  8186. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8187. $cateFalg = false;
  8188. break;
  8189. }
  8190. }
  8191. }
  8192. if ($cateFalg) {
  8193. $cateHtml .= '<td class="colGreen taR">-</td>';
  8194. $cateFalg = true;
  8195. }
  8196. $cateFalg = true;
  8197. foreach ( $itemCategoryList as $l ) {
  8198. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  8199. if (empty ( $l ['price'] )) {
  8200. $cateHtml .= '<td class="colGreen taR">-</td>';
  8201. $cateFalg = false;
  8202. break;
  8203. } else {
  8204. $catePrice += $l ['price'];
  8205. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8206. $cateFalg = false;
  8207. break;
  8208. }
  8209. }
  8210. }
  8211. if ($cateFalg) {
  8212. $cateHtml .= '<td class="colGreen taR">-</td>';
  8213. $cateFalg = true;
  8214. }
  8215. $cateFalg = true;
  8216. foreach ( $itemCategoryList as $l ) {
  8217. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  8218. if (empty ( $l ['price'] )) {
  8219. $cateHtml .= '<td class="colGreen taR">-</td>';
  8220. $cateFalg = false;
  8221. break;
  8222. } else {
  8223. $catePrice += $l ['price'];
  8224. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8225. $cateFalg = false;
  8226. break;
  8227. }
  8228. }
  8229. }
  8230. if ($cateFalg) {
  8231. $cateHtml .= '<td class="colGreen taR">-</td>';
  8232. $cateFalg = true;
  8233. }
  8234. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  8235. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  8236. /* -- --- */
  8237. }
  8238. // print_r($htmlArray);die;
  8239. $data ['htmlArray'] = $htmlArray;
  8240. // statistics html
  8241. $stList = $statistics->getOne ( array (
  8242. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8243. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8244. 'groupby' => 'Month(date)',
  8245. 'asArray' => true
  8246. ) );
  8247. if (empty ( $stList ))
  8248. $stList = array (
  8249. 'rePrice' => 0,
  8250. 'agPrice' => 0
  8251. );
  8252. $data ['stList'] = array (
  8253. 'rePrice' => $stList ['rePrice'],
  8254. 'agPrice' => $stList ['agPrice'],
  8255. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8256. );
  8257. $monthHtml = "";
  8258. for($i = 1; $i <= 12; $i ++) {
  8259. if ($i == $month)
  8260. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8261. else
  8262. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8263. }
  8264. $data ['monthHtml'] = $monthHtml;
  8265. $data ['year'] = $year;
  8266. $data ['month'] = $month;
  8267. $data ['memu'] = "receipt";
  8268. $data ['staff'] = $this->staff;
  8269. $data ['receiptMemu'] = 'companyCategoryCollect';
  8270. $data ['verifyId'] = $this->verifyId;
  8271. $data ['executeId'] = $this->executeId;
  8272. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  8273. Doo::loadModel ( 'receipt' );
  8274. $receipt = new receipt ();
  8275. $receiptList = $receipt->find ( array (
  8276. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  8277. 'asArray' => true
  8278. ) );
  8279. if (empty ( $receiptList )) { // generated files
  8280. ob_start ();
  8281. $this->render ( "/admin/saeaStaffCollect", $data );
  8282. $this->cacheFile ( $path );
  8283. die ();
  8284. }
  8285. }
  8286. $this->render ( "/admin/saeaStaffCollect", $data );
  8287. }
  8288. function lyt() {
  8289. Doo::loadModel ( "receiptDetail" );
  8290. $receiptDetail = new receiptDetail ();
  8291. $receiptCollectList = $receiptDetail->find ( array (
  8292. 'where' => 'status=1 ',
  8293. 'asArray' => true
  8294. ) );
  8295. foreach ( $receiptCollectList as $key => $value ) {
  8296. $receiptDetail = new receiptDetail ();
  8297. $receiptDetail->pastDate = $value ['date'];
  8298. $receiptDetail->update ( array (
  8299. 'where' => "rdid= '" . $value ['rdid'] . "'"
  8300. ) );
  8301. }
  8302. }
  8303. function staffCollectMonthDetail() {
  8304. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8305. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8306. if (! $year)
  8307. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8308. if (! $month)
  8309. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8310. Doo::loadModel ( 'staff' );
  8311. $staff = new staff ();
  8312. Doo::loadModel ( "receiptDetail" );
  8313. $receiptDetail = new receiptDetail ();
  8314. Doo::loadModel ( 'accountItem' );
  8315. $accountItem = new accountItem ();
  8316. Doo::loadModel ( 'statistics' );
  8317. $statistics = new statistics ();
  8318. Doo::loadModel ( 'L_category' );
  8319. $lCategory = new L_category ();
  8320. $staffList = $staff->find ( array (
  8321. 'where' => 'username!="admin"',
  8322. 'asArray' => true
  8323. ) );
  8324. $categoryList = $staff->find ( array (
  8325. 'select' => 'COUNT(*) as count,cid,category',
  8326. 'where' => 'username !="admin"',
  8327. 'groupby' => 'cid',
  8328. 'asArray' => true
  8329. ) );
  8330. $list = array ();
  8331. foreach ( $categoryList as $vlu ) {
  8332. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8333. $r1 = 0;
  8334. $r2 = 0;
  8335. $r3 = 0;
  8336. $r4 = 0;
  8337. $r5 = 0;
  8338. $r6 = 0;
  8339. $r7 = 0;
  8340. $r8 = 0;
  8341. $r9 = 0;
  8342. $r10 = 0;
  8343. $r11 = 0;
  8344. $r12 = 0;
  8345. $r13 = 0;
  8346. $r14 = 0;
  8347. $r15 = 0;
  8348. $r16=0;
  8349. $r17=0;
  8350. $r18=0;
  8351. $c1 = 0;
  8352. $c2 = 0;
  8353. $c3 = 0;
  8354. $c4 = 0;
  8355. $c5 = 0;
  8356. $c6 = 0;
  8357. $p1 = 0;
  8358. $p2 = 0;
  8359. $p3 = 0;
  8360. $p4 = 0;
  8361. $p5 = 0;
  8362. $p6 = 0;
  8363. $p7 = 0;
  8364. $p8 = 0;
  8365. $p9 = 0;
  8366. $t1 = 0;
  8367. $t2 = 0;
  8368. $t3 = 0;
  8369. $t4 = 0;
  8370. $t5 = 0;
  8371. $s1 = 0;
  8372. $m1 = 0;
  8373. foreach ( $staffList as $value ) {
  8374. if ($vlu ['cid'] == $value ['cid']) {
  8375. // pastDate
  8376. $receiptCollectList = $receiptDetail->find ( array (
  8377. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8378. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8379. 'groupby' => 'item,Month(pastDate),itemCategory',
  8380. 'asArray' => true
  8381. ) );
  8382. // if ($value['sid']==42){
  8383. // print_r($receiptCollectList);die;
  8384. // }
  8385. if (! empty ( $receiptCollectList )) {
  8386. $receiptL = array (
  8387. '日常相关费用' => array (),
  8388. '差旅相关费用' => array (),
  8389. '培训班费用' => array (),
  8390. '其他' => array ()
  8391. );
  8392. $html = "";
  8393. $psum = 0;
  8394. $item = array (
  8395. '市内交通费',
  8396. '市内出租费',
  8397. '办事处房租',
  8398. '电话费',
  8399. '水费',
  8400. '电费',
  8401. '办公费用',
  8402. '邮寄费',
  8403. '其他费用',
  8404. '车辆费用',
  8405. '广告费',
  8406. '团队建设费',
  8407. '物业管理费',
  8408. '宽带费',
  8409. '人员薪酬',
  8410. '公积金',
  8411. '社保'
  8412. );
  8413. foreach ( $item as $va ) {
  8414. $falg = true;
  8415. foreach ( $receiptCollectList as $v ) {
  8416. if ($v ['itemCategory'] == '日常相关费用') {
  8417. if ($v ['item'] == $va) {
  8418. if ($va == '市内交通费')
  8419. $r1 += $v ['price'];
  8420. if ($va == '市内出租费')
  8421. $r2 += $v ['price'];
  8422. if ($va == '办事处房租')
  8423. $r3 += $v ['price'];
  8424. if ($va == '电话费')
  8425. $r4 += $v ['price'];
  8426. if ($va == '水费')
  8427. $r5 += $v ['price'];
  8428. if ($va == '电费')
  8429. $r6 += $v ['price'];
  8430. if ($va == '办公费用')
  8431. $r7 += $v ['price'];
  8432. if ($va == '邮寄费')
  8433. $r8 += $v ['price'];
  8434. if ($va == '其他费用')
  8435. $r9 += $v ['price'];
  8436. if ($va == '车辆费用')
  8437. $r10 += $v ['price'];
  8438. if ($va == '广告费')
  8439. $r11 += $v ['price'];
  8440. if ($va == '团队建设费')
  8441. $r13 += $v ['price'];
  8442. if ($va == '物业管理费')
  8443. $r14 += $v ['price'];
  8444. if ($va == '宽带费')
  8445. $r15 += $v ['price'];
  8446. if ($va == '公积金')
  8447. $r16 += $v ['price'];
  8448. if ($va == '社保')
  8449. $r17 += $v ['price'];
  8450. if ($va == '人员薪酬')
  8451. $r18 += $v ['price'];
  8452. $psum += $v ['price'];
  8453. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8454. $falg = false;
  8455. break;
  8456. }
  8457. }
  8458. }
  8459. if ($falg)
  8460. $html .= '<td class="taR">-</td>';
  8461. }
  8462. $r12 += $psum;
  8463. if (! empty ( $psum ))
  8464. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8465. else
  8466. $psum = '<td class="colGreen taR">-</td>';
  8467. $receiptL ['日常相关费用'] = $psum . $html;
  8468. /* ----------------------------------- */
  8469. $html = "";
  8470. $psum = 0;
  8471. $item = array (
  8472. '往来交通费',
  8473. '市内交通费',
  8474. '出差住宿费',
  8475. '出差补助',
  8476. '其他费用'
  8477. );
  8478. foreach ( $item as $va ) {
  8479. $falg = true;
  8480. foreach ( $receiptCollectList as $v ) {
  8481. if ($v ['itemCategory'] == '差旅相关费用') {
  8482. if ($v ['item'] == $va) {
  8483. if ($va == '往来交通费')
  8484. $c1 += $v ['price'];
  8485. if ($va == '市内交通费')
  8486. $c2 += $v ['price'];
  8487. if ($va == '出差住宿费')
  8488. $c3 += $v ['price'];
  8489. if ($va == '出差补助')
  8490. $c4 += $v ['price'];
  8491. if ($va == '其他费用')
  8492. $c5 += $v ['price'];
  8493. $psum += $v ['price'];
  8494. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8495. $falg = false;
  8496. break;
  8497. }
  8498. }
  8499. }
  8500. if ($falg)
  8501. $html .= '<td class="taR">-</td>';
  8502. }
  8503. $c6 += $psum;
  8504. if (! empty ( $psum ))
  8505. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8506. else
  8507. $psum = '<td class="colGreen taR">-</td>';
  8508. $receiptL ['差旅相关费用'] = $psum . $html;
  8509. /* ------------------------------------- */
  8510. $html = "";
  8511. $psum = 0;
  8512. $item = array (
  8513. '场租费',
  8514. '薪酬',
  8515. '住宿费',
  8516. '交通费',
  8517. '餐饮费',
  8518. '办公费',
  8519. '公关费',
  8520. '其他'
  8521. );
  8522. foreach ( $item as $va ) {
  8523. $falg = true;
  8524. foreach ( $receiptCollectList as $v ) {
  8525. if ($v ['itemCategory'] == '培训班费用') {
  8526. if ($v ['item'] == $va) {
  8527. if ($va == '场租费')
  8528. $p1 += $v ['price'];
  8529. if ($va == '薪酬')
  8530. $p2 += $v ['price'];
  8531. if ($va == '住宿费')
  8532. $p3 += $v ['price'];
  8533. if ($va == '交通费')
  8534. $p4 += $v ['price'];
  8535. if ($va == '餐饮费')
  8536. $p5 += $v ['price'];
  8537. if ($va == '办公费')
  8538. $p6 += $v ['price'];
  8539. if ($va == '公关费')
  8540. $p7 += $v ['price'];
  8541. if ($va == '其他')
  8542. $p8 += $v ['price'];
  8543. $psum += $v ['price'];
  8544. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8545. $falg = false;
  8546. break;
  8547. }
  8548. }
  8549. }
  8550. if ($falg)
  8551. $html .= '<td class="taR">-</td>';
  8552. }
  8553. $p9 += $psum;
  8554. if (! empty ( $psum ))
  8555. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8556. else
  8557. $psum = '<td class="colGreen taR">-</td>';
  8558. $receiptL ['培训班费用'] = $psum . $html;
  8559. /* ------------------------------------- */
  8560. $html = "";
  8561. $psum = 0;
  8562. $item = array (
  8563. '公关费',
  8564. '广告费',
  8565. '借款',
  8566. '可自加费用'
  8567. );
  8568. foreach ( $item as $va ) {
  8569. $falg = true;
  8570. foreach ( $receiptCollectList as $v ) {
  8571. if ($v ['itemCategory'] == '其他') {
  8572. // if ($value['sid']==42){
  8573. //
  8574. // echo var_dump($v['item']);
  8575. // echo var_dump($va);
  8576. // echo var_dump($v['item']==" ".$va);
  8577. // echo $v['item']."==".$va."/<br/>";
  8578. // //print_r( $receiptCollectList);//echo $va;
  8579. // }
  8580. if (trim ( $v ['item'] ) == $va) {
  8581. if ($va == '公关费')
  8582. $t1 += $v ['price'];
  8583. if ($va == '广告费') {
  8584. $t2 += $v ['price'];
  8585. }
  8586. if ($va == '借款')
  8587. $t3 += $v ['price'];
  8588. if ($va == '可自加费用')
  8589. $t4 += $v ['price'];
  8590. $psum += $v ['price'];
  8591. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8592. $falg = false;
  8593. break;
  8594. }
  8595. }
  8596. }
  8597. if ($falg)
  8598. $html .= '<td class="taR">-</td>';
  8599. }
  8600. $t5 += $psum;
  8601. if (! empty ( $psum ))
  8602. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8603. else
  8604. $psum = '<td class="colGreen taR">-</td>';
  8605. $receiptL ['其他'] = $psum . $html;
  8606. /* ------------------------------------- */
  8607. $html = "";
  8608. $psum = 0;
  8609. foreach ( $receiptCollectList as $v ) {
  8610. if ($v ['itemCategory'] == '报销金额调整') {
  8611. if (! empty ( $v ['price'] )) {
  8612. $psum += $v ['price'];
  8613. }
  8614. }
  8615. }
  8616. $s1 += $psum;
  8617. if (! empty ( $psum ))
  8618. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8619. else
  8620. $psum = '<td class="taR colOrange">-</td>';
  8621. $receiptL ['报销金额调整'] = $psum . $html;
  8622. } else {
  8623. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8624. <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>
  8625. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8626. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  8627. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8628. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8629. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8630. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8631. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  8632. }
  8633. $monthStaffPrice = $receiptDetail->find ( array (
  8634. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8635. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8636. 'groupby' => 'Month(pastDate)',
  8637. 'asArray' => true
  8638. ) );
  8639. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  8640. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  8641. $m1 += $monthStaffPrice [0] ['price'];
  8642. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  8643. } else
  8644. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  8645. $list [$value ['username']] = $receiptL;
  8646. }
  8647. }
  8648. $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>
  8649. <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>
  8650. <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>';
  8651. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  8652. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  8653. $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>
  8654. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  8655. $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>';
  8656. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  8657. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  8658. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  8659. }
  8660. $data ['list'] = $list;
  8661. $receiptCollectList = $receiptDetail->find ( array (
  8662. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8663. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8664. 'groupby' => 'item,Month(pastDate),itemCategory',
  8665. 'asArray' => true
  8666. ) );
  8667. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  8668. // statistics html
  8669. $stList = $statistics->getOne ( array (
  8670. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8671. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8672. 'groupby' => 'Month(date)',
  8673. 'asArray' => true
  8674. ) );
  8675. if (empty ( $stList ))
  8676. $stList = array (
  8677. 'rePrice' => 0,
  8678. 'agPrice' => 0
  8679. );
  8680. $data ['stList'] = array (
  8681. 'rePrice' => $stList ['rePrice'],
  8682. 'agPrice' => $stList ['agPrice'],
  8683. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8684. );
  8685. $monthHtml = "";
  8686. for($i = 1; $i <= 12; $i ++) {
  8687. if ($i == $month)
  8688. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8689. else
  8690. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8691. }
  8692. $data ['monthHtml'] = $monthHtml;
  8693. $data ['year'] = $year;
  8694. $data ['month'] = $month;
  8695. $data ['memu'] = "receipt";
  8696. $data ['staff'] = $this->staff;
  8697. $data ['receiptMemu'] = 'companyCategoryCollect';
  8698. $data ['verifyId'] = $this->verifyId;
  8699. $data ['executeId'] = $this->executeId;
  8700. $this->render ( "/admin/staffCollectMonthDetail", $data );
  8701. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  8702. }
  8703. function staffCollectMonthDetail2() {
  8704. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8705. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8706. if (! $year)
  8707. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8708. if (! $month)
  8709. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8710. Doo::loadModel ( 'staff' );
  8711. $staff = new staff ();
  8712. Doo::loadModel ( "receiptDetail" );
  8713. $receiptDetail = new receiptDetail ();
  8714. Doo::loadModel ( 'accountItem' );
  8715. $accountItem = new accountItem ();
  8716. Doo::loadModel ( 'statistics' );
  8717. $statistics = new statistics ();
  8718. Doo::loadModel ( 'L_category' );
  8719. $lCategory = new L_category ();
  8720. $staffList = $staff->find ( array (
  8721. 'where' => 'username!="admin"',
  8722. 'asArray' => true
  8723. ) );
  8724. $categoryList = $staff->find ( array (
  8725. 'select' => 'COUNT(*) as count,cid,category',
  8726. 'where' => 'username !="admin"',
  8727. 'groupby' => 'cid',
  8728. 'asArray' => true
  8729. ) );
  8730. $list = array ();
  8731. foreach ( $categoryList as $vlu ) {
  8732. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8733. $r1 = 0;
  8734. $r2 = 0;
  8735. $r3 = 0;
  8736. $r4 = 0;
  8737. $r5 = 0;
  8738. $r6 = 0;
  8739. $r7 = 0;
  8740. $r8 = 0;
  8741. $r9 = 0;
  8742. $r10 = 0;
  8743. $r11 = 0;
  8744. $r12 = 0;
  8745. $r13 = 0;
  8746. $r14 = 0;
  8747. $r15 = 0;
  8748. $c1 = 0;
  8749. $c2 = 0;
  8750. $c3 = 0;
  8751. $c4 = 0;
  8752. $c5 = 0;
  8753. $c6 = 0;
  8754. $p1 = 0;
  8755. $p2 = 0;
  8756. $p3 = 0;
  8757. $p4 = 0;
  8758. $p5 = 0;
  8759. $p6 = 0;
  8760. $p7 = 0;
  8761. $p8 = 0;
  8762. $p9 = 0;
  8763. $t1 = 0;
  8764. $t2 = 0;
  8765. $t3 = 0;
  8766. $t4 = 0;
  8767. $t5 = 0;
  8768. $s1 = 0;
  8769. $m1 = 0;
  8770. foreach ( $staffList as $value ) {
  8771. if ($vlu ['cid'] == $value ['cid']) {
  8772. $receiptCollectList = $receiptDetail->find ( array (
  8773. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  8774. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  8775. 'groupby' => 'item,Month(date),itemCategory',
  8776. 'asArray' => true
  8777. ) );
  8778. if (! empty ( $receiptCollectList )) {
  8779. $receiptL = array (
  8780. '日常相关费用' => array (),
  8781. '差旅相关费用' => array (),
  8782. '培训班费用' => array (),
  8783. '其他' => array ()
  8784. );
  8785. $html = "";
  8786. $psum = 0;
  8787. $item = array (
  8788. '市内交通费',
  8789. '市内出租费',
  8790. '办事处房租',
  8791. '电话费',
  8792. '水费',
  8793. '电费',
  8794. '办公费用',
  8795. '邮寄费',
  8796. '其他费用',
  8797. '车辆费用',
  8798. '广告费',
  8799. '团队建设费',
  8800. '物业管理费',
  8801. '宽带费'
  8802. );
  8803. foreach ( $item as $va ) {
  8804. $falg = true;
  8805. foreach ( $receiptCollectList as $v ) {
  8806. if ($v ['itemCategory'] == '日常相关费用') {
  8807. if ($v ['item'] == $va) {
  8808. if ($va == '市内交通费')
  8809. $r1 += $v ['price'];
  8810. if ($va == '市内出租费')
  8811. $r2 += $v ['price'];
  8812. if ($va == '办事处房租')
  8813. $r3 += $v ['price'];
  8814. if ($va == '电话费')
  8815. $r4 += $v ['price'];
  8816. if ($va == '水费')
  8817. $r5 += $v ['price'];
  8818. if ($va == '电费')
  8819. $r6 += $v ['price'];
  8820. if ($va == '办公费用')
  8821. $r7 += $v ['price'];
  8822. if ($va == '邮寄费')
  8823. $r8 += $v ['price'];
  8824. if ($va == '其他费用')
  8825. $r9 += $v ['price'];
  8826. if ($va == '车辆费用')
  8827. $r10 += $v ['price'];
  8828. if ($va == '广告费')
  8829. $r11 += $v ['price'];
  8830. if ($va == '团队建设费')
  8831. $r13 += $v ['price'];
  8832. if ($va == '物业管理费')
  8833. $r14 += $v ['price'];
  8834. if ($va == '宽带费')
  8835. $r15 += $v ['price'];
  8836. $psum += $v ['price'];
  8837. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8838. $falg = false;
  8839. break;
  8840. }
  8841. }
  8842. }
  8843. if ($falg)
  8844. $html .= '<td class="taR">-</td>';
  8845. }
  8846. $r12 += $psum;
  8847. if (! empty ( $psum ))
  8848. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8849. else
  8850. $psum = '<td class="colGreen taR">-</td>';
  8851. $receiptL ['日常相关费用'] = $psum . $html;
  8852. /* ----------------------------------- */
  8853. $html = "";
  8854. $psum = 0;
  8855. $item = array (
  8856. '往来交通费',
  8857. '市内交通费',
  8858. '出差住宿费',
  8859. '出差补助',
  8860. '其他费用'
  8861. );
  8862. foreach ( $item as $va ) {
  8863. $falg = true;
  8864. foreach ( $receiptCollectList as $v ) {
  8865. if ($v ['itemCategory'] == '差旅相关费用') {
  8866. if ($v ['item'] == $va) {
  8867. if ($va == '往来交通费')
  8868. $c1 += $v ['price'];
  8869. if ($va == '市内交通费')
  8870. $c2 += $v ['price'];
  8871. if ($va == '出差住宿费')
  8872. $c3 += $v ['price'];
  8873. if ($va == '出差补助')
  8874. $c4 += $v ['price'];
  8875. if ($va == '其他费用')
  8876. $c5 += $v ['price'];
  8877. $psum += $v ['price'];
  8878. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8879. $falg = false;
  8880. break;
  8881. }
  8882. }
  8883. }
  8884. if ($falg)
  8885. $html .= '<td class="taR">-</td>';
  8886. }
  8887. $c6 += $psum;
  8888. if (! empty ( $psum ))
  8889. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8890. else
  8891. $psum = '<td class="colGreen taR">-</td>';
  8892. $receiptL ['差旅相关费用'] = $psum . $html;
  8893. /* ------------------------------------- */
  8894. $html = "";
  8895. $psum = 0;
  8896. $item = array (
  8897. '场租费',
  8898. '薪酬',
  8899. '住宿费',
  8900. '交通费',
  8901. '餐饮费',
  8902. '办公费',
  8903. '公关费',
  8904. '其他'
  8905. );
  8906. foreach ( $item as $va ) {
  8907. $falg = true;
  8908. foreach ( $receiptCollectList as $v ) {
  8909. if ($v ['itemCategory'] == '培训班费用') {
  8910. if ($v ['item'] == $va) {
  8911. if ($va == '场租费')
  8912. $p1 += $v ['price'];
  8913. if ($va == '薪酬')
  8914. $p2 += $v ['price'];
  8915. if ($va == '住宿费')
  8916. $p3 += $v ['price'];
  8917. if ($va == '交通费')
  8918. $p4 += $v ['price'];
  8919. if ($va == '餐饮费')
  8920. $p5 += $v ['price'];
  8921. if ($va == '办公费')
  8922. $p6 += $v ['price'];
  8923. if ($va == '公关费')
  8924. $p7 += $v ['price'];
  8925. if ($va == '其他')
  8926. $p8 += $v ['price'];
  8927. $psum += $v ['price'];
  8928. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8929. $falg = false;
  8930. break;
  8931. }
  8932. }
  8933. }
  8934. if ($falg)
  8935. $html .= '<td class="taR">-</td>';
  8936. }
  8937. $p9 += $psum;
  8938. if (! empty ( $psum ))
  8939. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8940. else
  8941. $psum = '<td class="colGreen taR">-</td>';
  8942. $receiptL ['培训班费用'] = $psum . $html;
  8943. /* ------------------------------------- */
  8944. $html = "";
  8945. $psum = 0;
  8946. $item = array (
  8947. '公关费',
  8948. '广告费',
  8949. '借款',
  8950. '可自加费用'
  8951. );
  8952. foreach ( $item as $va ) {
  8953. $falg = true;
  8954. foreach ( $receiptCollectList as $v ) {
  8955. if ($v ['itemCategory'] == '其他') {
  8956. if ($v ['item'] == $va) {
  8957. if ($va == '公关费')
  8958. $t1 += $v ['price'];
  8959. if ($va == '广告费')
  8960. $t2 += $v ['price'];
  8961. if ($va == '借款')
  8962. $t3 += $v ['price'];
  8963. if ($va == '可自加费用')
  8964. $t4 += $v ['price'];
  8965. $psum += $v ['price'];
  8966. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8967. $falg = false;
  8968. break;
  8969. }
  8970. }
  8971. }
  8972. if ($falg)
  8973. $html .= '<td class="taR">-</td>';
  8974. }
  8975. $t5 += $psum;
  8976. if (! empty ( $psum ))
  8977. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8978. else
  8979. $psum = '<td class="colGreen taR">-</td>';
  8980. $receiptL ['其他'] = $psum . $html;
  8981. /* ------------------------------------- */
  8982. $html = "";
  8983. $psum = 0;
  8984. foreach ( $receiptCollectList as $v ) {
  8985. if ($v ['itemCategory'] == '报销金额调整') {
  8986. if (! empty ( $v ['price'] )) {
  8987. $psum += $v ['price'];
  8988. }
  8989. }
  8990. }
  8991. $s1 += $psum;
  8992. if (! empty ( $psum ))
  8993. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8994. else
  8995. $psum = '<td class="taR colOrange">-</td>';
  8996. $receiptL ['报销金额调整'] = $psum . $html;
  8997. } else {
  8998. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8999. <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>';
  9000. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9001. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9002. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9003. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9004. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9005. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9006. }
  9007. $monthStaffPrice = $receiptDetail->find ( array (
  9008. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9009. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9010. 'asArray' => true
  9011. ) );
  9012. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  9013. $m1 += $monthStaffPrice [0] ['price'];
  9014. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9015. } else
  9016. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9017. $list [$value ['username']] = $receiptL;
  9018. }
  9019. }
  9020. $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>
  9021. <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>
  9022. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  9023. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  9024. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  9025. $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>
  9026. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  9027. $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>';
  9028. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  9029. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  9030. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  9031. }
  9032. $data ['list'] = $list;
  9033. $receiptCollectList = $receiptDetail->find ( array (
  9034. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9035. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9036. 'groupby' => 'item,Month(date),itemCategory',
  9037. 'asArray' => true
  9038. ) );
  9039. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9040. // statistics html
  9041. $stList = $statistics->getOne ( array (
  9042. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9043. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9044. 'groupby' => 'Month(date)',
  9045. 'asArray' => true
  9046. ) );
  9047. if (empty ( $stList ))
  9048. $stList = array (
  9049. 'rePrice' => 0,
  9050. 'agPrice' => 0
  9051. );
  9052. $data ['stList'] = array (
  9053. 'rePrice' => $stList ['rePrice'],
  9054. 'agPrice' => $stList ['agPrice'],
  9055. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9056. );
  9057. $monthHtml = "";
  9058. for($i = 1; $i <= 12; $i ++) {
  9059. if ($i == $month)
  9060. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9061. else
  9062. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9063. }
  9064. $data ['monthHtml'] = $monthHtml;
  9065. $data ['year'] = $year;
  9066. $data ['month'] = $month;
  9067. $data ['memu'] = "receipt";
  9068. $data ['staff'] = $this->staff;
  9069. $data ['receiptMemu'] = 'companyCategoryCollect';
  9070. $data ['verifyId'] = $this->verifyId;
  9071. $data ['executeId'] = $this->executeId;
  9072. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  9073. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9074. }
  9075. function companyMonthCollectDetail() {
  9076. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9077. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9078. if (! $year)
  9079. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9080. if (! $month)
  9081. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9082. Doo::loadModel ( 'staff' );
  9083. $staff = new staff ();
  9084. Doo::loadModel ( "receiptDetail" );
  9085. $receiptDetail = new receiptDetail ();
  9086. Doo::loadModel ( 'accountItem' );
  9087. $accountItem = new accountItem ();
  9088. Doo::loadModel ( 'statistics' );
  9089. $statistics = new statistics ();
  9090. Doo::loadModel ( 'L_category' );
  9091. $lCategory = new L_category ();
  9092. $staffList = $staff->find ( array (
  9093. 'where' => 'username!="admin"',
  9094. 'asArray' => true
  9095. ) );
  9096. $categoryList = $lCategory->find ( array (
  9097. 'asArray' => true
  9098. ) );
  9099. $list = array ();
  9100. foreach ( $categoryList as $value ) {
  9101. $receiptCollectList = $receiptDetail->find ( array (
  9102. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9103. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9104. 'groupby' => 'item,Month(pastDate),itemCategory',
  9105. 'asArray' => true
  9106. ) );
  9107. if (! empty ( $receiptCollectList )) {
  9108. $receiptL = array (
  9109. '日常相关费用' => array (),
  9110. '差旅相关费用' => array (),
  9111. '培训班费用' => array (),
  9112. '其他' => array ()
  9113. );
  9114. $html = "";
  9115. $psum = 0;
  9116. $item = array (
  9117. '市内交通费',
  9118. '市内出租费',
  9119. '办事处房租',
  9120. '电话费',
  9121. '水费',
  9122. '电费',
  9123. '办公费用',
  9124. '邮寄费',
  9125. '其他费用',
  9126. '车辆费用',
  9127. '广告费',
  9128. '团队建设费'
  9129. );
  9130. foreach ( $item as $va ) {
  9131. $falg = true;
  9132. foreach ( $receiptCollectList as $v ) {
  9133. if ($v ['itemCategory'] == '日常相关费用') {
  9134. if ($v ['item'] == $va) {
  9135. $psum += $v ['price'];
  9136. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9137. $falg = false;
  9138. break;
  9139. }
  9140. }
  9141. }
  9142. if ($falg)
  9143. $html .= '<td class="taR">-</td>';
  9144. }
  9145. if (! empty ( $psum ))
  9146. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9147. else
  9148. $psum = '<td class="colGreen taR">-</td>';
  9149. $receiptL ['日常相关费用'] = $psum . $html;
  9150. /* ----------------------------------- */
  9151. $html = "";
  9152. $psum = 0;
  9153. $item = array (
  9154. '往来交通费',
  9155. '市内交通费',
  9156. '出差住宿费',
  9157. '出差补助',
  9158. '其他费用'
  9159. );
  9160. foreach ( $item as $va ) {
  9161. $falg = true;
  9162. foreach ( $receiptCollectList as $v ) {
  9163. if ($v ['itemCategory'] == '差旅相关费用') {
  9164. if ($v ['item'] == $va) {
  9165. $psum += $v ['price'];
  9166. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9167. $falg = false;
  9168. break;
  9169. }
  9170. }
  9171. }
  9172. if ($falg)
  9173. $html .= '<td class="taR">-</td>';
  9174. }
  9175. if (! empty ( $psum ))
  9176. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9177. else
  9178. $psum = '<td class="colGreen taR">-</td>';
  9179. $receiptL ['差旅相关费用'] = $psum . $html;
  9180. /* ------------------------------------- */
  9181. $html = "";
  9182. $psum = 0;
  9183. $item = array (
  9184. '场租费',
  9185. '薪酬',
  9186. '住宿费',
  9187. '交通费',
  9188. '餐饮费',
  9189. '办公费',
  9190. '公关费',
  9191. '其他'
  9192. );
  9193. foreach ( $item as $va ) {
  9194. $falg = true;
  9195. foreach ( $receiptCollectList as $v ) {
  9196. if ($v ['itemCategory'] == '培训班费用') {
  9197. if ($v ['item'] == $va) {
  9198. $psum += $v ['price'];
  9199. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9200. $falg = false;
  9201. break;
  9202. }
  9203. }
  9204. }
  9205. if ($falg)
  9206. $html .= '<td class="taR">-</td>';
  9207. }
  9208. if (! empty ( $psum ))
  9209. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9210. else
  9211. $psum = '<td class="colGreen taR">-</td>';
  9212. $receiptL ['培训班费用'] = $psum . $html;
  9213. /* ------------------------------------- */
  9214. $html = "";
  9215. $psum = 0;
  9216. $item = array (
  9217. '公关费',
  9218. '广告费',
  9219. '借款',
  9220. '可自加费用'
  9221. );
  9222. foreach ( $item as $va ) {
  9223. $falg = true;
  9224. foreach ( $receiptCollectList as $v ) {
  9225. if ($v ['itemCategory'] == '其他') {
  9226. if ($v ['item'] == $va) {
  9227. $psum += $v ['price'];
  9228. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9229. $falg = false;
  9230. break;
  9231. }
  9232. }
  9233. }
  9234. if ($falg)
  9235. $html .= '<td class="taR">-</td>';
  9236. }
  9237. if (! empty ( $psum ))
  9238. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9239. else
  9240. $psum = '<td class="colGreen taR">-</td>';
  9241. $receiptL ['其他'] = $psum . $html;
  9242. /* ------------------------------------- */
  9243. $html = "";
  9244. $psum = 0;
  9245. foreach ( $receiptCollectList as $v ) {
  9246. if ($v ['itemCategory'] == '报销金额调整') {
  9247. if (! empty ( $v ['price'] ))
  9248. $psum += $v ['price'];
  9249. }
  9250. }
  9251. if (! empty ( $psum ))
  9252. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9253. else
  9254. $psum = '<td class="taR colOrange">-</td>';
  9255. $receiptL ['报销金额调整'] = $psum . $html;
  9256. } else {
  9257. $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>
  9258. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9259. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9260. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9261. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9262. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9263. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9264. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9265. }
  9266. $monthStaffPrice = $receiptDetail->find ( array (
  9267. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9268. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9269. 'asArray' => true
  9270. ) );
  9271. if (! empty ( $monthStaffPrice [0] ['price'] ))
  9272. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9273. else
  9274. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9275. $list [$value ['title']] = $receiptL;
  9276. }
  9277. $data ['list'] = $list;
  9278. $receiptCollectList = $receiptDetail->find ( array (
  9279. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9280. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9281. 'groupby' => 'item,Month(pastDate),itemCategory',
  9282. 'asArray' => true
  9283. ) );
  9284. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9285. // print_r($data['monthPriceHtml']);
  9286. // foreach ($data['monthPriceHtml'] as $value){
  9287. // echo $value;
  9288. // }
  9289. // die;
  9290. // statistics html
  9291. $stList = $statistics->getOne ( array (
  9292. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9293. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9294. 'groupby' => 'Month(date)',
  9295. 'asArray' => true
  9296. ) );
  9297. if (empty ( $stList ))
  9298. $stList = array (
  9299. 'rePrice' => 0,
  9300. 'agPrice' => 0
  9301. );
  9302. $data ['stList'] = array (
  9303. 'rePrice' => $stList ['rePrice'],
  9304. 'agPrice' => $stList ['agPrice'],
  9305. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9306. );
  9307. $monthHtml = "";
  9308. for($i = 1; $i <= 12; $i ++) {
  9309. if ($i == $month)
  9310. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9311. else
  9312. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9313. }
  9314. $data ['monthHtml'] = $monthHtml;
  9315. $data ['year'] = $year;
  9316. $data ['month'] = $month;
  9317. $data ['memu'] = "receipt";
  9318. $data ['staff'] = $this->staff;
  9319. $data ['receiptMemu'] = 'companyCategoryCollect';
  9320. $data ['verifyId'] = $this->verifyId;
  9321. $data ['executeId'] = $this->executeId;
  9322. $this->render ( "/admin/companyMonthCollectDetail", $data );
  9323. }
  9324. function staffCollectDetail() {
  9325. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9326. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  9327. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  9328. if (! $staffname) {
  9329. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  9330. $staffname = urldecode ( $staffname );
  9331. }
  9332. Doo::loadModel ( 'staff' );
  9333. $staff = new staff ();
  9334. Doo::loadModel ( "receiptDetail" );
  9335. $receiptDetail = new receiptDetail ();
  9336. Doo::loadModel ( 'accountItem' );
  9337. $accountItem = new accountItem ();
  9338. Doo::loadModel ( 'statistics' );
  9339. $statistics = new statistics ();
  9340. Doo::loadModel ( 'L_category' );
  9341. $lCategory = new L_category ();
  9342. $staffList = $staff->find ( array (
  9343. 'asArray' => true
  9344. ) );
  9345. $stHtml = '';
  9346. $stTitle = "";
  9347. $staffId = 0;
  9348. $cid = 0;
  9349. $ocid = 0;
  9350. foreach ( $staffList as $value ) {
  9351. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  9352. $stTitle = $value ['category'] . '-' . $value ['username'];
  9353. $staffId = $value ['sid'];
  9354. $cid = $value ['cid'];
  9355. $ocid = $value ['cid'];
  9356. if (! empty ( $value ['othercid'] ))
  9357. $cid = $value ['cid'] . ',' . $value ['othercid'];
  9358. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9359. } elseif ($value ['username'] != 'admin')
  9360. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9361. }
  9362. $data ['lCategoryHtml'] = $lCategory->find ( array (
  9363. 'where' => 'cid in(' . $cid . ')',
  9364. 'asArray' => true
  9365. ) );
  9366. if (empty ( $pcid ))
  9367. $pcid = $ocid;
  9368. $data ['ocid'] = $pcid;
  9369. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  9370. $this->showCache ( $path );
  9371. //
  9372. $receiptCollectList = $receiptDetail->find ( array (
  9373. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9374. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9375. 'groupby' => 'item,Month(pastDate),itemCategory',
  9376. 'asArray' => true
  9377. ) );
  9378. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  9379. // print_r($receiptCollectList);
  9380. $accountList = $accountItem->find ( array (
  9381. 'asArray' => true
  9382. ) );
  9383. // create CollectDetail HTML
  9384. $collectHtml = array ();
  9385. foreach ( $accountList as $key => $value ) {
  9386. $html = "";
  9387. $asum = 0;
  9388. for($i = 1; $i <= 12; $i ++) {
  9389. $falg = true;
  9390. foreach ( $receiptCollectList as $v ) {
  9391. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9392. if ($v ['item'] == '可自加费用') {
  9393. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  9394. }
  9395. $asum += $v ['price'];
  9396. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9397. $falg = false;
  9398. break;
  9399. }
  9400. }
  9401. if ($falg)
  9402. $html .= '<td class="taR">-</td>';
  9403. }
  9404. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9405. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9406. }
  9407. $data ['collectHtml'] = $collectHtml;
  9408. // print_r($collectHtml);
  9409. // create Adjustment price html
  9410. $receiptCollectList = $receiptDetail->find ( array (
  9411. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9412. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9413. 'groupby' => 'itemCategory,Month(pastDate)',
  9414. 'asArray' => true
  9415. ) );
  9416. $adjustment = array ();
  9417. $collectArray = array (
  9418. '日常相关费用' => array (),
  9419. '差旅相关费用' => array (),
  9420. '培训班费用' => array (),
  9421. '其他' => array ()
  9422. );
  9423. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9424. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9425. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9426. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9427. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9428. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9429. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9430. array_push ( $collectArray ['其他'], $collectHtml );
  9431. $data ['collectArray'] = $collectArray;
  9432. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9433. array_push ( $adjustment, $collectHtml );
  9434. $data ['adjustment'] = $adjustment;
  9435. // total price html
  9436. $collectHtml = "";
  9437. $total = 0;
  9438. for($i = 1; $i <= 12; $i ++) {
  9439. $sumPrice = 0;
  9440. foreach ( $receiptCollectList as $key => $value ) {
  9441. if ($value ['month'] == $i) {
  9442. $sumPrice += $value ['price'];
  9443. }
  9444. }
  9445. if ($sumPrice == 0)
  9446. $collectHtml .= '<td class="taR">-</td>';
  9447. else
  9448. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9449. $total += $sumPrice;
  9450. }
  9451. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9452. // statistics html
  9453. $stList = $statistics->statisticsByYear ( $year, $staffId );
  9454. if (empty ( $stList ))
  9455. $stList = array (
  9456. 'rePrice' => 0,
  9457. 'agPrice' => 0
  9458. );
  9459. $data ['stList'] = array (
  9460. 'rePrice' => $stList ['rePrice'],
  9461. 'agPrice' => $stList ['agPrice'],
  9462. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9463. );
  9464. $data ['totalPrice'] = $collectHtml;
  9465. $data ['totalYear'] = $total;
  9466. $data ['stHtml'] = $stHtml;
  9467. $data ['year'] = $year;
  9468. $data ['stTitle'] = $stTitle;
  9469. $data ['memu'] = "receipt";
  9470. $data ['staff'] = $this->staff;
  9471. $data ['receiptMemu'] = 'companyCategoryCollect';
  9472. $data ['verifyId'] = $this->verifyId;
  9473. $data ['executeId'] = $this->executeId;
  9474. if ($year < date ( "Y" )) {
  9475. Doo::loadModel ( 'receipt' );
  9476. $receipt = new receipt ();
  9477. $receiptList = $receipt->find ( array (
  9478. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  9479. 'asArray' => true
  9480. ) );
  9481. if (empty ( $receiptList )) { // generated files
  9482. ob_start ();
  9483. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9484. $this->cacheFile ( $path );
  9485. die ();
  9486. }
  9487. }
  9488. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9489. }
  9490. function BUGFLAG() {
  9491. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  9492. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  9493. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9494. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9495. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  9496. if (empty ( $status ))
  9497. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  9498. $page_size = 12;
  9499. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  9500. $vidList = array ();
  9501. $button = 0;
  9502. Doo::loadModel ( 'verify' );
  9503. $verify = new verify ();
  9504. Doo::loadModel ( 'receipt' );
  9505. $receipt = new receipt ();
  9506. Doo::loadModel ( 'staff' );
  9507. $staff = new staff ();
  9508. Doo::loadModel ( 'L_category' );
  9509. $Lcategory = new L_category ();
  9510. $dateCondition = " and Year(date) =" . $year;
  9511. if (! empty ( $month ))
  9512. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  9513. $categoryList = $Lcategory->find ( array (
  9514. 'asArray' => true
  9515. ) );
  9516. $staffList = $staff->find ( array (
  9517. 'where' => 'cid=' . $cid,
  9518. 'asArray' => true
  9519. ) );
  9520. $cateCondition = "";
  9521. $staffCondition = "";
  9522. $approvalCondition = "";
  9523. if (! empty ( $cid ))
  9524. $cateCondition = ' and cid=' . $cid;
  9525. if (! empty ( $sid )) {
  9526. $staffCondition = ' and staff=' . $sid;
  9527. $cateCondition = "";
  9528. }
  9529. $approvalCondition = " and status=" . $status;
  9530. if ($status == 2) {
  9531. // 查找角色审批人
  9532. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9533. }
  9534. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  9535. $approvalCondition = ' and status=2 ';
  9536. }
  9537. if ($status == 1) {
  9538. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  9539. }
  9540. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  9541. $pageinfo ['page'] = array (
  9542. 'previous' => ''
  9543. );
  9544. if ($status == 0) {
  9545. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  9546. $receiptList = $receipt->find ( array (
  9547. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  9548. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  9549. 'desc' => 'rid',
  9550. 'asArray' => true
  9551. ) );
  9552. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9553. } else
  9554. $receiptList = $receipt->find ( array (
  9555. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  9556. 'desc' => 'rid',
  9557. 'asArray' => true
  9558. ) );
  9559. $rLRes = $receipt->find ( array (
  9560. '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,
  9561. 'desc' => 'rid',
  9562. 'asArray' => true
  9563. ) );
  9564. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9565. // print_r($pageinfo);
  9566. $Locate = 0;
  9567. foreach ( $receiptList as $key => $value ) {
  9568. $receiptList [$key] ['Locate'] = $Locate;
  9569. $Locate ++;
  9570. $receiptList [$key] ['reviseDetail'] = array ();
  9571. if (! empty ( $value ['reviseDetail'] ))
  9572. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  9573. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  9574. $categoryDetil = $Lcategory->getOne ( array (
  9575. 'where' => 'cid=' . $value ['cid'],
  9576. 'asArray' => true
  9577. ) );
  9578. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  9579. $verifyList = $verify->getOne ( array (
  9580. 'where' => 'vid=' . $value ['verify'],
  9581. 'asArray' => true
  9582. ) );
  9583. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  9584. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  9585. foreach ( $verifyList as $k => $v ) {
  9586. // init verifyStaff
  9587. $verifyList [$k] ['date'] = "";
  9588. $verifyList [$k] ['opinion'] = "";
  9589. $verifyList [$k] ['status'] = "";
  9590. if (empty ( $verifyStaff )) {
  9591. $verifyList [$k] ['date'] = "";
  9592. $verifyList [$k] ['opinion'] = "";
  9593. if ($v [0] == $this->staff [0] ['sid']) {
  9594. $verifyList [$k] ['status'] = 4;
  9595. $button = 4;
  9596. }
  9597. } else {
  9598. $flag = true;
  9599. foreach ( $verifyStaff as $m => $u ) {
  9600. if ($v [0] == $m) {
  9601. $verifyList [$k] ['date'] = $u ['date'];
  9602. $verifyList [$k] ['opinion'] = $u ['opinion'];
  9603. $verifyList [$k] ['status'] = $u ['status'];
  9604. $flag = false;
  9605. break;
  9606. }
  9607. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  9608. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  9609. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  9610. }
  9611. if ($flag) { // 检测可编辑
  9612. if ($v [0] == $this->staff [0] ['sid']) {
  9613. $verifyList [$k] ['status'] = 4;
  9614. $button = 4;
  9615. }
  9616. }
  9617. }
  9618. }
  9619. $receiptList [$key] ['verifyList'] = $verifyList;
  9620. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  9621. 'where' => 'sid=' . $value ['staff'],
  9622. 'asArray' => true
  9623. ) );
  9624. $receiptList [$key] ['button'] = $button;
  9625. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  9626. }
  9627. // print_r($receiptList);die;
  9628. // $data['verifyDetail']=$verifyDetail;
  9629. $mothHtml = "";
  9630. for($i = 1; $i <= 12; $i ++) {
  9631. if ($month == $i)
  9632. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  9633. else
  9634. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  9635. }
  9636. $data ['mothHtml'] = $mothHtml;
  9637. $data ['page'] = $pageinfo;
  9638. $data ['receiptList'] = $receiptList;
  9639. $data ['receiptApprovalCount'] = count ( $rLRes );
  9640. $data ['status'] = $status;
  9641. $data ['year'] = $year;
  9642. $data ['categoryList'] = $categoryList;
  9643. $data ['staffList'] = $staffList;
  9644. $data ['cid'] = $cid;
  9645. $data ['sid'] = $sid;
  9646. // print_r($receiptList);
  9647. $data ['memu'] = "receipt";
  9648. $data ['staff'] = $this->staff;
  9649. $data ['receiptMemu'] = 'approvalExpenses';
  9650. $data ['verifyId'] = $this->verifyId;
  9651. $data ['executeId'] = $this->executeId;
  9652. $this->render ( "/admin/FALG", $data );
  9653. }
  9654. function ajaxGetReceiptOrder() {
  9655. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  9656. if (! empty ( $receiptOrder )) {
  9657. Doo::loadModel ( 'receipt' );
  9658. $receipt = new receipt ();
  9659. Doo::loadModel ( 'staff' );
  9660. $staff = new staff ();
  9661. $receiptInfo = $receipt->getOne ( array (
  9662. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  9663. 'asArray' => true
  9664. ) );
  9665. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  9666. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  9667. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  9668. </tbody></table><table class="table table table-bordered"><tbody>';
  9669. foreach ( $verifyStaff as $key => $value ) {
  9670. $staffInfo = $staff->getOne ( array (
  9671. 'select' => 'username',
  9672. 'where' => ' sid="' . $key . '"',
  9673. 'asArray' => true
  9674. ) );
  9675. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  9676. }
  9677. $html .= '</tbody></table></div></div>';
  9678. echo json_encode ( array (
  9679. 'status' => 1,
  9680. 'receiptHtml' => $html
  9681. ) );
  9682. die ();
  9683. }
  9684. echo json_encode ( array (
  9685. 'status' => 2,
  9686. 'receiptHtml' => ''
  9687. ) );
  9688. die ();
  9689. }
  9690. function _getMonthCollectDetail($receiptCollectList) {
  9691. if (! empty ( $receiptCollectList )) {
  9692. $receiptL = array (
  9693. '日常相关费用' => array (),
  9694. '差旅相关费用' => array (),
  9695. '培训班费用' => array (),
  9696. '其他' => array ()
  9697. );
  9698. $html = "";
  9699. $psum = 0;
  9700. $item = array (
  9701. '市内交通费',
  9702. '市内出租费',
  9703. '办事处房租',
  9704. '电话费',
  9705. '水费',
  9706. '电费',
  9707. '办公费用',
  9708. '邮寄费',
  9709. '其他费用',
  9710. '车辆费用',
  9711. '广告费',
  9712. '团队建设费',
  9713. '物业管理费',
  9714. '宽带费'
  9715. );
  9716. foreach ( $item as $value ) {
  9717. $falg = true;
  9718. foreach ( $receiptCollectList as $v ) {
  9719. if ($v ['itemCategory'] == '日常相关费用') {
  9720. if ($v ['item'] == $value) {
  9721. $psum += $v ['price'];
  9722. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9723. $falg = false;
  9724. break;
  9725. }
  9726. }
  9727. }
  9728. if ($falg)
  9729. $html .= '<td class="taR">-</td>';
  9730. }
  9731. if (! empty ( $psum ))
  9732. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9733. else
  9734. $psum = '<td class="colGreen taR">-</td>';
  9735. $receiptL ['日常相关费用'] = $psum . $html;
  9736. /* ----------------------------------- */
  9737. $html = "";
  9738. $psum = 0;
  9739. $item = array (
  9740. '往来交通费',
  9741. '市内交通费',
  9742. '出差住宿费',
  9743. '出差补助',
  9744. '其他费用'
  9745. );
  9746. foreach ( $item as $value ) {
  9747. $falg = true;
  9748. foreach ( $receiptCollectList as $v ) {
  9749. if ($v ['itemCategory'] == '差旅相关费用') {
  9750. if ($v ['item'] == $value) {
  9751. $psum += $v ['price'];
  9752. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9753. $falg = false;
  9754. break;
  9755. }
  9756. }
  9757. }
  9758. if ($falg)
  9759. $html .= '<td class="taR">-</td>';
  9760. }
  9761. if (! empty ( $psum ))
  9762. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9763. else
  9764. $psum = '<td class="colGreen taR">-</td>';
  9765. $receiptL ['差旅相关费用'] = $psum . $html;
  9766. /* ------------------------------------- */
  9767. $html = "";
  9768. $psum = 0;
  9769. $item = array (
  9770. '场租费',
  9771. '薪酬',
  9772. '住宿费',
  9773. '交通费',
  9774. '餐饮费',
  9775. '办公费',
  9776. '公关费',
  9777. '其他'
  9778. );
  9779. foreach ( $item as $value ) {
  9780. $falg = true;
  9781. foreach ( $receiptCollectList as $v ) {
  9782. if ($v ['itemCategory'] == '培训班费用') {
  9783. if ($v ['item'] == $value) {
  9784. $psum += $v ['price'];
  9785. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9786. $falg = false;
  9787. break;
  9788. }
  9789. }
  9790. }
  9791. if ($falg)
  9792. $html .= '<td class="taR">-</td>';
  9793. }
  9794. if (! empty ( $psum ))
  9795. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9796. else
  9797. $psum = '<td class="colGreen taR">-</td>';
  9798. $receiptL ['培训班费用'] = $psum . $html;
  9799. /* ------------------------------------- */
  9800. $html = "";
  9801. $psum = 0;
  9802. $item = array (
  9803. '公关费',
  9804. '广告费',
  9805. '借款',
  9806. '可自加费用'
  9807. );
  9808. foreach ( $item as $value ) {
  9809. $falg = true;
  9810. foreach ( $receiptCollectList as $v ) {
  9811. if ($v ['itemCategory'] == '其他') {
  9812. if ($v ['item'] == $value) {
  9813. $psum += $v ['price'];
  9814. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9815. $falg = false;
  9816. break;
  9817. }
  9818. }
  9819. }
  9820. if ($falg)
  9821. $html .= '<td class="taR">-</td>';
  9822. }
  9823. if (! empty ( $psum ))
  9824. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9825. else
  9826. $psum = '<td class="colGreen taR">-</td>';
  9827. $receiptL ['其他'] = $psum . $html;
  9828. /* ------------------------------------- */
  9829. $html = "";
  9830. $psum = 0;
  9831. foreach ( $receiptCollectList as $v ) {
  9832. if ($v ['itemCategory'] == '报销金额调整') {
  9833. if (! empty ( $v ['price'] ))
  9834. $psum += $v ['price'];
  9835. }
  9836. }
  9837. if (! empty ( $psum ))
  9838. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9839. else
  9840. $psum = '<td class="taR colOrange">-</td>';
  9841. $receiptL ['报销金额调整'] = $psum . $html;
  9842. } else {
  9843. $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>
  9844. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9845. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9846. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9847. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9848. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9849. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9850. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9851. }
  9852. return $receiptL;
  9853. }
  9854. function eMail() {
  9855. Doo::loadModel ( 'staff' );
  9856. $staff = new staff ();
  9857. Doo::loadModel ( 'receipt' );
  9858. $receipt = new receipt ();
  9859. Doo::loadModel ( 'L_category' );
  9860. $Lcategory = new L_category ();
  9861. Doo::loadModel ( "verify" );
  9862. $verify = new verify ();
  9863. $staffList = $staff->find ( array (
  9864. 'asArray' => true
  9865. ) );
  9866. foreach ( $staffList as $key => $value ) {
  9867. if ($value ['username'] != 'admin') {
  9868. // 提交人
  9869. $receiptList = $receipt->find ( array (
  9870. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  9871. 'asArray' => true
  9872. ) );
  9873. if (! empty ( $receiptList )) {
  9874. $html = '<br><div><style></style>
  9875. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  9876. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  9877. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9878. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  9879. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9880. <tbody><tr>
  9881. <td style="padding: 0 40px;" align="left">
  9882. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9883. </td></tr><tr>
  9884. <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>
  9885. </tr>
  9886. </tbody> </table></td> </tr> <tr><td>
  9887. <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">
  9888. <tbody> <tr><td>
  9889. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  9890. 以下报销单完成了审批,等着收款吧:</p>
  9891. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  9892. foreach ( $receiptList as $k => $v ) {
  9893. $category = $Lcategory->getOne ( array (
  9894. 'where' => 'cid=' . $v ['cid'],
  9895. 'asArray' => true
  9896. ) );
  9897. $html .= '
  9898. <tr>
  9899. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  9900. <td align="left">
  9901. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  9902. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  9903. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  9904. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  9905. </tr>';
  9906. }
  9907. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  9908. <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>
  9909. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  9910. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  9911. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  9912. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9913. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9914. $receipt = new receipt ();
  9915. $receipt->notice = 1;
  9916. $receipt->update ( array (
  9917. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  9918. ) );
  9919. }
  9920. }
  9921. // 审批人
  9922. $verifyList = $verify->find ( array (
  9923. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  9924. 'asArray' => true
  9925. ) );
  9926. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  9927. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  9928. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9929. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  9930. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9931. <tbody><tr><td style="padding: 0 40px;" align="left">
  9932. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9933. </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>
  9934. </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">
  9935. <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>
  9936. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  9937. foreach ( $verifyList as $k => $v ) {
  9938. $receiptList = $receipt->find ( array (
  9939. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  9940. 'asArray' => true
  9941. ) );
  9942. foreach ( $receiptList as $r => $l ) {
  9943. $category = $Lcategory->getOne ( array (
  9944. 'where' => 'cid=' . $l ['cid'],
  9945. 'asArray' => true
  9946. ) );
  9947. $staffDetile = $staff->getOne ( array (
  9948. 'where' => 'sid=' . $l ['staff'],
  9949. 'asArray' => true
  9950. ) );
  9951. $html .= '
  9952. <tr>
  9953. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  9954. <td align="left">
  9955. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  9956. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  9957. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  9958. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  9959. </tr>';
  9960. }
  9961. }
  9962. $html .= '
  9963. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  9964. <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>
  9965. </tr></tbody></table></td></tr></tbody></table></div><br>';
  9966. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  9967. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  9968. // $receipt=new receipt();
  9969. // $receipt->notice=1;
  9970. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  9971. }
  9972. }
  9973. }
  9974. }
  9975. function setWXMsg($rid, $type) {
  9976. Doo::loadModel ( "receipt" );
  9977. $receipt = new receipt ();
  9978. $receiptDetail = $receipt->getOne ( array (
  9979. 'where' => 'rid=' . $rid,
  9980. 'asArray' => true
  9981. ) );
  9982. if (! empty ( $receiptDetail )) {
  9983. Doo::loadModel ( 'staff' );
  9984. $staff = new staff ();
  9985. $staffmsg = $staff->getOne ( array (
  9986. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  9987. 'asArray' => TRUE
  9988. ) );
  9989. if (! empty ( $staffmsg ['wxid'] )) {
  9990. require_once (SITE_PATH . '/protected/class/client.php');
  9991. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  9992. $user = $staffmsg ['wxid'];
  9993. $receiptName = '';
  9994. $msg = '';
  9995. switch ($receiptDetail ['Rtype']) {
  9996. case 0 :
  9997. $receiptName = '报销';
  9998. break;
  9999. case 1 :
  10000. $receiptName = '借款';
  10001. break;
  10002. case 2 :
  10003. $receiptName = '对公汇款';
  10004. break;
  10005. }
  10006. switch ($type) {
  10007. case 1 :
  10008. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  10009. break;
  10010. case 2 :
  10011. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  10012. break;
  10013. case 3 :
  10014. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  10015. break;
  10016. }
  10017. $result = $client->SendMsg ( $user, $msg, 'text' );
  10018. }
  10019. }
  10020. }
  10021. // Email发送函数
  10022. function SMail($toemail, $subject, $contents) {
  10023. Doo::loadClass ( 'class.phpmailer' );
  10024. $mail = new PHPMailer ();
  10025. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  10026. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  10027. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  10028. $mail->Password = "cDO1GjtY1seH"; // 密码
  10029. $mail->CharSet = "UTF8";
  10030. $mail->SMTPAuth = true;
  10031. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  10032. $mail->Mailer = "smtp";
  10033. $mail->Port = 25;
  10034. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  10035. $mail->MsgHTML ( $contents );
  10036. $mail->AddAddress ( $toemail );
  10037. $mail->CharSet = "UTF-8";
  10038. return $mail->Send ();
  10039. }
  10040. function swfupload() {
  10041. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  10042. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  10043. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  10044. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  10045. header ( "HTTP/1.1 500 Internal Server Error" );
  10046. echo "POST exceeded maximum allowed size.";
  10047. exit ( 0 );
  10048. }
  10049. // Settings
  10050. $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)
  10051. $upload_name = "Filedata";
  10052. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  10053. $extension_whitelist = array (
  10054. "doc",
  10055. "txt",
  10056. "jpg",
  10057. "gif",
  10058. "png"
  10059. ); // Allowed file extensions
  10060. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  10061. // Other variables
  10062. $MAX_FILENAME_LENGTH = 260;
  10063. $file_name = "";
  10064. $file_extension = "";
  10065. $uploadErrors = array (
  10066. 0 => "文件上传成功",
  10067. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  10068. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  10069. 3 => "上传的文件仅为部分文件",
  10070. 4 => "没有文件上传",
  10071. 6 => "缺少临时文件夹"
  10072. );
  10073. $nk = time ();
  10074. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  10075. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  10076. echo "文件无法保存.";
  10077. exit ( 0 );
  10078. }
  10079. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  10080. echo json_encode ( array (
  10081. 'filename' => $file_name,
  10082. 'id' => $nk
  10083. ) );
  10084. exit ( 0 );
  10085. }
  10086. function _GetFileEXT($filename) {
  10087. $pics = explode ( '.', $filename );
  10088. $num = count ( $pics );
  10089. return $pics [$num - 1];
  10090. }
  10091. /**
  10092. * 获取get或者POST值
  10093. * @param string $name 属性名称
  10094. * @return fixed 值
  10095. */
  10096. function get_args($name) {
  10097. if (isset ( $_GET [$name] )) {
  10098. if (is_array ( $_GET [$name] ))
  10099. return $_GET [$name];
  10100. else
  10101. return addslashes ( $_GET [$name] );
  10102. } elseif (isset ( $_POST [$name] )) {
  10103. if (is_array ( $_POST [$name] ))
  10104. return $_POST [$name];
  10105. else
  10106. return addslashes ( $_POST [$name] );
  10107. } else
  10108. return false;
  10109. }
  10110. function num_to_rmb($num) {
  10111. $c1 = "零壹贰叁肆伍陆柒捌玖";
  10112. $c2 = "分角元拾佰仟万拾佰仟亿";
  10113. // 精确到分后面就不要了,所以只留两个小数位
  10114. $num = round ( $num, 2 );
  10115. // 将数字转化为整数
  10116. $num = $num * 100;
  10117. if (strlen ( $num ) > 10) {
  10118. return "金额太大,请检查";
  10119. }
  10120. $i = 0;
  10121. $c = "";
  10122. while ( 1 ) {
  10123. if ($i == 0) {
  10124. // 获取最后一位数字
  10125. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  10126. } else {
  10127. $n = $num % 10;
  10128. }
  10129. // 每次将最后一位数字转化为中文
  10130. $p1 = substr ( $c1, 3 * $n, 3 );
  10131. $p2 = substr ( $c2, 3 * $i, 3 );
  10132. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  10133. $c = $p1 . $p2 . $c;
  10134. } else {
  10135. $c = $p1 . $c;
  10136. }
  10137. $i = $i + 1;
  10138. // 去掉数字最后一位了
  10139. $num = $num / 10;
  10140. $num = ( int ) $num;
  10141. // 结束循环
  10142. if ($num == 0) {
  10143. break;
  10144. }
  10145. }
  10146. $j = 0;
  10147. $slen = strlen ( $c );
  10148. while ( $j < $slen ) {
  10149. // utf8一个汉字相当3个字符
  10150. $m = substr ( $c, $j, 6 );
  10151. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  10152. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  10153. $left = substr ( $c, 0, $j );
  10154. $right = substr ( $c, $j + 3 );
  10155. $c = $left . $right;
  10156. $j = $j - 3;
  10157. $slen = $slen - 3;
  10158. }
  10159. $j = $j + 3;
  10160. }
  10161. // 这个是为了去掉类似23.0中最后一个“零”字
  10162. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  10163. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  10164. }
  10165. // 将处理的汉字加上“整”
  10166. if (empty ( $c )) {
  10167. return "零元整";
  10168. } else {
  10169. return $c . "整";
  10170. }
  10171. }
  10172. /**
  10173. * 获得分页数据
  10174. * @param unknown_type $table
  10175. * @param unknown_type $condition
  10176. * @param unknown_type $on_page
  10177. * @param unknown_type $page_size
  10178. */
  10179. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  10180. $page_c = "";
  10181. $page ['previous'] = $this->get_previous ( $on_page );
  10182. $page ['on_page'] = $on_page;
  10183. $total_count = $this->get_table_count ( $table, $condition );
  10184. $total = intval ( $total_count / $page_size );
  10185. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  10186. $page ['total_data'] = $total_count;
  10187. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  10188. $i = 1;
  10189. $page_max = 1;
  10190. $page_width = 3;
  10191. if ($on_page >= $page_width) {
  10192. $page_max = intval ( $on_page / $page_width ) + 1;
  10193. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  10194. }
  10195. for(; $i <= $page ['total_page']; $i ++) {
  10196. if ($i == $on_page)
  10197. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  10198. else
  10199. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  10200. if ($i == ($page_width * $page_max))
  10201. break;
  10202. }
  10203. $page ['page'] = $page_c;
  10204. $page ['lower'] = (-- $on_page) * $page_size;
  10205. return $page;
  10206. }
  10207. /**
  10208. * 获取总页数
  10209. * @param unknown_type $table
  10210. * @param unknown_type $condition
  10211. */
  10212. public function get_table_count($table = "", $condition = "") {
  10213. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10214. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10215. // echo $sql;die;
  10216. $query = Doo::db ()->query ( $sql );
  10217. $result = $query->fetch ();
  10218. return $result ['count'];
  10219. }
  10220. /**
  10221. * 获取上一页
  10222. * @param unknown_type $on_page
  10223. */
  10224. function get_previous($on_page = 1) {
  10225. return $on_page != 0 ? $on_page - 1 : $on_page;
  10226. }
  10227. }
  10228. ?>