ReceiptController.php 495 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305
  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. /**
  1809. * 培训班结算
  1810. */
  1811. function receiptTrainAdd() {
  1812. Doo::loadModel ( 'accountItem' );
  1813. $accountItem = new accountItem ();
  1814. $acItem = $accountItem->find ( array (
  1815. 'asArray' => true
  1816. ) );
  1817. // 审批组
  1818. Doo::loadModel ( 'verify' );
  1819. $verify = new verify ();
  1820. $veList = $verify->getVerifyByAll ();
  1821. // 办事处
  1822. Doo::loadModel ( 'L_category' );
  1823. $lCategory = new L_category ();
  1824. $data ['category'] = $lCategory->getCategory ();
  1825. $data ['veList'] = $veList;
  1826. $data ['memu'] = "receipt";
  1827. $data ['staff'] = $this->staff;
  1828. $data ['acItem'] = $acItem;
  1829. $data ['receiptMemu'] = 'saeaBorad';
  1830. $data ['verifyId'] = $this->verifyId;
  1831. $data ['executeId'] = $this->executeId;
  1832. $this->render ( "/receipt/receiptTrainAdd", $data );
  1833. }
  1834. /**
  1835. * 添加培训班结算
  1836. */
  1837. function receiptTrainAddDo() {
  1838. // 培训班信息
  1839. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  1840. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  1841. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  1842. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  1843. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  1844. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  1845. // 发票信息
  1846. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1847. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  1848. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1849. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1850. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1851. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1852. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1853. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $participants ) && ! empty ( $trainAddress )) {
  1854. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1855. header ( 'Content-Type:text/html;charset=utf-8' );
  1856. die ( '请填写联行号' );
  1857. }
  1858. Doo::loadModel ( 'execute' );
  1859. $execute = new execute ();
  1860. $executeDetail = $execute->getOne ( array (
  1861. 'where' => 'mold="培训班结算"',
  1862. 'asArray' => true
  1863. ) );
  1864. if (empty ( $executeDetail )) {
  1865. header ( 'Content-Type:text/html;charset=utf-8' );
  1866. die ( '未设置执行人' );
  1867. }
  1868. Doo::loadClass ( 'XDeode' );
  1869. $XDeode = new XDeode ( 5 );
  1870. $cid = $XDeode->decode ( $cid );
  1871. Doo::loadModel ( 'receipt' );
  1872. $receipt = new receipt ();
  1873. Doo::loadModel ( 'receiptTraining' );
  1874. $receiptTraining = new receiptTraining ();
  1875. // 创建费用培训班
  1876. $item = array (
  1877. 'cid' => $this->staff [0] ['cid'],
  1878. 'categoryName' => $this->staff [0] ['category'],
  1879. 'trainName' => $trainName,
  1880. 'trainStartDate' => $trainStartDate,
  1881. 'trainEndDate' => $trainEndDate,
  1882. 'participants' => $participants,
  1883. 'trainAddress' => $trainAddress,
  1884. 'trainRemarks' => $trainRemarks,
  1885. 'creator' => $this->staff [0] ['sid'],
  1886. 'creatorDate' => date ( "Y-m-d H:i:s" )
  1887. );
  1888. $irid = $receiptTraining->addReceiptTraining ( $item );
  1889. // 报销单
  1890. $receipt->status = 5;
  1891. $receipt->trainId = $irid;
  1892. $receipt->Rtype = 3;
  1893. $receipt->staff = $this->staff [0] ['sid'];
  1894. $receipt->cid = $cid;
  1895. $receipt->verify = $verify;
  1896. $receipt->date = date ( "Y-m-d" );
  1897. $receipt->executeCopy = $executeDetail ['staff'];
  1898. $receipt->receiptOrder = "#P" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1899. $receipt->remittanceName = $remittanceName;
  1900. $receipt->bankName = $bankName;
  1901. $receipt->bankNumber = $bankNumber;
  1902. $receipt->remittanceBankType = $remittanceBankType;
  1903. if ($remittanceBankType == 1)
  1904. $receipt->coupletNumber = $coupletNumber;
  1905. $rid = $receipt->insert ();
  1906. $XDeode = new XDeode ( 7 );
  1907. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html";
  1908. } else
  1909. die ( 'illegal request' );
  1910. }
  1911. /**
  1912. * 培训班编辑
  1913. */
  1914. function receiptTrainEdi() {
  1915. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  1916. $trainEdiType = $this->get_args ( 'trainEdiType' ) ? $this->get_args ( 'trainEdiType' ) : "INFO";
  1917. Doo::loadClass ( 'XDeode' );
  1918. $XDeode = new XDeode ( 7 );
  1919. $rid = $XDeode->decode ( $ridKey );
  1920. if (! is_numeric ( $rid ))
  1921. die ( 'illegal request' );
  1922. Doo::loadModel ( 'receipt' );
  1923. $receipt = new receipt ();
  1924. Doo::loadModel ( 'receiptTraining' );
  1925. $receiptTraining = new receiptTraining ();
  1926. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  1927. if ($receiptDetail ['status'] != 5)
  1928. die ();
  1929. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  1930. // 审批组
  1931. Doo::loadModel ( 'verify' );
  1932. $verify = new verify ();
  1933. $veList = $verify->getVerifyByAll ();
  1934. // 办事处
  1935. Doo::loadModel ( 'L_category' );
  1936. $lCategory = new L_category ();
  1937. $data ['category'] = $lCategory->getCategory ();
  1938. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  1939. $data ['receiptDetail'] = $receiptDetail;
  1940. $data ['veList'] = $veList;
  1941. $data ['trainEdiType'] = $trainEdiType;
  1942. $data ['ridKey'] = $ridKey;
  1943. $data ['memu'] = "receipt";
  1944. $data ['staff'] = $this->staff;
  1945. $data ['receiptMemu'] = 'saeaBorad';
  1946. $data ['verifyId'] = $this->verifyId;
  1947. $data ['executeId'] = $this->executeId;
  1948. $this->render ( "/receipt/receiptTrainEdi", $data );
  1949. }
  1950. /**
  1951. * 培训班借款编辑
  1952. */
  1953. function receiptTrainLoanEdi() {
  1954. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  1955. Doo::loadClass ( 'XDeode' );
  1956. $XDeode = new XDeode ( 7 );
  1957. $rid = $XDeode->decode ( $ridKey );
  1958. if (! is_numeric ( $rid ))
  1959. die ( 'illegal request' );
  1960. Doo::loadModel ( 'receipt' );
  1961. $receipt = new receipt ();
  1962. Doo::loadModel ( 'receiptTraining' );
  1963. $receiptTraining = new receiptTraining ();
  1964. Doo::loadModel ( 'verify' );
  1965. $verify = new verify ();
  1966. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  1967. if ($receiptDetail ['status'] != 5)
  1968. die ();
  1969. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  1970. //借款详情HTML
  1971. //获得借款信息
  1972. $receiptLoanDetail = $receipt->getReceiptByRid ( $receiptDetail['trainLoanRid'] );
  1973. //获得某费用单审批信息
  1974. $verifylist=$verify->getVerifyByRid($receiptDetail['trainLoanRid']);
  1975. Doo::loadClass ( 'receipt.func' );
  1976. $extendHtml='<p><a class="button" href="javascript:if(window.confirm(\'确认移除?\'))window.location=\'/receiptTrainLoanRemoveDo/' . $receiptDetail ['ridKey'] . '/' . $receiptDetail['trainLoanRidKey'] . '.html\'" data-toggle="modal">移除借款</a></p>';
  1977. $receiptLoanHtml=_getReceiptLoanHtml($receiptLoanDetail,$verifylist,$extendHtml);
  1978. $data ['receiptLoanHtml'] = $receiptLoanHtml;
  1979. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  1980. $data ['receiptDetail'] = $receiptDetail;
  1981. $data ['trainEdiType'] = "LOAN";
  1982. $data ['ridKey'] = $ridKey;
  1983. $data ['memu'] = "receipt";
  1984. $data ['staff'] = $this->staff;
  1985. $data ['receiptMemu'] = 'saeaBorad';
  1986. $data ['verifyId'] = $this->verifyId;
  1987. $data ['executeId'] = $this->executeId;
  1988. $this->render ( "/receipt/receiptTrainLoanEdi", $data );
  1989. }
  1990. /**
  1991. * 更新培训班结算基本信息
  1992. */
  1993. function receiptTrainInfoEdiDo() {
  1994. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  1995. $rtid = $this->get_args ( 'rtid' ) ? $this->get_args ( 'rtid' ) : "";
  1996. // 培训班信息
  1997. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  1998. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  1999. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  2000. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  2001. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  2002. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  2003. // 发票信息
  2004. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2005. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2006. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2007. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2008. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2009. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2010. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2011. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $participants ) && ! empty ( $trainAddress )) {
  2012. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2013. header ( 'Content-Type:text/html;charset=utf-8' );
  2014. die ( '请填写联行号' );
  2015. }
  2016. Doo::loadClass ( 'XDeode' );
  2017. $XDeode = new XDeode ( 5 );
  2018. $cid = $XDeode->decode ( $cid );
  2019. $rtid = $XDeode->decode ( $rtid );
  2020. $rid = $XDeode->decode ( $rid );
  2021. if (! is_numeric ( $rtid ) || ! is_numeric ( $rid )) {
  2022. die ( 'illegal request-IdError' );
  2023. }
  2024. Doo::loadModel ( 'receipt' );
  2025. $receipt = new receipt ();
  2026. Doo::loadModel ( 'receiptTraining' );
  2027. $receiptTraining = new receiptTraining ();
  2028. // 更新费用培训班
  2029. $item = array (
  2030. 'rtid' => $rtid,
  2031. 'trainName' => $trainName,
  2032. 'trainStartDate' => $trainStartDate,
  2033. 'trainEndDate' => $trainEndDate,
  2034. 'participants' => $participants,
  2035. 'trainAddress' => $trainAddress,
  2036. 'trainRemarks' => $trainRemarks
  2037. );
  2038. $irid = $receiptTraining->setReceiptTrainByCondition ( $item );
  2039. // 报销单
  2040. $receipt->rid = $rid;
  2041. $receipt->cid = $cid;
  2042. $receipt->verify = $verify;
  2043. $receipt->remittanceName = $remittanceName;
  2044. $receipt->bankName = $bankName;
  2045. $receipt->bankNumber = $bankNumber;
  2046. $receipt->remittanceBankType = $remittanceBankType;
  2047. if ($remittanceBankType == 1)
  2048. $receipt->coupletNumber = $coupletNumber;
  2049. $receipt->update ();
  2050. $XDeode = new XDeode ( 7 );
  2051. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html?trainEdiType=INFO";
  2052. } else
  2053. die ( 'illegal request' );
  2054. }
  2055. /**
  2056. * 编辑培训班结算借款
  2057. */
  2058. function receiptTrainLoanEdiDo() {
  2059. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2060. $ridLoanKey = $this->get_args ( 'ridLoanKey' ) ? $this->get_args ( 'ridLoanKey' ) : "";
  2061. if(!empty($ridKey)&&!empty($ridLoanKey)){
  2062. Doo::loadModel ( 'receipt' );
  2063. $receipt = new receipt ();
  2064. Doo::loadClass ( 'XDeode' );
  2065. $XDeode = new XDeode ( 5 );
  2066. $rid=$XDeode->decode ( $ridKey );
  2067. $ridLoan=$XDeode->decode ( $ridLoanKey );
  2068. if (!is_numeric($rid)||!is_numeric($ridLoan))
  2069. die ( 'illegal request-ridError' );
  2070. $receiptDetail=$receipt->getReceiptByRid($rid);
  2071. $receiptLoanDetail=$receipt->getReceiptByRid($ridLoan);
  2072. //不合法的数据
  2073. if ($receiptDetail['status']!=3&&$receiptDetail['Rtype']!=3){
  2074. die ( 'illegal request-receiptError' );
  2075. }
  2076. if ($receiptLoanDetail['status']!=8&&$receiptLoanDetail['Rtype']!=1){
  2077. die ( 'illegal request-receipLoantError' );
  2078. }
  2079. //培训班结算挂钩借款
  2080. $receipt = new receipt ();
  2081. $item=array(
  2082. 'rid'=>$rid,
  2083. 'trainLoanRid'=>$ridLoan,
  2084. );
  2085. $receipt->setReceiptByCondition($item);
  2086. //更新借款状态变成已挂钩
  2087. $receipt = new receipt ();
  2088. $item=array(
  2089. 'rid'=>$ridLoan,
  2090. 'status'=>10,
  2091. 'statusTrain'=>1
  2092. );
  2093. $receipt->setReceiptByCondition($item);
  2094. $XDeode = new XDeode ( 7 );
  2095. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  2096. }else
  2097. die ( 'illegal request' );
  2098. }
  2099. /**
  2100. * 移除挂钩的费用借款
  2101. */
  2102. function receiptTrainLoanRemoveDo(){
  2103. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : 0;
  2104. $ridLoanKey = isset ( $this->params ['ridLoanKey'] ) ? $this->params ['ridLoanKey'] : 0;
  2105. if (!empty($ridKey)||!empty($ridLoanKey)){
  2106. Doo::loadClass ( 'XDeode' );
  2107. $XDeode = new XDeode ( 5 );
  2108. $rid=$XDeode->decode ( $ridKey );
  2109. $ridLoan=$XDeode->decode ( $ridLoanKey );
  2110. echo $rid;
  2111. echo $ridLoan;
  2112. }
  2113. }
  2114. /**
  2115. * 培训班结算挂钩发票
  2116. */
  2117. function receiptTrainInvoiceEdi(){
  2118. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2119. Doo::loadClass ( 'XDeode' );
  2120. $XDeode = new XDeode ( 7 );
  2121. $rid = $XDeode->decode ( $ridKey );
  2122. if (! is_numeric ( $rid ))
  2123. die ( 'illegal request' );
  2124. Doo::loadModel ( 'receipt' );
  2125. $receipt = new receipt ();
  2126. Doo::loadModel ( 'receiptTraining' );
  2127. $receiptTraining = new receiptTraining ();
  2128. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2129. if ($receiptDetail ['status'] != 5)
  2130. die ();
  2131. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2132. $data ['receiptDetail'] = $receiptDetail;
  2133. $data ['trainEdiType'] = "INVOICE";
  2134. $data ['ridKey'] = $ridKey;
  2135. $data ['memu'] = "receipt";
  2136. $data ['staff'] = $this->staff;
  2137. $data ['receiptMemu'] = 'saeaBorad';
  2138. $data ['verifyId'] = $this->verifyId;
  2139. $data ['executeId'] = $this->executeId;
  2140. $this->render ( "/receipt/receiptTrainInvoiceEdi", $data );
  2141. }
  2142. function confirmation() {
  2143. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2144. Doo::loadModel ( 'receipt' );
  2145. Doo::loadModel ( 'receiptDetail' );
  2146. $receipt = new receipt ();
  2147. $receiptDetail = new receiptDetail ();
  2148. Doo::loadModel ( 'statistics' );
  2149. Doo::loadModel ( 'itemStatistics' );
  2150. $statistics = new statistics ();
  2151. $itemStatistics = new itemStatistics ();
  2152. Doo::loadModel ( "verify" );
  2153. $verify = new verify ();
  2154. $receiptDetailList = $receipt->getOne ( array (
  2155. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  2156. 'asArray' => true
  2157. ) );
  2158. if (empty ( $receiptDetailList ))
  2159. return "/saeaBorad";
  2160. $verifyDetail = $verify->getOne ( array (
  2161. 'where' => ' vid =' . $receiptDetailList ['verify'],
  2162. 'asArray' => true
  2163. ) );
  2164. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  2165. if (empty ( $receiptDetailList ['nowStaff'] )) {
  2166. $nowStaff = "";
  2167. $nowStaffList = array ();
  2168. if ($verifyDetail [0] [1] == 'ROLE') {
  2169. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  2170. foreach ( $vStaffString as $key => $value ) {
  2171. $staffK = explode ( "_", $value );
  2172. array_push ( $nowStaffList, $staffK [0] );
  2173. }
  2174. $nowStaff = implode ( ',', $nowStaffList );
  2175. } else {
  2176. $nowStaff = $verifyDetail [0] [0];
  2177. }
  2178. $receipt->nowStaff = $nowStaff;
  2179. }
  2180. // echo $nowStaff;
  2181. // print_r($verifyDetail);die;
  2182. $receipt->rid = $receiptDetailList ['rid'];
  2183. $receipt->status = 2;
  2184. $receipt->update ();
  2185. // 操作日志
  2186. Doo::loadModel ( "receiptLog" );
  2187. $receiptLog = new receiptLog ();
  2188. $verify = new verify ();
  2189. $receiptInfo = $receipt->getOne ( array (
  2190. 'where' => 'rid=' . $rid,
  2191. 'asArray' => true
  2192. ) );
  2193. $vr = $verify->getOne ( array (
  2194. 'where' => 'vid=' . $receiptInfo ['verify'],
  2195. 'asArray' => true
  2196. ) );
  2197. $jd = json_decode ( $vr ['staff'] );
  2198. $roleId = 0;
  2199. foreach ( $jd as $key => $value ) {
  2200. if ($value [1] == 'ROLE') {
  2201. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  2202. if ($pos !== false) {
  2203. $roleId = $value [0];
  2204. }
  2205. }
  2206. }
  2207. // 审批日志
  2208. // echo $roleId;die;
  2209. if (! empty ( $roleId )) {
  2210. Doo::loadModel ( "role" );
  2211. $role = new role ();
  2212. $roleInfo = $role->getOne ( array (
  2213. 'where' => 'rid=' . $roleId,
  2214. 'asArray' => true
  2215. ) );
  2216. // $receiptLog->rolename = $roleInfo ['name'];
  2217. }
  2218. $receiptLog->username = $this->staff [0] ['username'];
  2219. $receiptLog->uid = $this->staff [0] ['sid'];
  2220. $receiptLog->date = date ( "Y-m-d" );
  2221. $receiptLog->opinion = '提交审批';
  2222. $receiptLog->img = $this->staff [0] ['avatar'];
  2223. $receiptLog->status = 2;
  2224. $receiptLog->rid = $rid;
  2225. $receiptLog->insert ();
  2226. return "/expenses";
  2227. }
  2228. function expenses() {
  2229. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  2230. if (empty ( $item ))
  2231. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  2232. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  2233. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  2234. Doo::loadModel ( 'receipt' );
  2235. $receipt = new receipt ();
  2236. Doo::loadModel ( 'L_category' );
  2237. $Lcategory = new L_category ();
  2238. Doo::loadModel ( 'verify' );
  2239. Doo::loadModel ( 'statistics' );
  2240. $statistics = new statistics ();
  2241. $verify = new verify ();
  2242. Doo::loadModel ( 'staff' );
  2243. $staff = new staff ();
  2244. $condition = "";
  2245. if ($item == "expenses")
  2246. $condition = " and Rtype=1 ";
  2247. elseif ($item == "receipts")
  2248. $condition = " and Rtype=0 ";
  2249. elseif ($item == "remits")
  2250. $condition = " and Rtype=2 ";
  2251. $dateCondition = " and Year(date) =" . $year;
  2252. if (! empty ( $moth )) {
  2253. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  2254. $stList = $statistics->getOne ( array (
  2255. 'select' => 'rePrice ,agPrice',
  2256. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  2257. 'asArray' => true
  2258. ) );
  2259. } else
  2260. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  2261. if (empty ( $stList ))
  2262. $stList = array (
  2263. 'rePrice' => 0,
  2264. 'agPrice' => 0
  2265. );
  2266. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  2267. if (! isset ( $noPassSum ['sum'] ))
  2268. $noPassSum ['sum'] = 0;
  2269. $data ['stList'] = array (
  2270. 'rePrice' => $stList ['rePrice'],
  2271. 'agPrice' => $stList ['agPrice'],
  2272. 'skPrice' => ($noPassSum ['sum'])
  2273. );
  2274. $receiptList = $receipt->find ( array (
  2275. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  2276. 'desc' => 'rid',
  2277. 'asArray' => true
  2278. ) );
  2279. $Locate = 0;
  2280. $roleId = 0;
  2281. $button = 0;
  2282. foreach ( $receiptList as $key => $value ) {
  2283. $receiptList [$key] ['Locate'] = $Locate;
  2284. $Locate ++;
  2285. $receiptList [$key] ['reviseDetail'] = array ();
  2286. if (! empty ( $value ['reviseDetail'] ))
  2287. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2288. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2289. $categoryDetil = $Lcategory->getOne ( array (
  2290. 'where' => 'cid=' . $value ['cid'],
  2291. 'asArray' => true
  2292. ) );
  2293. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2294. // 检测编辑状态
  2295. $verifyList = $verify->getOne ( array (
  2296. 'where' => 'vid=' . $value ['verify'],
  2297. 'asArray' => true
  2298. ) );
  2299. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2300. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2301. Doo::loadModel ( 'role' );
  2302. $role = new role ();
  2303. $flag = true;
  2304. $roleKey = 0;
  2305. $endStaffArray = array ();
  2306. $roleArrayCopy = array ();
  2307. foreach ( $verifyList as $k => $v ) {
  2308. // init verifyStaff
  2309. if ($v [1] == 'ROLE') {
  2310. if (! empty ( $verifyStaff )) {
  2311. $endStaffArray = end ( $verifyStaff );
  2312. // if ($v[0]==$endStaffArray['nextStaff']){
  2313. // $roleId=$v[0];
  2314. // }
  2315. }
  2316. $roleVerify = json_decode ( $v [3], true );
  2317. $roleKey = $k;
  2318. $roleArray = array ();
  2319. $rolename = $role->getOne ( array (
  2320. 'where' => 'rid=' . $v [0],
  2321. 'asArray' => true
  2322. ) );
  2323. foreach ( $roleVerify as $o => $p ) {
  2324. $staffID = explode ( '_', $p );
  2325. $staffInfo = $staff->getOne ( array (
  2326. 'where' => 'sid=' . $staffID [0],
  2327. 'asArray' => true
  2328. ) );
  2329. // print_r($staffID);
  2330. $exp = array (
  2331. 0 => $staffInfo ['sid'],
  2332. 1 => $staffID [1],
  2333. 2 => $staffInfo ['avatar'],
  2334. 'date' => '',
  2335. 'date' => '',
  2336. 'opinion' => '',
  2337. 'status' => '',
  2338. 'rolename' => $rolename ['name']
  2339. );
  2340. array_push ( $roleArray, $exp );
  2341. }
  2342. $roleArrayCopy [$v [0]] = $roleArray;
  2343. // $verifyList[$k]['roleArray']=$roleArray;
  2344. }
  2345. $verifyList [$k] ['date'] = "";
  2346. $verifyList [$k] ['opinion'] = "";
  2347. $verifyList [$k] ['status'] = "";
  2348. if (empty ( $verifyStaff )) {
  2349. $verifyList [$k] ['date'] = "";
  2350. $verifyList [$k] ['opinion'] = "";
  2351. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2352. $verifyList [$k] ['status'] = 4;
  2353. $flag = false;
  2354. }
  2355. } else {
  2356. foreach ( $verifyStaff as $m => $u ) {
  2357. if ($v [0] == $m) {
  2358. $verifyList [$k] ['date'] = $u ['date'];
  2359. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2360. $verifyList [$k] ['status'] = $u ['status'];
  2361. $flag = false;
  2362. break;
  2363. }
  2364. }
  2365. $endStaffArray = end ( $verifyStaff );
  2366. if (isset ( $endStaffArray ['ROLE'] )) {
  2367. } else {
  2368. // $endKey=key($verifyStaff);
  2369. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2370. // $button=4;
  2371. // $verifyList[$k]['status']=4;
  2372. // }
  2373. }
  2374. }
  2375. }
  2376. $rolename ['name'] = '';
  2377. if (! empty ( $roleId )) {
  2378. Doo::loadModel ( 'role' );
  2379. $role = new role ();
  2380. $rolename = $role->getOne ( array (
  2381. 'where' => 'rid=' . $roleId,
  2382. 'asArray' => true
  2383. ) );
  2384. }
  2385. if (! empty ( $verifyStaff ))
  2386. $endStaffArray = end ( $verifyStaff );
  2387. $KOP = false;
  2388. foreach ( $roleArrayCopy as $P => $A ) {
  2389. foreach ( $A as $MKI => $AVL ) {
  2390. if (! empty ( $verifyStaff )) {
  2391. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2392. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2393. $button = 4;
  2394. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2395. }
  2396. foreach ( $verifyStaff as $m => $u ) {
  2397. $AVLFK = $AVL [0] . '_R';
  2398. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2399. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2400. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2401. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2402. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2403. break;
  2404. }
  2405. }
  2406. } else {
  2407. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2408. $button = 4;
  2409. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2410. }
  2411. }
  2412. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2413. $KOP = true;
  2414. }
  2415. }
  2416. foreach ( $roleArrayCopy as $k => $v ) {
  2417. foreach ( $verifyList as $m => $n ) {
  2418. if ($n [0] == $k) {
  2419. array_splice ( $verifyList, $m, 1, $v );
  2420. }
  2421. }
  2422. }
  2423. $receiptList [$key] ['verifyList'] = $verifyList;
  2424. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2425. 'where' => 'sid=' . $value ['staff'],
  2426. 'asArray' => true
  2427. ) );
  2428. $receiptList [$key] ['button'] = $button;
  2429. }
  2430. // print_r($receiptList);die;
  2431. $mothHtml = "";
  2432. for($i = 1; $i <= 12; $i ++) {
  2433. if ($moth == $i)
  2434. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2435. else
  2436. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2437. }
  2438. $dateHtml = "";
  2439. $now = date ( "Y" );
  2440. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  2441. if ($YEARD <= $now) {
  2442. $dateHtml .= '<option ';
  2443. if ($year == $YEARD) {
  2444. $dateHtml .= 'selected ';
  2445. }
  2446. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  2447. }
  2448. }
  2449. $data ['dateHtml'] = $dateHtml;
  2450. $data ['mothHtml'] = $mothHtml;
  2451. $data ['receiptList'] = $receiptList;
  2452. $data ['memu'] = "receipt";
  2453. $data ['staff'] = $this->staff;
  2454. $data ['receiptMemu'] = 'expenses';
  2455. $data ['verifyId'] = $this->verifyId;
  2456. $data ['executeId'] = $this->executeId;
  2457. $data ['item'] = $item;
  2458. $data ['year'] = $year;
  2459. $this->render ( "/admin/expenses", $data );
  2460. }
  2461. function expensesCollect() {
  2462. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2463. Doo::loadModel ( 'receipt' );
  2464. $receipt = new receipt ();
  2465. Doo::loadModel ( 'L_category' );
  2466. $Lcategory = new L_category ();
  2467. Doo::loadModel ( 'verify' );
  2468. Doo::loadModel ( 'statistics' );
  2469. $statistics = new statistics ();
  2470. $verify = new verify ();
  2471. Doo::loadModel ( 'staff' );
  2472. $staff = new staff ();
  2473. Doo::loadModel ( 'loanReceipt' );
  2474. $loanReceipt = new loanReceipt ();
  2475. $receiptList = $receipt->find ( array (
  2476. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  2477. 'desc' => 'rid',
  2478. 'asArray' => true
  2479. ) );
  2480. $loanList = $loanReceipt->find ( array (
  2481. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2482. 'desc' => 'rid',
  2483. 'asArray' => true
  2484. ) );
  2485. /*
  2486. * $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;
  2487. */
  2488. $data ['explanation'] = '';
  2489. if (! empty ( $loanList ))
  2490. $data ['explanation'] = $loanList [0] ['explanation'];
  2491. $Locate = 0;
  2492. $roleId = 0;
  2493. $button = 0;
  2494. foreach ( $receiptList as $key => $value ) {
  2495. $receiptList [$key] ['Locate'] = $Locate;
  2496. $Locate ++;
  2497. $receiptList [$key] ['reviseDetail'] = array ();
  2498. if (! empty ( $value ['reviseDetail'] ))
  2499. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2500. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2501. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2502. $categoryDetil = $Lcategory->getOne ( array (
  2503. 'where' => 'cid=' . $value ['cid'],
  2504. 'asArray' => true
  2505. ) );
  2506. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2507. // 检测编辑状态
  2508. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  2509. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  2510. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  2511. else
  2512. $verifyList ['staff'] = $value ['verifyBreakup'];
  2513. } else
  2514. $verifyList = $verify->getOne ( array (
  2515. 'where' => 'vid=' . $value ['verify'],
  2516. 'asArray' => true
  2517. ) );
  2518. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2519. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2520. Doo::loadModel ( 'role' );
  2521. $role = new role ();
  2522. $flag = true;
  2523. $roleKey = 0;
  2524. $endStaffArray = array ();
  2525. $roleArrayCopy = array ();
  2526. foreach ( $verifyList as $k => $v ) {
  2527. // init verifyStaff
  2528. if ($v [1] == 'ROLE') {
  2529. if (! empty ( $verifyStaff )) {
  2530. $endStaffArray = end ( $verifyStaff );
  2531. // if ($v[0]==$endStaffArray['nextStaff']){
  2532. // $roleId=$v[0];
  2533. // }
  2534. }
  2535. $roleVerify = json_decode ( $v [3], true );
  2536. $roleKey = $k;
  2537. $roleArray = array ();
  2538. $rolename = $role->getOne ( array (
  2539. 'where' => 'rid=' . $v [0],
  2540. 'asArray' => true
  2541. ) );
  2542. foreach ( $roleVerify as $o => $p ) {
  2543. $staffID = explode ( '_', $p );
  2544. $staffInfo = $staff->getOne ( array (
  2545. 'where' => 'sid=' . $staffID [0],
  2546. 'asArray' => true
  2547. ) );
  2548. // print_r($staffID);
  2549. $exp = array (
  2550. 0 => $staffInfo ['sid'],
  2551. 1 => $staffID [1],
  2552. 2 => $staffInfo ['avatar'],
  2553. 'date' => '',
  2554. 'date' => '',
  2555. 'opinion' => '',
  2556. 'status' => '',
  2557. 'rolename' => $rolename ['name']
  2558. );
  2559. array_push ( $roleArray, $exp );
  2560. }
  2561. $roleArrayCopy [$v [0]] = $roleArray;
  2562. // $verifyList[$k]['roleArray']=$roleArray;
  2563. }
  2564. $verifyList [$k] ['date'] = "";
  2565. $verifyList [$k] ['opinion'] = "";
  2566. $verifyList [$k] ['status'] = "";
  2567. if (empty ( $verifyStaff )) {
  2568. $verifyList [$k] ['date'] = "";
  2569. $verifyList [$k] ['opinion'] = "";
  2570. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2571. $verifyList [$k] ['status'] = 4;
  2572. $flag = false;
  2573. }
  2574. } else {
  2575. foreach ( $verifyStaff as $m => $u ) {
  2576. if ($v [0] == $m) {
  2577. $verifyList [$k] ['date'] = $u ['date'];
  2578. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2579. $verifyList [$k] ['status'] = $u ['status'];
  2580. $flag = false;
  2581. break;
  2582. }
  2583. }
  2584. $endStaffArray = end ( $verifyStaff );
  2585. if (isset ( $endStaffArray ['ROLE'] )) {
  2586. } else {
  2587. // $endKey=key($verifyStaff);
  2588. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2589. // $button=4;
  2590. // $verifyList[$k]['status']=4;
  2591. // }
  2592. }
  2593. }
  2594. }
  2595. $rolename ['name'] = '';
  2596. if (! empty ( $roleId )) {
  2597. Doo::loadModel ( 'role' );
  2598. $role = new role ();
  2599. $rolename = $role->getOne ( array (
  2600. 'where' => 'rid=' . $roleId,
  2601. 'asArray' => true
  2602. ) );
  2603. }
  2604. if (! empty ( $verifyStaff ))
  2605. $endStaffArray = end ( $verifyStaff );
  2606. $KOP = false;
  2607. foreach ( $roleArrayCopy as $P => $A ) {
  2608. foreach ( $A as $MKI => $AVL ) {
  2609. if (! empty ( $verifyStaff )) {
  2610. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2611. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2612. $button = 4;
  2613. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2614. }
  2615. foreach ( $verifyStaff as $m => $u ) {
  2616. $AVLFK = $AVL [0] . '_R';
  2617. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2618. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2619. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2620. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2621. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2622. break;
  2623. }
  2624. }
  2625. } else {
  2626. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2627. $button = 4;
  2628. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2629. }
  2630. }
  2631. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2632. $KOP = true;
  2633. }
  2634. }
  2635. foreach ( $roleArrayCopy as $k => $v ) {
  2636. foreach ( $verifyList as $m => $n ) {
  2637. if ($n [0] == $k) {
  2638. array_splice ( $verifyList, $m, 1, $v );
  2639. }
  2640. }
  2641. }
  2642. // 费用执行人相关数据
  2643. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2644. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2645. foreach ( $executeCopy as $k => $v ) {
  2646. $executeCopy [$k] ['date'] = '';
  2647. $executeCopy [$k] ['opinion'] = '';
  2648. $executeCopy [$k] ['status'] = '';
  2649. if (! empty ( $executeStaff ))
  2650. foreach ( $executeStaff as $m => $u ) {
  2651. if ($v [0] == $m) {
  2652. $executeCopy [$k] ['date'] = $u ['date'];
  2653. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2654. $executeCopy [$k] ['status'] = $u ['status'];
  2655. break;
  2656. }
  2657. }
  2658. }
  2659. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2660. $receiptList [$key] ['verifyList'] = $verifyList;
  2661. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2662. 'where' => 'sid=' . $value ['staff'],
  2663. 'asArray' => true
  2664. ) );
  2665. $receiptList [$key] ['button'] = $button;
  2666. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2667. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2668. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  2669. $receiptList [$key] ['relust'] = $relust;
  2670. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2671. }
  2672. Doo::loadModel ( 'enclosur' );
  2673. $enclosur = new enclosur ();
  2674. $enclosurList = $enclosur->find ( array (
  2675. 'where' => 'rid=' . $rid,
  2676. 'asArray' => true
  2677. ) );
  2678. $enclosurHtml = '';
  2679. foreach ( $enclosurList as $value ) {
  2680. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2681. }
  2682. $data ['enclosurHtml'] = $enclosurHtml;
  2683. // print_r($receiptList);
  2684. $data ['receiptList'] = $receiptList;
  2685. $data ['memu'] = "receipt";
  2686. $data ['staff'] = $this->staff;
  2687. $data ['receiptMemu'] = 'expenses';
  2688. $data ['verifyId'] = $this->verifyId;
  2689. $data ['executeId'] = $this->executeId;
  2690. $this->render ( "/admin/expensesCollect", $data );
  2691. }
  2692. function approvalExpenses() {
  2693. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  2694. $year = $rdate = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2695. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2696. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2697. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2698. // $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) :"";
  2699. // echo $rdate;
  2700. if (empty ( $status ))
  2701. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  2702. $page_size = 2;
  2703. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2704. $vidList = array ();
  2705. $button = 0;
  2706. Doo::loadModel ( 'verify' );
  2707. $verify = new verify ();
  2708. Doo::loadModel ( 'receipt' );
  2709. $receipt = new receipt ();
  2710. Doo::loadModel ( 'staff' );
  2711. $staff = new staff ();
  2712. Doo::loadModel ( 'L_category' );
  2713. $Lcategory = new L_category ();
  2714. // user verify ID
  2715. $verifyDetail = $verify->find ( array (
  2716. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  2717. 'asArray' => true
  2718. ) );
  2719. foreach ( $verifyDetail as $key => $value ) {
  2720. array_push ( $vidList, $value ['vid'] );
  2721. }
  2722. $vid = implode ( ",", $vidList );
  2723. if (empty ( $verifyDetail ))
  2724. $vid = 0;
  2725. // if ($status==0)
  2726. // $dateCondition="";
  2727. // else
  2728. $dateCondition = " ";
  2729. // if (! empty ( $month ))
  2730. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  2731. if ($status == 'done' || $status == 'termination') {
  2732. if (! empty ( $year )) {
  2733. $dateCondition = " and Year(pastDate) =" . $year;
  2734. if (! empty ( $month ))
  2735. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  2736. }
  2737. } elseif ($status == 'finish') {
  2738. if (! empty ( $year )) {
  2739. $dateCondition = " and Year(pastDate) =" . $year;
  2740. if (! empty ( $month ))
  2741. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  2742. }
  2743. }
  2744. // date ( 'Y-m' )
  2745. // if (! empty ( $rdate ) && $status == 'done')
  2746. // $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  2747. // elseif (! empty ( $rdate ))
  2748. // $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  2749. $categoryList = $Lcategory->find ( array (
  2750. 'asArray' => true
  2751. ) );
  2752. $staffList = $staff->find ( array (
  2753. 'where' => 'cid=' . $cid,
  2754. 'asArray' => true
  2755. ) );
  2756. $cateCondition = "";
  2757. $staffCondition = "";
  2758. $approvalCondition = "";
  2759. if (! empty ( $cid )) {
  2760. $cateCondition = ' and cid=' . $cid;
  2761. }
  2762. if (! empty ( $sid )) {
  2763. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  2764. $cateCondition = "";
  2765. }
  2766. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  2767. if ($status == 'pendApproval') {
  2768. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  2769. }
  2770. if ($status == 'ongoing') {
  2771. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  2772. }
  2773. if ($status == 'done') {
  2774. $approvalCondition = ' and (status=8 or status=9 ) ';
  2775. }
  2776. if ($status == 'termination') {
  2777. $approvalCondition = " and status=3";
  2778. }
  2779. if ($status == 'finish') {
  2780. $approvalCondition = " and (status=1 or status=8 or status=9)";
  2781. }
  2782. $pageinfo ['page'] = array (
  2783. 'previous' => ''
  2784. );
  2785. if ($status == 'done' || $status == 'termination' || $status == 'finish') { // $dateCondition .
  2786. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  2787. $receiptList = $receipt->find ( array ( // $dateCondition.
  2788. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  2789. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2790. 'desc' => 'rid',
  2791. 'asArray' => true
  2792. ) );
  2793. } else {
  2794. $receiptList = $receipt->find ( array ( // $dateCondition
  2795. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  2796. 'desc' => 'rid',
  2797. 'asArray' => true
  2798. ) );
  2799. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  2800. }
  2801. $rLRes = $receipt->find ( array (
  2802. '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 . ')',
  2803. 'desc' => 'rid',
  2804. 'asArray' => true
  2805. ) );
  2806. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  2807. // print_r($receiptList);
  2808. $Locate = 0;
  2809. $reportList = $reportCateList = array ();
  2810. foreach ( $receiptList as $key => $value ) {
  2811. $receiptList [$key] ['Locate'] = $Locate;
  2812. $Locate ++;
  2813. $receiptList [$key] ['reviseDetail'] = array ();
  2814. if (! empty ( $value ['reviseDetail'] ))
  2815. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2816. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2817. $categoryDetil = $Lcategory->getOne ( array (
  2818. 'where' => 'cid=' . $value ['cid'],
  2819. 'asArray' => true
  2820. ) );
  2821. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2822. $verifyList = $verify->getOne ( array (
  2823. 'where' => 'vid=' . $value ['verify'],
  2824. 'asArray' => true
  2825. ) );
  2826. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2827. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2828. foreach ( $verifyList as $k => $v ) {
  2829. // init verifyStaff
  2830. $verifyList [$k] ['date'] = "";
  2831. $verifyList [$k] ['opinion'] = "";
  2832. $verifyList [$k] ['status'] = "";
  2833. if (empty ( $verifyStaff )) {
  2834. $verifyList [$k] ['date'] = "";
  2835. $verifyList [$k] ['opinion'] = "";
  2836. if ($v [0] == $this->staff [0] ['sid']) {
  2837. $verifyList [$k] ['status'] = 4;
  2838. $button = 4;
  2839. }
  2840. } else {
  2841. $flag = true;
  2842. foreach ( $verifyStaff as $m => $u ) {
  2843. if ($v [0] == $m) {
  2844. $verifyList [$k] ['date'] = $u ['date'];
  2845. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2846. $verifyList [$k] ['status'] = $u ['status'];
  2847. $flag = false;
  2848. break;
  2849. }
  2850. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  2851. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  2852. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  2853. }
  2854. if ($flag) { // 检测可编辑
  2855. if ($v [0] == $this->staff [0] ['sid']) {
  2856. $verifyList [$k] ['status'] = 4;
  2857. $button = 4;
  2858. }
  2859. }
  2860. }
  2861. }
  2862. $receiptList [$key] ['verifyList'] = $verifyList;
  2863. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2864. 'where' => 'sid=' . $value ['staff'],
  2865. 'asArray' => true
  2866. ) );
  2867. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  2868. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  2869. $receiptList [$key] ['button'] = $button;
  2870. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  2871. }
  2872. $reportList = array_unique ( $reportList );
  2873. $reportHtml = '';
  2874. foreach ( $reportList as $key => $value ) {
  2875. $v = explode ( "-", $value );
  2876. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  2877. }
  2878. // print_r($reportList)
  2879. $data ['reportHtml'] = $reportHtml;
  2880. $reportCateList = array_unique ( $reportCateList );
  2881. $reportCateHtml = '';
  2882. foreach ( $reportCateList as $key => $value ) {
  2883. $v = explode ( "-", $value );
  2884. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  2885. }
  2886. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  2887. $data ['reportCateHtml'] = $reportCateHtml;
  2888. // print_r($receiptList);die;
  2889. // $data['verifyDetail']=$verifyDetail;
  2890. $mothHtml = "";
  2891. for($i = 1; $i <= 12; $i ++) {
  2892. if ($month == $i)
  2893. $mothHtml .= '<option selected value="0' . $i . '">' . $i . '月</option>';
  2894. else
  2895. $mothHtml .= '<option value="0' . $i . '">' . $i . '月</option>';
  2896. }
  2897. $data ['mothHtml'] = $mothHtml;
  2898. $dateHtml = "";
  2899. $now = date ( "Y" );
  2900. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  2901. if ($YEARD <= $now) {
  2902. $dateHtml .= '<option ';
  2903. if ($year == $YEARD) {
  2904. $dateHtml .= 'selected ';
  2905. }
  2906. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  2907. }
  2908. }
  2909. $data ['dateHtml'] = $dateHtml;
  2910. $data ['page'] = $pageinfo;
  2911. $data ['receiptList'] = $receiptList;
  2912. $data ['receiptApprovalCount'] = count ( $rLRes );
  2913. $data ['status'] = $status;
  2914. $data ['year'] = $year;
  2915. $data ['month'] = $month;
  2916. $data ['categoryList'] = $categoryList;
  2917. $data ['staffList'] = $staffList;
  2918. $data ['cid'] = $cid;
  2919. $data ['sid'] = $sid;
  2920. // print_r($receiptList);
  2921. $data ['memu'] = "receipt";
  2922. $data ['staff'] = $this->staff;
  2923. $data ['receiptMemu'] = 'approvalExpenses';
  2924. $data ['verifyId'] = $this->verifyId;
  2925. $data ['executeId'] = $this->executeId;
  2926. $this->render ( "/admin/approvalExpenses", $data );
  2927. }
  2928. function expensesDoc() {
  2929. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2930. Doo::loadClass ( 'XDeode' );
  2931. $XDeode = new XDeode ( 5 );
  2932. if (! empty ( $rid ) && ! is_numeric ( $rid ))
  2933. $rid = $XDeode->decode ( $rid );
  2934. if (! is_numeric ( $rid ))
  2935. die ( 'illegal request' );
  2936. Doo::loadModel ( 'receipt' );
  2937. $receipt = new receipt ();
  2938. Doo::loadModel ( 'L_category' );
  2939. $Lcategory = new L_category ();
  2940. Doo::loadModel ( 'verify' );
  2941. Doo::loadModel ( 'statistics' );
  2942. $statistics = new statistics ();
  2943. $verify = new verify ();
  2944. Doo::loadModel ( 'staff' );
  2945. $staff = new staff ();
  2946. Doo::loadModel ( 'loanReceipt' );
  2947. $loanReceipt = new loanReceipt ();
  2948. $receiptList = $receipt->find ( array (
  2949. 'where' => ' rid=' . $rid,
  2950. 'desc' => 'rid',
  2951. 'asArray' => true
  2952. ) );
  2953. $loanList = array ();
  2954. if (! empty ( $receiptList ))
  2955. $loanList = $loanReceipt->find ( array (
  2956. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2957. 'desc' => 'rid',
  2958. 'asArray' => true
  2959. ) );
  2960. $Locate = 0;
  2961. $roleId = 0;
  2962. $button = 0;
  2963. foreach ( $loanList as $key => $value ) {
  2964. $loanList [$key] ['Locate'] = $Locate;
  2965. $Locate ++;
  2966. $loanList [$key] ['reviseDetail'] = array ();
  2967. if (! empty ( $value ['reviseDetail'] ))
  2968. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2969. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2970. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2971. $categoryDetil = $Lcategory->getOne ( array (
  2972. 'where' => 'cid=' . $value ['cid'],
  2973. 'asArray' => true
  2974. ) );
  2975. $loanList [$key] ['category'] = $categoryDetil ['title'];
  2976. // 检测编辑状态
  2977. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  2978. $verifyList ['staff'] = $value ['verifyBreakup'];
  2979. else
  2980. $verifyList = $verify->getOne ( array (
  2981. 'where' => 'vid=' . $value ['verify'],
  2982. 'asArray' => true
  2983. ) );
  2984. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2985. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2986. Doo::loadModel ( 'role' );
  2987. $role = new role ();
  2988. $flag = true;
  2989. $roleKey = 0;
  2990. $endStaffArray = array ();
  2991. $roleArrayCopy = array ();
  2992. foreach ( $verifyList as $k => $v ) {
  2993. // init verifyStaff
  2994. if ($v [1] == 'ROLE') {
  2995. if (! empty ( $verifyStaff )) {
  2996. $endStaffArray = end ( $verifyStaff );
  2997. // if ($v[0]==$endStaffArray['nextStaff']){
  2998. // $roleId=$v[0];
  2999. // }
  3000. }
  3001. $roleVerify = json_decode ( $v [3], true );
  3002. $roleKey = $k;
  3003. $roleArray = array ();
  3004. $rolename = $role->getOne ( array (
  3005. 'where' => 'rid=' . $v [0],
  3006. 'asArray' => true
  3007. ) );
  3008. foreach ( $roleVerify as $o => $p ) {
  3009. $staffID = explode ( '_', $p );
  3010. $staffInfo = $staff->getOne ( array (
  3011. 'where' => 'sid=' . $staffID [0],
  3012. 'asArray' => true
  3013. ) );
  3014. // print_r($staffID);
  3015. $exp = array (
  3016. 0 => $staffInfo ['sid'],
  3017. 1 => $staffID [1],
  3018. 2 => $staffInfo ['avatar'],
  3019. 'date' => '',
  3020. 'date' => '',
  3021. 'opinion' => '',
  3022. 'status' => '',
  3023. 'rolename' => $rolename ['name']
  3024. );
  3025. array_push ( $roleArray, $exp );
  3026. }
  3027. $roleArrayCopy [$v [0]] = $roleArray;
  3028. // $verifyList[$k]['roleArray']=$roleArray;
  3029. }
  3030. $verifyList [$k] ['date'] = "";
  3031. $verifyList [$k] ['opinion'] = "";
  3032. $verifyList [$k] ['status'] = "";
  3033. if (empty ( $verifyStaff )) {
  3034. $verifyList [$k] ['date'] = "";
  3035. $verifyList [$k] ['opinion'] = "";
  3036. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3037. $verifyList [$k] ['status'] = 4;
  3038. $flag = false;
  3039. }
  3040. } else {
  3041. foreach ( $verifyStaff as $m => $u ) {
  3042. if ($v [0] == $m) {
  3043. $verifyList [$k] ['date'] = $u ['date'];
  3044. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3045. $verifyList [$k] ['status'] = $u ['status'];
  3046. $flag = false;
  3047. break;
  3048. }
  3049. }
  3050. $endStaffArray = end ( $verifyStaff );
  3051. if (isset ( $endStaffArray ['ROLE'] )) {
  3052. } else {
  3053. // $endKey=key($verifyStaff);
  3054. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3055. // $button=4;
  3056. // $verifyList[$k]['status']=4;
  3057. // }
  3058. }
  3059. }
  3060. }
  3061. $rolename ['name'] = '';
  3062. if (! empty ( $roleId )) {
  3063. Doo::loadModel ( 'role' );
  3064. $role = new role ();
  3065. $rolename = $role->getOne ( array (
  3066. 'where' => 'rid=' . $roleId,
  3067. 'asArray' => true
  3068. ) );
  3069. }
  3070. if (! empty ( $verifyStaff ))
  3071. $endStaffArray = end ( $verifyStaff );
  3072. $KOP = false;
  3073. foreach ( $roleArrayCopy as $P => $A ) {
  3074. foreach ( $A as $MKI => $AVL ) {
  3075. if (! empty ( $verifyStaff )) {
  3076. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3077. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3078. $button = 4;
  3079. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3080. }
  3081. foreach ( $verifyStaff as $m => $u ) {
  3082. $AVLFK = $AVL [0] . '_R';
  3083. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3084. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3085. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3086. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3087. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3088. break;
  3089. }
  3090. }
  3091. } else {
  3092. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3093. $button = 4;
  3094. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3095. }
  3096. }
  3097. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3098. $KOP = true;
  3099. }
  3100. }
  3101. foreach ( $roleArrayCopy as $k => $v ) {
  3102. foreach ( $verifyList as $m => $n ) {
  3103. if ($n [0] == $k) {
  3104. array_splice ( $verifyList, $m, 1, $v );
  3105. }
  3106. }
  3107. }
  3108. $loanList [$key] ['verifyList'] = $verifyList;
  3109. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3110. 'where' => 'sid=' . $value ['staff'],
  3111. 'asArray' => true
  3112. ) );
  3113. $loanList [$key] ['button'] = $button;
  3114. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  3115. }
  3116. $data ['loanList'] = $loanList;
  3117. // print_r($loanList);
  3118. $Locate = 0;
  3119. $roleId = 0;
  3120. $button = 0;
  3121. foreach ( $receiptList as $key => $value ) {
  3122. $receiptList [$key] ['Locate'] = $Locate;
  3123. $Locate ++;
  3124. $receiptList [$key] ['reviseDetail'] = array ();
  3125. if (! empty ( $value ['reviseDetail'] ))
  3126. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3127. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3128. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3129. $categoryDetil = $Lcategory->getOne ( array (
  3130. 'where' => 'cid=' . $value ['cid'],
  3131. 'asArray' => true
  3132. ) );
  3133. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3134. // 检测编辑状态
  3135. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3136. $verifyList ['staff'] = $value ['verifyBreakup'];
  3137. } else
  3138. $verifyList = $verify->getOne ( array (
  3139. 'where' => 'vid=' . $value ['verify'],
  3140. 'asArray' => true
  3141. ) );
  3142. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3143. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3144. Doo::loadModel ( 'role' );
  3145. $role = new role ();
  3146. if ($verifyList == NULL)
  3147. $verifyList = array ();
  3148. $flag = true;
  3149. $roleKey = 0;
  3150. $endStaffArray = array ();
  3151. $roleArrayCopy = array ();
  3152. foreach ( $verifyList as $k => $v ) {
  3153. // init verifyStaff
  3154. if ($v [1] == 'ROLE') {
  3155. if (! empty ( $verifyStaff )) {
  3156. $endStaffArray = end ( $verifyStaff );
  3157. // if ($v[0]==$endStaffArray['nextStaff']){
  3158. // $roleId=$v[0];
  3159. // }
  3160. }
  3161. $roleVerify = json_decode ( $v [3], true );
  3162. $roleKey = $k;
  3163. $roleArray = array ();
  3164. $rolename = $role->getOne ( array (
  3165. 'where' => 'rid=' . $v [0],
  3166. 'asArray' => true
  3167. ) );
  3168. foreach ( $roleVerify as $o => $p ) {
  3169. $staffID = explode ( '_', $p );
  3170. $staffInfo = $staff->getOne ( array (
  3171. 'where' => 'sid=' . $staffID [0],
  3172. 'asArray' => true
  3173. ) );
  3174. // print_r($staffID);
  3175. $exp = array (
  3176. 0 => $staffInfo ['sid'],
  3177. 1 => $staffID [1],
  3178. 2 => $staffInfo ['avatar'],
  3179. 'date' => '',
  3180. 'date' => '',
  3181. 'opinion' => '',
  3182. 'status' => '',
  3183. 'rolename' => $rolename ['name']
  3184. );
  3185. array_push ( $roleArray, $exp );
  3186. }
  3187. $roleArrayCopy [$v [0]] = $roleArray;
  3188. // $verifyList[$k]['roleArray']=$roleArray;
  3189. }
  3190. $verifyList [$k] ['date'] = "";
  3191. $verifyList [$k] ['opinion'] = "";
  3192. $verifyList [$k] ['status'] = "";
  3193. if (empty ( $verifyStaff )) {
  3194. $verifyList [$k] ['date'] = "";
  3195. $verifyList [$k] ['opinion'] = "";
  3196. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3197. $verifyList [$k] ['status'] = 4;
  3198. $flag = false;
  3199. }
  3200. } else {
  3201. foreach ( $verifyStaff as $m => $u ) {
  3202. if ($v [0] == $m) {
  3203. $verifyList [$k] ['date'] = $u ['date'];
  3204. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3205. $verifyList [$k] ['status'] = $u ['status'];
  3206. $flag = false;
  3207. break;
  3208. }
  3209. }
  3210. $endStaffArray = end ( $verifyStaff );
  3211. if (isset ( $endStaffArray ['ROLE'] )) {
  3212. } else {
  3213. // $endKey=key($verifyStaff);
  3214. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3215. // $button=4;
  3216. // $verifyList[$k]['status']=4;
  3217. // }
  3218. }
  3219. }
  3220. }
  3221. $FC = @$rolename ['name'];
  3222. $rolename ['name'] = '';
  3223. if (! empty ( $roleId )) {
  3224. Doo::loadModel ( 'role' );
  3225. $role = new role ();
  3226. $rolename = $role->getOne ( array (
  3227. 'where' => 'rid=' . $roleId,
  3228. 'asArray' => true
  3229. ) );
  3230. }
  3231. if (! empty ( $verifyStaff ))
  3232. $endStaffArray = end ( $verifyStaff );
  3233. $KOP = false;
  3234. foreach ( $roleArrayCopy as $P => $A ) {
  3235. foreach ( $A as $MKI => $AVL ) {
  3236. if (! empty ( $verifyStaff )) {
  3237. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3238. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3239. $button = 4;
  3240. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3241. }
  3242. foreach ( $verifyStaff as $m => $u ) {
  3243. $AVLFK = $AVL [0] . '_R';
  3244. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3245. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3246. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3247. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3248. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3249. break;
  3250. }
  3251. }
  3252. } else {
  3253. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3254. $button = 4;
  3255. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3256. }
  3257. }
  3258. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3259. $KOP = true;
  3260. }
  3261. }
  3262. foreach ( $roleArrayCopy as $k => $v ) {
  3263. foreach ( $verifyList as $m => $n ) {
  3264. if ($n [0] == $k) {
  3265. array_splice ( $verifyList, $m, 1, $v );
  3266. }
  3267. }
  3268. }
  3269. // 费用执行人相关数据
  3270. $executeCopy = json_decode ( $value ['executeCopy'], true );
  3271. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3272. foreach ( $executeCopy as $k => $v ) {
  3273. $executeCopy [$k] ['date'] = '';
  3274. $executeCopy [$k] ['opinion'] = '';
  3275. $executeCopy [$k] ['status'] = '';
  3276. if (! empty ( $executeStaff ))
  3277. foreach ( $executeStaff as $m => $u ) {
  3278. if ($v [0] == $m) {
  3279. $executeCopy [$k] ['date'] = $u ['date'];
  3280. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  3281. $executeCopy [$k] ['status'] = $u ['status'];
  3282. break;
  3283. }
  3284. }
  3285. }
  3286. $receiptList [$key] ['executeCopy'] = $executeCopy;
  3287. // print_r($verifyList);
  3288. $receiptList [$key] ['verifyList'] = $verifyList;
  3289. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3290. 'where' => 'sid=' . $value ['staff'],
  3291. 'asArray' => true
  3292. ) );
  3293. $receiptList [$key] ['button'] = $button;
  3294. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3295. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3296. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  3297. $receiptList [$key] ['relust'] = $relust;
  3298. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  3299. }
  3300. // print_r($receiptList);
  3301. // 获取审批日志
  3302. Doo::loadModel ( 'receiptLog' );
  3303. $receiptLog = new receiptLog ();
  3304. $rlList = array ();
  3305. $rlInfo = $receiptLog->getOne ( array (
  3306. 'where' => 'rid=' . $rid . ' and status=4',
  3307. 'asArray' => true
  3308. ) );
  3309. $tijdate = $receiptLog->getOne ( array (
  3310. 'where' => 'rid=' . $rid . ' and status=2',
  3311. 'asc' => 'rlid',
  3312. 'asArray' => true
  3313. ) );
  3314. if (! empty ( $rlInfo )) {
  3315. $rlList = $receiptLog->find ( array (
  3316. 'where' => 'rid=' . $rid,
  3317. 'asc' => 'rlid',
  3318. 'asArray' => true
  3319. ) );
  3320. }
  3321. $RN = @json_decode ( $rolename ['staff'] );
  3322. //
  3323. foreach ( $rlList as $key => $value ) {
  3324. $rlList [$key] ['rolename'] = '';
  3325. foreach ( $RN as $k => $v ) {
  3326. $id = explode ( "_", $v );
  3327. if ($id [0] == $value ['uid']) {
  3328. $rlList [$key] ['rolename'] = $FC;
  3329. break;
  3330. }
  3331. }
  3332. }
  3333. Doo::loadModel ( 'enclosur' );
  3334. $enclosur = new enclosur ();
  3335. $enclosurList = $enclosur->find ( array (
  3336. 'where' => 'rid=' . $rid,
  3337. 'asArray' => true
  3338. ) );
  3339. $enclosurHtml = '';
  3340. foreach ( $enclosurList as $value ) {
  3341. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3342. }
  3343. $data ['enclosurHtml'] = $enclosurHtml;
  3344. $receiptList [0] ['rlList'] = $rlList;
  3345. $data ['receiptList'] = $receiptList;
  3346. // print_r($receiptList);
  3347. $data ['memu'] = "receipt";
  3348. $data ['staff'] = $this->staff;
  3349. $data ['receiptMemu'] = 'approvalExpenses';
  3350. $data ['verifyId'] = $this->verifyId;
  3351. $data ['executeId'] = $this->executeId;
  3352. $this->render ( "/admin/expensesDoc", $data );
  3353. }
  3354. function expensesEdi() {
  3355. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3356. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  3357. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  3358. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  3359. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3360. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  3361. if (empty ( $status ))
  3362. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  3363. $vidList = array ();
  3364. $button = 0;
  3365. Doo::loadModel ( 'verify' );
  3366. Doo::loadModel ( 'receipt' );
  3367. Doo::loadModel ( 'staff' );
  3368. $staff = new staff ();
  3369. $receipt = new receipt ();
  3370. $verify = new verify ();
  3371. Doo::loadModel ( 'L_category' );
  3372. $Lcategory = new L_category ();
  3373. Doo::loadModel ( 'enclosur' );
  3374. $enclosur = new enclosur ();
  3375. // user verify ID
  3376. $verifyDetail = $verify->find ( array (
  3377. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  3378. 'asArray' => true
  3379. ) );
  3380. foreach ( $verifyDetail as $key => $value ) {
  3381. array_push ( $vidList, $value ['vid'] );
  3382. }
  3383. $vid = implode ( ",", $vidList );
  3384. if (empty ( $verifyDetail ))
  3385. $vid = 0;
  3386. $categoryList = $Lcategory->find ( array (
  3387. 'asArray' => true
  3388. ) );
  3389. $staffList = $staff->find ( array (
  3390. 'where' => 'cid=' . $cid,
  3391. 'asArray' => true
  3392. ) );
  3393. $ap = "";
  3394. if ($status == 4) {
  3395. $ap = 4;
  3396. $status = 2;
  3397. }
  3398. // get Receipt By verifyID status 2
  3399. $receiptList = $receipt->find ( array (
  3400. 'where' => 'rid =' . $rid . ' and status=2',
  3401. 'desc' => 'rid',
  3402. 'asArray' => true
  3403. ) );
  3404. if (empty ( $receiptList )) {
  3405. die ( 'illegal request' );
  3406. }
  3407. $Locate = 0;
  3408. $roleId = 0;
  3409. if ($ap == 4)
  3410. $status = 4;
  3411. foreach ( $receiptList as $key => $value ) {
  3412. $receiptList [$key] ['Locate'] = $Locate;
  3413. $Locate ++;
  3414. $receiptList [$key] ['reviseDetail'] = array ();
  3415. if (! empty ( $value ['reviseDetail'] ))
  3416. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3417. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3418. $categoryDetil = $Lcategory->getOne ( array (
  3419. 'where' => 'cid=' . $value ['cid'],
  3420. 'asArray' => true
  3421. ) );
  3422. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3423. // 检测编辑状态
  3424. $verifyList = $verify->getOne ( array (
  3425. 'where' => 'vid=' . $value ['verify'],
  3426. 'asArray' => true
  3427. ) );
  3428. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3429. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3430. Doo::loadModel ( 'role' );
  3431. $role = new role ();
  3432. // print_r($verifyList);
  3433. $flag = true;
  3434. $roleKey = 0;
  3435. $endStaffArray = array ();
  3436. $roleArrayCopy = array ();
  3437. foreach ( $verifyList as $k => $v ) {
  3438. // init verifyStaff
  3439. if ($v [1] == 'ROLE') {
  3440. if (! empty ( $verifyStaff )) {
  3441. $endStaffArray = end ( $verifyStaff );
  3442. if ($v [0] == $endStaffArray ['nextStaff']) {
  3443. $roleId = $v [0];
  3444. }
  3445. }
  3446. $roleVerify = json_decode ( $v [3], true );
  3447. $roleKey = $k;
  3448. $roleArray = array ();
  3449. $rolename = $role->getOne ( array (
  3450. 'where' => 'rid=' . $v [0],
  3451. 'asArray' => true
  3452. ) );
  3453. foreach ( $roleVerify as $o => $p ) {
  3454. $staffID = explode ( '_', $p );
  3455. $staffInfo = $staff->getOne ( array (
  3456. 'where' => 'sid=' . $staffID [0],
  3457. 'asArray' => true
  3458. ) );
  3459. // print_r($staffID);
  3460. $exp = array (
  3461. 0 => $staffInfo ['sid'],
  3462. 1 => $staffID [1],
  3463. 2 => $staffInfo ['avatar'],
  3464. 'date' => '',
  3465. 'date' => '',
  3466. 'opinion' => '',
  3467. 'status' => '',
  3468. 'rolename' => $rolename ['name']
  3469. );
  3470. array_push ( $roleArray, $exp );
  3471. }
  3472. $roleArrayCopy [$v [0]] = $roleArray;
  3473. // $verifyList[$k]['roleArray']=$roleArray;
  3474. }
  3475. // print_r($roleArray);
  3476. $verifyList [$k] ['date'] = "";
  3477. $verifyList [$k] ['opinion'] = "";
  3478. $verifyList [$k] ['status'] = "";
  3479. if (empty ( $verifyStaff )) {
  3480. $verifyList [$k] ['date'] = "";
  3481. $verifyList [$k] ['opinion'] = "";
  3482. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3483. $verifyList [$k] ['status'] = 4;
  3484. $button = 4;
  3485. $flag = false;
  3486. }
  3487. } else {
  3488. foreach ( $verifyStaff as $m => $u ) {
  3489. if ($v [0] == $m) {
  3490. $verifyList [$k] ['date'] = $u ['date'];
  3491. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3492. $verifyList [$k] ['status'] = $u ['status'];
  3493. $flag = false;
  3494. break;
  3495. }
  3496. }
  3497. $endStaffArray = end ( $verifyStaff );
  3498. if (isset ( $endStaffArray ['ROLE'] )) {
  3499. } else {
  3500. $endKey = key ( $verifyStaff );
  3501. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  3502. $button = 4;
  3503. $verifyList [$k] ['status'] = 4;
  3504. }
  3505. }
  3506. }
  3507. }
  3508. $rolename ['name'] = '';
  3509. if (! empty ( $roleId )) {
  3510. Doo::loadModel ( 'role' );
  3511. $role = new role ();
  3512. $rolename = $role->getOne ( array (
  3513. 'where' => 'rid=' . $roleId,
  3514. 'asArray' => true
  3515. ) );
  3516. }
  3517. if (! empty ( $verifyStaff ))
  3518. $endStaffArray = end ( $verifyStaff );
  3519. $KOP = false;
  3520. foreach ( $roleArrayCopy as $P => $A ) {
  3521. foreach ( $A as $MKI => $AVL ) {
  3522. if (! empty ( $verifyStaff )) {
  3523. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3524. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3525. $button = 4;
  3526. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3527. }
  3528. foreach ( $verifyStaff as $m => $u ) {
  3529. $AVLFK = $AVL [0] . '_R';
  3530. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3531. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3532. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3533. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3534. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3535. break;
  3536. }
  3537. }
  3538. } else {
  3539. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3540. $button = 4;
  3541. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3542. }
  3543. }
  3544. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3545. $KOP = true;
  3546. }
  3547. }
  3548. // print_r($roleArrayCopy);
  3549. // echo $roleKey;
  3550. foreach ( $roleArrayCopy as $k => $v ) {
  3551. foreach ( $verifyList as $m => $n ) {
  3552. if ($n [0] == $k) {
  3553. array_splice ( $verifyList, $m, 1, $v );
  3554. }
  3555. }
  3556. }
  3557. $receiptList [$key] ['verifyList'] = $verifyList;
  3558. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3559. 'where' => 'sid=' . $value ['staff'],
  3560. 'asArray' => true
  3561. ) );
  3562. $receiptList [$key] ['button'] = $button;
  3563. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  3564. }
  3565. // $data['verifyDetail']=$verifyDetail;
  3566. $mothHtml = "";
  3567. for($i = 1; $i <= 12; $i ++) {
  3568. if ($month == $i)
  3569. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3570. else
  3571. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3572. }
  3573. // 获取审批日志
  3574. Doo::loadModel ( 'receiptLog' );
  3575. $receiptLog = new receiptLog ();
  3576. $rlList = array ();
  3577. $rlInfo = $receiptLog->getOne ( array (
  3578. 'where' => 'rid=' . $rid . ' and status=4',
  3579. 'asArray' => true
  3580. ) );
  3581. $tijdate = $receiptLog->getOne ( array (
  3582. 'where' => 'rid=' . $rid . ' and status=2',
  3583. 'asc' => 'rlid',
  3584. 'asArray' => true
  3585. ) );
  3586. if (! empty ( $rlInfo )) {
  3587. $rlList = $receiptLog->find ( array (
  3588. 'where' => 'rid=' . $rid,
  3589. 'asc' => 'rlid',
  3590. 'asArray' => true
  3591. ) );
  3592. }
  3593. $receiptList [0] ['rlList'] = $rlList;
  3594. $enclosurList = $enclosur->find ( array (
  3595. 'where' => 'rid=' . $rid,
  3596. 'asArray' => true
  3597. ) );
  3598. $enclosurHtml = '';
  3599. foreach ( $enclosurList as $value ) {
  3600. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3601. }
  3602. // print_r($receiptList);
  3603. $data ['rid'] = $rid;
  3604. $data ['enclosurHtml'] = $enclosurHtml;
  3605. $data ['rolename'] = $rolename ['name'];
  3606. $data ['datetij'] = $tijdate ['date'];
  3607. $data ['mothHtml'] = $mothHtml;
  3608. $data ['receiptList'] = $receiptList;
  3609. $data ['receiptApprovalCount'] = count ( $receiptList );
  3610. $data ['status'] = $status;
  3611. $data ['year'] = $year;
  3612. $data ['categoryList'] = $categoryList;
  3613. $data ['staffList'] = $staffList;
  3614. $data ['cid'] = $cid;
  3615. $data ['sid'] = $sid;
  3616. $data ['ap'] = $ap;
  3617. $data ['memu'] = "receipt";
  3618. $data ['staff'] = $this->staff;
  3619. $data ['receiptMemu'] = 'approvalExpenses';
  3620. $data ['verifyId'] = $this->verifyId;
  3621. $data ['executeId'] = $this->executeId;
  3622. $this->render ( "/admin/expensesEdi", $data );
  3623. }
  3624. function expensesDefray() {
  3625. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3626. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3627. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3628. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  3629. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  3630. if (! empty ( $rid )) {
  3631. Doo::loadModel ( "verify" );
  3632. $verify = new verify ();
  3633. Doo::loadModel ( "receiptDetail" );
  3634. $receiptDetailObj = new receiptDetail ();
  3635. Doo::loadModel ( "itemStatistics" );
  3636. Doo::loadModel ( "statistics" );
  3637. $statistics = new statistics ();
  3638. $itemStatistics = new itemStatistics ();
  3639. Doo::loadModel ( "receipt" );
  3640. $receipt = new receipt ();
  3641. Doo::loadModel ( "loanReceipt" );
  3642. $loanReceipt = new loanReceipt ();
  3643. $receiptDetail = $receipt->getOne ( array (
  3644. 'where' => 'rid=' . $rid . ' and status=2 ',
  3645. 'asArray' => true
  3646. ) );
  3647. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  3648. $nsflag = true;
  3649. foreach ( $nslist as $value ) {
  3650. if ($value == $this->staff ['0'] ['sid']) {
  3651. $nsflag = false;
  3652. break;
  3653. }
  3654. }
  3655. // print_r($nslist);die;
  3656. if (empty ( $receiptDetail ) || $nsflag)
  3657. return "/approvalExpenses/pendApproval";
  3658. $verifyDetail = $verify->getOne ( array (
  3659. 'where' => ' vid =' . $receiptDetail ['verify'],
  3660. 'asArray' => true
  3661. ) );
  3662. $verifyString = $verifyDetail ['staff'];
  3663. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3664. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  3665. if (empty ( $opinion )) {
  3666. if ($status == 3)
  3667. $opinion = "终止";
  3668. else
  3669. $opinion = "同意支付";
  3670. }
  3671. $nowStaff = 0;
  3672. $nowStaffList = array ();
  3673. if (empty ( $verifyStaff )) {
  3674. // 还需加入是否已经进入角色审批
  3675. if ($verifyDetail [0] [1] == 'ROLE') {
  3676. // print_r($verifyDetail);echo "ddd";
  3677. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3678. foreach ( $vStaffString as $key => $value ) {
  3679. $staffK = explode ( "_", $value );
  3680. if ($staffK [0] != $this->staff [0] ['sid'])
  3681. array_push ( $nowStaffList, $staffK [0] );
  3682. }
  3683. // print_r($verifyDetail);
  3684. // die;
  3685. if (! empty ( $nowStaffList )) {
  3686. $nowStaff = implode ( ',', $nowStaffList );
  3687. $verifyStaff = array (
  3688. $this->staff [0] ['sid'] . "_R" => array (
  3689. 'date' => date ( 'Y-m-d' ),
  3690. 'opinion' => $opinion,
  3691. 'status' => $status,
  3692. 'nextStaff' => $verifyDetail [0] [0],
  3693. 'ROLE' => 1
  3694. )
  3695. );
  3696. } else {
  3697. $nowStaff = $verifyDetail [1] [0];
  3698. $verifyStaff = array (
  3699. $this->staff [0] ['sid'] . "_R" => array (
  3700. 'date' => date ( 'Y-m-d' ),
  3701. 'opinion' => $opinion,
  3702. 'status' => $status,
  3703. 'nextStaff' => $verifyDetail [1] [0]
  3704. )
  3705. );
  3706. }
  3707. } else {
  3708. if ($verifyDetail [1] [1] == 'ROLE') {
  3709. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  3710. // echo "dd";
  3711. foreach ( $vStaffString as $key => $value ) {
  3712. $staffK = explode ( "_", $value );
  3713. array_push ( $nowStaffList, $staffK [0] );
  3714. }
  3715. $nowStaff = implode ( ',', $nowStaffList );
  3716. $verifyStaff = array (
  3717. $this->staff [0] ['sid'] => array (
  3718. 'date' => date ( 'Y-m-d' ),
  3719. 'opinion' => $opinion,
  3720. 'status' => $status,
  3721. 'nextStaff' => $verifyDetail [1] [0],
  3722. 'ROLE' => 1
  3723. )
  3724. );
  3725. } else {
  3726. $nowStaff = $verifyDetail [1] [0];
  3727. $verifyStaff = array (
  3728. $this->staff [0] ['sid'] => array (
  3729. 'date' => date ( 'Y-m-d' ),
  3730. 'opinion' => $opinion,
  3731. 'status' => $status,
  3732. 'nextStaff' => $verifyDetail [1] [0]
  3733. )
  3734. );
  3735. }
  3736. }
  3737. if ($status == 3)
  3738. $verifyStaff = array (
  3739. 'final' => $status,
  3740. $this->staff [0] ['sid'] => array (
  3741. 'date' => date ( 'Y-m-d' ),
  3742. 'opinion' => $opinion,
  3743. 'status' => $status
  3744. )
  3745. );
  3746. $vStaffString = json_encode ( $verifyStaff );
  3747. $receipt->nowStaff = $nowStaff;
  3748. $receipt->verifyStaff = $vStaffString;
  3749. $loanReceipt->nowStaff = $nowStaff;
  3750. $loanReceipt->verifyStaff = $vStaffString;
  3751. } else {
  3752. $VS = end ( $verifyStaff );
  3753. // 非角色审批
  3754. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  3755. $nextStaff = 0;
  3756. $roleSTF = false;
  3757. foreach ( $verifyDetail as $key => $value ) {
  3758. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  3759. if (isset ( $verifyDetail [$key + 1] )) {
  3760. $nextStaff = $verifyDetail [$key + 1] [0];
  3761. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  3762. $roleSTF = true;
  3763. }
  3764. break;
  3765. }
  3766. }
  3767. if (! $roleSTF) {
  3768. $nowStaff = $nextStaff;
  3769. $verifyStaff [$this->staff [0] ['sid']] = array (
  3770. 'date' => date ( 'Y-m-d' ),
  3771. 'opinion' => $opinion,
  3772. 'status' => $status,
  3773. 'nextStaff' => $nextStaff
  3774. );
  3775. } else {
  3776. // 获取角色下的所有用户ID
  3777. $nowStaffList = array ();
  3778. foreach ( $verifyDetail as $vfk ) {
  3779. if ($vfk [1] == 'ROLE') {
  3780. $vStaffString = json_decode ( $vfk [3] );
  3781. foreach ( $vStaffString as $key => $value ) {
  3782. $staffK = explode ( "_", $value );
  3783. array_push ( $nowStaffList, $staffK [0] );
  3784. }
  3785. }
  3786. }
  3787. $nowStaff = implode ( ',', $nowStaffList );
  3788. $verifyStaff [$this->staff [0] ['sid']] = array (
  3789. 'date' => date ( 'Y-m-d' ),
  3790. 'opinion' => $opinion,
  3791. 'status' => $status,
  3792. 'nextStaff' => $nextStaff,
  3793. 'ROLE' => 0
  3794. );
  3795. }
  3796. if ($status == 3) {
  3797. $verifyStaff ['final'] = $status;
  3798. $verifyStaff [$this->staff [0] ['sid']] = array (
  3799. 'date' => date ( 'Y-m-d' ),
  3800. 'opinion' => $opinion,
  3801. 'status' => $status
  3802. );
  3803. }
  3804. $vStaffString = json_encode ( $verifyStaff );
  3805. $receipt->nowStaff = $nowStaff;
  3806. $receipt->verifyStaff = $vStaffString;
  3807. $loanReceipt->nowStaff = $nowStaff;
  3808. $loanReceipt->verifyStaff = $vStaffString;
  3809. }
  3810. // 角色审批
  3811. if (isset ( $VS ['ROLE'] )) {
  3812. // 找出角色人 当前审批角色组
  3813. $verifyJSStaff = array ();
  3814. $nowStaffList2 = array ();
  3815. foreach ( $verifyDetail as $key => $value ) {
  3816. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  3817. $verifyJSStaff = json_decode ( $value [3] );
  3818. foreach ( $verifyJSStaff as $m ) {
  3819. $staffK = explode ( "_", $m );
  3820. array_push ( $nowStaffList2, $staffK [0] );
  3821. }
  3822. // print_r($nowStaffList2);
  3823. }
  3824. }
  3825. $RoleVerifyStaff = array ();
  3826. foreach ( $verifyStaff as $key => $value ) {
  3827. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  3828. foreach ( $nowStaffList2 as $m ) {
  3829. if ($key == $m . "_R")
  3830. $RoleVerifyStaff [$key] = $value;
  3831. }
  3832. }
  3833. }
  3834. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  3835. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  3836. // 下一个审批人ID
  3837. $nextStaff = 0;
  3838. $falg = false;
  3839. foreach ( $verifyDetail as $key => $value ) {
  3840. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  3841. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  3842. $falg = true;
  3843. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  3844. $nowStaffList = array ();
  3845. foreach ( $vStaffString as $v ) {
  3846. $staffK = explode ( "_", $v );
  3847. array_push ( $nowStaffList, $staffK [0] );
  3848. }
  3849. $nowStaff = implode ( ',', $nowStaffList );
  3850. $nextStaff = $verifyDetail [$key + 1] [0];
  3851. } elseif (isset ( $verifyDetail [$key + 1] )) {
  3852. $nextStaff = $verifyDetail [$key + 1] [0];
  3853. $nowStaff = $nextStaff;
  3854. } else
  3855. $nowStaff = '';
  3856. break;
  3857. }
  3858. }
  3859. if ($falg)
  3860. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3861. 'date' => date ( 'Y-m-d' ),
  3862. 'opinion' => $opinion,
  3863. 'status' => $status,
  3864. 'nextStaff' => $nextStaff,
  3865. 'ROLE' => 1
  3866. );
  3867. else
  3868. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3869. 'date' => date ( 'Y-m-d' ),
  3870. 'opinion' => $opinion,
  3871. 'status' => $status,
  3872. 'nextStaff' => $nextStaff
  3873. );
  3874. // print_r($verifyStaff);
  3875. // echo $nowStaff;die;
  3876. } else { // 进入下一个角色或者审批人
  3877. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  3878. //
  3879. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  3880. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3881. 'date' => date ( 'Y-m-d' ),
  3882. 'opinion' => $opinion,
  3883. 'status' => $status,
  3884. 'nextStaff' => $VS ['nextStaff'],
  3885. 'ROLE' => 1
  3886. );
  3887. // print_r($verifyStaff);
  3888. // die;
  3889. }
  3890. if ($status == 3) {
  3891. $verifyStaff ['final'] = $status;
  3892. $verifyStaff [$this->staff [0] ['sid']] = array (
  3893. 'date' => date ( 'Y-m-d' ),
  3894. 'opinion' => $opinion,
  3895. 'status' => $status
  3896. );
  3897. }
  3898. $vStaffString = json_encode ( $verifyStaff );
  3899. $receipt->verifyStaff = $vStaffString;
  3900. $receipt->nowStaff = $nowStaff;
  3901. $loanReceipt->nowStaff = $nowStaff;
  3902. $loanReceipt->verifyStaff = $vStaffString;
  3903. // die;
  3904. // }
  3905. // print_r($verifyStaff);
  3906. // die;
  3907. }
  3908. // print_r($verifyStaff);die;
  3909. }
  3910. // print_r($verifyDetail);
  3911. $roleKey = 0;
  3912. $roleId = 0;
  3913. $verifyDetailCopy = array ();
  3914. foreach ( $verifyDetail as $k => $v ) {
  3915. if ($v [1] == 'ROLE') {
  3916. $roleId = $v [0];
  3917. $roleVerify = json_decode ( $v [3], true );
  3918. $roleKey = $k;
  3919. $roleArray = array ();
  3920. foreach ( $roleVerify as $o => $p ) {
  3921. $staffID = explode ( '_', $p );
  3922. $exp = array (
  3923. 0 => $staffID [0],
  3924. 1 => $staffID [1]
  3925. );
  3926. array_push ( $roleArray, $exp );
  3927. }
  3928. $verifyDetailCopy [$v [0]] = $roleArray;
  3929. }
  3930. }
  3931. // print_r($verifyDetail);
  3932. foreach ( $verifyDetailCopy as $k => $v ) {
  3933. foreach ( $verifyDetail as $m => $n ) {
  3934. if ($n [0] == $k) {
  3935. array_splice ( $verifyDetail, $m, 1, $v );
  3936. }
  3937. }
  3938. }
  3939. // 审批日志
  3940. if (! isset ( $verifyStaff ['final'] )) {
  3941. Doo::loadModel ( "receiptLog" );
  3942. $receiptLog = new receiptLog ();
  3943. if (! empty ( $roleId )) {
  3944. Doo::loadModel ( "role" );
  3945. $role = new role ();
  3946. $roleInfo = $role->getOne ( array (
  3947. 'where' => 'rid=' . $roleId,
  3948. 'asArray' => true
  3949. ) );
  3950. $receiptLog->rolename = $roleInfo ['name'];
  3951. }
  3952. $receiptLog->username = $this->staff [0] ['username'];
  3953. $receiptLog->uid = $this->staff [0] ['sid'];
  3954. $receiptLog->date = date ( "Y-m-d" );
  3955. $receiptLog->opinion = $opinion;
  3956. $receiptLog->img = $this->staff [0] ['avatar'];
  3957. $receiptLog->status = 1;
  3958. $receiptLog->rid = $rid;
  3959. $receiptLog->insert ();
  3960. }
  3961. if (isset ( $verifyStaff ['final'] )) { // rDetail
  3962. $receipt->status = 3;
  3963. $receipt->verifyBreakup = $verifyString;
  3964. $receiptDetailObj->status = 3;
  3965. $receiptDetailObj->update ( array (
  3966. 'where' => 'rid=' . $rid
  3967. ) );
  3968. // 微信企业号通知
  3969. $this->setWXMsg ( $rid, 3 );
  3970. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  3971. $receipt->status = 6;
  3972. $receipt->pastDate = date ( "Y-m-d" );
  3973. $receipt->isBK = 1;
  3974. $loanReceipt->verifyBreakup = $verifyString;
  3975. $loanReceipt->status = 1;
  3976. $loanReceipt->pastDate = date ( "Y-m-d" );
  3977. $loanReceipt->amount = $receiptDetail ['amount'];
  3978. $loanReceipt->update ( array (
  3979. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  3980. ) );
  3981. // 微信企业号通知
  3982. $this->setWXMsg ( $rid, 1 );
  3983. }
  3984. $receipt->amount = $amount;
  3985. $receipt->update ( array (
  3986. 'where' => ' rid = ' . $rid
  3987. ) );
  3988. // 进入下一条审批费用新加需求
  3989. $vidList = array ();
  3990. $verifyDetail = $verify->find ( array (
  3991. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  3992. 'asArray' => true
  3993. ) );
  3994. foreach ( $verifyDetail as $key => $value ) {
  3995. array_push ( $vidList, $value ['vid'] );
  3996. }
  3997. $vid = implode ( ",", $vidList );
  3998. if (empty ( $verifyDetail ))
  3999. $vid = 0;
  4000. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  4001. $receipt = new receipt ();
  4002. $rd = $receipt->getOne ( array (
  4003. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  4004. 'asc' => 'rid',
  4005. 'asArray' => true
  4006. ) );
  4007. if (empty ( $rd )) {
  4008. return '/approvalExpenses/pendApproval';
  4009. }
  4010. if ($rd ['Rtype'] == 1) {
  4011. if ($rd ['isBK'] == 1) {
  4012. return '/receiptburEdi/' . $rd ['rid'];
  4013. } else {
  4014. return '/expensesEdi/' . $rd ['rid'];
  4015. }
  4016. } elseif ($rd ['Rtype'] == 2) {
  4017. return '/remitApproval/' . $rd ['rid'];
  4018. } else {
  4019. return '/receiptburEdi/' . $rd ['rid'];
  4020. }
  4021. // return "/approvalExpenses/pendApproval";
  4022. }
  4023. }
  4024. function ajaxExamineExe() {
  4025. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4026. Doo::loadModel ( 'receipt' );
  4027. $receipt = new receipt ();
  4028. Doo::loadClass ( 'XDeode' );
  4029. $XDeode = new XDeode ( 5 );
  4030. if (! empty ( $rid )) {
  4031. $rLRes = $receipt->find ( array (
  4032. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  4033. 'asArray' => true
  4034. ) );
  4035. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  4036. echo json_encode ( array (
  4037. 'status' => 1,
  4038. 'receipt' => $rLRes [0]
  4039. ) );
  4040. die ();
  4041. }
  4042. echo json_encode ( array (
  4043. 'status' => 0,
  4044. 'receipt' => array ()
  4045. ) );
  4046. die ();
  4047. }
  4048. function implement() {
  4049. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4050. Doo::loadClass ( 'XDeode' );
  4051. $XDeode = new XDeode ( 5 );
  4052. Doo::loadModel ( 'receipt' );
  4053. $receipt = new receipt ();
  4054. Doo::loadModel ( 'L_category' );
  4055. $Lcategory = new L_category ();
  4056. Doo::loadModel ( 'verify' );
  4057. $verify = new verify ();
  4058. Doo::loadModel ( 'staff' );
  4059. $staff = new staff ();
  4060. Doo::loadModel ( "execute" );
  4061. $execute = new execute ();
  4062. $rid = $XDeode->decode ( $rid );
  4063. $receiptList = $receipt->find ( array (
  4064. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  4065. 'desc' => 'rid',
  4066. 'asArray' => true
  4067. ) );
  4068. Doo::loadModel ( 'loanReceipt' );
  4069. $loanReceipt = new loanReceipt ();
  4070. // print_r($receiptList);
  4071. $loanList = array ();
  4072. if (! isset ( $receiptList ))
  4073. $loanList = $loanReceipt->find ( array (
  4074. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4075. 'desc' => 'rid',
  4076. 'asArray' => true
  4077. ) );
  4078. $Locate = 0;
  4079. $roleId = 0;
  4080. $button = 0;
  4081. foreach ( $loanList as $key => $value ) {
  4082. $loanList [$key] ['Locate'] = $Locate;
  4083. $Locate ++;
  4084. $loanList [$key] ['reviseDetail'] = array ();
  4085. if (! empty ( $value ['reviseDetail'] ))
  4086. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4087. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4088. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4089. $categoryDetil = $Lcategory->getOne ( array (
  4090. 'where' => 'cid=' . $value ['cid'],
  4091. 'asArray' => true
  4092. ) );
  4093. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4094. // 检测编辑状态
  4095. $verifyList = $verify->getOne ( array (
  4096. 'where' => 'vid=' . $value ['verify'],
  4097. 'asArray' => true
  4098. ) );
  4099. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4100. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4101. Doo::loadModel ( 'role' );
  4102. $role = new role ();
  4103. $flag = true;
  4104. $roleKey = 0;
  4105. $endStaffArray = array ();
  4106. $roleArrayCopy = array ();
  4107. foreach ( $verifyList as $k => $v ) {
  4108. // init verifyStaff
  4109. if ($v [1] == 'ROLE') {
  4110. if (! empty ( $verifyStaff )) {
  4111. $endStaffArray = end ( $verifyStaff );
  4112. // if ($v[0]==$endStaffArray['nextStaff']){
  4113. // $roleId=$v[0];
  4114. // }
  4115. }
  4116. $roleVerify = json_decode ( $v [3], true );
  4117. $roleKey = $k;
  4118. $roleArray = array ();
  4119. $rolename = $role->getOne ( array (
  4120. 'where' => 'rid=' . $v [0],
  4121. 'asArray' => true
  4122. ) );
  4123. foreach ( $roleVerify as $o => $p ) {
  4124. $staffID = explode ( '_', $p );
  4125. $staffInfo = $staff->getOne ( array (
  4126. 'where' => 'sid=' . $staffID [0],
  4127. 'asArray' => true
  4128. ) );
  4129. // print_r($staffID);
  4130. $exp = array (
  4131. 0 => $staffInfo ['sid'],
  4132. 1 => $staffID [1],
  4133. 2 => $staffInfo ['avatar'],
  4134. 'date' => '',
  4135. 'date' => '',
  4136. 'opinion' => '',
  4137. 'status' => '',
  4138. 'rolename' => $rolename ['name']
  4139. );
  4140. array_push ( $roleArray, $exp );
  4141. }
  4142. $roleArrayCopy [$v [0]] = $roleArray;
  4143. // $verifyList[$k]['roleArray']=$roleArray;
  4144. }
  4145. $verifyList [$k] ['date'] = "";
  4146. $verifyList [$k] ['opinion'] = "";
  4147. $verifyList [$k] ['status'] = "";
  4148. if (empty ( $verifyStaff )) {
  4149. $verifyList [$k] ['date'] = "";
  4150. $verifyList [$k] ['opinion'] = "";
  4151. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4152. $verifyList [$k] ['status'] = 4;
  4153. $flag = false;
  4154. }
  4155. } else {
  4156. foreach ( $verifyStaff as $m => $u ) {
  4157. if ($v [0] == $m) {
  4158. $verifyList [$k] ['date'] = $u ['date'];
  4159. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4160. $verifyList [$k] ['status'] = $u ['status'];
  4161. $flag = false;
  4162. break;
  4163. }
  4164. }
  4165. $endStaffArray = end ( $verifyStaff );
  4166. if (isset ( $endStaffArray ['ROLE'] )) {
  4167. } else {
  4168. // $endKey=key($verifyStaff);
  4169. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4170. // $button=4;
  4171. // $verifyList[$k]['status']=4;
  4172. // }
  4173. }
  4174. }
  4175. }
  4176. $rolename ['name'] = '';
  4177. if (! empty ( $roleId )) {
  4178. Doo::loadModel ( 'role' );
  4179. $role = new role ();
  4180. $rolename = $role->getOne ( array (
  4181. 'where' => 'rid=' . $roleId,
  4182. 'asArray' => true
  4183. ) );
  4184. }
  4185. if (! empty ( $verifyStaff ))
  4186. $endStaffArray = end ( $verifyStaff );
  4187. $KOP = false;
  4188. foreach ( $roleArrayCopy as $P => $A ) {
  4189. foreach ( $A as $MKI => $AVL ) {
  4190. if (! empty ( $verifyStaff )) {
  4191. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4192. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4193. $button = 4;
  4194. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4195. }
  4196. foreach ( $verifyStaff as $m => $u ) {
  4197. $AVLFK = $AVL [0] . '_R';
  4198. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4199. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4200. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4201. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4202. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4203. break;
  4204. }
  4205. }
  4206. } else {
  4207. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4208. $button = 4;
  4209. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4210. }
  4211. }
  4212. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4213. $KOP = true;
  4214. }
  4215. }
  4216. foreach ( $roleArrayCopy as $k => $v ) {
  4217. foreach ( $verifyList as $m => $n ) {
  4218. if ($n [0] == $k) {
  4219. array_splice ( $verifyList, $m, 1, $v );
  4220. }
  4221. }
  4222. }
  4223. $loanList [$key] ['verifyList'] = $verifyList;
  4224. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  4225. 'where' => 'sid=' . $value ['staff'],
  4226. 'asArray' => true
  4227. ) );
  4228. }
  4229. $data ['loanList'] = $loanList;
  4230. $Locate = 0;
  4231. $roleId = 0;
  4232. $button = 0;
  4233. foreach ( $receiptList as $key => $value ) {
  4234. $button2 = 0;
  4235. $receiptList [$key] ['Locate'] = $Locate;
  4236. $Locate ++;
  4237. $receiptList [$key] ['reviseDetail'] = array ();
  4238. if (! empty ( $value ['reviseDetail'] ))
  4239. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4240. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4241. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4242. $categoryDetil = $Lcategory->getOne ( array (
  4243. 'where' => 'cid=' . $value ['cid'],
  4244. 'asArray' => true
  4245. ) );
  4246. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4247. $executeList = json_decode ( $value ['executeCopy'], true );
  4248. $executeStaff = array ();
  4249. if (! empty ( $value ['executeStaff'] ))
  4250. $executeStaff = json_decode ( $value ['executeStaff'], true );
  4251. if (isset ( $executeList )) {
  4252. foreach ( $executeList as $op => $lo ) {
  4253. $executeList [$op] ['date'] = "";
  4254. $executeList [$op] ['opinion'] = "";
  4255. $executeList [$op] ['status'] = "";
  4256. foreach ( $executeStaff as $m => $u ) {
  4257. if ($lo [0] == $m) {
  4258. $executeList [$op] ['date'] = $u ['date'];
  4259. $executeList [$op] ['opinion'] = $u ['opinion'];
  4260. $executeList [$op] ['status'] = $u ['status'];
  4261. break;
  4262. }
  4263. }
  4264. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  4265. $button2 = 1;
  4266. $executeList [$op] ['status'] = 4;
  4267. }
  4268. }
  4269. }
  4270. // 检测编辑状态
  4271. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  4272. $verifyList ['staff'] = $value ['verifyBreakup'];
  4273. } else
  4274. $verifyList = $verify->getOne ( array (
  4275. 'where' => 'vid=' . $value ['verify'],
  4276. 'asArray' => true
  4277. ) );
  4278. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4279. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4280. Doo::loadModel ( 'role' );
  4281. $role = new role ();
  4282. if ($verifyList == NULL)
  4283. $verifyList = array ();
  4284. $flag = true;
  4285. $roleKey = 0;
  4286. $endStaffArray = array ();
  4287. $roleArrayCopy = array ();
  4288. foreach ( $verifyList as $k => $v ) {
  4289. // init verifyStaff
  4290. if ($v [1] == 'ROLE') {
  4291. if (! empty ( $verifyStaff )) {
  4292. $endStaffArray = end ( $verifyStaff );
  4293. // if ($v[0]==$endStaffArray['nextStaff']){
  4294. // $roleId=$v[0];
  4295. // }
  4296. }
  4297. $roleVerify = json_decode ( $v [3], true );
  4298. $roleKey = $k;
  4299. $roleArray = array ();
  4300. $rolename = $role->getOne ( array (
  4301. 'where' => 'rid=' . $v [0],
  4302. 'asArray' => true
  4303. ) );
  4304. foreach ( $roleVerify as $o => $p ) {
  4305. $staffID = explode ( '_', $p );
  4306. $staffInfo = $staff->getOne ( array (
  4307. 'where' => 'sid=' . $staffID [0],
  4308. 'asArray' => true
  4309. ) );
  4310. // print_r($staffID);
  4311. $exp = array (
  4312. 0 => $staffInfo ['sid'],
  4313. 1 => $staffID [1],
  4314. 2 => $staffInfo ['avatar'],
  4315. 'date' => '',
  4316. 'date' => '',
  4317. 'opinion' => '',
  4318. 'status' => '',
  4319. 'rolename' => $rolename ['name']
  4320. );
  4321. array_push ( $roleArray, $exp );
  4322. }
  4323. $roleArrayCopy [$v [0]] = $roleArray;
  4324. // $verifyList[$k]['roleArray']=$roleArray;
  4325. }
  4326. $verifyList [$k] ['date'] = "";
  4327. $verifyList [$k] ['opinion'] = "";
  4328. $verifyList [$k] ['status'] = "";
  4329. if (empty ( $verifyStaff )) {
  4330. $verifyList [$k] ['date'] = "";
  4331. $verifyList [$k] ['opinion'] = "";
  4332. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4333. $verifyList [$k] ['status'] = 4;
  4334. $flag = false;
  4335. }
  4336. } else {
  4337. foreach ( $verifyStaff as $m => $u ) {
  4338. if ($v [0] == $m) {
  4339. $verifyList [$k] ['date'] = $u ['date'];
  4340. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4341. $verifyList [$k] ['status'] = $u ['status'];
  4342. $flag = false;
  4343. break;
  4344. }
  4345. }
  4346. $endStaffArray = end ( $verifyStaff );
  4347. if (isset ( $endStaffArray ['ROLE'] )) {
  4348. } else {
  4349. // $endKey=key($verifyStaff);
  4350. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4351. // $button=4;
  4352. // $verifyList[$k]['status']=4;
  4353. // }
  4354. }
  4355. }
  4356. }
  4357. $rolename ['name'] = '';
  4358. if (! empty ( $roleId )) {
  4359. Doo::loadModel ( 'role' );
  4360. $role = new role ();
  4361. $rolename = $role->getOne ( array (
  4362. 'where' => 'rid=' . $roleId,
  4363. 'asArray' => true
  4364. ) );
  4365. }
  4366. if (! empty ( $verifyStaff ))
  4367. $endStaffArray = end ( $verifyStaff );
  4368. $KOP = false;
  4369. foreach ( $roleArrayCopy as $P => $A ) {
  4370. foreach ( $A as $MKI => $AVL ) {
  4371. if (! empty ( $verifyStaff )) {
  4372. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4373. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4374. $button = 4;
  4375. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4376. }
  4377. foreach ( $verifyStaff as $m => $u ) {
  4378. $AVLFK = $AVL [0] . '_R';
  4379. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4380. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4381. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4382. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4383. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4384. break;
  4385. }
  4386. }
  4387. } else {
  4388. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4389. $button = 4;
  4390. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4391. }
  4392. }
  4393. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4394. $KOP = true;
  4395. }
  4396. }
  4397. foreach ( $roleArrayCopy as $k => $v ) {
  4398. foreach ( $verifyList as $m => $n ) {
  4399. if ($n [0] == $k) {
  4400. array_splice ( $verifyList, $m, 1, $v );
  4401. }
  4402. }
  4403. }
  4404. $receiptList [$key] ['verifyList'] = $verifyList;
  4405. $receiptList [$key] ['executeList'] = $executeList;
  4406. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4407. 'where' => 'sid=' . $value ['staff'],
  4408. 'asArray' => true
  4409. ) );
  4410. $receiptList [$key] ['button2'] = $button2;
  4411. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4412. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4413. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  4414. $receiptList [$key] ['relust'] = $relust;
  4415. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  4416. }
  4417. // print_r($receiptList[$key]['executeList']);
  4418. $data ['receiptList'] = $receiptList;
  4419. $data ['memu'] = "receipt";
  4420. $data ['staff'] = $this->staff;
  4421. $data ['receiptMemu'] = 'implement';
  4422. $data ['verifyId'] = $this->verifyId;
  4423. $data ['executeId'] = $this->executeId;
  4424. $this->render ( "/admin/implement", $data );
  4425. }
  4426. function implementDo() {
  4427. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4428. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  4429. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  4430. $accountBank = $this->get_args ( 'accountBank' ) ? $this->get_args ( 'accountBank' ) : "";
  4431. $ab = '';
  4432. if ($accountBank == 'CGBDeposit')
  4433. $ab = '纵横广发';
  4434. elseif ($accountBank == 'ICBCDeposit')
  4435. $ab = '纵横工行';
  4436. elseif ($accountBank == 'HUADeposit')
  4437. $ab = '华润银行';
  4438. elseif ($accountBank == 'PersonalDeposit')
  4439. $ab = '个人广发';
  4440. if (empty ( $ab ))
  4441. die ( 'illegal request' );
  4442. if (! empty ( $rid ) && $amount != '') {
  4443. Doo::loadModel ( 'receipt' );
  4444. $receipt = new receipt ();
  4445. Doo::loadClass ( 'XDeode' );
  4446. $XDeode = new XDeode ( 5 );
  4447. // $rinfo = $receipt->getOne ( array (
  4448. // 'where' => 'rid=' . $rid,
  4449. // 'asArray' => true
  4450. // ) );
  4451. $rinfo = $receipt->getReceiptByRid ( $rid );
  4452. $accountType = '';
  4453. if ($rinfo ['Rtype'] == 1) {
  4454. if ($rinfo ['loanRid'] != 0)
  4455. $accountType = 2;
  4456. else
  4457. $accountType = 1;
  4458. } elseif ($rinfo ['Rtype'] == 2) {
  4459. $accountType = 4;
  4460. } elseif ($rinfo ['Rtype'] == 0)
  4461. $accountType = 3;
  4462. if (empty ( $accountType ))
  4463. die ( 'illegal request' );
  4464. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  4465. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  4466. if (empty ( $executeStaff )) {
  4467. $executeStaff = array (
  4468. $this->staff [0] ['sid'] => array (
  4469. 'date' => date ( 'Y-m-d' ),
  4470. 'opinion' => $implementOpinions,
  4471. 'status' => 1
  4472. )
  4473. );
  4474. } else {
  4475. $executeStaff [$this->staff [0] ['sid']] = array (
  4476. 'date' => date ( 'Y-m-d' ),
  4477. 'opinion' => $implementOpinions,
  4478. 'status' => 1
  4479. );
  4480. }
  4481. if (count ( $executeStaff ) == count ( $executeCopy )) {
  4482. $receipt->executeStaff = json_encode ( $executeStaff );
  4483. $receipt->status = 8;
  4484. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  4485. $receipt->status = 9;
  4486. if ($rinfo ['status'] == 6) {
  4487. $receipt->loanDate = date ( "Y-m-d" );
  4488. }
  4489. $receipt->executeDate = date ( "Y-m-d" );
  4490. } else {
  4491. $receipt->executeStaff = json_encode ( $executeStaff );
  4492. }
  4493. $receipt->amount = $amount;
  4494. $receipt->update ( array (
  4495. 'where' => 'rid=' . $rid
  4496. ) );
  4497. // 公司流水记录
  4498. Doo::loadModel ( 'wasteBook' );
  4499. $wasteBook = new wasteBook ();
  4500. $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountType, $rid );
  4501. // 银行
  4502. if (empty ( $abDetail ) && ! empty ( $amount )) {
  4503. $item = array (
  4504. 'dataID' => $rid,
  4505. 'expensesType' => 2,
  4506. 'accountType' => $accountType,
  4507. 'accountPriceShow' => $amount,
  4508. 'accountPrice' => - $amount,
  4509. 'accountBank' => $accountBank,
  4510. 'category' => $rinfo ['category'] [0] ['title'],
  4511. 'cid' => $rinfo ['category'] [0] ['cid'],
  4512. 'name' => $rinfo ['staffDetail'] ['username'],
  4513. 'sid' => $rinfo ['staffDetail'] ['sid'],
  4514. 'inputDate' => date ( "Y-m-d H:i:s" )
  4515. );
  4516. $wasteBook->setAccountBookStatistics ( $item );
  4517. }
  4518. }
  4519. $ridKey = $XDeode->encode ( $rid );
  4520. return "/hisImplement";
  4521. // return "/implement/" . $ridKey . ".html";
  4522. }
  4523. function receiptburEdi() {
  4524. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4525. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  4526. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4527. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4528. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4529. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4530. if (empty ( $status ))
  4531. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  4532. $vidList = array ();
  4533. $button = 0;
  4534. Doo::loadModel ( 'verify' );
  4535. Doo::loadModel ( 'receipt' );
  4536. Doo::loadModel ( 'staff' );
  4537. $staff = new staff ();
  4538. $receipt = new receipt ();
  4539. $verify = new verify ();
  4540. Doo::loadModel ( 'L_category' );
  4541. $Lcategory = new L_category ();
  4542. Doo::loadModel ( 'enclosur' );
  4543. $enclosur = new enclosur ();
  4544. Doo::loadModel ( 'loanReceipt' );
  4545. $loanReceipt = new loanReceipt ();
  4546. // user verify ID
  4547. $verifyDetail = $verify->find ( array (
  4548. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  4549. 'asArray' => true
  4550. ) );
  4551. foreach ( $verifyDetail as $key => $value ) {
  4552. array_push ( $vidList, $value ['vid'] );
  4553. }
  4554. $vid = implode ( ",", $vidList );
  4555. if (empty ( $verifyDetail ))
  4556. $vid = 0;
  4557. $categoryList = $Lcategory->find ( array (
  4558. 'asArray' => true
  4559. ) );
  4560. $staffList = $staff->find ( array (
  4561. 'where' => 'cid=' . $cid,
  4562. 'asArray' => true
  4563. ) );
  4564. $ap = "";
  4565. if ($status == 4) {
  4566. $ap = 4;
  4567. $status = 2;
  4568. }
  4569. // get Receipt By verifyID status 2
  4570. $receiptList = $receipt->find ( array (
  4571. 'where' => 'rid =' . $rid . ' and status=2',
  4572. 'desc' => 'rid',
  4573. 'asArray' => true
  4574. ) );
  4575. if (empty ( $receiptList )) {
  4576. die ( 'illegal request' );
  4577. }
  4578. $loanList = $loanReceipt->find ( array (
  4579. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4580. 'desc' => 'rid',
  4581. 'asArray' => true
  4582. ) );
  4583. $data ['explanation'] = '';
  4584. if (! empty ( $loanList ))
  4585. $data ['explanation'] = $loanList [0] ['explanation'];
  4586. $Locate = 0;
  4587. $roleId = 0;
  4588. $button = 0;
  4589. foreach ( $loanList as $key => $value ) {
  4590. $loanList [$key] ['Locate'] = $Locate;
  4591. $Locate ++;
  4592. $loanList [$key] ['reviseDetail'] = array ();
  4593. if (! empty ( $value ['reviseDetail'] ))
  4594. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4595. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4596. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4597. $categoryDetil = $Lcategory->getOne ( array (
  4598. 'where' => 'cid=' . $value ['cid'],
  4599. 'asArray' => true
  4600. ) );
  4601. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4602. // 检测编辑状态
  4603. $verifyList = $verify->getOne ( array (
  4604. 'where' => 'vid=' . $value ['verify'],
  4605. 'asArray' => true
  4606. ) );
  4607. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4608. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4609. Doo::loadModel ( 'role' );
  4610. $role = new role ();
  4611. $flag = true;
  4612. $roleKey = 0;
  4613. $endStaffArray = array ();
  4614. $roleArrayCopy = array ();
  4615. foreach ( $verifyList as $k => $v ) {
  4616. // init verifyStaff
  4617. if ($v [1] == 'ROLE') {
  4618. if (! empty ( $verifyStaff )) {
  4619. $endStaffArray = end ( $verifyStaff );
  4620. }
  4621. $roleVerify = json_decode ( $v [3], true );
  4622. $roleKey = $k;
  4623. $roleArray = array ();
  4624. $rolename = $role->getOne ( array (
  4625. 'where' => 'rid=' . $v [0],
  4626. 'asArray' => true
  4627. ) );
  4628. foreach ( $roleVerify as $o => $p ) {
  4629. $staffID = explode ( '_', $p );
  4630. $staffInfo = $staff->getOne ( array (
  4631. 'where' => 'sid=' . $staffID [0],
  4632. 'asArray' => true
  4633. ) );
  4634. // print_r($staffID);
  4635. $exp = array (
  4636. 0 => $staffInfo ['sid'],
  4637. 1 => $staffID [1],
  4638. 2 => $staffInfo ['avatar'],
  4639. 'date' => '',
  4640. 'date' => '',
  4641. 'opinion' => '',
  4642. 'status' => '',
  4643. 'rolename' => $rolename ['name']
  4644. );
  4645. array_push ( $roleArray, $exp );
  4646. }
  4647. $roleArrayCopy [$v [0]] = $roleArray;
  4648. // $verifyList[$k]['roleArray']=$roleArray;
  4649. }
  4650. $verifyList [$k] ['date'] = "";
  4651. $verifyList [$k] ['opinion'] = "";
  4652. $verifyList [$k] ['status'] = "";
  4653. if (empty ( $verifyStaff )) {
  4654. $verifyList [$k] ['date'] = "";
  4655. $verifyList [$k] ['opinion'] = "";
  4656. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4657. $verifyList [$k] ['status'] = 4;
  4658. $flag = false;
  4659. }
  4660. } else {
  4661. foreach ( $verifyStaff as $m => $u ) {
  4662. if ($v [0] == $m) {
  4663. $verifyList [$k] ['date'] = $u ['date'];
  4664. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4665. $verifyList [$k] ['status'] = $u ['status'];
  4666. $flag = false;
  4667. break;
  4668. }
  4669. }
  4670. $endStaffArray = end ( $verifyStaff );
  4671. if (isset ( $endStaffArray ['ROLE'] )) {
  4672. } else {
  4673. }
  4674. }
  4675. }
  4676. $rolename ['name'] = '';
  4677. if (! empty ( $roleId )) {
  4678. Doo::loadModel ( 'role' );
  4679. $role = new role ();
  4680. $rolename = $role->getOne ( array (
  4681. 'where' => 'rid=' . $roleId,
  4682. 'asArray' => true
  4683. ) );
  4684. }
  4685. if (! empty ( $verifyStaff ))
  4686. $endStaffArray = end ( $verifyStaff );
  4687. $KOP = false;
  4688. foreach ( $roleArrayCopy as $P => $A ) {
  4689. foreach ( $A as $MKI => $AVL ) {
  4690. if (! empty ( $verifyStaff )) {
  4691. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4692. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4693. $button = 4;
  4694. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4695. }
  4696. foreach ( $verifyStaff as $m => $u ) {
  4697. $AVLFK = $AVL [0] . '_R';
  4698. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4699. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4700. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4701. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4702. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4703. break;
  4704. }
  4705. }
  4706. } else {
  4707. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4708. $button = 4;
  4709. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4710. }
  4711. }
  4712. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4713. $KOP = true;
  4714. }
  4715. }
  4716. foreach ( $roleArrayCopy as $k => $v ) {
  4717. foreach ( $verifyList as $m => $n ) {
  4718. if ($n [0] == $k) {
  4719. array_splice ( $verifyList, $m, 1, $v );
  4720. }
  4721. }
  4722. }
  4723. $loanList [$key] ['verifyList'] = $verifyList;
  4724. }
  4725. $htmlLoan = '';
  4726. $data ['loanReceiptDate'] = '';
  4727. if (isset ( $loanList [0] )) {
  4728. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  4729. if ($value ['status'] == 1)
  4730. $htmlLoan .= '<li class="done" >';
  4731. elseif ($value ['status'] == 3)
  4732. $htmlLoan .= '<li class="undone" >';
  4733. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  4734. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  4735. if (isset ( $value ['rolename'] ))
  4736. $htmlLoan .= $value ['rolename'];
  4737. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  4738. }
  4739. $data ['loanDate'] = $loanList [0] ['date'];
  4740. } else {
  4741. $data ['loanReceiptDate'] = ''; // $loanList [0] ['date'];
  4742. }
  4743. $data ['htmlLoan'] = $htmlLoan;
  4744. // $data ['LoanReceipt']=$loanList[0];
  4745. // print_r($loanList);
  4746. $Locate = 0;
  4747. $roleId = 0;
  4748. $button = 0;
  4749. if ($ap == 4)
  4750. $status = 4;
  4751. Doo::loadClass ( 'XDeode' );
  4752. $XDeode = new XDeode ( 5 );
  4753. foreach ( $receiptList as $key => $value ) {
  4754. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4755. $receiptList [$key] ['Locate'] = $Locate;
  4756. $Locate ++;
  4757. $receiptList [$key] ['reviseDetail'] = array ();
  4758. // 调整金额 代码调整
  4759. if (! empty ( $value ['reviseDetail'] )) {
  4760. $reviseDetail = json_decode ( $value ['reviseDetail'], true );
  4761. foreach ( $reviseDetail as $ry => $re ) {
  4762. $reviseDetail [$ry] ['sidKey'] = $XDeode->encode ( $re ['sid'] );
  4763. $reviseDetail [$ry] ['reviseKey'] = $XDeode->encode ( $ry );
  4764. }
  4765. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  4766. // print_r($reviseDetail);
  4767. }
  4768. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4769. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4770. $categoryDetil = $Lcategory->getOne ( array (
  4771. 'where' => 'cid=' . $value ['cid'],
  4772. 'asArray' => true
  4773. ) );
  4774. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4775. // 检测编辑状态
  4776. $verifyList = $verify->getOne ( array (
  4777. 'where' => 'vid=' . $value ['verify'],
  4778. 'asArray' => true
  4779. ) );
  4780. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4781. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4782. Doo::loadModel ( 'role' );
  4783. $role = new role ();
  4784. // print_r($verifyList);
  4785. $flag = true;
  4786. $roleKey = 0;
  4787. $endStaffArray = array ();
  4788. $roleArrayCopy = array ();
  4789. foreach ( $verifyList as $k => $v ) {
  4790. // init verifyStaff
  4791. if ($v [1] == 'ROLE') {
  4792. if (! empty ( $verifyStaff )) {
  4793. $endStaffArray = end ( $verifyStaff );
  4794. if ($v [0] == $endStaffArray ['nextStaff']) {
  4795. $roleId = $v [0];
  4796. }
  4797. }
  4798. $roleVerify = json_decode ( $v [3], true );
  4799. $roleKey = $k;
  4800. $roleArray = array ();
  4801. $rolename = $role->getOne ( array (
  4802. 'where' => 'rid=' . $v [0],
  4803. 'asArray' => true
  4804. ) );
  4805. foreach ( $roleVerify as $o => $p ) {
  4806. $staffID = explode ( '_', $p );
  4807. $staffInfo = $staff->getOne ( array (
  4808. 'where' => 'sid=' . $staffID [0],
  4809. 'asArray' => true
  4810. ) );
  4811. // print_r($staffID);
  4812. $exp = array (
  4813. 0 => $staffInfo ['sid'],
  4814. 1 => $staffID [1],
  4815. 2 => $staffInfo ['avatar'],
  4816. 'date' => '',
  4817. 'date' => '',
  4818. 'opinion' => '',
  4819. 'status' => '',
  4820. 'rolename' => $rolename ['name']
  4821. );
  4822. array_push ( $roleArray, $exp );
  4823. }
  4824. $roleArrayCopy [$v [0]] = $roleArray;
  4825. // $verifyList[$k]['roleArray']=$roleArray;
  4826. }
  4827. // print_r($roleArray);
  4828. $verifyList [$k] ['date'] = "";
  4829. $verifyList [$k] ['opinion'] = "";
  4830. $verifyList [$k] ['status'] = "";
  4831. if (empty ( $verifyStaff )) {
  4832. $verifyList [$k] ['date'] = "";
  4833. $verifyList [$k] ['opinion'] = "";
  4834. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4835. $verifyList [$k] ['status'] = 4;
  4836. $button = 4;
  4837. $flag = false;
  4838. }
  4839. } else {
  4840. foreach ( $verifyStaff as $m => $u ) {
  4841. if ($v [0] == $m) {
  4842. $verifyList [$k] ['date'] = $u ['date'];
  4843. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4844. $verifyList [$k] ['status'] = $u ['status'];
  4845. $flag = false;
  4846. break;
  4847. }
  4848. }
  4849. $endStaffArray = end ( $verifyStaff );
  4850. if (isset ( $endStaffArray ['ROLE'] )) {
  4851. } else {
  4852. $endKey = key ( $verifyStaff );
  4853. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4854. $button = 4;
  4855. $verifyList [$k] ['status'] = 4;
  4856. }
  4857. }
  4858. }
  4859. }
  4860. $rolename ['name'] = '';
  4861. if (! empty ( $roleId )) {
  4862. Doo::loadModel ( 'role' );
  4863. $role = new role ();
  4864. $rolename = $role->getOne ( array (
  4865. 'where' => 'rid=' . $roleId,
  4866. 'asArray' => true
  4867. ) );
  4868. }
  4869. if (! empty ( $verifyStaff ))
  4870. $endStaffArray = end ( $verifyStaff );
  4871. $KOP = false;
  4872. foreach ( $roleArrayCopy as $P => $A ) {
  4873. foreach ( $A as $MKI => $AVL ) {
  4874. if (! empty ( $verifyStaff )) {
  4875. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4876. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4877. $button = 4;
  4878. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4879. }
  4880. foreach ( $verifyStaff as $m => $u ) {
  4881. $AVLFK = $AVL [0] . '_R';
  4882. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4883. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4884. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4885. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4886. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4887. break;
  4888. }
  4889. }
  4890. } else {
  4891. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4892. $button = 4;
  4893. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4894. }
  4895. }
  4896. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4897. $KOP = true;
  4898. }
  4899. }
  4900. foreach ( $roleArrayCopy as $k => $v ) {
  4901. foreach ( $verifyList as $m => $n ) {
  4902. if ($n [0] == $k) {
  4903. array_splice ( $verifyList, $m, 1, $v );
  4904. }
  4905. }
  4906. }
  4907. // print_r($verifyList);
  4908. $receiptList [$key] ['verifyList'] = $verifyList;
  4909. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4910. 'where' => 'sid=' . $value ['staff'],
  4911. 'asArray' => true
  4912. ) );
  4913. $receiptList [$key] ['button'] = $button;
  4914. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4915. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4916. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  4917. $receiptList [$key] ['relust'] = $relust;
  4918. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4919. }
  4920. // print_r($receiptList);die;
  4921. // $data['verifyDetail']=$verifyDetail;
  4922. $mothHtml = "";
  4923. for($i = 1; $i <= 12; $i ++) {
  4924. if ($month == $i)
  4925. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4926. else
  4927. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4928. }
  4929. // 获取审批日志
  4930. Doo::loadModel ( 'receiptLog' );
  4931. $receiptLog = new receiptLog ();
  4932. $rlList = array ();
  4933. $rlInfo = $receiptLog->getOne ( array (
  4934. 'where' => 'rid=' . $rid . ' and status=4',
  4935. 'asArray' => true
  4936. ) );
  4937. $tijdate = $receiptLog->getOne ( array (
  4938. 'where' => 'rid=' . $rid . ' and status=2',
  4939. 'asc' => 'rlid',
  4940. 'asArray' => true
  4941. ) );
  4942. if (! empty ( $rlInfo )) {
  4943. $rlList = $receiptLog->find ( array (
  4944. 'where' => 'rid=' . $rid,
  4945. 'asc' => 'rlid',
  4946. 'asArray' => true
  4947. ) );
  4948. }
  4949. // echo $rid;
  4950. // print_r($receiptList);
  4951. $receiptList [0] ['rlList'] = $rlList;
  4952. // print_r($receiptList);
  4953. $enclosurList = $enclosur->find ( array (
  4954. 'where' => 'rid=' . $rid,
  4955. 'asArray' => true
  4956. ) );
  4957. $enclosurHtml = '';
  4958. foreach ( $enclosurList as $value ) {
  4959. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4960. }
  4961. $data ['enclosurHtml'] = $enclosurHtml;
  4962. $data ['rolename'] = $rolename ['name'];
  4963. $data ['mothHtml'] = $mothHtml;
  4964. // print_r($receiptList);
  4965. $data ['rid'] = $rid;
  4966. $data ['tijdate'] = $tijdate ['date'];
  4967. $data ['receiptList'] = $receiptList;
  4968. $data ['receiptApprovalCount'] = count ( $receiptList );
  4969. $data ['status'] = $status;
  4970. $data ['year'] = $year;
  4971. $data ['categoryList'] = $categoryList;
  4972. $data ['staffList'] = $staffList;
  4973. $data ['cid'] = $cid;
  4974. $data ['sid'] = $sid;
  4975. $data ['ap'] = $ap;
  4976. $data ['memu'] = "receipt";
  4977. $data ['staff'] = $this->staff;
  4978. $data ['receiptMemu'] = 'approvalExpenses';
  4979. $data ['verifyId'] = $this->verifyId;
  4980. $data ['executeId'] = $this->executeId;
  4981. $this->render ( "/admin/receiptburEdi", $data );
  4982. }
  4983. function hisImplement() {
  4984. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4985. if (empty ( $item ))
  4986. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "expenses";
  4987. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  4988. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4989. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  4990. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  4991. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  4992. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'pendImplement';
  4993. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  4994. Doo::loadClass ( 'XDeode' );
  4995. $XDeode = new XDeode ( 5 );
  4996. Doo::loadModel ( 'receipt' );
  4997. $receipt = new receipt ();
  4998. Doo::loadModel ( 'L_category' );
  4999. $Lcategory = new L_category ();
  5000. Doo::loadModel ( 'verify' );
  5001. Doo::loadModel ( 'statistics' );
  5002. $statistics = new statistics ();
  5003. $verify = new verify ();
  5004. Doo::loadModel ( 'staff' );
  5005. $staff = new staff ();
  5006. Doo::loadClass ( 'XDeode' );
  5007. $XDeode = new XDeode ( 5 );
  5008. $cid = $XDeode->decode ( $cidKey );
  5009. $condition = "";
  5010. if ($item == "expenses")
  5011. $condition = " and Rtype=1 ";
  5012. elseif ($item == "receipts")
  5013. $condition = " and Rtype=0 ";
  5014. elseif ($item == "remits")
  5015. $condition = " and Rtype=2 ";
  5016. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  5017. $sopString = $cidString = "";
  5018. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  5019. if (empty ( $rdate ))
  5020. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  5021. else
  5022. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  5023. if ($status == 'pendImplement') {
  5024. $condition .= ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  5025. } elseif ($status == 'alerpts') {
  5026. $statusCon = '(status=8 or status=9 )';
  5027. if (empty ( $rdate ))
  5028. $dateCondition .= " and Year(date) =" . $year;
  5029. else
  5030. $dateCondition .= " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  5031. }
  5032. if ($sop != 'SOP')
  5033. $sopString = " and staff=" . $sop;
  5034. if ($cidKey != 'ALL')
  5035. $cidString = " and cid=" . $cid;
  5036. $receiptList = $receipt->find ( array (
  5037. 'where' => $statusCon . $condition . $dateCondition . $sopString . $cidString,
  5038. 'desc' => 'rid',
  5039. 'asArray' => true
  5040. ) );
  5041. // 员工筛选
  5042. $receiptList2 = $receipt->find ( array (
  5043. 'where' => $statusCon . $condition . $dateCondition,
  5044. 'desc' => 'rid',
  5045. 'asArray' => true
  5046. ) );
  5047. $sopStaff = array ();
  5048. foreach ( $receiptList2 as $key => $value ) {
  5049. $staffDetail = $staff->getOne ( array (
  5050. 'select' => 'username',
  5051. 'where' => 'sid=' . $value ['staff'],
  5052. 'asArray' => true
  5053. ) );
  5054. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  5055. }
  5056. // 办事处筛选
  5057. $categoryScreen = array ();
  5058. $categorList = $Lcategory->getCategory ();
  5059. foreach ( $receiptList2 as $key => $value ) {
  5060. foreach ( $categorList as $k => $v ) {
  5061. if ($value ['cid'] == $v ['cid']) {
  5062. $categoryScreen [$v ['cidKey']] = $v ['title'];
  5063. break;
  5064. }
  5065. }
  5066. }
  5067. $categoryScreenHtml = "";
  5068. foreach ( $categoryScreen as $key => $value ) {
  5069. if ($cidKey == $key)
  5070. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  5071. else
  5072. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  5073. }
  5074. $data ['categoryScreenHtml'] = $categoryScreenHtml;
  5075. $data ['cidKey'] = $cidKey;
  5076. $Locate = 0;
  5077. $roleId = 0;
  5078. $button = 0;
  5079. $staffBatchNumber = 100001;
  5080. $remittanceList = array ();
  5081. foreach ( $receiptList as $key => $value ) {
  5082. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  5083. $receiptList [$key] ['Texe'] = 'false';
  5084. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  5085. $receiptList [$key] ['Texe'] = 'true';
  5086. }
  5087. $receiptList [$key] ['TRexe'] = 'true';
  5088. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  5089. $receiptList [$key] ['TRexe'] = 'false';
  5090. }
  5091. $receiptList [$key] ['Locate'] = $Locate;
  5092. $Locate ++;
  5093. $receiptList [$key] ['reviseDetail'] = array ();
  5094. if (! empty ( $value ['reviseDetail'] ))
  5095. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5096. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5097. $categoryDetil = $Lcategory->getOne ( array (
  5098. 'where' => 'cid=' . $value ['cid'],
  5099. 'asArray' => true
  5100. ) );
  5101. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5102. // 检测编辑状态
  5103. $verifyList = $verify->getOne ( array (
  5104. 'where' => 'vid=' . $value ['verify'],
  5105. 'asArray' => true
  5106. ) );
  5107. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5108. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5109. Doo::loadModel ( 'role' );
  5110. $role = new role ();
  5111. $flag = true;
  5112. $roleKey = 0;
  5113. $endStaffArray = array ();
  5114. $roleArrayCopy = array ();
  5115. foreach ( $verifyList as $k => $v ) {
  5116. // init verifyStaff
  5117. if ($v [1] == 'ROLE') {
  5118. if (! empty ( $verifyStaff )) {
  5119. $endStaffArray = end ( $verifyStaff );
  5120. }
  5121. $roleVerify = json_decode ( $v [3], true );
  5122. $roleKey = $k;
  5123. $roleArray = array ();
  5124. $rolename = $role->getOne ( array (
  5125. 'where' => 'rid=' . $v [0],
  5126. 'asArray' => true
  5127. ) );
  5128. foreach ( $roleVerify as $o => $p ) {
  5129. $staffID = explode ( '_', $p );
  5130. $staffInfo = $staff->getOne ( array (
  5131. 'where' => 'sid=' . $staffID [0],
  5132. 'asArray' => true
  5133. ) );
  5134. $exp = array (
  5135. 0 => $staffInfo ['sid'],
  5136. 1 => $staffID [1],
  5137. 2 => $staffInfo ['avatar'],
  5138. 'date' => '',
  5139. 'date' => '',
  5140. 'opinion' => '',
  5141. 'status' => '',
  5142. 'rolename' => $rolename ['name']
  5143. );
  5144. array_push ( $roleArray, $exp );
  5145. }
  5146. $roleArrayCopy [$v [0]] = $roleArray;
  5147. }
  5148. $verifyList [$k] ['date'] = "";
  5149. $verifyList [$k] ['opinion'] = "";
  5150. $verifyList [$k] ['status'] = "";
  5151. if (empty ( $verifyStaff )) {
  5152. $verifyList [$k] ['date'] = "";
  5153. $verifyList [$k] ['opinion'] = "";
  5154. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5155. $verifyList [$k] ['status'] = 4;
  5156. $flag = false;
  5157. }
  5158. } else {
  5159. foreach ( $verifyStaff as $m => $u ) {
  5160. if ($v [0] == $m) {
  5161. $verifyList [$k] ['date'] = $u ['date'];
  5162. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5163. $verifyList [$k] ['status'] = $u ['status'];
  5164. $flag = false;
  5165. break;
  5166. }
  5167. }
  5168. $endStaffArray = end ( $verifyStaff );
  5169. }
  5170. }
  5171. $rolename ['name'] = '';
  5172. if (! empty ( $roleId )) {
  5173. Doo::loadModel ( 'role' );
  5174. $role = new role ();
  5175. $rolename = $role->getOne ( array (
  5176. 'where' => 'rid=' . $roleId,
  5177. 'asArray' => true
  5178. ) );
  5179. }
  5180. if (! empty ( $verifyStaff ))
  5181. $endStaffArray = end ( $verifyStaff );
  5182. $KOP = false;
  5183. foreach ( $roleArrayCopy as $P => $A ) {
  5184. foreach ( $A as $MKI => $AVL ) {
  5185. if (! empty ( $verifyStaff )) {
  5186. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5187. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5188. $button = 4;
  5189. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5190. }
  5191. foreach ( $verifyStaff as $m => $u ) {
  5192. $AVLFK = $AVL [0] . '_R';
  5193. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5194. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5195. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5196. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5197. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5198. break;
  5199. }
  5200. }
  5201. } else {
  5202. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5203. $button = 4;
  5204. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5205. }
  5206. }
  5207. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5208. $KOP = true;
  5209. }
  5210. }
  5211. foreach ( $roleArrayCopy as $k => $v ) {
  5212. foreach ( $verifyList as $m => $n ) {
  5213. if ($n [0] == $k) {
  5214. array_splice ( $verifyList, $m, 1, $v );
  5215. }
  5216. }
  5217. }
  5218. $receiptList [$key] ['verifyList'] = $verifyList;
  5219. $staffDetail = $staff->getOne ( array (
  5220. 'where' => 'sid=' . $value ['staff'],
  5221. 'asArray' => true
  5222. ) );
  5223. $receiptList [$key] ['staffDetail'] = $staffDetail;
  5224. $receiptList [$key] ['button'] = $button;
  5225. // 设置导出汇款execl
  5226. if (! empty ( $value ['remittanceName'] ) && ! empty ( $value ['bankName'] ) && ! empty ( $value ['bankNumber'] )) {
  5227. $remittanceDetail = array (
  5228. $staffBatchNumber,
  5229. $value ['remittanceName'],
  5230. $value ['bankNumber'],
  5231. $value ['bankName'],
  5232. $value ['remittanceBankType'],
  5233. $value ['coupletNumber'],
  5234. $value ['sum']
  5235. );
  5236. array_push ( $remittanceList, $remittanceDetail );
  5237. $staffBatchNumber ++;
  5238. }
  5239. }
  5240. $data ['remittanceList'] = json_encode ( $remittanceList );
  5241. // print_r($receiptList);
  5242. $mothHtml = "";
  5243. for($i = 1; $i <= 12; $i ++) {
  5244. if ($moth == $i)
  5245. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5246. else
  5247. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5248. }
  5249. $dayHtml = "";
  5250. if ($day != "DAY" || $moth != "MONTH") {
  5251. for($i = 1; $i <= 31; $i ++) {
  5252. if ($day == $i)
  5253. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  5254. else
  5255. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  5256. }
  5257. }
  5258. $sopHtml = "";
  5259. foreach ( $sopStaff as $key => $value ) {
  5260. if ($sop == $key)
  5261. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  5262. else
  5263. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  5264. }
  5265. $data ['status'] = $status;
  5266. $data ['rdate'] = $rdate;
  5267. $data ['sopHtml'] = $sopHtml;
  5268. $data ['dayHtml'] = $dayHtml;
  5269. $data ['mothHtml'] = $mothHtml;
  5270. $data ['receiptList'] = $receiptList;
  5271. $data ['memu'] = "receipt";
  5272. $data ['staff'] = $this->staff;
  5273. $data ['receiptMemu'] = 'implement';
  5274. $data ['verifyId'] = $this->verifyId;
  5275. $data ['executeId'] = $this->executeId;
  5276. $data ['item'] = $item;
  5277. $data ['year'] = $year;
  5278. $data ['moth'] = $moth;
  5279. $data ['day'] = $day;
  5280. $data ['sop'] = $sop;
  5281. $this->render ( "/admin/hisImplement", $data );
  5282. }
  5283. /**
  5284. * 导出汇款信息的exelc
  5285. */
  5286. function exportRemittance() {
  5287. $remittanceInfo = $_POST ['remittanceInfo']; // $this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  5288. if (empty ( $remittanceInfo ))
  5289. die ( 'illegal request' );
  5290. $title = array (
  5291. '员工编号',
  5292. '姓名',
  5293. '员工账号',
  5294. '员工账户开户行',
  5295. '转账类型',
  5296. '联行号',
  5297. '金额'
  5298. );
  5299. $data = json_decode ( $remittanceInfo, true );
  5300. if (empty ( $data ))
  5301. die ( 'illegal request' );
  5302. Doo::loadClass ( 'receipt.func' );
  5303. exportExcel ( $title, $data, '批量日常报销-公司账号', './', true );
  5304. header ( 'Content-Type:text/html;charset=utf-8' );
  5305. die ( '导出' . count ( $data ) . '条数据,<a href="/hisImplement">返回</a>' );
  5306. }
  5307. function ajaxExamine() {
  5308. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5309. Doo::loadModel ( 'receipt' );
  5310. $receipt = new receipt ();
  5311. if (! empty ( $rid )) {
  5312. $rLRes = $receipt->find ( array (
  5313. '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,
  5314. 'asArray' => true
  5315. ) );
  5316. echo json_encode ( array (
  5317. 'status' => 1,
  5318. 'receipt' => $rLRes [0]
  5319. ) );
  5320. die ();
  5321. }
  5322. echo json_encode ( array (
  5323. 'status' => 0,
  5324. 'receipt' => array ()
  5325. ) );
  5326. die ();
  5327. }
  5328. /*
  5329. * 废弃
  5330. */
  5331. function myReceipt() {
  5332. // all approval past withdraw
  5333. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  5334. if (empty ( $item ))
  5335. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  5336. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  5337. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  5338. Doo::loadModel ( 'receipt' );
  5339. $receipt = new receipt ();
  5340. // pre-loaded
  5341. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  5342. // have cache
  5343. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  5344. if (! empty ( $moth )) // yearPage
  5345. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  5346. $this->showCache ( $path );
  5347. }
  5348. Doo::loadModel ( 'L_category' );
  5349. $Lcategory = new L_category ();
  5350. Doo::loadModel ( 'verify' );
  5351. Doo::loadModel ( 'statistics' );
  5352. $statistics = new statistics ();
  5353. $verify = new verify ();
  5354. Doo::loadModel ( 'staff' );
  5355. $staff = new staff ();
  5356. $condition = " and status!=0 ";
  5357. if ($item == "approval")
  5358. $condition = " and status=2 ";
  5359. elseif ($item == "withdraw")
  5360. $condition = " and status=3 ";
  5361. elseif ($item == "past")
  5362. $condition = " and status=1 ";
  5363. elseif ($item == "whdw")
  5364. $condition = " and status=4 ";
  5365. $dateCondition = " and Year(date) =" . $year;
  5366. if (! empty ( $moth )) {
  5367. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  5368. $stList = $statistics->getOne ( array (
  5369. 'select' => 'rePrice ,agPrice',
  5370. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5371. 'asArray' => true
  5372. ) );
  5373. } else
  5374. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  5375. if (empty ( $stList ))
  5376. $stList = array (
  5377. 'rePrice' => 0,
  5378. 'agPrice' => 0
  5379. );
  5380. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  5381. $data ['stList'] = array (
  5382. 'rePrice' => $stList ['rePrice'],
  5383. 'agPrice' => $stList ['agPrice'],
  5384. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  5385. );
  5386. $receiptList = $receipt->find ( array (
  5387. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  5388. 'desc' => 'rid',
  5389. 'asArray' => true
  5390. ) );
  5391. $Locate = 0;
  5392. $roleId = 0;
  5393. $button = 0;
  5394. foreach ( $receiptList as $key => $value ) {
  5395. $receiptList [$key] ['Locate'] = $Locate;
  5396. $Locate ++;
  5397. $receiptList [$key] ['reviseDetail'] = array ();
  5398. if (! empty ( $value ['reviseDetail'] ))
  5399. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5400. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5401. $categoryDetil = $Lcategory->getOne ( array (
  5402. 'where' => 'cid=' . $value ['cid'],
  5403. 'asArray' => true
  5404. ) );
  5405. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5406. // 检测编辑状态
  5407. $verifyList = $verify->getOne ( array (
  5408. 'where' => 'vid=' . $value ['verify'],
  5409. 'asArray' => true
  5410. ) );
  5411. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5412. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5413. Doo::loadModel ( 'role' );
  5414. $role = new role ();
  5415. $flag = true;
  5416. $roleKey = 0;
  5417. $endStaffArray = array ();
  5418. $roleArrayCopy = array ();
  5419. foreach ( $verifyList as $k => $v ) {
  5420. // init verifyStaff
  5421. if ($v [1] == 'ROLE') {
  5422. if (! empty ( $verifyStaff )) {
  5423. $endStaffArray = end ( $verifyStaff );
  5424. // if ($v[0]==$endStaffArray['nextStaff']){
  5425. // $roleId=$v[0];
  5426. // }
  5427. }
  5428. $roleVerify = json_decode ( $v [3], true );
  5429. $roleKey = $k;
  5430. $roleArray = array ();
  5431. $rolename = $role->getOne ( array (
  5432. 'where' => 'rid=' . $v [0],
  5433. 'asArray' => true
  5434. ) );
  5435. foreach ( $roleVerify as $o => $p ) {
  5436. $staffID = explode ( '_', $p );
  5437. $staffInfo = $staff->getOne ( array (
  5438. 'where' => 'sid=' . $staffID [0],
  5439. 'asArray' => true
  5440. ) );
  5441. // print_r($staffID);
  5442. $exp = array (
  5443. 0 => $staffInfo ['sid'],
  5444. 1 => $staffID [1],
  5445. 2 => $staffInfo ['avatar'],
  5446. 'date' => '',
  5447. 'date' => '',
  5448. 'opinion' => '',
  5449. 'status' => '',
  5450. 'rolename' => $rolename ['name']
  5451. );
  5452. array_push ( $roleArray, $exp );
  5453. }
  5454. $roleArrayCopy [$v [0]] = $roleArray;
  5455. // $verifyList[$k]['roleArray']=$roleArray;
  5456. }
  5457. $verifyList [$k] ['date'] = "";
  5458. $verifyList [$k] ['opinion'] = "";
  5459. $verifyList [$k] ['status'] = "";
  5460. if (empty ( $verifyStaff )) {
  5461. $verifyList [$k] ['date'] = "";
  5462. $verifyList [$k] ['opinion'] = "";
  5463. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5464. $verifyList [$k] ['status'] = 4;
  5465. $flag = false;
  5466. }
  5467. } else {
  5468. foreach ( $verifyStaff as $m => $u ) {
  5469. if ($v [0] == $m) {
  5470. $verifyList [$k] ['date'] = $u ['date'];
  5471. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5472. $verifyList [$k] ['status'] = $u ['status'];
  5473. $flag = false;
  5474. break;
  5475. }
  5476. }
  5477. $endStaffArray = end ( $verifyStaff );
  5478. if (isset ( $endStaffArray ['ROLE'] )) {
  5479. } else {
  5480. // $endKey=key($verifyStaff);
  5481. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5482. // $button=4;
  5483. // $verifyList[$k]['status']=4;
  5484. // }
  5485. }
  5486. }
  5487. }
  5488. $rolename ['name'] = '';
  5489. if (! empty ( $roleId )) {
  5490. Doo::loadModel ( 'role' );
  5491. $role = new role ();
  5492. $rolename = $role->getOne ( array (
  5493. 'where' => 'rid=' . $roleId,
  5494. 'asArray' => true
  5495. ) );
  5496. }
  5497. if (! empty ( $verifyStaff ))
  5498. $endStaffArray = end ( $verifyStaff );
  5499. $KOP = false;
  5500. foreach ( $roleArrayCopy as $P => $A ) {
  5501. foreach ( $A as $MKI => $AVL ) {
  5502. if (! empty ( $verifyStaff )) {
  5503. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5504. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5505. $button = 4;
  5506. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5507. }
  5508. foreach ( $verifyStaff as $m => $u ) {
  5509. $AVLFK = $AVL [0] . '_R';
  5510. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5511. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5512. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5513. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5514. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5515. break;
  5516. }
  5517. }
  5518. } else {
  5519. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5520. $button = 4;
  5521. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5522. }
  5523. }
  5524. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5525. $KOP = true;
  5526. }
  5527. }
  5528. foreach ( $roleArrayCopy as $k => $v ) {
  5529. foreach ( $verifyList as $m => $n ) {
  5530. if ($n [0] == $k) {
  5531. array_splice ( $verifyList, $m, 1, $v );
  5532. }
  5533. }
  5534. }
  5535. $receiptList [$key] ['verifyList'] = $verifyList;
  5536. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5537. 'where' => 'sid=' . $value ['staff'],
  5538. 'asArray' => true
  5539. ) );
  5540. $receiptList [$key] ['button'] = $button;
  5541. }
  5542. // print_r($receiptList);die;
  5543. $mothHtml = "";
  5544. for($i = 1; $i <= 12; $i ++) {
  5545. if ($moth == $i)
  5546. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5547. else
  5548. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5549. }
  5550. $data ['mothHtml'] = $mothHtml;
  5551. $data ['receiptList'] = $receiptList;
  5552. $data ['memu'] = "receipt";
  5553. $data ['staff'] = $this->staff;
  5554. $data ['receiptMemu'] = 'receipt';
  5555. $data ['verifyId'] = $this->verifyId;
  5556. $data ['executeId'] = $this->executeId;
  5557. $data ['item'] = $item;
  5558. $data ['year'] = $year;
  5559. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  5560. // sufficient condition to generate cache
  5561. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  5562. $receiptList = $receipt->find ( array (
  5563. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  5564. 'asArray' => true
  5565. ) );
  5566. if (empty ( $receiptList )) { // generated files
  5567. ob_start ();
  5568. $this->render ( "/admin/saea_myList", $data );
  5569. $this->cacheFile ( $path );
  5570. die ();
  5571. // $content = ob_get_contents();
  5572. // $fp = fopen($path, "w");
  5573. // fwrite($fp, $content);
  5574. // fclose($fp);
  5575. }
  5576. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  5577. $receiptList = $receipt->find ( array (
  5578. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  5579. 'asArray' => true
  5580. ) );
  5581. if (empty ( $receiptList )) { // generated files
  5582. ob_start ();
  5583. $this->render ( "/admin/saea_myList", $data );
  5584. $this->cacheFile ( $path );
  5585. die ();
  5586. }
  5587. }
  5588. }
  5589. $this->render ( "/admin/saea_myList", $data );
  5590. }
  5591. function saeaCreate() {
  5592. Doo::loadModel ( 'accountItem' );
  5593. Doo::loadModel ( 'verify' );
  5594. Doo::loadModel ( 'receipt' );
  5595. Doo::loadModel ( 'L_category' );
  5596. $lCategory = new L_category ();
  5597. $receipt = new receipt ();
  5598. $verify = new verify ();
  5599. $accountItem = new accountItem ();
  5600. Doo::loadModel ( "role" );
  5601. $role = new role ();
  5602. $acItem = $accountItem->find ( array (
  5603. 'asArray' => true
  5604. ) );
  5605. $veList = $verify->find ( array (
  5606. 'asArray' => true
  5607. ) );
  5608. foreach ( $veList as $key => $value ) {
  5609. $v = json_decode ( $value ['staff'] );
  5610. $list = array ();
  5611. foreach ( $v as $n => $m ) {
  5612. if ($m ['1'] == 'ROLE') {
  5613. $roleInfo = $role->getOne ( array (
  5614. 'where' => 'rid=' . $m [0],
  5615. 'asArray' => true
  5616. ) );
  5617. $v [$n] [1] = $roleInfo ['name'];
  5618. array_push ( $list, $roleInfo ['name'] );
  5619. } else {
  5620. array_push ( $list, $v [$n] [1] );
  5621. }
  5622. }
  5623. $veList [$key] ['staff'] = implode ( '>', $list );
  5624. }
  5625. $data ['category'] = $lCategory->find ( array (
  5626. 'asArray' => true
  5627. ) );
  5628. $data ['veList'] = $veList;
  5629. $data ['acItem'] = $acItem;
  5630. $data ['memu'] = "receipt";
  5631. $data ['staff'] = $this->staff;
  5632. $data ['receiptMemu'] = 'saeaBorad';
  5633. $data ['verifyId'] = $this->verifyId;
  5634. $data ['executeId'] = $this->executeId;
  5635. $this->render ( "/admin/saea_create", $data );
  5636. }
  5637. function addReceipt() {
  5638. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  5639. $agency = $this->get_args ( 'agency' );
  5640. $travel = $this->get_args ( 'travel' );
  5641. $train = $this->get_args ( 'train' );
  5642. $other = $this->get_args ( 'other' );
  5643. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5644. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5645. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5646. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  5647. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  5648. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  5649. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  5650. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  5651. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  5652. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  5653. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  5654. header ( 'Content-Type:text/html;charset=utf-8' );
  5655. die ( '请填写联行号' );
  5656. }
  5657. Doo::loadModel ( 'receipt' );
  5658. Doo::loadModel ( 'receiptDetail' );
  5659. Doo::loadModel ( 'accountItem' );
  5660. $accountItem = new accountItem ();
  5661. $receipt = new receipt ();
  5662. Doo::loadModel ( 'enclosur' );
  5663. Doo::loadModel ( 'execute' );
  5664. $execute = new execute ();
  5665. $executeDetail = $execute->getOne ( array (
  5666. 'where' => 'mold="报销单执行人"',
  5667. 'asArray' => true
  5668. ) );
  5669. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  5670. // if(!empty($receiptDetail))
  5671. // return "/referReceipt/".$receiptDetail['rid'];
  5672. $aItem = $accountItem->find ( array (
  5673. 'asArray' => true
  5674. ) );
  5675. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5676. $ag = $tr = $ta = $ot = 0;
  5677. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5678. foreach ( $aItem as $key => $value ) {
  5679. if ($value ['category'] == $this->AGENCY) {
  5680. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5681. array_push ( $accountJson [$this->AGENCY], array (
  5682. 'aid' => $value ['aid'],
  5683. 'name' => $value ['name'],
  5684. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5685. ) );
  5686. $sum += $agency [$ag];
  5687. $agencySum += $agency [$ag];
  5688. }
  5689. $ag ++;
  5690. }
  5691. if ($value ['category'] == $this->TRAVEL) {
  5692. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5693. array_push ( $accountJson [$this->TRAVEL], array (
  5694. 'aid' => $value ['aid'],
  5695. 'name' => $value ['name'],
  5696. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5697. ) );
  5698. $sum += $travel [$tr];
  5699. $travelSum += $travel [$tr];
  5700. }
  5701. $tr ++;
  5702. }
  5703. if ($value ['category'] == $this->TRAIN) {
  5704. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5705. array_push ( $accountJson [$this->TRAIN], array (
  5706. 'aid' => $value ['aid'],
  5707. 'name' => $value ['name'],
  5708. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5709. ) );
  5710. $sum += $train [$ta];
  5711. $trainSum += $train [$ta];
  5712. }
  5713. $ta ++;
  5714. }
  5715. if ($value ['category'] == $this->OTHER) {
  5716. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5717. array_push ( $accountJson [$this->OTHER], array (
  5718. 'aid' => $value ['aid'],
  5719. 'name' => $value ['name'],
  5720. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5721. ) );
  5722. $sum += $other [$ot];
  5723. $otherSum += $other [$ot];
  5724. }
  5725. $ot ++;
  5726. }
  5727. }
  5728. $accountJson ['cSum'] = array (
  5729. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5730. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5731. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5732. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5733. );
  5734. // 报销单
  5735. $receipt->accountItem = json_encode ( $accountJson );
  5736. $receipt->staff = $this->staff [0] ['sid'];
  5737. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5738. $receipt->date = date ( "Y-m-d" );
  5739. $receipt->cid = $cid;
  5740. $receipt->status = 5;
  5741. // 修改审批流程加入角色
  5742. $receipt->verify = $verify;
  5743. $receipt->executeCopy = $executeDetail ['staff'];
  5744. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  5745. $order = array (
  5746. "\r\n",
  5747. "\n",
  5748. "\r"
  5749. );
  5750. $replace = '<br/>';
  5751. $explanation = str_replace ( $order, $replace, $explanation );
  5752. $receipt->explanation = $explanation;
  5753. $receipt->remittanceName = $remittanceName;
  5754. $receipt->bankName = $bankName;
  5755. $receipt->bankNumber = $bankNumber;
  5756. $receipt->remittanceBankType = $remittanceBankType;
  5757. if ($remittanceBankType == 1)
  5758. $receipt->coupletNumber = $coupletNumber;
  5759. $rid = $receipt->insert ();
  5760. // 附件
  5761. if (! empty ( $enclosurName )) {
  5762. $enclosurArray = explode ( '-', $enclosurName );
  5763. foreach ( $enclosurArray as $value ) {
  5764. $enclosur = new enclosur ();
  5765. $enclosur->name = $value;
  5766. $enclosur->rid = $rid;
  5767. $enclosur->insert ();
  5768. }
  5769. // print_r($enclosurArray);die;
  5770. }
  5771. // 报销详情
  5772. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5773. $receiptDetail = new receiptDetail ();
  5774. $receiptDetail->staff = $this->staff [0] ['sid'];
  5775. $receiptDetail->item = $value ['name'];
  5776. $receiptDetail->itemCategory = $this->AGENCY;
  5777. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5778. $receiptDetail->date = date ( "Y-m-d" );
  5779. $receiptDetail->cid = $cid;
  5780. $receiptDetail->rid = $rid;
  5781. $receiptDetail->status = 4;
  5782. $receiptDetail->insert ();
  5783. }
  5784. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5785. $receiptDetail = new receiptDetail ();
  5786. $receiptDetail->staff = $this->staff [0] ['sid'];
  5787. $receiptDetail->item = $value ['name'];
  5788. $receiptDetail->itemCategory = $this->TRAVEL;
  5789. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5790. $receiptDetail->date = date ( "Y-m-d" );
  5791. $receiptDetail->cid = $cid;
  5792. $receiptDetail->rid = $rid;
  5793. $receiptDetail->status = 4;
  5794. $receiptDetail->insert ();
  5795. }
  5796. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5797. $receiptDetail = new receiptDetail ();
  5798. $receiptDetail->staff = $this->staff [0] ['sid'];
  5799. $receiptDetail->item = $value ['name'];
  5800. $receiptDetail->itemCategory = $this->TRAIN;
  5801. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5802. $receiptDetail->date = date ( "Y-m-d" );
  5803. $receiptDetail->cid = $cid;
  5804. $receiptDetail->rid = $rid;
  5805. $receiptDetail->status = 4;
  5806. $receiptDetail->insert ();
  5807. }
  5808. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5809. $receiptDetail = new receiptDetail ();
  5810. $receiptDetail->staff = $this->staff [0] ['sid'];
  5811. $receiptDetail->item = $value ['name'];
  5812. $receiptDetail->itemCategory = $this->OTHER;
  5813. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5814. $receiptDetail->date = date ( "Y-m-d" );
  5815. $receiptDetail->cid = $cid;
  5816. $receiptDetail->rid = $rid;
  5817. $receiptDetail->status = 4;
  5818. $receiptDetail->insert ();
  5819. }
  5820. return "/saeaBorad";
  5821. } else
  5822. die ( 'illegal request' );
  5823. }
  5824. function referReceipt() {
  5825. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  5826. Doo::loadModel ( 'receipt' );
  5827. Doo::loadModel ( 'verify' );
  5828. $verify = new verify ();
  5829. $receipt = new receipt ();
  5830. Doo::loadModel ( 'L_category' );
  5831. $lCategory = new L_category ();
  5832. Doo::loadModel ( "role" );
  5833. $role = new role ();
  5834. $receiptDetail = $receipt->find ( array (
  5835. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  5836. 'asArray' => true
  5837. ) );
  5838. if (empty ( $receiptDetail ))
  5839. return "/addReceipt";
  5840. foreach ( $receiptDetail as $key => $value ) {
  5841. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5842. $veList = $verify->getOne ( array (
  5843. 'where' => 'vid=' . $value ['verify'],
  5844. 'asArray' => true
  5845. ) );
  5846. $v = json_decode ( $veList ['staff'] );
  5847. array_push ( $v [0], $veList ['description'] );
  5848. foreach ( $v as $n => $m ) {
  5849. if ($m ['1'] == 'ROLE') {
  5850. $roleInfo = $role->getOne ( array (
  5851. 'where' => 'rid=' . $m [0],
  5852. 'asArray' => true
  5853. ) );
  5854. $v [$n] [1] = $roleInfo ['name'];
  5855. }
  5856. }
  5857. $receiptDetail [$key] ['staff'] = $v;
  5858. $category = $lCategory->getOne ( array (
  5859. 'where' => 'cid=' . $value ['cid'],
  5860. 'asArray' => true
  5861. ) );
  5862. $receiptDetail [$key] ['category'] = $category ['title'];
  5863. }
  5864. // print_r($receiptDetail);
  5865. $data ['receiptDetail'] = $receiptDetail;
  5866. $data ['memu'] = "receipt";
  5867. $data ['staff'] = $this->staff;
  5868. $data ['receiptMemu'] = 'saeaCreate';
  5869. $data ['verifyId'] = $this->verifyId;
  5870. $data ['executeId'] = $this->executeId;
  5871. $this->render ( "/admin/saea_confirm", $data );
  5872. }
  5873. function editReceipt() {
  5874. // edit status 4
  5875. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  5876. Doo::loadClass ( 'XDeode' );
  5877. $XDeode = new XDeode ( 7 );
  5878. $rid = $XDeode->decode ( $ridKey );
  5879. if (empty ( $rid ))
  5880. die ( 'illegal request' );
  5881. // echo $rid.'sd';
  5882. Doo::loadModel ( 'accountItem' );
  5883. Doo::loadModel ( 'verify' );
  5884. Doo::loadModel ( 'receipt' );
  5885. $receipt = new receipt ();
  5886. $verify = new verify ();
  5887. $accountItem = new accountItem ();
  5888. Doo::loadModel ( 'L_category' );
  5889. $lCategory = new L_category ();
  5890. Doo::loadModel ( "role" );
  5891. $role = new role ();
  5892. Doo::loadModel ( 'enclosur' );
  5893. $enclosur = new enclosur ();
  5894. $receiptDetail = $receipt->getOne ( array (
  5895. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  5896. 'asArray' => true
  5897. ) );
  5898. if (empty ( $receiptDetail ))
  5899. die ( 'illegal request' );
  5900. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  5901. $acItem = $accountItem->find ( array (
  5902. 'asArray' => true
  5903. ) );
  5904. $veList = $verify->find ( array (
  5905. 'asArray' => true
  5906. ) );
  5907. foreach ( $veList as $key => $value ) {
  5908. $v = json_decode ( $value ['staff'] );
  5909. $list = array ();
  5910. foreach ( $v as $n => $m ) {
  5911. if ($m ['1'] == 'ROLE') {
  5912. $roleInfo = $role->getOne ( array (
  5913. 'where' => 'rid=' . $m [0],
  5914. 'asArray' => true
  5915. ) );
  5916. $v [$n] [1] = $roleInfo ['name'];
  5917. array_push ( $list, $roleInfo ['name'] );
  5918. } else {
  5919. array_push ( $list, $v [$n] [1] );
  5920. }
  5921. }
  5922. $veList [$key] ['staff'] = implode ( '>', $list );
  5923. }
  5924. // 配置编辑信息
  5925. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  5926. foreach ( $acItem as $key => $value ) {
  5927. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  5928. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  5929. $acItem [$key] ['price'] = $v ['price'];
  5930. }
  5931. }
  5932. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  5933. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  5934. $acItem [$key] ['price'] = $v ['price'];
  5935. }
  5936. }
  5937. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  5938. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  5939. $acItem [$key] ['price'] = $v ['price'];
  5940. }
  5941. }
  5942. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  5943. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  5944. $acItem [$key] ['price'] = $v ['price'];
  5945. }
  5946. }
  5947. }
  5948. $data ['category'] = $lCategory->find ( array (
  5949. 'asArray' => true
  5950. ) );
  5951. $data ['cSum'] = $accountItemList ['cSum'];
  5952. $data ['sum'] = $receiptDetail ['sum'];
  5953. $data ['enclosurList'] = $enclosurList;
  5954. $data ['receiptDetail'] = $receiptDetail;
  5955. $data ['veList'] = $veList;
  5956. $data ['acItem'] = $acItem;
  5957. $data ['memu'] = "receipt";
  5958. $data ['staff'] = $this->staff;
  5959. $data ['receiptMemu'] = 'saeaBorad';
  5960. $data ['verify'] = $receiptDetail ['verify'];
  5961. $data ['verifyId'] = $this->verifyId;
  5962. $data ['executeId'] = $this->executeId;
  5963. $data ['rid'] = $ridKey;
  5964. $this->render ( "/admin/saea_edit", $data );
  5965. }
  5966. function updateReceipt() {
  5967. $agency = $this->get_args ( 'agency' );
  5968. $travel = $this->get_args ( 'travel' );
  5969. $train = $this->get_args ( 'train' );
  5970. $other = $this->get_args ( 'other' );
  5971. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5972. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5973. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5974. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  5975. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  5976. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  5977. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  5978. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  5979. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  5980. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  5981. Doo::loadClass ( 'XDeode' );
  5982. $XDeode = new XDeode ( 7 );
  5983. $rid = $XDeode->decode ( $ridKey );
  5984. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  5985. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  5986. header ( 'Content-Type:text/html;charset=utf-8' );
  5987. die ( '请填写联行号' );
  5988. }
  5989. Doo::loadModel ( 'receipt' );
  5990. Doo::loadModel ( 'receiptDetail' );
  5991. Doo::loadModel ( 'accountItem' );
  5992. $accountItem = new accountItem ();
  5993. $receipt = new receipt ();
  5994. Doo::loadModel ( 'enclosur' );
  5995. Doo::loadModel ( 'execute' );
  5996. $execute = new execute ();
  5997. $receiptDetail = $receipt->getOne ( array (
  5998. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  5999. 'asArray' => true
  6000. ) );
  6001. if (empty ( $receiptDetail ))
  6002. return "/saeaBorad";
  6003. if ($receiptDetail ['Rtype'] == 1)
  6004. $executeDetail = $execute->getOne ( array (
  6005. 'where' => 'mold="借款费用执行人"',
  6006. 'asArray' => true
  6007. ) );
  6008. else
  6009. $executeDetail = $execute->getOne ( array (
  6010. 'where' => 'mold="报销单执行人"',
  6011. 'asArray' => true
  6012. ) );
  6013. $aItem = $accountItem->find ( array (
  6014. 'asArray' => true
  6015. ) );
  6016. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  6017. $ag = $tr = $ta = $ot = 0;
  6018. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  6019. foreach ( $aItem as $key => $value ) {
  6020. if ($value ['category'] == $this->AGENCY) {
  6021. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  6022. array_push ( $accountJson [$this->AGENCY], array (
  6023. 'aid' => $value ['aid'],
  6024. 'name' => $value ['name'],
  6025. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  6026. ) );
  6027. $sum += $agency [$ag];
  6028. $agencySum += $agency [$ag];
  6029. }
  6030. $ag ++;
  6031. }
  6032. if ($value ['category'] == $this->TRAVEL) {
  6033. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  6034. array_push ( $accountJson [$this->TRAVEL], array (
  6035. 'aid' => $value ['aid'],
  6036. 'name' => $value ['name'],
  6037. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  6038. ) );
  6039. $sum += $travel [$tr];
  6040. $travelSum += $travel [$tr];
  6041. }
  6042. $tr ++;
  6043. }
  6044. if ($value ['category'] == $this->TRAIN) {
  6045. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  6046. array_push ( $accountJson [$this->TRAIN], array (
  6047. 'aid' => $value ['aid'],
  6048. 'name' => $value ['name'],
  6049. 'price' => number_format ( $train [$ta], 2, '.', '' )
  6050. ) );
  6051. $sum += $train [$ta];
  6052. $trainSum += $train [$ta];
  6053. }
  6054. $ta ++;
  6055. }
  6056. if ($value ['category'] == $this->OTHER) {
  6057. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  6058. array_push ( $accountJson [$this->OTHER], array (
  6059. 'aid' => $value ['aid'],
  6060. 'name' => $value ['name'],
  6061. 'price' => number_format ( $other [$ot], 2, '.', '' )
  6062. ) );
  6063. $sum += $other [$ot];
  6064. $otherSum += $other [$ot];
  6065. }
  6066. $ot ++;
  6067. }
  6068. }
  6069. $accountJson ['cSum'] = array (
  6070. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  6071. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  6072. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  6073. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  6074. );
  6075. // 报销单
  6076. $rid = $receipt->rid = $receiptDetail ['rid'];
  6077. $receipt->accountItem = json_encode ( $accountJson );
  6078. $receipt->staff = $this->staff [0] ['sid'];
  6079. $receipt->sum = number_format ( $sum, 2, '.', '' );
  6080. $receipt->date = date ( "Y-m-d" );
  6081. $receipt->cid = $cid;
  6082. if (($receiptDetail ['status'] != 4)) {
  6083. if ($receiptDetail ['Rtype'] == 1)
  6084. $receipt->status = 7;
  6085. else
  6086. $receipt->status = 5;
  6087. }
  6088. if ($receiptDetail != 4 && ! empty ( $verify ))
  6089. $receipt->verify = $verify;
  6090. $receipt->executeCopy = $executeDetail ['staff'];
  6091. $order = array (
  6092. "\r\n",
  6093. "\n",
  6094. "\r"
  6095. );
  6096. $replace = '<br/>';
  6097. $explanation = str_replace ( $order, $replace, $explanation );
  6098. $receipt->explanation = $explanation;
  6099. $receipt->remittanceName = $remittanceName;
  6100. $receipt->bankName = $bankName;
  6101. $receipt->bankNumber = $bankNumber;
  6102. $receipt->remittanceBankType = $remittanceBankType;
  6103. if ($remittanceBankType == 1)
  6104. $receipt->coupletNumber = $coupletNumber;
  6105. $receipt->update ();
  6106. $receiptDetail = new receiptDetail ();
  6107. $receiptDetail->delete ( array (
  6108. 'where' => 'rid=' . $rid
  6109. ) );
  6110. // 报销详情
  6111. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  6112. $receiptDetail = new receiptDetail ();
  6113. $receiptDetail->staff = $this->staff [0] ['sid'];
  6114. $receiptDetail->item = $value ['name'];
  6115. $receiptDetail->itemCategory = $this->AGENCY;
  6116. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6117. $receiptDetail->date = date ( "Y-m-d" );
  6118. $receiptDetail->cid = $cid;
  6119. $receiptDetail->rid = $rid;
  6120. $receiptDetail->status = 4;
  6121. $receiptDetail->insert ();
  6122. }
  6123. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  6124. $receiptDetail = new receiptDetail ();
  6125. $receiptDetail->staff = $this->staff [0] ['sid'];
  6126. $receiptDetail->item = $value ['name'];
  6127. $receiptDetail->itemCategory = $this->TRAVEL;
  6128. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6129. $receiptDetail->date = date ( "Y-m-d" );
  6130. $receiptDetail->cid = $cid;
  6131. $receiptDetail->rid = $rid;
  6132. $receiptDetail->status = 4;
  6133. $receiptDetail->insert ();
  6134. }
  6135. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  6136. $receiptDetail = new receiptDetail ();
  6137. $receiptDetail->staff = $this->staff [0] ['sid'];
  6138. $receiptDetail->item = $value ['name'];
  6139. $receiptDetail->itemCategory = $this->TRAIN;
  6140. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6141. $receiptDetail->date = date ( "Y-m-d" );
  6142. $receiptDetail->cid = $cid;
  6143. $receiptDetail->rid = $rid;
  6144. $receiptDetail->status = 4;
  6145. $receiptDetail->insert ();
  6146. }
  6147. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  6148. $receiptDetail = new receiptDetail ();
  6149. $receiptDetail->staff = $this->staff [0] ['sid'];
  6150. $receiptDetail->item = $value ['name'];
  6151. $receiptDetail->itemCategory = $this->OTHER;
  6152. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6153. $receiptDetail->date = date ( "Y-m-d" );
  6154. $receiptDetail->cid = $cid;
  6155. $receiptDetail->rid = $rid;
  6156. $receiptDetail->status = 4;
  6157. $receiptDetail->insert ();
  6158. }
  6159. // 附件
  6160. if (! empty ( $enclosurName )) {
  6161. $enclosurArray = explode ( '-', $enclosurName );
  6162. foreach ( $enclosurArray as $value ) {
  6163. $enclosur = new enclosur ();
  6164. $enclosur->name = $value;
  6165. $enclosur->rid = $rid;
  6166. $enclosur->insert ();
  6167. }
  6168. }
  6169. // return "/referReceipt/".$rid;
  6170. }
  6171. return "/saeaBorad";
  6172. }
  6173. function approvedReceipt() {
  6174. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6175. Doo::loadModel ( 'receipt' );
  6176. Doo::loadModel ( 'receiptDetail' );
  6177. $receipt = new receipt ();
  6178. $receiptDetail = new receiptDetail ();
  6179. Doo::loadModel ( 'statistics' );
  6180. Doo::loadModel ( 'itemStatistics' );
  6181. $statistics = new statistics ();
  6182. $itemStatistics = new itemStatistics ();
  6183. Doo::loadModel ( "verify" );
  6184. $verify = new verify ();
  6185. // 审批状态的判定
  6186. $receiptDetailList = $receipt->getOne ( array (
  6187. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  6188. 'asArray' => true
  6189. ) );
  6190. if (empty ( $receiptDetailList ))
  6191. return "/saeaBorad";
  6192. $verifyDetail = $verify->getOne ( array (
  6193. 'where' => ' vid =' . $receiptDetailList ['verify'],
  6194. 'asArray' => true
  6195. ) );
  6196. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  6197. if (empty ( $receiptDetailList ['nowStaff'] )) {
  6198. $nowStaff = "";
  6199. $nowStaffList = array ();
  6200. if ($verifyDetail [0] [1] == 'ROLE') {
  6201. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  6202. foreach ( $vStaffString as $key => $value ) {
  6203. $staffK = explode ( "_", $value );
  6204. array_push ( $nowStaffList, $staffK [0] );
  6205. }
  6206. $nowStaff = implode ( ',', $nowStaffList );
  6207. } else {
  6208. $nowStaff = $verifyDetail [0] [0];
  6209. }
  6210. $receipt->nowStaff = $nowStaff;
  6211. }
  6212. // echo $nowStaff;
  6213. // print_r($verifyDetail);die;
  6214. $receipt->rid = $receiptDetailList ['rid'];
  6215. $receipt->date = date ( "Y-m-d" );
  6216. $receipt->status = 2;
  6217. $receipt->update ();
  6218. $receiptDetail->status = 2;
  6219. $receiptDetail->update ( array (
  6220. 'where' => 'rid=' . $receiptDetailList ['rid']
  6221. ) );
  6222. Doo::loadModel ( "receiptLog" );
  6223. $receiptLog = new receiptLog ();
  6224. Doo::loadModel ( "verify" );
  6225. $verify = new verify ();
  6226. $receiptInfo = $receipt->getOne ( array (
  6227. 'where' => 'rid=' . $rid,
  6228. 'asArray' => true
  6229. ) );
  6230. $vr = $verify->getOne ( array (
  6231. 'where' => 'vid=' . $receiptInfo ['verify'],
  6232. 'asArray' => true
  6233. ) );
  6234. $jd = json_decode ( $vr ['staff'] );
  6235. $roleId = 0;
  6236. foreach ( $jd as $key => $value ) {
  6237. if ($value [1] == 'ROLE') {
  6238. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  6239. if ($pos !== false) {
  6240. $roleId = $value [0];
  6241. }
  6242. }
  6243. }
  6244. // 审批日志
  6245. // echo $roleId;die;
  6246. if (! empty ( $roleId )) {
  6247. Doo::loadModel ( "role" );
  6248. $role = new role ();
  6249. $roleInfo = $role->getOne ( array (
  6250. 'where' => 'rid=' . $roleId,
  6251. 'asArray' => true
  6252. ) );
  6253. // $receiptLog->rolename = $roleInfo ['name'];
  6254. }
  6255. $receiptLog->username = $this->staff [0] ['username'];
  6256. $receiptLog->uid = $this->staff [0] ['sid'];
  6257. $receiptLog->date = date ( "Y-m-d" );
  6258. $receiptLog->opinion = '提交审批';
  6259. $receiptLog->img = $this->staff [0] ['avatar'];
  6260. $receiptLog->status = 2;
  6261. $receiptLog->rid = $rid;
  6262. $receiptLog->insert ();
  6263. // statistics item
  6264. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  6265. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  6266. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  6267. $stat = $statistics->getOne ( array (
  6268. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  6269. 'asArray' => true
  6270. ) );
  6271. if (empty ( $stat )) {
  6272. $statistics->date = date ( "Y-m-d" );
  6273. $statistics->cid = $this->staff [0] ['cid'];
  6274. $statistics->staff = $this->staff [0] ['sid'];
  6275. $statistics->agPrice = 0;
  6276. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  6277. $statistics->insert ();
  6278. } else {
  6279. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  6280. $statistics->update ( array (
  6281. 'where' => 'sid=' . $stat ['sid']
  6282. ) );
  6283. }
  6284. return "/expenses";
  6285. }
  6286. function approval() {
  6287. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  6288. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6289. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6290. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6291. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6292. if (empty ( $status ))
  6293. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  6294. $vidList = array ();
  6295. $button = 0;
  6296. Doo::loadModel ( 'verify' );
  6297. $verify = new verify ();
  6298. Doo::loadModel ( 'receipt' );
  6299. $receipt = new receipt ();
  6300. Doo::loadModel ( 'staff' );
  6301. $staff = new staff ();
  6302. Doo::loadModel ( 'L_category' );
  6303. $Lcategory = new L_category ();
  6304. // user verify ID
  6305. $verifyDetail = $verify->find ( array (
  6306. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6307. 'asArray' => true
  6308. ) );
  6309. foreach ( $verifyDetail as $key => $value ) {
  6310. array_push ( $vidList, $value ['vid'] );
  6311. }
  6312. $vid = implode ( ",", $vidList );
  6313. if (empty ( $verifyDetail ))
  6314. $vid = 0;
  6315. /*
  6316. */
  6317. $dateCondition = " and Year(date) =" . $year;
  6318. if (! empty ( $month ))
  6319. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  6320. $categoryList = $Lcategory->find ( array (
  6321. 'asArray' => true
  6322. ) );
  6323. $staffList = $staff->find ( array (
  6324. 'where' => 'cid=' . $cid,
  6325. 'asArray' => true
  6326. ) );
  6327. $cateCondition = "";
  6328. $staffCondition = "";
  6329. $approvalCondition = "";
  6330. if (! empty ( $cid ))
  6331. $cateCondition = ' and cid=' . $cid;
  6332. if (! empty ( $sid )) {
  6333. $staffCondition = ' and staff=' . $sid;
  6334. $cateCondition = "";
  6335. }
  6336. // elseif($status==1){
  6337. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  6338. // }
  6339. if ($status == 2) {
  6340. // 查找角色审批人
  6341. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  6342. }
  6343. $ap = "";
  6344. if ($status == 4) {
  6345. $ap = 4;
  6346. $status = 2;
  6347. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  6348. }
  6349. if ($status == 5) {
  6350. $status = 4;
  6351. $ap = 5;
  6352. }
  6353. // echo $vid;
  6354. // get Receipt By verifyID status 2 .$approvalCondition
  6355. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  6356. $receiptList = $receipt->find ( array (
  6357. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  6358. 'desc' => 'rid',
  6359. 'asArray' => true
  6360. ) );
  6361. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  6362. $Locate = 0;
  6363. if ($ap == 4)
  6364. $status = 4;
  6365. elseif ($ap == 5)
  6366. $status = 5;
  6367. foreach ( $receiptList as $key => $value ) {
  6368. $receiptList [$key] ['Locate'] = $Locate;
  6369. $Locate ++;
  6370. $receiptList [$key] ['reviseDetail'] = array ();
  6371. if (! empty ( $value ['reviseDetail'] ))
  6372. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6373. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6374. $categoryDetil = $Lcategory->getOne ( array (
  6375. 'where' => 'cid=' . $value ['cid'],
  6376. 'asArray' => true
  6377. ) );
  6378. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6379. $verifyList = $verify->getOne ( array (
  6380. 'where' => 'vid=' . $value ['verify'],
  6381. 'asArray' => true
  6382. ) );
  6383. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6384. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6385. foreach ( $verifyList as $k => $v ) {
  6386. // init verifyStaff
  6387. $verifyList [$k] ['date'] = "";
  6388. $verifyList [$k] ['opinion'] = "";
  6389. $verifyList [$k] ['status'] = "";
  6390. if (empty ( $verifyStaff )) {
  6391. $verifyList [$k] ['date'] = "";
  6392. $verifyList [$k] ['opinion'] = "";
  6393. if ($v [0] == $this->staff [0] ['sid']) {
  6394. $verifyList [$k] ['status'] = 4;
  6395. $button = 4;
  6396. }
  6397. } else {
  6398. $flag = true;
  6399. foreach ( $verifyStaff as $m => $u ) {
  6400. if ($v [0] == $m) {
  6401. $verifyList [$k] ['date'] = $u ['date'];
  6402. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6403. $verifyList [$k] ['status'] = $u ['status'];
  6404. $flag = false;
  6405. break;
  6406. }
  6407. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  6408. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  6409. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  6410. }
  6411. if ($flag) { // 检测可编辑
  6412. if ($v [0] == $this->staff [0] ['sid']) {
  6413. $verifyList [$k] ['status'] = 4;
  6414. $button = 4;
  6415. }
  6416. }
  6417. }
  6418. }
  6419. $receiptList [$key] ['verifyList'] = $verifyList;
  6420. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6421. 'where' => 'sid=' . $value ['staff'],
  6422. 'asArray' => true
  6423. ) );
  6424. $receiptList [$key] ['button'] = $button;
  6425. }
  6426. // print_r($receiptList);die;
  6427. // $data['verifyDetail']=$verifyDetail;
  6428. $mothHtml = "";
  6429. for($i = 1; $i <= 12; $i ++) {
  6430. if ($month == $i)
  6431. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6432. else
  6433. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6434. }
  6435. $data ['mothHtml'] = $mothHtml;
  6436. $data ['receiptList'] = $receiptList;
  6437. $data ['receiptApprovalCount'] = count ( $receiptList );
  6438. $data ['status'] = $status;
  6439. $data ['year'] = $year;
  6440. $data ['categoryList'] = $categoryList;
  6441. $data ['staffList'] = $staffList;
  6442. $data ['cid'] = $cid;
  6443. $data ['sid'] = $sid;
  6444. $data ['ap'] = $ap;
  6445. $data ['memu'] = "receipt";
  6446. $data ['staff'] = $this->staff;
  6447. $data ['receiptMemu'] = 'approval';
  6448. $data ['verifyId'] = $this->verifyId;
  6449. $data ['executeId'] = $this->executeId;
  6450. $this->render ( "/admin/saea_reportList", $data );
  6451. }
  6452. function approvalDetails() {
  6453. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6454. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6455. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6456. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6457. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6458. Doo::loadModel ( 'verify' );
  6459. $verify = new verify ();
  6460. Doo::loadModel ( 'receipt' );
  6461. $receipt = new receipt ();
  6462. Doo::loadModel ( 'staff' );
  6463. $staff = new staff ();
  6464. Doo::loadModel ( 'L_category' );
  6465. $Lcategory = new L_category ();
  6466. Doo::loadModel ( 'enclosur' );
  6467. $enclosur = new enclosur ();
  6468. $vidList = array ();
  6469. $verifyDetail = $verify->find ( array (
  6470. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6471. 'asArray' => true
  6472. ) );
  6473. foreach ( $verifyDetail as $key => $value ) {
  6474. array_push ( $vidList, $value ['vid'] );
  6475. }
  6476. $vid = implode ( ",", $vidList );
  6477. if (empty ( $verifyDetail ))
  6478. $vid = 0;
  6479. $categoryList = $Lcategory->find ( array (
  6480. 'asArray' => true
  6481. ) );
  6482. $staffList = $staff->find ( array (
  6483. 'where' => 'cid=' . $cid,
  6484. 'asArray' => true
  6485. ) );
  6486. $ap = 0;
  6487. $receiptList = $receipt->find ( array (
  6488. 'where' => 'rid =' . $rid,
  6489. 'desc' => 'rid',
  6490. 'asArray' => true
  6491. ) );
  6492. $Locate = 0;
  6493. $roleId = 0;
  6494. $button = 0;
  6495. foreach ( $receiptList as $key => $value ) {
  6496. $receiptList [$key] ['Locate'] = $Locate;
  6497. $Locate ++;
  6498. $receiptList [$key] ['reviseDetail'] = array ();
  6499. if (! empty ( $value ['reviseDetail'] ))
  6500. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6501. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6502. $categoryDetil = $Lcategory->getOne ( array (
  6503. 'where' => 'cid=' . $value ['cid'],
  6504. 'asArray' => true
  6505. ) );
  6506. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6507. // 检测编辑状态
  6508. $verifyList = $verify->getOne ( array (
  6509. 'where' => 'vid=' . $value ['verify'],
  6510. 'asArray' => true
  6511. ) );
  6512. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6513. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6514. Doo::loadModel ( 'role' );
  6515. $role = new role ();
  6516. // print_r($verifyList);
  6517. $flag = true;
  6518. $roleKey = 0;
  6519. $endStaffArray = array ();
  6520. $roleArrayCopy = array ();
  6521. foreach ( $verifyList as $k => $v ) {
  6522. // init verifyStaff
  6523. if ($v [1] == 'ROLE') {
  6524. if (! empty ( $verifyStaff )) {
  6525. $endStaffArray = end ( $verifyStaff );
  6526. if ($v [0] == $endStaffArray ['nextStaff']) {
  6527. $roleId = $v [0];
  6528. }
  6529. }
  6530. $roleVerify = json_decode ( $v [3], true );
  6531. $roleKey = $k;
  6532. $roleArray = array ();
  6533. $rolename = $role->getOne ( array (
  6534. 'where' => 'rid=' . $v [0],
  6535. 'asArray' => true
  6536. ) );
  6537. foreach ( $roleVerify as $o => $p ) {
  6538. $staffID = explode ( '_', $p );
  6539. $staffInfo = $staff->getOne ( array (
  6540. 'where' => 'sid=' . $staffID [0],
  6541. 'asArray' => true
  6542. ) );
  6543. // print_r($staffID);
  6544. $exp = array (
  6545. 0 => $staffInfo ['sid'],
  6546. 1 => $staffID [1],
  6547. 2 => $staffInfo ['avatar'],
  6548. 'date' => '',
  6549. 'date' => '',
  6550. 'opinion' => '',
  6551. 'status' => '',
  6552. 'rolename' => $rolename ['name']
  6553. );
  6554. array_push ( $roleArray, $exp );
  6555. }
  6556. $roleArrayCopy [$v [0]] = $roleArray;
  6557. // $verifyList[$k]['roleArray']=$roleArray;
  6558. }
  6559. // print_r($roleArray);
  6560. $verifyList [$k] ['date'] = "";
  6561. $verifyList [$k] ['opinion'] = "";
  6562. $verifyList [$k] ['status'] = "";
  6563. if (empty ( $verifyStaff )) {
  6564. $verifyList [$k] ['date'] = "";
  6565. $verifyList [$k] ['opinion'] = "";
  6566. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6567. $verifyList [$k] ['status'] = 4;
  6568. $button = 4;
  6569. $flag = false;
  6570. }
  6571. } else {
  6572. foreach ( $verifyStaff as $m => $u ) {
  6573. if ($v [0] == $m) {
  6574. $verifyList [$k] ['date'] = $u ['date'];
  6575. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6576. $verifyList [$k] ['status'] = $u ['status'];
  6577. $flag = false;
  6578. break;
  6579. }
  6580. }
  6581. $endStaffArray = end ( $verifyStaff );
  6582. if (isset ( $endStaffArray ['ROLE'] )) {
  6583. } else {
  6584. $endKey = key ( $verifyStaff );
  6585. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6586. $button = 4;
  6587. $verifyList [$k] ['status'] = 4;
  6588. }
  6589. }
  6590. }
  6591. }
  6592. $rolename ['name'] = '';
  6593. if (! empty ( $roleId )) {
  6594. Doo::loadModel ( 'role' );
  6595. $role = new role ();
  6596. $rolename = $role->getOne ( array (
  6597. 'where' => 'rid=' . $roleId,
  6598. 'asArray' => true
  6599. ) );
  6600. }
  6601. if (! empty ( $verifyStaff ))
  6602. $endStaffArray = end ( $verifyStaff );
  6603. $KOP = false;
  6604. foreach ( $roleArrayCopy as $P => $A ) {
  6605. foreach ( $A as $MKI => $AVL ) {
  6606. if (! empty ( $verifyStaff )) {
  6607. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6608. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6609. $button = 4;
  6610. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6611. }
  6612. foreach ( $verifyStaff as $m => $u ) {
  6613. $AVLFK = $AVL [0] . '_R';
  6614. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6615. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6616. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6617. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6618. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6619. break;
  6620. }
  6621. }
  6622. } else {
  6623. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6624. $button = 4;
  6625. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6626. }
  6627. }
  6628. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6629. $KOP = true;
  6630. }
  6631. }
  6632. foreach ( $roleArrayCopy as $k => $v ) {
  6633. foreach ( $verifyList as $m => $n ) {
  6634. if ($n [0] == $k) {
  6635. array_splice ( $verifyList, $m, 1, $v );
  6636. }
  6637. }
  6638. }
  6639. $receiptList [$key] ['verifyList'] = $verifyList;
  6640. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6641. 'where' => 'sid=' . $value ['staff'],
  6642. 'asArray' => true
  6643. ) );
  6644. $receiptList [$key] ['button'] = $button;
  6645. }
  6646. $mothHtml = "";
  6647. for($i = 1; $i <= 12; $i ++) {
  6648. if ($month == $i)
  6649. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6650. else
  6651. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6652. }
  6653. // 获取审批日志
  6654. Doo::loadModel ( 'receiptLog' );
  6655. $receiptLog = new receiptLog ();
  6656. $rlList = array ();
  6657. $rlInfo = $receiptLog->getOne ( array (
  6658. 'where' => 'rid=' . $rid . ' and status=4',
  6659. 'asArray' => true
  6660. ) );
  6661. $tijdate = $receiptLog->getOne ( array (
  6662. 'where' => 'rid=' . $rid . ' and status=2',
  6663. 'asc' => 'rlid',
  6664. 'asArray' => true
  6665. ) );
  6666. if (! empty ( $rlInfo )) {
  6667. $rlList = $receiptLog->find ( array (
  6668. 'where' => 'rid=' . $rid,
  6669. 'asc' => 'rlid',
  6670. 'asArray' => true
  6671. ) );
  6672. }
  6673. $receiptList [0] ['rlList'] = $rlList;
  6674. $enclosurList = $enclosur->find ( array (
  6675. 'where' => 'rid=' . $rid,
  6676. 'asArray' => true
  6677. ) );
  6678. $enclosurHtml = '';
  6679. foreach ( $enclosurList as $value ) {
  6680. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6681. }
  6682. $data ['enclosurHtml'] = $enclosurHtml;
  6683. $data ['rolename'] = $rolename ['name'];
  6684. $data ['datetij'] = $tijdate ['date'];
  6685. $data ['mothHtml'] = $mothHtml;
  6686. $data ['receiptList'] = $receiptList;
  6687. $data ['receiptApprovalCount'] = count ( $receiptList );
  6688. $data ['year'] = $year;
  6689. $data ['categoryList'] = $categoryList;
  6690. $data ['staffList'] = $staffList;
  6691. $data ['cid'] = $cid;
  6692. $data ['sid'] = $sid;
  6693. $data ['status'] = 0;
  6694. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  6695. $ap = 4;
  6696. } else
  6697. $data ['status'] = $receiptList [0] ['status'];
  6698. if ($receiptList [0] ['status'] == 4) {
  6699. $data ['status'] = 5;
  6700. $ap = 0;
  6701. }
  6702. $data ['ap'] = $ap;
  6703. $data ['memu'] = "receipt";
  6704. $data ['staff'] = $this->staff;
  6705. $data ['receiptMemu'] = 'approval';
  6706. $data ['verifyId'] = $this->verifyId;
  6707. $data ['executeId'] = $this->executeId;
  6708. $this->render ( "/admin/saeaReportListReport", $data );
  6709. }
  6710. function approvalEdi() {
  6711. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6712. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  6713. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6714. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6715. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6716. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6717. if (empty ( $status ))
  6718. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  6719. $vidList = array ();
  6720. $button = 0;
  6721. Doo::loadModel ( 'verify' );
  6722. Doo::loadModel ( 'receipt' );
  6723. Doo::loadModel ( 'staff' );
  6724. $staff = new staff ();
  6725. $receipt = new receipt ();
  6726. $verify = new verify ();
  6727. Doo::loadModel ( 'L_category' );
  6728. $Lcategory = new L_category ();
  6729. Doo::loadModel ( 'enclosur' );
  6730. $enclosur = new enclosur ();
  6731. // user verify ID
  6732. $verifyDetail = $verify->find ( array (
  6733. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6734. 'asArray' => true
  6735. ) );
  6736. foreach ( $verifyDetail as $key => $value ) {
  6737. array_push ( $vidList, $value ['vid'] );
  6738. }
  6739. $vid = implode ( ",", $vidList );
  6740. if (empty ( $verifyDetail ))
  6741. $vid = 0;
  6742. $categoryList = $Lcategory->find ( array (
  6743. 'asArray' => true
  6744. ) );
  6745. $staffList = $staff->find ( array (
  6746. 'where' => 'cid=' . $cid,
  6747. 'asArray' => true
  6748. ) );
  6749. $ap = "";
  6750. if ($status == 4) {
  6751. $ap = 4;
  6752. $status = 2;
  6753. }
  6754. // get Receipt By verifyID status 2
  6755. $receiptList = $receipt->find ( array (
  6756. 'where' => 'rid =' . $rid,
  6757. 'desc' => 'rid',
  6758. 'asArray' => true
  6759. ) );
  6760. $Locate = 0;
  6761. $roleId = 0;
  6762. if ($ap == 4)
  6763. $status = 4;
  6764. foreach ( $receiptList as $key => $value ) {
  6765. $receiptList [$key] ['Locate'] = $Locate;
  6766. $Locate ++;
  6767. $receiptList [$key] ['reviseDetail'] = array ();
  6768. if (! empty ( $value ['reviseDetail'] ))
  6769. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6770. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6771. $categoryDetil = $Lcategory->getOne ( array (
  6772. 'where' => 'cid=' . $value ['cid'],
  6773. 'asArray' => true
  6774. ) );
  6775. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6776. // 检测编辑状态
  6777. $verifyList = $verify->getOne ( array (
  6778. 'where' => 'vid=' . $value ['verify'],
  6779. 'asArray' => true
  6780. ) );
  6781. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6782. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6783. // print_r($verifyList);
  6784. //
  6785. // if (empty($verifyStaff)){
  6786. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6787. // $verifyList[0]['status']=4;$button=4;
  6788. // }
  6789. //
  6790. // }else{
  6791. //
  6792. // }
  6793. // die;
  6794. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  6795. // echo array_search("green",$a);
  6796. //
  6797. Doo::loadModel ( 'role' );
  6798. $role = new role ();
  6799. // print_r($verifyList);
  6800. $flag = true;
  6801. $roleKey = 0;
  6802. $endStaffArray = array ();
  6803. $roleArrayCopy = array ();
  6804. foreach ( $verifyList as $k => $v ) {
  6805. // init verifyStaff
  6806. if ($v [1] == 'ROLE') {
  6807. if (! empty ( $verifyStaff )) {
  6808. $endStaffArray = end ( $verifyStaff );
  6809. if ($v [0] == $endStaffArray ['nextStaff']) {
  6810. $roleId = $v [0];
  6811. }
  6812. }
  6813. $roleVerify = json_decode ( $v [3], true );
  6814. $roleKey = $k;
  6815. $roleArray = array ();
  6816. $rolename = $role->getOne ( array (
  6817. 'where' => 'rid=' . $v [0],
  6818. 'asArray' => true
  6819. ) );
  6820. foreach ( $roleVerify as $o => $p ) {
  6821. $staffID = explode ( '_', $p );
  6822. $staffInfo = $staff->getOne ( array (
  6823. 'where' => 'sid=' . $staffID [0],
  6824. 'asArray' => true
  6825. ) );
  6826. // print_r($staffID);
  6827. $exp = array (
  6828. 0 => $staffInfo ['sid'],
  6829. 1 => $staffID [1],
  6830. 2 => $staffInfo ['avatar'],
  6831. 'date' => '',
  6832. 'date' => '',
  6833. 'opinion' => '',
  6834. 'status' => '',
  6835. 'rolename' => $rolename ['name']
  6836. );
  6837. array_push ( $roleArray, $exp );
  6838. }
  6839. $roleArrayCopy [$v [0]] = $roleArray;
  6840. // $verifyList[$k]['roleArray']=$roleArray;
  6841. }
  6842. // print_r($roleArray);
  6843. $verifyList [$k] ['date'] = "";
  6844. $verifyList [$k] ['opinion'] = "";
  6845. $verifyList [$k] ['status'] = "";
  6846. if (empty ( $verifyStaff )) {
  6847. $verifyList [$k] ['date'] = "";
  6848. $verifyList [$k] ['opinion'] = "";
  6849. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6850. $verifyList [$k] ['status'] = 4;
  6851. $button = 4;
  6852. $flag = false;
  6853. }
  6854. } else {
  6855. foreach ( $verifyStaff as $m => $u ) {
  6856. if ($v [0] == $m) {
  6857. $verifyList [$k] ['date'] = $u ['date'];
  6858. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6859. $verifyList [$k] ['status'] = $u ['status'];
  6860. $flag = false;
  6861. break;
  6862. }
  6863. }
  6864. $endStaffArray = end ( $verifyStaff );
  6865. if (isset ( $endStaffArray ['ROLE'] )) {
  6866. } else {
  6867. $endKey = key ( $verifyStaff );
  6868. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6869. $button = 4;
  6870. $verifyList [$k] ['status'] = 4;
  6871. }
  6872. }
  6873. // print_r($endStaffArray);die;
  6874. // if (empty($verifyStaff)){
  6875. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6876. // $verifyList[$k]['status']=4;$button=4;
  6877. // }
  6878. //
  6879. // }else{
  6880. //
  6881. // }
  6882. // if($flag){//检测可编辑
  6883. // if($v[0]==$this->staff[0]['sid']){
  6884. // $verifyList[$k]['status']=4;$button=4;
  6885. // }
  6886. // }
  6887. }
  6888. }
  6889. $rolename ['name'] = '';
  6890. if (! empty ( $roleId )) {
  6891. Doo::loadModel ( 'role' );
  6892. $role = new role ();
  6893. $rolename = $role->getOne ( array (
  6894. 'where' => 'rid=' . $roleId,
  6895. 'asArray' => true
  6896. ) );
  6897. }
  6898. if (! empty ( $verifyStaff ))
  6899. $endStaffArray = end ( $verifyStaff );
  6900. $KOP = false;
  6901. foreach ( $roleArrayCopy as $P => $A ) {
  6902. foreach ( $A as $MKI => $AVL ) {
  6903. if (! empty ( $verifyStaff )) {
  6904. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6905. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6906. $button = 4;
  6907. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6908. }
  6909. foreach ( $verifyStaff as $m => $u ) {
  6910. $AVLFK = $AVL [0] . '_R';
  6911. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6912. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6913. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6914. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6915. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6916. break;
  6917. }
  6918. }
  6919. } else {
  6920. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6921. $button = 4;
  6922. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6923. }
  6924. }
  6925. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6926. $KOP = true;
  6927. }
  6928. }
  6929. // print_r($roleArrayCopy);
  6930. // echo $roleKey;
  6931. foreach ( $roleArrayCopy as $k => $v ) {
  6932. foreach ( $verifyList as $m => $n ) {
  6933. if ($n [0] == $k) {
  6934. array_splice ( $verifyList, $m, 1, $v );
  6935. }
  6936. }
  6937. }
  6938. // if ($KOP)
  6939. // array_splice($verifyList,$roleKey,1,$roleArray);
  6940. // print_r($verifyList);
  6941. $receiptList [$key] ['verifyList'] = $verifyList;
  6942. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6943. 'where' => 'sid=' . $value ['staff'],
  6944. 'asArray' => true
  6945. ) );
  6946. $receiptList [$key] ['button'] = $button;
  6947. }
  6948. // $data['verifyDetail']=$verifyDetail;
  6949. $mothHtml = "";
  6950. for($i = 1; $i <= 12; $i ++) {
  6951. if ($month == $i)
  6952. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6953. else
  6954. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6955. }
  6956. // 获取审批日志
  6957. Doo::loadModel ( 'receiptLog' );
  6958. $receiptLog = new receiptLog ();
  6959. $rlList = array ();
  6960. $rlInfo = $receiptLog->getOne ( array (
  6961. 'where' => 'rid=' . $rid . ' and status=4',
  6962. 'asArray' => true
  6963. ) );
  6964. $tijdate = $receiptLog->getOne ( array (
  6965. 'where' => 'rid=' . $rid . ' and status=2',
  6966. 'asc' => 'rlid',
  6967. 'asArray' => true
  6968. ) );
  6969. if (! empty ( $rlInfo )) {
  6970. $rlList = $receiptLog->find ( array (
  6971. 'where' => 'rid=' . $rid,
  6972. 'asc' => 'rlid',
  6973. 'asArray' => true
  6974. ) );
  6975. }
  6976. $receiptList [0] ['rlList'] = $rlList;
  6977. $enclosurList = $enclosur->find ( array (
  6978. 'where' => 'rid=' . $rid,
  6979. 'asArray' => true
  6980. ) );
  6981. $enclosurHtml = '';
  6982. foreach ( $enclosurList as $value ) {
  6983. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6984. }
  6985. $data ['enclosurHtml'] = $enclosurHtml;
  6986. $data ['rolename'] = $rolename ['name'];
  6987. $data ['datetij'] = $tijdate ['date'];
  6988. $data ['mothHtml'] = $mothHtml;
  6989. $data ['receiptList'] = $receiptList;
  6990. $data ['receiptApprovalCount'] = count ( $receiptList );
  6991. $data ['status'] = $status;
  6992. $data ['year'] = $year;
  6993. $data ['categoryList'] = $categoryList;
  6994. $data ['staffList'] = $staffList;
  6995. $data ['cid'] = $cid;
  6996. $data ['sid'] = $sid;
  6997. $data ['ap'] = $ap;
  6998. $data ['memu'] = "receipt";
  6999. $data ['staff'] = $this->staff;
  7000. $data ['receiptMemu'] = 'approval';
  7001. $data ['verifyId'] = $this->verifyId;
  7002. $data ['executeId'] = $this->executeId;
  7003. $this->render ( "/admin/saeaReportListReport", $data );
  7004. }
  7005. function remittanceHky() {
  7006. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7007. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  7008. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  7009. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  7010. $page_size = 15;
  7011. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  7012. Doo::loadModel ( 'receipt' );
  7013. $receipt = new receipt ();
  7014. Doo::loadModel ( 'staff' );
  7015. $staff = new staff ();
  7016. $dateCondition = " and Year(executeDate) =" . $year;
  7017. if ($moth != 'MONTH')
  7018. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  7019. if ($day != 'DAY' && $moth != 'MONTH')
  7020. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  7021. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  7022. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  7023. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  7024. $limit = $pageinfo ['lower'] . ',' . $page_size;
  7025. $dayList = $receipt->find ( array (
  7026. 'select' => 'executeDate,sum(amount) as amount',
  7027. 'where' => $sql,
  7028. 'desc' => 'executeDate',
  7029. 'groupby' => 'executeDate',
  7030. 'limit' => $limit,
  7031. 'asArray' => true
  7032. ) );
  7033. // print_r($dayList);
  7034. foreach ( $dayList as $key => $value ) {
  7035. $remitString = "";
  7036. $receiptList = $receipt->find ( array (
  7037. 'select' => 'rid,executeDate,amount,staff,cid',
  7038. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  7039. 'desc' => 'executeDate',
  7040. 'asArray' => true
  7041. ) );
  7042. foreach ( $receiptList as $k => $v ) {
  7043. $sinfo = $staff->getOne ( array (
  7044. 'select' => 'username,category',
  7045. 'where' => ' sid=' . $v ['staff'],
  7046. 'asArray' => true
  7047. ) );
  7048. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  7049. }
  7050. $dayList [$key] ['staff'] = $remitString;
  7051. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  7052. }
  7053. // print_r($dayList);
  7054. $mothHtml = "";
  7055. for($i = 1; $i <= 12; $i ++) {
  7056. if ($moth == $i)
  7057. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7058. else
  7059. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7060. }
  7061. $dayHtml = "";
  7062. if ($day != "DAY" || $moth != "MONTH") {
  7063. for($i = 1; $i <= 31; $i ++) {
  7064. if ($day == $i)
  7065. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  7066. else
  7067. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  7068. }
  7069. }
  7070. $dateHtml = "";
  7071. $now = date ( "Y" );
  7072. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  7073. if ($YEARD <= $now) {
  7074. $dateHtml .= '<option ';
  7075. if ($year == $YEARD) {
  7076. $dateHtml .= 'selected ';
  7077. }
  7078. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  7079. }
  7080. }
  7081. $data ['dateHtml'] = $dateHtml;
  7082. $data ['page'] = $pageinfo;
  7083. $data ['year'] = $year;
  7084. $data ['moth'] = $moth;
  7085. $data ['day'] = $day;
  7086. $data ['get'] = $get;
  7087. $data ['dayHtml'] = $dayHtml;
  7088. $data ['mothHtml'] = $mothHtml;
  7089. $data ['receiptList'] = $dayList;
  7090. $data ['memu'] = "receipt";
  7091. $data ['staff'] = $this->staff;
  7092. $data ['receiptMemu'] = 'remittanceHky';
  7093. $data ['verifyId'] = $this->verifyId;
  7094. $data ['executeId'] = $this->executeId;
  7095. $this->render ( "/admin/remittanceHky", $data );
  7096. }
  7097. function remittancep() {
  7098. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  7099. Doo::loadModel ( 'receipt' );
  7100. $receipt = new receipt ();
  7101. Doo::loadModel ( 'staff' );
  7102. $staff = new staff ();
  7103. Doo::loadClass ( 'XDeode' );
  7104. $XDeode = new XDeode ( 5 );
  7105. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  7106. $rplist = $receipt->find ( array (
  7107. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  7108. 'asArray' => true
  7109. ) );
  7110. $dayList = $receipt->find ( array (
  7111. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  7112. 'desc' => 'executeDate',
  7113. 'groupby' => 'staff',
  7114. 'asArray' => true
  7115. ) );
  7116. $html = '';
  7117. foreach ( $dayList as $key => $value ) {
  7118. $sinfo = $staff->getOne ( array (
  7119. 'select' => 'username,category',
  7120. 'where' => ' sid=' . $value ['staff'],
  7121. 'asArray' => true
  7122. ) );
  7123. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  7124. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  7125. $au = 0;
  7126. foreach ( $rplist as $k => $v ) {
  7127. if ($value ['staff'] == $v ['staff']) {
  7128. $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>';
  7129. $au += $v ['amount'];
  7130. }
  7131. }
  7132. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  7133. }
  7134. $data ['html'] = $html;
  7135. $data ['memu'] = "receipt";
  7136. $data ['staff'] = $this->staff;
  7137. $data ['receiptMemu'] = 'remittanceHky';
  7138. $data ['verifyId'] = $this->verifyId;
  7139. $data ['executeId'] = $this->executeId;
  7140. $this->render ( "/admin/remittancep", $data );
  7141. }
  7142. function ajaxGetReceiptDetails() {
  7143. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  7144. Doo::loadClass ( 'XDeode' );
  7145. $XDeode = new XDeode ( 5 );
  7146. $rid = $XDeode->decode ( $rid );
  7147. if (empty ( $rid )) {
  7148. echo json_encode ( array (
  7149. 'status' => 2,
  7150. 'msg' => 'illegal request'
  7151. ) );
  7152. die ();
  7153. }
  7154. Doo::loadModel ( 'receipt' );
  7155. $receipt = new receipt ();
  7156. Doo::loadModel ( 'staff' );
  7157. $staff = new staff ();
  7158. $rinfo = $receipt->getOne ( array (
  7159. 'where' => 'rid= ' . $rid,
  7160. 'asArray' => true
  7161. ) );
  7162. $sinfo = $staff->getOne ( array (
  7163. 'select' => 'username,category',
  7164. 'where' => ' sid=' . $rinfo ['staff'],
  7165. 'asArray' => true
  7166. ) );
  7167. $rinfo ['reviseDetail'] = array ();
  7168. if (! empty ( $rinfo ['reviseDetail'] ))
  7169. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  7170. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  7171. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  7172. $rinfo ['category'] = $sinfo ['category'];
  7173. $verifyStaff = array ();
  7174. if (! empty ( $rinfo ['verifyStaff'] ))
  7175. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  7176. $relust = bcsub ( $rinfo ['sum'], $rinfo ['loanSum'], 2 );
  7177. $rinfo ['relust'] = $relust;
  7178. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  7179. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  7180. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  7181. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  7182. // 费用执行人相关数据
  7183. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  7184. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  7185. foreach ( $executeCopy as $k => $v ) {
  7186. $executeCopy [$k] ['date'] = '';
  7187. $executeCopy [$k] ['opinion'] = '';
  7188. $executeCopy [$k] ['status'] = '';
  7189. if (! empty ( $executeStaff ))
  7190. foreach ( $executeStaff as $m => $u ) {
  7191. if ($v [0] == $m) {
  7192. $executeCopy [$k] ['date'] = $u ['date'];
  7193. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  7194. $executeCopy [$k] ['status'] = $u ['status'];
  7195. break;
  7196. }
  7197. }
  7198. }
  7199. $rinfo ['executeCopy'] = $executeCopy;
  7200. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  7201. if ($rinfo ['Rtype'] == 1) { // 借款费用
  7202. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  7203. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  7204. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  7205. $html .= '<tr><th>' . $value ['name'] . '</th>
  7206. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7207. }
  7208. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  7209. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  7210. <tr><th class="taC" colspan="2">费用说明</th>
  7211. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  7212. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  7213. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  7214. </tbody></table>';
  7215. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  7216. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  7217. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  7218. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  7219. $html .= '<tr><th>' . $value ['name'] . '</th>
  7220. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7221. }
  7222. $html .= '<tr><th class="taR">合计</th>
  7223. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  7224. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  7225. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  7226. $html .= '<tr><th>' . $value ['name'] . '</th>
  7227. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7228. }
  7229. $html .= '<tr><th class="taR">合计</th>
  7230. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  7231. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  7232. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  7233. $html .= '<tr><th>' . $value ['name'] . '</th>
  7234. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7235. }
  7236. $html .= '<tr><th class="taR">合计</th>
  7237. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  7238. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  7239. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  7240. $html .= '<tr><th>' . $value ['name'] . '</th>
  7241. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7242. }
  7243. $html .= '<tr><th class="taR">合计</th>
  7244. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  7245. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  7246. foreach ( $rinfo ['reviseDetail'] as $value ) {
  7247. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  7248. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  7249. }
  7250. $html .= '<tr><th class="taR">合计</th>
  7251. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  7252. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  7253. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  7254. <tr><th class="taC" colspan="2">报销说明</th></tr>
  7255. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  7256. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  7257. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  7258. <tr';
  7259. if ($rinfo ['relust'] >= 0) {
  7260. $html .= 'class="success"';
  7261. } else {
  7262. $html .= 'class="error"';
  7263. }
  7264. $html .= '><td class="taR"><b>借款结余</b></td>
  7265. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  7266. </tbody></table>
  7267. ';
  7268. }
  7269. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  7270. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  7271. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  7272. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  7273. $html .= '<tr><th>' . $value ['name'] . '</th>
  7274. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7275. }
  7276. $html .= '<tr><th class="taR">合计</th>
  7277. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  7278. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  7279. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  7280. <tr><th class="taC" colspan="2">费用说明</th>
  7281. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  7282. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  7283. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  7284. </tbody></table>';
  7285. } else {
  7286. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  7287. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  7288. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  7289. $html .= '<tr><th>' . $value ['name'] . '</th>
  7290. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7291. }
  7292. $html .= '<tr><th class="taR">合计</th>
  7293. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  7294. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  7295. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  7296. $html .= '<tr><th>' . $value ['name'] . '</th>
  7297. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7298. }
  7299. $html .= '<tr><th class="taR">合计</th>
  7300. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  7301. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  7302. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  7303. $html .= '<tr><th>' . $value ['name'] . '</th>
  7304. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7305. }
  7306. $html .= '<tr><th class="taR">合计</th>
  7307. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  7308. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  7309. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  7310. $html .= '<tr><th>' . $value ['name'] . '</th>
  7311. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7312. }
  7313. $html .= '<tr><th class="taR">合计</th>
  7314. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  7315. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  7316. foreach ( $rinfo ['reviseDetail'] as $value ) {
  7317. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  7318. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  7319. }
  7320. $html .= '<tr><th class="taR">合计</th>
  7321. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  7322. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  7323. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  7324. <tr><th class="taC" colspan="2">报销说明</th></tr>
  7325. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  7326. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  7327. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  7328. $html .= '</tbody></table>';
  7329. /*
  7330. * <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>
  7331. */
  7332. }
  7333. // print_r($verifyStaff);die;
  7334. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  7335. foreach ( $verifyStaff as $key => $value ) {
  7336. $key = trim ( strtr ( $key, '_R', ' ' ) );
  7337. $sinfo = $staff->getOne ( array (
  7338. 'select' => 'username',
  7339. 'where' => ' sid=' . $key,
  7340. 'asArray' => true
  7341. ) );
  7342. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  7343. }
  7344. $html .= '</tbody></table>';
  7345. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  7346. foreach ( $rinfo ['executeCopy'] as $value ) {
  7347. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  7348. }
  7349. $html .= '</tbody></table>';
  7350. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  7351. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  7352. </tr></table>';
  7353. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  7354. echo json_encode ( array (
  7355. 'status' => 1,
  7356. 'html' => $html
  7357. ) );
  7358. die ();
  7359. }
  7360. /**
  7361. * 删除附件
  7362. */
  7363. function ajaxRemEnclousur() {
  7364. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  7365. if (empty ( $key ))
  7366. echo json_encode ( array (
  7367. 'status' => 2
  7368. ) );
  7369. Doo::loadModel ( 'enclosur' );
  7370. $enclosur = new enclosur ();
  7371. $enclosur->delEnclosurByEid ( $key );
  7372. echo json_encode ( array (
  7373. 'status' => 1
  7374. ) );
  7375. }
  7376. function remittance() {
  7377. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7378. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7379. Doo::loadModel ( 'receipt' );
  7380. $receipt = new receipt ();
  7381. Doo::loadModel ( 'staff' );
  7382. $staff = new staff ();
  7383. $dateCondition = " and Year(pastDate) =" . $year;
  7384. if (! empty ( $month ))
  7385. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  7386. // get Receipt By verifyID status 1
  7387. $receiptList = $receipt->find ( array (
  7388. 'select' => 'sum(sum) as sum,staff,pastDate',
  7389. 'where' => ' status=1' . $dateCondition,
  7390. 'desc' => 'pastDate',
  7391. 'groupby' => 'staff,pastDate',
  7392. 'asArray' => true
  7393. ) );
  7394. $dateList = $receipt->find ( array (
  7395. 'select' => 'pastDate,verifyStaff',
  7396. 'where' => ' status=1' . $dateCondition,
  7397. 'desc' => 'pastDate',
  7398. 'groupby' => 'pastDate',
  7399. 'asArray' => true
  7400. ) );
  7401. $dataList = array ();
  7402. foreach ( $dateList as $d => $a ) {
  7403. $dataList [$a ['pastDate']] = array ();
  7404. $daySum = 0;
  7405. foreach ( $receiptList as $key => $value ) {
  7406. if ($a ['pastDate'] == $value ['pastDate']) {
  7407. $oderList = $receipt->find ( array (
  7408. 'select' => 'receiptOrder',
  7409. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  7410. 'asArray' => true
  7411. ) );
  7412. $list = array ();
  7413. $html = "";
  7414. foreach ( $oderList as $v ) {
  7415. array_push ( $list, $v ['receiptOrder'] );
  7416. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  7417. }
  7418. $receiptList [$key] ['receiptOrder'] = $html;
  7419. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  7420. $sinfo = $staff->getOne ( array (
  7421. 'select' => 'username ',
  7422. 'where' => ' sid=' . $value ['staff'],
  7423. 'asArray' => true
  7424. ) );
  7425. $receiptList [$key] ['username'] = $sinfo ['username'];
  7426. $daySum += $value ['sum'];
  7427. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  7428. }
  7429. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  7430. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  7431. }
  7432. }
  7433. // print_r($dataList);
  7434. $data ['dataList'] = $dataList;
  7435. $mothHtml = "";
  7436. for($i = 1; $i <= 12; $i ++) {
  7437. if ($month == $i)
  7438. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7439. else
  7440. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7441. }
  7442. $data ['year'] = $year;
  7443. $data ['mothHtml'] = $mothHtml;
  7444. $data ['memu'] = "receipt";
  7445. $data ['staff'] = $this->staff;
  7446. $data ['receiptMemu'] = 'approval';
  7447. $data ['verifyId'] = $this->verifyId;
  7448. $data ['executeId'] = $this->executeId;
  7449. $this->render ( "/admin/saeaReportListPay", $data );
  7450. }
  7451. /**
  7452. * 金额调整,提高稳定性
  7453. * @return string
  7454. */
  7455. function revocationAdjustment() {
  7456. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  7457. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  7458. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  7459. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  7460. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey ) && (! empty ( $reviseKey )))) {
  7461. Doo::loadClass ( 'XDeode' );
  7462. $XDeode = new XDeode ( 5 );
  7463. Doo::loadModel ( 'receipt' );
  7464. $receipt = new receipt ();
  7465. $sid = $XDeode->decode ( $sidKey );
  7466. $rid = $XDeode->decode ( $ridKey );
  7467. $reviseKey = $XDeode->decode ( $reviseKey );
  7468. if (! is_numeric ( $sid ) && ! is_numeric ( $rid ) && ! is_numeric ( $reviseKey ))
  7469. die ( 'illegal request' );
  7470. $receiptDetail = $receipt->getOne ( array (
  7471. 'where' => 'rid=' . $rid,
  7472. 'asArray' => true
  7473. ) );
  7474. if (empty ( $receiptDetail ) || empty ( $receiptDetail ['reviseDetail'] ))
  7475. die ( 'illegal request' );
  7476. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7477. if (! isset ( $reviseDetail [$reviseKey] ))
  7478. die ( 'illegal request' );
  7479. if ($reviseDetail [$reviseKey] ['sid'] == $sid && $reviseDetail [$reviseKey] ['price'] == $price)
  7480. unset ( $reviseDetail [$reviseKey] );
  7481. $revisePrice = 0;
  7482. foreach ( $reviseDetail as $key => $value ) {
  7483. $revisePrice += $value ['price'];
  7484. }
  7485. $reviseDetailString = json_encode ( $reviseDetail );
  7486. $receipt->reviseDetail = $reviseDetailString;
  7487. $receipt->sum = $receiptDetail ['sum'] - $price;
  7488. $receipt->revisePrice = $revisePrice;
  7489. $receipt->update ( array (
  7490. 'where' => 'rid=' . $rid
  7491. ) );
  7492. return '/receiptburEdi/' . $rid;
  7493. } else
  7494. die ( 'illegal request2' );
  7495. }
  7496. function updateApprovalReceipt() {
  7497. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7498. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  7499. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7500. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  7501. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  7502. if (! empty ( $rid )) {
  7503. Doo::loadModel ( "verify" );
  7504. $verify = new verify ();
  7505. Doo::loadModel ( "receiptDetail" );
  7506. $receiptDetailObj = new receiptDetail ();
  7507. Doo::loadModel ( "itemStatistics" );
  7508. Doo::loadModel ( "statistics" );
  7509. $statistics = new statistics ();
  7510. $itemStatistics = new itemStatistics ();
  7511. Doo::loadModel ( "receipt" );
  7512. $receipt = new receipt ();
  7513. $receiptDetail = $receipt->getOne ( array (
  7514. 'where' => 'rid=' . $rid . ' and status=2 ',
  7515. 'asArray' => true
  7516. ) );
  7517. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  7518. $nsflag = true;
  7519. foreach ( $nslist as $value ) {
  7520. if ($value == $this->staff ['0'] ['sid']) {
  7521. $nsflag = false;
  7522. break;
  7523. }
  7524. }
  7525. if (empty ( $receiptDetail ) || $nsflag)
  7526. return "/approval";
  7527. $verifyDetail = $verify->getOne ( array (
  7528. 'where' => ' vid =' . $receiptDetail ['verify'],
  7529. 'asArray' => true
  7530. ) );
  7531. $verifyString = $verifyDetail ['staff'];
  7532. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  7533. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  7534. if (empty ( $opinion )) {
  7535. if ($status == 3)
  7536. $opinion = "终止";
  7537. else
  7538. $opinion = "同意支付";
  7539. }
  7540. $nowStaff = 0;
  7541. $nowStaffList = array ();
  7542. if (empty ( $verifyStaff )) {
  7543. // 还需加入是否已经进入角色审批
  7544. if ($verifyDetail [0] [1] == 'ROLE') {
  7545. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  7546. foreach ( $vStaffString as $key => $value ) {
  7547. $staffK = explode ( "_", $value );
  7548. if ($staffK [0] != $this->staff [0] ['sid'])
  7549. array_push ( $nowStaffList, $staffK [0] );
  7550. }
  7551. // print_r($verifyDetail);
  7552. // die;
  7553. if (! empty ( $nowStaffList )) {
  7554. $nowStaff = implode ( ',', $nowStaffList );
  7555. $verifyStaff = array (
  7556. $this->staff [0] ['sid'] . "_R" => array (
  7557. 'date' => date ( 'Y-m-d' ),
  7558. 'opinion' => $opinion,
  7559. 'status' => $status,
  7560. 'nextStaff' => $verifyDetail [0] [0],
  7561. 'ROLE' => 1
  7562. )
  7563. );
  7564. } else {
  7565. $nowStaff = $verifyDetail [1] [0];
  7566. $verifyStaff = array (
  7567. $this->staff [0] ['sid'] . "_R" => array (
  7568. 'date' => date ( 'Y-m-d' ),
  7569. 'opinion' => $opinion,
  7570. 'status' => $status,
  7571. 'nextStaff' => $verifyDetail [1] [0]
  7572. )
  7573. );
  7574. }
  7575. } else {
  7576. if ($verifyDetail [1] [1] == 'ROLE') {
  7577. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  7578. // echo "dd";
  7579. foreach ( $vStaffString as $key => $value ) {
  7580. $staffK = explode ( "_", $value );
  7581. array_push ( $nowStaffList, $staffK [0] );
  7582. }
  7583. $nowStaff = implode ( ',', $nowStaffList );
  7584. $verifyStaff = array (
  7585. $this->staff [0] ['sid'] => array (
  7586. 'date' => date ( 'Y-m-d' ),
  7587. 'opinion' => $opinion,
  7588. 'status' => $status,
  7589. 'nextStaff' => $verifyDetail [1] [0],
  7590. 'ROLE' => 1
  7591. )
  7592. );
  7593. } else {
  7594. $nowStaff = $verifyDetail [1] [0];
  7595. $verifyStaff = array (
  7596. $this->staff [0] ['sid'] => array (
  7597. 'date' => date ( 'Y-m-d' ),
  7598. 'opinion' => $opinion,
  7599. 'status' => $status,
  7600. 'nextStaff' => $verifyDetail [1] [0]
  7601. )
  7602. );
  7603. }
  7604. }
  7605. if ($status == 3)
  7606. $verifyStaff = array (
  7607. 'final' => $status,
  7608. $this->staff [0] ['sid'] => array (
  7609. 'date' => date ( 'Y-m-d' ),
  7610. 'opinion' => $opinion,
  7611. 'status' => $status
  7612. )
  7613. );
  7614. $vStaffString = json_encode ( $verifyStaff );
  7615. $receipt->nowStaff = $nowStaff;
  7616. $receipt->verifyStaff = $vStaffString;
  7617. } else {
  7618. $VS = end ( $verifyStaff );
  7619. // 非角色审批
  7620. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  7621. $nextStaff = 0;
  7622. $roleSTF = false;
  7623. foreach ( $verifyDetail as $key => $value ) {
  7624. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  7625. if (isset ( $verifyDetail [$key + 1] )) {
  7626. $nextStaff = $verifyDetail [$key + 1] [0];
  7627. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  7628. $roleSTF = true;
  7629. }
  7630. break;
  7631. }
  7632. }
  7633. if (! $roleSTF) {
  7634. $nowStaff = $nextStaff;
  7635. $verifyStaff [$this->staff [0] ['sid']] = array (
  7636. 'date' => date ( 'Y-m-d' ),
  7637. 'opinion' => $opinion,
  7638. 'status' => $status,
  7639. 'nextStaff' => $nextStaff
  7640. );
  7641. } else {
  7642. // 获取角色下的所有用户ID
  7643. $nowStaffList = array ();
  7644. foreach ( $verifyDetail as $vfk ) {
  7645. if ($vfk [1] == 'ROLE') {
  7646. $vStaffString = json_decode ( $vfk [3] );
  7647. foreach ( $vStaffString as $key => $value ) {
  7648. $staffK = explode ( "_", $value );
  7649. array_push ( $nowStaffList, $staffK [0] );
  7650. }
  7651. }
  7652. }
  7653. $nowStaff = implode ( ',', $nowStaffList );
  7654. $verifyStaff [$this->staff [0] ['sid']] = array (
  7655. 'date' => date ( 'Y-m-d' ),
  7656. 'opinion' => $opinion,
  7657. 'status' => $status,
  7658. 'nextStaff' => $nextStaff,
  7659. 'ROLE' => 0
  7660. );
  7661. }
  7662. if ($status == 3) {
  7663. $verifyStaff ['final'] = $status;
  7664. $verifyStaff [$this->staff [0] ['sid']] = array (
  7665. 'date' => date ( 'Y-m-d' ),
  7666. 'opinion' => $opinion,
  7667. 'status' => $status
  7668. );
  7669. }
  7670. $vStaffString = json_encode ( $verifyStaff );
  7671. $receipt->nowStaff = $nowStaff;
  7672. $receipt->verifyStaff = $vStaffString;
  7673. }
  7674. // 角色审批
  7675. if (isset ( $VS ['ROLE'] )) {
  7676. // 找出角色人 当前审批角色组
  7677. $verifyJSStaff = array ();
  7678. $nowStaffList2 = array ();
  7679. foreach ( $verifyDetail as $key => $value ) {
  7680. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  7681. $verifyJSStaff = json_decode ( $value [3] );
  7682. foreach ( $verifyJSStaff as $m ) {
  7683. $staffK = explode ( "_", $m );
  7684. array_push ( $nowStaffList2, $staffK [0] );
  7685. }
  7686. // print_r($nowStaffList2);
  7687. }
  7688. }
  7689. $RoleVerifyStaff = array ();
  7690. foreach ( $verifyStaff as $key => $value ) {
  7691. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  7692. foreach ( $nowStaffList2 as $m ) {
  7693. if ($key == $m . "_R")
  7694. $RoleVerifyStaff [$key] = $value;
  7695. }
  7696. }
  7697. }
  7698. // print_r($verifyStaff);
  7699. // print_r($nowStaffList2);
  7700. // print_r($RoleVerifyStaff);
  7701. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  7702. // print_r($verifyJSStaff);
  7703. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  7704. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  7705. // 下一个审批人ID
  7706. $nextStaff = 0;
  7707. $falg = false;
  7708. foreach ( $verifyDetail as $key => $value ) {
  7709. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  7710. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  7711. $falg = true;
  7712. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  7713. $nowStaffList = array ();
  7714. foreach ( $vStaffString as $v ) {
  7715. $staffK = explode ( "_", $v );
  7716. array_push ( $nowStaffList, $staffK [0] );
  7717. }
  7718. $nowStaff = implode ( ',', $nowStaffList );
  7719. $nextStaff = $verifyDetail [$key + 1] [0];
  7720. } elseif (isset ( $verifyDetail [$key + 1] )) {
  7721. $nextStaff = $verifyDetail [$key + 1] [0];
  7722. $nowStaff = $nextStaff;
  7723. } else
  7724. $nowStaff = '';
  7725. break;
  7726. }
  7727. }
  7728. if ($falg)
  7729. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7730. 'date' => date ( 'Y-m-d' ),
  7731. 'opinion' => $opinion,
  7732. 'status' => $status,
  7733. 'nextStaff' => $nextStaff,
  7734. 'ROLE' => 1
  7735. );
  7736. else
  7737. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7738. 'date' => date ( 'Y-m-d' ),
  7739. 'opinion' => $opinion,
  7740. 'status' => $status,
  7741. 'nextStaff' => $nextStaff
  7742. );
  7743. // print_r($verifyStaff);
  7744. // echo $nowStaff;die;
  7745. } else { // 进入下一个角色或者审批人
  7746. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  7747. //
  7748. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  7749. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7750. 'date' => date ( 'Y-m-d' ),
  7751. 'opinion' => $opinion,
  7752. 'status' => $status,
  7753. 'nextStaff' => $VS ['nextStaff'],
  7754. 'ROLE' => 1
  7755. );
  7756. // print_r($verifyStaff);
  7757. // die;
  7758. }
  7759. if ($status == 3) {
  7760. $verifyStaff ['final'] = $status;
  7761. $verifyStaff [$this->staff [0] ['sid']] = array (
  7762. 'date' => date ( 'Y-m-d' ),
  7763. 'opinion' => $opinion,
  7764. 'status' => $status
  7765. );
  7766. }
  7767. $vStaffString = json_encode ( $verifyStaff );
  7768. $receipt->verifyStaff = $vStaffString;
  7769. $receipt->nowStaff = $nowStaff;
  7770. // die;
  7771. // }
  7772. // print_r($verifyStaff);
  7773. // die;
  7774. }
  7775. // print_r($verifyStaff);die;
  7776. }
  7777. // print_r($verifyDetail);
  7778. $roleKey = 0;
  7779. $roleId = 0;
  7780. $verifyDetailCopy = array ();
  7781. foreach ( $verifyDetail as $k => $v ) {
  7782. if ($v [1] == 'ROLE') {
  7783. $roleId = $v [0];
  7784. $roleVerify = json_decode ( $v [3], true );
  7785. $roleKey = $k;
  7786. $roleArray = array ();
  7787. foreach ( $roleVerify as $o => $p ) {
  7788. $staffID = explode ( '_', $p );
  7789. $exp = array (
  7790. 0 => $staffID [0],
  7791. 1 => $staffID [1]
  7792. );
  7793. array_push ( $roleArray, $exp );
  7794. }
  7795. $verifyDetailCopy [$v [0]] = $roleArray;
  7796. }
  7797. }
  7798. // print_r($verifyDetail);
  7799. foreach ( $verifyDetailCopy as $k => $v ) {
  7800. foreach ( $verifyDetail as $m => $n ) {
  7801. if ($n [0] == $k) {
  7802. array_splice ( $verifyDetail, $m, 1, $v );
  7803. }
  7804. }
  7805. }
  7806. // die;
  7807. // if (!empty($roleArray))
  7808. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  7809. // echo $roleId;
  7810. // print_r($verifyStaff);
  7811. // print_r($verifyDetail);
  7812. // die;
  7813. Doo::loadModel ( "receiptLog" );
  7814. $receiptLog = new receiptLog ();
  7815. // 审批日志
  7816. if (! isset ( $verifyStaff ['final'] )) {
  7817. if (! empty ( $roleId )) {
  7818. Doo::loadModel ( "role" );
  7819. $role = new role ();
  7820. $roleInfo = $role->getOne ( array (
  7821. 'where' => 'rid=' . $roleId,
  7822. 'asArray' => true
  7823. ) );
  7824. $receiptLog->rolename = $roleInfo ['name'];
  7825. }
  7826. $receiptLog->username = $this->staff [0] ['username'];
  7827. $receiptLog->uid = $this->staff [0] ['sid'];
  7828. $receiptLog->date = date ( "Y-m-d" );
  7829. $receiptLog->opinion = $opinion;
  7830. $receiptLog->img = $this->staff [0] ['avatar'];
  7831. $receiptLog->status = 1;
  7832. $receiptLog->rid = $rid;
  7833. $receiptLog->insert ();
  7834. }
  7835. if (isset ( $verifyStaff ['final'] )) { // rDetail
  7836. $receipt->verifyBreakup = $verifyString;
  7837. $receipt->status = 3;
  7838. $receiptDetailObj->status = 3;
  7839. $receiptDetailObj->update ( array (
  7840. 'where' => 'rid=' . $rid
  7841. ) );
  7842. if (! empty ( $roleId )) {
  7843. Doo::loadModel ( "role" );
  7844. $role = new role ();
  7845. $roleInfo = $role->getOne ( array (
  7846. 'where' => 'rid=' . $roleId,
  7847. 'asArray' => true
  7848. ) );
  7849. $receiptLog->rolename = $roleInfo ['name'];
  7850. }
  7851. $receiptLog->username = $this->staff [0] ['username'];
  7852. $receiptLog->uid = $this->staff [0] ['sid'];
  7853. $receiptLog->date = date ( "Y-m-d" );
  7854. $receiptLog->opinion = $opinion;
  7855. $receiptLog->img = $this->staff [0] ['avatar'];
  7856. $receiptLog->status = 3;
  7857. $receiptLog->rid = $rid;
  7858. $receiptLog->insert ();
  7859. // 微信企业号通知
  7860. $this->setWXMsg ( $rid, 3 );
  7861. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  7862. $receipt->status = 1;
  7863. $reviseSum = 0;
  7864. $receipt->verifyBreakup = $verifyString;
  7865. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  7866. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7867. foreach ( $reviseDetail as $key => $value ) {
  7868. $receiptDetailObj = new receiptDetail ();
  7869. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7870. $receiptDetailObj->item = $value ['description'];
  7871. $receiptDetailObj->itemCategory = "报销金额调整";
  7872. $receiptDetailObj->price = $value ['price'];
  7873. $receiptDetailObj->date = $receiptDetail ['date'];
  7874. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  7875. $receiptDetailObj->rid = $rid;
  7876. $receiptDetailObj->status = 1;
  7877. $receiptDetailObj->insert ();
  7878. $reviseSum += $value ['price'];
  7879. }
  7880. $itemStatistics = new itemStatistics ();
  7881. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7882. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7883. $itemStatistics->price = $reviseSum;
  7884. $itemStatistics->itemCategory = "报销金额调整";
  7885. $itemStatistics->date = $receiptDetail ['date'];
  7886. $itemStatistics->insert ();
  7887. }
  7888. $receiptDetailObj = new receiptDetail ();
  7889. $receiptDetailObj->status = 1;
  7890. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  7891. $receiptDetailObj->update ( array (
  7892. 'where' => 'rid=' . $rid
  7893. ) );
  7894. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7895. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7896. $stat = $statistics->getOne ( array (
  7897. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  7898. 'asArray' => true
  7899. ) );
  7900. if (empty ( $stat )) {
  7901. $statistics->date = $receiptDetail ['date'];
  7902. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7903. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7904. $statistics->agPrice = $receiptDetail ['sum'];
  7905. $statistics->rePrice = $reviseSum;
  7906. $statistics->insert ();
  7907. } else {
  7908. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  7909. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  7910. $statistics->update ( array (
  7911. 'where' => 'sid=' . $stat ['sid']
  7912. ) );
  7913. }
  7914. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7915. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7916. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  7917. foreach ( $accountItem ['cSum'] as $key => $value ) {
  7918. if ($key == "agencySum") {
  7919. $iStatistics = $itemStatistics->getOne ( array (
  7920. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  7921. 'asArray' => true
  7922. ) );
  7923. if (empty ( $iStatistics )) {
  7924. $itemStatistics->cid = $receiptDetail ['cid'];
  7925. ;
  7926. $itemStatistics->staff = $receiptDetail ['staff'];
  7927. $itemStatistics->price = $value;
  7928. $itemStatistics->itemCategory = $this->AGENCY;
  7929. $itemStatistics->date = $receiptDetail ['date'];
  7930. $itemStatistics->insert ();
  7931. } else {
  7932. if (! empty ( $value )) {
  7933. $itemStatistics->price = $value + $iStatistics ['price'];
  7934. $itemStatistics->update ( array (
  7935. 'where' => 'sid=' . $iStatistics ['sid']
  7936. ) );
  7937. }
  7938. }
  7939. } elseif ($key == "travelSum") {
  7940. $iStatistics = $itemStatistics->getOne ( array (
  7941. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  7942. 'asArray' => true
  7943. ) );
  7944. if (empty ( $iStatistics )) {
  7945. $itemStatistics->cid = $receiptDetail ['cid'];
  7946. $itemStatistics->staff = $receiptDetail ['staff'];
  7947. $itemStatistics->price = $value;
  7948. $itemStatistics->itemCategory = $this->TRAVEL;
  7949. $itemStatistics->date = $receiptDetail ['date'];
  7950. $itemStatistics->insert ();
  7951. } else {
  7952. if (! empty ( $value )) {
  7953. $itemStatistics->price = $value + $iStatistics ['price'];
  7954. $itemStatistics->update ( array (
  7955. 'where' => 'sid=' . $iStatistics ['sid']
  7956. ) );
  7957. }
  7958. }
  7959. } elseif ($key == "trainSum") {
  7960. $iStatistics = $itemStatistics->getOne ( array (
  7961. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  7962. 'asArray' => true
  7963. ) );
  7964. if (empty ( $iStatistics )) {
  7965. $itemStatistics->cid = $receiptDetail ['cid'];
  7966. $itemStatistics->staff = $receiptDetail ['staff'];
  7967. $itemStatistics->price = $value;
  7968. $itemStatistics->itemCategory = $this->TRAIN;
  7969. $itemStatistics->date = $receiptDetail ['date'];
  7970. $itemStatistics->insert ();
  7971. } else {
  7972. if (! empty ( $value )) {
  7973. $itemStatistics->price = $value + $iStatistics ['price'];
  7974. $itemStatistics->update ( array (
  7975. 'where' => 'sid=' . $iStatistics ['sid']
  7976. ) );
  7977. }
  7978. }
  7979. } elseif ($key == "otherSum") {
  7980. $iStatistics = $itemStatistics->getOne ( array (
  7981. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  7982. 'asArray' => true
  7983. ) );
  7984. if (empty ( $iStatistics )) {
  7985. $itemStatistics->cid = $receiptDetail ['cid'];
  7986. $itemStatistics->staff = $receiptDetail ['staff'];
  7987. $itemStatistics->price = $value;
  7988. $itemStatistics->itemCategory = $this->OTHER;
  7989. $itemStatistics->date = $receiptDetail ['date'];
  7990. $itemStatistics->insert ();
  7991. } else {
  7992. if (! empty ( $value )) {
  7993. $itemStatistics->price = $value + $iStatistics ['price'];
  7994. $itemStatistics->update ( array (
  7995. 'where' => 'sid=' . $iStatistics ['sid']
  7996. ) );
  7997. }
  7998. }
  7999. }
  8000. }
  8001. $receipt->pastDate = date ( "Y-m-d" );
  8002. // 微信企业号通知
  8003. $this->setWXMsg ( $rid, 1 );
  8004. }
  8005. $receipt->amount = $amount;
  8006. $receipt->update ( array (
  8007. 'where' => ' rid = ' . $rid
  8008. ) );
  8009. // 进入下一条审批费用新加需求
  8010. $vidList = array ();
  8011. $verifyDetail = $verify->find ( array (
  8012. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  8013. 'asArray' => true
  8014. ) );
  8015. foreach ( $verifyDetail as $key => $value ) {
  8016. array_push ( $vidList, $value ['vid'] );
  8017. }
  8018. $vid = implode ( ",", $vidList );
  8019. if (empty ( $verifyDetail ))
  8020. $vid = 0;
  8021. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  8022. $receipt = new receipt ();
  8023. $rd = $receipt->getOne ( array (
  8024. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  8025. 'asc' => 'rid',
  8026. 'asArray' => true
  8027. ) );
  8028. if (empty ( $rd )) {
  8029. return '/approvalExpenses/pendApproval';
  8030. }
  8031. if ($rd ['Rtype'] == 1) {
  8032. if ($rd ['isBK'] == 1) {
  8033. return '/receiptburEdi/' . $rd ['rid'];
  8034. } else {
  8035. return '/expensesEdi/' . $rd ['rid'];
  8036. }
  8037. } elseif ($rd ['Rtype'] == 2) {
  8038. return '/remitApproval/' . $rd ['rid'];
  8039. } else {
  8040. return '/receiptburEdi/' . $rd ['rid'];
  8041. }
  8042. // return "/approvalExpenses/pendApproval";
  8043. }
  8044. }
  8045. function expensesRetreats() {
  8046. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  8047. if (! empty ( $rid )) {
  8048. // 操作记录
  8049. Doo::loadModel ( "receipt" );
  8050. $receipt = new receipt ();
  8051. Doo::loadModel ( "receiptLog" );
  8052. $receiptLog = new receiptLog ();
  8053. Doo::loadModel ( "verify" );
  8054. $verify = new verify ();
  8055. $receiptInfo = $receipt->getOne ( array (
  8056. 'where' => 'rid=' . $rid,
  8057. 'asArray' => true
  8058. ) );
  8059. $vr = $verify->getOne ( array (
  8060. 'where' => 'vid=' . $receiptInfo ['verify'],
  8061. 'asArray' => true
  8062. ) );
  8063. $jd = json_decode ( $vr ['staff'] );
  8064. $roleId = 0;
  8065. foreach ( $jd as $key => $value ) {
  8066. if ($value [1] == 'ROLE') {
  8067. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  8068. if ($pos !== false) {
  8069. $roleId = $value [0];
  8070. }
  8071. }
  8072. }
  8073. // 审批日志
  8074. // echo $roleId;die;
  8075. if (! empty ( $roleId )) {
  8076. Doo::loadModel ( "role" );
  8077. $role = new role ();
  8078. $roleInfo = $role->getOne ( array (
  8079. 'where' => 'rid=' . $roleId,
  8080. 'asArray' => true
  8081. ) );
  8082. $receiptLog->rolename = $roleInfo ['name'];
  8083. }
  8084. $receiptLog->username = $this->staff [0] ['username'];
  8085. $receiptLog->uid = $this->staff [0] ['sid'];
  8086. $receiptLog->date = date ( "Y-m-d" );
  8087. $receiptLog->opinion = '撤回';
  8088. $receiptLog->img = $this->staff [0] ['avatar'];
  8089. $receiptLog->status = 4;
  8090. $receiptLog->rid = $rid;
  8091. $receiptLog->insert ();
  8092. $receipt->status = 4;
  8093. $receipt->update ( array (
  8094. 'where' => 'rid=' . $rid
  8095. ) );
  8096. // 微信企业号通知
  8097. $this->setWXMsg ( $rid, 2 );
  8098. }
  8099. // echo "ddd";
  8100. return '/approvalExpenses/pendApproval';
  8101. }
  8102. function updateCheReceipt() {
  8103. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  8104. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  8105. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  8106. if (! empty ( $rid )) {
  8107. // 操作记录
  8108. Doo::loadModel ( "receipt" );
  8109. $receipt = new receipt ();
  8110. Doo::loadModel ( "receiptLog" );
  8111. $receiptLog = new receiptLog ();
  8112. Doo::loadModel ( "verify" );
  8113. $verify = new verify ();
  8114. $receiptInfo = $receipt->getOne ( array (
  8115. 'where' => 'rid=' . $rid . ' and status=2',
  8116. 'asArray' => true
  8117. ) );
  8118. if (empty ( $receiptInfo )) {
  8119. echo json_encode ( array (
  8120. 'status' => 2
  8121. ) );
  8122. die ();
  8123. }
  8124. $vr = $verify->getOne ( array (
  8125. 'where' => 'vid=' . $receiptInfo ['verify'],
  8126. 'asArray' => true
  8127. ) );
  8128. $jd = json_decode ( $vr ['staff'] );
  8129. $roleId = 0;
  8130. foreach ( $jd as $key => $value ) {
  8131. if ($value [1] == 'ROLE') {
  8132. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  8133. if ($pos !== false) {
  8134. $roleId = $value [0];
  8135. }
  8136. }
  8137. }
  8138. // 审批日志
  8139. // echo $roleId;die;
  8140. if (! empty ( $roleId )) {
  8141. Doo::loadModel ( "role" );
  8142. $role = new role ();
  8143. $roleInfo = $role->getOne ( array (
  8144. 'where' => 'rid=' . $roleId,
  8145. 'asArray' => true
  8146. ) );
  8147. $receiptLog->rolename = $roleInfo ['name'];
  8148. }
  8149. $receiptLog->username = $this->staff [0] ['username'];
  8150. $receiptLog->uid = $this->staff [0] ['sid'];
  8151. $receiptLog->date = date ( "Y-m-d" );
  8152. $receiptLog->opinion = $opinion;
  8153. $receiptLog->img = $this->staff [0] ['avatar'];
  8154. $receiptLog->status = 4;
  8155. $receiptLog->rid = $rid;
  8156. $receiptLog->insert ();
  8157. $receipt->status = 4;
  8158. $receipt->update ( array (
  8159. 'where' => 'rid=' . $rid
  8160. ) );
  8161. // 微信企业号通知
  8162. $this->setWXMsg ( $rid, 2 );
  8163. echo json_encode ( array (
  8164. 'status' => 1
  8165. ) );
  8166. // Header("HTTP/1.1 303 See Other");
  8167. // Header("Location: /approvalExpenses/pendApproval");
  8168. die ();
  8169. }
  8170. echo json_encode ( array (
  8171. 'status' => 2
  8172. ) );
  8173. die ();
  8174. // echo "ddd";
  8175. // return '/saeaBorad';
  8176. }
  8177. function revisePrice() {
  8178. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  8179. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  8180. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  8181. // echo $price;die;
  8182. if (! empty ( $rid )) {
  8183. Doo::loadModel ( "receipt" );
  8184. $receipt = new receipt ();
  8185. $receiptDetail = $receipt->getOne ( array (
  8186. 'where' => 'rid=' . $rid . ' and status=2 ',
  8187. 'asArray' => true
  8188. ) );
  8189. if (empty ( $receiptDetail ))
  8190. die ( 'illegal request' );
  8191. $reviseDetail = array ();
  8192. if (empty ( $receiptDetail ['reviseDetail'] )) {
  8193. array_push ( $reviseDetail, array (
  8194. 'sid' => $this->staff [0] ['sid'],
  8195. 'name' => $this->staff [0] ['username'],
  8196. 'description' => $description,
  8197. 'price' => $price
  8198. ) );
  8199. $reviseDetailString = json_encode ( $reviseDetail );
  8200. $receipt->reviseDetail = $reviseDetailString;
  8201. $receipt->revisePrice = $price;
  8202. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  8203. } else {
  8204. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8205. array_push ( $reviseDetail, array (
  8206. 'sid' => $this->staff [0] ['sid'],
  8207. 'name' => $this->staff [0] ['username'],
  8208. 'description' => $description,
  8209. 'price' => $price
  8210. ) );
  8211. $reviseDetailString = json_encode ( $reviseDetail );
  8212. $receipt->reviseDetail = $reviseDetailString;
  8213. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  8214. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  8215. }
  8216. $receipt->update ( array (
  8217. 'where' => 'rid=' . $rid
  8218. ) );
  8219. if ($receiptDetail ['Rtype'] == 1) {
  8220. if ($receiptDetail ['isBK'] == 1) {
  8221. return '/receiptburEdi/' . $receiptDetail ['rid'];
  8222. }
  8223. } elseif ($receiptDetail ['Rtype'] == 2) {
  8224. } else {
  8225. return '/receiptburEdi/' . $receiptDetail ['rid'];
  8226. }
  8227. }
  8228. die ( 'illegal request' );
  8229. }
  8230. function personalCollect() {
  8231. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8232. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  8233. $this->showCache ( $path );
  8234. Doo::loadModel ( "receiptDetail" );
  8235. Doo::loadModel ( "itemStatistics" );
  8236. Doo::loadModel ( 'statistics' );
  8237. $statistics = new statistics ();
  8238. $itemStatistics = new itemStatistics ();
  8239. $receiptDetail = new receiptDetail ();
  8240. $receiptCollectList = $receiptDetail->find ( array (
  8241. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  8242. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  8243. 'groupby' => 'itemCategory,Month(date)',
  8244. 'asArray' => true
  8245. ) );
  8246. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  8247. 'where' => 'staff=' . $this->staff [0] ['sid'],
  8248. 'asArray' => true
  8249. ) );
  8250. // create collect html
  8251. $collectArray = array (
  8252. '日常相关费用' => array (),
  8253. '差旅相关费用' => array (),
  8254. '培训班费用' => array (),
  8255. '其他' => array ()
  8256. );
  8257. $adjustment = array ();
  8258. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  8259. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  8260. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  8261. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  8262. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  8263. array_push ( $collectArray ['培训班费用'], $collectHtml );
  8264. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  8265. array_push ( $collectArray ['其他'], $collectHtml );
  8266. $data ['collectArray'] = $collectArray;
  8267. // statistics html
  8268. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  8269. if (empty ( $stList ))
  8270. $stList = array (
  8271. 'rePrice' => 0,
  8272. 'agPrice' => 0
  8273. );
  8274. $data ['stList'] = array (
  8275. 'rePrice' => $stList ['rePrice'],
  8276. 'agPrice' => $stList ['agPrice'],
  8277. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8278. );
  8279. // Adjustment price html
  8280. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  8281. array_push ( $adjustment, $collectHtml );
  8282. $data ['adjustment'] = $adjustment;
  8283. // total price html
  8284. $collectHtml = "";
  8285. $total = 0;
  8286. for($i = 1; $i <= 12; $i ++) {
  8287. $sumPrice = 0;
  8288. foreach ( $receiptCollectList as $key => $value ) {
  8289. if ($value ['month'] == $i) {
  8290. $sumPrice += $value ['price'];
  8291. }
  8292. }
  8293. if ($sumPrice == 0)
  8294. $collectHtml .= '<td class="taR">-</td>';
  8295. else
  8296. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8297. $total += $sumPrice;
  8298. }
  8299. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8300. $data ['totalPrice'] = $collectHtml;
  8301. $dateHtml = "";
  8302. $now = date ( "Y" );
  8303. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  8304. if ($YEARD <= $now) {
  8305. $dateHtml .= '<option ';
  8306. if ($year == $YEARD) {
  8307. $dateHtml .= 'selected ';
  8308. }
  8309. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  8310. }
  8311. }
  8312. $data ['dateHtml'] = $dateHtml;
  8313. $data ['year'] = $year;
  8314. $data ['totalYear'] = $total;
  8315. $data ['memu'] = "receipt";
  8316. $data ['staff'] = $this->staff;
  8317. $data ['receiptMemu'] = 'personalCollect';
  8318. $data ['verifyId'] = $this->verifyId;
  8319. $data ['executeId'] = $this->executeId;
  8320. // year staff status 2,4
  8321. if ($year < date ( "Y" )) {
  8322. Doo::loadModel ( 'receipt' );
  8323. $receipt = new receipt ();
  8324. $receiptList = $receipt->find ( array (
  8325. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  8326. 'asArray' => true
  8327. ) );
  8328. if (empty ( $receiptList )) {
  8329. ob_start ();
  8330. $this->render ( "/admin/saea_slist_collect", $data );
  8331. $this->cacheFile ( $path );
  8332. die ();
  8333. }
  8334. }
  8335. $this->render ( "/admin/saea_slist_collect", $data );
  8336. }
  8337. function personalCollectDetail() {
  8338. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8339. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  8340. $this->showCache ( $path );
  8341. Doo::loadModel ( "receiptDetail" );
  8342. Doo::loadModel ( "itemStatistics" );
  8343. Doo::loadModel ( 'statistics' );
  8344. Doo::loadModel ( 'accountItem' );
  8345. $accountItem = new accountItem ();
  8346. $statistics = new statistics ();
  8347. $itemStatistics = new itemStatistics ();
  8348. $receiptDetail = new receiptDetail ();
  8349. $receiptCollectList = $receiptDetail->find ( array (
  8350. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  8351. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  8352. 'groupby' => 'item,Month(date)',
  8353. 'asArray' => true
  8354. ) );
  8355. $accountList = $accountItem->find ( array (
  8356. 'asArray' => true
  8357. ) );
  8358. // create CollectDetail HTML
  8359. $collectHtml = array ();
  8360. foreach ( $accountList as $key => $value ) {
  8361. $html = "";
  8362. $asum = 0;
  8363. for($i = 1; $i <= 12; $i ++) {
  8364. $falg = true;
  8365. foreach ( $receiptCollectList as $v ) {
  8366. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  8367. $asum += $v ['price'];
  8368. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8369. $falg = false;
  8370. break;
  8371. }
  8372. }
  8373. if ($falg)
  8374. $html .= '<td class="taR">-</td>';
  8375. }
  8376. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8377. $collectHtml [$value ['category']] [$value ['name']] = $html;
  8378. }
  8379. $data ['collectHtml'] = $collectHtml;
  8380. // create Adjustment price html
  8381. $receiptCollectList = $receiptDetail->find ( array (
  8382. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  8383. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  8384. 'groupby' => 'itemCategory,Month(date)',
  8385. 'asArray' => true
  8386. ) );
  8387. $adjustment = array ();
  8388. $collectArray = array (
  8389. '日常相关费用' => array (),
  8390. '差旅相关费用' => array (),
  8391. '培训班费用' => array (),
  8392. '其他' => array ()
  8393. );
  8394. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  8395. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  8396. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  8397. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  8398. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  8399. array_push ( $collectArray ['培训班费用'], $collectHtml );
  8400. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  8401. array_push ( $collectArray ['其他'], $collectHtml );
  8402. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  8403. array_push ( $adjustment, $collectHtml );
  8404. // total price html
  8405. $collectHtml = "";
  8406. $total = 0;
  8407. for($i = 1; $i <= 12; $i ++) {
  8408. $sumPrice = 0;
  8409. foreach ( $receiptCollectList as $key => $value ) {
  8410. if ($value ['month'] == $i) {
  8411. $sumPrice += $value ['price'];
  8412. }
  8413. }
  8414. if ($sumPrice == 0)
  8415. $collectHtml .= '<td class="taR">-</td>';
  8416. else
  8417. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8418. $total += $sumPrice;
  8419. }
  8420. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8421. // statistics html
  8422. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  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. $data ['collectArray'] = $collectArray;
  8434. $data ['adjustment'] = $adjustment;
  8435. $data ['totalPrice'] = $collectHtml;
  8436. $data ['totalYear'] = $total;
  8437. $data ['year'] = $year;
  8438. $dateHtml = "";
  8439. $now = date ( "Y" );
  8440. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  8441. if ($YEARD <= $now) {
  8442. $dateHtml .= '<option ';
  8443. if ($year == $YEARD) {
  8444. $dateHtml .= 'selected ';
  8445. }
  8446. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  8447. }
  8448. }
  8449. $data ['dateHtml'] = $dateHtml;
  8450. $data ['memu'] = "receipt";
  8451. $data ['staff'] = $this->staff;
  8452. $data ['receiptMemu'] = 'personalCollect';
  8453. $data ['verifyId'] = $this->verifyId;
  8454. $data ['executeId'] = $this->executeId;
  8455. // year staff status 2,4
  8456. if ($year < date ( "Y" )) {
  8457. Doo::loadModel ( 'receipt' );
  8458. $receipt = new receipt ();
  8459. $receiptList = $receipt->find ( array (
  8460. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  8461. 'asArray' => true
  8462. ) );
  8463. if (empty ( $receiptList )) {
  8464. ob_start ();
  8465. $this->render ( "/admin/saeaCollectArticles", $data );
  8466. $this->cacheFile ( $path );
  8467. die ();
  8468. }
  8469. }
  8470. $this->render ( "/admin/saeaCollectArticles", $data );
  8471. }
  8472. function companyCategoryCollect() {
  8473. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8474. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  8475. $this->showCache ( $path );
  8476. Doo::loadModel ( 'L_category' );
  8477. Doo::loadModel ( 'itemStatistics' );
  8478. Doo::loadModel ( 'statistics' );
  8479. $statistics = new statistics ();
  8480. $Lcategory = new L_category ();
  8481. $itemStatistics = new itemStatistics ();
  8482. Doo::loadModel ( "receiptAuthorityManage" );
  8483. $receiptAuthorityManage = new receiptAuthorityManage ();
  8484. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  8485. $cidList = array ();
  8486. foreach ( $imcStaff as $key => $value ) {
  8487. array_push ( $cidList, $value ['cid'] );
  8488. }
  8489. $cidString = implode ( ',', $cidList );
  8490. $LcategoryList = $Lcategory->find ( array (
  8491. 'where' => ' cid in (' . $cidString . ')',
  8492. 'asArray' => true
  8493. ) ); // 'staff='.$this->staff[0]['sid']." and
  8494. $itemStatisticsList = $itemStatistics->find ( array (
  8495. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8496. 'where' => " Year(date)=" . $year,
  8497. 'groupby' => 'cid,Month(date)',
  8498. 'asArray' => true
  8499. ) );
  8500. // ceatre companyCollectHtml
  8501. foreach ( $LcategoryList as $value ) {
  8502. $html = "";
  8503. $asum = 0;
  8504. for($i = 1; $i <= 12; $i ++) {
  8505. $falg = true;
  8506. foreach ( $itemStatisticsList as $v ) {
  8507. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  8508. $asum += $v ['price'];
  8509. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8510. $falg = false;
  8511. break;
  8512. }
  8513. }
  8514. if ($falg)
  8515. $html .= '<td class="taR">-</td>';
  8516. }
  8517. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8518. $collectHtml [$value ['title']] = array (
  8519. 'html' => $html,
  8520. 'cid' => $value ['cid']
  8521. );
  8522. }
  8523. $data ['companyHtml'] = $collectHtml;
  8524. // total price html
  8525. $collectHtml = "";
  8526. $total = 0;
  8527. for($i = 1; $i <= 12; $i ++) {
  8528. $sumPrice = 0;
  8529. foreach ( $itemStatisticsList as $key => $value ) {
  8530. if ($value ['month'] == $i) {
  8531. $sumPrice += $value ['price'];
  8532. }
  8533. }
  8534. if ($sumPrice == 0)
  8535. $collectHtml .= '<td class="taR">-</td>';
  8536. else
  8537. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8538. $total += $sumPrice;
  8539. }
  8540. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8541. $data ['companyTotalHtml'] = $collectHtml;
  8542. $data ['total'] = $total;
  8543. // statistics html
  8544. // echo $cidString;
  8545. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  8546. if (empty ( $stList ))
  8547. $stList = array (
  8548. 'rePrice' => 0,
  8549. 'agPrice' => 0
  8550. );
  8551. $data ['stList'] = array (
  8552. 'rePrice' => $stList ['rePrice'],
  8553. 'agPrice' => $stList ['agPrice'],
  8554. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8555. );
  8556. $data ['year'] = $year;
  8557. $data ['memu'] = "receipt";
  8558. $data ['staff'] = $this->staff;
  8559. $data ['receiptMemu'] = 'companyCategoryCollect';
  8560. $data ['verifyId'] = $this->verifyId;
  8561. $data ['executeId'] = $this->executeId;
  8562. $dateHtml = "";
  8563. $now = date ( "Y" );
  8564. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  8565. if ($YEARD <= $now) {
  8566. $dateHtml .= '<option ';
  8567. if ($year == $YEARD) {
  8568. $dateHtml .= 'selected ';
  8569. }
  8570. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  8571. }
  8572. }
  8573. $data ['dateHtml'] = $dateHtml;
  8574. // year staff status 2,4
  8575. if ($year < date ( "Y" )) {
  8576. Doo::loadModel ( 'receipt' );
  8577. $receipt = new receipt ();
  8578. $receiptList = $receipt->find ( array (
  8579. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  8580. 'asArray' => true
  8581. ) );
  8582. if (empty ( $receiptList )) {
  8583. ob_start ();
  8584. $this->render ( "/admin/saeaCompanyCollect", $data );
  8585. $this->cacheFile ( $path );
  8586. die ();
  8587. }
  8588. }
  8589. $this->render ( "/admin/saeaCompanyCollect", $data );
  8590. }
  8591. function categoryCollectDetail() {
  8592. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8593. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  8594. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  8595. $this->showCache ( $path );
  8596. Doo::loadModel ( 'statistics' );
  8597. $statistics = new statistics ();
  8598. Doo::loadModel ( "receiptDetail" );
  8599. $receiptDetail = new receiptDetail ();
  8600. Doo::loadModel ( 'L_category' );
  8601. $Lcategory = new L_category ();
  8602. Doo::loadModel ( 'accountItem' );
  8603. $accountItem = new accountItem ();
  8604. Doo::loadModel ( "receiptAuthorityManage" );
  8605. $receiptAuthorityManage = new receiptAuthorityManage ();
  8606. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  8607. $cidList = array ();
  8608. foreach ( $imcStaff as $key => $value ) {
  8609. array_push ( $cidList, $value ['cid'] );
  8610. }
  8611. $cidString = implode ( ',', $cidList );
  8612. $LcategoryList = $Lcategory->find ( array (
  8613. 'where' => 'cid in (' . $cidString . ')',
  8614. 'asArray' => true
  8615. ) );
  8616. if ($cid == 0) {
  8617. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  8618. if ($cid == 0)
  8619. $cid = $LcategoryList [0] ['cid'];
  8620. }
  8621. $data ['LcategoryList'] = $LcategoryList;
  8622. $receiptCollectList = $receiptDetail->find ( array (
  8623. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8624. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  8625. 'groupby' => 'item,Month(pastDate)',
  8626. 'asArray' => true
  8627. ) );
  8628. $accountList = $accountItem->find ( array (
  8629. 'asArray' => true
  8630. ) );
  8631. // create CollectDetail HTML
  8632. $collectHtml = array ();
  8633. foreach ( $accountList as $key => $value ) {
  8634. $html = "";
  8635. $asum = 0;
  8636. for($i = 1; $i <= 12; $i ++) {
  8637. $falg = true;
  8638. foreach ( $receiptCollectList as $v ) {
  8639. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  8640. $asum += $v ['price'];
  8641. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8642. $falg = false;
  8643. break;
  8644. }
  8645. }
  8646. if ($falg)
  8647. $html .= '<td class="taR">-</td>';
  8648. }
  8649. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8650. $collectHtml [$value ['category']] [$value ['name']] = $html;
  8651. }
  8652. $data ['collectHtml'] = $collectHtml;
  8653. // create Adjustment price html
  8654. $receiptCollectList = $receiptDetail->find ( array (
  8655. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  8656. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  8657. 'groupby' => 'itemCategory,Month(pastDate)',
  8658. 'asArray' => true
  8659. ) );
  8660. $adjustment = array ();
  8661. $collectArray = array (
  8662. '日常相关费用' => array (),
  8663. '差旅相关费用' => array (),
  8664. '培训班费用' => array (),
  8665. '其他' => array ()
  8666. );
  8667. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  8668. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  8669. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  8670. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  8671. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  8672. array_push ( $collectArray ['培训班费用'], $collectHtml );
  8673. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  8674. array_push ( $collectArray ['其他'], $collectHtml );
  8675. $data ['collectArray'] = $collectArray;
  8676. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  8677. array_push ( $adjustment, $collectHtml );
  8678. $data ['adjustment'] = $adjustment;
  8679. // total price html
  8680. $collectHtml = "";
  8681. $total = 0;
  8682. for($i = 1; $i <= 12; $i ++) {
  8683. $sumPrice = 0;
  8684. foreach ( $receiptCollectList as $key => $value ) {
  8685. if ($value ['month'] == $i) {
  8686. $sumPrice += $value ['price'];
  8687. }
  8688. }
  8689. if ($sumPrice == 0)
  8690. $collectHtml .= '<td class="taR">-</td>';
  8691. else
  8692. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8693. $total += $sumPrice;
  8694. }
  8695. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8696. // statistics html
  8697. $stList = $statistics->statisticsByCid ( $year, $cid );
  8698. if (empty ( $stList ))
  8699. $stList = array (
  8700. 'rePrice' => 0,
  8701. 'agPrice' => 0
  8702. );
  8703. $data ['stList'] = array (
  8704. 'rePrice' => $stList ['rePrice'],
  8705. 'agPrice' => $stList ['agPrice'],
  8706. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8707. );
  8708. $data ['totalYear'] = $total;
  8709. $data ['year'] = $year;
  8710. $data ['cid'] = $cid;
  8711. $data ['memu'] = "receipt";
  8712. $data ['staff'] = $this->staff;
  8713. $data ['receiptMemu'] = 'companyCategoryCollect';
  8714. $data ['verifyId'] = $this->verifyId;
  8715. $data ['executeId'] = $this->executeId;
  8716. // year staff status 2,4
  8717. if ($year < date ( "Y" )) {
  8718. Doo::loadModel ( 'receipt' );
  8719. $receipt = new receipt ();
  8720. $receiptList = $receipt->find ( array (
  8721. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  8722. 'asArray' => true
  8723. ) );
  8724. if (empty ( $receiptList )) {
  8725. ob_start ();
  8726. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  8727. $this->cacheFile ( $path );
  8728. die ();
  8729. }
  8730. }
  8731. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  8732. }
  8733. function staffCollect() {
  8734. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8735. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  8736. // $this->showCache($path);
  8737. Doo::loadModel ( 'statistics' );
  8738. $statistics = new statistics ();
  8739. Doo::loadModel ( "receiptDetail" );
  8740. $receiptDetail = new receiptDetail ();
  8741. Doo::loadModel ( 'L_category' );
  8742. $Lcategory = new L_category ();
  8743. Doo::loadModel ( 'accountItem' );
  8744. $accountItem = new accountItem ();
  8745. Doo::loadModel ( 'staff' );
  8746. $staff = new staff ();
  8747. Doo::loadModel ( 'itemStatistics' );
  8748. $itemStatistics = new itemStatistics ();
  8749. Doo::loadModel ( "receiptAuthorityManage" );
  8750. $receiptAuthorityManage = new receiptAuthorityManage ();
  8751. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  8752. $cidList = array ();
  8753. foreach ( $imcStaff as $key => $value ) {
  8754. array_push ( $cidList, $value ['cid'] );
  8755. }
  8756. $cidString = implode ( ',', $cidList );
  8757. // statistics html
  8758. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  8759. if (empty ( $stList ))
  8760. $stList = array (
  8761. 'rePrice' => 0,
  8762. 'agPrice' => 0
  8763. );
  8764. $data ['stList'] = array (
  8765. 'rePrice' => $stList ['rePrice'],
  8766. 'agPrice' => $stList ['agPrice'],
  8767. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8768. );
  8769. // ---
  8770. $staffList = $staff->find ( array (
  8771. 'where' => 'username !="admin"',
  8772. 'asArray' => true
  8773. ) );
  8774. $LcategoryList = $Lcategory->find ( array (
  8775. 'asArray' => true
  8776. ) ); // 'staff='.$this->staff[0]['sid']." and
  8777. $itemStatisticsList = $itemStatistics->find ( array (
  8778. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8779. 'where' => " Year(date)=" . $year . ' and cid in (' . $cidString . ')',
  8780. 'groupby' => 'staff,Month(date)',
  8781. 'asArray' => true
  8782. ) );
  8783. $categoryList = $staff->find ( array (
  8784. 'select' => 'COUNT(*) as count,cid,category',
  8785. 'where' => 'username !="admin" and cid in (' . $cidString . ')',
  8786. 'groupby' => 'cid',
  8787. 'asArray' => true
  8788. ) );
  8789. // print_r($itemStatisticsList);die;
  8790. // ceatre companyCollectHtml
  8791. foreach ( $categoryList as $vlu ) {
  8792. $count = $vlu ['count'] + 1;
  8793. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  8794. $m1 = 0;
  8795. $m2 = 0;
  8796. $m3 = 0;
  8797. $m4 = 0;
  8798. $m5 = 0;
  8799. $m6 = 0;
  8800. $m7 = 0;
  8801. $m8 = 0;
  8802. $m9 = 0;
  8803. $m10 = 0;
  8804. $m11 = 0;
  8805. $m12 = 0;
  8806. $m13 = 0;
  8807. foreach ( $staffList as $value ) {
  8808. if ($vlu ['cid'] == $value ['cid']) {
  8809. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  8810. $asum = 0;
  8811. for($i = 1; $i <= 12; $i ++) {
  8812. $falg = true;
  8813. foreach ( $itemStatisticsList as $v ) {
  8814. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  8815. if ($v ['month'] == 1)
  8816. $m1 += $v ['price'];
  8817. if ($v ['month'] == 2)
  8818. $m2 += $v ['price'];
  8819. if ($v ['month'] == 3)
  8820. $m3 += $v ['price'];
  8821. if ($v ['month'] == 4)
  8822. $m4 += $v ['price'];
  8823. if ($v ['month'] == 5)
  8824. $m5 += $v ['price'];
  8825. if ($v ['month'] == 6)
  8826. $m6 += $v ['price'];
  8827. if ($v ['month'] == 7)
  8828. $m7 += $v ['price'];
  8829. if ($v ['month'] == 8)
  8830. $m8 += $v ['price'];
  8831. if ($v ['month'] == 9)
  8832. $m9 += $v ['price'];
  8833. if ($v ['month'] == 10)
  8834. $m10 += $v ['price'];
  8835. if ($v ['month'] == 11)
  8836. $m11 += $v ['price'];
  8837. if ($v ['month'] == 12)
  8838. $m12 += $v ['price'];
  8839. $asum += $v ['price'];
  8840. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8841. $falg = false;
  8842. break;
  8843. }
  8844. }
  8845. if ($falg)
  8846. $html .= '<td class="taR">-</td>';
  8847. }
  8848. $m13 += $asum;
  8849. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8850. $collectHtml [$value ['username'] . '_' . $value ['sid']] = array (
  8851. 'html' => $html,
  8852. 'sid' => $value ['sid']
  8853. );
  8854. $html = "";
  8855. }
  8856. }
  8857. $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>
  8858. <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>
  8859. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  8860. $collectHtml [$vlu ['cid']] = array (
  8861. 'html' => $hl,
  8862. 'sid' => ''
  8863. );
  8864. }
  8865. $data ['companyHtml'] = $collectHtml;
  8866. // total price html
  8867. $collectHtml = "";
  8868. $total = 0;
  8869. for($i = 1; $i <= 12; $i ++) {
  8870. $sumPrice = 0;
  8871. foreach ( $itemStatisticsList as $key => $value ) {
  8872. if ($value ['month'] == $i) {
  8873. $sumPrice += $value ['price'];
  8874. }
  8875. }
  8876. if ($sumPrice == 0)
  8877. $collectHtml .= '<td class="taR">-</td>';
  8878. else
  8879. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8880. $total += $sumPrice;
  8881. }
  8882. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8883. $data ['companyTotalHtml'] = $collectHtml;
  8884. $data ['total'] = $total;
  8885. $data ['year'] = $year;
  8886. $data ['memu'] = "receipt";
  8887. $data ['staff'] = $this->staff;
  8888. $data ['receiptMemu'] = 'companyCategoryCollect';
  8889. $data ['verifyId'] = $this->verifyId;
  8890. $data ['executeId'] = $this->executeId;
  8891. if ($year <= date ( "Y" )) {
  8892. Doo::loadModel ( 'receipt' );
  8893. $receipt = new receipt ();
  8894. $receiptList = $receipt->find ( array (
  8895. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  8896. 'asArray' => true
  8897. ) );
  8898. if (empty ( $receiptList )) { // generated files
  8899. ob_start ();
  8900. $this->render ( "/admin/saeaStaffCollectB", $data );
  8901. $this->cacheFile ( $path );
  8902. die ();
  8903. }
  8904. }
  8905. $this->render ( "/admin/saeaStaffCollectB", $data );
  8906. }
  8907. function staffCollectBak() {
  8908. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8909. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  8910. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  8911. $this->showCache ( $path );
  8912. Doo::loadModel ( 'statistics' );
  8913. $statistics = new statistics ();
  8914. Doo::loadModel ( "receiptDetail" );
  8915. $receiptDetail = new receiptDetail ();
  8916. Doo::loadModel ( 'L_category' );
  8917. $Lcategory = new L_category ();
  8918. Doo::loadModel ( 'accountItem' );
  8919. $accountItem = new accountItem ();
  8920. Doo::loadModel ( 'staff' );
  8921. $staff = new staff ();
  8922. Doo::loadModel ( 'itemStatistics' );
  8923. $itemStatistics = new itemStatistics ();
  8924. $itemStatisticsList = $itemStatistics->find ( array (
  8925. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8926. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8927. 'groupby' => 'staff,itemCategory,Month(date)',
  8928. 'asArray' => true
  8929. ) );
  8930. $itemCategoryList = $itemStatistics->find ( array (
  8931. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8932. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8933. 'groupby' => 'cid,itemCategory,Month(date)',
  8934. 'asArray' => true
  8935. ) );
  8936. $LcategoryList = $Lcategory->find ( array (
  8937. 'asArray' => true
  8938. ) );
  8939. $staffList = $staff->find ( array (
  8940. 'asArray' => true
  8941. ) );
  8942. $htmlArray = array ();
  8943. foreach ( $LcategoryList as $value ) {
  8944. $htmlArray [$value ['title']] = array ();
  8945. foreach ( $staffList as $v ) {
  8946. if ($value ['cid'] == $v ['cid']) {
  8947. $html = "";
  8948. $falg = true;
  8949. $staffSumPrice = 0;
  8950. foreach ( $itemStatisticsList as $a ) {
  8951. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  8952. if (empty ( $a ['price'] )) {
  8953. $html .= '<td class="taR">-</td>';
  8954. $falg = false;
  8955. break;
  8956. } else {
  8957. $staffSumPrice += $a ['price'];
  8958. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8959. $falg = false;
  8960. break;
  8961. }
  8962. }
  8963. }
  8964. if ($falg) {
  8965. $html .= '<td class="taR">-</td>';
  8966. $falg = true;
  8967. }
  8968. $falg = true;
  8969. foreach ( $itemStatisticsList as $a ) {
  8970. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  8971. if (empty ( $a ['price'] )) {
  8972. $html .= '<td class="taR">-</td>';
  8973. $falg = false;
  8974. break;
  8975. } else {
  8976. $staffSumPrice += $a ['price'];
  8977. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8978. $falg = false;
  8979. break;
  8980. }
  8981. }
  8982. }
  8983. if ($falg) {
  8984. $html .= '<td class="taR">-</td>';
  8985. $falg = true;
  8986. }
  8987. $falg = true;
  8988. foreach ( $itemStatisticsList as $a ) {
  8989. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  8990. if (empty ( $a ['price'] )) {
  8991. $html .= '<td class="taR">-</td>';
  8992. $falg = false;
  8993. break;
  8994. } else {
  8995. $staffSumPrice += $a ['price'];
  8996. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8997. $falg = false;
  8998. break;
  8999. }
  9000. }
  9001. }
  9002. if ($falg) {
  9003. $html .= '<td class="taR">-</td>';
  9004. $falg = true;
  9005. }
  9006. $falg = true;
  9007. foreach ( $itemStatisticsList as $a ) {
  9008. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  9009. if (! empty ( $a ['price'] )) {
  9010. $staffSumPrice += $a ['price'];
  9011. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9012. $falg = false;
  9013. break;
  9014. } else {
  9015. $html .= '<td class="taR">-</td>';
  9016. $falg = false;
  9017. break;
  9018. }
  9019. }
  9020. }
  9021. if ($falg) {
  9022. $html .= '<td class="taR">-</td>';
  9023. $falg = true;
  9024. }
  9025. $falg = true;
  9026. foreach ( $itemStatisticsList as $a ) {
  9027. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  9028. if (! empty ( $a ['price'] )) {
  9029. $staffSumPrice += $a ['price'];
  9030. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9031. $falg = false;
  9032. break;
  9033. } else {
  9034. $html .= '<td class="taR">-</td>';
  9035. $falg = false;
  9036. break;
  9037. }
  9038. }
  9039. }
  9040. if ($falg) {
  9041. $html .= '<td class="taR">-</td>';
  9042. $falg = true;
  9043. }
  9044. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  9045. $htmlArray [$value ['title']] [$v ['username']] = $html;
  9046. }
  9047. }
  9048. /* -- --- */
  9049. // 合计费用
  9050. $cateHtml = "";
  9051. $catePrice = 0;
  9052. $cateFalg = true;
  9053. foreach ( $itemCategoryList as $l ) {
  9054. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  9055. if (empty ( $l ['price'] )) {
  9056. $cateHtml .= '<td class="colGreen taR">-</td>';
  9057. $cateFalg = false;
  9058. break;
  9059. } else {
  9060. $catePrice += $l ['price'];
  9061. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  9062. $cateFalg = false;
  9063. break;
  9064. }
  9065. }
  9066. }
  9067. if ($cateFalg) {
  9068. $cateHtml .= '<td class="colGreen taR">-</td>';
  9069. $cateFalg = true;
  9070. }
  9071. $cateFalg = true;
  9072. foreach ( $itemCategoryList as $l ) {
  9073. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  9074. if (empty ( $l ['price'] )) {
  9075. $cateHtml .= '<td class="colGreen taR">-</td>';
  9076. $cateFalg = false;
  9077. break;
  9078. } else {
  9079. $catePrice += $l ['price'];
  9080. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  9081. $cateFalg = false;
  9082. break;
  9083. }
  9084. }
  9085. }
  9086. if ($cateFalg) {
  9087. $cateHtml .= '<td class="colGreen taR">-</td>';
  9088. $cateFalg = true;
  9089. }
  9090. $cateFalg = true;
  9091. foreach ( $itemCategoryList as $l ) {
  9092. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  9093. if (empty ( $l ['price'] )) {
  9094. $cateHtml .= '<td class="colGreen taR">-</td>';
  9095. $cateFalg = false;
  9096. break;
  9097. } else {
  9098. $catePrice += $l ['price'];
  9099. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  9100. $cateFalg = false;
  9101. break;
  9102. }
  9103. }
  9104. }
  9105. if ($cateFalg) {
  9106. $cateHtml .= '<td class="colGreen taR">-</td>';
  9107. $cateFalg = true;
  9108. }
  9109. $cateFalg = true;
  9110. foreach ( $itemCategoryList as $l ) {
  9111. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  9112. if (empty ( $l ['price'] )) {
  9113. $cateHtml .= '<td class="colGreen taR">-</td>';
  9114. $cateFalg = false;
  9115. break;
  9116. } else {
  9117. $catePrice += $l ['price'];
  9118. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  9119. $cateFalg = false;
  9120. break;
  9121. }
  9122. }
  9123. }
  9124. if ($cateFalg) {
  9125. $cateHtml .= '<td class="colGreen taR">-</td>';
  9126. $cateFalg = true;
  9127. }
  9128. $cateFalg = true;
  9129. foreach ( $itemCategoryList as $l ) {
  9130. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  9131. if (empty ( $l ['price'] )) {
  9132. $cateHtml .= '<td class="colGreen taR">-</td>';
  9133. $cateFalg = false;
  9134. break;
  9135. } else {
  9136. $catePrice += $l ['price'];
  9137. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  9138. $cateFalg = false;
  9139. break;
  9140. }
  9141. }
  9142. }
  9143. if ($cateFalg) {
  9144. $cateHtml .= '<td class="colGreen taR">-</td>';
  9145. $cateFalg = true;
  9146. }
  9147. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  9148. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  9149. /* -- --- */
  9150. }
  9151. // print_r($htmlArray);die;
  9152. $data ['htmlArray'] = $htmlArray;
  9153. // statistics html
  9154. $stList = $statistics->getOne ( array (
  9155. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9156. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9157. 'groupby' => 'Month(date)',
  9158. 'asArray' => true
  9159. ) );
  9160. if (empty ( $stList ))
  9161. $stList = array (
  9162. 'rePrice' => 0,
  9163. 'agPrice' => 0
  9164. );
  9165. $data ['stList'] = array (
  9166. 'rePrice' => $stList ['rePrice'],
  9167. 'agPrice' => $stList ['agPrice'],
  9168. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9169. );
  9170. $monthHtml = "";
  9171. for($i = 1; $i <= 12; $i ++) {
  9172. if ($i == $month)
  9173. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9174. else
  9175. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9176. }
  9177. $data ['monthHtml'] = $monthHtml;
  9178. $data ['year'] = $year;
  9179. $data ['month'] = $month;
  9180. $data ['memu'] = "receipt";
  9181. $data ['staff'] = $this->staff;
  9182. $data ['receiptMemu'] = 'companyCategoryCollect';
  9183. $data ['verifyId'] = $this->verifyId;
  9184. $data ['executeId'] = $this->executeId;
  9185. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  9186. Doo::loadModel ( 'receipt' );
  9187. $receipt = new receipt ();
  9188. $receiptList = $receipt->find ( array (
  9189. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  9190. 'asArray' => true
  9191. ) );
  9192. if (empty ( $receiptList )) { // generated files
  9193. ob_start ();
  9194. $this->render ( "/admin/saeaStaffCollect", $data );
  9195. $this->cacheFile ( $path );
  9196. die ();
  9197. }
  9198. }
  9199. $this->render ( "/admin/saeaStaffCollect", $data );
  9200. }
  9201. /**
  9202. * 日常收支
  9203. */
  9204. function payments() {
  9205. // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  9206. Doo::loadModel ( "execute" );
  9207. $execute = new execute ();
  9208. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  9209. die ( 'illegal request' );
  9210. }
  9211. Doo::loadModel ( "accountBook" );
  9212. $accountBook = new accountBook ();
  9213. Doo::loadModel ( "accountBookStatistics" );
  9214. $accountBookStatistics = new accountBookStatistics ();
  9215. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  9216. $list = $accountBook->getAccountBookByLimit ( 10 );
  9217. $data ['date'] = date ( "Y-m-d" );
  9218. $data ['statisticsList'] = $statisticsList;
  9219. $data ['list'] = $list;
  9220. $data ['memu'] = "receipt";
  9221. $data ['staff'] = $this->staff;
  9222. $data ['receiptMemu'] = 'payments';
  9223. $data ['verifyId'] = $this->verifyId;
  9224. $data ['executeId'] = $this->executeId;
  9225. $this->render ( "/expenses/payments", $data );
  9226. }
  9227. function paymentsIncomeDo() {
  9228. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  9229. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  9230. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  9231. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  9232. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  9233. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  9234. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  9235. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  9236. Doo::loadClass ( 'XDeode' );
  9237. $XDeode = new XDeode ( 5 );
  9238. Doo::loadModel ( "accountBook" );
  9239. Doo::loadModel ( "accountBookStatistics" );
  9240. Doo::loadModel ( 'wasteBook' );
  9241. // 记录流水时银行的转换
  9242. $accountBank = '';
  9243. if ($receivedBank == '纵横广发') {
  9244. $accountBank = 'CGBDeposit';
  9245. } elseif ($receivedBank == '纵横工行') {
  9246. $accountBank = 'ICBCDeposit';
  9247. } elseif ($receivedBank == '华润银行') {
  9248. $accountBank = 'HUADeposit';
  9249. } elseif ($receivedBank == '个人广发') {
  9250. $accountBank = 'PersonalDeposit';
  9251. }
  9252. if (empty ( $accountBank ))
  9253. die ( 'illegal request' );
  9254. // 收入为理财时特殊处理
  9255. if ($accountType == 7 || $accountType == 9) {
  9256. if ($receivedBank == '个人广发') {
  9257. die ( '个人广发 illegal request' );
  9258. }
  9259. // 添加一条收入
  9260. $accountBook = new accountBook ();
  9261. $accountBook->accountType = 10;
  9262. $accountBook->accountMsg = $accountMsg;
  9263. $accountBook->receivedPrice = $receivedPrice;
  9264. $accountBook->receivedMsg = $receivedMsg;
  9265. $accountBook->receivedBank = $receivedBank;
  9266. $accountBook->receivedDate = $receivedDate;
  9267. $accountBook->remarks = $remarks;
  9268. $accountBook->expensesType = 1;
  9269. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9270. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9271. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9272. $inComeId = $accountBook->insert ();
  9273. // 收支汇总-添加一条收入日常汇总
  9274. $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  9275. $accountBookStatistics = new accountBookStatistics ();
  9276. $item = array (
  9277. 'date' => date ( "Y-m-d" ),
  9278. 'accountType' => $abDetail ['accountType'],
  9279. 'accountMsg' => $abDetail ['accountMsg'],
  9280. 'aid' => $abDetail ['aid'],
  9281. 'inComePrice' => $abDetail ['receivedPrice'],
  9282. 'expensesType' => $abDetail ['expensesType']
  9283. );
  9284. $accountBookStatistics->setAccountBookStatistics ( $item );
  9285. // 添加收入流水
  9286. $wasteBook = new wasteBook ();
  9287. $itemWaste = array (
  9288. 'accountPriceShow' => $receivedPrice,
  9289. 'accountPrice' => $receivedPrice,
  9290. 'expensesType' => 1,
  9291. 'accountType' => 6, // 流水类型
  9292. 'dataID' => $inComeId,
  9293. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  9294. 'accountBank' => $accountBank,
  9295. 'category' => $this->staff [0] ['category'],
  9296. 'cid' => $this->staff [0] ['cid'],
  9297. 'name' => $this->staff [0] ['username'],
  9298. 'sid' => $this->staff [0] ['sid'],
  9299. 'inputDate' => date ( "Y-m-d H:i:s" )
  9300. );
  9301. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9302. // 添加一条理财支出
  9303. $accountBank = 'CGBDeposit';
  9304. $expenditureBank = '纵横广发';
  9305. $dailyExpenditureType = 4;
  9306. if ($accountType == 9) {
  9307. $accountBank = 'ICBCDeposit';
  9308. $expenditureBank = '纵横工行';
  9309. $dailyExpenditureType = 6;
  9310. }
  9311. $accountBook = new accountBook ();
  9312. $accountBook->expensesType = 2;
  9313. $accountBook->expenditureType = $dailyExpenditureType;
  9314. $accountBook->expenditureMsg = $accountMsg;
  9315. $accountBook->expenditurePrice = $receivedPrice;
  9316. $accountBook->expenditureBank = $expenditureBank;
  9317. $accountBook->expenditureDate = $receivedDate;
  9318. $accountBook->remarks = $remarks;
  9319. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9320. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9321. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9322. $id = $accountBook->insert ();
  9323. // 收支汇总-添加一条理财支出汇总
  9324. $abDetail = $accountBook->getAccountBookByAid ( $id );
  9325. $accountBookStatistics = new accountBookStatistics ();
  9326. $item = array (
  9327. 'date' => date ( "Y-m-d" ),
  9328. 'accountType' => $abDetail ['accountType'],
  9329. 'accountMsg' => $abDetail ['accountMsg'],
  9330. 'aid' => $abDetail ['aid'],
  9331. 'financingPrice' => - $receivedPrice,
  9332. 'expensesType' => 3
  9333. );
  9334. $accountBookStatistics->setAccountBookStatistics ( $item );
  9335. // 添加一条支出理财流水
  9336. $accountTypeWaste = 5;
  9337. if ($accountMsg == '公司固定') {
  9338. $accountTypeWaste = 9;
  9339. } elseif ($accountMsg == '公司活期') {
  9340. $accountTypeWaste = 10;
  9341. } elseif ($accountMsg == '个人(GR)') {
  9342. $accountBank = 'PersonalDeposit';
  9343. }
  9344. $itemWaste = array (
  9345. 'expensesType' => 2,
  9346. 'accountType' => $accountTypeWaste,
  9347. 'accountPriceShow' => $receivedPrice,
  9348. 'accountPrice' => - $receivedPrice,
  9349. 'dataID' => $id,
  9350. 'dailyExpenditureType' => $dailyExpenditureType,
  9351. 'accountBank' => $accountBank,
  9352. 'category' => $this->staff [0] ['category'],
  9353. 'cid' => $this->staff [0] ['cid'],
  9354. 'name' => $this->staff [0] ['username'],
  9355. 'sid' => $this->staff [0] ['sid'],
  9356. 'inputDate' => date ( "Y-m-d H:i:s" )
  9357. );
  9358. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9359. } elseif ($accountType == 1) {
  9360. if ($receivedBank == '个人广发')
  9361. die ( 'illegal request' );
  9362. // 添加一条收入
  9363. $accountBook = new accountBook ();
  9364. $accountBook->accountType = $accountType;
  9365. $accountBook->accountMsg = $accountMsg;
  9366. $accountBook->receivedPrice = $receivedPrice;
  9367. $accountBook->receivedMsg = $receivedMsg;
  9368. $accountBook->receivedBank = $receivedBank;
  9369. $accountBook->receivedDate = $receivedDate;
  9370. $accountBook->remarks = $remarks;
  9371. $accountBook->expensesType = 1;
  9372. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9373. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9374. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9375. $id = $accountBook->insert ();
  9376. $abDetail = $accountBook->getAccountBookByAid ( $id );
  9377. // 收支汇总-添加一条收入日常汇总
  9378. $accountBookStatistics = new accountBookStatistics ();
  9379. $item = array (
  9380. 'date' => date ( "Y-m-d" ),
  9381. 'accountType' => $abDetail ['accountType'],
  9382. 'accountMsg' => $abDetail ['accountMsg'],
  9383. 'aid' => $abDetail ['aid'],
  9384. 'expensesType' => $abDetail ['expensesType']
  9385. );
  9386. if ($abDetail ['accountType'] == 8) {
  9387. $item += array (
  9388. 'inComePrice' => $abDetail ['receivedPrice']
  9389. );
  9390. } else {
  9391. $item += array (
  9392. 'inComePrice' => $abDetail ['receivedPrice']
  9393. );
  9394. }
  9395. $accountBookStatistics->setAccountBookStatistics ( $item );
  9396. // 流水存储方向
  9397. $itemWaste = array (
  9398. 'accountType' => 6
  9399. ); // 流水类型
  9400. // if($accountMsg=='银行存款'||$accountMsg=='固定理财收益'){
  9401. // }else
  9402. if ($accountMsg == '活期理财收益') {
  9403. $itemWaste = array (
  9404. 'accountType' => 10
  9405. ); // 流水类型
  9406. }
  9407. // 添加收入流水
  9408. $wasteBook = new wasteBook ();
  9409. $itemWaste += array (
  9410. 'accountPrice' => $receivedPrice,
  9411. 'accountPriceShow' => $receivedPrice,
  9412. 'expensesType' => 1,
  9413. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  9414. 'dataID' => $id,
  9415. 'accountBank' => $accountBank,
  9416. 'category' => $this->staff [0] ['category'],
  9417. 'cid' => $this->staff [0] ['cid'],
  9418. 'name' => $this->staff [0] ['username'],
  9419. 'sid' => $this->staff [0] ['sid'],
  9420. 'inputDate' => date ( "Y-m-d H:i:s" )
  9421. );
  9422. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9423. } else { // 普通日常收入处理
  9424. // 添加一条收入
  9425. $accountBook = new accountBook ();
  9426. $accountBook->accountType = $accountType;
  9427. $accountBook->accountMsg = $accountMsg;
  9428. $accountBook->receivedPrice = $receivedPrice;
  9429. $accountBook->receivedMsg = $receivedMsg;
  9430. $accountBook->receivedBank = $receivedBank;
  9431. $accountBook->receivedDate = $receivedDate;
  9432. $accountBook->remarks = $remarks;
  9433. $accountBook->expensesType = 1;
  9434. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9435. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9436. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9437. $id = $accountBook->insert ();
  9438. $abDetail = $accountBook->getAccountBookByAid ( $id );
  9439. // 收支汇总-添加一条收入日常汇总
  9440. $accountBookStatistics = new accountBookStatistics ();
  9441. $item = array (
  9442. 'date' => date ( "Y-m-d" ),
  9443. 'accountType' => $abDetail ['accountType'],
  9444. 'accountMsg' => $abDetail ['accountMsg'],
  9445. 'aid' => $abDetail ['aid'],
  9446. 'expensesType' => $abDetail ['expensesType']
  9447. );
  9448. if ($abDetail ['accountType'] == 8) {
  9449. $item += array (
  9450. 'inComePrice' => $abDetail ['receivedPrice']
  9451. );
  9452. } else {
  9453. $item += array (
  9454. 'inComePrice' => $abDetail ['receivedPrice']
  9455. );
  9456. }
  9457. $accountBookStatistics->setAccountBookStatistics ( $item );
  9458. // 添加收入流水
  9459. $itemWaste = array (
  9460. 'accountPrice' => $receivedPrice
  9461. );
  9462. if ($receivedBank == '个人广发') {
  9463. $itemWaste = array (
  9464. 'accountPrice' => - $receivedPrice
  9465. );
  9466. }
  9467. $wasteBook = new wasteBook ();
  9468. $itemWaste += array (
  9469. 'accountPriceShow' => $receivedPrice,
  9470. 'expensesType' => 1,
  9471. 'accountType' => 6, // 流水类型
  9472. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  9473. 'dataID' => $id,
  9474. 'accountBank' => $accountBank,
  9475. 'category' => $this->staff [0] ['category'],
  9476. 'cid' => $this->staff [0] ['cid'],
  9477. 'name' => $this->staff [0] ['username'],
  9478. 'sid' => $this->staff [0] ['sid'],
  9479. 'inputDate' => date ( "Y-m-d H:i:s" )
  9480. );
  9481. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9482. }
  9483. }
  9484. return '/payments';
  9485. }
  9486. /**
  9487. * 添加收入
  9488. * @return string
  9489. */
  9490. function paymentsIncomeDo_() {
  9491. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  9492. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  9493. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  9494. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  9495. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  9496. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  9497. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  9498. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  9499. Doo::loadClass ( 'XDeode' );
  9500. $XDeode = new XDeode ( 5 );
  9501. Doo::loadModel ( "accountBook" );
  9502. $accountBook = new accountBook ();
  9503. $accountBank = '';
  9504. $accountTypeWaste = 6;
  9505. if ($receivedBank == '纵横广发') {
  9506. $accountBank = 'CGBDeposit';
  9507. } elseif ($receivedBank == '纵横工行') {
  9508. $accountBank = 'ICBCDeposit';
  9509. } elseif ($receivedBank == '华润银行') {
  9510. $accountBank = 'HUADeposit';
  9511. } elseif ($receivedBank == '个人广发') {
  9512. $accountBank = 'PersonalDeposit';
  9513. }
  9514. if (empty ( $accountBank ))
  9515. die ( 'illegal request' );
  9516. $dailyIncomeType = '';
  9517. $itemWaste = array (
  9518. 'accountPrice' => $receivedPrice,
  9519. 'expensesType' => 1
  9520. );
  9521. if ($receivedBank == '个人广发') {
  9522. $itemWaste = array (
  9523. 'accountPrice' => - $receivedPrice,
  9524. 'expensesType' => 1
  9525. );
  9526. }
  9527. if ($accountType == 4) {
  9528. $dailyIncomeType = 4;
  9529. } elseif ($accountType == 1) {
  9530. $dailyIncomeType = 1;
  9531. } elseif ($accountType == 2) {
  9532. $dailyIncomeType = 2;
  9533. } elseif ($accountType == 3) {
  9534. $dailyIncomeType = 3;
  9535. } elseif ($accountType == 5) {
  9536. $dailyIncomeType = 5;
  9537. } elseif ($accountType == 6) {
  9538. $dailyIncomeType = 6;
  9539. } elseif ($accountType == 7 || $accountType == 9) {
  9540. $dailyIncomeType = 7;
  9541. if ($accountMsg == '公司固定') {
  9542. $accountTypeWaste = 9;
  9543. } elseif ($accountMsg == '公司活期') {
  9544. $accountTypeWaste = 10;
  9545. } elseif ($accountMsg == '个人(GR)') {
  9546. $accountBank = 'PersonalDeposit';
  9547. }
  9548. $itemWaste = array (
  9549. 'accountPrice' => - $receivedPrice,
  9550. 'expensesType' => 2
  9551. );
  9552. } elseif ($accountType == 8) {
  9553. $dailyIncomeType = 8;
  9554. }
  9555. if (empty ( $dailyIncomeType ))
  9556. die ( 'illegal request' );
  9557. $accountBook->accountType = $accountType;
  9558. $accountBook->accountMsg = $accountMsg;
  9559. $accountBook->receivedPrice = $receivedPrice;
  9560. $accountBook->receivedMsg = $receivedMsg;
  9561. $accountBook->receivedBank = $receivedBank;
  9562. $accountBook->receivedDate = $receivedDate;
  9563. $accountBook->remarks = $remarks;
  9564. $accountBook->expensesType = 1;
  9565. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9566. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9567. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9568. $id = $accountBook->insert ();
  9569. //
  9570. $abDetail = $accountBook->getAccountBookByAid ( $id );
  9571. // 收支汇总
  9572. Doo::loadModel ( "accountBookStatistics" );
  9573. $accountBookStatistics = new accountBookStatistics ();
  9574. $item = array (
  9575. 'date' => date ( "Y-m-d" ),
  9576. 'accountType' => $abDetail ['accountType'],
  9577. 'accountMsg' => $abDetail ['accountMsg'],
  9578. 'aid' => $abDetail ['aid']
  9579. );
  9580. if ($abDetail ['expensesType'] == 1) {
  9581. if ($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) {
  9582. $item += array (
  9583. 'financingPrice' => - $receivedPrice,
  9584. 'expensesType' => 3
  9585. );
  9586. } else if ($abDetail ['accountType'] == 8) {
  9587. $item += array (
  9588. 'inComePrice' => - $abDetail ['receivedPrice'],
  9589. 'expensesType' => $abDetail ['expensesType']
  9590. );
  9591. } else {
  9592. $item += array (
  9593. 'inComePrice' => $abDetail ['receivedPrice'],
  9594. 'expensesType' => $abDetail ['expensesType']
  9595. );
  9596. }
  9597. }
  9598. $accountBookStatistics->setAccountBookStatistics ( $item );
  9599. // 为理财时需添加一条日常支出
  9600. if ($accountType == 7 || $accountType == 9) {
  9601. }
  9602. // 公司流水记录
  9603. Doo::loadModel ( 'wasteBook' );
  9604. $wasteBook = new wasteBook ();
  9605. // 银行
  9606. // if (empty($abDetail)){
  9607. $itemWaste += array (
  9608. 'accountPriceShow' => $receivedPrice,
  9609. 'dataID' => $id,
  9610. 'accountType' => $accountTypeWaste,
  9611. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  9612. 'accountBank' => $accountBank,
  9613. 'category' => $this->staff [0] ['category'],
  9614. 'cid' => $this->staff [0] ['cid'],
  9615. 'name' => $this->staff [0] ['username'],
  9616. 'sid' => $this->staff [0] ['sid'],
  9617. 'inputDate' => date ( "Y-m-d H:i:s" )
  9618. );
  9619. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9620. // }
  9621. // 类型为理财7或者9 要添加一笔理财支出
  9622. if ($accountType == 7 || $accountType == 9) {
  9623. $accountBank = 'CGBDeposit';
  9624. $expenditureBank = '纵横广发';
  9625. $dailyExpenditureType = 4;
  9626. if ($accountType == 9) {
  9627. $accountBank = 'ICBCDeposit';
  9628. $expenditureBank = '纵横工行';
  9629. $dailyExpenditureType = 6;
  9630. }
  9631. // 添加一条支出
  9632. $accountBook = new accountBook ();
  9633. $accountBook->expenditureType = $dailyExpenditureType;
  9634. $accountBook->expenditureMsg = $accountMsg;
  9635. $accountBook->expenditurePrice = $receivedPrice;
  9636. $accountBook->expenditureBank = $expenditureBank;
  9637. $accountBook->expenditureDate = $receivedDate;
  9638. $accountBook->remarks = $remarks;
  9639. $accountBook->expensesType = 2;
  9640. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9641. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9642. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9643. $id = $accountBook->insert ();
  9644. // 添加一条收入流水
  9645. $itemWaste = array (
  9646. 'accountPriceShow' => $receivedPrice,
  9647. 'accountPrice' => $receivedPrice,
  9648. 'dataID' => $id,
  9649. 'expensesType' => 2,
  9650. 'accountType' => $accountTypeWaste,
  9651. 'dailyExpenditureType' => $dailyExpenditureType,
  9652. 'accountBank' => $accountBank,
  9653. 'category' => $this->staff [0] ['category'],
  9654. 'cid' => $this->staff [0] ['cid'],
  9655. 'name' => $this->staff [0] ['username'],
  9656. 'sid' => $this->staff [0] ['sid'],
  9657. 'inputDate' => date ( "Y-m-d H:i:s" )
  9658. );
  9659. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9660. }
  9661. }
  9662. return '/payments';
  9663. }
  9664. function paymentsExpenditureDo() {
  9665. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  9666. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  9667. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  9668. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  9669. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  9670. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  9671. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  9672. // 理财支出特殊处理
  9673. Doo::loadModel ( "accountBook" );
  9674. Doo::loadModel ( "accountBookStatistics" );
  9675. Doo::loadModel ( 'wasteBook' );
  9676. $accountBank = '';
  9677. if ($expenditureBank == '纵横广发') {
  9678. $accountBank = 'CGBDeposit';
  9679. } elseif ($expenditureBank == '纵横工行') {
  9680. $accountBank = 'ICBCDeposit';
  9681. } elseif ($expenditureBank == '华润银行') {
  9682. $accountBank = 'HUADeposit';
  9683. } elseif ($expenditureBank == '个人广发') {
  9684. $accountBank = 'PersonalDeposit';
  9685. }
  9686. if (empty ( $accountBank ))
  9687. die ( 'illegal request' );
  9688. if ($expenditureType == 4 || $expenditureType == 6) {
  9689. if ($expenditureBank == '个人广发') {
  9690. die ( '个人广发 illegal request' );
  9691. }
  9692. // 添加一笔日常支出
  9693. $accountBook = new accountBook ();
  9694. $accountBook->expensesType = 2;
  9695. $accountBook->expenditureType = 7;
  9696. $accountBook->expenditureMsg = $expenditureMsg;
  9697. $accountBook->expenditurePrice = $expenditurePrice;
  9698. $accountBook->expenditureBank = $expenditureBank;
  9699. $accountBook->expenditureDate = $expenditureDate;
  9700. $accountBook->remarks = $remarks;
  9701. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9702. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9703. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9704. $expenditureId = $accountBook->insert ();
  9705. // 添加日常支出汇总
  9706. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  9707. $accountBookStatistics = new accountBookStatistics ();
  9708. $item = array (
  9709. 'date' => date ( "Y-m-d" ),
  9710. 'expenditureType' => $abDetail ['expenditureType'],
  9711. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  9712. 'aid' => $abDetail ['aid'],
  9713. 'payPrice' => $abDetail ['expenditurePrice'],
  9714. 'expensesType' => $abDetail ['expensesType']
  9715. );
  9716. $accountBookStatistics->setAccountBookStatistics ( $item );
  9717. // 公司日常支出流水
  9718. $wasteBook = new wasteBook ();
  9719. $itemWaste = array (
  9720. 'accountPrice' => - $expenditurePrice
  9721. );
  9722. if ($expenditureBank == '个人广发') {
  9723. $itemWaste = array (
  9724. 'accountPrice' => $expenditurePrice
  9725. );
  9726. }
  9727. $itemWaste += array (
  9728. 'expensesType' => 2,
  9729. 'accountType' => 5,
  9730. 'dailyExpenditureType' => $expenditureType,
  9731. 'accountPriceShow' => $expenditurePrice,
  9732. 'accountPrice' => - $expenditurePrice,
  9733. 'dataID' => $expenditureId,
  9734. 'accountBank' => $accountBank,
  9735. 'category' => $this->staff [0] ['category'],
  9736. 'cid' => $this->staff [0] ['cid'],
  9737. 'name' => $this->staff [0] ['username'],
  9738. 'sid' => $this->staff [0] ['sid'],
  9739. 'inputDate' => date ( "Y-m-d H:i:s" )
  9740. );
  9741. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9742. // 添加一笔理财收入
  9743. $accountBank = 'CGBDeposit';
  9744. $dailyIncomeType = 7;
  9745. $receivedBank = '纵横广发';
  9746. if ($expenditureType == 6) {
  9747. $accountBank = 'ICBCDeposit';
  9748. $receivedBank = '纵横工行';
  9749. $dailyIncomeType = 9;
  9750. }
  9751. $accountBook = new accountBook ();
  9752. $accountBook->expensesType = 1;
  9753. $accountBook->accountType = $dailyIncomeType;
  9754. $accountBook->accountMsg = $expenditureMsg;
  9755. $accountBook->receivedPrice = $expenditurePrice;
  9756. $accountBook->receivedBank = $receivedBank;
  9757. $accountBook->receivedDate = $expenditureDate;
  9758. $accountBook->remarks = $remarks;
  9759. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9760. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9761. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9762. $id = $accountBook->insert ();
  9763. // 添加日常理财收入汇总
  9764. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  9765. $accountBookStatistics = new accountBookStatistics ();
  9766. $item = array (
  9767. 'date' => date ( "Y-m-d" ),
  9768. 'expenditureType' => $abDetail ['expenditureType'],
  9769. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  9770. 'aid' => $abDetail ['aid'],
  9771. 'financingPrice' => $expenditurePrice,
  9772. 'expensesType' => 3
  9773. );
  9774. $accountBookStatistics->setAccountBookStatistics ( $item );
  9775. // 添加一笔收入流水
  9776. if ($expenditureMsg == '公司固定') {
  9777. $accountTypeWaste = 9;
  9778. } elseif ($expenditureMsg == '公司活期') {
  9779. $accountTypeWaste = 10;
  9780. } elseif ($expenditureMsg == '个人(GR)') {
  9781. $accountBank = 'PersonalDeposit';
  9782. }
  9783. $itemWaste = array (
  9784. 'expensesType' => 1,
  9785. 'accountType' => $accountTypeWaste,
  9786. 'accountPriceShow' => $expenditurePrice,
  9787. 'accountPrice' => $expenditurePrice,
  9788. 'dataID' => $id,
  9789. 'dailyIncomeType' => $dailyIncomeType,
  9790. 'accountBank' => $accountBank,
  9791. 'category' => $this->staff [0] ['category'],
  9792. 'cid' => $this->staff [0] ['cid'],
  9793. 'name' => $this->staff [0] ['username'],
  9794. 'sid' => $this->staff [0] ['sid'],
  9795. 'inputDate' => date ( "Y-m-d H:i:s" )
  9796. );
  9797. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9798. } else {
  9799. // 添加一笔日常支出
  9800. $accountBook = new accountBook ();
  9801. $accountBook->expensesType = 2;
  9802. $accountBook->expenditureType = $expenditureType;
  9803. $accountBook->expenditureMsg = $expenditureMsg;
  9804. $accountBook->expenditurePrice = $expenditurePrice;
  9805. $accountBook->expenditureBank = $expenditureBank;
  9806. $accountBook->expenditureDate = $expenditureDate;
  9807. $accountBook->remarks = $remarks;
  9808. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9809. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9810. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9811. $id = $accountBook->insert ();
  9812. // 添加日常支出汇总
  9813. $abDetail = $accountBook->getAccountBookByAid ( $id );
  9814. $accountBookStatistics = new accountBookStatistics ();
  9815. $item = array (
  9816. 'date' => date ( "Y-m-d" ),
  9817. 'expenditureType' => $abDetail ['expenditureType'],
  9818. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  9819. 'aid' => $abDetail ['aid'],
  9820. 'expensesType' => $abDetail ['expensesType']
  9821. );
  9822. if ($expenditureType == 5) {
  9823. $item += array (
  9824. 'payPrice' => - $abDetail ['expenditurePrice']
  9825. );
  9826. } else {
  9827. $item += array (
  9828. 'payPrice' => $abDetail ['expenditurePrice']
  9829. );
  9830. }
  9831. $accountBookStatistics->setAccountBookStatistics ( $item );
  9832. // 公司日常支出流水
  9833. $wasteBook = new wasteBook ();
  9834. $itemWaste = array (
  9835. 'accountPrice' => - $expenditurePrice
  9836. );
  9837. if ($expenditureBank == '个人广发') {
  9838. $itemWaste = array (
  9839. 'accountPrice' => $expenditurePrice
  9840. );
  9841. }
  9842. $itemWaste += array (
  9843. 'expensesType' => 2,
  9844. 'accountType' => 5,
  9845. 'accountPriceShow' => $expenditurePrice,
  9846. 'dataID' => $id,
  9847. 'dailyExpenditureType' => $expenditureType,
  9848. 'accountBank' => $accountBank,
  9849. 'category' => $this->staff [0] ['category'],
  9850. 'cid' => $this->staff [0] ['cid'],
  9851. 'name' => $this->staff [0] ['username'],
  9852. 'sid' => $this->staff [0] ['sid'],
  9853. 'inputDate' => date ( "Y-m-d H:i:s" )
  9854. );
  9855. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9856. }
  9857. }
  9858. return '/payments';
  9859. }
  9860. /**
  9861. * 添加支出
  9862. */
  9863. function paymentsExpenditureDo_() {
  9864. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  9865. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  9866. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  9867. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  9868. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  9869. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  9870. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  9871. $dailyExpenditureType = '';
  9872. $accountTypeWaste = 5;
  9873. $accountBank = '';
  9874. if ($expenditureBank == '纵横广发') {
  9875. $accountBank = 'CGBDeposit';
  9876. } elseif ($expenditureBank == '纵横工行') {
  9877. $accountBank = 'ICBCDeposit';
  9878. } elseif ($expenditureBank == '华润银行') {
  9879. $accountBank = 'HUADeposit';
  9880. } elseif ($expenditureBank == '个人广发') {
  9881. $accountBank = 'PersonalDeposit';
  9882. }
  9883. if (empty ( $accountBank ))
  9884. die ( 'illegal request' );
  9885. $itemWaste = array (
  9886. 'accountPrice' => - $expenditurePrice
  9887. );
  9888. if ($expenditureBank == '个人广发') {
  9889. $itemWaste = array (
  9890. 'accountPrice' => $expenditurePrice
  9891. );
  9892. }
  9893. if ($expenditureType == 4 || $expenditureType == 6) {
  9894. $dailyExpenditureType = 4;
  9895. if ($expenditureMsg == '公司固定') {
  9896. $accountTypeWaste = 9;
  9897. } elseif ($expenditureMsg == '公司活期') {
  9898. $accountTypeWaste = 10;
  9899. } elseif ($expenditureMsg == '个人(GR)') {
  9900. $accountBank = 'PersonalDeposit';
  9901. }
  9902. $itemWaste = array (
  9903. 'accountPrice' => $expenditurePrice
  9904. );
  9905. } elseif ($expenditureType == 1) {
  9906. $dailyExpenditureType = 1;
  9907. } elseif ($expenditureType == 2) {
  9908. $dailyExpenditureType = 2;
  9909. } elseif ($expenditureType == 3) {
  9910. $dailyExpenditureType = 3;
  9911. } elseif ($expenditureType == 5) {
  9912. $dailyExpenditureType = 5;
  9913. }
  9914. if (empty ( $dailyExpenditureType ))
  9915. die ( 'illegal request' );
  9916. Doo::loadModel ( "accountBook" );
  9917. $accountBook = new accountBook ();
  9918. $accountBook->expenditureType = $expenditureType;
  9919. $accountBook->expenditureMsg = $expenditureMsg;
  9920. $accountBook->expenditurePrice = $expenditurePrice;
  9921. $accountBook->expenditureBank = $expenditureBank;
  9922. $accountBook->expenditureDate = $expenditureDate;
  9923. $accountBook->remarks = $remarks;
  9924. $accountBook->expensesType = 2;
  9925. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9926. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9927. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9928. $id = $accountBook->insert ();
  9929. //
  9930. $abDetail = $accountBook->getAccountBookByAid ( $id );
  9931. Doo::loadModel ( "accountBookStatistics" );
  9932. $accountBookStatistics = new accountBookStatistics ();
  9933. $item = array (
  9934. 'date' => date ( "Y-m-d" ),
  9935. 'expenditureType' => $abDetail ['expenditureType'],
  9936. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  9937. 'aid' => $abDetail ['aid']
  9938. );
  9939. if ($abDetail ['expensesType'] == 2) {
  9940. if ($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) {
  9941. $item += array (
  9942. 'financingPrice' => $expenditurePrice,
  9943. 'expensesType' => 3
  9944. );
  9945. } elseif ($abDetail ['expenditureType'] == 5) {
  9946. $item += array (
  9947. 'payPrice' => $abDetail ['expenditurePrice'],
  9948. 'expensesType' => $abDetail ['expensesType']
  9949. );
  9950. } else {
  9951. $item += array (
  9952. 'payPrice' => $abDetail ['expenditurePrice'],
  9953. 'expensesType' => $abDetail ['expensesType']
  9954. );
  9955. }
  9956. }
  9957. $accountBookStatistics->setAccountBookStatistics ( $item );
  9958. // 公司流水记录
  9959. Doo::loadModel ( 'wasteBook' );
  9960. $wasteBook = new wasteBook ();
  9961. $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountTypeWaste, $id );
  9962. // 银行
  9963. if (empty ( $abDetail )) {
  9964. $itemWaste += array (
  9965. 'accountPriceShow' => $expenditurePrice,
  9966. 'dataID' => $id,
  9967. 'expensesType' => 2,
  9968. 'accountType' => $accountTypeWaste,
  9969. 'dailyExpenditureType' => $expenditureType,
  9970. 'accountBank' => $accountBank,
  9971. 'category' => $this->staff [0] ['category'],
  9972. 'cid' => $this->staff [0] ['cid'],
  9973. 'name' => $this->staff [0] ['username'],
  9974. 'sid' => $this->staff [0] ['sid'],
  9975. 'inputDate' => date ( "Y-m-d H:i:s" )
  9976. );
  9977. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9978. }
  9979. // 支出类型为4或者6 需要添加一笔收入和收入流水
  9980. if ($expenditureType == 4 || $expenditureType == 6) {
  9981. $accountBank = 'CGBDeposit';
  9982. $dailyIncomeType = 7;
  9983. $receivedBank = '纵横广发';
  9984. if ($expenditureType == 6) {
  9985. $accountBank = 'ICBCDeposit';
  9986. $receivedBank = '纵横工行';
  9987. $dailyIncomeType = 9;
  9988. }
  9989. // 添加一笔收入
  9990. $accountBook = new accountBook ();
  9991. $accountBook->accountType = $dailyIncomeType;
  9992. $accountBook->accountMsg = $expenditureMsg;
  9993. $accountBook->receivedPrice = $expenditurePrice;
  9994. $accountBook->receivedBank = $receivedBank;
  9995. $accountBook->receivedDate = $expenditureDate;
  9996. $accountBook->remarks = $remarks;
  9997. $accountBook->expensesType = 1;
  9998. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9999. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10000. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10001. $id = $accountBook->insert ();
  10002. // 添加一笔收入流水
  10003. $itemWaste = array (
  10004. 'accountPriceShow' => $expenditurePrice,
  10005. 'accountPrice' => - $expenditurePrice,
  10006. 'dataID' => $id,
  10007. 'expensesType' => 1,
  10008. 'accountType' => $accountTypeWaste,
  10009. 'dailyIncomeType' => $dailyIncomeType,
  10010. 'accountBank' => $accountBank,
  10011. 'category' => $this->staff [0] ['category'],
  10012. 'cid' => $this->staff [0] ['cid'],
  10013. 'name' => $this->staff [0] ['username'],
  10014. 'sid' => $this->staff [0] ['sid'],
  10015. 'inputDate' => date ( "Y-m-d H:i:s" )
  10016. );
  10017. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10018. }
  10019. }
  10020. return '/payments';
  10021. }
  10022. /**
  10023. * 所有收支
  10024. */
  10025. function paymentsAchieve() {
  10026. $page_size = 12;
  10027. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  10028. $expensesType = isset ( $this->params ['expensesType'] ) ? $this->params ['expensesType'] : 'ALL';
  10029. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  10030. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  10031. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10032. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10033. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10034. $submitType = $this->get_args ( 'submitType' ) ? $this->get_args ( 'submitType' ) : "";
  10035. Doo::loadModel ( "accountBookStatistics" );
  10036. $accountBookStatistics = new accountBookStatistics ();
  10037. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  10038. $data ['statisticsList'] = $statisticsList;
  10039. Doo::loadModel ( "accountBook" );
  10040. $accountBook = new accountBook ();
  10041. $con = '';
  10042. if ($expensesType == 'INCOME')
  10043. $con = ' and expensesType=1 ';
  10044. elseif ($expensesType == 'PAY')
  10045. $con = ' and expensesType=2 ';
  10046. $dateArr = explode ( ':', $date );
  10047. $D1 = $dateString = '';
  10048. $D2 = '';
  10049. if (! empty ( $date )) {
  10050. $D1 = $dateArr [0];
  10051. if (isset ( $dateArr [1] ))
  10052. $D2 = $dateArr [1];
  10053. else
  10054. $D2 = '';
  10055. $dateString = $D1 . " : " . $D2;
  10056. }
  10057. if (! empty ( $D1 ) && ! empty ( $D2 ))
  10058. $con .= ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  10059. elseif (! empty ( $D1 ) && empty ( $D2 ))
  10060. $con .= ' and inputDate like "%' . $D1 . '%" ';
  10061. if (! empty ( $price ))
  10062. $con .= ' and (receivedPrice=' . $price . ' or expenditurePrice=' . $price . ')';
  10063. if ($submitType == 1) {
  10064. if ($accountType != '') {
  10065. $expenditureType = '';
  10066. $con .= ' and accountType=' . $accountType;
  10067. if (! empty ( $accountMsg ))
  10068. $con .= ' and (accountType=' . $accountType . ' and accountMsg like "%' . $accountMsg . '%")';
  10069. }
  10070. } elseif ($submitType == 2) {
  10071. if ($expenditureType != '') {
  10072. $accountType = $accountMsg = '';
  10073. $con .= ' and expenditureType=' . $expenditureType;
  10074. }
  10075. } else {
  10076. $accountType = $accountMsg = $expenditureType = '';
  10077. }
  10078. $sql = "" . $con;
  10079. $action = "paymentsAchieve";
  10080. $get = '/' . $expensesType; // "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  10081. $pageinfo = $this->get_page ( "CLD_accountBook", $sql, $page, $page_size, $action, $get, "" );
  10082. $limit = $pageinfo ['lower'] . ',' . $page_size;
  10083. $list = $accountBook->getAccountBookBySql ( $limit, $sql, 'desc' );
  10084. $data ['expenditureType'] = $expenditureType;
  10085. $data ['accountMsg'] = $accountMsg;
  10086. $data ['accountType'] = $accountType;
  10087. $data ['inputDate'] = $date;
  10088. $data ['price'] = $price;
  10089. $data ['expensesType'] = $expensesType;
  10090. $data ['page'] = $pageinfo;
  10091. $data ['list'] = $list;
  10092. $data ['memu'] = "receipt";
  10093. $data ['staff'] = $this->staff;
  10094. $data ['receiptMemu'] = 'payments';
  10095. $data ['verifyId'] = $this->verifyId;
  10096. $data ['executeId'] = $this->executeId;
  10097. $this->render ( "/expenses/paymentsAchieve", $data );
  10098. }
  10099. function paymentsIncomeUpdateDo() {
  10100. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  10101. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10102. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10103. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10104. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10105. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10106. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10107. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10108. if (! empty ( $aidKey ) && ! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10109. Doo::loadClass ( 'XDeode' );
  10110. $XDeode = new XDeode ( 5 );
  10111. $aid = $XDeode->decode ( $aidKey );
  10112. Doo::loadModel ( "accountBook" );
  10113. $accountBook = new accountBook ();
  10114. //
  10115. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  10116. $price = $receivedPrice - $abDetail [inComePrice];
  10117. Doo::loadModel ( "accountBookStatistics" );
  10118. $accountBookStatistics = new accountBookStatistics ();
  10119. if ($abDetail ['accountType'] == 7) {
  10120. $item += array (
  10121. 'date' => date ( "Y-m-d" ),
  10122. 'financingPrice' => - $price,
  10123. 'expensesType' => 3,
  10124. 'aid' => $abDetail ['aid']
  10125. );
  10126. } elseif ($abDetail ['accountType'] == 8) {
  10127. $item += array (
  10128. 'date' => date ( "Y-m-d" ),
  10129. 'expensesType' => $abDetail ['expensesType'],
  10130. 'inComePrice' => - $price,
  10131. 'aid' => $abDetail ['aid']
  10132. );
  10133. } else {
  10134. $item = array (
  10135. 'date' => date ( "Y-m-d" ),
  10136. 'expensesType' => $abDetail ['expensesType'],
  10137. 'inComePrice' => $price,
  10138. 'aid' => $abDetail ['aid']
  10139. );
  10140. }
  10141. $accountBookStatistics->setAccountBookStatistics ( $item );
  10142. $accountBook->accountType = $accountType;
  10143. $accountBook->accountMsg = $accountMsg;
  10144. $accountBook->receivedPrice = $receivedPrice;
  10145. $accountBook->receivedMsg = $receivedMsg;
  10146. $accountBook->receivedBank = $receivedBank;
  10147. $accountBook->receivedDate = $receivedDate;
  10148. $accountBook->remarks = $remarks;
  10149. $accountBook->aid = $aid;
  10150. $accountBook->update ();
  10151. }
  10152. return '/paymentsAchieve';
  10153. }
  10154. function paymentsExpenditureEdiDo() {
  10155. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  10156. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10157. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  10158. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  10159. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  10160. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10161. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  10162. if (! empty ( $aidKey ) && ! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  10163. Doo::loadClass ( 'XDeode' );
  10164. $XDeode = new XDeode ( 5 );
  10165. $aid = $XDeode->decode ( $aidKey );
  10166. Doo::loadModel ( "accountBook" );
  10167. $accountBook = new accountBook ();
  10168. // 汇总信息
  10169. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  10170. $price = $expenditurePrice - $abDetail [expenditurePrice];
  10171. Doo::loadModel ( "accountBookStatistics" );
  10172. $accountBookStatistics = new accountBookStatistics ();
  10173. if ($abDetail ['expenditureType'] == 4) {
  10174. $item += array (
  10175. 'date' => date ( "Y-m-d" ),
  10176. 'financingPrice' => $price,
  10177. 'expensesType' => 3,
  10178. 'aid' => $abDetail ['aid']
  10179. );
  10180. } elseif ($abDetail ['expenditureType'] == 5) {
  10181. $item += array (
  10182. 'date' => date ( "Y-m-d" ),
  10183. 'expensesType' => $abDetail ['expensesType'],
  10184. 'payPrice' => $price,
  10185. 'aid' => $abDetail ['aid']
  10186. );
  10187. } else {
  10188. $item = array (
  10189. 'date' => date ( "Y-m-d" ),
  10190. 'expensesType' => $abDetail ['expensesType'],
  10191. 'payPrice' => $price,
  10192. 'aid' => $abDetail ['aid']
  10193. );
  10194. }
  10195. $accountBookStatistics->setAccountBookStatistics ( $item );
  10196. //
  10197. $accountBook->expenditureType = $expenditureType;
  10198. $accountBook->expenditureMsg = $expenditureMsg;
  10199. $accountBook->expenditurePrice = $expenditurePrice;
  10200. $accountBook->expenditureBank = $expenditureBank;
  10201. $accountBook->remarks = $remarks;
  10202. $accountBook->expenditureDate = $expenditureDate;
  10203. $accountBook->aid = $aid;
  10204. $id = $accountBook->update ();
  10205. }
  10206. return '/paymentsAchieve';
  10207. }
  10208. function paymentsDelDo() {
  10209. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  10210. if (! empty ( $aidKey )) {
  10211. Doo::loadClass ( 'XDeode' );
  10212. $XDeode = new XDeode ( 5 );
  10213. $aid = $XDeode->decode ( $aidKey );
  10214. Doo::loadModel ( "accountBook" );
  10215. $accountBook = new accountBook ();
  10216. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  10217. if (empty ( $abDetail ))
  10218. die ( 'illegal request' );
  10219. // 删除收支
  10220. Doo::loadModel ( "accountBookStatistics" );
  10221. $accountBookStatistics = new accountBookStatistics ();
  10222. $item = array (
  10223. 'date' => date ( "Y-m-d" ),
  10224. 'aid' => $abDetail ['aid']
  10225. );
  10226. $accountType = '';
  10227. if ($abDetail ['expensesType'] == 1) {
  10228. $accountType = 6;
  10229. if ($abDetail ['accountType'] != 7) {
  10230. $item += array (
  10231. 'expensesType' => $abDetail ['expensesType'],
  10232. 'inComePrice' => - $abDetail ['receivedPrice']
  10233. );
  10234. } else {
  10235. $item += array (
  10236. 'financingPrice' => $abDetail ['receivedPrice'],
  10237. 'expensesType' => 3
  10238. );
  10239. }
  10240. } elseif ($abDetail ['expensesType'] == 2) {
  10241. $accountType = 5;
  10242. if ($abDetail ['accountType'] != 7) {
  10243. $item += array (
  10244. 'expensesType' => $abDetail ['expensesType'],
  10245. 'payPrice' => - $abDetail ['expenditurePrice']
  10246. );
  10247. } else {
  10248. $item += array (
  10249. 'financingPrice' => - $abDetail ['expenditurePrice'],
  10250. 'expensesType' => 3
  10251. );
  10252. }
  10253. }
  10254. if (($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) && $abDetail ['expensesType'] == 2) {
  10255. if ($abDetail ['expenditureMsg'] == '公司固定')
  10256. $accountType = 9;
  10257. elseif ($abDetail ['expenditureMsg'] == '公司活期')
  10258. $accountType = 10;
  10259. }
  10260. if (($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) && $abDetail ['expensesType'] == 1) {
  10261. if ($abDetail ['accountMsg'] == '公司固定')
  10262. $accountType = 9;
  10263. elseif ($abDetail ['accountMsg'] == '公司活期')
  10264. $accountType = 10;
  10265. }
  10266. if ($abDetail ['accountMsg'] == '活期理财收益') {
  10267. $accountType = 10;
  10268. }
  10269. $accountBookStatistics->setAccountBookStatistics ( $item );
  10270. $accountBook->delete ( array (
  10271. 'where' => 'aid=' . $aid,
  10272. 'limit' => 1
  10273. ) );
  10274. // 删除收入流水
  10275. if (! empty ( $accountType )) {
  10276. Doo::loadModel ( 'wasteBook' );
  10277. $wasteBook = new wasteBook ();
  10278. $wasteBook->delete ( array (
  10279. 'where' => 'dataID=' . $aid . ' and accountType=' . $accountType,
  10280. 'limit' => 1
  10281. ) );
  10282. }
  10283. }
  10284. return '/paymentsAchieve';
  10285. }
  10286. function paymentsCollect() {
  10287. Doo::loadModel ( "execute" );
  10288. $execute = new execute ();
  10289. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  10290. die ( 'illegal request' );
  10291. }
  10292. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10293. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  10294. Doo::loadModel ( "accountBookStatistics" );
  10295. $accountBookStatistics = new accountBookStatistics ();
  10296. Doo::loadClass ( 'receipt.func' );
  10297. $statisticsIncome = $accountBookStatistics->getStatisticsByCollect ( $year );
  10298. $html = _getPaymentsCollectByYearHtml ( $statisticsIncome );
  10299. $data ['html'] = $html ['html'];
  10300. $data ['inSum'] = $html ['sum'];
  10301. $statisticsPay = $accountBookStatistics->getStatisticsByCollect ( $year, 2 );
  10302. $html = _getPaymentsCollectPayByYearHtml ( $statisticsPay );
  10303. $data ['payHtml'] = $html ['html'];
  10304. $data ['paySum'] = $html ['sum'];
  10305. // 余额统计
  10306. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1 );
  10307. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2 );
  10308. include './protected/config/wasteBook.conf.php';
  10309. Doo::loadModel ( 'wasteBook' );
  10310. $wasteBook = new wasteBook ();
  10311. $inComePay = $wasteBook->getWasteBookByStatistics ( 1, $year );
  10312. $pay = $wasteBook->getWasteBookByStatistics ( 2, $year );
  10313. // 获得年份之前所有金额
  10314. $detail = $wasteBook->getWasteBookByStatisticsYear ( $year );
  10315. // print_r($detail);
  10316. // $waste['total'];
  10317. $lastBalanceHtml = '<tr><th colspan="2">截至上月余额</th>';
  10318. $inComeHtml = '<tr><th colspan="2">收入</th>';
  10319. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  10320. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  10321. $inSum = $paySum = $showInSum = $showPaySum = $balanceSum = 0;
  10322. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  10323. $limitMonth = date ( 'm' ); // 限制显示月份参数
  10324. if (date ( 'Y' ) > $year) {
  10325. $limitMonth = 12;
  10326. }
  10327. for($i = 1; $i <= 12; $i ++) {
  10328. $inComeA = $payB = 0;
  10329. $falg = true;
  10330. foreach ( $inComePay as $key => $value ) {
  10331. if ($value ['month'] == $i) {
  10332. $falg = false;
  10333. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  10334. $inSum += $value ['accountPrice'];
  10335. $showInSum += $value ['accountPriceShow'];
  10336. $inComeA = $value ['accountPrice'];
  10337. break;
  10338. }
  10339. }
  10340. if ($falg)
  10341. $inComeHtml .= '<td class="taR">-</td>';
  10342. $payFalg = true;
  10343. foreach ( $pay as $key => $value ) {
  10344. if ($value ['month'] == $i) {
  10345. $payFalg = false;
  10346. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  10347. $paySum += $value ['accountPrice'];
  10348. $showPaySum += $value ['accountPriceShow'];
  10349. $payB = $value ['accountPrice'];
  10350. break;
  10351. }
  10352. }
  10353. if ($payFalg)
  10354. $payHtml .= '<td class="taR">-</td>';
  10355. if (empty ( $balanceC ) || $limitMonth < $i)
  10356. $lastBalanceHtml .= '<td class="taR">-</td>';
  10357. else
  10358. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  10359. $balanceC = $balanceC + $inComeA + $payB;
  10360. $balanceSum += $balanceC;
  10361. if (empty ( $balanceC ) || $limitMonth < $i)
  10362. $BalanceHtml .= '<td class="taR">-</td>';
  10363. else
  10364. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  10365. // 余额统计
  10366. }
  10367. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  10368. $data ['inComeHtml'] = $inComeHtml;
  10369. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  10370. $data ['payBalanceHtml'] = $payHtml;
  10371. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  10372. $data ['BalanceHtml'] = $BalanceHtml;
  10373. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  10374. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  10375. $mothHtml = "";
  10376. for($i = 1; $i <= 12; $i ++) {
  10377. if ($moth == $i)
  10378. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  10379. else
  10380. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  10381. }
  10382. $data ['mothHtml'] = $mothHtml;
  10383. $dateHtml = "";
  10384. $now = date ( "Y" );
  10385. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  10386. if ($YEARD <= $now) {
  10387. $dateHtml .= '<option ';
  10388. if ($year == $YEARD) {
  10389. $dateHtml .= 'selected ';
  10390. }
  10391. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  10392. }
  10393. }
  10394. $data ['dateHtml'] = $dateHtml;
  10395. $data ['year'] = $year;
  10396. $data ['memu'] = "receipt";
  10397. $data ['staff'] = $this->staff;
  10398. $data ['receiptMemu'] = 'paymentsCollect';
  10399. $data ['verifyId'] = $this->verifyId;
  10400. $data ['executeId'] = $this->executeId;
  10401. $this->render ( "/expenses/paymentsCollect", $data );
  10402. }
  10403. function paymentsCollectDay() {
  10404. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10405. $moth = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : '';
  10406. if (empty ( $moth ))
  10407. return 'paymentsCollect';
  10408. Doo::loadModel ( "accountBookStatistics" );
  10409. $accountBookStatistics = new accountBookStatistics ();
  10410. $i = 2;
  10411. $y = 2013;
  10412. $day = date ( "t", strtotime ( "$year-$moth" ) );
  10413. Doo::loadClass ( 'receipt.func' );
  10414. $statisticsIncome = $accountBookStatistics->getStatisticsByCollectDay ( $year, 1, $moth );
  10415. $html = _getPaymentsCollectByDayHtml ( $statisticsIncome, $day );
  10416. $data ['html'] = $html ['html'];
  10417. $data ['inSum'] = $html ['sum'];
  10418. $statisticsPay = $accountBookStatistics->getStatisticsByCollectDay ( $year, 2, $moth );
  10419. $html = _getPaymentsCollectPayByDayHtml ( $statisticsPay, $day );
  10420. $data ['payHtml'] = $html ['html'];
  10421. $data ['paySum'] = $html ['sum'];
  10422. $mothHtml = "";
  10423. for($i = 1; $i <= 12; $i ++) {
  10424. if ($moth == $i)
  10425. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  10426. else
  10427. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  10428. }
  10429. $data ['mothHtml'] = $mothHtml;
  10430. $data ['year'] = $year;
  10431. // 余额
  10432. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1, $moth );
  10433. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2, $moth );
  10434. include './protected/config/wasteBook.conf.php';
  10435. Doo::loadModel ( 'wasteBook' );
  10436. $wasteBook = new wasteBook ();
  10437. $inComePay = $wasteBook->getStatisticsByDay ( 1, $year, $moth );
  10438. $pay = $wasteBook->getStatisticsByDay ( 2, $year, $moth );
  10439. // 获得年份之前所有金额
  10440. $detail = $wasteBook->getWasteBookByStatisticsDay ( $year, $moth );
  10441. $lastBalanceHtml = '<tr><th colspan="2">截至上日余额</th>';
  10442. $inComeHtml = '<tr><th colspan="2">收入</th>';
  10443. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  10444. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  10445. $dayHtml = '<tr><th class="taC" colspan="2">余额</th>';
  10446. $inSum = $paySum = $showPaySum = $showInSum = $balanceSum = 0;
  10447. // $balanceC = 0;
  10448. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  10449. $limitDay = date ( 'd' );
  10450. $monthLK = ( int ) date ( 'm' );
  10451. if (date ( 'Y' ) > $year) {
  10452. $limitDay = cal_days_in_month ( CAL_GREGORIAN, date ( 'm' ), date ( 'Y' ) );
  10453. } elseif (date ( 'Y' ) <= $year && $monthLK < $moth) {
  10454. $limitDay = 0;
  10455. }
  10456. for($i = 1; $i <= $day; $i ++) {
  10457. $dayHtml .= '<td class="taC">' . $i . '日</td>';
  10458. $inComeA = $payB = 0;
  10459. $falg = true;
  10460. foreach ( $inComePay as $key => $value ) {
  10461. if ($value ['day'] == $i) {
  10462. $falg = false;
  10463. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  10464. $inSum += $value ['accountPrice'];
  10465. $showInSum += $value ['accountPriceShow'];
  10466. $inComeA = $value ['accountPrice'];
  10467. break;
  10468. }
  10469. }
  10470. if ($falg)
  10471. $inComeHtml .= '<td class="taR">-</td>';
  10472. $payFalg = true;
  10473. foreach ( $pay as $key => $value ) {
  10474. if ($value ['day'] == $i) {
  10475. $payFalg = false;
  10476. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  10477. $paySum += $value ['accountPrice'];
  10478. $showPaySum += $value ['accountPriceShow'];
  10479. $payB = $value ['accountPrice'];
  10480. break;
  10481. }
  10482. }
  10483. if ($payFalg)
  10484. $payHtml .= '<td class="taR">-</td>';
  10485. if (empty ( $balanceC ) || $limitDay < $i)
  10486. $lastBalanceHtml .= '<td class="taR">-</td>';
  10487. else
  10488. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  10489. $balanceC = $balanceC + $inComeA + $payB;
  10490. $balanceSum += $balanceC;
  10491. if (empty ( $balanceC ) || $limitDay < $i)
  10492. $BalanceHtml .= '<td class="taR">-</td>';
  10493. else
  10494. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  10495. }
  10496. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  10497. $data ['inComeHtml'] = $inComeHtml;
  10498. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  10499. $data ['payBalanceHtml'] = $payHtml;
  10500. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  10501. $data ['BalanceHtml'] = $BalanceHtml;
  10502. $dayHtml .= '<td class="taR ">总计</td></tr>';
  10503. $data ['dayHtml'] = $dayHtml;
  10504. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  10505. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  10506. $dateHtml = "";
  10507. $now = date ( "Y" );
  10508. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  10509. if ($YEARD <= $now) {
  10510. $dateHtml .= '<option ';
  10511. if ($year == $YEARD) {
  10512. $dateHtml .= 'selected ';
  10513. }
  10514. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  10515. }
  10516. }
  10517. $data ['dateHtml'] = $dateHtml;
  10518. $data ['memu'] = "receipt";
  10519. $data ['staff'] = $this->staff;
  10520. $data ['receiptMemu'] = 'paymentsCollect';
  10521. $data ['verifyId'] = $this->verifyId;
  10522. $data ['executeId'] = $this->executeId;
  10523. $this->render ( "/expenses/paymentsCollectDay", $data );
  10524. }
  10525. function ajaxGetPaymentsByAid() {
  10526. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  10527. Doo::loadModel ( "accountBook" );
  10528. $accountBook = new accountBook ();
  10529. $detail = $accountBook->getAccountBookByAid ( $serial );
  10530. echo json_encode ( array (
  10531. 'status' => 1,
  10532. 'detail' => $detail
  10533. ) );
  10534. }
  10535. // 公司流水
  10536. function wasteBook() {
  10537. Doo::loadModel ( "execute" );
  10538. $execute = new execute ();
  10539. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  10540. die ( 'illegal request' );
  10541. }
  10542. include './protected/config/wasteBook.conf.php';
  10543. Doo::loadModel ( 'wasteBook' );
  10544. $wasteBook = new wasteBook ();
  10545. $inComeStatistics = $wasteBook->getWasteBookStatisticsByIncome ();
  10546. $waste = $this->getWasteBookStatistics ( $waste, $inComeStatistics );
  10547. $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'];
  10548. // print_r($waste);
  10549. $data ['waste'] = $waste;
  10550. $data ['total'] = $total;
  10551. // 月流水数据结构
  10552. $monthStatistics = array ();
  10553. $incomeMothStatistics = array ();
  10554. $expenditureMothStatistics = array ();
  10555. for($i = 1; $i <= 12; $i ++) {
  10556. $month = date ( 'Y' ) . '-' . $i;
  10557. if ($i < 10)
  10558. $month = date ( 'Y' ) . '-0' . $i;
  10559. array_push ( $monthStatistics, $month );
  10560. }
  10561. foreach ( $monthStatistics as $value ) {
  10562. $falg = true;
  10563. foreach ( $inComeStatistics ['incomeReport'] as $k => $v ) {
  10564. if ($value == $v ['inputDate']) {
  10565. array_push ( $incomeMothStatistics, $v ['accountPrice'] );
  10566. $falg = false;
  10567. }
  10568. }
  10569. if ($falg) {
  10570. array_push ( $incomeMothStatistics, '' );
  10571. }
  10572. $falgEx = true;
  10573. foreach ( $inComeStatistics ['expenditureReport'] as $k => $v ) {
  10574. if ($value == $v ['inputDate']) {
  10575. array_push ( $expenditureMothStatistics, $v ['accountPrice'] );
  10576. $falg = false;
  10577. }
  10578. }
  10579. if ($falgEx) {
  10580. array_push ( $expenditureMothStatistics, '' );
  10581. }
  10582. }
  10583. $data ['monthStatistics'] = json_encode ( $monthStatistics );
  10584. $data ['incomeMothStatistics'] = json_encode ( $incomeMothStatistics );
  10585. $data ['expenditureMothStatistics'] = json_encode ( $expenditureMothStatistics );
  10586. $expenditureList = $wasteBook->getAccountBookByExpensesType ( 4, 2 );
  10587. $incomeList = $wasteBook->getAccountBookByExpensesType ( 4, 1 );
  10588. // print_r($incomeList);
  10589. $data ['expenditureList'] = $expenditureList;
  10590. $data ['incomeList'] = $incomeList;
  10591. $data ['memu'] = "receipt";
  10592. $data ['staff'] = $this->staff;
  10593. $data ['receiptMemu'] = 'wasteBook';
  10594. $data ['verifyId'] = $this->verifyId;
  10595. $data ['executeId'] = $this->executeId;
  10596. $this->render ( "/expenses/wasteBook", $data );
  10597. }
  10598. function wasteBookIncome() {
  10599. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  10600. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  10601. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  10602. $dailyIncomeType = $this->get_args ( 'dailyIncomeType' ) ? $this->get_args ( 'dailyIncomeType' ) : "ALL";
  10603. $data ['dailyIncomeType'] = $dailyIncomeType;
  10604. Doo::loadModel ( 'wasteBook' );
  10605. $wasteBook = new wasteBook ();
  10606. Doo::loadModel ( 'L_category' );
  10607. $L_category = new L_category ();
  10608. Doo::loadClass ( 'XDeode' );
  10609. $XDeode = new XDeode ( 5 );
  10610. // echo $XDeode->encode(1).'<br>';
  10611. // echo $XDeode->encode(2).'<br>';
  10612. // echo $XDeode->encode(3).'<br>';
  10613. // echo $XDeode->encode(4).'<br>';
  10614. // echo $XDeode->encode(5).'<br>';
  10615. // echo $XDeode->encode(6).'<br>';
  10616. // echo $XDeode->encode(7).'<br>';
  10617. // echo $XDeode->encode(8).'<br>';
  10618. // echo $XDeode->encode(9).'<br>';
  10619. // echo $XDeode->encode(10).'<br>';
  10620. $dateArr = explode ( ':', $date );
  10621. $D1 = '';
  10622. $D2 = '';
  10623. $con = '';
  10624. if (! empty ( $date )) {
  10625. $D1 = $dateArr [0];
  10626. $D2 = $dateArr [1];
  10627. }
  10628. if (! empty ( $D1 ) && ! empty ( $D2 ))
  10629. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  10630. elseif (! empty ( $D1 ) && empty ( $D2 ))
  10631. $con = ' and inputDate = "' . $D1 . '"';
  10632. if ($cid != 'ALL') {
  10633. $cid = $XDeode->decode ( $cid );
  10634. $con .= ' and cid = "' . $cid . '"';
  10635. }
  10636. if ($accountType != 'ALL') {
  10637. if ($accountType == 'INVOICE') {
  10638. $con .= ' and (accountType = 7 or accountType = 8)';
  10639. } elseif ($accountType == 'PAYMENTS') {
  10640. $con .= ' and (accountType = 6 or accountType = 9 or accountType = 10)';
  10641. if ($dailyIncomeType != 'ALL') {
  10642. $dailyIncomeType = $XDeode->decode ( $dailyIncomeType );
  10643. $con .= ' and dailyIncomeType = ' . $dailyIncomeType;
  10644. }
  10645. }
  10646. }
  10647. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 1, $con );
  10648. $sum = 0;
  10649. foreach ( $incomeList as $key => $value ) {
  10650. $sum += $value ['accountPrice'];
  10651. }
  10652. // print_r($incomeList);
  10653. // 获得办事和部门
  10654. $categoryList = $L_category->getCategory ();
  10655. $data ['accountType'] = $accountType;
  10656. $data ['cid'] = $cid;
  10657. $data ['categoryList'] = $categoryList;
  10658. $data ['sum'] = $sum;
  10659. $data ['incomeList'] = $incomeList;
  10660. $data ['inputDate'] = $date;
  10661. $data ['memu'] = "receipt";
  10662. $data ['staff'] = $this->staff;
  10663. $data ['receiptMemu'] = 'wasteBook';
  10664. $data ['verifyId'] = $this->verifyId;
  10665. $data ['executeId'] = $this->executeId;
  10666. $this->render ( "/expenses/wasteBookIncome", $data );
  10667. }
  10668. /**
  10669. * 所有支出
  10670. */
  10671. function wasteBookExpenditure() {
  10672. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  10673. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  10674. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  10675. $dailyExpenditureType = $this->get_args ( 'dailyExpenditureType' ) ? $this->get_args ( 'dailyExpenditureType' ) : "ALL";
  10676. $data ['dailyExpenditureType'] = $dailyExpenditureType;
  10677. $receiptType = $this->get_args ( 'receiptType' ) ? $this->get_args ( 'receiptType' ) : "ALL";
  10678. $data ['receiptType'] = $receiptType;
  10679. Doo::loadModel ( 'wasteBook' );
  10680. $wasteBook = new wasteBook ();
  10681. Doo::loadModel ( 'L_category' );
  10682. $L_category = new L_category ();
  10683. Doo::loadClass ( 'XDeode' );
  10684. $XDeode = new XDeode ( 5 );
  10685. $dateArr = explode ( ':', $date );
  10686. $D1 = '';
  10687. $D2 = '';
  10688. $con = '';
  10689. if (! empty ( $date )) {
  10690. $D1 = $dateArr [0];
  10691. $D2 = $dateArr [1];
  10692. }
  10693. if (! empty ( $D1 ) && ! empty ( $D2 ))
  10694. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  10695. elseif (! empty ( $D1 ) && empty ( $D2 ))
  10696. $con = ' and inputDate = "' . $D1 . '"';
  10697. if ($cid != 'ALL') {
  10698. $cid = $XDeode->decode ( $cid );
  10699. $con .= ' and cid = "' . $cid . '"';
  10700. }
  10701. if ($accountType != 'ALL') {
  10702. if ($accountType == 'INVOICE') {
  10703. $con .= ' and accountType = 11';
  10704. } elseif ($accountType == 'PAYMENTS') {
  10705. $con .= ' and (accountType = 5 or accountType = 9 or accountType = 10)';
  10706. if ($dailyExpenditureType != 'ALL') {
  10707. $dailyExpenditureType = $XDeode->decode ( $dailyExpenditureType );
  10708. $con .= ' and dailyExpenditureType = ' . $dailyExpenditureType;
  10709. }
  10710. } elseif ($accountType == 'RECEIPT') {
  10711. if ($receiptType == 'ALL') {
  10712. $con .= ' and (accountType = 1 or accountType = 2 or accountType = 3 or accountType = 4)';
  10713. } else {
  10714. $receiptType = $XDeode->decode ( $receiptType );
  10715. echo $receiptType;
  10716. if ($receiptType == 1) {
  10717. $con .= ' and (accountType = 1 or accountType=2)';
  10718. } else {
  10719. $con .= ' and accountType = ' . $receiptType;
  10720. }
  10721. }
  10722. }
  10723. }
  10724. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 2, $con );
  10725. $sum = 0;
  10726. foreach ( $incomeList as $key => $value ) {
  10727. $sum += $value ['accountPriceShow'];
  10728. }
  10729. // print_r($incomeList);
  10730. // 获得办事和部门
  10731. $categoryList = $L_category->getCategory ();
  10732. $data ['accountType'] = $accountType;
  10733. $data ['cid'] = $cid;
  10734. $data ['categoryList'] = $categoryList;
  10735. $data ['sum'] = $sum;
  10736. $data ['incomeList'] = $incomeList;
  10737. $data ['inputDate'] = $date;
  10738. $data ['memu'] = "receipt";
  10739. $data ['staff'] = $this->staff;
  10740. $data ['receiptMemu'] = 'wasteBook';
  10741. $data ['verifyId'] = $this->verifyId;
  10742. $data ['executeId'] = $this->executeId;
  10743. $this->render ( "/expenses/wasteBookExpenditure", $data );
  10744. }
  10745. function ajaxGetWasteinvoiceReceivables() {
  10746. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  10747. Doo::loadClass ( 'XDeode' );
  10748. $XDeode = new XDeode ( 5 );
  10749. $irid = $XDeode->decode ( $serial );
  10750. Doo::loadModel ( 'invoiceReceivables' );
  10751. $invoiceReceivables = new invoiceReceivables ();
  10752. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  10753. echo json_encode ( array (
  10754. 'status' => 1,
  10755. 'detail' => $detail
  10756. ) );
  10757. }
  10758. function ajaxGetWasteInvoice() {
  10759. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  10760. Doo::loadModel ( 'invoice' );
  10761. $invoice = new invoice ();
  10762. Doo::loadModel ( 'invoiceReceivables' );
  10763. $invoiceReceivables = new invoiceReceivables ();
  10764. $detail = $invoice->getInvoiceByIid ( $serial );
  10765. $detailReceivables = $invoiceReceivables->getInvoiceReceivablesByIrid ( $detail ['irid'] );
  10766. $detail ['receivablesBank'] = $detailReceivables ['receivablesBank'];
  10767. echo json_encode ( array (
  10768. 'status' => 1,
  10769. 'detail' => $detail
  10770. ) );
  10771. }
  10772. /**
  10773. */
  10774. function ajaxGetWasteReceipt() {
  10775. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  10776. Doo::loadModel ( 'receipt' );
  10777. $receipt = new receipt ();
  10778. Doo::loadClass ( 'XDeode' );
  10779. $XDeode = new XDeode ( 5 );
  10780. $rid = $XDeode->decode ( $serial );
  10781. // 获得个数据
  10782. $detail = $receipt->getReceiptByRid ( $rid );
  10783. // 初始化
  10784. $detail ['reviseDetail'] = array ();
  10785. if (! empty ( $value ['reviseDetail'] ))
  10786. $detail ['reviseDetail'] = json_decode ( $detail ['reviseDetail'], true );
  10787. $detail ['accountItem'] = json_decode ( $detail ['accountItem'], true );
  10788. $detail ['loanItem'] = json_decode ( $detail ['loanItem'], true );
  10789. $detail ['loanSumCN'] = $this->num_to_rmb ( $detail ['loanSum'] );
  10790. $detail ['sumCN'] = $this->num_to_rmb ( $detail ['sum'] );
  10791. // 获得费用html
  10792. $html = $this->getWasteReceiptHtml ( $detail );
  10793. // 获得费用审批人数据
  10794. $detail = $this->getReceiptApproverHtml ( $detail );
  10795. // 审批执行
  10796. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  10797. <th class="taC" width="90">审批人</th>
  10798. <th class="taC">审批意见</th></tr>';
  10799. foreach ( $detail ['verifyList'] as $key => $value ) {
  10800. $html .= '<tr>
  10801. <td>' . $value [1] . '</td>
  10802. <td>' . $value ['opinion'] . '</td>
  10803. </tr>
  10804. ';
  10805. }
  10806. $html .= ' </tbody></table>';
  10807. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  10808. <th class="taC" width="90">执行人</th>
  10809. <th class="taC">执行意见</th></tr>';
  10810. foreach ( $detail ['executeCopy'] as $key => $value ) {
  10811. $html .= '<tr>
  10812. <td>' . $value [1] . '</td>
  10813. <td>' . $value ['opinion'] . '</td>
  10814. </tr>
  10815. ';
  10816. }
  10817. $html .= ' </tbody></table>';
  10818. $html .= '<table class="table table-bordered table-condensed">
  10819. <tr class="warning">
  10820. <td class="taR"><b>汇款金额</b></td>
  10821. <td width="140" class="taR"><b style="font-size: 24px">¥' . $detail ['amount'] . '</b></td>
  10822. </tr>
  10823. </table>';
  10824. // print_r($detail['verifyList']);
  10825. // header ( 'Content-Type:text/html;charset=utf-8' );
  10826. // echo $html;
  10827. echo json_encode ( array (
  10828. 'status' => 1,
  10829. 'html' => $html,
  10830. 'detail' => $detail
  10831. ) );
  10832. }
  10833. function getReceiptApproverHtml($detail = array()) {
  10834. Doo::loadModel ( 'loanReceipt' );
  10835. $loanReceipt = new loanReceipt ();
  10836. Doo::loadModel ( 'verify' );
  10837. $verify = new verify ();
  10838. Doo::loadModel ( 'staff' );
  10839. $staff = new staff ();
  10840. if (empty ( $detail ))
  10841. return array ();
  10842. $loanList = $loanReceipt->getOne ( array (
  10843. 'where' => 'rid=' . $detail ['loanRid'],
  10844. 'desc' => 'rid',
  10845. 'asArray' => true
  10846. ) );
  10847. if ($detail ['status'] == 3 || $detail ['status'] == 1 || $detail ['status'] == 8 || $detail ['status'] == 9) {
  10848. if ($detail ['status'] == 8 && $detail ['Rtype'] == 1)
  10849. $verifyList ['staff'] = $loanList ['verifyBreakup'];
  10850. else
  10851. $verifyList ['staff'] = $detail ['verifyBreakup'];
  10852. } else
  10853. $verifyList = $verify->getOne ( array (
  10854. 'where' => 'vid=' . $detail ['verify'],
  10855. 'asArray' => true
  10856. ) );
  10857. $verifyList = json_decode ( $verifyList ['staff'], true );
  10858. Doo::loadModel ( 'role' );
  10859. $role = new role ();
  10860. $roleId = 0;
  10861. $flag = true;
  10862. $roleKey = 0;
  10863. $endStaffArray = array ();
  10864. $roleArrayCopy = array ();
  10865. foreach ( $verifyList as $k => $v ) {
  10866. // init verifyStaff
  10867. if ($v [1] == 'ROLE') {
  10868. if (! empty ( $verifyStaff )) {
  10869. $endStaffArray = end ( $verifyStaff );
  10870. }
  10871. $roleVerify = json_decode ( $v [3], true );
  10872. $roleKey = $k;
  10873. $roleArray = array ();
  10874. $rolename = $role->getOne ( array (
  10875. 'where' => 'rid=' . $v [0],
  10876. 'asArray' => true
  10877. ) );
  10878. foreach ( $roleVerify as $o => $p ) {
  10879. $staffID = explode ( '_', $p );
  10880. $staffInfo = $staff->getOne ( array (
  10881. 'where' => 'sid=' . $staffID [0],
  10882. 'asArray' => true
  10883. ) );
  10884. // print_r($staffID);
  10885. $exp = array (
  10886. 0 => $staffInfo ['sid'],
  10887. 1 => $staffID [1],
  10888. 2 => $staffInfo ['avatar'],
  10889. 'date' => '',
  10890. 'date' => '',
  10891. 'opinion' => '',
  10892. 'status' => '',
  10893. 'rolename' => $rolename ['name']
  10894. );
  10895. array_push ( $roleArray, $exp );
  10896. }
  10897. $roleArrayCopy [$v [0]] = $roleArray;
  10898. // $verifyList[$k]['roleArray']=$roleArray;
  10899. }
  10900. $verifyList [$k] ['date'] = "";
  10901. $verifyList [$k] ['opinion'] = "";
  10902. $verifyList [$k] ['status'] = "";
  10903. if (empty ( $verifyStaff )) {
  10904. $verifyList [$k] ['date'] = "";
  10905. $verifyList [$k] ['opinion'] = "";
  10906. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  10907. $verifyList [$k] ['status'] = 4;
  10908. $flag = false;
  10909. }
  10910. } else {
  10911. foreach ( $verifyStaff as $m => $u ) {
  10912. if ($v [0] == $m) {
  10913. $verifyList [$k] ['date'] = $u ['date'];
  10914. $verifyList [$k] ['opinion'] = $u ['opinion'];
  10915. $verifyList [$k] ['status'] = $u ['status'];
  10916. $flag = false;
  10917. break;
  10918. }
  10919. }
  10920. $endStaffArray = end ( $verifyStaff );
  10921. }
  10922. }
  10923. $rolename ['name'] = '';
  10924. if (! empty ( $roleId )) {
  10925. Doo::loadModel ( 'role' );
  10926. $role = new role ();
  10927. $rolename = $role->getOne ( array (
  10928. 'where' => 'rid=' . $roleId,
  10929. 'asArray' => true
  10930. ) );
  10931. }
  10932. if (! empty ( $verifyStaff ))
  10933. $endStaffArray = end ( $verifyStaff );
  10934. $KOP = false;
  10935. foreach ( $roleArrayCopy as $P => $A ) {
  10936. foreach ( $A as $MKI => $AVL ) {
  10937. if (! empty ( $verifyStaff )) {
  10938. // &&$rolename['rid']==$endStaffArray['nextStaff']
  10939. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  10940. $button = 4;
  10941. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  10942. }
  10943. foreach ( $verifyStaff as $m => $u ) {
  10944. $AVLFK = $AVL [0] . '_R';
  10945. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  10946. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  10947. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  10948. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  10949. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  10950. break;
  10951. }
  10952. }
  10953. } else {
  10954. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  10955. $button = 4;
  10956. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  10957. }
  10958. }
  10959. // $roleArray[$MKI]['rolename']=$rolename['name'];
  10960. $KOP = true;
  10961. }
  10962. }
  10963. foreach ( $roleArrayCopy as $k => $v ) {
  10964. foreach ( $verifyList as $m => $n ) {
  10965. if ($n [0] == $k) {
  10966. array_splice ( $verifyList, $m, 1, $v );
  10967. }
  10968. }
  10969. }
  10970. // 费用执行人相关数据
  10971. $executeCopy = json_decode ( $detail ['executeCopy'], true );
  10972. $executeStaff = json_decode ( $detail ['executeStaff'], true );
  10973. foreach ( $executeCopy as $k => $v ) {
  10974. $executeCopy [$k] ['date'] = '';
  10975. $executeCopy [$k] ['opinion'] = '';
  10976. $executeCopy [$k] ['status'] = '';
  10977. if (! empty ( $executeStaff ))
  10978. foreach ( $executeStaff as $m => $u ) {
  10979. if ($v [0] == $m) {
  10980. $executeCopy [$k] ['date'] = $u ['date'];
  10981. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  10982. $executeCopy [$k] ['status'] = $u ['status'];
  10983. break;
  10984. }
  10985. }
  10986. }
  10987. $detail ['executeCopy'] = $executeCopy;
  10988. $detail ['verifyList'] = $verifyList;
  10989. return $detail;
  10990. }
  10991. function getWasteReceiptHtml($detail = array()) {
  10992. if (empty ( $detail ))
  10993. return '';
  10994. $html = '';
  10995. if ($detail ['Rtype'] == 0) { // 报销单
  10996. $html .= '
  10997. <table class="table table-bordered table-condensed">
  10998. <tbody>
  10999. <tr>
  11000. <th colspan="2" class="taC">日常相关费用</th>
  11001. </tr>';
  11002. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  11003. $html .= '
  11004. <tr>
  11005. <th>' . $value ['name'] . '</th>
  11006. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11007. </tr>';
  11008. }
  11009. $html .= '
  11010. <tr>
  11011. <th class="taR">合计</th>
  11012. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  11013. </tr>';
  11014. $html .= '<tr>
  11015. <th colspan="2" class="taC">差旅相关费用</th>
  11016. </tr>';
  11017. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  11018. $html .= '
  11019. <tr>
  11020. <th>' . $value ['name'] . '</th>
  11021. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11022. </tr>';
  11023. }
  11024. $html .= '
  11025. <tr>
  11026. <th class="taR">合计</th>
  11027. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  11028. </tr>';
  11029. $html .= '<tr>
  11030. <th colspan="2" class="taC">培训班费用</th>
  11031. </tr>';
  11032. foreach ( $detail ['accountItem'] ['培训班费用'] as $key => $value ) {
  11033. $html .= '
  11034. <tr>
  11035. <th>' . $value ['name'] . '</th>
  11036. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11037. </tr>';
  11038. }
  11039. $html .= '
  11040. <tr>
  11041. <th class="taR">合计</th>
  11042. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['trainSum'] . '</td>
  11043. </tr>';
  11044. $html .= '<tr>
  11045. <th colspan="2" class="taC">其他</th>
  11046. </tr>';
  11047. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  11048. $html .= '
  11049. <tr>
  11050. <th>' . $value ['name'] . '</th>
  11051. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11052. </tr>';
  11053. }
  11054. $html .= '
  11055. <tr>
  11056. <th class="taR">合计</th>
  11057. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  11058. </tr>';
  11059. $html .= '<tr>
  11060. <th colspan="2" class="taC">报销金额调整</th>
  11061. </tr>';
  11062. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  11063. $html .= '
  11064. <tr>
  11065. <th>' . $value ['name'] . '</th>
  11066. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11067. </tr>';
  11068. }
  11069. $html .= '
  11070. <tr>
  11071. <th class="taR">合计</th>
  11072. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  11073. </tr>';
  11074. $html .= '
  11075. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  11076. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  11077. <tr><th class="taC" colspan="2">报销说明</th></tr>
  11078. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  11079. <tr class="warning">
  11080. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  11081. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  11082. </tr>
  11083. </tbody>
  11084. </table>';
  11085. } elseif ($detail ['Rtype'] == 2) {
  11086. $html .= '
  11087. <table class="table table-bordered table-condensed">
  11088. <tbody>
  11089. <tr>
  11090. <th colspan="2" class="taC">办事处相关费用</th>
  11091. </tr>';
  11092. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  11093. $html .= '
  11094. <tr>
  11095. <th>' . $value ['name'] . '</th>
  11096. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11097. </tr>';
  11098. }
  11099. $html .= '
  11100. <tr>
  11101. <th class="taR">合计</th>
  11102. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  11103. </tr>';
  11104. $html .= '
  11105. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  11106. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  11107. <tr><th class="taC" colspan="2">报销说明</th></tr>
  11108. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  11109. <tr class="warning">
  11110. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  11111. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  11112. </tr>
  11113. </tbody>
  11114. </table>';
  11115. } elseif ($detail ['Rtype'] == 1) {
  11116. if ($detail ['loanRid'] != 0 && ! empty ( $detail ['accountItem'] )) {
  11117. $html .= '<table class="table table-bordered table-condensed">
  11118. <tbody>
  11119. <tr>
  11120. <th colspan="2" class="taC">日常相关费用</th>
  11121. </tr>';
  11122. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  11123. $html .= '
  11124. <tr>
  11125. <th>' . $value ['name'] . '</th>
  11126. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11127. </tr>';
  11128. }
  11129. $html .= '
  11130. <tr>
  11131. <th class="taR">合计</th>
  11132. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  11133. </tr>';
  11134. $html .= '<tr>
  11135. <th colspan="2" class="taC">差旅相关费用</th>
  11136. </tr>';
  11137. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  11138. $html .= '
  11139. <tr>
  11140. <th>' . $value ['name'] . '</th>
  11141. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11142. </tr>';
  11143. }
  11144. $html .= '
  11145. <tr>
  11146. <th class="taR">合计</th>
  11147. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  11148. </tr>';
  11149. $html .= '<tr>
  11150. <th colspan="2" class="taC">培训班费用</th>
  11151. </tr>';
  11152. foreach ( $detail ['accountItem'] ['培训班费用'] as $key => $value ) {
  11153. $html .= '
  11154. <tr>
  11155. <th>' . $value ['name'] . '</th>
  11156. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11157. </tr>';
  11158. }
  11159. $html .= '
  11160. <tr>
  11161. <th class="taR">合计</th>
  11162. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['trainSum'] . '</td>
  11163. </tr>';
  11164. $html .= '<tr>
  11165. <th colspan="2" class="taC">其他</th>
  11166. </tr>';
  11167. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  11168. $html .= '
  11169. <tr>
  11170. <th>' . $value ['name'] . '</th>
  11171. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11172. </tr>';
  11173. }
  11174. $html .= '
  11175. <tr>
  11176. <th class="taR">合计</th>
  11177. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  11178. </tr>';
  11179. $html .= '<tr>
  11180. <th colspan="2" class="taC">报销金额调整</th>
  11181. </tr>';
  11182. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  11183. $html .= '
  11184. <tr>
  11185. <th>' . $value ['name'] . '</th>
  11186. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11187. </tr>';
  11188. }
  11189. $html .= '
  11190. <tr>
  11191. <th class="taR">合计</th>
  11192. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  11193. </tr>';
  11194. $html .= '
  11195. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  11196. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  11197. <tr><th class="taC" colspan="2">报销说明</th></tr>
  11198. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  11199. <tr class="warning">
  11200. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  11201. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  11202. </tr>
  11203. </tbody>
  11204. </table>';
  11205. }
  11206. Doo::loadModel ( 'loanReceipt' );
  11207. $loanReceipt = new loanReceipt ();
  11208. $loanList = $loanReceipt->getOne ( array (
  11209. 'where' => 'rid=' . $detail ['loanRid'],
  11210. 'desc' => 'rid',
  11211. 'asArray' => true
  11212. ) );
  11213. // print_r($loanList);
  11214. $html .= '<table class="table table-bordered table-condensed">
  11215. <tbody>
  11216. <tr>
  11217. <th colspan="2" class="taC">借款费用</th>
  11218. </tr>';
  11219. foreach ( $detail ['loanItem'] ['借款费用'] as $key => $value ) {
  11220. $html .= '<tr>
  11221. <th>' . $value ['name'] . '</th>
  11222. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11223. </tr>';
  11224. }
  11225. $html .= '<tr>
  11226. <th class="taC" colspan="2">产生费用所在办事处</th>
  11227. </tr>
  11228. <tr>
  11229. <th style="text-align: center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th>
  11230. </tr>
  11231. <tr>
  11232. <th class="taC" colspan="2">费用说明</th>
  11233. </tr>
  11234. <tr>
  11235. <td colspan="2">' . $loanList ['explanation'] . '</td>
  11236. </tr>
  11237. <tr class="warning">
  11238. <td class="taR"><b>(' . $loanList ['receiptOrder'] . ')本次费用合计</b></td>
  11239. <td class="taR"><b style="font-size: 24px">¥' . $detail ['loanSum'] . '</b><br>' . $detail ['loanSumCN'] . '</td>
  11240. </tr>
  11241. </tbody>
  11242. </table>
  11243. ';
  11244. }
  11245. return $html;
  11246. }
  11247. /**
  11248. * 计算流水
  11249. */
  11250. function getWasteBookStatistics($waste = array(), $inComeStatistics) {
  11251. $bakWaste ['bank'] = array (
  11252. 'CGBDeposit' => 0,
  11253. 'ICBCDeposit' => 0,
  11254. 'HUADeposit' => 0,
  11255. 'PersonalDeposit' => 0
  11256. );
  11257. $bakWaste ['financial'] = array (
  11258. 'current' => array (
  11259. 'CGBDeposit' => 0,
  11260. 'ICBCDeposit' => 0
  11261. ),
  11262. 'fixed' => array (
  11263. 'CGBDeposit' => 0,
  11264. 'ICBCDeposit' => 0
  11265. )
  11266. );
  11267. // 存款
  11268. foreach ( $waste ['bank'] as $key => $value ) {
  11269. // 收入
  11270. foreach ( $inComeStatistics ['incomeStatistics'] as $k => $v ) {
  11271. // 广发
  11272. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  11273. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  11274. }
  11275. // 工商
  11276. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  11277. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  11278. }
  11279. // 华润
  11280. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  11281. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  11282. }
  11283. // 个人
  11284. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  11285. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  11286. }
  11287. }
  11288. }
  11289. foreach ( $waste ['bank'] as $key => $value ) {
  11290. // 支出
  11291. foreach ( $inComeStatistics ['expenditureStatistics'] as $k => $v ) {
  11292. // 广发
  11293. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  11294. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  11295. }
  11296. // 工商
  11297. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  11298. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  11299. }
  11300. // 华润
  11301. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  11302. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  11303. }
  11304. // 个人
  11305. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  11306. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  11307. }
  11308. }
  11309. }
  11310. // 活期
  11311. foreach ( $waste ['financial'] ['current'] as $key => $value ) {
  11312. foreach ( $inComeStatistics ['currentStatistics'] as $k => $v ) {
  11313. // 广发
  11314. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  11315. $waste ['financial'] ['current'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  11316. }
  11317. // 工商
  11318. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  11319. $waste ['financial'] ['current'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  11320. }
  11321. // 个人
  11322. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  11323. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  11324. }
  11325. }
  11326. }
  11327. // print_r($inComeStatistics ['fixedStatistics']);
  11328. // 固期
  11329. foreach ( $waste ['financial'] ['fixed'] as $key => $value ) {
  11330. foreach ( $inComeStatistics ['fixedStatistics'] as $k => $v ) {
  11331. // 广发
  11332. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  11333. $waste ['financial'] ['fixed'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  11334. }
  11335. // 工商
  11336. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  11337. $waste ['financial'] ['fixed'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  11338. }
  11339. // 个人
  11340. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  11341. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  11342. }
  11343. }
  11344. }
  11345. return $waste;
  11346. }
  11347. function lyt() {
  11348. Doo::loadModel ( "receiptDetail" );
  11349. $receiptDetail = new receiptDetail ();
  11350. $receiptCollectList = $receiptDetail->find ( array (
  11351. 'where' => 'status=1 ',
  11352. 'asArray' => true
  11353. ) );
  11354. foreach ( $receiptCollectList as $key => $value ) {
  11355. $receiptDetail = new receiptDetail ();
  11356. $receiptDetail->pastDate = $value ['date'];
  11357. $receiptDetail->update ( array (
  11358. 'where' => "rdid= '" . $value ['rdid'] . "'"
  11359. ) );
  11360. }
  11361. }
  11362. function staffCollectMonthDetail() {
  11363. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  11364. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  11365. if (! $year)
  11366. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  11367. if (! $month)
  11368. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  11369. Doo::loadModel ( 'staff' );
  11370. $staff = new staff ();
  11371. Doo::loadModel ( "receiptDetail" );
  11372. $receiptDetail = new receiptDetail ();
  11373. Doo::loadModel ( 'accountItem' );
  11374. $accountItem = new accountItem ();
  11375. Doo::loadModel ( 'statistics' );
  11376. $statistics = new statistics ();
  11377. Doo::loadModel ( 'L_category' );
  11378. $lCategory = new L_category ();
  11379. Doo::loadModel ( "receiptAuthorityManage" );
  11380. $receiptAuthorityManage = new receiptAuthorityManage ();
  11381. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  11382. $cidList = array ();
  11383. foreach ( $imcStaff as $key => $value ) {
  11384. array_push ( $cidList, $value ['cid'] );
  11385. }
  11386. $cidString = implode ( ',', $cidList );
  11387. $staffList = $staff->find ( array (
  11388. 'where' => 'username!="admin" and cid in (' . $cidString . ')',
  11389. 'asArray' => true
  11390. ) );
  11391. $categoryList = $staff->find ( array (
  11392. 'select' => 'COUNT(*) as count,cid,category',
  11393. 'where' => 'username !="admin" and cid in (' . $cidString . ')',
  11394. 'groupby' => 'cid',
  11395. 'asArray' => true
  11396. ) );
  11397. $list = array ();
  11398. foreach ( $categoryList as $vlu ) {
  11399. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  11400. $r1 = 0;
  11401. $r2 = 0;
  11402. $r3 = 0;
  11403. $r4 = 0;
  11404. $r5 = 0;
  11405. $r6 = 0;
  11406. $r7 = 0;
  11407. $r8 = 0;
  11408. $r9 = 0;
  11409. $r10 = 0;
  11410. $r11 = 0;
  11411. $r12 = 0;
  11412. $r13 = 0;
  11413. $r14 = 0;
  11414. $r15 = 0;
  11415. $r16 = 0;
  11416. $r17 = 0;
  11417. $r18 = 0;
  11418. $c1 = 0;
  11419. $c2 = 0;
  11420. $c3 = 0;
  11421. $c4 = 0;
  11422. $c5 = 0;
  11423. $c6 = 0;
  11424. $p1 = 0;
  11425. $p2 = 0;
  11426. $p3 = 0;
  11427. $p4 = 0;
  11428. $p5 = 0;
  11429. $p6 = 0;
  11430. $p7 = 0;
  11431. $p8 = 0;
  11432. $p9 = 0;
  11433. $p10 = 0;
  11434. $p11 = 0;
  11435. $t1 = 0;
  11436. $t2 = 0;
  11437. $t3 = 0;
  11438. $t4 = 0;
  11439. $t5 = 0;
  11440. $s1 = 0;
  11441. $m1 = 0;
  11442. foreach ( $staffList as $value ) {
  11443. if ($vlu ['cid'] == $value ['cid']) {
  11444. // pastDate
  11445. $receiptCollectList = $receiptDetail->find ( array (
  11446. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  11447. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  11448. 'groupby' => 'item,Month(pastDate),itemCategory',
  11449. 'asArray' => true
  11450. ) );
  11451. // if ($value['sid']==42){
  11452. // print_r($receiptCollectList);die;
  11453. // }
  11454. if (! empty ( $receiptCollectList )) {
  11455. $receiptL = array (
  11456. '日常相关费用' => array (),
  11457. '差旅相关费用' => array (),
  11458. '培训班费用' => array (),
  11459. '其他' => array ()
  11460. );
  11461. $html = "";
  11462. $psum = 0;
  11463. $item = array (
  11464. '市内交通费',
  11465. '市内出租费',
  11466. '办事处房租',
  11467. '电话费',
  11468. '水费',
  11469. '电费',
  11470. '办公费用',
  11471. '邮寄费',
  11472. '其他费用',
  11473. '车辆费用',
  11474. '广告费',
  11475. '团队建设费',
  11476. '物业管理费',
  11477. '宽带费',
  11478. '人员薪酬',
  11479. '公积金',
  11480. '社保'
  11481. );
  11482. foreach ( $item as $va ) {
  11483. $falg = true;
  11484. foreach ( $receiptCollectList as $v ) {
  11485. if ($v ['itemCategory'] == '日常相关费用') {
  11486. if ($v ['item'] == $va) {
  11487. if ($va == '市内交通费')
  11488. $r1 += $v ['price'];
  11489. if ($va == '市内出租费')
  11490. $r2 += $v ['price'];
  11491. if ($va == '办事处房租')
  11492. $r3 += $v ['price'];
  11493. if ($va == '电话费')
  11494. $r4 += $v ['price'];
  11495. if ($va == '水费')
  11496. $r5 += $v ['price'];
  11497. if ($va == '电费')
  11498. $r6 += $v ['price'];
  11499. if ($va == '办公费用')
  11500. $r7 += $v ['price'];
  11501. if ($va == '邮寄费')
  11502. $r8 += $v ['price'];
  11503. if ($va == '其他费用')
  11504. $r9 += $v ['price'];
  11505. if ($va == '车辆费用')
  11506. $r10 += $v ['price'];
  11507. if ($va == '广告费')
  11508. $r11 += $v ['price'];
  11509. if ($va == '团队建设费')
  11510. $r13 += $v ['price'];
  11511. if ($va == '物业管理费')
  11512. $r14 += $v ['price'];
  11513. if ($va == '宽带费')
  11514. $r15 += $v ['price'];
  11515. if ($va == '公积金')
  11516. $r16 += $v ['price'];
  11517. if ($va == '社保')
  11518. $r17 += $v ['price'];
  11519. if ($va == '人员薪酬')
  11520. $r18 += $v ['price'];
  11521. $psum += $v ['price'];
  11522. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11523. $falg = false;
  11524. break;
  11525. }
  11526. }
  11527. }
  11528. if ($falg)
  11529. $html .= '<td class="taR">-</td>';
  11530. }
  11531. $r12 += $psum;
  11532. if (! empty ( $psum ))
  11533. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  11534. else
  11535. $psum = '<td class="colGreen taR">-</td>';
  11536. $receiptL ['日常相关费用'] = $psum . $html;
  11537. /* ----------------------------------- */
  11538. $html = "";
  11539. $psum = 0;
  11540. $item = array (
  11541. '往来交通费',
  11542. '市内交通费',
  11543. '出差住宿费',
  11544. '出差补助',
  11545. '其他费用'
  11546. );
  11547. foreach ( $item as $va ) {
  11548. $falg = true;
  11549. foreach ( $receiptCollectList as $v ) {
  11550. if ($v ['itemCategory'] == '差旅相关费用') {
  11551. if ($v ['item'] == $va) {
  11552. if ($va == '往来交通费')
  11553. $c1 += $v ['price'];
  11554. if ($va == '市内交通费')
  11555. $c2 += $v ['price'];
  11556. if ($va == '出差住宿费')
  11557. $c3 += $v ['price'];
  11558. if ($va == '出差补助')
  11559. $c4 += $v ['price'];
  11560. if ($va == '其他费用')
  11561. $c5 += $v ['price'];
  11562. $psum += $v ['price'];
  11563. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11564. $falg = false;
  11565. break;
  11566. }
  11567. }
  11568. }
  11569. if ($falg)
  11570. $html .= '<td class="taR">-</td>';
  11571. }
  11572. $c6 += $psum;
  11573. if (! empty ( $psum ))
  11574. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  11575. else
  11576. $psum = '<td class="colGreen taR">-</td>';
  11577. $receiptL ['差旅相关费用'] = $psum . $html;
  11578. /* ------------------------------------- */
  11579. $html = "";
  11580. $psum = 0;
  11581. $item = array (
  11582. '场租费',
  11583. '薪酬',
  11584. '住宿费',
  11585. '交通费',
  11586. '餐饮费',
  11587. '办公费',
  11588. '公关费',
  11589. '其他',
  11590. '电话费',
  11591. '邮寄费'
  11592. );
  11593. foreach ( $item as $va ) {
  11594. $falg = true;
  11595. foreach ( $receiptCollectList as $v ) {
  11596. if ($v ['itemCategory'] == '培训班费用') {
  11597. if ($v ['item'] == $va) {
  11598. if ($va == '场租费')
  11599. $p1 += $v ['price'];
  11600. if ($va == '薪酬')
  11601. $p2 += $v ['price'];
  11602. if ($va == '住宿费')
  11603. $p3 += $v ['price'];
  11604. if ($va == '交通费')
  11605. $p4 += $v ['price'];
  11606. if ($va == '餐饮费')
  11607. $p5 += $v ['price'];
  11608. if ($va == '办公费')
  11609. $p6 += $v ['price'];
  11610. if ($va == '公关费')
  11611. $p7 += $v ['price'];
  11612. if ($va == '其他')
  11613. $p8 += $v ['price'];
  11614. if ($va == '电话费')
  11615. $p9 += $v ['price'];
  11616. if ($va == '邮寄费')
  11617. $p10 += $v ['price'];
  11618. $psum += $v ['price'];
  11619. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11620. $falg = false;
  11621. break;
  11622. }
  11623. }
  11624. }
  11625. if ($falg)
  11626. $html .= '<td class="taR">-</td>';
  11627. }
  11628. $p11 += $psum;
  11629. if (! empty ( $psum ))
  11630. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  11631. else
  11632. $psum = '<td class="colGreen taR">-</td>';
  11633. $receiptL ['培训班费用'] = $psum . $html;
  11634. /* ------------------------------------- */
  11635. $html = "";
  11636. $psum = 0;
  11637. $item = array (
  11638. '公关费',
  11639. '广告费',
  11640. '借款',
  11641. '可自加费用'
  11642. );
  11643. foreach ( $item as $va ) {
  11644. $falg = true;
  11645. foreach ( $receiptCollectList as $v ) {
  11646. if ($v ['itemCategory'] == '其他') {
  11647. // if ($value['sid']==42){
  11648. //
  11649. // echo var_dump($v['item']);
  11650. // echo var_dump($va);
  11651. // echo var_dump($v['item']==" ".$va);
  11652. // echo $v['item']."==".$va."/<br/>";
  11653. // //print_r( $receiptCollectList);//echo $va;
  11654. // }
  11655. if (trim ( $v ['item'] ) == $va) {
  11656. if ($va == '公关费')
  11657. $t1 += $v ['price'];
  11658. if ($va == '广告费') {
  11659. $t2 += $v ['price'];
  11660. }
  11661. if ($va == '借款')
  11662. $t3 += $v ['price'];
  11663. if ($va == '可自加费用')
  11664. $t4 += $v ['price'];
  11665. $psum += $v ['price'];
  11666. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11667. $falg = false;
  11668. break;
  11669. }
  11670. }
  11671. }
  11672. if ($falg)
  11673. $html .= '<td class="taR">-</td>';
  11674. }
  11675. $t5 += $psum;
  11676. if (! empty ( $psum ))
  11677. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  11678. else
  11679. $psum = '<td class="colGreen taR">-</td>';
  11680. $receiptL ['其他'] = $psum . $html;
  11681. /* ------------------------------------- */
  11682. $html = "";
  11683. $psum = 0;
  11684. foreach ( $receiptCollectList as $v ) {
  11685. if ($v ['itemCategory'] == '报销金额调整') {
  11686. if (! empty ( $v ['price'] )) {
  11687. $psum += $v ['price'];
  11688. }
  11689. }
  11690. }
  11691. $s1 += $psum;
  11692. if (! empty ( $psum ))
  11693. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  11694. else
  11695. $psum = '<td class="taR colOrange">-</td>';
  11696. $receiptL ['报销金额调整'] = $psum . $html;
  11697. } else {
  11698. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  11699. <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>
  11700. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  11701. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  11702. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  11703. $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>
  11704. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  11705. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  11706. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  11707. }
  11708. $monthStaffPrice = $receiptDetail->find ( array (
  11709. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  11710. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  11711. 'groupby' => 'Month(pastDate)',
  11712. 'asArray' => true
  11713. ) );
  11714. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  11715. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  11716. $m1 += $monthStaffPrice [0] ['price'];
  11717. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  11718. } else
  11719. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  11720. $receiptL ['usernameEn'] = urlencode ( $value ['username'] );
  11721. $list [$value ['username']] = $receiptL;
  11722. }
  11723. }
  11724. $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>
  11725. <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>
  11726. <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>';
  11727. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  11728. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  11729. $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>
  11730. <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>';
  11731. $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>';
  11732. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  11733. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  11734. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  11735. }
  11736. $data ['list'] = $list;
  11737. // print_r($list);
  11738. $receiptCollectList = $receiptDetail->find ( array (
  11739. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  11740. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  11741. 'groupby' => 'item,Month(pastDate),itemCategory',
  11742. 'asArray' => true
  11743. ) );
  11744. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  11745. // statistics html
  11746. $stList = $statistics->getOne ( array (
  11747. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  11748. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  11749. 'groupby' => 'Month(date)',
  11750. 'asArray' => true
  11751. ) );
  11752. if (empty ( $stList ))
  11753. $stList = array (
  11754. 'rePrice' => 0,
  11755. 'agPrice' => 0
  11756. );
  11757. $data ['stList'] = array (
  11758. 'rePrice' => $stList ['rePrice'],
  11759. 'agPrice' => $stList ['agPrice'],
  11760. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  11761. );
  11762. $monthHtml = "";
  11763. for($i = 1; $i <= 12; $i ++) {
  11764. if ($i == $month)
  11765. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  11766. else
  11767. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  11768. }
  11769. $data ['monthHtml'] = $monthHtml;
  11770. $data ['year'] = $year;
  11771. $data ['month'] = $month;
  11772. $data ['memu'] = "receipt";
  11773. $data ['staff'] = $this->staff;
  11774. $data ['receiptMemu'] = 'companyCategoryCollect';
  11775. $data ['verifyId'] = $this->verifyId;
  11776. $data ['executeId'] = $this->executeId;
  11777. $this->render ( "/admin/staffCollectMonthDetail", $data );
  11778. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  11779. }
  11780. function staffCollectMonthDetail2() {
  11781. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  11782. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  11783. if (! $year)
  11784. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  11785. if (! $month)
  11786. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  11787. Doo::loadModel ( 'staff' );
  11788. $staff = new staff ();
  11789. Doo::loadModel ( "receiptDetail" );
  11790. $receiptDetail = new receiptDetail ();
  11791. Doo::loadModel ( 'accountItem' );
  11792. $accountItem = new accountItem ();
  11793. Doo::loadModel ( 'statistics' );
  11794. $statistics = new statistics ();
  11795. Doo::loadModel ( 'L_category' );
  11796. $lCategory = new L_category ();
  11797. $staffList = $staff->find ( array (
  11798. 'where' => 'username!="admin"',
  11799. 'asArray' => true
  11800. ) );
  11801. $categoryList = $staff->find ( array (
  11802. 'select' => 'COUNT(*) as count,cid,category',
  11803. 'where' => 'username !="admin"',
  11804. 'groupby' => 'cid',
  11805. 'asArray' => true
  11806. ) );
  11807. $list = array ();
  11808. foreach ( $categoryList as $vlu ) {
  11809. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  11810. $r1 = 0;
  11811. $r2 = 0;
  11812. $r3 = 0;
  11813. $r4 = 0;
  11814. $r5 = 0;
  11815. $r6 = 0;
  11816. $r7 = 0;
  11817. $r8 = 0;
  11818. $r9 = 0;
  11819. $r10 = 0;
  11820. $r11 = 0;
  11821. $r12 = 0;
  11822. $r13 = 0;
  11823. $r14 = 0;
  11824. $r15 = 0;
  11825. $c1 = 0;
  11826. $c2 = 0;
  11827. $c3 = 0;
  11828. $c4 = 0;
  11829. $c5 = 0;
  11830. $c6 = 0;
  11831. $p1 = 0;
  11832. $p2 = 0;
  11833. $p3 = 0;
  11834. $p4 = 0;
  11835. $p5 = 0;
  11836. $p6 = 0;
  11837. $p7 = 0;
  11838. $p8 = 0;
  11839. $p9 = 0;
  11840. $t1 = 0;
  11841. $t2 = 0;
  11842. $t3 = 0;
  11843. $t4 = 0;
  11844. $t5 = 0;
  11845. $s1 = 0;
  11846. $m1 = 0;
  11847. foreach ( $staffList as $value ) {
  11848. if ($vlu ['cid'] == $value ['cid']) {
  11849. $receiptCollectList = $receiptDetail->find ( array (
  11850. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  11851. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  11852. 'groupby' => 'item,Month(date),itemCategory',
  11853. 'asArray' => true
  11854. ) );
  11855. if (! empty ( $receiptCollectList )) {
  11856. $receiptL = array (
  11857. '日常相关费用' => array (),
  11858. '差旅相关费用' => array (),
  11859. '培训班费用' => array (),
  11860. '其他' => array ()
  11861. );
  11862. $html = "";
  11863. $psum = 0;
  11864. $item = array (
  11865. '市内交通费',
  11866. '市内出租费',
  11867. '办事处房租',
  11868. '电话费',
  11869. '水费',
  11870. '电费',
  11871. '办公费用',
  11872. '邮寄费',
  11873. '其他费用',
  11874. '车辆费用',
  11875. '广告费',
  11876. '团队建设费',
  11877. '物业管理费',
  11878. '宽带费'
  11879. );
  11880. foreach ( $item as $va ) {
  11881. $falg = true;
  11882. foreach ( $receiptCollectList as $v ) {
  11883. if ($v ['itemCategory'] == '日常相关费用') {
  11884. if ($v ['item'] == $va) {
  11885. if ($va == '市内交通费')
  11886. $r1 += $v ['price'];
  11887. if ($va == '市内出租费')
  11888. $r2 += $v ['price'];
  11889. if ($va == '办事处房租')
  11890. $r3 += $v ['price'];
  11891. if ($va == '电话费')
  11892. $r4 += $v ['price'];
  11893. if ($va == '水费')
  11894. $r5 += $v ['price'];
  11895. if ($va == '电费')
  11896. $r6 += $v ['price'];
  11897. if ($va == '办公费用')
  11898. $r7 += $v ['price'];
  11899. if ($va == '邮寄费')
  11900. $r8 += $v ['price'];
  11901. if ($va == '其他费用')
  11902. $r9 += $v ['price'];
  11903. if ($va == '车辆费用')
  11904. $r10 += $v ['price'];
  11905. if ($va == '广告费')
  11906. $r11 += $v ['price'];
  11907. if ($va == '团队建设费')
  11908. $r13 += $v ['price'];
  11909. if ($va == '物业管理费')
  11910. $r14 += $v ['price'];
  11911. if ($va == '宽带费')
  11912. $r15 += $v ['price'];
  11913. $psum += $v ['price'];
  11914. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11915. $falg = false;
  11916. break;
  11917. }
  11918. }
  11919. }
  11920. if ($falg)
  11921. $html .= '<td class="taR">-</td>';
  11922. }
  11923. $r12 += $psum;
  11924. if (! empty ( $psum ))
  11925. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  11926. else
  11927. $psum = '<td class="colGreen taR">-</td>';
  11928. $receiptL ['日常相关费用'] = $psum . $html;
  11929. /* ----------------------------------- */
  11930. $html = "";
  11931. $psum = 0;
  11932. $item = array (
  11933. '往来交通费',
  11934. '市内交通费',
  11935. '出差住宿费',
  11936. '出差补助',
  11937. '其他费用'
  11938. );
  11939. foreach ( $item as $va ) {
  11940. $falg = true;
  11941. foreach ( $receiptCollectList as $v ) {
  11942. if ($v ['itemCategory'] == '差旅相关费用') {
  11943. if ($v ['item'] == $va) {
  11944. if ($va == '往来交通费')
  11945. $c1 += $v ['price'];
  11946. if ($va == '市内交通费')
  11947. $c2 += $v ['price'];
  11948. if ($va == '出差住宿费')
  11949. $c3 += $v ['price'];
  11950. if ($va == '出差补助')
  11951. $c4 += $v ['price'];
  11952. if ($va == '其他费用')
  11953. $c5 += $v ['price'];
  11954. $psum += $v ['price'];
  11955. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11956. $falg = false;
  11957. break;
  11958. }
  11959. }
  11960. }
  11961. if ($falg)
  11962. $html .= '<td class="taR">-</td>';
  11963. }
  11964. $c6 += $psum;
  11965. if (! empty ( $psum ))
  11966. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  11967. else
  11968. $psum = '<td class="colGreen taR">-</td>';
  11969. $receiptL ['差旅相关费用'] = $psum . $html;
  11970. /* ------------------------------------- */
  11971. $html = "";
  11972. $psum = 0;
  11973. $item = array (
  11974. '场租费',
  11975. '薪酬',
  11976. '住宿费',
  11977. '交通费',
  11978. '餐饮费',
  11979. '办公费',
  11980. '公关费',
  11981. '其他'
  11982. );
  11983. foreach ( $item as $va ) {
  11984. $falg = true;
  11985. foreach ( $receiptCollectList as $v ) {
  11986. if ($v ['itemCategory'] == '培训班费用') {
  11987. if ($v ['item'] == $va) {
  11988. if ($va == '场租费')
  11989. $p1 += $v ['price'];
  11990. if ($va == '薪酬')
  11991. $p2 += $v ['price'];
  11992. if ($va == '住宿费')
  11993. $p3 += $v ['price'];
  11994. if ($va == '交通费')
  11995. $p4 += $v ['price'];
  11996. if ($va == '餐饮费')
  11997. $p5 += $v ['price'];
  11998. if ($va == '办公费')
  11999. $p6 += $v ['price'];
  12000. if ($va == '公关费')
  12001. $p7 += $v ['price'];
  12002. if ($va == '其他')
  12003. $p8 += $v ['price'];
  12004. $psum += $v ['price'];
  12005. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12006. $falg = false;
  12007. break;
  12008. }
  12009. }
  12010. }
  12011. if ($falg)
  12012. $html .= '<td class="taR">-</td>';
  12013. }
  12014. $p9 += $psum;
  12015. if (! empty ( $psum ))
  12016. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12017. else
  12018. $psum = '<td class="colGreen taR">-</td>';
  12019. $receiptL ['培训班费用'] = $psum . $html;
  12020. /* ------------------------------------- */
  12021. $html = "";
  12022. $psum = 0;
  12023. $item = array (
  12024. '公关费',
  12025. '广告费',
  12026. '借款',
  12027. '可自加费用'
  12028. );
  12029. foreach ( $item as $va ) {
  12030. $falg = true;
  12031. foreach ( $receiptCollectList as $v ) {
  12032. if ($v ['itemCategory'] == '其他') {
  12033. if ($v ['item'] == $va) {
  12034. if ($va == '公关费')
  12035. $t1 += $v ['price'];
  12036. if ($va == '广告费')
  12037. $t2 += $v ['price'];
  12038. if ($va == '借款')
  12039. $t3 += $v ['price'];
  12040. if ($va == '可自加费用')
  12041. $t4 += $v ['price'];
  12042. $psum += $v ['price'];
  12043. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12044. $falg = false;
  12045. break;
  12046. }
  12047. }
  12048. }
  12049. if ($falg)
  12050. $html .= '<td class="taR">-</td>';
  12051. }
  12052. $t5 += $psum;
  12053. if (! empty ( $psum ))
  12054. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12055. else
  12056. $psum = '<td class="colGreen taR">-</td>';
  12057. $receiptL ['其他'] = $psum . $html;
  12058. /* ------------------------------------- */
  12059. $html = "";
  12060. $psum = 0;
  12061. foreach ( $receiptCollectList as $v ) {
  12062. if ($v ['itemCategory'] == '报销金额调整') {
  12063. if (! empty ( $v ['price'] )) {
  12064. $psum += $v ['price'];
  12065. }
  12066. }
  12067. }
  12068. $s1 += $psum;
  12069. if (! empty ( $psum ))
  12070. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  12071. else
  12072. $psum = '<td class="taR colOrange">-</td>';
  12073. $receiptL ['报销金额调整'] = $psum . $html;
  12074. } else {
  12075. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  12076. <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>';
  12077. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  12078. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12079. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  12080. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12081. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12082. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  12083. }
  12084. $monthStaffPrice = $receiptDetail->find ( array (
  12085. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  12086. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  12087. 'asArray' => true
  12088. ) );
  12089. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  12090. $m1 += $monthStaffPrice [0] ['price'];
  12091. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  12092. } else
  12093. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  12094. $list [$value ['username']] = $receiptL;
  12095. }
  12096. }
  12097. $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>
  12098. <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>
  12099. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  12100. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  12101. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  12102. $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>
  12103. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  12104. $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>';
  12105. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  12106. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  12107. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  12108. }
  12109. $data ['list'] = $list;
  12110. $receiptCollectList = $receiptDetail->find ( array (
  12111. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  12112. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  12113. 'groupby' => 'item,Month(date),itemCategory',
  12114. 'asArray' => true
  12115. ) );
  12116. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  12117. // statistics html
  12118. $stList = $statistics->getOne ( array (
  12119. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  12120. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  12121. 'groupby' => 'Month(date)',
  12122. 'asArray' => true
  12123. ) );
  12124. if (empty ( $stList ))
  12125. $stList = array (
  12126. 'rePrice' => 0,
  12127. 'agPrice' => 0
  12128. );
  12129. $data ['stList'] = array (
  12130. 'rePrice' => $stList ['rePrice'],
  12131. 'agPrice' => $stList ['agPrice'],
  12132. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  12133. );
  12134. $monthHtml = "";
  12135. for($i = 1; $i <= 12; $i ++) {
  12136. if ($i == $month)
  12137. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  12138. else
  12139. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  12140. }
  12141. $data ['monthHtml'] = $monthHtml;
  12142. $data ['year'] = $year;
  12143. $data ['month'] = $month;
  12144. $data ['memu'] = "receipt";
  12145. $data ['staff'] = $this->staff;
  12146. $data ['receiptMemu'] = 'companyCategoryCollect';
  12147. $data ['verifyId'] = $this->verifyId;
  12148. $data ['executeId'] = $this->executeId;
  12149. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  12150. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  12151. }
  12152. /**
  12153. * 用户报销单列表
  12154. */
  12155. function receiptStatisticsStaffDetail() {
  12156. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12157. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12158. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  12159. Doo::loadModel ( "receipt" );
  12160. $receipt = new receipt ();
  12161. Doo::loadModel ( "receiptDetail" );
  12162. $receiptDetail = new receiptDetail ();
  12163. Doo::loadModel ( 'staff' );
  12164. $staff = new staff ();
  12165. Doo::loadModel ( 'accountItem' );
  12166. $accountItem = new accountItem ();
  12167. Doo::loadModel ( 'statistics' );
  12168. $statistics = new statistics ();
  12169. if (! empty ( $username )) {
  12170. $username = addslashes ( urldecode ( $username ) );
  12171. $staffDetail = $staff->getStaffByName ( $username );
  12172. if (empty ( $staffDetail ))
  12173. die ( 'illegal request' );
  12174. $list = $receipt->getReceiptBySid ( $staffDetail ['sid'], $year, $month );
  12175. $itemList = $accountItem->getAccountItem ();
  12176. $itemHtml = '';
  12177. $categoryHtml = '';
  12178. $itemKeyList = array_keys ( $itemList );
  12179. $revisePrice = 0;
  12180. // 报销单内容详情
  12181. foreach ( $list as $key => $value ) {
  12182. $accountItemList = json_decode ( $value ['accountItem'], true );
  12183. $list [$key] ['accountItemList'] = $accountItemList;
  12184. $receiptItemHtml = '';
  12185. foreach ( $itemKeyList as $v ) {
  12186. if ($v == '日常相关费用')
  12187. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['agencySum'] . '</td>';
  12188. elseif ($v == '差旅相关费用')
  12189. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['travelSum'] . '</td>';
  12190. elseif ($v == '培训班费用')
  12191. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['trainSum'] . '</td>';
  12192. elseif ($v == '其他')
  12193. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['otherSum'] . '</td>';
  12194. foreach ( $itemList [$v] as $ke => $va ) {
  12195. $falg = true;
  12196. if (! empty ( $accountItemList [$v] )) {
  12197. foreach ( $accountItemList [$v] as $ve ) {
  12198. if ($va ['name'] == $ve ['name']) {
  12199. $receiptItemHtml .= '<td class="taR">' . $ve ['price'] . '</td>';
  12200. $falg = false;
  12201. break;
  12202. }
  12203. }
  12204. }
  12205. if ($falg)
  12206. $receiptItemHtml .= '<td class="taR"></td>';
  12207. }
  12208. }
  12209. // 金额调整和费用查看
  12210. $revisePrice += $value ['revisePrice'];
  12211. $receiptItemHtml .= '<td class="taR">' . $value ['revisePrice'] . '</td>';
  12212. $receiptItemHtml .= '<td class="taR"><a href="#detail" data-toggle="modal" onclick=showExplanation("' . $value ['explanation'] . '")>查看</a></td>';
  12213. $list [$key] ['receiptItemHtml'] = $receiptItemHtml;
  12214. }
  12215. // 报销单合计
  12216. $receiptTotalList = $receiptDetail->getReceiptTotalItem ( $staffDetail ['sid'], $year, $month );
  12217. $rtl = $receiptDetail->getReceiptTotalItemCategory ( $staffDetail ['sid'], $year, $month );
  12218. $receiptTotalHtml = '';
  12219. // 报销单项目抬头
  12220. foreach ( $itemKeyList as $value ) {
  12221. $count = count ( $itemList [$value] ) + 1;
  12222. $itemHtml .= '<th class="taC" colspan="' . $count . '">' . $value . '</th>';
  12223. $categoryHtml .= '<th class="taC">合计</th>';
  12224. foreach ( $rtl as $rtlValue ) {
  12225. if ($rtlValue ['itemCategory'] == $value) {
  12226. $receiptTotalHtml .= '<th>' . $rtlValue ['price'] . '</th>';
  12227. break;
  12228. }
  12229. }
  12230. foreach ( $itemList [$value] as $k => $v ) {
  12231. $categoryHtml .= '<th class="taC">' . $v ['name'] . '</th>';
  12232. // 合计
  12233. $falg = true;
  12234. foreach ( $receiptTotalList as $ve ) {
  12235. if ($ve ['itemCategory'] == $value && $ve ['item'] == $v ['name']) {
  12236. $receiptTotalHtml .= '<th >' . $ve ['price'] . '</th>';
  12237. $falg = false;
  12238. break;
  12239. }
  12240. }
  12241. if ($falg)
  12242. $receiptTotalHtml .= '<th></th>';
  12243. }
  12244. }
  12245. $receiptTotalHtml .= '<th>' . $revisePrice . '</th>';
  12246. $stList = $statistics->getStatisticsBySid ( $staffDetail ['sid'], $year, $month );
  12247. if (empty ( $stList ))
  12248. $stList = array (
  12249. 'rePrice' => 0,
  12250. 'agPrice' => 0
  12251. );
  12252. $data ['stList'] = array (
  12253. 'rePrice' => $stList ['rePrice'],
  12254. 'agPrice' => $stList ['agPrice'],
  12255. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  12256. );
  12257. $monthHtml = "";
  12258. for($i = 1; $i <= 12; $i ++) {
  12259. if ($i == $month)
  12260. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  12261. else
  12262. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  12263. }
  12264. $data ['username'] = urlencode ( $username );
  12265. $data ['usernameEN'] = $username;
  12266. $data ['monthHtml'] = $monthHtml;
  12267. $data ['receiptTotalHtml'] = $receiptTotalHtml;
  12268. $data ['list'] = $list;
  12269. $data ['categoryHtml'] = $categoryHtml;
  12270. $data ['itemHtml'] = $itemHtml;
  12271. $data ['itemList'] = $itemList;
  12272. $data ['year'] = $year;
  12273. $data ['month'] = $month;
  12274. $data ['memu'] = "receipt";
  12275. $data ['staff'] = $this->staff;
  12276. $data ['receiptMemu'] = 'companyCategoryCollect';
  12277. $data ['verifyId'] = $this->verifyId;
  12278. $data ['executeId'] = $this->executeId;
  12279. $this->render ( "/admin/receiptStatisticsStaffDetail", $data );
  12280. }
  12281. die ( 'illegal request' );
  12282. }
  12283. function companyMonthCollectDetail() {
  12284. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12285. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12286. if (! $year)
  12287. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  12288. if (! $month)
  12289. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  12290. Doo::loadModel ( 'staff' );
  12291. $staff = new staff ();
  12292. Doo::loadModel ( "receiptDetail" );
  12293. $receiptDetail = new receiptDetail ();
  12294. Doo::loadModel ( 'accountItem' );
  12295. $accountItem = new accountItem ();
  12296. Doo::loadModel ( 'statistics' );
  12297. $statistics = new statistics ();
  12298. Doo::loadModel ( 'L_category' );
  12299. $lCategory = new L_category ();
  12300. $staffList = $staff->find ( array (
  12301. 'where' => 'username!="admin"',
  12302. 'asArray' => true
  12303. ) );
  12304. $categoryList = $lCategory->find ( array (
  12305. 'asArray' => true
  12306. ) );
  12307. $list = array ();
  12308. foreach ( $categoryList as $value ) {
  12309. $receiptCollectList = $receiptDetail->find ( array (
  12310. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12311. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12312. 'groupby' => 'item,Month(pastDate),itemCategory',
  12313. 'asArray' => true
  12314. ) );
  12315. if (! empty ( $receiptCollectList )) {
  12316. $receiptL = array (
  12317. '日常相关费用' => array (),
  12318. '差旅相关费用' => array (),
  12319. '培训班费用' => array (),
  12320. '其他' => array ()
  12321. );
  12322. $html = "";
  12323. $psum = 0;
  12324. $item = array (
  12325. '市内交通费',
  12326. '市内出租费',
  12327. '办事处房租',
  12328. '电话费',
  12329. '水费',
  12330. '电费',
  12331. '办公费用',
  12332. '邮寄费',
  12333. '其他费用',
  12334. '车辆费用',
  12335. '广告费',
  12336. '团队建设费'
  12337. );
  12338. foreach ( $item as $va ) {
  12339. $falg = true;
  12340. foreach ( $receiptCollectList as $v ) {
  12341. if ($v ['itemCategory'] == '日常相关费用') {
  12342. if ($v ['item'] == $va) {
  12343. $psum += $v ['price'];
  12344. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12345. $falg = false;
  12346. break;
  12347. }
  12348. }
  12349. }
  12350. if ($falg)
  12351. $html .= '<td class="taR">-</td>';
  12352. }
  12353. if (! empty ( $psum ))
  12354. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  12355. else
  12356. $psum = '<td class="colGreen taR">-</td>';
  12357. $receiptL ['日常相关费用'] = $psum . $html;
  12358. /* ----------------------------------- */
  12359. $html = "";
  12360. $psum = 0;
  12361. $item = array (
  12362. '往来交通费',
  12363. '市内交通费',
  12364. '出差住宿费',
  12365. '出差补助',
  12366. '其他费用'
  12367. );
  12368. foreach ( $item as $va ) {
  12369. $falg = true;
  12370. foreach ( $receiptCollectList as $v ) {
  12371. if ($v ['itemCategory'] == '差旅相关费用') {
  12372. if ($v ['item'] == $va) {
  12373. $psum += $v ['price'];
  12374. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12375. $falg = false;
  12376. break;
  12377. }
  12378. }
  12379. }
  12380. if ($falg)
  12381. $html .= '<td class="taR">-</td>';
  12382. }
  12383. if (! empty ( $psum ))
  12384. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  12385. else
  12386. $psum = '<td class="colGreen taR">-</td>';
  12387. $receiptL ['差旅相关费用'] = $psum . $html;
  12388. /* ------------------------------------- */
  12389. $html = "";
  12390. $psum = 0;
  12391. $item = array (
  12392. '场租费',
  12393. '薪酬',
  12394. '住宿费',
  12395. '交通费',
  12396. '餐饮费',
  12397. '办公费',
  12398. '公关费',
  12399. '其他'
  12400. );
  12401. foreach ( $item as $va ) {
  12402. $falg = true;
  12403. foreach ( $receiptCollectList as $v ) {
  12404. if ($v ['itemCategory'] == '培训班费用') {
  12405. if ($v ['item'] == $va) {
  12406. $psum += $v ['price'];
  12407. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12408. $falg = false;
  12409. break;
  12410. }
  12411. }
  12412. }
  12413. if ($falg)
  12414. $html .= '<td class="taR">-</td>';
  12415. }
  12416. if (! empty ( $psum ))
  12417. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  12418. else
  12419. $psum = '<td class="colGreen taR">-</td>';
  12420. $receiptL ['培训班费用'] = $psum . $html;
  12421. /* ------------------------------------- */
  12422. $html = "";
  12423. $psum = 0;
  12424. $item = array (
  12425. '公关费',
  12426. '广告费',
  12427. '借款',
  12428. '可自加费用'
  12429. );
  12430. foreach ( $item as $va ) {
  12431. $falg = true;
  12432. foreach ( $receiptCollectList as $v ) {
  12433. if ($v ['itemCategory'] == '其他') {
  12434. if ($v ['item'] == $va) {
  12435. $psum += $v ['price'];
  12436. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12437. $falg = false;
  12438. break;
  12439. }
  12440. }
  12441. }
  12442. if ($falg)
  12443. $html .= '<td class="taR">-</td>';
  12444. }
  12445. if (! empty ( $psum ))
  12446. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  12447. else
  12448. $psum = '<td class="colGreen taR">-</td>';
  12449. $receiptL ['其他'] = $psum . $html;
  12450. /* ------------------------------------- */
  12451. $html = "";
  12452. $psum = 0;
  12453. foreach ( $receiptCollectList as $v ) {
  12454. if ($v ['itemCategory'] == '报销金额调整') {
  12455. if (! empty ( $v ['price'] ))
  12456. $psum += $v ['price'];
  12457. }
  12458. }
  12459. if (! empty ( $psum ))
  12460. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  12461. else
  12462. $psum = '<td class="taR colOrange">-</td>';
  12463. $receiptL ['报销金额调整'] = $psum . $html;
  12464. } else {
  12465. $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>
  12466. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12467. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  12468. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12469. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  12470. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12471. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12472. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  12473. }
  12474. $monthStaffPrice = $receiptDetail->find ( array (
  12475. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12476. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12477. 'asArray' => true
  12478. ) );
  12479. if (! empty ( $monthStaffPrice [0] ['price'] ))
  12480. $receiptL ['monthStaffPrice'] = '<td><b>' . $monthStaffPrice [0] ['price'] . '</b></td>';
  12481. else
  12482. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  12483. $list [$value ['title']] = $receiptL;
  12484. }
  12485. $data ['list'] = $list;
  12486. $receiptCollectList = $receiptDetail->find ( array (
  12487. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12488. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12489. 'groupby' => 'item,Month(pastDate),itemCategory',
  12490. 'asArray' => true
  12491. ) );
  12492. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  12493. // print_r($data['monthPriceHtml']);
  12494. // foreach ($data['monthPriceHtml'] as $value){
  12495. // echo $value;
  12496. // }
  12497. // die;
  12498. // statistics html
  12499. $stList = $statistics->getOne ( array (
  12500. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  12501. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  12502. 'groupby' => 'Month(date)',
  12503. 'asArray' => true
  12504. ) );
  12505. if (empty ( $stList ))
  12506. $stList = array (
  12507. 'rePrice' => 0,
  12508. 'agPrice' => 0
  12509. );
  12510. $data ['stList'] = array (
  12511. 'rePrice' => $stList ['rePrice'],
  12512. 'agPrice' => $stList ['agPrice'],
  12513. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  12514. );
  12515. $monthHtml = "";
  12516. for($i = 1; $i <= 12; $i ++) {
  12517. if ($i == $month)
  12518. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  12519. else
  12520. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  12521. }
  12522. $data ['monthHtml'] = $monthHtml;
  12523. $data ['year'] = $year;
  12524. $data ['month'] = $month;
  12525. $data ['memu'] = "receipt";
  12526. $data ['staff'] = $this->staff;
  12527. $data ['receiptMemu'] = 'companyCategoryCollect';
  12528. $data ['verifyId'] = $this->verifyId;
  12529. $data ['executeId'] = $this->executeId;
  12530. $this->render ( "/admin/companyMonthCollectDetail", $data );
  12531. }
  12532. function staffCollectDetail() {
  12533. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  12534. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  12535. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  12536. if (! $staffname) {
  12537. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  12538. $staffname = urldecode ( $staffname );
  12539. }
  12540. Doo::loadModel ( 'staff' );
  12541. $staff = new staff ();
  12542. Doo::loadModel ( "receiptDetail" );
  12543. $receiptDetail = new receiptDetail ();
  12544. Doo::loadModel ( 'accountItem' );
  12545. $accountItem = new accountItem ();
  12546. Doo::loadModel ( 'statistics' );
  12547. $statistics = new statistics ();
  12548. Doo::loadModel ( 'L_category' );
  12549. $lCategory = new L_category ();
  12550. Doo::loadModel ( "receiptAuthorityManage" );
  12551. $receiptAuthorityManage = new receiptAuthorityManage ();
  12552. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  12553. $cidList = array ();
  12554. foreach ( $imcStaff as $key => $value ) {
  12555. array_push ( $cidList, $value ['cid'] );
  12556. }
  12557. $cidString = implode ( ',', $cidList );
  12558. $staffList = $staff->find ( array (
  12559. 'where' => ' cid in (' . $cidString . ')',
  12560. 'asArray' => true
  12561. ) );
  12562. $stHtml = '';
  12563. $stTitle = "";
  12564. $staffId = 0;
  12565. $cid = 0;
  12566. $ocid = 0;
  12567. foreach ( $staffList as $value ) {
  12568. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  12569. $stTitle = $value ['category'] . '-' . $value ['username'];
  12570. $staffId = $value ['sid'];
  12571. $cid = $value ['cid'];
  12572. $ocid = $value ['cid'];
  12573. if (! empty ( $value ['othercid'] ))
  12574. $cid = $value ['cid'] . ',' . $value ['othercid'];
  12575. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  12576. } elseif ($value ['username'] != 'admin')
  12577. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  12578. }
  12579. $data ['lCategoryHtml'] = $lCategory->find ( array (
  12580. 'where' => 'cid in(' . $cid . ')',
  12581. 'asArray' => true
  12582. ) );
  12583. if (empty ( $pcid ))
  12584. $pcid = $ocid;
  12585. $data ['ocid'] = $pcid;
  12586. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  12587. $this->showCache ( $path );
  12588. //
  12589. $receiptCollectList = $receiptDetail->find ( array (
  12590. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12591. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  12592. 'groupby' => 'item,Month(pastDate),itemCategory',
  12593. 'asArray' => true
  12594. ) );
  12595. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  12596. // print_r($receiptCollectList);
  12597. $accountList = $accountItem->find ( array (
  12598. 'asArray' => true
  12599. ) );
  12600. // create CollectDetail HTML
  12601. $collectHtml = array ();
  12602. foreach ( $accountList as $key => $value ) {
  12603. $html = "";
  12604. $asum = 0;
  12605. for($i = 1; $i <= 12; $i ++) {
  12606. $falg = true;
  12607. foreach ( $receiptCollectList as $v ) {
  12608. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  12609. if ($v ['item'] == '可自加费用') {
  12610. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  12611. }
  12612. $asum += $v ['price'];
  12613. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12614. $falg = false;
  12615. break;
  12616. }
  12617. }
  12618. if ($falg)
  12619. $html .= '<td class="taR">-</td>';
  12620. }
  12621. $html .= '<td class="taR colGreen"><b>' . $asum . '</b></td>';
  12622. $collectHtml [$value ['category']] [$value ['name']] = $html;
  12623. }
  12624. $data ['collectHtml'] = $collectHtml;
  12625. // print_r($collectHtml);
  12626. // create Adjustment price html
  12627. $receiptCollectList = $receiptDetail->find ( array (
  12628. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  12629. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  12630. 'groupby' => 'itemCategory,Month(pastDate)',
  12631. 'asArray' => true
  12632. ) );
  12633. $adjustment = array ();
  12634. $collectArray = array (
  12635. '日常相关费用' => array (),
  12636. '差旅相关费用' => array (),
  12637. '培训班费用' => array (),
  12638. '其他' => array ()
  12639. );
  12640. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  12641. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  12642. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  12643. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  12644. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  12645. array_push ( $collectArray ['培训班费用'], $collectHtml );
  12646. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  12647. array_push ( $collectArray ['其他'], $collectHtml );
  12648. $data ['collectArray'] = $collectArray;
  12649. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  12650. array_push ( $adjustment, $collectHtml );
  12651. $data ['adjustment'] = $adjustment;
  12652. // total price html
  12653. $collectHtml = "";
  12654. $total = 0;
  12655. for($i = 1; $i <= 12; $i ++) {
  12656. $sumPrice = 0;
  12657. foreach ( $receiptCollectList as $key => $value ) {
  12658. if ($value ['month'] == $i) {
  12659. $sumPrice += $value ['price'];
  12660. }
  12661. }
  12662. if ($sumPrice == 0)
  12663. $collectHtml .= '<td class="taR">-</td>';
  12664. else
  12665. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  12666. $total += $sumPrice;
  12667. }
  12668. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  12669. // statistics html
  12670. $stList = $statistics->statisticsByYear ( $year, $staffId );
  12671. if (empty ( $stList ))
  12672. $stList = array (
  12673. 'rePrice' => 0,
  12674. 'agPrice' => 0
  12675. );
  12676. $data ['stList'] = array (
  12677. 'rePrice' => $stList ['rePrice'],
  12678. 'agPrice' => $stList ['agPrice'],
  12679. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  12680. );
  12681. $data ['totalPrice'] = $collectHtml;
  12682. $data ['totalYear'] = $total;
  12683. $data ['stHtml'] = $stHtml;
  12684. $data ['year'] = $year;
  12685. $data ['stTitle'] = $stTitle;
  12686. $data ['staffname'] = urlencode ( $staffname );
  12687. $data ['memu'] = "receipt";
  12688. $data ['staff'] = $this->staff;
  12689. $data ['receiptMemu'] = 'companyCategoryCollect';
  12690. $data ['verifyId'] = $this->verifyId;
  12691. $data ['executeId'] = $this->executeId;
  12692. if ($year < date ( "Y" )) {
  12693. Doo::loadModel ( 'receipt' );
  12694. $receipt = new receipt ();
  12695. $receiptList = $receipt->find ( array (
  12696. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  12697. 'asArray' => true
  12698. ) );
  12699. if (empty ( $receiptList )) { // generated files
  12700. ob_start ();
  12701. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  12702. $this->cacheFile ( $path );
  12703. die ();
  12704. }
  12705. }
  12706. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  12707. }
  12708. function BUGFLAG() {
  12709. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  12710. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  12711. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12712. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  12713. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  12714. if (empty ( $status ))
  12715. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  12716. $page_size = 12;
  12717. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  12718. $vidList = array ();
  12719. $button = 0;
  12720. Doo::loadModel ( 'verify' );
  12721. $verify = new verify ();
  12722. Doo::loadModel ( 'receipt' );
  12723. $receipt = new receipt ();
  12724. Doo::loadModel ( 'staff' );
  12725. $staff = new staff ();
  12726. Doo::loadModel ( 'L_category' );
  12727. $Lcategory = new L_category ();
  12728. $dateCondition = " and Year(date) =" . $year;
  12729. if (! empty ( $month ))
  12730. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  12731. $categoryList = $Lcategory->find ( array (
  12732. 'asArray' => true
  12733. ) );
  12734. $staffList = $staff->find ( array (
  12735. 'where' => 'cid=' . $cid,
  12736. 'asArray' => true
  12737. ) );
  12738. $cateCondition = "";
  12739. $staffCondition = "";
  12740. $approvalCondition = "";
  12741. if (! empty ( $cid ))
  12742. $cateCondition = ' and cid=' . $cid;
  12743. if (! empty ( $sid )) {
  12744. $staffCondition = ' and staff=' . $sid;
  12745. $cateCondition = "";
  12746. }
  12747. $approvalCondition = " and status=" . $status;
  12748. if ($status == 2) {
  12749. // 查找角色审批人
  12750. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  12751. }
  12752. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  12753. $approvalCondition = ' and status=2 ';
  12754. }
  12755. if ($status == 1) {
  12756. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  12757. }
  12758. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  12759. $pageinfo ['page'] = array (
  12760. 'previous' => ''
  12761. );
  12762. if ($status == 0) {
  12763. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  12764. $receiptList = $receipt->find ( array (
  12765. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  12766. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  12767. 'desc' => 'rid',
  12768. 'asArray' => true
  12769. ) );
  12770. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  12771. } else
  12772. $receiptList = $receipt->find ( array (
  12773. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  12774. 'desc' => 'rid',
  12775. 'asArray' => true
  12776. ) );
  12777. $rLRes = $receipt->find ( array (
  12778. '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,
  12779. 'desc' => 'rid',
  12780. 'asArray' => true
  12781. ) );
  12782. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  12783. // print_r($pageinfo);
  12784. $Locate = 0;
  12785. foreach ( $receiptList as $key => $value ) {
  12786. $receiptList [$key] ['Locate'] = $Locate;
  12787. $Locate ++;
  12788. $receiptList [$key] ['reviseDetail'] = array ();
  12789. if (! empty ( $value ['reviseDetail'] ))
  12790. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  12791. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  12792. $categoryDetil = $Lcategory->getOne ( array (
  12793. 'where' => 'cid=' . $value ['cid'],
  12794. 'asArray' => true
  12795. ) );
  12796. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  12797. $verifyList = $verify->getOne ( array (
  12798. 'where' => 'vid=' . $value ['verify'],
  12799. 'asArray' => true
  12800. ) );
  12801. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  12802. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  12803. foreach ( $verifyList as $k => $v ) {
  12804. // init verifyStaff
  12805. $verifyList [$k] ['date'] = "";
  12806. $verifyList [$k] ['opinion'] = "";
  12807. $verifyList [$k] ['status'] = "";
  12808. if (empty ( $verifyStaff )) {
  12809. $verifyList [$k] ['date'] = "";
  12810. $verifyList [$k] ['opinion'] = "";
  12811. if ($v [0] == $this->staff [0] ['sid']) {
  12812. $verifyList [$k] ['status'] = 4;
  12813. $button = 4;
  12814. }
  12815. } else {
  12816. $flag = true;
  12817. foreach ( $verifyStaff as $m => $u ) {
  12818. if ($v [0] == $m) {
  12819. $verifyList [$k] ['date'] = $u ['date'];
  12820. $verifyList [$k] ['opinion'] = $u ['opinion'];
  12821. $verifyList [$k] ['status'] = $u ['status'];
  12822. $flag = false;
  12823. break;
  12824. }
  12825. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  12826. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  12827. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  12828. }
  12829. if ($flag) { // 检测可编辑
  12830. if ($v [0] == $this->staff [0] ['sid']) {
  12831. $verifyList [$k] ['status'] = 4;
  12832. $button = 4;
  12833. }
  12834. }
  12835. }
  12836. }
  12837. $receiptList [$key] ['verifyList'] = $verifyList;
  12838. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  12839. 'where' => 'sid=' . $value ['staff'],
  12840. 'asArray' => true
  12841. ) );
  12842. $receiptList [$key] ['button'] = $button;
  12843. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  12844. }
  12845. // print_r($receiptList);die;
  12846. // $data['verifyDetail']=$verifyDetail;
  12847. $mothHtml = "";
  12848. for($i = 1; $i <= 12; $i ++) {
  12849. if ($month == $i)
  12850. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  12851. else
  12852. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  12853. }
  12854. $data ['mothHtml'] = $mothHtml;
  12855. $data ['page'] = $pageinfo;
  12856. $data ['receiptList'] = $receiptList;
  12857. $data ['receiptApprovalCount'] = count ( $rLRes );
  12858. $data ['status'] = $status;
  12859. $data ['year'] = $year;
  12860. $data ['categoryList'] = $categoryList;
  12861. $data ['staffList'] = $staffList;
  12862. $data ['cid'] = $cid;
  12863. $data ['sid'] = $sid;
  12864. // print_r($receiptList);
  12865. $data ['memu'] = "receipt";
  12866. $data ['staff'] = $this->staff;
  12867. $data ['receiptMemu'] = 'approvalExpenses';
  12868. $data ['verifyId'] = $this->verifyId;
  12869. $data ['executeId'] = $this->executeId;
  12870. $this->render ( "/admin/FALG", $data );
  12871. }
  12872. function ajaxGetReceiptOrder() {
  12873. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  12874. if (! empty ( $receiptOrder )) {
  12875. Doo::loadModel ( 'receipt' );
  12876. $receipt = new receipt ();
  12877. Doo::loadModel ( 'staff' );
  12878. $staff = new staff ();
  12879. $receiptInfo = $receipt->getOne ( array (
  12880. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  12881. 'asArray' => true
  12882. ) );
  12883. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  12884. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  12885. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  12886. </tbody></table><table class="table table table-bordered"><tbody>';
  12887. foreach ( $verifyStaff as $key => $value ) {
  12888. $staffInfo = $staff->getOne ( array (
  12889. 'select' => 'username',
  12890. 'where' => ' sid="' . $key . '"',
  12891. 'asArray' => true
  12892. ) );
  12893. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  12894. }
  12895. $html .= '</tbody></table></div></div>';
  12896. echo json_encode ( array (
  12897. 'status' => 1,
  12898. 'receiptHtml' => $html
  12899. ) );
  12900. die ();
  12901. }
  12902. echo json_encode ( array (
  12903. 'status' => 2,
  12904. 'receiptHtml' => ''
  12905. ) );
  12906. die ();
  12907. }
  12908. function _getMonthCollectDetail($receiptCollectList) {
  12909. if (! empty ( $receiptCollectList )) {
  12910. $receiptL = array (
  12911. '日常相关费用' => array (),
  12912. '差旅相关费用' => array (),
  12913. '培训班费用' => array (),
  12914. '其他' => array ()
  12915. );
  12916. $html = "";
  12917. $psum = 0;
  12918. $item = array (
  12919. '市内交通费',
  12920. '市内出租费',
  12921. '办事处房租',
  12922. '电话费',
  12923. '水费',
  12924. '电费',
  12925. '办公费用',
  12926. '邮寄费',
  12927. '其他费用',
  12928. '车辆费用',
  12929. '广告费',
  12930. '团队建设费',
  12931. '物业管理费',
  12932. '宽带费',
  12933. '人员薪酬',
  12934. '公积金',
  12935. '社保'
  12936. );
  12937. foreach ( $item as $value ) {
  12938. $falg = true;
  12939. foreach ( $receiptCollectList as $v ) {
  12940. if ($v ['itemCategory'] == '日常相关费用') {
  12941. if ($v ['item'] == $value) {
  12942. $psum += $v ['price'];
  12943. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12944. $falg = false;
  12945. break;
  12946. }
  12947. }
  12948. }
  12949. if ($falg)
  12950. $html .= '<td class="taR">-</td>';
  12951. }
  12952. if (! empty ( $psum ))
  12953. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  12954. else
  12955. $psum = '<td class="colGreen taR">-</td>';
  12956. $receiptL ['日常相关费用'] = $psum . $html;
  12957. /* ----------------------------------- */
  12958. $html = "";
  12959. $psum = 0;
  12960. $item = array (
  12961. '往来交通费',
  12962. '市内交通费',
  12963. '出差住宿费',
  12964. '出差补助',
  12965. '其他费用'
  12966. );
  12967. foreach ( $item as $value ) {
  12968. $falg = true;
  12969. foreach ( $receiptCollectList as $v ) {
  12970. if ($v ['itemCategory'] == '差旅相关费用') {
  12971. if ($v ['item'] == $value) {
  12972. $psum += $v ['price'];
  12973. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12974. $falg = false;
  12975. break;
  12976. }
  12977. }
  12978. }
  12979. if ($falg)
  12980. $html .= '<td class="taR">-</td>';
  12981. }
  12982. if (! empty ( $psum ))
  12983. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  12984. else
  12985. $psum = '<td class="colGreen taR">-</td>';
  12986. $receiptL ['差旅相关费用'] = $psum . $html;
  12987. /* ------------------------------------- */
  12988. $html = "";
  12989. $psum = 0;
  12990. $item = array (
  12991. '场租费',
  12992. '薪酬',
  12993. '住宿费',
  12994. '交通费',
  12995. '餐饮费',
  12996. '办公费',
  12997. '公关费',
  12998. '其他',
  12999. '电话费',
  13000. '邮寄费'
  13001. );
  13002. foreach ( $item as $value ) {
  13003. $falg = true;
  13004. foreach ( $receiptCollectList as $v ) {
  13005. if ($v ['itemCategory'] == '培训班费用') {
  13006. if ($v ['item'] == $value) {
  13007. $psum += $v ['price'];
  13008. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13009. $falg = false;
  13010. break;
  13011. }
  13012. }
  13013. }
  13014. if ($falg)
  13015. $html .= '<td class="taR">-</td>';
  13016. }
  13017. if (! empty ( $psum ))
  13018. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13019. else
  13020. $psum = '<td class="colGreen taR">-</td>';
  13021. $receiptL ['培训班费用'] = $psum . $html;
  13022. /* ------------------------------------- */
  13023. $html = "";
  13024. $psum = 0;
  13025. $item = array (
  13026. '公关费',
  13027. '广告费',
  13028. '借款',
  13029. '可自加费用'
  13030. );
  13031. foreach ( $item as $value ) {
  13032. $falg = true;
  13033. foreach ( $receiptCollectList as $v ) {
  13034. if ($v ['itemCategory'] == '其他') {
  13035. if ($v ['item'] == $value) {
  13036. $psum += $v ['price'];
  13037. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13038. $falg = false;
  13039. break;
  13040. }
  13041. }
  13042. }
  13043. if ($falg)
  13044. $html .= '<td class="taR">-</td>';
  13045. }
  13046. if (! empty ( $psum ))
  13047. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13048. else
  13049. $psum = '<td class="colGreen taR">-</td>';
  13050. $receiptL ['其他'] = $psum . $html;
  13051. /* ------------------------------------- */
  13052. $html = "";
  13053. $psum = 0;
  13054. foreach ( $receiptCollectList as $v ) {
  13055. if ($v ['itemCategory'] == '报销金额调整') {
  13056. if (! empty ( $v ['price'] ))
  13057. $psum += $v ['price'];
  13058. }
  13059. }
  13060. if (! empty ( $psum ))
  13061. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  13062. else
  13063. $psum = '<td class="taR colOrange">-</td>';
  13064. $receiptL ['报销金额调整'] = $psum . $html;
  13065. } else {
  13066. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td>
  13067. <td class="taR">-</td>
  13068. <td class="taR">-</td>
  13069. <td class="taR">-</td>
  13070. <td class="taR">-</td>
  13071. <td class="taR">-</td>
  13072. <td class="taR">-</td>
  13073. <td class="taR">-</td>
  13074. <td class="taR">-</td>
  13075. <td class="taR">-</td>
  13076. <td class="taR">-</td>
  13077. <td class="taR">-</td>
  13078. <td class="taR">-</td>';
  13079. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  13080. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13081. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td>
  13082. <td class="taR">-</td>
  13083. <td class="taR">-</td>
  13084. <td class="taR">-</td>
  13085. <td class="taR">-</td>
  13086. <td class="taR">-</td>
  13087. <td class="taR">-</td>
  13088. <td class="taR">-</td>
  13089. <td class="taR">-</td>';
  13090. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13091. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13092. }
  13093. return $receiptL;
  13094. }
  13095. function eMail() {
  13096. Doo::loadModel ( 'staff' );
  13097. $staff = new staff ();
  13098. Doo::loadModel ( 'receipt' );
  13099. $receipt = new receipt ();
  13100. Doo::loadModel ( 'L_category' );
  13101. $Lcategory = new L_category ();
  13102. Doo::loadModel ( "verify" );
  13103. $verify = new verify ();
  13104. $staffList = $staff->find ( array (
  13105. 'asArray' => true
  13106. ) );
  13107. foreach ( $staffList as $key => $value ) {
  13108. if ($value ['username'] != 'admin') {
  13109. // 提交人
  13110. $receiptList = $receipt->find ( array (
  13111. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  13112. 'asArray' => true
  13113. ) );
  13114. if (! empty ( $receiptList )) {
  13115. $html = '<br><div><style></style>
  13116. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  13117. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  13118. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  13119. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  13120. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  13121. <tbody><tr>
  13122. <td style="padding: 0 40px;" align="left">
  13123. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  13124. </td></tr><tr>
  13125. <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>
  13126. </tr>
  13127. </tbody> </table></td> </tr> <tr><td>
  13128. <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">
  13129. <tbody> <tr><td>
  13130. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  13131. 以下报销单完成了审批,等着收款吧:</p>
  13132. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  13133. foreach ( $receiptList as $k => $v ) {
  13134. $category = $Lcategory->getOne ( array (
  13135. 'where' => 'cid=' . $v ['cid'],
  13136. 'asArray' => true
  13137. ) );
  13138. $html .= '
  13139. <tr>
  13140. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  13141. <td align="left">
  13142. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  13143. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  13144. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  13145. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  13146. </tr>';
  13147. }
  13148. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  13149. <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>
  13150. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  13151. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  13152. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  13153. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  13154. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  13155. $receipt = new receipt ();
  13156. $receipt->notice = 1;
  13157. $receipt->update ( array (
  13158. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  13159. ) );
  13160. }
  13161. }
  13162. // 审批人
  13163. $verifyList = $verify->find ( array (
  13164. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  13165. 'asArray' => true
  13166. ) );
  13167. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  13168. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  13169. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  13170. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  13171. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  13172. <tbody><tr><td style="padding: 0 40px;" align="left">
  13173. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  13174. </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>
  13175. </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">
  13176. <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>
  13177. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  13178. foreach ( $verifyList as $k => $v ) {
  13179. $receiptList = $receipt->find ( array (
  13180. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  13181. 'asArray' => true
  13182. ) );
  13183. foreach ( $receiptList as $r => $l ) {
  13184. $category = $Lcategory->getOne ( array (
  13185. 'where' => 'cid=' . $l ['cid'],
  13186. 'asArray' => true
  13187. ) );
  13188. $staffDetile = $staff->getOne ( array (
  13189. 'where' => 'sid=' . $l ['staff'],
  13190. 'asArray' => true
  13191. ) );
  13192. $html .= '
  13193. <tr>
  13194. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  13195. <td align="left">
  13196. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  13197. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  13198. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  13199. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  13200. </tr>';
  13201. }
  13202. }
  13203. $html .= '
  13204. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  13205. <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>
  13206. </tr></tbody></table></td></tr></tbody></table></div><br>';
  13207. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  13208. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  13209. // $receipt=new receipt();
  13210. // $receipt->notice=1;
  13211. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  13212. }
  13213. }
  13214. }
  13215. }
  13216. function setWXMsg($rid, $type) {
  13217. Doo::loadModel ( "receipt" );
  13218. $receipt = new receipt ();
  13219. $receiptDetail = $receipt->getOne ( array (
  13220. 'where' => 'rid=' . $rid,
  13221. 'asArray' => true
  13222. ) );
  13223. if (! empty ( $receiptDetail )) {
  13224. Doo::loadModel ( 'staff' );
  13225. $staff = new staff ();
  13226. $staffmsg = $staff->getOne ( array (
  13227. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  13228. 'asArray' => TRUE
  13229. ) );
  13230. if (! empty ( $staffmsg ['wxid'] )) {
  13231. require_once (SITE_PATH . '/protected/class/client.php');
  13232. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  13233. $user = $staffmsg ['wxid'];
  13234. $receiptName = '';
  13235. $msg = '';
  13236. switch ($receiptDetail ['Rtype']) {
  13237. case 0 :
  13238. $receiptName = '报销';
  13239. break;
  13240. case 1 :
  13241. $receiptName = '借款';
  13242. break;
  13243. case 2 :
  13244. $receiptName = '对公汇款';
  13245. break;
  13246. }
  13247. switch ($type) {
  13248. case 1 :
  13249. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  13250. break;
  13251. case 2 :
  13252. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  13253. break;
  13254. case 3 :
  13255. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  13256. break;
  13257. }
  13258. // $result = $client->SendMsg ( $user, $msg, 'text' );
  13259. }
  13260. }
  13261. }
  13262. // Email发送函数
  13263. function SMail($toemail, $subject, $contents) {
  13264. Doo::loadClass ( 'class.phpmailer' );
  13265. $mail = new PHPMailer ();
  13266. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  13267. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  13268. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  13269. $mail->Password = "cDO1GjtY1seH"; // 密码
  13270. $mail->CharSet = "UTF8";
  13271. $mail->SMTPAuth = true;
  13272. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  13273. $mail->Mailer = "smtp";
  13274. $mail->Port = 25;
  13275. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  13276. $mail->MsgHTML ( $contents );
  13277. $mail->AddAddress ( $toemail );
  13278. $mail->CharSet = "UTF-8";
  13279. return $mail->Send ();
  13280. }
  13281. function swfupload() {
  13282. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  13283. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  13284. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  13285. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  13286. header ( "HTTP/1.1 500 Internal Server Error" );
  13287. echo "POST exceeded maximum allowed size.";
  13288. exit ( 0 );
  13289. }
  13290. // Settings
  13291. $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)
  13292. $upload_name = "Filedata";
  13293. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  13294. $extension_whitelist = array (
  13295. "doc",
  13296. "txt",
  13297. "jpg",
  13298. "gif",
  13299. "png"
  13300. ); // Allowed file extensions
  13301. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  13302. // Other variables
  13303. $MAX_FILENAME_LENGTH = 260;
  13304. $file_name = "";
  13305. $file_extension = "";
  13306. $uploadErrors = array (
  13307. 0 => "文件上传成功",
  13308. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  13309. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  13310. 3 => "上传的文件仅为部分文件",
  13311. 4 => "没有文件上传",
  13312. 6 => "缺少临时文件夹"
  13313. );
  13314. $nk = time ();
  13315. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  13316. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  13317. echo "文件无法保存.";
  13318. exit ( 0 );
  13319. }
  13320. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  13321. echo json_encode ( array (
  13322. 'filename' => $file_name,
  13323. 'id' => $nk
  13324. ) );
  13325. exit ( 0 );
  13326. }
  13327. function _GetFileEXT($filename) {
  13328. $pics = explode ( '.', $filename );
  13329. $num = count ( $pics );
  13330. return $pics [$num - 1];
  13331. }
  13332. /**
  13333. * 获取get或者POST值
  13334. * @param string $name 属性名称
  13335. * @return fixed 值
  13336. */
  13337. function get_args($name) {
  13338. if (isset ( $_GET [$name] )) {
  13339. if (is_array ( $_GET [$name] ))
  13340. return $_GET [$name];
  13341. else
  13342. return addslashes ( $_GET [$name] );
  13343. } elseif (isset ( $_POST [$name] )) {
  13344. if (is_array ( $_POST [$name] ))
  13345. return $_POST [$name];
  13346. else
  13347. return addslashes ( $_POST [$name] );
  13348. } else
  13349. return false;
  13350. }
  13351. function num_to_rmb($num) {
  13352. $c1 = "零壹贰叁肆伍陆柒捌玖";
  13353. $c2 = "分角元拾佰仟万拾佰仟亿";
  13354. // 精确到分后面就不要了,所以只留两个小数位
  13355. $num = round ( $num, 2 );
  13356. // 将数字转化为整数
  13357. $num = $num * 100;
  13358. if (strlen ( $num ) > 10) {
  13359. return "金额太大,请检查";
  13360. }
  13361. $i = 0;
  13362. $c = "";
  13363. while ( 1 ) {
  13364. if ($i == 0) {
  13365. // 获取最后一位数字
  13366. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  13367. } else {
  13368. $n = $num % 10;
  13369. }
  13370. // 每次将最后一位数字转化为中文
  13371. $p1 = substr ( $c1, 3 * $n, 3 );
  13372. $p2 = substr ( $c2, 3 * $i, 3 );
  13373. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  13374. $c = $p1 . $p2 . $c;
  13375. } else {
  13376. $c = $p1 . $c;
  13377. }
  13378. $i = $i + 1;
  13379. // 去掉数字最后一位了
  13380. $num = $num / 10;
  13381. // echo $num.'</br>';
  13382. $num = ( int ) $num;
  13383. // $num =floor($num);
  13384. // $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  13385. // echo $num.'</br>';
  13386. // 结束循环
  13387. if ($num == 0) {
  13388. break;
  13389. }
  13390. }
  13391. // echo $c.'</br>';
  13392. $j = 0;
  13393. $slen = strlen ( $c );
  13394. while ( $j < $slen ) {
  13395. // utf8一个汉字相当3个字符
  13396. $m = substr ( $c, $j, 6 );
  13397. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  13398. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  13399. $left = substr ( $c, 0, $j );
  13400. $right = substr ( $c, $j + 3 );
  13401. $c = $left . $right;
  13402. $j = $j - 3;
  13403. $slen = $slen - 3;
  13404. }
  13405. $j = $j + 3;
  13406. }
  13407. // 这个是为了去掉类似23.0中最后一个“零”字
  13408. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  13409. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  13410. }
  13411. // 将处理的汉字加上“整”
  13412. if (empty ( $c )) {
  13413. return "零元整";
  13414. } else {
  13415. return $c . "整";
  13416. }
  13417. }
  13418. /**
  13419. * 获得分页数据
  13420. * @param unknown_type $table
  13421. * @param unknown_type $condition
  13422. * @param unknown_type $on_page
  13423. * @param unknown_type $page_size
  13424. */
  13425. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  13426. $page_c = "";
  13427. $page ['previous'] = $this->get_previous ( $on_page );
  13428. $page ['on_page'] = $on_page;
  13429. $total_count = $this->get_table_count ( $table, $condition );
  13430. $total = intval ( $total_count / $page_size );
  13431. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  13432. $page ['total_data'] = $total_count;
  13433. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  13434. $i = 1;
  13435. $page_max = 1;
  13436. $page_width = 3;
  13437. if ($on_page >= $page_width) {
  13438. $page_max = intval ( $on_page / $page_width ) + 1;
  13439. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  13440. }
  13441. for(; $i <= $page ['total_page']; $i ++) {
  13442. if ($i == $on_page)
  13443. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  13444. else
  13445. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  13446. if ($i == ($page_width * $page_max))
  13447. break;
  13448. }
  13449. $page ['page'] = $page_c;
  13450. $page ['lower'] = (-- $on_page) * $page_size;
  13451. return $page;
  13452. }
  13453. /**
  13454. * 获取总页数
  13455. * @param unknown_type $table
  13456. * @param unknown_type $condition
  13457. */
  13458. public function get_table_count($table = "", $condition = "") {
  13459. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  13460. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  13461. // echo $sql;die;
  13462. $query = Doo::db ()->query ( $sql );
  13463. $result = $query->fetch ();
  13464. return $result ['count'];
  13465. }
  13466. /**
  13467. * 获取上一页
  13468. * @param unknown_type $on_page
  13469. */
  13470. function get_previous($on_page = 1) {
  13471. return $on_page != 0 ? $on_page - 1 : $on_page;
  13472. }
  13473. }
  13474. ?>