ReceiptController.php 394 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200
  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. public function beforeRun($resource, $action) {
  57. Doo::loadClass ( 'XDeode' );
  58. $XDeode = new XDeode ( 5 );
  59. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  60. //单独判断公司汇总的访问权限
  61. if ($action == 'companyCategoryCollect' ) {
  62. Doo::loadModel ( "receiptAuthorityManage" );
  63. $invoiceCompanyManage = new receiptAuthorityManage ();
  64. $icm = $invoiceCompanyManage->getInvoiceCMByStaff ( $sid );
  65. if (empty ( $icm ))
  66. die ( 'illegal request' );
  67. }
  68. }
  69. function __construct() {
  70. if (isset ( $_COOKIE ["staff"] )) {
  71. if (! empty ( $_COOKIE ["staff"] )) {
  72. Doo::loadModel ( 'staff' );
  73. Doo::loadModel ( 'verify' );
  74. $verify = new verify ();
  75. $staff = new staff ();
  76. Doo::loadModel ( "execute" );
  77. $execute = new execute ();
  78. $verifyList = $verify->find ( array (
  79. 'select' => 'staff',
  80. 'asArray' => true
  81. ) );
  82. $list = array ();
  83. // 判断角色的审批权限
  84. foreach ( $verifyList as $key => $value ) {
  85. $ver = json_decode ( $value ['staff'] );
  86. foreach ( $ver as $k => $v ) {
  87. if ($v [1] == 'ROLE') {
  88. $roleList = json_decode ( $v [3] );
  89. foreach ( $roleList as $t => $g ) {
  90. $gList = explode ( "_", $g );
  91. array_push ( $list, $gList [0] );
  92. // print_r($list);
  93. }
  94. } else
  95. array_push ( $list, $v [0] );
  96. }
  97. }
  98. // 判断执行人的审批权限
  99. $executeList = $execute->find ( array (
  100. 'select' => 'staff',
  101. 'asArray' => true
  102. ) );
  103. $list2 = array ();
  104. foreach ( $executeList as $key => $value ) {
  105. $ver = json_decode ( $value ['staff'] );
  106. foreach ( $ver as $k => $v ) {
  107. array_push ( $list2, $v [0] );
  108. }
  109. }
  110. $eidList = file_get_contents ( "protected/config/execute/execute.ini" );
  111. $eidList = array_filter ( explode ( ",", $eidList ) );
  112. $this->executeId = array_merge ( $list2, $eidList );
  113. $this->verifyId = $list;
  114. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  115. return "/";
  116. }
  117. }
  118. Doo::loadCore ( 'uri/DooUriRouter' );
  119. $router = new DooUriRouter ();
  120. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  121. if ($routeRs ['1'] != "login") {
  122. header ( 'Content-Type:text/html;charset=utf-8' );
  123. @header ( "Location: /login" );
  124. }
  125. }
  126. function saeaBorad() {
  127. Doo::loadModel ( 'receipt' );
  128. Doo::loadModel ( 'verify' );
  129. $verify = new verify ();
  130. $receipt = new receipt ();
  131. Doo::loadModel ( 'L_category' );
  132. $lCategory = new L_category ();
  133. Doo::loadModel ( "role" );
  134. $role = new role ();
  135. Doo::loadModel ( "receiptLog" );
  136. $receiptLog = new receiptLog ();
  137. Doo::loadClass ( 'XDeode' );
  138. $XDeode = new XDeode ( 7 );
  139. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  140. $receiptDetail = $receipt->find ( array (
  141. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  142. 'desc' => 'rid',
  143. 'asArray' => true
  144. ) );
  145. foreach ( $receiptDetail as $key => $value ) {
  146. $receiptDetail [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  147. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  148. $veList = $verify->getOne ( array (
  149. 'where' => 'vid=' . $value ['verify'],
  150. 'asArray' => true
  151. ) );
  152. $v = json_decode ( $veList ['staff'] );
  153. array_push ( $v [0], $veList ['description'] );
  154. foreach ( $v as $n => $m ) {
  155. if ($m ['1'] == 'ROLE') {
  156. $roleInfo = $role->getOne ( array (
  157. 'where' => 'rid=' . $m [0],
  158. 'asArray' => true
  159. ) );
  160. $v [$n] [1] = $roleInfo ['name'];
  161. }
  162. }
  163. $receiptDetail [$key] ['staff'] = $v;
  164. $category = $lCategory->getOne ( array (
  165. 'where' => 'cid=' . $value ['cid'],
  166. 'asArray' => true
  167. ) );
  168. $receiptDetail [$key] ['category'] = $category ['title'];
  169. }
  170. // print_r($receiptLogList);
  171. $data ['receiptLogList'] = $receiptLogList;
  172. $data ['receiptDetail'] = $receiptDetail;
  173. $data ['memu'] = "receipt";
  174. $data ['staff'] = $this->staff;
  175. $data ['receiptMemu'] = 'saeaBorad';
  176. $data ['verifyId'] = $this->verifyId;
  177. $data ['executeId'] = $this->executeId;
  178. $this->render ( "/admin/saeaBorad", $data );
  179. }
  180. function remitAdd() {
  181. Doo::loadModel ( 'accountItem' );
  182. Doo::loadModel ( 'verify' );
  183. Doo::loadModel ( 'receipt' );
  184. Doo::loadModel ( 'L_category' );
  185. $lCategory = new L_category ();
  186. $receipt = new receipt ();
  187. $verify = new verify ();
  188. $accountItem = new accountItem ();
  189. Doo::loadModel ( "role" );
  190. $role = new role ();
  191. $acItem = $accountItem->find ( array (
  192. 'asArray' => true
  193. ) );
  194. $veList = $verify->find ( array (
  195. 'asArray' => true
  196. ) );
  197. foreach ( $veList as $key => $value ) {
  198. $v = json_decode ( $value ['staff'] );
  199. $list = array ();
  200. foreach ( $v as $n => $m ) {
  201. if ($m ['1'] == 'ROLE') {
  202. $roleInfo = $role->getOne ( array (
  203. 'where' => 'rid=' . $m [0],
  204. 'asArray' => true
  205. ) );
  206. $v [$n] [1] = $roleInfo ['name'];
  207. array_push ( $list, $roleInfo ['name'] );
  208. } else {
  209. array_push ( $list, $v [$n] [1] );
  210. }
  211. }
  212. $veList [$key] ['staff'] = implode ( '>', $list );
  213. }
  214. $data ['category'] = $lCategory->find ( array (
  215. 'asArray' => true
  216. ) );
  217. $data ['veList'] = $veList;
  218. $data ['acItem'] = $acItem;
  219. $data ['memu'] = "receipt";
  220. $data ['staff'] = $this->staff;
  221. $data ['receiptMemu'] = 'saeaBorad';
  222. $data ['verifyId'] = $this->verifyId;
  223. $data ['executeId'] = $this->executeId;
  224. $this->render ( "/admin/remitAdd", $data );
  225. }
  226. function remitAddDo() {
  227. $agency = $this->get_args ( 'agency' );
  228. $travel = $this->get_args ( 'travel' );
  229. $train = $this->get_args ( 'train' );
  230. $other = $this->get_args ( 'other' );
  231. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  232. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  233. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  234. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  235. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  236. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  237. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  238. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  239. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  240. // print_r($agency);die;
  241. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  242. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  243. header ( 'Content-Type:text/html;charset=utf-8' );
  244. die ( '请填写联行号' );
  245. }
  246. Doo::loadModel ( 'receipt' );
  247. Doo::loadModel ( 'receiptDetail' );
  248. Doo::loadModel ( 'accountItem' );
  249. $accountItem = new accountItem ();
  250. $receipt = new receipt ();
  251. Doo::loadModel ( 'enclosur' );
  252. Doo::loadModel ( 'execute' );
  253. $execute = new execute ();
  254. $executeDetail = $execute->getOne ( array (
  255. 'where' => 'mold="对公汇款执行人"',
  256. 'asArray' => true
  257. ) );
  258. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  259. $aItem = $accountItem->find ( array (
  260. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  261. 'asArray' => true
  262. ) );
  263. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  264. $ag = $tr = $ta = $ot = 0;
  265. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  266. foreach ( $aItem as $key => $value ) {
  267. if ($value ['category'] == $this->AGENCY) {
  268. if (isset ( $agency [$ag] )) {
  269. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  270. array_push ( $accountJson [$this->AGENCY], array (
  271. 'aid' => $value ['aid'],
  272. 'name' => $value ['name'],
  273. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  274. ) );
  275. $sum += $agency [$ag];
  276. $agencySum += $agency [$ag];
  277. }
  278. }
  279. $ag ++;
  280. }
  281. }
  282. $accountJson ['cSum'] = array (
  283. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  284. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  285. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  286. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  287. );
  288. // 报销单
  289. $receipt->accountItem = json_encode ( $accountJson );
  290. $receipt->staff = $this->staff [0] ['sid'];
  291. $receipt->sum = number_format ( $sum, 2, '.', '' );
  292. $receipt->date = date ( "Y-m-d" );
  293. $receipt->cid = $cid;
  294. $receipt->status = 5;
  295. $receipt->Rtype = 2;
  296. // 修改审批流程加入角色
  297. $receipt->verify = $verify;
  298. $receipt->executeCopy = $executeDetail ['staff'];
  299. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  300. $receipt->explanation = $explanation;
  301. $receipt->remittanceName = $remittanceName;
  302. $receipt->bankName = $bankName;
  303. $receipt->bankNumber = $bankNumber;
  304. $receipt->remittanceBankType = $remittanceBankType;
  305. if ($remittanceBankType == 1)
  306. $receipt->coupletNumber = $coupletNumber;
  307. $rid = $receipt->insert ();
  308. // 附件
  309. if (! empty ( $enclosurName )) {
  310. $enclosurArray = explode ( '-', $enclosurName );
  311. foreach ( $enclosurArray as $value ) {
  312. $enclosur = new enclosur ();
  313. $enclosur->name = $value;
  314. $enclosur->rid = $rid;
  315. $enclosur->insert ();
  316. }
  317. // print_r($enclosurArray);die;
  318. }
  319. // 报销详情
  320. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  321. $receiptDetail = new receiptDetail ();
  322. $receiptDetail->staff = $this->staff [0] ['sid'];
  323. $receiptDetail->item = $value ['name'];
  324. $receiptDetail->itemCategory = $this->AGENCY;
  325. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  326. $receiptDetail->date = date ( "Y-m-d" );
  327. $receiptDetail->cid = $cid;
  328. $receiptDetail->rid = $rid;
  329. $receiptDetail->status = 4;
  330. $receiptDetail->insert ();
  331. }
  332. return "/saeaBorad";
  333. } else
  334. die ( 'illegal request' );
  335. }
  336. function remitEdit() {
  337. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  338. Doo::loadClass ( 'XDeode' );
  339. $XDeode = new XDeode ( 7 );
  340. $rid = $XDeode->decode ( $ridKey );
  341. if (! is_numeric ( $rid ))
  342. die ( 'illegal request' );
  343. Doo::loadModel ( 'accountItem' );
  344. Doo::loadModel ( 'verify' );
  345. Doo::loadModel ( 'receipt' );
  346. $receipt = new receipt ();
  347. $verify = new verify ();
  348. $accountItem = new accountItem ();
  349. Doo::loadModel ( 'L_category' );
  350. $lCategory = new L_category ();
  351. Doo::loadModel ( "role" );
  352. $role = new role ();
  353. Doo::loadModel ( 'enclosur' );
  354. $enclosur = new enclosur ();
  355. $receiptDetail = $receipt->getOne ( array (
  356. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  357. 'asArray' => true
  358. ) );
  359. if (empty ( $receiptDetail ))
  360. return "/saeaCreate";
  361. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  362. $acItem = $accountItem->find ( array (
  363. 'asArray' => true
  364. ) );
  365. $veList = $verify->find ( array (
  366. 'asArray' => true
  367. ) );
  368. foreach ( $veList as $key => $value ) {
  369. $v = json_decode ( $value ['staff'] );
  370. $list = array ();
  371. foreach ( $v as $n => $m ) {
  372. if ($m ['1'] == 'ROLE') {
  373. $roleInfo = $role->getOne ( array (
  374. 'where' => 'rid=' . $m [0],
  375. 'asArray' => true
  376. ) );
  377. $v [$n] [1] = $roleInfo ['name'];
  378. array_push ( $list, $roleInfo ['name'] );
  379. } else {
  380. array_push ( $list, $v [$n] [1] );
  381. }
  382. }
  383. $veList [$key] ['staff'] = implode ( '>', $list );
  384. }
  385. // 配置编辑信息
  386. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  387. foreach ( $acItem as $key => $value ) {
  388. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  389. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  390. $acItem [$key] ['price'] = $v ['price'];
  391. }
  392. }
  393. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  394. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  395. $acItem [$key] ['price'] = $v ['price'];
  396. }
  397. }
  398. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  399. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  400. $acItem [$key] ['price'] = $v ['price'];
  401. }
  402. }
  403. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  404. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  405. $acItem [$key] ['price'] = $v ['price'];
  406. }
  407. }
  408. }
  409. $data ['category'] = $lCategory->find ( array (
  410. 'asArray' => true
  411. ) );
  412. $data ['enclosurList'] = $enclosurList;
  413. $data ['cSum'] = $accountItemList ['cSum'];
  414. $data ['sum'] = $receiptDetail ['sum'];
  415. $data ['receiptDetail'] = $receiptDetail;
  416. $data ['veList'] = $veList;
  417. $data ['acItem'] = $acItem;
  418. $data ['memu'] = "receipt";
  419. $data ['staff'] = $this->staff;
  420. $data ['receiptMemu'] = 'saeaBorad';
  421. $data ['verify'] = $receiptDetail ['verify'];
  422. $data ['verifyId'] = $this->verifyId;
  423. $data ['executeId'] = $this->executeId;
  424. $data ['rid'] = $rid;
  425. $data ['ridKey'] = $ridKey;
  426. $this->render ( "/admin/remitEdit", $data );
  427. }
  428. function remitEdiDo() {
  429. $agency = $this->get_args ( 'agency' );
  430. $travel = $this->get_args ( 'travel' );
  431. $train = $this->get_args ( 'train' );
  432. $other = $this->get_args ( 'other' );
  433. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  434. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  435. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  436. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  437. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  438. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  439. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  440. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  441. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  442. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  443. Doo::loadClass ( 'XDeode' );
  444. $XDeode = new XDeode ( 7 );
  445. $rid = $XDeode->decode ( $ridKey );
  446. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  447. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  448. header ( 'Content-Type:text/html;charset=utf-8' );
  449. die ( '请填写联行号' );
  450. }
  451. Doo::loadModel ( 'receipt' );
  452. Doo::loadModel ( 'receiptDetail' );
  453. Doo::loadModel ( 'accountItem' );
  454. $accountItem = new accountItem ();
  455. $receipt = new receipt ();
  456. Doo::loadModel ( 'enclosur' );
  457. $enclosur = new enclosur ();
  458. Doo::loadModel ( 'execute' );
  459. $execute = new execute ();
  460. $executeDetail = $execute->getOne ( array (
  461. 'where' => 'mold="对公汇款执行人"',
  462. 'asArray' => true
  463. ) );
  464. $receiptDetail = $receipt->getOne ( array (
  465. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  466. 'asArray' => true
  467. ) );
  468. if (empty ( $receiptDetail ))
  469. return "/saeaBorad";
  470. $aItem = $accountItem->find ( array (
  471. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  472. 'asArray' => true
  473. ) );
  474. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  475. $ag = $tr = $ta = $ot = 0;
  476. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  477. foreach ( $aItem as $key => $value ) {
  478. if ($value ['category'] == $this->AGENCY) {
  479. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  480. array_push ( $accountJson [$this->AGENCY], array (
  481. 'aid' => $value ['aid'],
  482. 'name' => $value ['name'],
  483. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  484. ) );
  485. $sum += $agency [$ag];
  486. $agencySum += $agency [$ag];
  487. }
  488. $ag ++;
  489. }
  490. }
  491. $accountJson ['cSum'] = array (
  492. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  493. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  494. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  495. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  496. );
  497. // 报销单
  498. $rid = $receipt->rid = $receiptDetail ['rid'];
  499. $receipt->accountItem = json_encode ( $accountJson );
  500. $receipt->staff = $this->staff [0] ['sid'];
  501. $receipt->sum = number_format ( $sum, 2, '.', '' );
  502. $receipt->date = date ( "Y-m-d" );
  503. $receipt->cid = $cid;
  504. if ($receiptDetail ['Rtype'] == 1)
  505. $receipt->status = 7;
  506. else
  507. $receipt->status = 5;
  508. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  509. $receipt->verify = $verify;
  510. $receipt->executeCopy = $executeDetail ['staff'];
  511. $receipt->explanation = $explanation;
  512. $receipt->remittanceName = $remittanceName;
  513. $receipt->bankName = $bankName;
  514. $receipt->bankNumber = $bankNumber;
  515. $receipt->remittanceBankType = $remittanceBankType;
  516. if ($remittanceBankType == 1)
  517. $receipt->coupletNumber = $coupletNumber;
  518. $receipt->update ();
  519. $receiptDetail = new receiptDetail ();
  520. $receiptDetail->delete ( array (
  521. 'where' => 'rid=' . $rid
  522. ) );
  523. // 报销详情
  524. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  525. $receiptDetail = new receiptDetail ();
  526. $receiptDetail->staff = $this->staff [0] ['sid'];
  527. $receiptDetail->item = $value ['name'];
  528. $receiptDetail->itemCategory = $this->AGENCY;
  529. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  530. $receiptDetail->date = date ( "Y-m-d" );
  531. $receiptDetail->cid = $cid;
  532. $receiptDetail->rid = $rid;
  533. $receiptDetail->status = 4;
  534. $receiptDetail->insert ();
  535. }
  536. // 附件
  537. if (! empty ( $enclosurName )) {
  538. $enclosurArray = explode ( '-', $enclosurName );
  539. foreach ( $enclosurArray as $value ) {
  540. $enclosur = new enclosur ();
  541. $enclosur->name = $value;
  542. $enclosur->rid = $rid;
  543. $enclosur->insert ();
  544. }
  545. }
  546. }
  547. return "/saeaBorad";
  548. }
  549. function remitApproval() {
  550. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  551. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  552. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  553. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  554. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  555. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  556. if (empty ( $status ))
  557. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  558. $vidList = array ();
  559. $button = 0;
  560. Doo::loadModel ( 'verify' );
  561. Doo::loadModel ( 'receipt' );
  562. Doo::loadModel ( 'staff' );
  563. $staff = new staff ();
  564. $receipt = new receipt ();
  565. $verify = new verify ();
  566. Doo::loadModel ( 'L_category' );
  567. $Lcategory = new L_category ();
  568. Doo::loadModel ( 'enclosur' );
  569. $enclosur = new enclosur ();
  570. // user verify ID
  571. $verifyDetail = $verify->find ( array (
  572. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  573. 'asArray' => true
  574. ) );
  575. foreach ( $verifyDetail as $key => $value ) {
  576. array_push ( $vidList, $value ['vid'] );
  577. }
  578. $vid = implode ( ",", $vidList );
  579. if (empty ( $verifyDetail ))
  580. $vid = 0;
  581. $categoryList = $Lcategory->find ( array (
  582. 'asArray' => true
  583. ) );
  584. $staffList = $staff->find ( array (
  585. 'where' => 'cid=' . $cid,
  586. 'asArray' => true
  587. ) );
  588. $ap = "";
  589. if ($status == 4) {
  590. $ap = 4;
  591. $status = 2;
  592. }
  593. // get Receipt By verifyID status 2
  594. $receiptList = $receipt->find ( array (
  595. 'where' => 'rid =' . $rid . ' and status=2',
  596. 'desc' => 'rid',
  597. 'asArray' => true
  598. ) );
  599. if (empty ( $receiptList )) {
  600. die ( 'illegal request' );
  601. }
  602. $Locate = 0;
  603. $roleId = 0;
  604. if ($ap == 4)
  605. $status = 4;
  606. foreach ( $receiptList as $key => $value ) {
  607. $receiptList [$key] ['Locate'] = $Locate;
  608. $Locate ++;
  609. $receiptList [$key] ['reviseDetail'] = array ();
  610. if (! empty ( $value ['reviseDetail'] ))
  611. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  612. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  613. $categoryDetil = $Lcategory->getOne ( array (
  614. 'where' => 'cid=' . $value ['cid'],
  615. 'asArray' => true
  616. ) );
  617. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  618. // 检测编辑状态
  619. $verifyList = $verify->getOne ( array (
  620. 'where' => 'vid=' . $value ['verify'],
  621. 'asArray' => true
  622. ) );
  623. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  624. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  625. Doo::loadModel ( 'role' );
  626. $role = new role ();
  627. // print_r($verifyList);
  628. $flag = true;
  629. $roleKey = 0;
  630. $endStaffArray = array ();
  631. $roleArrayCopy = array ();
  632. foreach ( $verifyList as $k => $v ) {
  633. // init verifyStaff
  634. if ($v [1] == 'ROLE') {
  635. if (! empty ( $verifyStaff )) {
  636. $endStaffArray = end ( $verifyStaff );
  637. if ($v [0] == $endStaffArray ['nextStaff']) {
  638. $roleId = $v [0];
  639. }
  640. }
  641. $roleVerify = json_decode ( $v [3], true );
  642. $roleKey = $k;
  643. $roleArray = array ();
  644. $rolename = $role->getOne ( array (
  645. 'where' => 'rid=' . $v [0],
  646. 'asArray' => true
  647. ) );
  648. foreach ( $roleVerify as $o => $p ) {
  649. $staffID = explode ( '_', $p );
  650. $staffInfo = $staff->getOne ( array (
  651. 'where' => 'sid=' . $staffID [0],
  652. 'asArray' => true
  653. ) );
  654. // print_r($staffID);
  655. $exp = array (
  656. 0 => $staffInfo ['sid'],
  657. 1 => $staffID [1],
  658. 2 => $staffInfo ['avatar'],
  659. 'date' => '',
  660. 'date' => '',
  661. 'opinion' => '',
  662. 'status' => '',
  663. 'rolename' => $rolename ['name']
  664. );
  665. array_push ( $roleArray, $exp );
  666. }
  667. $roleArrayCopy [$v [0]] = $roleArray;
  668. // $verifyList[$k]['roleArray']=$roleArray;
  669. }
  670. // print_r($roleArray);
  671. $verifyList [$k] ['date'] = "";
  672. $verifyList [$k] ['opinion'] = "";
  673. $verifyList [$k] ['status'] = "";
  674. if (empty ( $verifyStaff )) {
  675. $verifyList [$k] ['date'] = "";
  676. $verifyList [$k] ['opinion'] = "";
  677. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  678. $verifyList [$k] ['status'] = 4;
  679. $button = 4;
  680. $flag = false;
  681. }
  682. } else {
  683. foreach ( $verifyStaff as $m => $u ) {
  684. if ($v [0] == $m) {
  685. $verifyList [$k] ['date'] = $u ['date'];
  686. $verifyList [$k] ['opinion'] = $u ['opinion'];
  687. $verifyList [$k] ['status'] = $u ['status'];
  688. $flag = false;
  689. break;
  690. }
  691. }
  692. $endStaffArray = end ( $verifyStaff );
  693. if (isset ( $endStaffArray ['ROLE'] )) {
  694. } else {
  695. $endKey = key ( $verifyStaff );
  696. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  697. $button = 4;
  698. $verifyList [$k] ['status'] = 4;
  699. }
  700. }
  701. }
  702. }
  703. $rolename ['name'] = '';
  704. if (! empty ( $roleId )) {
  705. Doo::loadModel ( 'role' );
  706. $role = new role ();
  707. $rolename = $role->getOne ( array (
  708. 'where' => 'rid=' . $roleId,
  709. 'asArray' => true
  710. ) );
  711. }
  712. if (! empty ( $verifyStaff ))
  713. $endStaffArray = end ( $verifyStaff );
  714. $KOP = false;
  715. foreach ( $roleArrayCopy as $P => $A ) {
  716. foreach ( $A as $MKI => $AVL ) {
  717. if (! empty ( $verifyStaff )) {
  718. // &&$rolename['rid']==$endStaffArray['nextStaff']
  719. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  720. $button = 4;
  721. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  722. }
  723. foreach ( $verifyStaff as $m => $u ) {
  724. $AVLFK = $AVL [0] . '_R';
  725. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  726. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  727. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  728. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  729. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  730. break;
  731. }
  732. }
  733. } else {
  734. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  735. $button = 4;
  736. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  737. }
  738. }
  739. // $roleArray[$MKI]['rolename']=$rolename['name'];
  740. $KOP = true;
  741. }
  742. }
  743. foreach ( $roleArrayCopy as $k => $v ) {
  744. foreach ( $verifyList as $m => $n ) {
  745. if ($n [0] == $k) {
  746. array_splice ( $verifyList, $m, 1, $v );
  747. }
  748. }
  749. }
  750. $receiptList [$key] ['verifyList'] = $verifyList;
  751. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  752. 'where' => 'sid=' . $value ['staff'],
  753. 'asArray' => true
  754. ) );
  755. $receiptList [$key] ['button'] = $button;
  756. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  757. }
  758. $mothHtml = "";
  759. for($i = 1; $i <= 12; $i ++) {
  760. if ($month == $i)
  761. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  762. else
  763. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  764. }
  765. // 获取审批日志
  766. Doo::loadModel ( 'receiptLog' );
  767. $receiptLog = new receiptLog ();
  768. $rlList = array ();
  769. $rlInfo = $receiptLog->getOne ( array (
  770. 'where' => 'rid=' . $rid . ' and status=4',
  771. 'asArray' => true
  772. ) );
  773. $tijdate = $receiptLog->getOne ( array (
  774. 'where' => 'rid=' . $rid . ' and status=2',
  775. 'asc' => 'rlid',
  776. 'asArray' => true
  777. ) );
  778. if (! empty ( $rlInfo )) {
  779. $rlList = $receiptLog->find ( array (
  780. 'where' => 'rid=' . $rid,
  781. 'asc' => 'rlid',
  782. 'asArray' => true
  783. ) );
  784. }
  785. $receiptList [0] ['rlList'] = $rlList;
  786. $enclosurList = $enclosur->find ( array (
  787. 'where' => 'rid=' . $rid,
  788. 'asArray' => true
  789. ) );
  790. $enclosurHtml = '';
  791. foreach ( $enclosurList as $value ) {
  792. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  793. }
  794. // print_r($receiptList);
  795. $data ['enclosurHtml'] = $enclosurHtml;
  796. $data ['rolename'] = $rolename ['name'];
  797. $data ['datetij'] = $tijdate ['date'];
  798. $data ['mothHtml'] = $mothHtml;
  799. $data ['rid'] = $rid;
  800. $data ['receiptList'] = $receiptList;
  801. $data ['receiptApprovalCount'] = count ( $receiptList );
  802. $data ['status'] = $status;
  803. $data ['year'] = $year;
  804. $data ['categoryList'] = $categoryList;
  805. $data ['staffList'] = $staffList;
  806. $data ['cid'] = $cid;
  807. $data ['sid'] = $sid;
  808. $data ['ap'] = $ap;
  809. $data ['memu'] = "receipt";
  810. $data ['staff'] = $this->staff;
  811. $data ['receiptMemu'] = 'approvalExpenses';
  812. $data ['verifyId'] = $this->verifyId;
  813. $data ['executeId'] = $this->executeId;
  814. $this->render ( "/admin/remitApproval", $data );
  815. }
  816. function saeaLoanAdd() {
  817. Doo::loadModel ( 'verify' );
  818. $verify = new verify ();
  819. Doo::loadModel ( "role" );
  820. $role = new role ();
  821. Doo::loadModel ( 'L_category' );
  822. $lCategory = new L_category ();
  823. $veList = $verify->find ( array (
  824. 'asArray' => true
  825. ) );
  826. foreach ( $veList as $key => $value ) {
  827. $v = json_decode ( $value ['staff'] );
  828. $list = array ();
  829. foreach ( $v as $n => $m ) {
  830. if ($m ['1'] == 'ROLE') {
  831. $roleInfo = $role->getOne ( array (
  832. 'where' => 'rid=' . $m [0],
  833. 'asArray' => true
  834. ) );
  835. $v [$n] [1] = $roleInfo ['name'];
  836. array_push ( $list, $roleInfo ['name'] );
  837. } else {
  838. array_push ( $list, $v [$n] [1] );
  839. }
  840. }
  841. $veList [$key] ['staff'] = implode ( '>', $list );
  842. }
  843. $data ['category'] = $lCategory->find ( array (
  844. 'asArray' => true
  845. ) );
  846. $data ['veList'] = $veList;
  847. $data ['memu'] = "receipt";
  848. $data ['staff'] = $this->staff;
  849. $data ['receiptMemu'] = 'saeaBorad';
  850. $data ['verifyId'] = $this->verifyId;
  851. $data ['executeId'] = $this->executeId;
  852. $this->render ( "/admin/saeaLoanAdd", $data );
  853. }
  854. function saeaLoanAddDo() {
  855. $agency = $this->get_args ( 'agency' );
  856. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  857. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  858. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  859. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  860. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  861. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  862. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  863. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  864. // die;
  865. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  866. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  867. header ( 'Content-Type:text/html;charset=utf-8' );
  868. die ( '请填写联行号' );
  869. }
  870. Doo::loadModel ( 'receipt' );
  871. Doo::loadModel ( 'receiptDetail' );
  872. Doo::loadModel ( 'accountItem' );
  873. $accountItem = new accountItem ();
  874. $receipt = new receipt ();
  875. Doo::loadModel ( 'loanReceipt' );
  876. $loanReceipt = new loanReceipt ();
  877. Doo::loadModel ( 'execute' );
  878. $execute = new execute ();
  879. Doo::loadModel ( 'enclosur' );
  880. $executeDetail = $execute->getOne ( array (
  881. 'where' => 'mold="借款执行人"',
  882. 'asArray' => true
  883. ) );
  884. $aItem = $accountItem->find ( array (
  885. 'asArray' => true
  886. ) );
  887. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  888. $ag = $tr = $ta = $ot = 0;
  889. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  890. array_push ( $accountJson ['借款费用'], array (
  891. 'aid' => 0,
  892. 'name' => '申请金额',
  893. 'price' => number_format ( $agency, 2, '.', '' )
  894. ) );
  895. $sum += $agency;
  896. $agencySum += $agency;
  897. $accountJson ['cSum'] = array (
  898. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  899. 'agencySum' => number_format ( 0, 2, '.', '' ),
  900. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  901. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  902. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  903. );
  904. // 借款数据备份
  905. $loanReceipt->loanItem = json_encode ( $accountJson );
  906. $loanReceipt->staff = $this->staff [0] ['sid'];
  907. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  908. $loanReceipt->date = date ( "Y-m-d" );
  909. $loanReceipt->cid = $cid;
  910. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  911. $loanReceipt->status = 5;
  912. $loanReceipt->Rtype = 1;
  913. $loanReceipt->verify = $verify;
  914. $receipt->receiptOrder = $receipt->receiptOrder;
  915. $loanReceipt->explanation = $explanation;
  916. $loanRid = $loanReceipt->insert ();
  917. // 报销单
  918. $receipt->loanItem = json_encode ( $accountJson );
  919. $receipt->staff = $this->staff [0] ['sid'];
  920. $receipt->sum = number_format ( $sum, 2, '.', '' );
  921. $receipt->date = date ( "Y-m-d" );
  922. $receipt->cid = $cid;
  923. // 特殊状态
  924. $receipt->status = 5;
  925. $receipt->Rtype = 1;
  926. $receipt->loanRid = $loanRid;
  927. // 修改审批流程加入角色
  928. $receipt->verify = $verify;
  929. $receipt->executeCopy = $executeDetail ['staff'];
  930. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  931. $receipt->explanation = $explanation;
  932. $receipt->remittanceName = $remittanceName;
  933. $receipt->bankName = $bankName;
  934. $receipt->bankNumber = $bankNumber;
  935. $receipt->remittanceBankType = $remittanceBankType;
  936. if ($remittanceBankType == 1)
  937. $receipt->coupletNumber = $coupletNumber;
  938. $rid = $receipt->insert ();
  939. return "/saeaBorad";
  940. } else
  941. die ( 'illegal request' );
  942. }
  943. function saeaLoanEdi() {
  944. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  945. Doo::loadClass ( 'XDeode' );
  946. $XDeode = new XDeode ( 7 );
  947. $rid = $XDeode->decode ( $ridKey );
  948. if (! is_numeric ( $rid ))
  949. die ( 'illegal request' );
  950. Doo::loadModel ( 'verify' );
  951. $verify = new verify ();
  952. Doo::loadModel ( "role" );
  953. $role = new role ();
  954. Doo::loadModel ( 'L_category' );
  955. $lCategory = new L_category ();
  956. Doo::loadModel ( 'receipt' );
  957. $receipt = new receipt ();
  958. $receiptInfo = $receipt->getOne ( array (
  959. 'where' => 'rid=' . $rid,
  960. 'asArray' => true
  961. ) );
  962. $veList = $verify->find ( array (
  963. 'asArray' => true
  964. ) );
  965. foreach ( $veList as $key => $value ) {
  966. $v = json_decode ( $value ['staff'] );
  967. $list = array ();
  968. foreach ( $v as $n => $m ) {
  969. if ($m ['1'] == 'ROLE') {
  970. $roleInfo = $role->getOne ( array (
  971. 'where' => 'rid=' . $m [0],
  972. 'asArray' => true
  973. ) );
  974. $v [$n] [1] = $roleInfo ['name'];
  975. array_push ( $list, $roleInfo ['name'] );
  976. } else {
  977. array_push ( $list, $v [$n] [1] );
  978. }
  979. }
  980. $veList [$key] ['staff'] = implode ( '>', $list );
  981. }
  982. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  983. // print_r($receiptInfo);
  984. $data ['receiptInfo'] = $receiptInfo;
  985. $data ['category'] = $lCategory->find ( array (
  986. 'asArray' => true
  987. ) );
  988. $data ['veList'] = $veList;
  989. $data ['ridKey'] = $ridKey;
  990. $data ['memu'] = "receipt";
  991. $data ['staff'] = $this->staff;
  992. $data ['receiptMemu'] = 'saeaBorad';
  993. $data ['verifyId'] = $this->verifyId;
  994. $data ['executeId'] = $this->executeId;
  995. $this->render ( "/admin/saeaLoanEdi", $data );
  996. }
  997. function saeaLoanEdiDo() {
  998. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  999. $agency = $this->get_args ( 'agency' );
  1000. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1001. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1002. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1003. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1004. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1005. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1006. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1007. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1008. // die;
  1009. Doo::loadClass ( 'XDeode' );
  1010. $XDeode = new XDeode ( 7 );
  1011. $rid = $XDeode->decode ( $ridKey );
  1012. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1013. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1014. header ( 'Content-Type:text/html;charset=utf-8' );
  1015. die ( '请填写联行号' );
  1016. }
  1017. Doo::loadModel ( 'receipt' );
  1018. Doo::loadModel ( 'receiptDetail' );
  1019. Doo::loadModel ( 'accountItem' );
  1020. $accountItem = new accountItem ();
  1021. $receipt = new receipt ();
  1022. Doo::loadModel ( 'loanReceipt' );
  1023. $loanReceipt = new loanReceipt ();
  1024. Doo::loadModel ( 'enclosur' );
  1025. Doo::loadModel ( 'execute' );
  1026. $execute = new execute ();
  1027. $executeDetail = $execute->getOne ( array (
  1028. 'where' => 'mold="借款执行人"',
  1029. 'asArray' => true
  1030. ) );
  1031. $receiptDetail = $receipt->getOne ( array (
  1032. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  1033. 'asArray' => true
  1034. ) );
  1035. if (empty ( $receiptDetail ))
  1036. die ( '参数错误' );
  1037. $aItem = $accountItem->find ( array (
  1038. 'asArray' => true
  1039. ) );
  1040. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1041. $ag = $tr = $ta = $ot = 0;
  1042. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1043. array_push ( $accountJson ['借款费用'], array (
  1044. 'aid' => 0,
  1045. 'name' => '申请金额',
  1046. 'price' => number_format ( $agency, 2, '.', '' )
  1047. ) );
  1048. $sum += $agency;
  1049. $agencySum += $agency;
  1050. $accountJson ['cSum'] = array (
  1051. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1052. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1053. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1054. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1055. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1056. );
  1057. // 报销单
  1058. $receipt->loanItem = json_encode ( $accountJson );
  1059. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1060. $receipt->cid = $cid;
  1061. // 特殊状态
  1062. // 修改审批流程加入角色
  1063. if ($receiptDetail ['status'] != 4)
  1064. $receipt->verify = $verify;
  1065. $receipt->explanation = $explanation;
  1066. $receipt->remittanceName = $remittanceName;
  1067. $receipt->bankName = $bankName;
  1068. $receipt->bankNumber = $bankNumber;
  1069. $receipt->remittanceBankType = $remittanceBankType;
  1070. if ($remittanceBankType == 1)
  1071. $receipt->coupletNumber = $coupletNumber;
  1072. $receipt->update ( array (
  1073. 'where' => 'rid=' . $rid
  1074. ) );
  1075. // 借款数据更新
  1076. $loanReceipt->loanItem = json_encode ( $accountJson );
  1077. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1078. $loanReceipt->cid = $cid;
  1079. if ($receiptDetail ['status'] != 4)
  1080. $loanReceipt->verify = $verify;
  1081. $loanReceipt->explanation = $explanation;
  1082. $receipt->executeCopy = $executeDetail ['staff'];
  1083. $loanReceipt->update ( array (
  1084. 'where' => 'rid=' . $receiptDetail ['loanRid']
  1085. ) );
  1086. }
  1087. return "/saeaBorad";
  1088. }
  1089. function saeaLoanReceiptAdd() {
  1090. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1091. Doo::loadModel ( 'receipt' );
  1092. $receipt = new receipt ();
  1093. Doo::loadModel ( 'loanReceipt' );
  1094. $loanReceipt = new loanReceipt ();
  1095. Doo::loadModel ( 'L_category' );
  1096. $Lcategory = new L_category ();
  1097. Doo::loadModel ( 'verify' );
  1098. Doo::loadModel ( 'statistics' );
  1099. $statistics = new statistics ();
  1100. $verify = new verify ();
  1101. Doo::loadModel ( 'staff' );
  1102. $staff = new staff ();
  1103. $receiptDetail = $receipt->getOne ( array (
  1104. 'where' => 'rid=' . $rid,
  1105. 'desc' => 'rid',
  1106. 'asArray' => true
  1107. ) );
  1108. $receiptList = $loanReceipt->find ( array (
  1109. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1110. 'desc' => 'rid',
  1111. 'asArray' => true
  1112. ) );
  1113. $Locate = 0;
  1114. $roleId = 0;
  1115. $button = 0;
  1116. foreach ( $receiptList as $key => $value ) {
  1117. $receiptList [$key] ['Locate'] = $Locate;
  1118. $Locate ++;
  1119. $receiptList [$key] ['reviseDetail'] = array ();
  1120. if (! empty ( $value ['reviseDetail'] ))
  1121. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1122. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1123. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1124. $categoryDetil = $Lcategory->getOne ( array (
  1125. 'where' => 'cid=' . $value ['cid'],
  1126. 'asArray' => true
  1127. ) );
  1128. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1129. // 检测编辑状态
  1130. $verifyList = $verify->getOne ( array (
  1131. 'where' => 'vid=' . $value ['verify'],
  1132. 'asArray' => true
  1133. ) );
  1134. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1135. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1136. Doo::loadModel ( 'role' );
  1137. $role = new role ();
  1138. $flag = true;
  1139. $roleKey = 0;
  1140. $endStaffArray = array ();
  1141. $roleArrayCopy = array ();
  1142. foreach ( $verifyList as $k => $v ) {
  1143. // init verifyStaff
  1144. if ($v [1] == 'ROLE') {
  1145. if (! empty ( $verifyStaff )) {
  1146. $endStaffArray = end ( $verifyStaff );
  1147. // if ($v[0]==$endStaffArray['nextStaff']){
  1148. // $roleId=$v[0];
  1149. // }
  1150. }
  1151. $roleVerify = json_decode ( $v [3], true );
  1152. $roleKey = $k;
  1153. $roleArray = array ();
  1154. $rolename = $role->getOne ( array (
  1155. 'where' => 'rid=' . $v [0],
  1156. 'asArray' => true
  1157. ) );
  1158. foreach ( $roleVerify as $o => $p ) {
  1159. $staffID = explode ( '_', $p );
  1160. $staffInfo = $staff->getOne ( array (
  1161. 'where' => 'sid=' . $staffID [0],
  1162. 'asArray' => true
  1163. ) );
  1164. // print_r($staffID);
  1165. $exp = array (
  1166. 0 => $staffInfo ['sid'],
  1167. 1 => $staffID [1],
  1168. 2 => $staffInfo ['avatar'],
  1169. 'date' => '',
  1170. 'date' => '',
  1171. 'opinion' => '',
  1172. 'status' => '',
  1173. 'rolename' => $rolename ['name']
  1174. );
  1175. array_push ( $roleArray, $exp );
  1176. }
  1177. $roleArrayCopy [$v [0]] = $roleArray;
  1178. // $verifyList[$k]['roleArray']=$roleArray;
  1179. }
  1180. $verifyList [$k] ['date'] = "";
  1181. $verifyList [$k] ['opinion'] = "";
  1182. $verifyList [$k] ['status'] = "";
  1183. if (empty ( $verifyStaff )) {
  1184. $verifyList [$k] ['date'] = "";
  1185. $verifyList [$k] ['opinion'] = "";
  1186. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1187. $verifyList [$k] ['status'] = 4;
  1188. $flag = false;
  1189. }
  1190. } else {
  1191. foreach ( $verifyStaff as $m => $u ) {
  1192. if ($v [0] == $m) {
  1193. $verifyList [$k] ['date'] = $u ['date'];
  1194. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1195. $verifyList [$k] ['status'] = $u ['status'];
  1196. $flag = false;
  1197. break;
  1198. }
  1199. }
  1200. $endStaffArray = end ( $verifyStaff );
  1201. if (isset ( $endStaffArray ['ROLE'] )) {
  1202. } else {
  1203. // $endKey=key($verifyStaff);
  1204. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1205. // $button=4;
  1206. // $verifyList[$k]['status']=4;
  1207. // }
  1208. }
  1209. }
  1210. }
  1211. $rolename ['name'] = '';
  1212. if (! empty ( $roleId )) {
  1213. Doo::loadModel ( 'role' );
  1214. $role = new role ();
  1215. $rolename = $role->getOne ( array (
  1216. 'where' => 'rid=' . $roleId,
  1217. 'asArray' => true
  1218. ) );
  1219. }
  1220. if (! empty ( $verifyStaff ))
  1221. $endStaffArray = end ( $verifyStaff );
  1222. $KOP = false;
  1223. foreach ( $roleArrayCopy as $P => $A ) {
  1224. foreach ( $A as $MKI => $AVL ) {
  1225. if (! empty ( $verifyStaff )) {
  1226. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1227. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1228. $button = 4;
  1229. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1230. }
  1231. foreach ( $verifyStaff as $m => $u ) {
  1232. $AVLFK = $AVL [0] . '_R';
  1233. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1234. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1235. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1236. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1237. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1238. break;
  1239. }
  1240. }
  1241. } else {
  1242. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1243. $button = 4;
  1244. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1245. }
  1246. }
  1247. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1248. $KOP = true;
  1249. }
  1250. }
  1251. foreach ( $roleArrayCopy as $k => $v ) {
  1252. foreach ( $verifyList as $m => $n ) {
  1253. if ($n [0] == $k) {
  1254. array_splice ( $verifyList, $m, 1, $v );
  1255. }
  1256. }
  1257. }
  1258. $receiptList [$key] ['verifyList'] = $verifyList;
  1259. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1260. 'where' => 'sid=' . $value ['staff'],
  1261. 'asArray' => true
  1262. ) );
  1263. $receiptList [$key] ['button'] = $button;
  1264. //
  1265. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1266. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1267. }
  1268. $data ['receiptList'] = $receiptList;
  1269. $data ['receiptDetail'] = $receiptDetail;
  1270. Doo::loadModel ( 'L_category' );
  1271. $lCategory = new L_category ();
  1272. Doo::loadModel ( 'accountItem' );
  1273. $accountItem = new accountItem ();
  1274. $acItem = $accountItem->find ( array (
  1275. 'asArray' => true
  1276. ) );
  1277. $veList = $verify->find ( array (
  1278. 'asArray' => true
  1279. ) );
  1280. foreach ( $veList as $key => $value ) {
  1281. $v = json_decode ( $value ['staff'] );
  1282. $list = array ();
  1283. foreach ( $v as $n => $m ) {
  1284. if ($m ['1'] == 'ROLE') {
  1285. $roleInfo = $role->getOne ( array (
  1286. 'where' => 'rid=' . $m [0],
  1287. 'asArray' => true
  1288. ) );
  1289. $v [$n] [1] = $roleInfo ['name'];
  1290. array_push ( $list, $roleInfo ['name'] );
  1291. } else {
  1292. array_push ( $list, $v [$n] [1] );
  1293. }
  1294. }
  1295. $veList [$key] ['staff'] = implode ( '>', $list );
  1296. }
  1297. $data ['rid'] = $rid;
  1298. $data ['category'] = $lCategory->find ( array (
  1299. 'asArray' => true
  1300. ) );
  1301. $data ['veList'] = $veList;
  1302. $data ['acItem'] = $acItem;
  1303. $data ['memu'] = "receipt";
  1304. $data ['staff'] = $this->staff;
  1305. $data ['receiptMemu'] = 'saeaBorad';
  1306. $data ['verifyId'] = $this->verifyId;
  1307. $data ['executeId'] = $this->executeId;
  1308. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1309. }
  1310. function saeaLoanReceiptAddDo() {
  1311. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1312. $agency = $this->get_args ( 'agency' );
  1313. $travel = $this->get_args ( 'travel' );
  1314. $train = $this->get_args ( 'train' );
  1315. $other = $this->get_args ( 'other' );
  1316. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1317. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1318. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1319. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1320. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1321. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1322. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1323. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1324. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1325. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1326. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1327. header ( 'Content-Type:text/html;charset=utf-8' );
  1328. die ( '请填写联行号' );
  1329. }
  1330. Doo::loadModel ( 'receipt' );
  1331. Doo::loadModel ( 'receiptDetail' );
  1332. Doo::loadModel ( 'accountItem' );
  1333. $accountItem = new accountItem ();
  1334. $receipt = new receipt ();
  1335. Doo::loadModel ( 'enclosur' );
  1336. Doo::loadModel ( 'execute' );
  1337. $execute = new execute ();
  1338. $executeDetail = $execute->getOne ( array (
  1339. 'where' => 'mold="借款费用执行人"',
  1340. 'asArray' => true
  1341. ) );
  1342. $receiptDet = $receipt->getOne ( array (
  1343. 'where' => 'rid=' . $rid,
  1344. 'asArray' => true
  1345. ) );
  1346. // if(!empty($receiptDetail))
  1347. // return "/referReceipt/".$receiptDetail['rid'];
  1348. $aItem = $accountItem->find ( array (
  1349. 'asArray' => true
  1350. ) );
  1351. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1352. $ag = $tr = $ta = $ot = 0;
  1353. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1354. foreach ( $aItem as $key => $value ) {
  1355. if ($value ['category'] == $this->AGENCY) {
  1356. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1357. array_push ( $accountJson [$this->AGENCY], array (
  1358. 'aid' => $value ['aid'],
  1359. 'name' => $value ['name'],
  1360. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1361. ) );
  1362. $sum += $agency [$ag];
  1363. $agencySum += $agency [$ag];
  1364. }
  1365. $ag ++;
  1366. }
  1367. if ($value ['category'] == $this->TRAVEL) {
  1368. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1369. array_push ( $accountJson [$this->TRAVEL], array (
  1370. 'aid' => $value ['aid'],
  1371. 'name' => $value ['name'],
  1372. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1373. ) );
  1374. $sum += $travel [$tr];
  1375. $travelSum += $travel [$tr];
  1376. }
  1377. $tr ++;
  1378. }
  1379. if ($value ['category'] == $this->TRAIN) {
  1380. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1381. array_push ( $accountJson [$this->TRAIN], array (
  1382. 'aid' => $value ['aid'],
  1383. 'name' => $value ['name'],
  1384. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1385. ) );
  1386. $sum += $train [$ta];
  1387. $trainSum += $train [$ta];
  1388. }
  1389. $ta ++;
  1390. }
  1391. if ($value ['category'] == $this->OTHER) {
  1392. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1393. array_push ( $accountJson [$this->OTHER], array (
  1394. 'aid' => $value ['aid'],
  1395. 'name' => $value ['name'],
  1396. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1397. ) );
  1398. $sum += $other [$ot];
  1399. $otherSum += $other [$ot];
  1400. }
  1401. $ot ++;
  1402. }
  1403. }
  1404. $accountJson ['cSum'] = array (
  1405. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1406. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1407. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1408. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1409. );
  1410. // 报销单
  1411. $receipt->accountItem = json_encode ( $accountJson );
  1412. $receipt->staff = $this->staff [0] ['sid'];
  1413. $receipt->loanSum = $receiptDet ['sum'];
  1414. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1415. $receipt->date = date ( "Y-m-d" );
  1416. $receipt->pastDate = '';
  1417. $receipt->cid = $cid;
  1418. $receipt->status = 7;
  1419. // 修改审批流程加入角色
  1420. $receipt->verify = $verify;
  1421. $receipt->verifyStaff = '';
  1422. $receipt->executeStaff = '';
  1423. $receipt->executeCopy = $executeDetail ['staff'];
  1424. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  1425. $receipt->explanation = $explanation;
  1426. $receipt->remittanceName = $remittanceName;
  1427. $receipt->bankName = $bankName;
  1428. $receipt->bankNumber = $bankNumber;
  1429. $receipt->remittanceBankType = $remittanceBankType;
  1430. if ($remittanceBankType == 1)
  1431. $receipt->coupletNumber = $coupletNumber;
  1432. $receipt->update ( array (
  1433. 'where' => 'rid=' . $rid
  1434. ) );
  1435. // 附件
  1436. if (! empty ( $enclosurName )) {
  1437. $enclosurArray = explode ( '-', $enclosurName );
  1438. foreach ( $enclosurArray as $value ) {
  1439. $enclosur = new enclosur ();
  1440. $enclosur->name = $value;
  1441. $enclosur->rid = $rid;
  1442. $enclosur->insert ();
  1443. }
  1444. // print_r($enclosurArray);die;
  1445. }
  1446. // 报销详情
  1447. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1448. $receiptDetail = new receiptDetail ();
  1449. $receiptDetail->staff = $this->staff [0] ['sid'];
  1450. $receiptDetail->item = $value ['name'];
  1451. $receiptDetail->itemCategory = $this->AGENCY;
  1452. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1453. $receiptDetail->date = date ( "Y-m-d" );
  1454. $receiptDetail->cid = $cid;
  1455. $receiptDetail->rid = $rid;
  1456. $receiptDetail->status = 4;
  1457. $receiptDetail->insert ();
  1458. }
  1459. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1460. $receiptDetail = new receiptDetail ();
  1461. $receiptDetail->staff = $this->staff [0] ['sid'];
  1462. $receiptDetail->item = $value ['name'];
  1463. $receiptDetail->itemCategory = $this->TRAVEL;
  1464. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1465. $receiptDetail->date = date ( "Y-m-d" );
  1466. $receiptDetail->cid = $cid;
  1467. $receiptDetail->rid = $rid;
  1468. $receiptDetail->status = 4;
  1469. $receiptDetail->insert ();
  1470. }
  1471. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1472. $receiptDetail = new receiptDetail ();
  1473. $receiptDetail->staff = $this->staff [0] ['sid'];
  1474. $receiptDetail->item = $value ['name'];
  1475. $receiptDetail->itemCategory = $this->TRAIN;
  1476. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1477. $receiptDetail->date = date ( "Y-m-d" );
  1478. $receiptDetail->cid = $cid;
  1479. $receiptDetail->rid = $rid;
  1480. $receiptDetail->status = 4;
  1481. $receiptDetail->insert ();
  1482. }
  1483. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1484. $receiptDetail = new receiptDetail ();
  1485. $receiptDetail->staff = $this->staff [0] ['sid'];
  1486. $receiptDetail->item = $value ['name'];
  1487. $receiptDetail->itemCategory = $this->OTHER;
  1488. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1489. $receiptDetail->date = date ( "Y-m-d" );
  1490. $receiptDetail->cid = $cid;
  1491. $receiptDetail->rid = $rid;
  1492. $receiptDetail->status = 4;
  1493. $receiptDetail->insert ();
  1494. }
  1495. return "/saeaBorad";
  1496. }
  1497. return "/saeaLoanReceiptAdd/" . $rid;
  1498. }
  1499. function saeaLoanReceiptEdi() {
  1500. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1501. Doo::loadClass ( 'XDeode' );
  1502. $XDeode = new XDeode ( 7 );
  1503. $rid = $XDeode->decode ( $ridKey );
  1504. if (! is_numeric ( $rid ))
  1505. die ( 'illegal request' );
  1506. Doo::loadModel ( 'accountItem' );
  1507. Doo::loadModel ( 'verify' );
  1508. Doo::loadModel ( 'receipt' );
  1509. $receipt = new receipt ();
  1510. $verify = new verify ();
  1511. $accountItem = new accountItem ();
  1512. Doo::loadModel ( 'L_category' );
  1513. $Lcategory = new L_category ();
  1514. Doo::loadModel ( "role" );
  1515. $role = new role ();
  1516. Doo::loadModel ( 'loanReceipt' );
  1517. $loanReceipt = new loanReceipt ();
  1518. Doo::loadModel ( 'staff' );
  1519. $staff = new staff ();
  1520. $receiptDetail = $receipt->getOne ( array (
  1521. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  1522. 'asArray' => true
  1523. ) );
  1524. if (empty ( $receiptDetail ))
  1525. return "/saeaBorad";
  1526. $receiptList = $loanReceipt->find ( array (
  1527. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1528. 'desc' => 'rid',
  1529. 'asArray' => true
  1530. ) );
  1531. $Locate = 0;
  1532. $roleId = 0;
  1533. $button = 0;
  1534. foreach ( $receiptList as $key => $value ) {
  1535. $receiptList [$key] ['Locate'] = $Locate;
  1536. $Locate ++;
  1537. $receiptList [$key] ['reviseDetail'] = array ();
  1538. if (! empty ( $value ['reviseDetail'] ))
  1539. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1540. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1541. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1542. $categoryDetil = $Lcategory->getOne ( array (
  1543. 'where' => 'cid=' . $value ['cid'],
  1544. 'asArray' => true
  1545. ) );
  1546. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1547. // 检测编辑状态
  1548. $verifyList = $verify->getOne ( array (
  1549. 'where' => 'vid=' . $value ['verify'],
  1550. 'asArray' => true
  1551. ) );
  1552. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1553. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1554. Doo::loadModel ( 'role' );
  1555. $role = new role ();
  1556. $flag = true;
  1557. $roleKey = 0;
  1558. $endStaffArray = array ();
  1559. $roleArrayCopy = array ();
  1560. foreach ( $verifyList as $k => $v ) {
  1561. // init verifyStaff
  1562. if ($v [1] == 'ROLE') {
  1563. if (! empty ( $verifyStaff )) {
  1564. $endStaffArray = end ( $verifyStaff );
  1565. // if ($v[0]==$endStaffArray['nextStaff']){
  1566. // $roleId=$v[0];
  1567. // }
  1568. }
  1569. $roleVerify = json_decode ( $v [3], true );
  1570. $roleKey = $k;
  1571. $roleArray = array ();
  1572. $rolename = $role->getOne ( array (
  1573. 'where' => 'rid=' . $v [0],
  1574. 'asArray' => true
  1575. ) );
  1576. foreach ( $roleVerify as $o => $p ) {
  1577. $staffID = explode ( '_', $p );
  1578. $staffInfo = $staff->getOne ( array (
  1579. 'where' => 'sid=' . $staffID [0],
  1580. 'asArray' => true
  1581. ) );
  1582. // print_r($staffID);
  1583. $exp = array (
  1584. 0 => $staffInfo ['sid'],
  1585. 1 => $staffID [1],
  1586. 2 => $staffInfo ['avatar'],
  1587. 'date' => '',
  1588. 'date' => '',
  1589. 'opinion' => '',
  1590. 'status' => '',
  1591. 'rolename' => $rolename ['name']
  1592. );
  1593. array_push ( $roleArray, $exp );
  1594. }
  1595. $roleArrayCopy [$v [0]] = $roleArray;
  1596. // $verifyList[$k]['roleArray']=$roleArray;
  1597. }
  1598. $verifyList [$k] ['date'] = "";
  1599. $verifyList [$k] ['opinion'] = "";
  1600. $verifyList [$k] ['status'] = "";
  1601. if (empty ( $verifyStaff )) {
  1602. $verifyList [$k] ['date'] = "";
  1603. $verifyList [$k] ['opinion'] = "";
  1604. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1605. $verifyList [$k] ['status'] = 4;
  1606. $flag = false;
  1607. }
  1608. } else {
  1609. foreach ( $verifyStaff as $m => $u ) {
  1610. if ($v [0] == $m) {
  1611. $verifyList [$k] ['date'] = $u ['date'];
  1612. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1613. $verifyList [$k] ['status'] = $u ['status'];
  1614. $flag = false;
  1615. break;
  1616. }
  1617. }
  1618. $endStaffArray = end ( $verifyStaff );
  1619. if (isset ( $endStaffArray ['ROLE'] )) {
  1620. } else {
  1621. // $endKey=key($verifyStaff);
  1622. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1623. // $button=4;
  1624. // $verifyList[$k]['status']=4;
  1625. // }
  1626. }
  1627. }
  1628. }
  1629. $rolename ['name'] = '';
  1630. if (! empty ( $roleId )) {
  1631. Doo::loadModel ( 'role' );
  1632. $role = new role ();
  1633. $rolename = $role->getOne ( array (
  1634. 'where' => 'rid=' . $roleId,
  1635. 'asArray' => true
  1636. ) );
  1637. }
  1638. if (! empty ( $verifyStaff ))
  1639. $endStaffArray = end ( $verifyStaff );
  1640. $KOP = false;
  1641. foreach ( $roleArrayCopy as $P => $A ) {
  1642. foreach ( $A as $MKI => $AVL ) {
  1643. if (! empty ( $verifyStaff )) {
  1644. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1645. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1646. $button = 4;
  1647. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1648. }
  1649. foreach ( $verifyStaff as $m => $u ) {
  1650. $AVLFK = $AVL [0] . '_R';
  1651. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1652. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1653. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1654. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1655. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1656. break;
  1657. }
  1658. }
  1659. } else {
  1660. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1661. $button = 4;
  1662. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1663. }
  1664. }
  1665. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1666. $KOP = true;
  1667. }
  1668. }
  1669. foreach ( $roleArrayCopy as $k => $v ) {
  1670. foreach ( $verifyList as $m => $n ) {
  1671. if ($n [0] == $k) {
  1672. array_splice ( $verifyList, $m, 1, $v );
  1673. }
  1674. }
  1675. }
  1676. $receiptList [$key] ['verifyList'] = $verifyList;
  1677. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1678. 'where' => 'sid=' . $value ['staff'],
  1679. 'asArray' => true
  1680. ) );
  1681. $receiptList [$key] ['button'] = $button;
  1682. //
  1683. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1684. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1685. }
  1686. $data ['receiptList'] = $receiptList;
  1687. $acItem = $accountItem->find ( array (
  1688. 'asArray' => true
  1689. ) );
  1690. $veList = $verify->find ( array (
  1691. 'asArray' => true
  1692. ) );
  1693. foreach ( $veList as $key => $value ) {
  1694. $v = json_decode ( $value ['staff'] );
  1695. $list = array ();
  1696. foreach ( $v as $n => $m ) {
  1697. if ($m ['1'] == 'ROLE') {
  1698. $roleInfo = $role->getOne ( array (
  1699. 'where' => 'rid=' . $m [0],
  1700. 'asArray' => true
  1701. ) );
  1702. $v [$n] [1] = $roleInfo ['name'];
  1703. array_push ( $list, $roleInfo ['name'] );
  1704. } else {
  1705. array_push ( $list, $v [$n] [1] );
  1706. }
  1707. }
  1708. $veList [$key] ['staff'] = implode ( '>', $list );
  1709. }
  1710. // 配置编辑信息
  1711. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1712. foreach ( $acItem as $key => $value ) {
  1713. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1714. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1715. $acItem [$key] ['price'] = $v ['price'];
  1716. }
  1717. }
  1718. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1719. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1720. $acItem [$key] ['price'] = $v ['price'];
  1721. }
  1722. }
  1723. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1724. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1725. $acItem [$key] ['price'] = $v ['price'];
  1726. }
  1727. }
  1728. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1729. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1730. $acItem [$key] ['price'] = $v ['price'];
  1731. }
  1732. }
  1733. }
  1734. $data ['category'] = $Lcategory->find ( array (
  1735. 'asArray' => true
  1736. ) );
  1737. $data ['ridKey'] = $ridKey;
  1738. $data ['cSum'] = $accountItemList ['cSum'];
  1739. $data ['sum'] = $receiptDetail ['sum'];
  1740. $data ['receiptDetail'] = $receiptDetail;
  1741. $data ['veList'] = $veList;
  1742. $data ['acItem'] = $acItem;
  1743. $data ['memu'] = "receipt";
  1744. $data ['staff'] = $this->staff;
  1745. $data ['receiptMemu'] = 'saeaBorad';
  1746. $data ['verify'] = $receiptDetail ['verify'];
  1747. $data ['verifyId'] = $this->verifyId;
  1748. $data ['executeId'] = $this->executeId;
  1749. $data ['rid'] = $rid;
  1750. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  1751. }
  1752. function confirmation() {
  1753. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1754. Doo::loadModel ( 'receipt' );
  1755. Doo::loadModel ( 'receiptDetail' );
  1756. $receipt = new receipt ();
  1757. $receiptDetail = new receiptDetail ();
  1758. Doo::loadModel ( 'statistics' );
  1759. Doo::loadModel ( 'itemStatistics' );
  1760. $statistics = new statistics ();
  1761. $itemStatistics = new itemStatistics ();
  1762. Doo::loadModel ( "verify" );
  1763. $verify = new verify ();
  1764. $receiptDetailList = $receipt->getOne ( array (
  1765. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  1766. 'asArray' => true
  1767. ) );
  1768. if (empty ( $receiptDetailList ))
  1769. return "/saeaBorad";
  1770. $verifyDetail = $verify->getOne ( array (
  1771. 'where' => ' vid =' . $receiptDetailList ['verify'],
  1772. 'asArray' => true
  1773. ) );
  1774. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  1775. if (empty ( $receiptDetailList ['nowStaff'] )) {
  1776. $nowStaff = "";
  1777. $nowStaffList = array ();
  1778. if ($verifyDetail [0] [1] == 'ROLE') {
  1779. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  1780. foreach ( $vStaffString as $key => $value ) {
  1781. $staffK = explode ( "_", $value );
  1782. array_push ( $nowStaffList, $staffK [0] );
  1783. }
  1784. $nowStaff = implode ( ',', $nowStaffList );
  1785. } else {
  1786. $nowStaff = $verifyDetail [0] [0];
  1787. }
  1788. $receipt->nowStaff = $nowStaff;
  1789. }
  1790. // echo $nowStaff;
  1791. // print_r($verifyDetail);die;
  1792. $receipt->rid = $receiptDetailList ['rid'];
  1793. $receipt->status = 2;
  1794. $receipt->update ();
  1795. // 操作日志
  1796. Doo::loadModel ( "receiptLog" );
  1797. $receiptLog = new receiptLog ();
  1798. $verify = new verify ();
  1799. $receiptInfo = $receipt->getOne ( array (
  1800. 'where' => 'rid=' . $rid,
  1801. 'asArray' => true
  1802. ) );
  1803. $vr = $verify->getOne ( array (
  1804. 'where' => 'vid=' . $receiptInfo ['verify'],
  1805. 'asArray' => true
  1806. ) );
  1807. $jd = json_decode ( $vr ['staff'] );
  1808. $roleId = 0;
  1809. foreach ( $jd as $key => $value ) {
  1810. if ($value [1] == 'ROLE') {
  1811. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  1812. if ($pos !== false) {
  1813. $roleId = $value [0];
  1814. }
  1815. }
  1816. }
  1817. // 审批日志
  1818. // echo $roleId;die;
  1819. if (! empty ( $roleId )) {
  1820. Doo::loadModel ( "role" );
  1821. $role = new role ();
  1822. $roleInfo = $role->getOne ( array (
  1823. 'where' => 'rid=' . $roleId,
  1824. 'asArray' => true
  1825. ) );
  1826. $receiptLog->rolename = $roleInfo ['name'];
  1827. }
  1828. $receiptLog->username = $this->staff [0] ['username'];
  1829. $receiptLog->uid = $this->staff [0] ['sid'];
  1830. $receiptLog->date = date ( "Y-m-d" );
  1831. $receiptLog->opinion = '提交审批';
  1832. $receiptLog->img = $this->staff [0] ['avatar'];
  1833. $receiptLog->status = 2;
  1834. $receiptLog->rid = $rid;
  1835. $receiptLog->insert ();
  1836. return "/expenses";
  1837. }
  1838. function expenses() {
  1839. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  1840. if (empty ( $item ))
  1841. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  1842. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1843. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  1844. Doo::loadModel ( 'receipt' );
  1845. $receipt = new receipt ();
  1846. Doo::loadModel ( 'L_category' );
  1847. $Lcategory = new L_category ();
  1848. Doo::loadModel ( 'verify' );
  1849. Doo::loadModel ( 'statistics' );
  1850. $statistics = new statistics ();
  1851. $verify = new verify ();
  1852. Doo::loadModel ( 'staff' );
  1853. $staff = new staff ();
  1854. $condition = "";
  1855. if ($item == "expenses")
  1856. $condition = " and Rtype=1 ";
  1857. elseif ($item == "receipts")
  1858. $condition = " and Rtype=0 ";
  1859. elseif ($item == "remits")
  1860. $condition = " and Rtype=2 ";
  1861. $dateCondition = " and Year(date) =" . $year;
  1862. if (! empty ( $moth )) {
  1863. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  1864. $stList = $statistics->getOne ( array (
  1865. 'select' => 'rePrice ,agPrice',
  1866. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  1867. 'asArray' => true
  1868. ) );
  1869. } else
  1870. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  1871. if (empty ( $stList ))
  1872. $stList = array (
  1873. 'rePrice' => 0,
  1874. 'agPrice' => 0
  1875. );
  1876. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  1877. if (! isset ( $noPassSum ['sum'] ))
  1878. $noPassSum ['sum'] = 0;
  1879. $data ['stList'] = array (
  1880. 'rePrice' => $stList ['rePrice'],
  1881. 'agPrice' => $stList ['agPrice'],
  1882. 'skPrice' => ($noPassSum ['sum'])
  1883. );
  1884. $receiptList = $receipt->find ( array (
  1885. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  1886. 'desc' => 'rid',
  1887. 'asArray' => true
  1888. ) );
  1889. $Locate = 0;
  1890. $roleId = 0;
  1891. $button = 0;
  1892. foreach ( $receiptList as $key => $value ) {
  1893. $receiptList [$key] ['Locate'] = $Locate;
  1894. $Locate ++;
  1895. $receiptList [$key] ['reviseDetail'] = array ();
  1896. if (! empty ( $value ['reviseDetail'] ))
  1897. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1898. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1899. $categoryDetil = $Lcategory->getOne ( array (
  1900. 'where' => 'cid=' . $value ['cid'],
  1901. 'asArray' => true
  1902. ) );
  1903. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1904. // 检测编辑状态
  1905. $verifyList = $verify->getOne ( array (
  1906. 'where' => 'vid=' . $value ['verify'],
  1907. 'asArray' => true
  1908. ) );
  1909. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1910. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1911. Doo::loadModel ( 'role' );
  1912. $role = new role ();
  1913. $flag = true;
  1914. $roleKey = 0;
  1915. $endStaffArray = array ();
  1916. $roleArrayCopy = array ();
  1917. foreach ( $verifyList as $k => $v ) {
  1918. // init verifyStaff
  1919. if ($v [1] == 'ROLE') {
  1920. if (! empty ( $verifyStaff )) {
  1921. $endStaffArray = end ( $verifyStaff );
  1922. // if ($v[0]==$endStaffArray['nextStaff']){
  1923. // $roleId=$v[0];
  1924. // }
  1925. }
  1926. $roleVerify = json_decode ( $v [3], true );
  1927. $roleKey = $k;
  1928. $roleArray = array ();
  1929. $rolename = $role->getOne ( array (
  1930. 'where' => 'rid=' . $v [0],
  1931. 'asArray' => true
  1932. ) );
  1933. foreach ( $roleVerify as $o => $p ) {
  1934. $staffID = explode ( '_', $p );
  1935. $staffInfo = $staff->getOne ( array (
  1936. 'where' => 'sid=' . $staffID [0],
  1937. 'asArray' => true
  1938. ) );
  1939. // print_r($staffID);
  1940. $exp = array (
  1941. 0 => $staffInfo ['sid'],
  1942. 1 => $staffID [1],
  1943. 2 => $staffInfo ['avatar'],
  1944. 'date' => '',
  1945. 'date' => '',
  1946. 'opinion' => '',
  1947. 'status' => '',
  1948. 'rolename' => $rolename ['name']
  1949. );
  1950. array_push ( $roleArray, $exp );
  1951. }
  1952. $roleArrayCopy [$v [0]] = $roleArray;
  1953. // $verifyList[$k]['roleArray']=$roleArray;
  1954. }
  1955. $verifyList [$k] ['date'] = "";
  1956. $verifyList [$k] ['opinion'] = "";
  1957. $verifyList [$k] ['status'] = "";
  1958. if (empty ( $verifyStaff )) {
  1959. $verifyList [$k] ['date'] = "";
  1960. $verifyList [$k] ['opinion'] = "";
  1961. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1962. $verifyList [$k] ['status'] = 4;
  1963. $flag = false;
  1964. }
  1965. } else {
  1966. foreach ( $verifyStaff as $m => $u ) {
  1967. if ($v [0] == $m) {
  1968. $verifyList [$k] ['date'] = $u ['date'];
  1969. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1970. $verifyList [$k] ['status'] = $u ['status'];
  1971. $flag = false;
  1972. break;
  1973. }
  1974. }
  1975. $endStaffArray = end ( $verifyStaff );
  1976. if (isset ( $endStaffArray ['ROLE'] )) {
  1977. } else {
  1978. // $endKey=key($verifyStaff);
  1979. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1980. // $button=4;
  1981. // $verifyList[$k]['status']=4;
  1982. // }
  1983. }
  1984. }
  1985. }
  1986. $rolename ['name'] = '';
  1987. if (! empty ( $roleId )) {
  1988. Doo::loadModel ( 'role' );
  1989. $role = new role ();
  1990. $rolename = $role->getOne ( array (
  1991. 'where' => 'rid=' . $roleId,
  1992. 'asArray' => true
  1993. ) );
  1994. }
  1995. if (! empty ( $verifyStaff ))
  1996. $endStaffArray = end ( $verifyStaff );
  1997. $KOP = false;
  1998. foreach ( $roleArrayCopy as $P => $A ) {
  1999. foreach ( $A as $MKI => $AVL ) {
  2000. if (! empty ( $verifyStaff )) {
  2001. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2002. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2003. $button = 4;
  2004. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2005. }
  2006. foreach ( $verifyStaff as $m => $u ) {
  2007. $AVLFK = $AVL [0] . '_R';
  2008. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2009. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2010. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2011. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2012. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2013. break;
  2014. }
  2015. }
  2016. } else {
  2017. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2018. $button = 4;
  2019. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2020. }
  2021. }
  2022. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2023. $KOP = true;
  2024. }
  2025. }
  2026. foreach ( $roleArrayCopy as $k => $v ) {
  2027. foreach ( $verifyList as $m => $n ) {
  2028. if ($n [0] == $k) {
  2029. array_splice ( $verifyList, $m, 1, $v );
  2030. }
  2031. }
  2032. }
  2033. $receiptList [$key] ['verifyList'] = $verifyList;
  2034. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2035. 'where' => 'sid=' . $value ['staff'],
  2036. 'asArray' => true
  2037. ) );
  2038. $receiptList [$key] ['button'] = $button;
  2039. }
  2040. // print_r($receiptList);die;
  2041. $mothHtml = "";
  2042. for($i = 1; $i <= 12; $i ++) {
  2043. if ($moth == $i)
  2044. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2045. else
  2046. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2047. }
  2048. $data ['mothHtml'] = $mothHtml;
  2049. $data ['receiptList'] = $receiptList;
  2050. $data ['memu'] = "receipt";
  2051. $data ['staff'] = $this->staff;
  2052. $data ['receiptMemu'] = 'expenses';
  2053. $data ['verifyId'] = $this->verifyId;
  2054. $data ['executeId'] = $this->executeId;
  2055. $data ['item'] = $item;
  2056. $data ['year'] = $year;
  2057. $this->render ( "/admin/expenses", $data );
  2058. }
  2059. function expensesCollect() {
  2060. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2061. Doo::loadModel ( 'receipt' );
  2062. $receipt = new receipt ();
  2063. Doo::loadModel ( 'L_category' );
  2064. $Lcategory = new L_category ();
  2065. Doo::loadModel ( 'verify' );
  2066. Doo::loadModel ( 'statistics' );
  2067. $statistics = new statistics ();
  2068. $verify = new verify ();
  2069. Doo::loadModel ( 'staff' );
  2070. $staff = new staff ();
  2071. Doo::loadModel ( 'loanReceipt' );
  2072. $loanReceipt = new loanReceipt ();
  2073. $receiptList = $receipt->find ( array (
  2074. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  2075. 'desc' => 'rid',
  2076. 'asArray' => true
  2077. ) );
  2078. $loanList = $loanReceipt->find ( array (
  2079. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2080. 'desc' => 'rid',
  2081. 'asArray' => true
  2082. ) );
  2083. /*
  2084. * $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;
  2085. */
  2086. $data ['explanation'] = '';
  2087. if (! empty ( $loanList ))
  2088. $data ['explanation'] = $loanList [0] ['explanation'];
  2089. $Locate = 0;
  2090. $roleId = 0;
  2091. $button = 0;
  2092. foreach ( $receiptList as $key => $value ) {
  2093. $receiptList [$key] ['Locate'] = $Locate;
  2094. $Locate ++;
  2095. $receiptList [$key] ['reviseDetail'] = array ();
  2096. if (! empty ( $value ['reviseDetail'] ))
  2097. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2098. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2099. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2100. $categoryDetil = $Lcategory->getOne ( array (
  2101. 'where' => 'cid=' . $value ['cid'],
  2102. 'asArray' => true
  2103. ) );
  2104. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2105. // 检测编辑状态
  2106. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  2107. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  2108. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  2109. else
  2110. $verifyList ['staff'] = $value ['verifyBreakup'];
  2111. } else
  2112. $verifyList = $verify->getOne ( array (
  2113. 'where' => 'vid=' . $value ['verify'],
  2114. 'asArray' => true
  2115. ) );
  2116. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2117. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2118. Doo::loadModel ( 'role' );
  2119. $role = new role ();
  2120. $flag = true;
  2121. $roleKey = 0;
  2122. $endStaffArray = array ();
  2123. $roleArrayCopy = array ();
  2124. foreach ( $verifyList as $k => $v ) {
  2125. // init verifyStaff
  2126. if ($v [1] == 'ROLE') {
  2127. if (! empty ( $verifyStaff )) {
  2128. $endStaffArray = end ( $verifyStaff );
  2129. // if ($v[0]==$endStaffArray['nextStaff']){
  2130. // $roleId=$v[0];
  2131. // }
  2132. }
  2133. $roleVerify = json_decode ( $v [3], true );
  2134. $roleKey = $k;
  2135. $roleArray = array ();
  2136. $rolename = $role->getOne ( array (
  2137. 'where' => 'rid=' . $v [0],
  2138. 'asArray' => true
  2139. ) );
  2140. foreach ( $roleVerify as $o => $p ) {
  2141. $staffID = explode ( '_', $p );
  2142. $staffInfo = $staff->getOne ( array (
  2143. 'where' => 'sid=' . $staffID [0],
  2144. 'asArray' => true
  2145. ) );
  2146. // print_r($staffID);
  2147. $exp = array (
  2148. 0 => $staffInfo ['sid'],
  2149. 1 => $staffID [1],
  2150. 2 => $staffInfo ['avatar'],
  2151. 'date' => '',
  2152. 'date' => '',
  2153. 'opinion' => '',
  2154. 'status' => '',
  2155. 'rolename' => $rolename ['name']
  2156. );
  2157. array_push ( $roleArray, $exp );
  2158. }
  2159. $roleArrayCopy [$v [0]] = $roleArray;
  2160. // $verifyList[$k]['roleArray']=$roleArray;
  2161. }
  2162. $verifyList [$k] ['date'] = "";
  2163. $verifyList [$k] ['opinion'] = "";
  2164. $verifyList [$k] ['status'] = "";
  2165. if (empty ( $verifyStaff )) {
  2166. $verifyList [$k] ['date'] = "";
  2167. $verifyList [$k] ['opinion'] = "";
  2168. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2169. $verifyList [$k] ['status'] = 4;
  2170. $flag = false;
  2171. }
  2172. } else {
  2173. foreach ( $verifyStaff as $m => $u ) {
  2174. if ($v [0] == $m) {
  2175. $verifyList [$k] ['date'] = $u ['date'];
  2176. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2177. $verifyList [$k] ['status'] = $u ['status'];
  2178. $flag = false;
  2179. break;
  2180. }
  2181. }
  2182. $endStaffArray = end ( $verifyStaff );
  2183. if (isset ( $endStaffArray ['ROLE'] )) {
  2184. } else {
  2185. // $endKey=key($verifyStaff);
  2186. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2187. // $button=4;
  2188. // $verifyList[$k]['status']=4;
  2189. // }
  2190. }
  2191. }
  2192. }
  2193. $rolename ['name'] = '';
  2194. if (! empty ( $roleId )) {
  2195. Doo::loadModel ( 'role' );
  2196. $role = new role ();
  2197. $rolename = $role->getOne ( array (
  2198. 'where' => 'rid=' . $roleId,
  2199. 'asArray' => true
  2200. ) );
  2201. }
  2202. if (! empty ( $verifyStaff ))
  2203. $endStaffArray = end ( $verifyStaff );
  2204. $KOP = false;
  2205. foreach ( $roleArrayCopy as $P => $A ) {
  2206. foreach ( $A as $MKI => $AVL ) {
  2207. if (! empty ( $verifyStaff )) {
  2208. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2209. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2210. $button = 4;
  2211. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2212. }
  2213. foreach ( $verifyStaff as $m => $u ) {
  2214. $AVLFK = $AVL [0] . '_R';
  2215. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2216. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2217. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2218. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2219. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2220. break;
  2221. }
  2222. }
  2223. } else {
  2224. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2225. $button = 4;
  2226. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2227. }
  2228. }
  2229. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2230. $KOP = true;
  2231. }
  2232. }
  2233. foreach ( $roleArrayCopy as $k => $v ) {
  2234. foreach ( $verifyList as $m => $n ) {
  2235. if ($n [0] == $k) {
  2236. array_splice ( $verifyList, $m, 1, $v );
  2237. }
  2238. }
  2239. }
  2240. // 费用执行人相关数据
  2241. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2242. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2243. foreach ( $executeCopy as $k => $v ) {
  2244. $executeCopy [$k] ['date'] = '';
  2245. $executeCopy [$k] ['opinion'] = '';
  2246. $executeCopy [$k] ['status'] = '';
  2247. if (! empty ( $executeStaff ))
  2248. foreach ( $executeStaff as $m => $u ) {
  2249. if ($v [0] == $m) {
  2250. $executeCopy [$k] ['date'] = $u ['date'];
  2251. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2252. $executeCopy [$k] ['status'] = $u ['status'];
  2253. break;
  2254. }
  2255. }
  2256. }
  2257. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2258. $receiptList [$key] ['verifyList'] = $verifyList;
  2259. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2260. 'where' => 'sid=' . $value ['staff'],
  2261. 'asArray' => true
  2262. ) );
  2263. $receiptList [$key] ['button'] = $button;
  2264. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2265. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2266. $relust = $value ['sum'] - $value ['loanSum'];
  2267. $receiptList [$key] ['relust'] = $relust;
  2268. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2269. }
  2270. Doo::loadModel ( 'enclosur' );
  2271. $enclosur = new enclosur ();
  2272. $enclosurList = $enclosur->find ( array (
  2273. 'where' => 'rid=' . $rid,
  2274. 'asArray' => true
  2275. ) );
  2276. $enclosurHtml = '';
  2277. foreach ( $enclosurList as $value ) {
  2278. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2279. }
  2280. $data ['enclosurHtml'] = $enclosurHtml;
  2281. // print_r($receiptList);
  2282. $data ['receiptList'] = $receiptList;
  2283. $data ['memu'] = "receipt";
  2284. $data ['staff'] = $this->staff;
  2285. $data ['receiptMemu'] = 'expenses';
  2286. $data ['verifyId'] = $this->verifyId;
  2287. $data ['executeId'] = $this->executeId;
  2288. $this->render ( "/admin/expensesCollect", $data );
  2289. }
  2290. function approvalExpenses() {
  2291. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  2292. $year = $rdate = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2293. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2294. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2295. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2296. // $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) :"";
  2297. // echo $rdate;
  2298. if (empty ( $status ))
  2299. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  2300. $page_size = 12;
  2301. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2302. $vidList = array ();
  2303. $button = 0;
  2304. Doo::loadModel ( 'verify' );
  2305. $verify = new verify ();
  2306. Doo::loadModel ( 'receipt' );
  2307. $receipt = new receipt ();
  2308. Doo::loadModel ( 'staff' );
  2309. $staff = new staff ();
  2310. Doo::loadModel ( 'L_category' );
  2311. $Lcategory = new L_category ();
  2312. // user verify ID
  2313. $verifyDetail = $verify->find ( array (
  2314. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  2315. 'asArray' => true
  2316. ) );
  2317. foreach ( $verifyDetail as $key => $value ) {
  2318. array_push ( $vidList, $value ['vid'] );
  2319. }
  2320. $vid = implode ( ",", $vidList );
  2321. if (empty ( $verifyDetail ))
  2322. $vid = 0;
  2323. // if ($status==0)
  2324. // $dateCondition="";
  2325. // else
  2326. $dateCondition = " ";
  2327. // if (! empty ( $month ))
  2328. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  2329. if ($status == 'done' || $status == 'termination') {
  2330. if (! empty ( $year )) {
  2331. $dateCondition = " and Year(pastDate) =" . $year;
  2332. if (! empty ( $month ))
  2333. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  2334. }
  2335. } elseif ($status == 'finish') {
  2336. if (! empty ( $year )) {
  2337. $dateCondition = " and Year(pastDate) =" . $year;
  2338. if (! empty ( $month ))
  2339. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  2340. }
  2341. }
  2342. // date ( 'Y-m' )
  2343. // if (! empty ( $rdate ) && $status == 'done')
  2344. // $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  2345. // elseif (! empty ( $rdate ))
  2346. // $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  2347. $categoryList = $Lcategory->find ( array (
  2348. 'asArray' => true
  2349. ) );
  2350. $staffList = $staff->find ( array (
  2351. 'where' => 'cid=' . $cid,
  2352. 'asArray' => true
  2353. ) );
  2354. $cateCondition = "";
  2355. $staffCondition = "";
  2356. $approvalCondition = "";
  2357. if (! empty ( $cid )) {
  2358. $cateCondition = ' and cid=' . $cid;
  2359. }
  2360. if (! empty ( $sid )) {
  2361. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  2362. $cateCondition = "";
  2363. }
  2364. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  2365. if ($status == 'pendApproval') {
  2366. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  2367. }
  2368. if ($status == 'ongoing') {
  2369. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  2370. }
  2371. if ($status == 'done') {
  2372. $approvalCondition = ' and (status=8 or status=9 ) ';
  2373. }
  2374. if ($status == 'termination') {
  2375. $approvalCondition = " and status=3";
  2376. }
  2377. if ($status == 'finish') {
  2378. $approvalCondition = " and (status=1 or status=8 or status=9)";
  2379. }
  2380. $pageinfo ['page'] = array (
  2381. 'previous' => ''
  2382. );
  2383. if ($status == 'done' || $status == 'termination' || $status == 'finish' ) { // $dateCondition .
  2384. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  2385. $receiptList = $receipt->find ( array ( // $dateCondition.
  2386. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  2387. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2388. 'desc' => 'rid',
  2389. 'asArray' => true
  2390. ) );
  2391. } else {
  2392. $receiptList = $receipt->find ( array ( // $dateCondition
  2393. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition.$dateCondition . ' and verify in (' . $vid . ')',
  2394. 'desc' => 'rid',
  2395. 'asArray' => true
  2396. ) );
  2397. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  2398. }
  2399. $rLRes = $receipt->find ( array (
  2400. '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 . ')',
  2401. 'desc' => 'rid',
  2402. 'asArray' => true
  2403. ) );
  2404. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  2405. // print_r($receiptList);
  2406. $Locate = 0;
  2407. $reportList = $reportCateList = array ();
  2408. foreach ( $receiptList as $key => $value ) {
  2409. $receiptList [$key] ['Locate'] = $Locate;
  2410. $Locate ++;
  2411. $receiptList [$key] ['reviseDetail'] = array ();
  2412. if (! empty ( $value ['reviseDetail'] ))
  2413. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2414. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2415. $categoryDetil = $Lcategory->getOne ( array (
  2416. 'where' => 'cid=' . $value ['cid'],
  2417. 'asArray' => true
  2418. ) );
  2419. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2420. $verifyList = $verify->getOne ( array (
  2421. 'where' => 'vid=' . $value ['verify'],
  2422. 'asArray' => true
  2423. ) );
  2424. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2425. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2426. foreach ( $verifyList as $k => $v ) {
  2427. // init verifyStaff
  2428. $verifyList [$k] ['date'] = "";
  2429. $verifyList [$k] ['opinion'] = "";
  2430. $verifyList [$k] ['status'] = "";
  2431. if (empty ( $verifyStaff )) {
  2432. $verifyList [$k] ['date'] = "";
  2433. $verifyList [$k] ['opinion'] = "";
  2434. if ($v [0] == $this->staff [0] ['sid']) {
  2435. $verifyList [$k] ['status'] = 4;
  2436. $button = 4;
  2437. }
  2438. } else {
  2439. $flag = true;
  2440. foreach ( $verifyStaff as $m => $u ) {
  2441. if ($v [0] == $m) {
  2442. $verifyList [$k] ['date'] = $u ['date'];
  2443. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2444. $verifyList [$k] ['status'] = $u ['status'];
  2445. $flag = false;
  2446. break;
  2447. }
  2448. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  2449. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  2450. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  2451. }
  2452. if ($flag) { // 检测可编辑
  2453. if ($v [0] == $this->staff [0] ['sid']) {
  2454. $verifyList [$k] ['status'] = 4;
  2455. $button = 4;
  2456. }
  2457. }
  2458. }
  2459. }
  2460. $receiptList [$key] ['verifyList'] = $verifyList;
  2461. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2462. 'where' => 'sid=' . $value ['staff'],
  2463. 'asArray' => true
  2464. ) );
  2465. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  2466. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  2467. $receiptList [$key] ['button'] = $button;
  2468. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  2469. }
  2470. $reportList = array_unique ( $reportList );
  2471. $reportHtml = '';
  2472. foreach ( $reportList as $key => $value ) {
  2473. $v = explode ( "-", $value );
  2474. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  2475. }
  2476. // print_r($reportList)
  2477. $data ['reportHtml'] = $reportHtml;
  2478. $reportCateList = array_unique ( $reportCateList );
  2479. $reportCateHtml = '';
  2480. foreach ( $reportCateList as $key => $value ) {
  2481. $v = explode ( "-", $value );
  2482. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  2483. }
  2484. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  2485. $data ['reportCateHtml'] = $reportCateHtml;
  2486. // print_r($receiptList);die;
  2487. // $data['verifyDetail']=$verifyDetail;
  2488. $mothHtml = "";
  2489. for($i = 1; $i <= 12; $i ++) {
  2490. if ($month == $i)
  2491. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2492. else
  2493. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2494. }
  2495. $data ['mothHtml'] = $mothHtml;
  2496. $data ['page'] = $pageinfo;
  2497. $data ['receiptList'] = $receiptList;
  2498. $data ['receiptApprovalCount'] = count ( $rLRes );
  2499. $data ['status'] = $status;
  2500. $data ['year'] = $year;
  2501. $data ['categoryList'] = $categoryList;
  2502. $data ['staffList'] = $staffList;
  2503. $data ['cid'] = $cid;
  2504. $data ['sid'] = $sid;
  2505. // print_r($receiptList);
  2506. $data ['memu'] = "receipt";
  2507. $data ['staff'] = $this->staff;
  2508. $data ['receiptMemu'] = 'approvalExpenses';
  2509. $data ['verifyId'] = $this->verifyId;
  2510. $data ['executeId'] = $this->executeId;
  2511. $this->render ( "/admin/approvalExpenses", $data );
  2512. }
  2513. function expensesDoc() {
  2514. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2515. Doo::loadClass ( 'XDeode' );
  2516. $XDeode = new XDeode ( 5 );
  2517. if (!empty($rid)&&!is_numeric($rid))
  2518. $rid = $XDeode->decode ( $rid );
  2519. if(!is_numeric($rid))
  2520. die ( 'illegal request' );
  2521. Doo::loadModel ( 'receipt' );
  2522. $receipt = new receipt ();
  2523. Doo::loadModel ( 'L_category' );
  2524. $Lcategory = new L_category ();
  2525. Doo::loadModel ( 'verify' );
  2526. Doo::loadModel ( 'statistics' );
  2527. $statistics = new statistics ();
  2528. $verify = new verify ();
  2529. Doo::loadModel ( 'staff' );
  2530. $staff = new staff ();
  2531. Doo::loadModel ( 'loanReceipt' );
  2532. $loanReceipt = new loanReceipt ();
  2533. $receiptList = $receipt->find ( array (
  2534. 'where' => ' rid=' . $rid,
  2535. 'desc' => 'rid',
  2536. 'asArray' => true
  2537. ) );
  2538. $loanList = array ();
  2539. if (! empty ( $receiptList ))
  2540. $loanList = $loanReceipt->find ( array (
  2541. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2542. 'desc' => 'rid',
  2543. 'asArray' => true
  2544. ) );
  2545. $Locate = 0;
  2546. $roleId = 0;
  2547. $button = 0;
  2548. foreach ( $loanList as $key => $value ) {
  2549. $loanList [$key] ['Locate'] = $Locate;
  2550. $Locate ++;
  2551. $loanList [$key] ['reviseDetail'] = array ();
  2552. if (! empty ( $value ['reviseDetail'] ))
  2553. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2554. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2555. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2556. $categoryDetil = $Lcategory->getOne ( array (
  2557. 'where' => 'cid=' . $value ['cid'],
  2558. 'asArray' => true
  2559. ) );
  2560. $loanList [$key] ['category'] = $categoryDetil ['title'];
  2561. // 检测编辑状态
  2562. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  2563. $verifyList ['staff'] = $value ['verifyBreakup'];
  2564. else
  2565. $verifyList = $verify->getOne ( array (
  2566. 'where' => 'vid=' . $value ['verify'],
  2567. 'asArray' => true
  2568. ) );
  2569. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2570. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2571. Doo::loadModel ( 'role' );
  2572. $role = new role ();
  2573. $flag = true;
  2574. $roleKey = 0;
  2575. $endStaffArray = array ();
  2576. $roleArrayCopy = array ();
  2577. foreach ( $verifyList as $k => $v ) {
  2578. // init verifyStaff
  2579. if ($v [1] == 'ROLE') {
  2580. if (! empty ( $verifyStaff )) {
  2581. $endStaffArray = end ( $verifyStaff );
  2582. // if ($v[0]==$endStaffArray['nextStaff']){
  2583. // $roleId=$v[0];
  2584. // }
  2585. }
  2586. $roleVerify = json_decode ( $v [3], true );
  2587. $roleKey = $k;
  2588. $roleArray = array ();
  2589. $rolename = $role->getOne ( array (
  2590. 'where' => 'rid=' . $v [0],
  2591. 'asArray' => true
  2592. ) );
  2593. foreach ( $roleVerify as $o => $p ) {
  2594. $staffID = explode ( '_', $p );
  2595. $staffInfo = $staff->getOne ( array (
  2596. 'where' => 'sid=' . $staffID [0],
  2597. 'asArray' => true
  2598. ) );
  2599. // print_r($staffID);
  2600. $exp = array (
  2601. 0 => $staffInfo ['sid'],
  2602. 1 => $staffID [1],
  2603. 2 => $staffInfo ['avatar'],
  2604. 'date' => '',
  2605. 'date' => '',
  2606. 'opinion' => '',
  2607. 'status' => '',
  2608. 'rolename' => $rolename ['name']
  2609. );
  2610. array_push ( $roleArray, $exp );
  2611. }
  2612. $roleArrayCopy [$v [0]] = $roleArray;
  2613. // $verifyList[$k]['roleArray']=$roleArray;
  2614. }
  2615. $verifyList [$k] ['date'] = "";
  2616. $verifyList [$k] ['opinion'] = "";
  2617. $verifyList [$k] ['status'] = "";
  2618. if (empty ( $verifyStaff )) {
  2619. $verifyList [$k] ['date'] = "";
  2620. $verifyList [$k] ['opinion'] = "";
  2621. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2622. $verifyList [$k] ['status'] = 4;
  2623. $flag = false;
  2624. }
  2625. } else {
  2626. foreach ( $verifyStaff as $m => $u ) {
  2627. if ($v [0] == $m) {
  2628. $verifyList [$k] ['date'] = $u ['date'];
  2629. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2630. $verifyList [$k] ['status'] = $u ['status'];
  2631. $flag = false;
  2632. break;
  2633. }
  2634. }
  2635. $endStaffArray = end ( $verifyStaff );
  2636. if (isset ( $endStaffArray ['ROLE'] )) {
  2637. } else {
  2638. // $endKey=key($verifyStaff);
  2639. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2640. // $button=4;
  2641. // $verifyList[$k]['status']=4;
  2642. // }
  2643. }
  2644. }
  2645. }
  2646. $rolename ['name'] = '';
  2647. if (! empty ( $roleId )) {
  2648. Doo::loadModel ( 'role' );
  2649. $role = new role ();
  2650. $rolename = $role->getOne ( array (
  2651. 'where' => 'rid=' . $roleId,
  2652. 'asArray' => true
  2653. ) );
  2654. }
  2655. if (! empty ( $verifyStaff ))
  2656. $endStaffArray = end ( $verifyStaff );
  2657. $KOP = false;
  2658. foreach ( $roleArrayCopy as $P => $A ) {
  2659. foreach ( $A as $MKI => $AVL ) {
  2660. if (! empty ( $verifyStaff )) {
  2661. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2662. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2663. $button = 4;
  2664. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2665. }
  2666. foreach ( $verifyStaff as $m => $u ) {
  2667. $AVLFK = $AVL [0] . '_R';
  2668. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2669. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2670. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2671. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2672. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2673. break;
  2674. }
  2675. }
  2676. } else {
  2677. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2678. $button = 4;
  2679. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2680. }
  2681. }
  2682. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2683. $KOP = true;
  2684. }
  2685. }
  2686. foreach ( $roleArrayCopy as $k => $v ) {
  2687. foreach ( $verifyList as $m => $n ) {
  2688. if ($n [0] == $k) {
  2689. array_splice ( $verifyList, $m, 1, $v );
  2690. }
  2691. }
  2692. }
  2693. $loanList [$key] ['verifyList'] = $verifyList;
  2694. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  2695. 'where' => 'sid=' . $value ['staff'],
  2696. 'asArray' => true
  2697. ) );
  2698. $loanList [$key] ['button'] = $button;
  2699. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  2700. }
  2701. $data ['loanList'] = $loanList;
  2702. // print_r($loanList);
  2703. $Locate = 0;
  2704. $roleId = 0;
  2705. $button = 0;
  2706. foreach ( $receiptList as $key => $value ) {
  2707. $receiptList [$key] ['Locate'] = $Locate;
  2708. $Locate ++;
  2709. $receiptList [$key] ['reviseDetail'] = array ();
  2710. if (! empty ( $value ['reviseDetail'] ))
  2711. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2712. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2713. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2714. $categoryDetil = $Lcategory->getOne ( array (
  2715. 'where' => 'cid=' . $value ['cid'],
  2716. 'asArray' => true
  2717. ) );
  2718. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2719. // 检测编辑状态
  2720. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  2721. $verifyList ['staff'] = $value ['verifyBreakup'];
  2722. } else
  2723. $verifyList = $verify->getOne ( array (
  2724. 'where' => 'vid=' . $value ['verify'],
  2725. 'asArray' => true
  2726. ) );
  2727. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2728. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2729. Doo::loadModel ( 'role' );
  2730. $role = new role ();
  2731. if ($verifyList == NULL)
  2732. $verifyList = array ();
  2733. $flag = true;
  2734. $roleKey = 0;
  2735. $endStaffArray = array ();
  2736. $roleArrayCopy = array ();
  2737. foreach ( $verifyList as $k => $v ) {
  2738. // init verifyStaff
  2739. if ($v [1] == 'ROLE') {
  2740. if (! empty ( $verifyStaff )) {
  2741. $endStaffArray = end ( $verifyStaff );
  2742. // if ($v[0]==$endStaffArray['nextStaff']){
  2743. // $roleId=$v[0];
  2744. // }
  2745. }
  2746. $roleVerify = json_decode ( $v [3], true );
  2747. $roleKey = $k;
  2748. $roleArray = array ();
  2749. $rolename = $role->getOne ( array (
  2750. 'where' => 'rid=' . $v [0],
  2751. 'asArray' => true
  2752. ) );
  2753. foreach ( $roleVerify as $o => $p ) {
  2754. $staffID = explode ( '_', $p );
  2755. $staffInfo = $staff->getOne ( array (
  2756. 'where' => 'sid=' . $staffID [0],
  2757. 'asArray' => true
  2758. ) );
  2759. // print_r($staffID);
  2760. $exp = array (
  2761. 0 => $staffInfo ['sid'],
  2762. 1 => $staffID [1],
  2763. 2 => $staffInfo ['avatar'],
  2764. 'date' => '',
  2765. 'date' => '',
  2766. 'opinion' => '',
  2767. 'status' => '',
  2768. 'rolename' => $rolename ['name']
  2769. );
  2770. array_push ( $roleArray, $exp );
  2771. }
  2772. $roleArrayCopy [$v [0]] = $roleArray;
  2773. // $verifyList[$k]['roleArray']=$roleArray;
  2774. }
  2775. $verifyList [$k] ['date'] = "";
  2776. $verifyList [$k] ['opinion'] = "";
  2777. $verifyList [$k] ['status'] = "";
  2778. if (empty ( $verifyStaff )) {
  2779. $verifyList [$k] ['date'] = "";
  2780. $verifyList [$k] ['opinion'] = "";
  2781. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2782. $verifyList [$k] ['status'] = 4;
  2783. $flag = false;
  2784. }
  2785. } else {
  2786. foreach ( $verifyStaff as $m => $u ) {
  2787. if ($v [0] == $m) {
  2788. $verifyList [$k] ['date'] = $u ['date'];
  2789. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2790. $verifyList [$k] ['status'] = $u ['status'];
  2791. $flag = false;
  2792. break;
  2793. }
  2794. }
  2795. $endStaffArray = end ( $verifyStaff );
  2796. if (isset ( $endStaffArray ['ROLE'] )) {
  2797. } else {
  2798. // $endKey=key($verifyStaff);
  2799. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2800. // $button=4;
  2801. // $verifyList[$k]['status']=4;
  2802. // }
  2803. }
  2804. }
  2805. }
  2806. $rolename ['name'] = '';
  2807. if (! empty ( $roleId )) {
  2808. Doo::loadModel ( 'role' );
  2809. $role = new role ();
  2810. $rolename = $role->getOne ( array (
  2811. 'where' => 'rid=' . $roleId,
  2812. 'asArray' => true
  2813. ) );
  2814. }
  2815. if (! empty ( $verifyStaff ))
  2816. $endStaffArray = end ( $verifyStaff );
  2817. $KOP = false;
  2818. foreach ( $roleArrayCopy as $P => $A ) {
  2819. foreach ( $A as $MKI => $AVL ) {
  2820. if (! empty ( $verifyStaff )) {
  2821. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2822. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2823. $button = 4;
  2824. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2825. }
  2826. foreach ( $verifyStaff as $m => $u ) {
  2827. $AVLFK = $AVL [0] . '_R';
  2828. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2829. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2830. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2831. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2832. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2833. break;
  2834. }
  2835. }
  2836. } else {
  2837. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2838. $button = 4;
  2839. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2840. }
  2841. }
  2842. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2843. $KOP = true;
  2844. }
  2845. }
  2846. foreach ( $roleArrayCopy as $k => $v ) {
  2847. foreach ( $verifyList as $m => $n ) {
  2848. if ($n [0] == $k) {
  2849. array_splice ( $verifyList, $m, 1, $v );
  2850. }
  2851. }
  2852. }
  2853. // 费用执行人相关数据
  2854. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2855. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2856. foreach ( $executeCopy as $k => $v ) {
  2857. $executeCopy [$k] ['date'] = '';
  2858. $executeCopy [$k] ['opinion'] = '';
  2859. $executeCopy [$k] ['status'] = '';
  2860. if (! empty ( $executeStaff ))
  2861. foreach ( $executeStaff as $m => $u ) {
  2862. if ($v [0] == $m) {
  2863. $executeCopy [$k] ['date'] = $u ['date'];
  2864. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2865. $executeCopy [$k] ['status'] = $u ['status'];
  2866. break;
  2867. }
  2868. }
  2869. }
  2870. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2871. $receiptList [$key] ['verifyList'] = $verifyList;
  2872. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2873. 'where' => 'sid=' . $value ['staff'],
  2874. 'asArray' => true
  2875. ) );
  2876. $receiptList [$key] ['button'] = $button;
  2877. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2878. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2879. $relust = $value ['sum'] - $value ['loanSum'];
  2880. $receiptList [$key] ['relust'] = $relust;
  2881. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2882. }
  2883. // print_r($receiptList);
  2884. // 获取审批日志
  2885. Doo::loadModel ( 'receiptLog' );
  2886. $receiptLog = new receiptLog ();
  2887. $rlList = array ();
  2888. $rlInfo = $receiptLog->getOne ( array (
  2889. 'where' => 'rid=' . $rid . ' and status=4',
  2890. 'asArray' => true
  2891. ) );
  2892. $tijdate = $receiptLog->getOne ( array (
  2893. 'where' => 'rid=' . $rid . ' and status=2',
  2894. 'asc' => 'rlid',
  2895. 'asArray' => true
  2896. ) );
  2897. if (! empty ( $rlInfo )) {
  2898. $rlList = $receiptLog->find ( array (
  2899. 'where' => 'rid=' . $rid,
  2900. 'asc' => 'rlid',
  2901. 'asArray' => true
  2902. ) );
  2903. }
  2904. Doo::loadModel ( 'enclosur' );
  2905. $enclosur = new enclosur ();
  2906. $enclosurList = $enclosur->find ( array (
  2907. 'where' => 'rid=' . $rid,
  2908. 'asArray' => true
  2909. ) );
  2910. $enclosurHtml = '';
  2911. foreach ( $enclosurList as $value ) {
  2912. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2913. }
  2914. $data ['enclosurHtml'] = $enclosurHtml;
  2915. $receiptList [0] ['rlList'] = $rlList;
  2916. $data ['receiptList'] = $receiptList;
  2917. //print_r($receiptList);
  2918. $data ['memu'] = "receipt";
  2919. $data ['staff'] = $this->staff;
  2920. $data ['receiptMemu'] = 'approvalExpenses';
  2921. $data ['verifyId'] = $this->verifyId;
  2922. $data ['executeId'] = $this->executeId;
  2923. $this->render ( "/admin/expensesDoc", $data );
  2924. }
  2925. function expensesEdi() {
  2926. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2927. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  2928. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2929. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2930. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2931. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2932. if (empty ( $status ))
  2933. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  2934. $vidList = array ();
  2935. $button = 0;
  2936. Doo::loadModel ( 'verify' );
  2937. Doo::loadModel ( 'receipt' );
  2938. Doo::loadModel ( 'staff' );
  2939. $staff = new staff ();
  2940. $receipt = new receipt ();
  2941. $verify = new verify ();
  2942. Doo::loadModel ( 'L_category' );
  2943. $Lcategory = new L_category ();
  2944. Doo::loadModel ( 'enclosur' );
  2945. $enclosur = new enclosur ();
  2946. // user verify ID
  2947. $verifyDetail = $verify->find ( array (
  2948. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  2949. 'asArray' => true
  2950. ) );
  2951. foreach ( $verifyDetail as $key => $value ) {
  2952. array_push ( $vidList, $value ['vid'] );
  2953. }
  2954. $vid = implode ( ",", $vidList );
  2955. if (empty ( $verifyDetail ))
  2956. $vid = 0;
  2957. $categoryList = $Lcategory->find ( array (
  2958. 'asArray' => true
  2959. ) );
  2960. $staffList = $staff->find ( array (
  2961. 'where' => 'cid=' . $cid,
  2962. 'asArray' => true
  2963. ) );
  2964. $ap = "";
  2965. if ($status == 4) {
  2966. $ap = 4;
  2967. $status = 2;
  2968. }
  2969. // get Receipt By verifyID status 2
  2970. $receiptList = $receipt->find ( array (
  2971. 'where' => 'rid =' . $rid . ' and status=2',
  2972. 'desc' => 'rid',
  2973. 'asArray' => true
  2974. ) );
  2975. if (empty ( $receiptList )) {
  2976. die ( 'illegal request' );
  2977. }
  2978. $Locate = 0;
  2979. $roleId = 0;
  2980. if ($ap == 4)
  2981. $status = 4;
  2982. foreach ( $receiptList as $key => $value ) {
  2983. $receiptList [$key] ['Locate'] = $Locate;
  2984. $Locate ++;
  2985. $receiptList [$key] ['reviseDetail'] = array ();
  2986. if (! empty ( $value ['reviseDetail'] ))
  2987. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2988. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2989. $categoryDetil = $Lcategory->getOne ( array (
  2990. 'where' => 'cid=' . $value ['cid'],
  2991. 'asArray' => true
  2992. ) );
  2993. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2994. // 检测编辑状态
  2995. $verifyList = $verify->getOne ( array (
  2996. 'where' => 'vid=' . $value ['verify'],
  2997. 'asArray' => true
  2998. ) );
  2999. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3000. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3001. Doo::loadModel ( 'role' );
  3002. $role = new role ();
  3003. // print_r($verifyList);
  3004. $flag = true;
  3005. $roleKey = 0;
  3006. $endStaffArray = array ();
  3007. $roleArrayCopy = array ();
  3008. foreach ( $verifyList as $k => $v ) {
  3009. // init verifyStaff
  3010. if ($v [1] == 'ROLE') {
  3011. if (! empty ( $verifyStaff )) {
  3012. $endStaffArray = end ( $verifyStaff );
  3013. if ($v [0] == $endStaffArray ['nextStaff']) {
  3014. $roleId = $v [0];
  3015. }
  3016. }
  3017. $roleVerify = json_decode ( $v [3], true );
  3018. $roleKey = $k;
  3019. $roleArray = array ();
  3020. $rolename = $role->getOne ( array (
  3021. 'where' => 'rid=' . $v [0],
  3022. 'asArray' => true
  3023. ) );
  3024. foreach ( $roleVerify as $o => $p ) {
  3025. $staffID = explode ( '_', $p );
  3026. $staffInfo = $staff->getOne ( array (
  3027. 'where' => 'sid=' . $staffID [0],
  3028. 'asArray' => true
  3029. ) );
  3030. // print_r($staffID);
  3031. $exp = array (
  3032. 0 => $staffInfo ['sid'],
  3033. 1 => $staffID [1],
  3034. 2 => $staffInfo ['avatar'],
  3035. 'date' => '',
  3036. 'date' => '',
  3037. 'opinion' => '',
  3038. 'status' => '',
  3039. 'rolename' => $rolename ['name']
  3040. );
  3041. array_push ( $roleArray, $exp );
  3042. }
  3043. $roleArrayCopy [$v [0]] = $roleArray;
  3044. // $verifyList[$k]['roleArray']=$roleArray;
  3045. }
  3046. // print_r($roleArray);
  3047. $verifyList [$k] ['date'] = "";
  3048. $verifyList [$k] ['opinion'] = "";
  3049. $verifyList [$k] ['status'] = "";
  3050. if (empty ( $verifyStaff )) {
  3051. $verifyList [$k] ['date'] = "";
  3052. $verifyList [$k] ['opinion'] = "";
  3053. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3054. $verifyList [$k] ['status'] = 4;
  3055. $button = 4;
  3056. $flag = false;
  3057. }
  3058. } else {
  3059. foreach ( $verifyStaff as $m => $u ) {
  3060. if ($v [0] == $m) {
  3061. $verifyList [$k] ['date'] = $u ['date'];
  3062. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3063. $verifyList [$k] ['status'] = $u ['status'];
  3064. $flag = false;
  3065. break;
  3066. }
  3067. }
  3068. $endStaffArray = end ( $verifyStaff );
  3069. if (isset ( $endStaffArray ['ROLE'] )) {
  3070. } else {
  3071. $endKey = key ( $verifyStaff );
  3072. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  3073. $button = 4;
  3074. $verifyList [$k] ['status'] = 4;
  3075. }
  3076. }
  3077. }
  3078. }
  3079. $rolename ['name'] = '';
  3080. if (! empty ( $roleId )) {
  3081. Doo::loadModel ( 'role' );
  3082. $role = new role ();
  3083. $rolename = $role->getOne ( array (
  3084. 'where' => 'rid=' . $roleId,
  3085. 'asArray' => true
  3086. ) );
  3087. }
  3088. if (! empty ( $verifyStaff ))
  3089. $endStaffArray = end ( $verifyStaff );
  3090. $KOP = false;
  3091. foreach ( $roleArrayCopy as $P => $A ) {
  3092. foreach ( $A as $MKI => $AVL ) {
  3093. if (! empty ( $verifyStaff )) {
  3094. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3095. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3096. $button = 4;
  3097. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3098. }
  3099. foreach ( $verifyStaff as $m => $u ) {
  3100. $AVLFK = $AVL [0] . '_R';
  3101. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3102. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3103. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3104. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3105. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3106. break;
  3107. }
  3108. }
  3109. } else {
  3110. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3111. $button = 4;
  3112. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3113. }
  3114. }
  3115. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3116. $KOP = true;
  3117. }
  3118. }
  3119. // print_r($roleArrayCopy);
  3120. // echo $roleKey;
  3121. foreach ( $roleArrayCopy as $k => $v ) {
  3122. foreach ( $verifyList as $m => $n ) {
  3123. if ($n [0] == $k) {
  3124. array_splice ( $verifyList, $m, 1, $v );
  3125. }
  3126. }
  3127. }
  3128. $receiptList [$key] ['verifyList'] = $verifyList;
  3129. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3130. 'where' => 'sid=' . $value ['staff'],
  3131. 'asArray' => true
  3132. ) );
  3133. $receiptList [$key] ['button'] = $button;
  3134. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  3135. }
  3136. // $data['verifyDetail']=$verifyDetail;
  3137. $mothHtml = "";
  3138. for($i = 1; $i <= 12; $i ++) {
  3139. if ($month == $i)
  3140. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3141. else
  3142. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3143. }
  3144. // 获取审批日志
  3145. Doo::loadModel ( 'receiptLog' );
  3146. $receiptLog = new receiptLog ();
  3147. $rlList = array ();
  3148. $rlInfo = $receiptLog->getOne ( array (
  3149. 'where' => 'rid=' . $rid . ' and status=4',
  3150. 'asArray' => true
  3151. ) );
  3152. $tijdate = $receiptLog->getOne ( array (
  3153. 'where' => 'rid=' . $rid . ' and status=2',
  3154. 'asc' => 'rlid',
  3155. 'asArray' => true
  3156. ) );
  3157. if (! empty ( $rlInfo )) {
  3158. $rlList = $receiptLog->find ( array (
  3159. 'where' => 'rid=' . $rid,
  3160. 'asc' => 'rlid',
  3161. 'asArray' => true
  3162. ) );
  3163. }
  3164. $receiptList [0] ['rlList'] = $rlList;
  3165. $enclosurList = $enclosur->find ( array (
  3166. 'where' => 'rid=' . $rid,
  3167. 'asArray' => true
  3168. ) );
  3169. $enclosurHtml = '';
  3170. foreach ( $enclosurList as $value ) {
  3171. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3172. }
  3173. // print_r($receiptList);
  3174. $data ['rid'] = $rid;
  3175. $data ['enclosurHtml'] = $enclosurHtml;
  3176. $data ['rolename'] = $rolename ['name'];
  3177. $data ['datetij'] = $tijdate ['date'];
  3178. $data ['mothHtml'] = $mothHtml;
  3179. $data ['receiptList'] = $receiptList;
  3180. $data ['receiptApprovalCount'] = count ( $receiptList );
  3181. $data ['status'] = $status;
  3182. $data ['year'] = $year;
  3183. $data ['categoryList'] = $categoryList;
  3184. $data ['staffList'] = $staffList;
  3185. $data ['cid'] = $cid;
  3186. $data ['sid'] = $sid;
  3187. $data ['ap'] = $ap;
  3188. $data ['memu'] = "receipt";
  3189. $data ['staff'] = $this->staff;
  3190. $data ['receiptMemu'] = 'approvalExpenses';
  3191. $data ['verifyId'] = $this->verifyId;
  3192. $data ['executeId'] = $this->executeId;
  3193. $this->render ( "/admin/expensesEdi", $data );
  3194. }
  3195. function expensesDefray() {
  3196. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3197. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3198. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3199. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  3200. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  3201. if (! empty ( $rid )) {
  3202. Doo::loadModel ( "verify" );
  3203. $verify = new verify ();
  3204. Doo::loadModel ( "receiptDetail" );
  3205. $receiptDetailObj = new receiptDetail ();
  3206. Doo::loadModel ( "itemStatistics" );
  3207. Doo::loadModel ( "statistics" );
  3208. $statistics = new statistics ();
  3209. $itemStatistics = new itemStatistics ();
  3210. Doo::loadModel ( "receipt" );
  3211. $receipt = new receipt ();
  3212. Doo::loadModel ( "loanReceipt" );
  3213. $loanReceipt = new loanReceipt ();
  3214. $receiptDetail = $receipt->getOne ( array (
  3215. 'where' => 'rid=' . $rid . ' and status=2 ',
  3216. 'asArray' => true
  3217. ) );
  3218. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  3219. $nsflag = true;
  3220. foreach ( $nslist as $value ) {
  3221. if ($value == $this->staff ['0'] ['sid']) {
  3222. $nsflag = false;
  3223. break;
  3224. }
  3225. }
  3226. // print_r($nslist);die;
  3227. if (empty ( $receiptDetail ) || $nsflag)
  3228. return "/approvalExpenses/pendApproval";
  3229. $verifyDetail = $verify->getOne ( array (
  3230. 'where' => ' vid =' . $receiptDetail ['verify'],
  3231. 'asArray' => true
  3232. ) );
  3233. $verifyString = $verifyDetail ['staff'];
  3234. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3235. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  3236. if (empty ( $opinion )) {
  3237. if ($status == 3)
  3238. $opinion = "终止";
  3239. else
  3240. $opinion = "同意支付";
  3241. }
  3242. $nowStaff = 0;
  3243. $nowStaffList = array ();
  3244. if (empty ( $verifyStaff )) {
  3245. // 还需加入是否已经进入角色审批
  3246. if ($verifyDetail [0] [1] == 'ROLE') {
  3247. // print_r($verifyDetail);echo "ddd";
  3248. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3249. foreach ( $vStaffString as $key => $value ) {
  3250. $staffK = explode ( "_", $value );
  3251. if ($staffK [0] != $this->staff [0] ['sid'])
  3252. array_push ( $nowStaffList, $staffK [0] );
  3253. }
  3254. // print_r($verifyDetail);
  3255. // die;
  3256. if (! empty ( $nowStaffList )) {
  3257. $nowStaff = implode ( ',', $nowStaffList );
  3258. $verifyStaff = array (
  3259. $this->staff [0] ['sid'] . "_R" => array (
  3260. 'date' => date ( 'Y-m-d' ),
  3261. 'opinion' => $opinion,
  3262. 'status' => $status,
  3263. 'nextStaff' => $verifyDetail [0] [0],
  3264. 'ROLE' => 1
  3265. )
  3266. );
  3267. } else {
  3268. $nowStaff = $verifyDetail [1] [0];
  3269. $verifyStaff = array (
  3270. $this->staff [0] ['sid'] . "_R" => array (
  3271. 'date' => date ( 'Y-m-d' ),
  3272. 'opinion' => $opinion,
  3273. 'status' => $status,
  3274. 'nextStaff' => $verifyDetail [1] [0]
  3275. )
  3276. );
  3277. }
  3278. } else {
  3279. if ($verifyDetail [1] [1] == 'ROLE') {
  3280. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  3281. // echo "dd";
  3282. foreach ( $vStaffString as $key => $value ) {
  3283. $staffK = explode ( "_", $value );
  3284. array_push ( $nowStaffList, $staffK [0] );
  3285. }
  3286. $nowStaff = implode ( ',', $nowStaffList );
  3287. $verifyStaff = array (
  3288. $this->staff [0] ['sid'] => array (
  3289. 'date' => date ( 'Y-m-d' ),
  3290. 'opinion' => $opinion,
  3291. 'status' => $status,
  3292. 'nextStaff' => $verifyDetail [1] [0],
  3293. 'ROLE' => 1
  3294. )
  3295. );
  3296. } else {
  3297. $nowStaff = $verifyDetail [1] [0];
  3298. $verifyStaff = array (
  3299. $this->staff [0] ['sid'] => array (
  3300. 'date' => date ( 'Y-m-d' ),
  3301. 'opinion' => $opinion,
  3302. 'status' => $status,
  3303. 'nextStaff' => $verifyDetail [1] [0]
  3304. )
  3305. );
  3306. }
  3307. }
  3308. if ($status == 3)
  3309. $verifyStaff = array (
  3310. 'final' => $status,
  3311. $this->staff [0] ['sid'] => array (
  3312. 'date' => date ( 'Y-m-d' ),
  3313. 'opinion' => $opinion,
  3314. 'status' => $status
  3315. )
  3316. );
  3317. $vStaffString = json_encode ( $verifyStaff );
  3318. $receipt->nowStaff = $nowStaff;
  3319. $receipt->verifyStaff = $vStaffString;
  3320. $loanReceipt->nowStaff = $nowStaff;
  3321. $loanReceipt->verifyStaff = $vStaffString;
  3322. } else {
  3323. $VS = end ( $verifyStaff );
  3324. // 非角色审批
  3325. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  3326. $nextStaff = 0;
  3327. $roleSTF = false;
  3328. foreach ( $verifyDetail as $key => $value ) {
  3329. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  3330. if (isset ( $verifyDetail [$key + 1] )) {
  3331. $nextStaff = $verifyDetail [$key + 1] [0];
  3332. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  3333. $roleSTF = true;
  3334. }
  3335. break;
  3336. }
  3337. }
  3338. if (! $roleSTF) {
  3339. $nowStaff = $nextStaff;
  3340. $verifyStaff [$this->staff [0] ['sid']] = array (
  3341. 'date' => date ( 'Y-m-d' ),
  3342. 'opinion' => $opinion,
  3343. 'status' => $status,
  3344. 'nextStaff' => $nextStaff
  3345. );
  3346. } else {
  3347. // 获取角色下的所有用户ID
  3348. $nowStaffList = array ();
  3349. foreach ( $verifyDetail as $vfk ) {
  3350. if ($vfk [1] == 'ROLE') {
  3351. $vStaffString = json_decode ( $vfk [3] );
  3352. foreach ( $vStaffString as $key => $value ) {
  3353. $staffK = explode ( "_", $value );
  3354. array_push ( $nowStaffList, $staffK [0] );
  3355. }
  3356. }
  3357. }
  3358. $nowStaff = implode ( ',', $nowStaffList );
  3359. $verifyStaff [$this->staff [0] ['sid']] = array (
  3360. 'date' => date ( 'Y-m-d' ),
  3361. 'opinion' => $opinion,
  3362. 'status' => $status,
  3363. 'nextStaff' => $nextStaff,
  3364. 'ROLE' => 0
  3365. );
  3366. }
  3367. if ($status == 3) {
  3368. $verifyStaff ['final'] = $status;
  3369. $verifyStaff [$this->staff [0] ['sid']] = array (
  3370. 'date' => date ( 'Y-m-d' ),
  3371. 'opinion' => $opinion,
  3372. 'status' => $status
  3373. );
  3374. }
  3375. $vStaffString = json_encode ( $verifyStaff );
  3376. $receipt->nowStaff = $nowStaff;
  3377. $receipt->verifyStaff = $vStaffString;
  3378. $loanReceipt->nowStaff = $nowStaff;
  3379. $loanReceipt->verifyStaff = $vStaffString;
  3380. }
  3381. // 角色审批
  3382. if (isset ( $VS ['ROLE'] )) {
  3383. // 找出角色人 当前审批角色组
  3384. $verifyJSStaff = array ();
  3385. $nowStaffList2 = array ();
  3386. foreach ( $verifyDetail as $key => $value ) {
  3387. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  3388. $verifyJSStaff = json_decode ( $value [3] );
  3389. foreach ( $verifyJSStaff as $m ) {
  3390. $staffK = explode ( "_", $m );
  3391. array_push ( $nowStaffList2, $staffK [0] );
  3392. }
  3393. // print_r($nowStaffList2);
  3394. }
  3395. }
  3396. $RoleVerifyStaff = array ();
  3397. foreach ( $verifyStaff as $key => $value ) {
  3398. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  3399. foreach ( $nowStaffList2 as $m ) {
  3400. if ($key == $m . "_R")
  3401. $RoleVerifyStaff [$key] = $value;
  3402. }
  3403. }
  3404. }
  3405. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  3406. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  3407. // 下一个审批人ID
  3408. $nextStaff = 0;
  3409. $falg = false;
  3410. foreach ( $verifyDetail as $key => $value ) {
  3411. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  3412. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  3413. $falg = true;
  3414. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  3415. $nowStaffList = array ();
  3416. foreach ( $vStaffString as $v ) {
  3417. $staffK = explode ( "_", $v );
  3418. array_push ( $nowStaffList, $staffK [0] );
  3419. }
  3420. $nowStaff = implode ( ',', $nowStaffList );
  3421. $nextStaff = $verifyDetail [$key + 1] [0];
  3422. } elseif (isset ( $verifyDetail [$key + 1] )) {
  3423. $nextStaff = $verifyDetail [$key + 1] [0];
  3424. $nowStaff = $nextStaff;
  3425. } else
  3426. $nowStaff = '';
  3427. break;
  3428. }
  3429. }
  3430. if ($falg)
  3431. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3432. 'date' => date ( 'Y-m-d' ),
  3433. 'opinion' => $opinion,
  3434. 'status' => $status,
  3435. 'nextStaff' => $nextStaff,
  3436. 'ROLE' => 1
  3437. );
  3438. else
  3439. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3440. 'date' => date ( 'Y-m-d' ),
  3441. 'opinion' => $opinion,
  3442. 'status' => $status,
  3443. 'nextStaff' => $nextStaff
  3444. );
  3445. // print_r($verifyStaff);
  3446. // echo $nowStaff;die;
  3447. } else { // 进入下一个角色或者审批人
  3448. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  3449. //
  3450. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  3451. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3452. 'date' => date ( 'Y-m-d' ),
  3453. 'opinion' => $opinion,
  3454. 'status' => $status,
  3455. 'nextStaff' => $VS ['nextStaff'],
  3456. 'ROLE' => 1
  3457. );
  3458. // print_r($verifyStaff);
  3459. // die;
  3460. }
  3461. if ($status == 3) {
  3462. $verifyStaff ['final'] = $status;
  3463. $verifyStaff [$this->staff [0] ['sid']] = array (
  3464. 'date' => date ( 'Y-m-d' ),
  3465. 'opinion' => $opinion,
  3466. 'status' => $status
  3467. );
  3468. }
  3469. $vStaffString = json_encode ( $verifyStaff );
  3470. $receipt->verifyStaff = $vStaffString;
  3471. $receipt->nowStaff = $nowStaff;
  3472. $loanReceipt->nowStaff = $nowStaff;
  3473. $loanReceipt->verifyStaff = $vStaffString;
  3474. // die;
  3475. // }
  3476. // print_r($verifyStaff);
  3477. // die;
  3478. }
  3479. // print_r($verifyStaff);die;
  3480. }
  3481. // print_r($verifyDetail);
  3482. $roleKey = 0;
  3483. $roleId = 0;
  3484. $verifyDetailCopy = array ();
  3485. foreach ( $verifyDetail as $k => $v ) {
  3486. if ($v [1] == 'ROLE') {
  3487. $roleId = $v [0];
  3488. $roleVerify = json_decode ( $v [3], true );
  3489. $roleKey = $k;
  3490. $roleArray = array ();
  3491. foreach ( $roleVerify as $o => $p ) {
  3492. $staffID = explode ( '_', $p );
  3493. $exp = array (
  3494. 0 => $staffID [0],
  3495. 1 => $staffID [1]
  3496. );
  3497. array_push ( $roleArray, $exp );
  3498. }
  3499. $verifyDetailCopy [$v [0]] = $roleArray;
  3500. }
  3501. }
  3502. // print_r($verifyDetail);
  3503. foreach ( $verifyDetailCopy as $k => $v ) {
  3504. foreach ( $verifyDetail as $m => $n ) {
  3505. if ($n [0] == $k) {
  3506. array_splice ( $verifyDetail, $m, 1, $v );
  3507. }
  3508. }
  3509. }
  3510. // 审批日志
  3511. if (! isset ( $verifyStaff ['final'] )) {
  3512. Doo::loadModel ( "receiptLog" );
  3513. $receiptLog = new receiptLog ();
  3514. if (! empty ( $roleId )) {
  3515. Doo::loadModel ( "role" );
  3516. $role = new role ();
  3517. $roleInfo = $role->getOne ( array (
  3518. 'where' => 'rid=' . $roleId,
  3519. 'asArray' => true
  3520. ) );
  3521. $receiptLog->rolename = $roleInfo ['name'];
  3522. }
  3523. $receiptLog->username = $this->staff [0] ['username'];
  3524. $receiptLog->uid = $this->staff [0] ['sid'];
  3525. $receiptLog->date = date ( "Y-m-d" );
  3526. $receiptLog->opinion = $opinion;
  3527. $receiptLog->img = $this->staff [0] ['avatar'];
  3528. $receiptLog->status = 1;
  3529. $receiptLog->rid = $rid;
  3530. $receiptLog->insert ();
  3531. }
  3532. if (isset ( $verifyStaff ['final'] )) { // rDetail
  3533. $receipt->status = 3;
  3534. $receipt->verifyBreakup = $verifyString;
  3535. $receiptDetailObj->status = 3;
  3536. $receiptDetailObj->update ( array (
  3537. 'where' => 'rid=' . $rid
  3538. ) );
  3539. // 微信企业号通知
  3540. $this->setWXMsg ( $rid, 3 );
  3541. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  3542. $receipt->status = 6;
  3543. $receipt->pastDate = date ( "Y-m-d" );
  3544. $receipt->isBK = 1;
  3545. $loanReceipt->verifyBreakup = $verifyString;
  3546. $loanReceipt->status = 1;
  3547. $loanReceipt->pastDate = date ( "Y-m-d" );
  3548. $loanReceipt->amount = $receiptDetail ['amount'];
  3549. $loanReceipt->update ( array (
  3550. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  3551. ) );
  3552. // 微信企业号通知
  3553. $this->setWXMsg ( $rid, 1 );
  3554. }
  3555. $receipt->amount = $amount;
  3556. $receipt->update ( array (
  3557. 'where' => ' rid = ' . $rid
  3558. ) );
  3559. // 进入下一条审批费用新加需求
  3560. $vidList = array ();
  3561. $verifyDetail = $verify->find ( array (
  3562. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  3563. 'asArray' => true
  3564. ) );
  3565. foreach ( $verifyDetail as $key => $value ) {
  3566. array_push ( $vidList, $value ['vid'] );
  3567. }
  3568. $vid = implode ( ",", $vidList );
  3569. if (empty ( $verifyDetail ))
  3570. $vid = 0;
  3571. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  3572. $receipt = new receipt ();
  3573. $rd = $receipt->getOne ( array (
  3574. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  3575. 'asc' => 'rid',
  3576. 'asArray' => true
  3577. ) );
  3578. if (empty ( $rd )) {
  3579. return '/approvalExpenses/pendApproval';
  3580. }
  3581. if ($rd ['Rtype'] == 1) {
  3582. if ($rd ['isBK'] == 1) {
  3583. return '/receiptburEdi/' . $rd ['rid'];
  3584. } else {
  3585. return '/expensesEdi/' . $rd ['rid'];
  3586. }
  3587. } elseif ($rd ['Rtype'] == 2) {
  3588. return '/remitApproval/' . $rd ['rid'];
  3589. } else {
  3590. return '/receiptburEdi/' . $rd ['rid'];
  3591. }
  3592. // return "/approvalExpenses/pendApproval";
  3593. }
  3594. }
  3595. function ajaxExamineExe() {
  3596. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3597. Doo::loadModel ( 'receipt' );
  3598. $receipt = new receipt ();
  3599. Doo::loadClass ( 'XDeode' );
  3600. $XDeode = new XDeode ( 5 );
  3601. if (! empty ( $rid )) {
  3602. $rLRes = $receipt->find ( array (
  3603. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  3604. 'asArray' => true
  3605. ) );
  3606. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  3607. echo json_encode ( array (
  3608. 'status' => 1,
  3609. 'receipt' => $rLRes [0]
  3610. ) );
  3611. die ();
  3612. }
  3613. echo json_encode ( array (
  3614. 'status' => 0,
  3615. 'receipt' => array ()
  3616. ) );
  3617. die ();
  3618. }
  3619. function implement() {
  3620. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3621. Doo::loadClass ( 'XDeode' );
  3622. $XDeode = new XDeode ( 5 );
  3623. Doo::loadModel ( 'receipt' );
  3624. $receipt = new receipt ();
  3625. Doo::loadModel ( 'L_category' );
  3626. $Lcategory = new L_category ();
  3627. Doo::loadModel ( 'verify' );
  3628. $verify = new verify ();
  3629. Doo::loadModel ( 'staff' );
  3630. $staff = new staff ();
  3631. Doo::loadModel ( "execute" );
  3632. $execute = new execute ();
  3633. $rid = $XDeode->decode ( $rid );
  3634. $receiptList = $receipt->find ( array (
  3635. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  3636. 'desc' => 'rid',
  3637. 'asArray' => true
  3638. ) );
  3639. Doo::loadModel ( 'loanReceipt' );
  3640. $loanReceipt = new loanReceipt ();
  3641. // print_r($receiptList);
  3642. $loanList = array ();
  3643. if (! isset ( $receiptList ))
  3644. $loanList = $loanReceipt->find ( array (
  3645. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3646. 'desc' => 'rid',
  3647. 'asArray' => true
  3648. ) );
  3649. $Locate = 0;
  3650. $roleId = 0;
  3651. $button = 0;
  3652. foreach ( $loanList as $key => $value ) {
  3653. $loanList [$key] ['Locate'] = $Locate;
  3654. $Locate ++;
  3655. $loanList [$key] ['reviseDetail'] = array ();
  3656. if (! empty ( $value ['reviseDetail'] ))
  3657. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3658. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3659. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3660. $categoryDetil = $Lcategory->getOne ( array (
  3661. 'where' => 'cid=' . $value ['cid'],
  3662. 'asArray' => true
  3663. ) );
  3664. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3665. // 检测编辑状态
  3666. $verifyList = $verify->getOne ( array (
  3667. 'where' => 'vid=' . $value ['verify'],
  3668. 'asArray' => true
  3669. ) );
  3670. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3671. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3672. Doo::loadModel ( 'role' );
  3673. $role = new role ();
  3674. $flag = true;
  3675. $roleKey = 0;
  3676. $endStaffArray = array ();
  3677. $roleArrayCopy = array ();
  3678. foreach ( $verifyList as $k => $v ) {
  3679. // init verifyStaff
  3680. if ($v [1] == 'ROLE') {
  3681. if (! empty ( $verifyStaff )) {
  3682. $endStaffArray = end ( $verifyStaff );
  3683. // if ($v[0]==$endStaffArray['nextStaff']){
  3684. // $roleId=$v[0];
  3685. // }
  3686. }
  3687. $roleVerify = json_decode ( $v [3], true );
  3688. $roleKey = $k;
  3689. $roleArray = array ();
  3690. $rolename = $role->getOne ( array (
  3691. 'where' => 'rid=' . $v [0],
  3692. 'asArray' => true
  3693. ) );
  3694. foreach ( $roleVerify as $o => $p ) {
  3695. $staffID = explode ( '_', $p );
  3696. $staffInfo = $staff->getOne ( array (
  3697. 'where' => 'sid=' . $staffID [0],
  3698. 'asArray' => true
  3699. ) );
  3700. // print_r($staffID);
  3701. $exp = array (
  3702. 0 => $staffInfo ['sid'],
  3703. 1 => $staffID [1],
  3704. 2 => $staffInfo ['avatar'],
  3705. 'date' => '',
  3706. 'date' => '',
  3707. 'opinion' => '',
  3708. 'status' => '',
  3709. 'rolename' => $rolename ['name']
  3710. );
  3711. array_push ( $roleArray, $exp );
  3712. }
  3713. $roleArrayCopy [$v [0]] = $roleArray;
  3714. // $verifyList[$k]['roleArray']=$roleArray;
  3715. }
  3716. $verifyList [$k] ['date'] = "";
  3717. $verifyList [$k] ['opinion'] = "";
  3718. $verifyList [$k] ['status'] = "";
  3719. if (empty ( $verifyStaff )) {
  3720. $verifyList [$k] ['date'] = "";
  3721. $verifyList [$k] ['opinion'] = "";
  3722. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3723. $verifyList [$k] ['status'] = 4;
  3724. $flag = false;
  3725. }
  3726. } else {
  3727. foreach ( $verifyStaff as $m => $u ) {
  3728. if ($v [0] == $m) {
  3729. $verifyList [$k] ['date'] = $u ['date'];
  3730. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3731. $verifyList [$k] ['status'] = $u ['status'];
  3732. $flag = false;
  3733. break;
  3734. }
  3735. }
  3736. $endStaffArray = end ( $verifyStaff );
  3737. if (isset ( $endStaffArray ['ROLE'] )) {
  3738. } else {
  3739. // $endKey=key($verifyStaff);
  3740. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3741. // $button=4;
  3742. // $verifyList[$k]['status']=4;
  3743. // }
  3744. }
  3745. }
  3746. }
  3747. $rolename ['name'] = '';
  3748. if (! empty ( $roleId )) {
  3749. Doo::loadModel ( 'role' );
  3750. $role = new role ();
  3751. $rolename = $role->getOne ( array (
  3752. 'where' => 'rid=' . $roleId,
  3753. 'asArray' => true
  3754. ) );
  3755. }
  3756. if (! empty ( $verifyStaff ))
  3757. $endStaffArray = end ( $verifyStaff );
  3758. $KOP = false;
  3759. foreach ( $roleArrayCopy as $P => $A ) {
  3760. foreach ( $A as $MKI => $AVL ) {
  3761. if (! empty ( $verifyStaff )) {
  3762. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3763. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3764. $button = 4;
  3765. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3766. }
  3767. foreach ( $verifyStaff as $m => $u ) {
  3768. $AVLFK = $AVL [0] . '_R';
  3769. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3770. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3771. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3772. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3773. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3774. break;
  3775. }
  3776. }
  3777. } else {
  3778. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3779. $button = 4;
  3780. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3781. }
  3782. }
  3783. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3784. $KOP = true;
  3785. }
  3786. }
  3787. foreach ( $roleArrayCopy as $k => $v ) {
  3788. foreach ( $verifyList as $m => $n ) {
  3789. if ($n [0] == $k) {
  3790. array_splice ( $verifyList, $m, 1, $v );
  3791. }
  3792. }
  3793. }
  3794. $loanList [$key] ['verifyList'] = $verifyList;
  3795. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3796. 'where' => 'sid=' . $value ['staff'],
  3797. 'asArray' => true
  3798. ) );
  3799. }
  3800. $data ['loanList'] = $loanList;
  3801. $Locate = 0;
  3802. $roleId = 0;
  3803. $button = 0;
  3804. foreach ( $receiptList as $key => $value ) {
  3805. $button2 = 0;
  3806. $receiptList [$key] ['Locate'] = $Locate;
  3807. $Locate ++;
  3808. $receiptList [$key] ['reviseDetail'] = array ();
  3809. if (! empty ( $value ['reviseDetail'] ))
  3810. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3811. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3812. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3813. $categoryDetil = $Lcategory->getOne ( array (
  3814. 'where' => 'cid=' . $value ['cid'],
  3815. 'asArray' => true
  3816. ) );
  3817. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3818. $executeList = json_decode ( $value ['executeCopy'], true );
  3819. $executeStaff = array ();
  3820. if (! empty ( $value ['executeStaff'] ))
  3821. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3822. if (isset ( $executeList )) {
  3823. foreach ( $executeList as $op => $lo ) {
  3824. $executeList [$op] ['date'] = "";
  3825. $executeList [$op] ['opinion'] = "";
  3826. $executeList [$op] ['status'] = "";
  3827. foreach ( $executeStaff as $m => $u ) {
  3828. if ($lo [0] == $m) {
  3829. $executeList [$op] ['date'] = $u ['date'];
  3830. $executeList [$op] ['opinion'] = $u ['opinion'];
  3831. $executeList [$op] ['status'] = $u ['status'];
  3832. break;
  3833. }
  3834. }
  3835. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  3836. $button2 = 1;
  3837. $executeList [$op] ['status'] = 4;
  3838. }
  3839. }
  3840. }
  3841. // 检测编辑状态
  3842. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3843. $verifyList ['staff'] = $value ['verifyBreakup'];
  3844. } else
  3845. $verifyList = $verify->getOne ( array (
  3846. 'where' => 'vid=' . $value ['verify'],
  3847. 'asArray' => true
  3848. ) );
  3849. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3850. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3851. Doo::loadModel ( 'role' );
  3852. $role = new role ();
  3853. if ($verifyList == NULL)
  3854. $verifyList = array ();
  3855. $flag = true;
  3856. $roleKey = 0;
  3857. $endStaffArray = array ();
  3858. $roleArrayCopy = array ();
  3859. foreach ( $verifyList as $k => $v ) {
  3860. // init verifyStaff
  3861. if ($v [1] == 'ROLE') {
  3862. if (! empty ( $verifyStaff )) {
  3863. $endStaffArray = end ( $verifyStaff );
  3864. // if ($v[0]==$endStaffArray['nextStaff']){
  3865. // $roleId=$v[0];
  3866. // }
  3867. }
  3868. $roleVerify = json_decode ( $v [3], true );
  3869. $roleKey = $k;
  3870. $roleArray = array ();
  3871. $rolename = $role->getOne ( array (
  3872. 'where' => 'rid=' . $v [0],
  3873. 'asArray' => true
  3874. ) );
  3875. foreach ( $roleVerify as $o => $p ) {
  3876. $staffID = explode ( '_', $p );
  3877. $staffInfo = $staff->getOne ( array (
  3878. 'where' => 'sid=' . $staffID [0],
  3879. 'asArray' => true
  3880. ) );
  3881. // print_r($staffID);
  3882. $exp = array (
  3883. 0 => $staffInfo ['sid'],
  3884. 1 => $staffID [1],
  3885. 2 => $staffInfo ['avatar'],
  3886. 'date' => '',
  3887. 'date' => '',
  3888. 'opinion' => '',
  3889. 'status' => '',
  3890. 'rolename' => $rolename ['name']
  3891. );
  3892. array_push ( $roleArray, $exp );
  3893. }
  3894. $roleArrayCopy [$v [0]] = $roleArray;
  3895. // $verifyList[$k]['roleArray']=$roleArray;
  3896. }
  3897. $verifyList [$k] ['date'] = "";
  3898. $verifyList [$k] ['opinion'] = "";
  3899. $verifyList [$k] ['status'] = "";
  3900. if (empty ( $verifyStaff )) {
  3901. $verifyList [$k] ['date'] = "";
  3902. $verifyList [$k] ['opinion'] = "";
  3903. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3904. $verifyList [$k] ['status'] = 4;
  3905. $flag = false;
  3906. }
  3907. } else {
  3908. foreach ( $verifyStaff as $m => $u ) {
  3909. if ($v [0] == $m) {
  3910. $verifyList [$k] ['date'] = $u ['date'];
  3911. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3912. $verifyList [$k] ['status'] = $u ['status'];
  3913. $flag = false;
  3914. break;
  3915. }
  3916. }
  3917. $endStaffArray = end ( $verifyStaff );
  3918. if (isset ( $endStaffArray ['ROLE'] )) {
  3919. } else {
  3920. // $endKey=key($verifyStaff);
  3921. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3922. // $button=4;
  3923. // $verifyList[$k]['status']=4;
  3924. // }
  3925. }
  3926. }
  3927. }
  3928. $rolename ['name'] = '';
  3929. if (! empty ( $roleId )) {
  3930. Doo::loadModel ( 'role' );
  3931. $role = new role ();
  3932. $rolename = $role->getOne ( array (
  3933. 'where' => 'rid=' . $roleId,
  3934. 'asArray' => true
  3935. ) );
  3936. }
  3937. if (! empty ( $verifyStaff ))
  3938. $endStaffArray = end ( $verifyStaff );
  3939. $KOP = false;
  3940. foreach ( $roleArrayCopy as $P => $A ) {
  3941. foreach ( $A as $MKI => $AVL ) {
  3942. if (! empty ( $verifyStaff )) {
  3943. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3944. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3945. $button = 4;
  3946. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3947. }
  3948. foreach ( $verifyStaff as $m => $u ) {
  3949. $AVLFK = $AVL [0] . '_R';
  3950. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3951. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3952. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3953. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3954. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3955. break;
  3956. }
  3957. }
  3958. } else {
  3959. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3960. $button = 4;
  3961. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3962. }
  3963. }
  3964. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3965. $KOP = true;
  3966. }
  3967. }
  3968. foreach ( $roleArrayCopy as $k => $v ) {
  3969. foreach ( $verifyList as $m => $n ) {
  3970. if ($n [0] == $k) {
  3971. array_splice ( $verifyList, $m, 1, $v );
  3972. }
  3973. }
  3974. }
  3975. $receiptList [$key] ['verifyList'] = $verifyList;
  3976. $receiptList [$key] ['executeList'] = $executeList;
  3977. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3978. 'where' => 'sid=' . $value ['staff'],
  3979. 'asArray' => true
  3980. ) );
  3981. $receiptList [$key] ['button2'] = $button2;
  3982. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3983. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3984. $relust = $value ['sum'] - $value ['loanSum'];
  3985. $receiptList [$key] ['relust'] = $relust;
  3986. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  3987. }
  3988. // print_r($receiptList[$key]['executeList']);
  3989. $data ['receiptList'] = $receiptList;
  3990. $data ['memu'] = "receipt";
  3991. $data ['staff'] = $this->staff;
  3992. $data ['receiptMemu'] = 'implement';
  3993. $data ['verifyId'] = $this->verifyId;
  3994. $data ['executeId'] = $this->executeId;
  3995. $this->render ( "/admin/implement", $data );
  3996. }
  3997. function implementDo() {
  3998. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3999. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  4000. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  4001. if (! empty ( $rid ) && $amount != '') {
  4002. Doo::loadModel ( 'receipt' );
  4003. $receipt = new receipt ();
  4004. Doo::loadClass ( 'XDeode' );
  4005. $XDeode = new XDeode ( 5 );
  4006. $rinfo = $receipt->getOne ( array (
  4007. 'where' => 'rid=' . $rid,
  4008. 'asArray' => true
  4009. ) );
  4010. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  4011. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  4012. if (empty ( $executeStaff )) {
  4013. $executeStaff = array (
  4014. $this->staff [0] ['sid'] => array (
  4015. 'date' => date ( 'Y-m-d' ),
  4016. 'opinion' => $implementOpinions,
  4017. 'status' => 1
  4018. )
  4019. );
  4020. } else {
  4021. $executeStaff [$this->staff [0] ['sid']] = array (
  4022. 'date' => date ( 'Y-m-d' ),
  4023. 'opinion' => $implementOpinions,
  4024. 'status' => 1
  4025. );
  4026. }
  4027. if (count ( $executeStaff ) == count ( $executeCopy )) {
  4028. $receipt->executeStaff = json_encode ( $executeStaff );
  4029. $receipt->status = 8;
  4030. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  4031. $receipt->status = 9;
  4032. if ($rinfo ['status'] == 6) {
  4033. $receipt->loanDate = date ( "Y-m-d" );
  4034. }
  4035. $receipt->executeDate = date ( "Y-m-d" );
  4036. } else {
  4037. $receipt->executeStaff = json_encode ( $executeStaff );
  4038. }
  4039. $receipt->amount = $amount;
  4040. $receipt->update ( array (
  4041. 'where' => 'rid=' . $rid
  4042. ) );
  4043. }
  4044. $ridKey = $XDeode->encode ( $rid );
  4045. return "/hisImplement";
  4046. // return "/implement/" . $ridKey . ".html";
  4047. }
  4048. function receiptburEdi() {
  4049. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4050. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  4051. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4052. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4053. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4054. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4055. if (empty ( $status ))
  4056. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  4057. $vidList = array ();
  4058. $button = 0;
  4059. Doo::loadModel ( 'verify' );
  4060. Doo::loadModel ( 'receipt' );
  4061. Doo::loadModel ( 'staff' );
  4062. $staff = new staff ();
  4063. $receipt = new receipt ();
  4064. $verify = new verify ();
  4065. Doo::loadModel ( 'L_category' );
  4066. $Lcategory = new L_category ();
  4067. Doo::loadModel ( 'enclosur' );
  4068. $enclosur = new enclosur ();
  4069. Doo::loadModel ( 'loanReceipt' );
  4070. $loanReceipt = new loanReceipt ();
  4071. // user verify ID
  4072. $verifyDetail = $verify->find ( array (
  4073. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  4074. 'asArray' => true
  4075. ) );
  4076. foreach ( $verifyDetail as $key => $value ) {
  4077. array_push ( $vidList, $value ['vid'] );
  4078. }
  4079. $vid = implode ( ",", $vidList );
  4080. if (empty ( $verifyDetail ))
  4081. $vid = 0;
  4082. $categoryList = $Lcategory->find ( array (
  4083. 'asArray' => true
  4084. ) );
  4085. $staffList = $staff->find ( array (
  4086. 'where' => 'cid=' . $cid,
  4087. 'asArray' => true
  4088. ) );
  4089. $ap = "";
  4090. if ($status == 4) {
  4091. $ap = 4;
  4092. $status = 2;
  4093. }
  4094. // get Receipt By verifyID status 2
  4095. $receiptList = $receipt->find ( array (
  4096. 'where' => 'rid =' . $rid . ' and status=2',
  4097. 'desc' => 'rid',
  4098. 'asArray' => true
  4099. ) );
  4100. if (empty ( $receiptList )) {
  4101. die ( 'illegal request' );
  4102. }
  4103. $loanList = $loanReceipt->find ( array (
  4104. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4105. 'desc' => 'rid',
  4106. 'asArray' => true
  4107. ) );
  4108. $data ['explanation'] = '';
  4109. if (! empty ( $loanList ))
  4110. $data ['explanation'] = $loanList [0] ['explanation'];
  4111. $Locate = 0;
  4112. $roleId = 0;
  4113. $button = 0;
  4114. foreach ( $loanList as $key => $value ) {
  4115. $loanList [$key] ['Locate'] = $Locate;
  4116. $Locate ++;
  4117. $loanList [$key] ['reviseDetail'] = array ();
  4118. if (! empty ( $value ['reviseDetail'] ))
  4119. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4120. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4121. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4122. $categoryDetil = $Lcategory->getOne ( array (
  4123. 'where' => 'cid=' . $value ['cid'],
  4124. 'asArray' => true
  4125. ) );
  4126. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4127. // 检测编辑状态
  4128. $verifyList = $verify->getOne ( array (
  4129. 'where' => 'vid=' . $value ['verify'],
  4130. 'asArray' => true
  4131. ) );
  4132. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4133. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4134. Doo::loadModel ( 'role' );
  4135. $role = new role ();
  4136. $flag = true;
  4137. $roleKey = 0;
  4138. $endStaffArray = array ();
  4139. $roleArrayCopy = array ();
  4140. foreach ( $verifyList as $k => $v ) {
  4141. // init verifyStaff
  4142. if ($v [1] == 'ROLE') {
  4143. if (! empty ( $verifyStaff )) {
  4144. $endStaffArray = end ( $verifyStaff );
  4145. }
  4146. $roleVerify = json_decode ( $v [3], true );
  4147. $roleKey = $k;
  4148. $roleArray = array ();
  4149. $rolename = $role->getOne ( array (
  4150. 'where' => 'rid=' . $v [0],
  4151. 'asArray' => true
  4152. ) );
  4153. foreach ( $roleVerify as $o => $p ) {
  4154. $staffID = explode ( '_', $p );
  4155. $staffInfo = $staff->getOne ( array (
  4156. 'where' => 'sid=' . $staffID [0],
  4157. 'asArray' => true
  4158. ) );
  4159. // print_r($staffID);
  4160. $exp = array (
  4161. 0 => $staffInfo ['sid'],
  4162. 1 => $staffID [1],
  4163. 2 => $staffInfo ['avatar'],
  4164. 'date' => '',
  4165. 'date' => '',
  4166. 'opinion' => '',
  4167. 'status' => '',
  4168. 'rolename' => $rolename ['name']
  4169. );
  4170. array_push ( $roleArray, $exp );
  4171. }
  4172. $roleArrayCopy [$v [0]] = $roleArray;
  4173. // $verifyList[$k]['roleArray']=$roleArray;
  4174. }
  4175. $verifyList [$k] ['date'] = "";
  4176. $verifyList [$k] ['opinion'] = "";
  4177. $verifyList [$k] ['status'] = "";
  4178. if (empty ( $verifyStaff )) {
  4179. $verifyList [$k] ['date'] = "";
  4180. $verifyList [$k] ['opinion'] = "";
  4181. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4182. $verifyList [$k] ['status'] = 4;
  4183. $flag = false;
  4184. }
  4185. } else {
  4186. foreach ( $verifyStaff as $m => $u ) {
  4187. if ($v [0] == $m) {
  4188. $verifyList [$k] ['date'] = $u ['date'];
  4189. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4190. $verifyList [$k] ['status'] = $u ['status'];
  4191. $flag = false;
  4192. break;
  4193. }
  4194. }
  4195. $endStaffArray = end ( $verifyStaff );
  4196. if (isset ( $endStaffArray ['ROLE'] )) {
  4197. } else {
  4198. }
  4199. }
  4200. }
  4201. $rolename ['name'] = '';
  4202. if (! empty ( $roleId )) {
  4203. Doo::loadModel ( 'role' );
  4204. $role = new role ();
  4205. $rolename = $role->getOne ( array (
  4206. 'where' => 'rid=' . $roleId,
  4207. 'asArray' => true
  4208. ) );
  4209. }
  4210. if (! empty ( $verifyStaff ))
  4211. $endStaffArray = end ( $verifyStaff );
  4212. $KOP = false;
  4213. foreach ( $roleArrayCopy as $P => $A ) {
  4214. foreach ( $A as $MKI => $AVL ) {
  4215. if (! empty ( $verifyStaff )) {
  4216. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4217. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4218. $button = 4;
  4219. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4220. }
  4221. foreach ( $verifyStaff as $m => $u ) {
  4222. $AVLFK = $AVL [0] . '_R';
  4223. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4224. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4225. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4226. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4227. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4228. break;
  4229. }
  4230. }
  4231. } else {
  4232. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4233. $button = 4;
  4234. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4235. }
  4236. }
  4237. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4238. $KOP = true;
  4239. }
  4240. }
  4241. foreach ( $roleArrayCopy as $k => $v ) {
  4242. foreach ( $verifyList as $m => $n ) {
  4243. if ($n [0] == $k) {
  4244. array_splice ( $verifyList, $m, 1, $v );
  4245. }
  4246. }
  4247. }
  4248. $loanList [$key] ['verifyList'] = $verifyList;
  4249. }
  4250. $htmlLoan = '';
  4251. if (isset ( $loanList [0] )) {
  4252. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  4253. if ($value ['status'] == 1)
  4254. $htmlLoan .= '<li class="done" >';
  4255. elseif ($value ['status'] == 3)
  4256. $htmlLoan .= '<li class="undone" >';
  4257. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  4258. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  4259. if (isset ( $value ['rolename'] ))
  4260. $htmlLoan .= $value ['rolename'];
  4261. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  4262. }
  4263. $data ['loanDate'] = $loanList [0] ['date'];
  4264. } else {
  4265. $data ['loanReceiptDate'] = ''; // $loanList [0] ['date'];
  4266. }
  4267. $data ['htmlLoan'] = $htmlLoan;
  4268. // $data ['LoanReceipt']=$loanList[0];
  4269. // print_r($loanList);
  4270. $Locate = 0;
  4271. $roleId = 0;
  4272. $button = 0;
  4273. if ($ap == 4)
  4274. $status = 4;
  4275. Doo::loadClass ( 'XDeode' );
  4276. $XDeode = new XDeode ( 5 );
  4277. foreach ( $receiptList as $key => $value ) {
  4278. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4279. $receiptList [$key] ['Locate'] = $Locate;
  4280. $Locate ++;
  4281. $receiptList [$key] ['reviseDetail'] = array ();
  4282. // 调整金额 代码调整
  4283. if (! empty ( $value ['reviseDetail'] )) {
  4284. $reviseDetail = json_decode ( $value ['reviseDetail'], true );
  4285. foreach ( $reviseDetail as $ry => $re ) {
  4286. $reviseDetail [$ry] ['sidKey'] = $XDeode->encode ( $re ['sid'] );
  4287. $reviseDetail [$ry] ['reviseKey'] = $XDeode->encode ( $ry );
  4288. }
  4289. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  4290. // print_r($reviseDetail);
  4291. }
  4292. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4293. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4294. $categoryDetil = $Lcategory->getOne ( array (
  4295. 'where' => 'cid=' . $value ['cid'],
  4296. 'asArray' => true
  4297. ) );
  4298. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4299. // 检测编辑状态
  4300. $verifyList = $verify->getOne ( array (
  4301. 'where' => 'vid=' . $value ['verify'],
  4302. 'asArray' => true
  4303. ) );
  4304. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4305. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4306. Doo::loadModel ( 'role' );
  4307. $role = new role ();
  4308. // print_r($verifyList);
  4309. $flag = true;
  4310. $roleKey = 0;
  4311. $endStaffArray = array ();
  4312. $roleArrayCopy = array ();
  4313. foreach ( $verifyList as $k => $v ) {
  4314. // init verifyStaff
  4315. if ($v [1] == 'ROLE') {
  4316. if (! empty ( $verifyStaff )) {
  4317. $endStaffArray = end ( $verifyStaff );
  4318. if ($v [0] == $endStaffArray ['nextStaff']) {
  4319. $roleId = $v [0];
  4320. }
  4321. }
  4322. $roleVerify = json_decode ( $v [3], true );
  4323. $roleKey = $k;
  4324. $roleArray = array ();
  4325. $rolename = $role->getOne ( array (
  4326. 'where' => 'rid=' . $v [0],
  4327. 'asArray' => true
  4328. ) );
  4329. foreach ( $roleVerify as $o => $p ) {
  4330. $staffID = explode ( '_', $p );
  4331. $staffInfo = $staff->getOne ( array (
  4332. 'where' => 'sid=' . $staffID [0],
  4333. 'asArray' => true
  4334. ) );
  4335. // print_r($staffID);
  4336. $exp = array (
  4337. 0 => $staffInfo ['sid'],
  4338. 1 => $staffID [1],
  4339. 2 => $staffInfo ['avatar'],
  4340. 'date' => '',
  4341. 'date' => '',
  4342. 'opinion' => '',
  4343. 'status' => '',
  4344. 'rolename' => $rolename ['name']
  4345. );
  4346. array_push ( $roleArray, $exp );
  4347. }
  4348. $roleArrayCopy [$v [0]] = $roleArray;
  4349. // $verifyList[$k]['roleArray']=$roleArray;
  4350. }
  4351. // print_r($roleArray);
  4352. $verifyList [$k] ['date'] = "";
  4353. $verifyList [$k] ['opinion'] = "";
  4354. $verifyList [$k] ['status'] = "";
  4355. if (empty ( $verifyStaff )) {
  4356. $verifyList [$k] ['date'] = "";
  4357. $verifyList [$k] ['opinion'] = "";
  4358. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4359. $verifyList [$k] ['status'] = 4;
  4360. $button = 4;
  4361. $flag = false;
  4362. }
  4363. } else {
  4364. foreach ( $verifyStaff as $m => $u ) {
  4365. if ($v [0] == $m) {
  4366. $verifyList [$k] ['date'] = $u ['date'];
  4367. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4368. $verifyList [$k] ['status'] = $u ['status'];
  4369. $flag = false;
  4370. break;
  4371. }
  4372. }
  4373. $endStaffArray = end ( $verifyStaff );
  4374. if (isset ( $endStaffArray ['ROLE'] )) {
  4375. } else {
  4376. $endKey = key ( $verifyStaff );
  4377. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4378. $button = 4;
  4379. $verifyList [$k] ['status'] = 4;
  4380. }
  4381. }
  4382. }
  4383. }
  4384. $rolename ['name'] = '';
  4385. if (! empty ( $roleId )) {
  4386. Doo::loadModel ( 'role' );
  4387. $role = new role ();
  4388. $rolename = $role->getOne ( array (
  4389. 'where' => 'rid=' . $roleId,
  4390. 'asArray' => true
  4391. ) );
  4392. }
  4393. if (! empty ( $verifyStaff ))
  4394. $endStaffArray = end ( $verifyStaff );
  4395. $KOP = false;
  4396. foreach ( $roleArrayCopy as $P => $A ) {
  4397. foreach ( $A as $MKI => $AVL ) {
  4398. if (! empty ( $verifyStaff )) {
  4399. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4400. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4401. $button = 4;
  4402. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4403. }
  4404. foreach ( $verifyStaff as $m => $u ) {
  4405. $AVLFK = $AVL [0] . '_R';
  4406. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4407. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4408. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4409. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4410. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4411. break;
  4412. }
  4413. }
  4414. } else {
  4415. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4416. $button = 4;
  4417. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4418. }
  4419. }
  4420. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4421. $KOP = true;
  4422. }
  4423. }
  4424. foreach ( $roleArrayCopy as $k => $v ) {
  4425. foreach ( $verifyList as $m => $n ) {
  4426. if ($n [0] == $k) {
  4427. array_splice ( $verifyList, $m, 1, $v );
  4428. }
  4429. }
  4430. }
  4431. // print_r($verifyList);
  4432. $receiptList [$key] ['verifyList'] = $verifyList;
  4433. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4434. 'where' => 'sid=' . $value ['staff'],
  4435. 'asArray' => true
  4436. ) );
  4437. $receiptList [$key] ['button'] = $button;
  4438. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4439. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4440. $relust = $value ['sum'] - $value ['loanSum'];
  4441. $receiptList [$key] ['relust'] = $relust;
  4442. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4443. }
  4444. // print_r($receiptList);die;
  4445. // $data['verifyDetail']=$verifyDetail;
  4446. $mothHtml = "";
  4447. for($i = 1; $i <= 12; $i ++) {
  4448. if ($month == $i)
  4449. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4450. else
  4451. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4452. }
  4453. // 获取审批日志
  4454. Doo::loadModel ( 'receiptLog' );
  4455. $receiptLog = new receiptLog ();
  4456. $rlList = array ();
  4457. $rlInfo = $receiptLog->getOne ( array (
  4458. 'where' => 'rid=' . $rid . ' and status=4',
  4459. 'asArray' => true
  4460. ) );
  4461. $tijdate = $receiptLog->getOne ( array (
  4462. 'where' => 'rid=' . $rid . ' and status=2',
  4463. 'asc' => 'rlid',
  4464. 'asArray' => true
  4465. ) );
  4466. if (! empty ( $rlInfo )) {
  4467. $rlList = $receiptLog->find ( array (
  4468. 'where' => 'rid=' . $rid,
  4469. 'asc' => 'rlid',
  4470. 'asArray' => true
  4471. ) );
  4472. }
  4473. // echo $rid;
  4474. // print_r($receiptList);
  4475. $receiptList [0] ['rlList'] = $rlList;
  4476. // print_r($receiptList);
  4477. $enclosurList = $enclosur->find ( array (
  4478. 'where' => 'rid=' . $rid,
  4479. 'asArray' => true
  4480. ) );
  4481. $enclosurHtml = '';
  4482. foreach ( $enclosurList as $value ) {
  4483. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4484. }
  4485. $data ['enclosurHtml'] = $enclosurHtml;
  4486. $data ['rolename'] = $rolename ['name'];
  4487. $data ['mothHtml'] = $mothHtml;
  4488. // print_r($receiptList);
  4489. $data ['rid'] = $rid;
  4490. $data ['tijdate'] = $tijdate ['date'];
  4491. $data ['receiptList'] = $receiptList;
  4492. $data ['receiptApprovalCount'] = count ( $receiptList );
  4493. $data ['status'] = $status;
  4494. $data ['year'] = $year;
  4495. $data ['categoryList'] = $categoryList;
  4496. $data ['staffList'] = $staffList;
  4497. $data ['cid'] = $cid;
  4498. $data ['sid'] = $sid;
  4499. $data ['ap'] = $ap;
  4500. $data ['memu'] = "receipt";
  4501. $data ['staff'] = $this->staff;
  4502. $data ['receiptMemu'] = 'approvalExpenses';
  4503. $data ['verifyId'] = $this->verifyId;
  4504. $data ['executeId'] = $this->executeId;
  4505. $this->render ( "/admin/receiptburEdi", $data );
  4506. }
  4507. function hisImplement() {
  4508. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4509. if (empty ( $item ))
  4510. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "expenses";
  4511. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  4512. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4513. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  4514. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  4515. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  4516. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'pendImplement';
  4517. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  4518. Doo::loadClass ( 'XDeode' );
  4519. $XDeode = new XDeode ( 5 );
  4520. Doo::loadModel ( 'receipt' );
  4521. $receipt = new receipt ();
  4522. Doo::loadModel ( 'L_category' );
  4523. $Lcategory = new L_category ();
  4524. Doo::loadModel ( 'verify' );
  4525. Doo::loadModel ( 'statistics' );
  4526. $statistics = new statistics ();
  4527. $verify = new verify ();
  4528. Doo::loadModel ( 'staff' );
  4529. $staff = new staff ();
  4530. Doo::loadClass ( 'XDeode' );
  4531. $XDeode = new XDeode ( 5 );
  4532. $cid = $XDeode->decode ( $cidKey );
  4533. $condition = "";
  4534. if ($item == "expenses")
  4535. $condition = " and Rtype=1 ";
  4536. elseif ($item == "receipts")
  4537. $condition = " and Rtype=0 ";
  4538. elseif ($item == "remits")
  4539. $condition = " and Rtype=2 ";
  4540. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  4541. $sopString = $cidString = "";
  4542. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  4543. if (empty ( $rdate ))
  4544. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  4545. else
  4546. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  4547. if ($status == 'pendImplement') {
  4548. $condition .= ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  4549. } elseif ($status == 'alerpts') {
  4550. $statusCon = '(status=8 or status=9 )';
  4551. if (empty ( $rdate ))
  4552. $dateCondition .= " and Year(date) =" . $year;
  4553. else
  4554. $dateCondition .= " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  4555. }
  4556. if ($sop != 'SOP')
  4557. $sopString = " and staff=" . $sop;
  4558. if ($cidKey != 'ALL')
  4559. $cidString = " and cid=" . $cid;
  4560. $receiptList = $receipt->find ( array (
  4561. 'where' => $statusCon . $condition . $dateCondition . $sopString . $cidString,
  4562. 'desc' => 'rid',
  4563. 'asArray' => true
  4564. ) );
  4565. // 员工筛选
  4566. $receiptList2 = $receipt->find ( array (
  4567. 'where' => $statusCon . $condition . $dateCondition,
  4568. 'desc' => 'rid',
  4569. 'asArray' => true
  4570. ) );
  4571. $sopStaff = array ();
  4572. foreach ( $receiptList2 as $key => $value ) {
  4573. $staffDetail = $staff->getOne ( array (
  4574. 'select' => 'username',
  4575. 'where' => 'sid=' . $value ['staff'],
  4576. 'asArray' => true
  4577. ) );
  4578. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  4579. }
  4580. // 办事处筛选
  4581. $categoryScreen = array ();
  4582. $categorList = $Lcategory->getCategory ();
  4583. foreach ( $receiptList2 as $key => $value ) {
  4584. foreach ( $categorList as $k => $v ) {
  4585. if ($value ['cid'] == $v ['cid']) {
  4586. $categoryScreen [$v ['cidKey']] = $v ['title'];
  4587. break;
  4588. }
  4589. }
  4590. }
  4591. $categoryScreenHtml = "";
  4592. foreach ( $categoryScreen as $key => $value ) {
  4593. if ($cidKey == $key)
  4594. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4595. else
  4596. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4597. }
  4598. $data ['categoryScreenHtml'] = $categoryScreenHtml;
  4599. $data ['cidKey'] = $cidKey;
  4600. $Locate = 0;
  4601. $roleId = 0;
  4602. $button = 0;
  4603. $staffBatchNumber = 100001;
  4604. $remittanceList = array ();
  4605. foreach ( $receiptList as $key => $value ) {
  4606. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4607. $receiptList [$key] ['Texe'] = 'false';
  4608. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  4609. $receiptList [$key] ['Texe'] = 'true';
  4610. }
  4611. $receiptList [$key] ['TRexe'] = 'true';
  4612. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  4613. $receiptList [$key] ['TRexe'] = 'false';
  4614. }
  4615. $receiptList [$key] ['Locate'] = $Locate;
  4616. $Locate ++;
  4617. $receiptList [$key] ['reviseDetail'] = array ();
  4618. if (! empty ( $value ['reviseDetail'] ))
  4619. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4620. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4621. $categoryDetil = $Lcategory->getOne ( array (
  4622. 'where' => 'cid=' . $value ['cid'],
  4623. 'asArray' => true
  4624. ) );
  4625. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4626. // 检测编辑状态
  4627. $verifyList = $verify->getOne ( array (
  4628. 'where' => 'vid=' . $value ['verify'],
  4629. 'asArray' => true
  4630. ) );
  4631. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4632. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4633. Doo::loadModel ( 'role' );
  4634. $role = new role ();
  4635. $flag = true;
  4636. $roleKey = 0;
  4637. $endStaffArray = array ();
  4638. $roleArrayCopy = array ();
  4639. foreach ( $verifyList as $k => $v ) {
  4640. // init verifyStaff
  4641. if ($v [1] == 'ROLE') {
  4642. if (! empty ( $verifyStaff )) {
  4643. $endStaffArray = end ( $verifyStaff );
  4644. }
  4645. $roleVerify = json_decode ( $v [3], true );
  4646. $roleKey = $k;
  4647. $roleArray = array ();
  4648. $rolename = $role->getOne ( array (
  4649. 'where' => 'rid=' . $v [0],
  4650. 'asArray' => true
  4651. ) );
  4652. foreach ( $roleVerify as $o => $p ) {
  4653. $staffID = explode ( '_', $p );
  4654. $staffInfo = $staff->getOne ( array (
  4655. 'where' => 'sid=' . $staffID [0],
  4656. 'asArray' => true
  4657. ) );
  4658. $exp = array (
  4659. 0 => $staffInfo ['sid'],
  4660. 1 => $staffID [1],
  4661. 2 => $staffInfo ['avatar'],
  4662. 'date' => '',
  4663. 'date' => '',
  4664. 'opinion' => '',
  4665. 'status' => '',
  4666. 'rolename' => $rolename ['name']
  4667. );
  4668. array_push ( $roleArray, $exp );
  4669. }
  4670. $roleArrayCopy [$v [0]] = $roleArray;
  4671. }
  4672. $verifyList [$k] ['date'] = "";
  4673. $verifyList [$k] ['opinion'] = "";
  4674. $verifyList [$k] ['status'] = "";
  4675. if (empty ( $verifyStaff )) {
  4676. $verifyList [$k] ['date'] = "";
  4677. $verifyList [$k] ['opinion'] = "";
  4678. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4679. $verifyList [$k] ['status'] = 4;
  4680. $flag = false;
  4681. }
  4682. } else {
  4683. foreach ( $verifyStaff as $m => $u ) {
  4684. if ($v [0] == $m) {
  4685. $verifyList [$k] ['date'] = $u ['date'];
  4686. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4687. $verifyList [$k] ['status'] = $u ['status'];
  4688. $flag = false;
  4689. break;
  4690. }
  4691. }
  4692. $endStaffArray = end ( $verifyStaff );
  4693. }
  4694. }
  4695. $rolename ['name'] = '';
  4696. if (! empty ( $roleId )) {
  4697. Doo::loadModel ( 'role' );
  4698. $role = new role ();
  4699. $rolename = $role->getOne ( array (
  4700. 'where' => 'rid=' . $roleId,
  4701. 'asArray' => true
  4702. ) );
  4703. }
  4704. if (! empty ( $verifyStaff ))
  4705. $endStaffArray = end ( $verifyStaff );
  4706. $KOP = false;
  4707. foreach ( $roleArrayCopy as $P => $A ) {
  4708. foreach ( $A as $MKI => $AVL ) {
  4709. if (! empty ( $verifyStaff )) {
  4710. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4711. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4712. $button = 4;
  4713. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4714. }
  4715. foreach ( $verifyStaff as $m => $u ) {
  4716. $AVLFK = $AVL [0] . '_R';
  4717. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4718. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4719. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4720. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4721. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4722. break;
  4723. }
  4724. }
  4725. } else {
  4726. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4727. $button = 4;
  4728. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4729. }
  4730. }
  4731. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4732. $KOP = true;
  4733. }
  4734. }
  4735. foreach ( $roleArrayCopy as $k => $v ) {
  4736. foreach ( $verifyList as $m => $n ) {
  4737. if ($n [0] == $k) {
  4738. array_splice ( $verifyList, $m, 1, $v );
  4739. }
  4740. }
  4741. }
  4742. $receiptList [$key] ['verifyList'] = $verifyList;
  4743. $staffDetail = $staff->getOne ( array (
  4744. 'where' => 'sid=' . $value ['staff'],
  4745. 'asArray' => true
  4746. ) );
  4747. $receiptList [$key] ['staffDetail'] = $staffDetail;
  4748. $receiptList [$key] ['button'] = $button;
  4749. // 设置导出汇款execl
  4750. if (! empty ( $value ['remittanceName'] ) && ! empty ( $value ['bankName'] ) && ! empty ( $value ['bankNumber'] )) {
  4751. $remittanceDetail = array (
  4752. $staffBatchNumber,
  4753. $value ['remittanceName'],
  4754. $value ['bankNumber'],
  4755. $value ['bankName'],
  4756. $value ['remittanceBankType'],
  4757. $value ['coupletNumber'],
  4758. $value ['sum']
  4759. );
  4760. array_push ( $remittanceList, $remittanceDetail );
  4761. $staffBatchNumber ++;
  4762. }
  4763. }
  4764. $data ['remittanceList'] = json_encode ( $remittanceList );
  4765. // print_r($receiptList);
  4766. $mothHtml = "";
  4767. for($i = 1; $i <= 12; $i ++) {
  4768. if ($moth == $i)
  4769. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4770. else
  4771. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4772. }
  4773. $dayHtml = "";
  4774. if ($day != "DAY" || $moth != "MONTH") {
  4775. for($i = 1; $i <= 31; $i ++) {
  4776. if ($day == $i)
  4777. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  4778. else
  4779. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  4780. }
  4781. }
  4782. $sopHtml = "";
  4783. foreach ( $sopStaff as $key => $value ) {
  4784. if ($sop == $key)
  4785. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4786. else
  4787. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4788. }
  4789. $data ['status'] = $status;
  4790. $data ['rdate'] = $rdate;
  4791. $data ['sopHtml'] = $sopHtml;
  4792. $data ['dayHtml'] = $dayHtml;
  4793. $data ['mothHtml'] = $mothHtml;
  4794. $data ['receiptList'] = $receiptList;
  4795. $data ['memu'] = "receipt";
  4796. $data ['staff'] = $this->staff;
  4797. $data ['receiptMemu'] = 'implement';
  4798. $data ['verifyId'] = $this->verifyId;
  4799. $data ['executeId'] = $this->executeId;
  4800. $data ['item'] = $item;
  4801. $data ['year'] = $year;
  4802. $data ['moth'] = $moth;
  4803. $data ['day'] = $day;
  4804. $data ['sop'] = $sop;
  4805. $this->render ( "/admin/hisImplement", $data );
  4806. }
  4807. /**
  4808. * 导出汇款信息的exelc
  4809. */
  4810. function exportRemittance() {
  4811. $remittanceInfo = $_POST ['remittanceInfo']; // $this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  4812. if (empty ( $remittanceInfo ))
  4813. die ( 'illegal request' );
  4814. $title = array (
  4815. '员工编号',
  4816. '姓名',
  4817. '员工账号',
  4818. '员工账户开户行',
  4819. '转账类型',
  4820. '联行号',
  4821. '金额'
  4822. );
  4823. $data = json_decode ( $remittanceInfo, true );
  4824. if (empty ( $data ))
  4825. die ( 'illegal request' );
  4826. Doo::loadClass ( 'receipt.func' );
  4827. exportExcel ( $title, $data, '批量日常报销-公司账号', './', true );
  4828. header ( 'Content-Type:text/html;charset=utf-8' );
  4829. die ( '导出' . count ( $data ) . '条数据,<a href="/hisImplement">返回</a>' );
  4830. }
  4831. function ajaxExamine() {
  4832. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4833. Doo::loadModel ( 'receipt' );
  4834. $receipt = new receipt ();
  4835. if (! empty ( $rid )) {
  4836. $rLRes = $receipt->find ( array (
  4837. '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,
  4838. 'asArray' => true
  4839. ) );
  4840. echo json_encode ( array (
  4841. 'status' => 1,
  4842. 'receipt' => $rLRes [0]
  4843. ) );
  4844. die ();
  4845. }
  4846. echo json_encode ( array (
  4847. 'status' => 0,
  4848. 'receipt' => array ()
  4849. ) );
  4850. die ();
  4851. }
  4852. /*
  4853. * 废弃
  4854. */
  4855. function myReceipt() {
  4856. // all approval past withdraw
  4857. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4858. if (empty ( $item ))
  4859. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4860. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4861. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  4862. Doo::loadModel ( 'receipt' );
  4863. $receipt = new receipt ();
  4864. // pre-loaded
  4865. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4866. // have cache
  4867. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  4868. if (! empty ( $moth )) // yearPage
  4869. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  4870. $this->showCache ( $path );
  4871. }
  4872. Doo::loadModel ( 'L_category' );
  4873. $Lcategory = new L_category ();
  4874. Doo::loadModel ( 'verify' );
  4875. Doo::loadModel ( 'statistics' );
  4876. $statistics = new statistics ();
  4877. $verify = new verify ();
  4878. Doo::loadModel ( 'staff' );
  4879. $staff = new staff ();
  4880. $condition = " and status!=0 ";
  4881. if ($item == "approval")
  4882. $condition = " and status=2 ";
  4883. elseif ($item == "withdraw")
  4884. $condition = " and status=3 ";
  4885. elseif ($item == "past")
  4886. $condition = " and status=1 ";
  4887. elseif ($item == "whdw")
  4888. $condition = " and status=4 ";
  4889. $dateCondition = " and Year(date) =" . $year;
  4890. if (! empty ( $moth )) {
  4891. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  4892. $stList = $statistics->getOne ( array (
  4893. 'select' => 'rePrice ,agPrice',
  4894. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  4895. 'asArray' => true
  4896. ) );
  4897. } else
  4898. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  4899. if (empty ( $stList ))
  4900. $stList = array (
  4901. 'rePrice' => 0,
  4902. 'agPrice' => 0
  4903. );
  4904. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  4905. $data ['stList'] = array (
  4906. 'rePrice' => $stList ['rePrice'],
  4907. 'agPrice' => $stList ['agPrice'],
  4908. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  4909. );
  4910. $receiptList = $receipt->find ( array (
  4911. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  4912. 'desc' => 'rid',
  4913. 'asArray' => true
  4914. ) );
  4915. $Locate = 0;
  4916. $roleId = 0;
  4917. $button = 0;
  4918. foreach ( $receiptList as $key => $value ) {
  4919. $receiptList [$key] ['Locate'] = $Locate;
  4920. $Locate ++;
  4921. $receiptList [$key] ['reviseDetail'] = array ();
  4922. if (! empty ( $value ['reviseDetail'] ))
  4923. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4924. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4925. $categoryDetil = $Lcategory->getOne ( array (
  4926. 'where' => 'cid=' . $value ['cid'],
  4927. 'asArray' => true
  4928. ) );
  4929. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4930. // 检测编辑状态
  4931. $verifyList = $verify->getOne ( array (
  4932. 'where' => 'vid=' . $value ['verify'],
  4933. 'asArray' => true
  4934. ) );
  4935. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4936. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4937. Doo::loadModel ( 'role' );
  4938. $role = new role ();
  4939. $flag = true;
  4940. $roleKey = 0;
  4941. $endStaffArray = array ();
  4942. $roleArrayCopy = array ();
  4943. foreach ( $verifyList as $k => $v ) {
  4944. // init verifyStaff
  4945. if ($v [1] == 'ROLE') {
  4946. if (! empty ( $verifyStaff )) {
  4947. $endStaffArray = end ( $verifyStaff );
  4948. // if ($v[0]==$endStaffArray['nextStaff']){
  4949. // $roleId=$v[0];
  4950. // }
  4951. }
  4952. $roleVerify = json_decode ( $v [3], true );
  4953. $roleKey = $k;
  4954. $roleArray = array ();
  4955. $rolename = $role->getOne ( array (
  4956. 'where' => 'rid=' . $v [0],
  4957. 'asArray' => true
  4958. ) );
  4959. foreach ( $roleVerify as $o => $p ) {
  4960. $staffID = explode ( '_', $p );
  4961. $staffInfo = $staff->getOne ( array (
  4962. 'where' => 'sid=' . $staffID [0],
  4963. 'asArray' => true
  4964. ) );
  4965. // print_r($staffID);
  4966. $exp = array (
  4967. 0 => $staffInfo ['sid'],
  4968. 1 => $staffID [1],
  4969. 2 => $staffInfo ['avatar'],
  4970. 'date' => '',
  4971. 'date' => '',
  4972. 'opinion' => '',
  4973. 'status' => '',
  4974. 'rolename' => $rolename ['name']
  4975. );
  4976. array_push ( $roleArray, $exp );
  4977. }
  4978. $roleArrayCopy [$v [0]] = $roleArray;
  4979. // $verifyList[$k]['roleArray']=$roleArray;
  4980. }
  4981. $verifyList [$k] ['date'] = "";
  4982. $verifyList [$k] ['opinion'] = "";
  4983. $verifyList [$k] ['status'] = "";
  4984. if (empty ( $verifyStaff )) {
  4985. $verifyList [$k] ['date'] = "";
  4986. $verifyList [$k] ['opinion'] = "";
  4987. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4988. $verifyList [$k] ['status'] = 4;
  4989. $flag = false;
  4990. }
  4991. } else {
  4992. foreach ( $verifyStaff as $m => $u ) {
  4993. if ($v [0] == $m) {
  4994. $verifyList [$k] ['date'] = $u ['date'];
  4995. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4996. $verifyList [$k] ['status'] = $u ['status'];
  4997. $flag = false;
  4998. break;
  4999. }
  5000. }
  5001. $endStaffArray = end ( $verifyStaff );
  5002. if (isset ( $endStaffArray ['ROLE'] )) {
  5003. } else {
  5004. // $endKey=key($verifyStaff);
  5005. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5006. // $button=4;
  5007. // $verifyList[$k]['status']=4;
  5008. // }
  5009. }
  5010. }
  5011. }
  5012. $rolename ['name'] = '';
  5013. if (! empty ( $roleId )) {
  5014. Doo::loadModel ( 'role' );
  5015. $role = new role ();
  5016. $rolename = $role->getOne ( array (
  5017. 'where' => 'rid=' . $roleId,
  5018. 'asArray' => true
  5019. ) );
  5020. }
  5021. if (! empty ( $verifyStaff ))
  5022. $endStaffArray = end ( $verifyStaff );
  5023. $KOP = false;
  5024. foreach ( $roleArrayCopy as $P => $A ) {
  5025. foreach ( $A as $MKI => $AVL ) {
  5026. if (! empty ( $verifyStaff )) {
  5027. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5028. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5029. $button = 4;
  5030. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5031. }
  5032. foreach ( $verifyStaff as $m => $u ) {
  5033. $AVLFK = $AVL [0] . '_R';
  5034. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5035. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5036. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5037. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5038. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5039. break;
  5040. }
  5041. }
  5042. } else {
  5043. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5044. $button = 4;
  5045. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5046. }
  5047. }
  5048. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5049. $KOP = true;
  5050. }
  5051. }
  5052. foreach ( $roleArrayCopy as $k => $v ) {
  5053. foreach ( $verifyList as $m => $n ) {
  5054. if ($n [0] == $k) {
  5055. array_splice ( $verifyList, $m, 1, $v );
  5056. }
  5057. }
  5058. }
  5059. $receiptList [$key] ['verifyList'] = $verifyList;
  5060. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5061. 'where' => 'sid=' . $value ['staff'],
  5062. 'asArray' => true
  5063. ) );
  5064. $receiptList [$key] ['button'] = $button;
  5065. }
  5066. // print_r($receiptList);die;
  5067. $mothHtml = "";
  5068. for($i = 1; $i <= 12; $i ++) {
  5069. if ($moth == $i)
  5070. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5071. else
  5072. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5073. }
  5074. $data ['mothHtml'] = $mothHtml;
  5075. $data ['receiptList'] = $receiptList;
  5076. $data ['memu'] = "receipt";
  5077. $data ['staff'] = $this->staff;
  5078. $data ['receiptMemu'] = 'receipt';
  5079. $data ['verifyId'] = $this->verifyId;
  5080. $data ['executeId'] = $this->executeId;
  5081. $data ['item'] = $item;
  5082. $data ['year'] = $year;
  5083. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  5084. // sufficient condition to generate cache
  5085. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  5086. $receiptList = $receipt->find ( array (
  5087. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  5088. 'asArray' => true
  5089. ) );
  5090. if (empty ( $receiptList )) { // generated files
  5091. ob_start ();
  5092. $this->render ( "/admin/saea_myList", $data );
  5093. $this->cacheFile ( $path );
  5094. die ();
  5095. // $content = ob_get_contents();
  5096. // $fp = fopen($path, "w");
  5097. // fwrite($fp, $content);
  5098. // fclose($fp);
  5099. }
  5100. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  5101. $receiptList = $receipt->find ( array (
  5102. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  5103. 'asArray' => true
  5104. ) );
  5105. if (empty ( $receiptList )) { // generated files
  5106. ob_start ();
  5107. $this->render ( "/admin/saea_myList", $data );
  5108. $this->cacheFile ( $path );
  5109. die ();
  5110. }
  5111. }
  5112. }
  5113. $this->render ( "/admin/saea_myList", $data );
  5114. }
  5115. function saeaCreate() {
  5116. Doo::loadModel ( 'accountItem' );
  5117. Doo::loadModel ( 'verify' );
  5118. Doo::loadModel ( 'receipt' );
  5119. Doo::loadModel ( 'L_category' );
  5120. $lCategory = new L_category ();
  5121. $receipt = new receipt ();
  5122. $verify = new verify ();
  5123. $accountItem = new accountItem ();
  5124. Doo::loadModel ( "role" );
  5125. $role = new role ();
  5126. $acItem = $accountItem->find ( array (
  5127. 'asArray' => true
  5128. ) );
  5129. $veList = $verify->find ( array (
  5130. 'asArray' => true
  5131. ) );
  5132. foreach ( $veList as $key => $value ) {
  5133. $v = json_decode ( $value ['staff'] );
  5134. $list = array ();
  5135. foreach ( $v as $n => $m ) {
  5136. if ($m ['1'] == 'ROLE') {
  5137. $roleInfo = $role->getOne ( array (
  5138. 'where' => 'rid=' . $m [0],
  5139. 'asArray' => true
  5140. ) );
  5141. $v [$n] [1] = $roleInfo ['name'];
  5142. array_push ( $list, $roleInfo ['name'] );
  5143. } else {
  5144. array_push ( $list, $v [$n] [1] );
  5145. }
  5146. }
  5147. $veList [$key] ['staff'] = implode ( '>', $list );
  5148. }
  5149. $data ['category'] = $lCategory->find ( array (
  5150. 'asArray' => true
  5151. ) );
  5152. $data ['veList'] = $veList;
  5153. $data ['acItem'] = $acItem;
  5154. $data ['memu'] = "receipt";
  5155. $data ['staff'] = $this->staff;
  5156. $data ['receiptMemu'] = 'saeaBorad';
  5157. $data ['verifyId'] = $this->verifyId;
  5158. $data ['executeId'] = $this->executeId;
  5159. $this->render ( "/admin/saea_create", $data );
  5160. }
  5161. function addReceipt() {
  5162. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  5163. $agency = $this->get_args ( 'agency' );
  5164. $travel = $this->get_args ( 'travel' );
  5165. $train = $this->get_args ( 'train' );
  5166. $other = $this->get_args ( 'other' );
  5167. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5168. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5169. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5170. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  5171. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  5172. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  5173. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  5174. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  5175. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  5176. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  5177. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  5178. header ( 'Content-Type:text/html;charset=utf-8' );
  5179. die ( '请填写联行号' );
  5180. }
  5181. Doo::loadModel ( 'receipt' );
  5182. Doo::loadModel ( 'receiptDetail' );
  5183. Doo::loadModel ( 'accountItem' );
  5184. $accountItem = new accountItem ();
  5185. $receipt = new receipt ();
  5186. Doo::loadModel ( 'enclosur' );
  5187. Doo::loadModel ( 'execute' );
  5188. $execute = new execute ();
  5189. $executeDetail = $execute->getOne ( array (
  5190. 'where' => 'mold="报销单执行人"',
  5191. 'asArray' => true
  5192. ) );
  5193. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  5194. // if(!empty($receiptDetail))
  5195. // return "/referReceipt/".$receiptDetail['rid'];
  5196. $aItem = $accountItem->find ( array (
  5197. 'asArray' => true
  5198. ) );
  5199. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5200. $ag = $tr = $ta = $ot = 0;
  5201. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5202. foreach ( $aItem as $key => $value ) {
  5203. if ($value ['category'] == $this->AGENCY) {
  5204. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5205. array_push ( $accountJson [$this->AGENCY], array (
  5206. 'aid' => $value ['aid'],
  5207. 'name' => $value ['name'],
  5208. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5209. ) );
  5210. $sum += $agency [$ag];
  5211. $agencySum += $agency [$ag];
  5212. }
  5213. $ag ++;
  5214. }
  5215. if ($value ['category'] == $this->TRAVEL) {
  5216. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5217. array_push ( $accountJson [$this->TRAVEL], array (
  5218. 'aid' => $value ['aid'],
  5219. 'name' => $value ['name'],
  5220. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5221. ) );
  5222. $sum += $travel [$tr];
  5223. $travelSum += $travel [$tr];
  5224. }
  5225. $tr ++;
  5226. }
  5227. if ($value ['category'] == $this->TRAIN) {
  5228. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5229. array_push ( $accountJson [$this->TRAIN], array (
  5230. 'aid' => $value ['aid'],
  5231. 'name' => $value ['name'],
  5232. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5233. ) );
  5234. $sum += $train [$ta];
  5235. $trainSum += $train [$ta];
  5236. }
  5237. $ta ++;
  5238. }
  5239. if ($value ['category'] == $this->OTHER) {
  5240. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5241. array_push ( $accountJson [$this->OTHER], array (
  5242. 'aid' => $value ['aid'],
  5243. 'name' => $value ['name'],
  5244. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5245. ) );
  5246. $sum += $other [$ot];
  5247. $otherSum += $other [$ot];
  5248. }
  5249. $ot ++;
  5250. }
  5251. }
  5252. $accountJson ['cSum'] = array (
  5253. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5254. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5255. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5256. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5257. );
  5258. // 报销单
  5259. $receipt->accountItem = json_encode ( $accountJson );
  5260. $receipt->staff = $this->staff [0] ['sid'];
  5261. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5262. $receipt->date = date ( "Y-m-d" );
  5263. $receipt->cid = $cid;
  5264. $receipt->status = 5;
  5265. // 修改审批流程加入角色
  5266. $receipt->verify = $verify;
  5267. $receipt->executeCopy = $executeDetail ['staff'];
  5268. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  5269. $receipt->explanation = $explanation;
  5270. $receipt->remittanceName = $remittanceName;
  5271. $receipt->bankName = $bankName;
  5272. $receipt->bankNumber = $bankNumber;
  5273. $receipt->remittanceBankType = $remittanceBankType;
  5274. if ($remittanceBankType == 1)
  5275. $receipt->coupletNumber = $coupletNumber;
  5276. $rid = $receipt->insert ();
  5277. // 附件
  5278. if (! empty ( $enclosurName )) {
  5279. $enclosurArray = explode ( '-', $enclosurName );
  5280. foreach ( $enclosurArray as $value ) {
  5281. $enclosur = new enclosur ();
  5282. $enclosur->name = $value;
  5283. $enclosur->rid = $rid;
  5284. $enclosur->insert ();
  5285. }
  5286. // print_r($enclosurArray);die;
  5287. }
  5288. // 报销详情
  5289. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5290. $receiptDetail = new receiptDetail ();
  5291. $receiptDetail->staff = $this->staff [0] ['sid'];
  5292. $receiptDetail->item = $value ['name'];
  5293. $receiptDetail->itemCategory = $this->AGENCY;
  5294. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5295. $receiptDetail->date = date ( "Y-m-d" );
  5296. $receiptDetail->cid = $cid;
  5297. $receiptDetail->rid = $rid;
  5298. $receiptDetail->status = 4;
  5299. $receiptDetail->insert ();
  5300. }
  5301. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5302. $receiptDetail = new receiptDetail ();
  5303. $receiptDetail->staff = $this->staff [0] ['sid'];
  5304. $receiptDetail->item = $value ['name'];
  5305. $receiptDetail->itemCategory = $this->TRAVEL;
  5306. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5307. $receiptDetail->date = date ( "Y-m-d" );
  5308. $receiptDetail->cid = $cid;
  5309. $receiptDetail->rid = $rid;
  5310. $receiptDetail->status = 4;
  5311. $receiptDetail->insert ();
  5312. }
  5313. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5314. $receiptDetail = new receiptDetail ();
  5315. $receiptDetail->staff = $this->staff [0] ['sid'];
  5316. $receiptDetail->item = $value ['name'];
  5317. $receiptDetail->itemCategory = $this->TRAIN;
  5318. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5319. $receiptDetail->date = date ( "Y-m-d" );
  5320. $receiptDetail->cid = $cid;
  5321. $receiptDetail->rid = $rid;
  5322. $receiptDetail->status = 4;
  5323. $receiptDetail->insert ();
  5324. }
  5325. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5326. $receiptDetail = new receiptDetail ();
  5327. $receiptDetail->staff = $this->staff [0] ['sid'];
  5328. $receiptDetail->item = $value ['name'];
  5329. $receiptDetail->itemCategory = $this->OTHER;
  5330. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5331. $receiptDetail->date = date ( "Y-m-d" );
  5332. $receiptDetail->cid = $cid;
  5333. $receiptDetail->rid = $rid;
  5334. $receiptDetail->status = 4;
  5335. $receiptDetail->insert ();
  5336. }
  5337. return "/saeaBorad";
  5338. } else
  5339. die ( 'illegal request' );
  5340. }
  5341. function referReceipt() {
  5342. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  5343. Doo::loadModel ( 'receipt' );
  5344. Doo::loadModel ( 'verify' );
  5345. $verify = new verify ();
  5346. $receipt = new receipt ();
  5347. Doo::loadModel ( 'L_category' );
  5348. $lCategory = new L_category ();
  5349. Doo::loadModel ( "role" );
  5350. $role = new role ();
  5351. $receiptDetail = $receipt->find ( array (
  5352. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  5353. 'asArray' => true
  5354. ) );
  5355. if (empty ( $receiptDetail ))
  5356. return "/addReceipt";
  5357. foreach ( $receiptDetail as $key => $value ) {
  5358. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5359. $veList = $verify->getOne ( array (
  5360. 'where' => 'vid=' . $value ['verify'],
  5361. 'asArray' => true
  5362. ) );
  5363. $v = json_decode ( $veList ['staff'] );
  5364. array_push ( $v [0], $veList ['description'] );
  5365. foreach ( $v as $n => $m ) {
  5366. if ($m ['1'] == 'ROLE') {
  5367. $roleInfo = $role->getOne ( array (
  5368. 'where' => 'rid=' . $m [0],
  5369. 'asArray' => true
  5370. ) );
  5371. $v [$n] [1] = $roleInfo ['name'];
  5372. }
  5373. }
  5374. $receiptDetail [$key] ['staff'] = $v;
  5375. $category = $lCategory->getOne ( array (
  5376. 'where' => 'cid=' . $value ['cid'],
  5377. 'asArray' => true
  5378. ) );
  5379. $receiptDetail [$key] ['category'] = $category ['title'];
  5380. }
  5381. // print_r($receiptDetail);
  5382. $data ['receiptDetail'] = $receiptDetail;
  5383. $data ['memu'] = "receipt";
  5384. $data ['staff'] = $this->staff;
  5385. $data ['receiptMemu'] = 'saeaCreate';
  5386. $data ['verifyId'] = $this->verifyId;
  5387. $data ['executeId'] = $this->executeId;
  5388. $this->render ( "/admin/saea_confirm", $data );
  5389. }
  5390. function editReceipt() {
  5391. // edit status 4
  5392. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  5393. Doo::loadClass ( 'XDeode' );
  5394. $XDeode = new XDeode ( 7 );
  5395. $rid = $XDeode->decode ( $ridKey );
  5396. if (empty ( $rid ))
  5397. die ( 'illegal request' );
  5398. // echo $rid.'sd';
  5399. Doo::loadModel ( 'accountItem' );
  5400. Doo::loadModel ( 'verify' );
  5401. Doo::loadModel ( 'receipt' );
  5402. $receipt = new receipt ();
  5403. $verify = new verify ();
  5404. $accountItem = new accountItem ();
  5405. Doo::loadModel ( 'L_category' );
  5406. $lCategory = new L_category ();
  5407. Doo::loadModel ( "role" );
  5408. $role = new role ();
  5409. Doo::loadModel ( 'enclosur' );
  5410. $enclosur = new enclosur ();
  5411. $receiptDetail = $receipt->getOne ( array (
  5412. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  5413. 'asArray' => true
  5414. ) );
  5415. if (empty ( $receiptDetail ))
  5416. die ( 'illegal request' );
  5417. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  5418. $acItem = $accountItem->find ( array (
  5419. 'asArray' => true
  5420. ) );
  5421. $veList = $verify->find ( array (
  5422. 'asArray' => true
  5423. ) );
  5424. foreach ( $veList as $key => $value ) {
  5425. $v = json_decode ( $value ['staff'] );
  5426. $list = array ();
  5427. foreach ( $v as $n => $m ) {
  5428. if ($m ['1'] == 'ROLE') {
  5429. $roleInfo = $role->getOne ( array (
  5430. 'where' => 'rid=' . $m [0],
  5431. 'asArray' => true
  5432. ) );
  5433. $v [$n] [1] = $roleInfo ['name'];
  5434. array_push ( $list, $roleInfo ['name'] );
  5435. } else {
  5436. array_push ( $list, $v [$n] [1] );
  5437. }
  5438. }
  5439. $veList [$key] ['staff'] = implode ( '>', $list );
  5440. }
  5441. // 配置编辑信息
  5442. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  5443. foreach ( $acItem as $key => $value ) {
  5444. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  5445. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  5446. $acItem [$key] ['price'] = $v ['price'];
  5447. }
  5448. }
  5449. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  5450. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  5451. $acItem [$key] ['price'] = $v ['price'];
  5452. }
  5453. }
  5454. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  5455. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  5456. $acItem [$key] ['price'] = $v ['price'];
  5457. }
  5458. }
  5459. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  5460. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  5461. $acItem [$key] ['price'] = $v ['price'];
  5462. }
  5463. }
  5464. }
  5465. $data ['category'] = $lCategory->find ( array (
  5466. 'asArray' => true
  5467. ) );
  5468. $data ['cSum'] = $accountItemList ['cSum'];
  5469. $data ['sum'] = $receiptDetail ['sum'];
  5470. $data ['enclosurList'] = $enclosurList;
  5471. $data ['receiptDetail'] = $receiptDetail;
  5472. $data ['veList'] = $veList;
  5473. $data ['acItem'] = $acItem;
  5474. $data ['memu'] = "receipt";
  5475. $data ['staff'] = $this->staff;
  5476. $data ['receiptMemu'] = 'saeaBorad';
  5477. $data ['verify'] = $receiptDetail ['verify'];
  5478. $data ['verifyId'] = $this->verifyId;
  5479. $data ['executeId'] = $this->executeId;
  5480. $data ['rid'] = $ridKey;
  5481. $this->render ( "/admin/saea_edit", $data );
  5482. }
  5483. function updateReceipt() {
  5484. $agency = $this->get_args ( 'agency' );
  5485. $travel = $this->get_args ( 'travel' );
  5486. $train = $this->get_args ( 'train' );
  5487. $other = $this->get_args ( 'other' );
  5488. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5489. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5490. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5491. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  5492. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  5493. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  5494. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  5495. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  5496. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  5497. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  5498. Doo::loadClass ( 'XDeode' );
  5499. $XDeode = new XDeode ( 7 );
  5500. $rid = $XDeode->decode ( $ridKey );
  5501. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  5502. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  5503. header ( 'Content-Type:text/html;charset=utf-8' );
  5504. die ( '请填写联行号' );
  5505. }
  5506. Doo::loadModel ( 'receipt' );
  5507. Doo::loadModel ( 'receiptDetail' );
  5508. Doo::loadModel ( 'accountItem' );
  5509. $accountItem = new accountItem ();
  5510. $receipt = new receipt ();
  5511. Doo::loadModel ( 'enclosur' );
  5512. Doo::loadModel ( 'execute' );
  5513. $execute = new execute ();
  5514. $receiptDetail = $receipt->getOne ( array (
  5515. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  5516. 'asArray' => true
  5517. ) );
  5518. if (empty ( $receiptDetail ))
  5519. return "/saeaBorad";
  5520. if ($receiptDetail ['Rtype'] == 1)
  5521. $executeDetail = $execute->getOne ( array (
  5522. 'where' => 'mold="借款费用执行人"',
  5523. 'asArray' => true
  5524. ) );
  5525. else
  5526. $executeDetail = $execute->getOne ( array (
  5527. 'where' => 'mold="报销单执行人"',
  5528. 'asArray' => true
  5529. ) );
  5530. $aItem = $accountItem->find ( array (
  5531. 'asArray' => true
  5532. ) );
  5533. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5534. $ag = $tr = $ta = $ot = 0;
  5535. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5536. foreach ( $aItem as $key => $value ) {
  5537. if ($value ['category'] == $this->AGENCY) {
  5538. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5539. array_push ( $accountJson [$this->AGENCY], array (
  5540. 'aid' => $value ['aid'],
  5541. 'name' => $value ['name'],
  5542. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5543. ) );
  5544. $sum += $agency [$ag];
  5545. $agencySum += $agency [$ag];
  5546. }
  5547. $ag ++;
  5548. }
  5549. if ($value ['category'] == $this->TRAVEL) {
  5550. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5551. array_push ( $accountJson [$this->TRAVEL], array (
  5552. 'aid' => $value ['aid'],
  5553. 'name' => $value ['name'],
  5554. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5555. ) );
  5556. $sum += $travel [$tr];
  5557. $travelSum += $travel [$tr];
  5558. }
  5559. $tr ++;
  5560. }
  5561. if ($value ['category'] == $this->TRAIN) {
  5562. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5563. array_push ( $accountJson [$this->TRAIN], array (
  5564. 'aid' => $value ['aid'],
  5565. 'name' => $value ['name'],
  5566. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5567. ) );
  5568. $sum += $train [$ta];
  5569. $trainSum += $train [$ta];
  5570. }
  5571. $ta ++;
  5572. }
  5573. if ($value ['category'] == $this->OTHER) {
  5574. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5575. array_push ( $accountJson [$this->OTHER], array (
  5576. 'aid' => $value ['aid'],
  5577. 'name' => $value ['name'],
  5578. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5579. ) );
  5580. $sum += $other [$ot];
  5581. $otherSum += $other [$ot];
  5582. }
  5583. $ot ++;
  5584. }
  5585. }
  5586. $accountJson ['cSum'] = array (
  5587. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5588. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5589. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5590. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5591. );
  5592. // 报销单
  5593. $rid = $receipt->rid = $receiptDetail ['rid'];
  5594. $receipt->accountItem = json_encode ( $accountJson );
  5595. $receipt->staff = $this->staff [0] ['sid'];
  5596. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5597. $receipt->date = date ( "Y-m-d" );
  5598. $receipt->cid = $cid;
  5599. if (($receiptDetail ['status'] != 4)) {
  5600. if ($receiptDetail ['Rtype'] == 1)
  5601. $receipt->status = 7;
  5602. else
  5603. $receipt->status = 5;
  5604. }
  5605. if ($receiptDetail != 4 && ! empty ( $verify ))
  5606. $receipt->verify = $verify;
  5607. $receipt->executeCopy = $executeDetail ['staff'];
  5608. $receipt->explanation = $explanation;
  5609. $receipt->remittanceName = $remittanceName;
  5610. $receipt->bankName = $bankName;
  5611. $receipt->bankNumber = $bankNumber;
  5612. $receipt->remittanceBankType = $remittanceBankType;
  5613. if ($remittanceBankType == 1)
  5614. $receipt->coupletNumber = $coupletNumber;
  5615. $receipt->update ();
  5616. $receiptDetail = new receiptDetail ();
  5617. $receiptDetail->delete ( array (
  5618. 'where' => 'rid=' . $rid
  5619. ) );
  5620. // 报销详情
  5621. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5622. $receiptDetail = new receiptDetail ();
  5623. $receiptDetail->staff = $this->staff [0] ['sid'];
  5624. $receiptDetail->item = $value ['name'];
  5625. $receiptDetail->itemCategory = $this->AGENCY;
  5626. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5627. $receiptDetail->date = date ( "Y-m-d" );
  5628. $receiptDetail->cid = $cid;
  5629. $receiptDetail->rid = $rid;
  5630. $receiptDetail->status = 4;
  5631. $receiptDetail->insert ();
  5632. }
  5633. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5634. $receiptDetail = new receiptDetail ();
  5635. $receiptDetail->staff = $this->staff [0] ['sid'];
  5636. $receiptDetail->item = $value ['name'];
  5637. $receiptDetail->itemCategory = $this->TRAVEL;
  5638. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5639. $receiptDetail->date = date ( "Y-m-d" );
  5640. $receiptDetail->cid = $cid;
  5641. $receiptDetail->rid = $rid;
  5642. $receiptDetail->status = 4;
  5643. $receiptDetail->insert ();
  5644. }
  5645. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5646. $receiptDetail = new receiptDetail ();
  5647. $receiptDetail->staff = $this->staff [0] ['sid'];
  5648. $receiptDetail->item = $value ['name'];
  5649. $receiptDetail->itemCategory = $this->TRAIN;
  5650. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5651. $receiptDetail->date = date ( "Y-m-d" );
  5652. $receiptDetail->cid = $cid;
  5653. $receiptDetail->rid = $rid;
  5654. $receiptDetail->status = 4;
  5655. $receiptDetail->insert ();
  5656. }
  5657. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5658. $receiptDetail = new receiptDetail ();
  5659. $receiptDetail->staff = $this->staff [0] ['sid'];
  5660. $receiptDetail->item = $value ['name'];
  5661. $receiptDetail->itemCategory = $this->OTHER;
  5662. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5663. $receiptDetail->date = date ( "Y-m-d" );
  5664. $receiptDetail->cid = $cid;
  5665. $receiptDetail->rid = $rid;
  5666. $receiptDetail->status = 4;
  5667. $receiptDetail->insert ();
  5668. }
  5669. // 附件
  5670. if (! empty ( $enclosurName )) {
  5671. $enclosurArray = explode ( '-', $enclosurName );
  5672. foreach ( $enclosurArray as $value ) {
  5673. $enclosur = new enclosur ();
  5674. $enclosur->name = $value;
  5675. $enclosur->rid = $rid;
  5676. $enclosur->insert ();
  5677. }
  5678. }
  5679. // return "/referReceipt/".$rid;
  5680. }
  5681. return "/saeaBorad";
  5682. }
  5683. function approvedReceipt() {
  5684. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5685. Doo::loadModel ( 'receipt' );
  5686. Doo::loadModel ( 'receiptDetail' );
  5687. $receipt = new receipt ();
  5688. $receiptDetail = new receiptDetail ();
  5689. Doo::loadModel ( 'statistics' );
  5690. Doo::loadModel ( 'itemStatistics' );
  5691. $statistics = new statistics ();
  5692. $itemStatistics = new itemStatistics ();
  5693. Doo::loadModel ( "verify" );
  5694. $verify = new verify ();
  5695. // 审批状态的判定
  5696. $receiptDetailList = $receipt->getOne ( array (
  5697. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  5698. 'asArray' => true
  5699. ) );
  5700. if (empty ( $receiptDetailList ))
  5701. return "/saeaBorad";
  5702. $verifyDetail = $verify->getOne ( array (
  5703. 'where' => ' vid =' . $receiptDetailList ['verify'],
  5704. 'asArray' => true
  5705. ) );
  5706. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5707. if (empty ( $receiptDetailList ['nowStaff'] )) {
  5708. $nowStaff = "";
  5709. $nowStaffList = array ();
  5710. if ($verifyDetail [0] [1] == 'ROLE') {
  5711. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5712. foreach ( $vStaffString as $key => $value ) {
  5713. $staffK = explode ( "_", $value );
  5714. array_push ( $nowStaffList, $staffK [0] );
  5715. }
  5716. $nowStaff = implode ( ',', $nowStaffList );
  5717. } else {
  5718. $nowStaff = $verifyDetail [0] [0];
  5719. }
  5720. $receipt->nowStaff = $nowStaff;
  5721. }
  5722. // echo $nowStaff;
  5723. // print_r($verifyDetail);die;
  5724. $receipt->rid = $receiptDetailList ['rid'];
  5725. $receipt->date = date ( "Y-m-d" );
  5726. $receipt->status = 2;
  5727. $receipt->update ();
  5728. $receiptDetail->status = 2;
  5729. $receiptDetail->update ( array (
  5730. 'where' => 'rid=' . $receiptDetailList ['rid']
  5731. ) );
  5732. Doo::loadModel ( "receiptLog" );
  5733. $receiptLog = new receiptLog ();
  5734. Doo::loadModel ( "verify" );
  5735. $verify = new verify ();
  5736. $receiptInfo = $receipt->getOne ( array (
  5737. 'where' => 'rid=' . $rid,
  5738. 'asArray' => true
  5739. ) );
  5740. $vr = $verify->getOne ( array (
  5741. 'where' => 'vid=' . $receiptInfo ['verify'],
  5742. 'asArray' => true
  5743. ) );
  5744. $jd = json_decode ( $vr ['staff'] );
  5745. $roleId = 0;
  5746. foreach ( $jd as $key => $value ) {
  5747. if ($value [1] == 'ROLE') {
  5748. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  5749. if ($pos !== false) {
  5750. $roleId = $value [0];
  5751. }
  5752. }
  5753. }
  5754. // 审批日志
  5755. // echo $roleId;die;
  5756. if (! empty ( $roleId )) {
  5757. Doo::loadModel ( "role" );
  5758. $role = new role ();
  5759. $roleInfo = $role->getOne ( array (
  5760. 'where' => 'rid=' . $roleId,
  5761. 'asArray' => true
  5762. ) );
  5763. $receiptLog->rolename = $roleInfo ['name'];
  5764. }
  5765. $receiptLog->username = $this->staff [0] ['username'];
  5766. $receiptLog->uid = $this->staff [0] ['sid'];
  5767. $receiptLog->date = date ( "Y-m-d" );
  5768. $receiptLog->opinion = '提交审批';
  5769. $receiptLog->img = $this->staff [0] ['avatar'];
  5770. $receiptLog->status = 2;
  5771. $receiptLog->rid = $rid;
  5772. $receiptLog->insert ();
  5773. // statistics item
  5774. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  5775. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  5776. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  5777. $stat = $statistics->getOne ( array (
  5778. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5779. 'asArray' => true
  5780. ) );
  5781. if (empty ( $stat )) {
  5782. $statistics->date = date ( "Y-m-d" );
  5783. $statistics->cid = $this->staff [0] ['cid'];
  5784. $statistics->staff = $this->staff [0] ['sid'];
  5785. $statistics->agPrice = 0;
  5786. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5787. $statistics->insert ();
  5788. } else {
  5789. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5790. $statistics->update ( array (
  5791. 'where' => 'sid=' . $stat ['sid']
  5792. ) );
  5793. }
  5794. return "/expenses";
  5795. }
  5796. function approval() {
  5797. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5798. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5799. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5800. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5801. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5802. if (empty ( $status ))
  5803. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5804. $vidList = array ();
  5805. $button = 0;
  5806. Doo::loadModel ( 'verify' );
  5807. $verify = new verify ();
  5808. Doo::loadModel ( 'receipt' );
  5809. $receipt = new receipt ();
  5810. Doo::loadModel ( 'staff' );
  5811. $staff = new staff ();
  5812. Doo::loadModel ( 'L_category' );
  5813. $Lcategory = new L_category ();
  5814. // user verify ID
  5815. $verifyDetail = $verify->find ( array (
  5816. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5817. 'asArray' => true
  5818. ) );
  5819. foreach ( $verifyDetail as $key => $value ) {
  5820. array_push ( $vidList, $value ['vid'] );
  5821. }
  5822. $vid = implode ( ",", $vidList );
  5823. if (empty ( $verifyDetail ))
  5824. $vid = 0;
  5825. /*
  5826. */
  5827. $dateCondition = " and Year(date) =" . $year;
  5828. if (! empty ( $month ))
  5829. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  5830. $categoryList = $Lcategory->find ( array (
  5831. 'asArray' => true
  5832. ) );
  5833. $staffList = $staff->find ( array (
  5834. 'where' => 'cid=' . $cid,
  5835. 'asArray' => true
  5836. ) );
  5837. $cateCondition = "";
  5838. $staffCondition = "";
  5839. $approvalCondition = "";
  5840. if (! empty ( $cid ))
  5841. $cateCondition = ' and cid=' . $cid;
  5842. if (! empty ( $sid )) {
  5843. $staffCondition = ' and staff=' . $sid;
  5844. $cateCondition = "";
  5845. }
  5846. // elseif($status==1){
  5847. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  5848. // }
  5849. if ($status == 2) {
  5850. // 查找角色审批人
  5851. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  5852. }
  5853. $ap = "";
  5854. if ($status == 4) {
  5855. $ap = 4;
  5856. $status = 2;
  5857. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  5858. }
  5859. if ($status == 5) {
  5860. $status = 4;
  5861. $ap = 5;
  5862. }
  5863. // echo $vid;
  5864. // get Receipt By verifyID status 2 .$approvalCondition
  5865. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  5866. $receiptList = $receipt->find ( array (
  5867. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  5868. 'desc' => 'rid',
  5869. 'asArray' => true
  5870. ) );
  5871. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  5872. $Locate = 0;
  5873. if ($ap == 4)
  5874. $status = 4;
  5875. elseif ($ap == 5)
  5876. $status = 5;
  5877. foreach ( $receiptList as $key => $value ) {
  5878. $receiptList [$key] ['Locate'] = $Locate;
  5879. $Locate ++;
  5880. $receiptList [$key] ['reviseDetail'] = array ();
  5881. if (! empty ( $value ['reviseDetail'] ))
  5882. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5883. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5884. $categoryDetil = $Lcategory->getOne ( array (
  5885. 'where' => 'cid=' . $value ['cid'],
  5886. 'asArray' => true
  5887. ) );
  5888. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5889. $verifyList = $verify->getOne ( array (
  5890. 'where' => 'vid=' . $value ['verify'],
  5891. 'asArray' => true
  5892. ) );
  5893. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5894. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5895. foreach ( $verifyList as $k => $v ) {
  5896. // init verifyStaff
  5897. $verifyList [$k] ['date'] = "";
  5898. $verifyList [$k] ['opinion'] = "";
  5899. $verifyList [$k] ['status'] = "";
  5900. if (empty ( $verifyStaff )) {
  5901. $verifyList [$k] ['date'] = "";
  5902. $verifyList [$k] ['opinion'] = "";
  5903. if ($v [0] == $this->staff [0] ['sid']) {
  5904. $verifyList [$k] ['status'] = 4;
  5905. $button = 4;
  5906. }
  5907. } else {
  5908. $flag = true;
  5909. foreach ( $verifyStaff as $m => $u ) {
  5910. if ($v [0] == $m) {
  5911. $verifyList [$k] ['date'] = $u ['date'];
  5912. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5913. $verifyList [$k] ['status'] = $u ['status'];
  5914. $flag = false;
  5915. break;
  5916. }
  5917. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  5918. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  5919. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  5920. }
  5921. if ($flag) { // 检测可编辑
  5922. if ($v [0] == $this->staff [0] ['sid']) {
  5923. $verifyList [$k] ['status'] = 4;
  5924. $button = 4;
  5925. }
  5926. }
  5927. }
  5928. }
  5929. $receiptList [$key] ['verifyList'] = $verifyList;
  5930. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5931. 'where' => 'sid=' . $value ['staff'],
  5932. 'asArray' => true
  5933. ) );
  5934. $receiptList [$key] ['button'] = $button;
  5935. }
  5936. // print_r($receiptList);die;
  5937. // $data['verifyDetail']=$verifyDetail;
  5938. $mothHtml = "";
  5939. for($i = 1; $i <= 12; $i ++) {
  5940. if ($month == $i)
  5941. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5942. else
  5943. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5944. }
  5945. $data ['mothHtml'] = $mothHtml;
  5946. $data ['receiptList'] = $receiptList;
  5947. $data ['receiptApprovalCount'] = count ( $receiptList );
  5948. $data ['status'] = $status;
  5949. $data ['year'] = $year;
  5950. $data ['categoryList'] = $categoryList;
  5951. $data ['staffList'] = $staffList;
  5952. $data ['cid'] = $cid;
  5953. $data ['sid'] = $sid;
  5954. $data ['ap'] = $ap;
  5955. $data ['memu'] = "receipt";
  5956. $data ['staff'] = $this->staff;
  5957. $data ['receiptMemu'] = 'approval';
  5958. $data ['verifyId'] = $this->verifyId;
  5959. $data ['executeId'] = $this->executeId;
  5960. $this->render ( "/admin/saea_reportList", $data );
  5961. }
  5962. function approvalDetails() {
  5963. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5964. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5965. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5966. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5967. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5968. Doo::loadModel ( 'verify' );
  5969. $verify = new verify ();
  5970. Doo::loadModel ( 'receipt' );
  5971. $receipt = new receipt ();
  5972. Doo::loadModel ( 'staff' );
  5973. $staff = new staff ();
  5974. Doo::loadModel ( 'L_category' );
  5975. $Lcategory = new L_category ();
  5976. Doo::loadModel ( 'enclosur' );
  5977. $enclosur = new enclosur ();
  5978. $vidList = array ();
  5979. $verifyDetail = $verify->find ( array (
  5980. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5981. 'asArray' => true
  5982. ) );
  5983. foreach ( $verifyDetail as $key => $value ) {
  5984. array_push ( $vidList, $value ['vid'] );
  5985. }
  5986. $vid = implode ( ",", $vidList );
  5987. if (empty ( $verifyDetail ))
  5988. $vid = 0;
  5989. $categoryList = $Lcategory->find ( array (
  5990. 'asArray' => true
  5991. ) );
  5992. $staffList = $staff->find ( array (
  5993. 'where' => 'cid=' . $cid,
  5994. 'asArray' => true
  5995. ) );
  5996. $ap = 0;
  5997. $receiptList = $receipt->find ( array (
  5998. 'where' => 'rid =' . $rid,
  5999. 'desc' => 'rid',
  6000. 'asArray' => true
  6001. ) );
  6002. $Locate = 0;
  6003. $roleId = 0;
  6004. $button = 0;
  6005. foreach ( $receiptList as $key => $value ) {
  6006. $receiptList [$key] ['Locate'] = $Locate;
  6007. $Locate ++;
  6008. $receiptList [$key] ['reviseDetail'] = array ();
  6009. if (! empty ( $value ['reviseDetail'] ))
  6010. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6011. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6012. $categoryDetil = $Lcategory->getOne ( array (
  6013. 'where' => 'cid=' . $value ['cid'],
  6014. 'asArray' => true
  6015. ) );
  6016. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6017. // 检测编辑状态
  6018. $verifyList = $verify->getOne ( array (
  6019. 'where' => 'vid=' . $value ['verify'],
  6020. 'asArray' => true
  6021. ) );
  6022. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6023. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6024. Doo::loadModel ( 'role' );
  6025. $role = new role ();
  6026. // print_r($verifyList);
  6027. $flag = true;
  6028. $roleKey = 0;
  6029. $endStaffArray = array ();
  6030. $roleArrayCopy = array ();
  6031. foreach ( $verifyList as $k => $v ) {
  6032. // init verifyStaff
  6033. if ($v [1] == 'ROLE') {
  6034. if (! empty ( $verifyStaff )) {
  6035. $endStaffArray = end ( $verifyStaff );
  6036. if ($v [0] == $endStaffArray ['nextStaff']) {
  6037. $roleId = $v [0];
  6038. }
  6039. }
  6040. $roleVerify = json_decode ( $v [3], true );
  6041. $roleKey = $k;
  6042. $roleArray = array ();
  6043. $rolename = $role->getOne ( array (
  6044. 'where' => 'rid=' . $v [0],
  6045. 'asArray' => true
  6046. ) );
  6047. foreach ( $roleVerify as $o => $p ) {
  6048. $staffID = explode ( '_', $p );
  6049. $staffInfo = $staff->getOne ( array (
  6050. 'where' => 'sid=' . $staffID [0],
  6051. 'asArray' => true
  6052. ) );
  6053. // print_r($staffID);
  6054. $exp = array (
  6055. 0 => $staffInfo ['sid'],
  6056. 1 => $staffID [1],
  6057. 2 => $staffInfo ['avatar'],
  6058. 'date' => '',
  6059. 'date' => '',
  6060. 'opinion' => '',
  6061. 'status' => '',
  6062. 'rolename' => $rolename ['name']
  6063. );
  6064. array_push ( $roleArray, $exp );
  6065. }
  6066. $roleArrayCopy [$v [0]] = $roleArray;
  6067. // $verifyList[$k]['roleArray']=$roleArray;
  6068. }
  6069. // print_r($roleArray);
  6070. $verifyList [$k] ['date'] = "";
  6071. $verifyList [$k] ['opinion'] = "";
  6072. $verifyList [$k] ['status'] = "";
  6073. if (empty ( $verifyStaff )) {
  6074. $verifyList [$k] ['date'] = "";
  6075. $verifyList [$k] ['opinion'] = "";
  6076. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6077. $verifyList [$k] ['status'] = 4;
  6078. $button = 4;
  6079. $flag = false;
  6080. }
  6081. } else {
  6082. foreach ( $verifyStaff as $m => $u ) {
  6083. if ($v [0] == $m) {
  6084. $verifyList [$k] ['date'] = $u ['date'];
  6085. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6086. $verifyList [$k] ['status'] = $u ['status'];
  6087. $flag = false;
  6088. break;
  6089. }
  6090. }
  6091. $endStaffArray = end ( $verifyStaff );
  6092. if (isset ( $endStaffArray ['ROLE'] )) {
  6093. } else {
  6094. $endKey = key ( $verifyStaff );
  6095. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6096. $button = 4;
  6097. $verifyList [$k] ['status'] = 4;
  6098. }
  6099. }
  6100. }
  6101. }
  6102. $rolename ['name'] = '';
  6103. if (! empty ( $roleId )) {
  6104. Doo::loadModel ( 'role' );
  6105. $role = new role ();
  6106. $rolename = $role->getOne ( array (
  6107. 'where' => 'rid=' . $roleId,
  6108. 'asArray' => true
  6109. ) );
  6110. }
  6111. if (! empty ( $verifyStaff ))
  6112. $endStaffArray = end ( $verifyStaff );
  6113. $KOP = false;
  6114. foreach ( $roleArrayCopy as $P => $A ) {
  6115. foreach ( $A as $MKI => $AVL ) {
  6116. if (! empty ( $verifyStaff )) {
  6117. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6118. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6119. $button = 4;
  6120. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6121. }
  6122. foreach ( $verifyStaff as $m => $u ) {
  6123. $AVLFK = $AVL [0] . '_R';
  6124. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6125. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6126. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6127. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6128. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6129. break;
  6130. }
  6131. }
  6132. } else {
  6133. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6134. $button = 4;
  6135. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6136. }
  6137. }
  6138. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6139. $KOP = true;
  6140. }
  6141. }
  6142. foreach ( $roleArrayCopy as $k => $v ) {
  6143. foreach ( $verifyList as $m => $n ) {
  6144. if ($n [0] == $k) {
  6145. array_splice ( $verifyList, $m, 1, $v );
  6146. }
  6147. }
  6148. }
  6149. $receiptList [$key] ['verifyList'] = $verifyList;
  6150. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6151. 'where' => 'sid=' . $value ['staff'],
  6152. 'asArray' => true
  6153. ) );
  6154. $receiptList [$key] ['button'] = $button;
  6155. }
  6156. $mothHtml = "";
  6157. for($i = 1; $i <= 12; $i ++) {
  6158. if ($month == $i)
  6159. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6160. else
  6161. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6162. }
  6163. // 获取审批日志
  6164. Doo::loadModel ( 'receiptLog' );
  6165. $receiptLog = new receiptLog ();
  6166. $rlList = array ();
  6167. $rlInfo = $receiptLog->getOne ( array (
  6168. 'where' => 'rid=' . $rid . ' and status=4',
  6169. 'asArray' => true
  6170. ) );
  6171. $tijdate = $receiptLog->getOne ( array (
  6172. 'where' => 'rid=' . $rid . ' and status=2',
  6173. 'asc' => 'rlid',
  6174. 'asArray' => true
  6175. ) );
  6176. if (! empty ( $rlInfo )) {
  6177. $rlList = $receiptLog->find ( array (
  6178. 'where' => 'rid=' . $rid,
  6179. 'asc' => 'rlid',
  6180. 'asArray' => true
  6181. ) );
  6182. }
  6183. $receiptList [0] ['rlList'] = $rlList;
  6184. $enclosurList = $enclosur->find ( array (
  6185. 'where' => 'rid=' . $rid,
  6186. 'asArray' => true
  6187. ) );
  6188. $enclosurHtml = '';
  6189. foreach ( $enclosurList as $value ) {
  6190. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6191. }
  6192. $data ['enclosurHtml'] = $enclosurHtml;
  6193. $data ['rolename'] = $rolename ['name'];
  6194. $data ['datetij'] = $tijdate ['date'];
  6195. $data ['mothHtml'] = $mothHtml;
  6196. $data ['receiptList'] = $receiptList;
  6197. $data ['receiptApprovalCount'] = count ( $receiptList );
  6198. $data ['year'] = $year;
  6199. $data ['categoryList'] = $categoryList;
  6200. $data ['staffList'] = $staffList;
  6201. $data ['cid'] = $cid;
  6202. $data ['sid'] = $sid;
  6203. $data ['status'] = 0;
  6204. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  6205. $ap = 4;
  6206. } else
  6207. $data ['status'] = $receiptList [0] ['status'];
  6208. if ($receiptList [0] ['status'] == 4) {
  6209. $data ['status'] = 5;
  6210. $ap = 0;
  6211. }
  6212. $data ['ap'] = $ap;
  6213. $data ['memu'] = "receipt";
  6214. $data ['staff'] = $this->staff;
  6215. $data ['receiptMemu'] = 'approval';
  6216. $data ['verifyId'] = $this->verifyId;
  6217. $data ['executeId'] = $this->executeId;
  6218. $this->render ( "/admin/saeaReportListReport", $data );
  6219. }
  6220. function approvalEdi() {
  6221. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6222. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  6223. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6224. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6225. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6226. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6227. if (empty ( $status ))
  6228. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  6229. $vidList = array ();
  6230. $button = 0;
  6231. Doo::loadModel ( 'verify' );
  6232. Doo::loadModel ( 'receipt' );
  6233. Doo::loadModel ( 'staff' );
  6234. $staff = new staff ();
  6235. $receipt = new receipt ();
  6236. $verify = new verify ();
  6237. Doo::loadModel ( 'L_category' );
  6238. $Lcategory = new L_category ();
  6239. Doo::loadModel ( 'enclosur' );
  6240. $enclosur = new enclosur ();
  6241. // user verify ID
  6242. $verifyDetail = $verify->find ( array (
  6243. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6244. 'asArray' => true
  6245. ) );
  6246. foreach ( $verifyDetail as $key => $value ) {
  6247. array_push ( $vidList, $value ['vid'] );
  6248. }
  6249. $vid = implode ( ",", $vidList );
  6250. if (empty ( $verifyDetail ))
  6251. $vid = 0;
  6252. $categoryList = $Lcategory->find ( array (
  6253. 'asArray' => true
  6254. ) );
  6255. $staffList = $staff->find ( array (
  6256. 'where' => 'cid=' . $cid,
  6257. 'asArray' => true
  6258. ) );
  6259. $ap = "";
  6260. if ($status == 4) {
  6261. $ap = 4;
  6262. $status = 2;
  6263. }
  6264. // get Receipt By verifyID status 2
  6265. $receiptList = $receipt->find ( array (
  6266. 'where' => 'rid =' . $rid,
  6267. 'desc' => 'rid',
  6268. 'asArray' => true
  6269. ) );
  6270. $Locate = 0;
  6271. $roleId = 0;
  6272. if ($ap == 4)
  6273. $status = 4;
  6274. foreach ( $receiptList as $key => $value ) {
  6275. $receiptList [$key] ['Locate'] = $Locate;
  6276. $Locate ++;
  6277. $receiptList [$key] ['reviseDetail'] = array ();
  6278. if (! empty ( $value ['reviseDetail'] ))
  6279. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6280. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6281. $categoryDetil = $Lcategory->getOne ( array (
  6282. 'where' => 'cid=' . $value ['cid'],
  6283. 'asArray' => true
  6284. ) );
  6285. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6286. // 检测编辑状态
  6287. $verifyList = $verify->getOne ( array (
  6288. 'where' => 'vid=' . $value ['verify'],
  6289. 'asArray' => true
  6290. ) );
  6291. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6292. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6293. // print_r($verifyList);
  6294. //
  6295. // if (empty($verifyStaff)){
  6296. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6297. // $verifyList[0]['status']=4;$button=4;
  6298. // }
  6299. //
  6300. // }else{
  6301. //
  6302. // }
  6303. // die;
  6304. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  6305. // echo array_search("green",$a);
  6306. //
  6307. Doo::loadModel ( 'role' );
  6308. $role = new role ();
  6309. // print_r($verifyList);
  6310. $flag = true;
  6311. $roleKey = 0;
  6312. $endStaffArray = array ();
  6313. $roleArrayCopy = array ();
  6314. foreach ( $verifyList as $k => $v ) {
  6315. // init verifyStaff
  6316. if ($v [1] == 'ROLE') {
  6317. if (! empty ( $verifyStaff )) {
  6318. $endStaffArray = end ( $verifyStaff );
  6319. if ($v [0] == $endStaffArray ['nextStaff']) {
  6320. $roleId = $v [0];
  6321. }
  6322. }
  6323. $roleVerify = json_decode ( $v [3], true );
  6324. $roleKey = $k;
  6325. $roleArray = array ();
  6326. $rolename = $role->getOne ( array (
  6327. 'where' => 'rid=' . $v [0],
  6328. 'asArray' => true
  6329. ) );
  6330. foreach ( $roleVerify as $o => $p ) {
  6331. $staffID = explode ( '_', $p );
  6332. $staffInfo = $staff->getOne ( array (
  6333. 'where' => 'sid=' . $staffID [0],
  6334. 'asArray' => true
  6335. ) );
  6336. // print_r($staffID);
  6337. $exp = array (
  6338. 0 => $staffInfo ['sid'],
  6339. 1 => $staffID [1],
  6340. 2 => $staffInfo ['avatar'],
  6341. 'date' => '',
  6342. 'date' => '',
  6343. 'opinion' => '',
  6344. 'status' => '',
  6345. 'rolename' => $rolename ['name']
  6346. );
  6347. array_push ( $roleArray, $exp );
  6348. }
  6349. $roleArrayCopy [$v [0]] = $roleArray;
  6350. // $verifyList[$k]['roleArray']=$roleArray;
  6351. }
  6352. // print_r($roleArray);
  6353. $verifyList [$k] ['date'] = "";
  6354. $verifyList [$k] ['opinion'] = "";
  6355. $verifyList [$k] ['status'] = "";
  6356. if (empty ( $verifyStaff )) {
  6357. $verifyList [$k] ['date'] = "";
  6358. $verifyList [$k] ['opinion'] = "";
  6359. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6360. $verifyList [$k] ['status'] = 4;
  6361. $button = 4;
  6362. $flag = false;
  6363. }
  6364. } else {
  6365. foreach ( $verifyStaff as $m => $u ) {
  6366. if ($v [0] == $m) {
  6367. $verifyList [$k] ['date'] = $u ['date'];
  6368. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6369. $verifyList [$k] ['status'] = $u ['status'];
  6370. $flag = false;
  6371. break;
  6372. }
  6373. }
  6374. $endStaffArray = end ( $verifyStaff );
  6375. if (isset ( $endStaffArray ['ROLE'] )) {
  6376. } else {
  6377. $endKey = key ( $verifyStaff );
  6378. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6379. $button = 4;
  6380. $verifyList [$k] ['status'] = 4;
  6381. }
  6382. }
  6383. // print_r($endStaffArray);die;
  6384. // if (empty($verifyStaff)){
  6385. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6386. // $verifyList[$k]['status']=4;$button=4;
  6387. // }
  6388. //
  6389. // }else{
  6390. //
  6391. // }
  6392. // if($flag){//检测可编辑
  6393. // if($v[0]==$this->staff[0]['sid']){
  6394. // $verifyList[$k]['status']=4;$button=4;
  6395. // }
  6396. // }
  6397. }
  6398. }
  6399. $rolename ['name'] = '';
  6400. if (! empty ( $roleId )) {
  6401. Doo::loadModel ( 'role' );
  6402. $role = new role ();
  6403. $rolename = $role->getOne ( array (
  6404. 'where' => 'rid=' . $roleId,
  6405. 'asArray' => true
  6406. ) );
  6407. }
  6408. if (! empty ( $verifyStaff ))
  6409. $endStaffArray = end ( $verifyStaff );
  6410. $KOP = false;
  6411. foreach ( $roleArrayCopy as $P => $A ) {
  6412. foreach ( $A as $MKI => $AVL ) {
  6413. if (! empty ( $verifyStaff )) {
  6414. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6415. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6416. $button = 4;
  6417. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6418. }
  6419. foreach ( $verifyStaff as $m => $u ) {
  6420. $AVLFK = $AVL [0] . '_R';
  6421. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6422. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6423. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6424. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6425. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6426. break;
  6427. }
  6428. }
  6429. } else {
  6430. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6431. $button = 4;
  6432. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6433. }
  6434. }
  6435. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6436. $KOP = true;
  6437. }
  6438. }
  6439. // print_r($roleArrayCopy);
  6440. // echo $roleKey;
  6441. foreach ( $roleArrayCopy as $k => $v ) {
  6442. foreach ( $verifyList as $m => $n ) {
  6443. if ($n [0] == $k) {
  6444. array_splice ( $verifyList, $m, 1, $v );
  6445. }
  6446. }
  6447. }
  6448. // if ($KOP)
  6449. // array_splice($verifyList,$roleKey,1,$roleArray);
  6450. // print_r($verifyList);
  6451. $receiptList [$key] ['verifyList'] = $verifyList;
  6452. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6453. 'where' => 'sid=' . $value ['staff'],
  6454. 'asArray' => true
  6455. ) );
  6456. $receiptList [$key] ['button'] = $button;
  6457. }
  6458. // $data['verifyDetail']=$verifyDetail;
  6459. $mothHtml = "";
  6460. for($i = 1; $i <= 12; $i ++) {
  6461. if ($month == $i)
  6462. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6463. else
  6464. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6465. }
  6466. // 获取审批日志
  6467. Doo::loadModel ( 'receiptLog' );
  6468. $receiptLog = new receiptLog ();
  6469. $rlList = array ();
  6470. $rlInfo = $receiptLog->getOne ( array (
  6471. 'where' => 'rid=' . $rid . ' and status=4',
  6472. 'asArray' => true
  6473. ) );
  6474. $tijdate = $receiptLog->getOne ( array (
  6475. 'where' => 'rid=' . $rid . ' and status=2',
  6476. 'asc' => 'rlid',
  6477. 'asArray' => true
  6478. ) );
  6479. if (! empty ( $rlInfo )) {
  6480. $rlList = $receiptLog->find ( array (
  6481. 'where' => 'rid=' . $rid,
  6482. 'asc' => 'rlid',
  6483. 'asArray' => true
  6484. ) );
  6485. }
  6486. $receiptList [0] ['rlList'] = $rlList;
  6487. $enclosurList = $enclosur->find ( array (
  6488. 'where' => 'rid=' . $rid,
  6489. 'asArray' => true
  6490. ) );
  6491. $enclosurHtml = '';
  6492. foreach ( $enclosurList as $value ) {
  6493. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6494. }
  6495. $data ['enclosurHtml'] = $enclosurHtml;
  6496. $data ['rolename'] = $rolename ['name'];
  6497. $data ['datetij'] = $tijdate ['date'];
  6498. $data ['mothHtml'] = $mothHtml;
  6499. $data ['receiptList'] = $receiptList;
  6500. $data ['receiptApprovalCount'] = count ( $receiptList );
  6501. $data ['status'] = $status;
  6502. $data ['year'] = $year;
  6503. $data ['categoryList'] = $categoryList;
  6504. $data ['staffList'] = $staffList;
  6505. $data ['cid'] = $cid;
  6506. $data ['sid'] = $sid;
  6507. $data ['ap'] = $ap;
  6508. $data ['memu'] = "receipt";
  6509. $data ['staff'] = $this->staff;
  6510. $data ['receiptMemu'] = 'approval';
  6511. $data ['verifyId'] = $this->verifyId;
  6512. $data ['executeId'] = $this->executeId;
  6513. $this->render ( "/admin/saeaReportListReport", $data );
  6514. }
  6515. function remittanceHky() {
  6516. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6517. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  6518. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6519. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  6520. $page_size = 15;
  6521. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  6522. Doo::loadModel ( 'receipt' );
  6523. $receipt = new receipt ();
  6524. Doo::loadModel ( 'staff' );
  6525. $staff = new staff ();
  6526. $dateCondition = " and Year(executeDate) =" . $year;
  6527. if ($moth != 'MONTH')
  6528. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  6529. if ($day != 'DAY' && $moth != 'MONTH')
  6530. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  6531. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  6532. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  6533. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  6534. $limit = $pageinfo ['lower'] . ',' . $page_size;
  6535. $dayList = $receipt->find ( array (
  6536. 'select' => 'executeDate,sum(amount) as amount',
  6537. 'where' => $sql,
  6538. 'desc' => 'executeDate',
  6539. 'groupby' => 'executeDate',
  6540. 'limit' => $limit,
  6541. 'asArray' => true
  6542. ) );
  6543. // print_r($dayList);
  6544. foreach ( $dayList as $key => $value ) {
  6545. $remitString = "";
  6546. $receiptList = $receipt->find ( array (
  6547. 'select' => 'rid,executeDate,amount,staff,cid',
  6548. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  6549. 'desc' => 'executeDate',
  6550. 'asArray' => true
  6551. ) );
  6552. foreach ( $receiptList as $k => $v ) {
  6553. $sinfo = $staff->getOne ( array (
  6554. 'select' => 'username,category',
  6555. 'where' => ' sid=' . $v ['staff'],
  6556. 'asArray' => true
  6557. ) );
  6558. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  6559. }
  6560. $dayList [$key] ['staff'] = $remitString;
  6561. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  6562. }
  6563. // print_r($dayList);
  6564. $mothHtml = "";
  6565. for($i = 1; $i <= 12; $i ++) {
  6566. if ($moth == $i)
  6567. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6568. else
  6569. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6570. }
  6571. $dayHtml = "";
  6572. if ($day != "DAY" || $moth != "MONTH") {
  6573. for($i = 1; $i <= 31; $i ++) {
  6574. if ($day == $i)
  6575. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6576. else
  6577. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6578. }
  6579. }
  6580. $data ['page'] = $pageinfo;
  6581. $data ['year'] = $year;
  6582. $data ['moth'] = $moth;
  6583. $data ['day'] = $day;
  6584. $data ['get'] = $get;
  6585. $data ['dayHtml'] = $dayHtml;
  6586. $data ['mothHtml'] = $mothHtml;
  6587. $data ['receiptList'] = $dayList;
  6588. $data ['memu'] = "receipt";
  6589. $data ['staff'] = $this->staff;
  6590. $data ['receiptMemu'] = 'remittanceHky';
  6591. $data ['verifyId'] = $this->verifyId;
  6592. $data ['executeId'] = $this->executeId;
  6593. $this->render ( "/admin/remittanceHky", $data );
  6594. }
  6595. function remittancep() {
  6596. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  6597. Doo::loadModel ( 'receipt' );
  6598. $receipt = new receipt ();
  6599. Doo::loadModel ( 'staff' );
  6600. $staff = new staff ();
  6601. Doo::loadClass ( 'XDeode' );
  6602. $XDeode = new XDeode ( 5 );
  6603. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  6604. $rplist = $receipt->find ( array (
  6605. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6606. 'asArray' => true
  6607. ) );
  6608. $dayList = $receipt->find ( array (
  6609. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6610. 'desc' => 'executeDate',
  6611. 'groupby' => 'staff',
  6612. 'asArray' => true
  6613. ) );
  6614. $html = '';
  6615. foreach ( $dayList as $key => $value ) {
  6616. $sinfo = $staff->getOne ( array (
  6617. 'select' => 'username,category',
  6618. 'where' => ' sid=' . $value ['staff'],
  6619. 'asArray' => true
  6620. ) );
  6621. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  6622. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  6623. $au = 0;
  6624. foreach ( $rplist as $k => $v ) {
  6625. if ($value ['staff'] == $v ['staff']) {
  6626. $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>';
  6627. $au += $v ['amount'];
  6628. }
  6629. }
  6630. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  6631. }
  6632. $data ['html'] = $html;
  6633. $data ['memu'] = "receipt";
  6634. $data ['staff'] = $this->staff;
  6635. $data ['receiptMemu'] = 'remittanceHky';
  6636. $data ['verifyId'] = $this->verifyId;
  6637. $data ['executeId'] = $this->executeId;
  6638. $this->render ( "/admin/remittancep", $data );
  6639. }
  6640. function ajaxGetReceiptDetails() {
  6641. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  6642. Doo::loadClass ( 'XDeode' );
  6643. $XDeode = new XDeode ( 5 );
  6644. $rid = $XDeode->decode ( $rid );
  6645. if (empty ( $rid )) {
  6646. echo json_encode ( array (
  6647. 'status' => 2,
  6648. 'msg' => 'illegal request'
  6649. ) );
  6650. die ();
  6651. }
  6652. Doo::loadModel ( 'receipt' );
  6653. $receipt = new receipt ();
  6654. Doo::loadModel ( 'staff' );
  6655. $staff = new staff ();
  6656. $rinfo = $receipt->getOne ( array (
  6657. 'where' => 'rid= ' . $rid,
  6658. 'asArray' => true
  6659. ) );
  6660. $sinfo = $staff->getOne ( array (
  6661. 'select' => 'username,category',
  6662. 'where' => ' sid=' . $rinfo ['staff'],
  6663. 'asArray' => true
  6664. ) );
  6665. $rinfo ['reviseDetail'] = array ();
  6666. if (! empty ( $rinfo ['reviseDetail'] ))
  6667. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  6668. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  6669. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  6670. $rinfo ['category'] = $sinfo ['category'];
  6671. $verifyStaff = array ();
  6672. if (! empty ( $rinfo ['verifyStaff'] ))
  6673. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  6674. $relust = $rinfo ['sum'] - $rinfo ['loanSum'];
  6675. $rinfo ['relust'] = $relust;
  6676. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  6677. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  6678. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  6679. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  6680. // 费用执行人相关数据
  6681. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6682. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6683. foreach ( $executeCopy as $k => $v ) {
  6684. $executeCopy [$k] ['date'] = '';
  6685. $executeCopy [$k] ['opinion'] = '';
  6686. $executeCopy [$k] ['status'] = '';
  6687. if (! empty ( $executeStaff ))
  6688. foreach ( $executeStaff as $m => $u ) {
  6689. if ($v [0] == $m) {
  6690. $executeCopy [$k] ['date'] = $u ['date'];
  6691. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  6692. $executeCopy [$k] ['status'] = $u ['status'];
  6693. break;
  6694. }
  6695. }
  6696. }
  6697. $rinfo ['executeCopy'] = $executeCopy;
  6698. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  6699. if ($rinfo ['Rtype'] == 1) { // 借款费用
  6700. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6701. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  6702. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  6703. $html .= '<tr><th>' . $value ['name'] . '</th>
  6704. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6705. }
  6706. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6707. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6708. <tr><th class="taC" colspan="2">费用说明</th>
  6709. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6710. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6711. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  6712. </tbody></table>';
  6713. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  6714. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6715. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6716. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6717. $html .= '<tr><th>' . $value ['name'] . '</th>
  6718. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6719. }
  6720. $html .= '<tr><th class="taR">合计</th>
  6721. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6722. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6723. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6724. $html .= '<tr><th>' . $value ['name'] . '</th>
  6725. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6726. }
  6727. $html .= '<tr><th class="taR">合计</th>
  6728. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6729. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6730. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6731. $html .= '<tr><th>' . $value ['name'] . '</th>
  6732. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6733. }
  6734. $html .= '<tr><th class="taR">合计</th>
  6735. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6736. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6737. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6738. $html .= '<tr><th>' . $value ['name'] . '</th>
  6739. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6740. }
  6741. $html .= '<tr><th class="taR">合计</th>
  6742. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6743. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6744. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6745. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6746. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6747. }
  6748. $html .= '<tr><th class="taR">合计</th>
  6749. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6750. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6751. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6752. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6753. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6754. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6755. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6756. <tr';
  6757. if ($rinfo ['relust'] >= 0) {
  6758. $html .= 'class="success"';
  6759. } else {
  6760. $html .= 'class="error"';
  6761. }
  6762. $html .= '><td class="taR"><b>借款结余</b></td>
  6763. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  6764. </tbody></table>
  6765. ';
  6766. }
  6767. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  6768. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6769. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  6770. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6771. $html .= '<tr><th>' . $value ['name'] . '</th>
  6772. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6773. }
  6774. $html .= '<tr><th class="taR">合计</th>
  6775. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6776. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6777. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6778. <tr><th class="taC" colspan="2">费用说明</th>
  6779. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6780. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6781. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6782. </tbody></table>';
  6783. } else {
  6784. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6785. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6786. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6787. $html .= '<tr><th>' . $value ['name'] . '</th>
  6788. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6789. }
  6790. $html .= '<tr><th class="taR">合计</th>
  6791. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6792. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6793. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6794. $html .= '<tr><th>' . $value ['name'] . '</th>
  6795. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6796. }
  6797. $html .= '<tr><th class="taR">合计</th>
  6798. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6799. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6800. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6801. $html .= '<tr><th>' . $value ['name'] . '</th>
  6802. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6803. }
  6804. $html .= '<tr><th class="taR">合计</th>
  6805. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6806. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6807. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6808. $html .= '<tr><th>' . $value ['name'] . '</th>
  6809. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6810. }
  6811. $html .= '<tr><th class="taR">合计</th>
  6812. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6813. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6814. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6815. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6816. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6817. }
  6818. $html .= '<tr><th class="taR">合计</th>
  6819. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6820. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6821. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6822. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6823. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6824. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6825. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  6826. $html .= '</tbody></table>';
  6827. /*
  6828. * <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>
  6829. */
  6830. }
  6831. // print_r($verifyStaff);die;
  6832. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  6833. foreach ( $verifyStaff as $key => $value ) {
  6834. $key = trim ( strtr ( $key, '_R', ' ' ) );
  6835. $sinfo = $staff->getOne ( array (
  6836. 'select' => 'username',
  6837. 'where' => ' sid=' . $key,
  6838. 'asArray' => true
  6839. ) );
  6840. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6841. }
  6842. $html .= '</tbody></table>';
  6843. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  6844. foreach ( $rinfo ['executeCopy'] as $value ) {
  6845. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6846. }
  6847. $html .= '</tbody></table>';
  6848. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  6849. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  6850. </tr></table>';
  6851. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  6852. echo json_encode ( array (
  6853. 'status' => 1,
  6854. 'html' => $html
  6855. ) );
  6856. die ();
  6857. }
  6858. /**
  6859. * 删除附件
  6860. */
  6861. function ajaxRemEnclousur() {
  6862. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  6863. if (empty ( $key ))
  6864. echo json_encode ( array (
  6865. 'status' => 2
  6866. ) );
  6867. Doo::loadModel ( 'enclosur' );
  6868. $enclosur = new enclosur ();
  6869. $enclosur->delEnclosurByEid ( $key );
  6870. echo json_encode ( array (
  6871. 'status' => 1
  6872. ) );
  6873. }
  6874. function remittance() {
  6875. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6876. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6877. Doo::loadModel ( 'receipt' );
  6878. $receipt = new receipt ();
  6879. Doo::loadModel ( 'staff' );
  6880. $staff = new staff ();
  6881. $dateCondition = " and Year(pastDate) =" . $year;
  6882. if (! empty ( $month ))
  6883. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  6884. // get Receipt By verifyID status 1
  6885. $receiptList = $receipt->find ( array (
  6886. 'select' => 'sum(sum) as sum,staff,pastDate',
  6887. 'where' => ' status=1' . $dateCondition,
  6888. 'desc' => 'pastDate',
  6889. 'groupby' => 'staff,pastDate',
  6890. 'asArray' => true
  6891. ) );
  6892. $dateList = $receipt->find ( array (
  6893. 'select' => 'pastDate,verifyStaff',
  6894. 'where' => ' status=1' . $dateCondition,
  6895. 'desc' => 'pastDate',
  6896. 'groupby' => 'pastDate',
  6897. 'asArray' => true
  6898. ) );
  6899. $dataList = array ();
  6900. foreach ( $dateList as $d => $a ) {
  6901. $dataList [$a ['pastDate']] = array ();
  6902. $daySum = 0;
  6903. foreach ( $receiptList as $key => $value ) {
  6904. if ($a ['pastDate'] == $value ['pastDate']) {
  6905. $oderList = $receipt->find ( array (
  6906. 'select' => 'receiptOrder',
  6907. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  6908. 'asArray' => true
  6909. ) );
  6910. $list = array ();
  6911. $html = "";
  6912. foreach ( $oderList as $v ) {
  6913. array_push ( $list, $v ['receiptOrder'] );
  6914. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  6915. }
  6916. $receiptList [$key] ['receiptOrder'] = $html;
  6917. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  6918. $sinfo = $staff->getOne ( array (
  6919. 'select' => 'username ',
  6920. 'where' => ' sid=' . $value ['staff'],
  6921. 'asArray' => true
  6922. ) );
  6923. $receiptList [$key] ['username'] = $sinfo ['username'];
  6924. $daySum += $value ['sum'];
  6925. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  6926. }
  6927. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  6928. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  6929. }
  6930. }
  6931. // print_r($dataList);
  6932. $data ['dataList'] = $dataList;
  6933. $mothHtml = "";
  6934. for($i = 1; $i <= 12; $i ++) {
  6935. if ($month == $i)
  6936. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6937. else
  6938. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6939. }
  6940. $data ['year'] = $year;
  6941. $data ['mothHtml'] = $mothHtml;
  6942. $data ['memu'] = "receipt";
  6943. $data ['staff'] = $this->staff;
  6944. $data ['receiptMemu'] = 'approval';
  6945. $data ['verifyId'] = $this->verifyId;
  6946. $data ['executeId'] = $this->executeId;
  6947. $this->render ( "/admin/saeaReportListPay", $data );
  6948. }
  6949. /**
  6950. * 金额调整,提高稳定性
  6951. * @return string
  6952. */
  6953. function revocationAdjustment() {
  6954. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  6955. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  6956. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  6957. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  6958. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey ) && (! empty ( $reviseKey )))) {
  6959. Doo::loadClass ( 'XDeode' );
  6960. $XDeode = new XDeode ( 5 );
  6961. Doo::loadModel ( 'receipt' );
  6962. $receipt = new receipt ();
  6963. $sid = $XDeode->decode ( $sidKey );
  6964. $rid = $XDeode->decode ( $ridKey );
  6965. $reviseKey = $XDeode->decode ( $reviseKey );
  6966. if (! is_numeric ( $sid ) && ! is_numeric ( $rid ) && ! is_numeric ( $reviseKey ))
  6967. die ( 'illegal request' );
  6968. $receiptDetail = $receipt->getOne ( array (
  6969. 'where' => 'rid=' . $rid,
  6970. 'asArray' => true
  6971. ) );
  6972. if (empty ( $receiptDetail ) || empty ( $receiptDetail ['reviseDetail'] ))
  6973. die ( 'illegal request' );
  6974. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  6975. if (! isset ( $reviseDetail [$reviseKey] ))
  6976. die ( 'illegal request' );
  6977. if ($reviseDetail [$reviseKey] ['sid'] == $sid && $reviseDetail [$reviseKey] ['price'] == $price)
  6978. unset ( $reviseDetail [$reviseKey] );
  6979. $revisePrice = 0;
  6980. foreach ( $reviseDetail as $key => $value ) {
  6981. $revisePrice += $value ['price'];
  6982. }
  6983. $reviseDetailString = json_encode ( $reviseDetail );
  6984. $receipt->reviseDetail = $reviseDetailString;
  6985. $receipt->sum = $receiptDetail ['sum'] - $price;
  6986. $receipt->revisePrice = $revisePrice;
  6987. $receipt->update ( array (
  6988. 'where' => 'rid=' . $rid
  6989. ) );
  6990. return '/receiptburEdi/' . $rid;
  6991. } else
  6992. die ( 'illegal request2' );
  6993. }
  6994. function updateApprovalReceipt() {
  6995. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6996. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  6997. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6998. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  6999. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  7000. if (! empty ( $rid )) {
  7001. Doo::loadModel ( "verify" );
  7002. $verify = new verify ();
  7003. Doo::loadModel ( "receiptDetail" );
  7004. $receiptDetailObj = new receiptDetail ();
  7005. Doo::loadModel ( "itemStatistics" );
  7006. Doo::loadModel ( "statistics" );
  7007. $statistics = new statistics ();
  7008. $itemStatistics = new itemStatistics ();
  7009. Doo::loadModel ( "receipt" );
  7010. $receipt = new receipt ();
  7011. $receiptDetail = $receipt->getOne ( array (
  7012. 'where' => 'rid=' . $rid . ' and status=2 ',
  7013. 'asArray' => true
  7014. ) );
  7015. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  7016. $nsflag = true;
  7017. foreach ( $nslist as $value ) {
  7018. if ($value == $this->staff ['0'] ['sid']) {
  7019. $nsflag = false;
  7020. break;
  7021. }
  7022. }
  7023. if (empty ( $receiptDetail ) || $nsflag)
  7024. return "/approval";
  7025. $verifyDetail = $verify->getOne ( array (
  7026. 'where' => ' vid =' . $receiptDetail ['verify'],
  7027. 'asArray' => true
  7028. ) );
  7029. $verifyString = $verifyDetail ['staff'];
  7030. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  7031. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  7032. if (empty ( $opinion )) {
  7033. if ($status == 3)
  7034. $opinion = "终止";
  7035. else
  7036. $opinion = "同意支付";
  7037. }
  7038. $nowStaff = 0;
  7039. $nowStaffList = array ();
  7040. if (empty ( $verifyStaff )) {
  7041. // 还需加入是否已经进入角色审批
  7042. if ($verifyDetail [0] [1] == 'ROLE') {
  7043. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  7044. foreach ( $vStaffString as $key => $value ) {
  7045. $staffK = explode ( "_", $value );
  7046. if ($staffK [0] != $this->staff [0] ['sid'])
  7047. array_push ( $nowStaffList, $staffK [0] );
  7048. }
  7049. // print_r($verifyDetail);
  7050. // die;
  7051. if (! empty ( $nowStaffList )) {
  7052. $nowStaff = implode ( ',', $nowStaffList );
  7053. $verifyStaff = array (
  7054. $this->staff [0] ['sid'] . "_R" => array (
  7055. 'date' => date ( 'Y-m-d' ),
  7056. 'opinion' => $opinion,
  7057. 'status' => $status,
  7058. 'nextStaff' => $verifyDetail [0] [0],
  7059. 'ROLE' => 1
  7060. )
  7061. );
  7062. } else {
  7063. $nowStaff = $verifyDetail [1] [0];
  7064. $verifyStaff = array (
  7065. $this->staff [0] ['sid'] . "_R" => array (
  7066. 'date' => date ( 'Y-m-d' ),
  7067. 'opinion' => $opinion,
  7068. 'status' => $status,
  7069. 'nextStaff' => $verifyDetail [1] [0]
  7070. )
  7071. );
  7072. }
  7073. } else {
  7074. if ($verifyDetail [1] [1] == 'ROLE') {
  7075. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  7076. // echo "dd";
  7077. foreach ( $vStaffString as $key => $value ) {
  7078. $staffK = explode ( "_", $value );
  7079. array_push ( $nowStaffList, $staffK [0] );
  7080. }
  7081. $nowStaff = implode ( ',', $nowStaffList );
  7082. $verifyStaff = array (
  7083. $this->staff [0] ['sid'] => array (
  7084. 'date' => date ( 'Y-m-d' ),
  7085. 'opinion' => $opinion,
  7086. 'status' => $status,
  7087. 'nextStaff' => $verifyDetail [1] [0],
  7088. 'ROLE' => 1
  7089. )
  7090. );
  7091. } else {
  7092. $nowStaff = $verifyDetail [1] [0];
  7093. $verifyStaff = array (
  7094. $this->staff [0] ['sid'] => array (
  7095. 'date' => date ( 'Y-m-d' ),
  7096. 'opinion' => $opinion,
  7097. 'status' => $status,
  7098. 'nextStaff' => $verifyDetail [1] [0]
  7099. )
  7100. );
  7101. }
  7102. }
  7103. if ($status == 3)
  7104. $verifyStaff = array (
  7105. 'final' => $status,
  7106. $this->staff [0] ['sid'] => array (
  7107. 'date' => date ( 'Y-m-d' ),
  7108. 'opinion' => $opinion,
  7109. 'status' => $status
  7110. )
  7111. );
  7112. $vStaffString = json_encode ( $verifyStaff );
  7113. $receipt->nowStaff = $nowStaff;
  7114. $receipt->verifyStaff = $vStaffString;
  7115. } else {
  7116. $VS = end ( $verifyStaff );
  7117. // 非角色审批
  7118. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  7119. $nextStaff = 0;
  7120. $roleSTF = false;
  7121. foreach ( $verifyDetail as $key => $value ) {
  7122. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  7123. if (isset ( $verifyDetail [$key + 1] )) {
  7124. $nextStaff = $verifyDetail [$key + 1] [0];
  7125. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  7126. $roleSTF = true;
  7127. }
  7128. break;
  7129. }
  7130. }
  7131. if (! $roleSTF) {
  7132. $nowStaff = $nextStaff;
  7133. $verifyStaff [$this->staff [0] ['sid']] = array (
  7134. 'date' => date ( 'Y-m-d' ),
  7135. 'opinion' => $opinion,
  7136. 'status' => $status,
  7137. 'nextStaff' => $nextStaff
  7138. );
  7139. } else {
  7140. // 获取角色下的所有用户ID
  7141. $nowStaffList = array ();
  7142. foreach ( $verifyDetail as $vfk ) {
  7143. if ($vfk [1] == 'ROLE') {
  7144. $vStaffString = json_decode ( $vfk [3] );
  7145. foreach ( $vStaffString as $key => $value ) {
  7146. $staffK = explode ( "_", $value );
  7147. array_push ( $nowStaffList, $staffK [0] );
  7148. }
  7149. }
  7150. }
  7151. $nowStaff = implode ( ',', $nowStaffList );
  7152. $verifyStaff [$this->staff [0] ['sid']] = array (
  7153. 'date' => date ( 'Y-m-d' ),
  7154. 'opinion' => $opinion,
  7155. 'status' => $status,
  7156. 'nextStaff' => $nextStaff,
  7157. 'ROLE' => 0
  7158. );
  7159. }
  7160. if ($status == 3) {
  7161. $verifyStaff ['final'] = $status;
  7162. $verifyStaff [$this->staff [0] ['sid']] = array (
  7163. 'date' => date ( 'Y-m-d' ),
  7164. 'opinion' => $opinion,
  7165. 'status' => $status
  7166. );
  7167. }
  7168. $vStaffString = json_encode ( $verifyStaff );
  7169. $receipt->nowStaff = $nowStaff;
  7170. $receipt->verifyStaff = $vStaffString;
  7171. }
  7172. // 角色审批
  7173. if (isset ( $VS ['ROLE'] )) {
  7174. // 找出角色人 当前审批角色组
  7175. $verifyJSStaff = array ();
  7176. $nowStaffList2 = array ();
  7177. foreach ( $verifyDetail as $key => $value ) {
  7178. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  7179. $verifyJSStaff = json_decode ( $value [3] );
  7180. foreach ( $verifyJSStaff as $m ) {
  7181. $staffK = explode ( "_", $m );
  7182. array_push ( $nowStaffList2, $staffK [0] );
  7183. }
  7184. // print_r($nowStaffList2);
  7185. }
  7186. }
  7187. $RoleVerifyStaff = array ();
  7188. foreach ( $verifyStaff as $key => $value ) {
  7189. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  7190. foreach ( $nowStaffList2 as $m ) {
  7191. if ($key == $m . "_R")
  7192. $RoleVerifyStaff [$key] = $value;
  7193. }
  7194. }
  7195. }
  7196. // print_r($verifyStaff);
  7197. // print_r($nowStaffList2);
  7198. // print_r($RoleVerifyStaff);
  7199. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  7200. // print_r($verifyJSStaff);
  7201. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  7202. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  7203. // 下一个审批人ID
  7204. $nextStaff = 0;
  7205. $falg = false;
  7206. foreach ( $verifyDetail as $key => $value ) {
  7207. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  7208. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  7209. $falg = true;
  7210. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  7211. $nowStaffList = array ();
  7212. foreach ( $vStaffString as $v ) {
  7213. $staffK = explode ( "_", $v );
  7214. array_push ( $nowStaffList, $staffK [0] );
  7215. }
  7216. $nowStaff = implode ( ',', $nowStaffList );
  7217. $nextStaff = $verifyDetail [$key + 1] [0];
  7218. } elseif (isset ( $verifyDetail [$key + 1] )) {
  7219. $nextStaff = $verifyDetail [$key + 1] [0];
  7220. $nowStaff = $nextStaff;
  7221. } else
  7222. $nowStaff = '';
  7223. break;
  7224. }
  7225. }
  7226. if ($falg)
  7227. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7228. 'date' => date ( 'Y-m-d' ),
  7229. 'opinion' => $opinion,
  7230. 'status' => $status,
  7231. 'nextStaff' => $nextStaff,
  7232. 'ROLE' => 1
  7233. );
  7234. else
  7235. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7236. 'date' => date ( 'Y-m-d' ),
  7237. 'opinion' => $opinion,
  7238. 'status' => $status,
  7239. 'nextStaff' => $nextStaff
  7240. );
  7241. // print_r($verifyStaff);
  7242. // echo $nowStaff;die;
  7243. } else { // 进入下一个角色或者审批人
  7244. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  7245. //
  7246. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  7247. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7248. 'date' => date ( 'Y-m-d' ),
  7249. 'opinion' => $opinion,
  7250. 'status' => $status,
  7251. 'nextStaff' => $VS ['nextStaff'],
  7252. 'ROLE' => 1
  7253. );
  7254. // print_r($verifyStaff);
  7255. // die;
  7256. }
  7257. if ($status == 3) {
  7258. $verifyStaff ['final'] = $status;
  7259. $verifyStaff [$this->staff [0] ['sid']] = array (
  7260. 'date' => date ( 'Y-m-d' ),
  7261. 'opinion' => $opinion,
  7262. 'status' => $status
  7263. );
  7264. }
  7265. $vStaffString = json_encode ( $verifyStaff );
  7266. $receipt->verifyStaff = $vStaffString;
  7267. $receipt->nowStaff = $nowStaff;
  7268. // die;
  7269. // }
  7270. // print_r($verifyStaff);
  7271. // die;
  7272. }
  7273. // print_r($verifyStaff);die;
  7274. }
  7275. // print_r($verifyDetail);
  7276. $roleKey = 0;
  7277. $roleId = 0;
  7278. $verifyDetailCopy = array ();
  7279. foreach ( $verifyDetail as $k => $v ) {
  7280. if ($v [1] == 'ROLE') {
  7281. $roleId = $v [0];
  7282. $roleVerify = json_decode ( $v [3], true );
  7283. $roleKey = $k;
  7284. $roleArray = array ();
  7285. foreach ( $roleVerify as $o => $p ) {
  7286. $staffID = explode ( '_', $p );
  7287. $exp = array (
  7288. 0 => $staffID [0],
  7289. 1 => $staffID [1]
  7290. );
  7291. array_push ( $roleArray, $exp );
  7292. }
  7293. $verifyDetailCopy [$v [0]] = $roleArray;
  7294. }
  7295. }
  7296. // print_r($verifyDetail);
  7297. foreach ( $verifyDetailCopy as $k => $v ) {
  7298. foreach ( $verifyDetail as $m => $n ) {
  7299. if ($n [0] == $k) {
  7300. array_splice ( $verifyDetail, $m, 1, $v );
  7301. }
  7302. }
  7303. }
  7304. // die;
  7305. // if (!empty($roleArray))
  7306. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  7307. // echo $roleId;
  7308. // print_r($verifyStaff);
  7309. // print_r($verifyDetail);
  7310. // die;
  7311. Doo::loadModel ( "receiptLog" );
  7312. $receiptLog = new receiptLog ();
  7313. // 审批日志
  7314. if (! isset ( $verifyStaff ['final'] )) {
  7315. if (! empty ( $roleId )) {
  7316. Doo::loadModel ( "role" );
  7317. $role = new role ();
  7318. $roleInfo = $role->getOne ( array (
  7319. 'where' => 'rid=' . $roleId,
  7320. 'asArray' => true
  7321. ) );
  7322. $receiptLog->rolename = $roleInfo ['name'];
  7323. }
  7324. $receiptLog->username = $this->staff [0] ['username'];
  7325. $receiptLog->uid = $this->staff [0] ['sid'];
  7326. $receiptLog->date = date ( "Y-m-d" );
  7327. $receiptLog->opinion = $opinion;
  7328. $receiptLog->img = $this->staff [0] ['avatar'];
  7329. $receiptLog->status = 1;
  7330. $receiptLog->rid = $rid;
  7331. $receiptLog->insert ();
  7332. }
  7333. if (isset ( $verifyStaff ['final'] )) { // rDetail
  7334. $receipt->verifyBreakup = $verifyString;
  7335. $receipt->status = 3;
  7336. $receiptDetailObj->status = 3;
  7337. $receiptDetailObj->update ( array (
  7338. 'where' => 'rid=' . $rid
  7339. ) );
  7340. if (! empty ( $roleId )) {
  7341. Doo::loadModel ( "role" );
  7342. $role = new role ();
  7343. $roleInfo = $role->getOne ( array (
  7344. 'where' => 'rid=' . $roleId,
  7345. 'asArray' => true
  7346. ) );
  7347. $receiptLog->rolename = $roleInfo ['name'];
  7348. }
  7349. $receiptLog->username = $this->staff [0] ['username'];
  7350. $receiptLog->uid = $this->staff [0] ['sid'];
  7351. $receiptLog->date = date ( "Y-m-d" );
  7352. $receiptLog->opinion = $opinion;
  7353. $receiptLog->img = $this->staff [0] ['avatar'];
  7354. $receiptLog->status = 3;
  7355. $receiptLog->rid = $rid;
  7356. $receiptLog->insert ();
  7357. // 微信企业号通知
  7358. $this->setWXMsg ( $rid, 3 );
  7359. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  7360. $receipt->status = 1;
  7361. $reviseSum = 0;
  7362. $receipt->verifyBreakup = $verifyString;
  7363. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  7364. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7365. foreach ( $reviseDetail as $key => $value ) {
  7366. $receiptDetailObj = new receiptDetail ();
  7367. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7368. $receiptDetailObj->item = $value ['description'];
  7369. $receiptDetailObj->itemCategory = "报销金额调整";
  7370. $receiptDetailObj->price = $value ['price'];
  7371. $receiptDetailObj->date = $receiptDetail ['date'];
  7372. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  7373. $receiptDetailObj->rid = $rid;
  7374. $receiptDetailObj->status = 1;
  7375. $receiptDetailObj->insert ();
  7376. $reviseSum += $value ['price'];
  7377. }
  7378. $itemStatistics = new itemStatistics ();
  7379. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7380. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7381. $itemStatistics->price = $reviseSum;
  7382. $itemStatistics->itemCategory = "报销金额调整";
  7383. $itemStatistics->date = $receiptDetail ['date'];
  7384. $itemStatistics->insert ();
  7385. }
  7386. $receiptDetailObj = new receiptDetail ();
  7387. $receiptDetailObj->status = 1;
  7388. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  7389. $receiptDetailObj->update ( array (
  7390. 'where' => 'rid=' . $rid
  7391. ) );
  7392. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7393. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7394. $stat = $statistics->getOne ( array (
  7395. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  7396. 'asArray' => true
  7397. ) );
  7398. if (empty ( $stat )) {
  7399. $statistics->date = $receiptDetail ['date'];
  7400. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7401. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7402. $statistics->agPrice = $receiptDetail ['sum'];
  7403. $statistics->rePrice = $reviseSum;
  7404. $statistics->insert ();
  7405. } else {
  7406. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  7407. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  7408. $statistics->update ( array (
  7409. 'where' => 'sid=' . $stat ['sid']
  7410. ) );
  7411. }
  7412. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7413. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7414. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  7415. foreach ( $accountItem ['cSum'] as $key => $value ) {
  7416. if ($key == "agencySum") {
  7417. $iStatistics = $itemStatistics->getOne ( array (
  7418. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  7419. 'asArray' => true
  7420. ) );
  7421. if (empty ( $iStatistics )) {
  7422. $itemStatistics->cid = $receiptDetail ['cid'];
  7423. ;
  7424. $itemStatistics->staff = $receiptDetail ['staff'];
  7425. $itemStatistics->price = $value;
  7426. $itemStatistics->itemCategory = $this->AGENCY;
  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 == "travelSum") {
  7438. $iStatistics = $itemStatistics->getOne ( array (
  7439. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $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->TRAVEL;
  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 == "trainSum") {
  7458. $iStatistics = $itemStatistics->getOne ( array (
  7459. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $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->TRAIN;
  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. } elseif ($key == "otherSum") {
  7478. $iStatistics = $itemStatistics->getOne ( array (
  7479. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  7480. 'asArray' => true
  7481. ) );
  7482. if (empty ( $iStatistics )) {
  7483. $itemStatistics->cid = $receiptDetail ['cid'];
  7484. $itemStatistics->staff = $receiptDetail ['staff'];
  7485. $itemStatistics->price = $value;
  7486. $itemStatistics->itemCategory = $this->OTHER;
  7487. $itemStatistics->date = $receiptDetail ['date'];
  7488. $itemStatistics->insert ();
  7489. } else {
  7490. if (! empty ( $value )) {
  7491. $itemStatistics->price = $value + $iStatistics ['price'];
  7492. $itemStatistics->update ( array (
  7493. 'where' => 'sid=' . $iStatistics ['sid']
  7494. ) );
  7495. }
  7496. }
  7497. }
  7498. }
  7499. $receipt->pastDate = date ( "Y-m-d" );
  7500. // 微信企业号通知
  7501. $this->setWXMsg ( $rid, 1 );
  7502. }
  7503. $receipt->amount = $amount;
  7504. $receipt->update ( array (
  7505. 'where' => ' rid = ' . $rid
  7506. ) );
  7507. // 进入下一条审批费用新加需求
  7508. $vidList = array ();
  7509. $verifyDetail = $verify->find ( array (
  7510. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  7511. 'asArray' => true
  7512. ) );
  7513. foreach ( $verifyDetail as $key => $value ) {
  7514. array_push ( $vidList, $value ['vid'] );
  7515. }
  7516. $vid = implode ( ",", $vidList );
  7517. if (empty ( $verifyDetail ))
  7518. $vid = 0;
  7519. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  7520. $receipt = new receipt ();
  7521. $rd = $receipt->getOne ( array (
  7522. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  7523. 'asc' => 'rid',
  7524. 'asArray' => true
  7525. ) );
  7526. if (empty ( $rd )) {
  7527. return '/approvalExpenses/pendApproval';
  7528. }
  7529. if ($rd ['Rtype'] == 1) {
  7530. if ($rd ['isBK'] == 1) {
  7531. return '/receiptburEdi/' . $rd ['rid'];
  7532. } else {
  7533. return '/expensesEdi/' . $rd ['rid'];
  7534. }
  7535. } elseif ($rd ['Rtype'] == 2) {
  7536. return '/remitApproval/' . $rd ['rid'];
  7537. } else {
  7538. return '/receiptburEdi/' . $rd ['rid'];
  7539. }
  7540. // return "/approvalExpenses/pendApproval";
  7541. }
  7542. }
  7543. function expensesRetreats() {
  7544. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7545. if (! empty ( $rid )) {
  7546. // 操作记录
  7547. Doo::loadModel ( "receipt" );
  7548. $receipt = new receipt ();
  7549. Doo::loadModel ( "receiptLog" );
  7550. $receiptLog = new receiptLog ();
  7551. Doo::loadModel ( "verify" );
  7552. $verify = new verify ();
  7553. $receiptInfo = $receipt->getOne ( array (
  7554. 'where' => 'rid=' . $rid,
  7555. 'asArray' => true
  7556. ) );
  7557. $vr = $verify->getOne ( array (
  7558. 'where' => 'vid=' . $receiptInfo ['verify'],
  7559. 'asArray' => true
  7560. ) );
  7561. $jd = json_decode ( $vr ['staff'] );
  7562. $roleId = 0;
  7563. foreach ( $jd as $key => $value ) {
  7564. if ($value [1] == 'ROLE') {
  7565. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7566. if ($pos !== false) {
  7567. $roleId = $value [0];
  7568. }
  7569. }
  7570. }
  7571. // 审批日志
  7572. // echo $roleId;die;
  7573. if (! empty ( $roleId )) {
  7574. Doo::loadModel ( "role" );
  7575. $role = new role ();
  7576. $roleInfo = $role->getOne ( array (
  7577. 'where' => 'rid=' . $roleId,
  7578. 'asArray' => true
  7579. ) );
  7580. $receiptLog->rolename = $roleInfo ['name'];
  7581. }
  7582. $receiptLog->username = $this->staff [0] ['username'];
  7583. $receiptLog->uid = $this->staff [0] ['sid'];
  7584. $receiptLog->date = date ( "Y-m-d" );
  7585. $receiptLog->opinion = '撤回';
  7586. $receiptLog->img = $this->staff [0] ['avatar'];
  7587. $receiptLog->status = 4;
  7588. $receiptLog->rid = $rid;
  7589. $receiptLog->insert ();
  7590. $receipt->status = 4;
  7591. $receipt->update ( array (
  7592. 'where' => 'rid=' . $rid
  7593. ) );
  7594. // 微信企业号通知
  7595. $this->setWXMsg ( $rid, 2 );
  7596. }
  7597. // echo "ddd";
  7598. return '/approvalExpenses/pendApproval';
  7599. }
  7600. function updateCheReceipt() {
  7601. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7602. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7603. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  7604. if (! empty ( $rid )) {
  7605. // 操作记录
  7606. Doo::loadModel ( "receipt" );
  7607. $receipt = new receipt ();
  7608. Doo::loadModel ( "receiptLog" );
  7609. $receiptLog = new receiptLog ();
  7610. Doo::loadModel ( "verify" );
  7611. $verify = new verify ();
  7612. $receiptInfo = $receipt->getOne ( array (
  7613. 'where' => 'rid=' . $rid . ' and status=2',
  7614. 'asArray' => true
  7615. ) );
  7616. if (empty ( $receiptInfo )) {
  7617. echo json_encode ( array (
  7618. 'status' => 2
  7619. ) );
  7620. die ();
  7621. }
  7622. $vr = $verify->getOne ( array (
  7623. 'where' => 'vid=' . $receiptInfo ['verify'],
  7624. 'asArray' => true
  7625. ) );
  7626. $jd = json_decode ( $vr ['staff'] );
  7627. $roleId = 0;
  7628. foreach ( $jd as $key => $value ) {
  7629. if ($value [1] == 'ROLE') {
  7630. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7631. if ($pos !== false) {
  7632. $roleId = $value [0];
  7633. }
  7634. }
  7635. }
  7636. // 审批日志
  7637. // echo $roleId;die;
  7638. if (! empty ( $roleId )) {
  7639. Doo::loadModel ( "role" );
  7640. $role = new role ();
  7641. $roleInfo = $role->getOne ( array (
  7642. 'where' => 'rid=' . $roleId,
  7643. 'asArray' => true
  7644. ) );
  7645. $receiptLog->rolename = $roleInfo ['name'];
  7646. }
  7647. $receiptLog->username = $this->staff [0] ['username'];
  7648. $receiptLog->uid = $this->staff [0] ['sid'];
  7649. $receiptLog->date = date ( "Y-m-d" );
  7650. $receiptLog->opinion = $opinion;
  7651. $receiptLog->img = $this->staff [0] ['avatar'];
  7652. $receiptLog->status = 4;
  7653. $receiptLog->rid = $rid;
  7654. $receiptLog->insert ();
  7655. $receipt->status = 4;
  7656. $receipt->update ( array (
  7657. 'where' => 'rid=' . $rid
  7658. ) );
  7659. // 微信企业号通知
  7660. $this->setWXMsg ( $rid, 2 );
  7661. echo json_encode ( array (
  7662. 'status' => 1
  7663. ) );
  7664. // Header("HTTP/1.1 303 See Other");
  7665. // Header("Location: /approvalExpenses/pendApproval");
  7666. die ();
  7667. }
  7668. echo json_encode ( array (
  7669. 'status' => 2
  7670. ) );
  7671. die ();
  7672. // echo "ddd";
  7673. // return '/saeaBorad';
  7674. }
  7675. function revisePrice() {
  7676. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  7677. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  7678. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7679. // echo $price;die;
  7680. if (! empty ( $rid )) {
  7681. Doo::loadModel ( "receipt" );
  7682. $receipt = new receipt ();
  7683. $receiptDetail = $receipt->getOne ( array (
  7684. 'where' => 'rid=' . $rid . ' and status=2 ',
  7685. 'asArray' => true
  7686. ) );
  7687. if (empty ( $receiptDetail ))
  7688. die ( 'illegal request' );
  7689. $reviseDetail = array ();
  7690. if (empty ( $receiptDetail ['reviseDetail'] )) {
  7691. array_push ( $reviseDetail, array (
  7692. 'sid' => $this->staff [0] ['sid'],
  7693. 'name' => $this->staff [0] ['username'],
  7694. 'description' => $description,
  7695. 'price' => $price
  7696. ) );
  7697. $reviseDetailString = json_encode ( $reviseDetail );
  7698. $receipt->reviseDetail = $reviseDetailString;
  7699. $receipt->revisePrice = $price;
  7700. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7701. } else {
  7702. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7703. array_push ( $reviseDetail, array (
  7704. 'sid' => $this->staff [0] ['sid'],
  7705. 'name' => $this->staff [0] ['username'],
  7706. 'description' => $description,
  7707. 'price' => $price
  7708. ) );
  7709. $reviseDetailString = json_encode ( $reviseDetail );
  7710. $receipt->reviseDetail = $reviseDetailString;
  7711. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  7712. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7713. }
  7714. $receipt->update ( array (
  7715. 'where' => 'rid=' . $rid
  7716. ) );
  7717. if ($receiptDetail ['Rtype'] == 1) {
  7718. if ($receiptDetail ['isBK'] == 1) {
  7719. return '/receiptburEdi/' . $receiptDetail ['rid'];
  7720. }
  7721. } elseif ($receiptDetail ['Rtype'] == 2) {
  7722. } else {
  7723. return '/receiptburEdi/' . $receiptDetail ['rid'];
  7724. }
  7725. }
  7726. die ( 'illegal request' );
  7727. }
  7728. function personalCollect() {
  7729. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7730. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  7731. $this->showCache ( $path );
  7732. Doo::loadModel ( "receiptDetail" );
  7733. Doo::loadModel ( "itemStatistics" );
  7734. Doo::loadModel ( 'statistics' );
  7735. $statistics = new statistics ();
  7736. $itemStatistics = new itemStatistics ();
  7737. $receiptDetail = new receiptDetail ();
  7738. $receiptCollectList = $receiptDetail->find ( array (
  7739. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7740. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7741. 'groupby' => 'itemCategory,Month(date)',
  7742. 'asArray' => true
  7743. ) );
  7744. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  7745. 'where' => 'staff=' . $this->staff [0] ['sid'],
  7746. 'asArray' => true
  7747. ) );
  7748. // create collect html
  7749. $collectArray = array (
  7750. '日常相关费用' => array (),
  7751. '差旅相关费用' => array (),
  7752. '培训班费用' => array (),
  7753. '其他' => array ()
  7754. );
  7755. $adjustment = array ();
  7756. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  7757. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7758. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  7759. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7760. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  7761. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7762. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  7763. array_push ( $collectArray ['其他'], $collectHtml );
  7764. $data ['collectArray'] = $collectArray;
  7765. // statistics html
  7766. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7767. if (empty ( $stList ))
  7768. $stList = array (
  7769. 'rePrice' => 0,
  7770. 'agPrice' => 0
  7771. );
  7772. $data ['stList'] = array (
  7773. 'rePrice' => $stList ['rePrice'],
  7774. 'agPrice' => $stList ['agPrice'],
  7775. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7776. );
  7777. // Adjustment price html
  7778. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7779. array_push ( $adjustment, $collectHtml );
  7780. $data ['adjustment'] = $adjustment;
  7781. // total price html
  7782. $collectHtml = "";
  7783. $total = 0;
  7784. for($i = 1; $i <= 12; $i ++) {
  7785. $sumPrice = 0;
  7786. foreach ( $receiptCollectList as $key => $value ) {
  7787. if ($value ['month'] == $i) {
  7788. $sumPrice += $value ['price'];
  7789. }
  7790. }
  7791. if ($sumPrice == 0)
  7792. $collectHtml .= '<td class="taR">-</td>';
  7793. else
  7794. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7795. $total += $sumPrice;
  7796. }
  7797. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7798. $data ['totalPrice'] = $collectHtml;
  7799. $data ['year'] = $year;
  7800. $data ['totalYear'] = $total;
  7801. $data ['memu'] = "receipt";
  7802. $data ['staff'] = $this->staff;
  7803. $data ['receiptMemu'] = 'personalCollect';
  7804. $data ['verifyId'] = $this->verifyId;
  7805. $data ['executeId'] = $this->executeId;
  7806. // year staff status 2,4
  7807. if ($year < date ( "Y" )) {
  7808. Doo::loadModel ( 'receipt' );
  7809. $receipt = new receipt ();
  7810. $receiptList = $receipt->find ( array (
  7811. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7812. 'asArray' => true
  7813. ) );
  7814. if (empty ( $receiptList )) {
  7815. ob_start ();
  7816. $this->render ( "/admin/saea_slist_collect", $data );
  7817. $this->cacheFile ( $path );
  7818. die ();
  7819. }
  7820. }
  7821. $this->render ( "/admin/saea_slist_collect", $data );
  7822. }
  7823. function personalCollectDetail() {
  7824. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7825. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  7826. $this->showCache ( $path );
  7827. Doo::loadModel ( "receiptDetail" );
  7828. Doo::loadModel ( "itemStatistics" );
  7829. Doo::loadModel ( 'statistics' );
  7830. Doo::loadModel ( 'accountItem' );
  7831. $accountItem = new accountItem ();
  7832. $statistics = new statistics ();
  7833. $itemStatistics = new itemStatistics ();
  7834. $receiptDetail = new receiptDetail ();
  7835. $receiptCollectList = $receiptDetail->find ( array (
  7836. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  7837. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7838. 'groupby' => 'item,Month(date)',
  7839. 'asArray' => true
  7840. ) );
  7841. $accountList = $accountItem->find ( array (
  7842. 'asArray' => true
  7843. ) );
  7844. // create CollectDetail HTML
  7845. $collectHtml = array ();
  7846. foreach ( $accountList as $key => $value ) {
  7847. $html = "";
  7848. $asum = 0;
  7849. for($i = 1; $i <= 12; $i ++) {
  7850. $falg = true;
  7851. foreach ( $receiptCollectList as $v ) {
  7852. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7853. $asum += $v ['price'];
  7854. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7855. $falg = false;
  7856. break;
  7857. }
  7858. }
  7859. if ($falg)
  7860. $html .= '<td class="taR">-</td>';
  7861. }
  7862. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7863. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7864. }
  7865. $data ['collectHtml'] = $collectHtml;
  7866. // create Adjustment price html
  7867. $receiptCollectList = $receiptDetail->find ( array (
  7868. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7869. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7870. 'groupby' => 'itemCategory,Month(date)',
  7871. 'asArray' => true
  7872. ) );
  7873. $adjustment = array ();
  7874. $collectArray = array (
  7875. '日常相关费用' => array (),
  7876. '差旅相关费用' => array (),
  7877. '培训班费用' => array (),
  7878. '其他' => array ()
  7879. );
  7880. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7881. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7882. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7883. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7884. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7885. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7886. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7887. array_push ( $collectArray ['其他'], $collectHtml );
  7888. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7889. array_push ( $adjustment, $collectHtml );
  7890. // total price html
  7891. $collectHtml = "";
  7892. $total = 0;
  7893. for($i = 1; $i <= 12; $i ++) {
  7894. $sumPrice = 0;
  7895. foreach ( $receiptCollectList as $key => $value ) {
  7896. if ($value ['month'] == $i) {
  7897. $sumPrice += $value ['price'];
  7898. }
  7899. }
  7900. if ($sumPrice == 0)
  7901. $collectHtml .= '<td class="taR">-</td>';
  7902. else
  7903. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7904. $total += $sumPrice;
  7905. }
  7906. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7907. // statistics html
  7908. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7909. if (empty ( $stList ))
  7910. $stList = array (
  7911. 'rePrice' => 0,
  7912. 'agPrice' => 0
  7913. );
  7914. $data ['stList'] = array (
  7915. 'rePrice' => $stList ['rePrice'],
  7916. 'agPrice' => $stList ['agPrice'],
  7917. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7918. );
  7919. $data ['collectArray'] = $collectArray;
  7920. $data ['adjustment'] = $adjustment;
  7921. $data ['totalPrice'] = $collectHtml;
  7922. $data ['totalYear'] = $total;
  7923. $data ['year'] = $year;
  7924. $data ['memu'] = "receipt";
  7925. $data ['staff'] = $this->staff;
  7926. $data ['receiptMemu'] = 'personalCollect';
  7927. $data ['verifyId'] = $this->verifyId;
  7928. $data ['executeId'] = $this->executeId;
  7929. // year staff status 2,4
  7930. if ($year < date ( "Y" )) {
  7931. Doo::loadModel ( 'receipt' );
  7932. $receipt = new receipt ();
  7933. $receiptList = $receipt->find ( array (
  7934. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7935. 'asArray' => true
  7936. ) );
  7937. if (empty ( $receiptList )) {
  7938. ob_start ();
  7939. $this->render ( "/admin/saeaCollectArticles", $data );
  7940. $this->cacheFile ( $path );
  7941. die ();
  7942. }
  7943. }
  7944. $this->render ( "/admin/saeaCollectArticles", $data );
  7945. }
  7946. function companyCategoryCollect() {
  7947. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7948. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  7949. $this->showCache ( $path );
  7950. Doo::loadModel ( 'L_category' );
  7951. Doo::loadModel ( 'itemStatistics' );
  7952. Doo::loadModel ( 'statistics' );
  7953. $statistics = new statistics ();
  7954. $Lcategory = new L_category ();
  7955. $itemStatistics = new itemStatistics ();
  7956. Doo::loadModel ( "receiptAuthorityManage" );
  7957. $receiptAuthorityManage = new receiptAuthorityManage ();
  7958. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  7959. $cidList = array ();
  7960. foreach ( $imcStaff as $key => $value ) {
  7961. array_push ( $cidList, $value ['cid'] );
  7962. }
  7963. $cidString=implode ( ',', $cidList );
  7964. $LcategoryList = $Lcategory->find ( array (
  7965. 'where'=>' cid in ('.$cidString.')',
  7966. 'asArray' => true
  7967. ) ); // 'staff='.$this->staff[0]['sid']." and
  7968. $itemStatisticsList = $itemStatistics->find ( array (
  7969. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7970. 'where' => " Year(date)=" . $year,
  7971. 'groupby' => 'cid,Month(date)',
  7972. 'asArray' => true
  7973. ) );
  7974. // ceatre companyCollectHtml
  7975. foreach ( $LcategoryList as $value ) {
  7976. $html = "";
  7977. $asum = 0;
  7978. for($i = 1; $i <= 12; $i ++) {
  7979. $falg = true;
  7980. foreach ( $itemStatisticsList as $v ) {
  7981. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  7982. $asum += $v ['price'];
  7983. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7984. $falg = false;
  7985. break;
  7986. }
  7987. }
  7988. if ($falg)
  7989. $html .= '<td class="taR">-</td>';
  7990. }
  7991. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7992. $collectHtml [$value ['title']] = array (
  7993. 'html' => $html,
  7994. 'cid' => $value ['cid']
  7995. );
  7996. }
  7997. $data ['companyHtml'] = $collectHtml;
  7998. // total price html
  7999. $collectHtml = "";
  8000. $total = 0;
  8001. for($i = 1; $i <= 12; $i ++) {
  8002. $sumPrice = 0;
  8003. foreach ( $itemStatisticsList as $key => $value ) {
  8004. if ($value ['month'] == $i) {
  8005. $sumPrice += $value ['price'];
  8006. }
  8007. }
  8008. if ($sumPrice == 0)
  8009. $collectHtml .= '<td class="taR">-</td>';
  8010. else
  8011. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8012. $total += $sumPrice;
  8013. }
  8014. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8015. $data ['companyTotalHtml'] = $collectHtml;
  8016. $data ['total'] = $total;
  8017. // statistics html
  8018. //echo $cidString;
  8019. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'],$cidString );
  8020. if (empty ( $stList ))
  8021. $stList = array (
  8022. 'rePrice' => 0,
  8023. 'agPrice' => 0
  8024. );
  8025. $data ['stList'] = array (
  8026. 'rePrice' => $stList ['rePrice'],
  8027. 'agPrice' => $stList ['agPrice'],
  8028. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8029. );
  8030. $data ['year'] = $year;
  8031. $data ['memu'] = "receipt";
  8032. $data ['staff'] = $this->staff;
  8033. $data ['receiptMemu'] = 'companyCategoryCollect';
  8034. $data ['verifyId'] = $this->verifyId;
  8035. $data ['executeId'] = $this->executeId;
  8036. // year staff status 2,4
  8037. if ($year < date ( "Y" )) {
  8038. Doo::loadModel ( 'receipt' );
  8039. $receipt = new receipt ();
  8040. $receiptList = $receipt->find ( array (
  8041. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  8042. 'asArray' => true
  8043. ) );
  8044. if (empty ( $receiptList )) {
  8045. ob_start ();
  8046. $this->render ( "/admin/saeaCompanyCollect", $data );
  8047. $this->cacheFile ( $path );
  8048. die ();
  8049. }
  8050. }
  8051. $this->render ( "/admin/saeaCompanyCollect", $data );
  8052. }
  8053. function categoryCollectDetail() {
  8054. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8055. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  8056. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  8057. $this->showCache ( $path );
  8058. Doo::loadModel ( 'statistics' );
  8059. $statistics = new statistics ();
  8060. Doo::loadModel ( "receiptDetail" );
  8061. $receiptDetail = new receiptDetail ();
  8062. Doo::loadModel ( 'L_category' );
  8063. $Lcategory = new L_category ();
  8064. Doo::loadModel ( 'accountItem' );
  8065. $accountItem = new accountItem ();
  8066. Doo::loadModel ( "receiptAuthorityManage" );
  8067. $receiptAuthorityManage = new receiptAuthorityManage ();
  8068. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  8069. $cidList = array ();
  8070. foreach ( $imcStaff as $key => $value ) {
  8071. array_push ( $cidList, $value ['cid'] );
  8072. }
  8073. $cidString=implode ( ',', $cidList );
  8074. $LcategoryList = $Lcategory->find ( array (
  8075. 'where'=>'cid in ('.$cidString.')',
  8076. 'asArray' => true
  8077. ) );
  8078. if ($cid == 0) {
  8079. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  8080. if ($cid == 0)
  8081. $cid = $LcategoryList [0] ['cid'];
  8082. }
  8083. $data ['LcategoryList'] = $LcategoryList;
  8084. $receiptCollectList = $receiptDetail->find ( array (
  8085. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8086. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  8087. 'groupby' => 'item,Month(pastDate)',
  8088. 'asArray' => true
  8089. ) );
  8090. $accountList = $accountItem->find ( array (
  8091. 'asArray' => true
  8092. ) );
  8093. // create CollectDetail HTML
  8094. $collectHtml = array ();
  8095. foreach ( $accountList as $key => $value ) {
  8096. $html = "";
  8097. $asum = 0;
  8098. for($i = 1; $i <= 12; $i ++) {
  8099. $falg = true;
  8100. foreach ( $receiptCollectList as $v ) {
  8101. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  8102. $asum += $v ['price'];
  8103. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8104. $falg = false;
  8105. break;
  8106. }
  8107. }
  8108. if ($falg)
  8109. $html .= '<td class="taR">-</td>';
  8110. }
  8111. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8112. $collectHtml [$value ['category']] [$value ['name']] = $html;
  8113. }
  8114. $data ['collectHtml'] = $collectHtml;
  8115. // create Adjustment price html
  8116. $receiptCollectList = $receiptDetail->find ( array (
  8117. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  8118. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  8119. 'groupby' => 'itemCategory,Month(pastDate)',
  8120. 'asArray' => true
  8121. ) );
  8122. $adjustment = array ();
  8123. $collectArray = array (
  8124. '日常相关费用' => array (),
  8125. '差旅相关费用' => array (),
  8126. '培训班费用' => array (),
  8127. '其他' => array ()
  8128. );
  8129. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  8130. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  8131. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  8132. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  8133. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  8134. array_push ( $collectArray ['培训班费用'], $collectHtml );
  8135. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  8136. array_push ( $collectArray ['其他'], $collectHtml );
  8137. $data ['collectArray'] = $collectArray;
  8138. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  8139. array_push ( $adjustment, $collectHtml );
  8140. $data ['adjustment'] = $adjustment;
  8141. // total price html
  8142. $collectHtml = "";
  8143. $total = 0;
  8144. for($i = 1; $i <= 12; $i ++) {
  8145. $sumPrice = 0;
  8146. foreach ( $receiptCollectList as $key => $value ) {
  8147. if ($value ['month'] == $i) {
  8148. $sumPrice += $value ['price'];
  8149. }
  8150. }
  8151. if ($sumPrice == 0)
  8152. $collectHtml .= '<td class="taR">-</td>';
  8153. else
  8154. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8155. $total += $sumPrice;
  8156. }
  8157. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8158. // statistics html
  8159. $stList = $statistics->statisticsByCid ( $year, $cid );
  8160. if (empty ( $stList ))
  8161. $stList = array (
  8162. 'rePrice' => 0,
  8163. 'agPrice' => 0
  8164. );
  8165. $data ['stList'] = array (
  8166. 'rePrice' => $stList ['rePrice'],
  8167. 'agPrice' => $stList ['agPrice'],
  8168. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8169. );
  8170. $data ['totalYear'] = $total;
  8171. $data ['year'] = $year;
  8172. $data ['cid'] = $cid;
  8173. $data ['memu'] = "receipt";
  8174. $data ['staff'] = $this->staff;
  8175. $data ['receiptMemu'] = 'companyCategoryCollect';
  8176. $data ['verifyId'] = $this->verifyId;
  8177. $data ['executeId'] = $this->executeId;
  8178. // year staff status 2,4
  8179. if ($year < date ( "Y" )) {
  8180. Doo::loadModel ( 'receipt' );
  8181. $receipt = new receipt ();
  8182. $receiptList = $receipt->find ( array (
  8183. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  8184. 'asArray' => true
  8185. ) );
  8186. if (empty ( $receiptList )) {
  8187. ob_start ();
  8188. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  8189. $this->cacheFile ( $path );
  8190. die ();
  8191. }
  8192. }
  8193. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  8194. }
  8195. function staffCollect() {
  8196. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8197. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  8198. // $this->showCache($path);
  8199. Doo::loadModel ( 'statistics' );
  8200. $statistics = new statistics ();
  8201. Doo::loadModel ( "receiptDetail" );
  8202. $receiptDetail = new receiptDetail ();
  8203. Doo::loadModel ( 'L_category' );
  8204. $Lcategory = new L_category ();
  8205. Doo::loadModel ( 'accountItem' );
  8206. $accountItem = new accountItem ();
  8207. Doo::loadModel ( 'staff' );
  8208. $staff = new staff ();
  8209. Doo::loadModel ( 'itemStatistics' );
  8210. $itemStatistics = new itemStatistics ();
  8211. Doo::loadModel ( "receiptAuthorityManage" );
  8212. $receiptAuthorityManage = new receiptAuthorityManage ();
  8213. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  8214. $cidList = array ();
  8215. foreach ( $imcStaff as $key => $value ) {
  8216. array_push ( $cidList, $value ['cid'] );
  8217. }
  8218. $cidString=implode ( ',', $cidList );
  8219. // statistics html
  8220. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'],$cidString );
  8221. if (empty ( $stList ))
  8222. $stList = array (
  8223. 'rePrice' => 0,
  8224. 'agPrice' => 0
  8225. );
  8226. $data ['stList'] = array (
  8227. 'rePrice' => $stList ['rePrice'],
  8228. 'agPrice' => $stList ['agPrice'],
  8229. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8230. );
  8231. // ---
  8232. $staffList = $staff->find ( array (
  8233. 'where' => 'username !="admin"',
  8234. 'asArray' => true
  8235. ) );
  8236. $LcategoryList = $Lcategory->find ( array (
  8237. 'asArray' => true
  8238. ) ); // 'staff='.$this->staff[0]['sid']." and
  8239. $itemStatisticsList = $itemStatistics->find ( array (
  8240. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8241. 'where' => " Year(date)=" . $year.' and cid in ('.$cidString.')',
  8242. 'groupby' => 'staff,Month(date)',
  8243. 'asArray' => true
  8244. ) );
  8245. $categoryList = $staff->find ( array (
  8246. 'select' => 'COUNT(*) as count,cid,category',
  8247. 'where' => 'username !="admin" and cid in ('.$cidString.')',
  8248. 'groupby' => 'cid',
  8249. 'asArray' => true
  8250. ) );
  8251. // print_r($itemStatisticsList);die;
  8252. // ceatre companyCollectHtml
  8253. foreach ( $categoryList as $vlu ) {
  8254. $count = $vlu ['count'] + 1;
  8255. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  8256. $m1 = 0;
  8257. $m2 = 0;
  8258. $m3 = 0;
  8259. $m4 = 0;
  8260. $m5 = 0;
  8261. $m6 = 0;
  8262. $m7 = 0;
  8263. $m8 = 0;
  8264. $m9 = 0;
  8265. $m10 = 0;
  8266. $m11 = 0;
  8267. $m12 = 0;
  8268. $m13 = 0;
  8269. foreach ( $staffList as $value ) {
  8270. if ($vlu ['cid'] == $value ['cid']) {
  8271. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  8272. $asum = 0;
  8273. for($i = 1; $i <= 12; $i ++) {
  8274. $falg = true;
  8275. foreach ( $itemStatisticsList as $v ) {
  8276. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  8277. if ($v ['month'] == 1)
  8278. $m1 += $v ['price'];
  8279. if ($v ['month'] == 2)
  8280. $m2 += $v ['price'];
  8281. if ($v ['month'] == 3)
  8282. $m3 += $v ['price'];
  8283. if ($v ['month'] == 4)
  8284. $m4 += $v ['price'];
  8285. if ($v ['month'] == 5)
  8286. $m5 += $v ['price'];
  8287. if ($v ['month'] == 6)
  8288. $m6 += $v ['price'];
  8289. if ($v ['month'] == 7)
  8290. $m7 += $v ['price'];
  8291. if ($v ['month'] == 8)
  8292. $m8 += $v ['price'];
  8293. if ($v ['month'] == 9)
  8294. $m9 += $v ['price'];
  8295. if ($v ['month'] == 10)
  8296. $m10 += $v ['price'];
  8297. if ($v ['month'] == 11)
  8298. $m11 += $v ['price'];
  8299. if ($v ['month'] == 12)
  8300. $m12 += $v ['price'];
  8301. $asum += $v ['price'];
  8302. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8303. $falg = false;
  8304. break;
  8305. }
  8306. }
  8307. if ($falg)
  8308. $html .= '<td class="taR">-</td>';
  8309. }
  8310. $m13 += $asum;
  8311. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8312. $collectHtml [$value ['username'] . '_' . $value ['sid']] = array (
  8313. 'html' => $html,
  8314. 'sid' => $value ['sid']
  8315. );
  8316. $html = "";
  8317. }
  8318. }
  8319. $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>
  8320. <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>
  8321. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  8322. $collectHtml [$vlu ['cid']] = array (
  8323. 'html' => $hl,
  8324. 'sid' => ''
  8325. );
  8326. }
  8327. $data ['companyHtml'] = $collectHtml;
  8328. // total price html
  8329. $collectHtml = "";
  8330. $total = 0;
  8331. for($i = 1; $i <= 12; $i ++) {
  8332. $sumPrice = 0;
  8333. foreach ( $itemStatisticsList as $key => $value ) {
  8334. if ($value ['month'] == $i) {
  8335. $sumPrice += $value ['price'];
  8336. }
  8337. }
  8338. if ($sumPrice == 0)
  8339. $collectHtml .= '<td class="taR">-</td>';
  8340. else
  8341. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8342. $total += $sumPrice;
  8343. }
  8344. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8345. $data ['companyTotalHtml'] = $collectHtml;
  8346. $data ['total'] = $total;
  8347. $data ['year'] = $year;
  8348. $data ['memu'] = "receipt";
  8349. $data ['staff'] = $this->staff;
  8350. $data ['receiptMemu'] = 'companyCategoryCollect';
  8351. $data ['verifyId'] = $this->verifyId;
  8352. $data ['executeId'] = $this->executeId;
  8353. if ($year <= date ( "Y" )) {
  8354. Doo::loadModel ( 'receipt' );
  8355. $receipt = new receipt ();
  8356. $receiptList = $receipt->find ( array (
  8357. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  8358. 'asArray' => true
  8359. ) );
  8360. if (empty ( $receiptList )) { // generated files
  8361. ob_start ();
  8362. $this->render ( "/admin/saeaStaffCollectB", $data );
  8363. $this->cacheFile ( $path );
  8364. die ();
  8365. }
  8366. }
  8367. $this->render ( "/admin/saeaStaffCollectB", $data );
  8368. }
  8369. function staffCollectBak() {
  8370. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8371. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  8372. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  8373. $this->showCache ( $path );
  8374. Doo::loadModel ( 'statistics' );
  8375. $statistics = new statistics ();
  8376. Doo::loadModel ( "receiptDetail" );
  8377. $receiptDetail = new receiptDetail ();
  8378. Doo::loadModel ( 'L_category' );
  8379. $Lcategory = new L_category ();
  8380. Doo::loadModel ( 'accountItem' );
  8381. $accountItem = new accountItem ();
  8382. Doo::loadModel ( 'staff' );
  8383. $staff = new staff ();
  8384. Doo::loadModel ( 'itemStatistics' );
  8385. $itemStatistics = new itemStatistics ();
  8386. $itemStatisticsList = $itemStatistics->find ( array (
  8387. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8388. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8389. 'groupby' => 'staff,itemCategory,Month(date)',
  8390. 'asArray' => true
  8391. ) );
  8392. $itemCategoryList = $itemStatistics->find ( array (
  8393. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8394. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8395. 'groupby' => 'cid,itemCategory,Month(date)',
  8396. 'asArray' => true
  8397. ) );
  8398. $LcategoryList = $Lcategory->find ( array (
  8399. 'asArray' => true
  8400. ) );
  8401. $staffList = $staff->find ( array (
  8402. 'asArray' => true
  8403. ) );
  8404. $htmlArray = array ();
  8405. foreach ( $LcategoryList as $value ) {
  8406. $htmlArray [$value ['title']] = array ();
  8407. foreach ( $staffList as $v ) {
  8408. if ($value ['cid'] == $v ['cid']) {
  8409. $html = "";
  8410. $falg = true;
  8411. $staffSumPrice = 0;
  8412. foreach ( $itemStatisticsList as $a ) {
  8413. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  8414. if (empty ( $a ['price'] )) {
  8415. $html .= '<td class="taR">-</td>';
  8416. $falg = false;
  8417. break;
  8418. } else {
  8419. $staffSumPrice += $a ['price'];
  8420. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8421. $falg = false;
  8422. break;
  8423. }
  8424. }
  8425. }
  8426. if ($falg) {
  8427. $html .= '<td class="taR">-</td>';
  8428. $falg = true;
  8429. }
  8430. $falg = true;
  8431. foreach ( $itemStatisticsList as $a ) {
  8432. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  8433. if (empty ( $a ['price'] )) {
  8434. $html .= '<td class="taR">-</td>';
  8435. $falg = false;
  8436. break;
  8437. } else {
  8438. $staffSumPrice += $a ['price'];
  8439. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8440. $falg = false;
  8441. break;
  8442. }
  8443. }
  8444. }
  8445. if ($falg) {
  8446. $html .= '<td class="taR">-</td>';
  8447. $falg = true;
  8448. }
  8449. $falg = true;
  8450. foreach ( $itemStatisticsList as $a ) {
  8451. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  8452. if (empty ( $a ['price'] )) {
  8453. $html .= '<td class="taR">-</td>';
  8454. $falg = false;
  8455. break;
  8456. } else {
  8457. $staffSumPrice += $a ['price'];
  8458. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8459. $falg = false;
  8460. break;
  8461. }
  8462. }
  8463. }
  8464. if ($falg) {
  8465. $html .= '<td class="taR">-</td>';
  8466. $falg = true;
  8467. }
  8468. $falg = true;
  8469. foreach ( $itemStatisticsList as $a ) {
  8470. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  8471. if (! empty ( $a ['price'] )) {
  8472. $staffSumPrice += $a ['price'];
  8473. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8474. $falg = false;
  8475. break;
  8476. } else {
  8477. $html .= '<td class="taR">-</td>';
  8478. $falg = false;
  8479. break;
  8480. }
  8481. }
  8482. }
  8483. if ($falg) {
  8484. $html .= '<td class="taR">-</td>';
  8485. $falg = true;
  8486. }
  8487. $falg = true;
  8488. foreach ( $itemStatisticsList as $a ) {
  8489. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  8490. if (! empty ( $a ['price'] )) {
  8491. $staffSumPrice += $a ['price'];
  8492. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8493. $falg = false;
  8494. break;
  8495. } else {
  8496. $html .= '<td class="taR">-</td>';
  8497. $falg = false;
  8498. break;
  8499. }
  8500. }
  8501. }
  8502. if ($falg) {
  8503. $html .= '<td class="taR">-</td>';
  8504. $falg = true;
  8505. }
  8506. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  8507. $htmlArray [$value ['title']] [$v ['username']] = $html;
  8508. }
  8509. }
  8510. /* -- --- */
  8511. // 合计费用
  8512. $cateHtml = "";
  8513. $catePrice = 0;
  8514. $cateFalg = true;
  8515. foreach ( $itemCategoryList as $l ) {
  8516. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  8517. if (empty ( $l ['price'] )) {
  8518. $cateHtml .= '<td class="colGreen taR">-</td>';
  8519. $cateFalg = false;
  8520. break;
  8521. } else {
  8522. $catePrice += $l ['price'];
  8523. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8524. $cateFalg = false;
  8525. break;
  8526. }
  8527. }
  8528. }
  8529. if ($cateFalg) {
  8530. $cateHtml .= '<td class="colGreen taR">-</td>';
  8531. $cateFalg = true;
  8532. }
  8533. $cateFalg = true;
  8534. foreach ( $itemCategoryList as $l ) {
  8535. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  8536. if (empty ( $l ['price'] )) {
  8537. $cateHtml .= '<td class="colGreen taR">-</td>';
  8538. $cateFalg = false;
  8539. break;
  8540. } else {
  8541. $catePrice += $l ['price'];
  8542. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8543. $cateFalg = false;
  8544. break;
  8545. }
  8546. }
  8547. }
  8548. if ($cateFalg) {
  8549. $cateHtml .= '<td class="colGreen taR">-</td>';
  8550. $cateFalg = true;
  8551. }
  8552. $cateFalg = true;
  8553. foreach ( $itemCategoryList as $l ) {
  8554. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  8555. if (empty ( $l ['price'] )) {
  8556. $cateHtml .= '<td class="colGreen taR">-</td>';
  8557. $cateFalg = false;
  8558. break;
  8559. } else {
  8560. $catePrice += $l ['price'];
  8561. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8562. $cateFalg = false;
  8563. break;
  8564. }
  8565. }
  8566. }
  8567. if ($cateFalg) {
  8568. $cateHtml .= '<td class="colGreen taR">-</td>';
  8569. $cateFalg = true;
  8570. }
  8571. $cateFalg = true;
  8572. foreach ( $itemCategoryList as $l ) {
  8573. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  8574. if (empty ( $l ['price'] )) {
  8575. $cateHtml .= '<td class="colGreen taR">-</td>';
  8576. $cateFalg = false;
  8577. break;
  8578. } else {
  8579. $catePrice += $l ['price'];
  8580. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8581. $cateFalg = false;
  8582. break;
  8583. }
  8584. }
  8585. }
  8586. if ($cateFalg) {
  8587. $cateHtml .= '<td class="colGreen taR">-</td>';
  8588. $cateFalg = true;
  8589. }
  8590. $cateFalg = true;
  8591. foreach ( $itemCategoryList as $l ) {
  8592. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  8593. if (empty ( $l ['price'] )) {
  8594. $cateHtml .= '<td class="colGreen taR">-</td>';
  8595. $cateFalg = false;
  8596. break;
  8597. } else {
  8598. $catePrice += $l ['price'];
  8599. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8600. $cateFalg = false;
  8601. break;
  8602. }
  8603. }
  8604. }
  8605. if ($cateFalg) {
  8606. $cateHtml .= '<td class="colGreen taR">-</td>';
  8607. $cateFalg = true;
  8608. }
  8609. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  8610. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  8611. /* -- --- */
  8612. }
  8613. // print_r($htmlArray);die;
  8614. $data ['htmlArray'] = $htmlArray;
  8615. // statistics html
  8616. $stList = $statistics->getOne ( array (
  8617. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8618. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8619. 'groupby' => 'Month(date)',
  8620. 'asArray' => true
  8621. ) );
  8622. if (empty ( $stList ))
  8623. $stList = array (
  8624. 'rePrice' => 0,
  8625. 'agPrice' => 0
  8626. );
  8627. $data ['stList'] = array (
  8628. 'rePrice' => $stList ['rePrice'],
  8629. 'agPrice' => $stList ['agPrice'],
  8630. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8631. );
  8632. $monthHtml = "";
  8633. for($i = 1; $i <= 12; $i ++) {
  8634. if ($i == $month)
  8635. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8636. else
  8637. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8638. }
  8639. $data ['monthHtml'] = $monthHtml;
  8640. $data ['year'] = $year;
  8641. $data ['month'] = $month;
  8642. $data ['memu'] = "receipt";
  8643. $data ['staff'] = $this->staff;
  8644. $data ['receiptMemu'] = 'companyCategoryCollect';
  8645. $data ['verifyId'] = $this->verifyId;
  8646. $data ['executeId'] = $this->executeId;
  8647. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  8648. Doo::loadModel ( 'receipt' );
  8649. $receipt = new receipt ();
  8650. $receiptList = $receipt->find ( array (
  8651. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  8652. 'asArray' => true
  8653. ) );
  8654. if (empty ( $receiptList )) { // generated files
  8655. ob_start ();
  8656. $this->render ( "/admin/saeaStaffCollect", $data );
  8657. $this->cacheFile ( $path );
  8658. die ();
  8659. }
  8660. }
  8661. $this->render ( "/admin/saeaStaffCollect", $data );
  8662. }
  8663. function lyt() {
  8664. Doo::loadModel ( "receiptDetail" );
  8665. $receiptDetail = new receiptDetail ();
  8666. $receiptCollectList = $receiptDetail->find ( array (
  8667. 'where' => 'status=1 ',
  8668. 'asArray' => true
  8669. ) );
  8670. foreach ( $receiptCollectList as $key => $value ) {
  8671. $receiptDetail = new receiptDetail ();
  8672. $receiptDetail->pastDate = $value ['date'];
  8673. $receiptDetail->update ( array (
  8674. 'where' => "rdid= '" . $value ['rdid'] . "'"
  8675. ) );
  8676. }
  8677. }
  8678. function staffCollectMonthDetail() {
  8679. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8680. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8681. if (! $year)
  8682. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8683. if (! $month)
  8684. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8685. Doo::loadModel ( 'staff' );
  8686. $staff = new staff ();
  8687. Doo::loadModel ( "receiptDetail" );
  8688. $receiptDetail = new receiptDetail ();
  8689. Doo::loadModel ( 'accountItem' );
  8690. $accountItem = new accountItem ();
  8691. Doo::loadModel ( 'statistics' );
  8692. $statistics = new statistics ();
  8693. Doo::loadModel ( 'L_category' );
  8694. $lCategory = new L_category ();
  8695. Doo::loadModel ( "receiptAuthorityManage" );
  8696. $receiptAuthorityManage = new receiptAuthorityManage ();
  8697. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  8698. $cidList = array ();
  8699. foreach ( $imcStaff as $key => $value ) {
  8700. array_push ( $cidList, $value ['cid'] );
  8701. }
  8702. $cidString=implode ( ',', $cidList );
  8703. $staffList = $staff->find ( array (
  8704. 'where' => 'username!="admin" and cid in ('.$cidString.')',
  8705. 'asArray' => true
  8706. ) );
  8707. $categoryList = $staff->find ( array (
  8708. 'select' => 'COUNT(*) as count,cid,category',
  8709. 'where' => 'username !="admin" and cid in ('.$cidString.')',
  8710. 'groupby' => 'cid',
  8711. 'asArray' => true
  8712. ) );
  8713. $list = array ();
  8714. foreach ( $categoryList as $vlu ) {
  8715. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8716. $r1 = 0;
  8717. $r2 = 0;
  8718. $r3 = 0;
  8719. $r4 = 0;
  8720. $r5 = 0;
  8721. $r6 = 0;
  8722. $r7 = 0;
  8723. $r8 = 0;
  8724. $r9 = 0;
  8725. $r10 = 0;
  8726. $r11 = 0;
  8727. $r12 = 0;
  8728. $r13 = 0;
  8729. $r14 = 0;
  8730. $r15 = 0;
  8731. $r16 = 0;
  8732. $r17 = 0;
  8733. $r18 = 0;
  8734. $c1 = 0;
  8735. $c2 = 0;
  8736. $c3 = 0;
  8737. $c4 = 0;
  8738. $c5 = 0;
  8739. $c6 = 0;
  8740. $p1 = 0;
  8741. $p2 = 0;
  8742. $p3 = 0;
  8743. $p4 = 0;
  8744. $p5 = 0;
  8745. $p6 = 0;
  8746. $p7 = 0;
  8747. $p8 = 0;
  8748. $p9 = 0;
  8749. $t1 = 0;
  8750. $t2 = 0;
  8751. $t3 = 0;
  8752. $t4 = 0;
  8753. $t5 = 0;
  8754. $s1 = 0;
  8755. $m1 = 0;
  8756. foreach ( $staffList as $value ) {
  8757. if ($vlu ['cid'] == $value ['cid']) {
  8758. // pastDate
  8759. $receiptCollectList = $receiptDetail->find ( array (
  8760. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8761. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8762. 'groupby' => 'item,Month(pastDate),itemCategory',
  8763. 'asArray' => true
  8764. ) );
  8765. // if ($value['sid']==42){
  8766. // print_r($receiptCollectList);die;
  8767. // }
  8768. if (! empty ( $receiptCollectList )) {
  8769. $receiptL = array (
  8770. '日常相关费用' => array (),
  8771. '差旅相关费用' => array (),
  8772. '培训班费用' => array (),
  8773. '其他' => array ()
  8774. );
  8775. $html = "";
  8776. $psum = 0;
  8777. $item = array (
  8778. '市内交通费',
  8779. '市内出租费',
  8780. '办事处房租',
  8781. '电话费',
  8782. '水费',
  8783. '电费',
  8784. '办公费用',
  8785. '邮寄费',
  8786. '其他费用',
  8787. '车辆费用',
  8788. '广告费',
  8789. '团队建设费',
  8790. '物业管理费',
  8791. '宽带费',
  8792. '人员薪酬',
  8793. '公积金',
  8794. '社保'
  8795. );
  8796. foreach ( $item as $va ) {
  8797. $falg = true;
  8798. foreach ( $receiptCollectList as $v ) {
  8799. if ($v ['itemCategory'] == '日常相关费用') {
  8800. if ($v ['item'] == $va) {
  8801. if ($va == '市内交通费')
  8802. $r1 += $v ['price'];
  8803. if ($va == '市内出租费')
  8804. $r2 += $v ['price'];
  8805. if ($va == '办事处房租')
  8806. $r3 += $v ['price'];
  8807. if ($va == '电话费')
  8808. $r4 += $v ['price'];
  8809. if ($va == '水费')
  8810. $r5 += $v ['price'];
  8811. if ($va == '电费')
  8812. $r6 += $v ['price'];
  8813. if ($va == '办公费用')
  8814. $r7 += $v ['price'];
  8815. if ($va == '邮寄费')
  8816. $r8 += $v ['price'];
  8817. if ($va == '其他费用')
  8818. $r9 += $v ['price'];
  8819. if ($va == '车辆费用')
  8820. $r10 += $v ['price'];
  8821. if ($va == '广告费')
  8822. $r11 += $v ['price'];
  8823. if ($va == '团队建设费')
  8824. $r13 += $v ['price'];
  8825. if ($va == '物业管理费')
  8826. $r14 += $v ['price'];
  8827. if ($va == '宽带费')
  8828. $r15 += $v ['price'];
  8829. if ($va == '公积金')
  8830. $r16 += $v ['price'];
  8831. if ($va == '社保')
  8832. $r17 += $v ['price'];
  8833. if ($va == '人员薪酬')
  8834. $r18 += $v ['price'];
  8835. $psum += $v ['price'];
  8836. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8837. $falg = false;
  8838. break;
  8839. }
  8840. }
  8841. }
  8842. if ($falg)
  8843. $html .= '<td class="taR">-</td>';
  8844. }
  8845. $r12 += $psum;
  8846. if (! empty ( $psum ))
  8847. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8848. else
  8849. $psum = '<td class="colGreen taR">-</td>';
  8850. $receiptL ['日常相关费用'] = $psum . $html;
  8851. /* ----------------------------------- */
  8852. $html = "";
  8853. $psum = 0;
  8854. $item = array (
  8855. '往来交通费',
  8856. '市内交通费',
  8857. '出差住宿费',
  8858. '出差补助',
  8859. '其他费用'
  8860. );
  8861. foreach ( $item as $va ) {
  8862. $falg = true;
  8863. foreach ( $receiptCollectList as $v ) {
  8864. if ($v ['itemCategory'] == '差旅相关费用') {
  8865. if ($v ['item'] == $va) {
  8866. if ($va == '往来交通费')
  8867. $c1 += $v ['price'];
  8868. if ($va == '市内交通费')
  8869. $c2 += $v ['price'];
  8870. if ($va == '出差住宿费')
  8871. $c3 += $v ['price'];
  8872. if ($va == '出差补助')
  8873. $c4 += $v ['price'];
  8874. if ($va == '其他费用')
  8875. $c5 += $v ['price'];
  8876. $psum += $v ['price'];
  8877. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8878. $falg = false;
  8879. break;
  8880. }
  8881. }
  8882. }
  8883. if ($falg)
  8884. $html .= '<td class="taR">-</td>';
  8885. }
  8886. $c6 += $psum;
  8887. if (! empty ( $psum ))
  8888. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8889. else
  8890. $psum = '<td class="colGreen taR">-</td>';
  8891. $receiptL ['差旅相关费用'] = $psum . $html;
  8892. /* ------------------------------------- */
  8893. $html = "";
  8894. $psum = 0;
  8895. $item = array (
  8896. '场租费',
  8897. '薪酬',
  8898. '住宿费',
  8899. '交通费',
  8900. '餐饮费',
  8901. '办公费',
  8902. '公关费',
  8903. '其他'
  8904. );
  8905. foreach ( $item as $va ) {
  8906. $falg = true;
  8907. foreach ( $receiptCollectList as $v ) {
  8908. if ($v ['itemCategory'] == '培训班费用') {
  8909. if ($v ['item'] == $va) {
  8910. if ($va == '场租费')
  8911. $p1 += $v ['price'];
  8912. if ($va == '薪酬')
  8913. $p2 += $v ['price'];
  8914. if ($va == '住宿费')
  8915. $p3 += $v ['price'];
  8916. if ($va == '交通费')
  8917. $p4 += $v ['price'];
  8918. if ($va == '餐饮费')
  8919. $p5 += $v ['price'];
  8920. if ($va == '办公费')
  8921. $p6 += $v ['price'];
  8922. if ($va == '公关费')
  8923. $p7 += $v ['price'];
  8924. if ($va == '其他')
  8925. $p8 += $v ['price'];
  8926. $psum += $v ['price'];
  8927. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8928. $falg = false;
  8929. break;
  8930. }
  8931. }
  8932. }
  8933. if ($falg)
  8934. $html .= '<td class="taR">-</td>';
  8935. }
  8936. $p9 += $psum;
  8937. if (! empty ( $psum ))
  8938. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8939. else
  8940. $psum = '<td class="colGreen taR">-</td>';
  8941. $receiptL ['培训班费用'] = $psum . $html;
  8942. /* ------------------------------------- */
  8943. $html = "";
  8944. $psum = 0;
  8945. $item = array (
  8946. '公关费',
  8947. '广告费',
  8948. '借款',
  8949. '可自加费用'
  8950. );
  8951. foreach ( $item as $va ) {
  8952. $falg = true;
  8953. foreach ( $receiptCollectList as $v ) {
  8954. if ($v ['itemCategory'] == '其他') {
  8955. // if ($value['sid']==42){
  8956. //
  8957. // echo var_dump($v['item']);
  8958. // echo var_dump($va);
  8959. // echo var_dump($v['item']==" ".$va);
  8960. // echo $v['item']."==".$va."/<br/>";
  8961. // //print_r( $receiptCollectList);//echo $va;
  8962. // }
  8963. if (trim ( $v ['item'] ) == $va) {
  8964. if ($va == '公关费')
  8965. $t1 += $v ['price'];
  8966. if ($va == '广告费') {
  8967. $t2 += $v ['price'];
  8968. }
  8969. if ($va == '借款')
  8970. $t3 += $v ['price'];
  8971. if ($va == '可自加费用')
  8972. $t4 += $v ['price'];
  8973. $psum += $v ['price'];
  8974. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8975. $falg = false;
  8976. break;
  8977. }
  8978. }
  8979. }
  8980. if ($falg)
  8981. $html .= '<td class="taR">-</td>';
  8982. }
  8983. $t5 += $psum;
  8984. if (! empty ( $psum ))
  8985. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8986. else
  8987. $psum = '<td class="colGreen taR">-</td>';
  8988. $receiptL ['其他'] = $psum . $html;
  8989. /* ------------------------------------- */
  8990. $html = "";
  8991. $psum = 0;
  8992. foreach ( $receiptCollectList as $v ) {
  8993. if ($v ['itemCategory'] == '报销金额调整') {
  8994. if (! empty ( $v ['price'] )) {
  8995. $psum += $v ['price'];
  8996. }
  8997. }
  8998. }
  8999. $s1 += $psum;
  9000. if (! empty ( $psum ))
  9001. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9002. else
  9003. $psum = '<td class="taR colOrange">-</td>';
  9004. $receiptL ['报销金额调整'] = $psum . $html;
  9005. } else {
  9006. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9007. <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>
  9008. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9009. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9010. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9011. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9012. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9013. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9014. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9015. }
  9016. $monthStaffPrice = $receiptDetail->find ( array (
  9017. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9018. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9019. 'groupby' => 'Month(pastDate)',
  9020. 'asArray' => true
  9021. ) );
  9022. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  9023. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  9024. $m1 += $monthStaffPrice [0] ['price'];
  9025. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9026. } else
  9027. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9028. $receiptL ['usernameEn'] = urlencode ( $value ['username'] );
  9029. $list [$value ['username']] = $receiptL;
  9030. }
  9031. }
  9032. $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>
  9033. <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>
  9034. <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>';
  9035. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  9036. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  9037. $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>
  9038. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  9039. $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>';
  9040. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  9041. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  9042. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  9043. }
  9044. $data ['list'] = $list;
  9045. // print_r($list);
  9046. $receiptCollectList = $receiptDetail->find ( array (
  9047. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9048. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9049. 'groupby' => 'item,Month(pastDate),itemCategory',
  9050. 'asArray' => true
  9051. ) );
  9052. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9053. // statistics html
  9054. $stList = $statistics->getOne ( array (
  9055. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9056. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9057. 'groupby' => 'Month(date)',
  9058. 'asArray' => true
  9059. ) );
  9060. if (empty ( $stList ))
  9061. $stList = array (
  9062. 'rePrice' => 0,
  9063. 'agPrice' => 0
  9064. );
  9065. $data ['stList'] = array (
  9066. 'rePrice' => $stList ['rePrice'],
  9067. 'agPrice' => $stList ['agPrice'],
  9068. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9069. );
  9070. $monthHtml = "";
  9071. for($i = 1; $i <= 12; $i ++) {
  9072. if ($i == $month)
  9073. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9074. else
  9075. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9076. }
  9077. $data ['monthHtml'] = $monthHtml;
  9078. $data ['year'] = $year;
  9079. $data ['month'] = $month;
  9080. $data ['memu'] = "receipt";
  9081. $data ['staff'] = $this->staff;
  9082. $data ['receiptMemu'] = 'companyCategoryCollect';
  9083. $data ['verifyId'] = $this->verifyId;
  9084. $data ['executeId'] = $this->executeId;
  9085. $this->render ( "/admin/staffCollectMonthDetail", $data );
  9086. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9087. }
  9088. function staffCollectMonthDetail2() {
  9089. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9090. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9091. if (! $year)
  9092. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9093. if (! $month)
  9094. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9095. Doo::loadModel ( 'staff' );
  9096. $staff = new staff ();
  9097. Doo::loadModel ( "receiptDetail" );
  9098. $receiptDetail = new receiptDetail ();
  9099. Doo::loadModel ( 'accountItem' );
  9100. $accountItem = new accountItem ();
  9101. Doo::loadModel ( 'statistics' );
  9102. $statistics = new statistics ();
  9103. Doo::loadModel ( 'L_category' );
  9104. $lCategory = new L_category ();
  9105. $staffList = $staff->find ( array (
  9106. 'where' => 'username!="admin"',
  9107. 'asArray' => true
  9108. ) );
  9109. $categoryList = $staff->find ( array (
  9110. 'select' => 'COUNT(*) as count,cid,category',
  9111. 'where' => 'username !="admin"',
  9112. 'groupby' => 'cid',
  9113. 'asArray' => true
  9114. ) );
  9115. $list = array ();
  9116. foreach ( $categoryList as $vlu ) {
  9117. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  9118. $r1 = 0;
  9119. $r2 = 0;
  9120. $r3 = 0;
  9121. $r4 = 0;
  9122. $r5 = 0;
  9123. $r6 = 0;
  9124. $r7 = 0;
  9125. $r8 = 0;
  9126. $r9 = 0;
  9127. $r10 = 0;
  9128. $r11 = 0;
  9129. $r12 = 0;
  9130. $r13 = 0;
  9131. $r14 = 0;
  9132. $r15 = 0;
  9133. $c1 = 0;
  9134. $c2 = 0;
  9135. $c3 = 0;
  9136. $c4 = 0;
  9137. $c5 = 0;
  9138. $c6 = 0;
  9139. $p1 = 0;
  9140. $p2 = 0;
  9141. $p3 = 0;
  9142. $p4 = 0;
  9143. $p5 = 0;
  9144. $p6 = 0;
  9145. $p7 = 0;
  9146. $p8 = 0;
  9147. $p9 = 0;
  9148. $t1 = 0;
  9149. $t2 = 0;
  9150. $t3 = 0;
  9151. $t4 = 0;
  9152. $t5 = 0;
  9153. $s1 = 0;
  9154. $m1 = 0;
  9155. foreach ( $staffList as $value ) {
  9156. if ($vlu ['cid'] == $value ['cid']) {
  9157. $receiptCollectList = $receiptDetail->find ( array (
  9158. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9159. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9160. 'groupby' => 'item,Month(date),itemCategory',
  9161. 'asArray' => true
  9162. ) );
  9163. if (! empty ( $receiptCollectList )) {
  9164. $receiptL = array (
  9165. '日常相关费用' => array (),
  9166. '差旅相关费用' => array (),
  9167. '培训班费用' => array (),
  9168. '其他' => array ()
  9169. );
  9170. $html = "";
  9171. $psum = 0;
  9172. $item = array (
  9173. '市内交通费',
  9174. '市内出租费',
  9175. '办事处房租',
  9176. '电话费',
  9177. '水费',
  9178. '电费',
  9179. '办公费用',
  9180. '邮寄费',
  9181. '其他费用',
  9182. '车辆费用',
  9183. '广告费',
  9184. '团队建设费',
  9185. '物业管理费',
  9186. '宽带费'
  9187. );
  9188. foreach ( $item as $va ) {
  9189. $falg = true;
  9190. foreach ( $receiptCollectList as $v ) {
  9191. if ($v ['itemCategory'] == '日常相关费用') {
  9192. if ($v ['item'] == $va) {
  9193. if ($va == '市内交通费')
  9194. $r1 += $v ['price'];
  9195. if ($va == '市内出租费')
  9196. $r2 += $v ['price'];
  9197. if ($va == '办事处房租')
  9198. $r3 += $v ['price'];
  9199. if ($va == '电话费')
  9200. $r4 += $v ['price'];
  9201. if ($va == '水费')
  9202. $r5 += $v ['price'];
  9203. if ($va == '电费')
  9204. $r6 += $v ['price'];
  9205. if ($va == '办公费用')
  9206. $r7 += $v ['price'];
  9207. if ($va == '邮寄费')
  9208. $r8 += $v ['price'];
  9209. if ($va == '其他费用')
  9210. $r9 += $v ['price'];
  9211. if ($va == '车辆费用')
  9212. $r10 += $v ['price'];
  9213. if ($va == '广告费')
  9214. $r11 += $v ['price'];
  9215. if ($va == '团队建设费')
  9216. $r13 += $v ['price'];
  9217. if ($va == '物业管理费')
  9218. $r14 += $v ['price'];
  9219. if ($va == '宽带费')
  9220. $r15 += $v ['price'];
  9221. $psum += $v ['price'];
  9222. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9223. $falg = false;
  9224. break;
  9225. }
  9226. }
  9227. }
  9228. if ($falg)
  9229. $html .= '<td class="taR">-</td>';
  9230. }
  9231. $r12 += $psum;
  9232. if (! empty ( $psum ))
  9233. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9234. else
  9235. $psum = '<td class="colGreen taR">-</td>';
  9236. $receiptL ['日常相关费用'] = $psum . $html;
  9237. /* ----------------------------------- */
  9238. $html = "";
  9239. $psum = 0;
  9240. $item = array (
  9241. '往来交通费',
  9242. '市内交通费',
  9243. '出差住宿费',
  9244. '出差补助',
  9245. '其他费用'
  9246. );
  9247. foreach ( $item as $va ) {
  9248. $falg = true;
  9249. foreach ( $receiptCollectList as $v ) {
  9250. if ($v ['itemCategory'] == '差旅相关费用') {
  9251. if ($v ['item'] == $va) {
  9252. if ($va == '往来交通费')
  9253. $c1 += $v ['price'];
  9254. if ($va == '市内交通费')
  9255. $c2 += $v ['price'];
  9256. if ($va == '出差住宿费')
  9257. $c3 += $v ['price'];
  9258. if ($va == '出差补助')
  9259. $c4 += $v ['price'];
  9260. if ($va == '其他费用')
  9261. $c5 += $v ['price'];
  9262. $psum += $v ['price'];
  9263. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9264. $falg = false;
  9265. break;
  9266. }
  9267. }
  9268. }
  9269. if ($falg)
  9270. $html .= '<td class="taR">-</td>';
  9271. }
  9272. $c6 += $psum;
  9273. if (! empty ( $psum ))
  9274. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9275. else
  9276. $psum = '<td class="colGreen taR">-</td>';
  9277. $receiptL ['差旅相关费用'] = $psum . $html;
  9278. /* ------------------------------------- */
  9279. $html = "";
  9280. $psum = 0;
  9281. $item = array (
  9282. '场租费',
  9283. '薪酬',
  9284. '住宿费',
  9285. '交通费',
  9286. '餐饮费',
  9287. '办公费',
  9288. '公关费',
  9289. '其他'
  9290. );
  9291. foreach ( $item as $va ) {
  9292. $falg = true;
  9293. foreach ( $receiptCollectList as $v ) {
  9294. if ($v ['itemCategory'] == '培训班费用') {
  9295. if ($v ['item'] == $va) {
  9296. if ($va == '场租费')
  9297. $p1 += $v ['price'];
  9298. if ($va == '薪酬')
  9299. $p2 += $v ['price'];
  9300. if ($va == '住宿费')
  9301. $p3 += $v ['price'];
  9302. if ($va == '交通费')
  9303. $p4 += $v ['price'];
  9304. if ($va == '餐饮费')
  9305. $p5 += $v ['price'];
  9306. if ($va == '办公费')
  9307. $p6 += $v ['price'];
  9308. if ($va == '公关费')
  9309. $p7 += $v ['price'];
  9310. if ($va == '其他')
  9311. $p8 += $v ['price'];
  9312. $psum += $v ['price'];
  9313. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9314. $falg = false;
  9315. break;
  9316. }
  9317. }
  9318. }
  9319. if ($falg)
  9320. $html .= '<td class="taR">-</td>';
  9321. }
  9322. $p9 += $psum;
  9323. if (! empty ( $psum ))
  9324. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9325. else
  9326. $psum = '<td class="colGreen taR">-</td>';
  9327. $receiptL ['培训班费用'] = $psum . $html;
  9328. /* ------------------------------------- */
  9329. $html = "";
  9330. $psum = 0;
  9331. $item = array (
  9332. '公关费',
  9333. '广告费',
  9334. '借款',
  9335. '可自加费用'
  9336. );
  9337. foreach ( $item as $va ) {
  9338. $falg = true;
  9339. foreach ( $receiptCollectList as $v ) {
  9340. if ($v ['itemCategory'] == '其他') {
  9341. if ($v ['item'] == $va) {
  9342. if ($va == '公关费')
  9343. $t1 += $v ['price'];
  9344. if ($va == '广告费')
  9345. $t2 += $v ['price'];
  9346. if ($va == '借款')
  9347. $t3 += $v ['price'];
  9348. if ($va == '可自加费用')
  9349. $t4 += $v ['price'];
  9350. $psum += $v ['price'];
  9351. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9352. $falg = false;
  9353. break;
  9354. }
  9355. }
  9356. }
  9357. if ($falg)
  9358. $html .= '<td class="taR">-</td>';
  9359. }
  9360. $t5 += $psum;
  9361. if (! empty ( $psum ))
  9362. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9363. else
  9364. $psum = '<td class="colGreen taR">-</td>';
  9365. $receiptL ['其他'] = $psum . $html;
  9366. /* ------------------------------------- */
  9367. $html = "";
  9368. $psum = 0;
  9369. foreach ( $receiptCollectList as $v ) {
  9370. if ($v ['itemCategory'] == '报销金额调整') {
  9371. if (! empty ( $v ['price'] )) {
  9372. $psum += $v ['price'];
  9373. }
  9374. }
  9375. }
  9376. $s1 += $psum;
  9377. if (! empty ( $psum ))
  9378. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9379. else
  9380. $psum = '<td class="taR colOrange">-</td>';
  9381. $receiptL ['报销金额调整'] = $psum . $html;
  9382. } else {
  9383. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9384. <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>';
  9385. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9386. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9387. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9388. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9389. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9390. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9391. }
  9392. $monthStaffPrice = $receiptDetail->find ( array (
  9393. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9394. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9395. 'asArray' => true
  9396. ) );
  9397. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  9398. $m1 += $monthStaffPrice [0] ['price'];
  9399. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9400. } else
  9401. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9402. $list [$value ['username']] = $receiptL;
  9403. }
  9404. }
  9405. $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>
  9406. <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>
  9407. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  9408. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  9409. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  9410. $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>
  9411. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  9412. $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>';
  9413. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  9414. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  9415. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  9416. }
  9417. $data ['list'] = $list;
  9418. $receiptCollectList = $receiptDetail->find ( array (
  9419. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9420. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9421. 'groupby' => 'item,Month(date),itemCategory',
  9422. 'asArray' => true
  9423. ) );
  9424. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9425. // statistics html
  9426. $stList = $statistics->getOne ( array (
  9427. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9428. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9429. 'groupby' => 'Month(date)',
  9430. 'asArray' => true
  9431. ) );
  9432. if (empty ( $stList ))
  9433. $stList = array (
  9434. 'rePrice' => 0,
  9435. 'agPrice' => 0
  9436. );
  9437. $data ['stList'] = array (
  9438. 'rePrice' => $stList ['rePrice'],
  9439. 'agPrice' => $stList ['agPrice'],
  9440. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9441. );
  9442. $monthHtml = "";
  9443. for($i = 1; $i <= 12; $i ++) {
  9444. if ($i == $month)
  9445. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9446. else
  9447. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9448. }
  9449. $data ['monthHtml'] = $monthHtml;
  9450. $data ['year'] = $year;
  9451. $data ['month'] = $month;
  9452. $data ['memu'] = "receipt";
  9453. $data ['staff'] = $this->staff;
  9454. $data ['receiptMemu'] = 'companyCategoryCollect';
  9455. $data ['verifyId'] = $this->verifyId;
  9456. $data ['executeId'] = $this->executeId;
  9457. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  9458. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9459. }
  9460. /**
  9461. * 用户报销单列表
  9462. */
  9463. function receiptStatisticsStaffDetail() {
  9464. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9465. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9466. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  9467. Doo::loadModel ( "receipt" );
  9468. $receipt = new receipt ();
  9469. Doo::loadModel ( "receiptDetail" );
  9470. $receiptDetail = new receiptDetail ();
  9471. Doo::loadModel ( 'staff' );
  9472. $staff = new staff ();
  9473. Doo::loadModel ( 'accountItem' );
  9474. $accountItem = new accountItem ();
  9475. Doo::loadModel ( 'statistics' );
  9476. $statistics = new statistics ();
  9477. if (! empty ( $username )) {
  9478. $username = addslashes ( urldecode ( $username ) );
  9479. $staffDetail = $staff->getStaffByName ( $username );
  9480. if (empty ( $staffDetail ))
  9481. die ( 'illegal request' );
  9482. $list = $receipt->getReceiptBySid ( $staffDetail ['sid'], $year, $month );
  9483. $itemList = $accountItem->getAccountItem ();
  9484. $itemHtml = '';
  9485. $categoryHtml = '';
  9486. $itemKeyList = array_keys ( $itemList );
  9487. $revisePrice=0;
  9488. // 报销单内容详情
  9489. foreach ( $list as $key => $value ) {
  9490. $accountItemList = json_decode ( $value ['accountItem'], true );
  9491. $list [$key] ['accountItemList'] = $accountItemList;
  9492. $receiptItemHtml = '';
  9493. foreach ( $itemKeyList as $v ) {
  9494. if ($v == '日常相关费用')
  9495. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['agencySum'] . '</td>';
  9496. elseif ($v == '差旅相关费用')
  9497. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['travelSum'] . '</td>';
  9498. elseif ($v == '培训班费用')
  9499. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['trainSum'] . '</td>';
  9500. elseif ($v == '其他')
  9501. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['otherSum'] . '</td>';
  9502. foreach ( $itemList [$v] as $ke => $va ) {
  9503. $falg = true;
  9504. if (! empty ( $accountItemList [$v] )) {
  9505. foreach ( $accountItemList [$v] as $ve ) {
  9506. if ($va ['name'] == $ve ['name']) {
  9507. $receiptItemHtml .= '<td class="taR">' . $ve ['price'] . '</td>';
  9508. $falg = false;
  9509. break;
  9510. }
  9511. }
  9512. }
  9513. if ($falg)
  9514. $receiptItemHtml .= '<td class="taR"></td>';
  9515. }
  9516. }
  9517. //金额调整和费用查看
  9518. $revisePrice+=$value ['revisePrice'];
  9519. $receiptItemHtml .= '<td class="taR">'.$value ['revisePrice'].'</td>';
  9520. $receiptItemHtml .= '<td class="taR"><a href="#detail" data-toggle="modal" onclick=showExplanation("'.$value ['explanation'].'")>查看</a></td>';
  9521. $list [$key] ['receiptItemHtml'] = $receiptItemHtml;
  9522. }
  9523. // 报销单合计
  9524. $receiptTotalList = $receiptDetail->getReceiptTotalItem ( $staffDetail ['sid'], $year, $month );
  9525. $rtl = $receiptDetail->getReceiptTotalItemCategory ( $staffDetail ['sid'], $year, $month );
  9526. $receiptTotalHtml = '';
  9527. // 报销单项目抬头
  9528. foreach ( $itemKeyList as $value ) {
  9529. $count = count ( $itemList [$value] ) + 1;
  9530. $itemHtml .= '<th class="taC" colspan="' . $count . '">' . $value . '</th>';
  9531. $categoryHtml .= '<th class="taC">合计</th>';
  9532. foreach ( $rtl as $rtlValue ) {
  9533. if ($rtlValue ['itemCategory'] == $value) {
  9534. $receiptTotalHtml .= '<th>' . $rtlValue ['price'] . '</th>';
  9535. break;
  9536. }
  9537. }
  9538. foreach ( $itemList [$value] as $k => $v ) {
  9539. $categoryHtml .= '<th class="taC">' . $v ['name'] . '</th>';
  9540. // 合计
  9541. $falg = true;
  9542. foreach ( $receiptTotalList as $ve ) {
  9543. if ($ve ['itemCategory'] == $value && $ve ['item'] == $v ['name']) {
  9544. $receiptTotalHtml .= '<th >' . $ve ['price'] . '</th>';
  9545. $falg = false;
  9546. break;
  9547. }
  9548. }
  9549. if ($falg)
  9550. $receiptTotalHtml .= '<th></th>';
  9551. }
  9552. }
  9553. $receiptTotalHtml .= '<th>'.$revisePrice.'</th>';
  9554. $stList = $statistics->getStatisticsBySid($staffDetail ['sid'], $year, $month);
  9555. if (empty ( $stList ))
  9556. $stList = array (
  9557. 'rePrice' => 0,
  9558. 'agPrice' => 0
  9559. );
  9560. $data ['stList'] = array (
  9561. 'rePrice' => $stList ['rePrice'],
  9562. 'agPrice' => $stList ['agPrice'],
  9563. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9564. );
  9565. $monthHtml = "";
  9566. for($i = 1; $i <= 12; $i ++) {
  9567. if ($i == $month)
  9568. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9569. else
  9570. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9571. }
  9572. $data ['username'] = urlencode ( $username );
  9573. $data ['usernameEN'] = $username ;
  9574. $data ['monthHtml'] = $monthHtml;
  9575. $data ['receiptTotalHtml'] = $receiptTotalHtml;
  9576. $data ['list'] = $list;
  9577. $data ['categoryHtml'] = $categoryHtml;
  9578. $data ['itemHtml'] = $itemHtml;
  9579. $data ['itemList'] = $itemList;
  9580. $data ['year'] = $year;
  9581. $data ['month'] = $month;
  9582. $data ['memu'] = "receipt";
  9583. $data ['staff'] = $this->staff;
  9584. $data ['receiptMemu'] = 'companyCategoryCollect';
  9585. $data ['verifyId'] = $this->verifyId;
  9586. $data ['executeId'] = $this->executeId;
  9587. $this->render ( "/admin/receiptStatisticsStaffDetail", $data );
  9588. }
  9589. die ( 'illegal request' );
  9590. }
  9591. function companyMonthCollectDetail() {
  9592. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9593. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9594. if (! $year)
  9595. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9596. if (! $month)
  9597. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9598. Doo::loadModel ( 'staff' );
  9599. $staff = new staff ();
  9600. Doo::loadModel ( "receiptDetail" );
  9601. $receiptDetail = new receiptDetail ();
  9602. Doo::loadModel ( 'accountItem' );
  9603. $accountItem = new accountItem ();
  9604. Doo::loadModel ( 'statistics' );
  9605. $statistics = new statistics ();
  9606. Doo::loadModel ( 'L_category' );
  9607. $lCategory = new L_category ();
  9608. $staffList = $staff->find ( array (
  9609. 'where' => 'username!="admin"',
  9610. 'asArray' => true
  9611. ) );
  9612. $categoryList = $lCategory->find ( array (
  9613. 'asArray' => true
  9614. ) );
  9615. $list = array ();
  9616. foreach ( $categoryList as $value ) {
  9617. $receiptCollectList = $receiptDetail->find ( array (
  9618. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9619. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9620. 'groupby' => 'item,Month(pastDate),itemCategory',
  9621. 'asArray' => true
  9622. ) );
  9623. if (! empty ( $receiptCollectList )) {
  9624. $receiptL = array (
  9625. '日常相关费用' => array (),
  9626. '差旅相关费用' => array (),
  9627. '培训班费用' => array (),
  9628. '其他' => array ()
  9629. );
  9630. $html = "";
  9631. $psum = 0;
  9632. $item = array (
  9633. '市内交通费',
  9634. '市内出租费',
  9635. '办事处房租',
  9636. '电话费',
  9637. '水费',
  9638. '电费',
  9639. '办公费用',
  9640. '邮寄费',
  9641. '其他费用',
  9642. '车辆费用',
  9643. '广告费',
  9644. '团队建设费'
  9645. );
  9646. foreach ( $item as $va ) {
  9647. $falg = true;
  9648. foreach ( $receiptCollectList as $v ) {
  9649. if ($v ['itemCategory'] == '日常相关费用') {
  9650. if ($v ['item'] == $va) {
  9651. $psum += $v ['price'];
  9652. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9653. $falg = false;
  9654. break;
  9655. }
  9656. }
  9657. }
  9658. if ($falg)
  9659. $html .= '<td class="taR">-</td>';
  9660. }
  9661. if (! empty ( $psum ))
  9662. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  9663. else
  9664. $psum = '<td class="colGreen taR">-</td>';
  9665. $receiptL ['日常相关费用'] = $psum . $html;
  9666. /* ----------------------------------- */
  9667. $html = "";
  9668. $psum = 0;
  9669. $item = array (
  9670. '往来交通费',
  9671. '市内交通费',
  9672. '出差住宿费',
  9673. '出差补助',
  9674. '其他费用'
  9675. );
  9676. foreach ( $item as $va ) {
  9677. $falg = true;
  9678. foreach ( $receiptCollectList as $v ) {
  9679. if ($v ['itemCategory'] == '差旅相关费用') {
  9680. if ($v ['item'] == $va) {
  9681. $psum += $v ['price'];
  9682. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9683. $falg = false;
  9684. break;
  9685. }
  9686. }
  9687. }
  9688. if ($falg)
  9689. $html .= '<td class="taR">-</td>';
  9690. }
  9691. if (! empty ( $psum ))
  9692. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  9693. else
  9694. $psum = '<td class="colGreen taR">-</td>';
  9695. $receiptL ['差旅相关费用'] = $psum . $html;
  9696. /* ------------------------------------- */
  9697. $html = "";
  9698. $psum = 0;
  9699. $item = array (
  9700. '场租费',
  9701. '薪酬',
  9702. '住宿费',
  9703. '交通费',
  9704. '餐饮费',
  9705. '办公费',
  9706. '公关费',
  9707. '其他'
  9708. );
  9709. foreach ( $item as $va ) {
  9710. $falg = true;
  9711. foreach ( $receiptCollectList as $v ) {
  9712. if ($v ['itemCategory'] == '培训班费用') {
  9713. if ($v ['item'] == $va) {
  9714. $psum += $v ['price'];
  9715. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9716. $falg = false;
  9717. break;
  9718. }
  9719. }
  9720. }
  9721. if ($falg)
  9722. $html .= '<td class="taR">-</td>';
  9723. }
  9724. if (! empty ( $psum ))
  9725. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  9726. else
  9727. $psum = '<td class="colGreen taR">-</td>';
  9728. $receiptL ['培训班费用'] = $psum . $html;
  9729. /* ------------------------------------- */
  9730. $html = "";
  9731. $psum = 0;
  9732. $item = array (
  9733. '公关费',
  9734. '广告费',
  9735. '借款',
  9736. '可自加费用'
  9737. );
  9738. foreach ( $item as $va ) {
  9739. $falg = true;
  9740. foreach ( $receiptCollectList as $v ) {
  9741. if ($v ['itemCategory'] == '其他') {
  9742. if ($v ['item'] == $va) {
  9743. $psum += $v ['price'];
  9744. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9745. $falg = false;
  9746. break;
  9747. }
  9748. }
  9749. }
  9750. if ($falg)
  9751. $html .= '<td class="taR">-</td>';
  9752. }
  9753. if (! empty ( $psum ))
  9754. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  9755. else
  9756. $psum = '<td class="colGreen taR">-</td>';
  9757. $receiptL ['其他'] = $psum . $html;
  9758. /* ------------------------------------- */
  9759. $html = "";
  9760. $psum = 0;
  9761. foreach ( $receiptCollectList as $v ) {
  9762. if ($v ['itemCategory'] == '报销金额调整') {
  9763. if (! empty ( $v ['price'] ))
  9764. $psum += $v ['price'];
  9765. }
  9766. }
  9767. if (! empty ( $psum ))
  9768. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  9769. else
  9770. $psum = '<td class="taR colOrange">-</td>';
  9771. $receiptL ['报销金额调整'] = $psum . $html;
  9772. } else {
  9773. $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>
  9774. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9775. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9776. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9777. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9778. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9779. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9780. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9781. }
  9782. $monthStaffPrice = $receiptDetail->find ( array (
  9783. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9784. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9785. 'asArray' => true
  9786. ) );
  9787. if (! empty ( $monthStaffPrice [0] ['price'] ))
  9788. $receiptL ['monthStaffPrice'] = '<td><b>' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9789. else
  9790. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9791. $list [$value ['title']] = $receiptL;
  9792. }
  9793. $data ['list'] = $list;
  9794. $receiptCollectList = $receiptDetail->find ( array (
  9795. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9796. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9797. 'groupby' => 'item,Month(pastDate),itemCategory',
  9798. 'asArray' => true
  9799. ) );
  9800. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9801. // print_r($data['monthPriceHtml']);
  9802. // foreach ($data['monthPriceHtml'] as $value){
  9803. // echo $value;
  9804. // }
  9805. // die;
  9806. // statistics html
  9807. $stList = $statistics->getOne ( array (
  9808. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9809. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9810. 'groupby' => 'Month(date)',
  9811. 'asArray' => true
  9812. ) );
  9813. if (empty ( $stList ))
  9814. $stList = array (
  9815. 'rePrice' => 0,
  9816. 'agPrice' => 0
  9817. );
  9818. $data ['stList'] = array (
  9819. 'rePrice' => $stList ['rePrice'],
  9820. 'agPrice' => $stList ['agPrice'],
  9821. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9822. );
  9823. $monthHtml = "";
  9824. for($i = 1; $i <= 12; $i ++) {
  9825. if ($i == $month)
  9826. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9827. else
  9828. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9829. }
  9830. $data ['monthHtml'] = $monthHtml;
  9831. $data ['year'] = $year;
  9832. $data ['month'] = $month;
  9833. $data ['memu'] = "receipt";
  9834. $data ['staff'] = $this->staff;
  9835. $data ['receiptMemu'] = 'companyCategoryCollect';
  9836. $data ['verifyId'] = $this->verifyId;
  9837. $data ['executeId'] = $this->executeId;
  9838. $this->render ( "/admin/companyMonthCollectDetail", $data );
  9839. }
  9840. function staffCollectDetail() {
  9841. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9842. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  9843. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  9844. if (! $staffname) {
  9845. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  9846. $staffname = urldecode ( $staffname );
  9847. }
  9848. Doo::loadModel ( 'staff' );
  9849. $staff = new staff ();
  9850. Doo::loadModel ( "receiptDetail" );
  9851. $receiptDetail = new receiptDetail ();
  9852. Doo::loadModel ( 'accountItem' );
  9853. $accountItem = new accountItem ();
  9854. Doo::loadModel ( 'statistics' );
  9855. $statistics = new statistics ();
  9856. Doo::loadModel ( 'L_category' );
  9857. $lCategory = new L_category ();
  9858. Doo::loadModel ( "receiptAuthorityManage" );
  9859. $receiptAuthorityManage = new receiptAuthorityManage ();
  9860. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9861. $cidList = array ();
  9862. foreach ( $imcStaff as $key => $value ) {
  9863. array_push ( $cidList, $value ['cid'] );
  9864. }
  9865. $cidString=implode ( ',', $cidList );
  9866. $staffList = $staff->find ( array (
  9867. 'where'=>' cid in ('.$cidString.')',
  9868. 'asArray' => true
  9869. ) );
  9870. $stHtml = '';
  9871. $stTitle = "";
  9872. $staffId = 0;
  9873. $cid = 0;
  9874. $ocid = 0;
  9875. foreach ( $staffList as $value ) {
  9876. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  9877. $stTitle = $value ['category'] . '-' . $value ['username'];
  9878. $staffId = $value ['sid'];
  9879. $cid = $value ['cid'];
  9880. $ocid = $value ['cid'];
  9881. if (! empty ( $value ['othercid'] ))
  9882. $cid = $value ['cid'] . ',' . $value ['othercid'];
  9883. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9884. } elseif ($value ['username'] != 'admin')
  9885. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9886. }
  9887. $data ['lCategoryHtml'] = $lCategory->find ( array (
  9888. 'where' => 'cid in(' . $cid . ')',
  9889. 'asArray' => true
  9890. ) );
  9891. if (empty ( $pcid ))
  9892. $pcid = $ocid;
  9893. $data ['ocid'] = $pcid;
  9894. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  9895. $this->showCache ( $path );
  9896. //
  9897. $receiptCollectList = $receiptDetail->find ( array (
  9898. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9899. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9900. 'groupby' => 'item,Month(pastDate),itemCategory',
  9901. 'asArray' => true
  9902. ) );
  9903. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  9904. // print_r($receiptCollectList);
  9905. $accountList = $accountItem->find ( array (
  9906. 'asArray' => true
  9907. ) );
  9908. // create CollectDetail HTML
  9909. $collectHtml = array ();
  9910. foreach ( $accountList as $key => $value ) {
  9911. $html = "";
  9912. $asum = 0;
  9913. for($i = 1; $i <= 12; $i ++) {
  9914. $falg = true;
  9915. foreach ( $receiptCollectList as $v ) {
  9916. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9917. if ($v ['item'] == '可自加费用') {
  9918. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  9919. }
  9920. $asum += $v ['price'];
  9921. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9922. $falg = false;
  9923. break;
  9924. }
  9925. }
  9926. if ($falg)
  9927. $html .= '<td class="taR">-</td>';
  9928. }
  9929. $html .= '<td class="taR colGreen"><b>' . $asum . '</b></td>';
  9930. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9931. }
  9932. $data ['collectHtml'] = $collectHtml;
  9933. // print_r($collectHtml);
  9934. // create Adjustment price html
  9935. $receiptCollectList = $receiptDetail->find ( array (
  9936. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9937. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9938. 'groupby' => 'itemCategory,Month(pastDate)',
  9939. 'asArray' => true
  9940. ) );
  9941. $adjustment = array ();
  9942. $collectArray = array (
  9943. '日常相关费用' => array (),
  9944. '差旅相关费用' => array (),
  9945. '培训班费用' => array (),
  9946. '其他' => array ()
  9947. );
  9948. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9949. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9950. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9951. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9952. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9953. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9954. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9955. array_push ( $collectArray ['其他'], $collectHtml );
  9956. $data ['collectArray'] = $collectArray;
  9957. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9958. array_push ( $adjustment, $collectHtml );
  9959. $data ['adjustment'] = $adjustment;
  9960. // total price html
  9961. $collectHtml = "";
  9962. $total = 0;
  9963. for($i = 1; $i <= 12; $i ++) {
  9964. $sumPrice = 0;
  9965. foreach ( $receiptCollectList as $key => $value ) {
  9966. if ($value ['month'] == $i) {
  9967. $sumPrice += $value ['price'];
  9968. }
  9969. }
  9970. if ($sumPrice == 0)
  9971. $collectHtml .= '<td class="taR">-</td>';
  9972. else
  9973. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9974. $total += $sumPrice;
  9975. }
  9976. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9977. // statistics html
  9978. $stList = $statistics->statisticsByYear ( $year, $staffId );
  9979. if (empty ( $stList ))
  9980. $stList = array (
  9981. 'rePrice' => 0,
  9982. 'agPrice' => 0
  9983. );
  9984. $data ['stList'] = array (
  9985. 'rePrice' => $stList ['rePrice'],
  9986. 'agPrice' => $stList ['agPrice'],
  9987. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9988. );
  9989. $data ['totalPrice'] = $collectHtml;
  9990. $data ['totalYear'] = $total;
  9991. $data ['stHtml'] = $stHtml;
  9992. $data ['year'] = $year;
  9993. $data ['stTitle'] = $stTitle;
  9994. $data['staffname']=urlencode($staffname);
  9995. $data ['memu'] = "receipt";
  9996. $data ['staff'] = $this->staff;
  9997. $data ['receiptMemu'] = 'companyCategoryCollect';
  9998. $data ['verifyId'] = $this->verifyId;
  9999. $data ['executeId'] = $this->executeId;
  10000. if ($year < date ( "Y" )) {
  10001. Doo::loadModel ( 'receipt' );
  10002. $receipt = new receipt ();
  10003. $receiptList = $receipt->find ( array (
  10004. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  10005. 'asArray' => true
  10006. ) );
  10007. if (empty ( $receiptList )) { // generated files
  10008. ob_start ();
  10009. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  10010. $this->cacheFile ( $path );
  10011. die ();
  10012. }
  10013. }
  10014. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  10015. }
  10016. function BUGFLAG() {
  10017. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  10018. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  10019. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  10020. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  10021. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  10022. if (empty ( $status ))
  10023. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  10024. $page_size = 12;
  10025. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  10026. $vidList = array ();
  10027. $button = 0;
  10028. Doo::loadModel ( 'verify' );
  10029. $verify = new verify ();
  10030. Doo::loadModel ( 'receipt' );
  10031. $receipt = new receipt ();
  10032. Doo::loadModel ( 'staff' );
  10033. $staff = new staff ();
  10034. Doo::loadModel ( 'L_category' );
  10035. $Lcategory = new L_category ();
  10036. $dateCondition = " and Year(date) =" . $year;
  10037. if (! empty ( $month ))
  10038. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  10039. $categoryList = $Lcategory->find ( array (
  10040. 'asArray' => true
  10041. ) );
  10042. $staffList = $staff->find ( array (
  10043. 'where' => 'cid=' . $cid,
  10044. 'asArray' => true
  10045. ) );
  10046. $cateCondition = "";
  10047. $staffCondition = "";
  10048. $approvalCondition = "";
  10049. if (! empty ( $cid ))
  10050. $cateCondition = ' and cid=' . $cid;
  10051. if (! empty ( $sid )) {
  10052. $staffCondition = ' and staff=' . $sid;
  10053. $cateCondition = "";
  10054. }
  10055. $approvalCondition = " and status=" . $status;
  10056. if ($status == 2) {
  10057. // 查找角色审批人
  10058. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  10059. }
  10060. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  10061. $approvalCondition = ' and status=2 ';
  10062. }
  10063. if ($status == 1) {
  10064. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  10065. }
  10066. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  10067. $pageinfo ['page'] = array (
  10068. 'previous' => ''
  10069. );
  10070. if ($status == 0) {
  10071. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  10072. $receiptList = $receipt->find ( array (
  10073. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  10074. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  10075. 'desc' => 'rid',
  10076. 'asArray' => true
  10077. ) );
  10078. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  10079. } else
  10080. $receiptList = $receipt->find ( array (
  10081. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  10082. 'desc' => 'rid',
  10083. 'asArray' => true
  10084. ) );
  10085. $rLRes = $receipt->find ( array (
  10086. '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,
  10087. 'desc' => 'rid',
  10088. 'asArray' => true
  10089. ) );
  10090. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  10091. // print_r($pageinfo);
  10092. $Locate = 0;
  10093. foreach ( $receiptList as $key => $value ) {
  10094. $receiptList [$key] ['Locate'] = $Locate;
  10095. $Locate ++;
  10096. $receiptList [$key] ['reviseDetail'] = array ();
  10097. if (! empty ( $value ['reviseDetail'] ))
  10098. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  10099. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  10100. $categoryDetil = $Lcategory->getOne ( array (
  10101. 'where' => 'cid=' . $value ['cid'],
  10102. 'asArray' => true
  10103. ) );
  10104. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  10105. $verifyList = $verify->getOne ( array (
  10106. 'where' => 'vid=' . $value ['verify'],
  10107. 'asArray' => true
  10108. ) );
  10109. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  10110. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  10111. foreach ( $verifyList as $k => $v ) {
  10112. // init verifyStaff
  10113. $verifyList [$k] ['date'] = "";
  10114. $verifyList [$k] ['opinion'] = "";
  10115. $verifyList [$k] ['status'] = "";
  10116. if (empty ( $verifyStaff )) {
  10117. $verifyList [$k] ['date'] = "";
  10118. $verifyList [$k] ['opinion'] = "";
  10119. if ($v [0] == $this->staff [0] ['sid']) {
  10120. $verifyList [$k] ['status'] = 4;
  10121. $button = 4;
  10122. }
  10123. } else {
  10124. $flag = true;
  10125. foreach ( $verifyStaff as $m => $u ) {
  10126. if ($v [0] == $m) {
  10127. $verifyList [$k] ['date'] = $u ['date'];
  10128. $verifyList [$k] ['opinion'] = $u ['opinion'];
  10129. $verifyList [$k] ['status'] = $u ['status'];
  10130. $flag = false;
  10131. break;
  10132. }
  10133. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  10134. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  10135. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  10136. }
  10137. if ($flag) { // 检测可编辑
  10138. if ($v [0] == $this->staff [0] ['sid']) {
  10139. $verifyList [$k] ['status'] = 4;
  10140. $button = 4;
  10141. }
  10142. }
  10143. }
  10144. }
  10145. $receiptList [$key] ['verifyList'] = $verifyList;
  10146. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  10147. 'where' => 'sid=' . $value ['staff'],
  10148. 'asArray' => true
  10149. ) );
  10150. $receiptList [$key] ['button'] = $button;
  10151. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  10152. }
  10153. // print_r($receiptList);die;
  10154. // $data['verifyDetail']=$verifyDetail;
  10155. $mothHtml = "";
  10156. for($i = 1; $i <= 12; $i ++) {
  10157. if ($month == $i)
  10158. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  10159. else
  10160. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  10161. }
  10162. $data ['mothHtml'] = $mothHtml;
  10163. $data ['page'] = $pageinfo;
  10164. $data ['receiptList'] = $receiptList;
  10165. $data ['receiptApprovalCount'] = count ( $rLRes );
  10166. $data ['status'] = $status;
  10167. $data ['year'] = $year;
  10168. $data ['categoryList'] = $categoryList;
  10169. $data ['staffList'] = $staffList;
  10170. $data ['cid'] = $cid;
  10171. $data ['sid'] = $sid;
  10172. // print_r($receiptList);
  10173. $data ['memu'] = "receipt";
  10174. $data ['staff'] = $this->staff;
  10175. $data ['receiptMemu'] = 'approvalExpenses';
  10176. $data ['verifyId'] = $this->verifyId;
  10177. $data ['executeId'] = $this->executeId;
  10178. $this->render ( "/admin/FALG", $data );
  10179. }
  10180. function ajaxGetReceiptOrder() {
  10181. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  10182. if (! empty ( $receiptOrder )) {
  10183. Doo::loadModel ( 'receipt' );
  10184. $receipt = new receipt ();
  10185. Doo::loadModel ( 'staff' );
  10186. $staff = new staff ();
  10187. $receiptInfo = $receipt->getOne ( array (
  10188. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  10189. 'asArray' => true
  10190. ) );
  10191. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  10192. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  10193. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  10194. </tbody></table><table class="table table table-bordered"><tbody>';
  10195. foreach ( $verifyStaff as $key => $value ) {
  10196. $staffInfo = $staff->getOne ( array (
  10197. 'select' => 'username',
  10198. 'where' => ' sid="' . $key . '"',
  10199. 'asArray' => true
  10200. ) );
  10201. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  10202. }
  10203. $html .= '</tbody></table></div></div>';
  10204. echo json_encode ( array (
  10205. 'status' => 1,
  10206. 'receiptHtml' => $html
  10207. ) );
  10208. die ();
  10209. }
  10210. echo json_encode ( array (
  10211. 'status' => 2,
  10212. 'receiptHtml' => ''
  10213. ) );
  10214. die ();
  10215. }
  10216. function _getMonthCollectDetail($receiptCollectList) {
  10217. if (! empty ( $receiptCollectList )) {
  10218. $receiptL = array (
  10219. '日常相关费用' => array (),
  10220. '差旅相关费用' => array (),
  10221. '培训班费用' => array (),
  10222. '其他' => array ()
  10223. );
  10224. $html = "";
  10225. $psum = 0;
  10226. $item = array (
  10227. '市内交通费',
  10228. '市内出租费',
  10229. '办事处房租',
  10230. '电话费',
  10231. '水费',
  10232. '电费',
  10233. '办公费用',
  10234. '邮寄费',
  10235. '其他费用',
  10236. '车辆费用',
  10237. '广告费',
  10238. '团队建设费',
  10239. '物业管理费',
  10240. '宽带费'
  10241. );
  10242. foreach ( $item as $value ) {
  10243. $falg = true;
  10244. foreach ( $receiptCollectList as $v ) {
  10245. if ($v ['itemCategory'] == '日常相关费用') {
  10246. if ($v ['item'] == $value) {
  10247. $psum += $v ['price'];
  10248. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10249. $falg = false;
  10250. break;
  10251. }
  10252. }
  10253. }
  10254. if ($falg)
  10255. $html .= '<td class="taR">-</td>';
  10256. }
  10257. if (! empty ( $psum ))
  10258. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  10259. else
  10260. $psum = '<td class="colGreen taR">-</td>';
  10261. $receiptL ['日常相关费用'] = $psum . $html;
  10262. /* ----------------------------------- */
  10263. $html = "";
  10264. $psum = 0;
  10265. $item = array (
  10266. '往来交通费',
  10267. '市内交通费',
  10268. '出差住宿费',
  10269. '出差补助',
  10270. '其他费用'
  10271. );
  10272. foreach ( $item as $value ) {
  10273. $falg = true;
  10274. foreach ( $receiptCollectList as $v ) {
  10275. if ($v ['itemCategory'] == '差旅相关费用') {
  10276. if ($v ['item'] == $value) {
  10277. $psum += $v ['price'];
  10278. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10279. $falg = false;
  10280. break;
  10281. }
  10282. }
  10283. }
  10284. if ($falg)
  10285. $html .= '<td class="taR">-</td>';
  10286. }
  10287. if (! empty ( $psum ))
  10288. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  10289. else
  10290. $psum = '<td class="colGreen taR">-</td>';
  10291. $receiptL ['差旅相关费用'] = $psum . $html;
  10292. /* ------------------------------------- */
  10293. $html = "";
  10294. $psum = 0;
  10295. $item = array (
  10296. '场租费',
  10297. '薪酬',
  10298. '住宿费',
  10299. '交通费',
  10300. '餐饮费',
  10301. '办公费',
  10302. '公关费',
  10303. '其他'
  10304. );
  10305. foreach ( $item as $value ) {
  10306. $falg = true;
  10307. foreach ( $receiptCollectList as $v ) {
  10308. if ($v ['itemCategory'] == '培训班费用') {
  10309. if ($v ['item'] == $value) {
  10310. $psum += $v ['price'];
  10311. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10312. $falg = false;
  10313. break;
  10314. }
  10315. }
  10316. }
  10317. if ($falg)
  10318. $html .= '<td class="taR">-</td>';
  10319. }
  10320. if (! empty ( $psum ))
  10321. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  10322. else
  10323. $psum = '<td class="colGreen taR">-</td>';
  10324. $receiptL ['培训班费用'] = $psum . $html;
  10325. /* ------------------------------------- */
  10326. $html = "";
  10327. $psum = 0;
  10328. $item = array (
  10329. '公关费',
  10330. '广告费',
  10331. '借款',
  10332. '可自加费用'
  10333. );
  10334. foreach ( $item as $value ) {
  10335. $falg = true;
  10336. foreach ( $receiptCollectList as $v ) {
  10337. if ($v ['itemCategory'] == '其他') {
  10338. if ($v ['item'] == $value) {
  10339. $psum += $v ['price'];
  10340. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10341. $falg = false;
  10342. break;
  10343. }
  10344. }
  10345. }
  10346. if ($falg)
  10347. $html .= '<td class="taR">-</td>';
  10348. }
  10349. if (! empty ( $psum ))
  10350. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  10351. else
  10352. $psum = '<td class="colGreen taR">-</td>';
  10353. $receiptL ['其他'] = $psum . $html;
  10354. /* ------------------------------------- */
  10355. $html = "";
  10356. $psum = 0;
  10357. foreach ( $receiptCollectList as $v ) {
  10358. if ($v ['itemCategory'] == '报销金额调整') {
  10359. if (! empty ( $v ['price'] ))
  10360. $psum += $v ['price'];
  10361. }
  10362. }
  10363. if (! empty ( $psum ))
  10364. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  10365. else
  10366. $psum = '<td class="taR colOrange">-</td>';
  10367. $receiptL ['报销金额调整'] = $psum . $html;
  10368. } else {
  10369. $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>
  10370. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10371. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  10372. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10373. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  10374. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10375. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10376. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  10377. }
  10378. return $receiptL;
  10379. }
  10380. function eMail() {
  10381. Doo::loadModel ( 'staff' );
  10382. $staff = new staff ();
  10383. Doo::loadModel ( 'receipt' );
  10384. $receipt = new receipt ();
  10385. Doo::loadModel ( 'L_category' );
  10386. $Lcategory = new L_category ();
  10387. Doo::loadModel ( "verify" );
  10388. $verify = new verify ();
  10389. $staffList = $staff->find ( array (
  10390. 'asArray' => true
  10391. ) );
  10392. foreach ( $staffList as $key => $value ) {
  10393. if ($value ['username'] != 'admin') {
  10394. // 提交人
  10395. $receiptList = $receipt->find ( array (
  10396. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  10397. 'asArray' => true
  10398. ) );
  10399. if (! empty ( $receiptList )) {
  10400. $html = '<br><div><style></style>
  10401. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  10402. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  10403. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  10404. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  10405. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  10406. <tbody><tr>
  10407. <td style="padding: 0 40px;" align="left">
  10408. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  10409. </td></tr><tr>
  10410. <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>
  10411. </tr>
  10412. </tbody> </table></td> </tr> <tr><td>
  10413. <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">
  10414. <tbody> <tr><td>
  10415. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  10416. 以下报销单完成了审批,等着收款吧:</p>
  10417. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  10418. foreach ( $receiptList as $k => $v ) {
  10419. $category = $Lcategory->getOne ( array (
  10420. 'where' => 'cid=' . $v ['cid'],
  10421. 'asArray' => true
  10422. ) );
  10423. $html .= '
  10424. <tr>
  10425. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  10426. <td align="left">
  10427. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  10428. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  10429. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  10430. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  10431. </tr>';
  10432. }
  10433. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  10434. <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>
  10435. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  10436. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  10437. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  10438. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  10439. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  10440. $receipt = new receipt ();
  10441. $receipt->notice = 1;
  10442. $receipt->update ( array (
  10443. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  10444. ) );
  10445. }
  10446. }
  10447. // 审批人
  10448. $verifyList = $verify->find ( array (
  10449. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  10450. 'asArray' => true
  10451. ) );
  10452. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  10453. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  10454. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  10455. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  10456. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  10457. <tbody><tr><td style="padding: 0 40px;" align="left">
  10458. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  10459. </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>
  10460. </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">
  10461. <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>
  10462. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  10463. foreach ( $verifyList as $k => $v ) {
  10464. $receiptList = $receipt->find ( array (
  10465. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  10466. 'asArray' => true
  10467. ) );
  10468. foreach ( $receiptList as $r => $l ) {
  10469. $category = $Lcategory->getOne ( array (
  10470. 'where' => 'cid=' . $l ['cid'],
  10471. 'asArray' => true
  10472. ) );
  10473. $staffDetile = $staff->getOne ( array (
  10474. 'where' => 'sid=' . $l ['staff'],
  10475. 'asArray' => true
  10476. ) );
  10477. $html .= '
  10478. <tr>
  10479. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  10480. <td align="left">
  10481. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  10482. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  10483. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  10484. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  10485. </tr>';
  10486. }
  10487. }
  10488. $html .= '
  10489. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  10490. <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>
  10491. </tr></tbody></table></td></tr></tbody></table></div><br>';
  10492. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  10493. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  10494. // $receipt=new receipt();
  10495. // $receipt->notice=1;
  10496. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  10497. }
  10498. }
  10499. }
  10500. }
  10501. function setWXMsg($rid, $type) {
  10502. Doo::loadModel ( "receipt" );
  10503. $receipt = new receipt ();
  10504. $receiptDetail = $receipt->getOne ( array (
  10505. 'where' => 'rid=' . $rid,
  10506. 'asArray' => true
  10507. ) );
  10508. if (! empty ( $receiptDetail )) {
  10509. Doo::loadModel ( 'staff' );
  10510. $staff = new staff ();
  10511. $staffmsg = $staff->getOne ( array (
  10512. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  10513. 'asArray' => TRUE
  10514. ) );
  10515. if (! empty ( $staffmsg ['wxid'] )) {
  10516. require_once (SITE_PATH . '/protected/class/client.php');
  10517. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  10518. $user = $staffmsg ['wxid'];
  10519. $receiptName = '';
  10520. $msg = '';
  10521. switch ($receiptDetail ['Rtype']) {
  10522. case 0 :
  10523. $receiptName = '报销';
  10524. break;
  10525. case 1 :
  10526. $receiptName = '借款';
  10527. break;
  10528. case 2 :
  10529. $receiptName = '对公汇款';
  10530. break;
  10531. }
  10532. switch ($type) {
  10533. case 1 :
  10534. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  10535. break;
  10536. case 2 :
  10537. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  10538. break;
  10539. case 3 :
  10540. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  10541. break;
  10542. }
  10543. // $result = $client->SendMsg ( $user, $msg, 'text' );
  10544. }
  10545. }
  10546. }
  10547. // Email发送函数
  10548. function SMail($toemail, $subject, $contents) {
  10549. Doo::loadClass ( 'class.phpmailer' );
  10550. $mail = new PHPMailer ();
  10551. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  10552. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  10553. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  10554. $mail->Password = "cDO1GjtY1seH"; // 密码
  10555. $mail->CharSet = "UTF8";
  10556. $mail->SMTPAuth = true;
  10557. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  10558. $mail->Mailer = "smtp";
  10559. $mail->Port = 25;
  10560. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  10561. $mail->MsgHTML ( $contents );
  10562. $mail->AddAddress ( $toemail );
  10563. $mail->CharSet = "UTF-8";
  10564. return $mail->Send ();
  10565. }
  10566. function swfupload() {
  10567. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  10568. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  10569. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  10570. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  10571. header ( "HTTP/1.1 500 Internal Server Error" );
  10572. echo "POST exceeded maximum allowed size.";
  10573. exit ( 0 );
  10574. }
  10575. // Settings
  10576. $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)
  10577. $upload_name = "Filedata";
  10578. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  10579. $extension_whitelist = array (
  10580. "doc",
  10581. "txt",
  10582. "jpg",
  10583. "gif",
  10584. "png"
  10585. ); // Allowed file extensions
  10586. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  10587. // Other variables
  10588. $MAX_FILENAME_LENGTH = 260;
  10589. $file_name = "";
  10590. $file_extension = "";
  10591. $uploadErrors = array (
  10592. 0 => "文件上传成功",
  10593. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  10594. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  10595. 3 => "上传的文件仅为部分文件",
  10596. 4 => "没有文件上传",
  10597. 6 => "缺少临时文件夹"
  10598. );
  10599. $nk = time ();
  10600. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  10601. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  10602. echo "文件无法保存.";
  10603. exit ( 0 );
  10604. }
  10605. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  10606. echo json_encode ( array (
  10607. 'filename' => $file_name,
  10608. 'id' => $nk
  10609. ) );
  10610. exit ( 0 );
  10611. }
  10612. function _GetFileEXT($filename) {
  10613. $pics = explode ( '.', $filename );
  10614. $num = count ( $pics );
  10615. return $pics [$num - 1];
  10616. }
  10617. /**
  10618. * 获取get或者POST值
  10619. * @param string $name 属性名称
  10620. * @return fixed 值
  10621. */
  10622. function get_args($name) {
  10623. if (isset ( $_GET [$name] )) {
  10624. if (is_array ( $_GET [$name] ))
  10625. return $_GET [$name];
  10626. else
  10627. return addslashes ( $_GET [$name] );
  10628. } elseif (isset ( $_POST [$name] )) {
  10629. if (is_array ( $_POST [$name] ))
  10630. return $_POST [$name];
  10631. else
  10632. return addslashes ( $_POST [$name] );
  10633. } else
  10634. return false;
  10635. }
  10636. function num_to_rmb($num) {
  10637. $c1 = "零壹贰叁肆伍陆柒捌玖";
  10638. $c2 = "分角元拾佰仟万拾佰仟亿";
  10639. // 精确到分后面就不要了,所以只留两个小数位
  10640. $num = round ( $num, 2 );
  10641. // 将数字转化为整数
  10642. $num = $num * 100;
  10643. if (strlen ( $num ) > 10) {
  10644. return "金额太大,请检查";
  10645. }
  10646. $i = 0;
  10647. $c = "";
  10648. while ( 1 ) {
  10649. if ($i == 0) {
  10650. // 获取最后一位数字
  10651. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  10652. } else {
  10653. $n = $num % 10;
  10654. }
  10655. // 每次将最后一位数字转化为中文
  10656. $p1 = substr ( $c1, 3 * $n, 3 );
  10657. $p2 = substr ( $c2, 3 * $i, 3 );
  10658. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  10659. $c = $p1 . $p2 . $c;
  10660. } else {
  10661. $c = $p1 . $c;
  10662. }
  10663. $i = $i + 1;
  10664. // 去掉数字最后一位了
  10665. $num = $num / 10;
  10666. // echo $num.'</br>';
  10667. $num = (int)$num;
  10668. // $num =floor($num);
  10669. //$num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  10670. // echo $num.'</br>';
  10671. // 结束循环
  10672. if ($num == 0) {
  10673. break;
  10674. }
  10675. }
  10676. // echo $c.'</br>';
  10677. $j = 0;
  10678. $slen = strlen ( $c );
  10679. while ( $j < $slen ) {
  10680. // utf8一个汉字相当3个字符
  10681. $m = substr ( $c, $j, 6 );
  10682. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  10683. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  10684. $left = substr ( $c, 0, $j );
  10685. $right = substr ( $c, $j + 3 );
  10686. $c = $left . $right;
  10687. $j = $j - 3;
  10688. $slen = $slen - 3;
  10689. }
  10690. $j = $j + 3;
  10691. }
  10692. // 这个是为了去掉类似23.0中最后一个“零”字
  10693. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  10694. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  10695. }
  10696. // 将处理的汉字加上“整”
  10697. if (empty ( $c )) {
  10698. return "零元整";
  10699. } else {
  10700. return $c . "整";
  10701. }
  10702. }
  10703. /**
  10704. * 获得分页数据
  10705. * @param unknown_type $table
  10706. * @param unknown_type $condition
  10707. * @param unknown_type $on_page
  10708. * @param unknown_type $page_size
  10709. */
  10710. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  10711. $page_c = "";
  10712. $page ['previous'] = $this->get_previous ( $on_page );
  10713. $page ['on_page'] = $on_page;
  10714. $total_count = $this->get_table_count ( $table, $condition );
  10715. $total = intval ( $total_count / $page_size );
  10716. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  10717. $page ['total_data'] = $total_count;
  10718. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  10719. $i = 1;
  10720. $page_max = 1;
  10721. $page_width = 3;
  10722. if ($on_page >= $page_width) {
  10723. $page_max = intval ( $on_page / $page_width ) + 1;
  10724. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  10725. }
  10726. for(; $i <= $page ['total_page']; $i ++) {
  10727. if ($i == $on_page)
  10728. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  10729. else
  10730. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  10731. if ($i == ($page_width * $page_max))
  10732. break;
  10733. }
  10734. $page ['page'] = $page_c;
  10735. $page ['lower'] = (-- $on_page) * $page_size;
  10736. return $page;
  10737. }
  10738. /**
  10739. * 获取总页数
  10740. * @param unknown_type $table
  10741. * @param unknown_type $condition
  10742. */
  10743. public function get_table_count($table = "", $condition = "") {
  10744. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10745. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10746. // echo $sql;die;
  10747. $query = Doo::db ()->query ( $sql );
  10748. $result = $query->fetch ();
  10749. return $result ['count'];
  10750. }
  10751. /**
  10752. * 获取上一页
  10753. * @param unknown_type $on_page
  10754. */
  10755. function get_previous($on_page = 1) {
  10756. return $on_page != 0 ? $on_page - 1 : $on_page;
  10757. }
  10758. }
  10759. ?>