ReceiptController.php 453 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186
  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. Doo::loadModel ( 'staff' );
  69. $staff = new staff ();
  70. $detail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
  71. $accessModular = 'RECEIPTS';
  72. if (empty ( $detail ['cldAccessArray'] ))
  73. die ( 'illegal request' );
  74. else {
  75. if (in_array ( $accessModular, $detail ['cldAccessArray'] )) {
  76. if (Doo::acl ()->isAllowed ( $accessModular, $resource, $action )) {
  77. $flag = true;
  78. } else {
  79. $flag = false;
  80. }
  81. } else {
  82. die ( 'illegal request' );
  83. }
  84. }
  85. if (! $flag)
  86. die ( 'illegal request' );
  87. }
  88. function __construct() {
  89. if (isset ( $_COOKIE ["staff"] )) {
  90. if (! empty ( $_COOKIE ["staff"] )) {
  91. Doo::loadModel ( 'staff' );
  92. Doo::loadModel ( 'verify' );
  93. $verify = new verify ();
  94. $staff = new staff ();
  95. Doo::loadModel ( "execute" );
  96. $execute = new execute ();
  97. $verifyList = $verify->find ( array (
  98. 'select' => 'staff',
  99. 'asArray' => true
  100. ) );
  101. $list = array ();
  102. // 判断角色的审批权限
  103. foreach ( $verifyList as $key => $value ) {
  104. $ver = json_decode ( $value ['staff'] );
  105. foreach ( $ver as $k => $v ) {
  106. if ($v [1] == 'ROLE') {
  107. $roleList = json_decode ( $v [3] );
  108. foreach ( $roleList as $t => $g ) {
  109. $gList = explode ( "_", $g );
  110. array_push ( $list, $gList [0] );
  111. // print_r($list);
  112. }
  113. } else
  114. array_push ( $list, $v [0] );
  115. }
  116. }
  117. // 判断执行人的审批权限
  118. $executeList = $execute->find ( array (
  119. 'select' => 'staff',
  120. 'asArray' => true
  121. ) );
  122. $list2 = array ();
  123. foreach ( $executeList as $key => $value ) {
  124. $ver = json_decode ( $value ['staff'] );
  125. foreach ( $ver as $k => $v ) {
  126. array_push ( $list2, $v [0] );
  127. }
  128. }
  129. $eidList = file_get_contents ( "protected/config/execute/execute.ini" );
  130. $eidList = array_filter ( explode ( ",", $eidList ) );
  131. $this->executeId = array_merge ( $list2, $eidList );
  132. $this->verifyId = $list;
  133. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  134. // 检测用户信息完成
  135. $this->data ['isStaffCompleteMsg'] = false;
  136. $detail = $staff->checkStaffInfoIsComplete ( $_COOKIE ["staff"] );
  137. if (! empty ( $detail ))
  138. $this->data ['isStaffCompleteMsg'] = true;
  139. return "/";
  140. }
  141. }
  142. Doo::loadCore ( 'uri/DooUriRouter' );
  143. $router = new DooUriRouter ();
  144. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  145. if ($routeRs ['1'] != "login") {
  146. header ( 'Content-Type:text/html;charset=utf-8' );
  147. @header ( "Location: /login" );
  148. }
  149. }
  150. function saeaBorad() {
  151. Doo::loadModel ( 'receipt' );
  152. Doo::loadModel ( 'verify' );
  153. $verify = new verify ();
  154. $receipt = new receipt ();
  155. Doo::loadModel ( 'L_category' );
  156. $lCategory = new L_category ();
  157. Doo::loadModel ( "role" );
  158. $role = new role ();
  159. Doo::loadModel ( "receiptLog" );
  160. $receiptLog = new receiptLog ();
  161. Doo::loadClass ( 'XDeode' );
  162. $XDeode = new XDeode ( 7 );
  163. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  164. $receiptDetail = $receipt->find ( array (
  165. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  166. 'desc' => 'rid',
  167. 'asArray' => true
  168. ) );
  169. foreach ( $receiptDetail as $key => $value ) {
  170. $receiptDetail [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  171. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  172. $veList = $verify->getOne ( array (
  173. 'where' => 'vid=' . $value ['verify'],
  174. 'asArray' => true
  175. ) );
  176. $v = json_decode ( $veList ['staff'] );
  177. array_push ( $v [0], $veList ['description'] );
  178. foreach ( $v as $n => $m ) {
  179. if ($m ['1'] == 'ROLE') {
  180. $roleInfo = $role->getOne ( array (
  181. 'where' => 'rid=' . $m [0],
  182. 'asArray' => true
  183. ) );
  184. $v [$n] [1] = $roleInfo ['name'];
  185. }
  186. }
  187. $receiptDetail [$key] ['staff'] = $v;
  188. $category = $lCategory->getOne ( array (
  189. 'where' => 'cid=' . $value ['cid'],
  190. 'asArray' => true
  191. ) );
  192. $receiptDetail [$key] ['category'] = $category ['title'];
  193. }
  194. // print_r($receiptLogList);
  195. $data ['receiptLogList'] = $receiptLogList;
  196. $data ['receiptDetail'] = $receiptDetail;
  197. $data ['memu'] = "receipt";
  198. $data ['staff'] = $this->staff;
  199. $data ['receiptMemu'] = 'saeaBorad';
  200. $data ['verifyId'] = $this->verifyId;
  201. $data ['executeId'] = $this->executeId;
  202. $this->render ( "/admin/saeaBorad", $data );
  203. }
  204. function remitAdd() {
  205. Doo::loadModel ( 'accountItem' );
  206. Doo::loadModel ( 'verify' );
  207. Doo::loadModel ( 'receipt' );
  208. Doo::loadModel ( 'L_category' );
  209. $lCategory = new L_category ();
  210. $receipt = new receipt ();
  211. $verify = new verify ();
  212. $accountItem = new accountItem ();
  213. Doo::loadModel ( "role" );
  214. $role = new role ();
  215. $acItem = $accountItem->find ( array (
  216. 'asArray' => true
  217. ) );
  218. $veList = $verify->find ( array (
  219. 'asArray' => true
  220. ) );
  221. foreach ( $veList as $key => $value ) {
  222. $v = json_decode ( $value ['staff'] );
  223. $list = array ();
  224. foreach ( $v as $n => $m ) {
  225. if ($m ['1'] == 'ROLE') {
  226. $roleInfo = $role->getOne ( array (
  227. 'where' => 'rid=' . $m [0],
  228. 'asArray' => true
  229. ) );
  230. $v [$n] [1] = $roleInfo ['name'];
  231. array_push ( $list, $roleInfo ['name'] );
  232. } else {
  233. array_push ( $list, $v [$n] [1] );
  234. }
  235. }
  236. $veList [$key] ['staff'] = implode ( '>', $list );
  237. }
  238. $data ['category'] = $lCategory->find ( array (
  239. 'asArray' => true
  240. ) );
  241. $data ['veList'] = $veList;
  242. $data ['acItem'] = $acItem;
  243. $data ['memu'] = "receipt";
  244. $data ['staff'] = $this->staff;
  245. $data ['receiptMemu'] = 'saeaBorad';
  246. $data ['verifyId'] = $this->verifyId;
  247. $data ['executeId'] = $this->executeId;
  248. $this->render ( "/admin/remitAdd", $data );
  249. }
  250. function remitAddDo() {
  251. $agency = $this->get_args ( 'agency' );
  252. $travel = $this->get_args ( 'travel' );
  253. $train = $this->get_args ( 'train' );
  254. $other = $this->get_args ( 'other' );
  255. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  256. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  257. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  258. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  259. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  260. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  261. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  262. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  263. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  264. // print_r($agency);die;
  265. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  266. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  267. header ( 'Content-Type:text/html;charset=utf-8' );
  268. die ( '请填写联行号' );
  269. }
  270. Doo::loadModel ( 'receipt' );
  271. Doo::loadModel ( 'receiptDetail' );
  272. Doo::loadModel ( 'accountItem' );
  273. $accountItem = new accountItem ();
  274. $receipt = new receipt ();
  275. Doo::loadModel ( 'enclosur' );
  276. Doo::loadModel ( 'execute' );
  277. $execute = new execute ();
  278. $executeDetail = $execute->getOne ( array (
  279. 'where' => 'mold="对公汇款执行人"',
  280. 'asArray' => true
  281. ) );
  282. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  283. $aItem = $accountItem->find ( array (
  284. 'where' => 'name like "办公费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保"',
  285. 'asArray' => true
  286. ) );
  287. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  288. $ag = $tr = $ta = $ot = 0;
  289. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  290. foreach ( $aItem as $key => $value ) {
  291. if ($value ['category'] == $this->AGENCY) {
  292. if (isset ( $agency [$ag] )) {
  293. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  294. array_push ( $accountJson [$this->AGENCY], array (
  295. 'aid' => $value ['aid'],
  296. 'name' => $value ['name'],
  297. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  298. ) );
  299. $sum += $agency [$ag];
  300. $agencySum += $agency [$ag];
  301. }
  302. }
  303. $ag ++;
  304. }
  305. }
  306. $accountJson ['cSum'] = array (
  307. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  308. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  309. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  310. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  311. );
  312. // 报销单
  313. $receipt->accountItem = json_encode ( $accountJson );
  314. $receipt->staff = $this->staff [0] ['sid'];
  315. $receipt->sum = number_format ( $sum, 2, '.', '' );
  316. $receipt->date = date ( "Y-m-d" );
  317. $receipt->cid = $cid;
  318. $receipt->status = 5;
  319. $receipt->Rtype = 2;
  320. // 修改审批流程加入角色
  321. $receipt->verify = $verify;
  322. $receipt->executeCopy = $executeDetail ['staff'];
  323. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  324. $order = array (
  325. "\r\n",
  326. "\n",
  327. "\r"
  328. );
  329. $replace = '<br/>';
  330. $explanation = str_replace ( $order, $replace, $explanation );
  331. $receipt->explanation = $explanation;
  332. $receipt->remittanceName = $remittanceName;
  333. $receipt->bankName = $bankName;
  334. $receipt->bankNumber = $bankNumber;
  335. $receipt->remittanceBankType = $remittanceBankType;
  336. if ($remittanceBankType == 1)
  337. $receipt->coupletNumber = $coupletNumber;
  338. $rid = $receipt->insert ();
  339. // 附件
  340. if (! empty ( $enclosurName )) {
  341. $enclosurArray = explode ( '-', $enclosurName );
  342. foreach ( $enclosurArray as $value ) {
  343. $enclosur = new enclosur ();
  344. $enclosur->name = $value;
  345. $enclosur->rid = $rid;
  346. $enclosur->insert ();
  347. }
  348. // print_r($enclosurArray);die;
  349. }
  350. // 报销详情
  351. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  352. $receiptDetail = new receiptDetail ();
  353. $receiptDetail->staff = $this->staff [0] ['sid'];
  354. $receiptDetail->item = $value ['name'];
  355. $receiptDetail->itemCategory = $this->AGENCY;
  356. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  357. $receiptDetail->date = date ( "Y-m-d" );
  358. $receiptDetail->cid = $cid;
  359. $receiptDetail->rid = $rid;
  360. $receiptDetail->status = 4;
  361. $receiptDetail->insert ();
  362. }
  363. return "/saeaBorad";
  364. } else
  365. die ( 'illegal request' );
  366. }
  367. function remitEdit() {
  368. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  369. Doo::loadClass ( 'XDeode' );
  370. $XDeode = new XDeode ( 7 );
  371. $rid = $XDeode->decode ( $ridKey );
  372. if (! is_numeric ( $rid ))
  373. die ( 'illegal request' );
  374. Doo::loadModel ( 'accountItem' );
  375. Doo::loadModel ( 'verify' );
  376. Doo::loadModel ( 'receipt' );
  377. $receipt = new receipt ();
  378. $verify = new verify ();
  379. $accountItem = new accountItem ();
  380. Doo::loadModel ( 'L_category' );
  381. $lCategory = new L_category ();
  382. Doo::loadModel ( "role" );
  383. $role = new role ();
  384. Doo::loadModel ( 'enclosur' );
  385. $enclosur = new enclosur ();
  386. $receiptDetail = $receipt->getOne ( array (
  387. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  388. 'asArray' => true
  389. ) );
  390. if (empty ( $receiptDetail ))
  391. return "/saeaCreate";
  392. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  393. $acItem = $accountItem->find ( array (
  394. 'asArray' => true
  395. ) );
  396. $veList = $verify->find ( array (
  397. 'asArray' => true
  398. ) );
  399. foreach ( $veList as $key => $value ) {
  400. $v = json_decode ( $value ['staff'] );
  401. $list = array ();
  402. foreach ( $v as $n => $m ) {
  403. if ($m ['1'] == 'ROLE') {
  404. $roleInfo = $role->getOne ( array (
  405. 'where' => 'rid=' . $m [0],
  406. 'asArray' => true
  407. ) );
  408. $v [$n] [1] = $roleInfo ['name'];
  409. array_push ( $list, $roleInfo ['name'] );
  410. } else {
  411. array_push ( $list, $v [$n] [1] );
  412. }
  413. }
  414. $veList [$key] ['staff'] = implode ( '>', $list );
  415. }
  416. // 配置编辑信息
  417. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  418. foreach ( $acItem as $key => $value ) {
  419. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  420. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  421. $acItem [$key] ['price'] = $v ['price'];
  422. }
  423. }
  424. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  425. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  426. $acItem [$key] ['price'] = $v ['price'];
  427. }
  428. }
  429. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  430. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  431. $acItem [$key] ['price'] = $v ['price'];
  432. }
  433. }
  434. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  435. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  436. $acItem [$key] ['price'] = $v ['price'];
  437. }
  438. }
  439. }
  440. $data ['category'] = $lCategory->find ( array (
  441. 'asArray' => true
  442. ) );
  443. $data ['enclosurList'] = $enclosurList;
  444. $data ['cSum'] = $accountItemList ['cSum'];
  445. $data ['sum'] = $receiptDetail ['sum'];
  446. $data ['receiptDetail'] = $receiptDetail;
  447. $data ['veList'] = $veList;
  448. $data ['acItem'] = $acItem;
  449. $data ['memu'] = "receipt";
  450. $data ['staff'] = $this->staff;
  451. $data ['receiptMemu'] = 'saeaBorad';
  452. $data ['verify'] = $receiptDetail ['verify'];
  453. $data ['verifyId'] = $this->verifyId;
  454. $data ['executeId'] = $this->executeId;
  455. $data ['rid'] = $rid;
  456. $data ['ridKey'] = $ridKey;
  457. $this->render ( "/admin/remitEdit", $data );
  458. }
  459. function remitEdiDo() {
  460. $agency = $this->get_args ( 'agency' );
  461. $travel = $this->get_args ( 'travel' );
  462. $train = $this->get_args ( 'train' );
  463. $other = $this->get_args ( 'other' );
  464. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  465. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  466. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  467. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  468. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  469. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  470. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  471. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  472. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  473. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  474. Doo::loadClass ( 'XDeode' );
  475. $XDeode = new XDeode ( 7 );
  476. $rid = $XDeode->decode ( $ridKey );
  477. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  478. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  479. header ( 'Content-Type:text/html;charset=utf-8' );
  480. die ( '请填写联行号' );
  481. }
  482. Doo::loadModel ( 'receipt' );
  483. Doo::loadModel ( 'receiptDetail' );
  484. Doo::loadModel ( 'accountItem' );
  485. $accountItem = new accountItem ();
  486. $receipt = new receipt ();
  487. Doo::loadModel ( 'enclosur' );
  488. $enclosur = new enclosur ();
  489. Doo::loadModel ( 'execute' );
  490. $execute = new execute ();
  491. $executeDetail = $execute->getOne ( array (
  492. 'where' => 'mold="对公汇款执行人"',
  493. 'asArray' => true
  494. ) );
  495. $receiptDetail = $receipt->getOne ( array (
  496. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  497. 'asArray' => true
  498. ) );
  499. if (empty ( $receiptDetail ))
  500. return "/saeaBorad";
  501. $aItem = $accountItem->find ( array (
  502. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  503. 'asArray' => true
  504. ) );
  505. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  506. $ag = $tr = $ta = $ot = 0;
  507. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  508. foreach ( $aItem as $key => $value ) {
  509. if ($value ['category'] == $this->AGENCY) {
  510. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  511. array_push ( $accountJson [$this->AGENCY], array (
  512. 'aid' => $value ['aid'],
  513. 'name' => $value ['name'],
  514. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  515. ) );
  516. $sum += $agency [$ag];
  517. $agencySum += $agency [$ag];
  518. }
  519. $ag ++;
  520. }
  521. }
  522. $accountJson ['cSum'] = array (
  523. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  524. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  525. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  526. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  527. );
  528. // 报销单
  529. $rid = $receipt->rid = $receiptDetail ['rid'];
  530. $receipt->accountItem = json_encode ( $accountJson );
  531. $receipt->staff = $this->staff [0] ['sid'];
  532. $receipt->sum = number_format ( $sum, 2, '.', '' );
  533. $receipt->date = date ( "Y-m-d" );
  534. $receipt->cid = $cid;
  535. if ($receiptDetail ['Rtype'] == 1)
  536. $receipt->status = 7;
  537. else
  538. $receipt->status = 5;
  539. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  540. $receipt->verify = $verify;
  541. $receipt->executeCopy = $executeDetail ['staff'];
  542. $order = array (
  543. "\r\n",
  544. "\n",
  545. "\r"
  546. );
  547. $replace = '<br/>';
  548. $explanation = str_replace ( $order, $replace, $explanation );
  549. $receipt->explanation = $explanation;
  550. $receipt->remittanceName = $remittanceName;
  551. $receipt->bankName = $bankName;
  552. $receipt->bankNumber = $bankNumber;
  553. $receipt->remittanceBankType = $remittanceBankType;
  554. if ($remittanceBankType == 1)
  555. $receipt->coupletNumber = $coupletNumber;
  556. $receipt->update ();
  557. $receiptDetail = new receiptDetail ();
  558. $receiptDetail->delete ( array (
  559. 'where' => 'rid=' . $rid
  560. ) );
  561. // 报销详情
  562. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  563. $receiptDetail = new receiptDetail ();
  564. $receiptDetail->staff = $this->staff [0] ['sid'];
  565. $receiptDetail->item = $value ['name'];
  566. $receiptDetail->itemCategory = $this->AGENCY;
  567. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  568. $receiptDetail->date = date ( "Y-m-d" );
  569. $receiptDetail->cid = $cid;
  570. $receiptDetail->rid = $rid;
  571. $receiptDetail->status = 4;
  572. $receiptDetail->insert ();
  573. }
  574. // 附件
  575. if (! empty ( $enclosurName )) {
  576. $enclosurArray = explode ( '-', $enclosurName );
  577. foreach ( $enclosurArray as $value ) {
  578. $enclosur = new enclosur ();
  579. $enclosur->name = $value;
  580. $enclosur->rid = $rid;
  581. $enclosur->insert ();
  582. }
  583. }
  584. }
  585. return "/saeaBorad";
  586. }
  587. function remitApproval() {
  588. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  589. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  590. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  591. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  592. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  593. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  594. if (empty ( $status ))
  595. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  596. $vidList = array ();
  597. $button = 0;
  598. Doo::loadModel ( 'verify' );
  599. Doo::loadModel ( 'receipt' );
  600. Doo::loadModel ( 'staff' );
  601. $staff = new staff ();
  602. $receipt = new receipt ();
  603. $verify = new verify ();
  604. Doo::loadModel ( 'L_category' );
  605. $Lcategory = new L_category ();
  606. Doo::loadModel ( 'enclosur' );
  607. $enclosur = new enclosur ();
  608. // user verify ID
  609. $verifyDetail = $verify->find ( array (
  610. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  611. 'asArray' => true
  612. ) );
  613. foreach ( $verifyDetail as $key => $value ) {
  614. array_push ( $vidList, $value ['vid'] );
  615. }
  616. $vid = implode ( ",", $vidList );
  617. if (empty ( $verifyDetail ))
  618. $vid = 0;
  619. $categoryList = $Lcategory->find ( array (
  620. 'asArray' => true
  621. ) );
  622. $staffList = $staff->find ( array (
  623. 'where' => 'cid=' . $cid,
  624. 'asArray' => true
  625. ) );
  626. $ap = "";
  627. if ($status == 4) {
  628. $ap = 4;
  629. $status = 2;
  630. }
  631. // get Receipt By verifyID status 2
  632. $receiptList = $receipt->find ( array (
  633. 'where' => 'rid =' . $rid . ' and status=2',
  634. 'desc' => 'rid',
  635. 'asArray' => true
  636. ) );
  637. if (empty ( $receiptList )) {
  638. die ( 'illegal request' );
  639. }
  640. $Locate = 0;
  641. $roleId = 0;
  642. if ($ap == 4)
  643. $status = 4;
  644. foreach ( $receiptList as $key => $value ) {
  645. $receiptList [$key] ['Locate'] = $Locate;
  646. $Locate ++;
  647. $receiptList [$key] ['reviseDetail'] = array ();
  648. if (! empty ( $value ['reviseDetail'] ))
  649. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  650. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  651. $categoryDetil = $Lcategory->getOne ( array (
  652. 'where' => 'cid=' . $value ['cid'],
  653. 'asArray' => true
  654. ) );
  655. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  656. // 检测编辑状态
  657. $verifyList = $verify->getOne ( array (
  658. 'where' => 'vid=' . $value ['verify'],
  659. 'asArray' => true
  660. ) );
  661. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  662. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  663. Doo::loadModel ( 'role' );
  664. $role = new role ();
  665. // print_r($verifyList);
  666. $flag = true;
  667. $roleKey = 0;
  668. $endStaffArray = array ();
  669. $roleArrayCopy = array ();
  670. foreach ( $verifyList as $k => $v ) {
  671. // init verifyStaff
  672. if ($v [1] == 'ROLE') {
  673. if (! empty ( $verifyStaff )) {
  674. $endStaffArray = end ( $verifyStaff );
  675. if ($v [0] == $endStaffArray ['nextStaff']) {
  676. $roleId = $v [0];
  677. }
  678. }
  679. $roleVerify = json_decode ( $v [3], true );
  680. $roleKey = $k;
  681. $roleArray = array ();
  682. $rolename = $role->getOne ( array (
  683. 'where' => 'rid=' . $v [0],
  684. 'asArray' => true
  685. ) );
  686. foreach ( $roleVerify as $o => $p ) {
  687. $staffID = explode ( '_', $p );
  688. $staffInfo = $staff->getOne ( array (
  689. 'where' => 'sid=' . $staffID [0],
  690. 'asArray' => true
  691. ) );
  692. // print_r($staffID);
  693. $exp = array (
  694. 0 => $staffInfo ['sid'],
  695. 1 => $staffID [1],
  696. 2 => $staffInfo ['avatar'],
  697. 'date' => '',
  698. 'date' => '',
  699. 'opinion' => '',
  700. 'status' => '',
  701. 'rolename' => $rolename ['name']
  702. );
  703. array_push ( $roleArray, $exp );
  704. }
  705. $roleArrayCopy [$v [0]] = $roleArray;
  706. // $verifyList[$k]['roleArray']=$roleArray;
  707. }
  708. // print_r($roleArray);
  709. $verifyList [$k] ['date'] = "";
  710. $verifyList [$k] ['opinion'] = "";
  711. $verifyList [$k] ['status'] = "";
  712. if (empty ( $verifyStaff )) {
  713. $verifyList [$k] ['date'] = "";
  714. $verifyList [$k] ['opinion'] = "";
  715. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  716. $verifyList [$k] ['status'] = 4;
  717. $button = 4;
  718. $flag = false;
  719. }
  720. } else {
  721. foreach ( $verifyStaff as $m => $u ) {
  722. if ($v [0] == $m) {
  723. $verifyList [$k] ['date'] = $u ['date'];
  724. $verifyList [$k] ['opinion'] = $u ['opinion'];
  725. $verifyList [$k] ['status'] = $u ['status'];
  726. $flag = false;
  727. break;
  728. }
  729. }
  730. $endStaffArray = end ( $verifyStaff );
  731. if (isset ( $endStaffArray ['ROLE'] )) {
  732. } else {
  733. $endKey = key ( $verifyStaff );
  734. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  735. $button = 4;
  736. $verifyList [$k] ['status'] = 4;
  737. }
  738. }
  739. }
  740. }
  741. $rolename ['name'] = '';
  742. if (! empty ( $roleId )) {
  743. Doo::loadModel ( 'role' );
  744. $role = new role ();
  745. $rolename = $role->getOne ( array (
  746. 'where' => 'rid=' . $roleId,
  747. 'asArray' => true
  748. ) );
  749. }
  750. if (! empty ( $verifyStaff ))
  751. $endStaffArray = end ( $verifyStaff );
  752. $KOP = false;
  753. foreach ( $roleArrayCopy as $P => $A ) {
  754. foreach ( $A as $MKI => $AVL ) {
  755. if (! empty ( $verifyStaff )) {
  756. // &&$rolename['rid']==$endStaffArray['nextStaff']
  757. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  758. $button = 4;
  759. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  760. }
  761. foreach ( $verifyStaff as $m => $u ) {
  762. $AVLFK = $AVL [0] . '_R';
  763. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  764. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  765. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  766. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  767. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  768. break;
  769. }
  770. }
  771. } else {
  772. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  773. $button = 4;
  774. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  775. }
  776. }
  777. // $roleArray[$MKI]['rolename']=$rolename['name'];
  778. $KOP = true;
  779. }
  780. }
  781. foreach ( $roleArrayCopy as $k => $v ) {
  782. foreach ( $verifyList as $m => $n ) {
  783. if ($n [0] == $k) {
  784. array_splice ( $verifyList, $m, 1, $v );
  785. }
  786. }
  787. }
  788. $receiptList [$key] ['verifyList'] = $verifyList;
  789. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  790. 'where' => 'sid=' . $value ['staff'],
  791. 'asArray' => true
  792. ) );
  793. $receiptList [$key] ['button'] = $button;
  794. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  795. }
  796. $mothHtml = "";
  797. for($i = 1; $i <= 12; $i ++) {
  798. if ($month == $i)
  799. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  800. else
  801. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  802. }
  803. // 获取审批日志
  804. Doo::loadModel ( 'receiptLog' );
  805. $receiptLog = new receiptLog ();
  806. $rlList = array ();
  807. $rlInfo = $receiptLog->getOne ( array (
  808. 'where' => 'rid=' . $rid . ' and status=4',
  809. 'asArray' => true
  810. ) );
  811. $tijdate = $receiptLog->getOne ( array (
  812. 'where' => 'rid=' . $rid . ' and status=2',
  813. 'asc' => 'rlid',
  814. 'asArray' => true
  815. ) );
  816. if (! empty ( $rlInfo )) {
  817. $rlList = $receiptLog->find ( array (
  818. 'where' => 'rid=' . $rid,
  819. 'asc' => 'rlid',
  820. 'asArray' => true
  821. ) );
  822. }
  823. $receiptList [0] ['rlList'] = $rlList;
  824. $enclosurList = $enclosur->find ( array (
  825. 'where' => 'rid=' . $rid,
  826. 'asArray' => true
  827. ) );
  828. $enclosurHtml = '';
  829. foreach ( $enclosurList as $value ) {
  830. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  831. }
  832. // print_r($receiptList);
  833. $data ['enclosurHtml'] = $enclosurHtml;
  834. $data ['rolename'] = $rolename ['name'];
  835. $data ['datetij'] = $tijdate ['date'];
  836. $data ['mothHtml'] = $mothHtml;
  837. $data ['rid'] = $rid;
  838. $data ['receiptList'] = $receiptList;
  839. $data ['receiptApprovalCount'] = count ( $receiptList );
  840. $data ['status'] = $status;
  841. $data ['year'] = $year;
  842. $data ['categoryList'] = $categoryList;
  843. $data ['staffList'] = $staffList;
  844. $data ['cid'] = $cid;
  845. $data ['sid'] = $sid;
  846. $data ['ap'] = $ap;
  847. $data ['memu'] = "receipt";
  848. $data ['staff'] = $this->staff;
  849. $data ['receiptMemu'] = 'approvalExpenses';
  850. $data ['verifyId'] = $this->verifyId;
  851. $data ['executeId'] = $this->executeId;
  852. $this->render ( "/admin/remitApproval", $data );
  853. }
  854. function saeaLoanAdd() {
  855. Doo::loadModel ( 'verify' );
  856. $verify = new verify ();
  857. Doo::loadModel ( "role" );
  858. $role = new role ();
  859. Doo::loadModel ( 'L_category' );
  860. $lCategory = new L_category ();
  861. $veList = $verify->find ( array (
  862. 'asArray' => true
  863. ) );
  864. foreach ( $veList as $key => $value ) {
  865. $v = json_decode ( $value ['staff'] );
  866. $list = array ();
  867. foreach ( $v as $n => $m ) {
  868. if ($m ['1'] == 'ROLE') {
  869. $roleInfo = $role->getOne ( array (
  870. 'where' => 'rid=' . $m [0],
  871. 'asArray' => true
  872. ) );
  873. $v [$n] [1] = $roleInfo ['name'];
  874. array_push ( $list, $roleInfo ['name'] );
  875. } else {
  876. array_push ( $list, $v [$n] [1] );
  877. }
  878. }
  879. $veList [$key] ['staff'] = implode ( '>', $list );
  880. }
  881. $data ['category'] = $lCategory->find ( array (
  882. 'asArray' => true
  883. ) );
  884. $data ['veList'] = $veList;
  885. $data ['memu'] = "receipt";
  886. $data ['staff'] = $this->staff;
  887. $data ['receiptMemu'] = 'saeaBorad';
  888. $data ['verifyId'] = $this->verifyId;
  889. $data ['executeId'] = $this->executeId;
  890. $this->render ( "/admin/saeaLoanAdd", $data );
  891. }
  892. function saeaLoanAddDo() {
  893. $agency = $this->get_args ( 'agency' );
  894. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  895. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  896. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  897. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  898. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  899. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  900. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  901. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  902. // die;
  903. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  904. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  905. header ( 'Content-Type:text/html;charset=utf-8' );
  906. die ( '请填写联行号' );
  907. }
  908. Doo::loadModel ( 'receipt' );
  909. Doo::loadModel ( 'receiptDetail' );
  910. Doo::loadModel ( 'accountItem' );
  911. $accountItem = new accountItem ();
  912. $receipt = new receipt ();
  913. Doo::loadModel ( 'loanReceipt' );
  914. $loanReceipt = new loanReceipt ();
  915. Doo::loadModel ( 'execute' );
  916. $execute = new execute ();
  917. Doo::loadModel ( 'enclosur' );
  918. $executeDetail = $execute->getOne ( array (
  919. 'where' => 'mold="借款执行人"',
  920. 'asArray' => true
  921. ) );
  922. $aItem = $accountItem->find ( array (
  923. 'asArray' => true
  924. ) );
  925. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  926. $ag = $tr = $ta = $ot = 0;
  927. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  928. array_push ( $accountJson ['借款费用'], array (
  929. 'aid' => 0,
  930. 'name' => '申请金额',
  931. 'price' => number_format ( $agency, 2, '.', '' )
  932. ) );
  933. $sum += $agency;
  934. $agencySum += $agency;
  935. $accountJson ['cSum'] = array (
  936. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  937. 'agencySum' => number_format ( 0, 2, '.', '' ),
  938. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  939. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  940. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  941. );
  942. // 借款数据备份
  943. $loanReceipt->loanItem = json_encode ( $accountJson );
  944. $loanReceipt->staff = $this->staff [0] ['sid'];
  945. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  946. $loanReceipt->date = date ( "Y-m-d" );
  947. $loanReceipt->cid = $cid;
  948. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  949. $loanReceipt->status = 5;
  950. $loanReceipt->Rtype = 1;
  951. $loanReceipt->verify = $verify;
  952. $receipt->receiptOrder = $receipt->receiptOrder;
  953. // 添加HTML换行符
  954. // var_dump($explanation);
  955. $order = array (
  956. "\r\n",
  957. "\n",
  958. "\r"
  959. );
  960. $replace = '<br/>';
  961. $explanation = str_replace ( $order, $replace, $explanation );
  962. // $explanation=str_replace('\r',"<br/>",$explanation);
  963. // $explanation=str_replace('\r\n',"<br/>",$explanation);
  964. $loanReceipt->explanation = $explanation;
  965. $loanRid = $loanReceipt->insert ();
  966. // 报销单
  967. $receipt->loanItem = json_encode ( $accountJson );
  968. $receipt->staff = $this->staff [0] ['sid'];
  969. $receipt->sum = number_format ( $sum, 2, '.', '' );
  970. $receipt->date = date ( "Y-m-d" );
  971. $receipt->cid = $cid;
  972. // 特殊状态
  973. $receipt->status = 5;
  974. $receipt->Rtype = 1;
  975. $receipt->loanRid = $loanRid;
  976. // 修改审批流程加入角色
  977. $receipt->verify = $verify;
  978. $receipt->executeCopy = $executeDetail ['staff'];
  979. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  980. $receipt->explanation = $explanation;
  981. $receipt->remittanceName = $remittanceName;
  982. $receipt->bankName = $bankName;
  983. $receipt->bankNumber = $bankNumber;
  984. $receipt->remittanceBankType = $remittanceBankType;
  985. if ($remittanceBankType == 1)
  986. $receipt->coupletNumber = $coupletNumber;
  987. $rid = $receipt->insert ();
  988. return "/saeaBorad";
  989. } else
  990. die ( 'illegal request' );
  991. }
  992. function saeaLoanEdi() {
  993. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  994. Doo::loadClass ( 'XDeode' );
  995. $XDeode = new XDeode ( 7 );
  996. $rid = $XDeode->decode ( $ridKey );
  997. if (! is_numeric ( $rid ))
  998. die ( 'illegal request' );
  999. Doo::loadModel ( 'verify' );
  1000. $verify = new verify ();
  1001. Doo::loadModel ( "role" );
  1002. $role = new role ();
  1003. Doo::loadModel ( 'L_category' );
  1004. $lCategory = new L_category ();
  1005. Doo::loadModel ( 'receipt' );
  1006. $receipt = new receipt ();
  1007. $receiptInfo = $receipt->getOne ( array (
  1008. 'where' => 'rid=' . $rid,
  1009. 'asArray' => true
  1010. ) );
  1011. $veList = $verify->find ( array (
  1012. 'asArray' => true
  1013. ) );
  1014. foreach ( $veList as $key => $value ) {
  1015. $v = json_decode ( $value ['staff'] );
  1016. $list = array ();
  1017. foreach ( $v as $n => $m ) {
  1018. if ($m ['1'] == 'ROLE') {
  1019. $roleInfo = $role->getOne ( array (
  1020. 'where' => 'rid=' . $m [0],
  1021. 'asArray' => true
  1022. ) );
  1023. $v [$n] [1] = $roleInfo ['name'];
  1024. array_push ( $list, $roleInfo ['name'] );
  1025. } else {
  1026. array_push ( $list, $v [$n] [1] );
  1027. }
  1028. }
  1029. $veList [$key] ['staff'] = implode ( '>', $list );
  1030. }
  1031. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  1032. // print_r($receiptInfo);
  1033. $data ['receiptInfo'] = $receiptInfo;
  1034. $data ['category'] = $lCategory->find ( array (
  1035. 'asArray' => true
  1036. ) );
  1037. $data ['veList'] = $veList;
  1038. $data ['ridKey'] = $ridKey;
  1039. $data ['memu'] = "receipt";
  1040. $data ['staff'] = $this->staff;
  1041. $data ['receiptMemu'] = 'saeaBorad';
  1042. $data ['verifyId'] = $this->verifyId;
  1043. $data ['executeId'] = $this->executeId;
  1044. $this->render ( "/admin/saeaLoanEdi", $data );
  1045. }
  1046. function saeaLoanEdiDo() {
  1047. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1048. $agency = $this->get_args ( 'agency' );
  1049. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1050. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1051. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1052. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1053. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1054. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1055. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1056. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1057. // die;
  1058. Doo::loadClass ( 'XDeode' );
  1059. $XDeode = new XDeode ( 7 );
  1060. $rid = $XDeode->decode ( $ridKey );
  1061. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1062. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1063. header ( 'Content-Type:text/html;charset=utf-8' );
  1064. die ( '请填写联行号' );
  1065. }
  1066. Doo::loadModel ( 'receipt' );
  1067. Doo::loadModel ( 'receiptDetail' );
  1068. Doo::loadModel ( 'accountItem' );
  1069. $accountItem = new accountItem ();
  1070. $receipt = new receipt ();
  1071. Doo::loadModel ( 'loanReceipt' );
  1072. $loanReceipt = new loanReceipt ();
  1073. Doo::loadModel ( 'enclosur' );
  1074. Doo::loadModel ( 'execute' );
  1075. $execute = new execute ();
  1076. $executeDetail = $execute->getOne ( array (
  1077. 'where' => 'mold="借款执行人"',
  1078. 'asArray' => true
  1079. ) );
  1080. $receiptDetail = $receipt->getOne ( array (
  1081. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  1082. 'asArray' => true
  1083. ) );
  1084. if (empty ( $receiptDetail ))
  1085. die ( '参数错误' );
  1086. $aItem = $accountItem->find ( array (
  1087. 'asArray' => true
  1088. ) );
  1089. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1090. $ag = $tr = $ta = $ot = 0;
  1091. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1092. array_push ( $accountJson ['借款费用'], array (
  1093. 'aid' => 0,
  1094. 'name' => '申请金额',
  1095. 'price' => number_format ( $agency, 2, '.', '' )
  1096. ) );
  1097. $sum += $agency;
  1098. $agencySum += $agency;
  1099. $accountJson ['cSum'] = array (
  1100. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1101. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1102. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1103. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1104. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1105. );
  1106. // 报销单
  1107. $receipt->loanItem = json_encode ( $accountJson );
  1108. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1109. $receipt->cid = $cid;
  1110. // 特殊状态
  1111. // 修改审批流程加入角色
  1112. if ($receiptDetail ['status'] != 4)
  1113. $receipt->verify = $verify;
  1114. $order = array (
  1115. "\r\n",
  1116. "\n",
  1117. "\r"
  1118. );
  1119. $replace = '<br/>';
  1120. $explanation = str_replace ( $order, $replace, $explanation );
  1121. $receipt->explanation = $explanation;
  1122. $receipt->remittanceName = $remittanceName;
  1123. $receipt->bankName = $bankName;
  1124. $receipt->bankNumber = $bankNumber;
  1125. $receipt->remittanceBankType = $remittanceBankType;
  1126. if ($remittanceBankType == 1)
  1127. $receipt->coupletNumber = $coupletNumber;
  1128. $receipt->update ( array (
  1129. 'where' => 'rid=' . $rid
  1130. ) );
  1131. // 借款数据更新
  1132. $loanReceipt->loanItem = json_encode ( $accountJson );
  1133. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1134. $loanReceipt->cid = $cid;
  1135. if ($receiptDetail ['status'] != 4)
  1136. $loanReceipt->verify = $verify;
  1137. $loanReceipt->explanation = $explanation;
  1138. $receipt->executeCopy = $executeDetail ['staff'];
  1139. $loanReceipt->update ( array (
  1140. 'where' => 'rid=' . $receiptDetail ['loanRid']
  1141. ) );
  1142. }
  1143. return "/saeaBorad";
  1144. }
  1145. function saeaLoanReceiptAdd() {
  1146. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1147. Doo::loadModel ( 'receipt' );
  1148. $receipt = new receipt ();
  1149. Doo::loadModel ( 'loanReceipt' );
  1150. $loanReceipt = new loanReceipt ();
  1151. Doo::loadModel ( 'L_category' );
  1152. $Lcategory = new L_category ();
  1153. Doo::loadModel ( 'verify' );
  1154. Doo::loadModel ( 'statistics' );
  1155. $statistics = new statistics ();
  1156. $verify = new verify ();
  1157. Doo::loadModel ( 'staff' );
  1158. $staff = new staff ();
  1159. $receiptDetail = $receipt->getOne ( array (
  1160. 'where' => 'rid=' . $rid,
  1161. 'desc' => 'rid',
  1162. 'asArray' => true
  1163. ) );
  1164. $receiptList = $loanReceipt->find ( array (
  1165. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1166. 'desc' => 'rid',
  1167. 'asArray' => true
  1168. ) );
  1169. $Locate = 0;
  1170. $roleId = 0;
  1171. $button = 0;
  1172. foreach ( $receiptList as $key => $value ) {
  1173. $receiptList [$key] ['Locate'] = $Locate;
  1174. $Locate ++;
  1175. $receiptList [$key] ['reviseDetail'] = array ();
  1176. if (! empty ( $value ['reviseDetail'] ))
  1177. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1178. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1179. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1180. $categoryDetil = $Lcategory->getOne ( array (
  1181. 'where' => 'cid=' . $value ['cid'],
  1182. 'asArray' => true
  1183. ) );
  1184. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1185. // 检测编辑状态
  1186. $verifyList = $verify->getOne ( array (
  1187. 'where' => 'vid=' . $value ['verify'],
  1188. 'asArray' => true
  1189. ) );
  1190. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1191. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1192. Doo::loadModel ( 'role' );
  1193. $role = new role ();
  1194. $flag = true;
  1195. $roleKey = 0;
  1196. $endStaffArray = array ();
  1197. $roleArrayCopy = array ();
  1198. foreach ( $verifyList as $k => $v ) {
  1199. // init verifyStaff
  1200. if ($v [1] == 'ROLE') {
  1201. if (! empty ( $verifyStaff )) {
  1202. $endStaffArray = end ( $verifyStaff );
  1203. // if ($v[0]==$endStaffArray['nextStaff']){
  1204. // $roleId=$v[0];
  1205. // }
  1206. }
  1207. $roleVerify = json_decode ( $v [3], true );
  1208. $roleKey = $k;
  1209. $roleArray = array ();
  1210. $rolename = $role->getOne ( array (
  1211. 'where' => 'rid=' . $v [0],
  1212. 'asArray' => true
  1213. ) );
  1214. foreach ( $roleVerify as $o => $p ) {
  1215. $staffID = explode ( '_', $p );
  1216. $staffInfo = $staff->getOne ( array (
  1217. 'where' => 'sid=' . $staffID [0],
  1218. 'asArray' => true
  1219. ) );
  1220. // print_r($staffID);
  1221. $exp = array (
  1222. 0 => $staffInfo ['sid'],
  1223. 1 => $staffID [1],
  1224. 2 => $staffInfo ['avatar'],
  1225. 'date' => '',
  1226. 'date' => '',
  1227. 'opinion' => '',
  1228. 'status' => '',
  1229. 'rolename' => $rolename ['name']
  1230. );
  1231. array_push ( $roleArray, $exp );
  1232. }
  1233. $roleArrayCopy [$v [0]] = $roleArray;
  1234. // $verifyList[$k]['roleArray']=$roleArray;
  1235. }
  1236. $verifyList [$k] ['date'] = "";
  1237. $verifyList [$k] ['opinion'] = "";
  1238. $verifyList [$k] ['status'] = "";
  1239. if (empty ( $verifyStaff )) {
  1240. $verifyList [$k] ['date'] = "";
  1241. $verifyList [$k] ['opinion'] = "";
  1242. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1243. $verifyList [$k] ['status'] = 4;
  1244. $flag = false;
  1245. }
  1246. } else {
  1247. foreach ( $verifyStaff as $m => $u ) {
  1248. if ($v [0] == $m) {
  1249. $verifyList [$k] ['date'] = $u ['date'];
  1250. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1251. $verifyList [$k] ['status'] = $u ['status'];
  1252. $flag = false;
  1253. break;
  1254. }
  1255. }
  1256. $endStaffArray = end ( $verifyStaff );
  1257. if (isset ( $endStaffArray ['ROLE'] )) {
  1258. } else {
  1259. // $endKey=key($verifyStaff);
  1260. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1261. // $button=4;
  1262. // $verifyList[$k]['status']=4;
  1263. // }
  1264. }
  1265. }
  1266. }
  1267. $rolename ['name'] = '';
  1268. if (! empty ( $roleId )) {
  1269. Doo::loadModel ( 'role' );
  1270. $role = new role ();
  1271. $rolename = $role->getOne ( array (
  1272. 'where' => 'rid=' . $roleId,
  1273. 'asArray' => true
  1274. ) );
  1275. }
  1276. if (! empty ( $verifyStaff ))
  1277. $endStaffArray = end ( $verifyStaff );
  1278. $KOP = false;
  1279. foreach ( $roleArrayCopy as $P => $A ) {
  1280. foreach ( $A as $MKI => $AVL ) {
  1281. if (! empty ( $verifyStaff )) {
  1282. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1283. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1284. $button = 4;
  1285. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1286. }
  1287. foreach ( $verifyStaff as $m => $u ) {
  1288. $AVLFK = $AVL [0] . '_R';
  1289. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1290. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1291. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1292. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1293. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1294. break;
  1295. }
  1296. }
  1297. } else {
  1298. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1299. $button = 4;
  1300. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1301. }
  1302. }
  1303. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1304. $KOP = true;
  1305. }
  1306. }
  1307. foreach ( $roleArrayCopy as $k => $v ) {
  1308. foreach ( $verifyList as $m => $n ) {
  1309. if ($n [0] == $k) {
  1310. array_splice ( $verifyList, $m, 1, $v );
  1311. }
  1312. }
  1313. }
  1314. $receiptList [$key] ['verifyList'] = $verifyList;
  1315. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1316. 'where' => 'sid=' . $value ['staff'],
  1317. 'asArray' => true
  1318. ) );
  1319. $receiptList [$key] ['button'] = $button;
  1320. //
  1321. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1322. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1323. }
  1324. $data ['receiptList'] = $receiptList;
  1325. $data ['receiptDetail'] = $receiptDetail;
  1326. Doo::loadModel ( 'L_category' );
  1327. $lCategory = new L_category ();
  1328. Doo::loadModel ( 'accountItem' );
  1329. $accountItem = new accountItem ();
  1330. $acItem = $accountItem->find ( array (
  1331. 'asArray' => true
  1332. ) );
  1333. $veList = $verify->find ( array (
  1334. 'asArray' => true
  1335. ) );
  1336. foreach ( $veList as $key => $value ) {
  1337. $v = json_decode ( $value ['staff'] );
  1338. $list = array ();
  1339. foreach ( $v as $n => $m ) {
  1340. if ($m ['1'] == 'ROLE') {
  1341. $roleInfo = $role->getOne ( array (
  1342. 'where' => 'rid=' . $m [0],
  1343. 'asArray' => true
  1344. ) );
  1345. $v [$n] [1] = $roleInfo ['name'];
  1346. array_push ( $list, $roleInfo ['name'] );
  1347. } else {
  1348. array_push ( $list, $v [$n] [1] );
  1349. }
  1350. }
  1351. $veList [$key] ['staff'] = implode ( '>', $list );
  1352. }
  1353. $data ['rid'] = $rid;
  1354. $data ['category'] = $lCategory->find ( array (
  1355. 'asArray' => true
  1356. ) );
  1357. $data ['veList'] = $veList;
  1358. $data ['acItem'] = $acItem;
  1359. $data ['memu'] = "receipt";
  1360. $data ['staff'] = $this->staff;
  1361. $data ['receiptMemu'] = 'saeaBorad';
  1362. $data ['verifyId'] = $this->verifyId;
  1363. $data ['executeId'] = $this->executeId;
  1364. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1365. }
  1366. function saeaLoanReceiptAddDo() {
  1367. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1368. $agency = $this->get_args ( 'agency' );
  1369. $travel = $this->get_args ( 'travel' );
  1370. $train = $this->get_args ( 'train' );
  1371. $other = $this->get_args ( 'other' );
  1372. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1373. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1374. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1375. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1376. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1377. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1378. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1379. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1380. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1381. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1382. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1383. header ( 'Content-Type:text/html;charset=utf-8' );
  1384. die ( '请填写联行号' );
  1385. }
  1386. Doo::loadModel ( 'receipt' );
  1387. Doo::loadModel ( 'receiptDetail' );
  1388. Doo::loadModel ( 'accountItem' );
  1389. $accountItem = new accountItem ();
  1390. $receipt = new receipt ();
  1391. Doo::loadModel ( 'enclosur' );
  1392. Doo::loadModel ( 'execute' );
  1393. $execute = new execute ();
  1394. $executeDetail = $execute->getOne ( array (
  1395. 'where' => 'mold="借款费用执行人"',
  1396. 'asArray' => true
  1397. ) );
  1398. $receiptDet = $receipt->getOne ( array (
  1399. 'where' => 'rid=' . $rid,
  1400. 'asArray' => true
  1401. ) );
  1402. // if(!empty($receiptDetail))
  1403. // return "/referReceipt/".$receiptDetail['rid'];
  1404. $aItem = $accountItem->find ( array (
  1405. 'asArray' => true
  1406. ) );
  1407. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1408. $ag = $tr = $ta = $ot = 0;
  1409. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1410. foreach ( $aItem as $key => $value ) {
  1411. if ($value ['category'] == $this->AGENCY) {
  1412. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1413. array_push ( $accountJson [$this->AGENCY], array (
  1414. 'aid' => $value ['aid'],
  1415. 'name' => $value ['name'],
  1416. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1417. ) );
  1418. $sum += $agency [$ag];
  1419. $agencySum += $agency [$ag];
  1420. }
  1421. $ag ++;
  1422. }
  1423. if ($value ['category'] == $this->TRAVEL) {
  1424. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1425. array_push ( $accountJson [$this->TRAVEL], array (
  1426. 'aid' => $value ['aid'],
  1427. 'name' => $value ['name'],
  1428. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1429. ) );
  1430. $sum += $travel [$tr];
  1431. $travelSum += $travel [$tr];
  1432. }
  1433. $tr ++;
  1434. }
  1435. if ($value ['category'] == $this->TRAIN) {
  1436. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1437. array_push ( $accountJson [$this->TRAIN], array (
  1438. 'aid' => $value ['aid'],
  1439. 'name' => $value ['name'],
  1440. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1441. ) );
  1442. $sum += $train [$ta];
  1443. $trainSum += $train [$ta];
  1444. }
  1445. $ta ++;
  1446. }
  1447. if ($value ['category'] == $this->OTHER) {
  1448. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1449. array_push ( $accountJson [$this->OTHER], array (
  1450. 'aid' => $value ['aid'],
  1451. 'name' => $value ['name'],
  1452. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1453. ) );
  1454. $sum += $other [$ot];
  1455. $otherSum += $other [$ot];
  1456. }
  1457. $ot ++;
  1458. }
  1459. }
  1460. $accountJson ['cSum'] = array (
  1461. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1462. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1463. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1464. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1465. );
  1466. // 报销单
  1467. $receipt->accountItem = json_encode ( $accountJson );
  1468. $receipt->staff = $this->staff [0] ['sid'];
  1469. $receipt->loanSum = $receiptDet ['sum'];
  1470. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1471. $receipt->date = date ( "Y-m-d" );
  1472. $receipt->pastDate = '';
  1473. $receipt->cid = $cid;
  1474. $receipt->status = 7;
  1475. // 修改审批流程加入角色
  1476. $receipt->verify = $verify;
  1477. $receipt->verifyStaff = '';
  1478. $receipt->executeStaff = '';
  1479. $receipt->executeCopy = $executeDetail ['staff'];
  1480. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  1481. $receipt->explanation = $explanation;
  1482. $receipt->remittanceName = $remittanceName;
  1483. $receipt->bankName = $bankName;
  1484. $receipt->bankNumber = $bankNumber;
  1485. $receipt->remittanceBankType = $remittanceBankType;
  1486. if ($remittanceBankType == 1)
  1487. $receipt->coupletNumber = $coupletNumber;
  1488. $receipt->update ( array (
  1489. 'where' => 'rid=' . $rid
  1490. ) );
  1491. // 附件
  1492. if (! empty ( $enclosurName )) {
  1493. $enclosurArray = explode ( '-', $enclosurName );
  1494. foreach ( $enclosurArray as $value ) {
  1495. $enclosur = new enclosur ();
  1496. $enclosur->name = $value;
  1497. $enclosur->rid = $rid;
  1498. $enclosur->insert ();
  1499. }
  1500. // print_r($enclosurArray);die;
  1501. }
  1502. // 报销详情
  1503. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1504. $receiptDetail = new receiptDetail ();
  1505. $receiptDetail->staff = $this->staff [0] ['sid'];
  1506. $receiptDetail->item = $value ['name'];
  1507. $receiptDetail->itemCategory = $this->AGENCY;
  1508. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1509. $receiptDetail->date = date ( "Y-m-d" );
  1510. $receiptDetail->cid = $cid;
  1511. $receiptDetail->rid = $rid;
  1512. $receiptDetail->status = 4;
  1513. $receiptDetail->insert ();
  1514. }
  1515. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1516. $receiptDetail = new receiptDetail ();
  1517. $receiptDetail->staff = $this->staff [0] ['sid'];
  1518. $receiptDetail->item = $value ['name'];
  1519. $receiptDetail->itemCategory = $this->TRAVEL;
  1520. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1521. $receiptDetail->date = date ( "Y-m-d" );
  1522. $receiptDetail->cid = $cid;
  1523. $receiptDetail->rid = $rid;
  1524. $receiptDetail->status = 4;
  1525. $receiptDetail->insert ();
  1526. }
  1527. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1528. $receiptDetail = new receiptDetail ();
  1529. $receiptDetail->staff = $this->staff [0] ['sid'];
  1530. $receiptDetail->item = $value ['name'];
  1531. $receiptDetail->itemCategory = $this->TRAIN;
  1532. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1533. $receiptDetail->date = date ( "Y-m-d" );
  1534. $receiptDetail->cid = $cid;
  1535. $receiptDetail->rid = $rid;
  1536. $receiptDetail->status = 4;
  1537. $receiptDetail->insert ();
  1538. }
  1539. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1540. $receiptDetail = new receiptDetail ();
  1541. $receiptDetail->staff = $this->staff [0] ['sid'];
  1542. $receiptDetail->item = $value ['name'];
  1543. $receiptDetail->itemCategory = $this->OTHER;
  1544. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1545. $receiptDetail->date = date ( "Y-m-d" );
  1546. $receiptDetail->cid = $cid;
  1547. $receiptDetail->rid = $rid;
  1548. $receiptDetail->status = 4;
  1549. $receiptDetail->insert ();
  1550. }
  1551. return "/saeaBorad";
  1552. }
  1553. return "/saeaLoanReceiptAdd/" . $rid;
  1554. }
  1555. function saeaLoanReceiptEdi() {
  1556. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1557. Doo::loadClass ( 'XDeode' );
  1558. $XDeode = new XDeode ( 7 );
  1559. $rid = $XDeode->decode ( $ridKey );
  1560. if (! is_numeric ( $rid ))
  1561. die ( 'illegal request' );
  1562. Doo::loadModel ( 'accountItem' );
  1563. Doo::loadModel ( 'verify' );
  1564. Doo::loadModel ( 'receipt' );
  1565. $receipt = new receipt ();
  1566. $verify = new verify ();
  1567. $accountItem = new accountItem ();
  1568. Doo::loadModel ( 'L_category' );
  1569. $Lcategory = new L_category ();
  1570. Doo::loadModel ( "role" );
  1571. $role = new role ();
  1572. Doo::loadModel ( 'loanReceipt' );
  1573. $loanReceipt = new loanReceipt ();
  1574. Doo::loadModel ( 'staff' );
  1575. $staff = new staff ();
  1576. $receiptDetail = $receipt->getOne ( array (
  1577. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  1578. 'asArray' => true
  1579. ) );
  1580. if (empty ( $receiptDetail ))
  1581. return "/saeaBorad";
  1582. $receiptList = $loanReceipt->find ( array (
  1583. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1584. 'desc' => 'rid',
  1585. 'asArray' => true
  1586. ) );
  1587. $Locate = 0;
  1588. $roleId = 0;
  1589. $button = 0;
  1590. foreach ( $receiptList as $key => $value ) {
  1591. $receiptList [$key] ['Locate'] = $Locate;
  1592. $Locate ++;
  1593. $receiptList [$key] ['reviseDetail'] = array ();
  1594. if (! empty ( $value ['reviseDetail'] ))
  1595. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1596. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1597. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1598. $categoryDetil = $Lcategory->getOne ( array (
  1599. 'where' => 'cid=' . $value ['cid'],
  1600. 'asArray' => true
  1601. ) );
  1602. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1603. // 检测编辑状态
  1604. $verifyList = $verify->getOne ( array (
  1605. 'where' => 'vid=' . $value ['verify'],
  1606. 'asArray' => true
  1607. ) );
  1608. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1609. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1610. Doo::loadModel ( 'role' );
  1611. $role = new role ();
  1612. $flag = true;
  1613. $roleKey = 0;
  1614. $endStaffArray = array ();
  1615. $roleArrayCopy = array ();
  1616. foreach ( $verifyList as $k => $v ) {
  1617. // init verifyStaff
  1618. if ($v [1] == 'ROLE') {
  1619. if (! empty ( $verifyStaff )) {
  1620. $endStaffArray = end ( $verifyStaff );
  1621. // if ($v[0]==$endStaffArray['nextStaff']){
  1622. // $roleId=$v[0];
  1623. // }
  1624. }
  1625. $roleVerify = json_decode ( $v [3], true );
  1626. $roleKey = $k;
  1627. $roleArray = array ();
  1628. $rolename = $role->getOne ( array (
  1629. 'where' => 'rid=' . $v [0],
  1630. 'asArray' => true
  1631. ) );
  1632. foreach ( $roleVerify as $o => $p ) {
  1633. $staffID = explode ( '_', $p );
  1634. $staffInfo = $staff->getOne ( array (
  1635. 'where' => 'sid=' . $staffID [0],
  1636. 'asArray' => true
  1637. ) );
  1638. // print_r($staffID);
  1639. $exp = array (
  1640. 0 => $staffInfo ['sid'],
  1641. 1 => $staffID [1],
  1642. 2 => $staffInfo ['avatar'],
  1643. 'date' => '',
  1644. 'date' => '',
  1645. 'opinion' => '',
  1646. 'status' => '',
  1647. 'rolename' => $rolename ['name']
  1648. );
  1649. array_push ( $roleArray, $exp );
  1650. }
  1651. $roleArrayCopy [$v [0]] = $roleArray;
  1652. // $verifyList[$k]['roleArray']=$roleArray;
  1653. }
  1654. $verifyList [$k] ['date'] = "";
  1655. $verifyList [$k] ['opinion'] = "";
  1656. $verifyList [$k] ['status'] = "";
  1657. if (empty ( $verifyStaff )) {
  1658. $verifyList [$k] ['date'] = "";
  1659. $verifyList [$k] ['opinion'] = "";
  1660. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1661. $verifyList [$k] ['status'] = 4;
  1662. $flag = false;
  1663. }
  1664. } else {
  1665. foreach ( $verifyStaff as $m => $u ) {
  1666. if ($v [0] == $m) {
  1667. $verifyList [$k] ['date'] = $u ['date'];
  1668. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1669. $verifyList [$k] ['status'] = $u ['status'];
  1670. $flag = false;
  1671. break;
  1672. }
  1673. }
  1674. $endStaffArray = end ( $verifyStaff );
  1675. if (isset ( $endStaffArray ['ROLE'] )) {
  1676. } else {
  1677. // $endKey=key($verifyStaff);
  1678. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1679. // $button=4;
  1680. // $verifyList[$k]['status']=4;
  1681. // }
  1682. }
  1683. }
  1684. }
  1685. $rolename ['name'] = '';
  1686. if (! empty ( $roleId )) {
  1687. Doo::loadModel ( 'role' );
  1688. $role = new role ();
  1689. $rolename = $role->getOne ( array (
  1690. 'where' => 'rid=' . $roleId,
  1691. 'asArray' => true
  1692. ) );
  1693. }
  1694. if (! empty ( $verifyStaff ))
  1695. $endStaffArray = end ( $verifyStaff );
  1696. $KOP = false;
  1697. foreach ( $roleArrayCopy as $P => $A ) {
  1698. foreach ( $A as $MKI => $AVL ) {
  1699. if (! empty ( $verifyStaff )) {
  1700. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1701. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1702. $button = 4;
  1703. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1704. }
  1705. foreach ( $verifyStaff as $m => $u ) {
  1706. $AVLFK = $AVL [0] . '_R';
  1707. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1708. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1709. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1710. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1711. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1712. break;
  1713. }
  1714. }
  1715. } else {
  1716. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1717. $button = 4;
  1718. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1719. }
  1720. }
  1721. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1722. $KOP = true;
  1723. }
  1724. }
  1725. foreach ( $roleArrayCopy as $k => $v ) {
  1726. foreach ( $verifyList as $m => $n ) {
  1727. if ($n [0] == $k) {
  1728. array_splice ( $verifyList, $m, 1, $v );
  1729. }
  1730. }
  1731. }
  1732. $receiptList [$key] ['verifyList'] = $verifyList;
  1733. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1734. 'where' => 'sid=' . $value ['staff'],
  1735. 'asArray' => true
  1736. ) );
  1737. $receiptList [$key] ['button'] = $button;
  1738. //
  1739. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1740. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1741. }
  1742. $data ['receiptList'] = $receiptList;
  1743. $acItem = $accountItem->find ( array (
  1744. 'asArray' => true
  1745. ) );
  1746. $veList = $verify->find ( array (
  1747. 'asArray' => true
  1748. ) );
  1749. foreach ( $veList as $key => $value ) {
  1750. $v = json_decode ( $value ['staff'] );
  1751. $list = array ();
  1752. foreach ( $v as $n => $m ) {
  1753. if ($m ['1'] == 'ROLE') {
  1754. $roleInfo = $role->getOne ( array (
  1755. 'where' => 'rid=' . $m [0],
  1756. 'asArray' => true
  1757. ) );
  1758. $v [$n] [1] = $roleInfo ['name'];
  1759. array_push ( $list, $roleInfo ['name'] );
  1760. } else {
  1761. array_push ( $list, $v [$n] [1] );
  1762. }
  1763. }
  1764. $veList [$key] ['staff'] = implode ( '>', $list );
  1765. }
  1766. // 配置编辑信息
  1767. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1768. foreach ( $acItem as $key => $value ) {
  1769. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1770. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1771. $acItem [$key] ['price'] = $v ['price'];
  1772. }
  1773. }
  1774. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1775. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1776. $acItem [$key] ['price'] = $v ['price'];
  1777. }
  1778. }
  1779. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1780. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1781. $acItem [$key] ['price'] = $v ['price'];
  1782. }
  1783. }
  1784. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1785. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1786. $acItem [$key] ['price'] = $v ['price'];
  1787. }
  1788. }
  1789. }
  1790. $data ['category'] = $Lcategory->find ( array (
  1791. 'asArray' => true
  1792. ) );
  1793. $data ['ridKey'] = $ridKey;
  1794. $data ['cSum'] = $accountItemList ['cSum'];
  1795. $data ['sum'] = $receiptDetail ['sum'];
  1796. $data ['receiptDetail'] = $receiptDetail;
  1797. $data ['veList'] = $veList;
  1798. $data ['acItem'] = $acItem;
  1799. $data ['memu'] = "receipt";
  1800. $data ['staff'] = $this->staff;
  1801. $data ['receiptMemu'] = 'saeaBorad';
  1802. $data ['verify'] = $receiptDetail ['verify'];
  1803. $data ['verifyId'] = $this->verifyId;
  1804. $data ['executeId'] = $this->executeId;
  1805. $data ['rid'] = $rid;
  1806. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  1807. }
  1808. function confirmation() {
  1809. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1810. Doo::loadModel ( 'receipt' );
  1811. Doo::loadModel ( 'receiptDetail' );
  1812. $receipt = new receipt ();
  1813. $receiptDetail = new receiptDetail ();
  1814. Doo::loadModel ( 'statistics' );
  1815. Doo::loadModel ( 'itemStatistics' );
  1816. $statistics = new statistics ();
  1817. $itemStatistics = new itemStatistics ();
  1818. Doo::loadModel ( "verify" );
  1819. $verify = new verify ();
  1820. $receiptDetailList = $receipt->getOne ( array (
  1821. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  1822. 'asArray' => true
  1823. ) );
  1824. if (empty ( $receiptDetailList ))
  1825. return "/saeaBorad";
  1826. $verifyDetail = $verify->getOne ( array (
  1827. 'where' => ' vid =' . $receiptDetailList ['verify'],
  1828. 'asArray' => true
  1829. ) );
  1830. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  1831. if (empty ( $receiptDetailList ['nowStaff'] )) {
  1832. $nowStaff = "";
  1833. $nowStaffList = array ();
  1834. if ($verifyDetail [0] [1] == 'ROLE') {
  1835. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  1836. foreach ( $vStaffString as $key => $value ) {
  1837. $staffK = explode ( "_", $value );
  1838. array_push ( $nowStaffList, $staffK [0] );
  1839. }
  1840. $nowStaff = implode ( ',', $nowStaffList );
  1841. } else {
  1842. $nowStaff = $verifyDetail [0] [0];
  1843. }
  1844. $receipt->nowStaff = $nowStaff;
  1845. }
  1846. // echo $nowStaff;
  1847. // print_r($verifyDetail);die;
  1848. $receipt->rid = $receiptDetailList ['rid'];
  1849. $receipt->status = 2;
  1850. $receipt->update ();
  1851. // 操作日志
  1852. Doo::loadModel ( "receiptLog" );
  1853. $receiptLog = new receiptLog ();
  1854. $verify = new verify ();
  1855. $receiptInfo = $receipt->getOne ( array (
  1856. 'where' => 'rid=' . $rid,
  1857. 'asArray' => true
  1858. ) );
  1859. $vr = $verify->getOne ( array (
  1860. 'where' => 'vid=' . $receiptInfo ['verify'],
  1861. 'asArray' => true
  1862. ) );
  1863. $jd = json_decode ( $vr ['staff'] );
  1864. $roleId = 0;
  1865. foreach ( $jd as $key => $value ) {
  1866. if ($value [1] == 'ROLE') {
  1867. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  1868. if ($pos !== false) {
  1869. $roleId = $value [0];
  1870. }
  1871. }
  1872. }
  1873. // 审批日志
  1874. // echo $roleId;die;
  1875. if (! empty ( $roleId )) {
  1876. Doo::loadModel ( "role" );
  1877. $role = new role ();
  1878. $roleInfo = $role->getOne ( array (
  1879. 'where' => 'rid=' . $roleId,
  1880. 'asArray' => true
  1881. ) );
  1882. // $receiptLog->rolename = $roleInfo ['name'];
  1883. }
  1884. $receiptLog->username = $this->staff [0] ['username'];
  1885. $receiptLog->uid = $this->staff [0] ['sid'];
  1886. $receiptLog->date = date ( "Y-m-d" );
  1887. $receiptLog->opinion = '提交审批';
  1888. $receiptLog->img = $this->staff [0] ['avatar'];
  1889. $receiptLog->status = 2;
  1890. $receiptLog->rid = $rid;
  1891. $receiptLog->insert ();
  1892. return "/expenses";
  1893. }
  1894. function expenses() {
  1895. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  1896. if (empty ( $item ))
  1897. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  1898. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1899. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  1900. Doo::loadModel ( 'receipt' );
  1901. $receipt = new receipt ();
  1902. Doo::loadModel ( 'L_category' );
  1903. $Lcategory = new L_category ();
  1904. Doo::loadModel ( 'verify' );
  1905. Doo::loadModel ( 'statistics' );
  1906. $statistics = new statistics ();
  1907. $verify = new verify ();
  1908. Doo::loadModel ( 'staff' );
  1909. $staff = new staff ();
  1910. $condition = "";
  1911. if ($item == "expenses")
  1912. $condition = " and Rtype=1 ";
  1913. elseif ($item == "receipts")
  1914. $condition = " and Rtype=0 ";
  1915. elseif ($item == "remits")
  1916. $condition = " and Rtype=2 ";
  1917. $dateCondition = " and Year(date) =" . $year;
  1918. if (! empty ( $moth )) {
  1919. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  1920. $stList = $statistics->getOne ( array (
  1921. 'select' => 'rePrice ,agPrice',
  1922. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  1923. 'asArray' => true
  1924. ) );
  1925. } else
  1926. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  1927. if (empty ( $stList ))
  1928. $stList = array (
  1929. 'rePrice' => 0,
  1930. 'agPrice' => 0
  1931. );
  1932. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  1933. if (! isset ( $noPassSum ['sum'] ))
  1934. $noPassSum ['sum'] = 0;
  1935. $data ['stList'] = array (
  1936. 'rePrice' => $stList ['rePrice'],
  1937. 'agPrice' => $stList ['agPrice'],
  1938. 'skPrice' => ($noPassSum ['sum'])
  1939. );
  1940. $receiptList = $receipt->find ( array (
  1941. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  1942. 'desc' => 'rid',
  1943. 'asArray' => true
  1944. ) );
  1945. $Locate = 0;
  1946. $roleId = 0;
  1947. $button = 0;
  1948. foreach ( $receiptList as $key => $value ) {
  1949. $receiptList [$key] ['Locate'] = $Locate;
  1950. $Locate ++;
  1951. $receiptList [$key] ['reviseDetail'] = array ();
  1952. if (! empty ( $value ['reviseDetail'] ))
  1953. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1954. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1955. $categoryDetil = $Lcategory->getOne ( array (
  1956. 'where' => 'cid=' . $value ['cid'],
  1957. 'asArray' => true
  1958. ) );
  1959. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1960. // 检测编辑状态
  1961. $verifyList = $verify->getOne ( array (
  1962. 'where' => 'vid=' . $value ['verify'],
  1963. 'asArray' => true
  1964. ) );
  1965. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1966. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1967. Doo::loadModel ( 'role' );
  1968. $role = new role ();
  1969. $flag = true;
  1970. $roleKey = 0;
  1971. $endStaffArray = array ();
  1972. $roleArrayCopy = array ();
  1973. foreach ( $verifyList as $k => $v ) {
  1974. // init verifyStaff
  1975. if ($v [1] == 'ROLE') {
  1976. if (! empty ( $verifyStaff )) {
  1977. $endStaffArray = end ( $verifyStaff );
  1978. // if ($v[0]==$endStaffArray['nextStaff']){
  1979. // $roleId=$v[0];
  1980. // }
  1981. }
  1982. $roleVerify = json_decode ( $v [3], true );
  1983. $roleKey = $k;
  1984. $roleArray = array ();
  1985. $rolename = $role->getOne ( array (
  1986. 'where' => 'rid=' . $v [0],
  1987. 'asArray' => true
  1988. ) );
  1989. foreach ( $roleVerify as $o => $p ) {
  1990. $staffID = explode ( '_', $p );
  1991. $staffInfo = $staff->getOne ( array (
  1992. 'where' => 'sid=' . $staffID [0],
  1993. 'asArray' => true
  1994. ) );
  1995. // print_r($staffID);
  1996. $exp = array (
  1997. 0 => $staffInfo ['sid'],
  1998. 1 => $staffID [1],
  1999. 2 => $staffInfo ['avatar'],
  2000. 'date' => '',
  2001. 'date' => '',
  2002. 'opinion' => '',
  2003. 'status' => '',
  2004. 'rolename' => $rolename ['name']
  2005. );
  2006. array_push ( $roleArray, $exp );
  2007. }
  2008. $roleArrayCopy [$v [0]] = $roleArray;
  2009. // $verifyList[$k]['roleArray']=$roleArray;
  2010. }
  2011. $verifyList [$k] ['date'] = "";
  2012. $verifyList [$k] ['opinion'] = "";
  2013. $verifyList [$k] ['status'] = "";
  2014. if (empty ( $verifyStaff )) {
  2015. $verifyList [$k] ['date'] = "";
  2016. $verifyList [$k] ['opinion'] = "";
  2017. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2018. $verifyList [$k] ['status'] = 4;
  2019. $flag = false;
  2020. }
  2021. } else {
  2022. foreach ( $verifyStaff as $m => $u ) {
  2023. if ($v [0] == $m) {
  2024. $verifyList [$k] ['date'] = $u ['date'];
  2025. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2026. $verifyList [$k] ['status'] = $u ['status'];
  2027. $flag = false;
  2028. break;
  2029. }
  2030. }
  2031. $endStaffArray = end ( $verifyStaff );
  2032. if (isset ( $endStaffArray ['ROLE'] )) {
  2033. } else {
  2034. // $endKey=key($verifyStaff);
  2035. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2036. // $button=4;
  2037. // $verifyList[$k]['status']=4;
  2038. // }
  2039. }
  2040. }
  2041. }
  2042. $rolename ['name'] = '';
  2043. if (! empty ( $roleId )) {
  2044. Doo::loadModel ( 'role' );
  2045. $role = new role ();
  2046. $rolename = $role->getOne ( array (
  2047. 'where' => 'rid=' . $roleId,
  2048. 'asArray' => true
  2049. ) );
  2050. }
  2051. if (! empty ( $verifyStaff ))
  2052. $endStaffArray = end ( $verifyStaff );
  2053. $KOP = false;
  2054. foreach ( $roleArrayCopy as $P => $A ) {
  2055. foreach ( $A as $MKI => $AVL ) {
  2056. if (! empty ( $verifyStaff )) {
  2057. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2058. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2059. $button = 4;
  2060. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2061. }
  2062. foreach ( $verifyStaff as $m => $u ) {
  2063. $AVLFK = $AVL [0] . '_R';
  2064. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2065. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2066. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2067. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2068. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2069. break;
  2070. }
  2071. }
  2072. } else {
  2073. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2074. $button = 4;
  2075. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2076. }
  2077. }
  2078. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2079. $KOP = true;
  2080. }
  2081. }
  2082. foreach ( $roleArrayCopy as $k => $v ) {
  2083. foreach ( $verifyList as $m => $n ) {
  2084. if ($n [0] == $k) {
  2085. array_splice ( $verifyList, $m, 1, $v );
  2086. }
  2087. }
  2088. }
  2089. $receiptList [$key] ['verifyList'] = $verifyList;
  2090. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2091. 'where' => 'sid=' . $value ['staff'],
  2092. 'asArray' => true
  2093. ) );
  2094. $receiptList [$key] ['button'] = $button;
  2095. }
  2096. // print_r($receiptList);die;
  2097. $mothHtml = "";
  2098. for($i = 1; $i <= 12; $i ++) {
  2099. if ($moth == $i)
  2100. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2101. else
  2102. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2103. }
  2104. $dateHtml = "";
  2105. $now = date ( "Y" );
  2106. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  2107. if ($YEARD <= $now) {
  2108. $dateHtml .= '<option ';
  2109. if ($year == $YEARD) {
  2110. $dateHtml .= 'selected ';
  2111. }
  2112. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  2113. }
  2114. }
  2115. $data ['dateHtml'] = $dateHtml;
  2116. $data ['mothHtml'] = $mothHtml;
  2117. $data ['receiptList'] = $receiptList;
  2118. $data ['memu'] = "receipt";
  2119. $data ['staff'] = $this->staff;
  2120. $data ['receiptMemu'] = 'expenses';
  2121. $data ['verifyId'] = $this->verifyId;
  2122. $data ['executeId'] = $this->executeId;
  2123. $data ['item'] = $item;
  2124. $data ['year'] = $year;
  2125. $this->render ( "/admin/expenses", $data );
  2126. }
  2127. function expensesCollect() {
  2128. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2129. Doo::loadModel ( 'receipt' );
  2130. $receipt = new receipt ();
  2131. Doo::loadModel ( 'L_category' );
  2132. $Lcategory = new L_category ();
  2133. Doo::loadModel ( 'verify' );
  2134. Doo::loadModel ( 'statistics' );
  2135. $statistics = new statistics ();
  2136. $verify = new verify ();
  2137. Doo::loadModel ( 'staff' );
  2138. $staff = new staff ();
  2139. Doo::loadModel ( 'loanReceipt' );
  2140. $loanReceipt = new loanReceipt ();
  2141. $receiptList = $receipt->find ( array (
  2142. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  2143. 'desc' => 'rid',
  2144. 'asArray' => true
  2145. ) );
  2146. $loanList = $loanReceipt->find ( array (
  2147. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2148. 'desc' => 'rid',
  2149. 'asArray' => true
  2150. ) );
  2151. /*
  2152. * $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;
  2153. */
  2154. $data ['explanation'] = '';
  2155. if (! empty ( $loanList ))
  2156. $data ['explanation'] = $loanList [0] ['explanation'];
  2157. $Locate = 0;
  2158. $roleId = 0;
  2159. $button = 0;
  2160. foreach ( $receiptList as $key => $value ) {
  2161. $receiptList [$key] ['Locate'] = $Locate;
  2162. $Locate ++;
  2163. $receiptList [$key] ['reviseDetail'] = array ();
  2164. if (! empty ( $value ['reviseDetail'] ))
  2165. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2166. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2167. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2168. $categoryDetil = $Lcategory->getOne ( array (
  2169. 'where' => 'cid=' . $value ['cid'],
  2170. 'asArray' => true
  2171. ) );
  2172. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2173. // 检测编辑状态
  2174. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  2175. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  2176. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  2177. else
  2178. $verifyList ['staff'] = $value ['verifyBreakup'];
  2179. } else
  2180. $verifyList = $verify->getOne ( array (
  2181. 'where' => 'vid=' . $value ['verify'],
  2182. 'asArray' => true
  2183. ) );
  2184. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2185. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2186. Doo::loadModel ( 'role' );
  2187. $role = new role ();
  2188. $flag = true;
  2189. $roleKey = 0;
  2190. $endStaffArray = array ();
  2191. $roleArrayCopy = array ();
  2192. foreach ( $verifyList as $k => $v ) {
  2193. // init verifyStaff
  2194. if ($v [1] == 'ROLE') {
  2195. if (! empty ( $verifyStaff )) {
  2196. $endStaffArray = end ( $verifyStaff );
  2197. // if ($v[0]==$endStaffArray['nextStaff']){
  2198. // $roleId=$v[0];
  2199. // }
  2200. }
  2201. $roleVerify = json_decode ( $v [3], true );
  2202. $roleKey = $k;
  2203. $roleArray = array ();
  2204. $rolename = $role->getOne ( array (
  2205. 'where' => 'rid=' . $v [0],
  2206. 'asArray' => true
  2207. ) );
  2208. foreach ( $roleVerify as $o => $p ) {
  2209. $staffID = explode ( '_', $p );
  2210. $staffInfo = $staff->getOne ( array (
  2211. 'where' => 'sid=' . $staffID [0],
  2212. 'asArray' => true
  2213. ) );
  2214. // print_r($staffID);
  2215. $exp = array (
  2216. 0 => $staffInfo ['sid'],
  2217. 1 => $staffID [1],
  2218. 2 => $staffInfo ['avatar'],
  2219. 'date' => '',
  2220. 'date' => '',
  2221. 'opinion' => '',
  2222. 'status' => '',
  2223. 'rolename' => $rolename ['name']
  2224. );
  2225. array_push ( $roleArray, $exp );
  2226. }
  2227. $roleArrayCopy [$v [0]] = $roleArray;
  2228. // $verifyList[$k]['roleArray']=$roleArray;
  2229. }
  2230. $verifyList [$k] ['date'] = "";
  2231. $verifyList [$k] ['opinion'] = "";
  2232. $verifyList [$k] ['status'] = "";
  2233. if (empty ( $verifyStaff )) {
  2234. $verifyList [$k] ['date'] = "";
  2235. $verifyList [$k] ['opinion'] = "";
  2236. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2237. $verifyList [$k] ['status'] = 4;
  2238. $flag = false;
  2239. }
  2240. } else {
  2241. foreach ( $verifyStaff as $m => $u ) {
  2242. if ($v [0] == $m) {
  2243. $verifyList [$k] ['date'] = $u ['date'];
  2244. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2245. $verifyList [$k] ['status'] = $u ['status'];
  2246. $flag = false;
  2247. break;
  2248. }
  2249. }
  2250. $endStaffArray = end ( $verifyStaff );
  2251. if (isset ( $endStaffArray ['ROLE'] )) {
  2252. } else {
  2253. // $endKey=key($verifyStaff);
  2254. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2255. // $button=4;
  2256. // $verifyList[$k]['status']=4;
  2257. // }
  2258. }
  2259. }
  2260. }
  2261. $rolename ['name'] = '';
  2262. if (! empty ( $roleId )) {
  2263. Doo::loadModel ( 'role' );
  2264. $role = new role ();
  2265. $rolename = $role->getOne ( array (
  2266. 'where' => 'rid=' . $roleId,
  2267. 'asArray' => true
  2268. ) );
  2269. }
  2270. if (! empty ( $verifyStaff ))
  2271. $endStaffArray = end ( $verifyStaff );
  2272. $KOP = false;
  2273. foreach ( $roleArrayCopy as $P => $A ) {
  2274. foreach ( $A as $MKI => $AVL ) {
  2275. if (! empty ( $verifyStaff )) {
  2276. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2277. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2278. $button = 4;
  2279. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2280. }
  2281. foreach ( $verifyStaff as $m => $u ) {
  2282. $AVLFK = $AVL [0] . '_R';
  2283. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2284. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2285. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2286. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2287. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2288. break;
  2289. }
  2290. }
  2291. } else {
  2292. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2293. $button = 4;
  2294. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2295. }
  2296. }
  2297. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2298. $KOP = true;
  2299. }
  2300. }
  2301. foreach ( $roleArrayCopy as $k => $v ) {
  2302. foreach ( $verifyList as $m => $n ) {
  2303. if ($n [0] == $k) {
  2304. array_splice ( $verifyList, $m, 1, $v );
  2305. }
  2306. }
  2307. }
  2308. // 费用执行人相关数据
  2309. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2310. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2311. foreach ( $executeCopy as $k => $v ) {
  2312. $executeCopy [$k] ['date'] = '';
  2313. $executeCopy [$k] ['opinion'] = '';
  2314. $executeCopy [$k] ['status'] = '';
  2315. if (! empty ( $executeStaff ))
  2316. foreach ( $executeStaff as $m => $u ) {
  2317. if ($v [0] == $m) {
  2318. $executeCopy [$k] ['date'] = $u ['date'];
  2319. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2320. $executeCopy [$k] ['status'] = $u ['status'];
  2321. break;
  2322. }
  2323. }
  2324. }
  2325. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2326. $receiptList [$key] ['verifyList'] = $verifyList;
  2327. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2328. 'where' => 'sid=' . $value ['staff'],
  2329. 'asArray' => true
  2330. ) );
  2331. $receiptList [$key] ['button'] = $button;
  2332. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2333. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2334. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  2335. $receiptList [$key] ['relust'] = $relust;
  2336. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2337. }
  2338. Doo::loadModel ( 'enclosur' );
  2339. $enclosur = new enclosur ();
  2340. $enclosurList = $enclosur->find ( array (
  2341. 'where' => 'rid=' . $rid,
  2342. 'asArray' => true
  2343. ) );
  2344. $enclosurHtml = '';
  2345. foreach ( $enclosurList as $value ) {
  2346. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2347. }
  2348. $data ['enclosurHtml'] = $enclosurHtml;
  2349. // print_r($receiptList);
  2350. $data ['receiptList'] = $receiptList;
  2351. $data ['memu'] = "receipt";
  2352. $data ['staff'] = $this->staff;
  2353. $data ['receiptMemu'] = 'expenses';
  2354. $data ['verifyId'] = $this->verifyId;
  2355. $data ['executeId'] = $this->executeId;
  2356. $this->render ( "/admin/expensesCollect", $data );
  2357. }
  2358. function approvalExpenses() {
  2359. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  2360. $year = $rdate = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2361. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2362. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2363. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2364. // $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) :"";
  2365. // echo $rdate;
  2366. if (empty ( $status ))
  2367. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  2368. $page_size = 12;
  2369. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2370. $vidList = array ();
  2371. $button = 0;
  2372. Doo::loadModel ( 'verify' );
  2373. $verify = new verify ();
  2374. Doo::loadModel ( 'receipt' );
  2375. $receipt = new receipt ();
  2376. Doo::loadModel ( 'staff' );
  2377. $staff = new staff ();
  2378. Doo::loadModel ( 'L_category' );
  2379. $Lcategory = new L_category ();
  2380. // user verify ID
  2381. $verifyDetail = $verify->find ( array (
  2382. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  2383. 'asArray' => true
  2384. ) );
  2385. foreach ( $verifyDetail as $key => $value ) {
  2386. array_push ( $vidList, $value ['vid'] );
  2387. }
  2388. $vid = implode ( ",", $vidList );
  2389. if (empty ( $verifyDetail ))
  2390. $vid = 0;
  2391. // if ($status==0)
  2392. // $dateCondition="";
  2393. // else
  2394. $dateCondition = " ";
  2395. // if (! empty ( $month ))
  2396. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  2397. if ($status == 'done' || $status == 'termination') {
  2398. if (! empty ( $year )) {
  2399. $dateCondition = " and Year(pastDate) =" . $year;
  2400. if (! empty ( $month ))
  2401. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  2402. }
  2403. } elseif ($status == 'finish') {
  2404. if (! empty ( $year )) {
  2405. $dateCondition = " and Year(pastDate) =" . $year;
  2406. if (! empty ( $month ))
  2407. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  2408. }
  2409. }
  2410. // date ( 'Y-m' )
  2411. // if (! empty ( $rdate ) && $status == 'done')
  2412. // $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  2413. // elseif (! empty ( $rdate ))
  2414. // $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  2415. $categoryList = $Lcategory->find ( array (
  2416. 'asArray' => true
  2417. ) );
  2418. $staffList = $staff->find ( array (
  2419. 'where' => 'cid=' . $cid,
  2420. 'asArray' => true
  2421. ) );
  2422. $cateCondition = "";
  2423. $staffCondition = "";
  2424. $approvalCondition = "";
  2425. if (! empty ( $cid )) {
  2426. $cateCondition = ' and cid=' . $cid;
  2427. }
  2428. if (! empty ( $sid )) {
  2429. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  2430. $cateCondition = "";
  2431. }
  2432. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  2433. if ($status == 'pendApproval') {
  2434. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  2435. }
  2436. if ($status == 'ongoing') {
  2437. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  2438. }
  2439. if ($status == 'done') {
  2440. $approvalCondition = ' and (status=8 or status=9 ) ';
  2441. }
  2442. if ($status == 'termination') {
  2443. $approvalCondition = " and status=3";
  2444. }
  2445. if ($status == 'finish') {
  2446. $approvalCondition = " and (status=1 or status=8 or status=9)";
  2447. }
  2448. $pageinfo ['page'] = array (
  2449. 'previous' => ''
  2450. );
  2451. if ($status == 'done' || $status == 'termination' || $status == 'finish') { // $dateCondition .
  2452. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  2453. $receiptList = $receipt->find ( array ( // $dateCondition.
  2454. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  2455. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2456. 'desc' => 'rid',
  2457. 'asArray' => true
  2458. ) );
  2459. } else {
  2460. $receiptList = $receipt->find ( array ( // $dateCondition
  2461. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  2462. 'desc' => 'rid',
  2463. 'asArray' => true
  2464. ) );
  2465. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  2466. }
  2467. $rLRes = $receipt->find ( array (
  2468. '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 . ')',
  2469. 'desc' => 'rid',
  2470. 'asArray' => true
  2471. ) );
  2472. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  2473. // print_r($receiptList);
  2474. $Locate = 0;
  2475. $reportList = $reportCateList = array ();
  2476. foreach ( $receiptList as $key => $value ) {
  2477. $receiptList [$key] ['Locate'] = $Locate;
  2478. $Locate ++;
  2479. $receiptList [$key] ['reviseDetail'] = array ();
  2480. if (! empty ( $value ['reviseDetail'] ))
  2481. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2482. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2483. $categoryDetil = $Lcategory->getOne ( array (
  2484. 'where' => 'cid=' . $value ['cid'],
  2485. 'asArray' => true
  2486. ) );
  2487. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2488. $verifyList = $verify->getOne ( array (
  2489. 'where' => 'vid=' . $value ['verify'],
  2490. 'asArray' => true
  2491. ) );
  2492. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2493. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2494. foreach ( $verifyList as $k => $v ) {
  2495. // init verifyStaff
  2496. $verifyList [$k] ['date'] = "";
  2497. $verifyList [$k] ['opinion'] = "";
  2498. $verifyList [$k] ['status'] = "";
  2499. if (empty ( $verifyStaff )) {
  2500. $verifyList [$k] ['date'] = "";
  2501. $verifyList [$k] ['opinion'] = "";
  2502. if ($v [0] == $this->staff [0] ['sid']) {
  2503. $verifyList [$k] ['status'] = 4;
  2504. $button = 4;
  2505. }
  2506. } else {
  2507. $flag = true;
  2508. foreach ( $verifyStaff as $m => $u ) {
  2509. if ($v [0] == $m) {
  2510. $verifyList [$k] ['date'] = $u ['date'];
  2511. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2512. $verifyList [$k] ['status'] = $u ['status'];
  2513. $flag = false;
  2514. break;
  2515. }
  2516. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  2517. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  2518. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  2519. }
  2520. if ($flag) { // 检测可编辑
  2521. if ($v [0] == $this->staff [0] ['sid']) {
  2522. $verifyList [$k] ['status'] = 4;
  2523. $button = 4;
  2524. }
  2525. }
  2526. }
  2527. }
  2528. $receiptList [$key] ['verifyList'] = $verifyList;
  2529. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2530. 'where' => 'sid=' . $value ['staff'],
  2531. 'asArray' => true
  2532. ) );
  2533. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  2534. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  2535. $receiptList [$key] ['button'] = $button;
  2536. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  2537. }
  2538. $reportList = array_unique ( $reportList );
  2539. $reportHtml = '';
  2540. foreach ( $reportList as $key => $value ) {
  2541. $v = explode ( "-", $value );
  2542. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  2543. }
  2544. // print_r($reportList)
  2545. $data ['reportHtml'] = $reportHtml;
  2546. $reportCateList = array_unique ( $reportCateList );
  2547. $reportCateHtml = '';
  2548. foreach ( $reportCateList as $key => $value ) {
  2549. $v = explode ( "-", $value );
  2550. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  2551. }
  2552. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  2553. $data ['reportCateHtml'] = $reportCateHtml;
  2554. // print_r($receiptList);die;
  2555. // $data['verifyDetail']=$verifyDetail;
  2556. $mothHtml = "";
  2557. for($i = 1; $i <= 12; $i ++) {
  2558. if ($month == $i)
  2559. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2560. else
  2561. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2562. }
  2563. $data ['mothHtml'] = $mothHtml;
  2564. $dateHtml = "";
  2565. $now = date ( "Y" );
  2566. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  2567. if ($YEARD <= $now) {
  2568. $dateHtml .= '<option ';
  2569. if ($year == $YEARD) {
  2570. $dateHtml .= 'selected ';
  2571. }
  2572. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  2573. }
  2574. }
  2575. $data ['dateHtml'] = $dateHtml;
  2576. $data ['page'] = $pageinfo;
  2577. $data ['receiptList'] = $receiptList;
  2578. $data ['receiptApprovalCount'] = count ( $rLRes );
  2579. $data ['status'] = $status;
  2580. $data ['year'] = $year;
  2581. $data ['categoryList'] = $categoryList;
  2582. $data ['staffList'] = $staffList;
  2583. $data ['cid'] = $cid;
  2584. $data ['sid'] = $sid;
  2585. // print_r($receiptList);
  2586. $data ['memu'] = "receipt";
  2587. $data ['staff'] = $this->staff;
  2588. $data ['receiptMemu'] = 'approvalExpenses';
  2589. $data ['verifyId'] = $this->verifyId;
  2590. $data ['executeId'] = $this->executeId;
  2591. $this->render ( "/admin/approvalExpenses", $data );
  2592. }
  2593. function expensesDoc() {
  2594. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2595. Doo::loadClass ( 'XDeode' );
  2596. $XDeode = new XDeode ( 5 );
  2597. if (! empty ( $rid ) && ! is_numeric ( $rid ))
  2598. $rid = $XDeode->decode ( $rid );
  2599. if (! is_numeric ( $rid ))
  2600. die ( 'illegal request' );
  2601. Doo::loadModel ( 'receipt' );
  2602. $receipt = new receipt ();
  2603. Doo::loadModel ( 'L_category' );
  2604. $Lcategory = new L_category ();
  2605. Doo::loadModel ( 'verify' );
  2606. Doo::loadModel ( 'statistics' );
  2607. $statistics = new statistics ();
  2608. $verify = new verify ();
  2609. Doo::loadModel ( 'staff' );
  2610. $staff = new staff ();
  2611. Doo::loadModel ( 'loanReceipt' );
  2612. $loanReceipt = new loanReceipt ();
  2613. $receiptList = $receipt->find ( array (
  2614. 'where' => ' rid=' . $rid,
  2615. 'desc' => 'rid',
  2616. 'asArray' => true
  2617. ) );
  2618. $loanList = array ();
  2619. if (! empty ( $receiptList ))
  2620. $loanList = $loanReceipt->find ( array (
  2621. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2622. 'desc' => 'rid',
  2623. 'asArray' => true
  2624. ) );
  2625. $Locate = 0;
  2626. $roleId = 0;
  2627. $button = 0;
  2628. foreach ( $loanList as $key => $value ) {
  2629. $loanList [$key] ['Locate'] = $Locate;
  2630. $Locate ++;
  2631. $loanList [$key] ['reviseDetail'] = array ();
  2632. if (! empty ( $value ['reviseDetail'] ))
  2633. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2634. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2635. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2636. $categoryDetil = $Lcategory->getOne ( array (
  2637. 'where' => 'cid=' . $value ['cid'],
  2638. 'asArray' => true
  2639. ) );
  2640. $loanList [$key] ['category'] = $categoryDetil ['title'];
  2641. // 检测编辑状态
  2642. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  2643. $verifyList ['staff'] = $value ['verifyBreakup'];
  2644. else
  2645. $verifyList = $verify->getOne ( array (
  2646. 'where' => 'vid=' . $value ['verify'],
  2647. 'asArray' => true
  2648. ) );
  2649. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2650. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2651. Doo::loadModel ( 'role' );
  2652. $role = new role ();
  2653. $flag = true;
  2654. $roleKey = 0;
  2655. $endStaffArray = array ();
  2656. $roleArrayCopy = array ();
  2657. foreach ( $verifyList as $k => $v ) {
  2658. // init verifyStaff
  2659. if ($v [1] == 'ROLE') {
  2660. if (! empty ( $verifyStaff )) {
  2661. $endStaffArray = end ( $verifyStaff );
  2662. // if ($v[0]==$endStaffArray['nextStaff']){
  2663. // $roleId=$v[0];
  2664. // }
  2665. }
  2666. $roleVerify = json_decode ( $v [3], true );
  2667. $roleKey = $k;
  2668. $roleArray = array ();
  2669. $rolename = $role->getOne ( array (
  2670. 'where' => 'rid=' . $v [0],
  2671. 'asArray' => true
  2672. ) );
  2673. foreach ( $roleVerify as $o => $p ) {
  2674. $staffID = explode ( '_', $p );
  2675. $staffInfo = $staff->getOne ( array (
  2676. 'where' => 'sid=' . $staffID [0],
  2677. 'asArray' => true
  2678. ) );
  2679. // print_r($staffID);
  2680. $exp = array (
  2681. 0 => $staffInfo ['sid'],
  2682. 1 => $staffID [1],
  2683. 2 => $staffInfo ['avatar'],
  2684. 'date' => '',
  2685. 'date' => '',
  2686. 'opinion' => '',
  2687. 'status' => '',
  2688. 'rolename' => $rolename ['name']
  2689. );
  2690. array_push ( $roleArray, $exp );
  2691. }
  2692. $roleArrayCopy [$v [0]] = $roleArray;
  2693. // $verifyList[$k]['roleArray']=$roleArray;
  2694. }
  2695. $verifyList [$k] ['date'] = "";
  2696. $verifyList [$k] ['opinion'] = "";
  2697. $verifyList [$k] ['status'] = "";
  2698. if (empty ( $verifyStaff )) {
  2699. $verifyList [$k] ['date'] = "";
  2700. $verifyList [$k] ['opinion'] = "";
  2701. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2702. $verifyList [$k] ['status'] = 4;
  2703. $flag = false;
  2704. }
  2705. } else {
  2706. foreach ( $verifyStaff as $m => $u ) {
  2707. if ($v [0] == $m) {
  2708. $verifyList [$k] ['date'] = $u ['date'];
  2709. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2710. $verifyList [$k] ['status'] = $u ['status'];
  2711. $flag = false;
  2712. break;
  2713. }
  2714. }
  2715. $endStaffArray = end ( $verifyStaff );
  2716. if (isset ( $endStaffArray ['ROLE'] )) {
  2717. } else {
  2718. // $endKey=key($verifyStaff);
  2719. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2720. // $button=4;
  2721. // $verifyList[$k]['status']=4;
  2722. // }
  2723. }
  2724. }
  2725. }
  2726. $rolename ['name'] = '';
  2727. if (! empty ( $roleId )) {
  2728. Doo::loadModel ( 'role' );
  2729. $role = new role ();
  2730. $rolename = $role->getOne ( array (
  2731. 'where' => 'rid=' . $roleId,
  2732. 'asArray' => true
  2733. ) );
  2734. }
  2735. if (! empty ( $verifyStaff ))
  2736. $endStaffArray = end ( $verifyStaff );
  2737. $KOP = false;
  2738. foreach ( $roleArrayCopy as $P => $A ) {
  2739. foreach ( $A as $MKI => $AVL ) {
  2740. if (! empty ( $verifyStaff )) {
  2741. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2742. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2743. $button = 4;
  2744. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2745. }
  2746. foreach ( $verifyStaff as $m => $u ) {
  2747. $AVLFK = $AVL [0] . '_R';
  2748. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2749. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2750. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2751. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2752. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2753. break;
  2754. }
  2755. }
  2756. } else {
  2757. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2758. $button = 4;
  2759. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2760. }
  2761. }
  2762. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2763. $KOP = true;
  2764. }
  2765. }
  2766. foreach ( $roleArrayCopy as $k => $v ) {
  2767. foreach ( $verifyList as $m => $n ) {
  2768. if ($n [0] == $k) {
  2769. array_splice ( $verifyList, $m, 1, $v );
  2770. }
  2771. }
  2772. }
  2773. $loanList [$key] ['verifyList'] = $verifyList;
  2774. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  2775. 'where' => 'sid=' . $value ['staff'],
  2776. 'asArray' => true
  2777. ) );
  2778. $loanList [$key] ['button'] = $button;
  2779. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  2780. }
  2781. $data ['loanList'] = $loanList;
  2782. // print_r($loanList);
  2783. $Locate = 0;
  2784. $roleId = 0;
  2785. $button = 0;
  2786. foreach ( $receiptList as $key => $value ) {
  2787. $receiptList [$key] ['Locate'] = $Locate;
  2788. $Locate ++;
  2789. $receiptList [$key] ['reviseDetail'] = array ();
  2790. if (! empty ( $value ['reviseDetail'] ))
  2791. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2792. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2793. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2794. $categoryDetil = $Lcategory->getOne ( array (
  2795. 'where' => 'cid=' . $value ['cid'],
  2796. 'asArray' => true
  2797. ) );
  2798. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2799. // 检测编辑状态
  2800. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  2801. $verifyList ['staff'] = $value ['verifyBreakup'];
  2802. } else
  2803. $verifyList = $verify->getOne ( array (
  2804. 'where' => 'vid=' . $value ['verify'],
  2805. 'asArray' => true
  2806. ) );
  2807. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2808. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2809. Doo::loadModel ( 'role' );
  2810. $role = new role ();
  2811. if ($verifyList == NULL)
  2812. $verifyList = array ();
  2813. $flag = true;
  2814. $roleKey = 0;
  2815. $endStaffArray = array ();
  2816. $roleArrayCopy = array ();
  2817. foreach ( $verifyList as $k => $v ) {
  2818. // init verifyStaff
  2819. if ($v [1] == 'ROLE') {
  2820. if (! empty ( $verifyStaff )) {
  2821. $endStaffArray = end ( $verifyStaff );
  2822. // if ($v[0]==$endStaffArray['nextStaff']){
  2823. // $roleId=$v[0];
  2824. // }
  2825. }
  2826. $roleVerify = json_decode ( $v [3], true );
  2827. $roleKey = $k;
  2828. $roleArray = array ();
  2829. $rolename = $role->getOne ( array (
  2830. 'where' => 'rid=' . $v [0],
  2831. 'asArray' => true
  2832. ) );
  2833. foreach ( $roleVerify as $o => $p ) {
  2834. $staffID = explode ( '_', $p );
  2835. $staffInfo = $staff->getOne ( array (
  2836. 'where' => 'sid=' . $staffID [0],
  2837. 'asArray' => true
  2838. ) );
  2839. // print_r($staffID);
  2840. $exp = array (
  2841. 0 => $staffInfo ['sid'],
  2842. 1 => $staffID [1],
  2843. 2 => $staffInfo ['avatar'],
  2844. 'date' => '',
  2845. 'date' => '',
  2846. 'opinion' => '',
  2847. 'status' => '',
  2848. 'rolename' => $rolename ['name']
  2849. );
  2850. array_push ( $roleArray, $exp );
  2851. }
  2852. $roleArrayCopy [$v [0]] = $roleArray;
  2853. // $verifyList[$k]['roleArray']=$roleArray;
  2854. }
  2855. $verifyList [$k] ['date'] = "";
  2856. $verifyList [$k] ['opinion'] = "";
  2857. $verifyList [$k] ['status'] = "";
  2858. if (empty ( $verifyStaff )) {
  2859. $verifyList [$k] ['date'] = "";
  2860. $verifyList [$k] ['opinion'] = "";
  2861. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2862. $verifyList [$k] ['status'] = 4;
  2863. $flag = false;
  2864. }
  2865. } else {
  2866. foreach ( $verifyStaff as $m => $u ) {
  2867. if ($v [0] == $m) {
  2868. $verifyList [$k] ['date'] = $u ['date'];
  2869. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2870. $verifyList [$k] ['status'] = $u ['status'];
  2871. $flag = false;
  2872. break;
  2873. }
  2874. }
  2875. $endStaffArray = end ( $verifyStaff );
  2876. if (isset ( $endStaffArray ['ROLE'] )) {
  2877. } else {
  2878. // $endKey=key($verifyStaff);
  2879. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2880. // $button=4;
  2881. // $verifyList[$k]['status']=4;
  2882. // }
  2883. }
  2884. }
  2885. }
  2886. $FC = $rolename ['name'];
  2887. $rolename ['name'] = '';
  2888. if (! empty ( $roleId )) {
  2889. Doo::loadModel ( 'role' );
  2890. $role = new role ();
  2891. $rolename = $role->getOne ( array (
  2892. 'where' => 'rid=' . $roleId,
  2893. 'asArray' => true
  2894. ) );
  2895. }
  2896. if (! empty ( $verifyStaff ))
  2897. $endStaffArray = end ( $verifyStaff );
  2898. $KOP = false;
  2899. foreach ( $roleArrayCopy as $P => $A ) {
  2900. foreach ( $A as $MKI => $AVL ) {
  2901. if (! empty ( $verifyStaff )) {
  2902. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2903. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2904. $button = 4;
  2905. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2906. }
  2907. foreach ( $verifyStaff as $m => $u ) {
  2908. $AVLFK = $AVL [0] . '_R';
  2909. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2910. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2911. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2912. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2913. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2914. break;
  2915. }
  2916. }
  2917. } else {
  2918. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2919. $button = 4;
  2920. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2921. }
  2922. }
  2923. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2924. $KOP = true;
  2925. }
  2926. }
  2927. foreach ( $roleArrayCopy as $k => $v ) {
  2928. foreach ( $verifyList as $m => $n ) {
  2929. if ($n [0] == $k) {
  2930. array_splice ( $verifyList, $m, 1, $v );
  2931. }
  2932. }
  2933. }
  2934. // 费用执行人相关数据
  2935. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2936. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2937. foreach ( $executeCopy as $k => $v ) {
  2938. $executeCopy [$k] ['date'] = '';
  2939. $executeCopy [$k] ['opinion'] = '';
  2940. $executeCopy [$k] ['status'] = '';
  2941. if (! empty ( $executeStaff ))
  2942. foreach ( $executeStaff as $m => $u ) {
  2943. if ($v [0] == $m) {
  2944. $executeCopy [$k] ['date'] = $u ['date'];
  2945. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2946. $executeCopy [$k] ['status'] = $u ['status'];
  2947. break;
  2948. }
  2949. }
  2950. }
  2951. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2952. // print_r($verifyList);
  2953. $receiptList [$key] ['verifyList'] = $verifyList;
  2954. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2955. 'where' => 'sid=' . $value ['staff'],
  2956. 'asArray' => true
  2957. ) );
  2958. $receiptList [$key] ['button'] = $button;
  2959. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2960. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2961. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  2962. $receiptList [$key] ['relust'] = $relust;
  2963. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2964. }
  2965. // print_r($receiptList);
  2966. // 获取审批日志
  2967. Doo::loadModel ( 'receiptLog' );
  2968. $receiptLog = new receiptLog ();
  2969. $rlList = array ();
  2970. $rlInfo = $receiptLog->getOne ( array (
  2971. 'where' => 'rid=' . $rid . ' and status=4',
  2972. 'asArray' => true
  2973. ) );
  2974. $tijdate = $receiptLog->getOne ( array (
  2975. 'where' => 'rid=' . $rid . ' and status=2',
  2976. 'asc' => 'rlid',
  2977. 'asArray' => true
  2978. ) );
  2979. if (! empty ( $rlInfo )) {
  2980. $rlList = $receiptLog->find ( array (
  2981. 'where' => 'rid=' . $rid,
  2982. 'asc' => 'rlid',
  2983. 'asArray' => true
  2984. ) );
  2985. }
  2986. $RN = json_decode ( $rolename ['staff'] );
  2987. //
  2988. foreach ( $rlList as $key => $value ) {
  2989. $rlList [$key] ['rolename'] = '';
  2990. foreach ( $RN as $k => $v ) {
  2991. $id = explode ( "_", $v );
  2992. if ($id [0] == $value ['uid']) {
  2993. $rlList [$key] ['rolename'] = $FC;
  2994. break;
  2995. }
  2996. }
  2997. }
  2998. Doo::loadModel ( 'enclosur' );
  2999. $enclosur = new enclosur ();
  3000. $enclosurList = $enclosur->find ( array (
  3001. 'where' => 'rid=' . $rid,
  3002. 'asArray' => true
  3003. ) );
  3004. $enclosurHtml = '';
  3005. foreach ( $enclosurList as $value ) {
  3006. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3007. }
  3008. $data ['enclosurHtml'] = $enclosurHtml;
  3009. $receiptList [0] ['rlList'] = $rlList;
  3010. $data ['receiptList'] = $receiptList;
  3011. // print_r($receiptList);
  3012. $data ['memu'] = "receipt";
  3013. $data ['staff'] = $this->staff;
  3014. $data ['receiptMemu'] = 'approvalExpenses';
  3015. $data ['verifyId'] = $this->verifyId;
  3016. $data ['executeId'] = $this->executeId;
  3017. $this->render ( "/admin/expensesDoc", $data );
  3018. }
  3019. function expensesEdi() {
  3020. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3021. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  3022. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  3023. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  3024. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3025. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  3026. if (empty ( $status ))
  3027. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  3028. $vidList = array ();
  3029. $button = 0;
  3030. Doo::loadModel ( 'verify' );
  3031. Doo::loadModel ( 'receipt' );
  3032. Doo::loadModel ( 'staff' );
  3033. $staff = new staff ();
  3034. $receipt = new receipt ();
  3035. $verify = new verify ();
  3036. Doo::loadModel ( 'L_category' );
  3037. $Lcategory = new L_category ();
  3038. Doo::loadModel ( 'enclosur' );
  3039. $enclosur = new enclosur ();
  3040. // user verify ID
  3041. $verifyDetail = $verify->find ( array (
  3042. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  3043. 'asArray' => true
  3044. ) );
  3045. foreach ( $verifyDetail as $key => $value ) {
  3046. array_push ( $vidList, $value ['vid'] );
  3047. }
  3048. $vid = implode ( ",", $vidList );
  3049. if (empty ( $verifyDetail ))
  3050. $vid = 0;
  3051. $categoryList = $Lcategory->find ( array (
  3052. 'asArray' => true
  3053. ) );
  3054. $staffList = $staff->find ( array (
  3055. 'where' => 'cid=' . $cid,
  3056. 'asArray' => true
  3057. ) );
  3058. $ap = "";
  3059. if ($status == 4) {
  3060. $ap = 4;
  3061. $status = 2;
  3062. }
  3063. // get Receipt By verifyID status 2
  3064. $receiptList = $receipt->find ( array (
  3065. 'where' => 'rid =' . $rid . ' and status=2',
  3066. 'desc' => 'rid',
  3067. 'asArray' => true
  3068. ) );
  3069. if (empty ( $receiptList )) {
  3070. die ( 'illegal request' );
  3071. }
  3072. $Locate = 0;
  3073. $roleId = 0;
  3074. if ($ap == 4)
  3075. $status = 4;
  3076. foreach ( $receiptList as $key => $value ) {
  3077. $receiptList [$key] ['Locate'] = $Locate;
  3078. $Locate ++;
  3079. $receiptList [$key] ['reviseDetail'] = array ();
  3080. if (! empty ( $value ['reviseDetail'] ))
  3081. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3082. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3083. $categoryDetil = $Lcategory->getOne ( array (
  3084. 'where' => 'cid=' . $value ['cid'],
  3085. 'asArray' => true
  3086. ) );
  3087. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3088. // 检测编辑状态
  3089. $verifyList = $verify->getOne ( array (
  3090. 'where' => 'vid=' . $value ['verify'],
  3091. 'asArray' => true
  3092. ) );
  3093. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3094. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3095. Doo::loadModel ( 'role' );
  3096. $role = new role ();
  3097. // print_r($verifyList);
  3098. $flag = true;
  3099. $roleKey = 0;
  3100. $endStaffArray = array ();
  3101. $roleArrayCopy = array ();
  3102. foreach ( $verifyList as $k => $v ) {
  3103. // init verifyStaff
  3104. if ($v [1] == 'ROLE') {
  3105. if (! empty ( $verifyStaff )) {
  3106. $endStaffArray = end ( $verifyStaff );
  3107. if ($v [0] == $endStaffArray ['nextStaff']) {
  3108. $roleId = $v [0];
  3109. }
  3110. }
  3111. $roleVerify = json_decode ( $v [3], true );
  3112. $roleKey = $k;
  3113. $roleArray = array ();
  3114. $rolename = $role->getOne ( array (
  3115. 'where' => 'rid=' . $v [0],
  3116. 'asArray' => true
  3117. ) );
  3118. foreach ( $roleVerify as $o => $p ) {
  3119. $staffID = explode ( '_', $p );
  3120. $staffInfo = $staff->getOne ( array (
  3121. 'where' => 'sid=' . $staffID [0],
  3122. 'asArray' => true
  3123. ) );
  3124. // print_r($staffID);
  3125. $exp = array (
  3126. 0 => $staffInfo ['sid'],
  3127. 1 => $staffID [1],
  3128. 2 => $staffInfo ['avatar'],
  3129. 'date' => '',
  3130. 'date' => '',
  3131. 'opinion' => '',
  3132. 'status' => '',
  3133. 'rolename' => $rolename ['name']
  3134. );
  3135. array_push ( $roleArray, $exp );
  3136. }
  3137. $roleArrayCopy [$v [0]] = $roleArray;
  3138. // $verifyList[$k]['roleArray']=$roleArray;
  3139. }
  3140. // print_r($roleArray);
  3141. $verifyList [$k] ['date'] = "";
  3142. $verifyList [$k] ['opinion'] = "";
  3143. $verifyList [$k] ['status'] = "";
  3144. if (empty ( $verifyStaff )) {
  3145. $verifyList [$k] ['date'] = "";
  3146. $verifyList [$k] ['opinion'] = "";
  3147. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3148. $verifyList [$k] ['status'] = 4;
  3149. $button = 4;
  3150. $flag = false;
  3151. }
  3152. } else {
  3153. foreach ( $verifyStaff as $m => $u ) {
  3154. if ($v [0] == $m) {
  3155. $verifyList [$k] ['date'] = $u ['date'];
  3156. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3157. $verifyList [$k] ['status'] = $u ['status'];
  3158. $flag = false;
  3159. break;
  3160. }
  3161. }
  3162. $endStaffArray = end ( $verifyStaff );
  3163. if (isset ( $endStaffArray ['ROLE'] )) {
  3164. } else {
  3165. $endKey = key ( $verifyStaff );
  3166. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  3167. $button = 4;
  3168. $verifyList [$k] ['status'] = 4;
  3169. }
  3170. }
  3171. }
  3172. }
  3173. $rolename ['name'] = '';
  3174. if (! empty ( $roleId )) {
  3175. Doo::loadModel ( 'role' );
  3176. $role = new role ();
  3177. $rolename = $role->getOne ( array (
  3178. 'where' => 'rid=' . $roleId,
  3179. 'asArray' => true
  3180. ) );
  3181. }
  3182. if (! empty ( $verifyStaff ))
  3183. $endStaffArray = end ( $verifyStaff );
  3184. $KOP = false;
  3185. foreach ( $roleArrayCopy as $P => $A ) {
  3186. foreach ( $A as $MKI => $AVL ) {
  3187. if (! empty ( $verifyStaff )) {
  3188. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3189. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3190. $button = 4;
  3191. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3192. }
  3193. foreach ( $verifyStaff as $m => $u ) {
  3194. $AVLFK = $AVL [0] . '_R';
  3195. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3196. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3197. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3198. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3199. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3200. break;
  3201. }
  3202. }
  3203. } else {
  3204. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3205. $button = 4;
  3206. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3207. }
  3208. }
  3209. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3210. $KOP = true;
  3211. }
  3212. }
  3213. // print_r($roleArrayCopy);
  3214. // echo $roleKey;
  3215. foreach ( $roleArrayCopy as $k => $v ) {
  3216. foreach ( $verifyList as $m => $n ) {
  3217. if ($n [0] == $k) {
  3218. array_splice ( $verifyList, $m, 1, $v );
  3219. }
  3220. }
  3221. }
  3222. $receiptList [$key] ['verifyList'] = $verifyList;
  3223. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3224. 'where' => 'sid=' . $value ['staff'],
  3225. 'asArray' => true
  3226. ) );
  3227. $receiptList [$key] ['button'] = $button;
  3228. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  3229. }
  3230. // $data['verifyDetail']=$verifyDetail;
  3231. $mothHtml = "";
  3232. for($i = 1; $i <= 12; $i ++) {
  3233. if ($month == $i)
  3234. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3235. else
  3236. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3237. }
  3238. // 获取审批日志
  3239. Doo::loadModel ( 'receiptLog' );
  3240. $receiptLog = new receiptLog ();
  3241. $rlList = array ();
  3242. $rlInfo = $receiptLog->getOne ( array (
  3243. 'where' => 'rid=' . $rid . ' and status=4',
  3244. 'asArray' => true
  3245. ) );
  3246. $tijdate = $receiptLog->getOne ( array (
  3247. 'where' => 'rid=' . $rid . ' and status=2',
  3248. 'asc' => 'rlid',
  3249. 'asArray' => true
  3250. ) );
  3251. if (! empty ( $rlInfo )) {
  3252. $rlList = $receiptLog->find ( array (
  3253. 'where' => 'rid=' . $rid,
  3254. 'asc' => 'rlid',
  3255. 'asArray' => true
  3256. ) );
  3257. }
  3258. $receiptList [0] ['rlList'] = $rlList;
  3259. $enclosurList = $enclosur->find ( array (
  3260. 'where' => 'rid=' . $rid,
  3261. 'asArray' => true
  3262. ) );
  3263. $enclosurHtml = '';
  3264. foreach ( $enclosurList as $value ) {
  3265. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3266. }
  3267. // print_r($receiptList);
  3268. $data ['rid'] = $rid;
  3269. $data ['enclosurHtml'] = $enclosurHtml;
  3270. $data ['rolename'] = $rolename ['name'];
  3271. $data ['datetij'] = $tijdate ['date'];
  3272. $data ['mothHtml'] = $mothHtml;
  3273. $data ['receiptList'] = $receiptList;
  3274. $data ['receiptApprovalCount'] = count ( $receiptList );
  3275. $data ['status'] = $status;
  3276. $data ['year'] = $year;
  3277. $data ['categoryList'] = $categoryList;
  3278. $data ['staffList'] = $staffList;
  3279. $data ['cid'] = $cid;
  3280. $data ['sid'] = $sid;
  3281. $data ['ap'] = $ap;
  3282. $data ['memu'] = "receipt";
  3283. $data ['staff'] = $this->staff;
  3284. $data ['receiptMemu'] = 'approvalExpenses';
  3285. $data ['verifyId'] = $this->verifyId;
  3286. $data ['executeId'] = $this->executeId;
  3287. $this->render ( "/admin/expensesEdi", $data );
  3288. }
  3289. function expensesDefray() {
  3290. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3291. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3292. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3293. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  3294. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  3295. if (! empty ( $rid )) {
  3296. Doo::loadModel ( "verify" );
  3297. $verify = new verify ();
  3298. Doo::loadModel ( "receiptDetail" );
  3299. $receiptDetailObj = new receiptDetail ();
  3300. Doo::loadModel ( "itemStatistics" );
  3301. Doo::loadModel ( "statistics" );
  3302. $statistics = new statistics ();
  3303. $itemStatistics = new itemStatistics ();
  3304. Doo::loadModel ( "receipt" );
  3305. $receipt = new receipt ();
  3306. Doo::loadModel ( "loanReceipt" );
  3307. $loanReceipt = new loanReceipt ();
  3308. $receiptDetail = $receipt->getOne ( array (
  3309. 'where' => 'rid=' . $rid . ' and status=2 ',
  3310. 'asArray' => true
  3311. ) );
  3312. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  3313. $nsflag = true;
  3314. foreach ( $nslist as $value ) {
  3315. if ($value == $this->staff ['0'] ['sid']) {
  3316. $nsflag = false;
  3317. break;
  3318. }
  3319. }
  3320. // print_r($nslist);die;
  3321. if (empty ( $receiptDetail ) || $nsflag)
  3322. return "/approvalExpenses/pendApproval";
  3323. $verifyDetail = $verify->getOne ( array (
  3324. 'where' => ' vid =' . $receiptDetail ['verify'],
  3325. 'asArray' => true
  3326. ) );
  3327. $verifyString = $verifyDetail ['staff'];
  3328. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3329. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  3330. if (empty ( $opinion )) {
  3331. if ($status == 3)
  3332. $opinion = "终止";
  3333. else
  3334. $opinion = "同意支付";
  3335. }
  3336. $nowStaff = 0;
  3337. $nowStaffList = array ();
  3338. if (empty ( $verifyStaff )) {
  3339. // 还需加入是否已经进入角色审批
  3340. if ($verifyDetail [0] [1] == 'ROLE') {
  3341. // print_r($verifyDetail);echo "ddd";
  3342. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3343. foreach ( $vStaffString as $key => $value ) {
  3344. $staffK = explode ( "_", $value );
  3345. if ($staffK [0] != $this->staff [0] ['sid'])
  3346. array_push ( $nowStaffList, $staffK [0] );
  3347. }
  3348. // print_r($verifyDetail);
  3349. // die;
  3350. if (! empty ( $nowStaffList )) {
  3351. $nowStaff = implode ( ',', $nowStaffList );
  3352. $verifyStaff = array (
  3353. $this->staff [0] ['sid'] . "_R" => array (
  3354. 'date' => date ( 'Y-m-d' ),
  3355. 'opinion' => $opinion,
  3356. 'status' => $status,
  3357. 'nextStaff' => $verifyDetail [0] [0],
  3358. 'ROLE' => 1
  3359. )
  3360. );
  3361. } else {
  3362. $nowStaff = $verifyDetail [1] [0];
  3363. $verifyStaff = array (
  3364. $this->staff [0] ['sid'] . "_R" => array (
  3365. 'date' => date ( 'Y-m-d' ),
  3366. 'opinion' => $opinion,
  3367. 'status' => $status,
  3368. 'nextStaff' => $verifyDetail [1] [0]
  3369. )
  3370. );
  3371. }
  3372. } else {
  3373. if ($verifyDetail [1] [1] == 'ROLE') {
  3374. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  3375. // echo "dd";
  3376. foreach ( $vStaffString as $key => $value ) {
  3377. $staffK = explode ( "_", $value );
  3378. array_push ( $nowStaffList, $staffK [0] );
  3379. }
  3380. $nowStaff = implode ( ',', $nowStaffList );
  3381. $verifyStaff = array (
  3382. $this->staff [0] ['sid'] => array (
  3383. 'date' => date ( 'Y-m-d' ),
  3384. 'opinion' => $opinion,
  3385. 'status' => $status,
  3386. 'nextStaff' => $verifyDetail [1] [0],
  3387. 'ROLE' => 1
  3388. )
  3389. );
  3390. } else {
  3391. $nowStaff = $verifyDetail [1] [0];
  3392. $verifyStaff = array (
  3393. $this->staff [0] ['sid'] => array (
  3394. 'date' => date ( 'Y-m-d' ),
  3395. 'opinion' => $opinion,
  3396. 'status' => $status,
  3397. 'nextStaff' => $verifyDetail [1] [0]
  3398. )
  3399. );
  3400. }
  3401. }
  3402. if ($status == 3)
  3403. $verifyStaff = array (
  3404. 'final' => $status,
  3405. $this->staff [0] ['sid'] => array (
  3406. 'date' => date ( 'Y-m-d' ),
  3407. 'opinion' => $opinion,
  3408. 'status' => $status
  3409. )
  3410. );
  3411. $vStaffString = json_encode ( $verifyStaff );
  3412. $receipt->nowStaff = $nowStaff;
  3413. $receipt->verifyStaff = $vStaffString;
  3414. $loanReceipt->nowStaff = $nowStaff;
  3415. $loanReceipt->verifyStaff = $vStaffString;
  3416. } else {
  3417. $VS = end ( $verifyStaff );
  3418. // 非角色审批
  3419. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  3420. $nextStaff = 0;
  3421. $roleSTF = false;
  3422. foreach ( $verifyDetail as $key => $value ) {
  3423. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  3424. if (isset ( $verifyDetail [$key + 1] )) {
  3425. $nextStaff = $verifyDetail [$key + 1] [0];
  3426. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  3427. $roleSTF = true;
  3428. }
  3429. break;
  3430. }
  3431. }
  3432. if (! $roleSTF) {
  3433. $nowStaff = $nextStaff;
  3434. $verifyStaff [$this->staff [0] ['sid']] = array (
  3435. 'date' => date ( 'Y-m-d' ),
  3436. 'opinion' => $opinion,
  3437. 'status' => $status,
  3438. 'nextStaff' => $nextStaff
  3439. );
  3440. } else {
  3441. // 获取角色下的所有用户ID
  3442. $nowStaffList = array ();
  3443. foreach ( $verifyDetail as $vfk ) {
  3444. if ($vfk [1] == 'ROLE') {
  3445. $vStaffString = json_decode ( $vfk [3] );
  3446. foreach ( $vStaffString as $key => $value ) {
  3447. $staffK = explode ( "_", $value );
  3448. array_push ( $nowStaffList, $staffK [0] );
  3449. }
  3450. }
  3451. }
  3452. $nowStaff = implode ( ',', $nowStaffList );
  3453. $verifyStaff [$this->staff [0] ['sid']] = array (
  3454. 'date' => date ( 'Y-m-d' ),
  3455. 'opinion' => $opinion,
  3456. 'status' => $status,
  3457. 'nextStaff' => $nextStaff,
  3458. 'ROLE' => 0
  3459. );
  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->nowStaff = $nowStaff;
  3471. $receipt->verifyStaff = $vStaffString;
  3472. $loanReceipt->nowStaff = $nowStaff;
  3473. $loanReceipt->verifyStaff = $vStaffString;
  3474. }
  3475. // 角色审批
  3476. if (isset ( $VS ['ROLE'] )) {
  3477. // 找出角色人 当前审批角色组
  3478. $verifyJSStaff = array ();
  3479. $nowStaffList2 = array ();
  3480. foreach ( $verifyDetail as $key => $value ) {
  3481. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  3482. $verifyJSStaff = json_decode ( $value [3] );
  3483. foreach ( $verifyJSStaff as $m ) {
  3484. $staffK = explode ( "_", $m );
  3485. array_push ( $nowStaffList2, $staffK [0] );
  3486. }
  3487. // print_r($nowStaffList2);
  3488. }
  3489. }
  3490. $RoleVerifyStaff = array ();
  3491. foreach ( $verifyStaff as $key => $value ) {
  3492. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  3493. foreach ( $nowStaffList2 as $m ) {
  3494. if ($key == $m . "_R")
  3495. $RoleVerifyStaff [$key] = $value;
  3496. }
  3497. }
  3498. }
  3499. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  3500. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  3501. // 下一个审批人ID
  3502. $nextStaff = 0;
  3503. $falg = false;
  3504. foreach ( $verifyDetail as $key => $value ) {
  3505. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  3506. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  3507. $falg = true;
  3508. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  3509. $nowStaffList = array ();
  3510. foreach ( $vStaffString as $v ) {
  3511. $staffK = explode ( "_", $v );
  3512. array_push ( $nowStaffList, $staffK [0] );
  3513. }
  3514. $nowStaff = implode ( ',', $nowStaffList );
  3515. $nextStaff = $verifyDetail [$key + 1] [0];
  3516. } elseif (isset ( $verifyDetail [$key + 1] )) {
  3517. $nextStaff = $verifyDetail [$key + 1] [0];
  3518. $nowStaff = $nextStaff;
  3519. } else
  3520. $nowStaff = '';
  3521. break;
  3522. }
  3523. }
  3524. if ($falg)
  3525. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3526. 'date' => date ( 'Y-m-d' ),
  3527. 'opinion' => $opinion,
  3528. 'status' => $status,
  3529. 'nextStaff' => $nextStaff,
  3530. 'ROLE' => 1
  3531. );
  3532. else
  3533. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3534. 'date' => date ( 'Y-m-d' ),
  3535. 'opinion' => $opinion,
  3536. 'status' => $status,
  3537. 'nextStaff' => $nextStaff
  3538. );
  3539. // print_r($verifyStaff);
  3540. // echo $nowStaff;die;
  3541. } else { // 进入下一个角色或者审批人
  3542. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  3543. //
  3544. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  3545. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3546. 'date' => date ( 'Y-m-d' ),
  3547. 'opinion' => $opinion,
  3548. 'status' => $status,
  3549. 'nextStaff' => $VS ['nextStaff'],
  3550. 'ROLE' => 1
  3551. );
  3552. // print_r($verifyStaff);
  3553. // die;
  3554. }
  3555. if ($status == 3) {
  3556. $verifyStaff ['final'] = $status;
  3557. $verifyStaff [$this->staff [0] ['sid']] = array (
  3558. 'date' => date ( 'Y-m-d' ),
  3559. 'opinion' => $opinion,
  3560. 'status' => $status
  3561. );
  3562. }
  3563. $vStaffString = json_encode ( $verifyStaff );
  3564. $receipt->verifyStaff = $vStaffString;
  3565. $receipt->nowStaff = $nowStaff;
  3566. $loanReceipt->nowStaff = $nowStaff;
  3567. $loanReceipt->verifyStaff = $vStaffString;
  3568. // die;
  3569. // }
  3570. // print_r($verifyStaff);
  3571. // die;
  3572. }
  3573. // print_r($verifyStaff);die;
  3574. }
  3575. // print_r($verifyDetail);
  3576. $roleKey = 0;
  3577. $roleId = 0;
  3578. $verifyDetailCopy = array ();
  3579. foreach ( $verifyDetail as $k => $v ) {
  3580. if ($v [1] == 'ROLE') {
  3581. $roleId = $v [0];
  3582. $roleVerify = json_decode ( $v [3], true );
  3583. $roleKey = $k;
  3584. $roleArray = array ();
  3585. foreach ( $roleVerify as $o => $p ) {
  3586. $staffID = explode ( '_', $p );
  3587. $exp = array (
  3588. 0 => $staffID [0],
  3589. 1 => $staffID [1]
  3590. );
  3591. array_push ( $roleArray, $exp );
  3592. }
  3593. $verifyDetailCopy [$v [0]] = $roleArray;
  3594. }
  3595. }
  3596. // print_r($verifyDetail);
  3597. foreach ( $verifyDetailCopy as $k => $v ) {
  3598. foreach ( $verifyDetail as $m => $n ) {
  3599. if ($n [0] == $k) {
  3600. array_splice ( $verifyDetail, $m, 1, $v );
  3601. }
  3602. }
  3603. }
  3604. // 审批日志
  3605. if (! isset ( $verifyStaff ['final'] )) {
  3606. Doo::loadModel ( "receiptLog" );
  3607. $receiptLog = new receiptLog ();
  3608. if (! empty ( $roleId )) {
  3609. Doo::loadModel ( "role" );
  3610. $role = new role ();
  3611. $roleInfo = $role->getOne ( array (
  3612. 'where' => 'rid=' . $roleId,
  3613. 'asArray' => true
  3614. ) );
  3615. $receiptLog->rolename = $roleInfo ['name'];
  3616. }
  3617. $receiptLog->username = $this->staff [0] ['username'];
  3618. $receiptLog->uid = $this->staff [0] ['sid'];
  3619. $receiptLog->date = date ( "Y-m-d" );
  3620. $receiptLog->opinion = $opinion;
  3621. $receiptLog->img = $this->staff [0] ['avatar'];
  3622. $receiptLog->status = 1;
  3623. $receiptLog->rid = $rid;
  3624. $receiptLog->insert ();
  3625. }
  3626. if (isset ( $verifyStaff ['final'] )) { // rDetail
  3627. $receipt->status = 3;
  3628. $receipt->verifyBreakup = $verifyString;
  3629. $receiptDetailObj->status = 3;
  3630. $receiptDetailObj->update ( array (
  3631. 'where' => 'rid=' . $rid
  3632. ) );
  3633. // 微信企业号通知
  3634. $this->setWXMsg ( $rid, 3 );
  3635. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  3636. $receipt->status = 6;
  3637. $receipt->pastDate = date ( "Y-m-d" );
  3638. $receipt->isBK = 1;
  3639. $loanReceipt->verifyBreakup = $verifyString;
  3640. $loanReceipt->status = 1;
  3641. $loanReceipt->pastDate = date ( "Y-m-d" );
  3642. $loanReceipt->amount = $receiptDetail ['amount'];
  3643. $loanReceipt->update ( array (
  3644. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  3645. ) );
  3646. // 微信企业号通知
  3647. $this->setWXMsg ( $rid, 1 );
  3648. }
  3649. $receipt->amount = $amount;
  3650. $receipt->update ( array (
  3651. 'where' => ' rid = ' . $rid
  3652. ) );
  3653. // 进入下一条审批费用新加需求
  3654. $vidList = array ();
  3655. $verifyDetail = $verify->find ( array (
  3656. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  3657. 'asArray' => true
  3658. ) );
  3659. foreach ( $verifyDetail as $key => $value ) {
  3660. array_push ( $vidList, $value ['vid'] );
  3661. }
  3662. $vid = implode ( ",", $vidList );
  3663. if (empty ( $verifyDetail ))
  3664. $vid = 0;
  3665. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  3666. $receipt = new receipt ();
  3667. $rd = $receipt->getOne ( array (
  3668. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  3669. 'asc' => 'rid',
  3670. 'asArray' => true
  3671. ) );
  3672. if (empty ( $rd )) {
  3673. return '/approvalExpenses/pendApproval';
  3674. }
  3675. if ($rd ['Rtype'] == 1) {
  3676. if ($rd ['isBK'] == 1) {
  3677. return '/receiptburEdi/' . $rd ['rid'];
  3678. } else {
  3679. return '/expensesEdi/' . $rd ['rid'];
  3680. }
  3681. } elseif ($rd ['Rtype'] == 2) {
  3682. return '/remitApproval/' . $rd ['rid'];
  3683. } else {
  3684. return '/receiptburEdi/' . $rd ['rid'];
  3685. }
  3686. // return "/approvalExpenses/pendApproval";
  3687. }
  3688. }
  3689. function ajaxExamineExe() {
  3690. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3691. Doo::loadModel ( 'receipt' );
  3692. $receipt = new receipt ();
  3693. Doo::loadClass ( 'XDeode' );
  3694. $XDeode = new XDeode ( 5 );
  3695. if (! empty ( $rid )) {
  3696. $rLRes = $receipt->find ( array (
  3697. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  3698. 'asArray' => true
  3699. ) );
  3700. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  3701. echo json_encode ( array (
  3702. 'status' => 1,
  3703. 'receipt' => $rLRes [0]
  3704. ) );
  3705. die ();
  3706. }
  3707. echo json_encode ( array (
  3708. 'status' => 0,
  3709. 'receipt' => array ()
  3710. ) );
  3711. die ();
  3712. }
  3713. function implement() {
  3714. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3715. Doo::loadClass ( 'XDeode' );
  3716. $XDeode = new XDeode ( 5 );
  3717. Doo::loadModel ( 'receipt' );
  3718. $receipt = new receipt ();
  3719. Doo::loadModel ( 'L_category' );
  3720. $Lcategory = new L_category ();
  3721. Doo::loadModel ( 'verify' );
  3722. $verify = new verify ();
  3723. Doo::loadModel ( 'staff' );
  3724. $staff = new staff ();
  3725. Doo::loadModel ( "execute" );
  3726. $execute = new execute ();
  3727. $rid = $XDeode->decode ( $rid );
  3728. $receiptList = $receipt->find ( array (
  3729. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  3730. 'desc' => 'rid',
  3731. 'asArray' => true
  3732. ) );
  3733. Doo::loadModel ( 'loanReceipt' );
  3734. $loanReceipt = new loanReceipt ();
  3735. // print_r($receiptList);
  3736. $loanList = array ();
  3737. if (! isset ( $receiptList ))
  3738. $loanList = $loanReceipt->find ( array (
  3739. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3740. 'desc' => 'rid',
  3741. 'asArray' => true
  3742. ) );
  3743. $Locate = 0;
  3744. $roleId = 0;
  3745. $button = 0;
  3746. foreach ( $loanList as $key => $value ) {
  3747. $loanList [$key] ['Locate'] = $Locate;
  3748. $Locate ++;
  3749. $loanList [$key] ['reviseDetail'] = array ();
  3750. if (! empty ( $value ['reviseDetail'] ))
  3751. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3752. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3753. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3754. $categoryDetil = $Lcategory->getOne ( array (
  3755. 'where' => 'cid=' . $value ['cid'],
  3756. 'asArray' => true
  3757. ) );
  3758. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3759. // 检测编辑状态
  3760. $verifyList = $verify->getOne ( array (
  3761. 'where' => 'vid=' . $value ['verify'],
  3762. 'asArray' => true
  3763. ) );
  3764. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3765. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3766. Doo::loadModel ( 'role' );
  3767. $role = new role ();
  3768. $flag = true;
  3769. $roleKey = 0;
  3770. $endStaffArray = array ();
  3771. $roleArrayCopy = array ();
  3772. foreach ( $verifyList as $k => $v ) {
  3773. // init verifyStaff
  3774. if ($v [1] == 'ROLE') {
  3775. if (! empty ( $verifyStaff )) {
  3776. $endStaffArray = end ( $verifyStaff );
  3777. // if ($v[0]==$endStaffArray['nextStaff']){
  3778. // $roleId=$v[0];
  3779. // }
  3780. }
  3781. $roleVerify = json_decode ( $v [3], true );
  3782. $roleKey = $k;
  3783. $roleArray = array ();
  3784. $rolename = $role->getOne ( array (
  3785. 'where' => 'rid=' . $v [0],
  3786. 'asArray' => true
  3787. ) );
  3788. foreach ( $roleVerify as $o => $p ) {
  3789. $staffID = explode ( '_', $p );
  3790. $staffInfo = $staff->getOne ( array (
  3791. 'where' => 'sid=' . $staffID [0],
  3792. 'asArray' => true
  3793. ) );
  3794. // print_r($staffID);
  3795. $exp = array (
  3796. 0 => $staffInfo ['sid'],
  3797. 1 => $staffID [1],
  3798. 2 => $staffInfo ['avatar'],
  3799. 'date' => '',
  3800. 'date' => '',
  3801. 'opinion' => '',
  3802. 'status' => '',
  3803. 'rolename' => $rolename ['name']
  3804. );
  3805. array_push ( $roleArray, $exp );
  3806. }
  3807. $roleArrayCopy [$v [0]] = $roleArray;
  3808. // $verifyList[$k]['roleArray']=$roleArray;
  3809. }
  3810. $verifyList [$k] ['date'] = "";
  3811. $verifyList [$k] ['opinion'] = "";
  3812. $verifyList [$k] ['status'] = "";
  3813. if (empty ( $verifyStaff )) {
  3814. $verifyList [$k] ['date'] = "";
  3815. $verifyList [$k] ['opinion'] = "";
  3816. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3817. $verifyList [$k] ['status'] = 4;
  3818. $flag = false;
  3819. }
  3820. } else {
  3821. foreach ( $verifyStaff as $m => $u ) {
  3822. if ($v [0] == $m) {
  3823. $verifyList [$k] ['date'] = $u ['date'];
  3824. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3825. $verifyList [$k] ['status'] = $u ['status'];
  3826. $flag = false;
  3827. break;
  3828. }
  3829. }
  3830. $endStaffArray = end ( $verifyStaff );
  3831. if (isset ( $endStaffArray ['ROLE'] )) {
  3832. } else {
  3833. // $endKey=key($verifyStaff);
  3834. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3835. // $button=4;
  3836. // $verifyList[$k]['status']=4;
  3837. // }
  3838. }
  3839. }
  3840. }
  3841. $rolename ['name'] = '';
  3842. if (! empty ( $roleId )) {
  3843. Doo::loadModel ( 'role' );
  3844. $role = new role ();
  3845. $rolename = $role->getOne ( array (
  3846. 'where' => 'rid=' . $roleId,
  3847. 'asArray' => true
  3848. ) );
  3849. }
  3850. if (! empty ( $verifyStaff ))
  3851. $endStaffArray = end ( $verifyStaff );
  3852. $KOP = false;
  3853. foreach ( $roleArrayCopy as $P => $A ) {
  3854. foreach ( $A as $MKI => $AVL ) {
  3855. if (! empty ( $verifyStaff )) {
  3856. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3857. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3858. $button = 4;
  3859. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3860. }
  3861. foreach ( $verifyStaff as $m => $u ) {
  3862. $AVLFK = $AVL [0] . '_R';
  3863. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3864. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3865. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3866. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3867. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3868. break;
  3869. }
  3870. }
  3871. } else {
  3872. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3873. $button = 4;
  3874. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3875. }
  3876. }
  3877. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3878. $KOP = true;
  3879. }
  3880. }
  3881. foreach ( $roleArrayCopy as $k => $v ) {
  3882. foreach ( $verifyList as $m => $n ) {
  3883. if ($n [0] == $k) {
  3884. array_splice ( $verifyList, $m, 1, $v );
  3885. }
  3886. }
  3887. }
  3888. $loanList [$key] ['verifyList'] = $verifyList;
  3889. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3890. 'where' => 'sid=' . $value ['staff'],
  3891. 'asArray' => true
  3892. ) );
  3893. }
  3894. $data ['loanList'] = $loanList;
  3895. $Locate = 0;
  3896. $roleId = 0;
  3897. $button = 0;
  3898. foreach ( $receiptList as $key => $value ) {
  3899. $button2 = 0;
  3900. $receiptList [$key] ['Locate'] = $Locate;
  3901. $Locate ++;
  3902. $receiptList [$key] ['reviseDetail'] = array ();
  3903. if (! empty ( $value ['reviseDetail'] ))
  3904. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3905. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3906. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3907. $categoryDetil = $Lcategory->getOne ( array (
  3908. 'where' => 'cid=' . $value ['cid'],
  3909. 'asArray' => true
  3910. ) );
  3911. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3912. $executeList = json_decode ( $value ['executeCopy'], true );
  3913. $executeStaff = array ();
  3914. if (! empty ( $value ['executeStaff'] ))
  3915. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3916. if (isset ( $executeList )) {
  3917. foreach ( $executeList as $op => $lo ) {
  3918. $executeList [$op] ['date'] = "";
  3919. $executeList [$op] ['opinion'] = "";
  3920. $executeList [$op] ['status'] = "";
  3921. foreach ( $executeStaff as $m => $u ) {
  3922. if ($lo [0] == $m) {
  3923. $executeList [$op] ['date'] = $u ['date'];
  3924. $executeList [$op] ['opinion'] = $u ['opinion'];
  3925. $executeList [$op] ['status'] = $u ['status'];
  3926. break;
  3927. }
  3928. }
  3929. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  3930. $button2 = 1;
  3931. $executeList [$op] ['status'] = 4;
  3932. }
  3933. }
  3934. }
  3935. // 检测编辑状态
  3936. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3937. $verifyList ['staff'] = $value ['verifyBreakup'];
  3938. } else
  3939. $verifyList = $verify->getOne ( array (
  3940. 'where' => 'vid=' . $value ['verify'],
  3941. 'asArray' => true
  3942. ) );
  3943. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3944. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3945. Doo::loadModel ( 'role' );
  3946. $role = new role ();
  3947. if ($verifyList == NULL)
  3948. $verifyList = array ();
  3949. $flag = true;
  3950. $roleKey = 0;
  3951. $endStaffArray = array ();
  3952. $roleArrayCopy = array ();
  3953. foreach ( $verifyList as $k => $v ) {
  3954. // init verifyStaff
  3955. if ($v [1] == 'ROLE') {
  3956. if (! empty ( $verifyStaff )) {
  3957. $endStaffArray = end ( $verifyStaff );
  3958. // if ($v[0]==$endStaffArray['nextStaff']){
  3959. // $roleId=$v[0];
  3960. // }
  3961. }
  3962. $roleVerify = json_decode ( $v [3], true );
  3963. $roleKey = $k;
  3964. $roleArray = array ();
  3965. $rolename = $role->getOne ( array (
  3966. 'where' => 'rid=' . $v [0],
  3967. 'asArray' => true
  3968. ) );
  3969. foreach ( $roleVerify as $o => $p ) {
  3970. $staffID = explode ( '_', $p );
  3971. $staffInfo = $staff->getOne ( array (
  3972. 'where' => 'sid=' . $staffID [0],
  3973. 'asArray' => true
  3974. ) );
  3975. // print_r($staffID);
  3976. $exp = array (
  3977. 0 => $staffInfo ['sid'],
  3978. 1 => $staffID [1],
  3979. 2 => $staffInfo ['avatar'],
  3980. 'date' => '',
  3981. 'date' => '',
  3982. 'opinion' => '',
  3983. 'status' => '',
  3984. 'rolename' => $rolename ['name']
  3985. );
  3986. array_push ( $roleArray, $exp );
  3987. }
  3988. $roleArrayCopy [$v [0]] = $roleArray;
  3989. // $verifyList[$k]['roleArray']=$roleArray;
  3990. }
  3991. $verifyList [$k] ['date'] = "";
  3992. $verifyList [$k] ['opinion'] = "";
  3993. $verifyList [$k] ['status'] = "";
  3994. if (empty ( $verifyStaff )) {
  3995. $verifyList [$k] ['date'] = "";
  3996. $verifyList [$k] ['opinion'] = "";
  3997. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3998. $verifyList [$k] ['status'] = 4;
  3999. $flag = false;
  4000. }
  4001. } else {
  4002. foreach ( $verifyStaff as $m => $u ) {
  4003. if ($v [0] == $m) {
  4004. $verifyList [$k] ['date'] = $u ['date'];
  4005. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4006. $verifyList [$k] ['status'] = $u ['status'];
  4007. $flag = false;
  4008. break;
  4009. }
  4010. }
  4011. $endStaffArray = end ( $verifyStaff );
  4012. if (isset ( $endStaffArray ['ROLE'] )) {
  4013. } else {
  4014. // $endKey=key($verifyStaff);
  4015. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4016. // $button=4;
  4017. // $verifyList[$k]['status']=4;
  4018. // }
  4019. }
  4020. }
  4021. }
  4022. $rolename ['name'] = '';
  4023. if (! empty ( $roleId )) {
  4024. Doo::loadModel ( 'role' );
  4025. $role = new role ();
  4026. $rolename = $role->getOne ( array (
  4027. 'where' => 'rid=' . $roleId,
  4028. 'asArray' => true
  4029. ) );
  4030. }
  4031. if (! empty ( $verifyStaff ))
  4032. $endStaffArray = end ( $verifyStaff );
  4033. $KOP = false;
  4034. foreach ( $roleArrayCopy as $P => $A ) {
  4035. foreach ( $A as $MKI => $AVL ) {
  4036. if (! empty ( $verifyStaff )) {
  4037. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4038. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4039. $button = 4;
  4040. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4041. }
  4042. foreach ( $verifyStaff as $m => $u ) {
  4043. $AVLFK = $AVL [0] . '_R';
  4044. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4045. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4046. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4047. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4048. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4049. break;
  4050. }
  4051. }
  4052. } else {
  4053. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4054. $button = 4;
  4055. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4056. }
  4057. }
  4058. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4059. $KOP = true;
  4060. }
  4061. }
  4062. foreach ( $roleArrayCopy as $k => $v ) {
  4063. foreach ( $verifyList as $m => $n ) {
  4064. if ($n [0] == $k) {
  4065. array_splice ( $verifyList, $m, 1, $v );
  4066. }
  4067. }
  4068. }
  4069. $receiptList [$key] ['verifyList'] = $verifyList;
  4070. $receiptList [$key] ['executeList'] = $executeList;
  4071. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4072. 'where' => 'sid=' . $value ['staff'],
  4073. 'asArray' => true
  4074. ) );
  4075. $receiptList [$key] ['button2'] = $button2;
  4076. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4077. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4078. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  4079. $receiptList [$key] ['relust'] = $relust;
  4080. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  4081. }
  4082. // print_r($receiptList[$key]['executeList']);
  4083. $data ['receiptList'] = $receiptList;
  4084. $data ['memu'] = "receipt";
  4085. $data ['staff'] = $this->staff;
  4086. $data ['receiptMemu'] = 'implement';
  4087. $data ['verifyId'] = $this->verifyId;
  4088. $data ['executeId'] = $this->executeId;
  4089. $this->render ( "/admin/implement", $data );
  4090. }
  4091. function implementDo() {
  4092. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4093. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  4094. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  4095. $accountBank = $this->get_args ( 'accountBank' ) ? $this->get_args ( 'accountBank' ) : "";
  4096. $ab = '';
  4097. if ($accountBank == 'CGBDeposit')
  4098. $ab = '纵横广发';
  4099. elseif ($accountBank == 'ICBCDeposit')
  4100. $ab = '纵横工行';
  4101. elseif ($accountBank == 'HUADeposit')
  4102. $ab = '华润银行';
  4103. elseif ($accountBank == 'PersonalDeposit')
  4104. $ab = '个人广发';
  4105. if (empty ( $ab ))
  4106. die ( 'illegal request' );
  4107. if (! empty ( $rid ) && $amount != '') {
  4108. Doo::loadModel ( 'receipt' );
  4109. $receipt = new receipt ();
  4110. Doo::loadClass ( 'XDeode' );
  4111. $XDeode = new XDeode ( 5 );
  4112. // $rinfo = $receipt->getOne ( array (
  4113. // 'where' => 'rid=' . $rid,
  4114. // 'asArray' => true
  4115. // ) );
  4116. $rinfo = $receipt->getReceiptByRid ( $rid );
  4117. $accountType = '';
  4118. if ($rinfo ['Rtype'] == 1) {
  4119. if ($rinfo ['loanRid'] != 0)
  4120. $accountType = 2;
  4121. else
  4122. $accountType = 1;
  4123. } elseif ($rinfo ['Rtype'] == 2) {
  4124. $accountType = 4;
  4125. } elseif ($rinfo ['Rtype'] == 0)
  4126. $accountType = 3;
  4127. if (empty ( $accountType ))
  4128. die ( 'illegal request' );
  4129. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  4130. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  4131. if (empty ( $executeStaff )) {
  4132. $executeStaff = array (
  4133. $this->staff [0] ['sid'] => array (
  4134. 'date' => date ( 'Y-m-d' ),
  4135. 'opinion' => $implementOpinions,
  4136. 'status' => 1
  4137. )
  4138. );
  4139. } else {
  4140. $executeStaff [$this->staff [0] ['sid']] = array (
  4141. 'date' => date ( 'Y-m-d' ),
  4142. 'opinion' => $implementOpinions,
  4143. 'status' => 1
  4144. );
  4145. }
  4146. if (count ( $executeStaff ) == count ( $executeCopy )) {
  4147. $receipt->executeStaff = json_encode ( $executeStaff );
  4148. $receipt->status = 8;
  4149. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  4150. $receipt->status = 9;
  4151. if ($rinfo ['status'] == 6) {
  4152. $receipt->loanDate = date ( "Y-m-d" );
  4153. }
  4154. $receipt->executeDate = date ( "Y-m-d" );
  4155. } else {
  4156. $receipt->executeStaff = json_encode ( $executeStaff );
  4157. }
  4158. $receipt->amount = $amount;
  4159. $receipt->update ( array (
  4160. 'where' => 'rid=' . $rid
  4161. ) );
  4162. // 公司流水记录
  4163. Doo::loadModel ( 'wasteBook' );
  4164. $wasteBook = new wasteBook ();
  4165. $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountType, $rid );
  4166. // 银行
  4167. if (empty ( $abDetail )) {
  4168. $item = array (
  4169. 'dataID' => $rid,
  4170. 'expensesType' => 2,
  4171. 'accountType' => $accountType,
  4172. 'accountPriceShow'=>$rinfo ['sum'],
  4173. 'accountPrice' => - $rinfo ['sum'],
  4174. 'accountBank' => $accountBank,
  4175. 'category' => $rinfo ['category'] [0] ['title'],
  4176. 'cid' => $rinfo ['category'] [0] ['cid'],
  4177. 'name' => $rinfo ['staffDetail'] ['username'],
  4178. 'sid' => $rinfo ['staffDetail'] ['sid'],
  4179. 'inputDate' => date ( "Y-m-d H:i:s" )
  4180. );
  4181. $wasteBook->setAccountBookStatistics ( $item );
  4182. }
  4183. }
  4184. $ridKey = $XDeode->encode ( $rid );
  4185. return "/hisImplement";
  4186. // return "/implement/" . $ridKey . ".html";
  4187. }
  4188. function receiptburEdi() {
  4189. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4190. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  4191. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4192. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4193. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4194. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4195. if (empty ( $status ))
  4196. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  4197. $vidList = array ();
  4198. $button = 0;
  4199. Doo::loadModel ( 'verify' );
  4200. Doo::loadModel ( 'receipt' );
  4201. Doo::loadModel ( 'staff' );
  4202. $staff = new staff ();
  4203. $receipt = new receipt ();
  4204. $verify = new verify ();
  4205. Doo::loadModel ( 'L_category' );
  4206. $Lcategory = new L_category ();
  4207. Doo::loadModel ( 'enclosur' );
  4208. $enclosur = new enclosur ();
  4209. Doo::loadModel ( 'loanReceipt' );
  4210. $loanReceipt = new loanReceipt ();
  4211. // user verify ID
  4212. $verifyDetail = $verify->find ( array (
  4213. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  4214. 'asArray' => true
  4215. ) );
  4216. foreach ( $verifyDetail as $key => $value ) {
  4217. array_push ( $vidList, $value ['vid'] );
  4218. }
  4219. $vid = implode ( ",", $vidList );
  4220. if (empty ( $verifyDetail ))
  4221. $vid = 0;
  4222. $categoryList = $Lcategory->find ( array (
  4223. 'asArray' => true
  4224. ) );
  4225. $staffList = $staff->find ( array (
  4226. 'where' => 'cid=' . $cid,
  4227. 'asArray' => true
  4228. ) );
  4229. $ap = "";
  4230. if ($status == 4) {
  4231. $ap = 4;
  4232. $status = 2;
  4233. }
  4234. // get Receipt By verifyID status 2
  4235. $receiptList = $receipt->find ( array (
  4236. 'where' => 'rid =' . $rid . ' and status=2',
  4237. 'desc' => 'rid',
  4238. 'asArray' => true
  4239. ) );
  4240. if (empty ( $receiptList )) {
  4241. die ( 'illegal request' );
  4242. }
  4243. $loanList = $loanReceipt->find ( array (
  4244. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4245. 'desc' => 'rid',
  4246. 'asArray' => true
  4247. ) );
  4248. $data ['explanation'] = '';
  4249. if (! empty ( $loanList ))
  4250. $data ['explanation'] = $loanList [0] ['explanation'];
  4251. $Locate = 0;
  4252. $roleId = 0;
  4253. $button = 0;
  4254. foreach ( $loanList as $key => $value ) {
  4255. $loanList [$key] ['Locate'] = $Locate;
  4256. $Locate ++;
  4257. $loanList [$key] ['reviseDetail'] = array ();
  4258. if (! empty ( $value ['reviseDetail'] ))
  4259. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4260. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4261. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4262. $categoryDetil = $Lcategory->getOne ( array (
  4263. 'where' => 'cid=' . $value ['cid'],
  4264. 'asArray' => true
  4265. ) );
  4266. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4267. // 检测编辑状态
  4268. $verifyList = $verify->getOne ( array (
  4269. 'where' => 'vid=' . $value ['verify'],
  4270. 'asArray' => true
  4271. ) );
  4272. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4273. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4274. Doo::loadModel ( 'role' );
  4275. $role = new role ();
  4276. $flag = true;
  4277. $roleKey = 0;
  4278. $endStaffArray = array ();
  4279. $roleArrayCopy = array ();
  4280. foreach ( $verifyList as $k => $v ) {
  4281. // init verifyStaff
  4282. if ($v [1] == 'ROLE') {
  4283. if (! empty ( $verifyStaff )) {
  4284. $endStaffArray = end ( $verifyStaff );
  4285. }
  4286. $roleVerify = json_decode ( $v [3], true );
  4287. $roleKey = $k;
  4288. $roleArray = array ();
  4289. $rolename = $role->getOne ( array (
  4290. 'where' => 'rid=' . $v [0],
  4291. 'asArray' => true
  4292. ) );
  4293. foreach ( $roleVerify as $o => $p ) {
  4294. $staffID = explode ( '_', $p );
  4295. $staffInfo = $staff->getOne ( array (
  4296. 'where' => 'sid=' . $staffID [0],
  4297. 'asArray' => true
  4298. ) );
  4299. // print_r($staffID);
  4300. $exp = array (
  4301. 0 => $staffInfo ['sid'],
  4302. 1 => $staffID [1],
  4303. 2 => $staffInfo ['avatar'],
  4304. 'date' => '',
  4305. 'date' => '',
  4306. 'opinion' => '',
  4307. 'status' => '',
  4308. 'rolename' => $rolename ['name']
  4309. );
  4310. array_push ( $roleArray, $exp );
  4311. }
  4312. $roleArrayCopy [$v [0]] = $roleArray;
  4313. // $verifyList[$k]['roleArray']=$roleArray;
  4314. }
  4315. $verifyList [$k] ['date'] = "";
  4316. $verifyList [$k] ['opinion'] = "";
  4317. $verifyList [$k] ['status'] = "";
  4318. if (empty ( $verifyStaff )) {
  4319. $verifyList [$k] ['date'] = "";
  4320. $verifyList [$k] ['opinion'] = "";
  4321. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4322. $verifyList [$k] ['status'] = 4;
  4323. $flag = false;
  4324. }
  4325. } else {
  4326. foreach ( $verifyStaff as $m => $u ) {
  4327. if ($v [0] == $m) {
  4328. $verifyList [$k] ['date'] = $u ['date'];
  4329. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4330. $verifyList [$k] ['status'] = $u ['status'];
  4331. $flag = false;
  4332. break;
  4333. }
  4334. }
  4335. $endStaffArray = end ( $verifyStaff );
  4336. if (isset ( $endStaffArray ['ROLE'] )) {
  4337. } else {
  4338. }
  4339. }
  4340. }
  4341. $rolename ['name'] = '';
  4342. if (! empty ( $roleId )) {
  4343. Doo::loadModel ( 'role' );
  4344. $role = new role ();
  4345. $rolename = $role->getOne ( array (
  4346. 'where' => 'rid=' . $roleId,
  4347. 'asArray' => true
  4348. ) );
  4349. }
  4350. if (! empty ( $verifyStaff ))
  4351. $endStaffArray = end ( $verifyStaff );
  4352. $KOP = false;
  4353. foreach ( $roleArrayCopy as $P => $A ) {
  4354. foreach ( $A as $MKI => $AVL ) {
  4355. if (! empty ( $verifyStaff )) {
  4356. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4357. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4358. $button = 4;
  4359. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4360. }
  4361. foreach ( $verifyStaff as $m => $u ) {
  4362. $AVLFK = $AVL [0] . '_R';
  4363. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4364. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4365. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4366. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4367. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4368. break;
  4369. }
  4370. }
  4371. } else {
  4372. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4373. $button = 4;
  4374. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4375. }
  4376. }
  4377. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4378. $KOP = true;
  4379. }
  4380. }
  4381. foreach ( $roleArrayCopy as $k => $v ) {
  4382. foreach ( $verifyList as $m => $n ) {
  4383. if ($n [0] == $k) {
  4384. array_splice ( $verifyList, $m, 1, $v );
  4385. }
  4386. }
  4387. }
  4388. $loanList [$key] ['verifyList'] = $verifyList;
  4389. }
  4390. $htmlLoan = '';
  4391. if (isset ( $loanList [0] )) {
  4392. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  4393. if ($value ['status'] == 1)
  4394. $htmlLoan .= '<li class="done" >';
  4395. elseif ($value ['status'] == 3)
  4396. $htmlLoan .= '<li class="undone" >';
  4397. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  4398. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  4399. if (isset ( $value ['rolename'] ))
  4400. $htmlLoan .= $value ['rolename'];
  4401. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  4402. }
  4403. $data ['loanDate'] = $loanList [0] ['date'];
  4404. } else {
  4405. $data ['loanReceiptDate'] = ''; // $loanList [0] ['date'];
  4406. }
  4407. $data ['htmlLoan'] = $htmlLoan;
  4408. // $data ['LoanReceipt']=$loanList[0];
  4409. // print_r($loanList);
  4410. $Locate = 0;
  4411. $roleId = 0;
  4412. $button = 0;
  4413. if ($ap == 4)
  4414. $status = 4;
  4415. Doo::loadClass ( 'XDeode' );
  4416. $XDeode = new XDeode ( 5 );
  4417. foreach ( $receiptList as $key => $value ) {
  4418. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4419. $receiptList [$key] ['Locate'] = $Locate;
  4420. $Locate ++;
  4421. $receiptList [$key] ['reviseDetail'] = array ();
  4422. // 调整金额 代码调整
  4423. if (! empty ( $value ['reviseDetail'] )) {
  4424. $reviseDetail = json_decode ( $value ['reviseDetail'], true );
  4425. foreach ( $reviseDetail as $ry => $re ) {
  4426. $reviseDetail [$ry] ['sidKey'] = $XDeode->encode ( $re ['sid'] );
  4427. $reviseDetail [$ry] ['reviseKey'] = $XDeode->encode ( $ry );
  4428. }
  4429. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  4430. // print_r($reviseDetail);
  4431. }
  4432. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4433. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4434. $categoryDetil = $Lcategory->getOne ( array (
  4435. 'where' => 'cid=' . $value ['cid'],
  4436. 'asArray' => true
  4437. ) );
  4438. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4439. // 检测编辑状态
  4440. $verifyList = $verify->getOne ( array (
  4441. 'where' => 'vid=' . $value ['verify'],
  4442. 'asArray' => true
  4443. ) );
  4444. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4445. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4446. Doo::loadModel ( 'role' );
  4447. $role = new role ();
  4448. // print_r($verifyList);
  4449. $flag = true;
  4450. $roleKey = 0;
  4451. $endStaffArray = array ();
  4452. $roleArrayCopy = array ();
  4453. foreach ( $verifyList as $k => $v ) {
  4454. // init verifyStaff
  4455. if ($v [1] == 'ROLE') {
  4456. if (! empty ( $verifyStaff )) {
  4457. $endStaffArray = end ( $verifyStaff );
  4458. if ($v [0] == $endStaffArray ['nextStaff']) {
  4459. $roleId = $v [0];
  4460. }
  4461. }
  4462. $roleVerify = json_decode ( $v [3], true );
  4463. $roleKey = $k;
  4464. $roleArray = array ();
  4465. $rolename = $role->getOne ( array (
  4466. 'where' => 'rid=' . $v [0],
  4467. 'asArray' => true
  4468. ) );
  4469. foreach ( $roleVerify as $o => $p ) {
  4470. $staffID = explode ( '_', $p );
  4471. $staffInfo = $staff->getOne ( array (
  4472. 'where' => 'sid=' . $staffID [0],
  4473. 'asArray' => true
  4474. ) );
  4475. // print_r($staffID);
  4476. $exp = array (
  4477. 0 => $staffInfo ['sid'],
  4478. 1 => $staffID [1],
  4479. 2 => $staffInfo ['avatar'],
  4480. 'date' => '',
  4481. 'date' => '',
  4482. 'opinion' => '',
  4483. 'status' => '',
  4484. 'rolename' => $rolename ['name']
  4485. );
  4486. array_push ( $roleArray, $exp );
  4487. }
  4488. $roleArrayCopy [$v [0]] = $roleArray;
  4489. // $verifyList[$k]['roleArray']=$roleArray;
  4490. }
  4491. // print_r($roleArray);
  4492. $verifyList [$k] ['date'] = "";
  4493. $verifyList [$k] ['opinion'] = "";
  4494. $verifyList [$k] ['status'] = "";
  4495. if (empty ( $verifyStaff )) {
  4496. $verifyList [$k] ['date'] = "";
  4497. $verifyList [$k] ['opinion'] = "";
  4498. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4499. $verifyList [$k] ['status'] = 4;
  4500. $button = 4;
  4501. $flag = false;
  4502. }
  4503. } else {
  4504. foreach ( $verifyStaff as $m => $u ) {
  4505. if ($v [0] == $m) {
  4506. $verifyList [$k] ['date'] = $u ['date'];
  4507. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4508. $verifyList [$k] ['status'] = $u ['status'];
  4509. $flag = false;
  4510. break;
  4511. }
  4512. }
  4513. $endStaffArray = end ( $verifyStaff );
  4514. if (isset ( $endStaffArray ['ROLE'] )) {
  4515. } else {
  4516. $endKey = key ( $verifyStaff );
  4517. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4518. $button = 4;
  4519. $verifyList [$k] ['status'] = 4;
  4520. }
  4521. }
  4522. }
  4523. }
  4524. $rolename ['name'] = '';
  4525. if (! empty ( $roleId )) {
  4526. Doo::loadModel ( 'role' );
  4527. $role = new role ();
  4528. $rolename = $role->getOne ( array (
  4529. 'where' => 'rid=' . $roleId,
  4530. 'asArray' => true
  4531. ) );
  4532. }
  4533. if (! empty ( $verifyStaff ))
  4534. $endStaffArray = end ( $verifyStaff );
  4535. $KOP = false;
  4536. foreach ( $roleArrayCopy as $P => $A ) {
  4537. foreach ( $A as $MKI => $AVL ) {
  4538. if (! empty ( $verifyStaff )) {
  4539. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4540. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4541. $button = 4;
  4542. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4543. }
  4544. foreach ( $verifyStaff as $m => $u ) {
  4545. $AVLFK = $AVL [0] . '_R';
  4546. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4547. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4548. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4549. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4550. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4551. break;
  4552. }
  4553. }
  4554. } else {
  4555. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4556. $button = 4;
  4557. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4558. }
  4559. }
  4560. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4561. $KOP = true;
  4562. }
  4563. }
  4564. foreach ( $roleArrayCopy as $k => $v ) {
  4565. foreach ( $verifyList as $m => $n ) {
  4566. if ($n [0] == $k) {
  4567. array_splice ( $verifyList, $m, 1, $v );
  4568. }
  4569. }
  4570. }
  4571. // print_r($verifyList);
  4572. $receiptList [$key] ['verifyList'] = $verifyList;
  4573. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4574. 'where' => 'sid=' . $value ['staff'],
  4575. 'asArray' => true
  4576. ) );
  4577. $receiptList [$key] ['button'] = $button;
  4578. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4579. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4580. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  4581. $receiptList [$key] ['relust'] = $relust;
  4582. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4583. }
  4584. // print_r($receiptList);die;
  4585. // $data['verifyDetail']=$verifyDetail;
  4586. $mothHtml = "";
  4587. for($i = 1; $i <= 12; $i ++) {
  4588. if ($month == $i)
  4589. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4590. else
  4591. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4592. }
  4593. // 获取审批日志
  4594. Doo::loadModel ( 'receiptLog' );
  4595. $receiptLog = new receiptLog ();
  4596. $rlList = array ();
  4597. $rlInfo = $receiptLog->getOne ( array (
  4598. 'where' => 'rid=' . $rid . ' and status=4',
  4599. 'asArray' => true
  4600. ) );
  4601. $tijdate = $receiptLog->getOne ( array (
  4602. 'where' => 'rid=' . $rid . ' and status=2',
  4603. 'asc' => 'rlid',
  4604. 'asArray' => true
  4605. ) );
  4606. if (! empty ( $rlInfo )) {
  4607. $rlList = $receiptLog->find ( array (
  4608. 'where' => 'rid=' . $rid,
  4609. 'asc' => 'rlid',
  4610. 'asArray' => true
  4611. ) );
  4612. }
  4613. // echo $rid;
  4614. // print_r($receiptList);
  4615. $receiptList [0] ['rlList'] = $rlList;
  4616. // print_r($receiptList);
  4617. $enclosurList = $enclosur->find ( array (
  4618. 'where' => 'rid=' . $rid,
  4619. 'asArray' => true
  4620. ) );
  4621. $enclosurHtml = '';
  4622. foreach ( $enclosurList as $value ) {
  4623. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4624. }
  4625. $data ['enclosurHtml'] = $enclosurHtml;
  4626. $data ['rolename'] = $rolename ['name'];
  4627. $data ['mothHtml'] = $mothHtml;
  4628. // print_r($receiptList);
  4629. $data ['rid'] = $rid;
  4630. $data ['tijdate'] = $tijdate ['date'];
  4631. $data ['receiptList'] = $receiptList;
  4632. $data ['receiptApprovalCount'] = count ( $receiptList );
  4633. $data ['status'] = $status;
  4634. $data ['year'] = $year;
  4635. $data ['categoryList'] = $categoryList;
  4636. $data ['staffList'] = $staffList;
  4637. $data ['cid'] = $cid;
  4638. $data ['sid'] = $sid;
  4639. $data ['ap'] = $ap;
  4640. $data ['memu'] = "receipt";
  4641. $data ['staff'] = $this->staff;
  4642. $data ['receiptMemu'] = 'approvalExpenses';
  4643. $data ['verifyId'] = $this->verifyId;
  4644. $data ['executeId'] = $this->executeId;
  4645. $this->render ( "/admin/receiptburEdi", $data );
  4646. }
  4647. function hisImplement() {
  4648. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4649. if (empty ( $item ))
  4650. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "expenses";
  4651. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  4652. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4653. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  4654. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  4655. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  4656. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'pendImplement';
  4657. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  4658. Doo::loadClass ( 'XDeode' );
  4659. $XDeode = new XDeode ( 5 );
  4660. Doo::loadModel ( 'receipt' );
  4661. $receipt = new receipt ();
  4662. Doo::loadModel ( 'L_category' );
  4663. $Lcategory = new L_category ();
  4664. Doo::loadModel ( 'verify' );
  4665. Doo::loadModel ( 'statistics' );
  4666. $statistics = new statistics ();
  4667. $verify = new verify ();
  4668. Doo::loadModel ( 'staff' );
  4669. $staff = new staff ();
  4670. Doo::loadClass ( 'XDeode' );
  4671. $XDeode = new XDeode ( 5 );
  4672. $cid = $XDeode->decode ( $cidKey );
  4673. $condition = "";
  4674. if ($item == "expenses")
  4675. $condition = " and Rtype=1 ";
  4676. elseif ($item == "receipts")
  4677. $condition = " and Rtype=0 ";
  4678. elseif ($item == "remits")
  4679. $condition = " and Rtype=2 ";
  4680. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  4681. $sopString = $cidString = "";
  4682. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  4683. if (empty ( $rdate ))
  4684. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  4685. else
  4686. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  4687. if ($status == 'pendImplement') {
  4688. $condition .= ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  4689. } elseif ($status == 'alerpts') {
  4690. $statusCon = '(status=8 or status=9 )';
  4691. if (empty ( $rdate ))
  4692. $dateCondition .= " and Year(date) =" . $year;
  4693. else
  4694. $dateCondition .= " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  4695. }
  4696. if ($sop != 'SOP')
  4697. $sopString = " and staff=" . $sop;
  4698. if ($cidKey != 'ALL')
  4699. $cidString = " and cid=" . $cid;
  4700. $receiptList = $receipt->find ( array (
  4701. 'where' => $statusCon . $condition . $dateCondition . $sopString . $cidString,
  4702. 'desc' => 'rid',
  4703. 'asArray' => true
  4704. ) );
  4705. // 员工筛选
  4706. $receiptList2 = $receipt->find ( array (
  4707. 'where' => $statusCon . $condition . $dateCondition,
  4708. 'desc' => 'rid',
  4709. 'asArray' => true
  4710. ) );
  4711. $sopStaff = array ();
  4712. foreach ( $receiptList2 as $key => $value ) {
  4713. $staffDetail = $staff->getOne ( array (
  4714. 'select' => 'username',
  4715. 'where' => 'sid=' . $value ['staff'],
  4716. 'asArray' => true
  4717. ) );
  4718. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  4719. }
  4720. // 办事处筛选
  4721. $categoryScreen = array ();
  4722. $categorList = $Lcategory->getCategory ();
  4723. foreach ( $receiptList2 as $key => $value ) {
  4724. foreach ( $categorList as $k => $v ) {
  4725. if ($value ['cid'] == $v ['cid']) {
  4726. $categoryScreen [$v ['cidKey']] = $v ['title'];
  4727. break;
  4728. }
  4729. }
  4730. }
  4731. $categoryScreenHtml = "";
  4732. foreach ( $categoryScreen as $key => $value ) {
  4733. if ($cidKey == $key)
  4734. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4735. else
  4736. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4737. }
  4738. $data ['categoryScreenHtml'] = $categoryScreenHtml;
  4739. $data ['cidKey'] = $cidKey;
  4740. $Locate = 0;
  4741. $roleId = 0;
  4742. $button = 0;
  4743. $staffBatchNumber = 100001;
  4744. $remittanceList = array ();
  4745. foreach ( $receiptList as $key => $value ) {
  4746. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4747. $receiptList [$key] ['Texe'] = 'false';
  4748. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  4749. $receiptList [$key] ['Texe'] = 'true';
  4750. }
  4751. $receiptList [$key] ['TRexe'] = 'true';
  4752. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  4753. $receiptList [$key] ['TRexe'] = 'false';
  4754. }
  4755. $receiptList [$key] ['Locate'] = $Locate;
  4756. $Locate ++;
  4757. $receiptList [$key] ['reviseDetail'] = array ();
  4758. if (! empty ( $value ['reviseDetail'] ))
  4759. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4760. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4761. $categoryDetil = $Lcategory->getOne ( array (
  4762. 'where' => 'cid=' . $value ['cid'],
  4763. 'asArray' => true
  4764. ) );
  4765. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4766. // 检测编辑状态
  4767. $verifyList = $verify->getOne ( array (
  4768. 'where' => 'vid=' . $value ['verify'],
  4769. 'asArray' => true
  4770. ) );
  4771. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4772. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4773. Doo::loadModel ( 'role' );
  4774. $role = new role ();
  4775. $flag = true;
  4776. $roleKey = 0;
  4777. $endStaffArray = array ();
  4778. $roleArrayCopy = array ();
  4779. foreach ( $verifyList as $k => $v ) {
  4780. // init verifyStaff
  4781. if ($v [1] == 'ROLE') {
  4782. if (! empty ( $verifyStaff )) {
  4783. $endStaffArray = end ( $verifyStaff );
  4784. }
  4785. $roleVerify = json_decode ( $v [3], true );
  4786. $roleKey = $k;
  4787. $roleArray = array ();
  4788. $rolename = $role->getOne ( array (
  4789. 'where' => 'rid=' . $v [0],
  4790. 'asArray' => true
  4791. ) );
  4792. foreach ( $roleVerify as $o => $p ) {
  4793. $staffID = explode ( '_', $p );
  4794. $staffInfo = $staff->getOne ( array (
  4795. 'where' => 'sid=' . $staffID [0],
  4796. 'asArray' => true
  4797. ) );
  4798. $exp = array (
  4799. 0 => $staffInfo ['sid'],
  4800. 1 => $staffID [1],
  4801. 2 => $staffInfo ['avatar'],
  4802. 'date' => '',
  4803. 'date' => '',
  4804. 'opinion' => '',
  4805. 'status' => '',
  4806. 'rolename' => $rolename ['name']
  4807. );
  4808. array_push ( $roleArray, $exp );
  4809. }
  4810. $roleArrayCopy [$v [0]] = $roleArray;
  4811. }
  4812. $verifyList [$k] ['date'] = "";
  4813. $verifyList [$k] ['opinion'] = "";
  4814. $verifyList [$k] ['status'] = "";
  4815. if (empty ( $verifyStaff )) {
  4816. $verifyList [$k] ['date'] = "";
  4817. $verifyList [$k] ['opinion'] = "";
  4818. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4819. $verifyList [$k] ['status'] = 4;
  4820. $flag = false;
  4821. }
  4822. } else {
  4823. foreach ( $verifyStaff as $m => $u ) {
  4824. if ($v [0] == $m) {
  4825. $verifyList [$k] ['date'] = $u ['date'];
  4826. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4827. $verifyList [$k] ['status'] = $u ['status'];
  4828. $flag = false;
  4829. break;
  4830. }
  4831. }
  4832. $endStaffArray = end ( $verifyStaff );
  4833. }
  4834. }
  4835. $rolename ['name'] = '';
  4836. if (! empty ( $roleId )) {
  4837. Doo::loadModel ( 'role' );
  4838. $role = new role ();
  4839. $rolename = $role->getOne ( array (
  4840. 'where' => 'rid=' . $roleId,
  4841. 'asArray' => true
  4842. ) );
  4843. }
  4844. if (! empty ( $verifyStaff ))
  4845. $endStaffArray = end ( $verifyStaff );
  4846. $KOP = false;
  4847. foreach ( $roleArrayCopy as $P => $A ) {
  4848. foreach ( $A as $MKI => $AVL ) {
  4849. if (! empty ( $verifyStaff )) {
  4850. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4851. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4852. $button = 4;
  4853. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4854. }
  4855. foreach ( $verifyStaff as $m => $u ) {
  4856. $AVLFK = $AVL [0] . '_R';
  4857. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4858. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4859. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4860. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4861. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4862. break;
  4863. }
  4864. }
  4865. } else {
  4866. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4867. $button = 4;
  4868. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4869. }
  4870. }
  4871. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4872. $KOP = true;
  4873. }
  4874. }
  4875. foreach ( $roleArrayCopy as $k => $v ) {
  4876. foreach ( $verifyList as $m => $n ) {
  4877. if ($n [0] == $k) {
  4878. array_splice ( $verifyList, $m, 1, $v );
  4879. }
  4880. }
  4881. }
  4882. $receiptList [$key] ['verifyList'] = $verifyList;
  4883. $staffDetail = $staff->getOne ( array (
  4884. 'where' => 'sid=' . $value ['staff'],
  4885. 'asArray' => true
  4886. ) );
  4887. $receiptList [$key] ['staffDetail'] = $staffDetail;
  4888. $receiptList [$key] ['button'] = $button;
  4889. // 设置导出汇款execl
  4890. if (! empty ( $value ['remittanceName'] ) && ! empty ( $value ['bankName'] ) && ! empty ( $value ['bankNumber'] )) {
  4891. $remittanceDetail = array (
  4892. $staffBatchNumber,
  4893. $value ['remittanceName'],
  4894. $value ['bankNumber'],
  4895. $value ['bankName'],
  4896. $value ['remittanceBankType'],
  4897. $value ['coupletNumber'],
  4898. $value ['sum']
  4899. );
  4900. array_push ( $remittanceList, $remittanceDetail );
  4901. $staffBatchNumber ++;
  4902. }
  4903. }
  4904. $data ['remittanceList'] = json_encode ( $remittanceList );
  4905. // print_r($receiptList);
  4906. $mothHtml = "";
  4907. for($i = 1; $i <= 12; $i ++) {
  4908. if ($moth == $i)
  4909. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4910. else
  4911. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4912. }
  4913. $dayHtml = "";
  4914. if ($day != "DAY" || $moth != "MONTH") {
  4915. for($i = 1; $i <= 31; $i ++) {
  4916. if ($day == $i)
  4917. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  4918. else
  4919. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  4920. }
  4921. }
  4922. $sopHtml = "";
  4923. foreach ( $sopStaff as $key => $value ) {
  4924. if ($sop == $key)
  4925. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4926. else
  4927. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4928. }
  4929. $data ['status'] = $status;
  4930. $data ['rdate'] = $rdate;
  4931. $data ['sopHtml'] = $sopHtml;
  4932. $data ['dayHtml'] = $dayHtml;
  4933. $data ['mothHtml'] = $mothHtml;
  4934. $data ['receiptList'] = $receiptList;
  4935. $data ['memu'] = "receipt";
  4936. $data ['staff'] = $this->staff;
  4937. $data ['receiptMemu'] = 'implement';
  4938. $data ['verifyId'] = $this->verifyId;
  4939. $data ['executeId'] = $this->executeId;
  4940. $data ['item'] = $item;
  4941. $data ['year'] = $year;
  4942. $data ['moth'] = $moth;
  4943. $data ['day'] = $day;
  4944. $data ['sop'] = $sop;
  4945. $this->render ( "/admin/hisImplement", $data );
  4946. }
  4947. /**
  4948. * 导出汇款信息的exelc
  4949. */
  4950. function exportRemittance() {
  4951. $remittanceInfo = $_POST ['remittanceInfo']; // $this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  4952. if (empty ( $remittanceInfo ))
  4953. die ( 'illegal request' );
  4954. $title = array (
  4955. '员工编号',
  4956. '姓名',
  4957. '员工账号',
  4958. '员工账户开户行',
  4959. '转账类型',
  4960. '联行号',
  4961. '金额'
  4962. );
  4963. $data = json_decode ( $remittanceInfo, true );
  4964. if (empty ( $data ))
  4965. die ( 'illegal request' );
  4966. Doo::loadClass ( 'receipt.func' );
  4967. exportExcel ( $title, $data, '批量日常报销-公司账号', './', true );
  4968. header ( 'Content-Type:text/html;charset=utf-8' );
  4969. die ( '导出' . count ( $data ) . '条数据,<a href="/hisImplement">返回</a>' );
  4970. }
  4971. function ajaxExamine() {
  4972. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4973. Doo::loadModel ( 'receipt' );
  4974. $receipt = new receipt ();
  4975. if (! empty ( $rid )) {
  4976. $rLRes = $receipt->find ( array (
  4977. '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,
  4978. 'asArray' => true
  4979. ) );
  4980. echo json_encode ( array (
  4981. 'status' => 1,
  4982. 'receipt' => $rLRes [0]
  4983. ) );
  4984. die ();
  4985. }
  4986. echo json_encode ( array (
  4987. 'status' => 0,
  4988. 'receipt' => array ()
  4989. ) );
  4990. die ();
  4991. }
  4992. /*
  4993. * 废弃
  4994. */
  4995. function myReceipt() {
  4996. // all approval past withdraw
  4997. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4998. if (empty ( $item ))
  4999. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  5000. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  5001. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  5002. Doo::loadModel ( 'receipt' );
  5003. $receipt = new receipt ();
  5004. // pre-loaded
  5005. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  5006. // have cache
  5007. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  5008. if (! empty ( $moth )) // yearPage
  5009. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  5010. $this->showCache ( $path );
  5011. }
  5012. Doo::loadModel ( 'L_category' );
  5013. $Lcategory = new L_category ();
  5014. Doo::loadModel ( 'verify' );
  5015. Doo::loadModel ( 'statistics' );
  5016. $statistics = new statistics ();
  5017. $verify = new verify ();
  5018. Doo::loadModel ( 'staff' );
  5019. $staff = new staff ();
  5020. $condition = " and status!=0 ";
  5021. if ($item == "approval")
  5022. $condition = " and status=2 ";
  5023. elseif ($item == "withdraw")
  5024. $condition = " and status=3 ";
  5025. elseif ($item == "past")
  5026. $condition = " and status=1 ";
  5027. elseif ($item == "whdw")
  5028. $condition = " and status=4 ";
  5029. $dateCondition = " and Year(date) =" . $year;
  5030. if (! empty ( $moth )) {
  5031. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  5032. $stList = $statistics->getOne ( array (
  5033. 'select' => 'rePrice ,agPrice',
  5034. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5035. 'asArray' => true
  5036. ) );
  5037. } else
  5038. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  5039. if (empty ( $stList ))
  5040. $stList = array (
  5041. 'rePrice' => 0,
  5042. 'agPrice' => 0
  5043. );
  5044. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  5045. $data ['stList'] = array (
  5046. 'rePrice' => $stList ['rePrice'],
  5047. 'agPrice' => $stList ['agPrice'],
  5048. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  5049. );
  5050. $receiptList = $receipt->find ( array (
  5051. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  5052. 'desc' => 'rid',
  5053. 'asArray' => true
  5054. ) );
  5055. $Locate = 0;
  5056. $roleId = 0;
  5057. $button = 0;
  5058. foreach ( $receiptList as $key => $value ) {
  5059. $receiptList [$key] ['Locate'] = $Locate;
  5060. $Locate ++;
  5061. $receiptList [$key] ['reviseDetail'] = array ();
  5062. if (! empty ( $value ['reviseDetail'] ))
  5063. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5064. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5065. $categoryDetil = $Lcategory->getOne ( array (
  5066. 'where' => 'cid=' . $value ['cid'],
  5067. 'asArray' => true
  5068. ) );
  5069. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5070. // 检测编辑状态
  5071. $verifyList = $verify->getOne ( array (
  5072. 'where' => 'vid=' . $value ['verify'],
  5073. 'asArray' => true
  5074. ) );
  5075. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5076. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5077. Doo::loadModel ( 'role' );
  5078. $role = new role ();
  5079. $flag = true;
  5080. $roleKey = 0;
  5081. $endStaffArray = array ();
  5082. $roleArrayCopy = array ();
  5083. foreach ( $verifyList as $k => $v ) {
  5084. // init verifyStaff
  5085. if ($v [1] == 'ROLE') {
  5086. if (! empty ( $verifyStaff )) {
  5087. $endStaffArray = end ( $verifyStaff );
  5088. // if ($v[0]==$endStaffArray['nextStaff']){
  5089. // $roleId=$v[0];
  5090. // }
  5091. }
  5092. $roleVerify = json_decode ( $v [3], true );
  5093. $roleKey = $k;
  5094. $roleArray = array ();
  5095. $rolename = $role->getOne ( array (
  5096. 'where' => 'rid=' . $v [0],
  5097. 'asArray' => true
  5098. ) );
  5099. foreach ( $roleVerify as $o => $p ) {
  5100. $staffID = explode ( '_', $p );
  5101. $staffInfo = $staff->getOne ( array (
  5102. 'where' => 'sid=' . $staffID [0],
  5103. 'asArray' => true
  5104. ) );
  5105. // print_r($staffID);
  5106. $exp = array (
  5107. 0 => $staffInfo ['sid'],
  5108. 1 => $staffID [1],
  5109. 2 => $staffInfo ['avatar'],
  5110. 'date' => '',
  5111. 'date' => '',
  5112. 'opinion' => '',
  5113. 'status' => '',
  5114. 'rolename' => $rolename ['name']
  5115. );
  5116. array_push ( $roleArray, $exp );
  5117. }
  5118. $roleArrayCopy [$v [0]] = $roleArray;
  5119. // $verifyList[$k]['roleArray']=$roleArray;
  5120. }
  5121. $verifyList [$k] ['date'] = "";
  5122. $verifyList [$k] ['opinion'] = "";
  5123. $verifyList [$k] ['status'] = "";
  5124. if (empty ( $verifyStaff )) {
  5125. $verifyList [$k] ['date'] = "";
  5126. $verifyList [$k] ['opinion'] = "";
  5127. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5128. $verifyList [$k] ['status'] = 4;
  5129. $flag = false;
  5130. }
  5131. } else {
  5132. foreach ( $verifyStaff as $m => $u ) {
  5133. if ($v [0] == $m) {
  5134. $verifyList [$k] ['date'] = $u ['date'];
  5135. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5136. $verifyList [$k] ['status'] = $u ['status'];
  5137. $flag = false;
  5138. break;
  5139. }
  5140. }
  5141. $endStaffArray = end ( $verifyStaff );
  5142. if (isset ( $endStaffArray ['ROLE'] )) {
  5143. } else {
  5144. // $endKey=key($verifyStaff);
  5145. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5146. // $button=4;
  5147. // $verifyList[$k]['status']=4;
  5148. // }
  5149. }
  5150. }
  5151. }
  5152. $rolename ['name'] = '';
  5153. if (! empty ( $roleId )) {
  5154. Doo::loadModel ( 'role' );
  5155. $role = new role ();
  5156. $rolename = $role->getOne ( array (
  5157. 'where' => 'rid=' . $roleId,
  5158. 'asArray' => true
  5159. ) );
  5160. }
  5161. if (! empty ( $verifyStaff ))
  5162. $endStaffArray = end ( $verifyStaff );
  5163. $KOP = false;
  5164. foreach ( $roleArrayCopy as $P => $A ) {
  5165. foreach ( $A as $MKI => $AVL ) {
  5166. if (! empty ( $verifyStaff )) {
  5167. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5168. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5169. $button = 4;
  5170. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5171. }
  5172. foreach ( $verifyStaff as $m => $u ) {
  5173. $AVLFK = $AVL [0] . '_R';
  5174. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5175. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5176. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5177. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5178. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5179. break;
  5180. }
  5181. }
  5182. } else {
  5183. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5184. $button = 4;
  5185. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5186. }
  5187. }
  5188. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5189. $KOP = true;
  5190. }
  5191. }
  5192. foreach ( $roleArrayCopy as $k => $v ) {
  5193. foreach ( $verifyList as $m => $n ) {
  5194. if ($n [0] == $k) {
  5195. array_splice ( $verifyList, $m, 1, $v );
  5196. }
  5197. }
  5198. }
  5199. $receiptList [$key] ['verifyList'] = $verifyList;
  5200. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5201. 'where' => 'sid=' . $value ['staff'],
  5202. 'asArray' => true
  5203. ) );
  5204. $receiptList [$key] ['button'] = $button;
  5205. }
  5206. // print_r($receiptList);die;
  5207. $mothHtml = "";
  5208. for($i = 1; $i <= 12; $i ++) {
  5209. if ($moth == $i)
  5210. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5211. else
  5212. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5213. }
  5214. $data ['mothHtml'] = $mothHtml;
  5215. $data ['receiptList'] = $receiptList;
  5216. $data ['memu'] = "receipt";
  5217. $data ['staff'] = $this->staff;
  5218. $data ['receiptMemu'] = 'receipt';
  5219. $data ['verifyId'] = $this->verifyId;
  5220. $data ['executeId'] = $this->executeId;
  5221. $data ['item'] = $item;
  5222. $data ['year'] = $year;
  5223. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  5224. // sufficient condition to generate cache
  5225. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  5226. $receiptList = $receipt->find ( array (
  5227. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  5228. 'asArray' => true
  5229. ) );
  5230. if (empty ( $receiptList )) { // generated files
  5231. ob_start ();
  5232. $this->render ( "/admin/saea_myList", $data );
  5233. $this->cacheFile ( $path );
  5234. die ();
  5235. // $content = ob_get_contents();
  5236. // $fp = fopen($path, "w");
  5237. // fwrite($fp, $content);
  5238. // fclose($fp);
  5239. }
  5240. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  5241. $receiptList = $receipt->find ( array (
  5242. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  5243. 'asArray' => true
  5244. ) );
  5245. if (empty ( $receiptList )) { // generated files
  5246. ob_start ();
  5247. $this->render ( "/admin/saea_myList", $data );
  5248. $this->cacheFile ( $path );
  5249. die ();
  5250. }
  5251. }
  5252. }
  5253. $this->render ( "/admin/saea_myList", $data );
  5254. }
  5255. function saeaCreate() {
  5256. Doo::loadModel ( 'accountItem' );
  5257. Doo::loadModel ( 'verify' );
  5258. Doo::loadModel ( 'receipt' );
  5259. Doo::loadModel ( 'L_category' );
  5260. $lCategory = new L_category ();
  5261. $receipt = new receipt ();
  5262. $verify = new verify ();
  5263. $accountItem = new accountItem ();
  5264. Doo::loadModel ( "role" );
  5265. $role = new role ();
  5266. $acItem = $accountItem->find ( array (
  5267. 'asArray' => true
  5268. ) );
  5269. $veList = $verify->find ( array (
  5270. 'asArray' => true
  5271. ) );
  5272. foreach ( $veList as $key => $value ) {
  5273. $v = json_decode ( $value ['staff'] );
  5274. $list = array ();
  5275. foreach ( $v as $n => $m ) {
  5276. if ($m ['1'] == 'ROLE') {
  5277. $roleInfo = $role->getOne ( array (
  5278. 'where' => 'rid=' . $m [0],
  5279. 'asArray' => true
  5280. ) );
  5281. $v [$n] [1] = $roleInfo ['name'];
  5282. array_push ( $list, $roleInfo ['name'] );
  5283. } else {
  5284. array_push ( $list, $v [$n] [1] );
  5285. }
  5286. }
  5287. $veList [$key] ['staff'] = implode ( '>', $list );
  5288. }
  5289. $data ['category'] = $lCategory->find ( array (
  5290. 'asArray' => true
  5291. ) );
  5292. $data ['veList'] = $veList;
  5293. $data ['acItem'] = $acItem;
  5294. $data ['memu'] = "receipt";
  5295. $data ['staff'] = $this->staff;
  5296. $data ['receiptMemu'] = 'saeaBorad';
  5297. $data ['verifyId'] = $this->verifyId;
  5298. $data ['executeId'] = $this->executeId;
  5299. $this->render ( "/admin/saea_create", $data );
  5300. }
  5301. function addReceipt() {
  5302. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  5303. $agency = $this->get_args ( 'agency' );
  5304. $travel = $this->get_args ( 'travel' );
  5305. $train = $this->get_args ( 'train' );
  5306. $other = $this->get_args ( 'other' );
  5307. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5308. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5309. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5310. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  5311. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  5312. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  5313. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  5314. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  5315. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  5316. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  5317. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  5318. header ( 'Content-Type:text/html;charset=utf-8' );
  5319. die ( '请填写联行号' );
  5320. }
  5321. Doo::loadModel ( 'receipt' );
  5322. Doo::loadModel ( 'receiptDetail' );
  5323. Doo::loadModel ( 'accountItem' );
  5324. $accountItem = new accountItem ();
  5325. $receipt = new receipt ();
  5326. Doo::loadModel ( 'enclosur' );
  5327. Doo::loadModel ( 'execute' );
  5328. $execute = new execute ();
  5329. $executeDetail = $execute->getOne ( array (
  5330. 'where' => 'mold="报销单执行人"',
  5331. 'asArray' => true
  5332. ) );
  5333. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  5334. // if(!empty($receiptDetail))
  5335. // return "/referReceipt/".$receiptDetail['rid'];
  5336. $aItem = $accountItem->find ( array (
  5337. 'asArray' => true
  5338. ) );
  5339. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5340. $ag = $tr = $ta = $ot = 0;
  5341. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5342. foreach ( $aItem as $key => $value ) {
  5343. if ($value ['category'] == $this->AGENCY) {
  5344. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5345. array_push ( $accountJson [$this->AGENCY], array (
  5346. 'aid' => $value ['aid'],
  5347. 'name' => $value ['name'],
  5348. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5349. ) );
  5350. $sum += $agency [$ag];
  5351. $agencySum += $agency [$ag];
  5352. }
  5353. $ag ++;
  5354. }
  5355. if ($value ['category'] == $this->TRAVEL) {
  5356. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5357. array_push ( $accountJson [$this->TRAVEL], array (
  5358. 'aid' => $value ['aid'],
  5359. 'name' => $value ['name'],
  5360. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5361. ) );
  5362. $sum += $travel [$tr];
  5363. $travelSum += $travel [$tr];
  5364. }
  5365. $tr ++;
  5366. }
  5367. if ($value ['category'] == $this->TRAIN) {
  5368. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5369. array_push ( $accountJson [$this->TRAIN], array (
  5370. 'aid' => $value ['aid'],
  5371. 'name' => $value ['name'],
  5372. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5373. ) );
  5374. $sum += $train [$ta];
  5375. $trainSum += $train [$ta];
  5376. }
  5377. $ta ++;
  5378. }
  5379. if ($value ['category'] == $this->OTHER) {
  5380. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5381. array_push ( $accountJson [$this->OTHER], array (
  5382. 'aid' => $value ['aid'],
  5383. 'name' => $value ['name'],
  5384. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5385. ) );
  5386. $sum += $other [$ot];
  5387. $otherSum += $other [$ot];
  5388. }
  5389. $ot ++;
  5390. }
  5391. }
  5392. $accountJson ['cSum'] = array (
  5393. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5394. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5395. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5396. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5397. );
  5398. // 报销单
  5399. $receipt->accountItem = json_encode ( $accountJson );
  5400. $receipt->staff = $this->staff [0] ['sid'];
  5401. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5402. $receipt->date = date ( "Y-m-d" );
  5403. $receipt->cid = $cid;
  5404. $receipt->status = 5;
  5405. // 修改审批流程加入角色
  5406. $receipt->verify = $verify;
  5407. $receipt->executeCopy = $executeDetail ['staff'];
  5408. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  5409. $order = array (
  5410. "\r\n",
  5411. "\n",
  5412. "\r"
  5413. );
  5414. $replace = '<br/>';
  5415. $explanation = str_replace ( $order, $replace, $explanation );
  5416. $receipt->explanation = $explanation;
  5417. $receipt->remittanceName = $remittanceName;
  5418. $receipt->bankName = $bankName;
  5419. $receipt->bankNumber = $bankNumber;
  5420. $receipt->remittanceBankType = $remittanceBankType;
  5421. if ($remittanceBankType == 1)
  5422. $receipt->coupletNumber = $coupletNumber;
  5423. $rid = $receipt->insert ();
  5424. // 附件
  5425. if (! empty ( $enclosurName )) {
  5426. $enclosurArray = explode ( '-', $enclosurName );
  5427. foreach ( $enclosurArray as $value ) {
  5428. $enclosur = new enclosur ();
  5429. $enclosur->name = $value;
  5430. $enclosur->rid = $rid;
  5431. $enclosur->insert ();
  5432. }
  5433. // print_r($enclosurArray);die;
  5434. }
  5435. // 报销详情
  5436. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5437. $receiptDetail = new receiptDetail ();
  5438. $receiptDetail->staff = $this->staff [0] ['sid'];
  5439. $receiptDetail->item = $value ['name'];
  5440. $receiptDetail->itemCategory = $this->AGENCY;
  5441. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5442. $receiptDetail->date = date ( "Y-m-d" );
  5443. $receiptDetail->cid = $cid;
  5444. $receiptDetail->rid = $rid;
  5445. $receiptDetail->status = 4;
  5446. $receiptDetail->insert ();
  5447. }
  5448. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5449. $receiptDetail = new receiptDetail ();
  5450. $receiptDetail->staff = $this->staff [0] ['sid'];
  5451. $receiptDetail->item = $value ['name'];
  5452. $receiptDetail->itemCategory = $this->TRAVEL;
  5453. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5454. $receiptDetail->date = date ( "Y-m-d" );
  5455. $receiptDetail->cid = $cid;
  5456. $receiptDetail->rid = $rid;
  5457. $receiptDetail->status = 4;
  5458. $receiptDetail->insert ();
  5459. }
  5460. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5461. $receiptDetail = new receiptDetail ();
  5462. $receiptDetail->staff = $this->staff [0] ['sid'];
  5463. $receiptDetail->item = $value ['name'];
  5464. $receiptDetail->itemCategory = $this->TRAIN;
  5465. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5466. $receiptDetail->date = date ( "Y-m-d" );
  5467. $receiptDetail->cid = $cid;
  5468. $receiptDetail->rid = $rid;
  5469. $receiptDetail->status = 4;
  5470. $receiptDetail->insert ();
  5471. }
  5472. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5473. $receiptDetail = new receiptDetail ();
  5474. $receiptDetail->staff = $this->staff [0] ['sid'];
  5475. $receiptDetail->item = $value ['name'];
  5476. $receiptDetail->itemCategory = $this->OTHER;
  5477. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5478. $receiptDetail->date = date ( "Y-m-d" );
  5479. $receiptDetail->cid = $cid;
  5480. $receiptDetail->rid = $rid;
  5481. $receiptDetail->status = 4;
  5482. $receiptDetail->insert ();
  5483. }
  5484. return "/saeaBorad";
  5485. } else
  5486. die ( 'illegal request' );
  5487. }
  5488. function referReceipt() {
  5489. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  5490. Doo::loadModel ( 'receipt' );
  5491. Doo::loadModel ( 'verify' );
  5492. $verify = new verify ();
  5493. $receipt = new receipt ();
  5494. Doo::loadModel ( 'L_category' );
  5495. $lCategory = new L_category ();
  5496. Doo::loadModel ( "role" );
  5497. $role = new role ();
  5498. $receiptDetail = $receipt->find ( array (
  5499. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  5500. 'asArray' => true
  5501. ) );
  5502. if (empty ( $receiptDetail ))
  5503. return "/addReceipt";
  5504. foreach ( $receiptDetail as $key => $value ) {
  5505. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5506. $veList = $verify->getOne ( array (
  5507. 'where' => 'vid=' . $value ['verify'],
  5508. 'asArray' => true
  5509. ) );
  5510. $v = json_decode ( $veList ['staff'] );
  5511. array_push ( $v [0], $veList ['description'] );
  5512. foreach ( $v as $n => $m ) {
  5513. if ($m ['1'] == 'ROLE') {
  5514. $roleInfo = $role->getOne ( array (
  5515. 'where' => 'rid=' . $m [0],
  5516. 'asArray' => true
  5517. ) );
  5518. $v [$n] [1] = $roleInfo ['name'];
  5519. }
  5520. }
  5521. $receiptDetail [$key] ['staff'] = $v;
  5522. $category = $lCategory->getOne ( array (
  5523. 'where' => 'cid=' . $value ['cid'],
  5524. 'asArray' => true
  5525. ) );
  5526. $receiptDetail [$key] ['category'] = $category ['title'];
  5527. }
  5528. // print_r($receiptDetail);
  5529. $data ['receiptDetail'] = $receiptDetail;
  5530. $data ['memu'] = "receipt";
  5531. $data ['staff'] = $this->staff;
  5532. $data ['receiptMemu'] = 'saeaCreate';
  5533. $data ['verifyId'] = $this->verifyId;
  5534. $data ['executeId'] = $this->executeId;
  5535. $this->render ( "/admin/saea_confirm", $data );
  5536. }
  5537. function editReceipt() {
  5538. // edit status 4
  5539. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  5540. Doo::loadClass ( 'XDeode' );
  5541. $XDeode = new XDeode ( 7 );
  5542. $rid = $XDeode->decode ( $ridKey );
  5543. if (empty ( $rid ))
  5544. die ( 'illegal request' );
  5545. // echo $rid.'sd';
  5546. Doo::loadModel ( 'accountItem' );
  5547. Doo::loadModel ( 'verify' );
  5548. Doo::loadModel ( 'receipt' );
  5549. $receipt = new receipt ();
  5550. $verify = new verify ();
  5551. $accountItem = new accountItem ();
  5552. Doo::loadModel ( 'L_category' );
  5553. $lCategory = new L_category ();
  5554. Doo::loadModel ( "role" );
  5555. $role = new role ();
  5556. Doo::loadModel ( 'enclosur' );
  5557. $enclosur = new enclosur ();
  5558. $receiptDetail = $receipt->getOne ( array (
  5559. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  5560. 'asArray' => true
  5561. ) );
  5562. if (empty ( $receiptDetail ))
  5563. die ( 'illegal request' );
  5564. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  5565. $acItem = $accountItem->find ( array (
  5566. 'asArray' => true
  5567. ) );
  5568. $veList = $verify->find ( array (
  5569. 'asArray' => true
  5570. ) );
  5571. foreach ( $veList as $key => $value ) {
  5572. $v = json_decode ( $value ['staff'] );
  5573. $list = array ();
  5574. foreach ( $v as $n => $m ) {
  5575. if ($m ['1'] == 'ROLE') {
  5576. $roleInfo = $role->getOne ( array (
  5577. 'where' => 'rid=' . $m [0],
  5578. 'asArray' => true
  5579. ) );
  5580. $v [$n] [1] = $roleInfo ['name'];
  5581. array_push ( $list, $roleInfo ['name'] );
  5582. } else {
  5583. array_push ( $list, $v [$n] [1] );
  5584. }
  5585. }
  5586. $veList [$key] ['staff'] = implode ( '>', $list );
  5587. }
  5588. // 配置编辑信息
  5589. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  5590. foreach ( $acItem as $key => $value ) {
  5591. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  5592. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  5593. $acItem [$key] ['price'] = $v ['price'];
  5594. }
  5595. }
  5596. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  5597. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  5598. $acItem [$key] ['price'] = $v ['price'];
  5599. }
  5600. }
  5601. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  5602. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  5603. $acItem [$key] ['price'] = $v ['price'];
  5604. }
  5605. }
  5606. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  5607. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  5608. $acItem [$key] ['price'] = $v ['price'];
  5609. }
  5610. }
  5611. }
  5612. $data ['category'] = $lCategory->find ( array (
  5613. 'asArray' => true
  5614. ) );
  5615. $data ['cSum'] = $accountItemList ['cSum'];
  5616. $data ['sum'] = $receiptDetail ['sum'];
  5617. $data ['enclosurList'] = $enclosurList;
  5618. $data ['receiptDetail'] = $receiptDetail;
  5619. $data ['veList'] = $veList;
  5620. $data ['acItem'] = $acItem;
  5621. $data ['memu'] = "receipt";
  5622. $data ['staff'] = $this->staff;
  5623. $data ['receiptMemu'] = 'saeaBorad';
  5624. $data ['verify'] = $receiptDetail ['verify'];
  5625. $data ['verifyId'] = $this->verifyId;
  5626. $data ['executeId'] = $this->executeId;
  5627. $data ['rid'] = $ridKey;
  5628. $this->render ( "/admin/saea_edit", $data );
  5629. }
  5630. function updateReceipt() {
  5631. $agency = $this->get_args ( 'agency' );
  5632. $travel = $this->get_args ( 'travel' );
  5633. $train = $this->get_args ( 'train' );
  5634. $other = $this->get_args ( 'other' );
  5635. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5636. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5637. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5638. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  5639. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  5640. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  5641. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  5642. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  5643. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  5644. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  5645. Doo::loadClass ( 'XDeode' );
  5646. $XDeode = new XDeode ( 7 );
  5647. $rid = $XDeode->decode ( $ridKey );
  5648. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  5649. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  5650. header ( 'Content-Type:text/html;charset=utf-8' );
  5651. die ( '请填写联行号' );
  5652. }
  5653. Doo::loadModel ( 'receipt' );
  5654. Doo::loadModel ( 'receiptDetail' );
  5655. Doo::loadModel ( 'accountItem' );
  5656. $accountItem = new accountItem ();
  5657. $receipt = new receipt ();
  5658. Doo::loadModel ( 'enclosur' );
  5659. Doo::loadModel ( 'execute' );
  5660. $execute = new execute ();
  5661. $receiptDetail = $receipt->getOne ( array (
  5662. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  5663. 'asArray' => true
  5664. ) );
  5665. if (empty ( $receiptDetail ))
  5666. return "/saeaBorad";
  5667. if ($receiptDetail ['Rtype'] == 1)
  5668. $executeDetail = $execute->getOne ( array (
  5669. 'where' => 'mold="借款费用执行人"',
  5670. 'asArray' => true
  5671. ) );
  5672. else
  5673. $executeDetail = $execute->getOne ( array (
  5674. 'where' => 'mold="报销单执行人"',
  5675. 'asArray' => true
  5676. ) );
  5677. $aItem = $accountItem->find ( array (
  5678. 'asArray' => true
  5679. ) );
  5680. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5681. $ag = $tr = $ta = $ot = 0;
  5682. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5683. foreach ( $aItem as $key => $value ) {
  5684. if ($value ['category'] == $this->AGENCY) {
  5685. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5686. array_push ( $accountJson [$this->AGENCY], array (
  5687. 'aid' => $value ['aid'],
  5688. 'name' => $value ['name'],
  5689. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5690. ) );
  5691. $sum += $agency [$ag];
  5692. $agencySum += $agency [$ag];
  5693. }
  5694. $ag ++;
  5695. }
  5696. if ($value ['category'] == $this->TRAVEL) {
  5697. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5698. array_push ( $accountJson [$this->TRAVEL], array (
  5699. 'aid' => $value ['aid'],
  5700. 'name' => $value ['name'],
  5701. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5702. ) );
  5703. $sum += $travel [$tr];
  5704. $travelSum += $travel [$tr];
  5705. }
  5706. $tr ++;
  5707. }
  5708. if ($value ['category'] == $this->TRAIN) {
  5709. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5710. array_push ( $accountJson [$this->TRAIN], array (
  5711. 'aid' => $value ['aid'],
  5712. 'name' => $value ['name'],
  5713. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5714. ) );
  5715. $sum += $train [$ta];
  5716. $trainSum += $train [$ta];
  5717. }
  5718. $ta ++;
  5719. }
  5720. if ($value ['category'] == $this->OTHER) {
  5721. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5722. array_push ( $accountJson [$this->OTHER], array (
  5723. 'aid' => $value ['aid'],
  5724. 'name' => $value ['name'],
  5725. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5726. ) );
  5727. $sum += $other [$ot];
  5728. $otherSum += $other [$ot];
  5729. }
  5730. $ot ++;
  5731. }
  5732. }
  5733. $accountJson ['cSum'] = array (
  5734. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5735. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5736. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5737. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5738. );
  5739. // 报销单
  5740. $rid = $receipt->rid = $receiptDetail ['rid'];
  5741. $receipt->accountItem = json_encode ( $accountJson );
  5742. $receipt->staff = $this->staff [0] ['sid'];
  5743. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5744. $receipt->date = date ( "Y-m-d" );
  5745. $receipt->cid = $cid;
  5746. if (($receiptDetail ['status'] != 4)) {
  5747. if ($receiptDetail ['Rtype'] == 1)
  5748. $receipt->status = 7;
  5749. else
  5750. $receipt->status = 5;
  5751. }
  5752. if ($receiptDetail != 4 && ! empty ( $verify ))
  5753. $receipt->verify = $verify;
  5754. $receipt->executeCopy = $executeDetail ['staff'];
  5755. $order = array (
  5756. "\r\n",
  5757. "\n",
  5758. "\r"
  5759. );
  5760. $replace = '<br/>';
  5761. $explanation = str_replace ( $order, $replace, $explanation );
  5762. $receipt->explanation = $explanation;
  5763. $receipt->remittanceName = $remittanceName;
  5764. $receipt->bankName = $bankName;
  5765. $receipt->bankNumber = $bankNumber;
  5766. $receipt->remittanceBankType = $remittanceBankType;
  5767. if ($remittanceBankType == 1)
  5768. $receipt->coupletNumber = $coupletNumber;
  5769. $receipt->update ();
  5770. $receiptDetail = new receiptDetail ();
  5771. $receiptDetail->delete ( array (
  5772. 'where' => 'rid=' . $rid
  5773. ) );
  5774. // 报销详情
  5775. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5776. $receiptDetail = new receiptDetail ();
  5777. $receiptDetail->staff = $this->staff [0] ['sid'];
  5778. $receiptDetail->item = $value ['name'];
  5779. $receiptDetail->itemCategory = $this->AGENCY;
  5780. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5781. $receiptDetail->date = date ( "Y-m-d" );
  5782. $receiptDetail->cid = $cid;
  5783. $receiptDetail->rid = $rid;
  5784. $receiptDetail->status = 4;
  5785. $receiptDetail->insert ();
  5786. }
  5787. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5788. $receiptDetail = new receiptDetail ();
  5789. $receiptDetail->staff = $this->staff [0] ['sid'];
  5790. $receiptDetail->item = $value ['name'];
  5791. $receiptDetail->itemCategory = $this->TRAVEL;
  5792. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5793. $receiptDetail->date = date ( "Y-m-d" );
  5794. $receiptDetail->cid = $cid;
  5795. $receiptDetail->rid = $rid;
  5796. $receiptDetail->status = 4;
  5797. $receiptDetail->insert ();
  5798. }
  5799. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5800. $receiptDetail = new receiptDetail ();
  5801. $receiptDetail->staff = $this->staff [0] ['sid'];
  5802. $receiptDetail->item = $value ['name'];
  5803. $receiptDetail->itemCategory = $this->TRAIN;
  5804. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5805. $receiptDetail->date = date ( "Y-m-d" );
  5806. $receiptDetail->cid = $cid;
  5807. $receiptDetail->rid = $rid;
  5808. $receiptDetail->status = 4;
  5809. $receiptDetail->insert ();
  5810. }
  5811. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5812. $receiptDetail = new receiptDetail ();
  5813. $receiptDetail->staff = $this->staff [0] ['sid'];
  5814. $receiptDetail->item = $value ['name'];
  5815. $receiptDetail->itemCategory = $this->OTHER;
  5816. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5817. $receiptDetail->date = date ( "Y-m-d" );
  5818. $receiptDetail->cid = $cid;
  5819. $receiptDetail->rid = $rid;
  5820. $receiptDetail->status = 4;
  5821. $receiptDetail->insert ();
  5822. }
  5823. // 附件
  5824. if (! empty ( $enclosurName )) {
  5825. $enclosurArray = explode ( '-', $enclosurName );
  5826. foreach ( $enclosurArray as $value ) {
  5827. $enclosur = new enclosur ();
  5828. $enclosur->name = $value;
  5829. $enclosur->rid = $rid;
  5830. $enclosur->insert ();
  5831. }
  5832. }
  5833. // return "/referReceipt/".$rid;
  5834. }
  5835. return "/saeaBorad";
  5836. }
  5837. function approvedReceipt() {
  5838. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5839. Doo::loadModel ( 'receipt' );
  5840. Doo::loadModel ( 'receiptDetail' );
  5841. $receipt = new receipt ();
  5842. $receiptDetail = new receiptDetail ();
  5843. Doo::loadModel ( 'statistics' );
  5844. Doo::loadModel ( 'itemStatistics' );
  5845. $statistics = new statistics ();
  5846. $itemStatistics = new itemStatistics ();
  5847. Doo::loadModel ( "verify" );
  5848. $verify = new verify ();
  5849. // 审批状态的判定
  5850. $receiptDetailList = $receipt->getOne ( array (
  5851. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  5852. 'asArray' => true
  5853. ) );
  5854. if (empty ( $receiptDetailList ))
  5855. return "/saeaBorad";
  5856. $verifyDetail = $verify->getOne ( array (
  5857. 'where' => ' vid =' . $receiptDetailList ['verify'],
  5858. 'asArray' => true
  5859. ) );
  5860. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5861. if (empty ( $receiptDetailList ['nowStaff'] )) {
  5862. $nowStaff = "";
  5863. $nowStaffList = array ();
  5864. if ($verifyDetail [0] [1] == 'ROLE') {
  5865. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5866. foreach ( $vStaffString as $key => $value ) {
  5867. $staffK = explode ( "_", $value );
  5868. array_push ( $nowStaffList, $staffK [0] );
  5869. }
  5870. $nowStaff = implode ( ',', $nowStaffList );
  5871. } else {
  5872. $nowStaff = $verifyDetail [0] [0];
  5873. }
  5874. $receipt->nowStaff = $nowStaff;
  5875. }
  5876. // echo $nowStaff;
  5877. // print_r($verifyDetail);die;
  5878. $receipt->rid = $receiptDetailList ['rid'];
  5879. $receipt->date = date ( "Y-m-d" );
  5880. $receipt->status = 2;
  5881. $receipt->update ();
  5882. $receiptDetail->status = 2;
  5883. $receiptDetail->update ( array (
  5884. 'where' => 'rid=' . $receiptDetailList ['rid']
  5885. ) );
  5886. Doo::loadModel ( "receiptLog" );
  5887. $receiptLog = new receiptLog ();
  5888. Doo::loadModel ( "verify" );
  5889. $verify = new verify ();
  5890. $receiptInfo = $receipt->getOne ( array (
  5891. 'where' => 'rid=' . $rid,
  5892. 'asArray' => true
  5893. ) );
  5894. $vr = $verify->getOne ( array (
  5895. 'where' => 'vid=' . $receiptInfo ['verify'],
  5896. 'asArray' => true
  5897. ) );
  5898. $jd = json_decode ( $vr ['staff'] );
  5899. $roleId = 0;
  5900. foreach ( $jd as $key => $value ) {
  5901. if ($value [1] == 'ROLE') {
  5902. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  5903. if ($pos !== false) {
  5904. $roleId = $value [0];
  5905. }
  5906. }
  5907. }
  5908. // 审批日志
  5909. // echo $roleId;die;
  5910. if (! empty ( $roleId )) {
  5911. Doo::loadModel ( "role" );
  5912. $role = new role ();
  5913. $roleInfo = $role->getOne ( array (
  5914. 'where' => 'rid=' . $roleId,
  5915. 'asArray' => true
  5916. ) );
  5917. // $receiptLog->rolename = $roleInfo ['name'];
  5918. }
  5919. $receiptLog->username = $this->staff [0] ['username'];
  5920. $receiptLog->uid = $this->staff [0] ['sid'];
  5921. $receiptLog->date = date ( "Y-m-d" );
  5922. $receiptLog->opinion = '提交审批';
  5923. $receiptLog->img = $this->staff [0] ['avatar'];
  5924. $receiptLog->status = 2;
  5925. $receiptLog->rid = $rid;
  5926. $receiptLog->insert ();
  5927. // statistics item
  5928. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  5929. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  5930. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  5931. $stat = $statistics->getOne ( array (
  5932. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5933. 'asArray' => true
  5934. ) );
  5935. if (empty ( $stat )) {
  5936. $statistics->date = date ( "Y-m-d" );
  5937. $statistics->cid = $this->staff [0] ['cid'];
  5938. $statistics->staff = $this->staff [0] ['sid'];
  5939. $statistics->agPrice = 0;
  5940. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5941. $statistics->insert ();
  5942. } else {
  5943. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5944. $statistics->update ( array (
  5945. 'where' => 'sid=' . $stat ['sid']
  5946. ) );
  5947. }
  5948. return "/expenses";
  5949. }
  5950. function approval() {
  5951. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5952. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5953. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5954. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5955. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5956. if (empty ( $status ))
  5957. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5958. $vidList = array ();
  5959. $button = 0;
  5960. Doo::loadModel ( 'verify' );
  5961. $verify = new verify ();
  5962. Doo::loadModel ( 'receipt' );
  5963. $receipt = new receipt ();
  5964. Doo::loadModel ( 'staff' );
  5965. $staff = new staff ();
  5966. Doo::loadModel ( 'L_category' );
  5967. $Lcategory = new L_category ();
  5968. // user verify ID
  5969. $verifyDetail = $verify->find ( array (
  5970. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5971. 'asArray' => true
  5972. ) );
  5973. foreach ( $verifyDetail as $key => $value ) {
  5974. array_push ( $vidList, $value ['vid'] );
  5975. }
  5976. $vid = implode ( ",", $vidList );
  5977. if (empty ( $verifyDetail ))
  5978. $vid = 0;
  5979. /*
  5980. */
  5981. $dateCondition = " and Year(date) =" . $year;
  5982. if (! empty ( $month ))
  5983. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  5984. $categoryList = $Lcategory->find ( array (
  5985. 'asArray' => true
  5986. ) );
  5987. $staffList = $staff->find ( array (
  5988. 'where' => 'cid=' . $cid,
  5989. 'asArray' => true
  5990. ) );
  5991. $cateCondition = "";
  5992. $staffCondition = "";
  5993. $approvalCondition = "";
  5994. if (! empty ( $cid ))
  5995. $cateCondition = ' and cid=' . $cid;
  5996. if (! empty ( $sid )) {
  5997. $staffCondition = ' and staff=' . $sid;
  5998. $cateCondition = "";
  5999. }
  6000. // elseif($status==1){
  6001. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  6002. // }
  6003. if ($status == 2) {
  6004. // 查找角色审批人
  6005. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  6006. }
  6007. $ap = "";
  6008. if ($status == 4) {
  6009. $ap = 4;
  6010. $status = 2;
  6011. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  6012. }
  6013. if ($status == 5) {
  6014. $status = 4;
  6015. $ap = 5;
  6016. }
  6017. // echo $vid;
  6018. // get Receipt By verifyID status 2 .$approvalCondition
  6019. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  6020. $receiptList = $receipt->find ( array (
  6021. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  6022. 'desc' => 'rid',
  6023. 'asArray' => true
  6024. ) );
  6025. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  6026. $Locate = 0;
  6027. if ($ap == 4)
  6028. $status = 4;
  6029. elseif ($ap == 5)
  6030. $status = 5;
  6031. foreach ( $receiptList as $key => $value ) {
  6032. $receiptList [$key] ['Locate'] = $Locate;
  6033. $Locate ++;
  6034. $receiptList [$key] ['reviseDetail'] = array ();
  6035. if (! empty ( $value ['reviseDetail'] ))
  6036. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6037. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6038. $categoryDetil = $Lcategory->getOne ( array (
  6039. 'where' => 'cid=' . $value ['cid'],
  6040. 'asArray' => true
  6041. ) );
  6042. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6043. $verifyList = $verify->getOne ( array (
  6044. 'where' => 'vid=' . $value ['verify'],
  6045. 'asArray' => true
  6046. ) );
  6047. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6048. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6049. foreach ( $verifyList as $k => $v ) {
  6050. // init verifyStaff
  6051. $verifyList [$k] ['date'] = "";
  6052. $verifyList [$k] ['opinion'] = "";
  6053. $verifyList [$k] ['status'] = "";
  6054. if (empty ( $verifyStaff )) {
  6055. $verifyList [$k] ['date'] = "";
  6056. $verifyList [$k] ['opinion'] = "";
  6057. if ($v [0] == $this->staff [0] ['sid']) {
  6058. $verifyList [$k] ['status'] = 4;
  6059. $button = 4;
  6060. }
  6061. } else {
  6062. $flag = true;
  6063. foreach ( $verifyStaff as $m => $u ) {
  6064. if ($v [0] == $m) {
  6065. $verifyList [$k] ['date'] = $u ['date'];
  6066. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6067. $verifyList [$k] ['status'] = $u ['status'];
  6068. $flag = false;
  6069. break;
  6070. }
  6071. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  6072. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  6073. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  6074. }
  6075. if ($flag) { // 检测可编辑
  6076. if ($v [0] == $this->staff [0] ['sid']) {
  6077. $verifyList [$k] ['status'] = 4;
  6078. $button = 4;
  6079. }
  6080. }
  6081. }
  6082. }
  6083. $receiptList [$key] ['verifyList'] = $verifyList;
  6084. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6085. 'where' => 'sid=' . $value ['staff'],
  6086. 'asArray' => true
  6087. ) );
  6088. $receiptList [$key] ['button'] = $button;
  6089. }
  6090. // print_r($receiptList);die;
  6091. // $data['verifyDetail']=$verifyDetail;
  6092. $mothHtml = "";
  6093. for($i = 1; $i <= 12; $i ++) {
  6094. if ($month == $i)
  6095. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6096. else
  6097. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6098. }
  6099. $data ['mothHtml'] = $mothHtml;
  6100. $data ['receiptList'] = $receiptList;
  6101. $data ['receiptApprovalCount'] = count ( $receiptList );
  6102. $data ['status'] = $status;
  6103. $data ['year'] = $year;
  6104. $data ['categoryList'] = $categoryList;
  6105. $data ['staffList'] = $staffList;
  6106. $data ['cid'] = $cid;
  6107. $data ['sid'] = $sid;
  6108. $data ['ap'] = $ap;
  6109. $data ['memu'] = "receipt";
  6110. $data ['staff'] = $this->staff;
  6111. $data ['receiptMemu'] = 'approval';
  6112. $data ['verifyId'] = $this->verifyId;
  6113. $data ['executeId'] = $this->executeId;
  6114. $this->render ( "/admin/saea_reportList", $data );
  6115. }
  6116. function approvalDetails() {
  6117. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6118. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6119. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6120. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6121. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6122. Doo::loadModel ( 'verify' );
  6123. $verify = new verify ();
  6124. Doo::loadModel ( 'receipt' );
  6125. $receipt = new receipt ();
  6126. Doo::loadModel ( 'staff' );
  6127. $staff = new staff ();
  6128. Doo::loadModel ( 'L_category' );
  6129. $Lcategory = new L_category ();
  6130. Doo::loadModel ( 'enclosur' );
  6131. $enclosur = new enclosur ();
  6132. $vidList = array ();
  6133. $verifyDetail = $verify->find ( array (
  6134. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6135. 'asArray' => true
  6136. ) );
  6137. foreach ( $verifyDetail as $key => $value ) {
  6138. array_push ( $vidList, $value ['vid'] );
  6139. }
  6140. $vid = implode ( ",", $vidList );
  6141. if (empty ( $verifyDetail ))
  6142. $vid = 0;
  6143. $categoryList = $Lcategory->find ( array (
  6144. 'asArray' => true
  6145. ) );
  6146. $staffList = $staff->find ( array (
  6147. 'where' => 'cid=' . $cid,
  6148. 'asArray' => true
  6149. ) );
  6150. $ap = 0;
  6151. $receiptList = $receipt->find ( array (
  6152. 'where' => 'rid =' . $rid,
  6153. 'desc' => 'rid',
  6154. 'asArray' => true
  6155. ) );
  6156. $Locate = 0;
  6157. $roleId = 0;
  6158. $button = 0;
  6159. foreach ( $receiptList as $key => $value ) {
  6160. $receiptList [$key] ['Locate'] = $Locate;
  6161. $Locate ++;
  6162. $receiptList [$key] ['reviseDetail'] = array ();
  6163. if (! empty ( $value ['reviseDetail'] ))
  6164. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6165. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6166. $categoryDetil = $Lcategory->getOne ( array (
  6167. 'where' => 'cid=' . $value ['cid'],
  6168. 'asArray' => true
  6169. ) );
  6170. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6171. // 检测编辑状态
  6172. $verifyList = $verify->getOne ( array (
  6173. 'where' => 'vid=' . $value ['verify'],
  6174. 'asArray' => true
  6175. ) );
  6176. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6177. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6178. Doo::loadModel ( 'role' );
  6179. $role = new role ();
  6180. // print_r($verifyList);
  6181. $flag = true;
  6182. $roleKey = 0;
  6183. $endStaffArray = array ();
  6184. $roleArrayCopy = array ();
  6185. foreach ( $verifyList as $k => $v ) {
  6186. // init verifyStaff
  6187. if ($v [1] == 'ROLE') {
  6188. if (! empty ( $verifyStaff )) {
  6189. $endStaffArray = end ( $verifyStaff );
  6190. if ($v [0] == $endStaffArray ['nextStaff']) {
  6191. $roleId = $v [0];
  6192. }
  6193. }
  6194. $roleVerify = json_decode ( $v [3], true );
  6195. $roleKey = $k;
  6196. $roleArray = array ();
  6197. $rolename = $role->getOne ( array (
  6198. 'where' => 'rid=' . $v [0],
  6199. 'asArray' => true
  6200. ) );
  6201. foreach ( $roleVerify as $o => $p ) {
  6202. $staffID = explode ( '_', $p );
  6203. $staffInfo = $staff->getOne ( array (
  6204. 'where' => 'sid=' . $staffID [0],
  6205. 'asArray' => true
  6206. ) );
  6207. // print_r($staffID);
  6208. $exp = array (
  6209. 0 => $staffInfo ['sid'],
  6210. 1 => $staffID [1],
  6211. 2 => $staffInfo ['avatar'],
  6212. 'date' => '',
  6213. 'date' => '',
  6214. 'opinion' => '',
  6215. 'status' => '',
  6216. 'rolename' => $rolename ['name']
  6217. );
  6218. array_push ( $roleArray, $exp );
  6219. }
  6220. $roleArrayCopy [$v [0]] = $roleArray;
  6221. // $verifyList[$k]['roleArray']=$roleArray;
  6222. }
  6223. // print_r($roleArray);
  6224. $verifyList [$k] ['date'] = "";
  6225. $verifyList [$k] ['opinion'] = "";
  6226. $verifyList [$k] ['status'] = "";
  6227. if (empty ( $verifyStaff )) {
  6228. $verifyList [$k] ['date'] = "";
  6229. $verifyList [$k] ['opinion'] = "";
  6230. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6231. $verifyList [$k] ['status'] = 4;
  6232. $button = 4;
  6233. $flag = false;
  6234. }
  6235. } else {
  6236. foreach ( $verifyStaff as $m => $u ) {
  6237. if ($v [0] == $m) {
  6238. $verifyList [$k] ['date'] = $u ['date'];
  6239. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6240. $verifyList [$k] ['status'] = $u ['status'];
  6241. $flag = false;
  6242. break;
  6243. }
  6244. }
  6245. $endStaffArray = end ( $verifyStaff );
  6246. if (isset ( $endStaffArray ['ROLE'] )) {
  6247. } else {
  6248. $endKey = key ( $verifyStaff );
  6249. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6250. $button = 4;
  6251. $verifyList [$k] ['status'] = 4;
  6252. }
  6253. }
  6254. }
  6255. }
  6256. $rolename ['name'] = '';
  6257. if (! empty ( $roleId )) {
  6258. Doo::loadModel ( 'role' );
  6259. $role = new role ();
  6260. $rolename = $role->getOne ( array (
  6261. 'where' => 'rid=' . $roleId,
  6262. 'asArray' => true
  6263. ) );
  6264. }
  6265. if (! empty ( $verifyStaff ))
  6266. $endStaffArray = end ( $verifyStaff );
  6267. $KOP = false;
  6268. foreach ( $roleArrayCopy as $P => $A ) {
  6269. foreach ( $A as $MKI => $AVL ) {
  6270. if (! empty ( $verifyStaff )) {
  6271. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6272. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6273. $button = 4;
  6274. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6275. }
  6276. foreach ( $verifyStaff as $m => $u ) {
  6277. $AVLFK = $AVL [0] . '_R';
  6278. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6279. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6280. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6281. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6282. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6283. break;
  6284. }
  6285. }
  6286. } else {
  6287. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6288. $button = 4;
  6289. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6290. }
  6291. }
  6292. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6293. $KOP = true;
  6294. }
  6295. }
  6296. foreach ( $roleArrayCopy as $k => $v ) {
  6297. foreach ( $verifyList as $m => $n ) {
  6298. if ($n [0] == $k) {
  6299. array_splice ( $verifyList, $m, 1, $v );
  6300. }
  6301. }
  6302. }
  6303. $receiptList [$key] ['verifyList'] = $verifyList;
  6304. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6305. 'where' => 'sid=' . $value ['staff'],
  6306. 'asArray' => true
  6307. ) );
  6308. $receiptList [$key] ['button'] = $button;
  6309. }
  6310. $mothHtml = "";
  6311. for($i = 1; $i <= 12; $i ++) {
  6312. if ($month == $i)
  6313. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6314. else
  6315. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6316. }
  6317. // 获取审批日志
  6318. Doo::loadModel ( 'receiptLog' );
  6319. $receiptLog = new receiptLog ();
  6320. $rlList = array ();
  6321. $rlInfo = $receiptLog->getOne ( array (
  6322. 'where' => 'rid=' . $rid . ' and status=4',
  6323. 'asArray' => true
  6324. ) );
  6325. $tijdate = $receiptLog->getOne ( array (
  6326. 'where' => 'rid=' . $rid . ' and status=2',
  6327. 'asc' => 'rlid',
  6328. 'asArray' => true
  6329. ) );
  6330. if (! empty ( $rlInfo )) {
  6331. $rlList = $receiptLog->find ( array (
  6332. 'where' => 'rid=' . $rid,
  6333. 'asc' => 'rlid',
  6334. 'asArray' => true
  6335. ) );
  6336. }
  6337. $receiptList [0] ['rlList'] = $rlList;
  6338. $enclosurList = $enclosur->find ( array (
  6339. 'where' => 'rid=' . $rid,
  6340. 'asArray' => true
  6341. ) );
  6342. $enclosurHtml = '';
  6343. foreach ( $enclosurList as $value ) {
  6344. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6345. }
  6346. $data ['enclosurHtml'] = $enclosurHtml;
  6347. $data ['rolename'] = $rolename ['name'];
  6348. $data ['datetij'] = $tijdate ['date'];
  6349. $data ['mothHtml'] = $mothHtml;
  6350. $data ['receiptList'] = $receiptList;
  6351. $data ['receiptApprovalCount'] = count ( $receiptList );
  6352. $data ['year'] = $year;
  6353. $data ['categoryList'] = $categoryList;
  6354. $data ['staffList'] = $staffList;
  6355. $data ['cid'] = $cid;
  6356. $data ['sid'] = $sid;
  6357. $data ['status'] = 0;
  6358. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  6359. $ap = 4;
  6360. } else
  6361. $data ['status'] = $receiptList [0] ['status'];
  6362. if ($receiptList [0] ['status'] == 4) {
  6363. $data ['status'] = 5;
  6364. $ap = 0;
  6365. }
  6366. $data ['ap'] = $ap;
  6367. $data ['memu'] = "receipt";
  6368. $data ['staff'] = $this->staff;
  6369. $data ['receiptMemu'] = 'approval';
  6370. $data ['verifyId'] = $this->verifyId;
  6371. $data ['executeId'] = $this->executeId;
  6372. $this->render ( "/admin/saeaReportListReport", $data );
  6373. }
  6374. function approvalEdi() {
  6375. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6376. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  6377. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6378. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6379. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6380. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6381. if (empty ( $status ))
  6382. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  6383. $vidList = array ();
  6384. $button = 0;
  6385. Doo::loadModel ( 'verify' );
  6386. Doo::loadModel ( 'receipt' );
  6387. Doo::loadModel ( 'staff' );
  6388. $staff = new staff ();
  6389. $receipt = new receipt ();
  6390. $verify = new verify ();
  6391. Doo::loadModel ( 'L_category' );
  6392. $Lcategory = new L_category ();
  6393. Doo::loadModel ( 'enclosur' );
  6394. $enclosur = new enclosur ();
  6395. // user verify ID
  6396. $verifyDetail = $verify->find ( array (
  6397. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6398. 'asArray' => true
  6399. ) );
  6400. foreach ( $verifyDetail as $key => $value ) {
  6401. array_push ( $vidList, $value ['vid'] );
  6402. }
  6403. $vid = implode ( ",", $vidList );
  6404. if (empty ( $verifyDetail ))
  6405. $vid = 0;
  6406. $categoryList = $Lcategory->find ( array (
  6407. 'asArray' => true
  6408. ) );
  6409. $staffList = $staff->find ( array (
  6410. 'where' => 'cid=' . $cid,
  6411. 'asArray' => true
  6412. ) );
  6413. $ap = "";
  6414. if ($status == 4) {
  6415. $ap = 4;
  6416. $status = 2;
  6417. }
  6418. // get Receipt By verifyID status 2
  6419. $receiptList = $receipt->find ( array (
  6420. 'where' => 'rid =' . $rid,
  6421. 'desc' => 'rid',
  6422. 'asArray' => true
  6423. ) );
  6424. $Locate = 0;
  6425. $roleId = 0;
  6426. if ($ap == 4)
  6427. $status = 4;
  6428. foreach ( $receiptList as $key => $value ) {
  6429. $receiptList [$key] ['Locate'] = $Locate;
  6430. $Locate ++;
  6431. $receiptList [$key] ['reviseDetail'] = array ();
  6432. if (! empty ( $value ['reviseDetail'] ))
  6433. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6434. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6435. $categoryDetil = $Lcategory->getOne ( array (
  6436. 'where' => 'cid=' . $value ['cid'],
  6437. 'asArray' => true
  6438. ) );
  6439. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6440. // 检测编辑状态
  6441. $verifyList = $verify->getOne ( array (
  6442. 'where' => 'vid=' . $value ['verify'],
  6443. 'asArray' => true
  6444. ) );
  6445. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6446. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6447. // print_r($verifyList);
  6448. //
  6449. // if (empty($verifyStaff)){
  6450. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6451. // $verifyList[0]['status']=4;$button=4;
  6452. // }
  6453. //
  6454. // }else{
  6455. //
  6456. // }
  6457. // die;
  6458. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  6459. // echo array_search("green",$a);
  6460. //
  6461. Doo::loadModel ( 'role' );
  6462. $role = new role ();
  6463. // print_r($verifyList);
  6464. $flag = true;
  6465. $roleKey = 0;
  6466. $endStaffArray = array ();
  6467. $roleArrayCopy = array ();
  6468. foreach ( $verifyList as $k => $v ) {
  6469. // init verifyStaff
  6470. if ($v [1] == 'ROLE') {
  6471. if (! empty ( $verifyStaff )) {
  6472. $endStaffArray = end ( $verifyStaff );
  6473. if ($v [0] == $endStaffArray ['nextStaff']) {
  6474. $roleId = $v [0];
  6475. }
  6476. }
  6477. $roleVerify = json_decode ( $v [3], true );
  6478. $roleKey = $k;
  6479. $roleArray = array ();
  6480. $rolename = $role->getOne ( array (
  6481. 'where' => 'rid=' . $v [0],
  6482. 'asArray' => true
  6483. ) );
  6484. foreach ( $roleVerify as $o => $p ) {
  6485. $staffID = explode ( '_', $p );
  6486. $staffInfo = $staff->getOne ( array (
  6487. 'where' => 'sid=' . $staffID [0],
  6488. 'asArray' => true
  6489. ) );
  6490. // print_r($staffID);
  6491. $exp = array (
  6492. 0 => $staffInfo ['sid'],
  6493. 1 => $staffID [1],
  6494. 2 => $staffInfo ['avatar'],
  6495. 'date' => '',
  6496. 'date' => '',
  6497. 'opinion' => '',
  6498. 'status' => '',
  6499. 'rolename' => $rolename ['name']
  6500. );
  6501. array_push ( $roleArray, $exp );
  6502. }
  6503. $roleArrayCopy [$v [0]] = $roleArray;
  6504. // $verifyList[$k]['roleArray']=$roleArray;
  6505. }
  6506. // print_r($roleArray);
  6507. $verifyList [$k] ['date'] = "";
  6508. $verifyList [$k] ['opinion'] = "";
  6509. $verifyList [$k] ['status'] = "";
  6510. if (empty ( $verifyStaff )) {
  6511. $verifyList [$k] ['date'] = "";
  6512. $verifyList [$k] ['opinion'] = "";
  6513. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6514. $verifyList [$k] ['status'] = 4;
  6515. $button = 4;
  6516. $flag = false;
  6517. }
  6518. } else {
  6519. foreach ( $verifyStaff as $m => $u ) {
  6520. if ($v [0] == $m) {
  6521. $verifyList [$k] ['date'] = $u ['date'];
  6522. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6523. $verifyList [$k] ['status'] = $u ['status'];
  6524. $flag = false;
  6525. break;
  6526. }
  6527. }
  6528. $endStaffArray = end ( $verifyStaff );
  6529. if (isset ( $endStaffArray ['ROLE'] )) {
  6530. } else {
  6531. $endKey = key ( $verifyStaff );
  6532. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6533. $button = 4;
  6534. $verifyList [$k] ['status'] = 4;
  6535. }
  6536. }
  6537. // print_r($endStaffArray);die;
  6538. // if (empty($verifyStaff)){
  6539. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6540. // $verifyList[$k]['status']=4;$button=4;
  6541. // }
  6542. //
  6543. // }else{
  6544. //
  6545. // }
  6546. // if($flag){//检测可编辑
  6547. // if($v[0]==$this->staff[0]['sid']){
  6548. // $verifyList[$k]['status']=4;$button=4;
  6549. // }
  6550. // }
  6551. }
  6552. }
  6553. $rolename ['name'] = '';
  6554. if (! empty ( $roleId )) {
  6555. Doo::loadModel ( 'role' );
  6556. $role = new role ();
  6557. $rolename = $role->getOne ( array (
  6558. 'where' => 'rid=' . $roleId,
  6559. 'asArray' => true
  6560. ) );
  6561. }
  6562. if (! empty ( $verifyStaff ))
  6563. $endStaffArray = end ( $verifyStaff );
  6564. $KOP = false;
  6565. foreach ( $roleArrayCopy as $P => $A ) {
  6566. foreach ( $A as $MKI => $AVL ) {
  6567. if (! empty ( $verifyStaff )) {
  6568. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6569. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6570. $button = 4;
  6571. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6572. }
  6573. foreach ( $verifyStaff as $m => $u ) {
  6574. $AVLFK = $AVL [0] . '_R';
  6575. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6576. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6577. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6578. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6579. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6580. break;
  6581. }
  6582. }
  6583. } else {
  6584. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6585. $button = 4;
  6586. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6587. }
  6588. }
  6589. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6590. $KOP = true;
  6591. }
  6592. }
  6593. // print_r($roleArrayCopy);
  6594. // echo $roleKey;
  6595. foreach ( $roleArrayCopy as $k => $v ) {
  6596. foreach ( $verifyList as $m => $n ) {
  6597. if ($n [0] == $k) {
  6598. array_splice ( $verifyList, $m, 1, $v );
  6599. }
  6600. }
  6601. }
  6602. // if ($KOP)
  6603. // array_splice($verifyList,$roleKey,1,$roleArray);
  6604. // print_r($verifyList);
  6605. $receiptList [$key] ['verifyList'] = $verifyList;
  6606. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6607. 'where' => 'sid=' . $value ['staff'],
  6608. 'asArray' => true
  6609. ) );
  6610. $receiptList [$key] ['button'] = $button;
  6611. }
  6612. // $data['verifyDetail']=$verifyDetail;
  6613. $mothHtml = "";
  6614. for($i = 1; $i <= 12; $i ++) {
  6615. if ($month == $i)
  6616. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6617. else
  6618. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6619. }
  6620. // 获取审批日志
  6621. Doo::loadModel ( 'receiptLog' );
  6622. $receiptLog = new receiptLog ();
  6623. $rlList = array ();
  6624. $rlInfo = $receiptLog->getOne ( array (
  6625. 'where' => 'rid=' . $rid . ' and status=4',
  6626. 'asArray' => true
  6627. ) );
  6628. $tijdate = $receiptLog->getOne ( array (
  6629. 'where' => 'rid=' . $rid . ' and status=2',
  6630. 'asc' => 'rlid',
  6631. 'asArray' => true
  6632. ) );
  6633. if (! empty ( $rlInfo )) {
  6634. $rlList = $receiptLog->find ( array (
  6635. 'where' => 'rid=' . $rid,
  6636. 'asc' => 'rlid',
  6637. 'asArray' => true
  6638. ) );
  6639. }
  6640. $receiptList [0] ['rlList'] = $rlList;
  6641. $enclosurList = $enclosur->find ( array (
  6642. 'where' => 'rid=' . $rid,
  6643. 'asArray' => true
  6644. ) );
  6645. $enclosurHtml = '';
  6646. foreach ( $enclosurList as $value ) {
  6647. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6648. }
  6649. $data ['enclosurHtml'] = $enclosurHtml;
  6650. $data ['rolename'] = $rolename ['name'];
  6651. $data ['datetij'] = $tijdate ['date'];
  6652. $data ['mothHtml'] = $mothHtml;
  6653. $data ['receiptList'] = $receiptList;
  6654. $data ['receiptApprovalCount'] = count ( $receiptList );
  6655. $data ['status'] = $status;
  6656. $data ['year'] = $year;
  6657. $data ['categoryList'] = $categoryList;
  6658. $data ['staffList'] = $staffList;
  6659. $data ['cid'] = $cid;
  6660. $data ['sid'] = $sid;
  6661. $data ['ap'] = $ap;
  6662. $data ['memu'] = "receipt";
  6663. $data ['staff'] = $this->staff;
  6664. $data ['receiptMemu'] = 'approval';
  6665. $data ['verifyId'] = $this->verifyId;
  6666. $data ['executeId'] = $this->executeId;
  6667. $this->render ( "/admin/saeaReportListReport", $data );
  6668. }
  6669. function remittanceHky() {
  6670. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6671. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  6672. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6673. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  6674. $page_size = 15;
  6675. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  6676. Doo::loadModel ( 'receipt' );
  6677. $receipt = new receipt ();
  6678. Doo::loadModel ( 'staff' );
  6679. $staff = new staff ();
  6680. $dateCondition = " and Year(executeDate) =" . $year;
  6681. if ($moth != 'MONTH')
  6682. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  6683. if ($day != 'DAY' && $moth != 'MONTH')
  6684. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  6685. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  6686. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  6687. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  6688. $limit = $pageinfo ['lower'] . ',' . $page_size;
  6689. $dayList = $receipt->find ( array (
  6690. 'select' => 'executeDate,sum(amount) as amount',
  6691. 'where' => $sql,
  6692. 'desc' => 'executeDate',
  6693. 'groupby' => 'executeDate',
  6694. 'limit' => $limit,
  6695. 'asArray' => true
  6696. ) );
  6697. // print_r($dayList);
  6698. foreach ( $dayList as $key => $value ) {
  6699. $remitString = "";
  6700. $receiptList = $receipt->find ( array (
  6701. 'select' => 'rid,executeDate,amount,staff,cid',
  6702. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  6703. 'desc' => 'executeDate',
  6704. 'asArray' => true
  6705. ) );
  6706. foreach ( $receiptList as $k => $v ) {
  6707. $sinfo = $staff->getOne ( array (
  6708. 'select' => 'username,category',
  6709. 'where' => ' sid=' . $v ['staff'],
  6710. 'asArray' => true
  6711. ) );
  6712. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  6713. }
  6714. $dayList [$key] ['staff'] = $remitString;
  6715. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  6716. }
  6717. // print_r($dayList);
  6718. $mothHtml = "";
  6719. for($i = 1; $i <= 12; $i ++) {
  6720. if ($moth == $i)
  6721. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6722. else
  6723. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6724. }
  6725. $dayHtml = "";
  6726. if ($day != "DAY" || $moth != "MONTH") {
  6727. for($i = 1; $i <= 31; $i ++) {
  6728. if ($day == $i)
  6729. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6730. else
  6731. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6732. }
  6733. }
  6734. $dateHtml = "";
  6735. $now = date ( "Y" );
  6736. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  6737. if ($YEARD <= $now) {
  6738. $dateHtml .= '<option ';
  6739. if ($year == $YEARD) {
  6740. $dateHtml .= 'selected ';
  6741. }
  6742. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  6743. }
  6744. }
  6745. $data ['dateHtml'] = $dateHtml;
  6746. $data ['page'] = $pageinfo;
  6747. $data ['year'] = $year;
  6748. $data ['moth'] = $moth;
  6749. $data ['day'] = $day;
  6750. $data ['get'] = $get;
  6751. $data ['dayHtml'] = $dayHtml;
  6752. $data ['mothHtml'] = $mothHtml;
  6753. $data ['receiptList'] = $dayList;
  6754. $data ['memu'] = "receipt";
  6755. $data ['staff'] = $this->staff;
  6756. $data ['receiptMemu'] = 'remittanceHky';
  6757. $data ['verifyId'] = $this->verifyId;
  6758. $data ['executeId'] = $this->executeId;
  6759. $this->render ( "/admin/remittanceHky", $data );
  6760. }
  6761. function remittancep() {
  6762. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  6763. Doo::loadModel ( 'receipt' );
  6764. $receipt = new receipt ();
  6765. Doo::loadModel ( 'staff' );
  6766. $staff = new staff ();
  6767. Doo::loadClass ( 'XDeode' );
  6768. $XDeode = new XDeode ( 5 );
  6769. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  6770. $rplist = $receipt->find ( array (
  6771. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6772. 'asArray' => true
  6773. ) );
  6774. $dayList = $receipt->find ( array (
  6775. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6776. 'desc' => 'executeDate',
  6777. 'groupby' => 'staff',
  6778. 'asArray' => true
  6779. ) );
  6780. $html = '';
  6781. foreach ( $dayList as $key => $value ) {
  6782. $sinfo = $staff->getOne ( array (
  6783. 'select' => 'username,category',
  6784. 'where' => ' sid=' . $value ['staff'],
  6785. 'asArray' => true
  6786. ) );
  6787. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  6788. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  6789. $au = 0;
  6790. foreach ( $rplist as $k => $v ) {
  6791. if ($value ['staff'] == $v ['staff']) {
  6792. $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>';
  6793. $au += $v ['amount'];
  6794. }
  6795. }
  6796. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  6797. }
  6798. $data ['html'] = $html;
  6799. $data ['memu'] = "receipt";
  6800. $data ['staff'] = $this->staff;
  6801. $data ['receiptMemu'] = 'remittanceHky';
  6802. $data ['verifyId'] = $this->verifyId;
  6803. $data ['executeId'] = $this->executeId;
  6804. $this->render ( "/admin/remittancep", $data );
  6805. }
  6806. function ajaxGetReceiptDetails() {
  6807. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  6808. Doo::loadClass ( 'XDeode' );
  6809. $XDeode = new XDeode ( 5 );
  6810. $rid = $XDeode->decode ( $rid );
  6811. if (empty ( $rid )) {
  6812. echo json_encode ( array (
  6813. 'status' => 2,
  6814. 'msg' => 'illegal request'
  6815. ) );
  6816. die ();
  6817. }
  6818. Doo::loadModel ( 'receipt' );
  6819. $receipt = new receipt ();
  6820. Doo::loadModel ( 'staff' );
  6821. $staff = new staff ();
  6822. $rinfo = $receipt->getOne ( array (
  6823. 'where' => 'rid= ' . $rid,
  6824. 'asArray' => true
  6825. ) );
  6826. $sinfo = $staff->getOne ( array (
  6827. 'select' => 'username,category',
  6828. 'where' => ' sid=' . $rinfo ['staff'],
  6829. 'asArray' => true
  6830. ) );
  6831. $rinfo ['reviseDetail'] = array ();
  6832. if (! empty ( $rinfo ['reviseDetail'] ))
  6833. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  6834. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  6835. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  6836. $rinfo ['category'] = $sinfo ['category'];
  6837. $verifyStaff = array ();
  6838. if (! empty ( $rinfo ['verifyStaff'] ))
  6839. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  6840. $relust = bcsub ( $rinfo ['sum'], $rinfo ['loanSum'], 2 );
  6841. $rinfo ['relust'] = $relust;
  6842. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  6843. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  6844. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  6845. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  6846. // 费用执行人相关数据
  6847. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6848. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6849. foreach ( $executeCopy as $k => $v ) {
  6850. $executeCopy [$k] ['date'] = '';
  6851. $executeCopy [$k] ['opinion'] = '';
  6852. $executeCopy [$k] ['status'] = '';
  6853. if (! empty ( $executeStaff ))
  6854. foreach ( $executeStaff as $m => $u ) {
  6855. if ($v [0] == $m) {
  6856. $executeCopy [$k] ['date'] = $u ['date'];
  6857. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  6858. $executeCopy [$k] ['status'] = $u ['status'];
  6859. break;
  6860. }
  6861. }
  6862. }
  6863. $rinfo ['executeCopy'] = $executeCopy;
  6864. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  6865. if ($rinfo ['Rtype'] == 1) { // 借款费用
  6866. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6867. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  6868. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  6869. $html .= '<tr><th>' . $value ['name'] . '</th>
  6870. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6871. }
  6872. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6873. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6874. <tr><th class="taC" colspan="2">费用说明</th>
  6875. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6876. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6877. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  6878. </tbody></table>';
  6879. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  6880. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6881. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6882. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6883. $html .= '<tr><th>' . $value ['name'] . '</th>
  6884. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6885. }
  6886. $html .= '<tr><th class="taR">合计</th>
  6887. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6888. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6889. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6890. $html .= '<tr><th>' . $value ['name'] . '</th>
  6891. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6892. }
  6893. $html .= '<tr><th class="taR">合计</th>
  6894. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6895. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6896. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6897. $html .= '<tr><th>' . $value ['name'] . '</th>
  6898. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6899. }
  6900. $html .= '<tr><th class="taR">合计</th>
  6901. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6902. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6903. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6904. $html .= '<tr><th>' . $value ['name'] . '</th>
  6905. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6906. }
  6907. $html .= '<tr><th class="taR">合计</th>
  6908. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6909. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6910. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6911. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6912. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6913. }
  6914. $html .= '<tr><th class="taR">合计</th>
  6915. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6916. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6917. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6918. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6919. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6920. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6921. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6922. <tr';
  6923. if ($rinfo ['relust'] >= 0) {
  6924. $html .= 'class="success"';
  6925. } else {
  6926. $html .= 'class="error"';
  6927. }
  6928. $html .= '><td class="taR"><b>借款结余</b></td>
  6929. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  6930. </tbody></table>
  6931. ';
  6932. }
  6933. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  6934. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6935. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  6936. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6937. $html .= '<tr><th>' . $value ['name'] . '</th>
  6938. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6939. }
  6940. $html .= '<tr><th class="taR">合计</th>
  6941. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6942. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6943. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6944. <tr><th class="taC" colspan="2">费用说明</th>
  6945. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6946. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6947. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6948. </tbody></table>';
  6949. } else {
  6950. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6951. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6952. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6953. $html .= '<tr><th>' . $value ['name'] . '</th>
  6954. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6955. }
  6956. $html .= '<tr><th class="taR">合计</th>
  6957. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6958. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6959. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6960. $html .= '<tr><th>' . $value ['name'] . '</th>
  6961. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6962. }
  6963. $html .= '<tr><th class="taR">合计</th>
  6964. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6965. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6966. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6967. $html .= '<tr><th>' . $value ['name'] . '</th>
  6968. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6969. }
  6970. $html .= '<tr><th class="taR">合计</th>
  6971. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6972. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6973. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6974. $html .= '<tr><th>' . $value ['name'] . '</th>
  6975. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6976. }
  6977. $html .= '<tr><th class="taR">合计</th>
  6978. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6979. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6980. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6981. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6982. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6983. }
  6984. $html .= '<tr><th class="taR">合计</th>
  6985. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6986. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6987. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6988. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6989. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6990. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6991. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  6992. $html .= '</tbody></table>';
  6993. /*
  6994. * <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>
  6995. */
  6996. }
  6997. // print_r($verifyStaff);die;
  6998. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  6999. foreach ( $verifyStaff as $key => $value ) {
  7000. $key = trim ( strtr ( $key, '_R', ' ' ) );
  7001. $sinfo = $staff->getOne ( array (
  7002. 'select' => 'username',
  7003. 'where' => ' sid=' . $key,
  7004. 'asArray' => true
  7005. ) );
  7006. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  7007. }
  7008. $html .= '</tbody></table>';
  7009. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  7010. foreach ( $rinfo ['executeCopy'] as $value ) {
  7011. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  7012. }
  7013. $html .= '</tbody></table>';
  7014. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  7015. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  7016. </tr></table>';
  7017. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  7018. echo json_encode ( array (
  7019. 'status' => 1,
  7020. 'html' => $html
  7021. ) );
  7022. die ();
  7023. }
  7024. /**
  7025. * 删除附件
  7026. */
  7027. function ajaxRemEnclousur() {
  7028. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  7029. if (empty ( $key ))
  7030. echo json_encode ( array (
  7031. 'status' => 2
  7032. ) );
  7033. Doo::loadModel ( 'enclosur' );
  7034. $enclosur = new enclosur ();
  7035. $enclosur->delEnclosurByEid ( $key );
  7036. echo json_encode ( array (
  7037. 'status' => 1
  7038. ) );
  7039. }
  7040. function remittance() {
  7041. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7042. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7043. Doo::loadModel ( 'receipt' );
  7044. $receipt = new receipt ();
  7045. Doo::loadModel ( 'staff' );
  7046. $staff = new staff ();
  7047. $dateCondition = " and Year(pastDate) =" . $year;
  7048. if (! empty ( $month ))
  7049. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  7050. // get Receipt By verifyID status 1
  7051. $receiptList = $receipt->find ( array (
  7052. 'select' => 'sum(sum) as sum,staff,pastDate',
  7053. 'where' => ' status=1' . $dateCondition,
  7054. 'desc' => 'pastDate',
  7055. 'groupby' => 'staff,pastDate',
  7056. 'asArray' => true
  7057. ) );
  7058. $dateList = $receipt->find ( array (
  7059. 'select' => 'pastDate,verifyStaff',
  7060. 'where' => ' status=1' . $dateCondition,
  7061. 'desc' => 'pastDate',
  7062. 'groupby' => 'pastDate',
  7063. 'asArray' => true
  7064. ) );
  7065. $dataList = array ();
  7066. foreach ( $dateList as $d => $a ) {
  7067. $dataList [$a ['pastDate']] = array ();
  7068. $daySum = 0;
  7069. foreach ( $receiptList as $key => $value ) {
  7070. if ($a ['pastDate'] == $value ['pastDate']) {
  7071. $oderList = $receipt->find ( array (
  7072. 'select' => 'receiptOrder',
  7073. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  7074. 'asArray' => true
  7075. ) );
  7076. $list = array ();
  7077. $html = "";
  7078. foreach ( $oderList as $v ) {
  7079. array_push ( $list, $v ['receiptOrder'] );
  7080. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  7081. }
  7082. $receiptList [$key] ['receiptOrder'] = $html;
  7083. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  7084. $sinfo = $staff->getOne ( array (
  7085. 'select' => 'username ',
  7086. 'where' => ' sid=' . $value ['staff'],
  7087. 'asArray' => true
  7088. ) );
  7089. $receiptList [$key] ['username'] = $sinfo ['username'];
  7090. $daySum += $value ['sum'];
  7091. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  7092. }
  7093. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  7094. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  7095. }
  7096. }
  7097. // print_r($dataList);
  7098. $data ['dataList'] = $dataList;
  7099. $mothHtml = "";
  7100. for($i = 1; $i <= 12; $i ++) {
  7101. if ($month == $i)
  7102. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7103. else
  7104. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7105. }
  7106. $data ['year'] = $year;
  7107. $data ['mothHtml'] = $mothHtml;
  7108. $data ['memu'] = "receipt";
  7109. $data ['staff'] = $this->staff;
  7110. $data ['receiptMemu'] = 'approval';
  7111. $data ['verifyId'] = $this->verifyId;
  7112. $data ['executeId'] = $this->executeId;
  7113. $this->render ( "/admin/saeaReportListPay", $data );
  7114. }
  7115. /**
  7116. * 金额调整,提高稳定性
  7117. * @return string
  7118. */
  7119. function revocationAdjustment() {
  7120. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  7121. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  7122. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  7123. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  7124. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey ) && (! empty ( $reviseKey )))) {
  7125. Doo::loadClass ( 'XDeode' );
  7126. $XDeode = new XDeode ( 5 );
  7127. Doo::loadModel ( 'receipt' );
  7128. $receipt = new receipt ();
  7129. $sid = $XDeode->decode ( $sidKey );
  7130. $rid = $XDeode->decode ( $ridKey );
  7131. $reviseKey = $XDeode->decode ( $reviseKey );
  7132. if (! is_numeric ( $sid ) && ! is_numeric ( $rid ) && ! is_numeric ( $reviseKey ))
  7133. die ( 'illegal request' );
  7134. $receiptDetail = $receipt->getOne ( array (
  7135. 'where' => 'rid=' . $rid,
  7136. 'asArray' => true
  7137. ) );
  7138. if (empty ( $receiptDetail ) || empty ( $receiptDetail ['reviseDetail'] ))
  7139. die ( 'illegal request' );
  7140. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7141. if (! isset ( $reviseDetail [$reviseKey] ))
  7142. die ( 'illegal request' );
  7143. if ($reviseDetail [$reviseKey] ['sid'] == $sid && $reviseDetail [$reviseKey] ['price'] == $price)
  7144. unset ( $reviseDetail [$reviseKey] );
  7145. $revisePrice = 0;
  7146. foreach ( $reviseDetail as $key => $value ) {
  7147. $revisePrice += $value ['price'];
  7148. }
  7149. $reviseDetailString = json_encode ( $reviseDetail );
  7150. $receipt->reviseDetail = $reviseDetailString;
  7151. $receipt->sum = $receiptDetail ['sum'] - $price;
  7152. $receipt->revisePrice = $revisePrice;
  7153. $receipt->update ( array (
  7154. 'where' => 'rid=' . $rid
  7155. ) );
  7156. return '/receiptburEdi/' . $rid;
  7157. } else
  7158. die ( 'illegal request2' );
  7159. }
  7160. function updateApprovalReceipt() {
  7161. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7162. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  7163. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7164. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  7165. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  7166. if (! empty ( $rid )) {
  7167. Doo::loadModel ( "verify" );
  7168. $verify = new verify ();
  7169. Doo::loadModel ( "receiptDetail" );
  7170. $receiptDetailObj = new receiptDetail ();
  7171. Doo::loadModel ( "itemStatistics" );
  7172. Doo::loadModel ( "statistics" );
  7173. $statistics = new statistics ();
  7174. $itemStatistics = new itemStatistics ();
  7175. Doo::loadModel ( "receipt" );
  7176. $receipt = new receipt ();
  7177. $receiptDetail = $receipt->getOne ( array (
  7178. 'where' => 'rid=' . $rid . ' and status=2 ',
  7179. 'asArray' => true
  7180. ) );
  7181. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  7182. $nsflag = true;
  7183. foreach ( $nslist as $value ) {
  7184. if ($value == $this->staff ['0'] ['sid']) {
  7185. $nsflag = false;
  7186. break;
  7187. }
  7188. }
  7189. if (empty ( $receiptDetail ) || $nsflag)
  7190. return "/approval";
  7191. $verifyDetail = $verify->getOne ( array (
  7192. 'where' => ' vid =' . $receiptDetail ['verify'],
  7193. 'asArray' => true
  7194. ) );
  7195. $verifyString = $verifyDetail ['staff'];
  7196. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  7197. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  7198. if (empty ( $opinion )) {
  7199. if ($status == 3)
  7200. $opinion = "终止";
  7201. else
  7202. $opinion = "同意支付";
  7203. }
  7204. $nowStaff = 0;
  7205. $nowStaffList = array ();
  7206. if (empty ( $verifyStaff )) {
  7207. // 还需加入是否已经进入角色审批
  7208. if ($verifyDetail [0] [1] == 'ROLE') {
  7209. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  7210. foreach ( $vStaffString as $key => $value ) {
  7211. $staffK = explode ( "_", $value );
  7212. if ($staffK [0] != $this->staff [0] ['sid'])
  7213. array_push ( $nowStaffList, $staffK [0] );
  7214. }
  7215. // print_r($verifyDetail);
  7216. // die;
  7217. if (! empty ( $nowStaffList )) {
  7218. $nowStaff = implode ( ',', $nowStaffList );
  7219. $verifyStaff = array (
  7220. $this->staff [0] ['sid'] . "_R" => array (
  7221. 'date' => date ( 'Y-m-d' ),
  7222. 'opinion' => $opinion,
  7223. 'status' => $status,
  7224. 'nextStaff' => $verifyDetail [0] [0],
  7225. 'ROLE' => 1
  7226. )
  7227. );
  7228. } else {
  7229. $nowStaff = $verifyDetail [1] [0];
  7230. $verifyStaff = array (
  7231. $this->staff [0] ['sid'] . "_R" => array (
  7232. 'date' => date ( 'Y-m-d' ),
  7233. 'opinion' => $opinion,
  7234. 'status' => $status,
  7235. 'nextStaff' => $verifyDetail [1] [0]
  7236. )
  7237. );
  7238. }
  7239. } else {
  7240. if ($verifyDetail [1] [1] == 'ROLE') {
  7241. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  7242. // echo "dd";
  7243. foreach ( $vStaffString as $key => $value ) {
  7244. $staffK = explode ( "_", $value );
  7245. array_push ( $nowStaffList, $staffK [0] );
  7246. }
  7247. $nowStaff = implode ( ',', $nowStaffList );
  7248. $verifyStaff = array (
  7249. $this->staff [0] ['sid'] => array (
  7250. 'date' => date ( 'Y-m-d' ),
  7251. 'opinion' => $opinion,
  7252. 'status' => $status,
  7253. 'nextStaff' => $verifyDetail [1] [0],
  7254. 'ROLE' => 1
  7255. )
  7256. );
  7257. } else {
  7258. $nowStaff = $verifyDetail [1] [0];
  7259. $verifyStaff = array (
  7260. $this->staff [0] ['sid'] => array (
  7261. 'date' => date ( 'Y-m-d' ),
  7262. 'opinion' => $opinion,
  7263. 'status' => $status,
  7264. 'nextStaff' => $verifyDetail [1] [0]
  7265. )
  7266. );
  7267. }
  7268. }
  7269. if ($status == 3)
  7270. $verifyStaff = array (
  7271. 'final' => $status,
  7272. $this->staff [0] ['sid'] => array (
  7273. 'date' => date ( 'Y-m-d' ),
  7274. 'opinion' => $opinion,
  7275. 'status' => $status
  7276. )
  7277. );
  7278. $vStaffString = json_encode ( $verifyStaff );
  7279. $receipt->nowStaff = $nowStaff;
  7280. $receipt->verifyStaff = $vStaffString;
  7281. } else {
  7282. $VS = end ( $verifyStaff );
  7283. // 非角色审批
  7284. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  7285. $nextStaff = 0;
  7286. $roleSTF = false;
  7287. foreach ( $verifyDetail as $key => $value ) {
  7288. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  7289. if (isset ( $verifyDetail [$key + 1] )) {
  7290. $nextStaff = $verifyDetail [$key + 1] [0];
  7291. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  7292. $roleSTF = true;
  7293. }
  7294. break;
  7295. }
  7296. }
  7297. if (! $roleSTF) {
  7298. $nowStaff = $nextStaff;
  7299. $verifyStaff [$this->staff [0] ['sid']] = array (
  7300. 'date' => date ( 'Y-m-d' ),
  7301. 'opinion' => $opinion,
  7302. 'status' => $status,
  7303. 'nextStaff' => $nextStaff
  7304. );
  7305. } else {
  7306. // 获取角色下的所有用户ID
  7307. $nowStaffList = array ();
  7308. foreach ( $verifyDetail as $vfk ) {
  7309. if ($vfk [1] == 'ROLE') {
  7310. $vStaffString = json_decode ( $vfk [3] );
  7311. foreach ( $vStaffString as $key => $value ) {
  7312. $staffK = explode ( "_", $value );
  7313. array_push ( $nowStaffList, $staffK [0] );
  7314. }
  7315. }
  7316. }
  7317. $nowStaff = implode ( ',', $nowStaffList );
  7318. $verifyStaff [$this->staff [0] ['sid']] = array (
  7319. 'date' => date ( 'Y-m-d' ),
  7320. 'opinion' => $opinion,
  7321. 'status' => $status,
  7322. 'nextStaff' => $nextStaff,
  7323. 'ROLE' => 0
  7324. );
  7325. }
  7326. if ($status == 3) {
  7327. $verifyStaff ['final'] = $status;
  7328. $verifyStaff [$this->staff [0] ['sid']] = array (
  7329. 'date' => date ( 'Y-m-d' ),
  7330. 'opinion' => $opinion,
  7331. 'status' => $status
  7332. );
  7333. }
  7334. $vStaffString = json_encode ( $verifyStaff );
  7335. $receipt->nowStaff = $nowStaff;
  7336. $receipt->verifyStaff = $vStaffString;
  7337. }
  7338. // 角色审批
  7339. if (isset ( $VS ['ROLE'] )) {
  7340. // 找出角色人 当前审批角色组
  7341. $verifyJSStaff = array ();
  7342. $nowStaffList2 = array ();
  7343. foreach ( $verifyDetail as $key => $value ) {
  7344. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  7345. $verifyJSStaff = json_decode ( $value [3] );
  7346. foreach ( $verifyJSStaff as $m ) {
  7347. $staffK = explode ( "_", $m );
  7348. array_push ( $nowStaffList2, $staffK [0] );
  7349. }
  7350. // print_r($nowStaffList2);
  7351. }
  7352. }
  7353. $RoleVerifyStaff = array ();
  7354. foreach ( $verifyStaff as $key => $value ) {
  7355. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  7356. foreach ( $nowStaffList2 as $m ) {
  7357. if ($key == $m . "_R")
  7358. $RoleVerifyStaff [$key] = $value;
  7359. }
  7360. }
  7361. }
  7362. // print_r($verifyStaff);
  7363. // print_r($nowStaffList2);
  7364. // print_r($RoleVerifyStaff);
  7365. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  7366. // print_r($verifyJSStaff);
  7367. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  7368. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  7369. // 下一个审批人ID
  7370. $nextStaff = 0;
  7371. $falg = false;
  7372. foreach ( $verifyDetail as $key => $value ) {
  7373. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  7374. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  7375. $falg = true;
  7376. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  7377. $nowStaffList = array ();
  7378. foreach ( $vStaffString as $v ) {
  7379. $staffK = explode ( "_", $v );
  7380. array_push ( $nowStaffList, $staffK [0] );
  7381. }
  7382. $nowStaff = implode ( ',', $nowStaffList );
  7383. $nextStaff = $verifyDetail [$key + 1] [0];
  7384. } elseif (isset ( $verifyDetail [$key + 1] )) {
  7385. $nextStaff = $verifyDetail [$key + 1] [0];
  7386. $nowStaff = $nextStaff;
  7387. } else
  7388. $nowStaff = '';
  7389. break;
  7390. }
  7391. }
  7392. if ($falg)
  7393. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7394. 'date' => date ( 'Y-m-d' ),
  7395. 'opinion' => $opinion,
  7396. 'status' => $status,
  7397. 'nextStaff' => $nextStaff,
  7398. 'ROLE' => 1
  7399. );
  7400. else
  7401. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7402. 'date' => date ( 'Y-m-d' ),
  7403. 'opinion' => $opinion,
  7404. 'status' => $status,
  7405. 'nextStaff' => $nextStaff
  7406. );
  7407. // print_r($verifyStaff);
  7408. // echo $nowStaff;die;
  7409. } else { // 进入下一个角色或者审批人
  7410. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  7411. //
  7412. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  7413. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7414. 'date' => date ( 'Y-m-d' ),
  7415. 'opinion' => $opinion,
  7416. 'status' => $status,
  7417. 'nextStaff' => $VS ['nextStaff'],
  7418. 'ROLE' => 1
  7419. );
  7420. // print_r($verifyStaff);
  7421. // die;
  7422. }
  7423. if ($status == 3) {
  7424. $verifyStaff ['final'] = $status;
  7425. $verifyStaff [$this->staff [0] ['sid']] = array (
  7426. 'date' => date ( 'Y-m-d' ),
  7427. 'opinion' => $opinion,
  7428. 'status' => $status
  7429. );
  7430. }
  7431. $vStaffString = json_encode ( $verifyStaff );
  7432. $receipt->verifyStaff = $vStaffString;
  7433. $receipt->nowStaff = $nowStaff;
  7434. // die;
  7435. // }
  7436. // print_r($verifyStaff);
  7437. // die;
  7438. }
  7439. // print_r($verifyStaff);die;
  7440. }
  7441. // print_r($verifyDetail);
  7442. $roleKey = 0;
  7443. $roleId = 0;
  7444. $verifyDetailCopy = array ();
  7445. foreach ( $verifyDetail as $k => $v ) {
  7446. if ($v [1] == 'ROLE') {
  7447. $roleId = $v [0];
  7448. $roleVerify = json_decode ( $v [3], true );
  7449. $roleKey = $k;
  7450. $roleArray = array ();
  7451. foreach ( $roleVerify as $o => $p ) {
  7452. $staffID = explode ( '_', $p );
  7453. $exp = array (
  7454. 0 => $staffID [0],
  7455. 1 => $staffID [1]
  7456. );
  7457. array_push ( $roleArray, $exp );
  7458. }
  7459. $verifyDetailCopy [$v [0]] = $roleArray;
  7460. }
  7461. }
  7462. // print_r($verifyDetail);
  7463. foreach ( $verifyDetailCopy as $k => $v ) {
  7464. foreach ( $verifyDetail as $m => $n ) {
  7465. if ($n [0] == $k) {
  7466. array_splice ( $verifyDetail, $m, 1, $v );
  7467. }
  7468. }
  7469. }
  7470. // die;
  7471. // if (!empty($roleArray))
  7472. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  7473. // echo $roleId;
  7474. // print_r($verifyStaff);
  7475. // print_r($verifyDetail);
  7476. // die;
  7477. Doo::loadModel ( "receiptLog" );
  7478. $receiptLog = new receiptLog ();
  7479. // 审批日志
  7480. if (! isset ( $verifyStaff ['final'] )) {
  7481. if (! empty ( $roleId )) {
  7482. Doo::loadModel ( "role" );
  7483. $role = new role ();
  7484. $roleInfo = $role->getOne ( array (
  7485. 'where' => 'rid=' . $roleId,
  7486. 'asArray' => true
  7487. ) );
  7488. $receiptLog->rolename = $roleInfo ['name'];
  7489. }
  7490. $receiptLog->username = $this->staff [0] ['username'];
  7491. $receiptLog->uid = $this->staff [0] ['sid'];
  7492. $receiptLog->date = date ( "Y-m-d" );
  7493. $receiptLog->opinion = $opinion;
  7494. $receiptLog->img = $this->staff [0] ['avatar'];
  7495. $receiptLog->status = 1;
  7496. $receiptLog->rid = $rid;
  7497. $receiptLog->insert ();
  7498. }
  7499. if (isset ( $verifyStaff ['final'] )) { // rDetail
  7500. $receipt->verifyBreakup = $verifyString;
  7501. $receipt->status = 3;
  7502. $receiptDetailObj->status = 3;
  7503. $receiptDetailObj->update ( array (
  7504. 'where' => 'rid=' . $rid
  7505. ) );
  7506. if (! empty ( $roleId )) {
  7507. Doo::loadModel ( "role" );
  7508. $role = new role ();
  7509. $roleInfo = $role->getOne ( array (
  7510. 'where' => 'rid=' . $roleId,
  7511. 'asArray' => true
  7512. ) );
  7513. $receiptLog->rolename = $roleInfo ['name'];
  7514. }
  7515. $receiptLog->username = $this->staff [0] ['username'];
  7516. $receiptLog->uid = $this->staff [0] ['sid'];
  7517. $receiptLog->date = date ( "Y-m-d" );
  7518. $receiptLog->opinion = $opinion;
  7519. $receiptLog->img = $this->staff [0] ['avatar'];
  7520. $receiptLog->status = 3;
  7521. $receiptLog->rid = $rid;
  7522. $receiptLog->insert ();
  7523. // 微信企业号通知
  7524. $this->setWXMsg ( $rid, 3 );
  7525. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  7526. $receipt->status = 1;
  7527. $reviseSum = 0;
  7528. $receipt->verifyBreakup = $verifyString;
  7529. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  7530. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7531. foreach ( $reviseDetail as $key => $value ) {
  7532. $receiptDetailObj = new receiptDetail ();
  7533. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7534. $receiptDetailObj->item = $value ['description'];
  7535. $receiptDetailObj->itemCategory = "报销金额调整";
  7536. $receiptDetailObj->price = $value ['price'];
  7537. $receiptDetailObj->date = $receiptDetail ['date'];
  7538. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  7539. $receiptDetailObj->rid = $rid;
  7540. $receiptDetailObj->status = 1;
  7541. $receiptDetailObj->insert ();
  7542. $reviseSum += $value ['price'];
  7543. }
  7544. $itemStatistics = new itemStatistics ();
  7545. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7546. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7547. $itemStatistics->price = $reviseSum;
  7548. $itemStatistics->itemCategory = "报销金额调整";
  7549. $itemStatistics->date = $receiptDetail ['date'];
  7550. $itemStatistics->insert ();
  7551. }
  7552. $receiptDetailObj = new receiptDetail ();
  7553. $receiptDetailObj->status = 1;
  7554. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  7555. $receiptDetailObj->update ( array (
  7556. 'where' => 'rid=' . $rid
  7557. ) );
  7558. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7559. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7560. $stat = $statistics->getOne ( array (
  7561. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  7562. 'asArray' => true
  7563. ) );
  7564. if (empty ( $stat )) {
  7565. $statistics->date = $receiptDetail ['date'];
  7566. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7567. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7568. $statistics->agPrice = $receiptDetail ['sum'];
  7569. $statistics->rePrice = $reviseSum;
  7570. $statistics->insert ();
  7571. } else {
  7572. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  7573. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  7574. $statistics->update ( array (
  7575. 'where' => 'sid=' . $stat ['sid']
  7576. ) );
  7577. }
  7578. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7579. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7580. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  7581. foreach ( $accountItem ['cSum'] as $key => $value ) {
  7582. if ($key == "agencySum") {
  7583. $iStatistics = $itemStatistics->getOne ( array (
  7584. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  7585. 'asArray' => true
  7586. ) );
  7587. if (empty ( $iStatistics )) {
  7588. $itemStatistics->cid = $receiptDetail ['cid'];
  7589. ;
  7590. $itemStatistics->staff = $receiptDetail ['staff'];
  7591. $itemStatistics->price = $value;
  7592. $itemStatistics->itemCategory = $this->AGENCY;
  7593. $itemStatistics->date = $receiptDetail ['date'];
  7594. $itemStatistics->insert ();
  7595. } else {
  7596. if (! empty ( $value )) {
  7597. $itemStatistics->price = $value + $iStatistics ['price'];
  7598. $itemStatistics->update ( array (
  7599. 'where' => 'sid=' . $iStatistics ['sid']
  7600. ) );
  7601. }
  7602. }
  7603. } elseif ($key == "travelSum") {
  7604. $iStatistics = $itemStatistics->getOne ( array (
  7605. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  7606. 'asArray' => true
  7607. ) );
  7608. if (empty ( $iStatistics )) {
  7609. $itemStatistics->cid = $receiptDetail ['cid'];
  7610. $itemStatistics->staff = $receiptDetail ['staff'];
  7611. $itemStatistics->price = $value;
  7612. $itemStatistics->itemCategory = $this->TRAVEL;
  7613. $itemStatistics->date = $receiptDetail ['date'];
  7614. $itemStatistics->insert ();
  7615. } else {
  7616. if (! empty ( $value )) {
  7617. $itemStatistics->price = $value + $iStatistics ['price'];
  7618. $itemStatistics->update ( array (
  7619. 'where' => 'sid=' . $iStatistics ['sid']
  7620. ) );
  7621. }
  7622. }
  7623. } elseif ($key == "trainSum") {
  7624. $iStatistics = $itemStatistics->getOne ( array (
  7625. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  7626. 'asArray' => true
  7627. ) );
  7628. if (empty ( $iStatistics )) {
  7629. $itemStatistics->cid = $receiptDetail ['cid'];
  7630. $itemStatistics->staff = $receiptDetail ['staff'];
  7631. $itemStatistics->price = $value;
  7632. $itemStatistics->itemCategory = $this->TRAIN;
  7633. $itemStatistics->date = $receiptDetail ['date'];
  7634. $itemStatistics->insert ();
  7635. } else {
  7636. if (! empty ( $value )) {
  7637. $itemStatistics->price = $value + $iStatistics ['price'];
  7638. $itemStatistics->update ( array (
  7639. 'where' => 'sid=' . $iStatistics ['sid']
  7640. ) );
  7641. }
  7642. }
  7643. } elseif ($key == "otherSum") {
  7644. $iStatistics = $itemStatistics->getOne ( array (
  7645. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  7646. 'asArray' => true
  7647. ) );
  7648. if (empty ( $iStatistics )) {
  7649. $itemStatistics->cid = $receiptDetail ['cid'];
  7650. $itemStatistics->staff = $receiptDetail ['staff'];
  7651. $itemStatistics->price = $value;
  7652. $itemStatistics->itemCategory = $this->OTHER;
  7653. $itemStatistics->date = $receiptDetail ['date'];
  7654. $itemStatistics->insert ();
  7655. } else {
  7656. if (! empty ( $value )) {
  7657. $itemStatistics->price = $value + $iStatistics ['price'];
  7658. $itemStatistics->update ( array (
  7659. 'where' => 'sid=' . $iStatistics ['sid']
  7660. ) );
  7661. }
  7662. }
  7663. }
  7664. }
  7665. $receipt->pastDate = date ( "Y-m-d" );
  7666. // 微信企业号通知
  7667. $this->setWXMsg ( $rid, 1 );
  7668. }
  7669. $receipt->amount = $amount;
  7670. $receipt->update ( array (
  7671. 'where' => ' rid = ' . $rid
  7672. ) );
  7673. // 进入下一条审批费用新加需求
  7674. $vidList = array ();
  7675. $verifyDetail = $verify->find ( array (
  7676. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  7677. 'asArray' => true
  7678. ) );
  7679. foreach ( $verifyDetail as $key => $value ) {
  7680. array_push ( $vidList, $value ['vid'] );
  7681. }
  7682. $vid = implode ( ",", $vidList );
  7683. if (empty ( $verifyDetail ))
  7684. $vid = 0;
  7685. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  7686. $receipt = new receipt ();
  7687. $rd = $receipt->getOne ( array (
  7688. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  7689. 'asc' => 'rid',
  7690. 'asArray' => true
  7691. ) );
  7692. if (empty ( $rd )) {
  7693. return '/approvalExpenses/pendApproval';
  7694. }
  7695. if ($rd ['Rtype'] == 1) {
  7696. if ($rd ['isBK'] == 1) {
  7697. return '/receiptburEdi/' . $rd ['rid'];
  7698. } else {
  7699. return '/expensesEdi/' . $rd ['rid'];
  7700. }
  7701. } elseif ($rd ['Rtype'] == 2) {
  7702. return '/remitApproval/' . $rd ['rid'];
  7703. } else {
  7704. return '/receiptburEdi/' . $rd ['rid'];
  7705. }
  7706. // return "/approvalExpenses/pendApproval";
  7707. }
  7708. }
  7709. function expensesRetreats() {
  7710. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7711. if (! empty ( $rid )) {
  7712. // 操作记录
  7713. Doo::loadModel ( "receipt" );
  7714. $receipt = new receipt ();
  7715. Doo::loadModel ( "receiptLog" );
  7716. $receiptLog = new receiptLog ();
  7717. Doo::loadModel ( "verify" );
  7718. $verify = new verify ();
  7719. $receiptInfo = $receipt->getOne ( array (
  7720. 'where' => 'rid=' . $rid,
  7721. 'asArray' => true
  7722. ) );
  7723. $vr = $verify->getOne ( array (
  7724. 'where' => 'vid=' . $receiptInfo ['verify'],
  7725. 'asArray' => true
  7726. ) );
  7727. $jd = json_decode ( $vr ['staff'] );
  7728. $roleId = 0;
  7729. foreach ( $jd as $key => $value ) {
  7730. if ($value [1] == 'ROLE') {
  7731. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7732. if ($pos !== false) {
  7733. $roleId = $value [0];
  7734. }
  7735. }
  7736. }
  7737. // 审批日志
  7738. // echo $roleId;die;
  7739. if (! empty ( $roleId )) {
  7740. Doo::loadModel ( "role" );
  7741. $role = new role ();
  7742. $roleInfo = $role->getOne ( array (
  7743. 'where' => 'rid=' . $roleId,
  7744. 'asArray' => true
  7745. ) );
  7746. $receiptLog->rolename = $roleInfo ['name'];
  7747. }
  7748. $receiptLog->username = $this->staff [0] ['username'];
  7749. $receiptLog->uid = $this->staff [0] ['sid'];
  7750. $receiptLog->date = date ( "Y-m-d" );
  7751. $receiptLog->opinion = '撤回';
  7752. $receiptLog->img = $this->staff [0] ['avatar'];
  7753. $receiptLog->status = 4;
  7754. $receiptLog->rid = $rid;
  7755. $receiptLog->insert ();
  7756. $receipt->status = 4;
  7757. $receipt->update ( array (
  7758. 'where' => 'rid=' . $rid
  7759. ) );
  7760. // 微信企业号通知
  7761. $this->setWXMsg ( $rid, 2 );
  7762. }
  7763. // echo "ddd";
  7764. return '/approvalExpenses/pendApproval';
  7765. }
  7766. function updateCheReceipt() {
  7767. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7768. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7769. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  7770. if (! empty ( $rid )) {
  7771. // 操作记录
  7772. Doo::loadModel ( "receipt" );
  7773. $receipt = new receipt ();
  7774. Doo::loadModel ( "receiptLog" );
  7775. $receiptLog = new receiptLog ();
  7776. Doo::loadModel ( "verify" );
  7777. $verify = new verify ();
  7778. $receiptInfo = $receipt->getOne ( array (
  7779. 'where' => 'rid=' . $rid . ' and status=2',
  7780. 'asArray' => true
  7781. ) );
  7782. if (empty ( $receiptInfo )) {
  7783. echo json_encode ( array (
  7784. 'status' => 2
  7785. ) );
  7786. die ();
  7787. }
  7788. $vr = $verify->getOne ( array (
  7789. 'where' => 'vid=' . $receiptInfo ['verify'],
  7790. 'asArray' => true
  7791. ) );
  7792. $jd = json_decode ( $vr ['staff'] );
  7793. $roleId = 0;
  7794. foreach ( $jd as $key => $value ) {
  7795. if ($value [1] == 'ROLE') {
  7796. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7797. if ($pos !== false) {
  7798. $roleId = $value [0];
  7799. }
  7800. }
  7801. }
  7802. // 审批日志
  7803. // echo $roleId;die;
  7804. if (! empty ( $roleId )) {
  7805. Doo::loadModel ( "role" );
  7806. $role = new role ();
  7807. $roleInfo = $role->getOne ( array (
  7808. 'where' => 'rid=' . $roleId,
  7809. 'asArray' => true
  7810. ) );
  7811. $receiptLog->rolename = $roleInfo ['name'];
  7812. }
  7813. $receiptLog->username = $this->staff [0] ['username'];
  7814. $receiptLog->uid = $this->staff [0] ['sid'];
  7815. $receiptLog->date = date ( "Y-m-d" );
  7816. $receiptLog->opinion = $opinion;
  7817. $receiptLog->img = $this->staff [0] ['avatar'];
  7818. $receiptLog->status = 4;
  7819. $receiptLog->rid = $rid;
  7820. $receiptLog->insert ();
  7821. $receipt->status = 4;
  7822. $receipt->update ( array (
  7823. 'where' => 'rid=' . $rid
  7824. ) );
  7825. // 微信企业号通知
  7826. $this->setWXMsg ( $rid, 2 );
  7827. echo json_encode ( array (
  7828. 'status' => 1
  7829. ) );
  7830. // Header("HTTP/1.1 303 See Other");
  7831. // Header("Location: /approvalExpenses/pendApproval");
  7832. die ();
  7833. }
  7834. echo json_encode ( array (
  7835. 'status' => 2
  7836. ) );
  7837. die ();
  7838. // echo "ddd";
  7839. // return '/saeaBorad';
  7840. }
  7841. function revisePrice() {
  7842. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  7843. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  7844. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7845. // echo $price;die;
  7846. if (! empty ( $rid )) {
  7847. Doo::loadModel ( "receipt" );
  7848. $receipt = new receipt ();
  7849. $receiptDetail = $receipt->getOne ( array (
  7850. 'where' => 'rid=' . $rid . ' and status=2 ',
  7851. 'asArray' => true
  7852. ) );
  7853. if (empty ( $receiptDetail ))
  7854. die ( 'illegal request' );
  7855. $reviseDetail = array ();
  7856. if (empty ( $receiptDetail ['reviseDetail'] )) {
  7857. array_push ( $reviseDetail, array (
  7858. 'sid' => $this->staff [0] ['sid'],
  7859. 'name' => $this->staff [0] ['username'],
  7860. 'description' => $description,
  7861. 'price' => $price
  7862. ) );
  7863. $reviseDetailString = json_encode ( $reviseDetail );
  7864. $receipt->reviseDetail = $reviseDetailString;
  7865. $receipt->revisePrice = $price;
  7866. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7867. } else {
  7868. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7869. array_push ( $reviseDetail, array (
  7870. 'sid' => $this->staff [0] ['sid'],
  7871. 'name' => $this->staff [0] ['username'],
  7872. 'description' => $description,
  7873. 'price' => $price
  7874. ) );
  7875. $reviseDetailString = json_encode ( $reviseDetail );
  7876. $receipt->reviseDetail = $reviseDetailString;
  7877. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  7878. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7879. }
  7880. $receipt->update ( array (
  7881. 'where' => 'rid=' . $rid
  7882. ) );
  7883. if ($receiptDetail ['Rtype'] == 1) {
  7884. if ($receiptDetail ['isBK'] == 1) {
  7885. return '/receiptburEdi/' . $receiptDetail ['rid'];
  7886. }
  7887. } elseif ($receiptDetail ['Rtype'] == 2) {
  7888. } else {
  7889. return '/receiptburEdi/' . $receiptDetail ['rid'];
  7890. }
  7891. }
  7892. die ( 'illegal request' );
  7893. }
  7894. function personalCollect() {
  7895. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7896. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  7897. $this->showCache ( $path );
  7898. Doo::loadModel ( "receiptDetail" );
  7899. Doo::loadModel ( "itemStatistics" );
  7900. Doo::loadModel ( 'statistics' );
  7901. $statistics = new statistics ();
  7902. $itemStatistics = new itemStatistics ();
  7903. $receiptDetail = new receiptDetail ();
  7904. $receiptCollectList = $receiptDetail->find ( array (
  7905. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7906. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7907. 'groupby' => 'itemCategory,Month(date)',
  7908. 'asArray' => true
  7909. ) );
  7910. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  7911. 'where' => 'staff=' . $this->staff [0] ['sid'],
  7912. 'asArray' => true
  7913. ) );
  7914. // create collect html
  7915. $collectArray = array (
  7916. '日常相关费用' => array (),
  7917. '差旅相关费用' => array (),
  7918. '培训班费用' => array (),
  7919. '其他' => array ()
  7920. );
  7921. $adjustment = array ();
  7922. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  7923. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7924. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  7925. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7926. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  7927. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7928. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  7929. array_push ( $collectArray ['其他'], $collectHtml );
  7930. $data ['collectArray'] = $collectArray;
  7931. // statistics html
  7932. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7933. if (empty ( $stList ))
  7934. $stList = array (
  7935. 'rePrice' => 0,
  7936. 'agPrice' => 0
  7937. );
  7938. $data ['stList'] = array (
  7939. 'rePrice' => $stList ['rePrice'],
  7940. 'agPrice' => $stList ['agPrice'],
  7941. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7942. );
  7943. // Adjustment price html
  7944. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7945. array_push ( $adjustment, $collectHtml );
  7946. $data ['adjustment'] = $adjustment;
  7947. // total price html
  7948. $collectHtml = "";
  7949. $total = 0;
  7950. for($i = 1; $i <= 12; $i ++) {
  7951. $sumPrice = 0;
  7952. foreach ( $receiptCollectList as $key => $value ) {
  7953. if ($value ['month'] == $i) {
  7954. $sumPrice += $value ['price'];
  7955. }
  7956. }
  7957. if ($sumPrice == 0)
  7958. $collectHtml .= '<td class="taR">-</td>';
  7959. else
  7960. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7961. $total += $sumPrice;
  7962. }
  7963. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7964. $data ['totalPrice'] = $collectHtml;
  7965. $dateHtml = "";
  7966. $now = date ( "Y" );
  7967. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  7968. if ($YEARD <= $now) {
  7969. $dateHtml .= '<option ';
  7970. if ($year == $YEARD) {
  7971. $dateHtml .= 'selected ';
  7972. }
  7973. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  7974. }
  7975. }
  7976. $data ['dateHtml'] = $dateHtml;
  7977. $data ['year'] = $year;
  7978. $data ['totalYear'] = $total;
  7979. $data ['memu'] = "receipt";
  7980. $data ['staff'] = $this->staff;
  7981. $data ['receiptMemu'] = 'personalCollect';
  7982. $data ['verifyId'] = $this->verifyId;
  7983. $data ['executeId'] = $this->executeId;
  7984. // year staff status 2,4
  7985. if ($year < date ( "Y" )) {
  7986. Doo::loadModel ( 'receipt' );
  7987. $receipt = new receipt ();
  7988. $receiptList = $receipt->find ( array (
  7989. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7990. 'asArray' => true
  7991. ) );
  7992. if (empty ( $receiptList )) {
  7993. ob_start ();
  7994. $this->render ( "/admin/saea_slist_collect", $data );
  7995. $this->cacheFile ( $path );
  7996. die ();
  7997. }
  7998. }
  7999. $this->render ( "/admin/saea_slist_collect", $data );
  8000. }
  8001. function personalCollectDetail() {
  8002. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8003. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  8004. $this->showCache ( $path );
  8005. Doo::loadModel ( "receiptDetail" );
  8006. Doo::loadModel ( "itemStatistics" );
  8007. Doo::loadModel ( 'statistics' );
  8008. Doo::loadModel ( 'accountItem' );
  8009. $accountItem = new accountItem ();
  8010. $statistics = new statistics ();
  8011. $itemStatistics = new itemStatistics ();
  8012. $receiptDetail = new receiptDetail ();
  8013. $receiptCollectList = $receiptDetail->find ( array (
  8014. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  8015. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  8016. 'groupby' => 'item,Month(date)',
  8017. 'asArray' => true
  8018. ) );
  8019. $accountList = $accountItem->find ( array (
  8020. 'asArray' => true
  8021. ) );
  8022. // create CollectDetail HTML
  8023. $collectHtml = array ();
  8024. foreach ( $accountList as $key => $value ) {
  8025. $html = "";
  8026. $asum = 0;
  8027. for($i = 1; $i <= 12; $i ++) {
  8028. $falg = true;
  8029. foreach ( $receiptCollectList as $v ) {
  8030. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  8031. $asum += $v ['price'];
  8032. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8033. $falg = false;
  8034. break;
  8035. }
  8036. }
  8037. if ($falg)
  8038. $html .= '<td class="taR">-</td>';
  8039. }
  8040. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8041. $collectHtml [$value ['category']] [$value ['name']] = $html;
  8042. }
  8043. $data ['collectHtml'] = $collectHtml;
  8044. // create Adjustment price html
  8045. $receiptCollectList = $receiptDetail->find ( array (
  8046. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  8047. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  8048. 'groupby' => 'itemCategory,Month(date)',
  8049. 'asArray' => true
  8050. ) );
  8051. $adjustment = array ();
  8052. $collectArray = array (
  8053. '日常相关费用' => array (),
  8054. '差旅相关费用' => array (),
  8055. '培训班费用' => array (),
  8056. '其他' => array ()
  8057. );
  8058. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  8059. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  8060. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  8061. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  8062. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  8063. array_push ( $collectArray ['培训班费用'], $collectHtml );
  8064. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  8065. array_push ( $collectArray ['其他'], $collectHtml );
  8066. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  8067. array_push ( $adjustment, $collectHtml );
  8068. // total price html
  8069. $collectHtml = "";
  8070. $total = 0;
  8071. for($i = 1; $i <= 12; $i ++) {
  8072. $sumPrice = 0;
  8073. foreach ( $receiptCollectList as $key => $value ) {
  8074. if ($value ['month'] == $i) {
  8075. $sumPrice += $value ['price'];
  8076. }
  8077. }
  8078. if ($sumPrice == 0)
  8079. $collectHtml .= '<td class="taR">-</td>';
  8080. else
  8081. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8082. $total += $sumPrice;
  8083. }
  8084. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8085. // statistics html
  8086. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  8087. if (empty ( $stList ))
  8088. $stList = array (
  8089. 'rePrice' => 0,
  8090. 'agPrice' => 0
  8091. );
  8092. $data ['stList'] = array (
  8093. 'rePrice' => $stList ['rePrice'],
  8094. 'agPrice' => $stList ['agPrice'],
  8095. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8096. );
  8097. $data ['collectArray'] = $collectArray;
  8098. $data ['adjustment'] = $adjustment;
  8099. $data ['totalPrice'] = $collectHtml;
  8100. $data ['totalYear'] = $total;
  8101. $data ['year'] = $year;
  8102. $dateHtml = "";
  8103. $now = date ( "Y" );
  8104. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  8105. if ($YEARD <= $now) {
  8106. $dateHtml .= '<option ';
  8107. if ($year == $YEARD) {
  8108. $dateHtml .= 'selected ';
  8109. }
  8110. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  8111. }
  8112. }
  8113. $data ['dateHtml'] = $dateHtml;
  8114. $data ['memu'] = "receipt";
  8115. $data ['staff'] = $this->staff;
  8116. $data ['receiptMemu'] = 'personalCollect';
  8117. $data ['verifyId'] = $this->verifyId;
  8118. $data ['executeId'] = $this->executeId;
  8119. // year staff status 2,4
  8120. if ($year < date ( "Y" )) {
  8121. Doo::loadModel ( 'receipt' );
  8122. $receipt = new receipt ();
  8123. $receiptList = $receipt->find ( array (
  8124. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  8125. 'asArray' => true
  8126. ) );
  8127. if (empty ( $receiptList )) {
  8128. ob_start ();
  8129. $this->render ( "/admin/saeaCollectArticles", $data );
  8130. $this->cacheFile ( $path );
  8131. die ();
  8132. }
  8133. }
  8134. $this->render ( "/admin/saeaCollectArticles", $data );
  8135. }
  8136. function companyCategoryCollect() {
  8137. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8138. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  8139. $this->showCache ( $path );
  8140. Doo::loadModel ( 'L_category' );
  8141. Doo::loadModel ( 'itemStatistics' );
  8142. Doo::loadModel ( 'statistics' );
  8143. $statistics = new statistics ();
  8144. $Lcategory = new L_category ();
  8145. $itemStatistics = new itemStatistics ();
  8146. Doo::loadModel ( "receiptAuthorityManage" );
  8147. $receiptAuthorityManage = new receiptAuthorityManage ();
  8148. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  8149. $cidList = array ();
  8150. foreach ( $imcStaff as $key => $value ) {
  8151. array_push ( $cidList, $value ['cid'] );
  8152. }
  8153. $cidString = implode ( ',', $cidList );
  8154. $LcategoryList = $Lcategory->find ( array (
  8155. 'where' => ' cid in (' . $cidString . ')',
  8156. 'asArray' => true
  8157. ) ); // 'staff='.$this->staff[0]['sid']." and
  8158. $itemStatisticsList = $itemStatistics->find ( array (
  8159. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8160. 'where' => " Year(date)=" . $year,
  8161. 'groupby' => 'cid,Month(date)',
  8162. 'asArray' => true
  8163. ) );
  8164. // ceatre companyCollectHtml
  8165. foreach ( $LcategoryList as $value ) {
  8166. $html = "";
  8167. $asum = 0;
  8168. for($i = 1; $i <= 12; $i ++) {
  8169. $falg = true;
  8170. foreach ( $itemStatisticsList as $v ) {
  8171. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  8172. $asum += $v ['price'];
  8173. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8174. $falg = false;
  8175. break;
  8176. }
  8177. }
  8178. if ($falg)
  8179. $html .= '<td class="taR">-</td>';
  8180. }
  8181. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8182. $collectHtml [$value ['title']] = array (
  8183. 'html' => $html,
  8184. 'cid' => $value ['cid']
  8185. );
  8186. }
  8187. $data ['companyHtml'] = $collectHtml;
  8188. // total price html
  8189. $collectHtml = "";
  8190. $total = 0;
  8191. for($i = 1; $i <= 12; $i ++) {
  8192. $sumPrice = 0;
  8193. foreach ( $itemStatisticsList as $key => $value ) {
  8194. if ($value ['month'] == $i) {
  8195. $sumPrice += $value ['price'];
  8196. }
  8197. }
  8198. if ($sumPrice == 0)
  8199. $collectHtml .= '<td class="taR">-</td>';
  8200. else
  8201. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8202. $total += $sumPrice;
  8203. }
  8204. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8205. $data ['companyTotalHtml'] = $collectHtml;
  8206. $data ['total'] = $total;
  8207. // statistics html
  8208. // echo $cidString;
  8209. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  8210. if (empty ( $stList ))
  8211. $stList = array (
  8212. 'rePrice' => 0,
  8213. 'agPrice' => 0
  8214. );
  8215. $data ['stList'] = array (
  8216. 'rePrice' => $stList ['rePrice'],
  8217. 'agPrice' => $stList ['agPrice'],
  8218. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8219. );
  8220. $data ['year'] = $year;
  8221. $data ['memu'] = "receipt";
  8222. $data ['staff'] = $this->staff;
  8223. $data ['receiptMemu'] = 'companyCategoryCollect';
  8224. $data ['verifyId'] = $this->verifyId;
  8225. $data ['executeId'] = $this->executeId;
  8226. $dateHtml = "";
  8227. $now = date ( "Y" );
  8228. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  8229. if ($YEARD <= $now) {
  8230. $dateHtml .= '<option ';
  8231. if ($year == $YEARD) {
  8232. $dateHtml .= 'selected ';
  8233. }
  8234. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  8235. }
  8236. }
  8237. $data ['dateHtml'] = $dateHtml;
  8238. // year staff status 2,4
  8239. if ($year < date ( "Y" )) {
  8240. Doo::loadModel ( 'receipt' );
  8241. $receipt = new receipt ();
  8242. $receiptList = $receipt->find ( array (
  8243. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  8244. 'asArray' => true
  8245. ) );
  8246. if (empty ( $receiptList )) {
  8247. ob_start ();
  8248. $this->render ( "/admin/saeaCompanyCollect", $data );
  8249. $this->cacheFile ( $path );
  8250. die ();
  8251. }
  8252. }
  8253. $this->render ( "/admin/saeaCompanyCollect", $data );
  8254. }
  8255. function categoryCollectDetail() {
  8256. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8257. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  8258. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  8259. $this->showCache ( $path );
  8260. Doo::loadModel ( 'statistics' );
  8261. $statistics = new statistics ();
  8262. Doo::loadModel ( "receiptDetail" );
  8263. $receiptDetail = new receiptDetail ();
  8264. Doo::loadModel ( 'L_category' );
  8265. $Lcategory = new L_category ();
  8266. Doo::loadModel ( 'accountItem' );
  8267. $accountItem = new accountItem ();
  8268. Doo::loadModel ( "receiptAuthorityManage" );
  8269. $receiptAuthorityManage = new receiptAuthorityManage ();
  8270. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  8271. $cidList = array ();
  8272. foreach ( $imcStaff as $key => $value ) {
  8273. array_push ( $cidList, $value ['cid'] );
  8274. }
  8275. $cidString = implode ( ',', $cidList );
  8276. $LcategoryList = $Lcategory->find ( array (
  8277. 'where' => 'cid in (' . $cidString . ')',
  8278. 'asArray' => true
  8279. ) );
  8280. if ($cid == 0) {
  8281. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  8282. if ($cid == 0)
  8283. $cid = $LcategoryList [0] ['cid'];
  8284. }
  8285. $data ['LcategoryList'] = $LcategoryList;
  8286. $receiptCollectList = $receiptDetail->find ( array (
  8287. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8288. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  8289. 'groupby' => 'item,Month(pastDate)',
  8290. 'asArray' => true
  8291. ) );
  8292. $accountList = $accountItem->find ( array (
  8293. 'asArray' => true
  8294. ) );
  8295. // create CollectDetail HTML
  8296. $collectHtml = array ();
  8297. foreach ( $accountList as $key => $value ) {
  8298. $html = "";
  8299. $asum = 0;
  8300. for($i = 1; $i <= 12; $i ++) {
  8301. $falg = true;
  8302. foreach ( $receiptCollectList as $v ) {
  8303. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  8304. $asum += $v ['price'];
  8305. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8306. $falg = false;
  8307. break;
  8308. }
  8309. }
  8310. if ($falg)
  8311. $html .= '<td class="taR">-</td>';
  8312. }
  8313. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8314. $collectHtml [$value ['category']] [$value ['name']] = $html;
  8315. }
  8316. $data ['collectHtml'] = $collectHtml;
  8317. // create Adjustment price html
  8318. $receiptCollectList = $receiptDetail->find ( array (
  8319. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  8320. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  8321. 'groupby' => 'itemCategory,Month(pastDate)',
  8322. 'asArray' => true
  8323. ) );
  8324. $adjustment = array ();
  8325. $collectArray = array (
  8326. '日常相关费用' => array (),
  8327. '差旅相关费用' => array (),
  8328. '培训班费用' => array (),
  8329. '其他' => array ()
  8330. );
  8331. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  8332. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  8333. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  8334. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  8335. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  8336. array_push ( $collectArray ['培训班费用'], $collectHtml );
  8337. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  8338. array_push ( $collectArray ['其他'], $collectHtml );
  8339. $data ['collectArray'] = $collectArray;
  8340. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  8341. array_push ( $adjustment, $collectHtml );
  8342. $data ['adjustment'] = $adjustment;
  8343. // total price html
  8344. $collectHtml = "";
  8345. $total = 0;
  8346. for($i = 1; $i <= 12; $i ++) {
  8347. $sumPrice = 0;
  8348. foreach ( $receiptCollectList as $key => $value ) {
  8349. if ($value ['month'] == $i) {
  8350. $sumPrice += $value ['price'];
  8351. }
  8352. }
  8353. if ($sumPrice == 0)
  8354. $collectHtml .= '<td class="taR">-</td>';
  8355. else
  8356. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8357. $total += $sumPrice;
  8358. }
  8359. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8360. // statistics html
  8361. $stList = $statistics->statisticsByCid ( $year, $cid );
  8362. if (empty ( $stList ))
  8363. $stList = array (
  8364. 'rePrice' => 0,
  8365. 'agPrice' => 0
  8366. );
  8367. $data ['stList'] = array (
  8368. 'rePrice' => $stList ['rePrice'],
  8369. 'agPrice' => $stList ['agPrice'],
  8370. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8371. );
  8372. $data ['totalYear'] = $total;
  8373. $data ['year'] = $year;
  8374. $data ['cid'] = $cid;
  8375. $data ['memu'] = "receipt";
  8376. $data ['staff'] = $this->staff;
  8377. $data ['receiptMemu'] = 'companyCategoryCollect';
  8378. $data ['verifyId'] = $this->verifyId;
  8379. $data ['executeId'] = $this->executeId;
  8380. // year staff status 2,4
  8381. if ($year < date ( "Y" )) {
  8382. Doo::loadModel ( 'receipt' );
  8383. $receipt = new receipt ();
  8384. $receiptList = $receipt->find ( array (
  8385. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  8386. 'asArray' => true
  8387. ) );
  8388. if (empty ( $receiptList )) {
  8389. ob_start ();
  8390. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  8391. $this->cacheFile ( $path );
  8392. die ();
  8393. }
  8394. }
  8395. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  8396. }
  8397. function staffCollect() {
  8398. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8399. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  8400. // $this->showCache($path);
  8401. Doo::loadModel ( 'statistics' );
  8402. $statistics = new statistics ();
  8403. Doo::loadModel ( "receiptDetail" );
  8404. $receiptDetail = new receiptDetail ();
  8405. Doo::loadModel ( 'L_category' );
  8406. $Lcategory = new L_category ();
  8407. Doo::loadModel ( 'accountItem' );
  8408. $accountItem = new accountItem ();
  8409. Doo::loadModel ( 'staff' );
  8410. $staff = new staff ();
  8411. Doo::loadModel ( 'itemStatistics' );
  8412. $itemStatistics = new itemStatistics ();
  8413. Doo::loadModel ( "receiptAuthorityManage" );
  8414. $receiptAuthorityManage = new receiptAuthorityManage ();
  8415. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  8416. $cidList = array ();
  8417. foreach ( $imcStaff as $key => $value ) {
  8418. array_push ( $cidList, $value ['cid'] );
  8419. }
  8420. $cidString = implode ( ',', $cidList );
  8421. // statistics html
  8422. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  8423. if (empty ( $stList ))
  8424. $stList = array (
  8425. 'rePrice' => 0,
  8426. 'agPrice' => 0
  8427. );
  8428. $data ['stList'] = array (
  8429. 'rePrice' => $stList ['rePrice'],
  8430. 'agPrice' => $stList ['agPrice'],
  8431. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8432. );
  8433. // ---
  8434. $staffList = $staff->find ( array (
  8435. 'where' => 'username !="admin"',
  8436. 'asArray' => true
  8437. ) );
  8438. $LcategoryList = $Lcategory->find ( array (
  8439. 'asArray' => true
  8440. ) ); // 'staff='.$this->staff[0]['sid']." and
  8441. $itemStatisticsList = $itemStatistics->find ( array (
  8442. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8443. 'where' => " Year(date)=" . $year . ' and cid in (' . $cidString . ')',
  8444. 'groupby' => 'staff,Month(date)',
  8445. 'asArray' => true
  8446. ) );
  8447. $categoryList = $staff->find ( array (
  8448. 'select' => 'COUNT(*) as count,cid,category',
  8449. 'where' => 'username !="admin" and cid in (' . $cidString . ')',
  8450. 'groupby' => 'cid',
  8451. 'asArray' => true
  8452. ) );
  8453. // print_r($itemStatisticsList);die;
  8454. // ceatre companyCollectHtml
  8455. foreach ( $categoryList as $vlu ) {
  8456. $count = $vlu ['count'] + 1;
  8457. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  8458. $m1 = 0;
  8459. $m2 = 0;
  8460. $m3 = 0;
  8461. $m4 = 0;
  8462. $m5 = 0;
  8463. $m6 = 0;
  8464. $m7 = 0;
  8465. $m8 = 0;
  8466. $m9 = 0;
  8467. $m10 = 0;
  8468. $m11 = 0;
  8469. $m12 = 0;
  8470. $m13 = 0;
  8471. foreach ( $staffList as $value ) {
  8472. if ($vlu ['cid'] == $value ['cid']) {
  8473. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  8474. $asum = 0;
  8475. for($i = 1; $i <= 12; $i ++) {
  8476. $falg = true;
  8477. foreach ( $itemStatisticsList as $v ) {
  8478. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  8479. if ($v ['month'] == 1)
  8480. $m1 += $v ['price'];
  8481. if ($v ['month'] == 2)
  8482. $m2 += $v ['price'];
  8483. if ($v ['month'] == 3)
  8484. $m3 += $v ['price'];
  8485. if ($v ['month'] == 4)
  8486. $m4 += $v ['price'];
  8487. if ($v ['month'] == 5)
  8488. $m5 += $v ['price'];
  8489. if ($v ['month'] == 6)
  8490. $m6 += $v ['price'];
  8491. if ($v ['month'] == 7)
  8492. $m7 += $v ['price'];
  8493. if ($v ['month'] == 8)
  8494. $m8 += $v ['price'];
  8495. if ($v ['month'] == 9)
  8496. $m9 += $v ['price'];
  8497. if ($v ['month'] == 10)
  8498. $m10 += $v ['price'];
  8499. if ($v ['month'] == 11)
  8500. $m11 += $v ['price'];
  8501. if ($v ['month'] == 12)
  8502. $m12 += $v ['price'];
  8503. $asum += $v ['price'];
  8504. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8505. $falg = false;
  8506. break;
  8507. }
  8508. }
  8509. if ($falg)
  8510. $html .= '<td class="taR">-</td>';
  8511. }
  8512. $m13 += $asum;
  8513. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8514. $collectHtml [$value ['username'] . '_' . $value ['sid']] = array (
  8515. 'html' => $html,
  8516. 'sid' => $value ['sid']
  8517. );
  8518. $html = "";
  8519. }
  8520. }
  8521. $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>
  8522. <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>
  8523. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  8524. $collectHtml [$vlu ['cid']] = array (
  8525. 'html' => $hl,
  8526. 'sid' => ''
  8527. );
  8528. }
  8529. $data ['companyHtml'] = $collectHtml;
  8530. // total price html
  8531. $collectHtml = "";
  8532. $total = 0;
  8533. for($i = 1; $i <= 12; $i ++) {
  8534. $sumPrice = 0;
  8535. foreach ( $itemStatisticsList as $key => $value ) {
  8536. if ($value ['month'] == $i) {
  8537. $sumPrice += $value ['price'];
  8538. }
  8539. }
  8540. if ($sumPrice == 0)
  8541. $collectHtml .= '<td class="taR">-</td>';
  8542. else
  8543. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8544. $total += $sumPrice;
  8545. }
  8546. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8547. $data ['companyTotalHtml'] = $collectHtml;
  8548. $data ['total'] = $total;
  8549. $data ['year'] = $year;
  8550. $data ['memu'] = "receipt";
  8551. $data ['staff'] = $this->staff;
  8552. $data ['receiptMemu'] = 'companyCategoryCollect';
  8553. $data ['verifyId'] = $this->verifyId;
  8554. $data ['executeId'] = $this->executeId;
  8555. if ($year <= date ( "Y" )) {
  8556. Doo::loadModel ( 'receipt' );
  8557. $receipt = new receipt ();
  8558. $receiptList = $receipt->find ( array (
  8559. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  8560. 'asArray' => true
  8561. ) );
  8562. if (empty ( $receiptList )) { // generated files
  8563. ob_start ();
  8564. $this->render ( "/admin/saeaStaffCollectB", $data );
  8565. $this->cacheFile ( $path );
  8566. die ();
  8567. }
  8568. }
  8569. $this->render ( "/admin/saeaStaffCollectB", $data );
  8570. }
  8571. function staffCollectBak() {
  8572. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8573. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  8574. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  8575. $this->showCache ( $path );
  8576. Doo::loadModel ( 'statistics' );
  8577. $statistics = new statistics ();
  8578. Doo::loadModel ( "receiptDetail" );
  8579. $receiptDetail = new receiptDetail ();
  8580. Doo::loadModel ( 'L_category' );
  8581. $Lcategory = new L_category ();
  8582. Doo::loadModel ( 'accountItem' );
  8583. $accountItem = new accountItem ();
  8584. Doo::loadModel ( 'staff' );
  8585. $staff = new staff ();
  8586. Doo::loadModel ( 'itemStatistics' );
  8587. $itemStatistics = new itemStatistics ();
  8588. $itemStatisticsList = $itemStatistics->find ( array (
  8589. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8590. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8591. 'groupby' => 'staff,itemCategory,Month(date)',
  8592. 'asArray' => true
  8593. ) );
  8594. $itemCategoryList = $itemStatistics->find ( array (
  8595. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8596. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8597. 'groupby' => 'cid,itemCategory,Month(date)',
  8598. 'asArray' => true
  8599. ) );
  8600. $LcategoryList = $Lcategory->find ( array (
  8601. 'asArray' => true
  8602. ) );
  8603. $staffList = $staff->find ( array (
  8604. 'asArray' => true
  8605. ) );
  8606. $htmlArray = array ();
  8607. foreach ( $LcategoryList as $value ) {
  8608. $htmlArray [$value ['title']] = array ();
  8609. foreach ( $staffList as $v ) {
  8610. if ($value ['cid'] == $v ['cid']) {
  8611. $html = "";
  8612. $falg = true;
  8613. $staffSumPrice = 0;
  8614. foreach ( $itemStatisticsList as $a ) {
  8615. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  8616. if (empty ( $a ['price'] )) {
  8617. $html .= '<td class="taR">-</td>';
  8618. $falg = false;
  8619. break;
  8620. } else {
  8621. $staffSumPrice += $a ['price'];
  8622. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8623. $falg = false;
  8624. break;
  8625. }
  8626. }
  8627. }
  8628. if ($falg) {
  8629. $html .= '<td class="taR">-</td>';
  8630. $falg = true;
  8631. }
  8632. $falg = true;
  8633. foreach ( $itemStatisticsList as $a ) {
  8634. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  8635. if (empty ( $a ['price'] )) {
  8636. $html .= '<td class="taR">-</td>';
  8637. $falg = false;
  8638. break;
  8639. } else {
  8640. $staffSumPrice += $a ['price'];
  8641. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8642. $falg = false;
  8643. break;
  8644. }
  8645. }
  8646. }
  8647. if ($falg) {
  8648. $html .= '<td class="taR">-</td>';
  8649. $falg = true;
  8650. }
  8651. $falg = true;
  8652. foreach ( $itemStatisticsList as $a ) {
  8653. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  8654. if (empty ( $a ['price'] )) {
  8655. $html .= '<td class="taR">-</td>';
  8656. $falg = false;
  8657. break;
  8658. } else {
  8659. $staffSumPrice += $a ['price'];
  8660. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8661. $falg = false;
  8662. break;
  8663. }
  8664. }
  8665. }
  8666. if ($falg) {
  8667. $html .= '<td class="taR">-</td>';
  8668. $falg = true;
  8669. }
  8670. $falg = true;
  8671. foreach ( $itemStatisticsList as $a ) {
  8672. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  8673. if (! empty ( $a ['price'] )) {
  8674. $staffSumPrice += $a ['price'];
  8675. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8676. $falg = false;
  8677. break;
  8678. } else {
  8679. $html .= '<td class="taR">-</td>';
  8680. $falg = false;
  8681. break;
  8682. }
  8683. }
  8684. }
  8685. if ($falg) {
  8686. $html .= '<td class="taR">-</td>';
  8687. $falg = true;
  8688. }
  8689. $falg = true;
  8690. foreach ( $itemStatisticsList as $a ) {
  8691. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  8692. if (! empty ( $a ['price'] )) {
  8693. $staffSumPrice += $a ['price'];
  8694. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8695. $falg = false;
  8696. break;
  8697. } else {
  8698. $html .= '<td class="taR">-</td>';
  8699. $falg = false;
  8700. break;
  8701. }
  8702. }
  8703. }
  8704. if ($falg) {
  8705. $html .= '<td class="taR">-</td>';
  8706. $falg = true;
  8707. }
  8708. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  8709. $htmlArray [$value ['title']] [$v ['username']] = $html;
  8710. }
  8711. }
  8712. /* -- --- */
  8713. // 合计费用
  8714. $cateHtml = "";
  8715. $catePrice = 0;
  8716. $cateFalg = true;
  8717. foreach ( $itemCategoryList as $l ) {
  8718. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  8719. if (empty ( $l ['price'] )) {
  8720. $cateHtml .= '<td class="colGreen taR">-</td>';
  8721. $cateFalg = false;
  8722. break;
  8723. } else {
  8724. $catePrice += $l ['price'];
  8725. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8726. $cateFalg = false;
  8727. break;
  8728. }
  8729. }
  8730. }
  8731. if ($cateFalg) {
  8732. $cateHtml .= '<td class="colGreen taR">-</td>';
  8733. $cateFalg = true;
  8734. }
  8735. $cateFalg = true;
  8736. foreach ( $itemCategoryList as $l ) {
  8737. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  8738. if (empty ( $l ['price'] )) {
  8739. $cateHtml .= '<td class="colGreen taR">-</td>';
  8740. $cateFalg = false;
  8741. break;
  8742. } else {
  8743. $catePrice += $l ['price'];
  8744. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8745. $cateFalg = false;
  8746. break;
  8747. }
  8748. }
  8749. }
  8750. if ($cateFalg) {
  8751. $cateHtml .= '<td class="colGreen taR">-</td>';
  8752. $cateFalg = true;
  8753. }
  8754. $cateFalg = true;
  8755. foreach ( $itemCategoryList as $l ) {
  8756. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  8757. if (empty ( $l ['price'] )) {
  8758. $cateHtml .= '<td class="colGreen taR">-</td>';
  8759. $cateFalg = false;
  8760. break;
  8761. } else {
  8762. $catePrice += $l ['price'];
  8763. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8764. $cateFalg = false;
  8765. break;
  8766. }
  8767. }
  8768. }
  8769. if ($cateFalg) {
  8770. $cateHtml .= '<td class="colGreen taR">-</td>';
  8771. $cateFalg = true;
  8772. }
  8773. $cateFalg = true;
  8774. foreach ( $itemCategoryList as $l ) {
  8775. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  8776. if (empty ( $l ['price'] )) {
  8777. $cateHtml .= '<td class="colGreen taR">-</td>';
  8778. $cateFalg = false;
  8779. break;
  8780. } else {
  8781. $catePrice += $l ['price'];
  8782. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8783. $cateFalg = false;
  8784. break;
  8785. }
  8786. }
  8787. }
  8788. if ($cateFalg) {
  8789. $cateHtml .= '<td class="colGreen taR">-</td>';
  8790. $cateFalg = true;
  8791. }
  8792. $cateFalg = true;
  8793. foreach ( $itemCategoryList as $l ) {
  8794. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  8795. if (empty ( $l ['price'] )) {
  8796. $cateHtml .= '<td class="colGreen taR">-</td>';
  8797. $cateFalg = false;
  8798. break;
  8799. } else {
  8800. $catePrice += $l ['price'];
  8801. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8802. $cateFalg = false;
  8803. break;
  8804. }
  8805. }
  8806. }
  8807. if ($cateFalg) {
  8808. $cateHtml .= '<td class="colGreen taR">-</td>';
  8809. $cateFalg = true;
  8810. }
  8811. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  8812. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  8813. /* -- --- */
  8814. }
  8815. // print_r($htmlArray);die;
  8816. $data ['htmlArray'] = $htmlArray;
  8817. // statistics html
  8818. $stList = $statistics->getOne ( array (
  8819. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8820. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8821. 'groupby' => 'Month(date)',
  8822. 'asArray' => true
  8823. ) );
  8824. if (empty ( $stList ))
  8825. $stList = array (
  8826. 'rePrice' => 0,
  8827. 'agPrice' => 0
  8828. );
  8829. $data ['stList'] = array (
  8830. 'rePrice' => $stList ['rePrice'],
  8831. 'agPrice' => $stList ['agPrice'],
  8832. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8833. );
  8834. $monthHtml = "";
  8835. for($i = 1; $i <= 12; $i ++) {
  8836. if ($i == $month)
  8837. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8838. else
  8839. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8840. }
  8841. $data ['monthHtml'] = $monthHtml;
  8842. $data ['year'] = $year;
  8843. $data ['month'] = $month;
  8844. $data ['memu'] = "receipt";
  8845. $data ['staff'] = $this->staff;
  8846. $data ['receiptMemu'] = 'companyCategoryCollect';
  8847. $data ['verifyId'] = $this->verifyId;
  8848. $data ['executeId'] = $this->executeId;
  8849. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  8850. Doo::loadModel ( 'receipt' );
  8851. $receipt = new receipt ();
  8852. $receiptList = $receipt->find ( array (
  8853. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  8854. 'asArray' => true
  8855. ) );
  8856. if (empty ( $receiptList )) { // generated files
  8857. ob_start ();
  8858. $this->render ( "/admin/saeaStaffCollect", $data );
  8859. $this->cacheFile ( $path );
  8860. die ();
  8861. }
  8862. }
  8863. $this->render ( "/admin/saeaStaffCollect", $data );
  8864. }
  8865. /**
  8866. * 日常收支
  8867. */
  8868. function payments() {
  8869. Doo::loadModel ( "accountBook" );
  8870. $accountBook = new accountBook ();
  8871. Doo::loadModel ( "accountBookStatistics" );
  8872. $accountBookStatistics = new accountBookStatistics ();
  8873. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  8874. $list = $accountBook->getAccountBookByLimit ( 10 );
  8875. $data ['statisticsList'] = $statisticsList;
  8876. $data ['list'] = $list;
  8877. $data ['memu'] = "receipt";
  8878. $data ['staff'] = $this->staff;
  8879. $data ['receiptMemu'] = 'payments';
  8880. $data ['verifyId'] = $this->verifyId;
  8881. $data ['executeId'] = $this->executeId;
  8882. $this->render ( "/expenses/payments", $data );
  8883. }
  8884. /**
  8885. * 添加收入
  8886. * @return string
  8887. */
  8888. function paymentsIncomeDo() {
  8889. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  8890. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  8891. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  8892. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  8893. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  8894. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  8895. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  8896. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  8897. Doo::loadClass ( 'XDeode' );
  8898. $XDeode = new XDeode ( 5 );
  8899. Doo::loadModel ( "accountBook" );
  8900. $accountBook = new accountBook ();
  8901. $accountBank = '';
  8902. $accountTypeWaste = 6;
  8903. if ($receivedBank == '纵横广发') {
  8904. $accountBank = 'CGBDeposit';
  8905. } elseif ($receivedBank == '纵横工行') {
  8906. $accountBank = 'ICBCDeposit';
  8907. } elseif ($receivedBank == '华润银行') {
  8908. $accountBank = 'HUADeposit';
  8909. } elseif ($receivedBank == '个人广发') {
  8910. $accountBank = 'PersonalDeposit';
  8911. }
  8912. if (empty ( $accountBank ))
  8913. die ( 'illegal request' );
  8914. $dailyIncomeType = '';
  8915. $itemWaste = array (
  8916. 'accountPrice' => $receivedPrice
  8917. );
  8918. if ($receivedBank == '个人广发') {
  8919. $itemWaste = array (
  8920. 'accountPrice' => - $receivedPrice
  8921. );
  8922. }
  8923. if ($accountType == 4) {
  8924. $dailyIncomeType = 4;
  8925. } elseif ($accountType == 1) {
  8926. $dailyIncomeType = 1;
  8927. } elseif ($accountType == 2) {
  8928. $dailyIncomeType = 2;
  8929. } elseif ($accountType == 3) {
  8930. $dailyIncomeType = 3;
  8931. } elseif ($accountType == 5) {
  8932. $dailyIncomeType = 5;
  8933. } elseif ($accountType == 6) {
  8934. $dailyIncomeType = 6;
  8935. } elseif ($accountType == 7||$accountType==9) {
  8936. $dailyIncomeType = 7;
  8937. if ($accountMsg == '公司固定') {
  8938. $accountTypeWaste = 9;
  8939. } elseif ($accountMsg == '公司活期') {
  8940. $accountTypeWaste = 10;
  8941. } elseif ($accountMsg == '个人(GR)') {
  8942. $accountBank = 'PersonalDeposit';
  8943. }
  8944. $itemWaste = array (
  8945. 'accountPrice' => - $receivedPrice
  8946. );
  8947. } elseif ($accountType == 8) {
  8948. $dailyIncomeType = 8;
  8949. }
  8950. if (empty ( $dailyIncomeType ))
  8951. die ( 'illegal request' );
  8952. $accountBook->accountType = $accountType;
  8953. $accountBook->accountMsg = $accountMsg;
  8954. $accountBook->receivedPrice = $receivedPrice;
  8955. $accountBook->receivedMsg = $receivedMsg;
  8956. $accountBook->receivedBank = $receivedBank;
  8957. $accountBook->receivedDate = $receivedDate;
  8958. $accountBook->remarks = $remarks;
  8959. $accountBook->expensesType = 1;
  8960. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  8961. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  8962. $accountBook->inputStaff = $this->staff [0] ['sid'];
  8963. $id = $accountBook->insert ();
  8964. //
  8965. $abDetail = $accountBook->getAccountBookByAid ( $id );
  8966. Doo::loadModel ( "accountBookStatistics" );
  8967. $accountBookStatistics = new accountBookStatistics ();
  8968. $item = array (
  8969. 'date' => date ( "Y-m-d" ),
  8970. 'accountType' => $abDetail ['accountType'],
  8971. 'accountMsg' => $abDetail ['accountMsg'],
  8972. 'aid' => $abDetail ['aid']
  8973. );
  8974. if ($abDetail ['expensesType'] == 1) {
  8975. if ($abDetail ['accountType'] == 7||$abDetail ['accountType'] == 9) {
  8976. $item += array (
  8977. 'financingPrice' => - $receivedPrice,
  8978. 'expensesType' => 3
  8979. );
  8980. } else if ($abDetail ['accountType'] == 8) {
  8981. $item += array (
  8982. 'inComePrice' => - $abDetail ['receivedPrice'],
  8983. 'expensesType' => $abDetail ['expensesType']
  8984. );
  8985. } else {
  8986. $item += array (
  8987. 'inComePrice' => $abDetail ['receivedPrice'],
  8988. 'expensesType' => $abDetail ['expensesType']
  8989. );
  8990. }
  8991. }
  8992. $accountBookStatistics->setAccountBookStatistics ( $item );
  8993. // 公司流水记录
  8994. Doo::loadModel ( 'wasteBook' );
  8995. $wasteBook = new wasteBook ();
  8996. $abDetail = $wasteBook->getAccountBookByAid ( 1, $accountTypeWaste, $id );
  8997. // 银行
  8998. // if (empty($abDetail)){
  8999. $itemWaste += array (
  9000. 'accountPriceShow'=>$receivedPrice,
  9001. 'dataID' => $id,
  9002. 'expensesType' => 1,
  9003. 'accountType' => $accountTypeWaste,
  9004. 'dailyIncomeType' => $dailyIncomeType,
  9005. 'accountBank' => $accountBank,
  9006. 'category' => $this->staff [0] ['category'],
  9007. 'cid' => $this->staff [0] ['cid'],
  9008. 'name' => $this->staff [0] ['username'],
  9009. 'sid' => $this->staff [0] ['sid'],
  9010. 'inputDate' => date ( "Y-m-d H:i:s" )
  9011. );
  9012. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9013. // }
  9014. }
  9015. return '/payments';
  9016. }
  9017. /**
  9018. * 添加支出
  9019. */
  9020. function paymentsExpenditureDo() {
  9021. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  9022. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  9023. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  9024. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  9025. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  9026. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  9027. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  9028. $dailyExpenditureType = '';
  9029. $accountTypeWaste=5;
  9030. $accountBank = '';
  9031. if ($expenditureBank == '纵横广发') {
  9032. $accountBank = 'CGBDeposit';
  9033. } elseif ($expenditureBank == '纵横工行') {
  9034. $accountBank = 'ICBCDeposit';
  9035. } elseif ($expenditureBank == '华润银行') {
  9036. $accountBank = 'HUADeposit';
  9037. } elseif ($expenditureBank == '个人广发') {
  9038. $accountBank = 'PersonalDeposit';
  9039. }
  9040. if (empty ( $accountBank ))
  9041. die ( 'illegal request' );
  9042. $itemWaste = array (
  9043. 'accountPrice' => - $expenditurePrice
  9044. );
  9045. if ($expenditureBank == '个人广发') {
  9046. $itemWaste = array (
  9047. 'accountPrice' => $expenditurePrice
  9048. );
  9049. }
  9050. if ($expenditureType == 4||$expenditureType == 6) {
  9051. $dailyExpenditureType = 4;
  9052. if ($expenditureMsg == '公司固定') {
  9053. $accountTypeWaste = 9;
  9054. } elseif ($expenditureMsg == '公司活期') {
  9055. $accountTypeWaste = 10;
  9056. } elseif ($expenditureMsg == '个人(GR)') {
  9057. $accountBank = 'PersonalDeposit';
  9058. }
  9059. $itemWaste = array (
  9060. 'accountPrice' => $expenditurePrice
  9061. );
  9062. } elseif ($expenditureType == 1) {
  9063. $dailyExpenditureType = 1;
  9064. } elseif ($expenditureType == 2) {
  9065. $dailyExpenditureType = 2;
  9066. } elseif ($expenditureType == 3) {
  9067. $dailyExpenditureType = 3;
  9068. } elseif ($expenditureType == 5) {
  9069. $dailyExpenditureType = 5;
  9070. }
  9071. if (empty ( $dailyExpenditureType ))
  9072. die ( 'illegal request' );
  9073. Doo::loadModel ( "accountBook" );
  9074. $accountBook = new accountBook ();
  9075. $accountBook->expenditureType = $expenditureType;
  9076. $accountBook->expenditureMsg = $expenditureMsg;
  9077. $accountBook->expenditurePrice = $expenditurePrice;
  9078. $accountBook->expenditureBank = $expenditureBank;
  9079. $accountBook->expenditureDate = $expenditureDate;
  9080. $accountBook->remarks = $remarks;
  9081. $accountBook->expensesType = 2;
  9082. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9083. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9084. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9085. $id = $accountBook->insert ();
  9086. //
  9087. $abDetail = $accountBook->getAccountBookByAid ( $id );
  9088. Doo::loadModel ( "accountBookStatistics" );
  9089. $accountBookStatistics = new accountBookStatistics ();
  9090. $item = array (
  9091. 'date' => date ( "Y-m-d" ),
  9092. 'expenditureType' => $abDetail ['expenditureType'],
  9093. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  9094. 'aid' => $abDetail ['aid']
  9095. );
  9096. if ($abDetail ['expensesType'] == 2) {
  9097. if ($abDetail ['expenditureType'] == 4||$abDetail ['expenditureType'] == 6) {
  9098. $item += array (
  9099. 'financingPrice' => $expenditurePrice,
  9100. 'expensesType' => 3
  9101. );
  9102. } elseif ($abDetail ['expenditureType'] == 5) {
  9103. $item += array (
  9104. 'payPrice' => $abDetail ['expenditurePrice'],
  9105. 'expensesType' => $abDetail ['expensesType']
  9106. );
  9107. } else {
  9108. $item += array (
  9109. 'payPrice' => $abDetail ['expenditurePrice'],
  9110. 'expensesType' => $abDetail ['expensesType']
  9111. );
  9112. }
  9113. }
  9114. $accountBookStatistics->setAccountBookStatistics ( $item );
  9115. // 公司流水记录
  9116. Doo::loadModel ( 'wasteBook' );
  9117. $wasteBook = new wasteBook ();
  9118. $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountTypeWaste, $id );
  9119. // 银行
  9120. if (empty ( $abDetail )) {
  9121. $itemWaste += array (
  9122. 'accountPriceShow'=>$expenditurePrice,
  9123. 'dataID' => $id,
  9124. 'expensesType' => 2,
  9125. 'accountType' => $accountTypeWaste,
  9126. 'dailyExpenditureType' => $dailyExpenditureType,
  9127. 'accountBank' => $accountBank,
  9128. 'category' => $this->staff [0] ['category'],
  9129. 'cid' => $this->staff [0] ['cid'],
  9130. 'name' => $this->staff [0] ['username'],
  9131. 'sid' => $this->staff [0] ['sid'],
  9132. 'inputDate' => date ( "Y-m-d H:i:s" )
  9133. );
  9134. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9135. }
  9136. }
  9137. return '/payments';
  9138. }
  9139. /**
  9140. * 所有收支
  9141. */
  9142. function paymentsAchieve() {
  9143. $page_size = 12;
  9144. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  9145. $expensesType = isset ( $this->params ['expensesType'] ) ? $this->params ['expensesType'] : 'ALL';
  9146. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  9147. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  9148. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "1";
  9149. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  9150. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "1";
  9151. $submitType = $this->get_args ( 'submitType' ) ? $this->get_args ( 'submitType' ) : "";
  9152. Doo::loadModel ( "accountBookStatistics" );
  9153. $accountBookStatistics = new accountBookStatistics ();
  9154. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  9155. $data ['statisticsList'] = $statisticsList;
  9156. Doo::loadModel ( "accountBook" );
  9157. $accountBook = new accountBook ();
  9158. $con = '';
  9159. if ($expensesType == 'INCOME')
  9160. $con = ' and expensesType=1 ';
  9161. elseif ($expensesType == 'PAY')
  9162. $con = ' and expensesType=2 ';
  9163. $dateArr = explode ( ':', $date );
  9164. $D1 = $dateString = '';
  9165. $D2 = '';
  9166. if (! empty ( $date )) {
  9167. $D1 = $dateArr [0];
  9168. if (isset ( $dateArr [1] ))
  9169. $D2 = $dateArr [1];
  9170. else
  9171. $D2 = '';
  9172. $dateString = $D1 . " : " . $D2;
  9173. }
  9174. if (! empty ( $D1 ) && ! empty ( $D2 ))
  9175. $con .= ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  9176. elseif (! empty ( $D1 ) && empty ( $D2 ))
  9177. $con .= ' and inputDate like "%' . $D1 . '%" ';
  9178. if (! empty ( $price ))
  9179. $con .= ' and (receivedPrice=' . $price . ' or expenditurePrice=' . $price . ')';
  9180. if ($submitType == 1) {
  9181. $expenditureType = '';
  9182. $con .= ' and accountType=' . $accountType;
  9183. if (! empty ( $accountMsg ))
  9184. $con .= ' and (accountType=' . $accountType . ' and accountMsg like "%' . $accountMsg . '%")';
  9185. } elseif ($submitType == 2) {
  9186. $accountType = $accountMsg = '';
  9187. $con .= ' and expenditureType=' . $expenditureType;
  9188. } else {
  9189. $accountType = $accountMsg = $expenditureType = '';
  9190. }
  9191. $sql = "" . $con;
  9192. $action = "paymentsAchieve";
  9193. $get = ''; // "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  9194. $pageinfo = $this->get_page ( "CLD_accountBook", $sql, $page, $page_size, $action, $get, "" );
  9195. $limit = $pageinfo ['lower'] . ',' . $page_size;
  9196. $list = $accountBook->getAccountBookBySql ( $limit, $sql, 'desc' );
  9197. $data ['expenditureType'] = $expenditureType;
  9198. $data ['accountMsg'] = $accountMsg;
  9199. $data ['accountType'] = $accountType;
  9200. $data ['inputDate'] = $date;
  9201. $data ['price'] = $price;
  9202. $data ['expensesType'] = $expensesType;
  9203. $data ['page'] = $pageinfo;
  9204. $data ['list'] = $list;
  9205. $data ['memu'] = "receipt";
  9206. $data ['staff'] = $this->staff;
  9207. $data ['receiptMemu'] = 'payments';
  9208. $data ['verifyId'] = $this->verifyId;
  9209. $data ['executeId'] = $this->executeId;
  9210. $this->render ( "/expenses/paymentsAchieve", $data );
  9211. }
  9212. function paymentsIncomeUpdateDo() {
  9213. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  9214. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  9215. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  9216. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  9217. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  9218. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  9219. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  9220. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  9221. if (! empty ( $aidKey ) && ! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  9222. Doo::loadClass ( 'XDeode' );
  9223. $XDeode = new XDeode ( 5 );
  9224. $aid = $XDeode->decode ( $aidKey );
  9225. Doo::loadModel ( "accountBook" );
  9226. $accountBook = new accountBook ();
  9227. //
  9228. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  9229. $price = $receivedPrice - $abDetail [inComePrice];
  9230. Doo::loadModel ( "accountBookStatistics" );
  9231. $accountBookStatistics = new accountBookStatistics ();
  9232. if ($abDetail ['accountType'] == 7) {
  9233. $item += array (
  9234. 'date' => date ( "Y-m-d" ),
  9235. 'financingPrice' => - $price,
  9236. 'expensesType' => 3,
  9237. 'aid' => $abDetail ['aid']
  9238. );
  9239. } elseif ($abDetail ['accountType'] == 8) {
  9240. $item += array (
  9241. 'date' => date ( "Y-m-d" ),
  9242. 'expensesType' => $abDetail ['expensesType'],
  9243. 'inComePrice' => - $price,
  9244. 'aid' => $abDetail ['aid']
  9245. );
  9246. } else {
  9247. $item = array (
  9248. 'date' => date ( "Y-m-d" ),
  9249. 'expensesType' => $abDetail ['expensesType'],
  9250. 'inComePrice' => $price,
  9251. 'aid' => $abDetail ['aid']
  9252. );
  9253. }
  9254. $accountBookStatistics->setAccountBookStatistics ( $item );
  9255. $accountBook->accountType = $accountType;
  9256. $accountBook->accountMsg = $accountMsg;
  9257. $accountBook->receivedPrice = $receivedPrice;
  9258. $accountBook->receivedMsg = $receivedMsg;
  9259. $accountBook->receivedBank = $receivedBank;
  9260. $accountBook->receivedDate = $receivedDate;
  9261. $accountBook->remarks = $remarks;
  9262. $accountBook->aid = $aid;
  9263. $accountBook->update ();
  9264. }
  9265. return '/paymentsAchieve';
  9266. }
  9267. function paymentsExpenditureEdiDo() {
  9268. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  9269. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  9270. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  9271. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  9272. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  9273. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  9274. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  9275. if (! empty ( $aidKey ) && ! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  9276. Doo::loadClass ( 'XDeode' );
  9277. $XDeode = new XDeode ( 5 );
  9278. $aid = $XDeode->decode ( $aidKey );
  9279. Doo::loadModel ( "accountBook" );
  9280. $accountBook = new accountBook ();
  9281. // 汇总信息
  9282. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  9283. $price = $expenditurePrice - $abDetail [expenditurePrice];
  9284. Doo::loadModel ( "accountBookStatistics" );
  9285. $accountBookStatistics = new accountBookStatistics ();
  9286. if ($abDetail ['expenditureType'] == 4) {
  9287. $item += array (
  9288. 'date' => date ( "Y-m-d" ),
  9289. 'financingPrice' => $price,
  9290. 'expensesType' => 3,
  9291. 'aid' => $abDetail ['aid']
  9292. );
  9293. } elseif ($abDetail ['expenditureType'] == 5) {
  9294. $item += array (
  9295. 'date' => date ( "Y-m-d" ),
  9296. 'expensesType' => $abDetail ['expensesType'],
  9297. 'payPrice' => $price,
  9298. 'aid' => $abDetail ['aid']
  9299. );
  9300. } else {
  9301. $item = array (
  9302. 'date' => date ( "Y-m-d" ),
  9303. 'expensesType' => $abDetail ['expensesType'],
  9304. 'payPrice' => $price,
  9305. 'aid' => $abDetail ['aid']
  9306. );
  9307. }
  9308. $accountBookStatistics->setAccountBookStatistics ( $item );
  9309. //
  9310. $accountBook->expenditureType = $expenditureType;
  9311. $accountBook->expenditureMsg = $expenditureMsg;
  9312. $accountBook->expenditurePrice = $expenditurePrice;
  9313. $accountBook->expenditureBank = $expenditureBank;
  9314. $accountBook->remarks = $remarks;
  9315. $accountBook->expenditureDate = $expenditureDate;
  9316. $accountBook->aid = $aid;
  9317. $id = $accountBook->update ();
  9318. }
  9319. return '/paymentsAchieve';
  9320. }
  9321. function paymentsDelDo() {
  9322. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  9323. if (! empty ( $aidKey )) {
  9324. Doo::loadClass ( 'XDeode' );
  9325. $XDeode = new XDeode ( 5 );
  9326. $aid = $XDeode->decode ( $aidKey );
  9327. Doo::loadModel ( "accountBook" );
  9328. $accountBook = new accountBook ();
  9329. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  9330. // 删除收支
  9331. Doo::loadModel ( "accountBookStatistics" );
  9332. $accountBookStatistics = new accountBookStatistics ();
  9333. $item = array (
  9334. 'date' => date ( "Y-m-d" ),
  9335. 'aid' => $abDetail ['aid']
  9336. );
  9337. if ($abDetail ['expensesType'] == 1) {
  9338. if ($abDetail ['accountType'] != 7) {
  9339. $item += array (
  9340. 'expensesType' => $abDetail ['expensesType'],
  9341. 'inComePrice' => - $abDetail ['receivedPrice']
  9342. );
  9343. } else {
  9344. $item += array (
  9345. 'financingPrice' => $abDetail ['receivedPrice'],
  9346. 'expensesType' => 3
  9347. );
  9348. }
  9349. } elseif ($abDetail ['expensesType'] == 2) {
  9350. if ($abDetail ['accountType'] != 7) {
  9351. $item += array (
  9352. 'expensesType' => $abDetail ['expensesType'],
  9353. 'payPrice' => - $abDetail ['expenditurePrice']
  9354. );
  9355. } else {
  9356. $item += array (
  9357. 'financingPrice' => - $abDetail ['expenditurePrice'],
  9358. 'expensesType' => 3
  9359. );
  9360. }
  9361. }
  9362. $accountBookStatistics->setAccountBookStatistics ( $item );
  9363. $accountBook->delete ( array (
  9364. 'where' => 'aid=' . $aid,
  9365. 'limit' => 1
  9366. ) );
  9367. }
  9368. return '/paymentsAchieve';
  9369. }
  9370. function paymentsCollect() {
  9371. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9372. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  9373. Doo::loadModel ( "accountBookStatistics" );
  9374. $accountBookStatistics = new accountBookStatistics ();
  9375. Doo::loadClass ( 'receipt.func' );
  9376. $statisticsIncome = $accountBookStatistics->getStatisticsByCollect ( $year );
  9377. $html = _getPaymentsCollectByYearHtml ( $statisticsIncome );
  9378. $data ['html'] = $html ['html'];
  9379. $data ['inSum'] = $html ['sum'];
  9380. $statisticsPay = $accountBookStatistics->getStatisticsByCollect ( $year, 2 );
  9381. $html = _getPaymentsCollectPayByYearHtml ( $statisticsPay );
  9382. $data ['payHtml'] = $html ['html'];
  9383. $data ['paySum'] = $html ['sum'];
  9384. //余额统计
  9385. //$inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1 );
  9386. //$pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2 );
  9387. include './protected/config/wasteBook.conf.php';
  9388. Doo::loadModel ( 'wasteBook' );
  9389. $wasteBook = new wasteBook ();
  9390. $inComePay=$wasteBook->getWasteBookByStatistics(1,$year);
  9391. $pay=$wasteBook->getWasteBookByStatistics(2,$year);
  9392. //获得年份之前所有金额
  9393. $detail=$wasteBook->getWasteBookByStatisticsYear($year);
  9394. //print_r($detail);
  9395. //$waste['total'];
  9396. $lastBalanceHtml='<tr><th colspan="2">截至上月余额</th>';
  9397. $inComeHtml = '<tr><th colspan="2">收入</th>';
  9398. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  9399. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  9400. $inSum = $paySum =$showInSum=$showPaySum = $balanceSum = 0;
  9401. $balanceC=$bakBC = $waste['total']+$detail[0]['accountPrice'];
  9402. $limitMonth=date('m');//限制显示月份参数
  9403. for($i = 1; $i <= 12; $i ++) {
  9404. $inComeA = $payB = 0;
  9405. $falg = true;
  9406. foreach ( $inComePay as $key => $value ) {
  9407. if ($value ['month'] == $i) {
  9408. $falg = false;
  9409. $inComeHtml .= '<td class="taR">' . $value ['accountPrice'] . '</td>';
  9410. $inSum += $value ['accountPrice'];
  9411. $showInSum+=$value ['accountPrice'];
  9412. $inComeA = $value ['accountPrice'];
  9413. break;
  9414. }
  9415. }
  9416. if ($falg)
  9417. $inComeHtml .= '<td class="taR">-</td>';
  9418. $payFalg = true;
  9419. foreach ( $pay as $key => $value ) {
  9420. if ($value ['month'] == $i) {
  9421. $payFalg = false;
  9422. $payHtml .= '<td class="taR">' . $value ['accountPrice'] . '</td>';
  9423. $paySum += $value ['accountPrice'];
  9424. $showPaySum+=$value ['accountPrice'];
  9425. $payB = $value ['accountPrice'];
  9426. break;
  9427. }
  9428. }
  9429. if ($payFalg)
  9430. $payHtml .= '<td class="taR">-</td>';
  9431. if (empty ( $balanceC )||$limitMonth<$i)
  9432. $lastBalanceHtml .= '<td class="taR">-</td>';
  9433. else
  9434. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  9435. $balanceC = $balanceC + $inComeA + $payB;
  9436. $balanceSum += $balanceC;
  9437. if (empty ( $balanceC )||$limitMonth<$i)
  9438. $BalanceHtml .= '<td class="taR">-</td>';
  9439. else
  9440. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  9441. //余额统计
  9442. }
  9443. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  9444. $data ['inComeHtml'] = $inComeHtml;
  9445. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  9446. $data ['payBalanceHtml'] = $payHtml;
  9447. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  9448. $data ['BalanceHtml'] = $BalanceHtml;
  9449. $lastBalanceHtml .= '<td class="taR ">'.$balanceC.'</td></tr>';
  9450. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  9451. $mothHtml = "";
  9452. for($i = 1; $i <= 12; $i ++) {
  9453. if ($moth == $i)
  9454. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  9455. else
  9456. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  9457. }
  9458. $data ['mothHtml'] = $mothHtml;
  9459. $dateHtml = "";
  9460. $now = date ( "Y" );
  9461. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9462. if ($YEARD <= $now) {
  9463. $dateHtml .= '<option ';
  9464. if ($year == $YEARD) {
  9465. $dateHtml .= 'selected ';
  9466. }
  9467. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9468. }
  9469. }
  9470. $data ['dateHtml'] = $dateHtml;
  9471. $data ['year'] = $year;
  9472. $data ['memu'] = "receipt";
  9473. $data ['staff'] = $this->staff;
  9474. $data ['receiptMemu'] = 'paymentsCollect';
  9475. $data ['verifyId'] = $this->verifyId;
  9476. $data ['executeId'] = $this->executeId;
  9477. $this->render ( "/expenses/paymentsCollect", $data );
  9478. }
  9479. function paymentsCollectDay() {
  9480. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9481. $moth = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : '';
  9482. if (empty($moth))
  9483. return 'paymentsCollect';
  9484. Doo::loadModel ( "accountBookStatistics" );
  9485. $accountBookStatistics = new accountBookStatistics ();
  9486. $i = 2;
  9487. $y = 2013;
  9488. $day = date ( "t", strtotime ( "$year-$moth" ) );
  9489. Doo::loadClass ( 'receipt.func' );
  9490. $statisticsIncome = $accountBookStatistics->getStatisticsByCollectDay ( $year, 1, $moth );
  9491. $html = _getPaymentsCollectByDayHtml ( $statisticsIncome, $day );
  9492. $data ['html'] = $html ['html'];
  9493. $data ['inSum'] = $html ['sum'];
  9494. $statisticsPay = $accountBookStatistics->getStatisticsByCollectDay ( $year, 2, $moth );
  9495. $html = _getPaymentsCollectPayByDayHtml ( $statisticsPay, $day );
  9496. $data ['payHtml'] = $html ['html'];
  9497. $data ['paySum'] = $html ['sum'];
  9498. $mothHtml = "";
  9499. for($i = 1; $i <= 12; $i ++) {
  9500. if ($moth == $i)
  9501. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  9502. else
  9503. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  9504. }
  9505. $data ['mothHtml'] = $mothHtml;
  9506. $data ['year'] = $year;
  9507. // 余额
  9508. //$inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1, $moth );
  9509. //$pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2, $moth );
  9510. include './protected/config/wasteBook.conf.php';
  9511. Doo::loadModel ( 'wasteBook' );
  9512. $wasteBook = new wasteBook ();
  9513. $inComePay = $wasteBook->getStatisticsByDay ( 1,$year, $moth );
  9514. $pay = $wasteBook->getStatisticsByDay ( 2,$year, $moth );
  9515. //获得年份之前所有金额
  9516. $detail=$wasteBook->getWasteBookByStatisticsDay($year,$moth);
  9517. $lastBalanceHtml='<tr><th colspan="2">截至上日余额</th>';
  9518. $inComeHtml = '<tr><th colspan="2">收入</th>';
  9519. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  9520. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  9521. $dayHtml = '<tr><th class="taC" colspan="2">余额</th>';
  9522. $inSum = $paySum =$showPaySum=$showInSum= $balanceSum = 0;
  9523. $balanceC = 0;
  9524. $balanceC=$bakBC = $waste['total']+$detail[0]['accountPrice'];
  9525. $limitDay=date('d');
  9526. for($i = 1; $i <= $day; $i ++) {
  9527. $dayHtml .= '<td class="taC">' . $i . '日</td>';
  9528. $inComeA = $payB = 0;
  9529. $falg = true;
  9530. foreach ( $inComePay as $key => $value ) {
  9531. if ($value ['day'] == $i) {
  9532. $falg = false;
  9533. $inComeHtml .= '<td class="taR">' . $value ['accountPrice'] . '</td>';
  9534. $inSum += $value ['accountPrice'];
  9535. $showInSum+=$value ['accountPrice'];
  9536. $inComeA = $value ['accountPrice'];
  9537. break;
  9538. }
  9539. }
  9540. if ($falg)
  9541. $inComeHtml .= '<td class="taR">-</td>';
  9542. $payFalg = true;
  9543. foreach ( $pay as $key => $value ) {
  9544. if ($value ['day'] == $i) {
  9545. $payFalg = false;
  9546. $payHtml .= '<td class="taR">' . $value ['accountPrice'] . '</td>';
  9547. $paySum += $value ['accountPrice'];
  9548. $showPaySum+=$value ['accountPrice'];
  9549. $payB = $value ['accountPrice'];
  9550. break;
  9551. }
  9552. }
  9553. if ($payFalg)
  9554. $payHtml .= '<td class="taR">-</td>';
  9555. if (empty ( $balanceC )||$limitDay<$i)
  9556. $lastBalanceHtml .= '<td class="taR">-</td>';
  9557. else
  9558. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  9559. $balanceC = $balanceC + $inComeA + $payB;
  9560. $balanceSum += $balanceC;
  9561. if (empty ( $balanceC )||$limitDay<$i)
  9562. $BalanceHtml .= '<td class="taR">-</td>';
  9563. else
  9564. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  9565. }
  9566. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  9567. $data ['inComeHtml'] = $inComeHtml;
  9568. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  9569. $data ['payBalanceHtml'] = $payHtml;
  9570. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  9571. $data ['BalanceHtml'] = $BalanceHtml;
  9572. $dayHtml .= '<td class="taR ">总计</td></tr>';
  9573. $data ['dayHtml'] = $dayHtml;
  9574. $lastBalanceHtml .= '<td class="taR ">'.$balanceC.'</td></tr>';
  9575. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  9576. $data ['memu'] = "receipt";
  9577. $data ['staff'] = $this->staff;
  9578. $data ['receiptMemu'] = 'paymentsCollect';
  9579. $data ['verifyId'] = $this->verifyId;
  9580. $data ['executeId'] = $this->executeId;
  9581. $this->render ( "/expenses/paymentsCollectDay", $data );
  9582. }
  9583. function ajaxGetPaymentsByAid() {
  9584. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  9585. Doo::loadModel ( "accountBook" );
  9586. $accountBook = new accountBook ();
  9587. $detail = $accountBook->getAccountBookByAid ( $serial );
  9588. echo json_encode ( array (
  9589. 'status' => 1,
  9590. 'detail' => $detail
  9591. ) );
  9592. }
  9593. // 公司流水
  9594. function wasteBook() {
  9595. include './protected/config/wasteBook.conf.php';
  9596. Doo::loadModel ( 'wasteBook' );
  9597. $wasteBook = new wasteBook ();
  9598. $inComeStatistics = $wasteBook->getWasteBookStatisticsByIncome ();
  9599. $waste = $this->getWasteBookStatistics ( $waste, $inComeStatistics );
  9600. $total = $waste ['bank'] ['CGBDeposit'] + $waste ['bank'] ['ICBCDeposit'] + $waste ['bank'] ['HUADeposit'] + $waste ['bank'] ['PersonalDeposit'] + $waste ['financial'] ['current'] ['CGBDeposit'] + $waste ['financial'] ['current'] ['ICBCDeposit'] + $waste ['financial'] ['fixed'] ['CGBDeposit'] + $waste ['financial'] ['fixed'] ['ICBCDeposit'];
  9601. // print_r($waste);
  9602. $data ['waste'] = $waste;
  9603. $data ['total'] = $total;
  9604. // 月流水数据结构
  9605. $monthStatistics = array ();
  9606. $incomeMothStatistics = array ();
  9607. $expenditureMothStatistics = array ();
  9608. for($i = 1; $i <= 12; $i ++) {
  9609. $month = date ( 'Y' ) . '-' . $i;
  9610. if ($i<10)
  9611. $month = date ( 'Y' ) . '-0' . $i;
  9612. array_push ( $monthStatistics, $month );
  9613. }
  9614. foreach ( $monthStatistics as $value ) {
  9615. $falg = true;
  9616. foreach ( $inComeStatistics ['incomeReport'] as $k => $v ) {
  9617. if ($value == $v ['inputDate']) {
  9618. array_push ( $incomeMothStatistics, $v ['accountPrice'] );
  9619. $falg = false;
  9620. }
  9621. }
  9622. if ($falg) {
  9623. array_push ( $incomeMothStatistics, '' );
  9624. }
  9625. $falgEx = true;
  9626. foreach ( $inComeStatistics ['expenditureReport'] as $k => $v ) {
  9627. if ($value == $v ['inputDate']) {
  9628. array_push ( $expenditureMothStatistics, $v ['accountPrice'] );
  9629. $falg = false;
  9630. }
  9631. }
  9632. if ($falgEx) {
  9633. array_push ( $expenditureMothStatistics, '' );
  9634. }
  9635. }
  9636. $data ['monthStatistics'] = json_encode ( $monthStatistics );
  9637. $data ['incomeMothStatistics'] = json_encode ( $incomeMothStatistics );
  9638. $data ['expenditureMothStatistics'] = json_encode ( $expenditureMothStatistics );
  9639. $expenditureList = $wasteBook->getAccountBookByExpensesType ( 4, 2 );
  9640. $incomeList = $wasteBook->getAccountBookByExpensesType ( 4, 1 );
  9641. // print_r($incomeList);
  9642. $data ['expenditureList'] = $expenditureList;
  9643. $data ['incomeList'] = $incomeList;
  9644. $data ['memu'] = "receipt";
  9645. $data ['staff'] = $this->staff;
  9646. $data ['receiptMemu'] = 'wasteBook';
  9647. $data ['verifyId'] = $this->verifyId;
  9648. $data ['executeId'] = $this->executeId;
  9649. $this->render ( "/expenses/wasteBook", $data );
  9650. }
  9651. function wasteBookIncome() {
  9652. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  9653. Doo::loadModel ( 'wasteBook' );
  9654. $wasteBook = new wasteBook ();
  9655. $dateArr = explode ( ':', $date );
  9656. $D1 = '';
  9657. $D2 = '';
  9658. $con = '';
  9659. if (! empty ( $date )) {
  9660. $D1 = $dateArr [0];
  9661. $D2 = $dateArr [1];
  9662. }
  9663. if (! empty ( $D1 ) && ! empty ( $D2 ))
  9664. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  9665. elseif (! empty ( $D1 ) && empty ( $D2 ))
  9666. $con = ' and inputDate = "' . $D1 . '"';
  9667. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 1, $con );
  9668. $sum = 0;
  9669. foreach ( $incomeList as $key => $value ) {
  9670. $sum += $value ['accountPrice'];
  9671. }
  9672. // print_r($incomeList);
  9673. $data ['sum'] = $sum;
  9674. $data ['incomeList'] = $incomeList;
  9675. $data ['inputDate'] = $date;
  9676. $data ['memu'] = "receipt";
  9677. $data ['staff'] = $this->staff;
  9678. $data ['receiptMemu'] = 'wasteBook';
  9679. $data ['verifyId'] = $this->verifyId;
  9680. $data ['executeId'] = $this->executeId;
  9681. $this->render ( "/expenses/wasteBookIncome", $data );
  9682. }
  9683. /**
  9684. * 所有支出
  9685. */
  9686. function wasteBookExpenditure() {
  9687. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  9688. Doo::loadModel ( 'wasteBook' );
  9689. $wasteBook = new wasteBook ();
  9690. $dateArr = explode ( ':', $date );
  9691. $D1 = '';
  9692. $D2 = '';
  9693. $con = '';
  9694. if (! empty ( $date )) {
  9695. $D1 = $dateArr [0];
  9696. $D2 = $dateArr [1];
  9697. }
  9698. if (! empty ( $D1 ) && ! empty ( $D2 ))
  9699. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  9700. elseif (! empty ( $D1 ) && empty ( $D2 ))
  9701. $con = ' and inputDate = "' . $D1 . '"';
  9702. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 2, $con );
  9703. $sum = 0;
  9704. foreach ( $incomeList as $key => $value ) {
  9705. $sum += $value ['accountPrice'];
  9706. }
  9707. // print_r($incomeList);
  9708. $data ['sum'] = $sum;
  9709. $data ['incomeList'] = $incomeList;
  9710. $data ['inputDate'] = $date;
  9711. $data ['memu'] = "receipt";
  9712. $data ['staff'] = $this->staff;
  9713. $data ['receiptMemu'] = 'wasteBook';
  9714. $data ['verifyId'] = $this->verifyId;
  9715. $data ['executeId'] = $this->executeId;
  9716. $this->render ( "/expenses/wasteBookExpenditure", $data );
  9717. }
  9718. function ajaxGetWasteinvoiceReceivables() {
  9719. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  9720. Doo::loadClass ( 'XDeode' );
  9721. $XDeode = new XDeode ( 5 );
  9722. $irid = $XDeode->decode ( $serial );
  9723. Doo::loadModel ( 'invoiceReceivables' );
  9724. $invoiceReceivables = new invoiceReceivables ();
  9725. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  9726. echo json_encode ( array (
  9727. 'status' => 1,
  9728. 'detail' => $detail
  9729. ) );
  9730. }
  9731. /**
  9732. */
  9733. function ajaxGetWasteReceipt() {
  9734. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  9735. Doo::loadModel ( 'receipt' );
  9736. $receipt = new receipt ();
  9737. Doo::loadClass ( 'XDeode' );
  9738. $XDeode = new XDeode ( 5 );
  9739. $rid = $XDeode->decode ( $serial );
  9740. // 获得个数据
  9741. $detail = $receipt->getReceiptByRid ( $rid );
  9742. // 初始化
  9743. $detail ['reviseDetail'] = array ();
  9744. if (! empty ( $value ['reviseDetail'] ))
  9745. $detail ['reviseDetail'] = json_decode ( $detail ['reviseDetail'], true );
  9746. $detail ['accountItem'] = json_decode ( $detail ['accountItem'], true );
  9747. $detail ['loanItem'] = json_decode ( $detail ['loanItem'], true );
  9748. $detail ['loanSumCN'] = $this->num_to_rmb ( $detail ['loanSum'] );
  9749. $detail ['sumCN'] = $this->num_to_rmb ( $detail ['sum'] );
  9750. // 获得费用html
  9751. $html = $this->getWasteReceiptHtml ( $detail );
  9752. // 获得费用审批人数据
  9753. $detail = $this->getReceiptApproverHtml ( $detail );
  9754. // 审批执行
  9755. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  9756. <th class="taC" width="90">审批人</th>
  9757. <th class="taC">审批意见</th></tr>';
  9758. foreach ( $detail ['verifyList'] as $key => $value ) {
  9759. $html .= '<tr>
  9760. <td>' . $value [1] . '</td>
  9761. <td>' . $value ['opinion'] . '</td>
  9762. </tr>
  9763. ';
  9764. }
  9765. $html .= ' </tbody></table>';
  9766. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  9767. <th class="taC" width="90">执行人</th>
  9768. <th class="taC">执行意见</th></tr>';
  9769. foreach ( $detail ['executeCopy'] as $key => $value ) {
  9770. $html .= '<tr>
  9771. <td>' . $value [1] . '</td>
  9772. <td>' . $value ['opinion'] . '</td>
  9773. </tr>
  9774. ';
  9775. }
  9776. $html .= ' </tbody></table>';
  9777. $html .= '<table class="table table-bordered table-condensed">
  9778. <tr class="warning">
  9779. <td class="taR"><b>汇款金额</b></td>
  9780. <td width="140" class="taR"><b style="font-size: 24px">¥' . $detail ['amount'] . '</b></td>
  9781. </tr>
  9782. </table>';
  9783. // print_r($detail['verifyList']);
  9784. // header ( 'Content-Type:text/html;charset=utf-8' );
  9785. // echo $html;
  9786. echo json_encode ( array (
  9787. 'status' => 1,
  9788. 'html' => $html,
  9789. 'detail' => $detail
  9790. ) );
  9791. }
  9792. function getReceiptApproverHtml($detail = array()) {
  9793. Doo::loadModel ( 'loanReceipt' );
  9794. $loanReceipt = new loanReceipt ();
  9795. Doo::loadModel ( 'verify' );
  9796. $verify = new verify ();
  9797. Doo::loadModel ( 'staff' );
  9798. $staff = new staff ();
  9799. if (empty ( $detail ))
  9800. return array ();
  9801. $loanList = $loanReceipt->getOne ( array (
  9802. 'where' => 'rid=' . $detail ['loanRid'],
  9803. 'desc' => 'rid',
  9804. 'asArray' => true
  9805. ) );
  9806. if ($detail ['status'] == 3 || $detail ['status'] == 1 || $detail ['status'] == 8 || $detail ['status'] == 9) {
  9807. if ($detail ['status'] == 8 && $detail ['Rtype'] == 1)
  9808. $verifyList ['staff'] = $loanList ['verifyBreakup'];
  9809. else
  9810. $verifyList ['staff'] = $detail ['verifyBreakup'];
  9811. } else
  9812. $verifyList = $verify->getOne ( array (
  9813. 'where' => 'vid=' . $detail ['verify'],
  9814. 'asArray' => true
  9815. ) );
  9816. $verifyList = json_decode ( $verifyList ['staff'], true );
  9817. Doo::loadModel ( 'role' );
  9818. $role = new role ();
  9819. $roleId = 0;
  9820. $flag = true;
  9821. $roleKey = 0;
  9822. $endStaffArray = array ();
  9823. $roleArrayCopy = array ();
  9824. foreach ( $verifyList as $k => $v ) {
  9825. // init verifyStaff
  9826. if ($v [1] == 'ROLE') {
  9827. if (! empty ( $verifyStaff )) {
  9828. $endStaffArray = end ( $verifyStaff );
  9829. }
  9830. $roleVerify = json_decode ( $v [3], true );
  9831. $roleKey = $k;
  9832. $roleArray = array ();
  9833. $rolename = $role->getOne ( array (
  9834. 'where' => 'rid=' . $v [0],
  9835. 'asArray' => true
  9836. ) );
  9837. foreach ( $roleVerify as $o => $p ) {
  9838. $staffID = explode ( '_', $p );
  9839. $staffInfo = $staff->getOne ( array (
  9840. 'where' => 'sid=' . $staffID [0],
  9841. 'asArray' => true
  9842. ) );
  9843. // print_r($staffID);
  9844. $exp = array (
  9845. 0 => $staffInfo ['sid'],
  9846. 1 => $staffID [1],
  9847. 2 => $staffInfo ['avatar'],
  9848. 'date' => '',
  9849. 'date' => '',
  9850. 'opinion' => '',
  9851. 'status' => '',
  9852. 'rolename' => $rolename ['name']
  9853. );
  9854. array_push ( $roleArray, $exp );
  9855. }
  9856. $roleArrayCopy [$v [0]] = $roleArray;
  9857. // $verifyList[$k]['roleArray']=$roleArray;
  9858. }
  9859. $verifyList [$k] ['date'] = "";
  9860. $verifyList [$k] ['opinion'] = "";
  9861. $verifyList [$k] ['status'] = "";
  9862. if (empty ( $verifyStaff )) {
  9863. $verifyList [$k] ['date'] = "";
  9864. $verifyList [$k] ['opinion'] = "";
  9865. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  9866. $verifyList [$k] ['status'] = 4;
  9867. $flag = false;
  9868. }
  9869. } else {
  9870. foreach ( $verifyStaff as $m => $u ) {
  9871. if ($v [0] == $m) {
  9872. $verifyList [$k] ['date'] = $u ['date'];
  9873. $verifyList [$k] ['opinion'] = $u ['opinion'];
  9874. $verifyList [$k] ['status'] = $u ['status'];
  9875. $flag = false;
  9876. break;
  9877. }
  9878. }
  9879. $endStaffArray = end ( $verifyStaff );
  9880. }
  9881. }
  9882. $rolename ['name'] = '';
  9883. if (! empty ( $roleId )) {
  9884. Doo::loadModel ( 'role' );
  9885. $role = new role ();
  9886. $rolename = $role->getOne ( array (
  9887. 'where' => 'rid=' . $roleId,
  9888. 'asArray' => true
  9889. ) );
  9890. }
  9891. if (! empty ( $verifyStaff ))
  9892. $endStaffArray = end ( $verifyStaff );
  9893. $KOP = false;
  9894. foreach ( $roleArrayCopy as $P => $A ) {
  9895. foreach ( $A as $MKI => $AVL ) {
  9896. if (! empty ( $verifyStaff )) {
  9897. // &&$rolename['rid']==$endStaffArray['nextStaff']
  9898. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  9899. $button = 4;
  9900. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  9901. }
  9902. foreach ( $verifyStaff as $m => $u ) {
  9903. $AVLFK = $AVL [0] . '_R';
  9904. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  9905. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  9906. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  9907. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  9908. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  9909. break;
  9910. }
  9911. }
  9912. } else {
  9913. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  9914. $button = 4;
  9915. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  9916. }
  9917. }
  9918. // $roleArray[$MKI]['rolename']=$rolename['name'];
  9919. $KOP = true;
  9920. }
  9921. }
  9922. foreach ( $roleArrayCopy as $k => $v ) {
  9923. foreach ( $verifyList as $m => $n ) {
  9924. if ($n [0] == $k) {
  9925. array_splice ( $verifyList, $m, 1, $v );
  9926. }
  9927. }
  9928. }
  9929. // 费用执行人相关数据
  9930. $executeCopy = json_decode ( $detail ['executeCopy'], true );
  9931. $executeStaff = json_decode ( $detail ['executeStaff'], true );
  9932. foreach ( $executeCopy as $k => $v ) {
  9933. $executeCopy [$k] ['date'] = '';
  9934. $executeCopy [$k] ['opinion'] = '';
  9935. $executeCopy [$k] ['status'] = '';
  9936. if (! empty ( $executeStaff ))
  9937. foreach ( $executeStaff as $m => $u ) {
  9938. if ($v [0] == $m) {
  9939. $executeCopy [$k] ['date'] = $u ['date'];
  9940. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  9941. $executeCopy [$k] ['status'] = $u ['status'];
  9942. break;
  9943. }
  9944. }
  9945. }
  9946. $detail ['executeCopy'] = $executeCopy;
  9947. $detail ['verifyList'] = $verifyList;
  9948. return $detail;
  9949. }
  9950. function getWasteReceiptHtml($detail = array()) {
  9951. if (empty ( $detail ))
  9952. return '';
  9953. $html = '';
  9954. if ($detail ['Rtype'] == 0) { // 报销单
  9955. $html .= '
  9956. <table class="table table-bordered table-condensed">
  9957. <tbody>
  9958. <tr>
  9959. <th colspan="2" class="taC">日常相关费用</th>
  9960. </tr>';
  9961. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  9962. $html .= '
  9963. <tr>
  9964. <th>' . $value ['name'] . '</th>
  9965. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  9966. </tr>';
  9967. }
  9968. $html .= '
  9969. <tr>
  9970. <th class="taR">合计</th>
  9971. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  9972. </tr>';
  9973. $html .= '<tr>
  9974. <th colspan="2" class="taC">差旅相关费用</th>
  9975. </tr>';
  9976. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  9977. $html .= '
  9978. <tr>
  9979. <th>' . $value ['name'] . '</th>
  9980. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  9981. </tr>';
  9982. }
  9983. $html .= '
  9984. <tr>
  9985. <th class="taR">合计</th>
  9986. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  9987. </tr>';
  9988. $html .= '<tr>
  9989. <th colspan="2" class="taC">培训班费用</th>
  9990. </tr>';
  9991. foreach ( $detail ['accountItem'] ['培训班费用'] as $key => $value ) {
  9992. $html .= '
  9993. <tr>
  9994. <th>' . $value ['name'] . '</th>
  9995. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  9996. </tr>';
  9997. }
  9998. $html .= '
  9999. <tr>
  10000. <th class="taR">合计</th>
  10001. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['trainSum'] . '</td>
  10002. </tr>';
  10003. $html .= '<tr>
  10004. <th colspan="2" class="taC">其他</th>
  10005. </tr>';
  10006. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  10007. $html .= '
  10008. <tr>
  10009. <th>' . $value ['name'] . '</th>
  10010. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10011. </tr>';
  10012. }
  10013. $html .= '
  10014. <tr>
  10015. <th class="taR">合计</th>
  10016. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  10017. </tr>';
  10018. $html .= '<tr>
  10019. <th colspan="2" class="taC">报销金额调整</th>
  10020. </tr>';
  10021. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  10022. $html .= '
  10023. <tr>
  10024. <th>' . $value ['name'] . '</th>
  10025. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10026. </tr>';
  10027. }
  10028. $html .= '
  10029. <tr>
  10030. <th class="taR">合计</th>
  10031. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  10032. </tr>';
  10033. $html .= '
  10034. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  10035. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  10036. <tr><th class="taC" colspan="2">报销说明</th></tr>
  10037. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  10038. <tr class="warning">
  10039. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  10040. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  10041. </tr>
  10042. </tbody>
  10043. </table>';
  10044. } elseif ($detail ['Rtype'] == 2) {
  10045. $html .= '
  10046. <table class="table table-bordered table-condensed">
  10047. <tbody>
  10048. <tr>
  10049. <th colspan="2" class="taC">办事处相关费用</th>
  10050. </tr>';
  10051. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  10052. $html .= '
  10053. <tr>
  10054. <th>' . $value ['name'] . '</th>
  10055. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10056. </tr>';
  10057. }
  10058. $html .= '
  10059. <tr>
  10060. <th class="taR">合计</th>
  10061. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  10062. </tr>';
  10063. $html .= '
  10064. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  10065. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  10066. <tr><th class="taC" colspan="2">报销说明</th></tr>
  10067. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  10068. <tr class="warning">
  10069. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  10070. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  10071. </tr>
  10072. </tbody>
  10073. </table>';
  10074. } elseif ($detail ['Rtype'] == 1) {
  10075. if ($detail ['loanRid'] != 0&& !empty($detail['accountItem'])) {
  10076. $html .= '<table class="table table-bordered table-condensed">
  10077. <tbody>
  10078. <tr>
  10079. <th colspan="2" class="taC">日常相关费用</th>
  10080. </tr>';
  10081. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  10082. $html .= '
  10083. <tr>
  10084. <th>' . $value ['name'] . '</th>
  10085. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10086. </tr>';
  10087. }
  10088. $html .= '
  10089. <tr>
  10090. <th class="taR">合计</th>
  10091. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  10092. </tr>';
  10093. $html .= '<tr>
  10094. <th colspan="2" class="taC">差旅相关费用</th>
  10095. </tr>';
  10096. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  10097. $html .= '
  10098. <tr>
  10099. <th>' . $value ['name'] . '</th>
  10100. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10101. </tr>';
  10102. }
  10103. $html .= '
  10104. <tr>
  10105. <th class="taR">合计</th>
  10106. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  10107. </tr>';
  10108. $html .= '<tr>
  10109. <th colspan="2" class="taC">培训班费用</th>
  10110. </tr>';
  10111. foreach ( $detail ['accountItem'] ['培训班费用'] as $key => $value ) {
  10112. $html .= '
  10113. <tr>
  10114. <th>' . $value ['name'] . '</th>
  10115. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10116. </tr>';
  10117. }
  10118. $html .= '
  10119. <tr>
  10120. <th class="taR">合计</th>
  10121. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['trainSum'] . '</td>
  10122. </tr>';
  10123. $html .= '<tr>
  10124. <th colspan="2" class="taC">其他</th>
  10125. </tr>';
  10126. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  10127. $html .= '
  10128. <tr>
  10129. <th>' . $value ['name'] . '</th>
  10130. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10131. </tr>';
  10132. }
  10133. $html .= '
  10134. <tr>
  10135. <th class="taR">合计</th>
  10136. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  10137. </tr>';
  10138. $html .= '<tr>
  10139. <th colspan="2" class="taC">报销金额调整</th>
  10140. </tr>';
  10141. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  10142. $html .= '
  10143. <tr>
  10144. <th>' . $value ['name'] . '</th>
  10145. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10146. </tr>';
  10147. }
  10148. $html .= '
  10149. <tr>
  10150. <th class="taR">合计</th>
  10151. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  10152. </tr>';
  10153. $html .= '
  10154. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  10155. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  10156. <tr><th class="taC" colspan="2">报销说明</th></tr>
  10157. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  10158. <tr class="warning">
  10159. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  10160. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  10161. </tr>
  10162. </tbody>
  10163. </table>';
  10164. }
  10165. Doo::loadModel ( 'loanReceipt' );
  10166. $loanReceipt = new loanReceipt ();
  10167. $loanList = $loanReceipt->getOne ( array (
  10168. 'where' => 'rid=' . $detail ['loanRid'],
  10169. 'desc' => 'rid',
  10170. 'asArray' => true
  10171. ) );
  10172. // print_r($loanList);
  10173. $html .= '<table class="table table-bordered table-condensed">
  10174. <tbody>
  10175. <tr>
  10176. <th colspan="2" class="taC">借款费用</th>
  10177. </tr>';
  10178. foreach ( $detail ['loanItem'] ['借款费用'] as $key => $value ) {
  10179. $html .= '<tr>
  10180. <th>' . $value ['name'] . '</th>
  10181. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10182. </tr>';
  10183. }
  10184. $html .= '<tr>
  10185. <th class="taC" colspan="2">产生费用所在办事处</th>
  10186. </tr>
  10187. <tr>
  10188. <th style="text-align: center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th>
  10189. </tr>
  10190. <tr>
  10191. <th class="taC" colspan="2">费用说明</th>
  10192. </tr>
  10193. <tr>
  10194. <td colspan="2">' . $loanList ['explanation'] . '</td>
  10195. </tr>
  10196. <tr class="warning">
  10197. <td class="taR"><b>(' . $loanList ['receiptOrder'] . ')本次费用合计</b></td>
  10198. <td class="taR"><b style="font-size: 24px">¥' . $detail ['loanSum'] . '</b><br>' . $detail ['loanSumCN'] . '</td>
  10199. </tr>
  10200. </tbody>
  10201. </table>
  10202. ';
  10203. }
  10204. return $html;
  10205. }
  10206. /**
  10207. * 计算流水
  10208. */
  10209. function getWasteBookStatistics($waste = array(), $inComeStatistics) {
  10210. $bakWaste ['bank'] = array (
  10211. 'CGBDeposit' => 0,
  10212. 'ICBCDeposit' => 0,
  10213. 'HUADeposit' => 0,
  10214. 'PersonalDeposit' => 0,
  10215. );
  10216. $bakWaste ['financial'] = array (
  10217. 'current' => array(
  10218. 'CGBDeposit' => 0,
  10219. 'ICBCDeposit' => 0,
  10220. ),
  10221. 'fixed' => array(
  10222. 'CGBDeposit' => 0,
  10223. 'ICBCDeposit' => 0,
  10224. ),
  10225. );
  10226. // 存款
  10227. foreach ( $waste ['bank'] as $key => $value ) {
  10228. // 收入
  10229. foreach ( $inComeStatistics ['incomeStatistics'] as $k => $v ) {
  10230. // 广发
  10231. if ($v ['accountBank'] == 'CGBDeposit'&&$key== 'CGBDeposit') {
  10232. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  10233. }
  10234. // 工商
  10235. if ($v ['accountBank'] == 'ICBCDeposit'&&$key== 'ICBCDeposit') {
  10236. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  10237. }
  10238. // 华润
  10239. if ($v ['accountBank'] == 'HUADeposit'&&$key== 'HUADeposit') {
  10240. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  10241. }
  10242. // 个人
  10243. if ($v ['accountBank'] == 'PersonalDeposit'&&$key== 'PersonalDeposit') {
  10244. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  10245. }
  10246. }
  10247. }
  10248. foreach ( $waste ['bank'] as $key => $value ) {
  10249. // 支出
  10250. foreach ( $inComeStatistics ['expenditureStatistics'] as $k => $v ) {
  10251. // 广发
  10252. if ($v ['accountBank'] == 'CGBDeposit' &&$key== 'CGBDeposit') {
  10253. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  10254. }
  10255. // 工商
  10256. if ($v ['accountBank'] == 'ICBCDeposit'&&$key== 'ICBCDeposit') {
  10257. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  10258. }
  10259. // 华润
  10260. if ($v ['accountBank'] == 'HUADeposit'&&$key== 'HUADeposit') {
  10261. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  10262. }
  10263. // 个人
  10264. if ($v ['accountBank'] == 'PersonalDeposit'&&$key== 'PersonalDeposit') {
  10265. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  10266. }
  10267. }
  10268. }
  10269. // 活期
  10270. foreach ( $waste ['financial'] ['current'] as $key => $value ) {
  10271. foreach ( $inComeStatistics ['currentStatistics'] as $k => $v ) {
  10272. // 广发
  10273. if ($v ['accountBank'] == 'CGBDeposit'&&$key== 'CGBDeposit') {
  10274. $waste ['financial'] ['current'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  10275. }
  10276. // 工商
  10277. if ($v ['accountBank'] == 'ICBCDeposit'&&$key== 'ICBCDeposit') {
  10278. $waste ['financial'] ['current'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  10279. }
  10280. // 个人
  10281. if ($v ['accountBank'] == 'PersonalDeposit'&&$key== 'PersonalDeposit') {
  10282. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  10283. }
  10284. }
  10285. }
  10286. //print_r($inComeStatistics ['fixedStatistics']);
  10287. // 固期
  10288. foreach ( $waste ['financial'] ['fixed'] as $key => $value ) {
  10289. foreach ( $inComeStatistics ['fixedStatistics'] as $k => $v ) {
  10290. // 广发
  10291. if ($v ['accountBank'] == 'CGBDeposit'&&$key== 'CGBDeposit') {
  10292. $waste ['financial'] ['fixed'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  10293. }
  10294. // 工商
  10295. if ($v ['accountBank'] == 'ICBCDeposit'&&$key== 'ICBCDeposit') {
  10296. $waste ['financial'] ['fixed'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  10297. }
  10298. // 个人
  10299. if ($v ['accountBank'] == 'PersonalDeposit'&&$key== 'PersonalDeposit') {
  10300. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  10301. }
  10302. }
  10303. }
  10304. return $waste;
  10305. }
  10306. function lyt() {
  10307. Doo::loadModel ( "receiptDetail" );
  10308. $receiptDetail = new receiptDetail ();
  10309. $receiptCollectList = $receiptDetail->find ( array (
  10310. 'where' => 'status=1 ',
  10311. 'asArray' => true
  10312. ) );
  10313. foreach ( $receiptCollectList as $key => $value ) {
  10314. $receiptDetail = new receiptDetail ();
  10315. $receiptDetail->pastDate = $value ['date'];
  10316. $receiptDetail->update ( array (
  10317. 'where' => "rdid= '" . $value ['rdid'] . "'"
  10318. ) );
  10319. }
  10320. }
  10321. function staffCollectMonthDetail() {
  10322. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  10323. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  10324. if (! $year)
  10325. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  10326. if (! $month)
  10327. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  10328. Doo::loadModel ( 'staff' );
  10329. $staff = new staff ();
  10330. Doo::loadModel ( "receiptDetail" );
  10331. $receiptDetail = new receiptDetail ();
  10332. Doo::loadModel ( 'accountItem' );
  10333. $accountItem = new accountItem ();
  10334. Doo::loadModel ( 'statistics' );
  10335. $statistics = new statistics ();
  10336. Doo::loadModel ( 'L_category' );
  10337. $lCategory = new L_category ();
  10338. Doo::loadModel ( "receiptAuthorityManage" );
  10339. $receiptAuthorityManage = new receiptAuthorityManage ();
  10340. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  10341. $cidList = array ();
  10342. foreach ( $imcStaff as $key => $value ) {
  10343. array_push ( $cidList, $value ['cid'] );
  10344. }
  10345. $cidString = implode ( ',', $cidList );
  10346. $staffList = $staff->find ( array (
  10347. 'where' => 'username!="admin" and cid in (' . $cidString . ')',
  10348. 'asArray' => true
  10349. ) );
  10350. $categoryList = $staff->find ( array (
  10351. 'select' => 'COUNT(*) as count,cid,category',
  10352. 'where' => 'username !="admin" and cid in (' . $cidString . ')',
  10353. 'groupby' => 'cid',
  10354. 'asArray' => true
  10355. ) );
  10356. $list = array ();
  10357. foreach ( $categoryList as $vlu ) {
  10358. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  10359. $r1 = 0;
  10360. $r2 = 0;
  10361. $r3 = 0;
  10362. $r4 = 0;
  10363. $r5 = 0;
  10364. $r6 = 0;
  10365. $r7 = 0;
  10366. $r8 = 0;
  10367. $r9 = 0;
  10368. $r10 = 0;
  10369. $r11 = 0;
  10370. $r12 = 0;
  10371. $r13 = 0;
  10372. $r14 = 0;
  10373. $r15 = 0;
  10374. $r16 = 0;
  10375. $r17 = 0;
  10376. $r18 = 0;
  10377. $c1 = 0;
  10378. $c2 = 0;
  10379. $c3 = 0;
  10380. $c4 = 0;
  10381. $c5 = 0;
  10382. $c6 = 0;
  10383. $p1 = 0;
  10384. $p2 = 0;
  10385. $p3 = 0;
  10386. $p4 = 0;
  10387. $p5 = 0;
  10388. $p6 = 0;
  10389. $p7 = 0;
  10390. $p8 = 0;
  10391. $p9 = 0;
  10392. $p10 = 0;
  10393. $p11 = 0;
  10394. $t1 = 0;
  10395. $t2 = 0;
  10396. $t3 = 0;
  10397. $t4 = 0;
  10398. $t5 = 0;
  10399. $s1 = 0;
  10400. $m1 = 0;
  10401. foreach ( $staffList as $value ) {
  10402. if ($vlu ['cid'] == $value ['cid']) {
  10403. // pastDate
  10404. $receiptCollectList = $receiptDetail->find ( array (
  10405. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  10406. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  10407. 'groupby' => 'item,Month(pastDate),itemCategory',
  10408. 'asArray' => true
  10409. ) );
  10410. // if ($value['sid']==42){
  10411. // print_r($receiptCollectList);die;
  10412. // }
  10413. if (! empty ( $receiptCollectList )) {
  10414. $receiptL = array (
  10415. '日常相关费用' => array (),
  10416. '差旅相关费用' => array (),
  10417. '培训班费用' => array (),
  10418. '其他' => array ()
  10419. );
  10420. $html = "";
  10421. $psum = 0;
  10422. $item = array (
  10423. '市内交通费',
  10424. '市内出租费',
  10425. '办事处房租',
  10426. '电话费',
  10427. '水费',
  10428. '电费',
  10429. '办公费用',
  10430. '邮寄费',
  10431. '其他费用',
  10432. '车辆费用',
  10433. '广告费',
  10434. '团队建设费',
  10435. '物业管理费',
  10436. '宽带费',
  10437. '人员薪酬',
  10438. '公积金',
  10439. '社保'
  10440. );
  10441. foreach ( $item as $va ) {
  10442. $falg = true;
  10443. foreach ( $receiptCollectList as $v ) {
  10444. if ($v ['itemCategory'] == '日常相关费用') {
  10445. if ($v ['item'] == $va) {
  10446. if ($va == '市内交通费')
  10447. $r1 += $v ['price'];
  10448. if ($va == '市内出租费')
  10449. $r2 += $v ['price'];
  10450. if ($va == '办事处房租')
  10451. $r3 += $v ['price'];
  10452. if ($va == '电话费')
  10453. $r4 += $v ['price'];
  10454. if ($va == '水费')
  10455. $r5 += $v ['price'];
  10456. if ($va == '电费')
  10457. $r6 += $v ['price'];
  10458. if ($va == '办公费用')
  10459. $r7 += $v ['price'];
  10460. if ($va == '邮寄费')
  10461. $r8 += $v ['price'];
  10462. if ($va == '其他费用')
  10463. $r9 += $v ['price'];
  10464. if ($va == '车辆费用')
  10465. $r10 += $v ['price'];
  10466. if ($va == '广告费')
  10467. $r11 += $v ['price'];
  10468. if ($va == '团队建设费')
  10469. $r13 += $v ['price'];
  10470. if ($va == '物业管理费')
  10471. $r14 += $v ['price'];
  10472. if ($va == '宽带费')
  10473. $r15 += $v ['price'];
  10474. if ($va == '公积金')
  10475. $r16 += $v ['price'];
  10476. if ($va == '社保')
  10477. $r17 += $v ['price'];
  10478. if ($va == '人员薪酬')
  10479. $r18 += $v ['price'];
  10480. $psum += $v ['price'];
  10481. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10482. $falg = false;
  10483. break;
  10484. }
  10485. }
  10486. }
  10487. if ($falg)
  10488. $html .= '<td class="taR">-</td>';
  10489. }
  10490. $r12 += $psum;
  10491. if (! empty ( $psum ))
  10492. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  10493. else
  10494. $psum = '<td class="colGreen taR">-</td>';
  10495. $receiptL ['日常相关费用'] = $psum . $html;
  10496. /* ----------------------------------- */
  10497. $html = "";
  10498. $psum = 0;
  10499. $item = array (
  10500. '往来交通费',
  10501. '市内交通费',
  10502. '出差住宿费',
  10503. '出差补助',
  10504. '其他费用'
  10505. );
  10506. foreach ( $item as $va ) {
  10507. $falg = true;
  10508. foreach ( $receiptCollectList as $v ) {
  10509. if ($v ['itemCategory'] == '差旅相关费用') {
  10510. if ($v ['item'] == $va) {
  10511. if ($va == '往来交通费')
  10512. $c1 += $v ['price'];
  10513. if ($va == '市内交通费')
  10514. $c2 += $v ['price'];
  10515. if ($va == '出差住宿费')
  10516. $c3 += $v ['price'];
  10517. if ($va == '出差补助')
  10518. $c4 += $v ['price'];
  10519. if ($va == '其他费用')
  10520. $c5 += $v ['price'];
  10521. $psum += $v ['price'];
  10522. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10523. $falg = false;
  10524. break;
  10525. }
  10526. }
  10527. }
  10528. if ($falg)
  10529. $html .= '<td class="taR">-</td>';
  10530. }
  10531. $c6 += $psum;
  10532. if (! empty ( $psum ))
  10533. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  10534. else
  10535. $psum = '<td class="colGreen taR">-</td>';
  10536. $receiptL ['差旅相关费用'] = $psum . $html;
  10537. /* ------------------------------------- */
  10538. $html = "";
  10539. $psum = 0;
  10540. $item = array (
  10541. '场租费',
  10542. '薪酬',
  10543. '住宿费',
  10544. '交通费',
  10545. '餐饮费',
  10546. '办公费',
  10547. '公关费',
  10548. '其他',
  10549. '电话费',
  10550. '邮寄费'
  10551. );
  10552. foreach ( $item as $va ) {
  10553. $falg = true;
  10554. foreach ( $receiptCollectList as $v ) {
  10555. if ($v ['itemCategory'] == '培训班费用') {
  10556. if ($v ['item'] == $va) {
  10557. if ($va == '场租费')
  10558. $p1 += $v ['price'];
  10559. if ($va == '薪酬')
  10560. $p2 += $v ['price'];
  10561. if ($va == '住宿费')
  10562. $p3 += $v ['price'];
  10563. if ($va == '交通费')
  10564. $p4 += $v ['price'];
  10565. if ($va == '餐饮费')
  10566. $p5 += $v ['price'];
  10567. if ($va == '办公费')
  10568. $p6 += $v ['price'];
  10569. if ($va == '公关费')
  10570. $p7 += $v ['price'];
  10571. if ($va == '其他')
  10572. $p8 += $v ['price'];
  10573. if ($va == '电话费')
  10574. $p9 += $v ['price'];
  10575. if ($va == '邮寄费')
  10576. $p10 += $v ['price'];
  10577. $psum += $v ['price'];
  10578. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10579. $falg = false;
  10580. break;
  10581. }
  10582. }
  10583. }
  10584. if ($falg)
  10585. $html .= '<td class="taR">-</td>';
  10586. }
  10587. $p11 += $psum;
  10588. if (! empty ( $psum ))
  10589. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  10590. else
  10591. $psum = '<td class="colGreen taR">-</td>';
  10592. $receiptL ['培训班费用'] = $psum . $html;
  10593. /* ------------------------------------- */
  10594. $html = "";
  10595. $psum = 0;
  10596. $item = array (
  10597. '公关费',
  10598. '广告费',
  10599. '借款',
  10600. '可自加费用'
  10601. );
  10602. foreach ( $item as $va ) {
  10603. $falg = true;
  10604. foreach ( $receiptCollectList as $v ) {
  10605. if ($v ['itemCategory'] == '其他') {
  10606. // if ($value['sid']==42){
  10607. //
  10608. // echo var_dump($v['item']);
  10609. // echo var_dump($va);
  10610. // echo var_dump($v['item']==" ".$va);
  10611. // echo $v['item']."==".$va."/<br/>";
  10612. // //print_r( $receiptCollectList);//echo $va;
  10613. // }
  10614. if (trim ( $v ['item'] ) == $va) {
  10615. if ($va == '公关费')
  10616. $t1 += $v ['price'];
  10617. if ($va == '广告费') {
  10618. $t2 += $v ['price'];
  10619. }
  10620. if ($va == '借款')
  10621. $t3 += $v ['price'];
  10622. if ($va == '可自加费用')
  10623. $t4 += $v ['price'];
  10624. $psum += $v ['price'];
  10625. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10626. $falg = false;
  10627. break;
  10628. }
  10629. }
  10630. }
  10631. if ($falg)
  10632. $html .= '<td class="taR">-</td>';
  10633. }
  10634. $t5 += $psum;
  10635. if (! empty ( $psum ))
  10636. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  10637. else
  10638. $psum = '<td class="colGreen taR">-</td>';
  10639. $receiptL ['其他'] = $psum . $html;
  10640. /* ------------------------------------- */
  10641. $html = "";
  10642. $psum = 0;
  10643. foreach ( $receiptCollectList as $v ) {
  10644. if ($v ['itemCategory'] == '报销金额调整') {
  10645. if (! empty ( $v ['price'] )) {
  10646. $psum += $v ['price'];
  10647. }
  10648. }
  10649. }
  10650. $s1 += $psum;
  10651. if (! empty ( $psum ))
  10652. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  10653. else
  10654. $psum = '<td class="taR colOrange">-</td>';
  10655. $receiptL ['报销金额调整'] = $psum . $html;
  10656. } else {
  10657. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  10658. <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>
  10659. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10660. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  10661. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10662. $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>
  10663. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10664. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10665. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  10666. }
  10667. $monthStaffPrice = $receiptDetail->find ( array (
  10668. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  10669. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  10670. 'groupby' => 'Month(pastDate)',
  10671. 'asArray' => true
  10672. ) );
  10673. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  10674. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  10675. $m1 += $monthStaffPrice [0] ['price'];
  10676. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  10677. } else
  10678. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  10679. $receiptL ['usernameEn'] = urlencode ( $value ['username'] );
  10680. $list [$value ['username']] = $receiptL;
  10681. }
  10682. }
  10683. $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>
  10684. <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>
  10685. <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>';
  10686. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  10687. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  10688. $receiptL ['培训班费用'] = '<td class="colGreen taR">' . $p11 . '</td><td class="taR">' . $p1 . '</td><td class="taR">' . $p2 . '</td><td class="taR">' . $p3 . '</td><td class="taR">' . $p4 . '</td>
  10689. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td><td class="taR">' . $p9 . '</td><td class="taR">' . $p10 . '</td>';
  10690. $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>';
  10691. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  10692. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  10693. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  10694. }
  10695. $data ['list'] = $list;
  10696. // print_r($list);
  10697. $receiptCollectList = $receiptDetail->find ( array (
  10698. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  10699. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  10700. 'groupby' => 'item,Month(pastDate),itemCategory',
  10701. 'asArray' => true
  10702. ) );
  10703. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  10704. // statistics html
  10705. $stList = $statistics->getOne ( array (
  10706. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  10707. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10708. 'groupby' => 'Month(date)',
  10709. 'asArray' => true
  10710. ) );
  10711. if (empty ( $stList ))
  10712. $stList = array (
  10713. 'rePrice' => 0,
  10714. 'agPrice' => 0
  10715. );
  10716. $data ['stList'] = array (
  10717. 'rePrice' => $stList ['rePrice'],
  10718. 'agPrice' => $stList ['agPrice'],
  10719. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10720. );
  10721. $monthHtml = "";
  10722. for($i = 1; $i <= 12; $i ++) {
  10723. if ($i == $month)
  10724. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  10725. else
  10726. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  10727. }
  10728. $data ['monthHtml'] = $monthHtml;
  10729. $data ['year'] = $year;
  10730. $data ['month'] = $month;
  10731. $data ['memu'] = "receipt";
  10732. $data ['staff'] = $this->staff;
  10733. $data ['receiptMemu'] = 'companyCategoryCollect';
  10734. $data ['verifyId'] = $this->verifyId;
  10735. $data ['executeId'] = $this->executeId;
  10736. $this->render ( "/admin/staffCollectMonthDetail", $data );
  10737. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  10738. }
  10739. function staffCollectMonthDetail2() {
  10740. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  10741. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  10742. if (! $year)
  10743. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  10744. if (! $month)
  10745. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  10746. Doo::loadModel ( 'staff' );
  10747. $staff = new staff ();
  10748. Doo::loadModel ( "receiptDetail" );
  10749. $receiptDetail = new receiptDetail ();
  10750. Doo::loadModel ( 'accountItem' );
  10751. $accountItem = new accountItem ();
  10752. Doo::loadModel ( 'statistics' );
  10753. $statistics = new statistics ();
  10754. Doo::loadModel ( 'L_category' );
  10755. $lCategory = new L_category ();
  10756. $staffList = $staff->find ( array (
  10757. 'where' => 'username!="admin"',
  10758. 'asArray' => true
  10759. ) );
  10760. $categoryList = $staff->find ( array (
  10761. 'select' => 'COUNT(*) as count,cid,category',
  10762. 'where' => 'username !="admin"',
  10763. 'groupby' => 'cid',
  10764. 'asArray' => true
  10765. ) );
  10766. $list = array ();
  10767. foreach ( $categoryList as $vlu ) {
  10768. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  10769. $r1 = 0;
  10770. $r2 = 0;
  10771. $r3 = 0;
  10772. $r4 = 0;
  10773. $r5 = 0;
  10774. $r6 = 0;
  10775. $r7 = 0;
  10776. $r8 = 0;
  10777. $r9 = 0;
  10778. $r10 = 0;
  10779. $r11 = 0;
  10780. $r12 = 0;
  10781. $r13 = 0;
  10782. $r14 = 0;
  10783. $r15 = 0;
  10784. $c1 = 0;
  10785. $c2 = 0;
  10786. $c3 = 0;
  10787. $c4 = 0;
  10788. $c5 = 0;
  10789. $c6 = 0;
  10790. $p1 = 0;
  10791. $p2 = 0;
  10792. $p3 = 0;
  10793. $p4 = 0;
  10794. $p5 = 0;
  10795. $p6 = 0;
  10796. $p7 = 0;
  10797. $p8 = 0;
  10798. $p9 = 0;
  10799. $t1 = 0;
  10800. $t2 = 0;
  10801. $t3 = 0;
  10802. $t4 = 0;
  10803. $t5 = 0;
  10804. $s1 = 0;
  10805. $m1 = 0;
  10806. foreach ( $staffList as $value ) {
  10807. if ($vlu ['cid'] == $value ['cid']) {
  10808. $receiptCollectList = $receiptDetail->find ( array (
  10809. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  10810. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  10811. 'groupby' => 'item,Month(date),itemCategory',
  10812. 'asArray' => true
  10813. ) );
  10814. if (! empty ( $receiptCollectList )) {
  10815. $receiptL = array (
  10816. '日常相关费用' => array (),
  10817. '差旅相关费用' => array (),
  10818. '培训班费用' => array (),
  10819. '其他' => array ()
  10820. );
  10821. $html = "";
  10822. $psum = 0;
  10823. $item = array (
  10824. '市内交通费',
  10825. '市内出租费',
  10826. '办事处房租',
  10827. '电话费',
  10828. '水费',
  10829. '电费',
  10830. '办公费用',
  10831. '邮寄费',
  10832. '其他费用',
  10833. '车辆费用',
  10834. '广告费',
  10835. '团队建设费',
  10836. '物业管理费',
  10837. '宽带费'
  10838. );
  10839. foreach ( $item as $va ) {
  10840. $falg = true;
  10841. foreach ( $receiptCollectList as $v ) {
  10842. if ($v ['itemCategory'] == '日常相关费用') {
  10843. if ($v ['item'] == $va) {
  10844. if ($va == '市内交通费')
  10845. $r1 += $v ['price'];
  10846. if ($va == '市内出租费')
  10847. $r2 += $v ['price'];
  10848. if ($va == '办事处房租')
  10849. $r3 += $v ['price'];
  10850. if ($va == '电话费')
  10851. $r4 += $v ['price'];
  10852. if ($va == '水费')
  10853. $r5 += $v ['price'];
  10854. if ($va == '电费')
  10855. $r6 += $v ['price'];
  10856. if ($va == '办公费用')
  10857. $r7 += $v ['price'];
  10858. if ($va == '邮寄费')
  10859. $r8 += $v ['price'];
  10860. if ($va == '其他费用')
  10861. $r9 += $v ['price'];
  10862. if ($va == '车辆费用')
  10863. $r10 += $v ['price'];
  10864. if ($va == '广告费')
  10865. $r11 += $v ['price'];
  10866. if ($va == '团队建设费')
  10867. $r13 += $v ['price'];
  10868. if ($va == '物业管理费')
  10869. $r14 += $v ['price'];
  10870. if ($va == '宽带费')
  10871. $r15 += $v ['price'];
  10872. $psum += $v ['price'];
  10873. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10874. $falg = false;
  10875. break;
  10876. }
  10877. }
  10878. }
  10879. if ($falg)
  10880. $html .= '<td class="taR">-</td>';
  10881. }
  10882. $r12 += $psum;
  10883. if (! empty ( $psum ))
  10884. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  10885. else
  10886. $psum = '<td class="colGreen taR">-</td>';
  10887. $receiptL ['日常相关费用'] = $psum . $html;
  10888. /* ----------------------------------- */
  10889. $html = "";
  10890. $psum = 0;
  10891. $item = array (
  10892. '往来交通费',
  10893. '市内交通费',
  10894. '出差住宿费',
  10895. '出差补助',
  10896. '其他费用'
  10897. );
  10898. foreach ( $item as $va ) {
  10899. $falg = true;
  10900. foreach ( $receiptCollectList as $v ) {
  10901. if ($v ['itemCategory'] == '差旅相关费用') {
  10902. if ($v ['item'] == $va) {
  10903. if ($va == '往来交通费')
  10904. $c1 += $v ['price'];
  10905. if ($va == '市内交通费')
  10906. $c2 += $v ['price'];
  10907. if ($va == '出差住宿费')
  10908. $c3 += $v ['price'];
  10909. if ($va == '出差补助')
  10910. $c4 += $v ['price'];
  10911. if ($va == '其他费用')
  10912. $c5 += $v ['price'];
  10913. $psum += $v ['price'];
  10914. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10915. $falg = false;
  10916. break;
  10917. }
  10918. }
  10919. }
  10920. if ($falg)
  10921. $html .= '<td class="taR">-</td>';
  10922. }
  10923. $c6 += $psum;
  10924. if (! empty ( $psum ))
  10925. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  10926. else
  10927. $psum = '<td class="colGreen taR">-</td>';
  10928. $receiptL ['差旅相关费用'] = $psum . $html;
  10929. /* ------------------------------------- */
  10930. $html = "";
  10931. $psum = 0;
  10932. $item = array (
  10933. '场租费',
  10934. '薪酬',
  10935. '住宿费',
  10936. '交通费',
  10937. '餐饮费',
  10938. '办公费',
  10939. '公关费',
  10940. '其他'
  10941. );
  10942. foreach ( $item as $va ) {
  10943. $falg = true;
  10944. foreach ( $receiptCollectList as $v ) {
  10945. if ($v ['itemCategory'] == '培训班费用') {
  10946. if ($v ['item'] == $va) {
  10947. if ($va == '场租费')
  10948. $p1 += $v ['price'];
  10949. if ($va == '薪酬')
  10950. $p2 += $v ['price'];
  10951. if ($va == '住宿费')
  10952. $p3 += $v ['price'];
  10953. if ($va == '交通费')
  10954. $p4 += $v ['price'];
  10955. if ($va == '餐饮费')
  10956. $p5 += $v ['price'];
  10957. if ($va == '办公费')
  10958. $p6 += $v ['price'];
  10959. if ($va == '公关费')
  10960. $p7 += $v ['price'];
  10961. if ($va == '其他')
  10962. $p8 += $v ['price'];
  10963. $psum += $v ['price'];
  10964. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10965. $falg = false;
  10966. break;
  10967. }
  10968. }
  10969. }
  10970. if ($falg)
  10971. $html .= '<td class="taR">-</td>';
  10972. }
  10973. $p9 += $psum;
  10974. if (! empty ( $psum ))
  10975. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  10976. else
  10977. $psum = '<td class="colGreen taR">-</td>';
  10978. $receiptL ['培训班费用'] = $psum . $html;
  10979. /* ------------------------------------- */
  10980. $html = "";
  10981. $psum = 0;
  10982. $item = array (
  10983. '公关费',
  10984. '广告费',
  10985. '借款',
  10986. '可自加费用'
  10987. );
  10988. foreach ( $item as $va ) {
  10989. $falg = true;
  10990. foreach ( $receiptCollectList as $v ) {
  10991. if ($v ['itemCategory'] == '其他') {
  10992. if ($v ['item'] == $va) {
  10993. if ($va == '公关费')
  10994. $t1 += $v ['price'];
  10995. if ($va == '广告费')
  10996. $t2 += $v ['price'];
  10997. if ($va == '借款')
  10998. $t3 += $v ['price'];
  10999. if ($va == '可自加费用')
  11000. $t4 += $v ['price'];
  11001. $psum += $v ['price'];
  11002. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11003. $falg = false;
  11004. break;
  11005. }
  11006. }
  11007. }
  11008. if ($falg)
  11009. $html .= '<td class="taR">-</td>';
  11010. }
  11011. $t5 += $psum;
  11012. if (! empty ( $psum ))
  11013. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  11014. else
  11015. $psum = '<td class="colGreen taR">-</td>';
  11016. $receiptL ['其他'] = $psum . $html;
  11017. /* ------------------------------------- */
  11018. $html = "";
  11019. $psum = 0;
  11020. foreach ( $receiptCollectList as $v ) {
  11021. if ($v ['itemCategory'] == '报销金额调整') {
  11022. if (! empty ( $v ['price'] )) {
  11023. $psum += $v ['price'];
  11024. }
  11025. }
  11026. }
  11027. $s1 += $psum;
  11028. if (! empty ( $psum ))
  11029. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  11030. else
  11031. $psum = '<td class="taR colOrange">-</td>';
  11032. $receiptL ['报销金额调整'] = $psum . $html;
  11033. } else {
  11034. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  11035. <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>';
  11036. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  11037. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  11038. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  11039. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  11040. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  11041. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  11042. }
  11043. $monthStaffPrice = $receiptDetail->find ( array (
  11044. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  11045. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  11046. 'asArray' => true
  11047. ) );
  11048. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  11049. $m1 += $monthStaffPrice [0] ['price'];
  11050. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  11051. } else
  11052. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  11053. $list [$value ['username']] = $receiptL;
  11054. }
  11055. }
  11056. $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>
  11057. <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>
  11058. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  11059. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  11060. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  11061. $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>
  11062. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  11063. $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>';
  11064. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  11065. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  11066. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  11067. }
  11068. $data ['list'] = $list;
  11069. $receiptCollectList = $receiptDetail->find ( array (
  11070. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  11071. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  11072. 'groupby' => 'item,Month(date),itemCategory',
  11073. 'asArray' => true
  11074. ) );
  11075. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  11076. // statistics html
  11077. $stList = $statistics->getOne ( array (
  11078. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  11079. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  11080. 'groupby' => 'Month(date)',
  11081. 'asArray' => true
  11082. ) );
  11083. if (empty ( $stList ))
  11084. $stList = array (
  11085. 'rePrice' => 0,
  11086. 'agPrice' => 0
  11087. );
  11088. $data ['stList'] = array (
  11089. 'rePrice' => $stList ['rePrice'],
  11090. 'agPrice' => $stList ['agPrice'],
  11091. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  11092. );
  11093. $monthHtml = "";
  11094. for($i = 1; $i <= 12; $i ++) {
  11095. if ($i == $month)
  11096. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  11097. else
  11098. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  11099. }
  11100. $data ['monthHtml'] = $monthHtml;
  11101. $data ['year'] = $year;
  11102. $data ['month'] = $month;
  11103. $data ['memu'] = "receipt";
  11104. $data ['staff'] = $this->staff;
  11105. $data ['receiptMemu'] = 'companyCategoryCollect';
  11106. $data ['verifyId'] = $this->verifyId;
  11107. $data ['executeId'] = $this->executeId;
  11108. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  11109. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  11110. }
  11111. /**
  11112. * 用户报销单列表
  11113. */
  11114. function receiptStatisticsStaffDetail() {
  11115. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  11116. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  11117. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  11118. Doo::loadModel ( "receipt" );
  11119. $receipt = new receipt ();
  11120. Doo::loadModel ( "receiptDetail" );
  11121. $receiptDetail = new receiptDetail ();
  11122. Doo::loadModel ( 'staff' );
  11123. $staff = new staff ();
  11124. Doo::loadModel ( 'accountItem' );
  11125. $accountItem = new accountItem ();
  11126. Doo::loadModel ( 'statistics' );
  11127. $statistics = new statistics ();
  11128. if (! empty ( $username )) {
  11129. $username = addslashes ( urldecode ( $username ) );
  11130. $staffDetail = $staff->getStaffByName ( $username );
  11131. if (empty ( $staffDetail ))
  11132. die ( 'illegal request' );
  11133. $list = $receipt->getReceiptBySid ( $staffDetail ['sid'], $year, $month );
  11134. $itemList = $accountItem->getAccountItem ();
  11135. $itemHtml = '';
  11136. $categoryHtml = '';
  11137. $itemKeyList = array_keys ( $itemList );
  11138. $revisePrice = 0;
  11139. // 报销单内容详情
  11140. foreach ( $list as $key => $value ) {
  11141. $accountItemList = json_decode ( $value ['accountItem'], true );
  11142. $list [$key] ['accountItemList'] = $accountItemList;
  11143. $receiptItemHtml = '';
  11144. foreach ( $itemKeyList as $v ) {
  11145. if ($v == '日常相关费用')
  11146. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['agencySum'] . '</td>';
  11147. elseif ($v == '差旅相关费用')
  11148. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['travelSum'] . '</td>';
  11149. elseif ($v == '培训班费用')
  11150. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['trainSum'] . '</td>';
  11151. elseif ($v == '其他')
  11152. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['otherSum'] . '</td>';
  11153. foreach ( $itemList [$v] as $ke => $va ) {
  11154. $falg = true;
  11155. if (! empty ( $accountItemList [$v] )) {
  11156. foreach ( $accountItemList [$v] as $ve ) {
  11157. if ($va ['name'] == $ve ['name']) {
  11158. $receiptItemHtml .= '<td class="taR">' . $ve ['price'] . '</td>';
  11159. $falg = false;
  11160. break;
  11161. }
  11162. }
  11163. }
  11164. if ($falg)
  11165. $receiptItemHtml .= '<td class="taR"></td>';
  11166. }
  11167. }
  11168. // 金额调整和费用查看
  11169. $revisePrice += $value ['revisePrice'];
  11170. $receiptItemHtml .= '<td class="taR">' . $value ['revisePrice'] . '</td>';
  11171. $receiptItemHtml .= '<td class="taR"><a href="#detail" data-toggle="modal" onclick=showExplanation("' . $value ['explanation'] . '")>查看</a></td>';
  11172. $list [$key] ['receiptItemHtml'] = $receiptItemHtml;
  11173. }
  11174. // 报销单合计
  11175. $receiptTotalList = $receiptDetail->getReceiptTotalItem ( $staffDetail ['sid'], $year, $month );
  11176. $rtl = $receiptDetail->getReceiptTotalItemCategory ( $staffDetail ['sid'], $year, $month );
  11177. $receiptTotalHtml = '';
  11178. // 报销单项目抬头
  11179. foreach ( $itemKeyList as $value ) {
  11180. $count = count ( $itemList [$value] ) + 1;
  11181. $itemHtml .= '<th class="taC" colspan="' . $count . '">' . $value . '</th>';
  11182. $categoryHtml .= '<th class="taC">合计</th>';
  11183. foreach ( $rtl as $rtlValue ) {
  11184. if ($rtlValue ['itemCategory'] == $value) {
  11185. $receiptTotalHtml .= '<th>' . $rtlValue ['price'] . '</th>';
  11186. break;
  11187. }
  11188. }
  11189. foreach ( $itemList [$value] as $k => $v ) {
  11190. $categoryHtml .= '<th class="taC">' . $v ['name'] . '</th>';
  11191. // 合计
  11192. $falg = true;
  11193. foreach ( $receiptTotalList as $ve ) {
  11194. if ($ve ['itemCategory'] == $value && $ve ['item'] == $v ['name']) {
  11195. $receiptTotalHtml .= '<th >' . $ve ['price'] . '</th>';
  11196. $falg = false;
  11197. break;
  11198. }
  11199. }
  11200. if ($falg)
  11201. $receiptTotalHtml .= '<th></th>';
  11202. }
  11203. }
  11204. $receiptTotalHtml .= '<th>' . $revisePrice . '</th>';
  11205. $stList = $statistics->getStatisticsBySid ( $staffDetail ['sid'], $year, $month );
  11206. if (empty ( $stList ))
  11207. $stList = array (
  11208. 'rePrice' => 0,
  11209. 'agPrice' => 0
  11210. );
  11211. $data ['stList'] = array (
  11212. 'rePrice' => $stList ['rePrice'],
  11213. 'agPrice' => $stList ['agPrice'],
  11214. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  11215. );
  11216. $monthHtml = "";
  11217. for($i = 1; $i <= 12; $i ++) {
  11218. if ($i == $month)
  11219. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  11220. else
  11221. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  11222. }
  11223. $data ['username'] = urlencode ( $username );
  11224. $data ['usernameEN'] = $username;
  11225. $data ['monthHtml'] = $monthHtml;
  11226. $data ['receiptTotalHtml'] = $receiptTotalHtml;
  11227. $data ['list'] = $list;
  11228. $data ['categoryHtml'] = $categoryHtml;
  11229. $data ['itemHtml'] = $itemHtml;
  11230. $data ['itemList'] = $itemList;
  11231. $data ['year'] = $year;
  11232. $data ['month'] = $month;
  11233. $data ['memu'] = "receipt";
  11234. $data ['staff'] = $this->staff;
  11235. $data ['receiptMemu'] = 'companyCategoryCollect';
  11236. $data ['verifyId'] = $this->verifyId;
  11237. $data ['executeId'] = $this->executeId;
  11238. $this->render ( "/admin/receiptStatisticsStaffDetail", $data );
  11239. }
  11240. die ( 'illegal request' );
  11241. }
  11242. function companyMonthCollectDetail() {
  11243. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  11244. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  11245. if (! $year)
  11246. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  11247. if (! $month)
  11248. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  11249. Doo::loadModel ( 'staff' );
  11250. $staff = new staff ();
  11251. Doo::loadModel ( "receiptDetail" );
  11252. $receiptDetail = new receiptDetail ();
  11253. Doo::loadModel ( 'accountItem' );
  11254. $accountItem = new accountItem ();
  11255. Doo::loadModel ( 'statistics' );
  11256. $statistics = new statistics ();
  11257. Doo::loadModel ( 'L_category' );
  11258. $lCategory = new L_category ();
  11259. $staffList = $staff->find ( array (
  11260. 'where' => 'username!="admin"',
  11261. 'asArray' => true
  11262. ) );
  11263. $categoryList = $lCategory->find ( array (
  11264. 'asArray' => true
  11265. ) );
  11266. $list = array ();
  11267. foreach ( $categoryList as $value ) {
  11268. $receiptCollectList = $receiptDetail->find ( array (
  11269. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  11270. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  11271. 'groupby' => 'item,Month(pastDate),itemCategory',
  11272. 'asArray' => true
  11273. ) );
  11274. if (! empty ( $receiptCollectList )) {
  11275. $receiptL = array (
  11276. '日常相关费用' => array (),
  11277. '差旅相关费用' => array (),
  11278. '培训班费用' => array (),
  11279. '其他' => array ()
  11280. );
  11281. $html = "";
  11282. $psum = 0;
  11283. $item = array (
  11284. '市内交通费',
  11285. '市内出租费',
  11286. '办事处房租',
  11287. '电话费',
  11288. '水费',
  11289. '电费',
  11290. '办公费用',
  11291. '邮寄费',
  11292. '其他费用',
  11293. '车辆费用',
  11294. '广告费',
  11295. '团队建设费'
  11296. );
  11297. foreach ( $item as $va ) {
  11298. $falg = true;
  11299. foreach ( $receiptCollectList as $v ) {
  11300. if ($v ['itemCategory'] == '日常相关费用') {
  11301. if ($v ['item'] == $va) {
  11302. $psum += $v ['price'];
  11303. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11304. $falg = false;
  11305. break;
  11306. }
  11307. }
  11308. }
  11309. if ($falg)
  11310. $html .= '<td class="taR">-</td>';
  11311. }
  11312. if (! empty ( $psum ))
  11313. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  11314. else
  11315. $psum = '<td class="colGreen taR">-</td>';
  11316. $receiptL ['日常相关费用'] = $psum . $html;
  11317. /* ----------------------------------- */
  11318. $html = "";
  11319. $psum = 0;
  11320. $item = array (
  11321. '往来交通费',
  11322. '市内交通费',
  11323. '出差住宿费',
  11324. '出差补助',
  11325. '其他费用'
  11326. );
  11327. foreach ( $item as $va ) {
  11328. $falg = true;
  11329. foreach ( $receiptCollectList as $v ) {
  11330. if ($v ['itemCategory'] == '差旅相关费用') {
  11331. if ($v ['item'] == $va) {
  11332. $psum += $v ['price'];
  11333. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11334. $falg = false;
  11335. break;
  11336. }
  11337. }
  11338. }
  11339. if ($falg)
  11340. $html .= '<td class="taR">-</td>';
  11341. }
  11342. if (! empty ( $psum ))
  11343. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  11344. else
  11345. $psum = '<td class="colGreen taR">-</td>';
  11346. $receiptL ['差旅相关费用'] = $psum . $html;
  11347. /* ------------------------------------- */
  11348. $html = "";
  11349. $psum = 0;
  11350. $item = array (
  11351. '场租费',
  11352. '薪酬',
  11353. '住宿费',
  11354. '交通费',
  11355. '餐饮费',
  11356. '办公费',
  11357. '公关费',
  11358. '其他'
  11359. );
  11360. foreach ( $item as $va ) {
  11361. $falg = true;
  11362. foreach ( $receiptCollectList as $v ) {
  11363. if ($v ['itemCategory'] == '培训班费用') {
  11364. if ($v ['item'] == $va) {
  11365. $psum += $v ['price'];
  11366. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11367. $falg = false;
  11368. break;
  11369. }
  11370. }
  11371. }
  11372. if ($falg)
  11373. $html .= '<td class="taR">-</td>';
  11374. }
  11375. if (! empty ( $psum ))
  11376. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  11377. else
  11378. $psum = '<td class="colGreen taR">-</td>';
  11379. $receiptL ['培训班费用'] = $psum . $html;
  11380. /* ------------------------------------- */
  11381. $html = "";
  11382. $psum = 0;
  11383. $item = array (
  11384. '公关费',
  11385. '广告费',
  11386. '借款',
  11387. '可自加费用'
  11388. );
  11389. foreach ( $item as $va ) {
  11390. $falg = true;
  11391. foreach ( $receiptCollectList as $v ) {
  11392. if ($v ['itemCategory'] == '其他') {
  11393. if ($v ['item'] == $va) {
  11394. $psum += $v ['price'];
  11395. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11396. $falg = false;
  11397. break;
  11398. }
  11399. }
  11400. }
  11401. if ($falg)
  11402. $html .= '<td class="taR">-</td>';
  11403. }
  11404. if (! empty ( $psum ))
  11405. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  11406. else
  11407. $psum = '<td class="colGreen taR">-</td>';
  11408. $receiptL ['其他'] = $psum . $html;
  11409. /* ------------------------------------- */
  11410. $html = "";
  11411. $psum = 0;
  11412. foreach ( $receiptCollectList as $v ) {
  11413. if ($v ['itemCategory'] == '报销金额调整') {
  11414. if (! empty ( $v ['price'] ))
  11415. $psum += $v ['price'];
  11416. }
  11417. }
  11418. if (! empty ( $psum ))
  11419. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  11420. else
  11421. $psum = '<td class="taR colOrange">-</td>';
  11422. $receiptL ['报销金额调整'] = $psum . $html;
  11423. } else {
  11424. $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>
  11425. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  11426. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  11427. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  11428. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  11429. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  11430. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  11431. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  11432. }
  11433. $monthStaffPrice = $receiptDetail->find ( array (
  11434. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  11435. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  11436. 'asArray' => true
  11437. ) );
  11438. if (! empty ( $monthStaffPrice [0] ['price'] ))
  11439. $receiptL ['monthStaffPrice'] = '<td><b>' . $monthStaffPrice [0] ['price'] . '</b></td>';
  11440. else
  11441. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  11442. $list [$value ['title']] = $receiptL;
  11443. }
  11444. $data ['list'] = $list;
  11445. $receiptCollectList = $receiptDetail->find ( array (
  11446. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  11447. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  11448. 'groupby' => 'item,Month(pastDate),itemCategory',
  11449. 'asArray' => true
  11450. ) );
  11451. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  11452. // print_r($data['monthPriceHtml']);
  11453. // foreach ($data['monthPriceHtml'] as $value){
  11454. // echo $value;
  11455. // }
  11456. // die;
  11457. // statistics html
  11458. $stList = $statistics->getOne ( array (
  11459. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  11460. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  11461. 'groupby' => 'Month(date)',
  11462. 'asArray' => true
  11463. ) );
  11464. if (empty ( $stList ))
  11465. $stList = array (
  11466. 'rePrice' => 0,
  11467. 'agPrice' => 0
  11468. );
  11469. $data ['stList'] = array (
  11470. 'rePrice' => $stList ['rePrice'],
  11471. 'agPrice' => $stList ['agPrice'],
  11472. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  11473. );
  11474. $monthHtml = "";
  11475. for($i = 1; $i <= 12; $i ++) {
  11476. if ($i == $month)
  11477. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  11478. else
  11479. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  11480. }
  11481. $data ['monthHtml'] = $monthHtml;
  11482. $data ['year'] = $year;
  11483. $data ['month'] = $month;
  11484. $data ['memu'] = "receipt";
  11485. $data ['staff'] = $this->staff;
  11486. $data ['receiptMemu'] = 'companyCategoryCollect';
  11487. $data ['verifyId'] = $this->verifyId;
  11488. $data ['executeId'] = $this->executeId;
  11489. $this->render ( "/admin/companyMonthCollectDetail", $data );
  11490. }
  11491. function staffCollectDetail() {
  11492. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11493. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  11494. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  11495. if (! $staffname) {
  11496. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  11497. $staffname = urldecode ( $staffname );
  11498. }
  11499. Doo::loadModel ( 'staff' );
  11500. $staff = new staff ();
  11501. Doo::loadModel ( "receiptDetail" );
  11502. $receiptDetail = new receiptDetail ();
  11503. Doo::loadModel ( 'accountItem' );
  11504. $accountItem = new accountItem ();
  11505. Doo::loadModel ( 'statistics' );
  11506. $statistics = new statistics ();
  11507. Doo::loadModel ( 'L_category' );
  11508. $lCategory = new L_category ();
  11509. Doo::loadModel ( "receiptAuthorityManage" );
  11510. $receiptAuthorityManage = new receiptAuthorityManage ();
  11511. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  11512. $cidList = array ();
  11513. foreach ( $imcStaff as $key => $value ) {
  11514. array_push ( $cidList, $value ['cid'] );
  11515. }
  11516. $cidString = implode ( ',', $cidList );
  11517. $staffList = $staff->find ( array (
  11518. 'where' => ' cid in (' . $cidString . ')',
  11519. 'asArray' => true
  11520. ) );
  11521. $stHtml = '';
  11522. $stTitle = "";
  11523. $staffId = 0;
  11524. $cid = 0;
  11525. $ocid = 0;
  11526. foreach ( $staffList as $value ) {
  11527. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  11528. $stTitle = $value ['category'] . '-' . $value ['username'];
  11529. $staffId = $value ['sid'];
  11530. $cid = $value ['cid'];
  11531. $ocid = $value ['cid'];
  11532. if (! empty ( $value ['othercid'] ))
  11533. $cid = $value ['cid'] . ',' . $value ['othercid'];
  11534. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  11535. } elseif ($value ['username'] != 'admin')
  11536. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  11537. }
  11538. $data ['lCategoryHtml'] = $lCategory->find ( array (
  11539. 'where' => 'cid in(' . $cid . ')',
  11540. 'asArray' => true
  11541. ) );
  11542. if (empty ( $pcid ))
  11543. $pcid = $ocid;
  11544. $data ['ocid'] = $pcid;
  11545. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  11546. $this->showCache ( $path );
  11547. //
  11548. $receiptCollectList = $receiptDetail->find ( array (
  11549. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  11550. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  11551. 'groupby' => 'item,Month(pastDate),itemCategory',
  11552. 'asArray' => true
  11553. ) );
  11554. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  11555. // print_r($receiptCollectList);
  11556. $accountList = $accountItem->find ( array (
  11557. 'asArray' => true
  11558. ) );
  11559. // create CollectDetail HTML
  11560. $collectHtml = array ();
  11561. foreach ( $accountList as $key => $value ) {
  11562. $html = "";
  11563. $asum = 0;
  11564. for($i = 1; $i <= 12; $i ++) {
  11565. $falg = true;
  11566. foreach ( $receiptCollectList as $v ) {
  11567. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  11568. if ($v ['item'] == '可自加费用') {
  11569. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  11570. }
  11571. $asum += $v ['price'];
  11572. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11573. $falg = false;
  11574. break;
  11575. }
  11576. }
  11577. if ($falg)
  11578. $html .= '<td class="taR">-</td>';
  11579. }
  11580. $html .= '<td class="taR colGreen"><b>' . $asum . '</b></td>';
  11581. $collectHtml [$value ['category']] [$value ['name']] = $html;
  11582. }
  11583. $data ['collectHtml'] = $collectHtml;
  11584. // print_r($collectHtml);
  11585. // create Adjustment price html
  11586. $receiptCollectList = $receiptDetail->find ( array (
  11587. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  11588. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  11589. 'groupby' => 'itemCategory,Month(pastDate)',
  11590. 'asArray' => true
  11591. ) );
  11592. $adjustment = array ();
  11593. $collectArray = array (
  11594. '日常相关费用' => array (),
  11595. '差旅相关费用' => array (),
  11596. '培训班费用' => array (),
  11597. '其他' => array ()
  11598. );
  11599. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  11600. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  11601. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  11602. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  11603. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  11604. array_push ( $collectArray ['培训班费用'], $collectHtml );
  11605. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  11606. array_push ( $collectArray ['其他'], $collectHtml );
  11607. $data ['collectArray'] = $collectArray;
  11608. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  11609. array_push ( $adjustment, $collectHtml );
  11610. $data ['adjustment'] = $adjustment;
  11611. // total price html
  11612. $collectHtml = "";
  11613. $total = 0;
  11614. for($i = 1; $i <= 12; $i ++) {
  11615. $sumPrice = 0;
  11616. foreach ( $receiptCollectList as $key => $value ) {
  11617. if ($value ['month'] == $i) {
  11618. $sumPrice += $value ['price'];
  11619. }
  11620. }
  11621. if ($sumPrice == 0)
  11622. $collectHtml .= '<td class="taR">-</td>';
  11623. else
  11624. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  11625. $total += $sumPrice;
  11626. }
  11627. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  11628. // statistics html
  11629. $stList = $statistics->statisticsByYear ( $year, $staffId );
  11630. if (empty ( $stList ))
  11631. $stList = array (
  11632. 'rePrice' => 0,
  11633. 'agPrice' => 0
  11634. );
  11635. $data ['stList'] = array (
  11636. 'rePrice' => $stList ['rePrice'],
  11637. 'agPrice' => $stList ['agPrice'],
  11638. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  11639. );
  11640. $data ['totalPrice'] = $collectHtml;
  11641. $data ['totalYear'] = $total;
  11642. $data ['stHtml'] = $stHtml;
  11643. $data ['year'] = $year;
  11644. $data ['stTitle'] = $stTitle;
  11645. $data ['staffname'] = urlencode ( $staffname );
  11646. $data ['memu'] = "receipt";
  11647. $data ['staff'] = $this->staff;
  11648. $data ['receiptMemu'] = 'companyCategoryCollect';
  11649. $data ['verifyId'] = $this->verifyId;
  11650. $data ['executeId'] = $this->executeId;
  11651. if ($year < date ( "Y" )) {
  11652. Doo::loadModel ( 'receipt' );
  11653. $receipt = new receipt ();
  11654. $receiptList = $receipt->find ( array (
  11655. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  11656. 'asArray' => true
  11657. ) );
  11658. if (empty ( $receiptList )) { // generated files
  11659. ob_start ();
  11660. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  11661. $this->cacheFile ( $path );
  11662. die ();
  11663. }
  11664. }
  11665. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  11666. }
  11667. function BUGFLAG() {
  11668. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  11669. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  11670. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  11671. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  11672. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  11673. if (empty ( $status ))
  11674. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  11675. $page_size = 12;
  11676. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  11677. $vidList = array ();
  11678. $button = 0;
  11679. Doo::loadModel ( 'verify' );
  11680. $verify = new verify ();
  11681. Doo::loadModel ( 'receipt' );
  11682. $receipt = new receipt ();
  11683. Doo::loadModel ( 'staff' );
  11684. $staff = new staff ();
  11685. Doo::loadModel ( 'L_category' );
  11686. $Lcategory = new L_category ();
  11687. $dateCondition = " and Year(date) =" . $year;
  11688. if (! empty ( $month ))
  11689. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  11690. $categoryList = $Lcategory->find ( array (
  11691. 'asArray' => true
  11692. ) );
  11693. $staffList = $staff->find ( array (
  11694. 'where' => 'cid=' . $cid,
  11695. 'asArray' => true
  11696. ) );
  11697. $cateCondition = "";
  11698. $staffCondition = "";
  11699. $approvalCondition = "";
  11700. if (! empty ( $cid ))
  11701. $cateCondition = ' and cid=' . $cid;
  11702. if (! empty ( $sid )) {
  11703. $staffCondition = ' and staff=' . $sid;
  11704. $cateCondition = "";
  11705. }
  11706. $approvalCondition = " and status=" . $status;
  11707. if ($status == 2) {
  11708. // 查找角色审批人
  11709. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  11710. }
  11711. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  11712. $approvalCondition = ' and status=2 ';
  11713. }
  11714. if ($status == 1) {
  11715. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  11716. }
  11717. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  11718. $pageinfo ['page'] = array (
  11719. 'previous' => ''
  11720. );
  11721. if ($status == 0) {
  11722. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  11723. $receiptList = $receipt->find ( array (
  11724. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  11725. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  11726. 'desc' => 'rid',
  11727. 'asArray' => true
  11728. ) );
  11729. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  11730. } else
  11731. $receiptList = $receipt->find ( array (
  11732. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  11733. 'desc' => 'rid',
  11734. 'asArray' => true
  11735. ) );
  11736. $rLRes = $receipt->find ( array (
  11737. '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,
  11738. 'desc' => 'rid',
  11739. 'asArray' => true
  11740. ) );
  11741. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  11742. // print_r($pageinfo);
  11743. $Locate = 0;
  11744. foreach ( $receiptList as $key => $value ) {
  11745. $receiptList [$key] ['Locate'] = $Locate;
  11746. $Locate ++;
  11747. $receiptList [$key] ['reviseDetail'] = array ();
  11748. if (! empty ( $value ['reviseDetail'] ))
  11749. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  11750. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  11751. $categoryDetil = $Lcategory->getOne ( array (
  11752. 'where' => 'cid=' . $value ['cid'],
  11753. 'asArray' => true
  11754. ) );
  11755. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  11756. $verifyList = $verify->getOne ( array (
  11757. 'where' => 'vid=' . $value ['verify'],
  11758. 'asArray' => true
  11759. ) );
  11760. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  11761. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  11762. foreach ( $verifyList as $k => $v ) {
  11763. // init verifyStaff
  11764. $verifyList [$k] ['date'] = "";
  11765. $verifyList [$k] ['opinion'] = "";
  11766. $verifyList [$k] ['status'] = "";
  11767. if (empty ( $verifyStaff )) {
  11768. $verifyList [$k] ['date'] = "";
  11769. $verifyList [$k] ['opinion'] = "";
  11770. if ($v [0] == $this->staff [0] ['sid']) {
  11771. $verifyList [$k] ['status'] = 4;
  11772. $button = 4;
  11773. }
  11774. } else {
  11775. $flag = true;
  11776. foreach ( $verifyStaff as $m => $u ) {
  11777. if ($v [0] == $m) {
  11778. $verifyList [$k] ['date'] = $u ['date'];
  11779. $verifyList [$k] ['opinion'] = $u ['opinion'];
  11780. $verifyList [$k] ['status'] = $u ['status'];
  11781. $flag = false;
  11782. break;
  11783. }
  11784. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  11785. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  11786. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  11787. }
  11788. if ($flag) { // 检测可编辑
  11789. if ($v [0] == $this->staff [0] ['sid']) {
  11790. $verifyList [$k] ['status'] = 4;
  11791. $button = 4;
  11792. }
  11793. }
  11794. }
  11795. }
  11796. $receiptList [$key] ['verifyList'] = $verifyList;
  11797. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  11798. 'where' => 'sid=' . $value ['staff'],
  11799. 'asArray' => true
  11800. ) );
  11801. $receiptList [$key] ['button'] = $button;
  11802. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  11803. }
  11804. // print_r($receiptList);die;
  11805. // $data['verifyDetail']=$verifyDetail;
  11806. $mothHtml = "";
  11807. for($i = 1; $i <= 12; $i ++) {
  11808. if ($month == $i)
  11809. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11810. else
  11811. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11812. }
  11813. $data ['mothHtml'] = $mothHtml;
  11814. $data ['page'] = $pageinfo;
  11815. $data ['receiptList'] = $receiptList;
  11816. $data ['receiptApprovalCount'] = count ( $rLRes );
  11817. $data ['status'] = $status;
  11818. $data ['year'] = $year;
  11819. $data ['categoryList'] = $categoryList;
  11820. $data ['staffList'] = $staffList;
  11821. $data ['cid'] = $cid;
  11822. $data ['sid'] = $sid;
  11823. // print_r($receiptList);
  11824. $data ['memu'] = "receipt";
  11825. $data ['staff'] = $this->staff;
  11826. $data ['receiptMemu'] = 'approvalExpenses';
  11827. $data ['verifyId'] = $this->verifyId;
  11828. $data ['executeId'] = $this->executeId;
  11829. $this->render ( "/admin/FALG", $data );
  11830. }
  11831. function ajaxGetReceiptOrder() {
  11832. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  11833. if (! empty ( $receiptOrder )) {
  11834. Doo::loadModel ( 'receipt' );
  11835. $receipt = new receipt ();
  11836. Doo::loadModel ( 'staff' );
  11837. $staff = new staff ();
  11838. $receiptInfo = $receipt->getOne ( array (
  11839. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  11840. 'asArray' => true
  11841. ) );
  11842. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  11843. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  11844. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  11845. </tbody></table><table class="table table table-bordered"><tbody>';
  11846. foreach ( $verifyStaff as $key => $value ) {
  11847. $staffInfo = $staff->getOne ( array (
  11848. 'select' => 'username',
  11849. 'where' => ' sid="' . $key . '"',
  11850. 'asArray' => true
  11851. ) );
  11852. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  11853. }
  11854. $html .= '</tbody></table></div></div>';
  11855. echo json_encode ( array (
  11856. 'status' => 1,
  11857. 'receiptHtml' => $html
  11858. ) );
  11859. die ();
  11860. }
  11861. echo json_encode ( array (
  11862. 'status' => 2,
  11863. 'receiptHtml' => ''
  11864. ) );
  11865. die ();
  11866. }
  11867. function _getMonthCollectDetail($receiptCollectList) {
  11868. if (! empty ( $receiptCollectList )) {
  11869. $receiptL = array (
  11870. '日常相关费用' => array (),
  11871. '差旅相关费用' => array (),
  11872. '培训班费用' => array (),
  11873. '其他' => array ()
  11874. );
  11875. $html = "";
  11876. $psum = 0;
  11877. $item = array (
  11878. '市内交通费',
  11879. '市内出租费',
  11880. '办事处房租',
  11881. '电话费',
  11882. '水费',
  11883. '电费',
  11884. '办公费用',
  11885. '邮寄费',
  11886. '其他费用',
  11887. '车辆费用',
  11888. '广告费',
  11889. '团队建设费',
  11890. '物业管理费',
  11891. '宽带费',
  11892. '人员薪酬',
  11893. '公积金',
  11894. '社保'
  11895. );
  11896. foreach ( $item as $value ) {
  11897. $falg = true;
  11898. foreach ( $receiptCollectList as $v ) {
  11899. if ($v ['itemCategory'] == '日常相关费用') {
  11900. if ($v ['item'] == $value) {
  11901. $psum += $v ['price'];
  11902. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11903. $falg = false;
  11904. break;
  11905. }
  11906. }
  11907. }
  11908. if ($falg)
  11909. $html .= '<td class="taR">-</td>';
  11910. }
  11911. if (! empty ( $psum ))
  11912. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  11913. else
  11914. $psum = '<td class="colGreen taR">-</td>';
  11915. $receiptL ['日常相关费用'] = $psum . $html;
  11916. /* ----------------------------------- */
  11917. $html = "";
  11918. $psum = 0;
  11919. $item = array (
  11920. '往来交通费',
  11921. '市内交通费',
  11922. '出差住宿费',
  11923. '出差补助',
  11924. '其他费用'
  11925. );
  11926. foreach ( $item as $value ) {
  11927. $falg = true;
  11928. foreach ( $receiptCollectList as $v ) {
  11929. if ($v ['itemCategory'] == '差旅相关费用') {
  11930. if ($v ['item'] == $value) {
  11931. $psum += $v ['price'];
  11932. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11933. $falg = false;
  11934. break;
  11935. }
  11936. }
  11937. }
  11938. if ($falg)
  11939. $html .= '<td class="taR">-</td>';
  11940. }
  11941. if (! empty ( $psum ))
  11942. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  11943. else
  11944. $psum = '<td class="colGreen taR">-</td>';
  11945. $receiptL ['差旅相关费用'] = $psum . $html;
  11946. /* ------------------------------------- */
  11947. $html = "";
  11948. $psum = 0;
  11949. $item = array (
  11950. '场租费',
  11951. '薪酬',
  11952. '住宿费',
  11953. '交通费',
  11954. '餐饮费',
  11955. '办公费',
  11956. '公关费',
  11957. '其他',
  11958. '电话费',
  11959. '邮寄费'
  11960. );
  11961. foreach ( $item as $value ) {
  11962. $falg = true;
  11963. foreach ( $receiptCollectList as $v ) {
  11964. if ($v ['itemCategory'] == '培训班费用') {
  11965. if ($v ['item'] == $value) {
  11966. $psum += $v ['price'];
  11967. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11968. $falg = false;
  11969. break;
  11970. }
  11971. }
  11972. }
  11973. if ($falg)
  11974. $html .= '<td class="taR">-</td>';
  11975. }
  11976. if (! empty ( $psum ))
  11977. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  11978. else
  11979. $psum = '<td class="colGreen taR">-</td>';
  11980. $receiptL ['培训班费用'] = $psum . $html;
  11981. /* ------------------------------------- */
  11982. $html = "";
  11983. $psum = 0;
  11984. $item = array (
  11985. '公关费',
  11986. '广告费',
  11987. '借款',
  11988. '可自加费用'
  11989. );
  11990. foreach ( $item as $value ) {
  11991. $falg = true;
  11992. foreach ( $receiptCollectList as $v ) {
  11993. if ($v ['itemCategory'] == '其他') {
  11994. if ($v ['item'] == $value) {
  11995. $psum += $v ['price'];
  11996. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11997. $falg = false;
  11998. break;
  11999. }
  12000. }
  12001. }
  12002. if ($falg)
  12003. $html .= '<td class="taR">-</td>';
  12004. }
  12005. if (! empty ( $psum ))
  12006. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  12007. else
  12008. $psum = '<td class="colGreen taR">-</td>';
  12009. $receiptL ['其他'] = $psum . $html;
  12010. /* ------------------------------------- */
  12011. $html = "";
  12012. $psum = 0;
  12013. foreach ( $receiptCollectList as $v ) {
  12014. if ($v ['itemCategory'] == '报销金额调整') {
  12015. if (! empty ( $v ['price'] ))
  12016. $psum += $v ['price'];
  12017. }
  12018. }
  12019. if (! empty ( $psum ))
  12020. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  12021. else
  12022. $psum = '<td class="taR colOrange">-</td>';
  12023. $receiptL ['报销金额调整'] = $psum . $html;
  12024. } else {
  12025. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td>
  12026. <td class="taR">-</td>
  12027. <td class="taR">-</td>
  12028. <td class="taR">-</td>
  12029. <td class="taR">-</td>
  12030. <td class="taR">-</td>
  12031. <td class="taR">-</td>
  12032. <td class="taR">-</td>
  12033. <td class="taR">-</td>
  12034. <td class="taR">-</td>
  12035. <td class="taR">-</td>
  12036. <td class="taR">-</td>
  12037. <td class="taR">-</td>';
  12038. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  12039. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12040. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td>
  12041. <td class="taR">-</td>
  12042. <td class="taR">-</td>
  12043. <td class="taR">-</td>
  12044. <td class="taR">-</td>
  12045. <td class="taR">-</td>
  12046. <td class="taR">-</td>
  12047. <td class="taR">-</td>
  12048. <td class="taR">-</td>';
  12049. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12050. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  12051. }
  12052. return $receiptL;
  12053. }
  12054. function eMail() {
  12055. Doo::loadModel ( 'staff' );
  12056. $staff = new staff ();
  12057. Doo::loadModel ( 'receipt' );
  12058. $receipt = new receipt ();
  12059. Doo::loadModel ( 'L_category' );
  12060. $Lcategory = new L_category ();
  12061. Doo::loadModel ( "verify" );
  12062. $verify = new verify ();
  12063. $staffList = $staff->find ( array (
  12064. 'asArray' => true
  12065. ) );
  12066. foreach ( $staffList as $key => $value ) {
  12067. if ($value ['username'] != 'admin') {
  12068. // 提交人
  12069. $receiptList = $receipt->find ( array (
  12070. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  12071. 'asArray' => true
  12072. ) );
  12073. if (! empty ( $receiptList )) {
  12074. $html = '<br><div><style></style>
  12075. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  12076. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  12077. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  12078. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  12079. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  12080. <tbody><tr>
  12081. <td style="padding: 0 40px;" align="left">
  12082. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  12083. </td></tr><tr>
  12084. <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>
  12085. </tr>
  12086. </tbody> </table></td> </tr> <tr><td>
  12087. <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">
  12088. <tbody> <tr><td>
  12089. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  12090. 以下报销单完成了审批,等着收款吧:</p>
  12091. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  12092. foreach ( $receiptList as $k => $v ) {
  12093. $category = $Lcategory->getOne ( array (
  12094. 'where' => 'cid=' . $v ['cid'],
  12095. 'asArray' => true
  12096. ) );
  12097. $html .= '
  12098. <tr>
  12099. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  12100. <td align="left">
  12101. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  12102. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  12103. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  12104. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  12105. </tr>';
  12106. }
  12107. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  12108. <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>
  12109. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  12110. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  12111. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  12112. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  12113. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  12114. $receipt = new receipt ();
  12115. $receipt->notice = 1;
  12116. $receipt->update ( array (
  12117. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  12118. ) );
  12119. }
  12120. }
  12121. // 审批人
  12122. $verifyList = $verify->find ( array (
  12123. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  12124. 'asArray' => true
  12125. ) );
  12126. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  12127. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  12128. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  12129. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  12130. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  12131. <tbody><tr><td style="padding: 0 40px;" align="left">
  12132. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  12133. </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>
  12134. </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">
  12135. <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>
  12136. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  12137. foreach ( $verifyList as $k => $v ) {
  12138. $receiptList = $receipt->find ( array (
  12139. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  12140. 'asArray' => true
  12141. ) );
  12142. foreach ( $receiptList as $r => $l ) {
  12143. $category = $Lcategory->getOne ( array (
  12144. 'where' => 'cid=' . $l ['cid'],
  12145. 'asArray' => true
  12146. ) );
  12147. $staffDetile = $staff->getOne ( array (
  12148. 'where' => 'sid=' . $l ['staff'],
  12149. 'asArray' => true
  12150. ) );
  12151. $html .= '
  12152. <tr>
  12153. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  12154. <td align="left">
  12155. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  12156. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  12157. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  12158. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  12159. </tr>';
  12160. }
  12161. }
  12162. $html .= '
  12163. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  12164. <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>
  12165. </tr></tbody></table></td></tr></tbody></table></div><br>';
  12166. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  12167. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  12168. // $receipt=new receipt();
  12169. // $receipt->notice=1;
  12170. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  12171. }
  12172. }
  12173. }
  12174. }
  12175. function setWXMsg($rid, $type) {
  12176. Doo::loadModel ( "receipt" );
  12177. $receipt = new receipt ();
  12178. $receiptDetail = $receipt->getOne ( array (
  12179. 'where' => 'rid=' . $rid,
  12180. 'asArray' => true
  12181. ) );
  12182. if (! empty ( $receiptDetail )) {
  12183. Doo::loadModel ( 'staff' );
  12184. $staff = new staff ();
  12185. $staffmsg = $staff->getOne ( array (
  12186. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  12187. 'asArray' => TRUE
  12188. ) );
  12189. if (! empty ( $staffmsg ['wxid'] )) {
  12190. require_once (SITE_PATH . '/protected/class/client.php');
  12191. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  12192. $user = $staffmsg ['wxid'];
  12193. $receiptName = '';
  12194. $msg = '';
  12195. switch ($receiptDetail ['Rtype']) {
  12196. case 0 :
  12197. $receiptName = '报销';
  12198. break;
  12199. case 1 :
  12200. $receiptName = '借款';
  12201. break;
  12202. case 2 :
  12203. $receiptName = '对公汇款';
  12204. break;
  12205. }
  12206. switch ($type) {
  12207. case 1 :
  12208. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  12209. break;
  12210. case 2 :
  12211. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  12212. break;
  12213. case 3 :
  12214. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  12215. break;
  12216. }
  12217. // $result = $client->SendMsg ( $user, $msg, 'text' );
  12218. }
  12219. }
  12220. }
  12221. // Email发送函数
  12222. function SMail($toemail, $subject, $contents) {
  12223. Doo::loadClass ( 'class.phpmailer' );
  12224. $mail = new PHPMailer ();
  12225. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  12226. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  12227. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  12228. $mail->Password = "cDO1GjtY1seH"; // 密码
  12229. $mail->CharSet = "UTF8";
  12230. $mail->SMTPAuth = true;
  12231. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  12232. $mail->Mailer = "smtp";
  12233. $mail->Port = 25;
  12234. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  12235. $mail->MsgHTML ( $contents );
  12236. $mail->AddAddress ( $toemail );
  12237. $mail->CharSet = "UTF-8";
  12238. return $mail->Send ();
  12239. }
  12240. function swfupload() {
  12241. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  12242. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  12243. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  12244. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  12245. header ( "HTTP/1.1 500 Internal Server Error" );
  12246. echo "POST exceeded maximum allowed size.";
  12247. exit ( 0 );
  12248. }
  12249. // Settings
  12250. $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)
  12251. $upload_name = "Filedata";
  12252. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  12253. $extension_whitelist = array (
  12254. "doc",
  12255. "txt",
  12256. "jpg",
  12257. "gif",
  12258. "png"
  12259. ); // Allowed file extensions
  12260. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  12261. // Other variables
  12262. $MAX_FILENAME_LENGTH = 260;
  12263. $file_name = "";
  12264. $file_extension = "";
  12265. $uploadErrors = array (
  12266. 0 => "文件上传成功",
  12267. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  12268. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  12269. 3 => "上传的文件仅为部分文件",
  12270. 4 => "没有文件上传",
  12271. 6 => "缺少临时文件夹"
  12272. );
  12273. $nk = time ();
  12274. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  12275. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  12276. echo "文件无法保存.";
  12277. exit ( 0 );
  12278. }
  12279. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  12280. echo json_encode ( array (
  12281. 'filename' => $file_name,
  12282. 'id' => $nk
  12283. ) );
  12284. exit ( 0 );
  12285. }
  12286. function _GetFileEXT($filename) {
  12287. $pics = explode ( '.', $filename );
  12288. $num = count ( $pics );
  12289. return $pics [$num - 1];
  12290. }
  12291. /**
  12292. * 获取get或者POST值
  12293. * @param string $name 属性名称
  12294. * @return fixed 值
  12295. */
  12296. function get_args($name) {
  12297. if (isset ( $_GET [$name] )) {
  12298. if (is_array ( $_GET [$name] ))
  12299. return $_GET [$name];
  12300. else
  12301. return addslashes ( $_GET [$name] );
  12302. } elseif (isset ( $_POST [$name] )) {
  12303. if (is_array ( $_POST [$name] ))
  12304. return $_POST [$name];
  12305. else
  12306. return addslashes ( $_POST [$name] );
  12307. } else
  12308. return false;
  12309. }
  12310. function num_to_rmb($num) {
  12311. $c1 = "零壹贰叁肆伍陆柒捌玖";
  12312. $c2 = "分角元拾佰仟万拾佰仟亿";
  12313. // 精确到分后面就不要了,所以只留两个小数位
  12314. $num = round ( $num, 2 );
  12315. // 将数字转化为整数
  12316. $num = $num * 100;
  12317. if (strlen ( $num ) > 10) {
  12318. return "金额太大,请检查";
  12319. }
  12320. $i = 0;
  12321. $c = "";
  12322. while ( 1 ) {
  12323. if ($i == 0) {
  12324. // 获取最后一位数字
  12325. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  12326. } else {
  12327. $n = $num % 10;
  12328. }
  12329. // 每次将最后一位数字转化为中文
  12330. $p1 = substr ( $c1, 3 * $n, 3 );
  12331. $p2 = substr ( $c2, 3 * $i, 3 );
  12332. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  12333. $c = $p1 . $p2 . $c;
  12334. } else {
  12335. $c = $p1 . $c;
  12336. }
  12337. $i = $i + 1;
  12338. // 去掉数字最后一位了
  12339. $num = $num / 10;
  12340. // echo $num.'</br>';
  12341. $num = ( int ) $num;
  12342. // $num =floor($num);
  12343. // $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  12344. // echo $num.'</br>';
  12345. // 结束循环
  12346. if ($num == 0) {
  12347. break;
  12348. }
  12349. }
  12350. // echo $c.'</br>';
  12351. $j = 0;
  12352. $slen = strlen ( $c );
  12353. while ( $j < $slen ) {
  12354. // utf8一个汉字相当3个字符
  12355. $m = substr ( $c, $j, 6 );
  12356. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  12357. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  12358. $left = substr ( $c, 0, $j );
  12359. $right = substr ( $c, $j + 3 );
  12360. $c = $left . $right;
  12361. $j = $j - 3;
  12362. $slen = $slen - 3;
  12363. }
  12364. $j = $j + 3;
  12365. }
  12366. // 这个是为了去掉类似23.0中最后一个“零”字
  12367. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  12368. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  12369. }
  12370. // 将处理的汉字加上“整”
  12371. if (empty ( $c )) {
  12372. return "零元整";
  12373. } else {
  12374. return $c . "整";
  12375. }
  12376. }
  12377. /**
  12378. * 获得分页数据
  12379. * @param unknown_type $table
  12380. * @param unknown_type $condition
  12381. * @param unknown_type $on_page
  12382. * @param unknown_type $page_size
  12383. */
  12384. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  12385. $page_c = "";
  12386. $page ['previous'] = $this->get_previous ( $on_page );
  12387. $page ['on_page'] = $on_page;
  12388. $total_count = $this->get_table_count ( $table, $condition );
  12389. $total = intval ( $total_count / $page_size );
  12390. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  12391. $page ['total_data'] = $total_count;
  12392. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  12393. $i = 1;
  12394. $page_max = 1;
  12395. $page_width = 3;
  12396. if ($on_page >= $page_width) {
  12397. $page_max = intval ( $on_page / $page_width ) + 1;
  12398. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  12399. }
  12400. for(; $i <= $page ['total_page']; $i ++) {
  12401. if ($i == $on_page)
  12402. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  12403. else
  12404. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  12405. if ($i == ($page_width * $page_max))
  12406. break;
  12407. }
  12408. $page ['page'] = $page_c;
  12409. $page ['lower'] = (-- $on_page) * $page_size;
  12410. return $page;
  12411. }
  12412. /**
  12413. * 获取总页数
  12414. * @param unknown_type $table
  12415. * @param unknown_type $condition
  12416. */
  12417. public function get_table_count($table = "", $condition = "") {
  12418. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  12419. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  12420. // echo $sql;die;
  12421. $query = Doo::db ()->query ( $sql );
  12422. $result = $query->fetch ();
  12423. return $result ['count'];
  12424. }
  12425. /**
  12426. * 获取上一页
  12427. * @param unknown_type $on_page
  12428. */
  12429. function get_previous($on_page = 1) {
  12430. return $on_page != 0 ? $on_page - 1 : $on_page;
  12431. }
  12432. }
  12433. ?>