ReceiptController.php 390 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104
  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'] : 0;
  2502. Doo::loadModel ( 'receipt' );
  2503. $receipt = new receipt ();
  2504. Doo::loadModel ( 'L_category' );
  2505. $Lcategory = new L_category ();
  2506. Doo::loadModel ( 'verify' );
  2507. Doo::loadModel ( 'statistics' );
  2508. $statistics = new statistics ();
  2509. $verify = new verify ();
  2510. Doo::loadModel ( 'staff' );
  2511. $staff = new staff ();
  2512. Doo::loadModel ( 'loanReceipt' );
  2513. $loanReceipt = new loanReceipt ();
  2514. $receiptList = $receipt->find ( array (
  2515. 'where' => ' rid=' . $rid,
  2516. 'desc' => 'rid',
  2517. 'asArray' => true
  2518. ) );
  2519. $loanList = array ();
  2520. if (! empty ( $receiptList ))
  2521. $loanList = $loanReceipt->find ( array (
  2522. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2523. 'desc' => 'rid',
  2524. 'asArray' => true
  2525. ) );
  2526. $Locate = 0;
  2527. $roleId = 0;
  2528. $button = 0;
  2529. foreach ( $loanList as $key => $value ) {
  2530. $loanList [$key] ['Locate'] = $Locate;
  2531. $Locate ++;
  2532. $loanList [$key] ['reviseDetail'] = array ();
  2533. if (! empty ( $value ['reviseDetail'] ))
  2534. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2535. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2536. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2537. $categoryDetil = $Lcategory->getOne ( array (
  2538. 'where' => 'cid=' . $value ['cid'],
  2539. 'asArray' => true
  2540. ) );
  2541. $loanList [$key] ['category'] = $categoryDetil ['title'];
  2542. // 检测编辑状态
  2543. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  2544. $verifyList ['staff'] = $value ['verifyBreakup'];
  2545. else
  2546. $verifyList = $verify->getOne ( array (
  2547. 'where' => 'vid=' . $value ['verify'],
  2548. 'asArray' => true
  2549. ) );
  2550. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2551. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2552. Doo::loadModel ( 'role' );
  2553. $role = new role ();
  2554. $flag = true;
  2555. $roleKey = 0;
  2556. $endStaffArray = array ();
  2557. $roleArrayCopy = array ();
  2558. foreach ( $verifyList as $k => $v ) {
  2559. // init verifyStaff
  2560. if ($v [1] == 'ROLE') {
  2561. if (! empty ( $verifyStaff )) {
  2562. $endStaffArray = end ( $verifyStaff );
  2563. // if ($v[0]==$endStaffArray['nextStaff']){
  2564. // $roleId=$v[0];
  2565. // }
  2566. }
  2567. $roleVerify = json_decode ( $v [3], true );
  2568. $roleKey = $k;
  2569. $roleArray = array ();
  2570. $rolename = $role->getOne ( array (
  2571. 'where' => 'rid=' . $v [0],
  2572. 'asArray' => true
  2573. ) );
  2574. foreach ( $roleVerify as $o => $p ) {
  2575. $staffID = explode ( '_', $p );
  2576. $staffInfo = $staff->getOne ( array (
  2577. 'where' => 'sid=' . $staffID [0],
  2578. 'asArray' => true
  2579. ) );
  2580. // print_r($staffID);
  2581. $exp = array (
  2582. 0 => $staffInfo ['sid'],
  2583. 1 => $staffID [1],
  2584. 2 => $staffInfo ['avatar'],
  2585. 'date' => '',
  2586. 'date' => '',
  2587. 'opinion' => '',
  2588. 'status' => '',
  2589. 'rolename' => $rolename ['name']
  2590. );
  2591. array_push ( $roleArray, $exp );
  2592. }
  2593. $roleArrayCopy [$v [0]] = $roleArray;
  2594. // $verifyList[$k]['roleArray']=$roleArray;
  2595. }
  2596. $verifyList [$k] ['date'] = "";
  2597. $verifyList [$k] ['opinion'] = "";
  2598. $verifyList [$k] ['status'] = "";
  2599. if (empty ( $verifyStaff )) {
  2600. $verifyList [$k] ['date'] = "";
  2601. $verifyList [$k] ['opinion'] = "";
  2602. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2603. $verifyList [$k] ['status'] = 4;
  2604. $flag = false;
  2605. }
  2606. } else {
  2607. foreach ( $verifyStaff as $m => $u ) {
  2608. if ($v [0] == $m) {
  2609. $verifyList [$k] ['date'] = $u ['date'];
  2610. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2611. $verifyList [$k] ['status'] = $u ['status'];
  2612. $flag = false;
  2613. break;
  2614. }
  2615. }
  2616. $endStaffArray = end ( $verifyStaff );
  2617. if (isset ( $endStaffArray ['ROLE'] )) {
  2618. } else {
  2619. // $endKey=key($verifyStaff);
  2620. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2621. // $button=4;
  2622. // $verifyList[$k]['status']=4;
  2623. // }
  2624. }
  2625. }
  2626. }
  2627. $rolename ['name'] = '';
  2628. if (! empty ( $roleId )) {
  2629. Doo::loadModel ( 'role' );
  2630. $role = new role ();
  2631. $rolename = $role->getOne ( array (
  2632. 'where' => 'rid=' . $roleId,
  2633. 'asArray' => true
  2634. ) );
  2635. }
  2636. if (! empty ( $verifyStaff ))
  2637. $endStaffArray = end ( $verifyStaff );
  2638. $KOP = false;
  2639. foreach ( $roleArrayCopy as $P => $A ) {
  2640. foreach ( $A as $MKI => $AVL ) {
  2641. if (! empty ( $verifyStaff )) {
  2642. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2643. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2644. $button = 4;
  2645. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2646. }
  2647. foreach ( $verifyStaff as $m => $u ) {
  2648. $AVLFK = $AVL [0] . '_R';
  2649. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2650. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2651. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2652. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2653. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2654. break;
  2655. }
  2656. }
  2657. } else {
  2658. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2659. $button = 4;
  2660. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2661. }
  2662. }
  2663. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2664. $KOP = true;
  2665. }
  2666. }
  2667. foreach ( $roleArrayCopy as $k => $v ) {
  2668. foreach ( $verifyList as $m => $n ) {
  2669. if ($n [0] == $k) {
  2670. array_splice ( $verifyList, $m, 1, $v );
  2671. }
  2672. }
  2673. }
  2674. $loanList [$key] ['verifyList'] = $verifyList;
  2675. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  2676. 'where' => 'sid=' . $value ['staff'],
  2677. 'asArray' => true
  2678. ) );
  2679. $loanList [$key] ['button'] = $button;
  2680. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  2681. }
  2682. $data ['loanList'] = $loanList;
  2683. // print_r($loanList);
  2684. $Locate = 0;
  2685. $roleId = 0;
  2686. $button = 0;
  2687. foreach ( $receiptList as $key => $value ) {
  2688. $receiptList [$key] ['Locate'] = $Locate;
  2689. $Locate ++;
  2690. $receiptList [$key] ['reviseDetail'] = array ();
  2691. if (! empty ( $value ['reviseDetail'] ))
  2692. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2693. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2694. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2695. $categoryDetil = $Lcategory->getOne ( array (
  2696. 'where' => 'cid=' . $value ['cid'],
  2697. 'asArray' => true
  2698. ) );
  2699. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2700. // 检测编辑状态
  2701. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  2702. $verifyList ['staff'] = $value ['verifyBreakup'];
  2703. } else
  2704. $verifyList = $verify->getOne ( array (
  2705. 'where' => 'vid=' . $value ['verify'],
  2706. 'asArray' => true
  2707. ) );
  2708. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2709. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2710. Doo::loadModel ( 'role' );
  2711. $role = new role ();
  2712. if ($verifyList == NULL)
  2713. $verifyList = array ();
  2714. $flag = true;
  2715. $roleKey = 0;
  2716. $endStaffArray = array ();
  2717. $roleArrayCopy = array ();
  2718. foreach ( $verifyList as $k => $v ) {
  2719. // init verifyStaff
  2720. if ($v [1] == 'ROLE') {
  2721. if (! empty ( $verifyStaff )) {
  2722. $endStaffArray = end ( $verifyStaff );
  2723. // if ($v[0]==$endStaffArray['nextStaff']){
  2724. // $roleId=$v[0];
  2725. // }
  2726. }
  2727. $roleVerify = json_decode ( $v [3], true );
  2728. $roleKey = $k;
  2729. $roleArray = array ();
  2730. $rolename = $role->getOne ( array (
  2731. 'where' => 'rid=' . $v [0],
  2732. 'asArray' => true
  2733. ) );
  2734. foreach ( $roleVerify as $o => $p ) {
  2735. $staffID = explode ( '_', $p );
  2736. $staffInfo = $staff->getOne ( array (
  2737. 'where' => 'sid=' . $staffID [0],
  2738. 'asArray' => true
  2739. ) );
  2740. // print_r($staffID);
  2741. $exp = array (
  2742. 0 => $staffInfo ['sid'],
  2743. 1 => $staffID [1],
  2744. 2 => $staffInfo ['avatar'],
  2745. 'date' => '',
  2746. 'date' => '',
  2747. 'opinion' => '',
  2748. 'status' => '',
  2749. 'rolename' => $rolename ['name']
  2750. );
  2751. array_push ( $roleArray, $exp );
  2752. }
  2753. $roleArrayCopy [$v [0]] = $roleArray;
  2754. // $verifyList[$k]['roleArray']=$roleArray;
  2755. }
  2756. $verifyList [$k] ['date'] = "";
  2757. $verifyList [$k] ['opinion'] = "";
  2758. $verifyList [$k] ['status'] = "";
  2759. if (empty ( $verifyStaff )) {
  2760. $verifyList [$k] ['date'] = "";
  2761. $verifyList [$k] ['opinion'] = "";
  2762. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2763. $verifyList [$k] ['status'] = 4;
  2764. $flag = false;
  2765. }
  2766. } else {
  2767. foreach ( $verifyStaff as $m => $u ) {
  2768. if ($v [0] == $m) {
  2769. $verifyList [$k] ['date'] = $u ['date'];
  2770. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2771. $verifyList [$k] ['status'] = $u ['status'];
  2772. $flag = false;
  2773. break;
  2774. }
  2775. }
  2776. $endStaffArray = end ( $verifyStaff );
  2777. if (isset ( $endStaffArray ['ROLE'] )) {
  2778. } else {
  2779. // $endKey=key($verifyStaff);
  2780. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2781. // $button=4;
  2782. // $verifyList[$k]['status']=4;
  2783. // }
  2784. }
  2785. }
  2786. }
  2787. $rolename ['name'] = '';
  2788. if (! empty ( $roleId )) {
  2789. Doo::loadModel ( 'role' );
  2790. $role = new role ();
  2791. $rolename = $role->getOne ( array (
  2792. 'where' => 'rid=' . $roleId,
  2793. 'asArray' => true
  2794. ) );
  2795. }
  2796. if (! empty ( $verifyStaff ))
  2797. $endStaffArray = end ( $verifyStaff );
  2798. $KOP = false;
  2799. foreach ( $roleArrayCopy as $P => $A ) {
  2800. foreach ( $A as $MKI => $AVL ) {
  2801. if (! empty ( $verifyStaff )) {
  2802. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2803. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2804. $button = 4;
  2805. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2806. }
  2807. foreach ( $verifyStaff as $m => $u ) {
  2808. $AVLFK = $AVL [0] . '_R';
  2809. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2810. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2811. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2812. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2813. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2814. break;
  2815. }
  2816. }
  2817. } else {
  2818. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2819. $button = 4;
  2820. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2821. }
  2822. }
  2823. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2824. $KOP = true;
  2825. }
  2826. }
  2827. foreach ( $roleArrayCopy as $k => $v ) {
  2828. foreach ( $verifyList as $m => $n ) {
  2829. if ($n [0] == $k) {
  2830. array_splice ( $verifyList, $m, 1, $v );
  2831. }
  2832. }
  2833. }
  2834. // 费用执行人相关数据
  2835. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2836. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2837. foreach ( $executeCopy as $k => $v ) {
  2838. $executeCopy [$k] ['date'] = '';
  2839. $executeCopy [$k] ['opinion'] = '';
  2840. $executeCopy [$k] ['status'] = '';
  2841. if (! empty ( $executeStaff ))
  2842. foreach ( $executeStaff as $m => $u ) {
  2843. if ($v [0] == $m) {
  2844. $executeCopy [$k] ['date'] = $u ['date'];
  2845. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2846. $executeCopy [$k] ['status'] = $u ['status'];
  2847. break;
  2848. }
  2849. }
  2850. }
  2851. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2852. $receiptList [$key] ['verifyList'] = $verifyList;
  2853. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2854. 'where' => 'sid=' . $value ['staff'],
  2855. 'asArray' => true
  2856. ) );
  2857. $receiptList [$key] ['button'] = $button;
  2858. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2859. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2860. $relust = $value ['sum'] - $value ['loanSum'];
  2861. $receiptList [$key] ['relust'] = $relust;
  2862. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2863. }
  2864. // print_r($receiptList);
  2865. // 获取审批日志
  2866. Doo::loadModel ( 'receiptLog' );
  2867. $receiptLog = new receiptLog ();
  2868. $rlList = array ();
  2869. $rlInfo = $receiptLog->getOne ( array (
  2870. 'where' => 'rid=' . $rid . ' and status=4',
  2871. 'asArray' => true
  2872. ) );
  2873. $tijdate = $receiptLog->getOne ( array (
  2874. 'where' => 'rid=' . $rid . ' and status=2',
  2875. 'asc' => 'rlid',
  2876. 'asArray' => true
  2877. ) );
  2878. if (! empty ( $rlInfo )) {
  2879. $rlList = $receiptLog->find ( array (
  2880. 'where' => 'rid=' . $rid,
  2881. 'asc' => 'rlid',
  2882. 'asArray' => true
  2883. ) );
  2884. }
  2885. Doo::loadModel ( 'enclosur' );
  2886. $enclosur = new enclosur ();
  2887. $enclosurList = $enclosur->find ( array (
  2888. 'where' => 'rid=' . $rid,
  2889. 'asArray' => true
  2890. ) );
  2891. $enclosurHtml = '';
  2892. foreach ( $enclosurList as $value ) {
  2893. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2894. }
  2895. $data ['enclosurHtml'] = $enclosurHtml;
  2896. $receiptList [0] ['rlList'] = $rlList;
  2897. $data ['receiptList'] = $receiptList;
  2898. $data ['memu'] = "receipt";
  2899. $data ['staff'] = $this->staff;
  2900. $data ['receiptMemu'] = 'approvalExpenses';
  2901. $data ['verifyId'] = $this->verifyId;
  2902. $data ['executeId'] = $this->executeId;
  2903. $this->render ( "/admin/expensesDoc", $data );
  2904. }
  2905. function expensesEdi() {
  2906. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2907. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  2908. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2909. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2910. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2911. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2912. if (empty ( $status ))
  2913. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  2914. $vidList = array ();
  2915. $button = 0;
  2916. Doo::loadModel ( 'verify' );
  2917. Doo::loadModel ( 'receipt' );
  2918. Doo::loadModel ( 'staff' );
  2919. $staff = new staff ();
  2920. $receipt = new receipt ();
  2921. $verify = new verify ();
  2922. Doo::loadModel ( 'L_category' );
  2923. $Lcategory = new L_category ();
  2924. Doo::loadModel ( 'enclosur' );
  2925. $enclosur = new enclosur ();
  2926. // user verify ID
  2927. $verifyDetail = $verify->find ( array (
  2928. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  2929. 'asArray' => true
  2930. ) );
  2931. foreach ( $verifyDetail as $key => $value ) {
  2932. array_push ( $vidList, $value ['vid'] );
  2933. }
  2934. $vid = implode ( ",", $vidList );
  2935. if (empty ( $verifyDetail ))
  2936. $vid = 0;
  2937. $categoryList = $Lcategory->find ( array (
  2938. 'asArray' => true
  2939. ) );
  2940. $staffList = $staff->find ( array (
  2941. 'where' => 'cid=' . $cid,
  2942. 'asArray' => true
  2943. ) );
  2944. $ap = "";
  2945. if ($status == 4) {
  2946. $ap = 4;
  2947. $status = 2;
  2948. }
  2949. // get Receipt By verifyID status 2
  2950. $receiptList = $receipt->find ( array (
  2951. 'where' => 'rid =' . $rid . ' and status=2',
  2952. 'desc' => 'rid',
  2953. 'asArray' => true
  2954. ) );
  2955. if (empty ( $receiptList )) {
  2956. die ( 'illegal request' );
  2957. }
  2958. $Locate = 0;
  2959. $roleId = 0;
  2960. if ($ap == 4)
  2961. $status = 4;
  2962. foreach ( $receiptList as $key => $value ) {
  2963. $receiptList [$key] ['Locate'] = $Locate;
  2964. $Locate ++;
  2965. $receiptList [$key] ['reviseDetail'] = array ();
  2966. if (! empty ( $value ['reviseDetail'] ))
  2967. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2968. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2969. $categoryDetil = $Lcategory->getOne ( array (
  2970. 'where' => 'cid=' . $value ['cid'],
  2971. 'asArray' => true
  2972. ) );
  2973. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2974. // 检测编辑状态
  2975. $verifyList = $verify->getOne ( array (
  2976. 'where' => 'vid=' . $value ['verify'],
  2977. 'asArray' => true
  2978. ) );
  2979. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2980. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2981. Doo::loadModel ( 'role' );
  2982. $role = new role ();
  2983. // print_r($verifyList);
  2984. $flag = true;
  2985. $roleKey = 0;
  2986. $endStaffArray = array ();
  2987. $roleArrayCopy = array ();
  2988. foreach ( $verifyList as $k => $v ) {
  2989. // init verifyStaff
  2990. if ($v [1] == 'ROLE') {
  2991. if (! empty ( $verifyStaff )) {
  2992. $endStaffArray = end ( $verifyStaff );
  2993. if ($v [0] == $endStaffArray ['nextStaff']) {
  2994. $roleId = $v [0];
  2995. }
  2996. }
  2997. $roleVerify = json_decode ( $v [3], true );
  2998. $roleKey = $k;
  2999. $roleArray = array ();
  3000. $rolename = $role->getOne ( array (
  3001. 'where' => 'rid=' . $v [0],
  3002. 'asArray' => true
  3003. ) );
  3004. foreach ( $roleVerify as $o => $p ) {
  3005. $staffID = explode ( '_', $p );
  3006. $staffInfo = $staff->getOne ( array (
  3007. 'where' => 'sid=' . $staffID [0],
  3008. 'asArray' => true
  3009. ) );
  3010. // print_r($staffID);
  3011. $exp = array (
  3012. 0 => $staffInfo ['sid'],
  3013. 1 => $staffID [1],
  3014. 2 => $staffInfo ['avatar'],
  3015. 'date' => '',
  3016. 'date' => '',
  3017. 'opinion' => '',
  3018. 'status' => '',
  3019. 'rolename' => $rolename ['name']
  3020. );
  3021. array_push ( $roleArray, $exp );
  3022. }
  3023. $roleArrayCopy [$v [0]] = $roleArray;
  3024. // $verifyList[$k]['roleArray']=$roleArray;
  3025. }
  3026. // print_r($roleArray);
  3027. $verifyList [$k] ['date'] = "";
  3028. $verifyList [$k] ['opinion'] = "";
  3029. $verifyList [$k] ['status'] = "";
  3030. if (empty ( $verifyStaff )) {
  3031. $verifyList [$k] ['date'] = "";
  3032. $verifyList [$k] ['opinion'] = "";
  3033. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3034. $verifyList [$k] ['status'] = 4;
  3035. $button = 4;
  3036. $flag = false;
  3037. }
  3038. } else {
  3039. foreach ( $verifyStaff as $m => $u ) {
  3040. if ($v [0] == $m) {
  3041. $verifyList [$k] ['date'] = $u ['date'];
  3042. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3043. $verifyList [$k] ['status'] = $u ['status'];
  3044. $flag = false;
  3045. break;
  3046. }
  3047. }
  3048. $endStaffArray = end ( $verifyStaff );
  3049. if (isset ( $endStaffArray ['ROLE'] )) {
  3050. } else {
  3051. $endKey = key ( $verifyStaff );
  3052. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  3053. $button = 4;
  3054. $verifyList [$k] ['status'] = 4;
  3055. }
  3056. }
  3057. }
  3058. }
  3059. $rolename ['name'] = '';
  3060. if (! empty ( $roleId )) {
  3061. Doo::loadModel ( 'role' );
  3062. $role = new role ();
  3063. $rolename = $role->getOne ( array (
  3064. 'where' => 'rid=' . $roleId,
  3065. 'asArray' => true
  3066. ) );
  3067. }
  3068. if (! empty ( $verifyStaff ))
  3069. $endStaffArray = end ( $verifyStaff );
  3070. $KOP = false;
  3071. foreach ( $roleArrayCopy as $P => $A ) {
  3072. foreach ( $A as $MKI => $AVL ) {
  3073. if (! empty ( $verifyStaff )) {
  3074. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3075. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3076. $button = 4;
  3077. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3078. }
  3079. foreach ( $verifyStaff as $m => $u ) {
  3080. $AVLFK = $AVL [0] . '_R';
  3081. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3082. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3083. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3084. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3085. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3086. break;
  3087. }
  3088. }
  3089. } else {
  3090. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3091. $button = 4;
  3092. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3093. }
  3094. }
  3095. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3096. $KOP = true;
  3097. }
  3098. }
  3099. // print_r($roleArrayCopy);
  3100. // echo $roleKey;
  3101. foreach ( $roleArrayCopy as $k => $v ) {
  3102. foreach ( $verifyList as $m => $n ) {
  3103. if ($n [0] == $k) {
  3104. array_splice ( $verifyList, $m, 1, $v );
  3105. }
  3106. }
  3107. }
  3108. $receiptList [$key] ['verifyList'] = $verifyList;
  3109. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3110. 'where' => 'sid=' . $value ['staff'],
  3111. 'asArray' => true
  3112. ) );
  3113. $receiptList [$key] ['button'] = $button;
  3114. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  3115. }
  3116. // $data['verifyDetail']=$verifyDetail;
  3117. $mothHtml = "";
  3118. for($i = 1; $i <= 12; $i ++) {
  3119. if ($month == $i)
  3120. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3121. else
  3122. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3123. }
  3124. // 获取审批日志
  3125. Doo::loadModel ( 'receiptLog' );
  3126. $receiptLog = new receiptLog ();
  3127. $rlList = array ();
  3128. $rlInfo = $receiptLog->getOne ( array (
  3129. 'where' => 'rid=' . $rid . ' and status=4',
  3130. 'asArray' => true
  3131. ) );
  3132. $tijdate = $receiptLog->getOne ( array (
  3133. 'where' => 'rid=' . $rid . ' and status=2',
  3134. 'asc' => 'rlid',
  3135. 'asArray' => true
  3136. ) );
  3137. if (! empty ( $rlInfo )) {
  3138. $rlList = $receiptLog->find ( array (
  3139. 'where' => 'rid=' . $rid,
  3140. 'asc' => 'rlid',
  3141. 'asArray' => true
  3142. ) );
  3143. }
  3144. $receiptList [0] ['rlList'] = $rlList;
  3145. $enclosurList = $enclosur->find ( array (
  3146. 'where' => 'rid=' . $rid,
  3147. 'asArray' => true
  3148. ) );
  3149. $enclosurHtml = '';
  3150. foreach ( $enclosurList as $value ) {
  3151. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3152. }
  3153. // print_r($receiptList);
  3154. $data ['rid'] = $rid;
  3155. $data ['enclosurHtml'] = $enclosurHtml;
  3156. $data ['rolename'] = $rolename ['name'];
  3157. $data ['datetij'] = $tijdate ['date'];
  3158. $data ['mothHtml'] = $mothHtml;
  3159. $data ['receiptList'] = $receiptList;
  3160. $data ['receiptApprovalCount'] = count ( $receiptList );
  3161. $data ['status'] = $status;
  3162. $data ['year'] = $year;
  3163. $data ['categoryList'] = $categoryList;
  3164. $data ['staffList'] = $staffList;
  3165. $data ['cid'] = $cid;
  3166. $data ['sid'] = $sid;
  3167. $data ['ap'] = $ap;
  3168. $data ['memu'] = "receipt";
  3169. $data ['staff'] = $this->staff;
  3170. $data ['receiptMemu'] = 'approvalExpenses';
  3171. $data ['verifyId'] = $this->verifyId;
  3172. $data ['executeId'] = $this->executeId;
  3173. $this->render ( "/admin/expensesEdi", $data );
  3174. }
  3175. function expensesDefray() {
  3176. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3177. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3178. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3179. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  3180. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  3181. if (! empty ( $rid )) {
  3182. Doo::loadModel ( "verify" );
  3183. $verify = new verify ();
  3184. Doo::loadModel ( "receiptDetail" );
  3185. $receiptDetailObj = new receiptDetail ();
  3186. Doo::loadModel ( "itemStatistics" );
  3187. Doo::loadModel ( "statistics" );
  3188. $statistics = new statistics ();
  3189. $itemStatistics = new itemStatistics ();
  3190. Doo::loadModel ( "receipt" );
  3191. $receipt = new receipt ();
  3192. Doo::loadModel ( "loanReceipt" );
  3193. $loanReceipt = new loanReceipt ();
  3194. $receiptDetail = $receipt->getOne ( array (
  3195. 'where' => 'rid=' . $rid . ' and status=2 ',
  3196. 'asArray' => true
  3197. ) );
  3198. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  3199. $nsflag = true;
  3200. foreach ( $nslist as $value ) {
  3201. if ($value == $this->staff ['0'] ['sid']) {
  3202. $nsflag = false;
  3203. break;
  3204. }
  3205. }
  3206. // print_r($nslist);die;
  3207. if (empty ( $receiptDetail ) || $nsflag)
  3208. return "/approvalExpenses/pendApproval";
  3209. $verifyDetail = $verify->getOne ( array (
  3210. 'where' => ' vid =' . $receiptDetail ['verify'],
  3211. 'asArray' => true
  3212. ) );
  3213. $verifyString = $verifyDetail ['staff'];
  3214. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3215. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  3216. if (empty ( $opinion )) {
  3217. if ($status == 3)
  3218. $opinion = "终止";
  3219. else
  3220. $opinion = "同意支付";
  3221. }
  3222. $nowStaff = 0;
  3223. $nowStaffList = array ();
  3224. if (empty ( $verifyStaff )) {
  3225. // 还需加入是否已经进入角色审批
  3226. if ($verifyDetail [0] [1] == 'ROLE') {
  3227. // print_r($verifyDetail);echo "ddd";
  3228. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3229. foreach ( $vStaffString as $key => $value ) {
  3230. $staffK = explode ( "_", $value );
  3231. if ($staffK [0] != $this->staff [0] ['sid'])
  3232. array_push ( $nowStaffList, $staffK [0] );
  3233. }
  3234. // print_r($verifyDetail);
  3235. // die;
  3236. if (! empty ( $nowStaffList )) {
  3237. $nowStaff = implode ( ',', $nowStaffList );
  3238. $verifyStaff = array (
  3239. $this->staff [0] ['sid'] . "_R" => array (
  3240. 'date' => date ( 'Y-m-d' ),
  3241. 'opinion' => $opinion,
  3242. 'status' => $status,
  3243. 'nextStaff' => $verifyDetail [0] [0],
  3244. 'ROLE' => 1
  3245. )
  3246. );
  3247. } else {
  3248. $nowStaff = $verifyDetail [1] [0];
  3249. $verifyStaff = array (
  3250. $this->staff [0] ['sid'] . "_R" => array (
  3251. 'date' => date ( 'Y-m-d' ),
  3252. 'opinion' => $opinion,
  3253. 'status' => $status,
  3254. 'nextStaff' => $verifyDetail [1] [0]
  3255. )
  3256. );
  3257. }
  3258. } else {
  3259. if ($verifyDetail [1] [1] == 'ROLE') {
  3260. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  3261. // echo "dd";
  3262. foreach ( $vStaffString as $key => $value ) {
  3263. $staffK = explode ( "_", $value );
  3264. array_push ( $nowStaffList, $staffK [0] );
  3265. }
  3266. $nowStaff = implode ( ',', $nowStaffList );
  3267. $verifyStaff = array (
  3268. $this->staff [0] ['sid'] => array (
  3269. 'date' => date ( 'Y-m-d' ),
  3270. 'opinion' => $opinion,
  3271. 'status' => $status,
  3272. 'nextStaff' => $verifyDetail [1] [0],
  3273. 'ROLE' => 1
  3274. )
  3275. );
  3276. } else {
  3277. $nowStaff = $verifyDetail [1] [0];
  3278. $verifyStaff = array (
  3279. $this->staff [0] ['sid'] => array (
  3280. 'date' => date ( 'Y-m-d' ),
  3281. 'opinion' => $opinion,
  3282. 'status' => $status,
  3283. 'nextStaff' => $verifyDetail [1] [0]
  3284. )
  3285. );
  3286. }
  3287. }
  3288. if ($status == 3)
  3289. $verifyStaff = array (
  3290. 'final' => $status,
  3291. $this->staff [0] ['sid'] => array (
  3292. 'date' => date ( 'Y-m-d' ),
  3293. 'opinion' => $opinion,
  3294. 'status' => $status
  3295. )
  3296. );
  3297. $vStaffString = json_encode ( $verifyStaff );
  3298. $receipt->nowStaff = $nowStaff;
  3299. $receipt->verifyStaff = $vStaffString;
  3300. $loanReceipt->nowStaff = $nowStaff;
  3301. $loanReceipt->verifyStaff = $vStaffString;
  3302. } else {
  3303. $VS = end ( $verifyStaff );
  3304. // 非角色审批
  3305. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  3306. $nextStaff = 0;
  3307. $roleSTF = false;
  3308. foreach ( $verifyDetail as $key => $value ) {
  3309. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  3310. if (isset ( $verifyDetail [$key + 1] )) {
  3311. $nextStaff = $verifyDetail [$key + 1] [0];
  3312. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  3313. $roleSTF = true;
  3314. }
  3315. break;
  3316. }
  3317. }
  3318. if (! $roleSTF) {
  3319. $nowStaff = $nextStaff;
  3320. $verifyStaff [$this->staff [0] ['sid']] = array (
  3321. 'date' => date ( 'Y-m-d' ),
  3322. 'opinion' => $opinion,
  3323. 'status' => $status,
  3324. 'nextStaff' => $nextStaff
  3325. );
  3326. } else {
  3327. // 获取角色下的所有用户ID
  3328. $nowStaffList = array ();
  3329. foreach ( $verifyDetail as $vfk ) {
  3330. if ($vfk [1] == 'ROLE') {
  3331. $vStaffString = json_decode ( $vfk [3] );
  3332. foreach ( $vStaffString as $key => $value ) {
  3333. $staffK = explode ( "_", $value );
  3334. array_push ( $nowStaffList, $staffK [0] );
  3335. }
  3336. }
  3337. }
  3338. $nowStaff = implode ( ',', $nowStaffList );
  3339. $verifyStaff [$this->staff [0] ['sid']] = array (
  3340. 'date' => date ( 'Y-m-d' ),
  3341. 'opinion' => $opinion,
  3342. 'status' => $status,
  3343. 'nextStaff' => $nextStaff,
  3344. 'ROLE' => 0
  3345. );
  3346. }
  3347. if ($status == 3) {
  3348. $verifyStaff ['final'] = $status;
  3349. $verifyStaff [$this->staff [0] ['sid']] = array (
  3350. 'date' => date ( 'Y-m-d' ),
  3351. 'opinion' => $opinion,
  3352. 'status' => $status
  3353. );
  3354. }
  3355. $vStaffString = json_encode ( $verifyStaff );
  3356. $receipt->nowStaff = $nowStaff;
  3357. $receipt->verifyStaff = $vStaffString;
  3358. $loanReceipt->nowStaff = $nowStaff;
  3359. $loanReceipt->verifyStaff = $vStaffString;
  3360. }
  3361. // 角色审批
  3362. if (isset ( $VS ['ROLE'] )) {
  3363. // 找出角色人 当前审批角色组
  3364. $verifyJSStaff = array ();
  3365. $nowStaffList2 = array ();
  3366. foreach ( $verifyDetail as $key => $value ) {
  3367. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  3368. $verifyJSStaff = json_decode ( $value [3] );
  3369. foreach ( $verifyJSStaff as $m ) {
  3370. $staffK = explode ( "_", $m );
  3371. array_push ( $nowStaffList2, $staffK [0] );
  3372. }
  3373. // print_r($nowStaffList2);
  3374. }
  3375. }
  3376. $RoleVerifyStaff = array ();
  3377. foreach ( $verifyStaff as $key => $value ) {
  3378. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  3379. foreach ( $nowStaffList2 as $m ) {
  3380. if ($key == $m . "_R")
  3381. $RoleVerifyStaff [$key] = $value;
  3382. }
  3383. }
  3384. }
  3385. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  3386. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  3387. // 下一个审批人ID
  3388. $nextStaff = 0;
  3389. $falg = false;
  3390. foreach ( $verifyDetail as $key => $value ) {
  3391. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  3392. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  3393. $falg = true;
  3394. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  3395. $nowStaffList = array ();
  3396. foreach ( $vStaffString as $v ) {
  3397. $staffK = explode ( "_", $v );
  3398. array_push ( $nowStaffList, $staffK [0] );
  3399. }
  3400. $nowStaff = implode ( ',', $nowStaffList );
  3401. $nextStaff = $verifyDetail [$key + 1] [0];
  3402. } elseif (isset ( $verifyDetail [$key + 1] )) {
  3403. $nextStaff = $verifyDetail [$key + 1] [0];
  3404. $nowStaff = $nextStaff;
  3405. } else
  3406. $nowStaff = '';
  3407. break;
  3408. }
  3409. }
  3410. if ($falg)
  3411. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3412. 'date' => date ( 'Y-m-d' ),
  3413. 'opinion' => $opinion,
  3414. 'status' => $status,
  3415. 'nextStaff' => $nextStaff,
  3416. 'ROLE' => 1
  3417. );
  3418. else
  3419. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3420. 'date' => date ( 'Y-m-d' ),
  3421. 'opinion' => $opinion,
  3422. 'status' => $status,
  3423. 'nextStaff' => $nextStaff
  3424. );
  3425. // print_r($verifyStaff);
  3426. // echo $nowStaff;die;
  3427. } else { // 进入下一个角色或者审批人
  3428. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  3429. //
  3430. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  3431. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3432. 'date' => date ( 'Y-m-d' ),
  3433. 'opinion' => $opinion,
  3434. 'status' => $status,
  3435. 'nextStaff' => $VS ['nextStaff'],
  3436. 'ROLE' => 1
  3437. );
  3438. // print_r($verifyStaff);
  3439. // die;
  3440. }
  3441. if ($status == 3) {
  3442. $verifyStaff ['final'] = $status;
  3443. $verifyStaff [$this->staff [0] ['sid']] = array (
  3444. 'date' => date ( 'Y-m-d' ),
  3445. 'opinion' => $opinion,
  3446. 'status' => $status
  3447. );
  3448. }
  3449. $vStaffString = json_encode ( $verifyStaff );
  3450. $receipt->verifyStaff = $vStaffString;
  3451. $receipt->nowStaff = $nowStaff;
  3452. $loanReceipt->nowStaff = $nowStaff;
  3453. $loanReceipt->verifyStaff = $vStaffString;
  3454. // die;
  3455. // }
  3456. // print_r($verifyStaff);
  3457. // die;
  3458. }
  3459. // print_r($verifyStaff);die;
  3460. }
  3461. // print_r($verifyDetail);
  3462. $roleKey = 0;
  3463. $roleId = 0;
  3464. $verifyDetailCopy = array ();
  3465. foreach ( $verifyDetail as $k => $v ) {
  3466. if ($v [1] == 'ROLE') {
  3467. $roleId = $v [0];
  3468. $roleVerify = json_decode ( $v [3], true );
  3469. $roleKey = $k;
  3470. $roleArray = array ();
  3471. foreach ( $roleVerify as $o => $p ) {
  3472. $staffID = explode ( '_', $p );
  3473. $exp = array (
  3474. 0 => $staffID [0],
  3475. 1 => $staffID [1]
  3476. );
  3477. array_push ( $roleArray, $exp );
  3478. }
  3479. $verifyDetailCopy [$v [0]] = $roleArray;
  3480. }
  3481. }
  3482. // print_r($verifyDetail);
  3483. foreach ( $verifyDetailCopy as $k => $v ) {
  3484. foreach ( $verifyDetail as $m => $n ) {
  3485. if ($n [0] == $k) {
  3486. array_splice ( $verifyDetail, $m, 1, $v );
  3487. }
  3488. }
  3489. }
  3490. // 审批日志
  3491. if (! isset ( $verifyStaff ['final'] )) {
  3492. Doo::loadModel ( "receiptLog" );
  3493. $receiptLog = new receiptLog ();
  3494. if (! empty ( $roleId )) {
  3495. Doo::loadModel ( "role" );
  3496. $role = new role ();
  3497. $roleInfo = $role->getOne ( array (
  3498. 'where' => 'rid=' . $roleId,
  3499. 'asArray' => true
  3500. ) );
  3501. $receiptLog->rolename = $roleInfo ['name'];
  3502. }
  3503. $receiptLog->username = $this->staff [0] ['username'];
  3504. $receiptLog->uid = $this->staff [0] ['sid'];
  3505. $receiptLog->date = date ( "Y-m-d" );
  3506. $receiptLog->opinion = $opinion;
  3507. $receiptLog->img = $this->staff [0] ['avatar'];
  3508. $receiptLog->status = 1;
  3509. $receiptLog->rid = $rid;
  3510. $receiptLog->insert ();
  3511. }
  3512. if (isset ( $verifyStaff ['final'] )) { // rDetail
  3513. $receipt->status = 3;
  3514. $receipt->verifyBreakup = $verifyString;
  3515. $receiptDetailObj->status = 3;
  3516. $receiptDetailObj->update ( array (
  3517. 'where' => 'rid=' . $rid
  3518. ) );
  3519. // 微信企业号通知
  3520. $this->setWXMsg ( $rid, 3 );
  3521. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  3522. $receipt->status = 6;
  3523. $receipt->pastDate = date ( "Y-m-d" );
  3524. $receipt->isBK = 1;
  3525. $loanReceipt->verifyBreakup = $verifyString;
  3526. $loanReceipt->status = 1;
  3527. $loanReceipt->pastDate = date ( "Y-m-d" );
  3528. $loanReceipt->amount = $receiptDetail ['amount'];
  3529. $loanReceipt->update ( array (
  3530. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  3531. ) );
  3532. // 微信企业号通知
  3533. $this->setWXMsg ( $rid, 1 );
  3534. }
  3535. $receipt->amount = $amount;
  3536. $receipt->update ( array (
  3537. 'where' => ' rid = ' . $rid
  3538. ) );
  3539. // 进入下一条审批费用新加需求
  3540. $vidList = array ();
  3541. $verifyDetail = $verify->find ( array (
  3542. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  3543. 'asArray' => true
  3544. ) );
  3545. foreach ( $verifyDetail as $key => $value ) {
  3546. array_push ( $vidList, $value ['vid'] );
  3547. }
  3548. $vid = implode ( ",", $vidList );
  3549. if (empty ( $verifyDetail ))
  3550. $vid = 0;
  3551. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  3552. $receipt = new receipt ();
  3553. $rd = $receipt->getOne ( array (
  3554. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  3555. 'asc' => 'rid',
  3556. 'asArray' => true
  3557. ) );
  3558. if (empty ( $rd )) {
  3559. return '/approvalExpenses/pendApproval';
  3560. }
  3561. if ($rd ['Rtype'] == 1) {
  3562. if ($rd ['isBK'] == 1) {
  3563. return '/receiptburEdi/' . $rd ['rid'];
  3564. } else {
  3565. return '/expensesEdi/' . $rd ['rid'];
  3566. }
  3567. } elseif ($rd ['Rtype'] == 2) {
  3568. return '/remitApproval/' . $rd ['rid'];
  3569. } else {
  3570. return '/receiptburEdi/' . $rd ['rid'];
  3571. }
  3572. // return "/approvalExpenses/pendApproval";
  3573. }
  3574. }
  3575. function ajaxExamineExe() {
  3576. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3577. Doo::loadModel ( 'receipt' );
  3578. $receipt = new receipt ();
  3579. Doo::loadClass ( 'XDeode' );
  3580. $XDeode = new XDeode ( 5 );
  3581. if (! empty ( $rid )) {
  3582. $rLRes = $receipt->find ( array (
  3583. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  3584. 'asArray' => true
  3585. ) );
  3586. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  3587. echo json_encode ( array (
  3588. 'status' => 1,
  3589. 'receipt' => $rLRes [0]
  3590. ) );
  3591. die ();
  3592. }
  3593. echo json_encode ( array (
  3594. 'status' => 0,
  3595. 'receipt' => array ()
  3596. ) );
  3597. die ();
  3598. }
  3599. function implement() {
  3600. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3601. Doo::loadClass ( 'XDeode' );
  3602. $XDeode = new XDeode ( 5 );
  3603. Doo::loadModel ( 'receipt' );
  3604. $receipt = new receipt ();
  3605. Doo::loadModel ( 'L_category' );
  3606. $Lcategory = new L_category ();
  3607. Doo::loadModel ( 'verify' );
  3608. $verify = new verify ();
  3609. Doo::loadModel ( 'staff' );
  3610. $staff = new staff ();
  3611. Doo::loadModel ( "execute" );
  3612. $execute = new execute ();
  3613. $rid = $XDeode->decode ( $rid );
  3614. $receiptList = $receipt->find ( array (
  3615. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  3616. 'desc' => 'rid',
  3617. 'asArray' => true
  3618. ) );
  3619. Doo::loadModel ( 'loanReceipt' );
  3620. $loanReceipt = new loanReceipt ();
  3621. // print_r($receiptList);
  3622. $loanList = array ();
  3623. if (! isset ( $receiptList ))
  3624. $loanList = $loanReceipt->find ( array (
  3625. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3626. 'desc' => 'rid',
  3627. 'asArray' => true
  3628. ) );
  3629. $Locate = 0;
  3630. $roleId = 0;
  3631. $button = 0;
  3632. foreach ( $loanList as $key => $value ) {
  3633. $loanList [$key] ['Locate'] = $Locate;
  3634. $Locate ++;
  3635. $loanList [$key] ['reviseDetail'] = array ();
  3636. if (! empty ( $value ['reviseDetail'] ))
  3637. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3638. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3639. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3640. $categoryDetil = $Lcategory->getOne ( array (
  3641. 'where' => 'cid=' . $value ['cid'],
  3642. 'asArray' => true
  3643. ) );
  3644. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3645. // 检测编辑状态
  3646. $verifyList = $verify->getOne ( array (
  3647. 'where' => 'vid=' . $value ['verify'],
  3648. 'asArray' => true
  3649. ) );
  3650. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3651. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3652. Doo::loadModel ( 'role' );
  3653. $role = new role ();
  3654. $flag = true;
  3655. $roleKey = 0;
  3656. $endStaffArray = array ();
  3657. $roleArrayCopy = array ();
  3658. foreach ( $verifyList as $k => $v ) {
  3659. // init verifyStaff
  3660. if ($v [1] == 'ROLE') {
  3661. if (! empty ( $verifyStaff )) {
  3662. $endStaffArray = end ( $verifyStaff );
  3663. // if ($v[0]==$endStaffArray['nextStaff']){
  3664. // $roleId=$v[0];
  3665. // }
  3666. }
  3667. $roleVerify = json_decode ( $v [3], true );
  3668. $roleKey = $k;
  3669. $roleArray = array ();
  3670. $rolename = $role->getOne ( array (
  3671. 'where' => 'rid=' . $v [0],
  3672. 'asArray' => true
  3673. ) );
  3674. foreach ( $roleVerify as $o => $p ) {
  3675. $staffID = explode ( '_', $p );
  3676. $staffInfo = $staff->getOne ( array (
  3677. 'where' => 'sid=' . $staffID [0],
  3678. 'asArray' => true
  3679. ) );
  3680. // print_r($staffID);
  3681. $exp = array (
  3682. 0 => $staffInfo ['sid'],
  3683. 1 => $staffID [1],
  3684. 2 => $staffInfo ['avatar'],
  3685. 'date' => '',
  3686. 'date' => '',
  3687. 'opinion' => '',
  3688. 'status' => '',
  3689. 'rolename' => $rolename ['name']
  3690. );
  3691. array_push ( $roleArray, $exp );
  3692. }
  3693. $roleArrayCopy [$v [0]] = $roleArray;
  3694. // $verifyList[$k]['roleArray']=$roleArray;
  3695. }
  3696. $verifyList [$k] ['date'] = "";
  3697. $verifyList [$k] ['opinion'] = "";
  3698. $verifyList [$k] ['status'] = "";
  3699. if (empty ( $verifyStaff )) {
  3700. $verifyList [$k] ['date'] = "";
  3701. $verifyList [$k] ['opinion'] = "";
  3702. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3703. $verifyList [$k] ['status'] = 4;
  3704. $flag = false;
  3705. }
  3706. } else {
  3707. foreach ( $verifyStaff as $m => $u ) {
  3708. if ($v [0] == $m) {
  3709. $verifyList [$k] ['date'] = $u ['date'];
  3710. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3711. $verifyList [$k] ['status'] = $u ['status'];
  3712. $flag = false;
  3713. break;
  3714. }
  3715. }
  3716. $endStaffArray = end ( $verifyStaff );
  3717. if (isset ( $endStaffArray ['ROLE'] )) {
  3718. } else {
  3719. // $endKey=key($verifyStaff);
  3720. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3721. // $button=4;
  3722. // $verifyList[$k]['status']=4;
  3723. // }
  3724. }
  3725. }
  3726. }
  3727. $rolename ['name'] = '';
  3728. if (! empty ( $roleId )) {
  3729. Doo::loadModel ( 'role' );
  3730. $role = new role ();
  3731. $rolename = $role->getOne ( array (
  3732. 'where' => 'rid=' . $roleId,
  3733. 'asArray' => true
  3734. ) );
  3735. }
  3736. if (! empty ( $verifyStaff ))
  3737. $endStaffArray = end ( $verifyStaff );
  3738. $KOP = false;
  3739. foreach ( $roleArrayCopy as $P => $A ) {
  3740. foreach ( $A as $MKI => $AVL ) {
  3741. if (! empty ( $verifyStaff )) {
  3742. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3743. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3744. $button = 4;
  3745. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3746. }
  3747. foreach ( $verifyStaff as $m => $u ) {
  3748. $AVLFK = $AVL [0] . '_R';
  3749. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3750. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3751. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3752. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3753. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3754. break;
  3755. }
  3756. }
  3757. } else {
  3758. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3759. $button = 4;
  3760. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3761. }
  3762. }
  3763. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3764. $KOP = true;
  3765. }
  3766. }
  3767. foreach ( $roleArrayCopy as $k => $v ) {
  3768. foreach ( $verifyList as $m => $n ) {
  3769. if ($n [0] == $k) {
  3770. array_splice ( $verifyList, $m, 1, $v );
  3771. }
  3772. }
  3773. }
  3774. $loanList [$key] ['verifyList'] = $verifyList;
  3775. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3776. 'where' => 'sid=' . $value ['staff'],
  3777. 'asArray' => true
  3778. ) );
  3779. }
  3780. $data ['loanList'] = $loanList;
  3781. $Locate = 0;
  3782. $roleId = 0;
  3783. $button = 0;
  3784. foreach ( $receiptList as $key => $value ) {
  3785. $button2 = 0;
  3786. $receiptList [$key] ['Locate'] = $Locate;
  3787. $Locate ++;
  3788. $receiptList [$key] ['reviseDetail'] = array ();
  3789. if (! empty ( $value ['reviseDetail'] ))
  3790. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3791. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3792. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3793. $categoryDetil = $Lcategory->getOne ( array (
  3794. 'where' => 'cid=' . $value ['cid'],
  3795. 'asArray' => true
  3796. ) );
  3797. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3798. $executeList = json_decode ( $value ['executeCopy'], true );
  3799. $executeStaff = array ();
  3800. if (! empty ( $value ['executeStaff'] ))
  3801. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3802. if (isset ( $executeList )) {
  3803. foreach ( $executeList as $op => $lo ) {
  3804. $executeList [$op] ['date'] = "";
  3805. $executeList [$op] ['opinion'] = "";
  3806. $executeList [$op] ['status'] = "";
  3807. foreach ( $executeStaff as $m => $u ) {
  3808. if ($lo [0] == $m) {
  3809. $executeList [$op] ['date'] = $u ['date'];
  3810. $executeList [$op] ['opinion'] = $u ['opinion'];
  3811. $executeList [$op] ['status'] = $u ['status'];
  3812. break;
  3813. }
  3814. }
  3815. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  3816. $button2 = 1;
  3817. $executeList [$op] ['status'] = 4;
  3818. }
  3819. }
  3820. }
  3821. // 检测编辑状态
  3822. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3823. $verifyList ['staff'] = $value ['verifyBreakup'];
  3824. } else
  3825. $verifyList = $verify->getOne ( array (
  3826. 'where' => 'vid=' . $value ['verify'],
  3827. 'asArray' => true
  3828. ) );
  3829. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3830. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3831. Doo::loadModel ( 'role' );
  3832. $role = new role ();
  3833. if ($verifyList == NULL)
  3834. $verifyList = array ();
  3835. $flag = true;
  3836. $roleKey = 0;
  3837. $endStaffArray = array ();
  3838. $roleArrayCopy = array ();
  3839. foreach ( $verifyList as $k => $v ) {
  3840. // init verifyStaff
  3841. if ($v [1] == 'ROLE') {
  3842. if (! empty ( $verifyStaff )) {
  3843. $endStaffArray = end ( $verifyStaff );
  3844. // if ($v[0]==$endStaffArray['nextStaff']){
  3845. // $roleId=$v[0];
  3846. // }
  3847. }
  3848. $roleVerify = json_decode ( $v [3], true );
  3849. $roleKey = $k;
  3850. $roleArray = array ();
  3851. $rolename = $role->getOne ( array (
  3852. 'where' => 'rid=' . $v [0],
  3853. 'asArray' => true
  3854. ) );
  3855. foreach ( $roleVerify as $o => $p ) {
  3856. $staffID = explode ( '_', $p );
  3857. $staffInfo = $staff->getOne ( array (
  3858. 'where' => 'sid=' . $staffID [0],
  3859. 'asArray' => true
  3860. ) );
  3861. // print_r($staffID);
  3862. $exp = array (
  3863. 0 => $staffInfo ['sid'],
  3864. 1 => $staffID [1],
  3865. 2 => $staffInfo ['avatar'],
  3866. 'date' => '',
  3867. 'date' => '',
  3868. 'opinion' => '',
  3869. 'status' => '',
  3870. 'rolename' => $rolename ['name']
  3871. );
  3872. array_push ( $roleArray, $exp );
  3873. }
  3874. $roleArrayCopy [$v [0]] = $roleArray;
  3875. // $verifyList[$k]['roleArray']=$roleArray;
  3876. }
  3877. $verifyList [$k] ['date'] = "";
  3878. $verifyList [$k] ['opinion'] = "";
  3879. $verifyList [$k] ['status'] = "";
  3880. if (empty ( $verifyStaff )) {
  3881. $verifyList [$k] ['date'] = "";
  3882. $verifyList [$k] ['opinion'] = "";
  3883. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3884. $verifyList [$k] ['status'] = 4;
  3885. $flag = false;
  3886. }
  3887. } else {
  3888. foreach ( $verifyStaff as $m => $u ) {
  3889. if ($v [0] == $m) {
  3890. $verifyList [$k] ['date'] = $u ['date'];
  3891. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3892. $verifyList [$k] ['status'] = $u ['status'];
  3893. $flag = false;
  3894. break;
  3895. }
  3896. }
  3897. $endStaffArray = end ( $verifyStaff );
  3898. if (isset ( $endStaffArray ['ROLE'] )) {
  3899. } else {
  3900. // $endKey=key($verifyStaff);
  3901. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3902. // $button=4;
  3903. // $verifyList[$k]['status']=4;
  3904. // }
  3905. }
  3906. }
  3907. }
  3908. $rolename ['name'] = '';
  3909. if (! empty ( $roleId )) {
  3910. Doo::loadModel ( 'role' );
  3911. $role = new role ();
  3912. $rolename = $role->getOne ( array (
  3913. 'where' => 'rid=' . $roleId,
  3914. 'asArray' => true
  3915. ) );
  3916. }
  3917. if (! empty ( $verifyStaff ))
  3918. $endStaffArray = end ( $verifyStaff );
  3919. $KOP = false;
  3920. foreach ( $roleArrayCopy as $P => $A ) {
  3921. foreach ( $A as $MKI => $AVL ) {
  3922. if (! empty ( $verifyStaff )) {
  3923. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3924. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3925. $button = 4;
  3926. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3927. }
  3928. foreach ( $verifyStaff as $m => $u ) {
  3929. $AVLFK = $AVL [0] . '_R';
  3930. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3931. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3932. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3933. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3934. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3935. break;
  3936. }
  3937. }
  3938. } else {
  3939. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3940. $button = 4;
  3941. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3942. }
  3943. }
  3944. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3945. $KOP = true;
  3946. }
  3947. }
  3948. foreach ( $roleArrayCopy as $k => $v ) {
  3949. foreach ( $verifyList as $m => $n ) {
  3950. if ($n [0] == $k) {
  3951. array_splice ( $verifyList, $m, 1, $v );
  3952. }
  3953. }
  3954. }
  3955. $receiptList [$key] ['verifyList'] = $verifyList;
  3956. $receiptList [$key] ['executeList'] = $executeList;
  3957. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3958. 'where' => 'sid=' . $value ['staff'],
  3959. 'asArray' => true
  3960. ) );
  3961. $receiptList [$key] ['button2'] = $button2;
  3962. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3963. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3964. $relust = $value ['sum'] - $value ['loanSum'];
  3965. $receiptList [$key] ['relust'] = $relust;
  3966. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  3967. }
  3968. // print_r($receiptList[$key]['executeList']);
  3969. $data ['receiptList'] = $receiptList;
  3970. $data ['memu'] = "receipt";
  3971. $data ['staff'] = $this->staff;
  3972. $data ['receiptMemu'] = 'implement';
  3973. $data ['verifyId'] = $this->verifyId;
  3974. $data ['executeId'] = $this->executeId;
  3975. $this->render ( "/admin/implement", $data );
  3976. }
  3977. function implementDo() {
  3978. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3979. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3980. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  3981. if (! empty ( $rid ) && $amount != '') {
  3982. Doo::loadModel ( 'receipt' );
  3983. $receipt = new receipt ();
  3984. Doo::loadClass ( 'XDeode' );
  3985. $XDeode = new XDeode ( 5 );
  3986. $rinfo = $receipt->getOne ( array (
  3987. 'where' => 'rid=' . $rid,
  3988. 'asArray' => true
  3989. ) );
  3990. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  3991. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  3992. if (empty ( $executeStaff )) {
  3993. $executeStaff = array (
  3994. $this->staff [0] ['sid'] => array (
  3995. 'date' => date ( 'Y-m-d' ),
  3996. 'opinion' => $implementOpinions,
  3997. 'status' => 1
  3998. )
  3999. );
  4000. } else {
  4001. $executeStaff [$this->staff [0] ['sid']] = array (
  4002. 'date' => date ( 'Y-m-d' ),
  4003. 'opinion' => $implementOpinions,
  4004. 'status' => 1
  4005. );
  4006. }
  4007. if (count ( $executeStaff ) == count ( $executeCopy )) {
  4008. $receipt->executeStaff = json_encode ( $executeStaff );
  4009. $receipt->status = 8;
  4010. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  4011. $receipt->status = 9;
  4012. if ($rinfo ['status'] == 6) {
  4013. $receipt->loanDate = date ( "Y-m-d" );
  4014. }
  4015. $receipt->executeDate = date ( "Y-m-d" );
  4016. } else {
  4017. $receipt->executeStaff = json_encode ( $executeStaff );
  4018. }
  4019. $receipt->amount = $amount;
  4020. $receipt->update ( array (
  4021. 'where' => 'rid=' . $rid
  4022. ) );
  4023. }
  4024. $ridKey = $XDeode->encode ( $rid );
  4025. return "/hisImplement";
  4026. // return "/implement/" . $ridKey . ".html";
  4027. }
  4028. function receiptburEdi() {
  4029. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4030. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  4031. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4032. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4033. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4034. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4035. if (empty ( $status ))
  4036. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  4037. $vidList = array ();
  4038. $button = 0;
  4039. Doo::loadModel ( 'verify' );
  4040. Doo::loadModel ( 'receipt' );
  4041. Doo::loadModel ( 'staff' );
  4042. $staff = new staff ();
  4043. $receipt = new receipt ();
  4044. $verify = new verify ();
  4045. Doo::loadModel ( 'L_category' );
  4046. $Lcategory = new L_category ();
  4047. Doo::loadModel ( 'enclosur' );
  4048. $enclosur = new enclosur ();
  4049. Doo::loadModel ( 'loanReceipt' );
  4050. $loanReceipt = new loanReceipt ();
  4051. // user verify ID
  4052. $verifyDetail = $verify->find ( array (
  4053. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  4054. 'asArray' => true
  4055. ) );
  4056. foreach ( $verifyDetail as $key => $value ) {
  4057. array_push ( $vidList, $value ['vid'] );
  4058. }
  4059. $vid = implode ( ",", $vidList );
  4060. if (empty ( $verifyDetail ))
  4061. $vid = 0;
  4062. $categoryList = $Lcategory->find ( array (
  4063. 'asArray' => true
  4064. ) );
  4065. $staffList = $staff->find ( array (
  4066. 'where' => 'cid=' . $cid,
  4067. 'asArray' => true
  4068. ) );
  4069. $ap = "";
  4070. if ($status == 4) {
  4071. $ap = 4;
  4072. $status = 2;
  4073. }
  4074. // get Receipt By verifyID status 2
  4075. $receiptList = $receipt->find ( array (
  4076. 'where' => 'rid =' . $rid . ' and status=2',
  4077. 'desc' => 'rid',
  4078. 'asArray' => true
  4079. ) );
  4080. if (empty ( $receiptList )) {
  4081. die ( 'illegal request' );
  4082. }
  4083. $loanList = $loanReceipt->find ( array (
  4084. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4085. 'desc' => 'rid',
  4086. 'asArray' => true
  4087. ) );
  4088. $data ['explanation'] = '';
  4089. if (! empty ( $loanList ))
  4090. $data ['explanation'] = $loanList [0] ['explanation'];
  4091. $Locate = 0;
  4092. $roleId = 0;
  4093. $button = 0;
  4094. foreach ( $loanList as $key => $value ) {
  4095. $loanList [$key] ['Locate'] = $Locate;
  4096. $Locate ++;
  4097. $loanList [$key] ['reviseDetail'] = array ();
  4098. if (! empty ( $value ['reviseDetail'] ))
  4099. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4100. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4101. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4102. $categoryDetil = $Lcategory->getOne ( array (
  4103. 'where' => 'cid=' . $value ['cid'],
  4104. 'asArray' => true
  4105. ) );
  4106. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4107. // 检测编辑状态
  4108. $verifyList = $verify->getOne ( array (
  4109. 'where' => 'vid=' . $value ['verify'],
  4110. 'asArray' => true
  4111. ) );
  4112. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4113. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4114. Doo::loadModel ( 'role' );
  4115. $role = new role ();
  4116. $flag = true;
  4117. $roleKey = 0;
  4118. $endStaffArray = array ();
  4119. $roleArrayCopy = array ();
  4120. foreach ( $verifyList as $k => $v ) {
  4121. // init verifyStaff
  4122. if ($v [1] == 'ROLE') {
  4123. if (! empty ( $verifyStaff )) {
  4124. $endStaffArray = end ( $verifyStaff );
  4125. }
  4126. $roleVerify = json_decode ( $v [3], true );
  4127. $roleKey = $k;
  4128. $roleArray = array ();
  4129. $rolename = $role->getOne ( array (
  4130. 'where' => 'rid=' . $v [0],
  4131. 'asArray' => true
  4132. ) );
  4133. foreach ( $roleVerify as $o => $p ) {
  4134. $staffID = explode ( '_', $p );
  4135. $staffInfo = $staff->getOne ( array (
  4136. 'where' => 'sid=' . $staffID [0],
  4137. 'asArray' => true
  4138. ) );
  4139. // print_r($staffID);
  4140. $exp = array (
  4141. 0 => $staffInfo ['sid'],
  4142. 1 => $staffID [1],
  4143. 2 => $staffInfo ['avatar'],
  4144. 'date' => '',
  4145. 'date' => '',
  4146. 'opinion' => '',
  4147. 'status' => '',
  4148. 'rolename' => $rolename ['name']
  4149. );
  4150. array_push ( $roleArray, $exp );
  4151. }
  4152. $roleArrayCopy [$v [0]] = $roleArray;
  4153. // $verifyList[$k]['roleArray']=$roleArray;
  4154. }
  4155. $verifyList [$k] ['date'] = "";
  4156. $verifyList [$k] ['opinion'] = "";
  4157. $verifyList [$k] ['status'] = "";
  4158. if (empty ( $verifyStaff )) {
  4159. $verifyList [$k] ['date'] = "";
  4160. $verifyList [$k] ['opinion'] = "";
  4161. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4162. $verifyList [$k] ['status'] = 4;
  4163. $flag = false;
  4164. }
  4165. } else {
  4166. foreach ( $verifyStaff as $m => $u ) {
  4167. if ($v [0] == $m) {
  4168. $verifyList [$k] ['date'] = $u ['date'];
  4169. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4170. $verifyList [$k] ['status'] = $u ['status'];
  4171. $flag = false;
  4172. break;
  4173. }
  4174. }
  4175. $endStaffArray = end ( $verifyStaff );
  4176. if (isset ( $endStaffArray ['ROLE'] )) {
  4177. } else {
  4178. }
  4179. }
  4180. }
  4181. $rolename ['name'] = '';
  4182. if (! empty ( $roleId )) {
  4183. Doo::loadModel ( 'role' );
  4184. $role = new role ();
  4185. $rolename = $role->getOne ( array (
  4186. 'where' => 'rid=' . $roleId,
  4187. 'asArray' => true
  4188. ) );
  4189. }
  4190. if (! empty ( $verifyStaff ))
  4191. $endStaffArray = end ( $verifyStaff );
  4192. $KOP = false;
  4193. foreach ( $roleArrayCopy as $P => $A ) {
  4194. foreach ( $A as $MKI => $AVL ) {
  4195. if (! empty ( $verifyStaff )) {
  4196. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4197. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4198. $button = 4;
  4199. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4200. }
  4201. foreach ( $verifyStaff as $m => $u ) {
  4202. $AVLFK = $AVL [0] . '_R';
  4203. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4204. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4205. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4206. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4207. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4208. break;
  4209. }
  4210. }
  4211. } else {
  4212. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4213. $button = 4;
  4214. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4215. }
  4216. }
  4217. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4218. $KOP = true;
  4219. }
  4220. }
  4221. foreach ( $roleArrayCopy as $k => $v ) {
  4222. foreach ( $verifyList as $m => $n ) {
  4223. if ($n [0] == $k) {
  4224. array_splice ( $verifyList, $m, 1, $v );
  4225. }
  4226. }
  4227. }
  4228. $loanList [$key] ['verifyList'] = $verifyList;
  4229. }
  4230. $htmlLoan = '';
  4231. if (isset ( $loanList [0] )) {
  4232. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  4233. if ($value ['status'] == 1)
  4234. $htmlLoan .= '<li class="done" >';
  4235. elseif ($value ['status'] == 3)
  4236. $htmlLoan .= '<li class="undone" >';
  4237. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  4238. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  4239. if (isset ( $value ['rolename'] ))
  4240. $htmlLoan .= $value ['rolename'];
  4241. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  4242. }
  4243. $data ['loanDate'] = $loanList [0] ['date'];
  4244. } else {
  4245. $data ['loanReceiptDate'] = ''; // $loanList [0] ['date'];
  4246. }
  4247. $data ['htmlLoan'] = $htmlLoan;
  4248. // $data ['LoanReceipt']=$loanList[0];
  4249. // print_r($loanList);
  4250. $Locate = 0;
  4251. $roleId = 0;
  4252. $button = 0;
  4253. if ($ap == 4)
  4254. $status = 4;
  4255. Doo::loadClass ( 'XDeode' );
  4256. $XDeode = new XDeode ( 5 );
  4257. foreach ( $receiptList as $key => $value ) {
  4258. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4259. $receiptList [$key] ['Locate'] = $Locate;
  4260. $Locate ++;
  4261. $receiptList [$key] ['reviseDetail'] = array ();
  4262. // 调整金额 代码调整
  4263. if (! empty ( $value ['reviseDetail'] )) {
  4264. $reviseDetail = json_decode ( $value ['reviseDetail'], true );
  4265. foreach ( $reviseDetail as $ry => $re ) {
  4266. $reviseDetail [$ry] ['sidKey'] = $XDeode->encode ( $re ['sid'] );
  4267. $reviseDetail [$ry] ['reviseKey'] = $XDeode->encode ( $ry );
  4268. }
  4269. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  4270. // print_r($reviseDetail);
  4271. }
  4272. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4273. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4274. $categoryDetil = $Lcategory->getOne ( array (
  4275. 'where' => 'cid=' . $value ['cid'],
  4276. 'asArray' => true
  4277. ) );
  4278. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4279. // 检测编辑状态
  4280. $verifyList = $verify->getOne ( array (
  4281. 'where' => 'vid=' . $value ['verify'],
  4282. 'asArray' => true
  4283. ) );
  4284. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4285. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4286. Doo::loadModel ( 'role' );
  4287. $role = new role ();
  4288. // print_r($verifyList);
  4289. $flag = true;
  4290. $roleKey = 0;
  4291. $endStaffArray = array ();
  4292. $roleArrayCopy = array ();
  4293. foreach ( $verifyList as $k => $v ) {
  4294. // init verifyStaff
  4295. if ($v [1] == 'ROLE') {
  4296. if (! empty ( $verifyStaff )) {
  4297. $endStaffArray = end ( $verifyStaff );
  4298. if ($v [0] == $endStaffArray ['nextStaff']) {
  4299. $roleId = $v [0];
  4300. }
  4301. }
  4302. $roleVerify = json_decode ( $v [3], true );
  4303. $roleKey = $k;
  4304. $roleArray = array ();
  4305. $rolename = $role->getOne ( array (
  4306. 'where' => 'rid=' . $v [0],
  4307. 'asArray' => true
  4308. ) );
  4309. foreach ( $roleVerify as $o => $p ) {
  4310. $staffID = explode ( '_', $p );
  4311. $staffInfo = $staff->getOne ( array (
  4312. 'where' => 'sid=' . $staffID [0],
  4313. 'asArray' => true
  4314. ) );
  4315. // print_r($staffID);
  4316. $exp = array (
  4317. 0 => $staffInfo ['sid'],
  4318. 1 => $staffID [1],
  4319. 2 => $staffInfo ['avatar'],
  4320. 'date' => '',
  4321. 'date' => '',
  4322. 'opinion' => '',
  4323. 'status' => '',
  4324. 'rolename' => $rolename ['name']
  4325. );
  4326. array_push ( $roleArray, $exp );
  4327. }
  4328. $roleArrayCopy [$v [0]] = $roleArray;
  4329. // $verifyList[$k]['roleArray']=$roleArray;
  4330. }
  4331. // print_r($roleArray);
  4332. $verifyList [$k] ['date'] = "";
  4333. $verifyList [$k] ['opinion'] = "";
  4334. $verifyList [$k] ['status'] = "";
  4335. if (empty ( $verifyStaff )) {
  4336. $verifyList [$k] ['date'] = "";
  4337. $verifyList [$k] ['opinion'] = "";
  4338. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4339. $verifyList [$k] ['status'] = 4;
  4340. $button = 4;
  4341. $flag = false;
  4342. }
  4343. } else {
  4344. foreach ( $verifyStaff as $m => $u ) {
  4345. if ($v [0] == $m) {
  4346. $verifyList [$k] ['date'] = $u ['date'];
  4347. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4348. $verifyList [$k] ['status'] = $u ['status'];
  4349. $flag = false;
  4350. break;
  4351. }
  4352. }
  4353. $endStaffArray = end ( $verifyStaff );
  4354. if (isset ( $endStaffArray ['ROLE'] )) {
  4355. } else {
  4356. $endKey = key ( $verifyStaff );
  4357. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4358. $button = 4;
  4359. $verifyList [$k] ['status'] = 4;
  4360. }
  4361. }
  4362. }
  4363. }
  4364. $rolename ['name'] = '';
  4365. if (! empty ( $roleId )) {
  4366. Doo::loadModel ( 'role' );
  4367. $role = new role ();
  4368. $rolename = $role->getOne ( array (
  4369. 'where' => 'rid=' . $roleId,
  4370. 'asArray' => true
  4371. ) );
  4372. }
  4373. if (! empty ( $verifyStaff ))
  4374. $endStaffArray = end ( $verifyStaff );
  4375. $KOP = false;
  4376. foreach ( $roleArrayCopy as $P => $A ) {
  4377. foreach ( $A as $MKI => $AVL ) {
  4378. if (! empty ( $verifyStaff )) {
  4379. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4380. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4381. $button = 4;
  4382. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4383. }
  4384. foreach ( $verifyStaff as $m => $u ) {
  4385. $AVLFK = $AVL [0] . '_R';
  4386. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4387. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4388. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4389. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4390. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4391. break;
  4392. }
  4393. }
  4394. } else {
  4395. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4396. $button = 4;
  4397. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4398. }
  4399. }
  4400. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4401. $KOP = true;
  4402. }
  4403. }
  4404. foreach ( $roleArrayCopy as $k => $v ) {
  4405. foreach ( $verifyList as $m => $n ) {
  4406. if ($n [0] == $k) {
  4407. array_splice ( $verifyList, $m, 1, $v );
  4408. }
  4409. }
  4410. }
  4411. // print_r($verifyList);
  4412. $receiptList [$key] ['verifyList'] = $verifyList;
  4413. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4414. 'where' => 'sid=' . $value ['staff'],
  4415. 'asArray' => true
  4416. ) );
  4417. $receiptList [$key] ['button'] = $button;
  4418. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4419. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4420. $relust = $value ['sum'] - $value ['loanSum'];
  4421. $receiptList [$key] ['relust'] = $relust;
  4422. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4423. }
  4424. // print_r($receiptList);die;
  4425. // $data['verifyDetail']=$verifyDetail;
  4426. $mothHtml = "";
  4427. for($i = 1; $i <= 12; $i ++) {
  4428. if ($month == $i)
  4429. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4430. else
  4431. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4432. }
  4433. // 获取审批日志
  4434. Doo::loadModel ( 'receiptLog' );
  4435. $receiptLog = new receiptLog ();
  4436. $rlList = array ();
  4437. $rlInfo = $receiptLog->getOne ( array (
  4438. 'where' => 'rid=' . $rid . ' and status=4',
  4439. 'asArray' => true
  4440. ) );
  4441. $tijdate = $receiptLog->getOne ( array (
  4442. 'where' => 'rid=' . $rid . ' and status=2',
  4443. 'asc' => 'rlid',
  4444. 'asArray' => true
  4445. ) );
  4446. if (! empty ( $rlInfo )) {
  4447. $rlList = $receiptLog->find ( array (
  4448. 'where' => 'rid=' . $rid,
  4449. 'asc' => 'rlid',
  4450. 'asArray' => true
  4451. ) );
  4452. }
  4453. // echo $rid;
  4454. // print_r($receiptList);
  4455. $receiptList [0] ['rlList'] = $rlList;
  4456. // print_r($receiptList);
  4457. $enclosurList = $enclosur->find ( array (
  4458. 'where' => 'rid=' . $rid,
  4459. 'asArray' => true
  4460. ) );
  4461. $enclosurHtml = '';
  4462. foreach ( $enclosurList as $value ) {
  4463. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4464. }
  4465. $data ['enclosurHtml'] = $enclosurHtml;
  4466. $data ['rolename'] = $rolename ['name'];
  4467. $data ['mothHtml'] = $mothHtml;
  4468. // print_r($receiptList);
  4469. $data ['rid'] = $rid;
  4470. $data ['tijdate'] = $tijdate ['date'];
  4471. $data ['receiptList'] = $receiptList;
  4472. $data ['receiptApprovalCount'] = count ( $receiptList );
  4473. $data ['status'] = $status;
  4474. $data ['year'] = $year;
  4475. $data ['categoryList'] = $categoryList;
  4476. $data ['staffList'] = $staffList;
  4477. $data ['cid'] = $cid;
  4478. $data ['sid'] = $sid;
  4479. $data ['ap'] = $ap;
  4480. $data ['memu'] = "receipt";
  4481. $data ['staff'] = $this->staff;
  4482. $data ['receiptMemu'] = 'approvalExpenses';
  4483. $data ['verifyId'] = $this->verifyId;
  4484. $data ['executeId'] = $this->executeId;
  4485. $this->render ( "/admin/receiptburEdi", $data );
  4486. }
  4487. function hisImplement() {
  4488. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4489. if (empty ( $item ))
  4490. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "expenses";
  4491. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  4492. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4493. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  4494. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  4495. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  4496. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'pendImplement';
  4497. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  4498. Doo::loadClass ( 'XDeode' );
  4499. $XDeode = new XDeode ( 5 );
  4500. Doo::loadModel ( 'receipt' );
  4501. $receipt = new receipt ();
  4502. Doo::loadModel ( 'L_category' );
  4503. $Lcategory = new L_category ();
  4504. Doo::loadModel ( 'verify' );
  4505. Doo::loadModel ( 'statistics' );
  4506. $statistics = new statistics ();
  4507. $verify = new verify ();
  4508. Doo::loadModel ( 'staff' );
  4509. $staff = new staff ();
  4510. Doo::loadClass ( 'XDeode' );
  4511. $XDeode = new XDeode ( 5 );
  4512. $cid = $XDeode->decode ( $cidKey );
  4513. $condition = "";
  4514. if ($item == "expenses")
  4515. $condition = " and Rtype=1 ";
  4516. elseif ($item == "receipts")
  4517. $condition = " and Rtype=0 ";
  4518. elseif ($item == "remits")
  4519. $condition = " and Rtype=2 ";
  4520. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  4521. $sopString = $cidString = "";
  4522. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  4523. if (empty ( $rdate ))
  4524. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  4525. else
  4526. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  4527. if ($status == 'pendImplement') {
  4528. $condition .= ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  4529. } elseif ($status == 'alerpts') {
  4530. $statusCon = '(status=8 or status=9 )';
  4531. if (empty ( $rdate ))
  4532. $dateCondition .= " and Year(date) =" . $year;
  4533. else
  4534. $dateCondition .= " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  4535. }
  4536. if ($sop != 'SOP')
  4537. $sopString = " and staff=" . $sop;
  4538. if ($cidKey != 'ALL')
  4539. $cidString = " and cid=" . $cid;
  4540. $receiptList = $receipt->find ( array (
  4541. 'where' => $statusCon . $condition . $dateCondition . $sopString . $cidString,
  4542. 'desc' => 'rid',
  4543. 'asArray' => true
  4544. ) );
  4545. // 员工筛选
  4546. $receiptList2 = $receipt->find ( array (
  4547. 'where' => $statusCon . $condition . $dateCondition,
  4548. 'desc' => 'rid',
  4549. 'asArray' => true
  4550. ) );
  4551. $sopStaff = array ();
  4552. foreach ( $receiptList2 as $key => $value ) {
  4553. $staffDetail = $staff->getOne ( array (
  4554. 'select' => 'username',
  4555. 'where' => 'sid=' . $value ['staff'],
  4556. 'asArray' => true
  4557. ) );
  4558. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  4559. }
  4560. // 办事处筛选
  4561. $categoryScreen = array ();
  4562. $categorList = $Lcategory->getCategory ();
  4563. foreach ( $receiptList2 as $key => $value ) {
  4564. foreach ( $categorList as $k => $v ) {
  4565. if ($value ['cid'] == $v ['cid']) {
  4566. $categoryScreen [$v ['cidKey']] = $v ['title'];
  4567. break;
  4568. }
  4569. }
  4570. }
  4571. $categoryScreenHtml = "";
  4572. foreach ( $categoryScreen as $key => $value ) {
  4573. if ($cidKey == $key)
  4574. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4575. else
  4576. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4577. }
  4578. $data ['categoryScreenHtml'] = $categoryScreenHtml;
  4579. $data ['cidKey'] = $cidKey;
  4580. $Locate = 0;
  4581. $roleId = 0;
  4582. $button = 0;
  4583. $staffBatchNumber = 100001;
  4584. $remittanceList = array ();
  4585. foreach ( $receiptList as $key => $value ) {
  4586. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4587. $receiptList [$key] ['Texe'] = 'false';
  4588. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  4589. $receiptList [$key] ['Texe'] = 'true';
  4590. }
  4591. $receiptList [$key] ['TRexe'] = 'true';
  4592. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  4593. $receiptList [$key] ['TRexe'] = 'false';
  4594. }
  4595. $receiptList [$key] ['Locate'] = $Locate;
  4596. $Locate ++;
  4597. $receiptList [$key] ['reviseDetail'] = array ();
  4598. if (! empty ( $value ['reviseDetail'] ))
  4599. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4600. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4601. $categoryDetil = $Lcategory->getOne ( array (
  4602. 'where' => 'cid=' . $value ['cid'],
  4603. 'asArray' => true
  4604. ) );
  4605. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4606. // 检测编辑状态
  4607. $verifyList = $verify->getOne ( array (
  4608. 'where' => 'vid=' . $value ['verify'],
  4609. 'asArray' => true
  4610. ) );
  4611. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4612. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4613. Doo::loadModel ( 'role' );
  4614. $role = new role ();
  4615. $flag = true;
  4616. $roleKey = 0;
  4617. $endStaffArray = array ();
  4618. $roleArrayCopy = array ();
  4619. foreach ( $verifyList as $k => $v ) {
  4620. // init verifyStaff
  4621. if ($v [1] == 'ROLE') {
  4622. if (! empty ( $verifyStaff )) {
  4623. $endStaffArray = end ( $verifyStaff );
  4624. }
  4625. $roleVerify = json_decode ( $v [3], true );
  4626. $roleKey = $k;
  4627. $roleArray = array ();
  4628. $rolename = $role->getOne ( array (
  4629. 'where' => 'rid=' . $v [0],
  4630. 'asArray' => true
  4631. ) );
  4632. foreach ( $roleVerify as $o => $p ) {
  4633. $staffID = explode ( '_', $p );
  4634. $staffInfo = $staff->getOne ( array (
  4635. 'where' => 'sid=' . $staffID [0],
  4636. 'asArray' => true
  4637. ) );
  4638. $exp = array (
  4639. 0 => $staffInfo ['sid'],
  4640. 1 => $staffID [1],
  4641. 2 => $staffInfo ['avatar'],
  4642. 'date' => '',
  4643. 'date' => '',
  4644. 'opinion' => '',
  4645. 'status' => '',
  4646. 'rolename' => $rolename ['name']
  4647. );
  4648. array_push ( $roleArray, $exp );
  4649. }
  4650. $roleArrayCopy [$v [0]] = $roleArray;
  4651. }
  4652. $verifyList [$k] ['date'] = "";
  4653. $verifyList [$k] ['opinion'] = "";
  4654. $verifyList [$k] ['status'] = "";
  4655. if (empty ( $verifyStaff )) {
  4656. $verifyList [$k] ['date'] = "";
  4657. $verifyList [$k] ['opinion'] = "";
  4658. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4659. $verifyList [$k] ['status'] = 4;
  4660. $flag = false;
  4661. }
  4662. } else {
  4663. foreach ( $verifyStaff as $m => $u ) {
  4664. if ($v [0] == $m) {
  4665. $verifyList [$k] ['date'] = $u ['date'];
  4666. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4667. $verifyList [$k] ['status'] = $u ['status'];
  4668. $flag = false;
  4669. break;
  4670. }
  4671. }
  4672. $endStaffArray = end ( $verifyStaff );
  4673. }
  4674. }
  4675. $rolename ['name'] = '';
  4676. if (! empty ( $roleId )) {
  4677. Doo::loadModel ( 'role' );
  4678. $role = new role ();
  4679. $rolename = $role->getOne ( array (
  4680. 'where' => 'rid=' . $roleId,
  4681. 'asArray' => true
  4682. ) );
  4683. }
  4684. if (! empty ( $verifyStaff ))
  4685. $endStaffArray = end ( $verifyStaff );
  4686. $KOP = false;
  4687. foreach ( $roleArrayCopy as $P => $A ) {
  4688. foreach ( $A as $MKI => $AVL ) {
  4689. if (! empty ( $verifyStaff )) {
  4690. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4691. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4692. $button = 4;
  4693. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4694. }
  4695. foreach ( $verifyStaff as $m => $u ) {
  4696. $AVLFK = $AVL [0] . '_R';
  4697. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4698. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4699. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4700. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4701. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4702. break;
  4703. }
  4704. }
  4705. } else {
  4706. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4707. $button = 4;
  4708. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4709. }
  4710. }
  4711. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4712. $KOP = true;
  4713. }
  4714. }
  4715. foreach ( $roleArrayCopy as $k => $v ) {
  4716. foreach ( $verifyList as $m => $n ) {
  4717. if ($n [0] == $k) {
  4718. array_splice ( $verifyList, $m, 1, $v );
  4719. }
  4720. }
  4721. }
  4722. $receiptList [$key] ['verifyList'] = $verifyList;
  4723. $staffDetail = $staff->getOne ( array (
  4724. 'where' => 'sid=' . $value ['staff'],
  4725. 'asArray' => true
  4726. ) );
  4727. $receiptList [$key] ['staffDetail'] = $staffDetail;
  4728. $receiptList [$key] ['button'] = $button;
  4729. // 设置导出汇款execl
  4730. if (! empty ( $value ['remittanceName'] ) && ! empty ( $value ['bankName'] ) && ! empty ( $value ['bankNumber'] )) {
  4731. $remittanceDetail = array (
  4732. $staffBatchNumber,
  4733. $value ['remittanceName'],
  4734. $value ['bankNumber'],
  4735. $value ['bankName'],
  4736. $value ['remittanceBankType'],
  4737. $value ['coupletNumber'],
  4738. $value ['sum']
  4739. );
  4740. array_push ( $remittanceList, $remittanceDetail );
  4741. $staffBatchNumber ++;
  4742. }
  4743. }
  4744. $data ['remittanceList'] = json_encode ( $remittanceList );
  4745. // print_r($receiptList);
  4746. $mothHtml = "";
  4747. for($i = 1; $i <= 12; $i ++) {
  4748. if ($moth == $i)
  4749. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4750. else
  4751. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4752. }
  4753. $dayHtml = "";
  4754. if ($day != "DAY" || $moth != "MONTH") {
  4755. for($i = 1; $i <= 31; $i ++) {
  4756. if ($day == $i)
  4757. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  4758. else
  4759. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  4760. }
  4761. }
  4762. $sopHtml = "";
  4763. foreach ( $sopStaff as $key => $value ) {
  4764. if ($sop == $key)
  4765. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4766. else
  4767. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4768. }
  4769. $data ['status'] = $status;
  4770. $data ['rdate'] = $rdate;
  4771. $data ['sopHtml'] = $sopHtml;
  4772. $data ['dayHtml'] = $dayHtml;
  4773. $data ['mothHtml'] = $mothHtml;
  4774. $data ['receiptList'] = $receiptList;
  4775. $data ['memu'] = "receipt";
  4776. $data ['staff'] = $this->staff;
  4777. $data ['receiptMemu'] = 'implement';
  4778. $data ['verifyId'] = $this->verifyId;
  4779. $data ['executeId'] = $this->executeId;
  4780. $data ['item'] = $item;
  4781. $data ['year'] = $year;
  4782. $data ['moth'] = $moth;
  4783. $data ['day'] = $day;
  4784. $data ['sop'] = $sop;
  4785. $this->render ( "/admin/hisImplement", $data );
  4786. }
  4787. /**
  4788. * 导出汇款信息的exelc
  4789. */
  4790. function exportRemittance() {
  4791. $remittanceInfo = $_POST ['remittanceInfo']; // $this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  4792. if (empty ( $remittanceInfo ))
  4793. die ( 'illegal request' );
  4794. $title = array (
  4795. '员工编号',
  4796. '姓名',
  4797. '员工账号',
  4798. '员工账户开户行',
  4799. '转账类型',
  4800. '联行号',
  4801. '金额'
  4802. );
  4803. $data = json_decode ( $remittanceInfo, true );
  4804. if (empty ( $data ))
  4805. die ( 'illegal request' );
  4806. Doo::loadClass ( 'receipt.func' );
  4807. exportExcel ( $title, $data, '批量日常报销-公司账号', './', true );
  4808. header ( 'Content-Type:text/html;charset=utf-8' );
  4809. die ( '导出' . count ( $data ) . '条数据,<a href="/hisImplement">返回</a>' );
  4810. }
  4811. function ajaxExamine() {
  4812. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4813. Doo::loadModel ( 'receipt' );
  4814. $receipt = new receipt ();
  4815. if (! empty ( $rid )) {
  4816. $rLRes = $receipt->find ( array (
  4817. '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,
  4818. 'asArray' => true
  4819. ) );
  4820. echo json_encode ( array (
  4821. 'status' => 1,
  4822. 'receipt' => $rLRes [0]
  4823. ) );
  4824. die ();
  4825. }
  4826. echo json_encode ( array (
  4827. 'status' => 0,
  4828. 'receipt' => array ()
  4829. ) );
  4830. die ();
  4831. }
  4832. /*
  4833. * 废弃
  4834. */
  4835. function myReceipt() {
  4836. // all approval past withdraw
  4837. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4838. if (empty ( $item ))
  4839. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4840. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4841. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  4842. Doo::loadModel ( 'receipt' );
  4843. $receipt = new receipt ();
  4844. // pre-loaded
  4845. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4846. // have cache
  4847. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  4848. if (! empty ( $moth )) // yearPage
  4849. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  4850. $this->showCache ( $path );
  4851. }
  4852. Doo::loadModel ( 'L_category' );
  4853. $Lcategory = new L_category ();
  4854. Doo::loadModel ( 'verify' );
  4855. Doo::loadModel ( 'statistics' );
  4856. $statistics = new statistics ();
  4857. $verify = new verify ();
  4858. Doo::loadModel ( 'staff' );
  4859. $staff = new staff ();
  4860. $condition = " and status!=0 ";
  4861. if ($item == "approval")
  4862. $condition = " and status=2 ";
  4863. elseif ($item == "withdraw")
  4864. $condition = " and status=3 ";
  4865. elseif ($item == "past")
  4866. $condition = " and status=1 ";
  4867. elseif ($item == "whdw")
  4868. $condition = " and status=4 ";
  4869. $dateCondition = " and Year(date) =" . $year;
  4870. if (! empty ( $moth )) {
  4871. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  4872. $stList = $statistics->getOne ( array (
  4873. 'select' => 'rePrice ,agPrice',
  4874. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  4875. 'asArray' => true
  4876. ) );
  4877. } else
  4878. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  4879. if (empty ( $stList ))
  4880. $stList = array (
  4881. 'rePrice' => 0,
  4882. 'agPrice' => 0
  4883. );
  4884. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  4885. $data ['stList'] = array (
  4886. 'rePrice' => $stList ['rePrice'],
  4887. 'agPrice' => $stList ['agPrice'],
  4888. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  4889. );
  4890. $receiptList = $receipt->find ( array (
  4891. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  4892. 'desc' => 'rid',
  4893. 'asArray' => true
  4894. ) );
  4895. $Locate = 0;
  4896. $roleId = 0;
  4897. $button = 0;
  4898. foreach ( $receiptList as $key => $value ) {
  4899. $receiptList [$key] ['Locate'] = $Locate;
  4900. $Locate ++;
  4901. $receiptList [$key] ['reviseDetail'] = array ();
  4902. if (! empty ( $value ['reviseDetail'] ))
  4903. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4904. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4905. $categoryDetil = $Lcategory->getOne ( array (
  4906. 'where' => 'cid=' . $value ['cid'],
  4907. 'asArray' => true
  4908. ) );
  4909. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4910. // 检测编辑状态
  4911. $verifyList = $verify->getOne ( array (
  4912. 'where' => 'vid=' . $value ['verify'],
  4913. 'asArray' => true
  4914. ) );
  4915. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4916. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4917. Doo::loadModel ( 'role' );
  4918. $role = new role ();
  4919. $flag = true;
  4920. $roleKey = 0;
  4921. $endStaffArray = array ();
  4922. $roleArrayCopy = array ();
  4923. foreach ( $verifyList as $k => $v ) {
  4924. // init verifyStaff
  4925. if ($v [1] == 'ROLE') {
  4926. if (! empty ( $verifyStaff )) {
  4927. $endStaffArray = end ( $verifyStaff );
  4928. // if ($v[0]==$endStaffArray['nextStaff']){
  4929. // $roleId=$v[0];
  4930. // }
  4931. }
  4932. $roleVerify = json_decode ( $v [3], true );
  4933. $roleKey = $k;
  4934. $roleArray = array ();
  4935. $rolename = $role->getOne ( array (
  4936. 'where' => 'rid=' . $v [0],
  4937. 'asArray' => true
  4938. ) );
  4939. foreach ( $roleVerify as $o => $p ) {
  4940. $staffID = explode ( '_', $p );
  4941. $staffInfo = $staff->getOne ( array (
  4942. 'where' => 'sid=' . $staffID [0],
  4943. 'asArray' => true
  4944. ) );
  4945. // print_r($staffID);
  4946. $exp = array (
  4947. 0 => $staffInfo ['sid'],
  4948. 1 => $staffID [1],
  4949. 2 => $staffInfo ['avatar'],
  4950. 'date' => '',
  4951. 'date' => '',
  4952. 'opinion' => '',
  4953. 'status' => '',
  4954. 'rolename' => $rolename ['name']
  4955. );
  4956. array_push ( $roleArray, $exp );
  4957. }
  4958. $roleArrayCopy [$v [0]] = $roleArray;
  4959. // $verifyList[$k]['roleArray']=$roleArray;
  4960. }
  4961. $verifyList [$k] ['date'] = "";
  4962. $verifyList [$k] ['opinion'] = "";
  4963. $verifyList [$k] ['status'] = "";
  4964. if (empty ( $verifyStaff )) {
  4965. $verifyList [$k] ['date'] = "";
  4966. $verifyList [$k] ['opinion'] = "";
  4967. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4968. $verifyList [$k] ['status'] = 4;
  4969. $flag = false;
  4970. }
  4971. } else {
  4972. foreach ( $verifyStaff as $m => $u ) {
  4973. if ($v [0] == $m) {
  4974. $verifyList [$k] ['date'] = $u ['date'];
  4975. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4976. $verifyList [$k] ['status'] = $u ['status'];
  4977. $flag = false;
  4978. break;
  4979. }
  4980. }
  4981. $endStaffArray = end ( $verifyStaff );
  4982. if (isset ( $endStaffArray ['ROLE'] )) {
  4983. } else {
  4984. // $endKey=key($verifyStaff);
  4985. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4986. // $button=4;
  4987. // $verifyList[$k]['status']=4;
  4988. // }
  4989. }
  4990. }
  4991. }
  4992. $rolename ['name'] = '';
  4993. if (! empty ( $roleId )) {
  4994. Doo::loadModel ( 'role' );
  4995. $role = new role ();
  4996. $rolename = $role->getOne ( array (
  4997. 'where' => 'rid=' . $roleId,
  4998. 'asArray' => true
  4999. ) );
  5000. }
  5001. if (! empty ( $verifyStaff ))
  5002. $endStaffArray = end ( $verifyStaff );
  5003. $KOP = false;
  5004. foreach ( $roleArrayCopy as $P => $A ) {
  5005. foreach ( $A as $MKI => $AVL ) {
  5006. if (! empty ( $verifyStaff )) {
  5007. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5008. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5009. $button = 4;
  5010. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5011. }
  5012. foreach ( $verifyStaff as $m => $u ) {
  5013. $AVLFK = $AVL [0] . '_R';
  5014. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5015. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5016. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5017. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5018. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5019. break;
  5020. }
  5021. }
  5022. } else {
  5023. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5024. $button = 4;
  5025. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5026. }
  5027. }
  5028. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5029. $KOP = true;
  5030. }
  5031. }
  5032. foreach ( $roleArrayCopy as $k => $v ) {
  5033. foreach ( $verifyList as $m => $n ) {
  5034. if ($n [0] == $k) {
  5035. array_splice ( $verifyList, $m, 1, $v );
  5036. }
  5037. }
  5038. }
  5039. $receiptList [$key] ['verifyList'] = $verifyList;
  5040. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5041. 'where' => 'sid=' . $value ['staff'],
  5042. 'asArray' => true
  5043. ) );
  5044. $receiptList [$key] ['button'] = $button;
  5045. }
  5046. // print_r($receiptList);die;
  5047. $mothHtml = "";
  5048. for($i = 1; $i <= 12; $i ++) {
  5049. if ($moth == $i)
  5050. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5051. else
  5052. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5053. }
  5054. $data ['mothHtml'] = $mothHtml;
  5055. $data ['receiptList'] = $receiptList;
  5056. $data ['memu'] = "receipt";
  5057. $data ['staff'] = $this->staff;
  5058. $data ['receiptMemu'] = 'receipt';
  5059. $data ['verifyId'] = $this->verifyId;
  5060. $data ['executeId'] = $this->executeId;
  5061. $data ['item'] = $item;
  5062. $data ['year'] = $year;
  5063. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  5064. // sufficient condition to generate cache
  5065. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  5066. $receiptList = $receipt->find ( array (
  5067. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  5068. 'asArray' => true
  5069. ) );
  5070. if (empty ( $receiptList )) { // generated files
  5071. ob_start ();
  5072. $this->render ( "/admin/saea_myList", $data );
  5073. $this->cacheFile ( $path );
  5074. die ();
  5075. // $content = ob_get_contents();
  5076. // $fp = fopen($path, "w");
  5077. // fwrite($fp, $content);
  5078. // fclose($fp);
  5079. }
  5080. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  5081. $receiptList = $receipt->find ( array (
  5082. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  5083. 'asArray' => true
  5084. ) );
  5085. if (empty ( $receiptList )) { // generated files
  5086. ob_start ();
  5087. $this->render ( "/admin/saea_myList", $data );
  5088. $this->cacheFile ( $path );
  5089. die ();
  5090. }
  5091. }
  5092. }
  5093. $this->render ( "/admin/saea_myList", $data );
  5094. }
  5095. function saeaCreate() {
  5096. Doo::loadModel ( 'accountItem' );
  5097. Doo::loadModel ( 'verify' );
  5098. Doo::loadModel ( 'receipt' );
  5099. Doo::loadModel ( 'L_category' );
  5100. $lCategory = new L_category ();
  5101. $receipt = new receipt ();
  5102. $verify = new verify ();
  5103. $accountItem = new accountItem ();
  5104. Doo::loadModel ( "role" );
  5105. $role = new role ();
  5106. $acItem = $accountItem->find ( array (
  5107. 'asArray' => true
  5108. ) );
  5109. $veList = $verify->find ( array (
  5110. 'asArray' => true
  5111. ) );
  5112. foreach ( $veList as $key => $value ) {
  5113. $v = json_decode ( $value ['staff'] );
  5114. $list = array ();
  5115. foreach ( $v as $n => $m ) {
  5116. if ($m ['1'] == 'ROLE') {
  5117. $roleInfo = $role->getOne ( array (
  5118. 'where' => 'rid=' . $m [0],
  5119. 'asArray' => true
  5120. ) );
  5121. $v [$n] [1] = $roleInfo ['name'];
  5122. array_push ( $list, $roleInfo ['name'] );
  5123. } else {
  5124. array_push ( $list, $v [$n] [1] );
  5125. }
  5126. }
  5127. $veList [$key] ['staff'] = implode ( '>', $list );
  5128. }
  5129. $data ['category'] = $lCategory->find ( array (
  5130. 'asArray' => true
  5131. ) );
  5132. $data ['veList'] = $veList;
  5133. $data ['acItem'] = $acItem;
  5134. $data ['memu'] = "receipt";
  5135. $data ['staff'] = $this->staff;
  5136. $data ['receiptMemu'] = 'saeaBorad';
  5137. $data ['verifyId'] = $this->verifyId;
  5138. $data ['executeId'] = $this->executeId;
  5139. $this->render ( "/admin/saea_create", $data );
  5140. }
  5141. function addReceipt() {
  5142. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  5143. $agency = $this->get_args ( 'agency' );
  5144. $travel = $this->get_args ( 'travel' );
  5145. $train = $this->get_args ( 'train' );
  5146. $other = $this->get_args ( 'other' );
  5147. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5148. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5149. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5150. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  5151. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  5152. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  5153. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  5154. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  5155. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  5156. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  5157. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  5158. header ( 'Content-Type:text/html;charset=utf-8' );
  5159. die ( '请填写联行号' );
  5160. }
  5161. Doo::loadModel ( 'receipt' );
  5162. Doo::loadModel ( 'receiptDetail' );
  5163. Doo::loadModel ( 'accountItem' );
  5164. $accountItem = new accountItem ();
  5165. $receipt = new receipt ();
  5166. Doo::loadModel ( 'enclosur' );
  5167. Doo::loadModel ( 'execute' );
  5168. $execute = new execute ();
  5169. $executeDetail = $execute->getOne ( array (
  5170. 'where' => 'mold="报销单执行人"',
  5171. 'asArray' => true
  5172. ) );
  5173. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  5174. // if(!empty($receiptDetail))
  5175. // return "/referReceipt/".$receiptDetail['rid'];
  5176. $aItem = $accountItem->find ( array (
  5177. 'asArray' => true
  5178. ) );
  5179. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5180. $ag = $tr = $ta = $ot = 0;
  5181. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5182. foreach ( $aItem as $key => $value ) {
  5183. if ($value ['category'] == $this->AGENCY) {
  5184. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5185. array_push ( $accountJson [$this->AGENCY], array (
  5186. 'aid' => $value ['aid'],
  5187. 'name' => $value ['name'],
  5188. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5189. ) );
  5190. $sum += $agency [$ag];
  5191. $agencySum += $agency [$ag];
  5192. }
  5193. $ag ++;
  5194. }
  5195. if ($value ['category'] == $this->TRAVEL) {
  5196. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5197. array_push ( $accountJson [$this->TRAVEL], array (
  5198. 'aid' => $value ['aid'],
  5199. 'name' => $value ['name'],
  5200. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5201. ) );
  5202. $sum += $travel [$tr];
  5203. $travelSum += $travel [$tr];
  5204. }
  5205. $tr ++;
  5206. }
  5207. if ($value ['category'] == $this->TRAIN) {
  5208. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5209. array_push ( $accountJson [$this->TRAIN], array (
  5210. 'aid' => $value ['aid'],
  5211. 'name' => $value ['name'],
  5212. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5213. ) );
  5214. $sum += $train [$ta];
  5215. $trainSum += $train [$ta];
  5216. }
  5217. $ta ++;
  5218. }
  5219. if ($value ['category'] == $this->OTHER) {
  5220. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5221. array_push ( $accountJson [$this->OTHER], array (
  5222. 'aid' => $value ['aid'],
  5223. 'name' => $value ['name'],
  5224. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5225. ) );
  5226. $sum += $other [$ot];
  5227. $otherSum += $other [$ot];
  5228. }
  5229. $ot ++;
  5230. }
  5231. }
  5232. $accountJson ['cSum'] = array (
  5233. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5234. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5235. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5236. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5237. );
  5238. // 报销单
  5239. $receipt->accountItem = json_encode ( $accountJson );
  5240. $receipt->staff = $this->staff [0] ['sid'];
  5241. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5242. $receipt->date = date ( "Y-m-d" );
  5243. $receipt->cid = $cid;
  5244. $receipt->status = 5;
  5245. // 修改审批流程加入角色
  5246. $receipt->verify = $verify;
  5247. $receipt->executeCopy = $executeDetail ['staff'];
  5248. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  5249. $receipt->explanation = $explanation;
  5250. $receipt->remittanceName = $remittanceName;
  5251. $receipt->bankName = $bankName;
  5252. $receipt->bankNumber = $bankNumber;
  5253. $receipt->remittanceBankType = $remittanceBankType;
  5254. if ($remittanceBankType == 1)
  5255. $receipt->coupletNumber = $coupletNumber;
  5256. $rid = $receipt->insert ();
  5257. // 附件
  5258. if (! empty ( $enclosurName )) {
  5259. $enclosurArray = explode ( '-', $enclosurName );
  5260. foreach ( $enclosurArray as $value ) {
  5261. $enclosur = new enclosur ();
  5262. $enclosur->name = $value;
  5263. $enclosur->rid = $rid;
  5264. $enclosur->insert ();
  5265. }
  5266. // print_r($enclosurArray);die;
  5267. }
  5268. // 报销详情
  5269. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5270. $receiptDetail = new receiptDetail ();
  5271. $receiptDetail->staff = $this->staff [0] ['sid'];
  5272. $receiptDetail->item = $value ['name'];
  5273. $receiptDetail->itemCategory = $this->AGENCY;
  5274. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5275. $receiptDetail->date = date ( "Y-m-d" );
  5276. $receiptDetail->cid = $cid;
  5277. $receiptDetail->rid = $rid;
  5278. $receiptDetail->status = 4;
  5279. $receiptDetail->insert ();
  5280. }
  5281. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5282. $receiptDetail = new receiptDetail ();
  5283. $receiptDetail->staff = $this->staff [0] ['sid'];
  5284. $receiptDetail->item = $value ['name'];
  5285. $receiptDetail->itemCategory = $this->TRAVEL;
  5286. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5287. $receiptDetail->date = date ( "Y-m-d" );
  5288. $receiptDetail->cid = $cid;
  5289. $receiptDetail->rid = $rid;
  5290. $receiptDetail->status = 4;
  5291. $receiptDetail->insert ();
  5292. }
  5293. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5294. $receiptDetail = new receiptDetail ();
  5295. $receiptDetail->staff = $this->staff [0] ['sid'];
  5296. $receiptDetail->item = $value ['name'];
  5297. $receiptDetail->itemCategory = $this->TRAIN;
  5298. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5299. $receiptDetail->date = date ( "Y-m-d" );
  5300. $receiptDetail->cid = $cid;
  5301. $receiptDetail->rid = $rid;
  5302. $receiptDetail->status = 4;
  5303. $receiptDetail->insert ();
  5304. }
  5305. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5306. $receiptDetail = new receiptDetail ();
  5307. $receiptDetail->staff = $this->staff [0] ['sid'];
  5308. $receiptDetail->item = $value ['name'];
  5309. $receiptDetail->itemCategory = $this->OTHER;
  5310. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5311. $receiptDetail->date = date ( "Y-m-d" );
  5312. $receiptDetail->cid = $cid;
  5313. $receiptDetail->rid = $rid;
  5314. $receiptDetail->status = 4;
  5315. $receiptDetail->insert ();
  5316. }
  5317. return "/saeaBorad";
  5318. } else
  5319. die ( 'illegal request' );
  5320. }
  5321. function referReceipt() {
  5322. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  5323. Doo::loadModel ( 'receipt' );
  5324. Doo::loadModel ( 'verify' );
  5325. $verify = new verify ();
  5326. $receipt = new receipt ();
  5327. Doo::loadModel ( 'L_category' );
  5328. $lCategory = new L_category ();
  5329. Doo::loadModel ( "role" );
  5330. $role = new role ();
  5331. $receiptDetail = $receipt->find ( array (
  5332. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  5333. 'asArray' => true
  5334. ) );
  5335. if (empty ( $receiptDetail ))
  5336. return "/addReceipt";
  5337. foreach ( $receiptDetail as $key => $value ) {
  5338. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5339. $veList = $verify->getOne ( array (
  5340. 'where' => 'vid=' . $value ['verify'],
  5341. 'asArray' => true
  5342. ) );
  5343. $v = json_decode ( $veList ['staff'] );
  5344. array_push ( $v [0], $veList ['description'] );
  5345. foreach ( $v as $n => $m ) {
  5346. if ($m ['1'] == 'ROLE') {
  5347. $roleInfo = $role->getOne ( array (
  5348. 'where' => 'rid=' . $m [0],
  5349. 'asArray' => true
  5350. ) );
  5351. $v [$n] [1] = $roleInfo ['name'];
  5352. }
  5353. }
  5354. $receiptDetail [$key] ['staff'] = $v;
  5355. $category = $lCategory->getOne ( array (
  5356. 'where' => 'cid=' . $value ['cid'],
  5357. 'asArray' => true
  5358. ) );
  5359. $receiptDetail [$key] ['category'] = $category ['title'];
  5360. }
  5361. // print_r($receiptDetail);
  5362. $data ['receiptDetail'] = $receiptDetail;
  5363. $data ['memu'] = "receipt";
  5364. $data ['staff'] = $this->staff;
  5365. $data ['receiptMemu'] = 'saeaCreate';
  5366. $data ['verifyId'] = $this->verifyId;
  5367. $data ['executeId'] = $this->executeId;
  5368. $this->render ( "/admin/saea_confirm", $data );
  5369. }
  5370. function editReceipt() {
  5371. // edit status 4
  5372. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  5373. Doo::loadClass ( 'XDeode' );
  5374. $XDeode = new XDeode ( 7 );
  5375. $rid = $XDeode->decode ( $ridKey );
  5376. if (empty ( $rid ))
  5377. die ( 'illegal request' );
  5378. // echo $rid.'sd';
  5379. Doo::loadModel ( 'accountItem' );
  5380. Doo::loadModel ( 'verify' );
  5381. Doo::loadModel ( 'receipt' );
  5382. $receipt = new receipt ();
  5383. $verify = new verify ();
  5384. $accountItem = new accountItem ();
  5385. Doo::loadModel ( 'L_category' );
  5386. $lCategory = new L_category ();
  5387. Doo::loadModel ( "role" );
  5388. $role = new role ();
  5389. Doo::loadModel ( 'enclosur' );
  5390. $enclosur = new enclosur ();
  5391. $receiptDetail = $receipt->getOne ( array (
  5392. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  5393. 'asArray' => true
  5394. ) );
  5395. if (empty ( $receiptDetail ))
  5396. die ( 'illegal request' );
  5397. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  5398. $acItem = $accountItem->find ( array (
  5399. 'asArray' => true
  5400. ) );
  5401. $veList = $verify->find ( array (
  5402. 'asArray' => true
  5403. ) );
  5404. foreach ( $veList as $key => $value ) {
  5405. $v = json_decode ( $value ['staff'] );
  5406. $list = array ();
  5407. foreach ( $v as $n => $m ) {
  5408. if ($m ['1'] == 'ROLE') {
  5409. $roleInfo = $role->getOne ( array (
  5410. 'where' => 'rid=' . $m [0],
  5411. 'asArray' => true
  5412. ) );
  5413. $v [$n] [1] = $roleInfo ['name'];
  5414. array_push ( $list, $roleInfo ['name'] );
  5415. } else {
  5416. array_push ( $list, $v [$n] [1] );
  5417. }
  5418. }
  5419. $veList [$key] ['staff'] = implode ( '>', $list );
  5420. }
  5421. // 配置编辑信息
  5422. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  5423. foreach ( $acItem as $key => $value ) {
  5424. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  5425. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  5426. $acItem [$key] ['price'] = $v ['price'];
  5427. }
  5428. }
  5429. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  5430. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  5431. $acItem [$key] ['price'] = $v ['price'];
  5432. }
  5433. }
  5434. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  5435. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  5436. $acItem [$key] ['price'] = $v ['price'];
  5437. }
  5438. }
  5439. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  5440. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  5441. $acItem [$key] ['price'] = $v ['price'];
  5442. }
  5443. }
  5444. }
  5445. $data ['category'] = $lCategory->find ( array (
  5446. 'asArray' => true
  5447. ) );
  5448. $data ['cSum'] = $accountItemList ['cSum'];
  5449. $data ['sum'] = $receiptDetail ['sum'];
  5450. $data ['enclosurList'] = $enclosurList;
  5451. $data ['receiptDetail'] = $receiptDetail;
  5452. $data ['veList'] = $veList;
  5453. $data ['acItem'] = $acItem;
  5454. $data ['memu'] = "receipt";
  5455. $data ['staff'] = $this->staff;
  5456. $data ['receiptMemu'] = 'saeaBorad';
  5457. $data ['verify'] = $receiptDetail ['verify'];
  5458. $data ['verifyId'] = $this->verifyId;
  5459. $data ['executeId'] = $this->executeId;
  5460. $data ['rid'] = $ridKey;
  5461. $this->render ( "/admin/saea_edit", $data );
  5462. }
  5463. function updateReceipt() {
  5464. $agency = $this->get_args ( 'agency' );
  5465. $travel = $this->get_args ( 'travel' );
  5466. $train = $this->get_args ( 'train' );
  5467. $other = $this->get_args ( 'other' );
  5468. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5469. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5470. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5471. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  5472. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  5473. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  5474. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  5475. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  5476. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  5477. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  5478. Doo::loadClass ( 'XDeode' );
  5479. $XDeode = new XDeode ( 7 );
  5480. $rid = $XDeode->decode ( $ridKey );
  5481. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  5482. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  5483. header ( 'Content-Type:text/html;charset=utf-8' );
  5484. die ( '请填写联行号' );
  5485. }
  5486. Doo::loadModel ( 'receipt' );
  5487. Doo::loadModel ( 'receiptDetail' );
  5488. Doo::loadModel ( 'accountItem' );
  5489. $accountItem = new accountItem ();
  5490. $receipt = new receipt ();
  5491. Doo::loadModel ( 'enclosur' );
  5492. Doo::loadModel ( 'execute' );
  5493. $execute = new execute ();
  5494. $receiptDetail = $receipt->getOne ( array (
  5495. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  5496. 'asArray' => true
  5497. ) );
  5498. if (empty ( $receiptDetail ))
  5499. return "/saeaBorad";
  5500. if ($receiptDetail ['Rtype'] == 1)
  5501. $executeDetail = $execute->getOne ( array (
  5502. 'where' => 'mold="借款费用执行人"',
  5503. 'asArray' => true
  5504. ) );
  5505. else
  5506. $executeDetail = $execute->getOne ( array (
  5507. 'where' => 'mold="报销单执行人"',
  5508. 'asArray' => true
  5509. ) );
  5510. $aItem = $accountItem->find ( array (
  5511. 'asArray' => true
  5512. ) );
  5513. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5514. $ag = $tr = $ta = $ot = 0;
  5515. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5516. foreach ( $aItem as $key => $value ) {
  5517. if ($value ['category'] == $this->AGENCY) {
  5518. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5519. array_push ( $accountJson [$this->AGENCY], array (
  5520. 'aid' => $value ['aid'],
  5521. 'name' => $value ['name'],
  5522. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5523. ) );
  5524. $sum += $agency [$ag];
  5525. $agencySum += $agency [$ag];
  5526. }
  5527. $ag ++;
  5528. }
  5529. if ($value ['category'] == $this->TRAVEL) {
  5530. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5531. array_push ( $accountJson [$this->TRAVEL], array (
  5532. 'aid' => $value ['aid'],
  5533. 'name' => $value ['name'],
  5534. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5535. ) );
  5536. $sum += $travel [$tr];
  5537. $travelSum += $travel [$tr];
  5538. }
  5539. $tr ++;
  5540. }
  5541. if ($value ['category'] == $this->TRAIN) {
  5542. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5543. array_push ( $accountJson [$this->TRAIN], array (
  5544. 'aid' => $value ['aid'],
  5545. 'name' => $value ['name'],
  5546. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5547. ) );
  5548. $sum += $train [$ta];
  5549. $trainSum += $train [$ta];
  5550. }
  5551. $ta ++;
  5552. }
  5553. if ($value ['category'] == $this->OTHER) {
  5554. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5555. array_push ( $accountJson [$this->OTHER], array (
  5556. 'aid' => $value ['aid'],
  5557. 'name' => $value ['name'],
  5558. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5559. ) );
  5560. $sum += $other [$ot];
  5561. $otherSum += $other [$ot];
  5562. }
  5563. $ot ++;
  5564. }
  5565. }
  5566. $accountJson ['cSum'] = array (
  5567. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5568. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5569. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5570. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5571. );
  5572. // 报销单
  5573. $rid = $receipt->rid = $receiptDetail ['rid'];
  5574. $receipt->accountItem = json_encode ( $accountJson );
  5575. $receipt->staff = $this->staff [0] ['sid'];
  5576. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5577. $receipt->date = date ( "Y-m-d" );
  5578. $receipt->cid = $cid;
  5579. if (($receiptDetail ['status'] != 4)) {
  5580. if ($receiptDetail ['Rtype'] == 1)
  5581. $receipt->status = 7;
  5582. else
  5583. $receipt->status = 5;
  5584. }
  5585. if ($receiptDetail != 4 && ! empty ( $verify ))
  5586. $receipt->verify = $verify;
  5587. $receipt->executeCopy = $executeDetail ['staff'];
  5588. $receipt->explanation = $explanation;
  5589. $receipt->remittanceName = $remittanceName;
  5590. $receipt->bankName = $bankName;
  5591. $receipt->bankNumber = $bankNumber;
  5592. $receipt->remittanceBankType = $remittanceBankType;
  5593. if ($remittanceBankType == 1)
  5594. $receipt->coupletNumber = $coupletNumber;
  5595. $receipt->update ();
  5596. $receiptDetail = new receiptDetail ();
  5597. $receiptDetail->delete ( array (
  5598. 'where' => 'rid=' . $rid
  5599. ) );
  5600. // 报销详情
  5601. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5602. $receiptDetail = new receiptDetail ();
  5603. $receiptDetail->staff = $this->staff [0] ['sid'];
  5604. $receiptDetail->item = $value ['name'];
  5605. $receiptDetail->itemCategory = $this->AGENCY;
  5606. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5607. $receiptDetail->date = date ( "Y-m-d" );
  5608. $receiptDetail->cid = $cid;
  5609. $receiptDetail->rid = $rid;
  5610. $receiptDetail->status = 4;
  5611. $receiptDetail->insert ();
  5612. }
  5613. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5614. $receiptDetail = new receiptDetail ();
  5615. $receiptDetail->staff = $this->staff [0] ['sid'];
  5616. $receiptDetail->item = $value ['name'];
  5617. $receiptDetail->itemCategory = $this->TRAVEL;
  5618. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5619. $receiptDetail->date = date ( "Y-m-d" );
  5620. $receiptDetail->cid = $cid;
  5621. $receiptDetail->rid = $rid;
  5622. $receiptDetail->status = 4;
  5623. $receiptDetail->insert ();
  5624. }
  5625. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5626. $receiptDetail = new receiptDetail ();
  5627. $receiptDetail->staff = $this->staff [0] ['sid'];
  5628. $receiptDetail->item = $value ['name'];
  5629. $receiptDetail->itemCategory = $this->TRAIN;
  5630. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5631. $receiptDetail->date = date ( "Y-m-d" );
  5632. $receiptDetail->cid = $cid;
  5633. $receiptDetail->rid = $rid;
  5634. $receiptDetail->status = 4;
  5635. $receiptDetail->insert ();
  5636. }
  5637. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5638. $receiptDetail = new receiptDetail ();
  5639. $receiptDetail->staff = $this->staff [0] ['sid'];
  5640. $receiptDetail->item = $value ['name'];
  5641. $receiptDetail->itemCategory = $this->OTHER;
  5642. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5643. $receiptDetail->date = date ( "Y-m-d" );
  5644. $receiptDetail->cid = $cid;
  5645. $receiptDetail->rid = $rid;
  5646. $receiptDetail->status = 4;
  5647. $receiptDetail->insert ();
  5648. }
  5649. // 附件
  5650. if (! empty ( $enclosurName )) {
  5651. $enclosurArray = explode ( '-', $enclosurName );
  5652. foreach ( $enclosurArray as $value ) {
  5653. $enclosur = new enclosur ();
  5654. $enclosur->name = $value;
  5655. $enclosur->rid = $rid;
  5656. $enclosur->insert ();
  5657. }
  5658. }
  5659. // return "/referReceipt/".$rid;
  5660. }
  5661. return "/saeaBorad";
  5662. }
  5663. function approvedReceipt() {
  5664. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5665. Doo::loadModel ( 'receipt' );
  5666. Doo::loadModel ( 'receiptDetail' );
  5667. $receipt = new receipt ();
  5668. $receiptDetail = new receiptDetail ();
  5669. Doo::loadModel ( 'statistics' );
  5670. Doo::loadModel ( 'itemStatistics' );
  5671. $statistics = new statistics ();
  5672. $itemStatistics = new itemStatistics ();
  5673. Doo::loadModel ( "verify" );
  5674. $verify = new verify ();
  5675. // 审批状态的判定
  5676. $receiptDetailList = $receipt->getOne ( array (
  5677. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  5678. 'asArray' => true
  5679. ) );
  5680. if (empty ( $receiptDetailList ))
  5681. return "/saeaBorad";
  5682. $verifyDetail = $verify->getOne ( array (
  5683. 'where' => ' vid =' . $receiptDetailList ['verify'],
  5684. 'asArray' => true
  5685. ) );
  5686. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5687. if (empty ( $receiptDetailList ['nowStaff'] )) {
  5688. $nowStaff = "";
  5689. $nowStaffList = array ();
  5690. if ($verifyDetail [0] [1] == 'ROLE') {
  5691. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5692. foreach ( $vStaffString as $key => $value ) {
  5693. $staffK = explode ( "_", $value );
  5694. array_push ( $nowStaffList, $staffK [0] );
  5695. }
  5696. $nowStaff = implode ( ',', $nowStaffList );
  5697. } else {
  5698. $nowStaff = $verifyDetail [0] [0];
  5699. }
  5700. $receipt->nowStaff = $nowStaff;
  5701. }
  5702. // echo $nowStaff;
  5703. // print_r($verifyDetail);die;
  5704. $receipt->rid = $receiptDetailList ['rid'];
  5705. $receipt->date = date ( "Y-m-d" );
  5706. $receipt->status = 2;
  5707. $receipt->update ();
  5708. $receiptDetail->status = 2;
  5709. $receiptDetail->update ( array (
  5710. 'where' => 'rid=' . $receiptDetailList ['rid']
  5711. ) );
  5712. Doo::loadModel ( "receiptLog" );
  5713. $receiptLog = new receiptLog ();
  5714. Doo::loadModel ( "verify" );
  5715. $verify = new verify ();
  5716. $receiptInfo = $receipt->getOne ( array (
  5717. 'where' => 'rid=' . $rid,
  5718. 'asArray' => true
  5719. ) );
  5720. $vr = $verify->getOne ( array (
  5721. 'where' => 'vid=' . $receiptInfo ['verify'],
  5722. 'asArray' => true
  5723. ) );
  5724. $jd = json_decode ( $vr ['staff'] );
  5725. $roleId = 0;
  5726. foreach ( $jd as $key => $value ) {
  5727. if ($value [1] == 'ROLE') {
  5728. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  5729. if ($pos !== false) {
  5730. $roleId = $value [0];
  5731. }
  5732. }
  5733. }
  5734. // 审批日志
  5735. // echo $roleId;die;
  5736. if (! empty ( $roleId )) {
  5737. Doo::loadModel ( "role" );
  5738. $role = new role ();
  5739. $roleInfo = $role->getOne ( array (
  5740. 'where' => 'rid=' . $roleId,
  5741. 'asArray' => true
  5742. ) );
  5743. $receiptLog->rolename = $roleInfo ['name'];
  5744. }
  5745. $receiptLog->username = $this->staff [0] ['username'];
  5746. $receiptLog->uid = $this->staff [0] ['sid'];
  5747. $receiptLog->date = date ( "Y-m-d" );
  5748. $receiptLog->opinion = '提交审批';
  5749. $receiptLog->img = $this->staff [0] ['avatar'];
  5750. $receiptLog->status = 2;
  5751. $receiptLog->rid = $rid;
  5752. $receiptLog->insert ();
  5753. // statistics item
  5754. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  5755. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  5756. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  5757. $stat = $statistics->getOne ( array (
  5758. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5759. 'asArray' => true
  5760. ) );
  5761. if (empty ( $stat )) {
  5762. $statistics->date = date ( "Y-m-d" );
  5763. $statistics->cid = $this->staff [0] ['cid'];
  5764. $statistics->staff = $this->staff [0] ['sid'];
  5765. $statistics->agPrice = 0;
  5766. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5767. $statistics->insert ();
  5768. } else {
  5769. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5770. $statistics->update ( array (
  5771. 'where' => 'sid=' . $stat ['sid']
  5772. ) );
  5773. }
  5774. return "/expenses";
  5775. }
  5776. function approval() {
  5777. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5778. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5779. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5780. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5781. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5782. if (empty ( $status ))
  5783. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5784. $vidList = array ();
  5785. $button = 0;
  5786. Doo::loadModel ( 'verify' );
  5787. $verify = new verify ();
  5788. Doo::loadModel ( 'receipt' );
  5789. $receipt = new receipt ();
  5790. Doo::loadModel ( 'staff' );
  5791. $staff = new staff ();
  5792. Doo::loadModel ( 'L_category' );
  5793. $Lcategory = new L_category ();
  5794. // user verify ID
  5795. $verifyDetail = $verify->find ( array (
  5796. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5797. 'asArray' => true
  5798. ) );
  5799. foreach ( $verifyDetail as $key => $value ) {
  5800. array_push ( $vidList, $value ['vid'] );
  5801. }
  5802. $vid = implode ( ",", $vidList );
  5803. if (empty ( $verifyDetail ))
  5804. $vid = 0;
  5805. /*
  5806. */
  5807. $dateCondition = " and Year(date) =" . $year;
  5808. if (! empty ( $month ))
  5809. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  5810. $categoryList = $Lcategory->find ( array (
  5811. 'asArray' => true
  5812. ) );
  5813. $staffList = $staff->find ( array (
  5814. 'where' => 'cid=' . $cid,
  5815. 'asArray' => true
  5816. ) );
  5817. $cateCondition = "";
  5818. $staffCondition = "";
  5819. $approvalCondition = "";
  5820. if (! empty ( $cid ))
  5821. $cateCondition = ' and cid=' . $cid;
  5822. if (! empty ( $sid )) {
  5823. $staffCondition = ' and staff=' . $sid;
  5824. $cateCondition = "";
  5825. }
  5826. // elseif($status==1){
  5827. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  5828. // }
  5829. if ($status == 2) {
  5830. // 查找角色审批人
  5831. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  5832. }
  5833. $ap = "";
  5834. if ($status == 4) {
  5835. $ap = 4;
  5836. $status = 2;
  5837. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  5838. }
  5839. if ($status == 5) {
  5840. $status = 4;
  5841. $ap = 5;
  5842. }
  5843. // echo $vid;
  5844. // get Receipt By verifyID status 2 .$approvalCondition
  5845. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  5846. $receiptList = $receipt->find ( array (
  5847. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  5848. 'desc' => 'rid',
  5849. 'asArray' => true
  5850. ) );
  5851. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  5852. $Locate = 0;
  5853. if ($ap == 4)
  5854. $status = 4;
  5855. elseif ($ap == 5)
  5856. $status = 5;
  5857. foreach ( $receiptList as $key => $value ) {
  5858. $receiptList [$key] ['Locate'] = $Locate;
  5859. $Locate ++;
  5860. $receiptList [$key] ['reviseDetail'] = array ();
  5861. if (! empty ( $value ['reviseDetail'] ))
  5862. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5863. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5864. $categoryDetil = $Lcategory->getOne ( array (
  5865. 'where' => 'cid=' . $value ['cid'],
  5866. 'asArray' => true
  5867. ) );
  5868. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5869. $verifyList = $verify->getOne ( array (
  5870. 'where' => 'vid=' . $value ['verify'],
  5871. 'asArray' => true
  5872. ) );
  5873. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5874. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5875. foreach ( $verifyList as $k => $v ) {
  5876. // init verifyStaff
  5877. $verifyList [$k] ['date'] = "";
  5878. $verifyList [$k] ['opinion'] = "";
  5879. $verifyList [$k] ['status'] = "";
  5880. if (empty ( $verifyStaff )) {
  5881. $verifyList [$k] ['date'] = "";
  5882. $verifyList [$k] ['opinion'] = "";
  5883. if ($v [0] == $this->staff [0] ['sid']) {
  5884. $verifyList [$k] ['status'] = 4;
  5885. $button = 4;
  5886. }
  5887. } else {
  5888. $flag = true;
  5889. foreach ( $verifyStaff as $m => $u ) {
  5890. if ($v [0] == $m) {
  5891. $verifyList [$k] ['date'] = $u ['date'];
  5892. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5893. $verifyList [$k] ['status'] = $u ['status'];
  5894. $flag = false;
  5895. break;
  5896. }
  5897. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  5898. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  5899. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  5900. }
  5901. if ($flag) { // 检测可编辑
  5902. if ($v [0] == $this->staff [0] ['sid']) {
  5903. $verifyList [$k] ['status'] = 4;
  5904. $button = 4;
  5905. }
  5906. }
  5907. }
  5908. }
  5909. $receiptList [$key] ['verifyList'] = $verifyList;
  5910. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5911. 'where' => 'sid=' . $value ['staff'],
  5912. 'asArray' => true
  5913. ) );
  5914. $receiptList [$key] ['button'] = $button;
  5915. }
  5916. // print_r($receiptList);die;
  5917. // $data['verifyDetail']=$verifyDetail;
  5918. $mothHtml = "";
  5919. for($i = 1; $i <= 12; $i ++) {
  5920. if ($month == $i)
  5921. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5922. else
  5923. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5924. }
  5925. $data ['mothHtml'] = $mothHtml;
  5926. $data ['receiptList'] = $receiptList;
  5927. $data ['receiptApprovalCount'] = count ( $receiptList );
  5928. $data ['status'] = $status;
  5929. $data ['year'] = $year;
  5930. $data ['categoryList'] = $categoryList;
  5931. $data ['staffList'] = $staffList;
  5932. $data ['cid'] = $cid;
  5933. $data ['sid'] = $sid;
  5934. $data ['ap'] = $ap;
  5935. $data ['memu'] = "receipt";
  5936. $data ['staff'] = $this->staff;
  5937. $data ['receiptMemu'] = 'approval';
  5938. $data ['verifyId'] = $this->verifyId;
  5939. $data ['executeId'] = $this->executeId;
  5940. $this->render ( "/admin/saea_reportList", $data );
  5941. }
  5942. function approvalDetails() {
  5943. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5944. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5945. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5946. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5947. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5948. Doo::loadModel ( 'verify' );
  5949. $verify = new verify ();
  5950. Doo::loadModel ( 'receipt' );
  5951. $receipt = new receipt ();
  5952. Doo::loadModel ( 'staff' );
  5953. $staff = new staff ();
  5954. Doo::loadModel ( 'L_category' );
  5955. $Lcategory = new L_category ();
  5956. Doo::loadModel ( 'enclosur' );
  5957. $enclosur = new enclosur ();
  5958. $vidList = array ();
  5959. $verifyDetail = $verify->find ( array (
  5960. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5961. 'asArray' => true
  5962. ) );
  5963. foreach ( $verifyDetail as $key => $value ) {
  5964. array_push ( $vidList, $value ['vid'] );
  5965. }
  5966. $vid = implode ( ",", $vidList );
  5967. if (empty ( $verifyDetail ))
  5968. $vid = 0;
  5969. $categoryList = $Lcategory->find ( array (
  5970. 'asArray' => true
  5971. ) );
  5972. $staffList = $staff->find ( array (
  5973. 'where' => 'cid=' . $cid,
  5974. 'asArray' => true
  5975. ) );
  5976. $ap = 0;
  5977. $receiptList = $receipt->find ( array (
  5978. 'where' => 'rid =' . $rid,
  5979. 'desc' => 'rid',
  5980. 'asArray' => true
  5981. ) );
  5982. $Locate = 0;
  5983. $roleId = 0;
  5984. $button = 0;
  5985. foreach ( $receiptList as $key => $value ) {
  5986. $receiptList [$key] ['Locate'] = $Locate;
  5987. $Locate ++;
  5988. $receiptList [$key] ['reviseDetail'] = array ();
  5989. if (! empty ( $value ['reviseDetail'] ))
  5990. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5991. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5992. $categoryDetil = $Lcategory->getOne ( array (
  5993. 'where' => 'cid=' . $value ['cid'],
  5994. 'asArray' => true
  5995. ) );
  5996. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5997. // 检测编辑状态
  5998. $verifyList = $verify->getOne ( array (
  5999. 'where' => 'vid=' . $value ['verify'],
  6000. 'asArray' => true
  6001. ) );
  6002. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6003. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6004. Doo::loadModel ( 'role' );
  6005. $role = new role ();
  6006. // print_r($verifyList);
  6007. $flag = true;
  6008. $roleKey = 0;
  6009. $endStaffArray = array ();
  6010. $roleArrayCopy = array ();
  6011. foreach ( $verifyList as $k => $v ) {
  6012. // init verifyStaff
  6013. if ($v [1] == 'ROLE') {
  6014. if (! empty ( $verifyStaff )) {
  6015. $endStaffArray = end ( $verifyStaff );
  6016. if ($v [0] == $endStaffArray ['nextStaff']) {
  6017. $roleId = $v [0];
  6018. }
  6019. }
  6020. $roleVerify = json_decode ( $v [3], true );
  6021. $roleKey = $k;
  6022. $roleArray = array ();
  6023. $rolename = $role->getOne ( array (
  6024. 'where' => 'rid=' . $v [0],
  6025. 'asArray' => true
  6026. ) );
  6027. foreach ( $roleVerify as $o => $p ) {
  6028. $staffID = explode ( '_', $p );
  6029. $staffInfo = $staff->getOne ( array (
  6030. 'where' => 'sid=' . $staffID [0],
  6031. 'asArray' => true
  6032. ) );
  6033. // print_r($staffID);
  6034. $exp = array (
  6035. 0 => $staffInfo ['sid'],
  6036. 1 => $staffID [1],
  6037. 2 => $staffInfo ['avatar'],
  6038. 'date' => '',
  6039. 'date' => '',
  6040. 'opinion' => '',
  6041. 'status' => '',
  6042. 'rolename' => $rolename ['name']
  6043. );
  6044. array_push ( $roleArray, $exp );
  6045. }
  6046. $roleArrayCopy [$v [0]] = $roleArray;
  6047. // $verifyList[$k]['roleArray']=$roleArray;
  6048. }
  6049. // print_r($roleArray);
  6050. $verifyList [$k] ['date'] = "";
  6051. $verifyList [$k] ['opinion'] = "";
  6052. $verifyList [$k] ['status'] = "";
  6053. if (empty ( $verifyStaff )) {
  6054. $verifyList [$k] ['date'] = "";
  6055. $verifyList [$k] ['opinion'] = "";
  6056. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6057. $verifyList [$k] ['status'] = 4;
  6058. $button = 4;
  6059. $flag = false;
  6060. }
  6061. } else {
  6062. foreach ( $verifyStaff as $m => $u ) {
  6063. if ($v [0] == $m) {
  6064. $verifyList [$k] ['date'] = $u ['date'];
  6065. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6066. $verifyList [$k] ['status'] = $u ['status'];
  6067. $flag = false;
  6068. break;
  6069. }
  6070. }
  6071. $endStaffArray = end ( $verifyStaff );
  6072. if (isset ( $endStaffArray ['ROLE'] )) {
  6073. } else {
  6074. $endKey = key ( $verifyStaff );
  6075. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6076. $button = 4;
  6077. $verifyList [$k] ['status'] = 4;
  6078. }
  6079. }
  6080. }
  6081. }
  6082. $rolename ['name'] = '';
  6083. if (! empty ( $roleId )) {
  6084. Doo::loadModel ( 'role' );
  6085. $role = new role ();
  6086. $rolename = $role->getOne ( array (
  6087. 'where' => 'rid=' . $roleId,
  6088. 'asArray' => true
  6089. ) );
  6090. }
  6091. if (! empty ( $verifyStaff ))
  6092. $endStaffArray = end ( $verifyStaff );
  6093. $KOP = false;
  6094. foreach ( $roleArrayCopy as $P => $A ) {
  6095. foreach ( $A as $MKI => $AVL ) {
  6096. if (! empty ( $verifyStaff )) {
  6097. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6098. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6099. $button = 4;
  6100. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6101. }
  6102. foreach ( $verifyStaff as $m => $u ) {
  6103. $AVLFK = $AVL [0] . '_R';
  6104. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6105. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6106. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6107. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6108. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6109. break;
  6110. }
  6111. }
  6112. } else {
  6113. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6114. $button = 4;
  6115. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6116. }
  6117. }
  6118. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6119. $KOP = true;
  6120. }
  6121. }
  6122. foreach ( $roleArrayCopy as $k => $v ) {
  6123. foreach ( $verifyList as $m => $n ) {
  6124. if ($n [0] == $k) {
  6125. array_splice ( $verifyList, $m, 1, $v );
  6126. }
  6127. }
  6128. }
  6129. $receiptList [$key] ['verifyList'] = $verifyList;
  6130. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6131. 'where' => 'sid=' . $value ['staff'],
  6132. 'asArray' => true
  6133. ) );
  6134. $receiptList [$key] ['button'] = $button;
  6135. }
  6136. $mothHtml = "";
  6137. for($i = 1; $i <= 12; $i ++) {
  6138. if ($month == $i)
  6139. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6140. else
  6141. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6142. }
  6143. // 获取审批日志
  6144. Doo::loadModel ( 'receiptLog' );
  6145. $receiptLog = new receiptLog ();
  6146. $rlList = array ();
  6147. $rlInfo = $receiptLog->getOne ( array (
  6148. 'where' => 'rid=' . $rid . ' and status=4',
  6149. 'asArray' => true
  6150. ) );
  6151. $tijdate = $receiptLog->getOne ( array (
  6152. 'where' => 'rid=' . $rid . ' and status=2',
  6153. 'asc' => 'rlid',
  6154. 'asArray' => true
  6155. ) );
  6156. if (! empty ( $rlInfo )) {
  6157. $rlList = $receiptLog->find ( array (
  6158. 'where' => 'rid=' . $rid,
  6159. 'asc' => 'rlid',
  6160. 'asArray' => true
  6161. ) );
  6162. }
  6163. $receiptList [0] ['rlList'] = $rlList;
  6164. $enclosurList = $enclosur->find ( array (
  6165. 'where' => 'rid=' . $rid,
  6166. 'asArray' => true
  6167. ) );
  6168. $enclosurHtml = '';
  6169. foreach ( $enclosurList as $value ) {
  6170. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6171. }
  6172. $data ['enclosurHtml'] = $enclosurHtml;
  6173. $data ['rolename'] = $rolename ['name'];
  6174. $data ['datetij'] = $tijdate ['date'];
  6175. $data ['mothHtml'] = $mothHtml;
  6176. $data ['receiptList'] = $receiptList;
  6177. $data ['receiptApprovalCount'] = count ( $receiptList );
  6178. $data ['year'] = $year;
  6179. $data ['categoryList'] = $categoryList;
  6180. $data ['staffList'] = $staffList;
  6181. $data ['cid'] = $cid;
  6182. $data ['sid'] = $sid;
  6183. $data ['status'] = 0;
  6184. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  6185. $ap = 4;
  6186. } else
  6187. $data ['status'] = $receiptList [0] ['status'];
  6188. if ($receiptList [0] ['status'] == 4) {
  6189. $data ['status'] = 5;
  6190. $ap = 0;
  6191. }
  6192. $data ['ap'] = $ap;
  6193. $data ['memu'] = "receipt";
  6194. $data ['staff'] = $this->staff;
  6195. $data ['receiptMemu'] = 'approval';
  6196. $data ['verifyId'] = $this->verifyId;
  6197. $data ['executeId'] = $this->executeId;
  6198. $this->render ( "/admin/saeaReportListReport", $data );
  6199. }
  6200. function approvalEdi() {
  6201. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6202. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  6203. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6204. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6205. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6206. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6207. if (empty ( $status ))
  6208. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  6209. $vidList = array ();
  6210. $button = 0;
  6211. Doo::loadModel ( 'verify' );
  6212. Doo::loadModel ( 'receipt' );
  6213. Doo::loadModel ( 'staff' );
  6214. $staff = new staff ();
  6215. $receipt = new receipt ();
  6216. $verify = new verify ();
  6217. Doo::loadModel ( 'L_category' );
  6218. $Lcategory = new L_category ();
  6219. Doo::loadModel ( 'enclosur' );
  6220. $enclosur = new enclosur ();
  6221. // user verify ID
  6222. $verifyDetail = $verify->find ( array (
  6223. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6224. 'asArray' => true
  6225. ) );
  6226. foreach ( $verifyDetail as $key => $value ) {
  6227. array_push ( $vidList, $value ['vid'] );
  6228. }
  6229. $vid = implode ( ",", $vidList );
  6230. if (empty ( $verifyDetail ))
  6231. $vid = 0;
  6232. $categoryList = $Lcategory->find ( array (
  6233. 'asArray' => true
  6234. ) );
  6235. $staffList = $staff->find ( array (
  6236. 'where' => 'cid=' . $cid,
  6237. 'asArray' => true
  6238. ) );
  6239. $ap = "";
  6240. if ($status == 4) {
  6241. $ap = 4;
  6242. $status = 2;
  6243. }
  6244. // get Receipt By verifyID status 2
  6245. $receiptList = $receipt->find ( array (
  6246. 'where' => 'rid =' . $rid,
  6247. 'desc' => 'rid',
  6248. 'asArray' => true
  6249. ) );
  6250. $Locate = 0;
  6251. $roleId = 0;
  6252. if ($ap == 4)
  6253. $status = 4;
  6254. foreach ( $receiptList as $key => $value ) {
  6255. $receiptList [$key] ['Locate'] = $Locate;
  6256. $Locate ++;
  6257. $receiptList [$key] ['reviseDetail'] = array ();
  6258. if (! empty ( $value ['reviseDetail'] ))
  6259. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6260. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6261. $categoryDetil = $Lcategory->getOne ( array (
  6262. 'where' => 'cid=' . $value ['cid'],
  6263. 'asArray' => true
  6264. ) );
  6265. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6266. // 检测编辑状态
  6267. $verifyList = $verify->getOne ( array (
  6268. 'where' => 'vid=' . $value ['verify'],
  6269. 'asArray' => true
  6270. ) );
  6271. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6272. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6273. // print_r($verifyList);
  6274. //
  6275. // if (empty($verifyStaff)){
  6276. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6277. // $verifyList[0]['status']=4;$button=4;
  6278. // }
  6279. //
  6280. // }else{
  6281. //
  6282. // }
  6283. // die;
  6284. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  6285. // echo array_search("green",$a);
  6286. //
  6287. Doo::loadModel ( 'role' );
  6288. $role = new role ();
  6289. // print_r($verifyList);
  6290. $flag = true;
  6291. $roleKey = 0;
  6292. $endStaffArray = array ();
  6293. $roleArrayCopy = array ();
  6294. foreach ( $verifyList as $k => $v ) {
  6295. // init verifyStaff
  6296. if ($v [1] == 'ROLE') {
  6297. if (! empty ( $verifyStaff )) {
  6298. $endStaffArray = end ( $verifyStaff );
  6299. if ($v [0] == $endStaffArray ['nextStaff']) {
  6300. $roleId = $v [0];
  6301. }
  6302. }
  6303. $roleVerify = json_decode ( $v [3], true );
  6304. $roleKey = $k;
  6305. $roleArray = array ();
  6306. $rolename = $role->getOne ( array (
  6307. 'where' => 'rid=' . $v [0],
  6308. 'asArray' => true
  6309. ) );
  6310. foreach ( $roleVerify as $o => $p ) {
  6311. $staffID = explode ( '_', $p );
  6312. $staffInfo = $staff->getOne ( array (
  6313. 'where' => 'sid=' . $staffID [0],
  6314. 'asArray' => true
  6315. ) );
  6316. // print_r($staffID);
  6317. $exp = array (
  6318. 0 => $staffInfo ['sid'],
  6319. 1 => $staffID [1],
  6320. 2 => $staffInfo ['avatar'],
  6321. 'date' => '',
  6322. 'date' => '',
  6323. 'opinion' => '',
  6324. 'status' => '',
  6325. 'rolename' => $rolename ['name']
  6326. );
  6327. array_push ( $roleArray, $exp );
  6328. }
  6329. $roleArrayCopy [$v [0]] = $roleArray;
  6330. // $verifyList[$k]['roleArray']=$roleArray;
  6331. }
  6332. // print_r($roleArray);
  6333. $verifyList [$k] ['date'] = "";
  6334. $verifyList [$k] ['opinion'] = "";
  6335. $verifyList [$k] ['status'] = "";
  6336. if (empty ( $verifyStaff )) {
  6337. $verifyList [$k] ['date'] = "";
  6338. $verifyList [$k] ['opinion'] = "";
  6339. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6340. $verifyList [$k] ['status'] = 4;
  6341. $button = 4;
  6342. $flag = false;
  6343. }
  6344. } else {
  6345. foreach ( $verifyStaff as $m => $u ) {
  6346. if ($v [0] == $m) {
  6347. $verifyList [$k] ['date'] = $u ['date'];
  6348. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6349. $verifyList [$k] ['status'] = $u ['status'];
  6350. $flag = false;
  6351. break;
  6352. }
  6353. }
  6354. $endStaffArray = end ( $verifyStaff );
  6355. if (isset ( $endStaffArray ['ROLE'] )) {
  6356. } else {
  6357. $endKey = key ( $verifyStaff );
  6358. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6359. $button = 4;
  6360. $verifyList [$k] ['status'] = 4;
  6361. }
  6362. }
  6363. // print_r($endStaffArray);die;
  6364. // if (empty($verifyStaff)){
  6365. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6366. // $verifyList[$k]['status']=4;$button=4;
  6367. // }
  6368. //
  6369. // }else{
  6370. //
  6371. // }
  6372. // if($flag){//检测可编辑
  6373. // if($v[0]==$this->staff[0]['sid']){
  6374. // $verifyList[$k]['status']=4;$button=4;
  6375. // }
  6376. // }
  6377. }
  6378. }
  6379. $rolename ['name'] = '';
  6380. if (! empty ( $roleId )) {
  6381. Doo::loadModel ( 'role' );
  6382. $role = new role ();
  6383. $rolename = $role->getOne ( array (
  6384. 'where' => 'rid=' . $roleId,
  6385. 'asArray' => true
  6386. ) );
  6387. }
  6388. if (! empty ( $verifyStaff ))
  6389. $endStaffArray = end ( $verifyStaff );
  6390. $KOP = false;
  6391. foreach ( $roleArrayCopy as $P => $A ) {
  6392. foreach ( $A as $MKI => $AVL ) {
  6393. if (! empty ( $verifyStaff )) {
  6394. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6395. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6396. $button = 4;
  6397. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6398. }
  6399. foreach ( $verifyStaff as $m => $u ) {
  6400. $AVLFK = $AVL [0] . '_R';
  6401. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6402. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6403. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6404. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6405. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6406. break;
  6407. }
  6408. }
  6409. } else {
  6410. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6411. $button = 4;
  6412. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6413. }
  6414. }
  6415. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6416. $KOP = true;
  6417. }
  6418. }
  6419. // print_r($roleArrayCopy);
  6420. // echo $roleKey;
  6421. foreach ( $roleArrayCopy as $k => $v ) {
  6422. foreach ( $verifyList as $m => $n ) {
  6423. if ($n [0] == $k) {
  6424. array_splice ( $verifyList, $m, 1, $v );
  6425. }
  6426. }
  6427. }
  6428. // if ($KOP)
  6429. // array_splice($verifyList,$roleKey,1,$roleArray);
  6430. // print_r($verifyList);
  6431. $receiptList [$key] ['verifyList'] = $verifyList;
  6432. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6433. 'where' => 'sid=' . $value ['staff'],
  6434. 'asArray' => true
  6435. ) );
  6436. $receiptList [$key] ['button'] = $button;
  6437. }
  6438. // $data['verifyDetail']=$verifyDetail;
  6439. $mothHtml = "";
  6440. for($i = 1; $i <= 12; $i ++) {
  6441. if ($month == $i)
  6442. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6443. else
  6444. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6445. }
  6446. // 获取审批日志
  6447. Doo::loadModel ( 'receiptLog' );
  6448. $receiptLog = new receiptLog ();
  6449. $rlList = array ();
  6450. $rlInfo = $receiptLog->getOne ( array (
  6451. 'where' => 'rid=' . $rid . ' and status=4',
  6452. 'asArray' => true
  6453. ) );
  6454. $tijdate = $receiptLog->getOne ( array (
  6455. 'where' => 'rid=' . $rid . ' and status=2',
  6456. 'asc' => 'rlid',
  6457. 'asArray' => true
  6458. ) );
  6459. if (! empty ( $rlInfo )) {
  6460. $rlList = $receiptLog->find ( array (
  6461. 'where' => 'rid=' . $rid,
  6462. 'asc' => 'rlid',
  6463. 'asArray' => true
  6464. ) );
  6465. }
  6466. $receiptList [0] ['rlList'] = $rlList;
  6467. $enclosurList = $enclosur->find ( array (
  6468. 'where' => 'rid=' . $rid,
  6469. 'asArray' => true
  6470. ) );
  6471. $enclosurHtml = '';
  6472. foreach ( $enclosurList as $value ) {
  6473. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6474. }
  6475. $data ['enclosurHtml'] = $enclosurHtml;
  6476. $data ['rolename'] = $rolename ['name'];
  6477. $data ['datetij'] = $tijdate ['date'];
  6478. $data ['mothHtml'] = $mothHtml;
  6479. $data ['receiptList'] = $receiptList;
  6480. $data ['receiptApprovalCount'] = count ( $receiptList );
  6481. $data ['status'] = $status;
  6482. $data ['year'] = $year;
  6483. $data ['categoryList'] = $categoryList;
  6484. $data ['staffList'] = $staffList;
  6485. $data ['cid'] = $cid;
  6486. $data ['sid'] = $sid;
  6487. $data ['ap'] = $ap;
  6488. $data ['memu'] = "receipt";
  6489. $data ['staff'] = $this->staff;
  6490. $data ['receiptMemu'] = 'approval';
  6491. $data ['verifyId'] = $this->verifyId;
  6492. $data ['executeId'] = $this->executeId;
  6493. $this->render ( "/admin/saeaReportListReport", $data );
  6494. }
  6495. function remittanceHky() {
  6496. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6497. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  6498. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6499. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  6500. $page_size = 15;
  6501. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  6502. Doo::loadModel ( 'receipt' );
  6503. $receipt = new receipt ();
  6504. Doo::loadModel ( 'staff' );
  6505. $staff = new staff ();
  6506. $dateCondition = " and Year(executeDate) =" . $year;
  6507. if ($moth != 'MONTH')
  6508. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  6509. if ($day != 'DAY' && $moth != 'MONTH')
  6510. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  6511. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  6512. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  6513. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  6514. $limit = $pageinfo ['lower'] . ',' . $page_size;
  6515. $dayList = $receipt->find ( array (
  6516. 'select' => 'executeDate,sum(amount) as amount',
  6517. 'where' => $sql,
  6518. 'desc' => 'executeDate',
  6519. 'groupby' => 'executeDate',
  6520. 'limit' => $limit,
  6521. 'asArray' => true
  6522. ) );
  6523. // print_r($dayList);
  6524. foreach ( $dayList as $key => $value ) {
  6525. $remitString = "";
  6526. $receiptList = $receipt->find ( array (
  6527. 'select' => 'rid,executeDate,amount,staff,cid',
  6528. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  6529. 'desc' => 'executeDate',
  6530. 'asArray' => true
  6531. ) );
  6532. foreach ( $receiptList as $k => $v ) {
  6533. $sinfo = $staff->getOne ( array (
  6534. 'select' => 'username,category',
  6535. 'where' => ' sid=' . $v ['staff'],
  6536. 'asArray' => true
  6537. ) );
  6538. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  6539. }
  6540. $dayList [$key] ['staff'] = $remitString;
  6541. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  6542. }
  6543. // print_r($dayList);
  6544. $mothHtml = "";
  6545. for($i = 1; $i <= 12; $i ++) {
  6546. if ($moth == $i)
  6547. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6548. else
  6549. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6550. }
  6551. $dayHtml = "";
  6552. if ($day != "DAY" || $moth != "MONTH") {
  6553. for($i = 1; $i <= 31; $i ++) {
  6554. if ($day == $i)
  6555. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6556. else
  6557. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6558. }
  6559. }
  6560. $data ['page'] = $pageinfo;
  6561. $data ['year'] = $year;
  6562. $data ['moth'] = $moth;
  6563. $data ['day'] = $day;
  6564. $data ['get'] = $get;
  6565. $data ['dayHtml'] = $dayHtml;
  6566. $data ['mothHtml'] = $mothHtml;
  6567. $data ['receiptList'] = $dayList;
  6568. $data ['memu'] = "receipt";
  6569. $data ['staff'] = $this->staff;
  6570. $data ['receiptMemu'] = 'remittanceHky';
  6571. $data ['verifyId'] = $this->verifyId;
  6572. $data ['executeId'] = $this->executeId;
  6573. $this->render ( "/admin/remittanceHky", $data );
  6574. }
  6575. function remittancep() {
  6576. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  6577. Doo::loadModel ( 'receipt' );
  6578. $receipt = new receipt ();
  6579. Doo::loadModel ( 'staff' );
  6580. $staff = new staff ();
  6581. Doo::loadClass ( 'XDeode' );
  6582. $XDeode = new XDeode ( 5 );
  6583. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  6584. $rplist = $receipt->find ( array (
  6585. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6586. 'asArray' => true
  6587. ) );
  6588. $dayList = $receipt->find ( array (
  6589. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6590. 'desc' => 'executeDate',
  6591. 'groupby' => 'staff',
  6592. 'asArray' => true
  6593. ) );
  6594. $html = '';
  6595. foreach ( $dayList as $key => $value ) {
  6596. $sinfo = $staff->getOne ( array (
  6597. 'select' => 'username,category',
  6598. 'where' => ' sid=' . $value ['staff'],
  6599. 'asArray' => true
  6600. ) );
  6601. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  6602. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  6603. $au = 0;
  6604. foreach ( $rplist as $k => $v ) {
  6605. if ($value ['staff'] == $v ['staff']) {
  6606. $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>';
  6607. $au += $v ['amount'];
  6608. }
  6609. }
  6610. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  6611. }
  6612. $data ['html'] = $html;
  6613. $data ['memu'] = "receipt";
  6614. $data ['staff'] = $this->staff;
  6615. $data ['receiptMemu'] = 'remittanceHky';
  6616. $data ['verifyId'] = $this->verifyId;
  6617. $data ['executeId'] = $this->executeId;
  6618. $this->render ( "/admin/remittancep", $data );
  6619. }
  6620. function ajaxGetReceiptDetails() {
  6621. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  6622. Doo::loadClass ( 'XDeode' );
  6623. $XDeode = new XDeode ( 5 );
  6624. $rid = $XDeode->decode ( $rid );
  6625. if (empty ( $rid )) {
  6626. echo json_encode ( array (
  6627. 'status' => 2,
  6628. 'msg' => 'illegal request'
  6629. ) );
  6630. die ();
  6631. }
  6632. Doo::loadModel ( 'receipt' );
  6633. $receipt = new receipt ();
  6634. Doo::loadModel ( 'staff' );
  6635. $staff = new staff ();
  6636. $rinfo = $receipt->getOne ( array (
  6637. 'where' => 'rid= ' . $rid,
  6638. 'asArray' => true
  6639. ) );
  6640. $sinfo = $staff->getOne ( array (
  6641. 'select' => 'username,category',
  6642. 'where' => ' sid=' . $rinfo ['staff'],
  6643. 'asArray' => true
  6644. ) );
  6645. $rinfo ['reviseDetail'] = array ();
  6646. if (! empty ( $rinfo ['reviseDetail'] ))
  6647. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  6648. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  6649. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  6650. $rinfo ['category'] = $sinfo ['category'];
  6651. $verifyStaff = array ();
  6652. if (! empty ( $rinfo ['verifyStaff'] ))
  6653. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  6654. $relust = $rinfo ['sum'] - $rinfo ['loanSum'];
  6655. $rinfo ['relust'] = $relust;
  6656. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  6657. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  6658. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  6659. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  6660. // 费用执行人相关数据
  6661. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6662. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6663. foreach ( $executeCopy as $k => $v ) {
  6664. $executeCopy [$k] ['date'] = '';
  6665. $executeCopy [$k] ['opinion'] = '';
  6666. $executeCopy [$k] ['status'] = '';
  6667. if (! empty ( $executeStaff ))
  6668. foreach ( $executeStaff as $m => $u ) {
  6669. if ($v [0] == $m) {
  6670. $executeCopy [$k] ['date'] = $u ['date'];
  6671. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  6672. $executeCopy [$k] ['status'] = $u ['status'];
  6673. break;
  6674. }
  6675. }
  6676. }
  6677. $rinfo ['executeCopy'] = $executeCopy;
  6678. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  6679. if ($rinfo ['Rtype'] == 1) { // 借款费用
  6680. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6681. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  6682. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  6683. $html .= '<tr><th>' . $value ['name'] . '</th>
  6684. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6685. }
  6686. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6687. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6688. <tr><th class="taC" colspan="2">费用说明</th>
  6689. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6690. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6691. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  6692. </tbody></table>';
  6693. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  6694. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6695. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6696. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6697. $html .= '<tr><th>' . $value ['name'] . '</th>
  6698. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6699. }
  6700. $html .= '<tr><th class="taR">合计</th>
  6701. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6702. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6703. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6704. $html .= '<tr><th>' . $value ['name'] . '</th>
  6705. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6706. }
  6707. $html .= '<tr><th class="taR">合计</th>
  6708. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6709. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6710. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6711. $html .= '<tr><th>' . $value ['name'] . '</th>
  6712. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6713. }
  6714. $html .= '<tr><th class="taR">合计</th>
  6715. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6716. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6717. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6718. $html .= '<tr><th>' . $value ['name'] . '</th>
  6719. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6720. }
  6721. $html .= '<tr><th class="taR">合计</th>
  6722. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6723. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6724. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6725. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6726. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6727. }
  6728. $html .= '<tr><th class="taR">合计</th>
  6729. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6730. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6731. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6732. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6733. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6734. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6735. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6736. <tr';
  6737. if ($rinfo ['relust'] >= 0) {
  6738. $html .= 'class="success"';
  6739. } else {
  6740. $html .= 'class="error"';
  6741. }
  6742. $html .= '><td class="taR"><b>借款结余</b></td>
  6743. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  6744. </tbody></table>
  6745. ';
  6746. }
  6747. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  6748. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6749. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  6750. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6751. $html .= '<tr><th>' . $value ['name'] . '</th>
  6752. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6753. }
  6754. $html .= '<tr><th class="taR">合计</th>
  6755. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6756. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6757. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6758. <tr><th class="taC" colspan="2">费用说明</th>
  6759. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6760. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6761. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6762. </tbody></table>';
  6763. } else {
  6764. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6765. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6766. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6767. $html .= '<tr><th>' . $value ['name'] . '</th>
  6768. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6769. }
  6770. $html .= '<tr><th class="taR">合计</th>
  6771. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6772. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6773. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6774. $html .= '<tr><th>' . $value ['name'] . '</th>
  6775. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6776. }
  6777. $html .= '<tr><th class="taR">合计</th>
  6778. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6779. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6780. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6781. $html .= '<tr><th>' . $value ['name'] . '</th>
  6782. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6783. }
  6784. $html .= '<tr><th class="taR">合计</th>
  6785. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6786. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6787. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6788. $html .= '<tr><th>' . $value ['name'] . '</th>
  6789. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6790. }
  6791. $html .= '<tr><th class="taR">合计</th>
  6792. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6793. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6794. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6795. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6796. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6797. }
  6798. $html .= '<tr><th class="taR">合计</th>
  6799. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6800. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6801. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6802. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6803. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6804. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6805. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  6806. $html .= '</tbody></table>';
  6807. /*
  6808. * <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>
  6809. */
  6810. }
  6811. // print_r($verifyStaff);die;
  6812. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  6813. foreach ( $verifyStaff as $key => $value ) {
  6814. $key = trim ( strtr ( $key, '_R', ' ' ) );
  6815. $sinfo = $staff->getOne ( array (
  6816. 'select' => 'username',
  6817. 'where' => ' sid=' . $key,
  6818. 'asArray' => true
  6819. ) );
  6820. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6821. }
  6822. $html .= '</tbody></table>';
  6823. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  6824. foreach ( $rinfo ['executeCopy'] as $value ) {
  6825. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6826. }
  6827. $html .= '</tbody></table>';
  6828. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  6829. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  6830. </tr></table>';
  6831. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  6832. echo json_encode ( array (
  6833. 'status' => 1,
  6834. 'html' => $html
  6835. ) );
  6836. die ();
  6837. }
  6838. /**
  6839. * 删除附件
  6840. */
  6841. function ajaxRemEnclousur() {
  6842. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  6843. if (empty ( $key ))
  6844. echo json_encode ( array (
  6845. 'status' => 2
  6846. ) );
  6847. Doo::loadModel ( 'enclosur' );
  6848. $enclosur = new enclosur ();
  6849. $enclosur->delEnclosurByEid ( $key );
  6850. echo json_encode ( array (
  6851. 'status' => 1
  6852. ) );
  6853. }
  6854. function remittance() {
  6855. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6856. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6857. Doo::loadModel ( 'receipt' );
  6858. $receipt = new receipt ();
  6859. Doo::loadModel ( 'staff' );
  6860. $staff = new staff ();
  6861. $dateCondition = " and Year(pastDate) =" . $year;
  6862. if (! empty ( $month ))
  6863. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  6864. // get Receipt By verifyID status 1
  6865. $receiptList = $receipt->find ( array (
  6866. 'select' => 'sum(sum) as sum,staff,pastDate',
  6867. 'where' => ' status=1' . $dateCondition,
  6868. 'desc' => 'pastDate',
  6869. 'groupby' => 'staff,pastDate',
  6870. 'asArray' => true
  6871. ) );
  6872. $dateList = $receipt->find ( array (
  6873. 'select' => 'pastDate,verifyStaff',
  6874. 'where' => ' status=1' . $dateCondition,
  6875. 'desc' => 'pastDate',
  6876. 'groupby' => 'pastDate',
  6877. 'asArray' => true
  6878. ) );
  6879. $dataList = array ();
  6880. foreach ( $dateList as $d => $a ) {
  6881. $dataList [$a ['pastDate']] = array ();
  6882. $daySum = 0;
  6883. foreach ( $receiptList as $key => $value ) {
  6884. if ($a ['pastDate'] == $value ['pastDate']) {
  6885. $oderList = $receipt->find ( array (
  6886. 'select' => 'receiptOrder',
  6887. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  6888. 'asArray' => true
  6889. ) );
  6890. $list = array ();
  6891. $html = "";
  6892. foreach ( $oderList as $v ) {
  6893. array_push ( $list, $v ['receiptOrder'] );
  6894. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  6895. }
  6896. $receiptList [$key] ['receiptOrder'] = $html;
  6897. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  6898. $sinfo = $staff->getOne ( array (
  6899. 'select' => 'username ',
  6900. 'where' => ' sid=' . $value ['staff'],
  6901. 'asArray' => true
  6902. ) );
  6903. $receiptList [$key] ['username'] = $sinfo ['username'];
  6904. $daySum += $value ['sum'];
  6905. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  6906. }
  6907. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  6908. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  6909. }
  6910. }
  6911. // print_r($dataList);
  6912. $data ['dataList'] = $dataList;
  6913. $mothHtml = "";
  6914. for($i = 1; $i <= 12; $i ++) {
  6915. if ($month == $i)
  6916. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6917. else
  6918. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6919. }
  6920. $data ['year'] = $year;
  6921. $data ['mothHtml'] = $mothHtml;
  6922. $data ['memu'] = "receipt";
  6923. $data ['staff'] = $this->staff;
  6924. $data ['receiptMemu'] = 'approval';
  6925. $data ['verifyId'] = $this->verifyId;
  6926. $data ['executeId'] = $this->executeId;
  6927. $this->render ( "/admin/saeaReportListPay", $data );
  6928. }
  6929. /**
  6930. * 金额调整,提高稳定性
  6931. * @return string
  6932. */
  6933. function revocationAdjustment() {
  6934. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  6935. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  6936. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  6937. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  6938. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey ) && (! empty ( $reviseKey )))) {
  6939. Doo::loadClass ( 'XDeode' );
  6940. $XDeode = new XDeode ( 5 );
  6941. Doo::loadModel ( 'receipt' );
  6942. $receipt = new receipt ();
  6943. $sid = $XDeode->decode ( $sidKey );
  6944. $rid = $XDeode->decode ( $ridKey );
  6945. $reviseKey = $XDeode->decode ( $reviseKey );
  6946. if (! is_numeric ( $sid ) && ! is_numeric ( $rid ) && ! is_numeric ( $reviseKey ))
  6947. die ( 'illegal request' );
  6948. $receiptDetail = $receipt->getOne ( array (
  6949. 'where' => 'rid=' . $rid,
  6950. 'asArray' => true
  6951. ) );
  6952. if (empty ( $receiptDetail ) || empty ( $receiptDetail ['reviseDetail'] ))
  6953. die ( 'illegal request' );
  6954. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  6955. if (! isset ( $reviseDetail [$reviseKey] ))
  6956. die ( 'illegal request' );
  6957. if ($reviseDetail [$reviseKey] ['sid'] == $sid && $reviseDetail [$reviseKey] ['price'] == $price)
  6958. unset ( $reviseDetail [$reviseKey] );
  6959. $revisePrice = 0;
  6960. foreach ( $reviseDetail as $key => $value ) {
  6961. $revisePrice += $value ['price'];
  6962. }
  6963. $reviseDetailString = json_encode ( $reviseDetail );
  6964. $receipt->reviseDetail = $reviseDetailString;
  6965. $receipt->sum = $receiptDetail ['sum'] - $price;
  6966. $receipt->revisePrice = $revisePrice;
  6967. $receipt->update ( array (
  6968. 'where' => 'rid=' . $rid
  6969. ) );
  6970. return '/receiptburEdi/' . $rid;
  6971. } else
  6972. die ( 'illegal request2' );
  6973. }
  6974. function updateApprovalReceipt() {
  6975. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6976. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  6977. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6978. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  6979. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  6980. if (! empty ( $rid )) {
  6981. Doo::loadModel ( "verify" );
  6982. $verify = new verify ();
  6983. Doo::loadModel ( "receiptDetail" );
  6984. $receiptDetailObj = new receiptDetail ();
  6985. Doo::loadModel ( "itemStatistics" );
  6986. Doo::loadModel ( "statistics" );
  6987. $statistics = new statistics ();
  6988. $itemStatistics = new itemStatistics ();
  6989. Doo::loadModel ( "receipt" );
  6990. $receipt = new receipt ();
  6991. $receiptDetail = $receipt->getOne ( array (
  6992. 'where' => 'rid=' . $rid . ' and status=2 ',
  6993. 'asArray' => true
  6994. ) );
  6995. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  6996. $nsflag = true;
  6997. foreach ( $nslist as $value ) {
  6998. if ($value == $this->staff ['0'] ['sid']) {
  6999. $nsflag = false;
  7000. break;
  7001. }
  7002. }
  7003. if (empty ( $receiptDetail ) || $nsflag)
  7004. return "/approval";
  7005. $verifyDetail = $verify->getOne ( array (
  7006. 'where' => ' vid =' . $receiptDetail ['verify'],
  7007. 'asArray' => true
  7008. ) );
  7009. $verifyString = $verifyDetail ['staff'];
  7010. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  7011. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  7012. if (empty ( $opinion )) {
  7013. if ($status == 3)
  7014. $opinion = "终止";
  7015. else
  7016. $opinion = "同意支付";
  7017. }
  7018. $nowStaff = 0;
  7019. $nowStaffList = array ();
  7020. if (empty ( $verifyStaff )) {
  7021. // 还需加入是否已经进入角色审批
  7022. if ($verifyDetail [0] [1] == 'ROLE') {
  7023. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  7024. foreach ( $vStaffString as $key => $value ) {
  7025. $staffK = explode ( "_", $value );
  7026. if ($staffK [0] != $this->staff [0] ['sid'])
  7027. array_push ( $nowStaffList, $staffK [0] );
  7028. }
  7029. // print_r($verifyDetail);
  7030. // die;
  7031. if (! empty ( $nowStaffList )) {
  7032. $nowStaff = implode ( ',', $nowStaffList );
  7033. $verifyStaff = array (
  7034. $this->staff [0] ['sid'] . "_R" => array (
  7035. 'date' => date ( 'Y-m-d' ),
  7036. 'opinion' => $opinion,
  7037. 'status' => $status,
  7038. 'nextStaff' => $verifyDetail [0] [0],
  7039. 'ROLE' => 1
  7040. )
  7041. );
  7042. } else {
  7043. $nowStaff = $verifyDetail [1] [0];
  7044. $verifyStaff = array (
  7045. $this->staff [0] ['sid'] . "_R" => array (
  7046. 'date' => date ( 'Y-m-d' ),
  7047. 'opinion' => $opinion,
  7048. 'status' => $status,
  7049. 'nextStaff' => $verifyDetail [1] [0]
  7050. )
  7051. );
  7052. }
  7053. } else {
  7054. if ($verifyDetail [1] [1] == 'ROLE') {
  7055. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  7056. // echo "dd";
  7057. foreach ( $vStaffString as $key => $value ) {
  7058. $staffK = explode ( "_", $value );
  7059. array_push ( $nowStaffList, $staffK [0] );
  7060. }
  7061. $nowStaff = implode ( ',', $nowStaffList );
  7062. $verifyStaff = array (
  7063. $this->staff [0] ['sid'] => array (
  7064. 'date' => date ( 'Y-m-d' ),
  7065. 'opinion' => $opinion,
  7066. 'status' => $status,
  7067. 'nextStaff' => $verifyDetail [1] [0],
  7068. 'ROLE' => 1
  7069. )
  7070. );
  7071. } else {
  7072. $nowStaff = $verifyDetail [1] [0];
  7073. $verifyStaff = array (
  7074. $this->staff [0] ['sid'] => array (
  7075. 'date' => date ( 'Y-m-d' ),
  7076. 'opinion' => $opinion,
  7077. 'status' => $status,
  7078. 'nextStaff' => $verifyDetail [1] [0]
  7079. )
  7080. );
  7081. }
  7082. }
  7083. if ($status == 3)
  7084. $verifyStaff = array (
  7085. 'final' => $status,
  7086. $this->staff [0] ['sid'] => array (
  7087. 'date' => date ( 'Y-m-d' ),
  7088. 'opinion' => $opinion,
  7089. 'status' => $status
  7090. )
  7091. );
  7092. $vStaffString = json_encode ( $verifyStaff );
  7093. $receipt->nowStaff = $nowStaff;
  7094. $receipt->verifyStaff = $vStaffString;
  7095. } else {
  7096. $VS = end ( $verifyStaff );
  7097. // 非角色审批
  7098. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  7099. $nextStaff = 0;
  7100. $roleSTF = false;
  7101. foreach ( $verifyDetail as $key => $value ) {
  7102. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  7103. if (isset ( $verifyDetail [$key + 1] )) {
  7104. $nextStaff = $verifyDetail [$key + 1] [0];
  7105. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  7106. $roleSTF = true;
  7107. }
  7108. break;
  7109. }
  7110. }
  7111. if (! $roleSTF) {
  7112. $nowStaff = $nextStaff;
  7113. $verifyStaff [$this->staff [0] ['sid']] = array (
  7114. 'date' => date ( 'Y-m-d' ),
  7115. 'opinion' => $opinion,
  7116. 'status' => $status,
  7117. 'nextStaff' => $nextStaff
  7118. );
  7119. } else {
  7120. // 获取角色下的所有用户ID
  7121. $nowStaffList = array ();
  7122. foreach ( $verifyDetail as $vfk ) {
  7123. if ($vfk [1] == 'ROLE') {
  7124. $vStaffString = json_decode ( $vfk [3] );
  7125. foreach ( $vStaffString as $key => $value ) {
  7126. $staffK = explode ( "_", $value );
  7127. array_push ( $nowStaffList, $staffK [0] );
  7128. }
  7129. }
  7130. }
  7131. $nowStaff = implode ( ',', $nowStaffList );
  7132. $verifyStaff [$this->staff [0] ['sid']] = array (
  7133. 'date' => date ( 'Y-m-d' ),
  7134. 'opinion' => $opinion,
  7135. 'status' => $status,
  7136. 'nextStaff' => $nextStaff,
  7137. 'ROLE' => 0
  7138. );
  7139. }
  7140. if ($status == 3) {
  7141. $verifyStaff ['final'] = $status;
  7142. $verifyStaff [$this->staff [0] ['sid']] = array (
  7143. 'date' => date ( 'Y-m-d' ),
  7144. 'opinion' => $opinion,
  7145. 'status' => $status
  7146. );
  7147. }
  7148. $vStaffString = json_encode ( $verifyStaff );
  7149. $receipt->nowStaff = $nowStaff;
  7150. $receipt->verifyStaff = $vStaffString;
  7151. }
  7152. // 角色审批
  7153. if (isset ( $VS ['ROLE'] )) {
  7154. // 找出角色人 当前审批角色组
  7155. $verifyJSStaff = array ();
  7156. $nowStaffList2 = array ();
  7157. foreach ( $verifyDetail as $key => $value ) {
  7158. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  7159. $verifyJSStaff = json_decode ( $value [3] );
  7160. foreach ( $verifyJSStaff as $m ) {
  7161. $staffK = explode ( "_", $m );
  7162. array_push ( $nowStaffList2, $staffK [0] );
  7163. }
  7164. // print_r($nowStaffList2);
  7165. }
  7166. }
  7167. $RoleVerifyStaff = array ();
  7168. foreach ( $verifyStaff as $key => $value ) {
  7169. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  7170. foreach ( $nowStaffList2 as $m ) {
  7171. if ($key == $m . "_R")
  7172. $RoleVerifyStaff [$key] = $value;
  7173. }
  7174. }
  7175. }
  7176. // print_r($verifyStaff);
  7177. // print_r($nowStaffList2);
  7178. // print_r($RoleVerifyStaff);
  7179. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  7180. // print_r($verifyJSStaff);
  7181. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  7182. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  7183. // 下一个审批人ID
  7184. $nextStaff = 0;
  7185. $falg = false;
  7186. foreach ( $verifyDetail as $key => $value ) {
  7187. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  7188. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  7189. $falg = true;
  7190. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  7191. $nowStaffList = array ();
  7192. foreach ( $vStaffString as $v ) {
  7193. $staffK = explode ( "_", $v );
  7194. array_push ( $nowStaffList, $staffK [0] );
  7195. }
  7196. $nowStaff = implode ( ',', $nowStaffList );
  7197. $nextStaff = $verifyDetail [$key + 1] [0];
  7198. } elseif (isset ( $verifyDetail [$key + 1] )) {
  7199. $nextStaff = $verifyDetail [$key + 1] [0];
  7200. $nowStaff = $nextStaff;
  7201. } else
  7202. $nowStaff = '';
  7203. break;
  7204. }
  7205. }
  7206. if ($falg)
  7207. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7208. 'date' => date ( 'Y-m-d' ),
  7209. 'opinion' => $opinion,
  7210. 'status' => $status,
  7211. 'nextStaff' => $nextStaff,
  7212. 'ROLE' => 1
  7213. );
  7214. else
  7215. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7216. 'date' => date ( 'Y-m-d' ),
  7217. 'opinion' => $opinion,
  7218. 'status' => $status,
  7219. 'nextStaff' => $nextStaff
  7220. );
  7221. // print_r($verifyStaff);
  7222. // echo $nowStaff;die;
  7223. } else { // 进入下一个角色或者审批人
  7224. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  7225. //
  7226. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  7227. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7228. 'date' => date ( 'Y-m-d' ),
  7229. 'opinion' => $opinion,
  7230. 'status' => $status,
  7231. 'nextStaff' => $VS ['nextStaff'],
  7232. 'ROLE' => 1
  7233. );
  7234. // print_r($verifyStaff);
  7235. // die;
  7236. }
  7237. if ($status == 3) {
  7238. $verifyStaff ['final'] = $status;
  7239. $verifyStaff [$this->staff [0] ['sid']] = array (
  7240. 'date' => date ( 'Y-m-d' ),
  7241. 'opinion' => $opinion,
  7242. 'status' => $status
  7243. );
  7244. }
  7245. $vStaffString = json_encode ( $verifyStaff );
  7246. $receipt->verifyStaff = $vStaffString;
  7247. $receipt->nowStaff = $nowStaff;
  7248. // die;
  7249. // }
  7250. // print_r($verifyStaff);
  7251. // die;
  7252. }
  7253. // print_r($verifyStaff);die;
  7254. }
  7255. // print_r($verifyDetail);
  7256. $roleKey = 0;
  7257. $roleId = 0;
  7258. $verifyDetailCopy = array ();
  7259. foreach ( $verifyDetail as $k => $v ) {
  7260. if ($v [1] == 'ROLE') {
  7261. $roleId = $v [0];
  7262. $roleVerify = json_decode ( $v [3], true );
  7263. $roleKey = $k;
  7264. $roleArray = array ();
  7265. foreach ( $roleVerify as $o => $p ) {
  7266. $staffID = explode ( '_', $p );
  7267. $exp = array (
  7268. 0 => $staffID [0],
  7269. 1 => $staffID [1]
  7270. );
  7271. array_push ( $roleArray, $exp );
  7272. }
  7273. $verifyDetailCopy [$v [0]] = $roleArray;
  7274. }
  7275. }
  7276. // print_r($verifyDetail);
  7277. foreach ( $verifyDetailCopy as $k => $v ) {
  7278. foreach ( $verifyDetail as $m => $n ) {
  7279. if ($n [0] == $k) {
  7280. array_splice ( $verifyDetail, $m, 1, $v );
  7281. }
  7282. }
  7283. }
  7284. // die;
  7285. // if (!empty($roleArray))
  7286. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  7287. // echo $roleId;
  7288. // print_r($verifyStaff);
  7289. // print_r($verifyDetail);
  7290. // die;
  7291. Doo::loadModel ( "receiptLog" );
  7292. $receiptLog = new receiptLog ();
  7293. // 审批日志
  7294. if (! isset ( $verifyStaff ['final'] )) {
  7295. if (! empty ( $roleId )) {
  7296. Doo::loadModel ( "role" );
  7297. $role = new role ();
  7298. $roleInfo = $role->getOne ( array (
  7299. 'where' => 'rid=' . $roleId,
  7300. 'asArray' => true
  7301. ) );
  7302. $receiptLog->rolename = $roleInfo ['name'];
  7303. }
  7304. $receiptLog->username = $this->staff [0] ['username'];
  7305. $receiptLog->uid = $this->staff [0] ['sid'];
  7306. $receiptLog->date = date ( "Y-m-d" );
  7307. $receiptLog->opinion = $opinion;
  7308. $receiptLog->img = $this->staff [0] ['avatar'];
  7309. $receiptLog->status = 1;
  7310. $receiptLog->rid = $rid;
  7311. $receiptLog->insert ();
  7312. }
  7313. if (isset ( $verifyStaff ['final'] )) { // rDetail
  7314. $receipt->verifyBreakup = $verifyString;
  7315. $receipt->status = 3;
  7316. $receiptDetailObj->status = 3;
  7317. $receiptDetailObj->update ( array (
  7318. 'where' => 'rid=' . $rid
  7319. ) );
  7320. if (! empty ( $roleId )) {
  7321. Doo::loadModel ( "role" );
  7322. $role = new role ();
  7323. $roleInfo = $role->getOne ( array (
  7324. 'where' => 'rid=' . $roleId,
  7325. 'asArray' => true
  7326. ) );
  7327. $receiptLog->rolename = $roleInfo ['name'];
  7328. }
  7329. $receiptLog->username = $this->staff [0] ['username'];
  7330. $receiptLog->uid = $this->staff [0] ['sid'];
  7331. $receiptLog->date = date ( "Y-m-d" );
  7332. $receiptLog->opinion = $opinion;
  7333. $receiptLog->img = $this->staff [0] ['avatar'];
  7334. $receiptLog->status = 3;
  7335. $receiptLog->rid = $rid;
  7336. $receiptLog->insert ();
  7337. // 微信企业号通知
  7338. $this->setWXMsg ( $rid, 3 );
  7339. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  7340. $receipt->status = 1;
  7341. $reviseSum = 0;
  7342. $receipt->verifyBreakup = $verifyString;
  7343. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  7344. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7345. foreach ( $reviseDetail as $key => $value ) {
  7346. $receiptDetailObj = new receiptDetail ();
  7347. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7348. $receiptDetailObj->item = $value ['description'];
  7349. $receiptDetailObj->itemCategory = "报销金额调整";
  7350. $receiptDetailObj->price = $value ['price'];
  7351. $receiptDetailObj->date = $receiptDetail ['date'];
  7352. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  7353. $receiptDetailObj->rid = $rid;
  7354. $receiptDetailObj->status = 1;
  7355. $receiptDetailObj->insert ();
  7356. $reviseSum += $value ['price'];
  7357. }
  7358. $itemStatistics = new itemStatistics ();
  7359. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7360. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7361. $itemStatistics->price = $reviseSum;
  7362. $itemStatistics->itemCategory = "报销金额调整";
  7363. $itemStatistics->date = $receiptDetail ['date'];
  7364. $itemStatistics->insert ();
  7365. }
  7366. $receiptDetailObj = new receiptDetail ();
  7367. $receiptDetailObj->status = 1;
  7368. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  7369. $receiptDetailObj->update ( array (
  7370. 'where' => 'rid=' . $rid
  7371. ) );
  7372. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7373. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7374. $stat = $statistics->getOne ( array (
  7375. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  7376. 'asArray' => true
  7377. ) );
  7378. if (empty ( $stat )) {
  7379. $statistics->date = $receiptDetail ['date'];
  7380. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7381. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7382. $statistics->agPrice = $receiptDetail ['sum'];
  7383. $statistics->rePrice = $reviseSum;
  7384. $statistics->insert ();
  7385. } else {
  7386. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  7387. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  7388. $statistics->update ( array (
  7389. 'where' => 'sid=' . $stat ['sid']
  7390. ) );
  7391. }
  7392. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7393. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7394. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  7395. foreach ( $accountItem ['cSum'] as $key => $value ) {
  7396. if ($key == "agencySum") {
  7397. $iStatistics = $itemStatistics->getOne ( array (
  7398. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  7399. 'asArray' => true
  7400. ) );
  7401. if (empty ( $iStatistics )) {
  7402. $itemStatistics->cid = $receiptDetail ['cid'];
  7403. ;
  7404. $itemStatistics->staff = $receiptDetail ['staff'];
  7405. $itemStatistics->price = $value;
  7406. $itemStatistics->itemCategory = $this->AGENCY;
  7407. $itemStatistics->date = $receiptDetail ['date'];
  7408. $itemStatistics->insert ();
  7409. } else {
  7410. if (! empty ( $value )) {
  7411. $itemStatistics->price = $value + $iStatistics ['price'];
  7412. $itemStatistics->update ( array (
  7413. 'where' => 'sid=' . $iStatistics ['sid']
  7414. ) );
  7415. }
  7416. }
  7417. } elseif ($key == "travelSum") {
  7418. $iStatistics = $itemStatistics->getOne ( array (
  7419. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  7420. 'asArray' => true
  7421. ) );
  7422. if (empty ( $iStatistics )) {
  7423. $itemStatistics->cid = $receiptDetail ['cid'];
  7424. $itemStatistics->staff = $receiptDetail ['staff'];
  7425. $itemStatistics->price = $value;
  7426. $itemStatistics->itemCategory = $this->TRAVEL;
  7427. $itemStatistics->date = $receiptDetail ['date'];
  7428. $itemStatistics->insert ();
  7429. } else {
  7430. if (! empty ( $value )) {
  7431. $itemStatistics->price = $value + $iStatistics ['price'];
  7432. $itemStatistics->update ( array (
  7433. 'where' => 'sid=' . $iStatistics ['sid']
  7434. ) );
  7435. }
  7436. }
  7437. } elseif ($key == "trainSum") {
  7438. $iStatistics = $itemStatistics->getOne ( array (
  7439. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  7440. 'asArray' => true
  7441. ) );
  7442. if (empty ( $iStatistics )) {
  7443. $itemStatistics->cid = $receiptDetail ['cid'];
  7444. $itemStatistics->staff = $receiptDetail ['staff'];
  7445. $itemStatistics->price = $value;
  7446. $itemStatistics->itemCategory = $this->TRAIN;
  7447. $itemStatistics->date = $receiptDetail ['date'];
  7448. $itemStatistics->insert ();
  7449. } else {
  7450. if (! empty ( $value )) {
  7451. $itemStatistics->price = $value + $iStatistics ['price'];
  7452. $itemStatistics->update ( array (
  7453. 'where' => 'sid=' . $iStatistics ['sid']
  7454. ) );
  7455. }
  7456. }
  7457. } elseif ($key == "otherSum") {
  7458. $iStatistics = $itemStatistics->getOne ( array (
  7459. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  7460. 'asArray' => true
  7461. ) );
  7462. if (empty ( $iStatistics )) {
  7463. $itemStatistics->cid = $receiptDetail ['cid'];
  7464. $itemStatistics->staff = $receiptDetail ['staff'];
  7465. $itemStatistics->price = $value;
  7466. $itemStatistics->itemCategory = $this->OTHER;
  7467. $itemStatistics->date = $receiptDetail ['date'];
  7468. $itemStatistics->insert ();
  7469. } else {
  7470. if (! empty ( $value )) {
  7471. $itemStatistics->price = $value + $iStatistics ['price'];
  7472. $itemStatistics->update ( array (
  7473. 'where' => 'sid=' . $iStatistics ['sid']
  7474. ) );
  7475. }
  7476. }
  7477. }
  7478. }
  7479. $receipt->pastDate = date ( "Y-m-d" );
  7480. // 微信企业号通知
  7481. $this->setWXMsg ( $rid, 1 );
  7482. }
  7483. $receipt->amount = $amount;
  7484. $receipt->update ( array (
  7485. 'where' => ' rid = ' . $rid
  7486. ) );
  7487. // 进入下一条审批费用新加需求
  7488. $vidList = array ();
  7489. $verifyDetail = $verify->find ( array (
  7490. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  7491. 'asArray' => true
  7492. ) );
  7493. foreach ( $verifyDetail as $key => $value ) {
  7494. array_push ( $vidList, $value ['vid'] );
  7495. }
  7496. $vid = implode ( ",", $vidList );
  7497. if (empty ( $verifyDetail ))
  7498. $vid = 0;
  7499. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  7500. $receipt = new receipt ();
  7501. $rd = $receipt->getOne ( array (
  7502. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  7503. 'asc' => 'rid',
  7504. 'asArray' => true
  7505. ) );
  7506. if (empty ( $rd )) {
  7507. return '/approvalExpenses/pendApproval';
  7508. }
  7509. if ($rd ['Rtype'] == 1) {
  7510. if ($rd ['isBK'] == 1) {
  7511. return '/receiptburEdi/' . $rd ['rid'];
  7512. } else {
  7513. return '/expensesEdi/' . $rd ['rid'];
  7514. }
  7515. } elseif ($rd ['Rtype'] == 2) {
  7516. return '/remitApproval/' . $rd ['rid'];
  7517. } else {
  7518. return '/receiptburEdi/' . $rd ['rid'];
  7519. }
  7520. // return "/approvalExpenses/pendApproval";
  7521. }
  7522. }
  7523. function expensesRetreats() {
  7524. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7525. if (! empty ( $rid )) {
  7526. // 操作记录
  7527. Doo::loadModel ( "receipt" );
  7528. $receipt = new receipt ();
  7529. Doo::loadModel ( "receiptLog" );
  7530. $receiptLog = new receiptLog ();
  7531. Doo::loadModel ( "verify" );
  7532. $verify = new verify ();
  7533. $receiptInfo = $receipt->getOne ( array (
  7534. 'where' => 'rid=' . $rid,
  7535. 'asArray' => true
  7536. ) );
  7537. $vr = $verify->getOne ( array (
  7538. 'where' => 'vid=' . $receiptInfo ['verify'],
  7539. 'asArray' => true
  7540. ) );
  7541. $jd = json_decode ( $vr ['staff'] );
  7542. $roleId = 0;
  7543. foreach ( $jd as $key => $value ) {
  7544. if ($value [1] == 'ROLE') {
  7545. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7546. if ($pos !== false) {
  7547. $roleId = $value [0];
  7548. }
  7549. }
  7550. }
  7551. // 审批日志
  7552. // echo $roleId;die;
  7553. if (! empty ( $roleId )) {
  7554. Doo::loadModel ( "role" );
  7555. $role = new role ();
  7556. $roleInfo = $role->getOne ( array (
  7557. 'where' => 'rid=' . $roleId,
  7558. 'asArray' => true
  7559. ) );
  7560. $receiptLog->rolename = $roleInfo ['name'];
  7561. }
  7562. $receiptLog->username = $this->staff [0] ['username'];
  7563. $receiptLog->uid = $this->staff [0] ['sid'];
  7564. $receiptLog->date = date ( "Y-m-d" );
  7565. $receiptLog->opinion = '撤回';
  7566. $receiptLog->img = $this->staff [0] ['avatar'];
  7567. $receiptLog->status = 4;
  7568. $receiptLog->rid = $rid;
  7569. $receiptLog->insert ();
  7570. $receipt->status = 4;
  7571. $receipt->update ( array (
  7572. 'where' => 'rid=' . $rid
  7573. ) );
  7574. // 微信企业号通知
  7575. $this->setWXMsg ( $rid, 2 );
  7576. }
  7577. // echo "ddd";
  7578. return '/approvalExpenses/pendApproval';
  7579. }
  7580. function updateCheReceipt() {
  7581. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7582. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7583. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  7584. if (! empty ( $rid )) {
  7585. // 操作记录
  7586. Doo::loadModel ( "receipt" );
  7587. $receipt = new receipt ();
  7588. Doo::loadModel ( "receiptLog" );
  7589. $receiptLog = new receiptLog ();
  7590. Doo::loadModel ( "verify" );
  7591. $verify = new verify ();
  7592. $receiptInfo = $receipt->getOne ( array (
  7593. 'where' => 'rid=' . $rid . ' and status=2',
  7594. 'asArray' => true
  7595. ) );
  7596. if (empty ( $receiptInfo )) {
  7597. echo json_encode ( array (
  7598. 'status' => 2
  7599. ) );
  7600. die ();
  7601. }
  7602. $vr = $verify->getOne ( array (
  7603. 'where' => 'vid=' . $receiptInfo ['verify'],
  7604. 'asArray' => true
  7605. ) );
  7606. $jd = json_decode ( $vr ['staff'] );
  7607. $roleId = 0;
  7608. foreach ( $jd as $key => $value ) {
  7609. if ($value [1] == 'ROLE') {
  7610. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7611. if ($pos !== false) {
  7612. $roleId = $value [0];
  7613. }
  7614. }
  7615. }
  7616. // 审批日志
  7617. // echo $roleId;die;
  7618. if (! empty ( $roleId )) {
  7619. Doo::loadModel ( "role" );
  7620. $role = new role ();
  7621. $roleInfo = $role->getOne ( array (
  7622. 'where' => 'rid=' . $roleId,
  7623. 'asArray' => true
  7624. ) );
  7625. $receiptLog->rolename = $roleInfo ['name'];
  7626. }
  7627. $receiptLog->username = $this->staff [0] ['username'];
  7628. $receiptLog->uid = $this->staff [0] ['sid'];
  7629. $receiptLog->date = date ( "Y-m-d" );
  7630. $receiptLog->opinion = $opinion;
  7631. $receiptLog->img = $this->staff [0] ['avatar'];
  7632. $receiptLog->status = 4;
  7633. $receiptLog->rid = $rid;
  7634. $receiptLog->insert ();
  7635. $receipt->status = 4;
  7636. $receipt->update ( array (
  7637. 'where' => 'rid=' . $rid
  7638. ) );
  7639. // 微信企业号通知
  7640. $this->setWXMsg ( $rid, 2 );
  7641. echo json_encode ( array (
  7642. 'status' => 1
  7643. ) );
  7644. // Header("HTTP/1.1 303 See Other");
  7645. // Header("Location: /approvalExpenses/pendApproval");
  7646. die ();
  7647. }
  7648. echo json_encode ( array (
  7649. 'status' => 2
  7650. ) );
  7651. die ();
  7652. // echo "ddd";
  7653. // return '/saeaBorad';
  7654. }
  7655. function revisePrice() {
  7656. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  7657. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  7658. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7659. // echo $price;die;
  7660. if (! empty ( $rid )) {
  7661. Doo::loadModel ( "receipt" );
  7662. $receipt = new receipt ();
  7663. $receiptDetail = $receipt->getOne ( array (
  7664. 'where' => 'rid=' . $rid . ' and status=2 ',
  7665. 'asArray' => true
  7666. ) );
  7667. if (empty ( $receiptDetail ))
  7668. die ( 'illegal request' );
  7669. $reviseDetail = array ();
  7670. if (empty ( $receiptDetail ['reviseDetail'] )) {
  7671. array_push ( $reviseDetail, array (
  7672. 'sid' => $this->staff [0] ['sid'],
  7673. 'name' => $this->staff [0] ['username'],
  7674. 'description' => $description,
  7675. 'price' => $price
  7676. ) );
  7677. $reviseDetailString = json_encode ( $reviseDetail );
  7678. $receipt->reviseDetail = $reviseDetailString;
  7679. $receipt->revisePrice = $price;
  7680. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7681. } else {
  7682. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7683. array_push ( $reviseDetail, array (
  7684. 'sid' => $this->staff [0] ['sid'],
  7685. 'name' => $this->staff [0] ['username'],
  7686. 'description' => $description,
  7687. 'price' => $price
  7688. ) );
  7689. $reviseDetailString = json_encode ( $reviseDetail );
  7690. $receipt->reviseDetail = $reviseDetailString;
  7691. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  7692. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7693. }
  7694. $receipt->update ( array (
  7695. 'where' => 'rid=' . $rid
  7696. ) );
  7697. if ($receiptDetail ['Rtype'] == 1) {
  7698. if ($receiptDetail ['isBK'] == 1) {
  7699. return '/receiptburEdi/' . $receiptDetail ['rid'];
  7700. }
  7701. } elseif ($receiptDetail ['Rtype'] == 2) {
  7702. } else {
  7703. return '/receiptburEdi/' . $receiptDetail ['rid'];
  7704. }
  7705. }
  7706. die ( 'illegal request' );
  7707. }
  7708. function personalCollect() {
  7709. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7710. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  7711. $this->showCache ( $path );
  7712. Doo::loadModel ( "receiptDetail" );
  7713. Doo::loadModel ( "itemStatistics" );
  7714. Doo::loadModel ( 'statistics' );
  7715. $statistics = new statistics ();
  7716. $itemStatistics = new itemStatistics ();
  7717. $receiptDetail = new receiptDetail ();
  7718. $receiptCollectList = $receiptDetail->find ( array (
  7719. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7720. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7721. 'groupby' => 'itemCategory,Month(date)',
  7722. 'asArray' => true
  7723. ) );
  7724. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  7725. 'where' => 'staff=' . $this->staff [0] ['sid'],
  7726. 'asArray' => true
  7727. ) );
  7728. // create collect html
  7729. $collectArray = array (
  7730. '日常相关费用' => array (),
  7731. '差旅相关费用' => array (),
  7732. '培训班费用' => array (),
  7733. '其他' => array ()
  7734. );
  7735. $adjustment = array ();
  7736. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  7737. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7738. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  7739. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7740. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  7741. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7742. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  7743. array_push ( $collectArray ['其他'], $collectHtml );
  7744. $data ['collectArray'] = $collectArray;
  7745. // statistics html
  7746. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7747. if (empty ( $stList ))
  7748. $stList = array (
  7749. 'rePrice' => 0,
  7750. 'agPrice' => 0
  7751. );
  7752. $data ['stList'] = array (
  7753. 'rePrice' => $stList ['rePrice'],
  7754. 'agPrice' => $stList ['agPrice'],
  7755. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7756. );
  7757. // Adjustment price html
  7758. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7759. array_push ( $adjustment, $collectHtml );
  7760. $data ['adjustment'] = $adjustment;
  7761. // total price html
  7762. $collectHtml = "";
  7763. $total = 0;
  7764. for($i = 1; $i <= 12; $i ++) {
  7765. $sumPrice = 0;
  7766. foreach ( $receiptCollectList as $key => $value ) {
  7767. if ($value ['month'] == $i) {
  7768. $sumPrice += $value ['price'];
  7769. }
  7770. }
  7771. if ($sumPrice == 0)
  7772. $collectHtml .= '<td class="taR">-</td>';
  7773. else
  7774. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7775. $total += $sumPrice;
  7776. }
  7777. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7778. $data ['totalPrice'] = $collectHtml;
  7779. $data ['year'] = $year;
  7780. $data ['totalYear'] = $total;
  7781. $data ['memu'] = "receipt";
  7782. $data ['staff'] = $this->staff;
  7783. $data ['receiptMemu'] = 'personalCollect';
  7784. $data ['verifyId'] = $this->verifyId;
  7785. $data ['executeId'] = $this->executeId;
  7786. // year staff status 2,4
  7787. if ($year < date ( "Y" )) {
  7788. Doo::loadModel ( 'receipt' );
  7789. $receipt = new receipt ();
  7790. $receiptList = $receipt->find ( array (
  7791. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7792. 'asArray' => true
  7793. ) );
  7794. if (empty ( $receiptList )) {
  7795. ob_start ();
  7796. $this->render ( "/admin/saea_slist_collect", $data );
  7797. $this->cacheFile ( $path );
  7798. die ();
  7799. }
  7800. }
  7801. $this->render ( "/admin/saea_slist_collect", $data );
  7802. }
  7803. function personalCollectDetail() {
  7804. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7805. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  7806. $this->showCache ( $path );
  7807. Doo::loadModel ( "receiptDetail" );
  7808. Doo::loadModel ( "itemStatistics" );
  7809. Doo::loadModel ( 'statistics' );
  7810. Doo::loadModel ( 'accountItem' );
  7811. $accountItem = new accountItem ();
  7812. $statistics = new statistics ();
  7813. $itemStatistics = new itemStatistics ();
  7814. $receiptDetail = new receiptDetail ();
  7815. $receiptCollectList = $receiptDetail->find ( array (
  7816. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  7817. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7818. 'groupby' => 'item,Month(date)',
  7819. 'asArray' => true
  7820. ) );
  7821. $accountList = $accountItem->find ( array (
  7822. 'asArray' => true
  7823. ) );
  7824. // create CollectDetail HTML
  7825. $collectHtml = array ();
  7826. foreach ( $accountList as $key => $value ) {
  7827. $html = "";
  7828. $asum = 0;
  7829. for($i = 1; $i <= 12; $i ++) {
  7830. $falg = true;
  7831. foreach ( $receiptCollectList as $v ) {
  7832. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7833. $asum += $v ['price'];
  7834. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7835. $falg = false;
  7836. break;
  7837. }
  7838. }
  7839. if ($falg)
  7840. $html .= '<td class="taR">-</td>';
  7841. }
  7842. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7843. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7844. }
  7845. $data ['collectHtml'] = $collectHtml;
  7846. // create Adjustment price html
  7847. $receiptCollectList = $receiptDetail->find ( array (
  7848. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7849. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7850. 'groupby' => 'itemCategory,Month(date)',
  7851. 'asArray' => true
  7852. ) );
  7853. $adjustment = array ();
  7854. $collectArray = array (
  7855. '日常相关费用' => array (),
  7856. '差旅相关费用' => array (),
  7857. '培训班费用' => array (),
  7858. '其他' => array ()
  7859. );
  7860. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7861. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7862. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7863. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7864. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7865. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7866. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7867. array_push ( $collectArray ['其他'], $collectHtml );
  7868. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7869. array_push ( $adjustment, $collectHtml );
  7870. // total price html
  7871. $collectHtml = "";
  7872. $total = 0;
  7873. for($i = 1; $i <= 12; $i ++) {
  7874. $sumPrice = 0;
  7875. foreach ( $receiptCollectList as $key => $value ) {
  7876. if ($value ['month'] == $i) {
  7877. $sumPrice += $value ['price'];
  7878. }
  7879. }
  7880. if ($sumPrice == 0)
  7881. $collectHtml .= '<td class="taR">-</td>';
  7882. else
  7883. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7884. $total += $sumPrice;
  7885. }
  7886. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7887. // statistics html
  7888. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7889. if (empty ( $stList ))
  7890. $stList = array (
  7891. 'rePrice' => 0,
  7892. 'agPrice' => 0
  7893. );
  7894. $data ['stList'] = array (
  7895. 'rePrice' => $stList ['rePrice'],
  7896. 'agPrice' => $stList ['agPrice'],
  7897. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7898. );
  7899. $data ['collectArray'] = $collectArray;
  7900. $data ['adjustment'] = $adjustment;
  7901. $data ['totalPrice'] = $collectHtml;
  7902. $data ['totalYear'] = $total;
  7903. $data ['year'] = $year;
  7904. $data ['memu'] = "receipt";
  7905. $data ['staff'] = $this->staff;
  7906. $data ['receiptMemu'] = 'personalCollect';
  7907. $data ['verifyId'] = $this->verifyId;
  7908. $data ['executeId'] = $this->executeId;
  7909. // year staff status 2,4
  7910. if ($year < date ( "Y" )) {
  7911. Doo::loadModel ( 'receipt' );
  7912. $receipt = new receipt ();
  7913. $receiptList = $receipt->find ( array (
  7914. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7915. 'asArray' => true
  7916. ) );
  7917. if (empty ( $receiptList )) {
  7918. ob_start ();
  7919. $this->render ( "/admin/saeaCollectArticles", $data );
  7920. $this->cacheFile ( $path );
  7921. die ();
  7922. }
  7923. }
  7924. $this->render ( "/admin/saeaCollectArticles", $data );
  7925. }
  7926. function companyCategoryCollect() {
  7927. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7928. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  7929. $this->showCache ( $path );
  7930. Doo::loadModel ( 'L_category' );
  7931. Doo::loadModel ( 'itemStatistics' );
  7932. Doo::loadModel ( 'statistics' );
  7933. $statistics = new statistics ();
  7934. $Lcategory = new L_category ();
  7935. $itemStatistics = new itemStatistics ();
  7936. $LcategoryList = $Lcategory->find ( array (
  7937. 'asArray' => true
  7938. ) ); // 'staff='.$this->staff[0]['sid']." and
  7939. $itemStatisticsList = $itemStatistics->find ( array (
  7940. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7941. 'where' => " Year(date)=" . $year,
  7942. 'groupby' => 'cid,Month(date)',
  7943. 'asArray' => true
  7944. ) );
  7945. // ceatre companyCollectHtml
  7946. foreach ( $LcategoryList as $value ) {
  7947. $html = "";
  7948. $asum = 0;
  7949. for($i = 1; $i <= 12; $i ++) {
  7950. $falg = true;
  7951. foreach ( $itemStatisticsList as $v ) {
  7952. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  7953. $asum += $v ['price'];
  7954. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7955. $falg = false;
  7956. break;
  7957. }
  7958. }
  7959. if ($falg)
  7960. $html .= '<td class="taR">-</td>';
  7961. }
  7962. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7963. $collectHtml [$value ['title']] = array (
  7964. 'html' => $html,
  7965. 'cid' => $value ['cid']
  7966. );
  7967. }
  7968. $data ['companyHtml'] = $collectHtml;
  7969. // total price html
  7970. $collectHtml = "";
  7971. $total = 0;
  7972. for($i = 1; $i <= 12; $i ++) {
  7973. $sumPrice = 0;
  7974. foreach ( $itemStatisticsList as $key => $value ) {
  7975. if ($value ['month'] == $i) {
  7976. $sumPrice += $value ['price'];
  7977. }
  7978. }
  7979. if ($sumPrice == 0)
  7980. $collectHtml .= '<td class="taR">-</td>';
  7981. else
  7982. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7983. $total += $sumPrice;
  7984. }
  7985. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7986. $data ['companyTotalHtml'] = $collectHtml;
  7987. $data ['total'] = $total;
  7988. // statistics html
  7989. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7990. if (empty ( $stList ))
  7991. $stList = array (
  7992. 'rePrice' => 0,
  7993. 'agPrice' => 0
  7994. );
  7995. $data ['stList'] = array (
  7996. 'rePrice' => $stList ['rePrice'],
  7997. 'agPrice' => $stList ['agPrice'],
  7998. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7999. );
  8000. $data ['year'] = $year;
  8001. $data ['memu'] = "receipt";
  8002. $data ['staff'] = $this->staff;
  8003. $data ['receiptMemu'] = 'companyCategoryCollect';
  8004. $data ['verifyId'] = $this->verifyId;
  8005. $data ['executeId'] = $this->executeId;
  8006. // year staff status 2,4
  8007. if ($year < date ( "Y" )) {
  8008. Doo::loadModel ( 'receipt' );
  8009. $receipt = new receipt ();
  8010. $receiptList = $receipt->find ( array (
  8011. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  8012. 'asArray' => true
  8013. ) );
  8014. if (empty ( $receiptList )) {
  8015. ob_start ();
  8016. $this->render ( "/admin/saeaCompanyCollect", $data );
  8017. $this->cacheFile ( $path );
  8018. die ();
  8019. }
  8020. }
  8021. $this->render ( "/admin/saeaCompanyCollect", $data );
  8022. }
  8023. function categoryCollectDetail() {
  8024. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8025. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  8026. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  8027. $this->showCache ( $path );
  8028. Doo::loadModel ( 'statistics' );
  8029. $statistics = new statistics ();
  8030. Doo::loadModel ( "receiptDetail" );
  8031. $receiptDetail = new receiptDetail ();
  8032. Doo::loadModel ( 'L_category' );
  8033. $Lcategory = new L_category ();
  8034. Doo::loadModel ( 'accountItem' );
  8035. $accountItem = new accountItem ();
  8036. $LcategoryList = $Lcategory->find ( array (
  8037. 'asArray' => true
  8038. ) );
  8039. if ($cid == 0) {
  8040. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  8041. if ($cid == 0)
  8042. $cid = $LcategoryList [0] ['cid'];
  8043. }
  8044. $data ['LcategoryList'] = $LcategoryList;
  8045. $receiptCollectList = $receiptDetail->find ( array (
  8046. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8047. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  8048. 'groupby' => 'item,Month(pastDate)',
  8049. 'asArray' => true
  8050. ) );
  8051. $accountList = $accountItem->find ( array (
  8052. 'asArray' => true
  8053. ) );
  8054. // create CollectDetail HTML
  8055. $collectHtml = array ();
  8056. foreach ( $accountList as $key => $value ) {
  8057. $html = "";
  8058. $asum = 0;
  8059. for($i = 1; $i <= 12; $i ++) {
  8060. $falg = true;
  8061. foreach ( $receiptCollectList as $v ) {
  8062. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  8063. $asum += $v ['price'];
  8064. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8065. $falg = false;
  8066. break;
  8067. }
  8068. }
  8069. if ($falg)
  8070. $html .= '<td class="taR">-</td>';
  8071. }
  8072. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8073. $collectHtml [$value ['category']] [$value ['name']] = $html;
  8074. }
  8075. $data ['collectHtml'] = $collectHtml;
  8076. // create Adjustment price html
  8077. $receiptCollectList = $receiptDetail->find ( array (
  8078. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  8079. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  8080. 'groupby' => 'itemCategory,Month(pastDate)',
  8081. 'asArray' => true
  8082. ) );
  8083. $adjustment = array ();
  8084. $collectArray = array (
  8085. '日常相关费用' => array (),
  8086. '差旅相关费用' => array (),
  8087. '培训班费用' => array (),
  8088. '其他' => array ()
  8089. );
  8090. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  8091. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  8092. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  8093. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  8094. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  8095. array_push ( $collectArray ['培训班费用'], $collectHtml );
  8096. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  8097. array_push ( $collectArray ['其他'], $collectHtml );
  8098. $data ['collectArray'] = $collectArray;
  8099. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  8100. array_push ( $adjustment, $collectHtml );
  8101. $data ['adjustment'] = $adjustment;
  8102. // total price html
  8103. $collectHtml = "";
  8104. $total = 0;
  8105. for($i = 1; $i <= 12; $i ++) {
  8106. $sumPrice = 0;
  8107. foreach ( $receiptCollectList as $key => $value ) {
  8108. if ($value ['month'] == $i) {
  8109. $sumPrice += $value ['price'];
  8110. }
  8111. }
  8112. if ($sumPrice == 0)
  8113. $collectHtml .= '<td class="taR">-</td>';
  8114. else
  8115. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8116. $total += $sumPrice;
  8117. }
  8118. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8119. // statistics html
  8120. $stList = $statistics->statisticsByCid ( $year, $cid );
  8121. if (empty ( $stList ))
  8122. $stList = array (
  8123. 'rePrice' => 0,
  8124. 'agPrice' => 0
  8125. );
  8126. $data ['stList'] = array (
  8127. 'rePrice' => $stList ['rePrice'],
  8128. 'agPrice' => $stList ['agPrice'],
  8129. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8130. );
  8131. $data ['totalYear'] = $total;
  8132. $data ['year'] = $year;
  8133. $data ['cid'] = $cid;
  8134. $data ['memu'] = "receipt";
  8135. $data ['staff'] = $this->staff;
  8136. $data ['receiptMemu'] = 'companyCategoryCollect';
  8137. $data ['verifyId'] = $this->verifyId;
  8138. $data ['executeId'] = $this->executeId;
  8139. // year staff status 2,4
  8140. if ($year < date ( "Y" )) {
  8141. Doo::loadModel ( 'receipt' );
  8142. $receipt = new receipt ();
  8143. $receiptList = $receipt->find ( array (
  8144. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  8145. 'asArray' => true
  8146. ) );
  8147. if (empty ( $receiptList )) {
  8148. ob_start ();
  8149. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  8150. $this->cacheFile ( $path );
  8151. die ();
  8152. }
  8153. }
  8154. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  8155. }
  8156. function staffCollect() {
  8157. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8158. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  8159. // $this->showCache($path);
  8160. Doo::loadModel ( 'statistics' );
  8161. $statistics = new statistics ();
  8162. Doo::loadModel ( "receiptDetail" );
  8163. $receiptDetail = new receiptDetail ();
  8164. Doo::loadModel ( 'L_category' );
  8165. $Lcategory = new L_category ();
  8166. Doo::loadModel ( 'accountItem' );
  8167. $accountItem = new accountItem ();
  8168. Doo::loadModel ( 'staff' );
  8169. $staff = new staff ();
  8170. Doo::loadModel ( 'itemStatistics' );
  8171. $itemStatistics = new itemStatistics ();
  8172. // statistics html
  8173. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  8174. if (empty ( $stList ))
  8175. $stList = array (
  8176. 'rePrice' => 0,
  8177. 'agPrice' => 0
  8178. );
  8179. $data ['stList'] = array (
  8180. 'rePrice' => $stList ['rePrice'],
  8181. 'agPrice' => $stList ['agPrice'],
  8182. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8183. );
  8184. // ---
  8185. $staffList = $staff->find ( array (
  8186. 'where' => 'username !="admin"',
  8187. 'asArray' => true
  8188. ) );
  8189. $LcategoryList = $Lcategory->find ( array (
  8190. 'asArray' => true
  8191. ) ); // 'staff='.$this->staff[0]['sid']." and
  8192. $itemStatisticsList = $itemStatistics->find ( array (
  8193. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8194. 'where' => " Year(date)=" . $year,
  8195. 'groupby' => 'staff,Month(date)',
  8196. 'asArray' => true
  8197. ) );
  8198. $categoryList = $staff->find ( array (
  8199. 'select' => 'COUNT(*) as count,cid,category',
  8200. 'where' => 'username !="admin"',
  8201. 'groupby' => 'cid',
  8202. 'asArray' => true
  8203. ) );
  8204. // print_r($itemStatisticsList);die;
  8205. // ceatre companyCollectHtml
  8206. foreach ( $categoryList as $vlu ) {
  8207. $count = $vlu ['count'] + 1;
  8208. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  8209. $m1 = 0;
  8210. $m2 = 0;
  8211. $m3 = 0;
  8212. $m4 = 0;
  8213. $m5 = 0;
  8214. $m6 = 0;
  8215. $m7 = 0;
  8216. $m8 = 0;
  8217. $m9 = 0;
  8218. $m10 = 0;
  8219. $m11 = 0;
  8220. $m12 = 0;
  8221. $m13 = 0;
  8222. foreach ( $staffList as $value ) {
  8223. if ($vlu ['cid'] == $value ['cid']) {
  8224. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  8225. $asum = 0;
  8226. for($i = 1; $i <= 12; $i ++) {
  8227. $falg = true;
  8228. foreach ( $itemStatisticsList as $v ) {
  8229. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  8230. if ($v ['month'] == 1)
  8231. $m1 += $v ['price'];
  8232. if ($v ['month'] == 2)
  8233. $m2 += $v ['price'];
  8234. if ($v ['month'] == 3)
  8235. $m3 += $v ['price'];
  8236. if ($v ['month'] == 4)
  8237. $m4 += $v ['price'];
  8238. if ($v ['month'] == 5)
  8239. $m5 += $v ['price'];
  8240. if ($v ['month'] == 6)
  8241. $m6 += $v ['price'];
  8242. if ($v ['month'] == 7)
  8243. $m7 += $v ['price'];
  8244. if ($v ['month'] == 8)
  8245. $m8 += $v ['price'];
  8246. if ($v ['month'] == 9)
  8247. $m9 += $v ['price'];
  8248. if ($v ['month'] == 10)
  8249. $m10 += $v ['price'];
  8250. if ($v ['month'] == 11)
  8251. $m11 += $v ['price'];
  8252. if ($v ['month'] == 12)
  8253. $m12 += $v ['price'];
  8254. $asum += $v ['price'];
  8255. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8256. $falg = false;
  8257. break;
  8258. }
  8259. }
  8260. if ($falg)
  8261. $html .= '<td class="taR">-</td>';
  8262. }
  8263. $m13 += $asum;
  8264. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8265. $collectHtml [$value ['username'] . '_' . $value ['sid']] = array (
  8266. 'html' => $html,
  8267. 'sid' => $value ['sid']
  8268. );
  8269. $html = "";
  8270. }
  8271. }
  8272. $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>
  8273. <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>
  8274. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  8275. $collectHtml [$vlu ['cid']] = array (
  8276. 'html' => $hl,
  8277. 'sid' => ''
  8278. );
  8279. }
  8280. $data ['companyHtml'] = $collectHtml;
  8281. // total price html
  8282. $collectHtml = "";
  8283. $total = 0;
  8284. for($i = 1; $i <= 12; $i ++) {
  8285. $sumPrice = 0;
  8286. foreach ( $itemStatisticsList as $key => $value ) {
  8287. if ($value ['month'] == $i) {
  8288. $sumPrice += $value ['price'];
  8289. }
  8290. }
  8291. if ($sumPrice == 0)
  8292. $collectHtml .= '<td class="taR">-</td>';
  8293. else
  8294. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8295. $total += $sumPrice;
  8296. }
  8297. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8298. $data ['companyTotalHtml'] = $collectHtml;
  8299. $data ['total'] = $total;
  8300. $data ['year'] = $year;
  8301. $data ['memu'] = "receipt";
  8302. $data ['staff'] = $this->staff;
  8303. $data ['receiptMemu'] = 'companyCategoryCollect';
  8304. $data ['verifyId'] = $this->verifyId;
  8305. $data ['executeId'] = $this->executeId;
  8306. if ($year <= date ( "Y" )) {
  8307. Doo::loadModel ( 'receipt' );
  8308. $receipt = new receipt ();
  8309. $receiptList = $receipt->find ( array (
  8310. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  8311. 'asArray' => true
  8312. ) );
  8313. if (empty ( $receiptList )) { // generated files
  8314. ob_start ();
  8315. $this->render ( "/admin/saeaStaffCollectB", $data );
  8316. $this->cacheFile ( $path );
  8317. die ();
  8318. }
  8319. }
  8320. $this->render ( "/admin/saeaStaffCollectB", $data );
  8321. }
  8322. function staffCollectBak() {
  8323. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8324. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  8325. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  8326. $this->showCache ( $path );
  8327. Doo::loadModel ( 'statistics' );
  8328. $statistics = new statistics ();
  8329. Doo::loadModel ( "receiptDetail" );
  8330. $receiptDetail = new receiptDetail ();
  8331. Doo::loadModel ( 'L_category' );
  8332. $Lcategory = new L_category ();
  8333. Doo::loadModel ( 'accountItem' );
  8334. $accountItem = new accountItem ();
  8335. Doo::loadModel ( 'staff' );
  8336. $staff = new staff ();
  8337. Doo::loadModel ( 'itemStatistics' );
  8338. $itemStatistics = new itemStatistics ();
  8339. $itemStatisticsList = $itemStatistics->find ( array (
  8340. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8341. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8342. 'groupby' => 'staff,itemCategory,Month(date)',
  8343. 'asArray' => true
  8344. ) );
  8345. $itemCategoryList = $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' => 'cid,itemCategory,Month(date)',
  8349. 'asArray' => true
  8350. ) );
  8351. $LcategoryList = $Lcategory->find ( array (
  8352. 'asArray' => true
  8353. ) );
  8354. $staffList = $staff->find ( array (
  8355. 'asArray' => true
  8356. ) );
  8357. $htmlArray = array ();
  8358. foreach ( $LcategoryList as $value ) {
  8359. $htmlArray [$value ['title']] = array ();
  8360. foreach ( $staffList as $v ) {
  8361. if ($value ['cid'] == $v ['cid']) {
  8362. $html = "";
  8363. $falg = true;
  8364. $staffSumPrice = 0;
  8365. foreach ( $itemStatisticsList as $a ) {
  8366. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  8367. if (empty ( $a ['price'] )) {
  8368. $html .= '<td class="taR">-</td>';
  8369. $falg = false;
  8370. break;
  8371. } else {
  8372. $staffSumPrice += $a ['price'];
  8373. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8374. $falg = false;
  8375. break;
  8376. }
  8377. }
  8378. }
  8379. if ($falg) {
  8380. $html .= '<td class="taR">-</td>';
  8381. $falg = true;
  8382. }
  8383. $falg = true;
  8384. foreach ( $itemStatisticsList as $a ) {
  8385. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  8386. if (empty ( $a ['price'] )) {
  8387. $html .= '<td class="taR">-</td>';
  8388. $falg = false;
  8389. break;
  8390. } else {
  8391. $staffSumPrice += $a ['price'];
  8392. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8393. $falg = false;
  8394. break;
  8395. }
  8396. }
  8397. }
  8398. if ($falg) {
  8399. $html .= '<td class="taR">-</td>';
  8400. $falg = true;
  8401. }
  8402. $falg = true;
  8403. foreach ( $itemStatisticsList as $a ) {
  8404. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  8405. if (empty ( $a ['price'] )) {
  8406. $html .= '<td class="taR">-</td>';
  8407. $falg = false;
  8408. break;
  8409. } else {
  8410. $staffSumPrice += $a ['price'];
  8411. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8412. $falg = false;
  8413. break;
  8414. }
  8415. }
  8416. }
  8417. if ($falg) {
  8418. $html .= '<td class="taR">-</td>';
  8419. $falg = true;
  8420. }
  8421. $falg = true;
  8422. foreach ( $itemStatisticsList as $a ) {
  8423. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  8424. if (! empty ( $a ['price'] )) {
  8425. $staffSumPrice += $a ['price'];
  8426. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8427. $falg = false;
  8428. break;
  8429. } else {
  8430. $html .= '<td class="taR">-</td>';
  8431. $falg = false;
  8432. break;
  8433. }
  8434. }
  8435. }
  8436. if ($falg) {
  8437. $html .= '<td class="taR">-</td>';
  8438. $falg = true;
  8439. }
  8440. $falg = true;
  8441. foreach ( $itemStatisticsList as $a ) {
  8442. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  8443. if (! empty ( $a ['price'] )) {
  8444. $staffSumPrice += $a ['price'];
  8445. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8446. $falg = false;
  8447. break;
  8448. } else {
  8449. $html .= '<td class="taR">-</td>';
  8450. $falg = false;
  8451. break;
  8452. }
  8453. }
  8454. }
  8455. if ($falg) {
  8456. $html .= '<td class="taR">-</td>';
  8457. $falg = true;
  8458. }
  8459. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  8460. $htmlArray [$value ['title']] [$v ['username']] = $html;
  8461. }
  8462. }
  8463. /* -- --- */
  8464. // 合计费用
  8465. $cateHtml = "";
  8466. $catePrice = 0;
  8467. $cateFalg = true;
  8468. foreach ( $itemCategoryList as $l ) {
  8469. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  8470. if (empty ( $l ['price'] )) {
  8471. $cateHtml .= '<td class="colGreen taR">-</td>';
  8472. $cateFalg = false;
  8473. break;
  8474. } else {
  8475. $catePrice += $l ['price'];
  8476. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8477. $cateFalg = false;
  8478. break;
  8479. }
  8480. }
  8481. }
  8482. if ($cateFalg) {
  8483. $cateHtml .= '<td class="colGreen taR">-</td>';
  8484. $cateFalg = true;
  8485. }
  8486. $cateFalg = true;
  8487. foreach ( $itemCategoryList as $l ) {
  8488. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  8489. if (empty ( $l ['price'] )) {
  8490. $cateHtml .= '<td class="colGreen taR">-</td>';
  8491. $cateFalg = false;
  8492. break;
  8493. } else {
  8494. $catePrice += $l ['price'];
  8495. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8496. $cateFalg = false;
  8497. break;
  8498. }
  8499. }
  8500. }
  8501. if ($cateFalg) {
  8502. $cateHtml .= '<td class="colGreen taR">-</td>';
  8503. $cateFalg = true;
  8504. }
  8505. $cateFalg = true;
  8506. foreach ( $itemCategoryList as $l ) {
  8507. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  8508. if (empty ( $l ['price'] )) {
  8509. $cateHtml .= '<td class="colGreen taR">-</td>';
  8510. $cateFalg = false;
  8511. break;
  8512. } else {
  8513. $catePrice += $l ['price'];
  8514. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8515. $cateFalg = false;
  8516. break;
  8517. }
  8518. }
  8519. }
  8520. if ($cateFalg) {
  8521. $cateHtml .= '<td class="colGreen taR">-</td>';
  8522. $cateFalg = true;
  8523. }
  8524. $cateFalg = true;
  8525. foreach ( $itemCategoryList as $l ) {
  8526. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  8527. if (empty ( $l ['price'] )) {
  8528. $cateHtml .= '<td class="colGreen taR">-</td>';
  8529. $cateFalg = false;
  8530. break;
  8531. } else {
  8532. $catePrice += $l ['price'];
  8533. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8534. $cateFalg = false;
  8535. break;
  8536. }
  8537. }
  8538. }
  8539. if ($cateFalg) {
  8540. $cateHtml .= '<td class="colGreen taR">-</td>';
  8541. $cateFalg = true;
  8542. }
  8543. $cateFalg = true;
  8544. foreach ( $itemCategoryList as $l ) {
  8545. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  8546. if (empty ( $l ['price'] )) {
  8547. $cateHtml .= '<td class="colGreen taR">-</td>';
  8548. $cateFalg = false;
  8549. break;
  8550. } else {
  8551. $catePrice += $l ['price'];
  8552. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8553. $cateFalg = false;
  8554. break;
  8555. }
  8556. }
  8557. }
  8558. if ($cateFalg) {
  8559. $cateHtml .= '<td class="colGreen taR">-</td>';
  8560. $cateFalg = true;
  8561. }
  8562. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  8563. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  8564. /* -- --- */
  8565. }
  8566. // print_r($htmlArray);die;
  8567. $data ['htmlArray'] = $htmlArray;
  8568. // statistics html
  8569. $stList = $statistics->getOne ( array (
  8570. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8571. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8572. 'groupby' => 'Month(date)',
  8573. 'asArray' => true
  8574. ) );
  8575. if (empty ( $stList ))
  8576. $stList = array (
  8577. 'rePrice' => 0,
  8578. 'agPrice' => 0
  8579. );
  8580. $data ['stList'] = array (
  8581. 'rePrice' => $stList ['rePrice'],
  8582. 'agPrice' => $stList ['agPrice'],
  8583. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8584. );
  8585. $monthHtml = "";
  8586. for($i = 1; $i <= 12; $i ++) {
  8587. if ($i == $month)
  8588. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8589. else
  8590. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8591. }
  8592. $data ['monthHtml'] = $monthHtml;
  8593. $data ['year'] = $year;
  8594. $data ['month'] = $month;
  8595. $data ['memu'] = "receipt";
  8596. $data ['staff'] = $this->staff;
  8597. $data ['receiptMemu'] = 'companyCategoryCollect';
  8598. $data ['verifyId'] = $this->verifyId;
  8599. $data ['executeId'] = $this->executeId;
  8600. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  8601. Doo::loadModel ( 'receipt' );
  8602. $receipt = new receipt ();
  8603. $receiptList = $receipt->find ( array (
  8604. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  8605. 'asArray' => true
  8606. ) );
  8607. if (empty ( $receiptList )) { // generated files
  8608. ob_start ();
  8609. $this->render ( "/admin/saeaStaffCollect", $data );
  8610. $this->cacheFile ( $path );
  8611. die ();
  8612. }
  8613. }
  8614. $this->render ( "/admin/saeaStaffCollect", $data );
  8615. }
  8616. function lyt() {
  8617. Doo::loadModel ( "receiptDetail" );
  8618. $receiptDetail = new receiptDetail ();
  8619. $receiptCollectList = $receiptDetail->find ( array (
  8620. 'where' => 'status=1 ',
  8621. 'asArray' => true
  8622. ) );
  8623. foreach ( $receiptCollectList as $key => $value ) {
  8624. $receiptDetail = new receiptDetail ();
  8625. $receiptDetail->pastDate = $value ['date'];
  8626. $receiptDetail->update ( array (
  8627. 'where' => "rdid= '" . $value ['rdid'] . "'"
  8628. ) );
  8629. }
  8630. }
  8631. function staffCollectMonthDetail() {
  8632. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8633. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8634. if (! $year)
  8635. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8636. if (! $month)
  8637. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8638. Doo::loadModel ( 'staff' );
  8639. $staff = new staff ();
  8640. Doo::loadModel ( "receiptDetail" );
  8641. $receiptDetail = new receiptDetail ();
  8642. Doo::loadModel ( 'accountItem' );
  8643. $accountItem = new accountItem ();
  8644. Doo::loadModel ( 'statistics' );
  8645. $statistics = new statistics ();
  8646. Doo::loadModel ( 'L_category' );
  8647. $lCategory = new L_category ();
  8648. $staffList = $staff->find ( array (
  8649. 'where' => 'username!="admin"',
  8650. 'asArray' => true
  8651. ) );
  8652. $categoryList = $staff->find ( array (
  8653. 'select' => 'COUNT(*) as count,cid,category',
  8654. 'where' => 'username !="admin"',
  8655. 'groupby' => 'cid',
  8656. 'asArray' => true
  8657. ) );
  8658. $list = array ();
  8659. foreach ( $categoryList as $vlu ) {
  8660. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8661. $r1 = 0;
  8662. $r2 = 0;
  8663. $r3 = 0;
  8664. $r4 = 0;
  8665. $r5 = 0;
  8666. $r6 = 0;
  8667. $r7 = 0;
  8668. $r8 = 0;
  8669. $r9 = 0;
  8670. $r10 = 0;
  8671. $r11 = 0;
  8672. $r12 = 0;
  8673. $r13 = 0;
  8674. $r14 = 0;
  8675. $r15 = 0;
  8676. $r16 = 0;
  8677. $r17 = 0;
  8678. $r18 = 0;
  8679. $c1 = 0;
  8680. $c2 = 0;
  8681. $c3 = 0;
  8682. $c4 = 0;
  8683. $c5 = 0;
  8684. $c6 = 0;
  8685. $p1 = 0;
  8686. $p2 = 0;
  8687. $p3 = 0;
  8688. $p4 = 0;
  8689. $p5 = 0;
  8690. $p6 = 0;
  8691. $p7 = 0;
  8692. $p8 = 0;
  8693. $p9 = 0;
  8694. $t1 = 0;
  8695. $t2 = 0;
  8696. $t3 = 0;
  8697. $t4 = 0;
  8698. $t5 = 0;
  8699. $s1 = 0;
  8700. $m1 = 0;
  8701. foreach ( $staffList as $value ) {
  8702. if ($vlu ['cid'] == $value ['cid']) {
  8703. // pastDate
  8704. $receiptCollectList = $receiptDetail->find ( array (
  8705. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8706. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8707. 'groupby' => 'item,Month(pastDate),itemCategory',
  8708. 'asArray' => true
  8709. ) );
  8710. // if ($value['sid']==42){
  8711. // print_r($receiptCollectList);die;
  8712. // }
  8713. if (! empty ( $receiptCollectList )) {
  8714. $receiptL = array (
  8715. '日常相关费用' => array (),
  8716. '差旅相关费用' => array (),
  8717. '培训班费用' => array (),
  8718. '其他' => array ()
  8719. );
  8720. $html = "";
  8721. $psum = 0;
  8722. $item = array (
  8723. '市内交通费',
  8724. '市内出租费',
  8725. '办事处房租',
  8726. '电话费',
  8727. '水费',
  8728. '电费',
  8729. '办公费用',
  8730. '邮寄费',
  8731. '其他费用',
  8732. '车辆费用',
  8733. '广告费',
  8734. '团队建设费',
  8735. '物业管理费',
  8736. '宽带费',
  8737. '人员薪酬',
  8738. '公积金',
  8739. '社保'
  8740. );
  8741. foreach ( $item as $va ) {
  8742. $falg = true;
  8743. foreach ( $receiptCollectList as $v ) {
  8744. if ($v ['itemCategory'] == '日常相关费用') {
  8745. if ($v ['item'] == $va) {
  8746. if ($va == '市内交通费')
  8747. $r1 += $v ['price'];
  8748. if ($va == '市内出租费')
  8749. $r2 += $v ['price'];
  8750. if ($va == '办事处房租')
  8751. $r3 += $v ['price'];
  8752. if ($va == '电话费')
  8753. $r4 += $v ['price'];
  8754. if ($va == '水费')
  8755. $r5 += $v ['price'];
  8756. if ($va == '电费')
  8757. $r6 += $v ['price'];
  8758. if ($va == '办公费用')
  8759. $r7 += $v ['price'];
  8760. if ($va == '邮寄费')
  8761. $r8 += $v ['price'];
  8762. if ($va == '其他费用')
  8763. $r9 += $v ['price'];
  8764. if ($va == '车辆费用')
  8765. $r10 += $v ['price'];
  8766. if ($va == '广告费')
  8767. $r11 += $v ['price'];
  8768. if ($va == '团队建设费')
  8769. $r13 += $v ['price'];
  8770. if ($va == '物业管理费')
  8771. $r14 += $v ['price'];
  8772. if ($va == '宽带费')
  8773. $r15 += $v ['price'];
  8774. if ($va == '公积金')
  8775. $r16 += $v ['price'];
  8776. if ($va == '社保')
  8777. $r17 += $v ['price'];
  8778. if ($va == '人员薪酬')
  8779. $r18 += $v ['price'];
  8780. $psum += $v ['price'];
  8781. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8782. $falg = false;
  8783. break;
  8784. }
  8785. }
  8786. }
  8787. if ($falg)
  8788. $html .= '<td class="taR">-</td>';
  8789. }
  8790. $r12 += $psum;
  8791. if (! empty ( $psum ))
  8792. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8793. else
  8794. $psum = '<td class="colGreen taR">-</td>';
  8795. $receiptL ['日常相关费用'] = $psum . $html;
  8796. /* ----------------------------------- */
  8797. $html = "";
  8798. $psum = 0;
  8799. $item = array (
  8800. '往来交通费',
  8801. '市内交通费',
  8802. '出差住宿费',
  8803. '出差补助',
  8804. '其他费用'
  8805. );
  8806. foreach ( $item as $va ) {
  8807. $falg = true;
  8808. foreach ( $receiptCollectList as $v ) {
  8809. if ($v ['itemCategory'] == '差旅相关费用') {
  8810. if ($v ['item'] == $va) {
  8811. if ($va == '往来交通费')
  8812. $c1 += $v ['price'];
  8813. if ($va == '市内交通费')
  8814. $c2 += $v ['price'];
  8815. if ($va == '出差住宿费')
  8816. $c3 += $v ['price'];
  8817. if ($va == '出差补助')
  8818. $c4 += $v ['price'];
  8819. if ($va == '其他费用')
  8820. $c5 += $v ['price'];
  8821. $psum += $v ['price'];
  8822. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8823. $falg = false;
  8824. break;
  8825. }
  8826. }
  8827. }
  8828. if ($falg)
  8829. $html .= '<td class="taR">-</td>';
  8830. }
  8831. $c6 += $psum;
  8832. if (! empty ( $psum ))
  8833. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8834. else
  8835. $psum = '<td class="colGreen taR">-</td>';
  8836. $receiptL ['差旅相关费用'] = $psum . $html;
  8837. /* ------------------------------------- */
  8838. $html = "";
  8839. $psum = 0;
  8840. $item = array (
  8841. '场租费',
  8842. '薪酬',
  8843. '住宿费',
  8844. '交通费',
  8845. '餐饮费',
  8846. '办公费',
  8847. '公关费',
  8848. '其他'
  8849. );
  8850. foreach ( $item as $va ) {
  8851. $falg = true;
  8852. foreach ( $receiptCollectList as $v ) {
  8853. if ($v ['itemCategory'] == '培训班费用') {
  8854. if ($v ['item'] == $va) {
  8855. if ($va == '场租费')
  8856. $p1 += $v ['price'];
  8857. if ($va == '薪酬')
  8858. $p2 += $v ['price'];
  8859. if ($va == '住宿费')
  8860. $p3 += $v ['price'];
  8861. if ($va == '交通费')
  8862. $p4 += $v ['price'];
  8863. if ($va == '餐饮费')
  8864. $p5 += $v ['price'];
  8865. if ($va == '办公费')
  8866. $p6 += $v ['price'];
  8867. if ($va == '公关费')
  8868. $p7 += $v ['price'];
  8869. if ($va == '其他')
  8870. $p8 += $v ['price'];
  8871. $psum += $v ['price'];
  8872. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8873. $falg = false;
  8874. break;
  8875. }
  8876. }
  8877. }
  8878. if ($falg)
  8879. $html .= '<td class="taR">-</td>';
  8880. }
  8881. $p9 += $psum;
  8882. if (! empty ( $psum ))
  8883. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8884. else
  8885. $psum = '<td class="colGreen taR">-</td>';
  8886. $receiptL ['培训班费用'] = $psum . $html;
  8887. /* ------------------------------------- */
  8888. $html = "";
  8889. $psum = 0;
  8890. $item = array (
  8891. '公关费',
  8892. '广告费',
  8893. '借款',
  8894. '可自加费用'
  8895. );
  8896. foreach ( $item as $va ) {
  8897. $falg = true;
  8898. foreach ( $receiptCollectList as $v ) {
  8899. if ($v ['itemCategory'] == '其他') {
  8900. // if ($value['sid']==42){
  8901. //
  8902. // echo var_dump($v['item']);
  8903. // echo var_dump($va);
  8904. // echo var_dump($v['item']==" ".$va);
  8905. // echo $v['item']."==".$va."/<br/>";
  8906. // //print_r( $receiptCollectList);//echo $va;
  8907. // }
  8908. if (trim ( $v ['item'] ) == $va) {
  8909. if ($va == '公关费')
  8910. $t1 += $v ['price'];
  8911. if ($va == '广告费') {
  8912. $t2 += $v ['price'];
  8913. }
  8914. if ($va == '借款')
  8915. $t3 += $v ['price'];
  8916. if ($va == '可自加费用')
  8917. $t4 += $v ['price'];
  8918. $psum += $v ['price'];
  8919. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8920. $falg = false;
  8921. break;
  8922. }
  8923. }
  8924. }
  8925. if ($falg)
  8926. $html .= '<td class="taR">-</td>';
  8927. }
  8928. $t5 += $psum;
  8929. if (! empty ( $psum ))
  8930. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8931. else
  8932. $psum = '<td class="colGreen taR">-</td>';
  8933. $receiptL ['其他'] = $psum . $html;
  8934. /* ------------------------------------- */
  8935. $html = "";
  8936. $psum = 0;
  8937. foreach ( $receiptCollectList as $v ) {
  8938. if ($v ['itemCategory'] == '报销金额调整') {
  8939. if (! empty ( $v ['price'] )) {
  8940. $psum += $v ['price'];
  8941. }
  8942. }
  8943. }
  8944. $s1 += $psum;
  8945. if (! empty ( $psum ))
  8946. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8947. else
  8948. $psum = '<td class="taR colOrange">-</td>';
  8949. $receiptL ['报销金额调整'] = $psum . $html;
  8950. } else {
  8951. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8952. <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>
  8953. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8954. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  8955. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8956. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8957. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8958. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8959. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  8960. }
  8961. $monthStaffPrice = $receiptDetail->find ( array (
  8962. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8963. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8964. 'groupby' => 'Month(pastDate)',
  8965. 'asArray' => true
  8966. ) );
  8967. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  8968. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  8969. $m1 += $monthStaffPrice [0] ['price'];
  8970. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  8971. } else
  8972. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  8973. $receiptL ['usernameEn'] = urlencode ( $value ['username'] );
  8974. $list [$value ['username']] = $receiptL;
  8975. }
  8976. }
  8977. $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>
  8978. <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>
  8979. <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>';
  8980. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  8981. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  8982. $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>
  8983. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  8984. $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>';
  8985. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  8986. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  8987. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  8988. }
  8989. $data ['list'] = $list;
  8990. // print_r($list);
  8991. $receiptCollectList = $receiptDetail->find ( array (
  8992. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8993. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8994. 'groupby' => 'item,Month(pastDate),itemCategory',
  8995. 'asArray' => true
  8996. ) );
  8997. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  8998. // statistics html
  8999. $stList = $statistics->getOne ( array (
  9000. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9001. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9002. 'groupby' => 'Month(date)',
  9003. 'asArray' => true
  9004. ) );
  9005. if (empty ( $stList ))
  9006. $stList = array (
  9007. 'rePrice' => 0,
  9008. 'agPrice' => 0
  9009. );
  9010. $data ['stList'] = array (
  9011. 'rePrice' => $stList ['rePrice'],
  9012. 'agPrice' => $stList ['agPrice'],
  9013. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9014. );
  9015. $monthHtml = "";
  9016. for($i = 1; $i <= 12; $i ++) {
  9017. if ($i == $month)
  9018. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9019. else
  9020. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9021. }
  9022. $data ['monthHtml'] = $monthHtml;
  9023. $data ['year'] = $year;
  9024. $data ['month'] = $month;
  9025. $data ['memu'] = "receipt";
  9026. $data ['staff'] = $this->staff;
  9027. $data ['receiptMemu'] = 'companyCategoryCollect';
  9028. $data ['verifyId'] = $this->verifyId;
  9029. $data ['executeId'] = $this->executeId;
  9030. $this->render ( "/admin/staffCollectMonthDetail", $data );
  9031. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9032. }
  9033. function staffCollectMonthDetail2() {
  9034. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9035. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9036. if (! $year)
  9037. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9038. if (! $month)
  9039. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9040. Doo::loadModel ( 'staff' );
  9041. $staff = new staff ();
  9042. Doo::loadModel ( "receiptDetail" );
  9043. $receiptDetail = new receiptDetail ();
  9044. Doo::loadModel ( 'accountItem' );
  9045. $accountItem = new accountItem ();
  9046. Doo::loadModel ( 'statistics' );
  9047. $statistics = new statistics ();
  9048. Doo::loadModel ( 'L_category' );
  9049. $lCategory = new L_category ();
  9050. $staffList = $staff->find ( array (
  9051. 'where' => 'username!="admin"',
  9052. 'asArray' => true
  9053. ) );
  9054. $categoryList = $staff->find ( array (
  9055. 'select' => 'COUNT(*) as count,cid,category',
  9056. 'where' => 'username !="admin"',
  9057. 'groupby' => 'cid',
  9058. 'asArray' => true
  9059. ) );
  9060. $list = array ();
  9061. foreach ( $categoryList as $vlu ) {
  9062. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  9063. $r1 = 0;
  9064. $r2 = 0;
  9065. $r3 = 0;
  9066. $r4 = 0;
  9067. $r5 = 0;
  9068. $r6 = 0;
  9069. $r7 = 0;
  9070. $r8 = 0;
  9071. $r9 = 0;
  9072. $r10 = 0;
  9073. $r11 = 0;
  9074. $r12 = 0;
  9075. $r13 = 0;
  9076. $r14 = 0;
  9077. $r15 = 0;
  9078. $c1 = 0;
  9079. $c2 = 0;
  9080. $c3 = 0;
  9081. $c4 = 0;
  9082. $c5 = 0;
  9083. $c6 = 0;
  9084. $p1 = 0;
  9085. $p2 = 0;
  9086. $p3 = 0;
  9087. $p4 = 0;
  9088. $p5 = 0;
  9089. $p6 = 0;
  9090. $p7 = 0;
  9091. $p8 = 0;
  9092. $p9 = 0;
  9093. $t1 = 0;
  9094. $t2 = 0;
  9095. $t3 = 0;
  9096. $t4 = 0;
  9097. $t5 = 0;
  9098. $s1 = 0;
  9099. $m1 = 0;
  9100. foreach ( $staffList as $value ) {
  9101. if ($vlu ['cid'] == $value ['cid']) {
  9102. $receiptCollectList = $receiptDetail->find ( array (
  9103. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9104. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9105. 'groupby' => 'item,Month(date),itemCategory',
  9106. 'asArray' => true
  9107. ) );
  9108. if (! empty ( $receiptCollectList )) {
  9109. $receiptL = array (
  9110. '日常相关费用' => array (),
  9111. '差旅相关费用' => array (),
  9112. '培训班费用' => array (),
  9113. '其他' => array ()
  9114. );
  9115. $html = "";
  9116. $psum = 0;
  9117. $item = array (
  9118. '市内交通费',
  9119. '市内出租费',
  9120. '办事处房租',
  9121. '电话费',
  9122. '水费',
  9123. '电费',
  9124. '办公费用',
  9125. '邮寄费',
  9126. '其他费用',
  9127. '车辆费用',
  9128. '广告费',
  9129. '团队建设费',
  9130. '物业管理费',
  9131. '宽带费'
  9132. );
  9133. foreach ( $item as $va ) {
  9134. $falg = true;
  9135. foreach ( $receiptCollectList as $v ) {
  9136. if ($v ['itemCategory'] == '日常相关费用') {
  9137. if ($v ['item'] == $va) {
  9138. if ($va == '市内交通费')
  9139. $r1 += $v ['price'];
  9140. if ($va == '市内出租费')
  9141. $r2 += $v ['price'];
  9142. if ($va == '办事处房租')
  9143. $r3 += $v ['price'];
  9144. if ($va == '电话费')
  9145. $r4 += $v ['price'];
  9146. if ($va == '水费')
  9147. $r5 += $v ['price'];
  9148. if ($va == '电费')
  9149. $r6 += $v ['price'];
  9150. if ($va == '办公费用')
  9151. $r7 += $v ['price'];
  9152. if ($va == '邮寄费')
  9153. $r8 += $v ['price'];
  9154. if ($va == '其他费用')
  9155. $r9 += $v ['price'];
  9156. if ($va == '车辆费用')
  9157. $r10 += $v ['price'];
  9158. if ($va == '广告费')
  9159. $r11 += $v ['price'];
  9160. if ($va == '团队建设费')
  9161. $r13 += $v ['price'];
  9162. if ($va == '物业管理费')
  9163. $r14 += $v ['price'];
  9164. if ($va == '宽带费')
  9165. $r15 += $v ['price'];
  9166. $psum += $v ['price'];
  9167. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9168. $falg = false;
  9169. break;
  9170. }
  9171. }
  9172. }
  9173. if ($falg)
  9174. $html .= '<td class="taR">-</td>';
  9175. }
  9176. $r12 += $psum;
  9177. if (! empty ( $psum ))
  9178. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9179. else
  9180. $psum = '<td class="colGreen taR">-</td>';
  9181. $receiptL ['日常相关费用'] = $psum . $html;
  9182. /* ----------------------------------- */
  9183. $html = "";
  9184. $psum = 0;
  9185. $item = array (
  9186. '往来交通费',
  9187. '市内交通费',
  9188. '出差住宿费',
  9189. '出差补助',
  9190. '其他费用'
  9191. );
  9192. foreach ( $item as $va ) {
  9193. $falg = true;
  9194. foreach ( $receiptCollectList as $v ) {
  9195. if ($v ['itemCategory'] == '差旅相关费用') {
  9196. if ($v ['item'] == $va) {
  9197. if ($va == '往来交通费')
  9198. $c1 += $v ['price'];
  9199. if ($va == '市内交通费')
  9200. $c2 += $v ['price'];
  9201. if ($va == '出差住宿费')
  9202. $c3 += $v ['price'];
  9203. if ($va == '出差补助')
  9204. $c4 += $v ['price'];
  9205. if ($va == '其他费用')
  9206. $c5 += $v ['price'];
  9207. $psum += $v ['price'];
  9208. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9209. $falg = false;
  9210. break;
  9211. }
  9212. }
  9213. }
  9214. if ($falg)
  9215. $html .= '<td class="taR">-</td>';
  9216. }
  9217. $c6 += $psum;
  9218. if (! empty ( $psum ))
  9219. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9220. else
  9221. $psum = '<td class="colGreen taR">-</td>';
  9222. $receiptL ['差旅相关费用'] = $psum . $html;
  9223. /* ------------------------------------- */
  9224. $html = "";
  9225. $psum = 0;
  9226. $item = array (
  9227. '场租费',
  9228. '薪酬',
  9229. '住宿费',
  9230. '交通费',
  9231. '餐饮费',
  9232. '办公费',
  9233. '公关费',
  9234. '其他'
  9235. );
  9236. foreach ( $item as $va ) {
  9237. $falg = true;
  9238. foreach ( $receiptCollectList as $v ) {
  9239. if ($v ['itemCategory'] == '培训班费用') {
  9240. if ($v ['item'] == $va) {
  9241. if ($va == '场租费')
  9242. $p1 += $v ['price'];
  9243. if ($va == '薪酬')
  9244. $p2 += $v ['price'];
  9245. if ($va == '住宿费')
  9246. $p3 += $v ['price'];
  9247. if ($va == '交通费')
  9248. $p4 += $v ['price'];
  9249. if ($va == '餐饮费')
  9250. $p5 += $v ['price'];
  9251. if ($va == '办公费')
  9252. $p6 += $v ['price'];
  9253. if ($va == '公关费')
  9254. $p7 += $v ['price'];
  9255. if ($va == '其他')
  9256. $p8 += $v ['price'];
  9257. $psum += $v ['price'];
  9258. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9259. $falg = false;
  9260. break;
  9261. }
  9262. }
  9263. }
  9264. if ($falg)
  9265. $html .= '<td class="taR">-</td>';
  9266. }
  9267. $p9 += $psum;
  9268. if (! empty ( $psum ))
  9269. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9270. else
  9271. $psum = '<td class="colGreen taR">-</td>';
  9272. $receiptL ['培训班费用'] = $psum . $html;
  9273. /* ------------------------------------- */
  9274. $html = "";
  9275. $psum = 0;
  9276. $item = array (
  9277. '公关费',
  9278. '广告费',
  9279. '借款',
  9280. '可自加费用'
  9281. );
  9282. foreach ( $item as $va ) {
  9283. $falg = true;
  9284. foreach ( $receiptCollectList as $v ) {
  9285. if ($v ['itemCategory'] == '其他') {
  9286. if ($v ['item'] == $va) {
  9287. if ($va == '公关费')
  9288. $t1 += $v ['price'];
  9289. if ($va == '广告费')
  9290. $t2 += $v ['price'];
  9291. if ($va == '借款')
  9292. $t3 += $v ['price'];
  9293. if ($va == '可自加费用')
  9294. $t4 += $v ['price'];
  9295. $psum += $v ['price'];
  9296. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9297. $falg = false;
  9298. break;
  9299. }
  9300. }
  9301. }
  9302. if ($falg)
  9303. $html .= '<td class="taR">-</td>';
  9304. }
  9305. $t5 += $psum;
  9306. if (! empty ( $psum ))
  9307. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9308. else
  9309. $psum = '<td class="colGreen taR">-</td>';
  9310. $receiptL ['其他'] = $psum . $html;
  9311. /* ------------------------------------- */
  9312. $html = "";
  9313. $psum = 0;
  9314. foreach ( $receiptCollectList as $v ) {
  9315. if ($v ['itemCategory'] == '报销金额调整') {
  9316. if (! empty ( $v ['price'] )) {
  9317. $psum += $v ['price'];
  9318. }
  9319. }
  9320. }
  9321. $s1 += $psum;
  9322. if (! empty ( $psum ))
  9323. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9324. else
  9325. $psum = '<td class="taR colOrange">-</td>';
  9326. $receiptL ['报销金额调整'] = $psum . $html;
  9327. } else {
  9328. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9329. <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>';
  9330. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9331. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9332. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9333. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9334. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9335. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9336. }
  9337. $monthStaffPrice = $receiptDetail->find ( array (
  9338. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9339. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9340. 'asArray' => true
  9341. ) );
  9342. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  9343. $m1 += $monthStaffPrice [0] ['price'];
  9344. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9345. } else
  9346. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9347. $list [$value ['username']] = $receiptL;
  9348. }
  9349. }
  9350. $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>
  9351. <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>
  9352. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  9353. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  9354. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  9355. $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>
  9356. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  9357. $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>';
  9358. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  9359. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  9360. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  9361. }
  9362. $data ['list'] = $list;
  9363. $receiptCollectList = $receiptDetail->find ( array (
  9364. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9365. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9366. 'groupby' => 'item,Month(date),itemCategory',
  9367. 'asArray' => true
  9368. ) );
  9369. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9370. // statistics html
  9371. $stList = $statistics->getOne ( array (
  9372. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9373. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9374. 'groupby' => 'Month(date)',
  9375. 'asArray' => true
  9376. ) );
  9377. if (empty ( $stList ))
  9378. $stList = array (
  9379. 'rePrice' => 0,
  9380. 'agPrice' => 0
  9381. );
  9382. $data ['stList'] = array (
  9383. 'rePrice' => $stList ['rePrice'],
  9384. 'agPrice' => $stList ['agPrice'],
  9385. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9386. );
  9387. $monthHtml = "";
  9388. for($i = 1; $i <= 12; $i ++) {
  9389. if ($i == $month)
  9390. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9391. else
  9392. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9393. }
  9394. $data ['monthHtml'] = $monthHtml;
  9395. $data ['year'] = $year;
  9396. $data ['month'] = $month;
  9397. $data ['memu'] = "receipt";
  9398. $data ['staff'] = $this->staff;
  9399. $data ['receiptMemu'] = 'companyCategoryCollect';
  9400. $data ['verifyId'] = $this->verifyId;
  9401. $data ['executeId'] = $this->executeId;
  9402. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  9403. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9404. }
  9405. /**
  9406. * 用户报销单列表
  9407. */
  9408. function receiptStatisticsStaffDetail() {
  9409. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9410. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9411. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  9412. Doo::loadModel ( "receipt" );
  9413. $receipt = new receipt ();
  9414. Doo::loadModel ( "receiptDetail" );
  9415. $receiptDetail = new receiptDetail ();
  9416. Doo::loadModel ( 'staff' );
  9417. $staff = new staff ();
  9418. Doo::loadModel ( 'accountItem' );
  9419. $accountItem = new accountItem ();
  9420. Doo::loadModel ( 'statistics' );
  9421. $statistics = new statistics ();
  9422. if (! empty ( $username )) {
  9423. $username = addslashes ( urldecode ( $username ) );
  9424. $staffDetail = $staff->getStaffByName ( $username );
  9425. if (empty ( $staffDetail ))
  9426. die ( 'illegal request' );
  9427. $list = $receipt->getReceiptBySid ( $staffDetail ['sid'], $year, $month );
  9428. $itemList = $accountItem->getAccountItem ();
  9429. $itemHtml = '';
  9430. $categoryHtml = '';
  9431. $itemKeyList = array_keys ( $itemList );
  9432. // 报销单内容详情
  9433. foreach ( $list as $key => $value ) {
  9434. $accountItemList = json_decode ( $value ['accountItem'], true );
  9435. $list [$key] ['accountItemList'] = $accountItemList;
  9436. $receiptItemHtml = '';
  9437. foreach ( $itemKeyList as $v ) {
  9438. if ($v == '日常相关费用')
  9439. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['agencySum'] . '</td>';
  9440. elseif ($v == '差旅相关费用')
  9441. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['travelSum'] . '</td>';
  9442. elseif ($v == '培训班费用')
  9443. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['trainSum'] . '</td>';
  9444. elseif ($v == '其他')
  9445. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['otherSum'] . '</td>';
  9446. foreach ( $itemList [$v] as $ke => $va ) {
  9447. $falg = true;
  9448. if (! empty ( $accountItemList [$v] )) {
  9449. foreach ( $accountItemList [$v] as $ve ) {
  9450. if ($va ['name'] == $ve ['name']) {
  9451. $receiptItemHtml .= '<td class="taR">' . $ve ['price'] . '</td>';
  9452. $falg = false;
  9453. break;
  9454. }
  9455. }
  9456. }
  9457. if ($falg)
  9458. $receiptItemHtml .= '<td class="taR"></td>';
  9459. }
  9460. }
  9461. //金额调整和费用查看
  9462. $list [$key] ['receiptItemHtml'] = $receiptItemHtml;
  9463. }
  9464. // 报销单合计
  9465. $receiptTotalList = $receiptDetail->getReceiptTotalItem ( $staffDetail ['sid'], $year, $month );
  9466. $rtl = $receiptDetail->getReceiptTotalItemCategory ( $staffDetail ['sid'], $year, $month );
  9467. $receiptTotalHtml = '';
  9468. // 报销单项目抬头
  9469. foreach ( $itemKeyList as $value ) {
  9470. $count = count ( $itemList [$value] ) + 1;
  9471. $itemHtml .= '<th class="taC" colspan="' . $count . '">' . $value . '</th>';
  9472. $categoryHtml .= '<th class="taC">合计</th>';
  9473. foreach ( $rtl as $rtlValue ) {
  9474. if ($rtlValue ['itemCategory'] == $value) {
  9475. $receiptTotalHtml .= '<th>' . $rtlValue ['price'] . '</th>';
  9476. break;
  9477. }
  9478. }
  9479. foreach ( $itemList [$value] as $k => $v ) {
  9480. $categoryHtml .= '<th class="taC">' . $v ['name'] . '</th>';
  9481. // 合计
  9482. $falg = true;
  9483. foreach ( $receiptTotalList as $ve ) {
  9484. if ($ve ['itemCategory'] == $value && $ve ['item'] == $v ['name']) {
  9485. $receiptTotalHtml .= '<th >' . $ve ['price'] . '</th>';
  9486. $falg = false;
  9487. break;
  9488. }
  9489. }
  9490. if ($falg)
  9491. $receiptTotalHtml .= '<th></th>';
  9492. }
  9493. }
  9494. $stList = $statistics->getStatisticsBySid($staffDetail ['sid'], $year, $month);
  9495. if (empty ( $stList ))
  9496. $stList = array (
  9497. 'rePrice' => 0,
  9498. 'agPrice' => 0
  9499. );
  9500. $data ['stList'] = array (
  9501. 'rePrice' => $stList ['rePrice'],
  9502. 'agPrice' => $stList ['agPrice'],
  9503. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9504. );
  9505. $monthHtml = "";
  9506. for($i = 1; $i <= 12; $i ++) {
  9507. if ($i == $month)
  9508. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9509. else
  9510. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9511. }
  9512. $data ['username'] = urlencode ( $username );
  9513. $data ['monthHtml'] = $monthHtml;
  9514. $data ['receiptTotalHtml'] = $receiptTotalHtml;
  9515. $data ['list'] = $list;
  9516. $data ['categoryHtml'] = $categoryHtml;
  9517. $data ['itemHtml'] = $itemHtml;
  9518. $data ['itemList'] = $itemList;
  9519. $data ['year'] = $year;
  9520. $data ['month'] = $month;
  9521. $data ['memu'] = "receipt";
  9522. $data ['staff'] = $this->staff;
  9523. $data ['receiptMemu'] = 'companyCategoryCollect';
  9524. $data ['verifyId'] = $this->verifyId;
  9525. $data ['executeId'] = $this->executeId;
  9526. $this->render ( "/admin/receiptStatisticsStaffDetail", $data );
  9527. }
  9528. die ( 'illegal request' );
  9529. }
  9530. function companyMonthCollectDetail() {
  9531. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9532. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9533. if (! $year)
  9534. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9535. if (! $month)
  9536. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9537. Doo::loadModel ( 'staff' );
  9538. $staff = new staff ();
  9539. Doo::loadModel ( "receiptDetail" );
  9540. $receiptDetail = new receiptDetail ();
  9541. Doo::loadModel ( 'accountItem' );
  9542. $accountItem = new accountItem ();
  9543. Doo::loadModel ( 'statistics' );
  9544. $statistics = new statistics ();
  9545. Doo::loadModel ( 'L_category' );
  9546. $lCategory = new L_category ();
  9547. $staffList = $staff->find ( array (
  9548. 'where' => 'username!="admin"',
  9549. 'asArray' => true
  9550. ) );
  9551. $categoryList = $lCategory->find ( array (
  9552. 'asArray' => true
  9553. ) );
  9554. $list = array ();
  9555. foreach ( $categoryList as $value ) {
  9556. $receiptCollectList = $receiptDetail->find ( array (
  9557. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9558. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9559. 'groupby' => 'item,Month(pastDate),itemCategory',
  9560. 'asArray' => true
  9561. ) );
  9562. if (! empty ( $receiptCollectList )) {
  9563. $receiptL = array (
  9564. '日常相关费用' => array (),
  9565. '差旅相关费用' => array (),
  9566. '培训班费用' => array (),
  9567. '其他' => array ()
  9568. );
  9569. $html = "";
  9570. $psum = 0;
  9571. $item = array (
  9572. '市内交通费',
  9573. '市内出租费',
  9574. '办事处房租',
  9575. '电话费',
  9576. '水费',
  9577. '电费',
  9578. '办公费用',
  9579. '邮寄费',
  9580. '其他费用',
  9581. '车辆费用',
  9582. '广告费',
  9583. '团队建设费'
  9584. );
  9585. foreach ( $item as $va ) {
  9586. $falg = true;
  9587. foreach ( $receiptCollectList as $v ) {
  9588. if ($v ['itemCategory'] == '日常相关费用') {
  9589. if ($v ['item'] == $va) {
  9590. $psum += $v ['price'];
  9591. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9592. $falg = false;
  9593. break;
  9594. }
  9595. }
  9596. }
  9597. if ($falg)
  9598. $html .= '<td class="taR">-</td>';
  9599. }
  9600. if (! empty ( $psum ))
  9601. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9602. else
  9603. $psum = '<td class="colGreen taR">-</td>';
  9604. $receiptL ['日常相关费用'] = $psum . $html;
  9605. /* ----------------------------------- */
  9606. $html = "";
  9607. $psum = 0;
  9608. $item = array (
  9609. '往来交通费',
  9610. '市内交通费',
  9611. '出差住宿费',
  9612. '出差补助',
  9613. '其他费用'
  9614. );
  9615. foreach ( $item as $va ) {
  9616. $falg = true;
  9617. foreach ( $receiptCollectList as $v ) {
  9618. if ($v ['itemCategory'] == '差旅相关费用') {
  9619. if ($v ['item'] == $va) {
  9620. $psum += $v ['price'];
  9621. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9622. $falg = false;
  9623. break;
  9624. }
  9625. }
  9626. }
  9627. if ($falg)
  9628. $html .= '<td class="taR">-</td>';
  9629. }
  9630. if (! empty ( $psum ))
  9631. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9632. else
  9633. $psum = '<td class="colGreen taR">-</td>';
  9634. $receiptL ['差旅相关费用'] = $psum . $html;
  9635. /* ------------------------------------- */
  9636. $html = "";
  9637. $psum = 0;
  9638. $item = array (
  9639. '场租费',
  9640. '薪酬',
  9641. '住宿费',
  9642. '交通费',
  9643. '餐饮费',
  9644. '办公费',
  9645. '公关费',
  9646. '其他'
  9647. );
  9648. foreach ( $item as $va ) {
  9649. $falg = true;
  9650. foreach ( $receiptCollectList as $v ) {
  9651. if ($v ['itemCategory'] == '培训班费用') {
  9652. if ($v ['item'] == $va) {
  9653. $psum += $v ['price'];
  9654. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9655. $falg = false;
  9656. break;
  9657. }
  9658. }
  9659. }
  9660. if ($falg)
  9661. $html .= '<td class="taR">-</td>';
  9662. }
  9663. if (! empty ( $psum ))
  9664. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9665. else
  9666. $psum = '<td class="colGreen taR">-</td>';
  9667. $receiptL ['培训班费用'] = $psum . $html;
  9668. /* ------------------------------------- */
  9669. $html = "";
  9670. $psum = 0;
  9671. $item = array (
  9672. '公关费',
  9673. '广告费',
  9674. '借款',
  9675. '可自加费用'
  9676. );
  9677. foreach ( $item as $va ) {
  9678. $falg = true;
  9679. foreach ( $receiptCollectList as $v ) {
  9680. if ($v ['itemCategory'] == '其他') {
  9681. if ($v ['item'] == $va) {
  9682. $psum += $v ['price'];
  9683. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9684. $falg = false;
  9685. break;
  9686. }
  9687. }
  9688. }
  9689. if ($falg)
  9690. $html .= '<td class="taR">-</td>';
  9691. }
  9692. if (! empty ( $psum ))
  9693. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9694. else
  9695. $psum = '<td class="colGreen taR">-</td>';
  9696. $receiptL ['其他'] = $psum . $html;
  9697. /* ------------------------------------- */
  9698. $html = "";
  9699. $psum = 0;
  9700. foreach ( $receiptCollectList as $v ) {
  9701. if ($v ['itemCategory'] == '报销金额调整') {
  9702. if (! empty ( $v ['price'] ))
  9703. $psum += $v ['price'];
  9704. }
  9705. }
  9706. if (! empty ( $psum ))
  9707. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9708. else
  9709. $psum = '<td class="taR colOrange">-</td>';
  9710. $receiptL ['报销金额调整'] = $psum . $html;
  9711. } else {
  9712. $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>
  9713. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9714. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9715. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9716. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9717. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9718. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9719. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9720. }
  9721. $monthStaffPrice = $receiptDetail->find ( array (
  9722. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9723. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9724. 'asArray' => true
  9725. ) );
  9726. if (! empty ( $monthStaffPrice [0] ['price'] ))
  9727. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9728. else
  9729. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9730. $list [$value ['title']] = $receiptL;
  9731. }
  9732. $data ['list'] = $list;
  9733. $receiptCollectList = $receiptDetail->find ( array (
  9734. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9735. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9736. 'groupby' => 'item,Month(pastDate),itemCategory',
  9737. 'asArray' => true
  9738. ) );
  9739. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9740. // print_r($data['monthPriceHtml']);
  9741. // foreach ($data['monthPriceHtml'] as $value){
  9742. // echo $value;
  9743. // }
  9744. // die;
  9745. // statistics html
  9746. $stList = $statistics->getOne ( array (
  9747. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9748. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9749. 'groupby' => 'Month(date)',
  9750. 'asArray' => true
  9751. ) );
  9752. if (empty ( $stList ))
  9753. $stList = array (
  9754. 'rePrice' => 0,
  9755. 'agPrice' => 0
  9756. );
  9757. $data ['stList'] = array (
  9758. 'rePrice' => $stList ['rePrice'],
  9759. 'agPrice' => $stList ['agPrice'],
  9760. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9761. );
  9762. $monthHtml = "";
  9763. for($i = 1; $i <= 12; $i ++) {
  9764. if ($i == $month)
  9765. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9766. else
  9767. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9768. }
  9769. $data ['monthHtml'] = $monthHtml;
  9770. $data ['year'] = $year;
  9771. $data ['month'] = $month;
  9772. $data ['memu'] = "receipt";
  9773. $data ['staff'] = $this->staff;
  9774. $data ['receiptMemu'] = 'companyCategoryCollect';
  9775. $data ['verifyId'] = $this->verifyId;
  9776. $data ['executeId'] = $this->executeId;
  9777. $this->render ( "/admin/companyMonthCollectDetail", $data );
  9778. }
  9779. function staffCollectDetail() {
  9780. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9781. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  9782. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  9783. if (! $staffname) {
  9784. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  9785. $staffname = urldecode ( $staffname );
  9786. }
  9787. Doo::loadModel ( 'staff' );
  9788. $staff = new staff ();
  9789. Doo::loadModel ( "receiptDetail" );
  9790. $receiptDetail = new receiptDetail ();
  9791. Doo::loadModel ( 'accountItem' );
  9792. $accountItem = new accountItem ();
  9793. Doo::loadModel ( 'statistics' );
  9794. $statistics = new statistics ();
  9795. Doo::loadModel ( 'L_category' );
  9796. $lCategory = new L_category ();
  9797. $staffList = $staff->find ( array (
  9798. 'asArray' => true
  9799. ) );
  9800. $stHtml = '';
  9801. $stTitle = "";
  9802. $staffId = 0;
  9803. $cid = 0;
  9804. $ocid = 0;
  9805. foreach ( $staffList as $value ) {
  9806. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  9807. $stTitle = $value ['category'] . '-' . $value ['username'];
  9808. $staffId = $value ['sid'];
  9809. $cid = $value ['cid'];
  9810. $ocid = $value ['cid'];
  9811. if (! empty ( $value ['othercid'] ))
  9812. $cid = $value ['cid'] . ',' . $value ['othercid'];
  9813. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9814. } elseif ($value ['username'] != 'admin')
  9815. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9816. }
  9817. $data ['lCategoryHtml'] = $lCategory->find ( array (
  9818. 'where' => 'cid in(' . $cid . ')',
  9819. 'asArray' => true
  9820. ) );
  9821. if (empty ( $pcid ))
  9822. $pcid = $ocid;
  9823. $data ['ocid'] = $pcid;
  9824. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  9825. $this->showCache ( $path );
  9826. //
  9827. $receiptCollectList = $receiptDetail->find ( array (
  9828. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9829. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9830. 'groupby' => 'item,Month(pastDate),itemCategory',
  9831. 'asArray' => true
  9832. ) );
  9833. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  9834. // print_r($receiptCollectList);
  9835. $accountList = $accountItem->find ( array (
  9836. 'asArray' => true
  9837. ) );
  9838. // create CollectDetail HTML
  9839. $collectHtml = array ();
  9840. foreach ( $accountList as $key => $value ) {
  9841. $html = "";
  9842. $asum = 0;
  9843. for($i = 1; $i <= 12; $i ++) {
  9844. $falg = true;
  9845. foreach ( $receiptCollectList as $v ) {
  9846. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9847. if ($v ['item'] == '可自加费用') {
  9848. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  9849. }
  9850. $asum += $v ['price'];
  9851. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9852. $falg = false;
  9853. break;
  9854. }
  9855. }
  9856. if ($falg)
  9857. $html .= '<td class="taR">-</td>';
  9858. }
  9859. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9860. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9861. }
  9862. $data ['collectHtml'] = $collectHtml;
  9863. // print_r($collectHtml);
  9864. // create Adjustment price html
  9865. $receiptCollectList = $receiptDetail->find ( array (
  9866. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9867. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9868. 'groupby' => 'itemCategory,Month(pastDate)',
  9869. 'asArray' => true
  9870. ) );
  9871. $adjustment = array ();
  9872. $collectArray = array (
  9873. '日常相关费用' => array (),
  9874. '差旅相关费用' => array (),
  9875. '培训班费用' => array (),
  9876. '其他' => array ()
  9877. );
  9878. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9879. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9880. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9881. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9882. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9883. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9884. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9885. array_push ( $collectArray ['其他'], $collectHtml );
  9886. $data ['collectArray'] = $collectArray;
  9887. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9888. array_push ( $adjustment, $collectHtml );
  9889. $data ['adjustment'] = $adjustment;
  9890. // total price html
  9891. $collectHtml = "";
  9892. $total = 0;
  9893. for($i = 1; $i <= 12; $i ++) {
  9894. $sumPrice = 0;
  9895. foreach ( $receiptCollectList as $key => $value ) {
  9896. if ($value ['month'] == $i) {
  9897. $sumPrice += $value ['price'];
  9898. }
  9899. }
  9900. if ($sumPrice == 0)
  9901. $collectHtml .= '<td class="taR">-</td>';
  9902. else
  9903. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9904. $total += $sumPrice;
  9905. }
  9906. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9907. // statistics html
  9908. $stList = $statistics->statisticsByYear ( $year, $staffId );
  9909. if (empty ( $stList ))
  9910. $stList = array (
  9911. 'rePrice' => 0,
  9912. 'agPrice' => 0
  9913. );
  9914. $data ['stList'] = array (
  9915. 'rePrice' => $stList ['rePrice'],
  9916. 'agPrice' => $stList ['agPrice'],
  9917. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9918. );
  9919. $data ['totalPrice'] = $collectHtml;
  9920. $data ['totalYear'] = $total;
  9921. $data ['stHtml'] = $stHtml;
  9922. $data ['year'] = $year;
  9923. $data ['stTitle'] = $stTitle;
  9924. $data ['memu'] = "receipt";
  9925. $data ['staff'] = $this->staff;
  9926. $data ['receiptMemu'] = 'companyCategoryCollect';
  9927. $data ['verifyId'] = $this->verifyId;
  9928. $data ['executeId'] = $this->executeId;
  9929. if ($year < date ( "Y" )) {
  9930. Doo::loadModel ( 'receipt' );
  9931. $receipt = new receipt ();
  9932. $receiptList = $receipt->find ( array (
  9933. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  9934. 'asArray' => true
  9935. ) );
  9936. if (empty ( $receiptList )) { // generated files
  9937. ob_start ();
  9938. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9939. $this->cacheFile ( $path );
  9940. die ();
  9941. }
  9942. }
  9943. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9944. }
  9945. function BUGFLAG() {
  9946. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  9947. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  9948. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9949. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9950. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  9951. if (empty ( $status ))
  9952. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  9953. $page_size = 12;
  9954. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  9955. $vidList = array ();
  9956. $button = 0;
  9957. Doo::loadModel ( 'verify' );
  9958. $verify = new verify ();
  9959. Doo::loadModel ( 'receipt' );
  9960. $receipt = new receipt ();
  9961. Doo::loadModel ( 'staff' );
  9962. $staff = new staff ();
  9963. Doo::loadModel ( 'L_category' );
  9964. $Lcategory = new L_category ();
  9965. $dateCondition = " and Year(date) =" . $year;
  9966. if (! empty ( $month ))
  9967. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  9968. $categoryList = $Lcategory->find ( array (
  9969. 'asArray' => true
  9970. ) );
  9971. $staffList = $staff->find ( array (
  9972. 'where' => 'cid=' . $cid,
  9973. 'asArray' => true
  9974. ) );
  9975. $cateCondition = "";
  9976. $staffCondition = "";
  9977. $approvalCondition = "";
  9978. if (! empty ( $cid ))
  9979. $cateCondition = ' and cid=' . $cid;
  9980. if (! empty ( $sid )) {
  9981. $staffCondition = ' and staff=' . $sid;
  9982. $cateCondition = "";
  9983. }
  9984. $approvalCondition = " and status=" . $status;
  9985. if ($status == 2) {
  9986. // 查找角色审批人
  9987. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9988. }
  9989. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  9990. $approvalCondition = ' and status=2 ';
  9991. }
  9992. if ($status == 1) {
  9993. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  9994. }
  9995. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  9996. $pageinfo ['page'] = array (
  9997. 'previous' => ''
  9998. );
  9999. if ($status == 0) {
  10000. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  10001. $receiptList = $receipt->find ( array (
  10002. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  10003. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  10004. 'desc' => 'rid',
  10005. 'asArray' => true
  10006. ) );
  10007. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  10008. } else
  10009. $receiptList = $receipt->find ( array (
  10010. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  10011. 'desc' => 'rid',
  10012. 'asArray' => true
  10013. ) );
  10014. $rLRes = $receipt->find ( array (
  10015. '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,
  10016. 'desc' => 'rid',
  10017. 'asArray' => true
  10018. ) );
  10019. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  10020. // print_r($pageinfo);
  10021. $Locate = 0;
  10022. foreach ( $receiptList as $key => $value ) {
  10023. $receiptList [$key] ['Locate'] = $Locate;
  10024. $Locate ++;
  10025. $receiptList [$key] ['reviseDetail'] = array ();
  10026. if (! empty ( $value ['reviseDetail'] ))
  10027. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  10028. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  10029. $categoryDetil = $Lcategory->getOne ( array (
  10030. 'where' => 'cid=' . $value ['cid'],
  10031. 'asArray' => true
  10032. ) );
  10033. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  10034. $verifyList = $verify->getOne ( array (
  10035. 'where' => 'vid=' . $value ['verify'],
  10036. 'asArray' => true
  10037. ) );
  10038. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  10039. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  10040. foreach ( $verifyList as $k => $v ) {
  10041. // init verifyStaff
  10042. $verifyList [$k] ['date'] = "";
  10043. $verifyList [$k] ['opinion'] = "";
  10044. $verifyList [$k] ['status'] = "";
  10045. if (empty ( $verifyStaff )) {
  10046. $verifyList [$k] ['date'] = "";
  10047. $verifyList [$k] ['opinion'] = "";
  10048. if ($v [0] == $this->staff [0] ['sid']) {
  10049. $verifyList [$k] ['status'] = 4;
  10050. $button = 4;
  10051. }
  10052. } else {
  10053. $flag = true;
  10054. foreach ( $verifyStaff as $m => $u ) {
  10055. if ($v [0] == $m) {
  10056. $verifyList [$k] ['date'] = $u ['date'];
  10057. $verifyList [$k] ['opinion'] = $u ['opinion'];
  10058. $verifyList [$k] ['status'] = $u ['status'];
  10059. $flag = false;
  10060. break;
  10061. }
  10062. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  10063. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  10064. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  10065. }
  10066. if ($flag) { // 检测可编辑
  10067. if ($v [0] == $this->staff [0] ['sid']) {
  10068. $verifyList [$k] ['status'] = 4;
  10069. $button = 4;
  10070. }
  10071. }
  10072. }
  10073. }
  10074. $receiptList [$key] ['verifyList'] = $verifyList;
  10075. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  10076. 'where' => 'sid=' . $value ['staff'],
  10077. 'asArray' => true
  10078. ) );
  10079. $receiptList [$key] ['button'] = $button;
  10080. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  10081. }
  10082. // print_r($receiptList);die;
  10083. // $data['verifyDetail']=$verifyDetail;
  10084. $mothHtml = "";
  10085. for($i = 1; $i <= 12; $i ++) {
  10086. if ($month == $i)
  10087. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  10088. else
  10089. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  10090. }
  10091. $data ['mothHtml'] = $mothHtml;
  10092. $data ['page'] = $pageinfo;
  10093. $data ['receiptList'] = $receiptList;
  10094. $data ['receiptApprovalCount'] = count ( $rLRes );
  10095. $data ['status'] = $status;
  10096. $data ['year'] = $year;
  10097. $data ['categoryList'] = $categoryList;
  10098. $data ['staffList'] = $staffList;
  10099. $data ['cid'] = $cid;
  10100. $data ['sid'] = $sid;
  10101. // print_r($receiptList);
  10102. $data ['memu'] = "receipt";
  10103. $data ['staff'] = $this->staff;
  10104. $data ['receiptMemu'] = 'approvalExpenses';
  10105. $data ['verifyId'] = $this->verifyId;
  10106. $data ['executeId'] = $this->executeId;
  10107. $this->render ( "/admin/FALG", $data );
  10108. }
  10109. function ajaxGetReceiptOrder() {
  10110. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  10111. if (! empty ( $receiptOrder )) {
  10112. Doo::loadModel ( 'receipt' );
  10113. $receipt = new receipt ();
  10114. Doo::loadModel ( 'staff' );
  10115. $staff = new staff ();
  10116. $receiptInfo = $receipt->getOne ( array (
  10117. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  10118. 'asArray' => true
  10119. ) );
  10120. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  10121. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  10122. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  10123. </tbody></table><table class="table table table-bordered"><tbody>';
  10124. foreach ( $verifyStaff as $key => $value ) {
  10125. $staffInfo = $staff->getOne ( array (
  10126. 'select' => 'username',
  10127. 'where' => ' sid="' . $key . '"',
  10128. 'asArray' => true
  10129. ) );
  10130. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  10131. }
  10132. $html .= '</tbody></table></div></div>';
  10133. echo json_encode ( array (
  10134. 'status' => 1,
  10135. 'receiptHtml' => $html
  10136. ) );
  10137. die ();
  10138. }
  10139. echo json_encode ( array (
  10140. 'status' => 2,
  10141. 'receiptHtml' => ''
  10142. ) );
  10143. die ();
  10144. }
  10145. function _getMonthCollectDetail($receiptCollectList) {
  10146. if (! empty ( $receiptCollectList )) {
  10147. $receiptL = array (
  10148. '日常相关费用' => array (),
  10149. '差旅相关费用' => array (),
  10150. '培训班费用' => array (),
  10151. '其他' => array ()
  10152. );
  10153. $html = "";
  10154. $psum = 0;
  10155. $item = array (
  10156. '市内交通费',
  10157. '市内出租费',
  10158. '办事处房租',
  10159. '电话费',
  10160. '水费',
  10161. '电费',
  10162. '办公费用',
  10163. '邮寄费',
  10164. '其他费用',
  10165. '车辆费用',
  10166. '广告费',
  10167. '团队建设费',
  10168. '物业管理费',
  10169. '宽带费'
  10170. );
  10171. foreach ( $item as $value ) {
  10172. $falg = true;
  10173. foreach ( $receiptCollectList as $v ) {
  10174. if ($v ['itemCategory'] == '日常相关费用') {
  10175. if ($v ['item'] == $value) {
  10176. $psum += $v ['price'];
  10177. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10178. $falg = false;
  10179. break;
  10180. }
  10181. }
  10182. }
  10183. if ($falg)
  10184. $html .= '<td class="taR">-</td>';
  10185. }
  10186. if (! empty ( $psum ))
  10187. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  10188. else
  10189. $psum = '<td class="colGreen taR">-</td>';
  10190. $receiptL ['日常相关费用'] = $psum . $html;
  10191. /* ----------------------------------- */
  10192. $html = "";
  10193. $psum = 0;
  10194. $item = array (
  10195. '往来交通费',
  10196. '市内交通费',
  10197. '出差住宿费',
  10198. '出差补助',
  10199. '其他费用'
  10200. );
  10201. foreach ( $item as $value ) {
  10202. $falg = true;
  10203. foreach ( $receiptCollectList as $v ) {
  10204. if ($v ['itemCategory'] == '差旅相关费用') {
  10205. if ($v ['item'] == $value) {
  10206. $psum += $v ['price'];
  10207. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10208. $falg = false;
  10209. break;
  10210. }
  10211. }
  10212. }
  10213. if ($falg)
  10214. $html .= '<td class="taR">-</td>';
  10215. }
  10216. if (! empty ( $psum ))
  10217. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  10218. else
  10219. $psum = '<td class="colGreen taR">-</td>';
  10220. $receiptL ['差旅相关费用'] = $psum . $html;
  10221. /* ------------------------------------- */
  10222. $html = "";
  10223. $psum = 0;
  10224. $item = array (
  10225. '场租费',
  10226. '薪酬',
  10227. '住宿费',
  10228. '交通费',
  10229. '餐饮费',
  10230. '办公费',
  10231. '公关费',
  10232. '其他'
  10233. );
  10234. foreach ( $item as $value ) {
  10235. $falg = true;
  10236. foreach ( $receiptCollectList as $v ) {
  10237. if ($v ['itemCategory'] == '培训班费用') {
  10238. if ($v ['item'] == $value) {
  10239. $psum += $v ['price'];
  10240. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10241. $falg = false;
  10242. break;
  10243. }
  10244. }
  10245. }
  10246. if ($falg)
  10247. $html .= '<td class="taR">-</td>';
  10248. }
  10249. if (! empty ( $psum ))
  10250. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  10251. else
  10252. $psum = '<td class="colGreen taR">-</td>';
  10253. $receiptL ['培训班费用'] = $psum . $html;
  10254. /* ------------------------------------- */
  10255. $html = "";
  10256. $psum = 0;
  10257. $item = array (
  10258. '公关费',
  10259. '广告费',
  10260. '借款',
  10261. '可自加费用'
  10262. );
  10263. foreach ( $item as $value ) {
  10264. $falg = true;
  10265. foreach ( $receiptCollectList as $v ) {
  10266. if ($v ['itemCategory'] == '其他') {
  10267. if ($v ['item'] == $value) {
  10268. $psum += $v ['price'];
  10269. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10270. $falg = false;
  10271. break;
  10272. }
  10273. }
  10274. }
  10275. if ($falg)
  10276. $html .= '<td class="taR">-</td>';
  10277. }
  10278. if (! empty ( $psum ))
  10279. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  10280. else
  10281. $psum = '<td class="colGreen taR">-</td>';
  10282. $receiptL ['其他'] = $psum . $html;
  10283. /* ------------------------------------- */
  10284. $html = "";
  10285. $psum = 0;
  10286. foreach ( $receiptCollectList as $v ) {
  10287. if ($v ['itemCategory'] == '报销金额调整') {
  10288. if (! empty ( $v ['price'] ))
  10289. $psum += $v ['price'];
  10290. }
  10291. }
  10292. if (! empty ( $psum ))
  10293. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  10294. else
  10295. $psum = '<td class="taR colOrange">-</td>';
  10296. $receiptL ['报销金额调整'] = $psum . $html;
  10297. } else {
  10298. $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>
  10299. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10300. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  10301. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10302. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  10303. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10304. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10305. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  10306. }
  10307. return $receiptL;
  10308. }
  10309. function eMail() {
  10310. Doo::loadModel ( 'staff' );
  10311. $staff = new staff ();
  10312. Doo::loadModel ( 'receipt' );
  10313. $receipt = new receipt ();
  10314. Doo::loadModel ( 'L_category' );
  10315. $Lcategory = new L_category ();
  10316. Doo::loadModel ( "verify" );
  10317. $verify = new verify ();
  10318. $staffList = $staff->find ( array (
  10319. 'asArray' => true
  10320. ) );
  10321. foreach ( $staffList as $key => $value ) {
  10322. if ($value ['username'] != 'admin') {
  10323. // 提交人
  10324. $receiptList = $receipt->find ( array (
  10325. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  10326. 'asArray' => true
  10327. ) );
  10328. if (! empty ( $receiptList )) {
  10329. $html = '<br><div><style></style>
  10330. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  10331. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  10332. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  10333. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  10334. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  10335. <tbody><tr>
  10336. <td style="padding: 0 40px;" align="left">
  10337. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  10338. </td></tr><tr>
  10339. <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>
  10340. </tr>
  10341. </tbody> </table></td> </tr> <tr><td>
  10342. <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">
  10343. <tbody> <tr><td>
  10344. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  10345. 以下报销单完成了审批,等着收款吧:</p>
  10346. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  10347. foreach ( $receiptList as $k => $v ) {
  10348. $category = $Lcategory->getOne ( array (
  10349. 'where' => 'cid=' . $v ['cid'],
  10350. 'asArray' => true
  10351. ) );
  10352. $html .= '
  10353. <tr>
  10354. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  10355. <td align="left">
  10356. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  10357. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  10358. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  10359. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  10360. </tr>';
  10361. }
  10362. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  10363. <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>
  10364. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  10365. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  10366. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  10367. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  10368. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  10369. $receipt = new receipt ();
  10370. $receipt->notice = 1;
  10371. $receipt->update ( array (
  10372. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  10373. ) );
  10374. }
  10375. }
  10376. // 审批人
  10377. $verifyList = $verify->find ( array (
  10378. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  10379. 'asArray' => true
  10380. ) );
  10381. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  10382. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  10383. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  10384. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  10385. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  10386. <tbody><tr><td style="padding: 0 40px;" align="left">
  10387. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  10388. </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>
  10389. </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">
  10390. <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>
  10391. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  10392. foreach ( $verifyList as $k => $v ) {
  10393. $receiptList = $receipt->find ( array (
  10394. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  10395. 'asArray' => true
  10396. ) );
  10397. foreach ( $receiptList as $r => $l ) {
  10398. $category = $Lcategory->getOne ( array (
  10399. 'where' => 'cid=' . $l ['cid'],
  10400. 'asArray' => true
  10401. ) );
  10402. $staffDetile = $staff->getOne ( array (
  10403. 'where' => 'sid=' . $l ['staff'],
  10404. 'asArray' => true
  10405. ) );
  10406. $html .= '
  10407. <tr>
  10408. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  10409. <td align="left">
  10410. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  10411. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  10412. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  10413. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  10414. </tr>';
  10415. }
  10416. }
  10417. $html .= '
  10418. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  10419. <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>
  10420. </tr></tbody></table></td></tr></tbody></table></div><br>';
  10421. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  10422. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  10423. // $receipt=new receipt();
  10424. // $receipt->notice=1;
  10425. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  10426. }
  10427. }
  10428. }
  10429. }
  10430. function setWXMsg($rid, $type) {
  10431. Doo::loadModel ( "receipt" );
  10432. $receipt = new receipt ();
  10433. $receiptDetail = $receipt->getOne ( array (
  10434. 'where' => 'rid=' . $rid,
  10435. 'asArray' => true
  10436. ) );
  10437. if (! empty ( $receiptDetail )) {
  10438. Doo::loadModel ( 'staff' );
  10439. $staff = new staff ();
  10440. $staffmsg = $staff->getOne ( array (
  10441. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  10442. 'asArray' => TRUE
  10443. ) );
  10444. if (! empty ( $staffmsg ['wxid'] )) {
  10445. require_once (SITE_PATH . '/protected/class/client.php');
  10446. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  10447. $user = $staffmsg ['wxid'];
  10448. $receiptName = '';
  10449. $msg = '';
  10450. switch ($receiptDetail ['Rtype']) {
  10451. case 0 :
  10452. $receiptName = '报销';
  10453. break;
  10454. case 1 :
  10455. $receiptName = '借款';
  10456. break;
  10457. case 2 :
  10458. $receiptName = '对公汇款';
  10459. break;
  10460. }
  10461. switch ($type) {
  10462. case 1 :
  10463. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  10464. break;
  10465. case 2 :
  10466. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  10467. break;
  10468. case 3 :
  10469. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  10470. break;
  10471. }
  10472. // $result = $client->SendMsg ( $user, $msg, 'text' );
  10473. }
  10474. }
  10475. }
  10476. // Email发送函数
  10477. function SMail($toemail, $subject, $contents) {
  10478. Doo::loadClass ( 'class.phpmailer' );
  10479. $mail = new PHPMailer ();
  10480. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  10481. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  10482. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  10483. $mail->Password = "cDO1GjtY1seH"; // 密码
  10484. $mail->CharSet = "UTF8";
  10485. $mail->SMTPAuth = true;
  10486. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  10487. $mail->Mailer = "smtp";
  10488. $mail->Port = 25;
  10489. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  10490. $mail->MsgHTML ( $contents );
  10491. $mail->AddAddress ( $toemail );
  10492. $mail->CharSet = "UTF-8";
  10493. return $mail->Send ();
  10494. }
  10495. function swfupload() {
  10496. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  10497. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  10498. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  10499. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  10500. header ( "HTTP/1.1 500 Internal Server Error" );
  10501. echo "POST exceeded maximum allowed size.";
  10502. exit ( 0 );
  10503. }
  10504. // Settings
  10505. $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)
  10506. $upload_name = "Filedata";
  10507. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  10508. $extension_whitelist = array (
  10509. "doc",
  10510. "txt",
  10511. "jpg",
  10512. "gif",
  10513. "png"
  10514. ); // Allowed file extensions
  10515. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  10516. // Other variables
  10517. $MAX_FILENAME_LENGTH = 260;
  10518. $file_name = "";
  10519. $file_extension = "";
  10520. $uploadErrors = array (
  10521. 0 => "文件上传成功",
  10522. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  10523. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  10524. 3 => "上传的文件仅为部分文件",
  10525. 4 => "没有文件上传",
  10526. 6 => "缺少临时文件夹"
  10527. );
  10528. $nk = time ();
  10529. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  10530. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  10531. echo "文件无法保存.";
  10532. exit ( 0 );
  10533. }
  10534. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  10535. echo json_encode ( array (
  10536. 'filename' => $file_name,
  10537. 'id' => $nk
  10538. ) );
  10539. exit ( 0 );
  10540. }
  10541. function _GetFileEXT($filename) {
  10542. $pics = explode ( '.', $filename );
  10543. $num = count ( $pics );
  10544. return $pics [$num - 1];
  10545. }
  10546. /**
  10547. * 获取get或者POST值
  10548. * @param string $name 属性名称
  10549. * @return fixed 值
  10550. */
  10551. function get_args($name) {
  10552. if (isset ( $_GET [$name] )) {
  10553. if (is_array ( $_GET [$name] ))
  10554. return $_GET [$name];
  10555. else
  10556. return addslashes ( $_GET [$name] );
  10557. } elseif (isset ( $_POST [$name] )) {
  10558. if (is_array ( $_POST [$name] ))
  10559. return $_POST [$name];
  10560. else
  10561. return addslashes ( $_POST [$name] );
  10562. } else
  10563. return false;
  10564. }
  10565. function num_to_rmb($num) {
  10566. $c1 = "零壹贰叁肆伍陆柒捌玖";
  10567. $c2 = "分角元拾佰仟万拾佰仟亿";
  10568. // 精确到分后面就不要了,所以只留两个小数位
  10569. $num = round ( $num, 2 );
  10570. // 将数字转化为整数
  10571. $num = $num * 100;
  10572. if (strlen ( $num ) > 10) {
  10573. return "金额太大,请检查";
  10574. }
  10575. $i = 0;
  10576. $c = "";
  10577. while ( 1 ) {
  10578. if ($i == 0) {
  10579. // 获取最后一位数字
  10580. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  10581. } else {
  10582. $n = $num % 10;
  10583. }
  10584. // 每次将最后一位数字转化为中文
  10585. $p1 = substr ( $c1, 3 * $n, 3 );
  10586. $p2 = substr ( $c2, 3 * $i, 3 );
  10587. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  10588. $c = $p1 . $p2 . $c;
  10589. } else {
  10590. $c = $p1 . $c;
  10591. }
  10592. $i = $i + 1;
  10593. // 去掉数字最后一位了
  10594. $num = $num / 10;
  10595. // echo $num.'</br>';
  10596. // $num = (int)$num;
  10597. // $num =floor($num);
  10598. $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  10599. // echo $num.'</br>';
  10600. // 结束循环
  10601. if ($num == 0) {
  10602. break;
  10603. }
  10604. }
  10605. // echo $c.'</br>';
  10606. $j = 0;
  10607. $slen = strlen ( $c );
  10608. while ( $j < $slen ) {
  10609. // utf8一个汉字相当3个字符
  10610. $m = substr ( $c, $j, 6 );
  10611. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  10612. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  10613. $left = substr ( $c, 0, $j );
  10614. $right = substr ( $c, $j + 3 );
  10615. $c = $left . $right;
  10616. $j = $j - 3;
  10617. $slen = $slen - 3;
  10618. }
  10619. $j = $j + 3;
  10620. }
  10621. // 这个是为了去掉类似23.0中最后一个“零”字
  10622. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  10623. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  10624. }
  10625. // 将处理的汉字加上“整”
  10626. if (empty ( $c )) {
  10627. return "零元整";
  10628. } else {
  10629. return $c . "整";
  10630. }
  10631. }
  10632. /**
  10633. * 获得分页数据
  10634. * @param unknown_type $table
  10635. * @param unknown_type $condition
  10636. * @param unknown_type $on_page
  10637. * @param unknown_type $page_size
  10638. */
  10639. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  10640. $page_c = "";
  10641. $page ['previous'] = $this->get_previous ( $on_page );
  10642. $page ['on_page'] = $on_page;
  10643. $total_count = $this->get_table_count ( $table, $condition );
  10644. $total = intval ( $total_count / $page_size );
  10645. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  10646. $page ['total_data'] = $total_count;
  10647. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  10648. $i = 1;
  10649. $page_max = 1;
  10650. $page_width = 3;
  10651. if ($on_page >= $page_width) {
  10652. $page_max = intval ( $on_page / $page_width ) + 1;
  10653. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  10654. }
  10655. for(; $i <= $page ['total_page']; $i ++) {
  10656. if ($i == $on_page)
  10657. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  10658. else
  10659. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  10660. if ($i == ($page_width * $page_max))
  10661. break;
  10662. }
  10663. $page ['page'] = $page_c;
  10664. $page ['lower'] = (-- $on_page) * $page_size;
  10665. return $page;
  10666. }
  10667. /**
  10668. * 获取总页数
  10669. * @param unknown_type $table
  10670. * @param unknown_type $condition
  10671. */
  10672. public function get_table_count($table = "", $condition = "") {
  10673. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10674. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10675. // echo $sql;die;
  10676. $query = Doo::db ()->query ( $sql );
  10677. $result = $query->fetch ();
  10678. return $result ['count'];
  10679. }
  10680. /**
  10681. * 获取上一页
  10682. * @param unknown_type $on_page
  10683. */
  10684. function get_previous($on_page = 1) {
  10685. return $on_page != 0 ? $on_page - 1 : $on_page;
  10686. }
  10687. }
  10688. ?>