ReceiptController.php 391 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116
  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. Doo::loadClass ( 'XDeode' );
  125. $XDeode = new XDeode ( 7 );
  126. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  127. $receiptDetail = $receipt->find ( array (
  128. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  129. 'desc' => 'rid',
  130. 'asArray' => true
  131. ) );
  132. foreach ( $receiptDetail as $key => $value ) {
  133. $receiptDetail [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  134. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  135. $veList = $verify->getOne ( array (
  136. 'where' => 'vid=' . $value ['verify'],
  137. 'asArray' => true
  138. ) );
  139. $v = json_decode ( $veList ['staff'] );
  140. array_push ( $v [0], $veList ['description'] );
  141. foreach ( $v as $n => $m ) {
  142. if ($m ['1'] == 'ROLE') {
  143. $roleInfo = $role->getOne ( array (
  144. 'where' => 'rid=' . $m [0],
  145. 'asArray' => true
  146. ) );
  147. $v [$n] [1] = $roleInfo ['name'];
  148. }
  149. }
  150. $receiptDetail [$key] ['staff'] = $v;
  151. $category = $lCategory->getOne ( array (
  152. 'where' => 'cid=' . $value ['cid'],
  153. 'asArray' => true
  154. ) );
  155. $receiptDetail [$key] ['category'] = $category ['title'];
  156. }
  157. // print_r($receiptLogList);
  158. $data ['receiptLogList'] = $receiptLogList;
  159. $data ['receiptDetail'] = $receiptDetail;
  160. $data ['memu'] = "receipt";
  161. $data ['staff'] = $this->staff;
  162. $data ['receiptMemu'] = 'saeaBorad';
  163. $data ['verifyId'] = $this->verifyId;
  164. $data ['executeId'] = $this->executeId;
  165. $this->render ( "/admin/saeaBorad", $data );
  166. }
  167. function remitAdd() {
  168. Doo::loadModel ( 'accountItem' );
  169. Doo::loadModel ( 'verify' );
  170. Doo::loadModel ( 'receipt' );
  171. Doo::loadModel ( 'L_category' );
  172. $lCategory = new L_category ();
  173. $receipt = new receipt ();
  174. $verify = new verify ();
  175. $accountItem = new accountItem ();
  176. Doo::loadModel ( "role" );
  177. $role = new role ();
  178. $acItem = $accountItem->find ( array (
  179. 'asArray' => true
  180. ) );
  181. $veList = $verify->find ( array (
  182. 'asArray' => true
  183. ) );
  184. foreach ( $veList as $key => $value ) {
  185. $v = json_decode ( $value ['staff'] );
  186. $list = array ();
  187. foreach ( $v as $n => $m ) {
  188. if ($m ['1'] == 'ROLE') {
  189. $roleInfo = $role->getOne ( array (
  190. 'where' => 'rid=' . $m [0],
  191. 'asArray' => true
  192. ) );
  193. $v [$n] [1] = $roleInfo ['name'];
  194. array_push ( $list, $roleInfo ['name'] );
  195. } else {
  196. array_push ( $list, $v [$n] [1] );
  197. }
  198. }
  199. $veList [$key] ['staff'] = implode ( '>', $list );
  200. }
  201. $data ['category'] = $lCategory->find ( array (
  202. 'asArray' => true
  203. ) );
  204. $data ['veList'] = $veList;
  205. $data ['acItem'] = $acItem;
  206. $data ['memu'] = "receipt";
  207. $data ['staff'] = $this->staff;
  208. $data ['receiptMemu'] = 'saeaBorad';
  209. $data ['verifyId'] = $this->verifyId;
  210. $data ['executeId'] = $this->executeId;
  211. $this->render ( "/admin/remitAdd", $data );
  212. }
  213. function remitAddDo() {
  214. $agency = $this->get_args ( 'agency' );
  215. $travel = $this->get_args ( 'travel' );
  216. $train = $this->get_args ( 'train' );
  217. $other = $this->get_args ( 'other' );
  218. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  219. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  220. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  221. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  222. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  223. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  224. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  225. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  226. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  227. // print_r($agency);die;
  228. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  229. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  230. header ( 'Content-Type:text/html;charset=utf-8' );
  231. die ( '请填写联行号' );
  232. }
  233. Doo::loadModel ( 'receipt' );
  234. Doo::loadModel ( 'receiptDetail' );
  235. Doo::loadModel ( 'accountItem' );
  236. $accountItem = new accountItem ();
  237. $receipt = new receipt ();
  238. Doo::loadModel ( 'enclosur' );
  239. Doo::loadModel ( 'execute' );
  240. $execute = new execute ();
  241. $executeDetail = $execute->getOne ( array (
  242. 'where' => 'mold="对公汇款执行人"',
  243. 'asArray' => true
  244. ) );
  245. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  246. $aItem = $accountItem->find ( array (
  247. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  248. 'asArray' => true
  249. ) );
  250. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  251. $ag = $tr = $ta = $ot = 0;
  252. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  253. foreach ( $aItem as $key => $value ) {
  254. if ($value ['category'] == $this->AGENCY) {
  255. if (isset ( $agency [$ag] )) {
  256. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  257. array_push ( $accountJson [$this->AGENCY], array (
  258. 'aid' => $value ['aid'],
  259. 'name' => $value ['name'],
  260. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  261. ) );
  262. $sum += $agency [$ag];
  263. $agencySum += $agency [$ag];
  264. }
  265. }
  266. $ag ++;
  267. }
  268. }
  269. $accountJson ['cSum'] = array (
  270. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  271. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  272. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  273. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  274. );
  275. // 报销单
  276. $receipt->accountItem = json_encode ( $accountJson );
  277. $receipt->staff = $this->staff [0] ['sid'];
  278. $receipt->sum = number_format ( $sum, 2, '.', '' );
  279. $receipt->date = date ( "Y-m-d" );
  280. $receipt->cid = $cid;
  281. $receipt->status = 5;
  282. $receipt->Rtype = 2;
  283. // 修改审批流程加入角色
  284. $receipt->verify = $verify;
  285. $receipt->executeCopy = $executeDetail ['staff'];
  286. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  287. $receipt->explanation = $explanation;
  288. $receipt->remittanceName = $remittanceName;
  289. $receipt->bankName = $bankName;
  290. $receipt->bankNumber = $bankNumber;
  291. $receipt->remittanceBankType = $remittanceBankType;
  292. if ($remittanceBankType == 1)
  293. $receipt->coupletNumber = $coupletNumber;
  294. $rid = $receipt->insert ();
  295. // 附件
  296. if (! empty ( $enclosurName )) {
  297. $enclosurArray = explode ( '-', $enclosurName );
  298. foreach ( $enclosurArray as $value ) {
  299. $enclosur = new enclosur ();
  300. $enclosur->name = $value;
  301. $enclosur->rid = $rid;
  302. $enclosur->insert ();
  303. }
  304. // print_r($enclosurArray);die;
  305. }
  306. // 报销详情
  307. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  308. $receiptDetail = new receiptDetail ();
  309. $receiptDetail->staff = $this->staff [0] ['sid'];
  310. $receiptDetail->item = $value ['name'];
  311. $receiptDetail->itemCategory = $this->AGENCY;
  312. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  313. $receiptDetail->date = date ( "Y-m-d" );
  314. $receiptDetail->cid = $cid;
  315. $receiptDetail->rid = $rid;
  316. $receiptDetail->status = 4;
  317. $receiptDetail->insert ();
  318. }
  319. return "/saeaBorad";
  320. } else
  321. die ( 'illegal request' );
  322. }
  323. function remitEdit() {
  324. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  325. Doo::loadClass ( 'XDeode' );
  326. $XDeode = new XDeode ( 7 );
  327. $rid = $XDeode->decode ( $ridKey );
  328. if (! is_numeric ( $rid ))
  329. die ( 'illegal request' );
  330. Doo::loadModel ( 'accountItem' );
  331. Doo::loadModel ( 'verify' );
  332. Doo::loadModel ( 'receipt' );
  333. $receipt = new receipt ();
  334. $verify = new verify ();
  335. $accountItem = new accountItem ();
  336. Doo::loadModel ( 'L_category' );
  337. $lCategory = new L_category ();
  338. Doo::loadModel ( "role" );
  339. $role = new role ();
  340. Doo::loadModel ( 'enclosur' );
  341. $enclosur = new enclosur ();
  342. $receiptDetail = $receipt->getOne ( array (
  343. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  344. 'asArray' => true
  345. ) );
  346. if (empty ( $receiptDetail ))
  347. return "/saeaCreate";
  348. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  349. $acItem = $accountItem->find ( array (
  350. 'asArray' => true
  351. ) );
  352. $veList = $verify->find ( array (
  353. 'asArray' => true
  354. ) );
  355. foreach ( $veList as $key => $value ) {
  356. $v = json_decode ( $value ['staff'] );
  357. $list = array ();
  358. foreach ( $v as $n => $m ) {
  359. if ($m ['1'] == 'ROLE') {
  360. $roleInfo = $role->getOne ( array (
  361. 'where' => 'rid=' . $m [0],
  362. 'asArray' => true
  363. ) );
  364. $v [$n] [1] = $roleInfo ['name'];
  365. array_push ( $list, $roleInfo ['name'] );
  366. } else {
  367. array_push ( $list, $v [$n] [1] );
  368. }
  369. }
  370. $veList [$key] ['staff'] = implode ( '>', $list );
  371. }
  372. // 配置编辑信息
  373. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  374. foreach ( $acItem as $key => $value ) {
  375. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  376. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  377. $acItem [$key] ['price'] = $v ['price'];
  378. }
  379. }
  380. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  381. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  382. $acItem [$key] ['price'] = $v ['price'];
  383. }
  384. }
  385. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  386. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  387. $acItem [$key] ['price'] = $v ['price'];
  388. }
  389. }
  390. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  391. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  392. $acItem [$key] ['price'] = $v ['price'];
  393. }
  394. }
  395. }
  396. $data ['category'] = $lCategory->find ( array (
  397. 'asArray' => true
  398. ) );
  399. $data ['enclosurList'] = $enclosurList;
  400. $data ['cSum'] = $accountItemList ['cSum'];
  401. $data ['sum'] = $receiptDetail ['sum'];
  402. $data ['receiptDetail'] = $receiptDetail;
  403. $data ['veList'] = $veList;
  404. $data ['acItem'] = $acItem;
  405. $data ['memu'] = "receipt";
  406. $data ['staff'] = $this->staff;
  407. $data ['receiptMemu'] = 'saeaBorad';
  408. $data ['verify'] = $receiptDetail ['verify'];
  409. $data ['verifyId'] = $this->verifyId;
  410. $data ['executeId'] = $this->executeId;
  411. $data ['rid'] = $rid;
  412. $data ['ridKey'] = $ridKey;
  413. $this->render ( "/admin/remitEdit", $data );
  414. }
  415. function remitEdiDo() {
  416. $agency = $this->get_args ( 'agency' );
  417. $travel = $this->get_args ( 'travel' );
  418. $train = $this->get_args ( 'train' );
  419. $other = $this->get_args ( 'other' );
  420. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  421. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  422. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  423. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  424. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  425. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  426. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  427. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  428. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  429. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  430. Doo::loadClass ( 'XDeode' );
  431. $XDeode = new XDeode ( 7 );
  432. $rid = $XDeode->decode ( $ridKey );
  433. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  434. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  435. header ( 'Content-Type:text/html;charset=utf-8' );
  436. die ( '请填写联行号' );
  437. }
  438. Doo::loadModel ( 'receipt' );
  439. Doo::loadModel ( 'receiptDetail' );
  440. Doo::loadModel ( 'accountItem' );
  441. $accountItem = new accountItem ();
  442. $receipt = new receipt ();
  443. Doo::loadModel ( 'enclosur' );
  444. $enclosur = new enclosur ();
  445. Doo::loadModel ( 'execute' );
  446. $execute = new execute ();
  447. $executeDetail = $execute->getOne ( array (
  448. 'where' => 'mold="对公汇款执行人"',
  449. 'asArray' => true
  450. ) );
  451. $receiptDetail = $receipt->getOne ( array (
  452. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  453. 'asArray' => true
  454. ) );
  455. if (empty ( $receiptDetail ))
  456. return "/saeaBorad";
  457. $aItem = $accountItem->find ( array (
  458. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  459. 'asArray' => true
  460. ) );
  461. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  462. $ag = $tr = $ta = $ot = 0;
  463. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  464. foreach ( $aItem as $key => $value ) {
  465. if ($value ['category'] == $this->AGENCY) {
  466. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  467. array_push ( $accountJson [$this->AGENCY], array (
  468. 'aid' => $value ['aid'],
  469. 'name' => $value ['name'],
  470. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  471. ) );
  472. $sum += $agency [$ag];
  473. $agencySum += $agency [$ag];
  474. }
  475. $ag ++;
  476. }
  477. }
  478. $accountJson ['cSum'] = array (
  479. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  480. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  481. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  482. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  483. );
  484. // 报销单
  485. $rid = $receipt->rid = $receiptDetail ['rid'];
  486. $receipt->accountItem = json_encode ( $accountJson );
  487. $receipt->staff = $this->staff [0] ['sid'];
  488. $receipt->sum = number_format ( $sum, 2, '.', '' );
  489. $receipt->date = date ( "Y-m-d" );
  490. $receipt->cid = $cid;
  491. if ($receiptDetail ['Rtype'] == 1)
  492. $receipt->status = 7;
  493. else
  494. $receipt->status = 5;
  495. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  496. $receipt->verify = $verify;
  497. $receipt->executeCopy = $executeDetail ['staff'];
  498. $receipt->explanation = $explanation;
  499. $receipt->remittanceName = $remittanceName;
  500. $receipt->bankName = $bankName;
  501. $receipt->bankNumber = $bankNumber;
  502. $receipt->remittanceBankType = $remittanceBankType;
  503. if ($remittanceBankType == 1)
  504. $receipt->coupletNumber = $coupletNumber;
  505. $receipt->update ();
  506. $receiptDetail = new receiptDetail ();
  507. $receiptDetail->delete ( array (
  508. 'where' => 'rid=' . $rid
  509. ) );
  510. // 报销详情
  511. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  512. $receiptDetail = new receiptDetail ();
  513. $receiptDetail->staff = $this->staff [0] ['sid'];
  514. $receiptDetail->item = $value ['name'];
  515. $receiptDetail->itemCategory = $this->AGENCY;
  516. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  517. $receiptDetail->date = date ( "Y-m-d" );
  518. $receiptDetail->cid = $cid;
  519. $receiptDetail->rid = $rid;
  520. $receiptDetail->status = 4;
  521. $receiptDetail->insert ();
  522. }
  523. // 附件
  524. if (! empty ( $enclosurName )) {
  525. $enclosurArray = explode ( '-', $enclosurName );
  526. foreach ( $enclosurArray as $value ) {
  527. $enclosur = new enclosur ();
  528. $enclosur->name = $value;
  529. $enclosur->rid = $rid;
  530. $enclosur->insert ();
  531. }
  532. }
  533. }
  534. return "/saeaBorad";
  535. }
  536. function remitApproval() {
  537. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  538. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  539. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  540. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  541. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  542. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  543. if (empty ( $status ))
  544. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  545. $vidList = array ();
  546. $button = 0;
  547. Doo::loadModel ( 'verify' );
  548. Doo::loadModel ( 'receipt' );
  549. Doo::loadModel ( 'staff' );
  550. $staff = new staff ();
  551. $receipt = new receipt ();
  552. $verify = new verify ();
  553. Doo::loadModel ( 'L_category' );
  554. $Lcategory = new L_category ();
  555. Doo::loadModel ( 'enclosur' );
  556. $enclosur = new enclosur ();
  557. // user verify ID
  558. $verifyDetail = $verify->find ( array (
  559. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  560. 'asArray' => true
  561. ) );
  562. foreach ( $verifyDetail as $key => $value ) {
  563. array_push ( $vidList, $value ['vid'] );
  564. }
  565. $vid = implode ( ",", $vidList );
  566. if (empty ( $verifyDetail ))
  567. $vid = 0;
  568. $categoryList = $Lcategory->find ( array (
  569. 'asArray' => true
  570. ) );
  571. $staffList = $staff->find ( array (
  572. 'where' => 'cid=' . $cid,
  573. 'asArray' => true
  574. ) );
  575. $ap = "";
  576. if ($status == 4) {
  577. $ap = 4;
  578. $status = 2;
  579. }
  580. // get Receipt By verifyID status 2
  581. $receiptList = $receipt->find ( array (
  582. 'where' => 'rid =' . $rid . ' and status=2',
  583. 'desc' => 'rid',
  584. 'asArray' => true
  585. ) );
  586. if (empty ( $receiptList )) {
  587. die ( 'illegal request' );
  588. }
  589. $Locate = 0;
  590. $roleId = 0;
  591. if ($ap == 4)
  592. $status = 4;
  593. foreach ( $receiptList as $key => $value ) {
  594. $receiptList [$key] ['Locate'] = $Locate;
  595. $Locate ++;
  596. $receiptList [$key] ['reviseDetail'] = array ();
  597. if (! empty ( $value ['reviseDetail'] ))
  598. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  599. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  600. $categoryDetil = $Lcategory->getOne ( array (
  601. 'where' => 'cid=' . $value ['cid'],
  602. 'asArray' => true
  603. ) );
  604. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  605. // 检测编辑状态
  606. $verifyList = $verify->getOne ( array (
  607. 'where' => 'vid=' . $value ['verify'],
  608. 'asArray' => true
  609. ) );
  610. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  611. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  612. Doo::loadModel ( 'role' );
  613. $role = new role ();
  614. // print_r($verifyList);
  615. $flag = true;
  616. $roleKey = 0;
  617. $endStaffArray = array ();
  618. $roleArrayCopy = array ();
  619. foreach ( $verifyList as $k => $v ) {
  620. // init verifyStaff
  621. if ($v [1] == 'ROLE') {
  622. if (! empty ( $verifyStaff )) {
  623. $endStaffArray = end ( $verifyStaff );
  624. if ($v [0] == $endStaffArray ['nextStaff']) {
  625. $roleId = $v [0];
  626. }
  627. }
  628. $roleVerify = json_decode ( $v [3], true );
  629. $roleKey = $k;
  630. $roleArray = array ();
  631. $rolename = $role->getOne ( array (
  632. 'where' => 'rid=' . $v [0],
  633. 'asArray' => true
  634. ) );
  635. foreach ( $roleVerify as $o => $p ) {
  636. $staffID = explode ( '_', $p );
  637. $staffInfo = $staff->getOne ( array (
  638. 'where' => 'sid=' . $staffID [0],
  639. 'asArray' => true
  640. ) );
  641. // print_r($staffID);
  642. $exp = array (
  643. 0 => $staffInfo ['sid'],
  644. 1 => $staffID [1],
  645. 2 => $staffInfo ['avatar'],
  646. 'date' => '',
  647. 'date' => '',
  648. 'opinion' => '',
  649. 'status' => '',
  650. 'rolename' => $rolename ['name']
  651. );
  652. array_push ( $roleArray, $exp );
  653. }
  654. $roleArrayCopy [$v [0]] = $roleArray;
  655. // $verifyList[$k]['roleArray']=$roleArray;
  656. }
  657. // print_r($roleArray);
  658. $verifyList [$k] ['date'] = "";
  659. $verifyList [$k] ['opinion'] = "";
  660. $verifyList [$k] ['status'] = "";
  661. if (empty ( $verifyStaff )) {
  662. $verifyList [$k] ['date'] = "";
  663. $verifyList [$k] ['opinion'] = "";
  664. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  665. $verifyList [$k] ['status'] = 4;
  666. $button = 4;
  667. $flag = false;
  668. }
  669. } else {
  670. foreach ( $verifyStaff as $m => $u ) {
  671. if ($v [0] == $m) {
  672. $verifyList [$k] ['date'] = $u ['date'];
  673. $verifyList [$k] ['opinion'] = $u ['opinion'];
  674. $verifyList [$k] ['status'] = $u ['status'];
  675. $flag = false;
  676. break;
  677. }
  678. }
  679. $endStaffArray = end ( $verifyStaff );
  680. if (isset ( $endStaffArray ['ROLE'] )) {
  681. } else {
  682. $endKey = key ( $verifyStaff );
  683. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  684. $button = 4;
  685. $verifyList [$k] ['status'] = 4;
  686. }
  687. }
  688. }
  689. }
  690. $rolename ['name'] = '';
  691. if (! empty ( $roleId )) {
  692. Doo::loadModel ( 'role' );
  693. $role = new role ();
  694. $rolename = $role->getOne ( array (
  695. 'where' => 'rid=' . $roleId,
  696. 'asArray' => true
  697. ) );
  698. }
  699. if (! empty ( $verifyStaff ))
  700. $endStaffArray = end ( $verifyStaff );
  701. $KOP = false;
  702. foreach ( $roleArrayCopy as $P => $A ) {
  703. foreach ( $A as $MKI => $AVL ) {
  704. if (! empty ( $verifyStaff )) {
  705. // &&$rolename['rid']==$endStaffArray['nextStaff']
  706. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  707. $button = 4;
  708. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  709. }
  710. foreach ( $verifyStaff as $m => $u ) {
  711. $AVLFK = $AVL [0] . '_R';
  712. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  713. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  714. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  715. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  716. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  717. break;
  718. }
  719. }
  720. } else {
  721. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  722. $button = 4;
  723. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  724. }
  725. }
  726. // $roleArray[$MKI]['rolename']=$rolename['name'];
  727. $KOP = true;
  728. }
  729. }
  730. foreach ( $roleArrayCopy as $k => $v ) {
  731. foreach ( $verifyList as $m => $n ) {
  732. if ($n [0] == $k) {
  733. array_splice ( $verifyList, $m, 1, $v );
  734. }
  735. }
  736. }
  737. $receiptList [$key] ['verifyList'] = $verifyList;
  738. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  739. 'where' => 'sid=' . $value ['staff'],
  740. 'asArray' => true
  741. ) );
  742. $receiptList [$key] ['button'] = $button;
  743. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  744. }
  745. $mothHtml = "";
  746. for($i = 1; $i <= 12; $i ++) {
  747. if ($month == $i)
  748. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  749. else
  750. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  751. }
  752. // 获取审批日志
  753. Doo::loadModel ( 'receiptLog' );
  754. $receiptLog = new receiptLog ();
  755. $rlList = array ();
  756. $rlInfo = $receiptLog->getOne ( array (
  757. 'where' => 'rid=' . $rid . ' and status=4',
  758. 'asArray' => true
  759. ) );
  760. $tijdate = $receiptLog->getOne ( array (
  761. 'where' => 'rid=' . $rid . ' and status=2',
  762. 'asc' => 'rlid',
  763. 'asArray' => true
  764. ) );
  765. if (! empty ( $rlInfo )) {
  766. $rlList = $receiptLog->find ( array (
  767. 'where' => 'rid=' . $rid,
  768. 'asc' => 'rlid',
  769. 'asArray' => true
  770. ) );
  771. }
  772. $receiptList [0] ['rlList'] = $rlList;
  773. $enclosurList = $enclosur->find ( array (
  774. 'where' => 'rid=' . $rid,
  775. 'asArray' => true
  776. ) );
  777. $enclosurHtml = '';
  778. foreach ( $enclosurList as $value ) {
  779. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  780. }
  781. // print_r($receiptList);
  782. $data ['enclosurHtml'] = $enclosurHtml;
  783. $data ['rolename'] = $rolename ['name'];
  784. $data ['datetij'] = $tijdate ['date'];
  785. $data ['mothHtml'] = $mothHtml;
  786. $data ['rid'] = $rid;
  787. $data ['receiptList'] = $receiptList;
  788. $data ['receiptApprovalCount'] = count ( $receiptList );
  789. $data ['status'] = $status;
  790. $data ['year'] = $year;
  791. $data ['categoryList'] = $categoryList;
  792. $data ['staffList'] = $staffList;
  793. $data ['cid'] = $cid;
  794. $data ['sid'] = $sid;
  795. $data ['ap'] = $ap;
  796. $data ['memu'] = "receipt";
  797. $data ['staff'] = $this->staff;
  798. $data ['receiptMemu'] = 'approvalExpenses';
  799. $data ['verifyId'] = $this->verifyId;
  800. $data ['executeId'] = $this->executeId;
  801. $this->render ( "/admin/remitApproval", $data );
  802. }
  803. function saeaLoanAdd() {
  804. Doo::loadModel ( 'verify' );
  805. $verify = new verify ();
  806. Doo::loadModel ( "role" );
  807. $role = new role ();
  808. Doo::loadModel ( 'L_category' );
  809. $lCategory = new L_category ();
  810. $veList = $verify->find ( array (
  811. 'asArray' => true
  812. ) );
  813. foreach ( $veList as $key => $value ) {
  814. $v = json_decode ( $value ['staff'] );
  815. $list = array ();
  816. foreach ( $v as $n => $m ) {
  817. if ($m ['1'] == 'ROLE') {
  818. $roleInfo = $role->getOne ( array (
  819. 'where' => 'rid=' . $m [0],
  820. 'asArray' => true
  821. ) );
  822. $v [$n] [1] = $roleInfo ['name'];
  823. array_push ( $list, $roleInfo ['name'] );
  824. } else {
  825. array_push ( $list, $v [$n] [1] );
  826. }
  827. }
  828. $veList [$key] ['staff'] = implode ( '>', $list );
  829. }
  830. $data ['category'] = $lCategory->find ( array (
  831. 'asArray' => true
  832. ) );
  833. $data ['veList'] = $veList;
  834. $data ['memu'] = "receipt";
  835. $data ['staff'] = $this->staff;
  836. $data ['receiptMemu'] = 'saeaBorad';
  837. $data ['verifyId'] = $this->verifyId;
  838. $data ['executeId'] = $this->executeId;
  839. $this->render ( "/admin/saeaLoanAdd", $data );
  840. }
  841. function saeaLoanAddDo() {
  842. $agency = $this->get_args ( 'agency' );
  843. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  844. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  845. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  846. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  847. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  848. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  849. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  850. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  851. // die;
  852. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  853. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  854. header ( 'Content-Type:text/html;charset=utf-8' );
  855. die ( '请填写联行号' );
  856. }
  857. Doo::loadModel ( 'receipt' );
  858. Doo::loadModel ( 'receiptDetail' );
  859. Doo::loadModel ( 'accountItem' );
  860. $accountItem = new accountItem ();
  861. $receipt = new receipt ();
  862. Doo::loadModel ( 'loanReceipt' );
  863. $loanReceipt = new loanReceipt ();
  864. Doo::loadModel ( 'execute' );
  865. $execute = new execute ();
  866. Doo::loadModel ( 'enclosur' );
  867. $executeDetail = $execute->getOne ( array (
  868. 'where' => 'mold="借款执行人"',
  869. 'asArray' => true
  870. ) );
  871. $aItem = $accountItem->find ( array (
  872. 'asArray' => true
  873. ) );
  874. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  875. $ag = $tr = $ta = $ot = 0;
  876. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  877. array_push ( $accountJson ['借款费用'], array (
  878. 'aid' => 0,
  879. 'name' => '申请金额',
  880. 'price' => number_format ( $agency, 2, '.', '' )
  881. ) );
  882. $sum += $agency;
  883. $agencySum += $agency;
  884. $accountJson ['cSum'] = array (
  885. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  886. 'agencySum' => number_format ( 0, 2, '.', '' ),
  887. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  888. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  889. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  890. );
  891. // 借款数据备份
  892. $loanReceipt->loanItem = json_encode ( $accountJson );
  893. $loanReceipt->staff = $this->staff [0] ['sid'];
  894. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  895. $loanReceipt->date = date ( "Y-m-d" );
  896. $loanReceipt->cid = $cid;
  897. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  898. $loanReceipt->status = 5;
  899. $loanReceipt->Rtype = 1;
  900. $loanReceipt->verify = $verify;
  901. $receipt->receiptOrder = $receipt->receiptOrder;
  902. $loanReceipt->explanation = $explanation;
  903. $loanRid = $loanReceipt->insert ();
  904. // 报销单
  905. $receipt->loanItem = json_encode ( $accountJson );
  906. $receipt->staff = $this->staff [0] ['sid'];
  907. $receipt->sum = number_format ( $sum, 2, '.', '' );
  908. $receipt->date = date ( "Y-m-d" );
  909. $receipt->cid = $cid;
  910. // 特殊状态
  911. $receipt->status = 5;
  912. $receipt->Rtype = 1;
  913. $receipt->loanRid = $loanRid;
  914. // 修改审批流程加入角色
  915. $receipt->verify = $verify;
  916. $receipt->executeCopy = $executeDetail ['staff'];
  917. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  918. $receipt->explanation = $explanation;
  919. $receipt->remittanceName = $remittanceName;
  920. $receipt->bankName = $bankName;
  921. $receipt->bankNumber = $bankNumber;
  922. $receipt->remittanceBankType = $remittanceBankType;
  923. if ($remittanceBankType == 1)
  924. $receipt->coupletNumber = $coupletNumber;
  925. $rid = $receipt->insert ();
  926. return "/saeaBorad";
  927. } else
  928. die ( 'illegal request' );
  929. }
  930. function saeaLoanEdi() {
  931. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  932. Doo::loadClass ( 'XDeode' );
  933. $XDeode = new XDeode ( 7 );
  934. $rid = $XDeode->decode ( $ridKey );
  935. if (! is_numeric ( $rid ))
  936. die ( 'illegal request' );
  937. Doo::loadModel ( 'verify' );
  938. $verify = new verify ();
  939. Doo::loadModel ( "role" );
  940. $role = new role ();
  941. Doo::loadModel ( 'L_category' );
  942. $lCategory = new L_category ();
  943. Doo::loadModel ( 'receipt' );
  944. $receipt = new receipt ();
  945. $receiptInfo = $receipt->getOne ( array (
  946. 'where' => 'rid=' . $rid,
  947. 'asArray' => true
  948. ) );
  949. $veList = $verify->find ( array (
  950. 'asArray' => true
  951. ) );
  952. foreach ( $veList as $key => $value ) {
  953. $v = json_decode ( $value ['staff'] );
  954. $list = array ();
  955. foreach ( $v as $n => $m ) {
  956. if ($m ['1'] == 'ROLE') {
  957. $roleInfo = $role->getOne ( array (
  958. 'where' => 'rid=' . $m [0],
  959. 'asArray' => true
  960. ) );
  961. $v [$n] [1] = $roleInfo ['name'];
  962. array_push ( $list, $roleInfo ['name'] );
  963. } else {
  964. array_push ( $list, $v [$n] [1] );
  965. }
  966. }
  967. $veList [$key] ['staff'] = implode ( '>', $list );
  968. }
  969. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  970. // print_r($receiptInfo);
  971. $data ['receiptInfo'] = $receiptInfo;
  972. $data ['category'] = $lCategory->find ( array (
  973. 'asArray' => true
  974. ) );
  975. $data ['veList'] = $veList;
  976. $data ['ridKey'] = $ridKey;
  977. $data ['memu'] = "receipt";
  978. $data ['staff'] = $this->staff;
  979. $data ['receiptMemu'] = 'saeaBorad';
  980. $data ['verifyId'] = $this->verifyId;
  981. $data ['executeId'] = $this->executeId;
  982. $this->render ( "/admin/saeaLoanEdi", $data );
  983. }
  984. function saeaLoanEdiDo() {
  985. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  986. $agency = $this->get_args ( 'agency' );
  987. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  988. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  989. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  990. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  991. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  992. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  993. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  994. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  995. // die;
  996. Doo::loadClass ( 'XDeode' );
  997. $XDeode = new XDeode ( 7 );
  998. $rid = $XDeode->decode ( $ridKey );
  999. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1000. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1001. header ( 'Content-Type:text/html;charset=utf-8' );
  1002. die ( '请填写联行号' );
  1003. }
  1004. Doo::loadModel ( 'receipt' );
  1005. Doo::loadModel ( 'receiptDetail' );
  1006. Doo::loadModel ( 'accountItem' );
  1007. $accountItem = new accountItem ();
  1008. $receipt = new receipt ();
  1009. Doo::loadModel ( 'loanReceipt' );
  1010. $loanReceipt = new loanReceipt ();
  1011. Doo::loadModel ( 'enclosur' );
  1012. Doo::loadModel ( 'execute' );
  1013. $execute = new execute ();
  1014. $executeDetail = $execute->getOne ( array (
  1015. 'where' => 'mold="借款执行人"',
  1016. 'asArray' => true
  1017. ) );
  1018. $receiptDetail = $receipt->getOne ( array (
  1019. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  1020. 'asArray' => true
  1021. ) );
  1022. if (empty ( $receiptDetail ))
  1023. die ( '参数错误' );
  1024. $aItem = $accountItem->find ( array (
  1025. 'asArray' => true
  1026. ) );
  1027. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1028. $ag = $tr = $ta = $ot = 0;
  1029. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1030. array_push ( $accountJson ['借款费用'], array (
  1031. 'aid' => 0,
  1032. 'name' => '申请金额',
  1033. 'price' => number_format ( $agency, 2, '.', '' )
  1034. ) );
  1035. $sum += $agency;
  1036. $agencySum += $agency;
  1037. $accountJson ['cSum'] = array (
  1038. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1039. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1040. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1041. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1042. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1043. );
  1044. // 报销单
  1045. $receipt->loanItem = json_encode ( $accountJson );
  1046. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1047. $receipt->cid = $cid;
  1048. // 特殊状态
  1049. // 修改审批流程加入角色
  1050. if ($receiptDetail ['status'] != 4)
  1051. $receipt->verify = $verify;
  1052. $receipt->explanation = $explanation;
  1053. $receipt->remittanceName = $remittanceName;
  1054. $receipt->bankName = $bankName;
  1055. $receipt->bankNumber = $bankNumber;
  1056. $receipt->remittanceBankType = $remittanceBankType;
  1057. if ($remittanceBankType == 1)
  1058. $receipt->coupletNumber = $coupletNumber;
  1059. $receipt->update ( array (
  1060. 'where' => 'rid=' . $rid
  1061. ) );
  1062. // 借款数据更新
  1063. $loanReceipt->loanItem = json_encode ( $accountJson );
  1064. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1065. $loanReceipt->cid = $cid;
  1066. if ($receiptDetail ['status'] != 4)
  1067. $loanReceipt->verify = $verify;
  1068. $loanReceipt->explanation = $explanation;
  1069. $receipt->executeCopy = $executeDetail ['staff'];
  1070. $loanReceipt->update ( array (
  1071. 'where' => 'rid=' . $receiptDetail ['loanRid']
  1072. ) );
  1073. }
  1074. return "/saeaBorad";
  1075. }
  1076. function saeaLoanReceiptAdd() {
  1077. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1078. Doo::loadModel ( 'receipt' );
  1079. $receipt = new receipt ();
  1080. Doo::loadModel ( 'loanReceipt' );
  1081. $loanReceipt = new loanReceipt ();
  1082. Doo::loadModel ( 'L_category' );
  1083. $Lcategory = new L_category ();
  1084. Doo::loadModel ( 'verify' );
  1085. Doo::loadModel ( 'statistics' );
  1086. $statistics = new statistics ();
  1087. $verify = new verify ();
  1088. Doo::loadModel ( 'staff' );
  1089. $staff = new staff ();
  1090. $receiptDetail = $receipt->getOne ( array (
  1091. 'where' => 'rid=' . $rid,
  1092. 'desc' => 'rid',
  1093. 'asArray' => true
  1094. ) );
  1095. $receiptList = $loanReceipt->find ( array (
  1096. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1097. 'desc' => 'rid',
  1098. 'asArray' => true
  1099. ) );
  1100. $Locate = 0;
  1101. $roleId = 0;
  1102. $button = 0;
  1103. foreach ( $receiptList as $key => $value ) {
  1104. $receiptList [$key] ['Locate'] = $Locate;
  1105. $Locate ++;
  1106. $receiptList [$key] ['reviseDetail'] = array ();
  1107. if (! empty ( $value ['reviseDetail'] ))
  1108. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1109. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1110. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1111. $categoryDetil = $Lcategory->getOne ( array (
  1112. 'where' => 'cid=' . $value ['cid'],
  1113. 'asArray' => true
  1114. ) );
  1115. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1116. // 检测编辑状态
  1117. $verifyList = $verify->getOne ( array (
  1118. 'where' => 'vid=' . $value ['verify'],
  1119. 'asArray' => true
  1120. ) );
  1121. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1122. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1123. Doo::loadModel ( 'role' );
  1124. $role = new role ();
  1125. $flag = true;
  1126. $roleKey = 0;
  1127. $endStaffArray = array ();
  1128. $roleArrayCopy = array ();
  1129. foreach ( $verifyList as $k => $v ) {
  1130. // init verifyStaff
  1131. if ($v [1] == 'ROLE') {
  1132. if (! empty ( $verifyStaff )) {
  1133. $endStaffArray = end ( $verifyStaff );
  1134. // if ($v[0]==$endStaffArray['nextStaff']){
  1135. // $roleId=$v[0];
  1136. // }
  1137. }
  1138. $roleVerify = json_decode ( $v [3], true );
  1139. $roleKey = $k;
  1140. $roleArray = array ();
  1141. $rolename = $role->getOne ( array (
  1142. 'where' => 'rid=' . $v [0],
  1143. 'asArray' => true
  1144. ) );
  1145. foreach ( $roleVerify as $o => $p ) {
  1146. $staffID = explode ( '_', $p );
  1147. $staffInfo = $staff->getOne ( array (
  1148. 'where' => 'sid=' . $staffID [0],
  1149. 'asArray' => true
  1150. ) );
  1151. // print_r($staffID);
  1152. $exp = array (
  1153. 0 => $staffInfo ['sid'],
  1154. 1 => $staffID [1],
  1155. 2 => $staffInfo ['avatar'],
  1156. 'date' => '',
  1157. 'date' => '',
  1158. 'opinion' => '',
  1159. 'status' => '',
  1160. 'rolename' => $rolename ['name']
  1161. );
  1162. array_push ( $roleArray, $exp );
  1163. }
  1164. $roleArrayCopy [$v [0]] = $roleArray;
  1165. // $verifyList[$k]['roleArray']=$roleArray;
  1166. }
  1167. $verifyList [$k] ['date'] = "";
  1168. $verifyList [$k] ['opinion'] = "";
  1169. $verifyList [$k] ['status'] = "";
  1170. if (empty ( $verifyStaff )) {
  1171. $verifyList [$k] ['date'] = "";
  1172. $verifyList [$k] ['opinion'] = "";
  1173. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1174. $verifyList [$k] ['status'] = 4;
  1175. $flag = false;
  1176. }
  1177. } else {
  1178. foreach ( $verifyStaff as $m => $u ) {
  1179. if ($v [0] == $m) {
  1180. $verifyList [$k] ['date'] = $u ['date'];
  1181. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1182. $verifyList [$k] ['status'] = $u ['status'];
  1183. $flag = false;
  1184. break;
  1185. }
  1186. }
  1187. $endStaffArray = end ( $verifyStaff );
  1188. if (isset ( $endStaffArray ['ROLE'] )) {
  1189. } else {
  1190. // $endKey=key($verifyStaff);
  1191. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1192. // $button=4;
  1193. // $verifyList[$k]['status']=4;
  1194. // }
  1195. }
  1196. }
  1197. }
  1198. $rolename ['name'] = '';
  1199. if (! empty ( $roleId )) {
  1200. Doo::loadModel ( 'role' );
  1201. $role = new role ();
  1202. $rolename = $role->getOne ( array (
  1203. 'where' => 'rid=' . $roleId,
  1204. 'asArray' => true
  1205. ) );
  1206. }
  1207. if (! empty ( $verifyStaff ))
  1208. $endStaffArray = end ( $verifyStaff );
  1209. $KOP = false;
  1210. foreach ( $roleArrayCopy as $P => $A ) {
  1211. foreach ( $A as $MKI => $AVL ) {
  1212. if (! empty ( $verifyStaff )) {
  1213. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1214. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1215. $button = 4;
  1216. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1217. }
  1218. foreach ( $verifyStaff as $m => $u ) {
  1219. $AVLFK = $AVL [0] . '_R';
  1220. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1221. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1222. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1223. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1224. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1225. break;
  1226. }
  1227. }
  1228. } else {
  1229. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1230. $button = 4;
  1231. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1232. }
  1233. }
  1234. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1235. $KOP = true;
  1236. }
  1237. }
  1238. foreach ( $roleArrayCopy as $k => $v ) {
  1239. foreach ( $verifyList as $m => $n ) {
  1240. if ($n [0] == $k) {
  1241. array_splice ( $verifyList, $m, 1, $v );
  1242. }
  1243. }
  1244. }
  1245. $receiptList [$key] ['verifyList'] = $verifyList;
  1246. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1247. 'where' => 'sid=' . $value ['staff'],
  1248. 'asArray' => true
  1249. ) );
  1250. $receiptList [$key] ['button'] = $button;
  1251. //
  1252. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1253. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1254. }
  1255. $data ['receiptList'] = $receiptList;
  1256. $data ['receiptDetail'] = $receiptDetail;
  1257. Doo::loadModel ( 'L_category' );
  1258. $lCategory = new L_category ();
  1259. Doo::loadModel ( 'accountItem' );
  1260. $accountItem = new accountItem ();
  1261. $acItem = $accountItem->find ( array (
  1262. 'asArray' => true
  1263. ) );
  1264. $veList = $verify->find ( array (
  1265. 'asArray' => true
  1266. ) );
  1267. foreach ( $veList as $key => $value ) {
  1268. $v = json_decode ( $value ['staff'] );
  1269. $list = array ();
  1270. foreach ( $v as $n => $m ) {
  1271. if ($m ['1'] == 'ROLE') {
  1272. $roleInfo = $role->getOne ( array (
  1273. 'where' => 'rid=' . $m [0],
  1274. 'asArray' => true
  1275. ) );
  1276. $v [$n] [1] = $roleInfo ['name'];
  1277. array_push ( $list, $roleInfo ['name'] );
  1278. } else {
  1279. array_push ( $list, $v [$n] [1] );
  1280. }
  1281. }
  1282. $veList [$key] ['staff'] = implode ( '>', $list );
  1283. }
  1284. $data ['rid'] = $rid;
  1285. $data ['category'] = $lCategory->find ( array (
  1286. 'asArray' => true
  1287. ) );
  1288. $data ['veList'] = $veList;
  1289. $data ['acItem'] = $acItem;
  1290. $data ['memu'] = "receipt";
  1291. $data ['staff'] = $this->staff;
  1292. $data ['receiptMemu'] = 'saeaBorad';
  1293. $data ['verifyId'] = $this->verifyId;
  1294. $data ['executeId'] = $this->executeId;
  1295. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1296. }
  1297. function saeaLoanReceiptAddDo() {
  1298. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1299. $agency = $this->get_args ( 'agency' );
  1300. $travel = $this->get_args ( 'travel' );
  1301. $train = $this->get_args ( 'train' );
  1302. $other = $this->get_args ( 'other' );
  1303. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1304. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1305. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1306. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1307. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1308. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1309. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1310. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1311. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1312. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1313. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1314. header ( 'Content-Type:text/html;charset=utf-8' );
  1315. die ( '请填写联行号' );
  1316. }
  1317. Doo::loadModel ( 'receipt' );
  1318. Doo::loadModel ( 'receiptDetail' );
  1319. Doo::loadModel ( 'accountItem' );
  1320. $accountItem = new accountItem ();
  1321. $receipt = new receipt ();
  1322. Doo::loadModel ( 'enclosur' );
  1323. Doo::loadModel ( 'execute' );
  1324. $execute = new execute ();
  1325. $executeDetail = $execute->getOne ( array (
  1326. 'where' => 'mold="借款费用执行人"',
  1327. 'asArray' => true
  1328. ) );
  1329. $receiptDet = $receipt->getOne ( array (
  1330. 'where' => 'rid=' . $rid,
  1331. 'asArray' => true
  1332. ) );
  1333. // if(!empty($receiptDetail))
  1334. // return "/referReceipt/".$receiptDetail['rid'];
  1335. $aItem = $accountItem->find ( array (
  1336. 'asArray' => true
  1337. ) );
  1338. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1339. $ag = $tr = $ta = $ot = 0;
  1340. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1341. foreach ( $aItem as $key => $value ) {
  1342. if ($value ['category'] == $this->AGENCY) {
  1343. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1344. array_push ( $accountJson [$this->AGENCY], array (
  1345. 'aid' => $value ['aid'],
  1346. 'name' => $value ['name'],
  1347. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1348. ) );
  1349. $sum += $agency [$ag];
  1350. $agencySum += $agency [$ag];
  1351. }
  1352. $ag ++;
  1353. }
  1354. if ($value ['category'] == $this->TRAVEL) {
  1355. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1356. array_push ( $accountJson [$this->TRAVEL], array (
  1357. 'aid' => $value ['aid'],
  1358. 'name' => $value ['name'],
  1359. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1360. ) );
  1361. $sum += $travel [$tr];
  1362. $travelSum += $travel [$tr];
  1363. }
  1364. $tr ++;
  1365. }
  1366. if ($value ['category'] == $this->TRAIN) {
  1367. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1368. array_push ( $accountJson [$this->TRAIN], array (
  1369. 'aid' => $value ['aid'],
  1370. 'name' => $value ['name'],
  1371. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1372. ) );
  1373. $sum += $train [$ta];
  1374. $trainSum += $train [$ta];
  1375. }
  1376. $ta ++;
  1377. }
  1378. if ($value ['category'] == $this->OTHER) {
  1379. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1380. array_push ( $accountJson [$this->OTHER], array (
  1381. 'aid' => $value ['aid'],
  1382. 'name' => $value ['name'],
  1383. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1384. ) );
  1385. $sum += $other [$ot];
  1386. $otherSum += $other [$ot];
  1387. }
  1388. $ot ++;
  1389. }
  1390. }
  1391. $accountJson ['cSum'] = array (
  1392. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1393. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1394. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1395. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1396. );
  1397. // 报销单
  1398. $receipt->accountItem = json_encode ( $accountJson );
  1399. $receipt->staff = $this->staff [0] ['sid'];
  1400. $receipt->loanSum = $receiptDet ['sum'];
  1401. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1402. $receipt->date = date ( "Y-m-d" );
  1403. $receipt->pastDate = '';
  1404. $receipt->cid = $cid;
  1405. $receipt->status = 7;
  1406. // 修改审批流程加入角色
  1407. $receipt->verify = $verify;
  1408. $receipt->verifyStaff = '';
  1409. $receipt->executeStaff = '';
  1410. $receipt->executeCopy = $executeDetail ['staff'];
  1411. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  1412. $receipt->explanation = $explanation;
  1413. $receipt->remittanceName = $remittanceName;
  1414. $receipt->bankName = $bankName;
  1415. $receipt->bankNumber = $bankNumber;
  1416. $receipt->remittanceBankType = $remittanceBankType;
  1417. if ($remittanceBankType == 1)
  1418. $receipt->coupletNumber = $coupletNumber;
  1419. $receipt->update ( array (
  1420. 'where' => 'rid=' . $rid
  1421. ) );
  1422. // 附件
  1423. if (! empty ( $enclosurName )) {
  1424. $enclosurArray = explode ( '-', $enclosurName );
  1425. foreach ( $enclosurArray as $value ) {
  1426. $enclosur = new enclosur ();
  1427. $enclosur->name = $value;
  1428. $enclosur->rid = $rid;
  1429. $enclosur->insert ();
  1430. }
  1431. // print_r($enclosurArray);die;
  1432. }
  1433. // 报销详情
  1434. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1435. $receiptDetail = new receiptDetail ();
  1436. $receiptDetail->staff = $this->staff [0] ['sid'];
  1437. $receiptDetail->item = $value ['name'];
  1438. $receiptDetail->itemCategory = $this->AGENCY;
  1439. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1440. $receiptDetail->date = date ( "Y-m-d" );
  1441. $receiptDetail->cid = $cid;
  1442. $receiptDetail->rid = $rid;
  1443. $receiptDetail->status = 4;
  1444. $receiptDetail->insert ();
  1445. }
  1446. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1447. $receiptDetail = new receiptDetail ();
  1448. $receiptDetail->staff = $this->staff [0] ['sid'];
  1449. $receiptDetail->item = $value ['name'];
  1450. $receiptDetail->itemCategory = $this->TRAVEL;
  1451. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1452. $receiptDetail->date = date ( "Y-m-d" );
  1453. $receiptDetail->cid = $cid;
  1454. $receiptDetail->rid = $rid;
  1455. $receiptDetail->status = 4;
  1456. $receiptDetail->insert ();
  1457. }
  1458. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1459. $receiptDetail = new receiptDetail ();
  1460. $receiptDetail->staff = $this->staff [0] ['sid'];
  1461. $receiptDetail->item = $value ['name'];
  1462. $receiptDetail->itemCategory = $this->TRAIN;
  1463. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1464. $receiptDetail->date = date ( "Y-m-d" );
  1465. $receiptDetail->cid = $cid;
  1466. $receiptDetail->rid = $rid;
  1467. $receiptDetail->status = 4;
  1468. $receiptDetail->insert ();
  1469. }
  1470. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1471. $receiptDetail = new receiptDetail ();
  1472. $receiptDetail->staff = $this->staff [0] ['sid'];
  1473. $receiptDetail->item = $value ['name'];
  1474. $receiptDetail->itemCategory = $this->OTHER;
  1475. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1476. $receiptDetail->date = date ( "Y-m-d" );
  1477. $receiptDetail->cid = $cid;
  1478. $receiptDetail->rid = $rid;
  1479. $receiptDetail->status = 4;
  1480. $receiptDetail->insert ();
  1481. }
  1482. return "/saeaBorad";
  1483. }
  1484. return "/saeaLoanReceiptAdd/" . $rid;
  1485. }
  1486. function saeaLoanReceiptEdi() {
  1487. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1488. Doo::loadClass ( 'XDeode' );
  1489. $XDeode = new XDeode ( 7 );
  1490. $rid = $XDeode->decode ( $ridKey );
  1491. if (! is_numeric ( $rid ))
  1492. die ( 'illegal request' );
  1493. Doo::loadModel ( 'accountItem' );
  1494. Doo::loadModel ( 'verify' );
  1495. Doo::loadModel ( 'receipt' );
  1496. $receipt = new receipt ();
  1497. $verify = new verify ();
  1498. $accountItem = new accountItem ();
  1499. Doo::loadModel ( 'L_category' );
  1500. $Lcategory = new L_category ();
  1501. Doo::loadModel ( "role" );
  1502. $role = new role ();
  1503. Doo::loadModel ( 'loanReceipt' );
  1504. $loanReceipt = new loanReceipt ();
  1505. Doo::loadModel ( 'staff' );
  1506. $staff = new staff ();
  1507. $receiptDetail = $receipt->getOne ( array (
  1508. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  1509. 'asArray' => true
  1510. ) );
  1511. if (empty ( $receiptDetail ))
  1512. return "/saeaBorad";
  1513. $receiptList = $loanReceipt->find ( array (
  1514. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1515. 'desc' => 'rid',
  1516. 'asArray' => true
  1517. ) );
  1518. $Locate = 0;
  1519. $roleId = 0;
  1520. $button = 0;
  1521. foreach ( $receiptList as $key => $value ) {
  1522. $receiptList [$key] ['Locate'] = $Locate;
  1523. $Locate ++;
  1524. $receiptList [$key] ['reviseDetail'] = array ();
  1525. if (! empty ( $value ['reviseDetail'] ))
  1526. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1527. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1528. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1529. $categoryDetil = $Lcategory->getOne ( array (
  1530. 'where' => 'cid=' . $value ['cid'],
  1531. 'asArray' => true
  1532. ) );
  1533. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1534. // 检测编辑状态
  1535. $verifyList = $verify->getOne ( array (
  1536. 'where' => 'vid=' . $value ['verify'],
  1537. 'asArray' => true
  1538. ) );
  1539. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1540. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1541. Doo::loadModel ( 'role' );
  1542. $role = new role ();
  1543. $flag = true;
  1544. $roleKey = 0;
  1545. $endStaffArray = array ();
  1546. $roleArrayCopy = array ();
  1547. foreach ( $verifyList as $k => $v ) {
  1548. // init verifyStaff
  1549. if ($v [1] == 'ROLE') {
  1550. if (! empty ( $verifyStaff )) {
  1551. $endStaffArray = end ( $verifyStaff );
  1552. // if ($v[0]==$endStaffArray['nextStaff']){
  1553. // $roleId=$v[0];
  1554. // }
  1555. }
  1556. $roleVerify = json_decode ( $v [3], true );
  1557. $roleKey = $k;
  1558. $roleArray = array ();
  1559. $rolename = $role->getOne ( array (
  1560. 'where' => 'rid=' . $v [0],
  1561. 'asArray' => true
  1562. ) );
  1563. foreach ( $roleVerify as $o => $p ) {
  1564. $staffID = explode ( '_', $p );
  1565. $staffInfo = $staff->getOne ( array (
  1566. 'where' => 'sid=' . $staffID [0],
  1567. 'asArray' => true
  1568. ) );
  1569. // print_r($staffID);
  1570. $exp = array (
  1571. 0 => $staffInfo ['sid'],
  1572. 1 => $staffID [1],
  1573. 2 => $staffInfo ['avatar'],
  1574. 'date' => '',
  1575. 'date' => '',
  1576. 'opinion' => '',
  1577. 'status' => '',
  1578. 'rolename' => $rolename ['name']
  1579. );
  1580. array_push ( $roleArray, $exp );
  1581. }
  1582. $roleArrayCopy [$v [0]] = $roleArray;
  1583. // $verifyList[$k]['roleArray']=$roleArray;
  1584. }
  1585. $verifyList [$k] ['date'] = "";
  1586. $verifyList [$k] ['opinion'] = "";
  1587. $verifyList [$k] ['status'] = "";
  1588. if (empty ( $verifyStaff )) {
  1589. $verifyList [$k] ['date'] = "";
  1590. $verifyList [$k] ['opinion'] = "";
  1591. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1592. $verifyList [$k] ['status'] = 4;
  1593. $flag = false;
  1594. }
  1595. } else {
  1596. foreach ( $verifyStaff as $m => $u ) {
  1597. if ($v [0] == $m) {
  1598. $verifyList [$k] ['date'] = $u ['date'];
  1599. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1600. $verifyList [$k] ['status'] = $u ['status'];
  1601. $flag = false;
  1602. break;
  1603. }
  1604. }
  1605. $endStaffArray = end ( $verifyStaff );
  1606. if (isset ( $endStaffArray ['ROLE'] )) {
  1607. } else {
  1608. // $endKey=key($verifyStaff);
  1609. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1610. // $button=4;
  1611. // $verifyList[$k]['status']=4;
  1612. // }
  1613. }
  1614. }
  1615. }
  1616. $rolename ['name'] = '';
  1617. if (! empty ( $roleId )) {
  1618. Doo::loadModel ( 'role' );
  1619. $role = new role ();
  1620. $rolename = $role->getOne ( array (
  1621. 'where' => 'rid=' . $roleId,
  1622. 'asArray' => true
  1623. ) );
  1624. }
  1625. if (! empty ( $verifyStaff ))
  1626. $endStaffArray = end ( $verifyStaff );
  1627. $KOP = false;
  1628. foreach ( $roleArrayCopy as $P => $A ) {
  1629. foreach ( $A as $MKI => $AVL ) {
  1630. if (! empty ( $verifyStaff )) {
  1631. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1632. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1633. $button = 4;
  1634. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1635. }
  1636. foreach ( $verifyStaff as $m => $u ) {
  1637. $AVLFK = $AVL [0] . '_R';
  1638. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1639. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1640. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1641. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1642. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1643. break;
  1644. }
  1645. }
  1646. } else {
  1647. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1648. $button = 4;
  1649. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1650. }
  1651. }
  1652. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1653. $KOP = true;
  1654. }
  1655. }
  1656. foreach ( $roleArrayCopy as $k => $v ) {
  1657. foreach ( $verifyList as $m => $n ) {
  1658. if ($n [0] == $k) {
  1659. array_splice ( $verifyList, $m, 1, $v );
  1660. }
  1661. }
  1662. }
  1663. $receiptList [$key] ['verifyList'] = $verifyList;
  1664. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1665. 'where' => 'sid=' . $value ['staff'],
  1666. 'asArray' => true
  1667. ) );
  1668. $receiptList [$key] ['button'] = $button;
  1669. //
  1670. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1671. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1672. }
  1673. $data ['receiptList'] = $receiptList;
  1674. $acItem = $accountItem->find ( array (
  1675. 'asArray' => true
  1676. ) );
  1677. $veList = $verify->find ( array (
  1678. 'asArray' => true
  1679. ) );
  1680. foreach ( $veList as $key => $value ) {
  1681. $v = json_decode ( $value ['staff'] );
  1682. $list = array ();
  1683. foreach ( $v as $n => $m ) {
  1684. if ($m ['1'] == 'ROLE') {
  1685. $roleInfo = $role->getOne ( array (
  1686. 'where' => 'rid=' . $m [0],
  1687. 'asArray' => true
  1688. ) );
  1689. $v [$n] [1] = $roleInfo ['name'];
  1690. array_push ( $list, $roleInfo ['name'] );
  1691. } else {
  1692. array_push ( $list, $v [$n] [1] );
  1693. }
  1694. }
  1695. $veList [$key] ['staff'] = implode ( '>', $list );
  1696. }
  1697. // 配置编辑信息
  1698. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1699. foreach ( $acItem as $key => $value ) {
  1700. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1701. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1702. $acItem [$key] ['price'] = $v ['price'];
  1703. }
  1704. }
  1705. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1706. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1707. $acItem [$key] ['price'] = $v ['price'];
  1708. }
  1709. }
  1710. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1711. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1712. $acItem [$key] ['price'] = $v ['price'];
  1713. }
  1714. }
  1715. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1716. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1717. $acItem [$key] ['price'] = $v ['price'];
  1718. }
  1719. }
  1720. }
  1721. $data ['category'] = $Lcategory->find ( array (
  1722. 'asArray' => true
  1723. ) );
  1724. $data ['ridKey'] = $ridKey;
  1725. $data ['cSum'] = $accountItemList ['cSum'];
  1726. $data ['sum'] = $receiptDetail ['sum'];
  1727. $data ['receiptDetail'] = $receiptDetail;
  1728. $data ['veList'] = $veList;
  1729. $data ['acItem'] = $acItem;
  1730. $data ['memu'] = "receipt";
  1731. $data ['staff'] = $this->staff;
  1732. $data ['receiptMemu'] = 'saeaBorad';
  1733. $data ['verify'] = $receiptDetail ['verify'];
  1734. $data ['verifyId'] = $this->verifyId;
  1735. $data ['executeId'] = $this->executeId;
  1736. $data ['rid'] = $rid;
  1737. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  1738. }
  1739. function confirmation() {
  1740. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1741. Doo::loadModel ( 'receipt' );
  1742. Doo::loadModel ( 'receiptDetail' );
  1743. $receipt = new receipt ();
  1744. $receiptDetail = new receiptDetail ();
  1745. Doo::loadModel ( 'statistics' );
  1746. Doo::loadModel ( 'itemStatistics' );
  1747. $statistics = new statistics ();
  1748. $itemStatistics = new itemStatistics ();
  1749. Doo::loadModel ( "verify" );
  1750. $verify = new verify ();
  1751. $receiptDetailList = $receipt->getOne ( array (
  1752. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  1753. 'asArray' => true
  1754. ) );
  1755. if (empty ( $receiptDetailList ))
  1756. return "/saeaBorad";
  1757. $verifyDetail = $verify->getOne ( array (
  1758. 'where' => ' vid =' . $receiptDetailList ['verify'],
  1759. 'asArray' => true
  1760. ) );
  1761. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  1762. if (empty ( $receiptDetailList ['nowStaff'] )) {
  1763. $nowStaff = "";
  1764. $nowStaffList = array ();
  1765. if ($verifyDetail [0] [1] == 'ROLE') {
  1766. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  1767. foreach ( $vStaffString as $key => $value ) {
  1768. $staffK = explode ( "_", $value );
  1769. array_push ( $nowStaffList, $staffK [0] );
  1770. }
  1771. $nowStaff = implode ( ',', $nowStaffList );
  1772. } else {
  1773. $nowStaff = $verifyDetail [0] [0];
  1774. }
  1775. $receipt->nowStaff = $nowStaff;
  1776. }
  1777. // echo $nowStaff;
  1778. // print_r($verifyDetail);die;
  1779. $receipt->rid = $receiptDetailList ['rid'];
  1780. $receipt->status = 2;
  1781. $receipt->update ();
  1782. // 操作日志
  1783. Doo::loadModel ( "receiptLog" );
  1784. $receiptLog = new receiptLog ();
  1785. $verify = new verify ();
  1786. $receiptInfo = $receipt->getOne ( array (
  1787. 'where' => 'rid=' . $rid,
  1788. 'asArray' => true
  1789. ) );
  1790. $vr = $verify->getOne ( array (
  1791. 'where' => 'vid=' . $receiptInfo ['verify'],
  1792. 'asArray' => true
  1793. ) );
  1794. $jd = json_decode ( $vr ['staff'] );
  1795. $roleId = 0;
  1796. foreach ( $jd as $key => $value ) {
  1797. if ($value [1] == 'ROLE') {
  1798. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  1799. if ($pos !== false) {
  1800. $roleId = $value [0];
  1801. }
  1802. }
  1803. }
  1804. // 审批日志
  1805. // echo $roleId;die;
  1806. if (! empty ( $roleId )) {
  1807. Doo::loadModel ( "role" );
  1808. $role = new role ();
  1809. $roleInfo = $role->getOne ( array (
  1810. 'where' => 'rid=' . $roleId,
  1811. 'asArray' => true
  1812. ) );
  1813. $receiptLog->rolename = $roleInfo ['name'];
  1814. }
  1815. $receiptLog->username = $this->staff [0] ['username'];
  1816. $receiptLog->uid = $this->staff [0] ['sid'];
  1817. $receiptLog->date = date ( "Y-m-d" );
  1818. $receiptLog->opinion = '提交审批';
  1819. $receiptLog->img = $this->staff [0] ['avatar'];
  1820. $receiptLog->status = 2;
  1821. $receiptLog->rid = $rid;
  1822. $receiptLog->insert ();
  1823. return "/expenses";
  1824. }
  1825. function expenses() {
  1826. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  1827. if (empty ( $item ))
  1828. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  1829. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1830. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  1831. Doo::loadModel ( 'receipt' );
  1832. $receipt = new receipt ();
  1833. Doo::loadModel ( 'L_category' );
  1834. $Lcategory = new L_category ();
  1835. Doo::loadModel ( 'verify' );
  1836. Doo::loadModel ( 'statistics' );
  1837. $statistics = new statistics ();
  1838. $verify = new verify ();
  1839. Doo::loadModel ( 'staff' );
  1840. $staff = new staff ();
  1841. $condition = "";
  1842. if ($item == "expenses")
  1843. $condition = " and Rtype=1 ";
  1844. elseif ($item == "receipts")
  1845. $condition = " and Rtype=0 ";
  1846. elseif ($item == "remits")
  1847. $condition = " and Rtype=2 ";
  1848. $dateCondition = " and Year(date) =" . $year;
  1849. if (! empty ( $moth )) {
  1850. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  1851. $stList = $statistics->getOne ( array (
  1852. 'select' => 'rePrice ,agPrice',
  1853. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  1854. 'asArray' => true
  1855. ) );
  1856. } else
  1857. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  1858. if (empty ( $stList ))
  1859. $stList = array (
  1860. 'rePrice' => 0,
  1861. 'agPrice' => 0
  1862. );
  1863. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  1864. if (! isset ( $noPassSum ['sum'] ))
  1865. $noPassSum ['sum'] = 0;
  1866. $data ['stList'] = array (
  1867. 'rePrice' => $stList ['rePrice'],
  1868. 'agPrice' => $stList ['agPrice'],
  1869. 'skPrice' => ($noPassSum ['sum'])
  1870. );
  1871. $receiptList = $receipt->find ( array (
  1872. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  1873. 'desc' => 'rid',
  1874. 'asArray' => true
  1875. ) );
  1876. $Locate = 0;
  1877. $roleId = 0;
  1878. $button = 0;
  1879. foreach ( $receiptList as $key => $value ) {
  1880. $receiptList [$key] ['Locate'] = $Locate;
  1881. $Locate ++;
  1882. $receiptList [$key] ['reviseDetail'] = array ();
  1883. if (! empty ( $value ['reviseDetail'] ))
  1884. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1885. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1886. $categoryDetil = $Lcategory->getOne ( array (
  1887. 'where' => 'cid=' . $value ['cid'],
  1888. 'asArray' => true
  1889. ) );
  1890. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1891. // 检测编辑状态
  1892. $verifyList = $verify->getOne ( array (
  1893. 'where' => 'vid=' . $value ['verify'],
  1894. 'asArray' => true
  1895. ) );
  1896. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1897. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1898. Doo::loadModel ( 'role' );
  1899. $role = new role ();
  1900. $flag = true;
  1901. $roleKey = 0;
  1902. $endStaffArray = array ();
  1903. $roleArrayCopy = array ();
  1904. foreach ( $verifyList as $k => $v ) {
  1905. // init verifyStaff
  1906. if ($v [1] == 'ROLE') {
  1907. if (! empty ( $verifyStaff )) {
  1908. $endStaffArray = end ( $verifyStaff );
  1909. // if ($v[0]==$endStaffArray['nextStaff']){
  1910. // $roleId=$v[0];
  1911. // }
  1912. }
  1913. $roleVerify = json_decode ( $v [3], true );
  1914. $roleKey = $k;
  1915. $roleArray = array ();
  1916. $rolename = $role->getOne ( array (
  1917. 'where' => 'rid=' . $v [0],
  1918. 'asArray' => true
  1919. ) );
  1920. foreach ( $roleVerify as $o => $p ) {
  1921. $staffID = explode ( '_', $p );
  1922. $staffInfo = $staff->getOne ( array (
  1923. 'where' => 'sid=' . $staffID [0],
  1924. 'asArray' => true
  1925. ) );
  1926. // print_r($staffID);
  1927. $exp = array (
  1928. 0 => $staffInfo ['sid'],
  1929. 1 => $staffID [1],
  1930. 2 => $staffInfo ['avatar'],
  1931. 'date' => '',
  1932. 'date' => '',
  1933. 'opinion' => '',
  1934. 'status' => '',
  1935. 'rolename' => $rolename ['name']
  1936. );
  1937. array_push ( $roleArray, $exp );
  1938. }
  1939. $roleArrayCopy [$v [0]] = $roleArray;
  1940. // $verifyList[$k]['roleArray']=$roleArray;
  1941. }
  1942. $verifyList [$k] ['date'] = "";
  1943. $verifyList [$k] ['opinion'] = "";
  1944. $verifyList [$k] ['status'] = "";
  1945. if (empty ( $verifyStaff )) {
  1946. $verifyList [$k] ['date'] = "";
  1947. $verifyList [$k] ['opinion'] = "";
  1948. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1949. $verifyList [$k] ['status'] = 4;
  1950. $flag = false;
  1951. }
  1952. } else {
  1953. foreach ( $verifyStaff as $m => $u ) {
  1954. if ($v [0] == $m) {
  1955. $verifyList [$k] ['date'] = $u ['date'];
  1956. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1957. $verifyList [$k] ['status'] = $u ['status'];
  1958. $flag = false;
  1959. break;
  1960. }
  1961. }
  1962. $endStaffArray = end ( $verifyStaff );
  1963. if (isset ( $endStaffArray ['ROLE'] )) {
  1964. } else {
  1965. // $endKey=key($verifyStaff);
  1966. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1967. // $button=4;
  1968. // $verifyList[$k]['status']=4;
  1969. // }
  1970. }
  1971. }
  1972. }
  1973. $rolename ['name'] = '';
  1974. if (! empty ( $roleId )) {
  1975. Doo::loadModel ( 'role' );
  1976. $role = new role ();
  1977. $rolename = $role->getOne ( array (
  1978. 'where' => 'rid=' . $roleId,
  1979. 'asArray' => true
  1980. ) );
  1981. }
  1982. if (! empty ( $verifyStaff ))
  1983. $endStaffArray = end ( $verifyStaff );
  1984. $KOP = false;
  1985. foreach ( $roleArrayCopy as $P => $A ) {
  1986. foreach ( $A as $MKI => $AVL ) {
  1987. if (! empty ( $verifyStaff )) {
  1988. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1989. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1990. $button = 4;
  1991. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1992. }
  1993. foreach ( $verifyStaff as $m => $u ) {
  1994. $AVLFK = $AVL [0] . '_R';
  1995. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1996. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1997. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1998. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1999. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2000. break;
  2001. }
  2002. }
  2003. } else {
  2004. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2005. $button = 4;
  2006. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2007. }
  2008. }
  2009. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2010. $KOP = true;
  2011. }
  2012. }
  2013. foreach ( $roleArrayCopy as $k => $v ) {
  2014. foreach ( $verifyList as $m => $n ) {
  2015. if ($n [0] == $k) {
  2016. array_splice ( $verifyList, $m, 1, $v );
  2017. }
  2018. }
  2019. }
  2020. $receiptList [$key] ['verifyList'] = $verifyList;
  2021. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2022. 'where' => 'sid=' . $value ['staff'],
  2023. 'asArray' => true
  2024. ) );
  2025. $receiptList [$key] ['button'] = $button;
  2026. }
  2027. // print_r($receiptList);die;
  2028. $mothHtml = "";
  2029. for($i = 1; $i <= 12; $i ++) {
  2030. if ($moth == $i)
  2031. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2032. else
  2033. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2034. }
  2035. $data ['mothHtml'] = $mothHtml;
  2036. $data ['receiptList'] = $receiptList;
  2037. $data ['memu'] = "receipt";
  2038. $data ['staff'] = $this->staff;
  2039. $data ['receiptMemu'] = 'expenses';
  2040. $data ['verifyId'] = $this->verifyId;
  2041. $data ['executeId'] = $this->executeId;
  2042. $data ['item'] = $item;
  2043. $data ['year'] = $year;
  2044. $this->render ( "/admin/expenses", $data );
  2045. }
  2046. function expensesCollect() {
  2047. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2048. Doo::loadModel ( 'receipt' );
  2049. $receipt = new receipt ();
  2050. Doo::loadModel ( 'L_category' );
  2051. $Lcategory = new L_category ();
  2052. Doo::loadModel ( 'verify' );
  2053. Doo::loadModel ( 'statistics' );
  2054. $statistics = new statistics ();
  2055. $verify = new verify ();
  2056. Doo::loadModel ( 'staff' );
  2057. $staff = new staff ();
  2058. Doo::loadModel ( 'loanReceipt' );
  2059. $loanReceipt = new loanReceipt ();
  2060. $receiptList = $receipt->find ( array (
  2061. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  2062. 'desc' => 'rid',
  2063. 'asArray' => true
  2064. ) );
  2065. $loanList = $loanReceipt->find ( array (
  2066. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2067. 'desc' => 'rid',
  2068. 'asArray' => true
  2069. ) );
  2070. /*
  2071. * $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;
  2072. */
  2073. $data ['explanation'] = '';
  2074. if (! empty ( $loanList ))
  2075. $data ['explanation'] = $loanList [0] ['explanation'];
  2076. $Locate = 0;
  2077. $roleId = 0;
  2078. $button = 0;
  2079. foreach ( $receiptList as $key => $value ) {
  2080. $receiptList [$key] ['Locate'] = $Locate;
  2081. $Locate ++;
  2082. $receiptList [$key] ['reviseDetail'] = array ();
  2083. if (! empty ( $value ['reviseDetail'] ))
  2084. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2085. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2086. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2087. $categoryDetil = $Lcategory->getOne ( array (
  2088. 'where' => 'cid=' . $value ['cid'],
  2089. 'asArray' => true
  2090. ) );
  2091. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2092. // 检测编辑状态
  2093. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  2094. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  2095. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  2096. else
  2097. $verifyList ['staff'] = $value ['verifyBreakup'];
  2098. } else
  2099. $verifyList = $verify->getOne ( array (
  2100. 'where' => 'vid=' . $value ['verify'],
  2101. 'asArray' => true
  2102. ) );
  2103. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2104. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2105. Doo::loadModel ( 'role' );
  2106. $role = new role ();
  2107. $flag = true;
  2108. $roleKey = 0;
  2109. $endStaffArray = array ();
  2110. $roleArrayCopy = array ();
  2111. foreach ( $verifyList as $k => $v ) {
  2112. // init verifyStaff
  2113. if ($v [1] == 'ROLE') {
  2114. if (! empty ( $verifyStaff )) {
  2115. $endStaffArray = end ( $verifyStaff );
  2116. // if ($v[0]==$endStaffArray['nextStaff']){
  2117. // $roleId=$v[0];
  2118. // }
  2119. }
  2120. $roleVerify = json_decode ( $v [3], true );
  2121. $roleKey = $k;
  2122. $roleArray = array ();
  2123. $rolename = $role->getOne ( array (
  2124. 'where' => 'rid=' . $v [0],
  2125. 'asArray' => true
  2126. ) );
  2127. foreach ( $roleVerify as $o => $p ) {
  2128. $staffID = explode ( '_', $p );
  2129. $staffInfo = $staff->getOne ( array (
  2130. 'where' => 'sid=' . $staffID [0],
  2131. 'asArray' => true
  2132. ) );
  2133. // print_r($staffID);
  2134. $exp = array (
  2135. 0 => $staffInfo ['sid'],
  2136. 1 => $staffID [1],
  2137. 2 => $staffInfo ['avatar'],
  2138. 'date' => '',
  2139. 'date' => '',
  2140. 'opinion' => '',
  2141. 'status' => '',
  2142. 'rolename' => $rolename ['name']
  2143. );
  2144. array_push ( $roleArray, $exp );
  2145. }
  2146. $roleArrayCopy [$v [0]] = $roleArray;
  2147. // $verifyList[$k]['roleArray']=$roleArray;
  2148. }
  2149. $verifyList [$k] ['date'] = "";
  2150. $verifyList [$k] ['opinion'] = "";
  2151. $verifyList [$k] ['status'] = "";
  2152. if (empty ( $verifyStaff )) {
  2153. $verifyList [$k] ['date'] = "";
  2154. $verifyList [$k] ['opinion'] = "";
  2155. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2156. $verifyList [$k] ['status'] = 4;
  2157. $flag = false;
  2158. }
  2159. } else {
  2160. foreach ( $verifyStaff as $m => $u ) {
  2161. if ($v [0] == $m) {
  2162. $verifyList [$k] ['date'] = $u ['date'];
  2163. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2164. $verifyList [$k] ['status'] = $u ['status'];
  2165. $flag = false;
  2166. break;
  2167. }
  2168. }
  2169. $endStaffArray = end ( $verifyStaff );
  2170. if (isset ( $endStaffArray ['ROLE'] )) {
  2171. } else {
  2172. // $endKey=key($verifyStaff);
  2173. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2174. // $button=4;
  2175. // $verifyList[$k]['status']=4;
  2176. // }
  2177. }
  2178. }
  2179. }
  2180. $rolename ['name'] = '';
  2181. if (! empty ( $roleId )) {
  2182. Doo::loadModel ( 'role' );
  2183. $role = new role ();
  2184. $rolename = $role->getOne ( array (
  2185. 'where' => 'rid=' . $roleId,
  2186. 'asArray' => true
  2187. ) );
  2188. }
  2189. if (! empty ( $verifyStaff ))
  2190. $endStaffArray = end ( $verifyStaff );
  2191. $KOP = false;
  2192. foreach ( $roleArrayCopy as $P => $A ) {
  2193. foreach ( $A as $MKI => $AVL ) {
  2194. if (! empty ( $verifyStaff )) {
  2195. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2196. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2197. $button = 4;
  2198. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2199. }
  2200. foreach ( $verifyStaff as $m => $u ) {
  2201. $AVLFK = $AVL [0] . '_R';
  2202. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2203. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2204. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2205. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2206. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2207. break;
  2208. }
  2209. }
  2210. } else {
  2211. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2212. $button = 4;
  2213. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2214. }
  2215. }
  2216. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2217. $KOP = true;
  2218. }
  2219. }
  2220. foreach ( $roleArrayCopy as $k => $v ) {
  2221. foreach ( $verifyList as $m => $n ) {
  2222. if ($n [0] == $k) {
  2223. array_splice ( $verifyList, $m, 1, $v );
  2224. }
  2225. }
  2226. }
  2227. // 费用执行人相关数据
  2228. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2229. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2230. foreach ( $executeCopy as $k => $v ) {
  2231. $executeCopy [$k] ['date'] = '';
  2232. $executeCopy [$k] ['opinion'] = '';
  2233. $executeCopy [$k] ['status'] = '';
  2234. if (! empty ( $executeStaff ))
  2235. foreach ( $executeStaff as $m => $u ) {
  2236. if ($v [0] == $m) {
  2237. $executeCopy [$k] ['date'] = $u ['date'];
  2238. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2239. $executeCopy [$k] ['status'] = $u ['status'];
  2240. break;
  2241. }
  2242. }
  2243. }
  2244. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2245. $receiptList [$key] ['verifyList'] = $verifyList;
  2246. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2247. 'where' => 'sid=' . $value ['staff'],
  2248. 'asArray' => true
  2249. ) );
  2250. $receiptList [$key] ['button'] = $button;
  2251. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2252. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2253. $relust = $value ['sum'] - $value ['loanSum'];
  2254. $receiptList [$key] ['relust'] = $relust;
  2255. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2256. }
  2257. Doo::loadModel ( 'enclosur' );
  2258. $enclosur = new enclosur ();
  2259. $enclosurList = $enclosur->find ( array (
  2260. 'where' => 'rid=' . $rid,
  2261. 'asArray' => true
  2262. ) );
  2263. $enclosurHtml = '';
  2264. foreach ( $enclosurList as $value ) {
  2265. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2266. }
  2267. $data ['enclosurHtml'] = $enclosurHtml;
  2268. // print_r($receiptList);
  2269. $data ['receiptList'] = $receiptList;
  2270. $data ['memu'] = "receipt";
  2271. $data ['staff'] = $this->staff;
  2272. $data ['receiptMemu'] = 'expenses';
  2273. $data ['verifyId'] = $this->verifyId;
  2274. $data ['executeId'] = $this->executeId;
  2275. $this->render ( "/admin/expensesCollect", $data );
  2276. }
  2277. function approvalExpenses() {
  2278. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  2279. $year = $rdate = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2280. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2281. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2282. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2283. // $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) :"";
  2284. // echo $rdate;
  2285. if (empty ( $status ))
  2286. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  2287. $page_size = 12;
  2288. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2289. $vidList = array ();
  2290. $button = 0;
  2291. Doo::loadModel ( 'verify' );
  2292. $verify = new verify ();
  2293. Doo::loadModel ( 'receipt' );
  2294. $receipt = new receipt ();
  2295. Doo::loadModel ( 'staff' );
  2296. $staff = new staff ();
  2297. Doo::loadModel ( 'L_category' );
  2298. $Lcategory = new L_category ();
  2299. // user verify ID
  2300. $verifyDetail = $verify->find ( array (
  2301. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  2302. 'asArray' => true
  2303. ) );
  2304. foreach ( $verifyDetail as $key => $value ) {
  2305. array_push ( $vidList, $value ['vid'] );
  2306. }
  2307. $vid = implode ( ",", $vidList );
  2308. if (empty ( $verifyDetail ))
  2309. $vid = 0;
  2310. // if ($status==0)
  2311. // $dateCondition="";
  2312. // else
  2313. $dateCondition = " ";
  2314. // if (! empty ( $month ))
  2315. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  2316. if ($status == 'done' || $status == 'termination') {
  2317. if (! empty ( $year )) {
  2318. $dateCondition = " and Year(pastDate) =" . $year;
  2319. if (! empty ( $month ))
  2320. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  2321. }
  2322. } elseif ($status == 'finish') {
  2323. if (! empty ( $year )) {
  2324. $dateCondition = " and Year(pastDate) =" . $year;
  2325. if (! empty ( $month ))
  2326. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  2327. }
  2328. }
  2329. // date ( 'Y-m' )
  2330. // if (! empty ( $rdate ) && $status == 'done')
  2331. // $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  2332. // elseif (! empty ( $rdate ))
  2333. // $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  2334. $categoryList = $Lcategory->find ( array (
  2335. 'asArray' => true
  2336. ) );
  2337. $staffList = $staff->find ( array (
  2338. 'where' => 'cid=' . $cid,
  2339. 'asArray' => true
  2340. ) );
  2341. $cateCondition = "";
  2342. $staffCondition = "";
  2343. $approvalCondition = "";
  2344. if (! empty ( $cid )) {
  2345. $cateCondition = ' and cid=' . $cid;
  2346. }
  2347. if (! empty ( $sid )) {
  2348. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  2349. $cateCondition = "";
  2350. }
  2351. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  2352. if ($status == 'pendApproval') {
  2353. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  2354. }
  2355. if ($status == 'ongoing') {
  2356. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  2357. }
  2358. if ($status == 'done') {
  2359. $approvalCondition = ' and (status=8 or status=9 ) ';
  2360. }
  2361. if ($status == 'termination') {
  2362. $approvalCondition = " and status=3";
  2363. }
  2364. if ($status == 'finish') {
  2365. $approvalCondition = " and (status=1 or status=8 or status=9)";
  2366. }
  2367. $pageinfo ['page'] = array (
  2368. 'previous' => ''
  2369. );
  2370. if ($status == 'done' || $status == 'termination' || $status == 'finish') { // $dateCondition .
  2371. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  2372. $receiptList = $receipt->find ( array ( // $dateCondition.
  2373. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  2374. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2375. 'desc' => 'rid',
  2376. 'asArray' => true
  2377. ) );
  2378. } else {
  2379. $receiptList = $receipt->find ( array ( // $dateCondition
  2380. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
  2381. 'desc' => 'rid',
  2382. 'asArray' => true
  2383. ) );
  2384. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  2385. }
  2386. $rLRes = $receipt->find ( array (
  2387. 'where' => 'status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )' . $cateCondition . $staffCondition . ' and verify in (' . $vid . ')',
  2388. 'desc' => 'rid',
  2389. 'asArray' => true
  2390. ) );
  2391. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  2392. // print_r($receiptList);
  2393. $Locate = 0;
  2394. $reportList = $reportCateList = array ();
  2395. foreach ( $receiptList as $key => $value ) {
  2396. $receiptList [$key] ['Locate'] = $Locate;
  2397. $Locate ++;
  2398. $receiptList [$key] ['reviseDetail'] = array ();
  2399. if (! empty ( $value ['reviseDetail'] ))
  2400. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2401. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2402. $categoryDetil = $Lcategory->getOne ( array (
  2403. 'where' => 'cid=' . $value ['cid'],
  2404. 'asArray' => true
  2405. ) );
  2406. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2407. $verifyList = $verify->getOne ( array (
  2408. 'where' => 'vid=' . $value ['verify'],
  2409. 'asArray' => true
  2410. ) );
  2411. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2412. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2413. foreach ( $verifyList as $k => $v ) {
  2414. // init verifyStaff
  2415. $verifyList [$k] ['date'] = "";
  2416. $verifyList [$k] ['opinion'] = "";
  2417. $verifyList [$k] ['status'] = "";
  2418. if (empty ( $verifyStaff )) {
  2419. $verifyList [$k] ['date'] = "";
  2420. $verifyList [$k] ['opinion'] = "";
  2421. if ($v [0] == $this->staff [0] ['sid']) {
  2422. $verifyList [$k] ['status'] = 4;
  2423. $button = 4;
  2424. }
  2425. } else {
  2426. $flag = true;
  2427. foreach ( $verifyStaff as $m => $u ) {
  2428. if ($v [0] == $m) {
  2429. $verifyList [$k] ['date'] = $u ['date'];
  2430. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2431. $verifyList [$k] ['status'] = $u ['status'];
  2432. $flag = false;
  2433. break;
  2434. }
  2435. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  2436. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  2437. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  2438. }
  2439. if ($flag) { // 检测可编辑
  2440. if ($v [0] == $this->staff [0] ['sid']) {
  2441. $verifyList [$k] ['status'] = 4;
  2442. $button = 4;
  2443. }
  2444. }
  2445. }
  2446. }
  2447. $receiptList [$key] ['verifyList'] = $verifyList;
  2448. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2449. 'where' => 'sid=' . $value ['staff'],
  2450. 'asArray' => true
  2451. ) );
  2452. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  2453. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  2454. $receiptList [$key] ['button'] = $button;
  2455. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  2456. }
  2457. $reportList = array_unique ( $reportList );
  2458. $reportHtml = '';
  2459. foreach ( $reportList as $key => $value ) {
  2460. $v = explode ( "-", $value );
  2461. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  2462. }
  2463. // print_r($reportList)
  2464. $data ['reportHtml'] = $reportHtml;
  2465. $reportCateList = array_unique ( $reportCateList );
  2466. $reportCateHtml = '';
  2467. foreach ( $reportCateList as $key => $value ) {
  2468. $v = explode ( "-", $value );
  2469. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  2470. }
  2471. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  2472. $data ['reportCateHtml'] = $reportCateHtml;
  2473. // print_r($receiptList);die;
  2474. // $data['verifyDetail']=$verifyDetail;
  2475. $mothHtml = "";
  2476. for($i = 1; $i <= 12; $i ++) {
  2477. if ($month == $i)
  2478. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2479. else
  2480. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2481. }
  2482. $data ['mothHtml'] = $mothHtml;
  2483. $data ['page'] = $pageinfo;
  2484. $data ['receiptList'] = $receiptList;
  2485. $data ['receiptApprovalCount'] = count ( $rLRes );
  2486. $data ['status'] = $status;
  2487. $data ['year'] = $year;
  2488. $data ['categoryList'] = $categoryList;
  2489. $data ['staffList'] = $staffList;
  2490. $data ['cid'] = $cid;
  2491. $data ['sid'] = $sid;
  2492. // print_r($receiptList);
  2493. $data ['memu'] = "receipt";
  2494. $data ['staff'] = $this->staff;
  2495. $data ['receiptMemu'] = 'approvalExpenses';
  2496. $data ['verifyId'] = $this->verifyId;
  2497. $data ['executeId'] = $this->executeId;
  2498. $this->render ( "/admin/approvalExpenses", $data );
  2499. }
  2500. function expensesDoc() {
  2501. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2502. Doo::loadClass ( 'XDeode' );
  2503. $XDeode = new XDeode ( 5 );
  2504. if (!empty($rid)&&!is_numeric($rid))
  2505. $rid = $XDeode->decode ( $rid );
  2506. if(!is_numeric($rid))
  2507. die ( 'illegal request' );
  2508. Doo::loadModel ( 'receipt' );
  2509. $receipt = new receipt ();
  2510. Doo::loadModel ( 'L_category' );
  2511. $Lcategory = new L_category ();
  2512. Doo::loadModel ( 'verify' );
  2513. Doo::loadModel ( 'statistics' );
  2514. $statistics = new statistics ();
  2515. $verify = new verify ();
  2516. Doo::loadModel ( 'staff' );
  2517. $staff = new staff ();
  2518. Doo::loadModel ( 'loanReceipt' );
  2519. $loanReceipt = new loanReceipt ();
  2520. $receiptList = $receipt->find ( array (
  2521. 'where' => ' rid=' . $rid,
  2522. 'desc' => 'rid',
  2523. 'asArray' => true
  2524. ) );
  2525. $loanList = array ();
  2526. if (! empty ( $receiptList ))
  2527. $loanList = $loanReceipt->find ( array (
  2528. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2529. 'desc' => 'rid',
  2530. 'asArray' => true
  2531. ) );
  2532. $Locate = 0;
  2533. $roleId = 0;
  2534. $button = 0;
  2535. foreach ( $loanList as $key => $value ) {
  2536. $loanList [$key] ['Locate'] = $Locate;
  2537. $Locate ++;
  2538. $loanList [$key] ['reviseDetail'] = array ();
  2539. if (! empty ( $value ['reviseDetail'] ))
  2540. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2541. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2542. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2543. $categoryDetil = $Lcategory->getOne ( array (
  2544. 'where' => 'cid=' . $value ['cid'],
  2545. 'asArray' => true
  2546. ) );
  2547. $loanList [$key] ['category'] = $categoryDetil ['title'];
  2548. // 检测编辑状态
  2549. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  2550. $verifyList ['staff'] = $value ['verifyBreakup'];
  2551. else
  2552. $verifyList = $verify->getOne ( array (
  2553. 'where' => 'vid=' . $value ['verify'],
  2554. 'asArray' => true
  2555. ) );
  2556. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2557. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2558. Doo::loadModel ( 'role' );
  2559. $role = new role ();
  2560. $flag = true;
  2561. $roleKey = 0;
  2562. $endStaffArray = array ();
  2563. $roleArrayCopy = array ();
  2564. foreach ( $verifyList as $k => $v ) {
  2565. // init verifyStaff
  2566. if ($v [1] == 'ROLE') {
  2567. if (! empty ( $verifyStaff )) {
  2568. $endStaffArray = end ( $verifyStaff );
  2569. // if ($v[0]==$endStaffArray['nextStaff']){
  2570. // $roleId=$v[0];
  2571. // }
  2572. }
  2573. $roleVerify = json_decode ( $v [3], true );
  2574. $roleKey = $k;
  2575. $roleArray = array ();
  2576. $rolename = $role->getOne ( array (
  2577. 'where' => 'rid=' . $v [0],
  2578. 'asArray' => true
  2579. ) );
  2580. foreach ( $roleVerify as $o => $p ) {
  2581. $staffID = explode ( '_', $p );
  2582. $staffInfo = $staff->getOne ( array (
  2583. 'where' => 'sid=' . $staffID [0],
  2584. 'asArray' => true
  2585. ) );
  2586. // print_r($staffID);
  2587. $exp = array (
  2588. 0 => $staffInfo ['sid'],
  2589. 1 => $staffID [1],
  2590. 2 => $staffInfo ['avatar'],
  2591. 'date' => '',
  2592. 'date' => '',
  2593. 'opinion' => '',
  2594. 'status' => '',
  2595. 'rolename' => $rolename ['name']
  2596. );
  2597. array_push ( $roleArray, $exp );
  2598. }
  2599. $roleArrayCopy [$v [0]] = $roleArray;
  2600. // $verifyList[$k]['roleArray']=$roleArray;
  2601. }
  2602. $verifyList [$k] ['date'] = "";
  2603. $verifyList [$k] ['opinion'] = "";
  2604. $verifyList [$k] ['status'] = "";
  2605. if (empty ( $verifyStaff )) {
  2606. $verifyList [$k] ['date'] = "";
  2607. $verifyList [$k] ['opinion'] = "";
  2608. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2609. $verifyList [$k] ['status'] = 4;
  2610. $flag = false;
  2611. }
  2612. } else {
  2613. foreach ( $verifyStaff as $m => $u ) {
  2614. if ($v [0] == $m) {
  2615. $verifyList [$k] ['date'] = $u ['date'];
  2616. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2617. $verifyList [$k] ['status'] = $u ['status'];
  2618. $flag = false;
  2619. break;
  2620. }
  2621. }
  2622. $endStaffArray = end ( $verifyStaff );
  2623. if (isset ( $endStaffArray ['ROLE'] )) {
  2624. } else {
  2625. // $endKey=key($verifyStaff);
  2626. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2627. // $button=4;
  2628. // $verifyList[$k]['status']=4;
  2629. // }
  2630. }
  2631. }
  2632. }
  2633. $rolename ['name'] = '';
  2634. if (! empty ( $roleId )) {
  2635. Doo::loadModel ( 'role' );
  2636. $role = new role ();
  2637. $rolename = $role->getOne ( array (
  2638. 'where' => 'rid=' . $roleId,
  2639. 'asArray' => true
  2640. ) );
  2641. }
  2642. if (! empty ( $verifyStaff ))
  2643. $endStaffArray = end ( $verifyStaff );
  2644. $KOP = false;
  2645. foreach ( $roleArrayCopy as $P => $A ) {
  2646. foreach ( $A as $MKI => $AVL ) {
  2647. if (! empty ( $verifyStaff )) {
  2648. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2649. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2650. $button = 4;
  2651. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2652. }
  2653. foreach ( $verifyStaff as $m => $u ) {
  2654. $AVLFK = $AVL [0] . '_R';
  2655. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2656. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2657. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2658. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2659. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2660. break;
  2661. }
  2662. }
  2663. } else {
  2664. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2665. $button = 4;
  2666. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2667. }
  2668. }
  2669. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2670. $KOP = true;
  2671. }
  2672. }
  2673. foreach ( $roleArrayCopy as $k => $v ) {
  2674. foreach ( $verifyList as $m => $n ) {
  2675. if ($n [0] == $k) {
  2676. array_splice ( $verifyList, $m, 1, $v );
  2677. }
  2678. }
  2679. }
  2680. $loanList [$key] ['verifyList'] = $verifyList;
  2681. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  2682. 'where' => 'sid=' . $value ['staff'],
  2683. 'asArray' => true
  2684. ) );
  2685. $loanList [$key] ['button'] = $button;
  2686. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  2687. }
  2688. $data ['loanList'] = $loanList;
  2689. // print_r($loanList);
  2690. $Locate = 0;
  2691. $roleId = 0;
  2692. $button = 0;
  2693. foreach ( $receiptList as $key => $value ) {
  2694. $receiptList [$key] ['Locate'] = $Locate;
  2695. $Locate ++;
  2696. $receiptList [$key] ['reviseDetail'] = array ();
  2697. if (! empty ( $value ['reviseDetail'] ))
  2698. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2699. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2700. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2701. $categoryDetil = $Lcategory->getOne ( array (
  2702. 'where' => 'cid=' . $value ['cid'],
  2703. 'asArray' => true
  2704. ) );
  2705. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2706. // 检测编辑状态
  2707. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  2708. $verifyList ['staff'] = $value ['verifyBreakup'];
  2709. } else
  2710. $verifyList = $verify->getOne ( array (
  2711. 'where' => 'vid=' . $value ['verify'],
  2712. 'asArray' => true
  2713. ) );
  2714. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2715. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2716. Doo::loadModel ( 'role' );
  2717. $role = new role ();
  2718. if ($verifyList == NULL)
  2719. $verifyList = array ();
  2720. $flag = true;
  2721. $roleKey = 0;
  2722. $endStaffArray = array ();
  2723. $roleArrayCopy = array ();
  2724. foreach ( $verifyList as $k => $v ) {
  2725. // init verifyStaff
  2726. if ($v [1] == 'ROLE') {
  2727. if (! empty ( $verifyStaff )) {
  2728. $endStaffArray = end ( $verifyStaff );
  2729. // if ($v[0]==$endStaffArray['nextStaff']){
  2730. // $roleId=$v[0];
  2731. // }
  2732. }
  2733. $roleVerify = json_decode ( $v [3], true );
  2734. $roleKey = $k;
  2735. $roleArray = array ();
  2736. $rolename = $role->getOne ( array (
  2737. 'where' => 'rid=' . $v [0],
  2738. 'asArray' => true
  2739. ) );
  2740. foreach ( $roleVerify as $o => $p ) {
  2741. $staffID = explode ( '_', $p );
  2742. $staffInfo = $staff->getOne ( array (
  2743. 'where' => 'sid=' . $staffID [0],
  2744. 'asArray' => true
  2745. ) );
  2746. // print_r($staffID);
  2747. $exp = array (
  2748. 0 => $staffInfo ['sid'],
  2749. 1 => $staffID [1],
  2750. 2 => $staffInfo ['avatar'],
  2751. 'date' => '',
  2752. 'date' => '',
  2753. 'opinion' => '',
  2754. 'status' => '',
  2755. 'rolename' => $rolename ['name']
  2756. );
  2757. array_push ( $roleArray, $exp );
  2758. }
  2759. $roleArrayCopy [$v [0]] = $roleArray;
  2760. // $verifyList[$k]['roleArray']=$roleArray;
  2761. }
  2762. $verifyList [$k] ['date'] = "";
  2763. $verifyList [$k] ['opinion'] = "";
  2764. $verifyList [$k] ['status'] = "";
  2765. if (empty ( $verifyStaff )) {
  2766. $verifyList [$k] ['date'] = "";
  2767. $verifyList [$k] ['opinion'] = "";
  2768. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2769. $verifyList [$k] ['status'] = 4;
  2770. $flag = false;
  2771. }
  2772. } else {
  2773. foreach ( $verifyStaff as $m => $u ) {
  2774. if ($v [0] == $m) {
  2775. $verifyList [$k] ['date'] = $u ['date'];
  2776. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2777. $verifyList [$k] ['status'] = $u ['status'];
  2778. $flag = false;
  2779. break;
  2780. }
  2781. }
  2782. $endStaffArray = end ( $verifyStaff );
  2783. if (isset ( $endStaffArray ['ROLE'] )) {
  2784. } else {
  2785. // $endKey=key($verifyStaff);
  2786. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2787. // $button=4;
  2788. // $verifyList[$k]['status']=4;
  2789. // }
  2790. }
  2791. }
  2792. }
  2793. $rolename ['name'] = '';
  2794. if (! empty ( $roleId )) {
  2795. Doo::loadModel ( 'role' );
  2796. $role = new role ();
  2797. $rolename = $role->getOne ( array (
  2798. 'where' => 'rid=' . $roleId,
  2799. 'asArray' => true
  2800. ) );
  2801. }
  2802. if (! empty ( $verifyStaff ))
  2803. $endStaffArray = end ( $verifyStaff );
  2804. $KOP = false;
  2805. foreach ( $roleArrayCopy as $P => $A ) {
  2806. foreach ( $A as $MKI => $AVL ) {
  2807. if (! empty ( $verifyStaff )) {
  2808. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2809. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2810. $button = 4;
  2811. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2812. }
  2813. foreach ( $verifyStaff as $m => $u ) {
  2814. $AVLFK = $AVL [0] . '_R';
  2815. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2816. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2817. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2818. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2819. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2820. break;
  2821. }
  2822. }
  2823. } else {
  2824. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2825. $button = 4;
  2826. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2827. }
  2828. }
  2829. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2830. $KOP = true;
  2831. }
  2832. }
  2833. foreach ( $roleArrayCopy as $k => $v ) {
  2834. foreach ( $verifyList as $m => $n ) {
  2835. if ($n [0] == $k) {
  2836. array_splice ( $verifyList, $m, 1, $v );
  2837. }
  2838. }
  2839. }
  2840. // 费用执行人相关数据
  2841. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2842. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2843. foreach ( $executeCopy as $k => $v ) {
  2844. $executeCopy [$k] ['date'] = '';
  2845. $executeCopy [$k] ['opinion'] = '';
  2846. $executeCopy [$k] ['status'] = '';
  2847. if (! empty ( $executeStaff ))
  2848. foreach ( $executeStaff as $m => $u ) {
  2849. if ($v [0] == $m) {
  2850. $executeCopy [$k] ['date'] = $u ['date'];
  2851. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2852. $executeCopy [$k] ['status'] = $u ['status'];
  2853. break;
  2854. }
  2855. }
  2856. }
  2857. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2858. $receiptList [$key] ['verifyList'] = $verifyList;
  2859. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2860. 'where' => 'sid=' . $value ['staff'],
  2861. 'asArray' => true
  2862. ) );
  2863. $receiptList [$key] ['button'] = $button;
  2864. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2865. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2866. $relust = $value ['sum'] - $value ['loanSum'];
  2867. $receiptList [$key] ['relust'] = $relust;
  2868. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2869. }
  2870. // print_r($receiptList);
  2871. // 获取审批日志
  2872. Doo::loadModel ( 'receiptLog' );
  2873. $receiptLog = new receiptLog ();
  2874. $rlList = array ();
  2875. $rlInfo = $receiptLog->getOne ( array (
  2876. 'where' => 'rid=' . $rid . ' and status=4',
  2877. 'asArray' => true
  2878. ) );
  2879. $tijdate = $receiptLog->getOne ( array (
  2880. 'where' => 'rid=' . $rid . ' and status=2',
  2881. 'asc' => 'rlid',
  2882. 'asArray' => true
  2883. ) );
  2884. if (! empty ( $rlInfo )) {
  2885. $rlList = $receiptLog->find ( array (
  2886. 'where' => 'rid=' . $rid,
  2887. 'asc' => 'rlid',
  2888. 'asArray' => true
  2889. ) );
  2890. }
  2891. Doo::loadModel ( 'enclosur' );
  2892. $enclosur = new enclosur ();
  2893. $enclosurList = $enclosur->find ( array (
  2894. 'where' => 'rid=' . $rid,
  2895. 'asArray' => true
  2896. ) );
  2897. $enclosurHtml = '';
  2898. foreach ( $enclosurList as $value ) {
  2899. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2900. }
  2901. $data ['enclosurHtml'] = $enclosurHtml;
  2902. $receiptList [0] ['rlList'] = $rlList;
  2903. $data ['receiptList'] = $receiptList;
  2904. $data ['memu'] = "receipt";
  2905. $data ['staff'] = $this->staff;
  2906. $data ['receiptMemu'] = 'approvalExpenses';
  2907. $data ['verifyId'] = $this->verifyId;
  2908. $data ['executeId'] = $this->executeId;
  2909. $this->render ( "/admin/expensesDoc", $data );
  2910. }
  2911. function expensesEdi() {
  2912. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2913. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  2914. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2915. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2916. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2917. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2918. if (empty ( $status ))
  2919. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  2920. $vidList = array ();
  2921. $button = 0;
  2922. Doo::loadModel ( 'verify' );
  2923. Doo::loadModel ( 'receipt' );
  2924. Doo::loadModel ( 'staff' );
  2925. $staff = new staff ();
  2926. $receipt = new receipt ();
  2927. $verify = new verify ();
  2928. Doo::loadModel ( 'L_category' );
  2929. $Lcategory = new L_category ();
  2930. Doo::loadModel ( 'enclosur' );
  2931. $enclosur = new enclosur ();
  2932. // user verify ID
  2933. $verifyDetail = $verify->find ( array (
  2934. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  2935. 'asArray' => true
  2936. ) );
  2937. foreach ( $verifyDetail as $key => $value ) {
  2938. array_push ( $vidList, $value ['vid'] );
  2939. }
  2940. $vid = implode ( ",", $vidList );
  2941. if (empty ( $verifyDetail ))
  2942. $vid = 0;
  2943. $categoryList = $Lcategory->find ( array (
  2944. 'asArray' => true
  2945. ) );
  2946. $staffList = $staff->find ( array (
  2947. 'where' => 'cid=' . $cid,
  2948. 'asArray' => true
  2949. ) );
  2950. $ap = "";
  2951. if ($status == 4) {
  2952. $ap = 4;
  2953. $status = 2;
  2954. }
  2955. // get Receipt By verifyID status 2
  2956. $receiptList = $receipt->find ( array (
  2957. 'where' => 'rid =' . $rid . ' and status=2',
  2958. 'desc' => 'rid',
  2959. 'asArray' => true
  2960. ) );
  2961. if (empty ( $receiptList )) {
  2962. die ( 'illegal request' );
  2963. }
  2964. $Locate = 0;
  2965. $roleId = 0;
  2966. if ($ap == 4)
  2967. $status = 4;
  2968. foreach ( $receiptList as $key => $value ) {
  2969. $receiptList [$key] ['Locate'] = $Locate;
  2970. $Locate ++;
  2971. $receiptList [$key] ['reviseDetail'] = array ();
  2972. if (! empty ( $value ['reviseDetail'] ))
  2973. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2974. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2975. $categoryDetil = $Lcategory->getOne ( array (
  2976. 'where' => 'cid=' . $value ['cid'],
  2977. 'asArray' => true
  2978. ) );
  2979. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2980. // 检测编辑状态
  2981. $verifyList = $verify->getOne ( array (
  2982. 'where' => 'vid=' . $value ['verify'],
  2983. 'asArray' => true
  2984. ) );
  2985. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2986. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2987. Doo::loadModel ( 'role' );
  2988. $role = new role ();
  2989. // print_r($verifyList);
  2990. $flag = true;
  2991. $roleKey = 0;
  2992. $endStaffArray = array ();
  2993. $roleArrayCopy = array ();
  2994. foreach ( $verifyList as $k => $v ) {
  2995. // init verifyStaff
  2996. if ($v [1] == 'ROLE') {
  2997. if (! empty ( $verifyStaff )) {
  2998. $endStaffArray = end ( $verifyStaff );
  2999. if ($v [0] == $endStaffArray ['nextStaff']) {
  3000. $roleId = $v [0];
  3001. }
  3002. }
  3003. $roleVerify = json_decode ( $v [3], true );
  3004. $roleKey = $k;
  3005. $roleArray = array ();
  3006. $rolename = $role->getOne ( array (
  3007. 'where' => 'rid=' . $v [0],
  3008. 'asArray' => true
  3009. ) );
  3010. foreach ( $roleVerify as $o => $p ) {
  3011. $staffID = explode ( '_', $p );
  3012. $staffInfo = $staff->getOne ( array (
  3013. 'where' => 'sid=' . $staffID [0],
  3014. 'asArray' => true
  3015. ) );
  3016. // print_r($staffID);
  3017. $exp = array (
  3018. 0 => $staffInfo ['sid'],
  3019. 1 => $staffID [1],
  3020. 2 => $staffInfo ['avatar'],
  3021. 'date' => '',
  3022. 'date' => '',
  3023. 'opinion' => '',
  3024. 'status' => '',
  3025. 'rolename' => $rolename ['name']
  3026. );
  3027. array_push ( $roleArray, $exp );
  3028. }
  3029. $roleArrayCopy [$v [0]] = $roleArray;
  3030. // $verifyList[$k]['roleArray']=$roleArray;
  3031. }
  3032. // print_r($roleArray);
  3033. $verifyList [$k] ['date'] = "";
  3034. $verifyList [$k] ['opinion'] = "";
  3035. $verifyList [$k] ['status'] = "";
  3036. if (empty ( $verifyStaff )) {
  3037. $verifyList [$k] ['date'] = "";
  3038. $verifyList [$k] ['opinion'] = "";
  3039. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3040. $verifyList [$k] ['status'] = 4;
  3041. $button = 4;
  3042. $flag = false;
  3043. }
  3044. } else {
  3045. foreach ( $verifyStaff as $m => $u ) {
  3046. if ($v [0] == $m) {
  3047. $verifyList [$k] ['date'] = $u ['date'];
  3048. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3049. $verifyList [$k] ['status'] = $u ['status'];
  3050. $flag = false;
  3051. break;
  3052. }
  3053. }
  3054. $endStaffArray = end ( $verifyStaff );
  3055. if (isset ( $endStaffArray ['ROLE'] )) {
  3056. } else {
  3057. $endKey = key ( $verifyStaff );
  3058. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  3059. $button = 4;
  3060. $verifyList [$k] ['status'] = 4;
  3061. }
  3062. }
  3063. }
  3064. }
  3065. $rolename ['name'] = '';
  3066. if (! empty ( $roleId )) {
  3067. Doo::loadModel ( 'role' );
  3068. $role = new role ();
  3069. $rolename = $role->getOne ( array (
  3070. 'where' => 'rid=' . $roleId,
  3071. 'asArray' => true
  3072. ) );
  3073. }
  3074. if (! empty ( $verifyStaff ))
  3075. $endStaffArray = end ( $verifyStaff );
  3076. $KOP = false;
  3077. foreach ( $roleArrayCopy as $P => $A ) {
  3078. foreach ( $A as $MKI => $AVL ) {
  3079. if (! empty ( $verifyStaff )) {
  3080. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3081. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3082. $button = 4;
  3083. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3084. }
  3085. foreach ( $verifyStaff as $m => $u ) {
  3086. $AVLFK = $AVL [0] . '_R';
  3087. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3088. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3089. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3090. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3091. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3092. break;
  3093. }
  3094. }
  3095. } else {
  3096. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3097. $button = 4;
  3098. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3099. }
  3100. }
  3101. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3102. $KOP = true;
  3103. }
  3104. }
  3105. // print_r($roleArrayCopy);
  3106. // echo $roleKey;
  3107. foreach ( $roleArrayCopy as $k => $v ) {
  3108. foreach ( $verifyList as $m => $n ) {
  3109. if ($n [0] == $k) {
  3110. array_splice ( $verifyList, $m, 1, $v );
  3111. }
  3112. }
  3113. }
  3114. $receiptList [$key] ['verifyList'] = $verifyList;
  3115. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3116. 'where' => 'sid=' . $value ['staff'],
  3117. 'asArray' => true
  3118. ) );
  3119. $receiptList [$key] ['button'] = $button;
  3120. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  3121. }
  3122. // $data['verifyDetail']=$verifyDetail;
  3123. $mothHtml = "";
  3124. for($i = 1; $i <= 12; $i ++) {
  3125. if ($month == $i)
  3126. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3127. else
  3128. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3129. }
  3130. // 获取审批日志
  3131. Doo::loadModel ( 'receiptLog' );
  3132. $receiptLog = new receiptLog ();
  3133. $rlList = array ();
  3134. $rlInfo = $receiptLog->getOne ( array (
  3135. 'where' => 'rid=' . $rid . ' and status=4',
  3136. 'asArray' => true
  3137. ) );
  3138. $tijdate = $receiptLog->getOne ( array (
  3139. 'where' => 'rid=' . $rid . ' and status=2',
  3140. 'asc' => 'rlid',
  3141. 'asArray' => true
  3142. ) );
  3143. if (! empty ( $rlInfo )) {
  3144. $rlList = $receiptLog->find ( array (
  3145. 'where' => 'rid=' . $rid,
  3146. 'asc' => 'rlid',
  3147. 'asArray' => true
  3148. ) );
  3149. }
  3150. $receiptList [0] ['rlList'] = $rlList;
  3151. $enclosurList = $enclosur->find ( array (
  3152. 'where' => 'rid=' . $rid,
  3153. 'asArray' => true
  3154. ) );
  3155. $enclosurHtml = '';
  3156. foreach ( $enclosurList as $value ) {
  3157. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3158. }
  3159. // print_r($receiptList);
  3160. $data ['rid'] = $rid;
  3161. $data ['enclosurHtml'] = $enclosurHtml;
  3162. $data ['rolename'] = $rolename ['name'];
  3163. $data ['datetij'] = $tijdate ['date'];
  3164. $data ['mothHtml'] = $mothHtml;
  3165. $data ['receiptList'] = $receiptList;
  3166. $data ['receiptApprovalCount'] = count ( $receiptList );
  3167. $data ['status'] = $status;
  3168. $data ['year'] = $year;
  3169. $data ['categoryList'] = $categoryList;
  3170. $data ['staffList'] = $staffList;
  3171. $data ['cid'] = $cid;
  3172. $data ['sid'] = $sid;
  3173. $data ['ap'] = $ap;
  3174. $data ['memu'] = "receipt";
  3175. $data ['staff'] = $this->staff;
  3176. $data ['receiptMemu'] = 'approvalExpenses';
  3177. $data ['verifyId'] = $this->verifyId;
  3178. $data ['executeId'] = $this->executeId;
  3179. $this->render ( "/admin/expensesEdi", $data );
  3180. }
  3181. function expensesDefray() {
  3182. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3183. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3184. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3185. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  3186. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  3187. if (! empty ( $rid )) {
  3188. Doo::loadModel ( "verify" );
  3189. $verify = new verify ();
  3190. Doo::loadModel ( "receiptDetail" );
  3191. $receiptDetailObj = new receiptDetail ();
  3192. Doo::loadModel ( "itemStatistics" );
  3193. Doo::loadModel ( "statistics" );
  3194. $statistics = new statistics ();
  3195. $itemStatistics = new itemStatistics ();
  3196. Doo::loadModel ( "receipt" );
  3197. $receipt = new receipt ();
  3198. Doo::loadModel ( "loanReceipt" );
  3199. $loanReceipt = new loanReceipt ();
  3200. $receiptDetail = $receipt->getOne ( array (
  3201. 'where' => 'rid=' . $rid . ' and status=2 ',
  3202. 'asArray' => true
  3203. ) );
  3204. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  3205. $nsflag = true;
  3206. foreach ( $nslist as $value ) {
  3207. if ($value == $this->staff ['0'] ['sid']) {
  3208. $nsflag = false;
  3209. break;
  3210. }
  3211. }
  3212. // print_r($nslist);die;
  3213. if (empty ( $receiptDetail ) || $nsflag)
  3214. return "/approvalExpenses/pendApproval";
  3215. $verifyDetail = $verify->getOne ( array (
  3216. 'where' => ' vid =' . $receiptDetail ['verify'],
  3217. 'asArray' => true
  3218. ) );
  3219. $verifyString = $verifyDetail ['staff'];
  3220. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3221. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  3222. if (empty ( $opinion )) {
  3223. if ($status == 3)
  3224. $opinion = "终止";
  3225. else
  3226. $opinion = "同意支付";
  3227. }
  3228. $nowStaff = 0;
  3229. $nowStaffList = array ();
  3230. if (empty ( $verifyStaff )) {
  3231. // 还需加入是否已经进入角色审批
  3232. if ($verifyDetail [0] [1] == 'ROLE') {
  3233. // print_r($verifyDetail);echo "ddd";
  3234. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3235. foreach ( $vStaffString as $key => $value ) {
  3236. $staffK = explode ( "_", $value );
  3237. if ($staffK [0] != $this->staff [0] ['sid'])
  3238. array_push ( $nowStaffList, $staffK [0] );
  3239. }
  3240. // print_r($verifyDetail);
  3241. // die;
  3242. if (! empty ( $nowStaffList )) {
  3243. $nowStaff = implode ( ',', $nowStaffList );
  3244. $verifyStaff = array (
  3245. $this->staff [0] ['sid'] . "_R" => array (
  3246. 'date' => date ( 'Y-m-d' ),
  3247. 'opinion' => $opinion,
  3248. 'status' => $status,
  3249. 'nextStaff' => $verifyDetail [0] [0],
  3250. 'ROLE' => 1
  3251. )
  3252. );
  3253. } else {
  3254. $nowStaff = $verifyDetail [1] [0];
  3255. $verifyStaff = array (
  3256. $this->staff [0] ['sid'] . "_R" => array (
  3257. 'date' => date ( 'Y-m-d' ),
  3258. 'opinion' => $opinion,
  3259. 'status' => $status,
  3260. 'nextStaff' => $verifyDetail [1] [0]
  3261. )
  3262. );
  3263. }
  3264. } else {
  3265. if ($verifyDetail [1] [1] == 'ROLE') {
  3266. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  3267. // echo "dd";
  3268. foreach ( $vStaffString as $key => $value ) {
  3269. $staffK = explode ( "_", $value );
  3270. array_push ( $nowStaffList, $staffK [0] );
  3271. }
  3272. $nowStaff = implode ( ',', $nowStaffList );
  3273. $verifyStaff = array (
  3274. $this->staff [0] ['sid'] => array (
  3275. 'date' => date ( 'Y-m-d' ),
  3276. 'opinion' => $opinion,
  3277. 'status' => $status,
  3278. 'nextStaff' => $verifyDetail [1] [0],
  3279. 'ROLE' => 1
  3280. )
  3281. );
  3282. } else {
  3283. $nowStaff = $verifyDetail [1] [0];
  3284. $verifyStaff = array (
  3285. $this->staff [0] ['sid'] => array (
  3286. 'date' => date ( 'Y-m-d' ),
  3287. 'opinion' => $opinion,
  3288. 'status' => $status,
  3289. 'nextStaff' => $verifyDetail [1] [0]
  3290. )
  3291. );
  3292. }
  3293. }
  3294. if ($status == 3)
  3295. $verifyStaff = array (
  3296. 'final' => $status,
  3297. $this->staff [0] ['sid'] => array (
  3298. 'date' => date ( 'Y-m-d' ),
  3299. 'opinion' => $opinion,
  3300. 'status' => $status
  3301. )
  3302. );
  3303. $vStaffString = json_encode ( $verifyStaff );
  3304. $receipt->nowStaff = $nowStaff;
  3305. $receipt->verifyStaff = $vStaffString;
  3306. $loanReceipt->nowStaff = $nowStaff;
  3307. $loanReceipt->verifyStaff = $vStaffString;
  3308. } else {
  3309. $VS = end ( $verifyStaff );
  3310. // 非角色审批
  3311. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  3312. $nextStaff = 0;
  3313. $roleSTF = false;
  3314. foreach ( $verifyDetail as $key => $value ) {
  3315. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  3316. if (isset ( $verifyDetail [$key + 1] )) {
  3317. $nextStaff = $verifyDetail [$key + 1] [0];
  3318. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  3319. $roleSTF = true;
  3320. }
  3321. break;
  3322. }
  3323. }
  3324. if (! $roleSTF) {
  3325. $nowStaff = $nextStaff;
  3326. $verifyStaff [$this->staff [0] ['sid']] = array (
  3327. 'date' => date ( 'Y-m-d' ),
  3328. 'opinion' => $opinion,
  3329. 'status' => $status,
  3330. 'nextStaff' => $nextStaff
  3331. );
  3332. } else {
  3333. // 获取角色下的所有用户ID
  3334. $nowStaffList = array ();
  3335. foreach ( $verifyDetail as $vfk ) {
  3336. if ($vfk [1] == 'ROLE') {
  3337. $vStaffString = json_decode ( $vfk [3] );
  3338. foreach ( $vStaffString as $key => $value ) {
  3339. $staffK = explode ( "_", $value );
  3340. array_push ( $nowStaffList, $staffK [0] );
  3341. }
  3342. }
  3343. }
  3344. $nowStaff = implode ( ',', $nowStaffList );
  3345. $verifyStaff [$this->staff [0] ['sid']] = array (
  3346. 'date' => date ( 'Y-m-d' ),
  3347. 'opinion' => $opinion,
  3348. 'status' => $status,
  3349. 'nextStaff' => $nextStaff,
  3350. 'ROLE' => 0
  3351. );
  3352. }
  3353. if ($status == 3) {
  3354. $verifyStaff ['final'] = $status;
  3355. $verifyStaff [$this->staff [0] ['sid']] = array (
  3356. 'date' => date ( 'Y-m-d' ),
  3357. 'opinion' => $opinion,
  3358. 'status' => $status
  3359. );
  3360. }
  3361. $vStaffString = json_encode ( $verifyStaff );
  3362. $receipt->nowStaff = $nowStaff;
  3363. $receipt->verifyStaff = $vStaffString;
  3364. $loanReceipt->nowStaff = $nowStaff;
  3365. $loanReceipt->verifyStaff = $vStaffString;
  3366. }
  3367. // 角色审批
  3368. if (isset ( $VS ['ROLE'] )) {
  3369. // 找出角色人 当前审批角色组
  3370. $verifyJSStaff = array ();
  3371. $nowStaffList2 = array ();
  3372. foreach ( $verifyDetail as $key => $value ) {
  3373. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  3374. $verifyJSStaff = json_decode ( $value [3] );
  3375. foreach ( $verifyJSStaff as $m ) {
  3376. $staffK = explode ( "_", $m );
  3377. array_push ( $nowStaffList2, $staffK [0] );
  3378. }
  3379. // print_r($nowStaffList2);
  3380. }
  3381. }
  3382. $RoleVerifyStaff = array ();
  3383. foreach ( $verifyStaff as $key => $value ) {
  3384. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  3385. foreach ( $nowStaffList2 as $m ) {
  3386. if ($key == $m . "_R")
  3387. $RoleVerifyStaff [$key] = $value;
  3388. }
  3389. }
  3390. }
  3391. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  3392. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  3393. // 下一个审批人ID
  3394. $nextStaff = 0;
  3395. $falg = false;
  3396. foreach ( $verifyDetail as $key => $value ) {
  3397. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  3398. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  3399. $falg = true;
  3400. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  3401. $nowStaffList = array ();
  3402. foreach ( $vStaffString as $v ) {
  3403. $staffK = explode ( "_", $v );
  3404. array_push ( $nowStaffList, $staffK [0] );
  3405. }
  3406. $nowStaff = implode ( ',', $nowStaffList );
  3407. $nextStaff = $verifyDetail [$key + 1] [0];
  3408. } elseif (isset ( $verifyDetail [$key + 1] )) {
  3409. $nextStaff = $verifyDetail [$key + 1] [0];
  3410. $nowStaff = $nextStaff;
  3411. } else
  3412. $nowStaff = '';
  3413. break;
  3414. }
  3415. }
  3416. if ($falg)
  3417. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3418. 'date' => date ( 'Y-m-d' ),
  3419. 'opinion' => $opinion,
  3420. 'status' => $status,
  3421. 'nextStaff' => $nextStaff,
  3422. 'ROLE' => 1
  3423. );
  3424. else
  3425. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3426. 'date' => date ( 'Y-m-d' ),
  3427. 'opinion' => $opinion,
  3428. 'status' => $status,
  3429. 'nextStaff' => $nextStaff
  3430. );
  3431. // print_r($verifyStaff);
  3432. // echo $nowStaff;die;
  3433. } else { // 进入下一个角色或者审批人
  3434. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  3435. //
  3436. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  3437. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3438. 'date' => date ( 'Y-m-d' ),
  3439. 'opinion' => $opinion,
  3440. 'status' => $status,
  3441. 'nextStaff' => $VS ['nextStaff'],
  3442. 'ROLE' => 1
  3443. );
  3444. // print_r($verifyStaff);
  3445. // die;
  3446. }
  3447. if ($status == 3) {
  3448. $verifyStaff ['final'] = $status;
  3449. $verifyStaff [$this->staff [0] ['sid']] = array (
  3450. 'date' => date ( 'Y-m-d' ),
  3451. 'opinion' => $opinion,
  3452. 'status' => $status
  3453. );
  3454. }
  3455. $vStaffString = json_encode ( $verifyStaff );
  3456. $receipt->verifyStaff = $vStaffString;
  3457. $receipt->nowStaff = $nowStaff;
  3458. $loanReceipt->nowStaff = $nowStaff;
  3459. $loanReceipt->verifyStaff = $vStaffString;
  3460. // die;
  3461. // }
  3462. // print_r($verifyStaff);
  3463. // die;
  3464. }
  3465. // print_r($verifyStaff);die;
  3466. }
  3467. // print_r($verifyDetail);
  3468. $roleKey = 0;
  3469. $roleId = 0;
  3470. $verifyDetailCopy = array ();
  3471. foreach ( $verifyDetail as $k => $v ) {
  3472. if ($v [1] == 'ROLE') {
  3473. $roleId = $v [0];
  3474. $roleVerify = json_decode ( $v [3], true );
  3475. $roleKey = $k;
  3476. $roleArray = array ();
  3477. foreach ( $roleVerify as $o => $p ) {
  3478. $staffID = explode ( '_', $p );
  3479. $exp = array (
  3480. 0 => $staffID [0],
  3481. 1 => $staffID [1]
  3482. );
  3483. array_push ( $roleArray, $exp );
  3484. }
  3485. $verifyDetailCopy [$v [0]] = $roleArray;
  3486. }
  3487. }
  3488. // print_r($verifyDetail);
  3489. foreach ( $verifyDetailCopy as $k => $v ) {
  3490. foreach ( $verifyDetail as $m => $n ) {
  3491. if ($n [0] == $k) {
  3492. array_splice ( $verifyDetail, $m, 1, $v );
  3493. }
  3494. }
  3495. }
  3496. // 审批日志
  3497. if (! isset ( $verifyStaff ['final'] )) {
  3498. Doo::loadModel ( "receiptLog" );
  3499. $receiptLog = new receiptLog ();
  3500. if (! empty ( $roleId )) {
  3501. Doo::loadModel ( "role" );
  3502. $role = new role ();
  3503. $roleInfo = $role->getOne ( array (
  3504. 'where' => 'rid=' . $roleId,
  3505. 'asArray' => true
  3506. ) );
  3507. $receiptLog->rolename = $roleInfo ['name'];
  3508. }
  3509. $receiptLog->username = $this->staff [0] ['username'];
  3510. $receiptLog->uid = $this->staff [0] ['sid'];
  3511. $receiptLog->date = date ( "Y-m-d" );
  3512. $receiptLog->opinion = $opinion;
  3513. $receiptLog->img = $this->staff [0] ['avatar'];
  3514. $receiptLog->status = 1;
  3515. $receiptLog->rid = $rid;
  3516. $receiptLog->insert ();
  3517. }
  3518. if (isset ( $verifyStaff ['final'] )) { // rDetail
  3519. $receipt->status = 3;
  3520. $receipt->verifyBreakup = $verifyString;
  3521. $receiptDetailObj->status = 3;
  3522. $receiptDetailObj->update ( array (
  3523. 'where' => 'rid=' . $rid
  3524. ) );
  3525. // 微信企业号通知
  3526. $this->setWXMsg ( $rid, 3 );
  3527. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  3528. $receipt->status = 6;
  3529. $receipt->pastDate = date ( "Y-m-d" );
  3530. $receipt->isBK = 1;
  3531. $loanReceipt->verifyBreakup = $verifyString;
  3532. $loanReceipt->status = 1;
  3533. $loanReceipt->pastDate = date ( "Y-m-d" );
  3534. $loanReceipt->amount = $receiptDetail ['amount'];
  3535. $loanReceipt->update ( array (
  3536. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  3537. ) );
  3538. // 微信企业号通知
  3539. $this->setWXMsg ( $rid, 1 );
  3540. }
  3541. $receipt->amount = $amount;
  3542. $receipt->update ( array (
  3543. 'where' => ' rid = ' . $rid
  3544. ) );
  3545. // 进入下一条审批费用新加需求
  3546. $vidList = array ();
  3547. $verifyDetail = $verify->find ( array (
  3548. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  3549. 'asArray' => true
  3550. ) );
  3551. foreach ( $verifyDetail as $key => $value ) {
  3552. array_push ( $vidList, $value ['vid'] );
  3553. }
  3554. $vid = implode ( ",", $vidList );
  3555. if (empty ( $verifyDetail ))
  3556. $vid = 0;
  3557. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  3558. $receipt = new receipt ();
  3559. $rd = $receipt->getOne ( array (
  3560. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  3561. 'asc' => 'rid',
  3562. 'asArray' => true
  3563. ) );
  3564. if (empty ( $rd )) {
  3565. return '/approvalExpenses/pendApproval';
  3566. }
  3567. if ($rd ['Rtype'] == 1) {
  3568. if ($rd ['isBK'] == 1) {
  3569. return '/receiptburEdi/' . $rd ['rid'];
  3570. } else {
  3571. return '/expensesEdi/' . $rd ['rid'];
  3572. }
  3573. } elseif ($rd ['Rtype'] == 2) {
  3574. return '/remitApproval/' . $rd ['rid'];
  3575. } else {
  3576. return '/receiptburEdi/' . $rd ['rid'];
  3577. }
  3578. // return "/approvalExpenses/pendApproval";
  3579. }
  3580. }
  3581. function ajaxExamineExe() {
  3582. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3583. Doo::loadModel ( 'receipt' );
  3584. $receipt = new receipt ();
  3585. Doo::loadClass ( 'XDeode' );
  3586. $XDeode = new XDeode ( 5 );
  3587. if (! empty ( $rid )) {
  3588. $rLRes = $receipt->find ( array (
  3589. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  3590. 'asArray' => true
  3591. ) );
  3592. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  3593. echo json_encode ( array (
  3594. 'status' => 1,
  3595. 'receipt' => $rLRes [0]
  3596. ) );
  3597. die ();
  3598. }
  3599. echo json_encode ( array (
  3600. 'status' => 0,
  3601. 'receipt' => array ()
  3602. ) );
  3603. die ();
  3604. }
  3605. function implement() {
  3606. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3607. Doo::loadClass ( 'XDeode' );
  3608. $XDeode = new XDeode ( 5 );
  3609. Doo::loadModel ( 'receipt' );
  3610. $receipt = new receipt ();
  3611. Doo::loadModel ( 'L_category' );
  3612. $Lcategory = new L_category ();
  3613. Doo::loadModel ( 'verify' );
  3614. $verify = new verify ();
  3615. Doo::loadModel ( 'staff' );
  3616. $staff = new staff ();
  3617. Doo::loadModel ( "execute" );
  3618. $execute = new execute ();
  3619. $rid = $XDeode->decode ( $rid );
  3620. $receiptList = $receipt->find ( array (
  3621. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  3622. 'desc' => 'rid',
  3623. 'asArray' => true
  3624. ) );
  3625. Doo::loadModel ( 'loanReceipt' );
  3626. $loanReceipt = new loanReceipt ();
  3627. // print_r($receiptList);
  3628. $loanList = array ();
  3629. if (! isset ( $receiptList ))
  3630. $loanList = $loanReceipt->find ( array (
  3631. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3632. 'desc' => 'rid',
  3633. 'asArray' => true
  3634. ) );
  3635. $Locate = 0;
  3636. $roleId = 0;
  3637. $button = 0;
  3638. foreach ( $loanList as $key => $value ) {
  3639. $loanList [$key] ['Locate'] = $Locate;
  3640. $Locate ++;
  3641. $loanList [$key] ['reviseDetail'] = array ();
  3642. if (! empty ( $value ['reviseDetail'] ))
  3643. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3644. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3645. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3646. $categoryDetil = $Lcategory->getOne ( array (
  3647. 'where' => 'cid=' . $value ['cid'],
  3648. 'asArray' => true
  3649. ) );
  3650. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3651. // 检测编辑状态
  3652. $verifyList = $verify->getOne ( array (
  3653. 'where' => 'vid=' . $value ['verify'],
  3654. 'asArray' => true
  3655. ) );
  3656. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3657. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3658. Doo::loadModel ( 'role' );
  3659. $role = new role ();
  3660. $flag = true;
  3661. $roleKey = 0;
  3662. $endStaffArray = array ();
  3663. $roleArrayCopy = array ();
  3664. foreach ( $verifyList as $k => $v ) {
  3665. // init verifyStaff
  3666. if ($v [1] == 'ROLE') {
  3667. if (! empty ( $verifyStaff )) {
  3668. $endStaffArray = end ( $verifyStaff );
  3669. // if ($v[0]==$endStaffArray['nextStaff']){
  3670. // $roleId=$v[0];
  3671. // }
  3672. }
  3673. $roleVerify = json_decode ( $v [3], true );
  3674. $roleKey = $k;
  3675. $roleArray = array ();
  3676. $rolename = $role->getOne ( array (
  3677. 'where' => 'rid=' . $v [0],
  3678. 'asArray' => true
  3679. ) );
  3680. foreach ( $roleVerify as $o => $p ) {
  3681. $staffID = explode ( '_', $p );
  3682. $staffInfo = $staff->getOne ( array (
  3683. 'where' => 'sid=' . $staffID [0],
  3684. 'asArray' => true
  3685. ) );
  3686. // print_r($staffID);
  3687. $exp = array (
  3688. 0 => $staffInfo ['sid'],
  3689. 1 => $staffID [1],
  3690. 2 => $staffInfo ['avatar'],
  3691. 'date' => '',
  3692. 'date' => '',
  3693. 'opinion' => '',
  3694. 'status' => '',
  3695. 'rolename' => $rolename ['name']
  3696. );
  3697. array_push ( $roleArray, $exp );
  3698. }
  3699. $roleArrayCopy [$v [0]] = $roleArray;
  3700. // $verifyList[$k]['roleArray']=$roleArray;
  3701. }
  3702. $verifyList [$k] ['date'] = "";
  3703. $verifyList [$k] ['opinion'] = "";
  3704. $verifyList [$k] ['status'] = "";
  3705. if (empty ( $verifyStaff )) {
  3706. $verifyList [$k] ['date'] = "";
  3707. $verifyList [$k] ['opinion'] = "";
  3708. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3709. $verifyList [$k] ['status'] = 4;
  3710. $flag = false;
  3711. }
  3712. } else {
  3713. foreach ( $verifyStaff as $m => $u ) {
  3714. if ($v [0] == $m) {
  3715. $verifyList [$k] ['date'] = $u ['date'];
  3716. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3717. $verifyList [$k] ['status'] = $u ['status'];
  3718. $flag = false;
  3719. break;
  3720. }
  3721. }
  3722. $endStaffArray = end ( $verifyStaff );
  3723. if (isset ( $endStaffArray ['ROLE'] )) {
  3724. } else {
  3725. // $endKey=key($verifyStaff);
  3726. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3727. // $button=4;
  3728. // $verifyList[$k]['status']=4;
  3729. // }
  3730. }
  3731. }
  3732. }
  3733. $rolename ['name'] = '';
  3734. if (! empty ( $roleId )) {
  3735. Doo::loadModel ( 'role' );
  3736. $role = new role ();
  3737. $rolename = $role->getOne ( array (
  3738. 'where' => 'rid=' . $roleId,
  3739. 'asArray' => true
  3740. ) );
  3741. }
  3742. if (! empty ( $verifyStaff ))
  3743. $endStaffArray = end ( $verifyStaff );
  3744. $KOP = false;
  3745. foreach ( $roleArrayCopy as $P => $A ) {
  3746. foreach ( $A as $MKI => $AVL ) {
  3747. if (! empty ( $verifyStaff )) {
  3748. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3749. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3750. $button = 4;
  3751. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3752. }
  3753. foreach ( $verifyStaff as $m => $u ) {
  3754. $AVLFK = $AVL [0] . '_R';
  3755. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3756. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3757. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3758. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3759. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3760. break;
  3761. }
  3762. }
  3763. } else {
  3764. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3765. $button = 4;
  3766. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3767. }
  3768. }
  3769. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3770. $KOP = true;
  3771. }
  3772. }
  3773. foreach ( $roleArrayCopy as $k => $v ) {
  3774. foreach ( $verifyList as $m => $n ) {
  3775. if ($n [0] == $k) {
  3776. array_splice ( $verifyList, $m, 1, $v );
  3777. }
  3778. }
  3779. }
  3780. $loanList [$key] ['verifyList'] = $verifyList;
  3781. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3782. 'where' => 'sid=' . $value ['staff'],
  3783. 'asArray' => true
  3784. ) );
  3785. }
  3786. $data ['loanList'] = $loanList;
  3787. $Locate = 0;
  3788. $roleId = 0;
  3789. $button = 0;
  3790. foreach ( $receiptList as $key => $value ) {
  3791. $button2 = 0;
  3792. $receiptList [$key] ['Locate'] = $Locate;
  3793. $Locate ++;
  3794. $receiptList [$key] ['reviseDetail'] = array ();
  3795. if (! empty ( $value ['reviseDetail'] ))
  3796. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3797. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3798. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3799. $categoryDetil = $Lcategory->getOne ( array (
  3800. 'where' => 'cid=' . $value ['cid'],
  3801. 'asArray' => true
  3802. ) );
  3803. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3804. $executeList = json_decode ( $value ['executeCopy'], true );
  3805. $executeStaff = array ();
  3806. if (! empty ( $value ['executeStaff'] ))
  3807. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3808. if (isset ( $executeList )) {
  3809. foreach ( $executeList as $op => $lo ) {
  3810. $executeList [$op] ['date'] = "";
  3811. $executeList [$op] ['opinion'] = "";
  3812. $executeList [$op] ['status'] = "";
  3813. foreach ( $executeStaff as $m => $u ) {
  3814. if ($lo [0] == $m) {
  3815. $executeList [$op] ['date'] = $u ['date'];
  3816. $executeList [$op] ['opinion'] = $u ['opinion'];
  3817. $executeList [$op] ['status'] = $u ['status'];
  3818. break;
  3819. }
  3820. }
  3821. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  3822. $button2 = 1;
  3823. $executeList [$op] ['status'] = 4;
  3824. }
  3825. }
  3826. }
  3827. // 检测编辑状态
  3828. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3829. $verifyList ['staff'] = $value ['verifyBreakup'];
  3830. } else
  3831. $verifyList = $verify->getOne ( array (
  3832. 'where' => 'vid=' . $value ['verify'],
  3833. 'asArray' => true
  3834. ) );
  3835. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3836. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3837. Doo::loadModel ( 'role' );
  3838. $role = new role ();
  3839. if ($verifyList == NULL)
  3840. $verifyList = array ();
  3841. $flag = true;
  3842. $roleKey = 0;
  3843. $endStaffArray = array ();
  3844. $roleArrayCopy = array ();
  3845. foreach ( $verifyList as $k => $v ) {
  3846. // init verifyStaff
  3847. if ($v [1] == 'ROLE') {
  3848. if (! empty ( $verifyStaff )) {
  3849. $endStaffArray = end ( $verifyStaff );
  3850. // if ($v[0]==$endStaffArray['nextStaff']){
  3851. // $roleId=$v[0];
  3852. // }
  3853. }
  3854. $roleVerify = json_decode ( $v [3], true );
  3855. $roleKey = $k;
  3856. $roleArray = array ();
  3857. $rolename = $role->getOne ( array (
  3858. 'where' => 'rid=' . $v [0],
  3859. 'asArray' => true
  3860. ) );
  3861. foreach ( $roleVerify as $o => $p ) {
  3862. $staffID = explode ( '_', $p );
  3863. $staffInfo = $staff->getOne ( array (
  3864. 'where' => 'sid=' . $staffID [0],
  3865. 'asArray' => true
  3866. ) );
  3867. // print_r($staffID);
  3868. $exp = array (
  3869. 0 => $staffInfo ['sid'],
  3870. 1 => $staffID [1],
  3871. 2 => $staffInfo ['avatar'],
  3872. 'date' => '',
  3873. 'date' => '',
  3874. 'opinion' => '',
  3875. 'status' => '',
  3876. 'rolename' => $rolename ['name']
  3877. );
  3878. array_push ( $roleArray, $exp );
  3879. }
  3880. $roleArrayCopy [$v [0]] = $roleArray;
  3881. // $verifyList[$k]['roleArray']=$roleArray;
  3882. }
  3883. $verifyList [$k] ['date'] = "";
  3884. $verifyList [$k] ['opinion'] = "";
  3885. $verifyList [$k] ['status'] = "";
  3886. if (empty ( $verifyStaff )) {
  3887. $verifyList [$k] ['date'] = "";
  3888. $verifyList [$k] ['opinion'] = "";
  3889. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3890. $verifyList [$k] ['status'] = 4;
  3891. $flag = false;
  3892. }
  3893. } else {
  3894. foreach ( $verifyStaff as $m => $u ) {
  3895. if ($v [0] == $m) {
  3896. $verifyList [$k] ['date'] = $u ['date'];
  3897. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3898. $verifyList [$k] ['status'] = $u ['status'];
  3899. $flag = false;
  3900. break;
  3901. }
  3902. }
  3903. $endStaffArray = end ( $verifyStaff );
  3904. if (isset ( $endStaffArray ['ROLE'] )) {
  3905. } else {
  3906. // $endKey=key($verifyStaff);
  3907. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3908. // $button=4;
  3909. // $verifyList[$k]['status']=4;
  3910. // }
  3911. }
  3912. }
  3913. }
  3914. $rolename ['name'] = '';
  3915. if (! empty ( $roleId )) {
  3916. Doo::loadModel ( 'role' );
  3917. $role = new role ();
  3918. $rolename = $role->getOne ( array (
  3919. 'where' => 'rid=' . $roleId,
  3920. 'asArray' => true
  3921. ) );
  3922. }
  3923. if (! empty ( $verifyStaff ))
  3924. $endStaffArray = end ( $verifyStaff );
  3925. $KOP = false;
  3926. foreach ( $roleArrayCopy as $P => $A ) {
  3927. foreach ( $A as $MKI => $AVL ) {
  3928. if (! empty ( $verifyStaff )) {
  3929. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3930. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3931. $button = 4;
  3932. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3933. }
  3934. foreach ( $verifyStaff as $m => $u ) {
  3935. $AVLFK = $AVL [0] . '_R';
  3936. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3937. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3938. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3939. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3940. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3941. break;
  3942. }
  3943. }
  3944. } else {
  3945. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3946. $button = 4;
  3947. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3948. }
  3949. }
  3950. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3951. $KOP = true;
  3952. }
  3953. }
  3954. foreach ( $roleArrayCopy as $k => $v ) {
  3955. foreach ( $verifyList as $m => $n ) {
  3956. if ($n [0] == $k) {
  3957. array_splice ( $verifyList, $m, 1, $v );
  3958. }
  3959. }
  3960. }
  3961. $receiptList [$key] ['verifyList'] = $verifyList;
  3962. $receiptList [$key] ['executeList'] = $executeList;
  3963. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3964. 'where' => 'sid=' . $value ['staff'],
  3965. 'asArray' => true
  3966. ) );
  3967. $receiptList [$key] ['button2'] = $button2;
  3968. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3969. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3970. $relust = $value ['sum'] - $value ['loanSum'];
  3971. $receiptList [$key] ['relust'] = $relust;
  3972. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  3973. }
  3974. // print_r($receiptList[$key]['executeList']);
  3975. $data ['receiptList'] = $receiptList;
  3976. $data ['memu'] = "receipt";
  3977. $data ['staff'] = $this->staff;
  3978. $data ['receiptMemu'] = 'implement';
  3979. $data ['verifyId'] = $this->verifyId;
  3980. $data ['executeId'] = $this->executeId;
  3981. $this->render ( "/admin/implement", $data );
  3982. }
  3983. function implementDo() {
  3984. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3985. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3986. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  3987. if (! empty ( $rid ) && $amount != '') {
  3988. Doo::loadModel ( 'receipt' );
  3989. $receipt = new receipt ();
  3990. Doo::loadClass ( 'XDeode' );
  3991. $XDeode = new XDeode ( 5 );
  3992. $rinfo = $receipt->getOne ( array (
  3993. 'where' => 'rid=' . $rid,
  3994. 'asArray' => true
  3995. ) );
  3996. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  3997. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  3998. if (empty ( $executeStaff )) {
  3999. $executeStaff = array (
  4000. $this->staff [0] ['sid'] => array (
  4001. 'date' => date ( 'Y-m-d' ),
  4002. 'opinion' => $implementOpinions,
  4003. 'status' => 1
  4004. )
  4005. );
  4006. } else {
  4007. $executeStaff [$this->staff [0] ['sid']] = array (
  4008. 'date' => date ( 'Y-m-d' ),
  4009. 'opinion' => $implementOpinions,
  4010. 'status' => 1
  4011. );
  4012. }
  4013. if (count ( $executeStaff ) == count ( $executeCopy )) {
  4014. $receipt->executeStaff = json_encode ( $executeStaff );
  4015. $receipt->status = 8;
  4016. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  4017. $receipt->status = 9;
  4018. if ($rinfo ['status'] == 6) {
  4019. $receipt->loanDate = date ( "Y-m-d" );
  4020. }
  4021. $receipt->executeDate = date ( "Y-m-d" );
  4022. } else {
  4023. $receipt->executeStaff = json_encode ( $executeStaff );
  4024. }
  4025. $receipt->amount = $amount;
  4026. $receipt->update ( array (
  4027. 'where' => 'rid=' . $rid
  4028. ) );
  4029. }
  4030. $ridKey = $XDeode->encode ( $rid );
  4031. return "/hisImplement";
  4032. // return "/implement/" . $ridKey . ".html";
  4033. }
  4034. function receiptburEdi() {
  4035. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4036. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  4037. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4038. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4039. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4040. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4041. if (empty ( $status ))
  4042. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  4043. $vidList = array ();
  4044. $button = 0;
  4045. Doo::loadModel ( 'verify' );
  4046. Doo::loadModel ( 'receipt' );
  4047. Doo::loadModel ( 'staff' );
  4048. $staff = new staff ();
  4049. $receipt = new receipt ();
  4050. $verify = new verify ();
  4051. Doo::loadModel ( 'L_category' );
  4052. $Lcategory = new L_category ();
  4053. Doo::loadModel ( 'enclosur' );
  4054. $enclosur = new enclosur ();
  4055. Doo::loadModel ( 'loanReceipt' );
  4056. $loanReceipt = new loanReceipt ();
  4057. // user verify ID
  4058. $verifyDetail = $verify->find ( array (
  4059. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  4060. 'asArray' => true
  4061. ) );
  4062. foreach ( $verifyDetail as $key => $value ) {
  4063. array_push ( $vidList, $value ['vid'] );
  4064. }
  4065. $vid = implode ( ",", $vidList );
  4066. if (empty ( $verifyDetail ))
  4067. $vid = 0;
  4068. $categoryList = $Lcategory->find ( array (
  4069. 'asArray' => true
  4070. ) );
  4071. $staffList = $staff->find ( array (
  4072. 'where' => 'cid=' . $cid,
  4073. 'asArray' => true
  4074. ) );
  4075. $ap = "";
  4076. if ($status == 4) {
  4077. $ap = 4;
  4078. $status = 2;
  4079. }
  4080. // get Receipt By verifyID status 2
  4081. $receiptList = $receipt->find ( array (
  4082. 'where' => 'rid =' . $rid . ' and status=2',
  4083. 'desc' => 'rid',
  4084. 'asArray' => true
  4085. ) );
  4086. if (empty ( $receiptList )) {
  4087. die ( 'illegal request' );
  4088. }
  4089. $loanList = $loanReceipt->find ( array (
  4090. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4091. 'desc' => 'rid',
  4092. 'asArray' => true
  4093. ) );
  4094. $data ['explanation'] = '';
  4095. if (! empty ( $loanList ))
  4096. $data ['explanation'] = $loanList [0] ['explanation'];
  4097. $Locate = 0;
  4098. $roleId = 0;
  4099. $button = 0;
  4100. foreach ( $loanList as $key => $value ) {
  4101. $loanList [$key] ['Locate'] = $Locate;
  4102. $Locate ++;
  4103. $loanList [$key] ['reviseDetail'] = array ();
  4104. if (! empty ( $value ['reviseDetail'] ))
  4105. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4106. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4107. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4108. $categoryDetil = $Lcategory->getOne ( array (
  4109. 'where' => 'cid=' . $value ['cid'],
  4110. 'asArray' => true
  4111. ) );
  4112. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4113. // 检测编辑状态
  4114. $verifyList = $verify->getOne ( array (
  4115. 'where' => 'vid=' . $value ['verify'],
  4116. 'asArray' => true
  4117. ) );
  4118. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4119. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4120. Doo::loadModel ( 'role' );
  4121. $role = new role ();
  4122. $flag = true;
  4123. $roleKey = 0;
  4124. $endStaffArray = array ();
  4125. $roleArrayCopy = array ();
  4126. foreach ( $verifyList as $k => $v ) {
  4127. // init verifyStaff
  4128. if ($v [1] == 'ROLE') {
  4129. if (! empty ( $verifyStaff )) {
  4130. $endStaffArray = end ( $verifyStaff );
  4131. }
  4132. $roleVerify = json_decode ( $v [3], true );
  4133. $roleKey = $k;
  4134. $roleArray = array ();
  4135. $rolename = $role->getOne ( array (
  4136. 'where' => 'rid=' . $v [0],
  4137. 'asArray' => true
  4138. ) );
  4139. foreach ( $roleVerify as $o => $p ) {
  4140. $staffID = explode ( '_', $p );
  4141. $staffInfo = $staff->getOne ( array (
  4142. 'where' => 'sid=' . $staffID [0],
  4143. 'asArray' => true
  4144. ) );
  4145. // print_r($staffID);
  4146. $exp = array (
  4147. 0 => $staffInfo ['sid'],
  4148. 1 => $staffID [1],
  4149. 2 => $staffInfo ['avatar'],
  4150. 'date' => '',
  4151. 'date' => '',
  4152. 'opinion' => '',
  4153. 'status' => '',
  4154. 'rolename' => $rolename ['name']
  4155. );
  4156. array_push ( $roleArray, $exp );
  4157. }
  4158. $roleArrayCopy [$v [0]] = $roleArray;
  4159. // $verifyList[$k]['roleArray']=$roleArray;
  4160. }
  4161. $verifyList [$k] ['date'] = "";
  4162. $verifyList [$k] ['opinion'] = "";
  4163. $verifyList [$k] ['status'] = "";
  4164. if (empty ( $verifyStaff )) {
  4165. $verifyList [$k] ['date'] = "";
  4166. $verifyList [$k] ['opinion'] = "";
  4167. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4168. $verifyList [$k] ['status'] = 4;
  4169. $flag = false;
  4170. }
  4171. } else {
  4172. foreach ( $verifyStaff as $m => $u ) {
  4173. if ($v [0] == $m) {
  4174. $verifyList [$k] ['date'] = $u ['date'];
  4175. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4176. $verifyList [$k] ['status'] = $u ['status'];
  4177. $flag = false;
  4178. break;
  4179. }
  4180. }
  4181. $endStaffArray = end ( $verifyStaff );
  4182. if (isset ( $endStaffArray ['ROLE'] )) {
  4183. } else {
  4184. }
  4185. }
  4186. }
  4187. $rolename ['name'] = '';
  4188. if (! empty ( $roleId )) {
  4189. Doo::loadModel ( 'role' );
  4190. $role = new role ();
  4191. $rolename = $role->getOne ( array (
  4192. 'where' => 'rid=' . $roleId,
  4193. 'asArray' => true
  4194. ) );
  4195. }
  4196. if (! empty ( $verifyStaff ))
  4197. $endStaffArray = end ( $verifyStaff );
  4198. $KOP = false;
  4199. foreach ( $roleArrayCopy as $P => $A ) {
  4200. foreach ( $A as $MKI => $AVL ) {
  4201. if (! empty ( $verifyStaff )) {
  4202. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4203. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4204. $button = 4;
  4205. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4206. }
  4207. foreach ( $verifyStaff as $m => $u ) {
  4208. $AVLFK = $AVL [0] . '_R';
  4209. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4210. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4211. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4212. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4213. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4214. break;
  4215. }
  4216. }
  4217. } else {
  4218. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4219. $button = 4;
  4220. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4221. }
  4222. }
  4223. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4224. $KOP = true;
  4225. }
  4226. }
  4227. foreach ( $roleArrayCopy as $k => $v ) {
  4228. foreach ( $verifyList as $m => $n ) {
  4229. if ($n [0] == $k) {
  4230. array_splice ( $verifyList, $m, 1, $v );
  4231. }
  4232. }
  4233. }
  4234. $loanList [$key] ['verifyList'] = $verifyList;
  4235. }
  4236. $htmlLoan = '';
  4237. if (isset ( $loanList [0] )) {
  4238. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  4239. if ($value ['status'] == 1)
  4240. $htmlLoan .= '<li class="done" >';
  4241. elseif ($value ['status'] == 3)
  4242. $htmlLoan .= '<li class="undone" >';
  4243. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  4244. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  4245. if (isset ( $value ['rolename'] ))
  4246. $htmlLoan .= $value ['rolename'];
  4247. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  4248. }
  4249. $data ['loanDate'] = $loanList [0] ['date'];
  4250. } else {
  4251. $data ['loanReceiptDate'] = ''; // $loanList [0] ['date'];
  4252. }
  4253. $data ['htmlLoan'] = $htmlLoan;
  4254. // $data ['LoanReceipt']=$loanList[0];
  4255. // print_r($loanList);
  4256. $Locate = 0;
  4257. $roleId = 0;
  4258. $button = 0;
  4259. if ($ap == 4)
  4260. $status = 4;
  4261. Doo::loadClass ( 'XDeode' );
  4262. $XDeode = new XDeode ( 5 );
  4263. foreach ( $receiptList as $key => $value ) {
  4264. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4265. $receiptList [$key] ['Locate'] = $Locate;
  4266. $Locate ++;
  4267. $receiptList [$key] ['reviseDetail'] = array ();
  4268. // 调整金额 代码调整
  4269. if (! empty ( $value ['reviseDetail'] )) {
  4270. $reviseDetail = json_decode ( $value ['reviseDetail'], true );
  4271. foreach ( $reviseDetail as $ry => $re ) {
  4272. $reviseDetail [$ry] ['sidKey'] = $XDeode->encode ( $re ['sid'] );
  4273. $reviseDetail [$ry] ['reviseKey'] = $XDeode->encode ( $ry );
  4274. }
  4275. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  4276. // print_r($reviseDetail);
  4277. }
  4278. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4279. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4280. $categoryDetil = $Lcategory->getOne ( array (
  4281. 'where' => 'cid=' . $value ['cid'],
  4282. 'asArray' => true
  4283. ) );
  4284. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4285. // 检测编辑状态
  4286. $verifyList = $verify->getOne ( array (
  4287. 'where' => 'vid=' . $value ['verify'],
  4288. 'asArray' => true
  4289. ) );
  4290. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4291. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4292. Doo::loadModel ( 'role' );
  4293. $role = new role ();
  4294. // print_r($verifyList);
  4295. $flag = true;
  4296. $roleKey = 0;
  4297. $endStaffArray = array ();
  4298. $roleArrayCopy = array ();
  4299. foreach ( $verifyList as $k => $v ) {
  4300. // init verifyStaff
  4301. if ($v [1] == 'ROLE') {
  4302. if (! empty ( $verifyStaff )) {
  4303. $endStaffArray = end ( $verifyStaff );
  4304. if ($v [0] == $endStaffArray ['nextStaff']) {
  4305. $roleId = $v [0];
  4306. }
  4307. }
  4308. $roleVerify = json_decode ( $v [3], true );
  4309. $roleKey = $k;
  4310. $roleArray = array ();
  4311. $rolename = $role->getOne ( array (
  4312. 'where' => 'rid=' . $v [0],
  4313. 'asArray' => true
  4314. ) );
  4315. foreach ( $roleVerify as $o => $p ) {
  4316. $staffID = explode ( '_', $p );
  4317. $staffInfo = $staff->getOne ( array (
  4318. 'where' => 'sid=' . $staffID [0],
  4319. 'asArray' => true
  4320. ) );
  4321. // print_r($staffID);
  4322. $exp = array (
  4323. 0 => $staffInfo ['sid'],
  4324. 1 => $staffID [1],
  4325. 2 => $staffInfo ['avatar'],
  4326. 'date' => '',
  4327. 'date' => '',
  4328. 'opinion' => '',
  4329. 'status' => '',
  4330. 'rolename' => $rolename ['name']
  4331. );
  4332. array_push ( $roleArray, $exp );
  4333. }
  4334. $roleArrayCopy [$v [0]] = $roleArray;
  4335. // $verifyList[$k]['roleArray']=$roleArray;
  4336. }
  4337. // print_r($roleArray);
  4338. $verifyList [$k] ['date'] = "";
  4339. $verifyList [$k] ['opinion'] = "";
  4340. $verifyList [$k] ['status'] = "";
  4341. if (empty ( $verifyStaff )) {
  4342. $verifyList [$k] ['date'] = "";
  4343. $verifyList [$k] ['opinion'] = "";
  4344. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4345. $verifyList [$k] ['status'] = 4;
  4346. $button = 4;
  4347. $flag = false;
  4348. }
  4349. } else {
  4350. foreach ( $verifyStaff as $m => $u ) {
  4351. if ($v [0] == $m) {
  4352. $verifyList [$k] ['date'] = $u ['date'];
  4353. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4354. $verifyList [$k] ['status'] = $u ['status'];
  4355. $flag = false;
  4356. break;
  4357. }
  4358. }
  4359. $endStaffArray = end ( $verifyStaff );
  4360. if (isset ( $endStaffArray ['ROLE'] )) {
  4361. } else {
  4362. $endKey = key ( $verifyStaff );
  4363. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4364. $button = 4;
  4365. $verifyList [$k] ['status'] = 4;
  4366. }
  4367. }
  4368. }
  4369. }
  4370. $rolename ['name'] = '';
  4371. if (! empty ( $roleId )) {
  4372. Doo::loadModel ( 'role' );
  4373. $role = new role ();
  4374. $rolename = $role->getOne ( array (
  4375. 'where' => 'rid=' . $roleId,
  4376. 'asArray' => true
  4377. ) );
  4378. }
  4379. if (! empty ( $verifyStaff ))
  4380. $endStaffArray = end ( $verifyStaff );
  4381. $KOP = false;
  4382. foreach ( $roleArrayCopy as $P => $A ) {
  4383. foreach ( $A as $MKI => $AVL ) {
  4384. if (! empty ( $verifyStaff )) {
  4385. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4386. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4387. $button = 4;
  4388. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4389. }
  4390. foreach ( $verifyStaff as $m => $u ) {
  4391. $AVLFK = $AVL [0] . '_R';
  4392. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4393. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4394. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4395. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4396. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4397. break;
  4398. }
  4399. }
  4400. } else {
  4401. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4402. $button = 4;
  4403. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4404. }
  4405. }
  4406. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4407. $KOP = true;
  4408. }
  4409. }
  4410. foreach ( $roleArrayCopy as $k => $v ) {
  4411. foreach ( $verifyList as $m => $n ) {
  4412. if ($n [0] == $k) {
  4413. array_splice ( $verifyList, $m, 1, $v );
  4414. }
  4415. }
  4416. }
  4417. // print_r($verifyList);
  4418. $receiptList [$key] ['verifyList'] = $verifyList;
  4419. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4420. 'where' => 'sid=' . $value ['staff'],
  4421. 'asArray' => true
  4422. ) );
  4423. $receiptList [$key] ['button'] = $button;
  4424. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4425. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4426. $relust = $value ['sum'] - $value ['loanSum'];
  4427. $receiptList [$key] ['relust'] = $relust;
  4428. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4429. }
  4430. // print_r($receiptList);die;
  4431. // $data['verifyDetail']=$verifyDetail;
  4432. $mothHtml = "";
  4433. for($i = 1; $i <= 12; $i ++) {
  4434. if ($month == $i)
  4435. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4436. else
  4437. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4438. }
  4439. // 获取审批日志
  4440. Doo::loadModel ( 'receiptLog' );
  4441. $receiptLog = new receiptLog ();
  4442. $rlList = array ();
  4443. $rlInfo = $receiptLog->getOne ( array (
  4444. 'where' => 'rid=' . $rid . ' and status=4',
  4445. 'asArray' => true
  4446. ) );
  4447. $tijdate = $receiptLog->getOne ( array (
  4448. 'where' => 'rid=' . $rid . ' and status=2',
  4449. 'asc' => 'rlid',
  4450. 'asArray' => true
  4451. ) );
  4452. if (! empty ( $rlInfo )) {
  4453. $rlList = $receiptLog->find ( array (
  4454. 'where' => 'rid=' . $rid,
  4455. 'asc' => 'rlid',
  4456. 'asArray' => true
  4457. ) );
  4458. }
  4459. // echo $rid;
  4460. // print_r($receiptList);
  4461. $receiptList [0] ['rlList'] = $rlList;
  4462. // print_r($receiptList);
  4463. $enclosurList = $enclosur->find ( array (
  4464. 'where' => 'rid=' . $rid,
  4465. 'asArray' => true
  4466. ) );
  4467. $enclosurHtml = '';
  4468. foreach ( $enclosurList as $value ) {
  4469. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4470. }
  4471. $data ['enclosurHtml'] = $enclosurHtml;
  4472. $data ['rolename'] = $rolename ['name'];
  4473. $data ['mothHtml'] = $mothHtml;
  4474. // print_r($receiptList);
  4475. $data ['rid'] = $rid;
  4476. $data ['tijdate'] = $tijdate ['date'];
  4477. $data ['receiptList'] = $receiptList;
  4478. $data ['receiptApprovalCount'] = count ( $receiptList );
  4479. $data ['status'] = $status;
  4480. $data ['year'] = $year;
  4481. $data ['categoryList'] = $categoryList;
  4482. $data ['staffList'] = $staffList;
  4483. $data ['cid'] = $cid;
  4484. $data ['sid'] = $sid;
  4485. $data ['ap'] = $ap;
  4486. $data ['memu'] = "receipt";
  4487. $data ['staff'] = $this->staff;
  4488. $data ['receiptMemu'] = 'approvalExpenses';
  4489. $data ['verifyId'] = $this->verifyId;
  4490. $data ['executeId'] = $this->executeId;
  4491. $this->render ( "/admin/receiptburEdi", $data );
  4492. }
  4493. function hisImplement() {
  4494. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4495. if (empty ( $item ))
  4496. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "expenses";
  4497. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  4498. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4499. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  4500. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  4501. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  4502. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'pendImplement';
  4503. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  4504. Doo::loadClass ( 'XDeode' );
  4505. $XDeode = new XDeode ( 5 );
  4506. Doo::loadModel ( 'receipt' );
  4507. $receipt = new receipt ();
  4508. Doo::loadModel ( 'L_category' );
  4509. $Lcategory = new L_category ();
  4510. Doo::loadModel ( 'verify' );
  4511. Doo::loadModel ( 'statistics' );
  4512. $statistics = new statistics ();
  4513. $verify = new verify ();
  4514. Doo::loadModel ( 'staff' );
  4515. $staff = new staff ();
  4516. Doo::loadClass ( 'XDeode' );
  4517. $XDeode = new XDeode ( 5 );
  4518. $cid = $XDeode->decode ( $cidKey );
  4519. $condition = "";
  4520. if ($item == "expenses")
  4521. $condition = " and Rtype=1 ";
  4522. elseif ($item == "receipts")
  4523. $condition = " and Rtype=0 ";
  4524. elseif ($item == "remits")
  4525. $condition = " and Rtype=2 ";
  4526. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  4527. $sopString = $cidString = "";
  4528. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  4529. if (empty ( $rdate ))
  4530. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  4531. else
  4532. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  4533. if ($status == 'pendImplement') {
  4534. $condition .= ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  4535. } elseif ($status == 'alerpts') {
  4536. $statusCon = '(status=8 or status=9 )';
  4537. if (empty ( $rdate ))
  4538. $dateCondition .= " and Year(date) =" . $year;
  4539. else
  4540. $dateCondition .= " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  4541. }
  4542. if ($sop != 'SOP')
  4543. $sopString = " and staff=" . $sop;
  4544. if ($cidKey != 'ALL')
  4545. $cidString = " and cid=" . $cid;
  4546. $receiptList = $receipt->find ( array (
  4547. 'where' => $statusCon . $condition . $dateCondition . $sopString . $cidString,
  4548. 'desc' => 'rid',
  4549. 'asArray' => true
  4550. ) );
  4551. // 员工筛选
  4552. $receiptList2 = $receipt->find ( array (
  4553. 'where' => $statusCon . $condition . $dateCondition,
  4554. 'desc' => 'rid',
  4555. 'asArray' => true
  4556. ) );
  4557. $sopStaff = array ();
  4558. foreach ( $receiptList2 as $key => $value ) {
  4559. $staffDetail = $staff->getOne ( array (
  4560. 'select' => 'username',
  4561. 'where' => 'sid=' . $value ['staff'],
  4562. 'asArray' => true
  4563. ) );
  4564. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  4565. }
  4566. // 办事处筛选
  4567. $categoryScreen = array ();
  4568. $categorList = $Lcategory->getCategory ();
  4569. foreach ( $receiptList2 as $key => $value ) {
  4570. foreach ( $categorList as $k => $v ) {
  4571. if ($value ['cid'] == $v ['cid']) {
  4572. $categoryScreen [$v ['cidKey']] = $v ['title'];
  4573. break;
  4574. }
  4575. }
  4576. }
  4577. $categoryScreenHtml = "";
  4578. foreach ( $categoryScreen as $key => $value ) {
  4579. if ($cidKey == $key)
  4580. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4581. else
  4582. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4583. }
  4584. $data ['categoryScreenHtml'] = $categoryScreenHtml;
  4585. $data ['cidKey'] = $cidKey;
  4586. $Locate = 0;
  4587. $roleId = 0;
  4588. $button = 0;
  4589. $staffBatchNumber = 100001;
  4590. $remittanceList = array ();
  4591. foreach ( $receiptList as $key => $value ) {
  4592. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4593. $receiptList [$key] ['Texe'] = 'false';
  4594. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  4595. $receiptList [$key] ['Texe'] = 'true';
  4596. }
  4597. $receiptList [$key] ['TRexe'] = 'true';
  4598. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  4599. $receiptList [$key] ['TRexe'] = 'false';
  4600. }
  4601. $receiptList [$key] ['Locate'] = $Locate;
  4602. $Locate ++;
  4603. $receiptList [$key] ['reviseDetail'] = array ();
  4604. if (! empty ( $value ['reviseDetail'] ))
  4605. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4606. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4607. $categoryDetil = $Lcategory->getOne ( array (
  4608. 'where' => 'cid=' . $value ['cid'],
  4609. 'asArray' => true
  4610. ) );
  4611. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4612. // 检测编辑状态
  4613. $verifyList = $verify->getOne ( array (
  4614. 'where' => 'vid=' . $value ['verify'],
  4615. 'asArray' => true
  4616. ) );
  4617. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4618. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4619. Doo::loadModel ( 'role' );
  4620. $role = new role ();
  4621. $flag = true;
  4622. $roleKey = 0;
  4623. $endStaffArray = array ();
  4624. $roleArrayCopy = array ();
  4625. foreach ( $verifyList as $k => $v ) {
  4626. // init verifyStaff
  4627. if ($v [1] == 'ROLE') {
  4628. if (! empty ( $verifyStaff )) {
  4629. $endStaffArray = end ( $verifyStaff );
  4630. }
  4631. $roleVerify = json_decode ( $v [3], true );
  4632. $roleKey = $k;
  4633. $roleArray = array ();
  4634. $rolename = $role->getOne ( array (
  4635. 'where' => 'rid=' . $v [0],
  4636. 'asArray' => true
  4637. ) );
  4638. foreach ( $roleVerify as $o => $p ) {
  4639. $staffID = explode ( '_', $p );
  4640. $staffInfo = $staff->getOne ( array (
  4641. 'where' => 'sid=' . $staffID [0],
  4642. 'asArray' => true
  4643. ) );
  4644. $exp = array (
  4645. 0 => $staffInfo ['sid'],
  4646. 1 => $staffID [1],
  4647. 2 => $staffInfo ['avatar'],
  4648. 'date' => '',
  4649. 'date' => '',
  4650. 'opinion' => '',
  4651. 'status' => '',
  4652. 'rolename' => $rolename ['name']
  4653. );
  4654. array_push ( $roleArray, $exp );
  4655. }
  4656. $roleArrayCopy [$v [0]] = $roleArray;
  4657. }
  4658. $verifyList [$k] ['date'] = "";
  4659. $verifyList [$k] ['opinion'] = "";
  4660. $verifyList [$k] ['status'] = "";
  4661. if (empty ( $verifyStaff )) {
  4662. $verifyList [$k] ['date'] = "";
  4663. $verifyList [$k] ['opinion'] = "";
  4664. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4665. $verifyList [$k] ['status'] = 4;
  4666. $flag = false;
  4667. }
  4668. } else {
  4669. foreach ( $verifyStaff as $m => $u ) {
  4670. if ($v [0] == $m) {
  4671. $verifyList [$k] ['date'] = $u ['date'];
  4672. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4673. $verifyList [$k] ['status'] = $u ['status'];
  4674. $flag = false;
  4675. break;
  4676. }
  4677. }
  4678. $endStaffArray = end ( $verifyStaff );
  4679. }
  4680. }
  4681. $rolename ['name'] = '';
  4682. if (! empty ( $roleId )) {
  4683. Doo::loadModel ( 'role' );
  4684. $role = new role ();
  4685. $rolename = $role->getOne ( array (
  4686. 'where' => 'rid=' . $roleId,
  4687. 'asArray' => true
  4688. ) );
  4689. }
  4690. if (! empty ( $verifyStaff ))
  4691. $endStaffArray = end ( $verifyStaff );
  4692. $KOP = false;
  4693. foreach ( $roleArrayCopy as $P => $A ) {
  4694. foreach ( $A as $MKI => $AVL ) {
  4695. if (! empty ( $verifyStaff )) {
  4696. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4697. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4698. $button = 4;
  4699. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4700. }
  4701. foreach ( $verifyStaff as $m => $u ) {
  4702. $AVLFK = $AVL [0] . '_R';
  4703. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4704. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4705. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4706. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4707. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4708. break;
  4709. }
  4710. }
  4711. } else {
  4712. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4713. $button = 4;
  4714. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4715. }
  4716. }
  4717. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4718. $KOP = true;
  4719. }
  4720. }
  4721. foreach ( $roleArrayCopy as $k => $v ) {
  4722. foreach ( $verifyList as $m => $n ) {
  4723. if ($n [0] == $k) {
  4724. array_splice ( $verifyList, $m, 1, $v );
  4725. }
  4726. }
  4727. }
  4728. $receiptList [$key] ['verifyList'] = $verifyList;
  4729. $staffDetail = $staff->getOne ( array (
  4730. 'where' => 'sid=' . $value ['staff'],
  4731. 'asArray' => true
  4732. ) );
  4733. $receiptList [$key] ['staffDetail'] = $staffDetail;
  4734. $receiptList [$key] ['button'] = $button;
  4735. // 设置导出汇款execl
  4736. if (! empty ( $value ['remittanceName'] ) && ! empty ( $value ['bankName'] ) && ! empty ( $value ['bankNumber'] )) {
  4737. $remittanceDetail = array (
  4738. $staffBatchNumber,
  4739. $value ['remittanceName'],
  4740. $value ['bankNumber'],
  4741. $value ['bankName'],
  4742. $value ['remittanceBankType'],
  4743. $value ['coupletNumber'],
  4744. $value ['sum']
  4745. );
  4746. array_push ( $remittanceList, $remittanceDetail );
  4747. $staffBatchNumber ++;
  4748. }
  4749. }
  4750. $data ['remittanceList'] = json_encode ( $remittanceList );
  4751. // print_r($receiptList);
  4752. $mothHtml = "";
  4753. for($i = 1; $i <= 12; $i ++) {
  4754. if ($moth == $i)
  4755. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4756. else
  4757. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4758. }
  4759. $dayHtml = "";
  4760. if ($day != "DAY" || $moth != "MONTH") {
  4761. for($i = 1; $i <= 31; $i ++) {
  4762. if ($day == $i)
  4763. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  4764. else
  4765. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  4766. }
  4767. }
  4768. $sopHtml = "";
  4769. foreach ( $sopStaff as $key => $value ) {
  4770. if ($sop == $key)
  4771. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4772. else
  4773. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4774. }
  4775. $data ['status'] = $status;
  4776. $data ['rdate'] = $rdate;
  4777. $data ['sopHtml'] = $sopHtml;
  4778. $data ['dayHtml'] = $dayHtml;
  4779. $data ['mothHtml'] = $mothHtml;
  4780. $data ['receiptList'] = $receiptList;
  4781. $data ['memu'] = "receipt";
  4782. $data ['staff'] = $this->staff;
  4783. $data ['receiptMemu'] = 'implement';
  4784. $data ['verifyId'] = $this->verifyId;
  4785. $data ['executeId'] = $this->executeId;
  4786. $data ['item'] = $item;
  4787. $data ['year'] = $year;
  4788. $data ['moth'] = $moth;
  4789. $data ['day'] = $day;
  4790. $data ['sop'] = $sop;
  4791. $this->render ( "/admin/hisImplement", $data );
  4792. }
  4793. /**
  4794. * 导出汇款信息的exelc
  4795. */
  4796. function exportRemittance() {
  4797. $remittanceInfo = $_POST ['remittanceInfo']; // $this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  4798. if (empty ( $remittanceInfo ))
  4799. die ( 'illegal request' );
  4800. $title = array (
  4801. '员工编号',
  4802. '姓名',
  4803. '员工账号',
  4804. '员工账户开户行',
  4805. '转账类型',
  4806. '联行号',
  4807. '金额'
  4808. );
  4809. $data = json_decode ( $remittanceInfo, true );
  4810. if (empty ( $data ))
  4811. die ( 'illegal request' );
  4812. Doo::loadClass ( 'receipt.func' );
  4813. exportExcel ( $title, $data, '批量日常报销-公司账号', './', true );
  4814. header ( 'Content-Type:text/html;charset=utf-8' );
  4815. die ( '导出' . count ( $data ) . '条数据,<a href="/hisImplement">返回</a>' );
  4816. }
  4817. function ajaxExamine() {
  4818. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4819. Doo::loadModel ( 'receipt' );
  4820. $receipt = new receipt ();
  4821. if (! empty ( $rid )) {
  4822. $rLRes = $receipt->find ( array (
  4823. '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,
  4824. 'asArray' => true
  4825. ) );
  4826. echo json_encode ( array (
  4827. 'status' => 1,
  4828. 'receipt' => $rLRes [0]
  4829. ) );
  4830. die ();
  4831. }
  4832. echo json_encode ( array (
  4833. 'status' => 0,
  4834. 'receipt' => array ()
  4835. ) );
  4836. die ();
  4837. }
  4838. /*
  4839. * 废弃
  4840. */
  4841. function myReceipt() {
  4842. // all approval past withdraw
  4843. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4844. if (empty ( $item ))
  4845. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4846. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4847. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  4848. Doo::loadModel ( 'receipt' );
  4849. $receipt = new receipt ();
  4850. // pre-loaded
  4851. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4852. // have cache
  4853. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  4854. if (! empty ( $moth )) // yearPage
  4855. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  4856. $this->showCache ( $path );
  4857. }
  4858. Doo::loadModel ( 'L_category' );
  4859. $Lcategory = new L_category ();
  4860. Doo::loadModel ( 'verify' );
  4861. Doo::loadModel ( 'statistics' );
  4862. $statistics = new statistics ();
  4863. $verify = new verify ();
  4864. Doo::loadModel ( 'staff' );
  4865. $staff = new staff ();
  4866. $condition = " and status!=0 ";
  4867. if ($item == "approval")
  4868. $condition = " and status=2 ";
  4869. elseif ($item == "withdraw")
  4870. $condition = " and status=3 ";
  4871. elseif ($item == "past")
  4872. $condition = " and status=1 ";
  4873. elseif ($item == "whdw")
  4874. $condition = " and status=4 ";
  4875. $dateCondition = " and Year(date) =" . $year;
  4876. if (! empty ( $moth )) {
  4877. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  4878. $stList = $statistics->getOne ( array (
  4879. 'select' => 'rePrice ,agPrice',
  4880. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  4881. 'asArray' => true
  4882. ) );
  4883. } else
  4884. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  4885. if (empty ( $stList ))
  4886. $stList = array (
  4887. 'rePrice' => 0,
  4888. 'agPrice' => 0
  4889. );
  4890. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  4891. $data ['stList'] = array (
  4892. 'rePrice' => $stList ['rePrice'],
  4893. 'agPrice' => $stList ['agPrice'],
  4894. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  4895. );
  4896. $receiptList = $receipt->find ( array (
  4897. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  4898. 'desc' => 'rid',
  4899. 'asArray' => true
  4900. ) );
  4901. $Locate = 0;
  4902. $roleId = 0;
  4903. $button = 0;
  4904. foreach ( $receiptList as $key => $value ) {
  4905. $receiptList [$key] ['Locate'] = $Locate;
  4906. $Locate ++;
  4907. $receiptList [$key] ['reviseDetail'] = array ();
  4908. if (! empty ( $value ['reviseDetail'] ))
  4909. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4910. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4911. $categoryDetil = $Lcategory->getOne ( array (
  4912. 'where' => 'cid=' . $value ['cid'],
  4913. 'asArray' => true
  4914. ) );
  4915. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4916. // 检测编辑状态
  4917. $verifyList = $verify->getOne ( array (
  4918. 'where' => 'vid=' . $value ['verify'],
  4919. 'asArray' => true
  4920. ) );
  4921. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4922. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4923. Doo::loadModel ( 'role' );
  4924. $role = new role ();
  4925. $flag = true;
  4926. $roleKey = 0;
  4927. $endStaffArray = array ();
  4928. $roleArrayCopy = array ();
  4929. foreach ( $verifyList as $k => $v ) {
  4930. // init verifyStaff
  4931. if ($v [1] == 'ROLE') {
  4932. if (! empty ( $verifyStaff )) {
  4933. $endStaffArray = end ( $verifyStaff );
  4934. // if ($v[0]==$endStaffArray['nextStaff']){
  4935. // $roleId=$v[0];
  4936. // }
  4937. }
  4938. $roleVerify = json_decode ( $v [3], true );
  4939. $roleKey = $k;
  4940. $roleArray = array ();
  4941. $rolename = $role->getOne ( array (
  4942. 'where' => 'rid=' . $v [0],
  4943. 'asArray' => true
  4944. ) );
  4945. foreach ( $roleVerify as $o => $p ) {
  4946. $staffID = explode ( '_', $p );
  4947. $staffInfo = $staff->getOne ( array (
  4948. 'where' => 'sid=' . $staffID [0],
  4949. 'asArray' => true
  4950. ) );
  4951. // print_r($staffID);
  4952. $exp = array (
  4953. 0 => $staffInfo ['sid'],
  4954. 1 => $staffID [1],
  4955. 2 => $staffInfo ['avatar'],
  4956. 'date' => '',
  4957. 'date' => '',
  4958. 'opinion' => '',
  4959. 'status' => '',
  4960. 'rolename' => $rolename ['name']
  4961. );
  4962. array_push ( $roleArray, $exp );
  4963. }
  4964. $roleArrayCopy [$v [0]] = $roleArray;
  4965. // $verifyList[$k]['roleArray']=$roleArray;
  4966. }
  4967. $verifyList [$k] ['date'] = "";
  4968. $verifyList [$k] ['opinion'] = "";
  4969. $verifyList [$k] ['status'] = "";
  4970. if (empty ( $verifyStaff )) {
  4971. $verifyList [$k] ['date'] = "";
  4972. $verifyList [$k] ['opinion'] = "";
  4973. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4974. $verifyList [$k] ['status'] = 4;
  4975. $flag = false;
  4976. }
  4977. } else {
  4978. foreach ( $verifyStaff as $m => $u ) {
  4979. if ($v [0] == $m) {
  4980. $verifyList [$k] ['date'] = $u ['date'];
  4981. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4982. $verifyList [$k] ['status'] = $u ['status'];
  4983. $flag = false;
  4984. break;
  4985. }
  4986. }
  4987. $endStaffArray = end ( $verifyStaff );
  4988. if (isset ( $endStaffArray ['ROLE'] )) {
  4989. } else {
  4990. // $endKey=key($verifyStaff);
  4991. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4992. // $button=4;
  4993. // $verifyList[$k]['status']=4;
  4994. // }
  4995. }
  4996. }
  4997. }
  4998. $rolename ['name'] = '';
  4999. if (! empty ( $roleId )) {
  5000. Doo::loadModel ( 'role' );
  5001. $role = new role ();
  5002. $rolename = $role->getOne ( array (
  5003. 'where' => 'rid=' . $roleId,
  5004. 'asArray' => true
  5005. ) );
  5006. }
  5007. if (! empty ( $verifyStaff ))
  5008. $endStaffArray = end ( $verifyStaff );
  5009. $KOP = false;
  5010. foreach ( $roleArrayCopy as $P => $A ) {
  5011. foreach ( $A as $MKI => $AVL ) {
  5012. if (! empty ( $verifyStaff )) {
  5013. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5014. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5015. $button = 4;
  5016. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5017. }
  5018. foreach ( $verifyStaff as $m => $u ) {
  5019. $AVLFK = $AVL [0] . '_R';
  5020. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5021. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5022. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5023. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5024. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5025. break;
  5026. }
  5027. }
  5028. } else {
  5029. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5030. $button = 4;
  5031. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5032. }
  5033. }
  5034. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5035. $KOP = true;
  5036. }
  5037. }
  5038. foreach ( $roleArrayCopy as $k => $v ) {
  5039. foreach ( $verifyList as $m => $n ) {
  5040. if ($n [0] == $k) {
  5041. array_splice ( $verifyList, $m, 1, $v );
  5042. }
  5043. }
  5044. }
  5045. $receiptList [$key] ['verifyList'] = $verifyList;
  5046. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5047. 'where' => 'sid=' . $value ['staff'],
  5048. 'asArray' => true
  5049. ) );
  5050. $receiptList [$key] ['button'] = $button;
  5051. }
  5052. // print_r($receiptList);die;
  5053. $mothHtml = "";
  5054. for($i = 1; $i <= 12; $i ++) {
  5055. if ($moth == $i)
  5056. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5057. else
  5058. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5059. }
  5060. $data ['mothHtml'] = $mothHtml;
  5061. $data ['receiptList'] = $receiptList;
  5062. $data ['memu'] = "receipt";
  5063. $data ['staff'] = $this->staff;
  5064. $data ['receiptMemu'] = 'receipt';
  5065. $data ['verifyId'] = $this->verifyId;
  5066. $data ['executeId'] = $this->executeId;
  5067. $data ['item'] = $item;
  5068. $data ['year'] = $year;
  5069. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  5070. // sufficient condition to generate cache
  5071. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  5072. $receiptList = $receipt->find ( array (
  5073. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  5074. 'asArray' => true
  5075. ) );
  5076. if (empty ( $receiptList )) { // generated files
  5077. ob_start ();
  5078. $this->render ( "/admin/saea_myList", $data );
  5079. $this->cacheFile ( $path );
  5080. die ();
  5081. // $content = ob_get_contents();
  5082. // $fp = fopen($path, "w");
  5083. // fwrite($fp, $content);
  5084. // fclose($fp);
  5085. }
  5086. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  5087. $receiptList = $receipt->find ( array (
  5088. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  5089. 'asArray' => true
  5090. ) );
  5091. if (empty ( $receiptList )) { // generated files
  5092. ob_start ();
  5093. $this->render ( "/admin/saea_myList", $data );
  5094. $this->cacheFile ( $path );
  5095. die ();
  5096. }
  5097. }
  5098. }
  5099. $this->render ( "/admin/saea_myList", $data );
  5100. }
  5101. function saeaCreate() {
  5102. Doo::loadModel ( 'accountItem' );
  5103. Doo::loadModel ( 'verify' );
  5104. Doo::loadModel ( 'receipt' );
  5105. Doo::loadModel ( 'L_category' );
  5106. $lCategory = new L_category ();
  5107. $receipt = new receipt ();
  5108. $verify = new verify ();
  5109. $accountItem = new accountItem ();
  5110. Doo::loadModel ( "role" );
  5111. $role = new role ();
  5112. $acItem = $accountItem->find ( array (
  5113. 'asArray' => true
  5114. ) );
  5115. $veList = $verify->find ( array (
  5116. 'asArray' => true
  5117. ) );
  5118. foreach ( $veList as $key => $value ) {
  5119. $v = json_decode ( $value ['staff'] );
  5120. $list = array ();
  5121. foreach ( $v as $n => $m ) {
  5122. if ($m ['1'] == 'ROLE') {
  5123. $roleInfo = $role->getOne ( array (
  5124. 'where' => 'rid=' . $m [0],
  5125. 'asArray' => true
  5126. ) );
  5127. $v [$n] [1] = $roleInfo ['name'];
  5128. array_push ( $list, $roleInfo ['name'] );
  5129. } else {
  5130. array_push ( $list, $v [$n] [1] );
  5131. }
  5132. }
  5133. $veList [$key] ['staff'] = implode ( '>', $list );
  5134. }
  5135. $data ['category'] = $lCategory->find ( array (
  5136. 'asArray' => true
  5137. ) );
  5138. $data ['veList'] = $veList;
  5139. $data ['acItem'] = $acItem;
  5140. $data ['memu'] = "receipt";
  5141. $data ['staff'] = $this->staff;
  5142. $data ['receiptMemu'] = 'saeaBorad';
  5143. $data ['verifyId'] = $this->verifyId;
  5144. $data ['executeId'] = $this->executeId;
  5145. $this->render ( "/admin/saea_create", $data );
  5146. }
  5147. function addReceipt() {
  5148. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  5149. $agency = $this->get_args ( 'agency' );
  5150. $travel = $this->get_args ( 'travel' );
  5151. $train = $this->get_args ( 'train' );
  5152. $other = $this->get_args ( 'other' );
  5153. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5154. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5155. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5156. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  5157. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  5158. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  5159. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  5160. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  5161. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  5162. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  5163. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  5164. header ( 'Content-Type:text/html;charset=utf-8' );
  5165. die ( '请填写联行号' );
  5166. }
  5167. Doo::loadModel ( 'receipt' );
  5168. Doo::loadModel ( 'receiptDetail' );
  5169. Doo::loadModel ( 'accountItem' );
  5170. $accountItem = new accountItem ();
  5171. $receipt = new receipt ();
  5172. Doo::loadModel ( 'enclosur' );
  5173. Doo::loadModel ( 'execute' );
  5174. $execute = new execute ();
  5175. $executeDetail = $execute->getOne ( array (
  5176. 'where' => 'mold="报销单执行人"',
  5177. 'asArray' => true
  5178. ) );
  5179. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  5180. // if(!empty($receiptDetail))
  5181. // return "/referReceipt/".$receiptDetail['rid'];
  5182. $aItem = $accountItem->find ( array (
  5183. 'asArray' => true
  5184. ) );
  5185. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5186. $ag = $tr = $ta = $ot = 0;
  5187. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5188. foreach ( $aItem as $key => $value ) {
  5189. if ($value ['category'] == $this->AGENCY) {
  5190. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5191. array_push ( $accountJson [$this->AGENCY], array (
  5192. 'aid' => $value ['aid'],
  5193. 'name' => $value ['name'],
  5194. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5195. ) );
  5196. $sum += $agency [$ag];
  5197. $agencySum += $agency [$ag];
  5198. }
  5199. $ag ++;
  5200. }
  5201. if ($value ['category'] == $this->TRAVEL) {
  5202. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5203. array_push ( $accountJson [$this->TRAVEL], array (
  5204. 'aid' => $value ['aid'],
  5205. 'name' => $value ['name'],
  5206. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5207. ) );
  5208. $sum += $travel [$tr];
  5209. $travelSum += $travel [$tr];
  5210. }
  5211. $tr ++;
  5212. }
  5213. if ($value ['category'] == $this->TRAIN) {
  5214. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5215. array_push ( $accountJson [$this->TRAIN], array (
  5216. 'aid' => $value ['aid'],
  5217. 'name' => $value ['name'],
  5218. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5219. ) );
  5220. $sum += $train [$ta];
  5221. $trainSum += $train [$ta];
  5222. }
  5223. $ta ++;
  5224. }
  5225. if ($value ['category'] == $this->OTHER) {
  5226. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5227. array_push ( $accountJson [$this->OTHER], array (
  5228. 'aid' => $value ['aid'],
  5229. 'name' => $value ['name'],
  5230. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5231. ) );
  5232. $sum += $other [$ot];
  5233. $otherSum += $other [$ot];
  5234. }
  5235. $ot ++;
  5236. }
  5237. }
  5238. $accountJson ['cSum'] = array (
  5239. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5240. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5241. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5242. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5243. );
  5244. // 报销单
  5245. $receipt->accountItem = json_encode ( $accountJson );
  5246. $receipt->staff = $this->staff [0] ['sid'];
  5247. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5248. $receipt->date = date ( "Y-m-d" );
  5249. $receipt->cid = $cid;
  5250. $receipt->status = 5;
  5251. // 修改审批流程加入角色
  5252. $receipt->verify = $verify;
  5253. $receipt->executeCopy = $executeDetail ['staff'];
  5254. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  5255. $receipt->explanation = $explanation;
  5256. $receipt->remittanceName = $remittanceName;
  5257. $receipt->bankName = $bankName;
  5258. $receipt->bankNumber = $bankNumber;
  5259. $receipt->remittanceBankType = $remittanceBankType;
  5260. if ($remittanceBankType == 1)
  5261. $receipt->coupletNumber = $coupletNumber;
  5262. $rid = $receipt->insert ();
  5263. // 附件
  5264. if (! empty ( $enclosurName )) {
  5265. $enclosurArray = explode ( '-', $enclosurName );
  5266. foreach ( $enclosurArray as $value ) {
  5267. $enclosur = new enclosur ();
  5268. $enclosur->name = $value;
  5269. $enclosur->rid = $rid;
  5270. $enclosur->insert ();
  5271. }
  5272. // print_r($enclosurArray);die;
  5273. }
  5274. // 报销详情
  5275. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5276. $receiptDetail = new receiptDetail ();
  5277. $receiptDetail->staff = $this->staff [0] ['sid'];
  5278. $receiptDetail->item = $value ['name'];
  5279. $receiptDetail->itemCategory = $this->AGENCY;
  5280. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5281. $receiptDetail->date = date ( "Y-m-d" );
  5282. $receiptDetail->cid = $cid;
  5283. $receiptDetail->rid = $rid;
  5284. $receiptDetail->status = 4;
  5285. $receiptDetail->insert ();
  5286. }
  5287. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5288. $receiptDetail = new receiptDetail ();
  5289. $receiptDetail->staff = $this->staff [0] ['sid'];
  5290. $receiptDetail->item = $value ['name'];
  5291. $receiptDetail->itemCategory = $this->TRAVEL;
  5292. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5293. $receiptDetail->date = date ( "Y-m-d" );
  5294. $receiptDetail->cid = $cid;
  5295. $receiptDetail->rid = $rid;
  5296. $receiptDetail->status = 4;
  5297. $receiptDetail->insert ();
  5298. }
  5299. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5300. $receiptDetail = new receiptDetail ();
  5301. $receiptDetail->staff = $this->staff [0] ['sid'];
  5302. $receiptDetail->item = $value ['name'];
  5303. $receiptDetail->itemCategory = $this->TRAIN;
  5304. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5305. $receiptDetail->date = date ( "Y-m-d" );
  5306. $receiptDetail->cid = $cid;
  5307. $receiptDetail->rid = $rid;
  5308. $receiptDetail->status = 4;
  5309. $receiptDetail->insert ();
  5310. }
  5311. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5312. $receiptDetail = new receiptDetail ();
  5313. $receiptDetail->staff = $this->staff [0] ['sid'];
  5314. $receiptDetail->item = $value ['name'];
  5315. $receiptDetail->itemCategory = $this->OTHER;
  5316. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5317. $receiptDetail->date = date ( "Y-m-d" );
  5318. $receiptDetail->cid = $cid;
  5319. $receiptDetail->rid = $rid;
  5320. $receiptDetail->status = 4;
  5321. $receiptDetail->insert ();
  5322. }
  5323. return "/saeaBorad";
  5324. } else
  5325. die ( 'illegal request' );
  5326. }
  5327. function referReceipt() {
  5328. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  5329. Doo::loadModel ( 'receipt' );
  5330. Doo::loadModel ( 'verify' );
  5331. $verify = new verify ();
  5332. $receipt = new receipt ();
  5333. Doo::loadModel ( 'L_category' );
  5334. $lCategory = new L_category ();
  5335. Doo::loadModel ( "role" );
  5336. $role = new role ();
  5337. $receiptDetail = $receipt->find ( array (
  5338. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  5339. 'asArray' => true
  5340. ) );
  5341. if (empty ( $receiptDetail ))
  5342. return "/addReceipt";
  5343. foreach ( $receiptDetail as $key => $value ) {
  5344. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5345. $veList = $verify->getOne ( array (
  5346. 'where' => 'vid=' . $value ['verify'],
  5347. 'asArray' => true
  5348. ) );
  5349. $v = json_decode ( $veList ['staff'] );
  5350. array_push ( $v [0], $veList ['description'] );
  5351. foreach ( $v as $n => $m ) {
  5352. if ($m ['1'] == 'ROLE') {
  5353. $roleInfo = $role->getOne ( array (
  5354. 'where' => 'rid=' . $m [0],
  5355. 'asArray' => true
  5356. ) );
  5357. $v [$n] [1] = $roleInfo ['name'];
  5358. }
  5359. }
  5360. $receiptDetail [$key] ['staff'] = $v;
  5361. $category = $lCategory->getOne ( array (
  5362. 'where' => 'cid=' . $value ['cid'],
  5363. 'asArray' => true
  5364. ) );
  5365. $receiptDetail [$key] ['category'] = $category ['title'];
  5366. }
  5367. // print_r($receiptDetail);
  5368. $data ['receiptDetail'] = $receiptDetail;
  5369. $data ['memu'] = "receipt";
  5370. $data ['staff'] = $this->staff;
  5371. $data ['receiptMemu'] = 'saeaCreate';
  5372. $data ['verifyId'] = $this->verifyId;
  5373. $data ['executeId'] = $this->executeId;
  5374. $this->render ( "/admin/saea_confirm", $data );
  5375. }
  5376. function editReceipt() {
  5377. // edit status 4
  5378. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  5379. Doo::loadClass ( 'XDeode' );
  5380. $XDeode = new XDeode ( 7 );
  5381. $rid = $XDeode->decode ( $ridKey );
  5382. if (empty ( $rid ))
  5383. die ( 'illegal request' );
  5384. // echo $rid.'sd';
  5385. Doo::loadModel ( 'accountItem' );
  5386. Doo::loadModel ( 'verify' );
  5387. Doo::loadModel ( 'receipt' );
  5388. $receipt = new receipt ();
  5389. $verify = new verify ();
  5390. $accountItem = new accountItem ();
  5391. Doo::loadModel ( 'L_category' );
  5392. $lCategory = new L_category ();
  5393. Doo::loadModel ( "role" );
  5394. $role = new role ();
  5395. Doo::loadModel ( 'enclosur' );
  5396. $enclosur = new enclosur ();
  5397. $receiptDetail = $receipt->getOne ( array (
  5398. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  5399. 'asArray' => true
  5400. ) );
  5401. if (empty ( $receiptDetail ))
  5402. die ( 'illegal request' );
  5403. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  5404. $acItem = $accountItem->find ( array (
  5405. 'asArray' => true
  5406. ) );
  5407. $veList = $verify->find ( array (
  5408. 'asArray' => true
  5409. ) );
  5410. foreach ( $veList as $key => $value ) {
  5411. $v = json_decode ( $value ['staff'] );
  5412. $list = array ();
  5413. foreach ( $v as $n => $m ) {
  5414. if ($m ['1'] == 'ROLE') {
  5415. $roleInfo = $role->getOne ( array (
  5416. 'where' => 'rid=' . $m [0],
  5417. 'asArray' => true
  5418. ) );
  5419. $v [$n] [1] = $roleInfo ['name'];
  5420. array_push ( $list, $roleInfo ['name'] );
  5421. } else {
  5422. array_push ( $list, $v [$n] [1] );
  5423. }
  5424. }
  5425. $veList [$key] ['staff'] = implode ( '>', $list );
  5426. }
  5427. // 配置编辑信息
  5428. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  5429. foreach ( $acItem as $key => $value ) {
  5430. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  5431. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  5432. $acItem [$key] ['price'] = $v ['price'];
  5433. }
  5434. }
  5435. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  5436. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  5437. $acItem [$key] ['price'] = $v ['price'];
  5438. }
  5439. }
  5440. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  5441. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  5442. $acItem [$key] ['price'] = $v ['price'];
  5443. }
  5444. }
  5445. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  5446. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  5447. $acItem [$key] ['price'] = $v ['price'];
  5448. }
  5449. }
  5450. }
  5451. $data ['category'] = $lCategory->find ( array (
  5452. 'asArray' => true
  5453. ) );
  5454. $data ['cSum'] = $accountItemList ['cSum'];
  5455. $data ['sum'] = $receiptDetail ['sum'];
  5456. $data ['enclosurList'] = $enclosurList;
  5457. $data ['receiptDetail'] = $receiptDetail;
  5458. $data ['veList'] = $veList;
  5459. $data ['acItem'] = $acItem;
  5460. $data ['memu'] = "receipt";
  5461. $data ['staff'] = $this->staff;
  5462. $data ['receiptMemu'] = 'saeaBorad';
  5463. $data ['verify'] = $receiptDetail ['verify'];
  5464. $data ['verifyId'] = $this->verifyId;
  5465. $data ['executeId'] = $this->executeId;
  5466. $data ['rid'] = $ridKey;
  5467. $this->render ( "/admin/saea_edit", $data );
  5468. }
  5469. function updateReceipt() {
  5470. $agency = $this->get_args ( 'agency' );
  5471. $travel = $this->get_args ( 'travel' );
  5472. $train = $this->get_args ( 'train' );
  5473. $other = $this->get_args ( 'other' );
  5474. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5475. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5476. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5477. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  5478. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  5479. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  5480. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  5481. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  5482. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  5483. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  5484. Doo::loadClass ( 'XDeode' );
  5485. $XDeode = new XDeode ( 7 );
  5486. $rid = $XDeode->decode ( $ridKey );
  5487. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  5488. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  5489. header ( 'Content-Type:text/html;charset=utf-8' );
  5490. die ( '请填写联行号' );
  5491. }
  5492. Doo::loadModel ( 'receipt' );
  5493. Doo::loadModel ( 'receiptDetail' );
  5494. Doo::loadModel ( 'accountItem' );
  5495. $accountItem = new accountItem ();
  5496. $receipt = new receipt ();
  5497. Doo::loadModel ( 'enclosur' );
  5498. Doo::loadModel ( 'execute' );
  5499. $execute = new execute ();
  5500. $receiptDetail = $receipt->getOne ( array (
  5501. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  5502. 'asArray' => true
  5503. ) );
  5504. if (empty ( $receiptDetail ))
  5505. return "/saeaBorad";
  5506. if ($receiptDetail ['Rtype'] == 1)
  5507. $executeDetail = $execute->getOne ( array (
  5508. 'where' => 'mold="借款费用执行人"',
  5509. 'asArray' => true
  5510. ) );
  5511. else
  5512. $executeDetail = $execute->getOne ( array (
  5513. 'where' => 'mold="报销单执行人"',
  5514. 'asArray' => true
  5515. ) );
  5516. $aItem = $accountItem->find ( array (
  5517. 'asArray' => true
  5518. ) );
  5519. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5520. $ag = $tr = $ta = $ot = 0;
  5521. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5522. foreach ( $aItem as $key => $value ) {
  5523. if ($value ['category'] == $this->AGENCY) {
  5524. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5525. array_push ( $accountJson [$this->AGENCY], array (
  5526. 'aid' => $value ['aid'],
  5527. 'name' => $value ['name'],
  5528. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5529. ) );
  5530. $sum += $agency [$ag];
  5531. $agencySum += $agency [$ag];
  5532. }
  5533. $ag ++;
  5534. }
  5535. if ($value ['category'] == $this->TRAVEL) {
  5536. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5537. array_push ( $accountJson [$this->TRAVEL], array (
  5538. 'aid' => $value ['aid'],
  5539. 'name' => $value ['name'],
  5540. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5541. ) );
  5542. $sum += $travel [$tr];
  5543. $travelSum += $travel [$tr];
  5544. }
  5545. $tr ++;
  5546. }
  5547. if ($value ['category'] == $this->TRAIN) {
  5548. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5549. array_push ( $accountJson [$this->TRAIN], array (
  5550. 'aid' => $value ['aid'],
  5551. 'name' => $value ['name'],
  5552. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5553. ) );
  5554. $sum += $train [$ta];
  5555. $trainSum += $train [$ta];
  5556. }
  5557. $ta ++;
  5558. }
  5559. if ($value ['category'] == $this->OTHER) {
  5560. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5561. array_push ( $accountJson [$this->OTHER], array (
  5562. 'aid' => $value ['aid'],
  5563. 'name' => $value ['name'],
  5564. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5565. ) );
  5566. $sum += $other [$ot];
  5567. $otherSum += $other [$ot];
  5568. }
  5569. $ot ++;
  5570. }
  5571. }
  5572. $accountJson ['cSum'] = array (
  5573. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5574. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5575. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5576. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5577. );
  5578. // 报销单
  5579. $rid = $receipt->rid = $receiptDetail ['rid'];
  5580. $receipt->accountItem = json_encode ( $accountJson );
  5581. $receipt->staff = $this->staff [0] ['sid'];
  5582. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5583. $receipt->date = date ( "Y-m-d" );
  5584. $receipt->cid = $cid;
  5585. if (($receiptDetail ['status'] != 4)) {
  5586. if ($receiptDetail ['Rtype'] == 1)
  5587. $receipt->status = 7;
  5588. else
  5589. $receipt->status = 5;
  5590. }
  5591. if ($receiptDetail != 4 && ! empty ( $verify ))
  5592. $receipt->verify = $verify;
  5593. $receipt->executeCopy = $executeDetail ['staff'];
  5594. $receipt->explanation = $explanation;
  5595. $receipt->remittanceName = $remittanceName;
  5596. $receipt->bankName = $bankName;
  5597. $receipt->bankNumber = $bankNumber;
  5598. $receipt->remittanceBankType = $remittanceBankType;
  5599. if ($remittanceBankType == 1)
  5600. $receipt->coupletNumber = $coupletNumber;
  5601. $receipt->update ();
  5602. $receiptDetail = new receiptDetail ();
  5603. $receiptDetail->delete ( array (
  5604. 'where' => 'rid=' . $rid
  5605. ) );
  5606. // 报销详情
  5607. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5608. $receiptDetail = new receiptDetail ();
  5609. $receiptDetail->staff = $this->staff [0] ['sid'];
  5610. $receiptDetail->item = $value ['name'];
  5611. $receiptDetail->itemCategory = $this->AGENCY;
  5612. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5613. $receiptDetail->date = date ( "Y-m-d" );
  5614. $receiptDetail->cid = $cid;
  5615. $receiptDetail->rid = $rid;
  5616. $receiptDetail->status = 4;
  5617. $receiptDetail->insert ();
  5618. }
  5619. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5620. $receiptDetail = new receiptDetail ();
  5621. $receiptDetail->staff = $this->staff [0] ['sid'];
  5622. $receiptDetail->item = $value ['name'];
  5623. $receiptDetail->itemCategory = $this->TRAVEL;
  5624. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5625. $receiptDetail->date = date ( "Y-m-d" );
  5626. $receiptDetail->cid = $cid;
  5627. $receiptDetail->rid = $rid;
  5628. $receiptDetail->status = 4;
  5629. $receiptDetail->insert ();
  5630. }
  5631. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5632. $receiptDetail = new receiptDetail ();
  5633. $receiptDetail->staff = $this->staff [0] ['sid'];
  5634. $receiptDetail->item = $value ['name'];
  5635. $receiptDetail->itemCategory = $this->TRAIN;
  5636. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5637. $receiptDetail->date = date ( "Y-m-d" );
  5638. $receiptDetail->cid = $cid;
  5639. $receiptDetail->rid = $rid;
  5640. $receiptDetail->status = 4;
  5641. $receiptDetail->insert ();
  5642. }
  5643. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5644. $receiptDetail = new receiptDetail ();
  5645. $receiptDetail->staff = $this->staff [0] ['sid'];
  5646. $receiptDetail->item = $value ['name'];
  5647. $receiptDetail->itemCategory = $this->OTHER;
  5648. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5649. $receiptDetail->date = date ( "Y-m-d" );
  5650. $receiptDetail->cid = $cid;
  5651. $receiptDetail->rid = $rid;
  5652. $receiptDetail->status = 4;
  5653. $receiptDetail->insert ();
  5654. }
  5655. // 附件
  5656. if (! empty ( $enclosurName )) {
  5657. $enclosurArray = explode ( '-', $enclosurName );
  5658. foreach ( $enclosurArray as $value ) {
  5659. $enclosur = new enclosur ();
  5660. $enclosur->name = $value;
  5661. $enclosur->rid = $rid;
  5662. $enclosur->insert ();
  5663. }
  5664. }
  5665. // return "/referReceipt/".$rid;
  5666. }
  5667. return "/saeaBorad";
  5668. }
  5669. function approvedReceipt() {
  5670. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5671. Doo::loadModel ( 'receipt' );
  5672. Doo::loadModel ( 'receiptDetail' );
  5673. $receipt = new receipt ();
  5674. $receiptDetail = new receiptDetail ();
  5675. Doo::loadModel ( 'statistics' );
  5676. Doo::loadModel ( 'itemStatistics' );
  5677. $statistics = new statistics ();
  5678. $itemStatistics = new itemStatistics ();
  5679. Doo::loadModel ( "verify" );
  5680. $verify = new verify ();
  5681. // 审批状态的判定
  5682. $receiptDetailList = $receipt->getOne ( array (
  5683. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  5684. 'asArray' => true
  5685. ) );
  5686. if (empty ( $receiptDetailList ))
  5687. return "/saeaBorad";
  5688. $verifyDetail = $verify->getOne ( array (
  5689. 'where' => ' vid =' . $receiptDetailList ['verify'],
  5690. 'asArray' => true
  5691. ) );
  5692. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5693. if (empty ( $receiptDetailList ['nowStaff'] )) {
  5694. $nowStaff = "";
  5695. $nowStaffList = array ();
  5696. if ($verifyDetail [0] [1] == 'ROLE') {
  5697. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5698. foreach ( $vStaffString as $key => $value ) {
  5699. $staffK = explode ( "_", $value );
  5700. array_push ( $nowStaffList, $staffK [0] );
  5701. }
  5702. $nowStaff = implode ( ',', $nowStaffList );
  5703. } else {
  5704. $nowStaff = $verifyDetail [0] [0];
  5705. }
  5706. $receipt->nowStaff = $nowStaff;
  5707. }
  5708. // echo $nowStaff;
  5709. // print_r($verifyDetail);die;
  5710. $receipt->rid = $receiptDetailList ['rid'];
  5711. $receipt->date = date ( "Y-m-d" );
  5712. $receipt->status = 2;
  5713. $receipt->update ();
  5714. $receiptDetail->status = 2;
  5715. $receiptDetail->update ( array (
  5716. 'where' => 'rid=' . $receiptDetailList ['rid']
  5717. ) );
  5718. Doo::loadModel ( "receiptLog" );
  5719. $receiptLog = new receiptLog ();
  5720. Doo::loadModel ( "verify" );
  5721. $verify = new verify ();
  5722. $receiptInfo = $receipt->getOne ( array (
  5723. 'where' => 'rid=' . $rid,
  5724. 'asArray' => true
  5725. ) );
  5726. $vr = $verify->getOne ( array (
  5727. 'where' => 'vid=' . $receiptInfo ['verify'],
  5728. 'asArray' => true
  5729. ) );
  5730. $jd = json_decode ( $vr ['staff'] );
  5731. $roleId = 0;
  5732. foreach ( $jd as $key => $value ) {
  5733. if ($value [1] == 'ROLE') {
  5734. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  5735. if ($pos !== false) {
  5736. $roleId = $value [0];
  5737. }
  5738. }
  5739. }
  5740. // 审批日志
  5741. // echo $roleId;die;
  5742. if (! empty ( $roleId )) {
  5743. Doo::loadModel ( "role" );
  5744. $role = new role ();
  5745. $roleInfo = $role->getOne ( array (
  5746. 'where' => 'rid=' . $roleId,
  5747. 'asArray' => true
  5748. ) );
  5749. $receiptLog->rolename = $roleInfo ['name'];
  5750. }
  5751. $receiptLog->username = $this->staff [0] ['username'];
  5752. $receiptLog->uid = $this->staff [0] ['sid'];
  5753. $receiptLog->date = date ( "Y-m-d" );
  5754. $receiptLog->opinion = '提交审批';
  5755. $receiptLog->img = $this->staff [0] ['avatar'];
  5756. $receiptLog->status = 2;
  5757. $receiptLog->rid = $rid;
  5758. $receiptLog->insert ();
  5759. // statistics item
  5760. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  5761. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  5762. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  5763. $stat = $statistics->getOne ( array (
  5764. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5765. 'asArray' => true
  5766. ) );
  5767. if (empty ( $stat )) {
  5768. $statistics->date = date ( "Y-m-d" );
  5769. $statistics->cid = $this->staff [0] ['cid'];
  5770. $statistics->staff = $this->staff [0] ['sid'];
  5771. $statistics->agPrice = 0;
  5772. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5773. $statistics->insert ();
  5774. } else {
  5775. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5776. $statistics->update ( array (
  5777. 'where' => 'sid=' . $stat ['sid']
  5778. ) );
  5779. }
  5780. return "/expenses";
  5781. }
  5782. function approval() {
  5783. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5784. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5785. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5786. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5787. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5788. if (empty ( $status ))
  5789. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5790. $vidList = array ();
  5791. $button = 0;
  5792. Doo::loadModel ( 'verify' );
  5793. $verify = new verify ();
  5794. Doo::loadModel ( 'receipt' );
  5795. $receipt = new receipt ();
  5796. Doo::loadModel ( 'staff' );
  5797. $staff = new staff ();
  5798. Doo::loadModel ( 'L_category' );
  5799. $Lcategory = new L_category ();
  5800. // user verify ID
  5801. $verifyDetail = $verify->find ( array (
  5802. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5803. 'asArray' => true
  5804. ) );
  5805. foreach ( $verifyDetail as $key => $value ) {
  5806. array_push ( $vidList, $value ['vid'] );
  5807. }
  5808. $vid = implode ( ",", $vidList );
  5809. if (empty ( $verifyDetail ))
  5810. $vid = 0;
  5811. /*
  5812. */
  5813. $dateCondition = " and Year(date) =" . $year;
  5814. if (! empty ( $month ))
  5815. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  5816. $categoryList = $Lcategory->find ( array (
  5817. 'asArray' => true
  5818. ) );
  5819. $staffList = $staff->find ( array (
  5820. 'where' => 'cid=' . $cid,
  5821. 'asArray' => true
  5822. ) );
  5823. $cateCondition = "";
  5824. $staffCondition = "";
  5825. $approvalCondition = "";
  5826. if (! empty ( $cid ))
  5827. $cateCondition = ' and cid=' . $cid;
  5828. if (! empty ( $sid )) {
  5829. $staffCondition = ' and staff=' . $sid;
  5830. $cateCondition = "";
  5831. }
  5832. // elseif($status==1){
  5833. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  5834. // }
  5835. if ($status == 2) {
  5836. // 查找角色审批人
  5837. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  5838. }
  5839. $ap = "";
  5840. if ($status == 4) {
  5841. $ap = 4;
  5842. $status = 2;
  5843. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  5844. }
  5845. if ($status == 5) {
  5846. $status = 4;
  5847. $ap = 5;
  5848. }
  5849. // echo $vid;
  5850. // get Receipt By verifyID status 2 .$approvalCondition
  5851. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  5852. $receiptList = $receipt->find ( array (
  5853. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  5854. 'desc' => 'rid',
  5855. 'asArray' => true
  5856. ) );
  5857. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  5858. $Locate = 0;
  5859. if ($ap == 4)
  5860. $status = 4;
  5861. elseif ($ap == 5)
  5862. $status = 5;
  5863. foreach ( $receiptList as $key => $value ) {
  5864. $receiptList [$key] ['Locate'] = $Locate;
  5865. $Locate ++;
  5866. $receiptList [$key] ['reviseDetail'] = array ();
  5867. if (! empty ( $value ['reviseDetail'] ))
  5868. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5869. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5870. $categoryDetil = $Lcategory->getOne ( array (
  5871. 'where' => 'cid=' . $value ['cid'],
  5872. 'asArray' => true
  5873. ) );
  5874. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5875. $verifyList = $verify->getOne ( array (
  5876. 'where' => 'vid=' . $value ['verify'],
  5877. 'asArray' => true
  5878. ) );
  5879. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5880. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5881. foreach ( $verifyList as $k => $v ) {
  5882. // init verifyStaff
  5883. $verifyList [$k] ['date'] = "";
  5884. $verifyList [$k] ['opinion'] = "";
  5885. $verifyList [$k] ['status'] = "";
  5886. if (empty ( $verifyStaff )) {
  5887. $verifyList [$k] ['date'] = "";
  5888. $verifyList [$k] ['opinion'] = "";
  5889. if ($v [0] == $this->staff [0] ['sid']) {
  5890. $verifyList [$k] ['status'] = 4;
  5891. $button = 4;
  5892. }
  5893. } else {
  5894. $flag = true;
  5895. foreach ( $verifyStaff as $m => $u ) {
  5896. if ($v [0] == $m) {
  5897. $verifyList [$k] ['date'] = $u ['date'];
  5898. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5899. $verifyList [$k] ['status'] = $u ['status'];
  5900. $flag = false;
  5901. break;
  5902. }
  5903. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  5904. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  5905. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  5906. }
  5907. if ($flag) { // 检测可编辑
  5908. if ($v [0] == $this->staff [0] ['sid']) {
  5909. $verifyList [$k] ['status'] = 4;
  5910. $button = 4;
  5911. }
  5912. }
  5913. }
  5914. }
  5915. $receiptList [$key] ['verifyList'] = $verifyList;
  5916. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5917. 'where' => 'sid=' . $value ['staff'],
  5918. 'asArray' => true
  5919. ) );
  5920. $receiptList [$key] ['button'] = $button;
  5921. }
  5922. // print_r($receiptList);die;
  5923. // $data['verifyDetail']=$verifyDetail;
  5924. $mothHtml = "";
  5925. for($i = 1; $i <= 12; $i ++) {
  5926. if ($month == $i)
  5927. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5928. else
  5929. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5930. }
  5931. $data ['mothHtml'] = $mothHtml;
  5932. $data ['receiptList'] = $receiptList;
  5933. $data ['receiptApprovalCount'] = count ( $receiptList );
  5934. $data ['status'] = $status;
  5935. $data ['year'] = $year;
  5936. $data ['categoryList'] = $categoryList;
  5937. $data ['staffList'] = $staffList;
  5938. $data ['cid'] = $cid;
  5939. $data ['sid'] = $sid;
  5940. $data ['ap'] = $ap;
  5941. $data ['memu'] = "receipt";
  5942. $data ['staff'] = $this->staff;
  5943. $data ['receiptMemu'] = 'approval';
  5944. $data ['verifyId'] = $this->verifyId;
  5945. $data ['executeId'] = $this->executeId;
  5946. $this->render ( "/admin/saea_reportList", $data );
  5947. }
  5948. function approvalDetails() {
  5949. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5950. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5951. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5952. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5953. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5954. Doo::loadModel ( 'verify' );
  5955. $verify = new verify ();
  5956. Doo::loadModel ( 'receipt' );
  5957. $receipt = new receipt ();
  5958. Doo::loadModel ( 'staff' );
  5959. $staff = new staff ();
  5960. Doo::loadModel ( 'L_category' );
  5961. $Lcategory = new L_category ();
  5962. Doo::loadModel ( 'enclosur' );
  5963. $enclosur = new enclosur ();
  5964. $vidList = array ();
  5965. $verifyDetail = $verify->find ( array (
  5966. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5967. 'asArray' => true
  5968. ) );
  5969. foreach ( $verifyDetail as $key => $value ) {
  5970. array_push ( $vidList, $value ['vid'] );
  5971. }
  5972. $vid = implode ( ",", $vidList );
  5973. if (empty ( $verifyDetail ))
  5974. $vid = 0;
  5975. $categoryList = $Lcategory->find ( array (
  5976. 'asArray' => true
  5977. ) );
  5978. $staffList = $staff->find ( array (
  5979. 'where' => 'cid=' . $cid,
  5980. 'asArray' => true
  5981. ) );
  5982. $ap = 0;
  5983. $receiptList = $receipt->find ( array (
  5984. 'where' => 'rid =' . $rid,
  5985. 'desc' => 'rid',
  5986. 'asArray' => true
  5987. ) );
  5988. $Locate = 0;
  5989. $roleId = 0;
  5990. $button = 0;
  5991. foreach ( $receiptList as $key => $value ) {
  5992. $receiptList [$key] ['Locate'] = $Locate;
  5993. $Locate ++;
  5994. $receiptList [$key] ['reviseDetail'] = array ();
  5995. if (! empty ( $value ['reviseDetail'] ))
  5996. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5997. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5998. $categoryDetil = $Lcategory->getOne ( array (
  5999. 'where' => 'cid=' . $value ['cid'],
  6000. 'asArray' => true
  6001. ) );
  6002. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6003. // 检测编辑状态
  6004. $verifyList = $verify->getOne ( array (
  6005. 'where' => 'vid=' . $value ['verify'],
  6006. 'asArray' => true
  6007. ) );
  6008. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6009. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6010. Doo::loadModel ( 'role' );
  6011. $role = new role ();
  6012. // print_r($verifyList);
  6013. $flag = true;
  6014. $roleKey = 0;
  6015. $endStaffArray = array ();
  6016. $roleArrayCopy = array ();
  6017. foreach ( $verifyList as $k => $v ) {
  6018. // init verifyStaff
  6019. if ($v [1] == 'ROLE') {
  6020. if (! empty ( $verifyStaff )) {
  6021. $endStaffArray = end ( $verifyStaff );
  6022. if ($v [0] == $endStaffArray ['nextStaff']) {
  6023. $roleId = $v [0];
  6024. }
  6025. }
  6026. $roleVerify = json_decode ( $v [3], true );
  6027. $roleKey = $k;
  6028. $roleArray = array ();
  6029. $rolename = $role->getOne ( array (
  6030. 'where' => 'rid=' . $v [0],
  6031. 'asArray' => true
  6032. ) );
  6033. foreach ( $roleVerify as $o => $p ) {
  6034. $staffID = explode ( '_', $p );
  6035. $staffInfo = $staff->getOne ( array (
  6036. 'where' => 'sid=' . $staffID [0],
  6037. 'asArray' => true
  6038. ) );
  6039. // print_r($staffID);
  6040. $exp = array (
  6041. 0 => $staffInfo ['sid'],
  6042. 1 => $staffID [1],
  6043. 2 => $staffInfo ['avatar'],
  6044. 'date' => '',
  6045. 'date' => '',
  6046. 'opinion' => '',
  6047. 'status' => '',
  6048. 'rolename' => $rolename ['name']
  6049. );
  6050. array_push ( $roleArray, $exp );
  6051. }
  6052. $roleArrayCopy [$v [0]] = $roleArray;
  6053. // $verifyList[$k]['roleArray']=$roleArray;
  6054. }
  6055. // print_r($roleArray);
  6056. $verifyList [$k] ['date'] = "";
  6057. $verifyList [$k] ['opinion'] = "";
  6058. $verifyList [$k] ['status'] = "";
  6059. if (empty ( $verifyStaff )) {
  6060. $verifyList [$k] ['date'] = "";
  6061. $verifyList [$k] ['opinion'] = "";
  6062. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6063. $verifyList [$k] ['status'] = 4;
  6064. $button = 4;
  6065. $flag = false;
  6066. }
  6067. } else {
  6068. foreach ( $verifyStaff as $m => $u ) {
  6069. if ($v [0] == $m) {
  6070. $verifyList [$k] ['date'] = $u ['date'];
  6071. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6072. $verifyList [$k] ['status'] = $u ['status'];
  6073. $flag = false;
  6074. break;
  6075. }
  6076. }
  6077. $endStaffArray = end ( $verifyStaff );
  6078. if (isset ( $endStaffArray ['ROLE'] )) {
  6079. } else {
  6080. $endKey = key ( $verifyStaff );
  6081. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6082. $button = 4;
  6083. $verifyList [$k] ['status'] = 4;
  6084. }
  6085. }
  6086. }
  6087. }
  6088. $rolename ['name'] = '';
  6089. if (! empty ( $roleId )) {
  6090. Doo::loadModel ( 'role' );
  6091. $role = new role ();
  6092. $rolename = $role->getOne ( array (
  6093. 'where' => 'rid=' . $roleId,
  6094. 'asArray' => true
  6095. ) );
  6096. }
  6097. if (! empty ( $verifyStaff ))
  6098. $endStaffArray = end ( $verifyStaff );
  6099. $KOP = false;
  6100. foreach ( $roleArrayCopy as $P => $A ) {
  6101. foreach ( $A as $MKI => $AVL ) {
  6102. if (! empty ( $verifyStaff )) {
  6103. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6104. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6105. $button = 4;
  6106. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6107. }
  6108. foreach ( $verifyStaff as $m => $u ) {
  6109. $AVLFK = $AVL [0] . '_R';
  6110. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6111. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6112. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6113. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6114. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6115. break;
  6116. }
  6117. }
  6118. } else {
  6119. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6120. $button = 4;
  6121. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6122. }
  6123. }
  6124. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6125. $KOP = true;
  6126. }
  6127. }
  6128. foreach ( $roleArrayCopy as $k => $v ) {
  6129. foreach ( $verifyList as $m => $n ) {
  6130. if ($n [0] == $k) {
  6131. array_splice ( $verifyList, $m, 1, $v );
  6132. }
  6133. }
  6134. }
  6135. $receiptList [$key] ['verifyList'] = $verifyList;
  6136. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6137. 'where' => 'sid=' . $value ['staff'],
  6138. 'asArray' => true
  6139. ) );
  6140. $receiptList [$key] ['button'] = $button;
  6141. }
  6142. $mothHtml = "";
  6143. for($i = 1; $i <= 12; $i ++) {
  6144. if ($month == $i)
  6145. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6146. else
  6147. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6148. }
  6149. // 获取审批日志
  6150. Doo::loadModel ( 'receiptLog' );
  6151. $receiptLog = new receiptLog ();
  6152. $rlList = array ();
  6153. $rlInfo = $receiptLog->getOne ( array (
  6154. 'where' => 'rid=' . $rid . ' and status=4',
  6155. 'asArray' => true
  6156. ) );
  6157. $tijdate = $receiptLog->getOne ( array (
  6158. 'where' => 'rid=' . $rid . ' and status=2',
  6159. 'asc' => 'rlid',
  6160. 'asArray' => true
  6161. ) );
  6162. if (! empty ( $rlInfo )) {
  6163. $rlList = $receiptLog->find ( array (
  6164. 'where' => 'rid=' . $rid,
  6165. 'asc' => 'rlid',
  6166. 'asArray' => true
  6167. ) );
  6168. }
  6169. $receiptList [0] ['rlList'] = $rlList;
  6170. $enclosurList = $enclosur->find ( array (
  6171. 'where' => 'rid=' . $rid,
  6172. 'asArray' => true
  6173. ) );
  6174. $enclosurHtml = '';
  6175. foreach ( $enclosurList as $value ) {
  6176. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6177. }
  6178. $data ['enclosurHtml'] = $enclosurHtml;
  6179. $data ['rolename'] = $rolename ['name'];
  6180. $data ['datetij'] = $tijdate ['date'];
  6181. $data ['mothHtml'] = $mothHtml;
  6182. $data ['receiptList'] = $receiptList;
  6183. $data ['receiptApprovalCount'] = count ( $receiptList );
  6184. $data ['year'] = $year;
  6185. $data ['categoryList'] = $categoryList;
  6186. $data ['staffList'] = $staffList;
  6187. $data ['cid'] = $cid;
  6188. $data ['sid'] = $sid;
  6189. $data ['status'] = 0;
  6190. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  6191. $ap = 4;
  6192. } else
  6193. $data ['status'] = $receiptList [0] ['status'];
  6194. if ($receiptList [0] ['status'] == 4) {
  6195. $data ['status'] = 5;
  6196. $ap = 0;
  6197. }
  6198. $data ['ap'] = $ap;
  6199. $data ['memu'] = "receipt";
  6200. $data ['staff'] = $this->staff;
  6201. $data ['receiptMemu'] = 'approval';
  6202. $data ['verifyId'] = $this->verifyId;
  6203. $data ['executeId'] = $this->executeId;
  6204. $this->render ( "/admin/saeaReportListReport", $data );
  6205. }
  6206. function approvalEdi() {
  6207. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6208. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  6209. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6210. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6211. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6212. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6213. if (empty ( $status ))
  6214. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  6215. $vidList = array ();
  6216. $button = 0;
  6217. Doo::loadModel ( 'verify' );
  6218. Doo::loadModel ( 'receipt' );
  6219. Doo::loadModel ( 'staff' );
  6220. $staff = new staff ();
  6221. $receipt = new receipt ();
  6222. $verify = new verify ();
  6223. Doo::loadModel ( 'L_category' );
  6224. $Lcategory = new L_category ();
  6225. Doo::loadModel ( 'enclosur' );
  6226. $enclosur = new enclosur ();
  6227. // user verify ID
  6228. $verifyDetail = $verify->find ( array (
  6229. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6230. 'asArray' => true
  6231. ) );
  6232. foreach ( $verifyDetail as $key => $value ) {
  6233. array_push ( $vidList, $value ['vid'] );
  6234. }
  6235. $vid = implode ( ",", $vidList );
  6236. if (empty ( $verifyDetail ))
  6237. $vid = 0;
  6238. $categoryList = $Lcategory->find ( array (
  6239. 'asArray' => true
  6240. ) );
  6241. $staffList = $staff->find ( array (
  6242. 'where' => 'cid=' . $cid,
  6243. 'asArray' => true
  6244. ) );
  6245. $ap = "";
  6246. if ($status == 4) {
  6247. $ap = 4;
  6248. $status = 2;
  6249. }
  6250. // get Receipt By verifyID status 2
  6251. $receiptList = $receipt->find ( array (
  6252. 'where' => 'rid =' . $rid,
  6253. 'desc' => 'rid',
  6254. 'asArray' => true
  6255. ) );
  6256. $Locate = 0;
  6257. $roleId = 0;
  6258. if ($ap == 4)
  6259. $status = 4;
  6260. foreach ( $receiptList as $key => $value ) {
  6261. $receiptList [$key] ['Locate'] = $Locate;
  6262. $Locate ++;
  6263. $receiptList [$key] ['reviseDetail'] = array ();
  6264. if (! empty ( $value ['reviseDetail'] ))
  6265. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6266. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6267. $categoryDetil = $Lcategory->getOne ( array (
  6268. 'where' => 'cid=' . $value ['cid'],
  6269. 'asArray' => true
  6270. ) );
  6271. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6272. // 检测编辑状态
  6273. $verifyList = $verify->getOne ( array (
  6274. 'where' => 'vid=' . $value ['verify'],
  6275. 'asArray' => true
  6276. ) );
  6277. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6278. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6279. // print_r($verifyList);
  6280. //
  6281. // if (empty($verifyStaff)){
  6282. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6283. // $verifyList[0]['status']=4;$button=4;
  6284. // }
  6285. //
  6286. // }else{
  6287. //
  6288. // }
  6289. // die;
  6290. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  6291. // echo array_search("green",$a);
  6292. //
  6293. Doo::loadModel ( 'role' );
  6294. $role = new role ();
  6295. // print_r($verifyList);
  6296. $flag = true;
  6297. $roleKey = 0;
  6298. $endStaffArray = array ();
  6299. $roleArrayCopy = array ();
  6300. foreach ( $verifyList as $k => $v ) {
  6301. // init verifyStaff
  6302. if ($v [1] == 'ROLE') {
  6303. if (! empty ( $verifyStaff )) {
  6304. $endStaffArray = end ( $verifyStaff );
  6305. if ($v [0] == $endStaffArray ['nextStaff']) {
  6306. $roleId = $v [0];
  6307. }
  6308. }
  6309. $roleVerify = json_decode ( $v [3], true );
  6310. $roleKey = $k;
  6311. $roleArray = array ();
  6312. $rolename = $role->getOne ( array (
  6313. 'where' => 'rid=' . $v [0],
  6314. 'asArray' => true
  6315. ) );
  6316. foreach ( $roleVerify as $o => $p ) {
  6317. $staffID = explode ( '_', $p );
  6318. $staffInfo = $staff->getOne ( array (
  6319. 'where' => 'sid=' . $staffID [0],
  6320. 'asArray' => true
  6321. ) );
  6322. // print_r($staffID);
  6323. $exp = array (
  6324. 0 => $staffInfo ['sid'],
  6325. 1 => $staffID [1],
  6326. 2 => $staffInfo ['avatar'],
  6327. 'date' => '',
  6328. 'date' => '',
  6329. 'opinion' => '',
  6330. 'status' => '',
  6331. 'rolename' => $rolename ['name']
  6332. );
  6333. array_push ( $roleArray, $exp );
  6334. }
  6335. $roleArrayCopy [$v [0]] = $roleArray;
  6336. // $verifyList[$k]['roleArray']=$roleArray;
  6337. }
  6338. // print_r($roleArray);
  6339. $verifyList [$k] ['date'] = "";
  6340. $verifyList [$k] ['opinion'] = "";
  6341. $verifyList [$k] ['status'] = "";
  6342. if (empty ( $verifyStaff )) {
  6343. $verifyList [$k] ['date'] = "";
  6344. $verifyList [$k] ['opinion'] = "";
  6345. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6346. $verifyList [$k] ['status'] = 4;
  6347. $button = 4;
  6348. $flag = false;
  6349. }
  6350. } else {
  6351. foreach ( $verifyStaff as $m => $u ) {
  6352. if ($v [0] == $m) {
  6353. $verifyList [$k] ['date'] = $u ['date'];
  6354. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6355. $verifyList [$k] ['status'] = $u ['status'];
  6356. $flag = false;
  6357. break;
  6358. }
  6359. }
  6360. $endStaffArray = end ( $verifyStaff );
  6361. if (isset ( $endStaffArray ['ROLE'] )) {
  6362. } else {
  6363. $endKey = key ( $verifyStaff );
  6364. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6365. $button = 4;
  6366. $verifyList [$k] ['status'] = 4;
  6367. }
  6368. }
  6369. // print_r($endStaffArray);die;
  6370. // if (empty($verifyStaff)){
  6371. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6372. // $verifyList[$k]['status']=4;$button=4;
  6373. // }
  6374. //
  6375. // }else{
  6376. //
  6377. // }
  6378. // if($flag){//检测可编辑
  6379. // if($v[0]==$this->staff[0]['sid']){
  6380. // $verifyList[$k]['status']=4;$button=4;
  6381. // }
  6382. // }
  6383. }
  6384. }
  6385. $rolename ['name'] = '';
  6386. if (! empty ( $roleId )) {
  6387. Doo::loadModel ( 'role' );
  6388. $role = new role ();
  6389. $rolename = $role->getOne ( array (
  6390. 'where' => 'rid=' . $roleId,
  6391. 'asArray' => true
  6392. ) );
  6393. }
  6394. if (! empty ( $verifyStaff ))
  6395. $endStaffArray = end ( $verifyStaff );
  6396. $KOP = false;
  6397. foreach ( $roleArrayCopy as $P => $A ) {
  6398. foreach ( $A as $MKI => $AVL ) {
  6399. if (! empty ( $verifyStaff )) {
  6400. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6401. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6402. $button = 4;
  6403. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6404. }
  6405. foreach ( $verifyStaff as $m => $u ) {
  6406. $AVLFK = $AVL [0] . '_R';
  6407. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6408. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6409. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6410. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6411. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6412. break;
  6413. }
  6414. }
  6415. } else {
  6416. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6417. $button = 4;
  6418. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6419. }
  6420. }
  6421. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6422. $KOP = true;
  6423. }
  6424. }
  6425. // print_r($roleArrayCopy);
  6426. // echo $roleKey;
  6427. foreach ( $roleArrayCopy as $k => $v ) {
  6428. foreach ( $verifyList as $m => $n ) {
  6429. if ($n [0] == $k) {
  6430. array_splice ( $verifyList, $m, 1, $v );
  6431. }
  6432. }
  6433. }
  6434. // if ($KOP)
  6435. // array_splice($verifyList,$roleKey,1,$roleArray);
  6436. // print_r($verifyList);
  6437. $receiptList [$key] ['verifyList'] = $verifyList;
  6438. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6439. 'where' => 'sid=' . $value ['staff'],
  6440. 'asArray' => true
  6441. ) );
  6442. $receiptList [$key] ['button'] = $button;
  6443. }
  6444. // $data['verifyDetail']=$verifyDetail;
  6445. $mothHtml = "";
  6446. for($i = 1; $i <= 12; $i ++) {
  6447. if ($month == $i)
  6448. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6449. else
  6450. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6451. }
  6452. // 获取审批日志
  6453. Doo::loadModel ( 'receiptLog' );
  6454. $receiptLog = new receiptLog ();
  6455. $rlList = array ();
  6456. $rlInfo = $receiptLog->getOne ( array (
  6457. 'where' => 'rid=' . $rid . ' and status=4',
  6458. 'asArray' => true
  6459. ) );
  6460. $tijdate = $receiptLog->getOne ( array (
  6461. 'where' => 'rid=' . $rid . ' and status=2',
  6462. 'asc' => 'rlid',
  6463. 'asArray' => true
  6464. ) );
  6465. if (! empty ( $rlInfo )) {
  6466. $rlList = $receiptLog->find ( array (
  6467. 'where' => 'rid=' . $rid,
  6468. 'asc' => 'rlid',
  6469. 'asArray' => true
  6470. ) );
  6471. }
  6472. $receiptList [0] ['rlList'] = $rlList;
  6473. $enclosurList = $enclosur->find ( array (
  6474. 'where' => 'rid=' . $rid,
  6475. 'asArray' => true
  6476. ) );
  6477. $enclosurHtml = '';
  6478. foreach ( $enclosurList as $value ) {
  6479. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6480. }
  6481. $data ['enclosurHtml'] = $enclosurHtml;
  6482. $data ['rolename'] = $rolename ['name'];
  6483. $data ['datetij'] = $tijdate ['date'];
  6484. $data ['mothHtml'] = $mothHtml;
  6485. $data ['receiptList'] = $receiptList;
  6486. $data ['receiptApprovalCount'] = count ( $receiptList );
  6487. $data ['status'] = $status;
  6488. $data ['year'] = $year;
  6489. $data ['categoryList'] = $categoryList;
  6490. $data ['staffList'] = $staffList;
  6491. $data ['cid'] = $cid;
  6492. $data ['sid'] = $sid;
  6493. $data ['ap'] = $ap;
  6494. $data ['memu'] = "receipt";
  6495. $data ['staff'] = $this->staff;
  6496. $data ['receiptMemu'] = 'approval';
  6497. $data ['verifyId'] = $this->verifyId;
  6498. $data ['executeId'] = $this->executeId;
  6499. $this->render ( "/admin/saeaReportListReport", $data );
  6500. }
  6501. function remittanceHky() {
  6502. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6503. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  6504. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6505. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  6506. $page_size = 15;
  6507. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  6508. Doo::loadModel ( 'receipt' );
  6509. $receipt = new receipt ();
  6510. Doo::loadModel ( 'staff' );
  6511. $staff = new staff ();
  6512. $dateCondition = " and Year(executeDate) =" . $year;
  6513. if ($moth != 'MONTH')
  6514. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  6515. if ($day != 'DAY' && $moth != 'MONTH')
  6516. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  6517. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  6518. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  6519. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  6520. $limit = $pageinfo ['lower'] . ',' . $page_size;
  6521. $dayList = $receipt->find ( array (
  6522. 'select' => 'executeDate,sum(amount) as amount',
  6523. 'where' => $sql,
  6524. 'desc' => 'executeDate',
  6525. 'groupby' => 'executeDate',
  6526. 'limit' => $limit,
  6527. 'asArray' => true
  6528. ) );
  6529. // print_r($dayList);
  6530. foreach ( $dayList as $key => $value ) {
  6531. $remitString = "";
  6532. $receiptList = $receipt->find ( array (
  6533. 'select' => 'rid,executeDate,amount,staff,cid',
  6534. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  6535. 'desc' => 'executeDate',
  6536. 'asArray' => true
  6537. ) );
  6538. foreach ( $receiptList as $k => $v ) {
  6539. $sinfo = $staff->getOne ( array (
  6540. 'select' => 'username,category',
  6541. 'where' => ' sid=' . $v ['staff'],
  6542. 'asArray' => true
  6543. ) );
  6544. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  6545. }
  6546. $dayList [$key] ['staff'] = $remitString;
  6547. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  6548. }
  6549. // print_r($dayList);
  6550. $mothHtml = "";
  6551. for($i = 1; $i <= 12; $i ++) {
  6552. if ($moth == $i)
  6553. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6554. else
  6555. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6556. }
  6557. $dayHtml = "";
  6558. if ($day != "DAY" || $moth != "MONTH") {
  6559. for($i = 1; $i <= 31; $i ++) {
  6560. if ($day == $i)
  6561. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6562. else
  6563. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6564. }
  6565. }
  6566. $data ['page'] = $pageinfo;
  6567. $data ['year'] = $year;
  6568. $data ['moth'] = $moth;
  6569. $data ['day'] = $day;
  6570. $data ['get'] = $get;
  6571. $data ['dayHtml'] = $dayHtml;
  6572. $data ['mothHtml'] = $mothHtml;
  6573. $data ['receiptList'] = $dayList;
  6574. $data ['memu'] = "receipt";
  6575. $data ['staff'] = $this->staff;
  6576. $data ['receiptMemu'] = 'remittanceHky';
  6577. $data ['verifyId'] = $this->verifyId;
  6578. $data ['executeId'] = $this->executeId;
  6579. $this->render ( "/admin/remittanceHky", $data );
  6580. }
  6581. function remittancep() {
  6582. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  6583. Doo::loadModel ( 'receipt' );
  6584. $receipt = new receipt ();
  6585. Doo::loadModel ( 'staff' );
  6586. $staff = new staff ();
  6587. Doo::loadClass ( 'XDeode' );
  6588. $XDeode = new XDeode ( 5 );
  6589. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  6590. $rplist = $receipt->find ( array (
  6591. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6592. 'asArray' => true
  6593. ) );
  6594. $dayList = $receipt->find ( array (
  6595. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6596. 'desc' => 'executeDate',
  6597. 'groupby' => 'staff',
  6598. 'asArray' => true
  6599. ) );
  6600. $html = '';
  6601. foreach ( $dayList as $key => $value ) {
  6602. $sinfo = $staff->getOne ( array (
  6603. 'select' => 'username,category',
  6604. 'where' => ' sid=' . $value ['staff'],
  6605. 'asArray' => true
  6606. ) );
  6607. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  6608. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  6609. $au = 0;
  6610. foreach ( $rplist as $k => $v ) {
  6611. if ($value ['staff'] == $v ['staff']) {
  6612. $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>';
  6613. $au += $v ['amount'];
  6614. }
  6615. }
  6616. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  6617. }
  6618. $data ['html'] = $html;
  6619. $data ['memu'] = "receipt";
  6620. $data ['staff'] = $this->staff;
  6621. $data ['receiptMemu'] = 'remittanceHky';
  6622. $data ['verifyId'] = $this->verifyId;
  6623. $data ['executeId'] = $this->executeId;
  6624. $this->render ( "/admin/remittancep", $data );
  6625. }
  6626. function ajaxGetReceiptDetails() {
  6627. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  6628. Doo::loadClass ( 'XDeode' );
  6629. $XDeode = new XDeode ( 5 );
  6630. $rid = $XDeode->decode ( $rid );
  6631. if (empty ( $rid )) {
  6632. echo json_encode ( array (
  6633. 'status' => 2,
  6634. 'msg' => 'illegal request'
  6635. ) );
  6636. die ();
  6637. }
  6638. Doo::loadModel ( 'receipt' );
  6639. $receipt = new receipt ();
  6640. Doo::loadModel ( 'staff' );
  6641. $staff = new staff ();
  6642. $rinfo = $receipt->getOne ( array (
  6643. 'where' => 'rid= ' . $rid,
  6644. 'asArray' => true
  6645. ) );
  6646. $sinfo = $staff->getOne ( array (
  6647. 'select' => 'username,category',
  6648. 'where' => ' sid=' . $rinfo ['staff'],
  6649. 'asArray' => true
  6650. ) );
  6651. $rinfo ['reviseDetail'] = array ();
  6652. if (! empty ( $rinfo ['reviseDetail'] ))
  6653. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  6654. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  6655. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  6656. $rinfo ['category'] = $sinfo ['category'];
  6657. $verifyStaff = array ();
  6658. if (! empty ( $rinfo ['verifyStaff'] ))
  6659. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  6660. $relust = $rinfo ['sum'] - $rinfo ['loanSum'];
  6661. $rinfo ['relust'] = $relust;
  6662. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  6663. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  6664. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  6665. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  6666. // 费用执行人相关数据
  6667. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6668. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6669. foreach ( $executeCopy as $k => $v ) {
  6670. $executeCopy [$k] ['date'] = '';
  6671. $executeCopy [$k] ['opinion'] = '';
  6672. $executeCopy [$k] ['status'] = '';
  6673. if (! empty ( $executeStaff ))
  6674. foreach ( $executeStaff as $m => $u ) {
  6675. if ($v [0] == $m) {
  6676. $executeCopy [$k] ['date'] = $u ['date'];
  6677. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  6678. $executeCopy [$k] ['status'] = $u ['status'];
  6679. break;
  6680. }
  6681. }
  6682. }
  6683. $rinfo ['executeCopy'] = $executeCopy;
  6684. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  6685. if ($rinfo ['Rtype'] == 1) { // 借款费用
  6686. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6687. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  6688. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  6689. $html .= '<tr><th>' . $value ['name'] . '</th>
  6690. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6691. }
  6692. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6693. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6694. <tr><th class="taC" colspan="2">费用说明</th>
  6695. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6696. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6697. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  6698. </tbody></table>';
  6699. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  6700. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6701. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6702. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6703. $html .= '<tr><th>' . $value ['name'] . '</th>
  6704. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6705. }
  6706. $html .= '<tr><th class="taR">合计</th>
  6707. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6708. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6709. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6710. $html .= '<tr><th>' . $value ['name'] . '</th>
  6711. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6712. }
  6713. $html .= '<tr><th class="taR">合计</th>
  6714. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6715. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6716. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6717. $html .= '<tr><th>' . $value ['name'] . '</th>
  6718. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6719. }
  6720. $html .= '<tr><th class="taR">合计</th>
  6721. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6722. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6723. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6724. $html .= '<tr><th>' . $value ['name'] . '</th>
  6725. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6726. }
  6727. $html .= '<tr><th class="taR">合计</th>
  6728. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6729. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6730. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6731. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6732. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6733. }
  6734. $html .= '<tr><th class="taR">合计</th>
  6735. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6736. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6737. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6738. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6739. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6740. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6741. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6742. <tr';
  6743. if ($rinfo ['relust'] >= 0) {
  6744. $html .= 'class="success"';
  6745. } else {
  6746. $html .= 'class="error"';
  6747. }
  6748. $html .= '><td class="taR"><b>借款结余</b></td>
  6749. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  6750. </tbody></table>
  6751. ';
  6752. }
  6753. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  6754. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6755. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  6756. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6757. $html .= '<tr><th>' . $value ['name'] . '</th>
  6758. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6759. }
  6760. $html .= '<tr><th class="taR">合计</th>
  6761. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6762. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6763. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6764. <tr><th class="taC" colspan="2">费用说明</th>
  6765. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6766. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6767. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6768. </tbody></table>';
  6769. } else {
  6770. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6771. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6772. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6773. $html .= '<tr><th>' . $value ['name'] . '</th>
  6774. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6775. }
  6776. $html .= '<tr><th class="taR">合计</th>
  6777. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6778. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6779. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6780. $html .= '<tr><th>' . $value ['name'] . '</th>
  6781. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6782. }
  6783. $html .= '<tr><th class="taR">合计</th>
  6784. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6785. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6786. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6787. $html .= '<tr><th>' . $value ['name'] . '</th>
  6788. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6789. }
  6790. $html .= '<tr><th class="taR">合计</th>
  6791. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6792. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6793. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6794. $html .= '<tr><th>' . $value ['name'] . '</th>
  6795. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6796. }
  6797. $html .= '<tr><th class="taR">合计</th>
  6798. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6799. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6800. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6801. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6802. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6803. }
  6804. $html .= '<tr><th class="taR">合计</th>
  6805. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6806. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6807. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6808. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6809. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6810. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6811. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  6812. $html .= '</tbody></table>';
  6813. /*
  6814. * <table class="table table-bordered table-condensed table-hover"> <tbody> <tr><th colspan="2" class="taC">日常相关费用</th></tr> <!-- loop receiptList' value.accountItem.日常相关费用 --> <tr><th>{{receiptList' value' value.name}}</th><td width="140" class="taR">¥{{receiptList' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptList' value.accountItem.cSum.agencySum}}</td></tr> <tr><th colspan="2" class="taC">差旅相关费用</th></tr> <!-- loop receiptDetail' value.accountItem.差旅相关费用 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.travelSum}}</td></tr> <tr><th colspan="2" class="taC">培训班费用</th></tr> <!-- loop receiptDetail' value.accountItem.培训班费用 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.trainSum}}</td></tr> <tr><th colspan="2" class="taC">其他</th></tr> <!-- loop receiptDetail' value.accountItem.其他 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.otherSum}}</td></tr> <tr><th colspan="2" class="taC">报销金额调整</th></tr> <!-- loop receiptList' value.reviseDetail --> <tr><th><span class="interval">|</span>{{receiptList' value' value.name}}:{{receiptList' value' value.description}}</th><td class="taR">¥{{receiptList' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colOrange taR">¥{{receiptList' value.revisePrice}}</td></tr> <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr> <tr><th style="text-align:center" colspan="2">{{receiptDetail' value.category}}</th></tr> <tr><th class="taC" colspan="2">报销说明</th></tr> <tr><td colspan="2">{{receiptDetail' value.explanation}}</td></tr> <tr class="warning"><td class="taR"><b>({{receiptDetail' value.receiptOrder}})本次报销费用合计</b></td> <td class="colGreed taR"><b style="font-size:24px">¥{{receiptDetail' value.sum}}</b><br>{{receiptDetail' value.sumCN}}</td></tr> </tbody> </table>
  6815. */
  6816. }
  6817. // print_r($verifyStaff);die;
  6818. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  6819. foreach ( $verifyStaff as $key => $value ) {
  6820. $key = trim ( strtr ( $key, '_R', ' ' ) );
  6821. $sinfo = $staff->getOne ( array (
  6822. 'select' => 'username',
  6823. 'where' => ' sid=' . $key,
  6824. 'asArray' => true
  6825. ) );
  6826. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6827. }
  6828. $html .= '</tbody></table>';
  6829. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  6830. foreach ( $rinfo ['executeCopy'] as $value ) {
  6831. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6832. }
  6833. $html .= '</tbody></table>';
  6834. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  6835. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  6836. </tr></table>';
  6837. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  6838. echo json_encode ( array (
  6839. 'status' => 1,
  6840. 'html' => $html
  6841. ) );
  6842. die ();
  6843. }
  6844. /**
  6845. * 删除附件
  6846. */
  6847. function ajaxRemEnclousur() {
  6848. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  6849. if (empty ( $key ))
  6850. echo json_encode ( array (
  6851. 'status' => 2
  6852. ) );
  6853. Doo::loadModel ( 'enclosur' );
  6854. $enclosur = new enclosur ();
  6855. $enclosur->delEnclosurByEid ( $key );
  6856. echo json_encode ( array (
  6857. 'status' => 1
  6858. ) );
  6859. }
  6860. function remittance() {
  6861. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6862. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6863. Doo::loadModel ( 'receipt' );
  6864. $receipt = new receipt ();
  6865. Doo::loadModel ( 'staff' );
  6866. $staff = new staff ();
  6867. $dateCondition = " and Year(pastDate) =" . $year;
  6868. if (! empty ( $month ))
  6869. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  6870. // get Receipt By verifyID status 1
  6871. $receiptList = $receipt->find ( array (
  6872. 'select' => 'sum(sum) as sum,staff,pastDate',
  6873. 'where' => ' status=1' . $dateCondition,
  6874. 'desc' => 'pastDate',
  6875. 'groupby' => 'staff,pastDate',
  6876. 'asArray' => true
  6877. ) );
  6878. $dateList = $receipt->find ( array (
  6879. 'select' => 'pastDate,verifyStaff',
  6880. 'where' => ' status=1' . $dateCondition,
  6881. 'desc' => 'pastDate',
  6882. 'groupby' => 'pastDate',
  6883. 'asArray' => true
  6884. ) );
  6885. $dataList = array ();
  6886. foreach ( $dateList as $d => $a ) {
  6887. $dataList [$a ['pastDate']] = array ();
  6888. $daySum = 0;
  6889. foreach ( $receiptList as $key => $value ) {
  6890. if ($a ['pastDate'] == $value ['pastDate']) {
  6891. $oderList = $receipt->find ( array (
  6892. 'select' => 'receiptOrder',
  6893. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  6894. 'asArray' => true
  6895. ) );
  6896. $list = array ();
  6897. $html = "";
  6898. foreach ( $oderList as $v ) {
  6899. array_push ( $list, $v ['receiptOrder'] );
  6900. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  6901. }
  6902. $receiptList [$key] ['receiptOrder'] = $html;
  6903. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  6904. $sinfo = $staff->getOne ( array (
  6905. 'select' => 'username ',
  6906. 'where' => ' sid=' . $value ['staff'],
  6907. 'asArray' => true
  6908. ) );
  6909. $receiptList [$key] ['username'] = $sinfo ['username'];
  6910. $daySum += $value ['sum'];
  6911. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  6912. }
  6913. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  6914. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  6915. }
  6916. }
  6917. // print_r($dataList);
  6918. $data ['dataList'] = $dataList;
  6919. $mothHtml = "";
  6920. for($i = 1; $i <= 12; $i ++) {
  6921. if ($month == $i)
  6922. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6923. else
  6924. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6925. }
  6926. $data ['year'] = $year;
  6927. $data ['mothHtml'] = $mothHtml;
  6928. $data ['memu'] = "receipt";
  6929. $data ['staff'] = $this->staff;
  6930. $data ['receiptMemu'] = 'approval';
  6931. $data ['verifyId'] = $this->verifyId;
  6932. $data ['executeId'] = $this->executeId;
  6933. $this->render ( "/admin/saeaReportListPay", $data );
  6934. }
  6935. /**
  6936. * 金额调整,提高稳定性
  6937. * @return string
  6938. */
  6939. function revocationAdjustment() {
  6940. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  6941. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  6942. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  6943. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  6944. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey ) && (! empty ( $reviseKey )))) {
  6945. Doo::loadClass ( 'XDeode' );
  6946. $XDeode = new XDeode ( 5 );
  6947. Doo::loadModel ( 'receipt' );
  6948. $receipt = new receipt ();
  6949. $sid = $XDeode->decode ( $sidKey );
  6950. $rid = $XDeode->decode ( $ridKey );
  6951. $reviseKey = $XDeode->decode ( $reviseKey );
  6952. if (! is_numeric ( $sid ) && ! is_numeric ( $rid ) && ! is_numeric ( $reviseKey ))
  6953. die ( 'illegal request' );
  6954. $receiptDetail = $receipt->getOne ( array (
  6955. 'where' => 'rid=' . $rid,
  6956. 'asArray' => true
  6957. ) );
  6958. if (empty ( $receiptDetail ) || empty ( $receiptDetail ['reviseDetail'] ))
  6959. die ( 'illegal request' );
  6960. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  6961. if (! isset ( $reviseDetail [$reviseKey] ))
  6962. die ( 'illegal request' );
  6963. if ($reviseDetail [$reviseKey] ['sid'] == $sid && $reviseDetail [$reviseKey] ['price'] == $price)
  6964. unset ( $reviseDetail [$reviseKey] );
  6965. $revisePrice = 0;
  6966. foreach ( $reviseDetail as $key => $value ) {
  6967. $revisePrice += $value ['price'];
  6968. }
  6969. $reviseDetailString = json_encode ( $reviseDetail );
  6970. $receipt->reviseDetail = $reviseDetailString;
  6971. $receipt->sum = $receiptDetail ['sum'] - $price;
  6972. $receipt->revisePrice = $revisePrice;
  6973. $receipt->update ( array (
  6974. 'where' => 'rid=' . $rid
  6975. ) );
  6976. return '/receiptburEdi/' . $rid;
  6977. } else
  6978. die ( 'illegal request2' );
  6979. }
  6980. function updateApprovalReceipt() {
  6981. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6982. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  6983. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6984. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  6985. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  6986. if (! empty ( $rid )) {
  6987. Doo::loadModel ( "verify" );
  6988. $verify = new verify ();
  6989. Doo::loadModel ( "receiptDetail" );
  6990. $receiptDetailObj = new receiptDetail ();
  6991. Doo::loadModel ( "itemStatistics" );
  6992. Doo::loadModel ( "statistics" );
  6993. $statistics = new statistics ();
  6994. $itemStatistics = new itemStatistics ();
  6995. Doo::loadModel ( "receipt" );
  6996. $receipt = new receipt ();
  6997. $receiptDetail = $receipt->getOne ( array (
  6998. 'where' => 'rid=' . $rid . ' and status=2 ',
  6999. 'asArray' => true
  7000. ) );
  7001. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  7002. $nsflag = true;
  7003. foreach ( $nslist as $value ) {
  7004. if ($value == $this->staff ['0'] ['sid']) {
  7005. $nsflag = false;
  7006. break;
  7007. }
  7008. }
  7009. if (empty ( $receiptDetail ) || $nsflag)
  7010. return "/approval";
  7011. $verifyDetail = $verify->getOne ( array (
  7012. 'where' => ' vid =' . $receiptDetail ['verify'],
  7013. 'asArray' => true
  7014. ) );
  7015. $verifyString = $verifyDetail ['staff'];
  7016. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  7017. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  7018. if (empty ( $opinion )) {
  7019. if ($status == 3)
  7020. $opinion = "终止";
  7021. else
  7022. $opinion = "同意支付";
  7023. }
  7024. $nowStaff = 0;
  7025. $nowStaffList = array ();
  7026. if (empty ( $verifyStaff )) {
  7027. // 还需加入是否已经进入角色审批
  7028. if ($verifyDetail [0] [1] == 'ROLE') {
  7029. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  7030. foreach ( $vStaffString as $key => $value ) {
  7031. $staffK = explode ( "_", $value );
  7032. if ($staffK [0] != $this->staff [0] ['sid'])
  7033. array_push ( $nowStaffList, $staffK [0] );
  7034. }
  7035. // print_r($verifyDetail);
  7036. // die;
  7037. if (! empty ( $nowStaffList )) {
  7038. $nowStaff = implode ( ',', $nowStaffList );
  7039. $verifyStaff = array (
  7040. $this->staff [0] ['sid'] . "_R" => array (
  7041. 'date' => date ( 'Y-m-d' ),
  7042. 'opinion' => $opinion,
  7043. 'status' => $status,
  7044. 'nextStaff' => $verifyDetail [0] [0],
  7045. 'ROLE' => 1
  7046. )
  7047. );
  7048. } else {
  7049. $nowStaff = $verifyDetail [1] [0];
  7050. $verifyStaff = array (
  7051. $this->staff [0] ['sid'] . "_R" => array (
  7052. 'date' => date ( 'Y-m-d' ),
  7053. 'opinion' => $opinion,
  7054. 'status' => $status,
  7055. 'nextStaff' => $verifyDetail [1] [0]
  7056. )
  7057. );
  7058. }
  7059. } else {
  7060. if ($verifyDetail [1] [1] == 'ROLE') {
  7061. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  7062. // echo "dd";
  7063. foreach ( $vStaffString as $key => $value ) {
  7064. $staffK = explode ( "_", $value );
  7065. array_push ( $nowStaffList, $staffK [0] );
  7066. }
  7067. $nowStaff = implode ( ',', $nowStaffList );
  7068. $verifyStaff = array (
  7069. $this->staff [0] ['sid'] => array (
  7070. 'date' => date ( 'Y-m-d' ),
  7071. 'opinion' => $opinion,
  7072. 'status' => $status,
  7073. 'nextStaff' => $verifyDetail [1] [0],
  7074. 'ROLE' => 1
  7075. )
  7076. );
  7077. } else {
  7078. $nowStaff = $verifyDetail [1] [0];
  7079. $verifyStaff = array (
  7080. $this->staff [0] ['sid'] => array (
  7081. 'date' => date ( 'Y-m-d' ),
  7082. 'opinion' => $opinion,
  7083. 'status' => $status,
  7084. 'nextStaff' => $verifyDetail [1] [0]
  7085. )
  7086. );
  7087. }
  7088. }
  7089. if ($status == 3)
  7090. $verifyStaff = array (
  7091. 'final' => $status,
  7092. $this->staff [0] ['sid'] => array (
  7093. 'date' => date ( 'Y-m-d' ),
  7094. 'opinion' => $opinion,
  7095. 'status' => $status
  7096. )
  7097. );
  7098. $vStaffString = json_encode ( $verifyStaff );
  7099. $receipt->nowStaff = $nowStaff;
  7100. $receipt->verifyStaff = $vStaffString;
  7101. } else {
  7102. $VS = end ( $verifyStaff );
  7103. // 非角色审批
  7104. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  7105. $nextStaff = 0;
  7106. $roleSTF = false;
  7107. foreach ( $verifyDetail as $key => $value ) {
  7108. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  7109. if (isset ( $verifyDetail [$key + 1] )) {
  7110. $nextStaff = $verifyDetail [$key + 1] [0];
  7111. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  7112. $roleSTF = true;
  7113. }
  7114. break;
  7115. }
  7116. }
  7117. if (! $roleSTF) {
  7118. $nowStaff = $nextStaff;
  7119. $verifyStaff [$this->staff [0] ['sid']] = array (
  7120. 'date' => date ( 'Y-m-d' ),
  7121. 'opinion' => $opinion,
  7122. 'status' => $status,
  7123. 'nextStaff' => $nextStaff
  7124. );
  7125. } else {
  7126. // 获取角色下的所有用户ID
  7127. $nowStaffList = array ();
  7128. foreach ( $verifyDetail as $vfk ) {
  7129. if ($vfk [1] == 'ROLE') {
  7130. $vStaffString = json_decode ( $vfk [3] );
  7131. foreach ( $vStaffString as $key => $value ) {
  7132. $staffK = explode ( "_", $value );
  7133. array_push ( $nowStaffList, $staffK [0] );
  7134. }
  7135. }
  7136. }
  7137. $nowStaff = implode ( ',', $nowStaffList );
  7138. $verifyStaff [$this->staff [0] ['sid']] = array (
  7139. 'date' => date ( 'Y-m-d' ),
  7140. 'opinion' => $opinion,
  7141. 'status' => $status,
  7142. 'nextStaff' => $nextStaff,
  7143. 'ROLE' => 0
  7144. );
  7145. }
  7146. if ($status == 3) {
  7147. $verifyStaff ['final'] = $status;
  7148. $verifyStaff [$this->staff [0] ['sid']] = array (
  7149. 'date' => date ( 'Y-m-d' ),
  7150. 'opinion' => $opinion,
  7151. 'status' => $status
  7152. );
  7153. }
  7154. $vStaffString = json_encode ( $verifyStaff );
  7155. $receipt->nowStaff = $nowStaff;
  7156. $receipt->verifyStaff = $vStaffString;
  7157. }
  7158. // 角色审批
  7159. if (isset ( $VS ['ROLE'] )) {
  7160. // 找出角色人 当前审批角色组
  7161. $verifyJSStaff = array ();
  7162. $nowStaffList2 = array ();
  7163. foreach ( $verifyDetail as $key => $value ) {
  7164. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  7165. $verifyJSStaff = json_decode ( $value [3] );
  7166. foreach ( $verifyJSStaff as $m ) {
  7167. $staffK = explode ( "_", $m );
  7168. array_push ( $nowStaffList2, $staffK [0] );
  7169. }
  7170. // print_r($nowStaffList2);
  7171. }
  7172. }
  7173. $RoleVerifyStaff = array ();
  7174. foreach ( $verifyStaff as $key => $value ) {
  7175. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  7176. foreach ( $nowStaffList2 as $m ) {
  7177. if ($key == $m . "_R")
  7178. $RoleVerifyStaff [$key] = $value;
  7179. }
  7180. }
  7181. }
  7182. // print_r($verifyStaff);
  7183. // print_r($nowStaffList2);
  7184. // print_r($RoleVerifyStaff);
  7185. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  7186. // print_r($verifyJSStaff);
  7187. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  7188. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  7189. // 下一个审批人ID
  7190. $nextStaff = 0;
  7191. $falg = false;
  7192. foreach ( $verifyDetail as $key => $value ) {
  7193. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  7194. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  7195. $falg = true;
  7196. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  7197. $nowStaffList = array ();
  7198. foreach ( $vStaffString as $v ) {
  7199. $staffK = explode ( "_", $v );
  7200. array_push ( $nowStaffList, $staffK [0] );
  7201. }
  7202. $nowStaff = implode ( ',', $nowStaffList );
  7203. $nextStaff = $verifyDetail [$key + 1] [0];
  7204. } elseif (isset ( $verifyDetail [$key + 1] )) {
  7205. $nextStaff = $verifyDetail [$key + 1] [0];
  7206. $nowStaff = $nextStaff;
  7207. } else
  7208. $nowStaff = '';
  7209. break;
  7210. }
  7211. }
  7212. if ($falg)
  7213. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7214. 'date' => date ( 'Y-m-d' ),
  7215. 'opinion' => $opinion,
  7216. 'status' => $status,
  7217. 'nextStaff' => $nextStaff,
  7218. 'ROLE' => 1
  7219. );
  7220. else
  7221. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7222. 'date' => date ( 'Y-m-d' ),
  7223. 'opinion' => $opinion,
  7224. 'status' => $status,
  7225. 'nextStaff' => $nextStaff
  7226. );
  7227. // print_r($verifyStaff);
  7228. // echo $nowStaff;die;
  7229. } else { // 进入下一个角色或者审批人
  7230. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  7231. //
  7232. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  7233. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7234. 'date' => date ( 'Y-m-d' ),
  7235. 'opinion' => $opinion,
  7236. 'status' => $status,
  7237. 'nextStaff' => $VS ['nextStaff'],
  7238. 'ROLE' => 1
  7239. );
  7240. // print_r($verifyStaff);
  7241. // die;
  7242. }
  7243. if ($status == 3) {
  7244. $verifyStaff ['final'] = $status;
  7245. $verifyStaff [$this->staff [0] ['sid']] = array (
  7246. 'date' => date ( 'Y-m-d' ),
  7247. 'opinion' => $opinion,
  7248. 'status' => $status
  7249. );
  7250. }
  7251. $vStaffString = json_encode ( $verifyStaff );
  7252. $receipt->verifyStaff = $vStaffString;
  7253. $receipt->nowStaff = $nowStaff;
  7254. // die;
  7255. // }
  7256. // print_r($verifyStaff);
  7257. // die;
  7258. }
  7259. // print_r($verifyStaff);die;
  7260. }
  7261. // print_r($verifyDetail);
  7262. $roleKey = 0;
  7263. $roleId = 0;
  7264. $verifyDetailCopy = array ();
  7265. foreach ( $verifyDetail as $k => $v ) {
  7266. if ($v [1] == 'ROLE') {
  7267. $roleId = $v [0];
  7268. $roleVerify = json_decode ( $v [3], true );
  7269. $roleKey = $k;
  7270. $roleArray = array ();
  7271. foreach ( $roleVerify as $o => $p ) {
  7272. $staffID = explode ( '_', $p );
  7273. $exp = array (
  7274. 0 => $staffID [0],
  7275. 1 => $staffID [1]
  7276. );
  7277. array_push ( $roleArray, $exp );
  7278. }
  7279. $verifyDetailCopy [$v [0]] = $roleArray;
  7280. }
  7281. }
  7282. // print_r($verifyDetail);
  7283. foreach ( $verifyDetailCopy as $k => $v ) {
  7284. foreach ( $verifyDetail as $m => $n ) {
  7285. if ($n [0] == $k) {
  7286. array_splice ( $verifyDetail, $m, 1, $v );
  7287. }
  7288. }
  7289. }
  7290. // die;
  7291. // if (!empty($roleArray))
  7292. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  7293. // echo $roleId;
  7294. // print_r($verifyStaff);
  7295. // print_r($verifyDetail);
  7296. // die;
  7297. Doo::loadModel ( "receiptLog" );
  7298. $receiptLog = new receiptLog ();
  7299. // 审批日志
  7300. if (! isset ( $verifyStaff ['final'] )) {
  7301. if (! empty ( $roleId )) {
  7302. Doo::loadModel ( "role" );
  7303. $role = new role ();
  7304. $roleInfo = $role->getOne ( array (
  7305. 'where' => 'rid=' . $roleId,
  7306. 'asArray' => true
  7307. ) );
  7308. $receiptLog->rolename = $roleInfo ['name'];
  7309. }
  7310. $receiptLog->username = $this->staff [0] ['username'];
  7311. $receiptLog->uid = $this->staff [0] ['sid'];
  7312. $receiptLog->date = date ( "Y-m-d" );
  7313. $receiptLog->opinion = $opinion;
  7314. $receiptLog->img = $this->staff [0] ['avatar'];
  7315. $receiptLog->status = 1;
  7316. $receiptLog->rid = $rid;
  7317. $receiptLog->insert ();
  7318. }
  7319. if (isset ( $verifyStaff ['final'] )) { // rDetail
  7320. $receipt->verifyBreakup = $verifyString;
  7321. $receipt->status = 3;
  7322. $receiptDetailObj->status = 3;
  7323. $receiptDetailObj->update ( array (
  7324. 'where' => 'rid=' . $rid
  7325. ) );
  7326. if (! empty ( $roleId )) {
  7327. Doo::loadModel ( "role" );
  7328. $role = new role ();
  7329. $roleInfo = $role->getOne ( array (
  7330. 'where' => 'rid=' . $roleId,
  7331. 'asArray' => true
  7332. ) );
  7333. $receiptLog->rolename = $roleInfo ['name'];
  7334. }
  7335. $receiptLog->username = $this->staff [0] ['username'];
  7336. $receiptLog->uid = $this->staff [0] ['sid'];
  7337. $receiptLog->date = date ( "Y-m-d" );
  7338. $receiptLog->opinion = $opinion;
  7339. $receiptLog->img = $this->staff [0] ['avatar'];
  7340. $receiptLog->status = 3;
  7341. $receiptLog->rid = $rid;
  7342. $receiptLog->insert ();
  7343. // 微信企业号通知
  7344. $this->setWXMsg ( $rid, 3 );
  7345. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  7346. $receipt->status = 1;
  7347. $reviseSum = 0;
  7348. $receipt->verifyBreakup = $verifyString;
  7349. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  7350. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7351. foreach ( $reviseDetail as $key => $value ) {
  7352. $receiptDetailObj = new receiptDetail ();
  7353. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7354. $receiptDetailObj->item = $value ['description'];
  7355. $receiptDetailObj->itemCategory = "报销金额调整";
  7356. $receiptDetailObj->price = $value ['price'];
  7357. $receiptDetailObj->date = $receiptDetail ['date'];
  7358. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  7359. $receiptDetailObj->rid = $rid;
  7360. $receiptDetailObj->status = 1;
  7361. $receiptDetailObj->insert ();
  7362. $reviseSum += $value ['price'];
  7363. }
  7364. $itemStatistics = new itemStatistics ();
  7365. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7366. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7367. $itemStatistics->price = $reviseSum;
  7368. $itemStatistics->itemCategory = "报销金额调整";
  7369. $itemStatistics->date = $receiptDetail ['date'];
  7370. $itemStatistics->insert ();
  7371. }
  7372. $receiptDetailObj = new receiptDetail ();
  7373. $receiptDetailObj->status = 1;
  7374. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  7375. $receiptDetailObj->update ( array (
  7376. 'where' => 'rid=' . $rid
  7377. ) );
  7378. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7379. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7380. $stat = $statistics->getOne ( array (
  7381. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  7382. 'asArray' => true
  7383. ) );
  7384. if (empty ( $stat )) {
  7385. $statistics->date = $receiptDetail ['date'];
  7386. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7387. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7388. $statistics->agPrice = $receiptDetail ['sum'];
  7389. $statistics->rePrice = $reviseSum;
  7390. $statistics->insert ();
  7391. } else {
  7392. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  7393. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  7394. $statistics->update ( array (
  7395. 'where' => 'sid=' . $stat ['sid']
  7396. ) );
  7397. }
  7398. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7399. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7400. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  7401. foreach ( $accountItem ['cSum'] as $key => $value ) {
  7402. if ($key == "agencySum") {
  7403. $iStatistics = $itemStatistics->getOne ( array (
  7404. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  7405. 'asArray' => true
  7406. ) );
  7407. if (empty ( $iStatistics )) {
  7408. $itemStatistics->cid = $receiptDetail ['cid'];
  7409. ;
  7410. $itemStatistics->staff = $receiptDetail ['staff'];
  7411. $itemStatistics->price = $value;
  7412. $itemStatistics->itemCategory = $this->AGENCY;
  7413. $itemStatistics->date = $receiptDetail ['date'];
  7414. $itemStatistics->insert ();
  7415. } else {
  7416. if (! empty ( $value )) {
  7417. $itemStatistics->price = $value + $iStatistics ['price'];
  7418. $itemStatistics->update ( array (
  7419. 'where' => 'sid=' . $iStatistics ['sid']
  7420. ) );
  7421. }
  7422. }
  7423. } elseif ($key == "travelSum") {
  7424. $iStatistics = $itemStatistics->getOne ( array (
  7425. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  7426. 'asArray' => true
  7427. ) );
  7428. if (empty ( $iStatistics )) {
  7429. $itemStatistics->cid = $receiptDetail ['cid'];
  7430. $itemStatistics->staff = $receiptDetail ['staff'];
  7431. $itemStatistics->price = $value;
  7432. $itemStatistics->itemCategory = $this->TRAVEL;
  7433. $itemStatistics->date = $receiptDetail ['date'];
  7434. $itemStatistics->insert ();
  7435. } else {
  7436. if (! empty ( $value )) {
  7437. $itemStatistics->price = $value + $iStatistics ['price'];
  7438. $itemStatistics->update ( array (
  7439. 'where' => 'sid=' . $iStatistics ['sid']
  7440. ) );
  7441. }
  7442. }
  7443. } elseif ($key == "trainSum") {
  7444. $iStatistics = $itemStatistics->getOne ( array (
  7445. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  7446. 'asArray' => true
  7447. ) );
  7448. if (empty ( $iStatistics )) {
  7449. $itemStatistics->cid = $receiptDetail ['cid'];
  7450. $itemStatistics->staff = $receiptDetail ['staff'];
  7451. $itemStatistics->price = $value;
  7452. $itemStatistics->itemCategory = $this->TRAIN;
  7453. $itemStatistics->date = $receiptDetail ['date'];
  7454. $itemStatistics->insert ();
  7455. } else {
  7456. if (! empty ( $value )) {
  7457. $itemStatistics->price = $value + $iStatistics ['price'];
  7458. $itemStatistics->update ( array (
  7459. 'where' => 'sid=' . $iStatistics ['sid']
  7460. ) );
  7461. }
  7462. }
  7463. } elseif ($key == "otherSum") {
  7464. $iStatistics = $itemStatistics->getOne ( array (
  7465. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  7466. 'asArray' => true
  7467. ) );
  7468. if (empty ( $iStatistics )) {
  7469. $itemStatistics->cid = $receiptDetail ['cid'];
  7470. $itemStatistics->staff = $receiptDetail ['staff'];
  7471. $itemStatistics->price = $value;
  7472. $itemStatistics->itemCategory = $this->OTHER;
  7473. $itemStatistics->date = $receiptDetail ['date'];
  7474. $itemStatistics->insert ();
  7475. } else {
  7476. if (! empty ( $value )) {
  7477. $itemStatistics->price = $value + $iStatistics ['price'];
  7478. $itemStatistics->update ( array (
  7479. 'where' => 'sid=' . $iStatistics ['sid']
  7480. ) );
  7481. }
  7482. }
  7483. }
  7484. }
  7485. $receipt->pastDate = date ( "Y-m-d" );
  7486. // 微信企业号通知
  7487. $this->setWXMsg ( $rid, 1 );
  7488. }
  7489. $receipt->amount = $amount;
  7490. $receipt->update ( array (
  7491. 'where' => ' rid = ' . $rid
  7492. ) );
  7493. // 进入下一条审批费用新加需求
  7494. $vidList = array ();
  7495. $verifyDetail = $verify->find ( array (
  7496. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  7497. 'asArray' => true
  7498. ) );
  7499. foreach ( $verifyDetail as $key => $value ) {
  7500. array_push ( $vidList, $value ['vid'] );
  7501. }
  7502. $vid = implode ( ",", $vidList );
  7503. if (empty ( $verifyDetail ))
  7504. $vid = 0;
  7505. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  7506. $receipt = new receipt ();
  7507. $rd = $receipt->getOne ( array (
  7508. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  7509. 'asc' => 'rid',
  7510. 'asArray' => true
  7511. ) );
  7512. if (empty ( $rd )) {
  7513. return '/approvalExpenses/pendApproval';
  7514. }
  7515. if ($rd ['Rtype'] == 1) {
  7516. if ($rd ['isBK'] == 1) {
  7517. return '/receiptburEdi/' . $rd ['rid'];
  7518. } else {
  7519. return '/expensesEdi/' . $rd ['rid'];
  7520. }
  7521. } elseif ($rd ['Rtype'] == 2) {
  7522. return '/remitApproval/' . $rd ['rid'];
  7523. } else {
  7524. return '/receiptburEdi/' . $rd ['rid'];
  7525. }
  7526. // return "/approvalExpenses/pendApproval";
  7527. }
  7528. }
  7529. function expensesRetreats() {
  7530. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7531. if (! empty ( $rid )) {
  7532. // 操作记录
  7533. Doo::loadModel ( "receipt" );
  7534. $receipt = new receipt ();
  7535. Doo::loadModel ( "receiptLog" );
  7536. $receiptLog = new receiptLog ();
  7537. Doo::loadModel ( "verify" );
  7538. $verify = new verify ();
  7539. $receiptInfo = $receipt->getOne ( array (
  7540. 'where' => 'rid=' . $rid,
  7541. 'asArray' => true
  7542. ) );
  7543. $vr = $verify->getOne ( array (
  7544. 'where' => 'vid=' . $receiptInfo ['verify'],
  7545. 'asArray' => true
  7546. ) );
  7547. $jd = json_decode ( $vr ['staff'] );
  7548. $roleId = 0;
  7549. foreach ( $jd as $key => $value ) {
  7550. if ($value [1] == 'ROLE') {
  7551. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7552. if ($pos !== false) {
  7553. $roleId = $value [0];
  7554. }
  7555. }
  7556. }
  7557. // 审批日志
  7558. // echo $roleId;die;
  7559. if (! empty ( $roleId )) {
  7560. Doo::loadModel ( "role" );
  7561. $role = new role ();
  7562. $roleInfo = $role->getOne ( array (
  7563. 'where' => 'rid=' . $roleId,
  7564. 'asArray' => true
  7565. ) );
  7566. $receiptLog->rolename = $roleInfo ['name'];
  7567. }
  7568. $receiptLog->username = $this->staff [0] ['username'];
  7569. $receiptLog->uid = $this->staff [0] ['sid'];
  7570. $receiptLog->date = date ( "Y-m-d" );
  7571. $receiptLog->opinion = '撤回';
  7572. $receiptLog->img = $this->staff [0] ['avatar'];
  7573. $receiptLog->status = 4;
  7574. $receiptLog->rid = $rid;
  7575. $receiptLog->insert ();
  7576. $receipt->status = 4;
  7577. $receipt->update ( array (
  7578. 'where' => 'rid=' . $rid
  7579. ) );
  7580. // 微信企业号通知
  7581. $this->setWXMsg ( $rid, 2 );
  7582. }
  7583. // echo "ddd";
  7584. return '/approvalExpenses/pendApproval';
  7585. }
  7586. function updateCheReceipt() {
  7587. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7588. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7589. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  7590. if (! empty ( $rid )) {
  7591. // 操作记录
  7592. Doo::loadModel ( "receipt" );
  7593. $receipt = new receipt ();
  7594. Doo::loadModel ( "receiptLog" );
  7595. $receiptLog = new receiptLog ();
  7596. Doo::loadModel ( "verify" );
  7597. $verify = new verify ();
  7598. $receiptInfo = $receipt->getOne ( array (
  7599. 'where' => 'rid=' . $rid . ' and status=2',
  7600. 'asArray' => true
  7601. ) );
  7602. if (empty ( $receiptInfo )) {
  7603. echo json_encode ( array (
  7604. 'status' => 2
  7605. ) );
  7606. die ();
  7607. }
  7608. $vr = $verify->getOne ( array (
  7609. 'where' => 'vid=' . $receiptInfo ['verify'],
  7610. 'asArray' => true
  7611. ) );
  7612. $jd = json_decode ( $vr ['staff'] );
  7613. $roleId = 0;
  7614. foreach ( $jd as $key => $value ) {
  7615. if ($value [1] == 'ROLE') {
  7616. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7617. if ($pos !== false) {
  7618. $roleId = $value [0];
  7619. }
  7620. }
  7621. }
  7622. // 审批日志
  7623. // echo $roleId;die;
  7624. if (! empty ( $roleId )) {
  7625. Doo::loadModel ( "role" );
  7626. $role = new role ();
  7627. $roleInfo = $role->getOne ( array (
  7628. 'where' => 'rid=' . $roleId,
  7629. 'asArray' => true
  7630. ) );
  7631. $receiptLog->rolename = $roleInfo ['name'];
  7632. }
  7633. $receiptLog->username = $this->staff [0] ['username'];
  7634. $receiptLog->uid = $this->staff [0] ['sid'];
  7635. $receiptLog->date = date ( "Y-m-d" );
  7636. $receiptLog->opinion = $opinion;
  7637. $receiptLog->img = $this->staff [0] ['avatar'];
  7638. $receiptLog->status = 4;
  7639. $receiptLog->rid = $rid;
  7640. $receiptLog->insert ();
  7641. $receipt->status = 4;
  7642. $receipt->update ( array (
  7643. 'where' => 'rid=' . $rid
  7644. ) );
  7645. // 微信企业号通知
  7646. $this->setWXMsg ( $rid, 2 );
  7647. echo json_encode ( array (
  7648. 'status' => 1
  7649. ) );
  7650. // Header("HTTP/1.1 303 See Other");
  7651. // Header("Location: /approvalExpenses/pendApproval");
  7652. die ();
  7653. }
  7654. echo json_encode ( array (
  7655. 'status' => 2
  7656. ) );
  7657. die ();
  7658. // echo "ddd";
  7659. // return '/saeaBorad';
  7660. }
  7661. function revisePrice() {
  7662. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  7663. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  7664. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7665. // echo $price;die;
  7666. if (! empty ( $rid )) {
  7667. Doo::loadModel ( "receipt" );
  7668. $receipt = new receipt ();
  7669. $receiptDetail = $receipt->getOne ( array (
  7670. 'where' => 'rid=' . $rid . ' and status=2 ',
  7671. 'asArray' => true
  7672. ) );
  7673. if (empty ( $receiptDetail ))
  7674. die ( 'illegal request' );
  7675. $reviseDetail = array ();
  7676. if (empty ( $receiptDetail ['reviseDetail'] )) {
  7677. array_push ( $reviseDetail, array (
  7678. 'sid' => $this->staff [0] ['sid'],
  7679. 'name' => $this->staff [0] ['username'],
  7680. 'description' => $description,
  7681. 'price' => $price
  7682. ) );
  7683. $reviseDetailString = json_encode ( $reviseDetail );
  7684. $receipt->reviseDetail = $reviseDetailString;
  7685. $receipt->revisePrice = $price;
  7686. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7687. } else {
  7688. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7689. array_push ( $reviseDetail, array (
  7690. 'sid' => $this->staff [0] ['sid'],
  7691. 'name' => $this->staff [0] ['username'],
  7692. 'description' => $description,
  7693. 'price' => $price
  7694. ) );
  7695. $reviseDetailString = json_encode ( $reviseDetail );
  7696. $receipt->reviseDetail = $reviseDetailString;
  7697. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  7698. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7699. }
  7700. $receipt->update ( array (
  7701. 'where' => 'rid=' . $rid
  7702. ) );
  7703. if ($receiptDetail ['Rtype'] == 1) {
  7704. if ($receiptDetail ['isBK'] == 1) {
  7705. return '/receiptburEdi/' . $receiptDetail ['rid'];
  7706. }
  7707. } elseif ($receiptDetail ['Rtype'] == 2) {
  7708. } else {
  7709. return '/receiptburEdi/' . $receiptDetail ['rid'];
  7710. }
  7711. }
  7712. die ( 'illegal request' );
  7713. }
  7714. function personalCollect() {
  7715. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7716. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  7717. $this->showCache ( $path );
  7718. Doo::loadModel ( "receiptDetail" );
  7719. Doo::loadModel ( "itemStatistics" );
  7720. Doo::loadModel ( 'statistics' );
  7721. $statistics = new statistics ();
  7722. $itemStatistics = new itemStatistics ();
  7723. $receiptDetail = new receiptDetail ();
  7724. $receiptCollectList = $receiptDetail->find ( array (
  7725. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7726. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7727. 'groupby' => 'itemCategory,Month(date)',
  7728. 'asArray' => true
  7729. ) );
  7730. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  7731. 'where' => 'staff=' . $this->staff [0] ['sid'],
  7732. 'asArray' => true
  7733. ) );
  7734. // create collect html
  7735. $collectArray = array (
  7736. '日常相关费用' => array (),
  7737. '差旅相关费用' => array (),
  7738. '培训班费用' => array (),
  7739. '其他' => array ()
  7740. );
  7741. $adjustment = array ();
  7742. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  7743. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7744. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  7745. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7746. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  7747. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7748. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  7749. array_push ( $collectArray ['其他'], $collectHtml );
  7750. $data ['collectArray'] = $collectArray;
  7751. // statistics html
  7752. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7753. if (empty ( $stList ))
  7754. $stList = array (
  7755. 'rePrice' => 0,
  7756. 'agPrice' => 0
  7757. );
  7758. $data ['stList'] = array (
  7759. 'rePrice' => $stList ['rePrice'],
  7760. 'agPrice' => $stList ['agPrice'],
  7761. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7762. );
  7763. // Adjustment price html
  7764. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7765. array_push ( $adjustment, $collectHtml );
  7766. $data ['adjustment'] = $adjustment;
  7767. // total price html
  7768. $collectHtml = "";
  7769. $total = 0;
  7770. for($i = 1; $i <= 12; $i ++) {
  7771. $sumPrice = 0;
  7772. foreach ( $receiptCollectList as $key => $value ) {
  7773. if ($value ['month'] == $i) {
  7774. $sumPrice += $value ['price'];
  7775. }
  7776. }
  7777. if ($sumPrice == 0)
  7778. $collectHtml .= '<td class="taR">-</td>';
  7779. else
  7780. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7781. $total += $sumPrice;
  7782. }
  7783. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7784. $data ['totalPrice'] = $collectHtml;
  7785. $data ['year'] = $year;
  7786. $data ['totalYear'] = $total;
  7787. $data ['memu'] = "receipt";
  7788. $data ['staff'] = $this->staff;
  7789. $data ['receiptMemu'] = 'personalCollect';
  7790. $data ['verifyId'] = $this->verifyId;
  7791. $data ['executeId'] = $this->executeId;
  7792. // year staff status 2,4
  7793. if ($year < date ( "Y" )) {
  7794. Doo::loadModel ( 'receipt' );
  7795. $receipt = new receipt ();
  7796. $receiptList = $receipt->find ( array (
  7797. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7798. 'asArray' => true
  7799. ) );
  7800. if (empty ( $receiptList )) {
  7801. ob_start ();
  7802. $this->render ( "/admin/saea_slist_collect", $data );
  7803. $this->cacheFile ( $path );
  7804. die ();
  7805. }
  7806. }
  7807. $this->render ( "/admin/saea_slist_collect", $data );
  7808. }
  7809. function personalCollectDetail() {
  7810. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7811. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  7812. $this->showCache ( $path );
  7813. Doo::loadModel ( "receiptDetail" );
  7814. Doo::loadModel ( "itemStatistics" );
  7815. Doo::loadModel ( 'statistics' );
  7816. Doo::loadModel ( 'accountItem' );
  7817. $accountItem = new accountItem ();
  7818. $statistics = new statistics ();
  7819. $itemStatistics = new itemStatistics ();
  7820. $receiptDetail = new receiptDetail ();
  7821. $receiptCollectList = $receiptDetail->find ( array (
  7822. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  7823. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7824. 'groupby' => 'item,Month(date)',
  7825. 'asArray' => true
  7826. ) );
  7827. $accountList = $accountItem->find ( array (
  7828. 'asArray' => true
  7829. ) );
  7830. // create CollectDetail HTML
  7831. $collectHtml = array ();
  7832. foreach ( $accountList as $key => $value ) {
  7833. $html = "";
  7834. $asum = 0;
  7835. for($i = 1; $i <= 12; $i ++) {
  7836. $falg = true;
  7837. foreach ( $receiptCollectList as $v ) {
  7838. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7839. $asum += $v ['price'];
  7840. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7841. $falg = false;
  7842. break;
  7843. }
  7844. }
  7845. if ($falg)
  7846. $html .= '<td class="taR">-</td>';
  7847. }
  7848. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7849. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7850. }
  7851. $data ['collectHtml'] = $collectHtml;
  7852. // create Adjustment price html
  7853. $receiptCollectList = $receiptDetail->find ( array (
  7854. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7855. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7856. 'groupby' => 'itemCategory,Month(date)',
  7857. 'asArray' => true
  7858. ) );
  7859. $adjustment = array ();
  7860. $collectArray = array (
  7861. '日常相关费用' => array (),
  7862. '差旅相关费用' => array (),
  7863. '培训班费用' => array (),
  7864. '其他' => array ()
  7865. );
  7866. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7867. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7868. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7869. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7870. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7871. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7872. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7873. array_push ( $collectArray ['其他'], $collectHtml );
  7874. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7875. array_push ( $adjustment, $collectHtml );
  7876. // total price html
  7877. $collectHtml = "";
  7878. $total = 0;
  7879. for($i = 1; $i <= 12; $i ++) {
  7880. $sumPrice = 0;
  7881. foreach ( $receiptCollectList as $key => $value ) {
  7882. if ($value ['month'] == $i) {
  7883. $sumPrice += $value ['price'];
  7884. }
  7885. }
  7886. if ($sumPrice == 0)
  7887. $collectHtml .= '<td class="taR">-</td>';
  7888. else
  7889. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7890. $total += $sumPrice;
  7891. }
  7892. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7893. // statistics html
  7894. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7895. if (empty ( $stList ))
  7896. $stList = array (
  7897. 'rePrice' => 0,
  7898. 'agPrice' => 0
  7899. );
  7900. $data ['stList'] = array (
  7901. 'rePrice' => $stList ['rePrice'],
  7902. 'agPrice' => $stList ['agPrice'],
  7903. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7904. );
  7905. $data ['collectArray'] = $collectArray;
  7906. $data ['adjustment'] = $adjustment;
  7907. $data ['totalPrice'] = $collectHtml;
  7908. $data ['totalYear'] = $total;
  7909. $data ['year'] = $year;
  7910. $data ['memu'] = "receipt";
  7911. $data ['staff'] = $this->staff;
  7912. $data ['receiptMemu'] = 'personalCollect';
  7913. $data ['verifyId'] = $this->verifyId;
  7914. $data ['executeId'] = $this->executeId;
  7915. // year staff status 2,4
  7916. if ($year < date ( "Y" )) {
  7917. Doo::loadModel ( 'receipt' );
  7918. $receipt = new receipt ();
  7919. $receiptList = $receipt->find ( array (
  7920. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7921. 'asArray' => true
  7922. ) );
  7923. if (empty ( $receiptList )) {
  7924. ob_start ();
  7925. $this->render ( "/admin/saeaCollectArticles", $data );
  7926. $this->cacheFile ( $path );
  7927. die ();
  7928. }
  7929. }
  7930. $this->render ( "/admin/saeaCollectArticles", $data );
  7931. }
  7932. function companyCategoryCollect() {
  7933. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7934. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  7935. $this->showCache ( $path );
  7936. Doo::loadModel ( 'L_category' );
  7937. Doo::loadModel ( 'itemStatistics' );
  7938. Doo::loadModel ( 'statistics' );
  7939. $statistics = new statistics ();
  7940. $Lcategory = new L_category ();
  7941. $itemStatistics = new itemStatistics ();
  7942. $LcategoryList = $Lcategory->find ( array (
  7943. 'asArray' => true
  7944. ) ); // 'staff='.$this->staff[0]['sid']." and
  7945. $itemStatisticsList = $itemStatistics->find ( array (
  7946. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7947. 'where' => " Year(date)=" . $year,
  7948. 'groupby' => 'cid,Month(date)',
  7949. 'asArray' => true
  7950. ) );
  7951. // ceatre companyCollectHtml
  7952. foreach ( $LcategoryList as $value ) {
  7953. $html = "";
  7954. $asum = 0;
  7955. for($i = 1; $i <= 12; $i ++) {
  7956. $falg = true;
  7957. foreach ( $itemStatisticsList as $v ) {
  7958. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  7959. $asum += $v ['price'];
  7960. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7961. $falg = false;
  7962. break;
  7963. }
  7964. }
  7965. if ($falg)
  7966. $html .= '<td class="taR">-</td>';
  7967. }
  7968. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7969. $collectHtml [$value ['title']] = array (
  7970. 'html' => $html,
  7971. 'cid' => $value ['cid']
  7972. );
  7973. }
  7974. $data ['companyHtml'] = $collectHtml;
  7975. // total price html
  7976. $collectHtml = "";
  7977. $total = 0;
  7978. for($i = 1; $i <= 12; $i ++) {
  7979. $sumPrice = 0;
  7980. foreach ( $itemStatisticsList as $key => $value ) {
  7981. if ($value ['month'] == $i) {
  7982. $sumPrice += $value ['price'];
  7983. }
  7984. }
  7985. if ($sumPrice == 0)
  7986. $collectHtml .= '<td class="taR">-</td>';
  7987. else
  7988. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7989. $total += $sumPrice;
  7990. }
  7991. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7992. $data ['companyTotalHtml'] = $collectHtml;
  7993. $data ['total'] = $total;
  7994. // statistics html
  7995. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7996. if (empty ( $stList ))
  7997. $stList = array (
  7998. 'rePrice' => 0,
  7999. 'agPrice' => 0
  8000. );
  8001. $data ['stList'] = array (
  8002. 'rePrice' => $stList ['rePrice'],
  8003. 'agPrice' => $stList ['agPrice'],
  8004. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8005. );
  8006. $data ['year'] = $year;
  8007. $data ['memu'] = "receipt";
  8008. $data ['staff'] = $this->staff;
  8009. $data ['receiptMemu'] = 'companyCategoryCollect';
  8010. $data ['verifyId'] = $this->verifyId;
  8011. $data ['executeId'] = $this->executeId;
  8012. // year staff status 2,4
  8013. if ($year < date ( "Y" )) {
  8014. Doo::loadModel ( 'receipt' );
  8015. $receipt = new receipt ();
  8016. $receiptList = $receipt->find ( array (
  8017. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  8018. 'asArray' => true
  8019. ) );
  8020. if (empty ( $receiptList )) {
  8021. ob_start ();
  8022. $this->render ( "/admin/saeaCompanyCollect", $data );
  8023. $this->cacheFile ( $path );
  8024. die ();
  8025. }
  8026. }
  8027. $this->render ( "/admin/saeaCompanyCollect", $data );
  8028. }
  8029. function categoryCollectDetail() {
  8030. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8031. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  8032. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  8033. $this->showCache ( $path );
  8034. Doo::loadModel ( 'statistics' );
  8035. $statistics = new statistics ();
  8036. Doo::loadModel ( "receiptDetail" );
  8037. $receiptDetail = new receiptDetail ();
  8038. Doo::loadModel ( 'L_category' );
  8039. $Lcategory = new L_category ();
  8040. Doo::loadModel ( 'accountItem' );
  8041. $accountItem = new accountItem ();
  8042. $LcategoryList = $Lcategory->find ( array (
  8043. 'asArray' => true
  8044. ) );
  8045. if ($cid == 0) {
  8046. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  8047. if ($cid == 0)
  8048. $cid = $LcategoryList [0] ['cid'];
  8049. }
  8050. $data ['LcategoryList'] = $LcategoryList;
  8051. $receiptCollectList = $receiptDetail->find ( array (
  8052. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8053. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  8054. 'groupby' => 'item,Month(pastDate)',
  8055. 'asArray' => true
  8056. ) );
  8057. $accountList = $accountItem->find ( array (
  8058. 'asArray' => true
  8059. ) );
  8060. // create CollectDetail HTML
  8061. $collectHtml = array ();
  8062. foreach ( $accountList as $key => $value ) {
  8063. $html = "";
  8064. $asum = 0;
  8065. for($i = 1; $i <= 12; $i ++) {
  8066. $falg = true;
  8067. foreach ( $receiptCollectList as $v ) {
  8068. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  8069. $asum += $v ['price'];
  8070. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8071. $falg = false;
  8072. break;
  8073. }
  8074. }
  8075. if ($falg)
  8076. $html .= '<td class="taR">-</td>';
  8077. }
  8078. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8079. $collectHtml [$value ['category']] [$value ['name']] = $html;
  8080. }
  8081. $data ['collectHtml'] = $collectHtml;
  8082. // create Adjustment price html
  8083. $receiptCollectList = $receiptDetail->find ( array (
  8084. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  8085. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  8086. 'groupby' => 'itemCategory,Month(pastDate)',
  8087. 'asArray' => true
  8088. ) );
  8089. $adjustment = array ();
  8090. $collectArray = array (
  8091. '日常相关费用' => array (),
  8092. '差旅相关费用' => array (),
  8093. '培训班费用' => array (),
  8094. '其他' => array ()
  8095. );
  8096. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  8097. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  8098. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  8099. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  8100. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  8101. array_push ( $collectArray ['培训班费用'], $collectHtml );
  8102. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  8103. array_push ( $collectArray ['其他'], $collectHtml );
  8104. $data ['collectArray'] = $collectArray;
  8105. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  8106. array_push ( $adjustment, $collectHtml );
  8107. $data ['adjustment'] = $adjustment;
  8108. // total price html
  8109. $collectHtml = "";
  8110. $total = 0;
  8111. for($i = 1; $i <= 12; $i ++) {
  8112. $sumPrice = 0;
  8113. foreach ( $receiptCollectList as $key => $value ) {
  8114. if ($value ['month'] == $i) {
  8115. $sumPrice += $value ['price'];
  8116. }
  8117. }
  8118. if ($sumPrice == 0)
  8119. $collectHtml .= '<td class="taR">-</td>';
  8120. else
  8121. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8122. $total += $sumPrice;
  8123. }
  8124. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8125. // statistics html
  8126. $stList = $statistics->statisticsByCid ( $year, $cid );
  8127. if (empty ( $stList ))
  8128. $stList = array (
  8129. 'rePrice' => 0,
  8130. 'agPrice' => 0
  8131. );
  8132. $data ['stList'] = array (
  8133. 'rePrice' => $stList ['rePrice'],
  8134. 'agPrice' => $stList ['agPrice'],
  8135. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8136. );
  8137. $data ['totalYear'] = $total;
  8138. $data ['year'] = $year;
  8139. $data ['cid'] = $cid;
  8140. $data ['memu'] = "receipt";
  8141. $data ['staff'] = $this->staff;
  8142. $data ['receiptMemu'] = 'companyCategoryCollect';
  8143. $data ['verifyId'] = $this->verifyId;
  8144. $data ['executeId'] = $this->executeId;
  8145. // year staff status 2,4
  8146. if ($year < date ( "Y" )) {
  8147. Doo::loadModel ( 'receipt' );
  8148. $receipt = new receipt ();
  8149. $receiptList = $receipt->find ( array (
  8150. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  8151. 'asArray' => true
  8152. ) );
  8153. if (empty ( $receiptList )) {
  8154. ob_start ();
  8155. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  8156. $this->cacheFile ( $path );
  8157. die ();
  8158. }
  8159. }
  8160. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  8161. }
  8162. function staffCollect() {
  8163. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8164. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  8165. // $this->showCache($path);
  8166. Doo::loadModel ( 'statistics' );
  8167. $statistics = new statistics ();
  8168. Doo::loadModel ( "receiptDetail" );
  8169. $receiptDetail = new receiptDetail ();
  8170. Doo::loadModel ( 'L_category' );
  8171. $Lcategory = new L_category ();
  8172. Doo::loadModel ( 'accountItem' );
  8173. $accountItem = new accountItem ();
  8174. Doo::loadModel ( 'staff' );
  8175. $staff = new staff ();
  8176. Doo::loadModel ( 'itemStatistics' );
  8177. $itemStatistics = new itemStatistics ();
  8178. // statistics html
  8179. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  8180. if (empty ( $stList ))
  8181. $stList = array (
  8182. 'rePrice' => 0,
  8183. 'agPrice' => 0
  8184. );
  8185. $data ['stList'] = array (
  8186. 'rePrice' => $stList ['rePrice'],
  8187. 'agPrice' => $stList ['agPrice'],
  8188. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8189. );
  8190. // ---
  8191. $staffList = $staff->find ( array (
  8192. 'where' => 'username !="admin"',
  8193. 'asArray' => true
  8194. ) );
  8195. $LcategoryList = $Lcategory->find ( array (
  8196. 'asArray' => true
  8197. ) ); // 'staff='.$this->staff[0]['sid']." and
  8198. $itemStatisticsList = $itemStatistics->find ( array (
  8199. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8200. 'where' => " Year(date)=" . $year,
  8201. 'groupby' => 'staff,Month(date)',
  8202. 'asArray' => true
  8203. ) );
  8204. $categoryList = $staff->find ( array (
  8205. 'select' => 'COUNT(*) as count,cid,category',
  8206. 'where' => 'username !="admin"',
  8207. 'groupby' => 'cid',
  8208. 'asArray' => true
  8209. ) );
  8210. // print_r($itemStatisticsList);die;
  8211. // ceatre companyCollectHtml
  8212. foreach ( $categoryList as $vlu ) {
  8213. $count = $vlu ['count'] + 1;
  8214. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  8215. $m1 = 0;
  8216. $m2 = 0;
  8217. $m3 = 0;
  8218. $m4 = 0;
  8219. $m5 = 0;
  8220. $m6 = 0;
  8221. $m7 = 0;
  8222. $m8 = 0;
  8223. $m9 = 0;
  8224. $m10 = 0;
  8225. $m11 = 0;
  8226. $m12 = 0;
  8227. $m13 = 0;
  8228. foreach ( $staffList as $value ) {
  8229. if ($vlu ['cid'] == $value ['cid']) {
  8230. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  8231. $asum = 0;
  8232. for($i = 1; $i <= 12; $i ++) {
  8233. $falg = true;
  8234. foreach ( $itemStatisticsList as $v ) {
  8235. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  8236. if ($v ['month'] == 1)
  8237. $m1 += $v ['price'];
  8238. if ($v ['month'] == 2)
  8239. $m2 += $v ['price'];
  8240. if ($v ['month'] == 3)
  8241. $m3 += $v ['price'];
  8242. if ($v ['month'] == 4)
  8243. $m4 += $v ['price'];
  8244. if ($v ['month'] == 5)
  8245. $m5 += $v ['price'];
  8246. if ($v ['month'] == 6)
  8247. $m6 += $v ['price'];
  8248. if ($v ['month'] == 7)
  8249. $m7 += $v ['price'];
  8250. if ($v ['month'] == 8)
  8251. $m8 += $v ['price'];
  8252. if ($v ['month'] == 9)
  8253. $m9 += $v ['price'];
  8254. if ($v ['month'] == 10)
  8255. $m10 += $v ['price'];
  8256. if ($v ['month'] == 11)
  8257. $m11 += $v ['price'];
  8258. if ($v ['month'] == 12)
  8259. $m12 += $v ['price'];
  8260. $asum += $v ['price'];
  8261. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8262. $falg = false;
  8263. break;
  8264. }
  8265. }
  8266. if ($falg)
  8267. $html .= '<td class="taR">-</td>';
  8268. }
  8269. $m13 += $asum;
  8270. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8271. $collectHtml [$value ['username'] . '_' . $value ['sid']] = array (
  8272. 'html' => $html,
  8273. 'sid' => $value ['sid']
  8274. );
  8275. $html = "";
  8276. }
  8277. }
  8278. $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>
  8279. <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>
  8280. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  8281. $collectHtml [$vlu ['cid']] = array (
  8282. 'html' => $hl,
  8283. 'sid' => ''
  8284. );
  8285. }
  8286. $data ['companyHtml'] = $collectHtml;
  8287. // total price html
  8288. $collectHtml = "";
  8289. $total = 0;
  8290. for($i = 1; $i <= 12; $i ++) {
  8291. $sumPrice = 0;
  8292. foreach ( $itemStatisticsList as $key => $value ) {
  8293. if ($value ['month'] == $i) {
  8294. $sumPrice += $value ['price'];
  8295. }
  8296. }
  8297. if ($sumPrice == 0)
  8298. $collectHtml .= '<td class="taR">-</td>';
  8299. else
  8300. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8301. $total += $sumPrice;
  8302. }
  8303. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8304. $data ['companyTotalHtml'] = $collectHtml;
  8305. $data ['total'] = $total;
  8306. $data ['year'] = $year;
  8307. $data ['memu'] = "receipt";
  8308. $data ['staff'] = $this->staff;
  8309. $data ['receiptMemu'] = 'companyCategoryCollect';
  8310. $data ['verifyId'] = $this->verifyId;
  8311. $data ['executeId'] = $this->executeId;
  8312. if ($year <= date ( "Y" )) {
  8313. Doo::loadModel ( 'receipt' );
  8314. $receipt = new receipt ();
  8315. $receiptList = $receipt->find ( array (
  8316. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  8317. 'asArray' => true
  8318. ) );
  8319. if (empty ( $receiptList )) { // generated files
  8320. ob_start ();
  8321. $this->render ( "/admin/saeaStaffCollectB", $data );
  8322. $this->cacheFile ( $path );
  8323. die ();
  8324. }
  8325. }
  8326. $this->render ( "/admin/saeaStaffCollectB", $data );
  8327. }
  8328. function staffCollectBak() {
  8329. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8330. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  8331. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  8332. $this->showCache ( $path );
  8333. Doo::loadModel ( 'statistics' );
  8334. $statistics = new statistics ();
  8335. Doo::loadModel ( "receiptDetail" );
  8336. $receiptDetail = new receiptDetail ();
  8337. Doo::loadModel ( 'L_category' );
  8338. $Lcategory = new L_category ();
  8339. Doo::loadModel ( 'accountItem' );
  8340. $accountItem = new accountItem ();
  8341. Doo::loadModel ( 'staff' );
  8342. $staff = new staff ();
  8343. Doo::loadModel ( 'itemStatistics' );
  8344. $itemStatistics = new itemStatistics ();
  8345. $itemStatisticsList = $itemStatistics->find ( array (
  8346. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8347. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8348. 'groupby' => 'staff,itemCategory,Month(date)',
  8349. 'asArray' => true
  8350. ) );
  8351. $itemCategoryList = $itemStatistics->find ( array (
  8352. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8353. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8354. 'groupby' => 'cid,itemCategory,Month(date)',
  8355. 'asArray' => true
  8356. ) );
  8357. $LcategoryList = $Lcategory->find ( array (
  8358. 'asArray' => true
  8359. ) );
  8360. $staffList = $staff->find ( array (
  8361. 'asArray' => true
  8362. ) );
  8363. $htmlArray = array ();
  8364. foreach ( $LcategoryList as $value ) {
  8365. $htmlArray [$value ['title']] = array ();
  8366. foreach ( $staffList as $v ) {
  8367. if ($value ['cid'] == $v ['cid']) {
  8368. $html = "";
  8369. $falg = true;
  8370. $staffSumPrice = 0;
  8371. foreach ( $itemStatisticsList as $a ) {
  8372. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  8373. if (empty ( $a ['price'] )) {
  8374. $html .= '<td class="taR">-</td>';
  8375. $falg = false;
  8376. break;
  8377. } else {
  8378. $staffSumPrice += $a ['price'];
  8379. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8380. $falg = false;
  8381. break;
  8382. }
  8383. }
  8384. }
  8385. if ($falg) {
  8386. $html .= '<td class="taR">-</td>';
  8387. $falg = true;
  8388. }
  8389. $falg = true;
  8390. foreach ( $itemStatisticsList as $a ) {
  8391. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  8392. if (empty ( $a ['price'] )) {
  8393. $html .= '<td class="taR">-</td>';
  8394. $falg = false;
  8395. break;
  8396. } else {
  8397. $staffSumPrice += $a ['price'];
  8398. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8399. $falg = false;
  8400. break;
  8401. }
  8402. }
  8403. }
  8404. if ($falg) {
  8405. $html .= '<td class="taR">-</td>';
  8406. $falg = true;
  8407. }
  8408. $falg = true;
  8409. foreach ( $itemStatisticsList as $a ) {
  8410. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  8411. if (empty ( $a ['price'] )) {
  8412. $html .= '<td class="taR">-</td>';
  8413. $falg = false;
  8414. break;
  8415. } else {
  8416. $staffSumPrice += $a ['price'];
  8417. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8418. $falg = false;
  8419. break;
  8420. }
  8421. }
  8422. }
  8423. if ($falg) {
  8424. $html .= '<td class="taR">-</td>';
  8425. $falg = true;
  8426. }
  8427. $falg = true;
  8428. foreach ( $itemStatisticsList as $a ) {
  8429. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  8430. if (! empty ( $a ['price'] )) {
  8431. $staffSumPrice += $a ['price'];
  8432. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8433. $falg = false;
  8434. break;
  8435. } else {
  8436. $html .= '<td class="taR">-</td>';
  8437. $falg = false;
  8438. break;
  8439. }
  8440. }
  8441. }
  8442. if ($falg) {
  8443. $html .= '<td class="taR">-</td>';
  8444. $falg = true;
  8445. }
  8446. $falg = true;
  8447. foreach ( $itemStatisticsList as $a ) {
  8448. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  8449. if (! empty ( $a ['price'] )) {
  8450. $staffSumPrice += $a ['price'];
  8451. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8452. $falg = false;
  8453. break;
  8454. } else {
  8455. $html .= '<td class="taR">-</td>';
  8456. $falg = false;
  8457. break;
  8458. }
  8459. }
  8460. }
  8461. if ($falg) {
  8462. $html .= '<td class="taR">-</td>';
  8463. $falg = true;
  8464. }
  8465. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  8466. $htmlArray [$value ['title']] [$v ['username']] = $html;
  8467. }
  8468. }
  8469. /* -- --- */
  8470. // 合计费用
  8471. $cateHtml = "";
  8472. $catePrice = 0;
  8473. $cateFalg = true;
  8474. foreach ( $itemCategoryList as $l ) {
  8475. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  8476. if (empty ( $l ['price'] )) {
  8477. $cateHtml .= '<td class="colGreen taR">-</td>';
  8478. $cateFalg = false;
  8479. break;
  8480. } else {
  8481. $catePrice += $l ['price'];
  8482. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8483. $cateFalg = false;
  8484. break;
  8485. }
  8486. }
  8487. }
  8488. if ($cateFalg) {
  8489. $cateHtml .= '<td class="colGreen taR">-</td>';
  8490. $cateFalg = true;
  8491. }
  8492. $cateFalg = true;
  8493. foreach ( $itemCategoryList as $l ) {
  8494. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  8495. if (empty ( $l ['price'] )) {
  8496. $cateHtml .= '<td class="colGreen taR">-</td>';
  8497. $cateFalg = false;
  8498. break;
  8499. } else {
  8500. $catePrice += $l ['price'];
  8501. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8502. $cateFalg = false;
  8503. break;
  8504. }
  8505. }
  8506. }
  8507. if ($cateFalg) {
  8508. $cateHtml .= '<td class="colGreen taR">-</td>';
  8509. $cateFalg = true;
  8510. }
  8511. $cateFalg = true;
  8512. foreach ( $itemCategoryList as $l ) {
  8513. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  8514. if (empty ( $l ['price'] )) {
  8515. $cateHtml .= '<td class="colGreen taR">-</td>';
  8516. $cateFalg = false;
  8517. break;
  8518. } else {
  8519. $catePrice += $l ['price'];
  8520. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8521. $cateFalg = false;
  8522. break;
  8523. }
  8524. }
  8525. }
  8526. if ($cateFalg) {
  8527. $cateHtml .= '<td class="colGreen taR">-</td>';
  8528. $cateFalg = true;
  8529. }
  8530. $cateFalg = true;
  8531. foreach ( $itemCategoryList as $l ) {
  8532. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  8533. if (empty ( $l ['price'] )) {
  8534. $cateHtml .= '<td class="colGreen taR">-</td>';
  8535. $cateFalg = false;
  8536. break;
  8537. } else {
  8538. $catePrice += $l ['price'];
  8539. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8540. $cateFalg = false;
  8541. break;
  8542. }
  8543. }
  8544. }
  8545. if ($cateFalg) {
  8546. $cateHtml .= '<td class="colGreen taR">-</td>';
  8547. $cateFalg = true;
  8548. }
  8549. $cateFalg = true;
  8550. foreach ( $itemCategoryList as $l ) {
  8551. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  8552. if (empty ( $l ['price'] )) {
  8553. $cateHtml .= '<td class="colGreen taR">-</td>';
  8554. $cateFalg = false;
  8555. break;
  8556. } else {
  8557. $catePrice += $l ['price'];
  8558. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8559. $cateFalg = false;
  8560. break;
  8561. }
  8562. }
  8563. }
  8564. if ($cateFalg) {
  8565. $cateHtml .= '<td class="colGreen taR">-</td>';
  8566. $cateFalg = true;
  8567. }
  8568. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  8569. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  8570. /* -- --- */
  8571. }
  8572. // print_r($htmlArray);die;
  8573. $data ['htmlArray'] = $htmlArray;
  8574. // statistics html
  8575. $stList = $statistics->getOne ( array (
  8576. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8577. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8578. 'groupby' => 'Month(date)',
  8579. 'asArray' => true
  8580. ) );
  8581. if (empty ( $stList ))
  8582. $stList = array (
  8583. 'rePrice' => 0,
  8584. 'agPrice' => 0
  8585. );
  8586. $data ['stList'] = array (
  8587. 'rePrice' => $stList ['rePrice'],
  8588. 'agPrice' => $stList ['agPrice'],
  8589. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8590. );
  8591. $monthHtml = "";
  8592. for($i = 1; $i <= 12; $i ++) {
  8593. if ($i == $month)
  8594. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8595. else
  8596. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8597. }
  8598. $data ['monthHtml'] = $monthHtml;
  8599. $data ['year'] = $year;
  8600. $data ['month'] = $month;
  8601. $data ['memu'] = "receipt";
  8602. $data ['staff'] = $this->staff;
  8603. $data ['receiptMemu'] = 'companyCategoryCollect';
  8604. $data ['verifyId'] = $this->verifyId;
  8605. $data ['executeId'] = $this->executeId;
  8606. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  8607. Doo::loadModel ( 'receipt' );
  8608. $receipt = new receipt ();
  8609. $receiptList = $receipt->find ( array (
  8610. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  8611. 'asArray' => true
  8612. ) );
  8613. if (empty ( $receiptList )) { // generated files
  8614. ob_start ();
  8615. $this->render ( "/admin/saeaStaffCollect", $data );
  8616. $this->cacheFile ( $path );
  8617. die ();
  8618. }
  8619. }
  8620. $this->render ( "/admin/saeaStaffCollect", $data );
  8621. }
  8622. function lyt() {
  8623. Doo::loadModel ( "receiptDetail" );
  8624. $receiptDetail = new receiptDetail ();
  8625. $receiptCollectList = $receiptDetail->find ( array (
  8626. 'where' => 'status=1 ',
  8627. 'asArray' => true
  8628. ) );
  8629. foreach ( $receiptCollectList as $key => $value ) {
  8630. $receiptDetail = new receiptDetail ();
  8631. $receiptDetail->pastDate = $value ['date'];
  8632. $receiptDetail->update ( array (
  8633. 'where' => "rdid= '" . $value ['rdid'] . "'"
  8634. ) );
  8635. }
  8636. }
  8637. function staffCollectMonthDetail() {
  8638. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8639. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8640. if (! $year)
  8641. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8642. if (! $month)
  8643. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8644. Doo::loadModel ( 'staff' );
  8645. $staff = new staff ();
  8646. Doo::loadModel ( "receiptDetail" );
  8647. $receiptDetail = new receiptDetail ();
  8648. Doo::loadModel ( 'accountItem' );
  8649. $accountItem = new accountItem ();
  8650. Doo::loadModel ( 'statistics' );
  8651. $statistics = new statistics ();
  8652. Doo::loadModel ( 'L_category' );
  8653. $lCategory = new L_category ();
  8654. $staffList = $staff->find ( array (
  8655. 'where' => 'username!="admin"',
  8656. 'asArray' => true
  8657. ) );
  8658. $categoryList = $staff->find ( array (
  8659. 'select' => 'COUNT(*) as count,cid,category',
  8660. 'where' => 'username !="admin"',
  8661. 'groupby' => 'cid',
  8662. 'asArray' => true
  8663. ) );
  8664. $list = array ();
  8665. foreach ( $categoryList as $vlu ) {
  8666. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8667. $r1 = 0;
  8668. $r2 = 0;
  8669. $r3 = 0;
  8670. $r4 = 0;
  8671. $r5 = 0;
  8672. $r6 = 0;
  8673. $r7 = 0;
  8674. $r8 = 0;
  8675. $r9 = 0;
  8676. $r10 = 0;
  8677. $r11 = 0;
  8678. $r12 = 0;
  8679. $r13 = 0;
  8680. $r14 = 0;
  8681. $r15 = 0;
  8682. $r16 = 0;
  8683. $r17 = 0;
  8684. $r18 = 0;
  8685. $c1 = 0;
  8686. $c2 = 0;
  8687. $c3 = 0;
  8688. $c4 = 0;
  8689. $c5 = 0;
  8690. $c6 = 0;
  8691. $p1 = 0;
  8692. $p2 = 0;
  8693. $p3 = 0;
  8694. $p4 = 0;
  8695. $p5 = 0;
  8696. $p6 = 0;
  8697. $p7 = 0;
  8698. $p8 = 0;
  8699. $p9 = 0;
  8700. $t1 = 0;
  8701. $t2 = 0;
  8702. $t3 = 0;
  8703. $t4 = 0;
  8704. $t5 = 0;
  8705. $s1 = 0;
  8706. $m1 = 0;
  8707. foreach ( $staffList as $value ) {
  8708. if ($vlu ['cid'] == $value ['cid']) {
  8709. // pastDate
  8710. $receiptCollectList = $receiptDetail->find ( array (
  8711. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8712. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8713. 'groupby' => 'item,Month(pastDate),itemCategory',
  8714. 'asArray' => true
  8715. ) );
  8716. // if ($value['sid']==42){
  8717. // print_r($receiptCollectList);die;
  8718. // }
  8719. if (! empty ( $receiptCollectList )) {
  8720. $receiptL = array (
  8721. '日常相关费用' => array (),
  8722. '差旅相关费用' => array (),
  8723. '培训班费用' => array (),
  8724. '其他' => array ()
  8725. );
  8726. $html = "";
  8727. $psum = 0;
  8728. $item = array (
  8729. '市内交通费',
  8730. '市内出租费',
  8731. '办事处房租',
  8732. '电话费',
  8733. '水费',
  8734. '电费',
  8735. '办公费用',
  8736. '邮寄费',
  8737. '其他费用',
  8738. '车辆费用',
  8739. '广告费',
  8740. '团队建设费',
  8741. '物业管理费',
  8742. '宽带费',
  8743. '人员薪酬',
  8744. '公积金',
  8745. '社保'
  8746. );
  8747. foreach ( $item as $va ) {
  8748. $falg = true;
  8749. foreach ( $receiptCollectList as $v ) {
  8750. if ($v ['itemCategory'] == '日常相关费用') {
  8751. if ($v ['item'] == $va) {
  8752. if ($va == '市内交通费')
  8753. $r1 += $v ['price'];
  8754. if ($va == '市内出租费')
  8755. $r2 += $v ['price'];
  8756. if ($va == '办事处房租')
  8757. $r3 += $v ['price'];
  8758. if ($va == '电话费')
  8759. $r4 += $v ['price'];
  8760. if ($va == '水费')
  8761. $r5 += $v ['price'];
  8762. if ($va == '电费')
  8763. $r6 += $v ['price'];
  8764. if ($va == '办公费用')
  8765. $r7 += $v ['price'];
  8766. if ($va == '邮寄费')
  8767. $r8 += $v ['price'];
  8768. if ($va == '其他费用')
  8769. $r9 += $v ['price'];
  8770. if ($va == '车辆费用')
  8771. $r10 += $v ['price'];
  8772. if ($va == '广告费')
  8773. $r11 += $v ['price'];
  8774. if ($va == '团队建设费')
  8775. $r13 += $v ['price'];
  8776. if ($va == '物业管理费')
  8777. $r14 += $v ['price'];
  8778. if ($va == '宽带费')
  8779. $r15 += $v ['price'];
  8780. if ($va == '公积金')
  8781. $r16 += $v ['price'];
  8782. if ($va == '社保')
  8783. $r17 += $v ['price'];
  8784. if ($va == '人员薪酬')
  8785. $r18 += $v ['price'];
  8786. $psum += $v ['price'];
  8787. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8788. $falg = false;
  8789. break;
  8790. }
  8791. }
  8792. }
  8793. if ($falg)
  8794. $html .= '<td class="taR">-</td>';
  8795. }
  8796. $r12 += $psum;
  8797. if (! empty ( $psum ))
  8798. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8799. else
  8800. $psum = '<td class="colGreen taR">-</td>';
  8801. $receiptL ['日常相关费用'] = $psum . $html;
  8802. /* ----------------------------------- */
  8803. $html = "";
  8804. $psum = 0;
  8805. $item = array (
  8806. '往来交通费',
  8807. '市内交通费',
  8808. '出差住宿费',
  8809. '出差补助',
  8810. '其他费用'
  8811. );
  8812. foreach ( $item as $va ) {
  8813. $falg = true;
  8814. foreach ( $receiptCollectList as $v ) {
  8815. if ($v ['itemCategory'] == '差旅相关费用') {
  8816. if ($v ['item'] == $va) {
  8817. if ($va == '往来交通费')
  8818. $c1 += $v ['price'];
  8819. if ($va == '市内交通费')
  8820. $c2 += $v ['price'];
  8821. if ($va == '出差住宿费')
  8822. $c3 += $v ['price'];
  8823. if ($va == '出差补助')
  8824. $c4 += $v ['price'];
  8825. if ($va == '其他费用')
  8826. $c5 += $v ['price'];
  8827. $psum += $v ['price'];
  8828. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8829. $falg = false;
  8830. break;
  8831. }
  8832. }
  8833. }
  8834. if ($falg)
  8835. $html .= '<td class="taR">-</td>';
  8836. }
  8837. $c6 += $psum;
  8838. if (! empty ( $psum ))
  8839. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8840. else
  8841. $psum = '<td class="colGreen taR">-</td>';
  8842. $receiptL ['差旅相关费用'] = $psum . $html;
  8843. /* ------------------------------------- */
  8844. $html = "";
  8845. $psum = 0;
  8846. $item = array (
  8847. '场租费',
  8848. '薪酬',
  8849. '住宿费',
  8850. '交通费',
  8851. '餐饮费',
  8852. '办公费',
  8853. '公关费',
  8854. '其他'
  8855. );
  8856. foreach ( $item as $va ) {
  8857. $falg = true;
  8858. foreach ( $receiptCollectList as $v ) {
  8859. if ($v ['itemCategory'] == '培训班费用') {
  8860. if ($v ['item'] == $va) {
  8861. if ($va == '场租费')
  8862. $p1 += $v ['price'];
  8863. if ($va == '薪酬')
  8864. $p2 += $v ['price'];
  8865. if ($va == '住宿费')
  8866. $p3 += $v ['price'];
  8867. if ($va == '交通费')
  8868. $p4 += $v ['price'];
  8869. if ($va == '餐饮费')
  8870. $p5 += $v ['price'];
  8871. if ($va == '办公费')
  8872. $p6 += $v ['price'];
  8873. if ($va == '公关费')
  8874. $p7 += $v ['price'];
  8875. if ($va == '其他')
  8876. $p8 += $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. $p9 += $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. foreach ( $item as $va ) {
  8903. $falg = true;
  8904. foreach ( $receiptCollectList as $v ) {
  8905. if ($v ['itemCategory'] == '其他') {
  8906. // if ($value['sid']==42){
  8907. //
  8908. // echo var_dump($v['item']);
  8909. // echo var_dump($va);
  8910. // echo var_dump($v['item']==" ".$va);
  8911. // echo $v['item']."==".$va."/<br/>";
  8912. // //print_r( $receiptCollectList);//echo $va;
  8913. // }
  8914. if (trim ( $v ['item'] ) == $va) {
  8915. if ($va == '公关费')
  8916. $t1 += $v ['price'];
  8917. if ($va == '广告费') {
  8918. $t2 += $v ['price'];
  8919. }
  8920. if ($va == '借款')
  8921. $t3 += $v ['price'];
  8922. if ($va == '可自加费用')
  8923. $t4 += $v ['price'];
  8924. $psum += $v ['price'];
  8925. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8926. $falg = false;
  8927. break;
  8928. }
  8929. }
  8930. }
  8931. if ($falg)
  8932. $html .= '<td class="taR">-</td>';
  8933. }
  8934. $t5 += $psum;
  8935. if (! empty ( $psum ))
  8936. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8937. else
  8938. $psum = '<td class="colGreen taR">-</td>';
  8939. $receiptL ['其他'] = $psum . $html;
  8940. /* ------------------------------------- */
  8941. $html = "";
  8942. $psum = 0;
  8943. foreach ( $receiptCollectList as $v ) {
  8944. if ($v ['itemCategory'] == '报销金额调整') {
  8945. if (! empty ( $v ['price'] )) {
  8946. $psum += $v ['price'];
  8947. }
  8948. }
  8949. }
  8950. $s1 += $psum;
  8951. if (! empty ( $psum ))
  8952. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8953. else
  8954. $psum = '<td class="taR colOrange">-</td>';
  8955. $receiptL ['报销金额调整'] = $psum . $html;
  8956. } else {
  8957. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8958. <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>
  8959. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8960. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  8961. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8962. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8963. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8964. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8965. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  8966. }
  8967. $monthStaffPrice = $receiptDetail->find ( array (
  8968. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8969. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8970. 'groupby' => 'Month(pastDate)',
  8971. 'asArray' => true
  8972. ) );
  8973. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  8974. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  8975. $m1 += $monthStaffPrice [0] ['price'];
  8976. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  8977. } else
  8978. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  8979. $receiptL ['usernameEn'] = urlencode ( $value ['username'] );
  8980. $list [$value ['username']] = $receiptL;
  8981. }
  8982. }
  8983. $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>
  8984. <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>
  8985. <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>';
  8986. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  8987. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  8988. $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>
  8989. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  8990. $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>';
  8991. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  8992. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  8993. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  8994. }
  8995. $data ['list'] = $list;
  8996. // print_r($list);
  8997. $receiptCollectList = $receiptDetail->find ( array (
  8998. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8999. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9000. 'groupby' => 'item,Month(pastDate),itemCategory',
  9001. 'asArray' => true
  9002. ) );
  9003. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9004. // statistics html
  9005. $stList = $statistics->getOne ( array (
  9006. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9007. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9008. 'groupby' => 'Month(date)',
  9009. 'asArray' => true
  9010. ) );
  9011. if (empty ( $stList ))
  9012. $stList = array (
  9013. 'rePrice' => 0,
  9014. 'agPrice' => 0
  9015. );
  9016. $data ['stList'] = array (
  9017. 'rePrice' => $stList ['rePrice'],
  9018. 'agPrice' => $stList ['agPrice'],
  9019. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9020. );
  9021. $monthHtml = "";
  9022. for($i = 1; $i <= 12; $i ++) {
  9023. if ($i == $month)
  9024. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9025. else
  9026. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9027. }
  9028. $data ['monthHtml'] = $monthHtml;
  9029. $data ['year'] = $year;
  9030. $data ['month'] = $month;
  9031. $data ['memu'] = "receipt";
  9032. $data ['staff'] = $this->staff;
  9033. $data ['receiptMemu'] = 'companyCategoryCollect';
  9034. $data ['verifyId'] = $this->verifyId;
  9035. $data ['executeId'] = $this->executeId;
  9036. $this->render ( "/admin/staffCollectMonthDetail", $data );
  9037. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9038. }
  9039. function staffCollectMonthDetail2() {
  9040. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9041. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9042. if (! $year)
  9043. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9044. if (! $month)
  9045. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9046. Doo::loadModel ( 'staff' );
  9047. $staff = new staff ();
  9048. Doo::loadModel ( "receiptDetail" );
  9049. $receiptDetail = new receiptDetail ();
  9050. Doo::loadModel ( 'accountItem' );
  9051. $accountItem = new accountItem ();
  9052. Doo::loadModel ( 'statistics' );
  9053. $statistics = new statistics ();
  9054. Doo::loadModel ( 'L_category' );
  9055. $lCategory = new L_category ();
  9056. $staffList = $staff->find ( array (
  9057. 'where' => 'username!="admin"',
  9058. 'asArray' => true
  9059. ) );
  9060. $categoryList = $staff->find ( array (
  9061. 'select' => 'COUNT(*) as count,cid,category',
  9062. 'where' => 'username !="admin"',
  9063. 'groupby' => 'cid',
  9064. 'asArray' => true
  9065. ) );
  9066. $list = array ();
  9067. foreach ( $categoryList as $vlu ) {
  9068. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  9069. $r1 = 0;
  9070. $r2 = 0;
  9071. $r3 = 0;
  9072. $r4 = 0;
  9073. $r5 = 0;
  9074. $r6 = 0;
  9075. $r7 = 0;
  9076. $r8 = 0;
  9077. $r9 = 0;
  9078. $r10 = 0;
  9079. $r11 = 0;
  9080. $r12 = 0;
  9081. $r13 = 0;
  9082. $r14 = 0;
  9083. $r15 = 0;
  9084. $c1 = 0;
  9085. $c2 = 0;
  9086. $c3 = 0;
  9087. $c4 = 0;
  9088. $c5 = 0;
  9089. $c6 = 0;
  9090. $p1 = 0;
  9091. $p2 = 0;
  9092. $p3 = 0;
  9093. $p4 = 0;
  9094. $p5 = 0;
  9095. $p6 = 0;
  9096. $p7 = 0;
  9097. $p8 = 0;
  9098. $p9 = 0;
  9099. $t1 = 0;
  9100. $t2 = 0;
  9101. $t3 = 0;
  9102. $t4 = 0;
  9103. $t5 = 0;
  9104. $s1 = 0;
  9105. $m1 = 0;
  9106. foreach ( $staffList as $value ) {
  9107. if ($vlu ['cid'] == $value ['cid']) {
  9108. $receiptCollectList = $receiptDetail->find ( array (
  9109. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9110. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9111. 'groupby' => 'item,Month(date),itemCategory',
  9112. 'asArray' => true
  9113. ) );
  9114. if (! empty ( $receiptCollectList )) {
  9115. $receiptL = array (
  9116. '日常相关费用' => array (),
  9117. '差旅相关费用' => array (),
  9118. '培训班费用' => array (),
  9119. '其他' => array ()
  9120. );
  9121. $html = "";
  9122. $psum = 0;
  9123. $item = array (
  9124. '市内交通费',
  9125. '市内出租费',
  9126. '办事处房租',
  9127. '电话费',
  9128. '水费',
  9129. '电费',
  9130. '办公费用',
  9131. '邮寄费',
  9132. '其他费用',
  9133. '车辆费用',
  9134. '广告费',
  9135. '团队建设费',
  9136. '物业管理费',
  9137. '宽带费'
  9138. );
  9139. foreach ( $item as $va ) {
  9140. $falg = true;
  9141. foreach ( $receiptCollectList as $v ) {
  9142. if ($v ['itemCategory'] == '日常相关费用') {
  9143. if ($v ['item'] == $va) {
  9144. if ($va == '市内交通费')
  9145. $r1 += $v ['price'];
  9146. if ($va == '市内出租费')
  9147. $r2 += $v ['price'];
  9148. if ($va == '办事处房租')
  9149. $r3 += $v ['price'];
  9150. if ($va == '电话费')
  9151. $r4 += $v ['price'];
  9152. if ($va == '水费')
  9153. $r5 += $v ['price'];
  9154. if ($va == '电费')
  9155. $r6 += $v ['price'];
  9156. if ($va == '办公费用')
  9157. $r7 += $v ['price'];
  9158. if ($va == '邮寄费')
  9159. $r8 += $v ['price'];
  9160. if ($va == '其他费用')
  9161. $r9 += $v ['price'];
  9162. if ($va == '车辆费用')
  9163. $r10 += $v ['price'];
  9164. if ($va == '广告费')
  9165. $r11 += $v ['price'];
  9166. if ($va == '团队建设费')
  9167. $r13 += $v ['price'];
  9168. if ($va == '物业管理费')
  9169. $r14 += $v ['price'];
  9170. if ($va == '宽带费')
  9171. $r15 += $v ['price'];
  9172. $psum += $v ['price'];
  9173. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9174. $falg = false;
  9175. break;
  9176. }
  9177. }
  9178. }
  9179. if ($falg)
  9180. $html .= '<td class="taR">-</td>';
  9181. }
  9182. $r12 += $psum;
  9183. if (! empty ( $psum ))
  9184. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9185. else
  9186. $psum = '<td class="colGreen taR">-</td>';
  9187. $receiptL ['日常相关费用'] = $psum . $html;
  9188. /* ----------------------------------- */
  9189. $html = "";
  9190. $psum = 0;
  9191. $item = array (
  9192. '往来交通费',
  9193. '市内交通费',
  9194. '出差住宿费',
  9195. '出差补助',
  9196. '其他费用'
  9197. );
  9198. foreach ( $item as $va ) {
  9199. $falg = true;
  9200. foreach ( $receiptCollectList as $v ) {
  9201. if ($v ['itemCategory'] == '差旅相关费用') {
  9202. if ($v ['item'] == $va) {
  9203. if ($va == '往来交通费')
  9204. $c1 += $v ['price'];
  9205. if ($va == '市内交通费')
  9206. $c2 += $v ['price'];
  9207. if ($va == '出差住宿费')
  9208. $c3 += $v ['price'];
  9209. if ($va == '出差补助')
  9210. $c4 += $v ['price'];
  9211. if ($va == '其他费用')
  9212. $c5 += $v ['price'];
  9213. $psum += $v ['price'];
  9214. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9215. $falg = false;
  9216. break;
  9217. }
  9218. }
  9219. }
  9220. if ($falg)
  9221. $html .= '<td class="taR">-</td>';
  9222. }
  9223. $c6 += $psum;
  9224. if (! empty ( $psum ))
  9225. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9226. else
  9227. $psum = '<td class="colGreen taR">-</td>';
  9228. $receiptL ['差旅相关费用'] = $psum . $html;
  9229. /* ------------------------------------- */
  9230. $html = "";
  9231. $psum = 0;
  9232. $item = array (
  9233. '场租费',
  9234. '薪酬',
  9235. '住宿费',
  9236. '交通费',
  9237. '餐饮费',
  9238. '办公费',
  9239. '公关费',
  9240. '其他'
  9241. );
  9242. foreach ( $item as $va ) {
  9243. $falg = true;
  9244. foreach ( $receiptCollectList as $v ) {
  9245. if ($v ['itemCategory'] == '培训班费用') {
  9246. if ($v ['item'] == $va) {
  9247. if ($va == '场租费')
  9248. $p1 += $v ['price'];
  9249. if ($va == '薪酬')
  9250. $p2 += $v ['price'];
  9251. if ($va == '住宿费')
  9252. $p3 += $v ['price'];
  9253. if ($va == '交通费')
  9254. $p4 += $v ['price'];
  9255. if ($va == '餐饮费')
  9256. $p5 += $v ['price'];
  9257. if ($va == '办公费')
  9258. $p6 += $v ['price'];
  9259. if ($va == '公关费')
  9260. $p7 += $v ['price'];
  9261. if ($va == '其他')
  9262. $p8 += $v ['price'];
  9263. $psum += $v ['price'];
  9264. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9265. $falg = false;
  9266. break;
  9267. }
  9268. }
  9269. }
  9270. if ($falg)
  9271. $html .= '<td class="taR">-</td>';
  9272. }
  9273. $p9 += $psum;
  9274. if (! empty ( $psum ))
  9275. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9276. else
  9277. $psum = '<td class="colGreen taR">-</td>';
  9278. $receiptL ['培训班费用'] = $psum . $html;
  9279. /* ------------------------------------- */
  9280. $html = "";
  9281. $psum = 0;
  9282. $item = array (
  9283. '公关费',
  9284. '广告费',
  9285. '借款',
  9286. '可自加费用'
  9287. );
  9288. foreach ( $item as $va ) {
  9289. $falg = true;
  9290. foreach ( $receiptCollectList as $v ) {
  9291. if ($v ['itemCategory'] == '其他') {
  9292. if ($v ['item'] == $va) {
  9293. if ($va == '公关费')
  9294. $t1 += $v ['price'];
  9295. if ($va == '广告费')
  9296. $t2 += $v ['price'];
  9297. if ($va == '借款')
  9298. $t3 += $v ['price'];
  9299. if ($va == '可自加费用')
  9300. $t4 += $v ['price'];
  9301. $psum += $v ['price'];
  9302. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9303. $falg = false;
  9304. break;
  9305. }
  9306. }
  9307. }
  9308. if ($falg)
  9309. $html .= '<td class="taR">-</td>';
  9310. }
  9311. $t5 += $psum;
  9312. if (! empty ( $psum ))
  9313. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9314. else
  9315. $psum = '<td class="colGreen taR">-</td>';
  9316. $receiptL ['其他'] = $psum . $html;
  9317. /* ------------------------------------- */
  9318. $html = "";
  9319. $psum = 0;
  9320. foreach ( $receiptCollectList as $v ) {
  9321. if ($v ['itemCategory'] == '报销金额调整') {
  9322. if (! empty ( $v ['price'] )) {
  9323. $psum += $v ['price'];
  9324. }
  9325. }
  9326. }
  9327. $s1 += $psum;
  9328. if (! empty ( $psum ))
  9329. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9330. else
  9331. $psum = '<td class="taR colOrange">-</td>';
  9332. $receiptL ['报销金额调整'] = $psum . $html;
  9333. } else {
  9334. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9335. <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>';
  9336. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9337. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9338. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9339. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9340. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9341. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9342. }
  9343. $monthStaffPrice = $receiptDetail->find ( array (
  9344. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9345. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9346. 'asArray' => true
  9347. ) );
  9348. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  9349. $m1 += $monthStaffPrice [0] ['price'];
  9350. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9351. } else
  9352. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9353. $list [$value ['username']] = $receiptL;
  9354. }
  9355. }
  9356. $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>
  9357. <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>
  9358. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  9359. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  9360. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  9361. $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>
  9362. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  9363. $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>';
  9364. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  9365. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  9366. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  9367. }
  9368. $data ['list'] = $list;
  9369. $receiptCollectList = $receiptDetail->find ( array (
  9370. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9371. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9372. 'groupby' => 'item,Month(date),itemCategory',
  9373. 'asArray' => true
  9374. ) );
  9375. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9376. // statistics html
  9377. $stList = $statistics->getOne ( array (
  9378. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9379. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9380. 'groupby' => 'Month(date)',
  9381. 'asArray' => true
  9382. ) );
  9383. if (empty ( $stList ))
  9384. $stList = array (
  9385. 'rePrice' => 0,
  9386. 'agPrice' => 0
  9387. );
  9388. $data ['stList'] = array (
  9389. 'rePrice' => $stList ['rePrice'],
  9390. 'agPrice' => $stList ['agPrice'],
  9391. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9392. );
  9393. $monthHtml = "";
  9394. for($i = 1; $i <= 12; $i ++) {
  9395. if ($i == $month)
  9396. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9397. else
  9398. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9399. }
  9400. $data ['monthHtml'] = $monthHtml;
  9401. $data ['year'] = $year;
  9402. $data ['month'] = $month;
  9403. $data ['memu'] = "receipt";
  9404. $data ['staff'] = $this->staff;
  9405. $data ['receiptMemu'] = 'companyCategoryCollect';
  9406. $data ['verifyId'] = $this->verifyId;
  9407. $data ['executeId'] = $this->executeId;
  9408. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  9409. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9410. }
  9411. /**
  9412. * 用户报销单列表
  9413. */
  9414. function receiptStatisticsStaffDetail() {
  9415. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9416. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9417. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  9418. Doo::loadModel ( "receipt" );
  9419. $receipt = new receipt ();
  9420. Doo::loadModel ( "receiptDetail" );
  9421. $receiptDetail = new receiptDetail ();
  9422. Doo::loadModel ( 'staff' );
  9423. $staff = new staff ();
  9424. Doo::loadModel ( 'accountItem' );
  9425. $accountItem = new accountItem ();
  9426. Doo::loadModel ( 'statistics' );
  9427. $statistics = new statistics ();
  9428. if (! empty ( $username )) {
  9429. $username = addslashes ( urldecode ( $username ) );
  9430. $staffDetail = $staff->getStaffByName ( $username );
  9431. if (empty ( $staffDetail ))
  9432. die ( 'illegal request' );
  9433. $list = $receipt->getReceiptBySid ( $staffDetail ['sid'], $year, $month );
  9434. $itemList = $accountItem->getAccountItem ();
  9435. $itemHtml = '';
  9436. $categoryHtml = '';
  9437. $itemKeyList = array_keys ( $itemList );
  9438. $revisePrice=0;
  9439. // 报销单内容详情
  9440. foreach ( $list as $key => $value ) {
  9441. $accountItemList = json_decode ( $value ['accountItem'], true );
  9442. $list [$key] ['accountItemList'] = $accountItemList;
  9443. $receiptItemHtml = '';
  9444. foreach ( $itemKeyList as $v ) {
  9445. if ($v == '日常相关费用')
  9446. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['agencySum'] . '</td>';
  9447. elseif ($v == '差旅相关费用')
  9448. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['travelSum'] . '</td>';
  9449. elseif ($v == '培训班费用')
  9450. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['trainSum'] . '</td>';
  9451. elseif ($v == '其他')
  9452. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['otherSum'] . '</td>';
  9453. foreach ( $itemList [$v] as $ke => $va ) {
  9454. $falg = true;
  9455. if (! empty ( $accountItemList [$v] )) {
  9456. foreach ( $accountItemList [$v] as $ve ) {
  9457. if ($va ['name'] == $ve ['name']) {
  9458. $receiptItemHtml .= '<td class="taR">' . $ve ['price'] . '</td>';
  9459. $falg = false;
  9460. break;
  9461. }
  9462. }
  9463. }
  9464. if ($falg)
  9465. $receiptItemHtml .= '<td class="taR"></td>';
  9466. }
  9467. }
  9468. //金额调整和费用查看
  9469. $revisePrice+=$value ['revisePrice'];
  9470. $receiptItemHtml .= '<td class="taR">'.$value ['revisePrice'].'</td>';
  9471. $receiptItemHtml .= '<td class="taR"><a href="#detail" data-toggle="modal" onclick=showExplanation("'.$value ['explanation'].'")>查看</a></td>';
  9472. $list [$key] ['receiptItemHtml'] = $receiptItemHtml;
  9473. }
  9474. // 报销单合计
  9475. $receiptTotalList = $receiptDetail->getReceiptTotalItem ( $staffDetail ['sid'], $year, $month );
  9476. $rtl = $receiptDetail->getReceiptTotalItemCategory ( $staffDetail ['sid'], $year, $month );
  9477. $receiptTotalHtml = '';
  9478. // 报销单项目抬头
  9479. foreach ( $itemKeyList as $value ) {
  9480. $count = count ( $itemList [$value] ) + 1;
  9481. $itemHtml .= '<th class="taC" colspan="' . $count . '">' . $value . '</th>';
  9482. $categoryHtml .= '<th class="taC">合计</th>';
  9483. foreach ( $rtl as $rtlValue ) {
  9484. if ($rtlValue ['itemCategory'] == $value) {
  9485. $receiptTotalHtml .= '<th>' . $rtlValue ['price'] . '</th>';
  9486. break;
  9487. }
  9488. }
  9489. foreach ( $itemList [$value] as $k => $v ) {
  9490. $categoryHtml .= '<th class="taC">' . $v ['name'] . '</th>';
  9491. // 合计
  9492. $falg = true;
  9493. foreach ( $receiptTotalList as $ve ) {
  9494. if ($ve ['itemCategory'] == $value && $ve ['item'] == $v ['name']) {
  9495. $receiptTotalHtml .= '<th >' . $ve ['price'] . '</th>';
  9496. $falg = false;
  9497. break;
  9498. }
  9499. }
  9500. if ($falg)
  9501. $receiptTotalHtml .= '<th></th>';
  9502. }
  9503. }
  9504. $receiptTotalHtml .= '<th>'.$revisePrice.'</th>';
  9505. $stList = $statistics->getStatisticsBySid($staffDetail ['sid'], $year, $month);
  9506. if (empty ( $stList ))
  9507. $stList = array (
  9508. 'rePrice' => 0,
  9509. 'agPrice' => 0
  9510. );
  9511. $data ['stList'] = array (
  9512. 'rePrice' => $stList ['rePrice'],
  9513. 'agPrice' => $stList ['agPrice'],
  9514. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9515. );
  9516. $monthHtml = "";
  9517. for($i = 1; $i <= 12; $i ++) {
  9518. if ($i == $month)
  9519. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9520. else
  9521. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9522. }
  9523. $data ['username'] = urlencode ( $username );
  9524. $data ['usernameEN'] = $username ;
  9525. $data ['monthHtml'] = $monthHtml;
  9526. $data ['receiptTotalHtml'] = $receiptTotalHtml;
  9527. $data ['list'] = $list;
  9528. $data ['categoryHtml'] = $categoryHtml;
  9529. $data ['itemHtml'] = $itemHtml;
  9530. $data ['itemList'] = $itemList;
  9531. $data ['year'] = $year;
  9532. $data ['month'] = $month;
  9533. $data ['memu'] = "receipt";
  9534. $data ['staff'] = $this->staff;
  9535. $data ['receiptMemu'] = 'companyCategoryCollect';
  9536. $data ['verifyId'] = $this->verifyId;
  9537. $data ['executeId'] = $this->executeId;
  9538. $this->render ( "/admin/receiptStatisticsStaffDetail", $data );
  9539. }
  9540. die ( 'illegal request' );
  9541. }
  9542. function companyMonthCollectDetail() {
  9543. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9544. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9545. if (! $year)
  9546. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9547. if (! $month)
  9548. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9549. Doo::loadModel ( 'staff' );
  9550. $staff = new staff ();
  9551. Doo::loadModel ( "receiptDetail" );
  9552. $receiptDetail = new receiptDetail ();
  9553. Doo::loadModel ( 'accountItem' );
  9554. $accountItem = new accountItem ();
  9555. Doo::loadModel ( 'statistics' );
  9556. $statistics = new statistics ();
  9557. Doo::loadModel ( 'L_category' );
  9558. $lCategory = new L_category ();
  9559. $staffList = $staff->find ( array (
  9560. 'where' => 'username!="admin"',
  9561. 'asArray' => true
  9562. ) );
  9563. $categoryList = $lCategory->find ( array (
  9564. 'asArray' => true
  9565. ) );
  9566. $list = array ();
  9567. foreach ( $categoryList as $value ) {
  9568. $receiptCollectList = $receiptDetail->find ( array (
  9569. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9570. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9571. 'groupby' => 'item,Month(pastDate),itemCategory',
  9572. 'asArray' => true
  9573. ) );
  9574. if (! empty ( $receiptCollectList )) {
  9575. $receiptL = array (
  9576. '日常相关费用' => array (),
  9577. '差旅相关费用' => array (),
  9578. '培训班费用' => array (),
  9579. '其他' => array ()
  9580. );
  9581. $html = "";
  9582. $psum = 0;
  9583. $item = array (
  9584. '市内交通费',
  9585. '市内出租费',
  9586. '办事处房租',
  9587. '电话费',
  9588. '水费',
  9589. '电费',
  9590. '办公费用',
  9591. '邮寄费',
  9592. '其他费用',
  9593. '车辆费用',
  9594. '广告费',
  9595. '团队建设费'
  9596. );
  9597. foreach ( $item as $va ) {
  9598. $falg = true;
  9599. foreach ( $receiptCollectList as $v ) {
  9600. if ($v ['itemCategory'] == '日常相关费用') {
  9601. if ($v ['item'] == $va) {
  9602. $psum += $v ['price'];
  9603. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9604. $falg = false;
  9605. break;
  9606. }
  9607. }
  9608. }
  9609. if ($falg)
  9610. $html .= '<td class="taR">-</td>';
  9611. }
  9612. if (! empty ( $psum ))
  9613. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9614. else
  9615. $psum = '<td class="colGreen taR">-</td>';
  9616. $receiptL ['日常相关费用'] = $psum . $html;
  9617. /* ----------------------------------- */
  9618. $html = "";
  9619. $psum = 0;
  9620. $item = array (
  9621. '往来交通费',
  9622. '市内交通费',
  9623. '出差住宿费',
  9624. '出差补助',
  9625. '其他费用'
  9626. );
  9627. foreach ( $item as $va ) {
  9628. $falg = true;
  9629. foreach ( $receiptCollectList as $v ) {
  9630. if ($v ['itemCategory'] == '差旅相关费用') {
  9631. if ($v ['item'] == $va) {
  9632. $psum += $v ['price'];
  9633. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9634. $falg = false;
  9635. break;
  9636. }
  9637. }
  9638. }
  9639. if ($falg)
  9640. $html .= '<td class="taR">-</td>';
  9641. }
  9642. if (! empty ( $psum ))
  9643. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9644. else
  9645. $psum = '<td class="colGreen taR">-</td>';
  9646. $receiptL ['差旅相关费用'] = $psum . $html;
  9647. /* ------------------------------------- */
  9648. $html = "";
  9649. $psum = 0;
  9650. $item = array (
  9651. '场租费',
  9652. '薪酬',
  9653. '住宿费',
  9654. '交通费',
  9655. '餐饮费',
  9656. '办公费',
  9657. '公关费',
  9658. '其他'
  9659. );
  9660. foreach ( $item as $va ) {
  9661. $falg = true;
  9662. foreach ( $receiptCollectList as $v ) {
  9663. if ($v ['itemCategory'] == '培训班费用') {
  9664. if ($v ['item'] == $va) {
  9665. $psum += $v ['price'];
  9666. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9667. $falg = false;
  9668. break;
  9669. }
  9670. }
  9671. }
  9672. if ($falg)
  9673. $html .= '<td class="taR">-</td>';
  9674. }
  9675. if (! empty ( $psum ))
  9676. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9677. else
  9678. $psum = '<td class="colGreen taR">-</td>';
  9679. $receiptL ['培训班费用'] = $psum . $html;
  9680. /* ------------------------------------- */
  9681. $html = "";
  9682. $psum = 0;
  9683. $item = array (
  9684. '公关费',
  9685. '广告费',
  9686. '借款',
  9687. '可自加费用'
  9688. );
  9689. foreach ( $item as $va ) {
  9690. $falg = true;
  9691. foreach ( $receiptCollectList as $v ) {
  9692. if ($v ['itemCategory'] == '其他') {
  9693. if ($v ['item'] == $va) {
  9694. $psum += $v ['price'];
  9695. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9696. $falg = false;
  9697. break;
  9698. }
  9699. }
  9700. }
  9701. if ($falg)
  9702. $html .= '<td class="taR">-</td>';
  9703. }
  9704. if (! empty ( $psum ))
  9705. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9706. else
  9707. $psum = '<td class="colGreen taR">-</td>';
  9708. $receiptL ['其他'] = $psum . $html;
  9709. /* ------------------------------------- */
  9710. $html = "";
  9711. $psum = 0;
  9712. foreach ( $receiptCollectList as $v ) {
  9713. if ($v ['itemCategory'] == '报销金额调整') {
  9714. if (! empty ( $v ['price'] ))
  9715. $psum += $v ['price'];
  9716. }
  9717. }
  9718. if (! empty ( $psum ))
  9719. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9720. else
  9721. $psum = '<td class="taR colOrange">-</td>';
  9722. $receiptL ['报销金额调整'] = $psum . $html;
  9723. } else {
  9724. $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>
  9725. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9726. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9727. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9728. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9729. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9730. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9731. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9732. }
  9733. $monthStaffPrice = $receiptDetail->find ( array (
  9734. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9735. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9736. 'asArray' => true
  9737. ) );
  9738. if (! empty ( $monthStaffPrice [0] ['price'] ))
  9739. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9740. else
  9741. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9742. $list [$value ['title']] = $receiptL;
  9743. }
  9744. $data ['list'] = $list;
  9745. $receiptCollectList = $receiptDetail->find ( array (
  9746. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9747. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9748. 'groupby' => 'item,Month(pastDate),itemCategory',
  9749. 'asArray' => true
  9750. ) );
  9751. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9752. // print_r($data['monthPriceHtml']);
  9753. // foreach ($data['monthPriceHtml'] as $value){
  9754. // echo $value;
  9755. // }
  9756. // die;
  9757. // statistics html
  9758. $stList = $statistics->getOne ( array (
  9759. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9760. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9761. 'groupby' => 'Month(date)',
  9762. 'asArray' => true
  9763. ) );
  9764. if (empty ( $stList ))
  9765. $stList = array (
  9766. 'rePrice' => 0,
  9767. 'agPrice' => 0
  9768. );
  9769. $data ['stList'] = array (
  9770. 'rePrice' => $stList ['rePrice'],
  9771. 'agPrice' => $stList ['agPrice'],
  9772. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9773. );
  9774. $monthHtml = "";
  9775. for($i = 1; $i <= 12; $i ++) {
  9776. if ($i == $month)
  9777. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9778. else
  9779. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9780. }
  9781. $data ['monthHtml'] = $monthHtml;
  9782. $data ['year'] = $year;
  9783. $data ['month'] = $month;
  9784. $data ['memu'] = "receipt";
  9785. $data ['staff'] = $this->staff;
  9786. $data ['receiptMemu'] = 'companyCategoryCollect';
  9787. $data ['verifyId'] = $this->verifyId;
  9788. $data ['executeId'] = $this->executeId;
  9789. $this->render ( "/admin/companyMonthCollectDetail", $data );
  9790. }
  9791. function staffCollectDetail() {
  9792. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9793. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  9794. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  9795. if (! $staffname) {
  9796. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  9797. $staffname = urldecode ( $staffname );
  9798. }
  9799. Doo::loadModel ( 'staff' );
  9800. $staff = new staff ();
  9801. Doo::loadModel ( "receiptDetail" );
  9802. $receiptDetail = new receiptDetail ();
  9803. Doo::loadModel ( 'accountItem' );
  9804. $accountItem = new accountItem ();
  9805. Doo::loadModel ( 'statistics' );
  9806. $statistics = new statistics ();
  9807. Doo::loadModel ( 'L_category' );
  9808. $lCategory = new L_category ();
  9809. $staffList = $staff->find ( array (
  9810. 'asArray' => true
  9811. ) );
  9812. $stHtml = '';
  9813. $stTitle = "";
  9814. $staffId = 0;
  9815. $cid = 0;
  9816. $ocid = 0;
  9817. foreach ( $staffList as $value ) {
  9818. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  9819. $stTitle = $value ['category'] . '-' . $value ['username'];
  9820. $staffId = $value ['sid'];
  9821. $cid = $value ['cid'];
  9822. $ocid = $value ['cid'];
  9823. if (! empty ( $value ['othercid'] ))
  9824. $cid = $value ['cid'] . ',' . $value ['othercid'];
  9825. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9826. } elseif ($value ['username'] != 'admin')
  9827. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9828. }
  9829. $data ['lCategoryHtml'] = $lCategory->find ( array (
  9830. 'where' => 'cid in(' . $cid . ')',
  9831. 'asArray' => true
  9832. ) );
  9833. if (empty ( $pcid ))
  9834. $pcid = $ocid;
  9835. $data ['ocid'] = $pcid;
  9836. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  9837. $this->showCache ( $path );
  9838. //
  9839. $receiptCollectList = $receiptDetail->find ( array (
  9840. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9841. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9842. 'groupby' => 'item,Month(pastDate),itemCategory',
  9843. 'asArray' => true
  9844. ) );
  9845. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  9846. // print_r($receiptCollectList);
  9847. $accountList = $accountItem->find ( array (
  9848. 'asArray' => true
  9849. ) );
  9850. // create CollectDetail HTML
  9851. $collectHtml = array ();
  9852. foreach ( $accountList as $key => $value ) {
  9853. $html = "";
  9854. $asum = 0;
  9855. for($i = 1; $i <= 12; $i ++) {
  9856. $falg = true;
  9857. foreach ( $receiptCollectList as $v ) {
  9858. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9859. if ($v ['item'] == '可自加费用') {
  9860. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  9861. }
  9862. $asum += $v ['price'];
  9863. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9864. $falg = false;
  9865. break;
  9866. }
  9867. }
  9868. if ($falg)
  9869. $html .= '<td class="taR">-</td>';
  9870. }
  9871. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9872. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9873. }
  9874. $data ['collectHtml'] = $collectHtml;
  9875. // print_r($collectHtml);
  9876. // create Adjustment price html
  9877. $receiptCollectList = $receiptDetail->find ( array (
  9878. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9879. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9880. 'groupby' => 'itemCategory,Month(pastDate)',
  9881. 'asArray' => true
  9882. ) );
  9883. $adjustment = array ();
  9884. $collectArray = array (
  9885. '日常相关费用' => array (),
  9886. '差旅相关费用' => array (),
  9887. '培训班费用' => array (),
  9888. '其他' => array ()
  9889. );
  9890. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9891. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9892. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9893. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9894. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9895. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9896. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9897. array_push ( $collectArray ['其他'], $collectHtml );
  9898. $data ['collectArray'] = $collectArray;
  9899. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9900. array_push ( $adjustment, $collectHtml );
  9901. $data ['adjustment'] = $adjustment;
  9902. // total price html
  9903. $collectHtml = "";
  9904. $total = 0;
  9905. for($i = 1; $i <= 12; $i ++) {
  9906. $sumPrice = 0;
  9907. foreach ( $receiptCollectList as $key => $value ) {
  9908. if ($value ['month'] == $i) {
  9909. $sumPrice += $value ['price'];
  9910. }
  9911. }
  9912. if ($sumPrice == 0)
  9913. $collectHtml .= '<td class="taR">-</td>';
  9914. else
  9915. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9916. $total += $sumPrice;
  9917. }
  9918. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9919. // statistics html
  9920. $stList = $statistics->statisticsByYear ( $year, $staffId );
  9921. if (empty ( $stList ))
  9922. $stList = array (
  9923. 'rePrice' => 0,
  9924. 'agPrice' => 0
  9925. );
  9926. $data ['stList'] = array (
  9927. 'rePrice' => $stList ['rePrice'],
  9928. 'agPrice' => $stList ['agPrice'],
  9929. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9930. );
  9931. $data ['totalPrice'] = $collectHtml;
  9932. $data ['totalYear'] = $total;
  9933. $data ['stHtml'] = $stHtml;
  9934. $data ['year'] = $year;
  9935. $data ['stTitle'] = $stTitle;
  9936. $data['staffname']=urlencode($staffname);
  9937. $data ['memu'] = "receipt";
  9938. $data ['staff'] = $this->staff;
  9939. $data ['receiptMemu'] = 'companyCategoryCollect';
  9940. $data ['verifyId'] = $this->verifyId;
  9941. $data ['executeId'] = $this->executeId;
  9942. if ($year < date ( "Y" )) {
  9943. Doo::loadModel ( 'receipt' );
  9944. $receipt = new receipt ();
  9945. $receiptList = $receipt->find ( array (
  9946. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  9947. 'asArray' => true
  9948. ) );
  9949. if (empty ( $receiptList )) { // generated files
  9950. ob_start ();
  9951. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9952. $this->cacheFile ( $path );
  9953. die ();
  9954. }
  9955. }
  9956. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9957. }
  9958. function BUGFLAG() {
  9959. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  9960. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  9961. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9962. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9963. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  9964. if (empty ( $status ))
  9965. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  9966. $page_size = 12;
  9967. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  9968. $vidList = array ();
  9969. $button = 0;
  9970. Doo::loadModel ( 'verify' );
  9971. $verify = new verify ();
  9972. Doo::loadModel ( 'receipt' );
  9973. $receipt = new receipt ();
  9974. Doo::loadModel ( 'staff' );
  9975. $staff = new staff ();
  9976. Doo::loadModel ( 'L_category' );
  9977. $Lcategory = new L_category ();
  9978. $dateCondition = " and Year(date) =" . $year;
  9979. if (! empty ( $month ))
  9980. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  9981. $categoryList = $Lcategory->find ( array (
  9982. 'asArray' => true
  9983. ) );
  9984. $staffList = $staff->find ( array (
  9985. 'where' => 'cid=' . $cid,
  9986. 'asArray' => true
  9987. ) );
  9988. $cateCondition = "";
  9989. $staffCondition = "";
  9990. $approvalCondition = "";
  9991. if (! empty ( $cid ))
  9992. $cateCondition = ' and cid=' . $cid;
  9993. if (! empty ( $sid )) {
  9994. $staffCondition = ' and staff=' . $sid;
  9995. $cateCondition = "";
  9996. }
  9997. $approvalCondition = " and status=" . $status;
  9998. if ($status == 2) {
  9999. // 查找角色审批人
  10000. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  10001. }
  10002. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  10003. $approvalCondition = ' and status=2 ';
  10004. }
  10005. if ($status == 1) {
  10006. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  10007. }
  10008. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  10009. $pageinfo ['page'] = array (
  10010. 'previous' => ''
  10011. );
  10012. if ($status == 0) {
  10013. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  10014. $receiptList = $receipt->find ( array (
  10015. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  10016. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  10017. 'desc' => 'rid',
  10018. 'asArray' => true
  10019. ) );
  10020. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  10021. } else
  10022. $receiptList = $receipt->find ( array (
  10023. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  10024. 'desc' => 'rid',
  10025. 'asArray' => true
  10026. ) );
  10027. $rLRes = $receipt->find ( array (
  10028. '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,
  10029. 'desc' => 'rid',
  10030. 'asArray' => true
  10031. ) );
  10032. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  10033. // print_r($pageinfo);
  10034. $Locate = 0;
  10035. foreach ( $receiptList as $key => $value ) {
  10036. $receiptList [$key] ['Locate'] = $Locate;
  10037. $Locate ++;
  10038. $receiptList [$key] ['reviseDetail'] = array ();
  10039. if (! empty ( $value ['reviseDetail'] ))
  10040. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  10041. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  10042. $categoryDetil = $Lcategory->getOne ( array (
  10043. 'where' => 'cid=' . $value ['cid'],
  10044. 'asArray' => true
  10045. ) );
  10046. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  10047. $verifyList = $verify->getOne ( array (
  10048. 'where' => 'vid=' . $value ['verify'],
  10049. 'asArray' => true
  10050. ) );
  10051. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  10052. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  10053. foreach ( $verifyList as $k => $v ) {
  10054. // init verifyStaff
  10055. $verifyList [$k] ['date'] = "";
  10056. $verifyList [$k] ['opinion'] = "";
  10057. $verifyList [$k] ['status'] = "";
  10058. if (empty ( $verifyStaff )) {
  10059. $verifyList [$k] ['date'] = "";
  10060. $verifyList [$k] ['opinion'] = "";
  10061. if ($v [0] == $this->staff [0] ['sid']) {
  10062. $verifyList [$k] ['status'] = 4;
  10063. $button = 4;
  10064. }
  10065. } else {
  10066. $flag = true;
  10067. foreach ( $verifyStaff as $m => $u ) {
  10068. if ($v [0] == $m) {
  10069. $verifyList [$k] ['date'] = $u ['date'];
  10070. $verifyList [$k] ['opinion'] = $u ['opinion'];
  10071. $verifyList [$k] ['status'] = $u ['status'];
  10072. $flag = false;
  10073. break;
  10074. }
  10075. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  10076. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  10077. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  10078. }
  10079. if ($flag) { // 检测可编辑
  10080. if ($v [0] == $this->staff [0] ['sid']) {
  10081. $verifyList [$k] ['status'] = 4;
  10082. $button = 4;
  10083. }
  10084. }
  10085. }
  10086. }
  10087. $receiptList [$key] ['verifyList'] = $verifyList;
  10088. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  10089. 'where' => 'sid=' . $value ['staff'],
  10090. 'asArray' => true
  10091. ) );
  10092. $receiptList [$key] ['button'] = $button;
  10093. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  10094. }
  10095. // print_r($receiptList);die;
  10096. // $data['verifyDetail']=$verifyDetail;
  10097. $mothHtml = "";
  10098. for($i = 1; $i <= 12; $i ++) {
  10099. if ($month == $i)
  10100. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  10101. else
  10102. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  10103. }
  10104. $data ['mothHtml'] = $mothHtml;
  10105. $data ['page'] = $pageinfo;
  10106. $data ['receiptList'] = $receiptList;
  10107. $data ['receiptApprovalCount'] = count ( $rLRes );
  10108. $data ['status'] = $status;
  10109. $data ['year'] = $year;
  10110. $data ['categoryList'] = $categoryList;
  10111. $data ['staffList'] = $staffList;
  10112. $data ['cid'] = $cid;
  10113. $data ['sid'] = $sid;
  10114. // print_r($receiptList);
  10115. $data ['memu'] = "receipt";
  10116. $data ['staff'] = $this->staff;
  10117. $data ['receiptMemu'] = 'approvalExpenses';
  10118. $data ['verifyId'] = $this->verifyId;
  10119. $data ['executeId'] = $this->executeId;
  10120. $this->render ( "/admin/FALG", $data );
  10121. }
  10122. function ajaxGetReceiptOrder() {
  10123. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  10124. if (! empty ( $receiptOrder )) {
  10125. Doo::loadModel ( 'receipt' );
  10126. $receipt = new receipt ();
  10127. Doo::loadModel ( 'staff' );
  10128. $staff = new staff ();
  10129. $receiptInfo = $receipt->getOne ( array (
  10130. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  10131. 'asArray' => true
  10132. ) );
  10133. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  10134. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  10135. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  10136. </tbody></table><table class="table table table-bordered"><tbody>';
  10137. foreach ( $verifyStaff as $key => $value ) {
  10138. $staffInfo = $staff->getOne ( array (
  10139. 'select' => 'username',
  10140. 'where' => ' sid="' . $key . '"',
  10141. 'asArray' => true
  10142. ) );
  10143. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  10144. }
  10145. $html .= '</tbody></table></div></div>';
  10146. echo json_encode ( array (
  10147. 'status' => 1,
  10148. 'receiptHtml' => $html
  10149. ) );
  10150. die ();
  10151. }
  10152. echo json_encode ( array (
  10153. 'status' => 2,
  10154. 'receiptHtml' => ''
  10155. ) );
  10156. die ();
  10157. }
  10158. function _getMonthCollectDetail($receiptCollectList) {
  10159. if (! empty ( $receiptCollectList )) {
  10160. $receiptL = array (
  10161. '日常相关费用' => array (),
  10162. '差旅相关费用' => array (),
  10163. '培训班费用' => array (),
  10164. '其他' => array ()
  10165. );
  10166. $html = "";
  10167. $psum = 0;
  10168. $item = array (
  10169. '市内交通费',
  10170. '市内出租费',
  10171. '办事处房租',
  10172. '电话费',
  10173. '水费',
  10174. '电费',
  10175. '办公费用',
  10176. '邮寄费',
  10177. '其他费用',
  10178. '车辆费用',
  10179. '广告费',
  10180. '团队建设费',
  10181. '物业管理费',
  10182. '宽带费'
  10183. );
  10184. foreach ( $item as $value ) {
  10185. $falg = true;
  10186. foreach ( $receiptCollectList as $v ) {
  10187. if ($v ['itemCategory'] == '日常相关费用') {
  10188. if ($v ['item'] == $value) {
  10189. $psum += $v ['price'];
  10190. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10191. $falg = false;
  10192. break;
  10193. }
  10194. }
  10195. }
  10196. if ($falg)
  10197. $html .= '<td class="taR">-</td>';
  10198. }
  10199. if (! empty ( $psum ))
  10200. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  10201. else
  10202. $psum = '<td class="colGreen taR">-</td>';
  10203. $receiptL ['日常相关费用'] = $psum . $html;
  10204. /* ----------------------------------- */
  10205. $html = "";
  10206. $psum = 0;
  10207. $item = array (
  10208. '往来交通费',
  10209. '市内交通费',
  10210. '出差住宿费',
  10211. '出差补助',
  10212. '其他费用'
  10213. );
  10214. foreach ( $item as $value ) {
  10215. $falg = true;
  10216. foreach ( $receiptCollectList as $v ) {
  10217. if ($v ['itemCategory'] == '差旅相关费用') {
  10218. if ($v ['item'] == $value) {
  10219. $psum += $v ['price'];
  10220. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10221. $falg = false;
  10222. break;
  10223. }
  10224. }
  10225. }
  10226. if ($falg)
  10227. $html .= '<td class="taR">-</td>';
  10228. }
  10229. if (! empty ( $psum ))
  10230. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  10231. else
  10232. $psum = '<td class="colGreen taR">-</td>';
  10233. $receiptL ['差旅相关费用'] = $psum . $html;
  10234. /* ------------------------------------- */
  10235. $html = "";
  10236. $psum = 0;
  10237. $item = array (
  10238. '场租费',
  10239. '薪酬',
  10240. '住宿费',
  10241. '交通费',
  10242. '餐饮费',
  10243. '办公费',
  10244. '公关费',
  10245. '其他'
  10246. );
  10247. foreach ( $item as $value ) {
  10248. $falg = true;
  10249. foreach ( $receiptCollectList as $v ) {
  10250. if ($v ['itemCategory'] == '培训班费用') {
  10251. if ($v ['item'] == $value) {
  10252. $psum += $v ['price'];
  10253. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10254. $falg = false;
  10255. break;
  10256. }
  10257. }
  10258. }
  10259. if ($falg)
  10260. $html .= '<td class="taR">-</td>';
  10261. }
  10262. if (! empty ( $psum ))
  10263. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  10264. else
  10265. $psum = '<td class="colGreen taR">-</td>';
  10266. $receiptL ['培训班费用'] = $psum . $html;
  10267. /* ------------------------------------- */
  10268. $html = "";
  10269. $psum = 0;
  10270. $item = array (
  10271. '公关费',
  10272. '广告费',
  10273. '借款',
  10274. '可自加费用'
  10275. );
  10276. foreach ( $item as $value ) {
  10277. $falg = true;
  10278. foreach ( $receiptCollectList as $v ) {
  10279. if ($v ['itemCategory'] == '其他') {
  10280. if ($v ['item'] == $value) {
  10281. $psum += $v ['price'];
  10282. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10283. $falg = false;
  10284. break;
  10285. }
  10286. }
  10287. }
  10288. if ($falg)
  10289. $html .= '<td class="taR">-</td>';
  10290. }
  10291. if (! empty ( $psum ))
  10292. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  10293. else
  10294. $psum = '<td class="colGreen taR">-</td>';
  10295. $receiptL ['其他'] = $psum . $html;
  10296. /* ------------------------------------- */
  10297. $html = "";
  10298. $psum = 0;
  10299. foreach ( $receiptCollectList as $v ) {
  10300. if ($v ['itemCategory'] == '报销金额调整') {
  10301. if (! empty ( $v ['price'] ))
  10302. $psum += $v ['price'];
  10303. }
  10304. }
  10305. if (! empty ( $psum ))
  10306. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  10307. else
  10308. $psum = '<td class="taR colOrange">-</td>';
  10309. $receiptL ['报销金额调整'] = $psum . $html;
  10310. } else {
  10311. $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>
  10312. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10313. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  10314. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10315. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  10316. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10317. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10318. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  10319. }
  10320. return $receiptL;
  10321. }
  10322. function eMail() {
  10323. Doo::loadModel ( 'staff' );
  10324. $staff = new staff ();
  10325. Doo::loadModel ( 'receipt' );
  10326. $receipt = new receipt ();
  10327. Doo::loadModel ( 'L_category' );
  10328. $Lcategory = new L_category ();
  10329. Doo::loadModel ( "verify" );
  10330. $verify = new verify ();
  10331. $staffList = $staff->find ( array (
  10332. 'asArray' => true
  10333. ) );
  10334. foreach ( $staffList as $key => $value ) {
  10335. if ($value ['username'] != 'admin') {
  10336. // 提交人
  10337. $receiptList = $receipt->find ( array (
  10338. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  10339. 'asArray' => true
  10340. ) );
  10341. if (! empty ( $receiptList )) {
  10342. $html = '<br><div><style></style>
  10343. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  10344. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  10345. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  10346. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  10347. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  10348. <tbody><tr>
  10349. <td style="padding: 0 40px;" align="left">
  10350. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  10351. </td></tr><tr>
  10352. <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>
  10353. </tr>
  10354. </tbody> </table></td> </tr> <tr><td>
  10355. <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">
  10356. <tbody> <tr><td>
  10357. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  10358. 以下报销单完成了审批,等着收款吧:</p>
  10359. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  10360. foreach ( $receiptList as $k => $v ) {
  10361. $category = $Lcategory->getOne ( array (
  10362. 'where' => 'cid=' . $v ['cid'],
  10363. 'asArray' => true
  10364. ) );
  10365. $html .= '
  10366. <tr>
  10367. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  10368. <td align="left">
  10369. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  10370. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  10371. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  10372. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  10373. </tr>';
  10374. }
  10375. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  10376. <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>
  10377. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  10378. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  10379. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  10380. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  10381. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  10382. $receipt = new receipt ();
  10383. $receipt->notice = 1;
  10384. $receipt->update ( array (
  10385. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  10386. ) );
  10387. }
  10388. }
  10389. // 审批人
  10390. $verifyList = $verify->find ( array (
  10391. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  10392. 'asArray' => true
  10393. ) );
  10394. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  10395. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  10396. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  10397. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  10398. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  10399. <tbody><tr><td style="padding: 0 40px;" align="left">
  10400. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  10401. </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>
  10402. </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">
  10403. <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>
  10404. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  10405. foreach ( $verifyList as $k => $v ) {
  10406. $receiptList = $receipt->find ( array (
  10407. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  10408. 'asArray' => true
  10409. ) );
  10410. foreach ( $receiptList as $r => $l ) {
  10411. $category = $Lcategory->getOne ( array (
  10412. 'where' => 'cid=' . $l ['cid'],
  10413. 'asArray' => true
  10414. ) );
  10415. $staffDetile = $staff->getOne ( array (
  10416. 'where' => 'sid=' . $l ['staff'],
  10417. 'asArray' => true
  10418. ) );
  10419. $html .= '
  10420. <tr>
  10421. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  10422. <td align="left">
  10423. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  10424. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  10425. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  10426. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  10427. </tr>';
  10428. }
  10429. }
  10430. $html .= '
  10431. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  10432. <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>
  10433. </tr></tbody></table></td></tr></tbody></table></div><br>';
  10434. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  10435. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  10436. // $receipt=new receipt();
  10437. // $receipt->notice=1;
  10438. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  10439. }
  10440. }
  10441. }
  10442. }
  10443. function setWXMsg($rid, $type) {
  10444. Doo::loadModel ( "receipt" );
  10445. $receipt = new receipt ();
  10446. $receiptDetail = $receipt->getOne ( array (
  10447. 'where' => 'rid=' . $rid,
  10448. 'asArray' => true
  10449. ) );
  10450. if (! empty ( $receiptDetail )) {
  10451. Doo::loadModel ( 'staff' );
  10452. $staff = new staff ();
  10453. $staffmsg = $staff->getOne ( array (
  10454. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  10455. 'asArray' => TRUE
  10456. ) );
  10457. if (! empty ( $staffmsg ['wxid'] )) {
  10458. require_once (SITE_PATH . '/protected/class/client.php');
  10459. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  10460. $user = $staffmsg ['wxid'];
  10461. $receiptName = '';
  10462. $msg = '';
  10463. switch ($receiptDetail ['Rtype']) {
  10464. case 0 :
  10465. $receiptName = '报销';
  10466. break;
  10467. case 1 :
  10468. $receiptName = '借款';
  10469. break;
  10470. case 2 :
  10471. $receiptName = '对公汇款';
  10472. break;
  10473. }
  10474. switch ($type) {
  10475. case 1 :
  10476. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  10477. break;
  10478. case 2 :
  10479. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  10480. break;
  10481. case 3 :
  10482. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  10483. break;
  10484. }
  10485. // $result = $client->SendMsg ( $user, $msg, 'text' );
  10486. }
  10487. }
  10488. }
  10489. // Email发送函数
  10490. function SMail($toemail, $subject, $contents) {
  10491. Doo::loadClass ( 'class.phpmailer' );
  10492. $mail = new PHPMailer ();
  10493. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  10494. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  10495. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  10496. $mail->Password = "cDO1GjtY1seH"; // 密码
  10497. $mail->CharSet = "UTF8";
  10498. $mail->SMTPAuth = true;
  10499. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  10500. $mail->Mailer = "smtp";
  10501. $mail->Port = 25;
  10502. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  10503. $mail->MsgHTML ( $contents );
  10504. $mail->AddAddress ( $toemail );
  10505. $mail->CharSet = "UTF-8";
  10506. return $mail->Send ();
  10507. }
  10508. function swfupload() {
  10509. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  10510. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  10511. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  10512. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  10513. header ( "HTTP/1.1 500 Internal Server Error" );
  10514. echo "POST exceeded maximum allowed size.";
  10515. exit ( 0 );
  10516. }
  10517. // Settings
  10518. $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)
  10519. $upload_name = "Filedata";
  10520. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  10521. $extension_whitelist = array (
  10522. "doc",
  10523. "txt",
  10524. "jpg",
  10525. "gif",
  10526. "png"
  10527. ); // Allowed file extensions
  10528. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  10529. // Other variables
  10530. $MAX_FILENAME_LENGTH = 260;
  10531. $file_name = "";
  10532. $file_extension = "";
  10533. $uploadErrors = array (
  10534. 0 => "文件上传成功",
  10535. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  10536. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  10537. 3 => "上传的文件仅为部分文件",
  10538. 4 => "没有文件上传",
  10539. 6 => "缺少临时文件夹"
  10540. );
  10541. $nk = time ();
  10542. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  10543. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  10544. echo "文件无法保存.";
  10545. exit ( 0 );
  10546. }
  10547. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  10548. echo json_encode ( array (
  10549. 'filename' => $file_name,
  10550. 'id' => $nk
  10551. ) );
  10552. exit ( 0 );
  10553. }
  10554. function _GetFileEXT($filename) {
  10555. $pics = explode ( '.', $filename );
  10556. $num = count ( $pics );
  10557. return $pics [$num - 1];
  10558. }
  10559. /**
  10560. * 获取get或者POST值
  10561. * @param string $name 属性名称
  10562. * @return fixed 值
  10563. */
  10564. function get_args($name) {
  10565. if (isset ( $_GET [$name] )) {
  10566. if (is_array ( $_GET [$name] ))
  10567. return $_GET [$name];
  10568. else
  10569. return addslashes ( $_GET [$name] );
  10570. } elseif (isset ( $_POST [$name] )) {
  10571. if (is_array ( $_POST [$name] ))
  10572. return $_POST [$name];
  10573. else
  10574. return addslashes ( $_POST [$name] );
  10575. } else
  10576. return false;
  10577. }
  10578. function num_to_rmb($num) {
  10579. $c1 = "零壹贰叁肆伍陆柒捌玖";
  10580. $c2 = "分角元拾佰仟万拾佰仟亿";
  10581. // 精确到分后面就不要了,所以只留两个小数位
  10582. $num = round ( $num, 2 );
  10583. // 将数字转化为整数
  10584. $num = $num * 100;
  10585. if (strlen ( $num ) > 10) {
  10586. return "金额太大,请检查";
  10587. }
  10588. $i = 0;
  10589. $c = "";
  10590. while ( 1 ) {
  10591. if ($i == 0) {
  10592. // 获取最后一位数字
  10593. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  10594. } else {
  10595. $n = $num % 10;
  10596. }
  10597. // 每次将最后一位数字转化为中文
  10598. $p1 = substr ( $c1, 3 * $n, 3 );
  10599. $p2 = substr ( $c2, 3 * $i, 3 );
  10600. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  10601. $c = $p1 . $p2 . $c;
  10602. } else {
  10603. $c = $p1 . $c;
  10604. }
  10605. $i = $i + 1;
  10606. // 去掉数字最后一位了
  10607. $num = $num / 10;
  10608. // echo $num.'</br>';
  10609. // $num = (int)$num;
  10610. // $num =floor($num);
  10611. $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  10612. // echo $num.'</br>';
  10613. // 结束循环
  10614. if ($num == 0) {
  10615. break;
  10616. }
  10617. }
  10618. // echo $c.'</br>';
  10619. $j = 0;
  10620. $slen = strlen ( $c );
  10621. while ( $j < $slen ) {
  10622. // utf8一个汉字相当3个字符
  10623. $m = substr ( $c, $j, 6 );
  10624. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  10625. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  10626. $left = substr ( $c, 0, $j );
  10627. $right = substr ( $c, $j + 3 );
  10628. $c = $left . $right;
  10629. $j = $j - 3;
  10630. $slen = $slen - 3;
  10631. }
  10632. $j = $j + 3;
  10633. }
  10634. // 这个是为了去掉类似23.0中最后一个“零”字
  10635. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  10636. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  10637. }
  10638. // 将处理的汉字加上“整”
  10639. if (empty ( $c )) {
  10640. return "零元整";
  10641. } else {
  10642. return $c . "整";
  10643. }
  10644. }
  10645. /**
  10646. * 获得分页数据
  10647. * @param unknown_type $table
  10648. * @param unknown_type $condition
  10649. * @param unknown_type $on_page
  10650. * @param unknown_type $page_size
  10651. */
  10652. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  10653. $page_c = "";
  10654. $page ['previous'] = $this->get_previous ( $on_page );
  10655. $page ['on_page'] = $on_page;
  10656. $total_count = $this->get_table_count ( $table, $condition );
  10657. $total = intval ( $total_count / $page_size );
  10658. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  10659. $page ['total_data'] = $total_count;
  10660. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  10661. $i = 1;
  10662. $page_max = 1;
  10663. $page_width = 3;
  10664. if ($on_page >= $page_width) {
  10665. $page_max = intval ( $on_page / $page_width ) + 1;
  10666. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  10667. }
  10668. for(; $i <= $page ['total_page']; $i ++) {
  10669. if ($i == $on_page)
  10670. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  10671. else
  10672. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  10673. if ($i == ($page_width * $page_max))
  10674. break;
  10675. }
  10676. $page ['page'] = $page_c;
  10677. $page ['lower'] = (-- $on_page) * $page_size;
  10678. return $page;
  10679. }
  10680. /**
  10681. * 获取总页数
  10682. * @param unknown_type $table
  10683. * @param unknown_type $condition
  10684. */
  10685. public function get_table_count($table = "", $condition = "") {
  10686. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10687. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10688. // echo $sql;die;
  10689. $query = Doo::db ()->query ( $sql );
  10690. $result = $query->fetch ();
  10691. return $result ['count'];
  10692. }
  10693. /**
  10694. * 获取上一页
  10695. * @param unknown_type $on_page
  10696. */
  10697. function get_previous($on_page = 1) {
  10698. return $on_page != 0 ? $on_page - 1 : $on_page;
  10699. }
  10700. }
  10701. ?>